From nobody Thu Nov 6 01:12:41 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538298037730979.669394316576; Sun, 30 Sep 2018 02:00:37 -0700 (PDT) Received: from localhost ([::1]:54478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Xac-0005N9-Bu for importer@patchew.org; Sun, 30 Sep 2018 05:00:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsC-00032f-8j for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsA-0001Fo-Q7 for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:40 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:40054) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsA-00012y-Gi for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:38 -0400 Received: by mail-wm1-x32d.google.com with SMTP id o2-v6so5730371wmh.5 for ; Sun, 30 Sep 2018 01:14:19 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZEE0OY6rs3XbkYZGg+MvyS6wdixhHhIY69zPNG6MFsw=; b=Dh3fryfm6N0sjsnJ5UIZHGXiuUXvQ/4I2fjBQxb2QhfzVnPQIIAYQHjOM2WaUuZq7z RFWphu46i31vOH/Z+rd7em06VGef7OWVYAnbJqO/ZGcx+rd514qO9/yPs5v9k2gEwVId 7kniLsjkc6crZEicIsoLt8uQv5M9Biw48yDgG8i9+wiXzL0MkhCKq+UawOnH+w7tT5zs Wv+hvIg2yJQQl/oPwPyk9dmRquFlcJVctVGP7wwzuXxn5ZxhpSecAdomfe5h5Hxc+zxj 5cPrV5gGMZ8aOE7iGcdIEDXMLqYqKKwCI9CqY2PqyFcYJr94PHWuTxbwZJRkE+PR7U4O YMxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZEE0OY6rs3XbkYZGg+MvyS6wdixhHhIY69zPNG6MFsw=; b=bPyFG38EP4YnIMzG8hs9FyRlzg7edFnalBP4L/a+2tsB8RTBEFxk25UNR8LQtKNxRe 2HFDs+Qg+nVKHhC0qC7ogs9MVlOAEJYJifisB1zZu9AI2UNNN61+Nd7Eh6xvthWb3CL/ wpD3093lw/opbbCd7Y73dOzoWs1Y/mSsnLlwekuymRpuwM6WMtgsKJzIuvFNI5c5JUnV Oh9D1biBRPyvXwbpUtxWZbZ1Hj3rQRhz7iL4fU+qSkCS4Kwed3TFeKgNbgL0HFrBpt9j ZK08MRjkIEGob+ysBXHvVoGdMmBECV3J4Ia8WDRUjwy7h7aO57VYQtbnHSS0mo+hqWGS Horg== X-Gm-Message-State: ABuFfohDWh9guTHtNBar7cdIv9ijR9QdcbFaLTLwInMRVEN2+Uxv8lFQ M8702JcWlsNSmcwecu3hjBSZR8EI X-Google-Smtp-Source: ACcGV624ST9Fm6NAPSl3etu8jZfMfjRM1bLNGl7ZwN9PQjzWHcSMUdFwj4M03RRapvlPmsIvztyx/g== X-Received: by 2002:a1c:f016:: with SMTP id a22-v6mr5862850wmb.76.1538295258804; Sun, 30 Sep 2018 01:14:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:12:55 +0200 Message-Id: <1538295197-23704-58-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d Subject: [Qemu-devel] [PULL 57/79] 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: Liran Alon 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" From: Liran Alon 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 Message-Id: <20180914003827.124570-2-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- 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 6f0e4de..730c06f 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 0d27a0d..2d33477 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 df69e6d..5db167d 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 6c88939..df8e946 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 de892db..dc4047b 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 1.8.3.1