From nobody Sat Feb 7 07:10:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505293829412134.43411449369773; Wed, 13 Sep 2017 02:10:29 -0700 (PDT) Received: from localhost ([::1]:41069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds3gi-0005wN-Jd for importer@patchew.org; Wed, 13 Sep 2017 05:10:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds3cO-0001Wm-ID for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds3cN-0007Ww-1k for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:06:00 -0400 Received: from mail-vk0-x242.google.com ([2607:f8b0:400c:c05::242]:37926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ds3cM-0007WK-SK for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:05:58 -0400 Received: by mail-vk0-x242.google.com with SMTP id o22so3314246vke.5 for ; Wed, 13 Sep 2017 02:05:58 -0700 (PDT) Received: from localhost.localdomain ([190.66.154.128]) by smtp.gmail.com with ESMTPSA id r74sm2677601vkf.19.2017.09.13.02.05.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 02:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iiAVmFHcqT9w3SytGT50doDlLLYr5MtciQUWpN/tF1w=; b=jj0Nb/Nkx7qDx1Rkg0tcIqVo6+xHnhk6DlJIiMBecWKpQEU/KnGXJXT7fr2/Rvuaia J9CnRhxp6hhB4njjLv39x9F66gFWSw45ZR0oZMQFKgqvakuvKToDgLXNeEOEZ32bpCCU A4VZy+s4Ap8TjRfNIHefFHqrWQX/S9xKkz67Hk7RlPd54MhJtYDVzWqnhEUc9GuCSPJa OKUwQJyJocajmdHRn21Fq27mTfcrNyHV6xURQKv0+WWZr2Xrb3nEshCkgm/UJEITQzOC s1MqMO0KDW8nooSgjvUFYf/mwCSAfK9vk2Xz2Fx6C7jURwnJFi+THtaMaRJorbe3N1pO mdNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iiAVmFHcqT9w3SytGT50doDlLLYr5MtciQUWpN/tF1w=; b=Z3LulD2eZGvvMQQ5cfM4z1ssHIYbYrfQ8XKSq6nBc3o9N9y+O39BRMrRbRL3e1So/V tp4o0tuy1rHeu84ucYWACGARNTs0s2xppYUJBLvRfps2ZULXdz5EVXp39Biuytbl+yl+ l2V5qryw6vYOAuJ/ptjaXLRE2BGAaGle6emc+LkjtleF2aN/A01z9Qx9762esLejLlQy UyC+OYef96Su1qsD7q3h91ASKu8woG5sVCNAw9MrcZBEbm6n1c4fl1RlOg8VevZ9n0lS tZnCYS4YcNI2F45iWJZA5ABv3i3cL+YOVlvGoDWOIvtl65aJ875uGSMOdHxNb0V0D5Ws cCVg== X-Gm-Message-State: AHPjjUgiDV2HRaatEmETkbM/uTeDMgMWQo/1NBSdVtRCrTUvn330A5pj IyAAMuF36vF70oFx X-Google-Smtp-Source: AOwi7QDPO8E0Iu/22DYq5qK0/3hl1QjBHx9U8iCdXA4/0LX9QDOEQvi7TuaFP6wtiDqXGcJalZy8jQ== X-Received: by 10.31.181.200 with SMTP id e191mr9911229vkf.55.1505293558226; Wed, 13 Sep 2017 02:05:58 -0700 (PDT) From: Sergio Andres Gomez Del Real X-Google-Original-From: Sergio Andres Gomez Del Real To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 04:05:17 -0500 Message-Id: <20170913090522.4022-10-Sergio.G.DelReal@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913090522.4022-1-Sergio.G.DelReal@gmail.com> References: <20170913090522.4022-1-Sergio.G.DelReal@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c05::242 Subject: [Qemu-devel] [PATCH v4 09/14] hvf: use new helper functions for put/get xsave X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Andres Gomez Del Real , pbonzini@redhat.com, stefanha@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch makes use of the helper functions for handling xsave in xsave_helper.c, which are shared with kvm. Signed-off-by: Sergio Andres Gomez Del Real --- target/i386/hvf-utils/x86hvf.c | 63 ++++++--------------------------------= ---- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/target/i386/hvf-utils/x86hvf.c b/target/i386/hvf-utils/x86hvf.c index 1e687f4f89..dd0710d056 100644 --- a/target/i386/hvf-utils/x86hvf.c +++ b/target/i386/hvf-utils/x86hvf.c @@ -76,36 +76,13 @@ void hvf_get_segment(SegmentCache *qseg, struct vmx_seg= ment *vmx_seg) void hvf_put_xsave(CPUState *cpu_state) { =20 - int x; struct hvf_xsave_buf *xsave; - =20 + xsave =3D X86_CPU(cpu_state)->env.kvm_xsave_buf; - memset(xsave, 0, sizeof(*xsave));=20 - =20 - memcpy(&xsave->data[4], &X86_CPU(cpu_state)->env.fpdp, sizeof(X86_CPU(= cpu_state)->env.fpdp)); - memcpy(&xsave->data[2], &X86_CPU(cpu_state)->env.fpip, sizeof(X86_CPU(= cpu_state)->env.fpip)); - memcpy(&xsave->data[8], &X86_CPU(cpu_state)->env.fpregs, sizeof(X86_CP= U(cpu_state)->env.fpregs)); - memcpy(&xsave->data[144], &X86_CPU(cpu_state)->env.ymmh_regs, sizeof(X= 86_CPU(cpu_state)->env.ymmh_regs)); - memcpy(&xsave->data[288], &X86_CPU(cpu_state)->env.zmmh_regs, sizeof(X= 86_CPU(cpu_state)->env.zmmh_regs)); - memcpy(&xsave->data[272], &X86_CPU(cpu_state)->env.opmask_regs, sizeof= (X86_CPU(cpu_state)->env.opmask_regs)); - memcpy(&xsave->data[240], &X86_CPU(cpu_state)->env.bnd_regs, sizeof(X8= 6_CPU(cpu_state)->env.bnd_regs)); - memcpy(&xsave->data[256], &X86_CPU(cpu_state)->env.bndcs_regs, sizeof(= X86_CPU(cpu_state)->env.bndcs_regs)); - memcpy(&xsave->data[416], &X86_CPU(cpu_state)->env.hi16_zmm_regs, size= of(X86_CPU(cpu_state)->env.hi16_zmm_regs)); - =20 - xsave->data[0] =3D (uint16_t)X86_CPU(cpu_state)->env.fpuc; - xsave->data[0] |=3D (X86_CPU(cpu_state)->env.fpus << 16); - xsave->data[0] |=3D (X86_CPU(cpu_state)->env.fpstt & 7) << 11; - =20 - for (x =3D 0; x < 8; ++x) - xsave->data[1] |=3D ((!X86_CPU(cpu_state)->env.fptags[x]) << x); - xsave->data[1] |=3D (uint32_t)(X86_CPU(cpu_state)->env.fpop << 16); - =20 - memcpy(&xsave->data[40], &X86_CPU(cpu_state)->env.xmm_regs, sizeof(X86= _CPU(cpu_state)->env.xmm_regs)); - =20 - xsave->data[6] =3D X86_CPU(cpu_state)->env.mxcsr; - *(uint64_t *)&xsave->data[128] =3D X86_CPU(cpu_state)->env.xstate_bv; - =20 - if (hv_vcpu_write_fpstate(cpu_state->hvf_fd, xsave->data, 4096)){ + + x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave); + + if (hv_vcpu_write_fpstate(cpu_state->hvf_fd, xsave->data, 4096)) { abort(); } } @@ -187,39 +164,15 @@ void hvf_put_msrs(CPUState *cpu_state) =20 void hvf_get_xsave(CPUState *cpu_state) { - int x; struct hvf_xsave_buf *xsave; - =20 + xsave =3D X86_CPU(cpu_state)->env.kvm_xsave_buf; - =20 + if (hv_vcpu_read_fpstate(cpu_state->hvf_fd, xsave->data, 4096)) { abort(); } =20 - memcpy(&X86_CPU(cpu_state)->env.fpdp, &xsave->data[4], sizeof(X86_CPU(= cpu_state)->env.fpdp)); - memcpy(&X86_CPU(cpu_state)->env.fpip, &xsave->data[2], sizeof(X86_CPU(= cpu_state)->env.fpip)); - memcpy(&X86_CPU(cpu_state)->env.fpregs, &xsave->data[8], sizeof(X86_CP= U(cpu_state)->env.fpregs)); - memcpy(&X86_CPU(cpu_state)->env.ymmh_regs, &xsave->data[144], sizeof(X= 86_CPU(cpu_state)->env.ymmh_regs)); - memcpy(&X86_CPU(cpu_state)->env.zmmh_regs, &xsave->data[288], sizeof(X= 86_CPU(cpu_state)->env.zmmh_regs)); - memcpy(&X86_CPU(cpu_state)->env.opmask_regs, &xsave->data[272], sizeof= (X86_CPU(cpu_state)->env.opmask_regs)); - memcpy(&X86_CPU(cpu_state)->env.bnd_regs, &xsave->data[240], sizeof(X8= 6_CPU(cpu_state)->env.bnd_regs)); - memcpy(&X86_CPU(cpu_state)->env.bndcs_regs, &xsave->data[256], sizeof(= X86_CPU(cpu_state)->env.bndcs_regs)); - memcpy(&X86_CPU(cpu_state)->env.hi16_zmm_regs, &xsave->data[416], size= of(X86_CPU(cpu_state)->env.hi16_zmm_regs)); - =20 - =20 - X86_CPU(cpu_state)->env.fpuc =3D (uint16_t)xsave->data[0]; - X86_CPU(cpu_state)->env.fpus =3D (uint16_t)(xsave->data[0] >> 16); - X86_CPU(cpu_state)->env.fpstt =3D (X86_CPU(cpu_state)->env.fpus >> 11)= & 7; - X86_CPU(cpu_state)->env.fpop =3D (uint16_t)(xsave->data[1] >> 16); - =20 - for (x =3D 0; x < 8; ++x) - X86_CPU(cpu_state)->env.fptags[x] =3D - ((((uint16_t)xsave->data[1] >> x) & 1) =3D=3D 0); - =20 - memcpy(&X86_CPU(cpu_state)->env.xmm_regs, &xsave->data[40], sizeof(X86= _CPU(cpu_state)->env.xmm_regs)); - - X86_CPU(cpu_state)->env.mxcsr =3D xsave->data[6]; - X86_CPU(cpu_state)->env.xstate_bv =3D *(uint64_t *)&xsave->data[128]; + x86_cpu_xrstor_all_areas(X86_CPU(cpu_state), xsave); } =20 void hvf_get_segments(CPUState *cpu_state) --=20 2.14.1