From nobody Wed Nov 5 20:16:09 2025 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; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536885655692587.9693778024368; Thu, 13 Sep 2018 17:40:55 -0700 (PDT) Received: from localhost ([::1]:46775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0cAD-0005aS-3c for importer@patchew.org; Thu, 13 Sep 2018 20:40:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0c8W-0004ZX-6k for qemu-devel@nongnu.org; Thu, 13 Sep 2018 20:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0c8S-0004cX-PK for qemu-devel@nongnu.org; Thu, 13 Sep 2018 20:39:03 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36330) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0c8S-0004bB-FT for qemu-devel@nongnu.org; Thu, 13 Sep 2018 20:39:00 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8E0YYke186588; Fri, 14 Sep 2018 00:38:54 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mc72r499t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Sep 2018 00:38:54 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8E0crVa028443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Sep 2018 00:38:53 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8E0cr94014145; Fri, 14 Sep 2018 00:38:53 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Sep 2018 00:38:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=UGFyisa0N7LYS/aIlb1S/6VxUjz957q4kytLrlcB2oA=; b=nJ4otqbxz4YypR3eNZ+EjFJQ8yGOZJw5KO+p9b7Whg8BzZaWrFdN9rDe+k9abrVn9ViP L5wTuYT/MD2nmof6qKmilzQCzRFyyMFxY7s66yy2XtJSHR2R23y5jL8bUic+QWMN1PJV f5RQX7TPTFVXsLmYlaNcJ625VM6n8zLKOHGfM9d5KGbQR0iAnzxzlmoTkB3EMPnPqytD xhpirwLjPLbiAOaUzHkBcDkOSvGMMIQUr+w9uSdDZYyJBz7WoltO+ez8kvbwI47KJ+Tb DAfVQTSUhXsYeniuZS0RkFX5Yj0DoBcUFPRONcHwZ9UVy3Z3Y/xuYhrenwYhLuamm8IB xw== From: Liran Alon To: qemu-devel@nongnu.org, rth@twiddle.net, ehabkost@redhat.com Date: Fri, 14 Sep 2018 03:38:26 +0300 Message-Id: <20180914003827.124570-2-liran.alon@oracle.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180914003827.124570-1-liran.alon@oracle.com> References: <20180914003827.124570-1-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9015 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=975 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809140005 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH 1/2] i386: Compile CPUX86State xsave_buf only when support KVM or HVF 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: idan.brown@oracle.com, kvm@vger.kernel.org, mtosatti@redhat.com, Liran Alon , pbonzini@redhat.com, jmattson@google.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: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While at it, also rename var to indicate it is not used only in KVM. Reviewed-by: Nikita Leshchenko Reviewed-by: Patrick Colp Signed-off-by: Liran Alon --- target/i386/cpu.h | 4 +++- target/i386/hvf/README.md | 2 +- target/i386/hvf/hvf.c | 2 +- target/i386/hvf/x86hvf.c | 4 ++-- target/i386/kvm.c | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b572a8e4aa41..6e4c2b02f947 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1327,7 +1327,9 @@ typedef struct CPUX86State { bool tsc_valid; int64_t tsc_khz; int64_t user_tsc_khz; /* for sanity check only */ - void *kvm_xsave_buf; +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) + void *xsave_buf; +#endif #if defined(CONFIG_HVF) HVFX86EmulatorState *hvf_emul; #endif diff --git a/target/i386/hvf/README.md b/target/i386/hvf/README.md index 0d27a0d52b58..2d33477aca50 100644 --- a/target/i386/hvf/README.md +++ b/target/i386/hvf/README.md @@ -2,6 +2,6 @@ =20 These sources (and ../hvf-all.c) are adapted from Veertu Inc's vdhh (Veert= u Desktop Hosted Hypervisor) (last known location: https://github.com/veert= uinc/vdhh) with some minor changes, the most significant of which were: =20 -1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw`= API; many struct members have been moved around (emulated x86 state, kvm_x= save_buf) due to historical differences + QEMU needing to handle more emula= tion targets. +1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw`= API; many struct members have been moved around (emulated x86 state, xsave= _buf) due to historical differences + QEMU needing to handle more emulation= targets. 2. Removal of `apic_page` and hyperv-related functionality. 3. More relaxed use of `qemu_mutex_lock_iothread`. diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index df69e6d0a7af..5db167df98e6 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -587,7 +587,7 @@ int hvf_init_vcpu(CPUState *cpu) hvf_reset_vcpu(cpu); =20 x86cpu =3D X86_CPU(cpu); - x86cpu->env.kvm_xsave_buf =3D qemu_memalign(4096, 4096); + x86cpu->env.xsave_buf =3D qemu_memalign(4096, 4096); =20 hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_STAR, 1); hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_LSTAR, 1); diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index 6c88939b968b..df8e946fbcde 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -75,7 +75,7 @@ void hvf_put_xsave(CPUState *cpu_state) =20 struct X86XSaveArea *xsave; =20 - xsave =3D X86_CPU(cpu_state)->env.kvm_xsave_buf; + xsave =3D X86_CPU(cpu_state)->env.xsave_buf; =20 x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave); =20 @@ -163,7 +163,7 @@ void hvf_get_xsave(CPUState *cpu_state) { struct X86XSaveArea *xsave; =20 - xsave =3D X86_CPU(cpu_state)->env.kvm_xsave_buf; + xsave =3D X86_CPU(cpu_state)->env.xsave_buf; =20 if (hv_vcpu_read_fpstate(cpu_state->hvf_fd, (void*)xsave, 4096)) { abort(); diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 0b2a07d3a47b..c1cd8c461fe4 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1189,7 +1189,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } =20 if (has_xsave) { - env->kvm_xsave_buf =3D qemu_memalign(4096, sizeof(struct kvm_xsave= )); + env->xsave_buf =3D qemu_memalign(4096, sizeof(struct kvm_xsave)); } cpu->kvm_msr_buf =3D g_malloc0(MSR_BUF_SIZE); =20 @@ -1639,7 +1639,7 @@ ASSERT_OFFSET(XSAVE_PKRU, pkru_state); static int kvm_put_xsave(X86CPU *cpu) { CPUX86State *env =3D &cpu->env; - X86XSaveArea *xsave =3D env->kvm_xsave_buf; + X86XSaveArea *xsave =3D env->xsave_buf; =20 if (!has_xsave) { return kvm_put_fpu(cpu); @@ -2081,7 +2081,7 @@ static int kvm_get_fpu(X86CPU *cpu) static int kvm_get_xsave(X86CPU *cpu) { CPUX86State *env =3D &cpu->env; - X86XSaveArea *xsave =3D env->kvm_xsave_buf; + X86XSaveArea *xsave =3D env->xsave_buf; int ret; =20 if (!has_xsave) { --=20 2.16.1