All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liran Alon <liran.alon@oracle.com>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, kvm@vger.kernel.org, mtosatti@redhat.com,
	Liran Alon <liran.alon@oracle.com>,
	pbonzini@redhat.com, rth@twiddle.net, jmattson@google.com
Subject: [QEMU PATCH v2 1/2] i386: Compile CPUX86State xsave_buf only when support KVM or HVF
Date: Sun, 16 Sep 2018 15:46:30 +0300	[thread overview]
Message-ID: <20180916124631.39016-2-liran.alon@oracle.com> (raw)
In-Reply-To: <20180916124631.39016-1-liran.alon@oracle.com>

While at it, also rename var to indicate it is not used only in KVM.

Reviewed-by: Nikita Leshchenko <nikita.leshchenko@oracle.com>
Reviewed-by: Patrick Colp <patrick.colp@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
 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 @@
 
 These sources (and ../hvf-all.c) are adapted from Veertu Inc's vdhh (Veertu Desktop Hosted Hypervisor) (last known location: https://github.com/veertuinc/vdhh) with some minor changes, the most significant of which were:
 
-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_xsave_buf) due to historical differences + QEMU needing to handle more emulation 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);
 
     x86cpu = X86_CPU(cpu);
-    x86cpu->env.kvm_xsave_buf = qemu_memalign(4096, 4096);
+    x86cpu->env.xsave_buf = qemu_memalign(4096, 4096);
 
     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)
 
     struct X86XSaveArea *xsave;
 
-    xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
+    xsave = X86_CPU(cpu_state)->env.xsave_buf;
 
     x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave);
 
@@ -163,7 +163,7 @@ void hvf_get_xsave(CPUState *cpu_state)
 {
     struct X86XSaveArea *xsave;
 
-    xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
+    xsave = X86_CPU(cpu_state)->env.xsave_buf;
 
     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)
     }
 
     if (has_xsave) {
-        env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
+        env->xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
     }
     cpu->kvm_msr_buf = g_malloc0(MSR_BUF_SIZE);
 
@@ -1639,7 +1639,7 @@ ASSERT_OFFSET(XSAVE_PKRU, pkru_state);
 static int kvm_put_xsave(X86CPU *cpu)
 {
     CPUX86State *env = &cpu->env;
-    X86XSaveArea *xsave = env->kvm_xsave_buf;
+    X86XSaveArea *xsave = env->xsave_buf;
 
     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 = &cpu->env;
-    X86XSaveArea *xsave = env->kvm_xsave_buf;
+    X86XSaveArea *xsave = env->xsave_buf;
     int ret;
 
     if (!has_xsave) {
-- 
2.16.1

WARNING: multiple messages have this Message-ID (diff)
From: Liran Alon <liran.alon@oracle.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, rth@twiddle.net,
	ehabkost@redhat.com, kvm@vger.kernel.org, jmattson@google.com,
	Liran Alon <liran.alon@oracle.com>
Subject: [Qemu-devel] [QEMU PATCH v2 1/2] i386: Compile CPUX86State xsave_buf only when support KVM or HVF
Date: Sun, 16 Sep 2018 15:46:30 +0300	[thread overview]
Message-ID: <20180916124631.39016-2-liran.alon@oracle.com> (raw)
In-Reply-To: <20180916124631.39016-1-liran.alon@oracle.com>

While at it, also rename var to indicate it is not used only in KVM.

Reviewed-by: Nikita Leshchenko <nikita.leshchenko@oracle.com>
Reviewed-by: Patrick Colp <patrick.colp@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
 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 @@
 
 These sources (and ../hvf-all.c) are adapted from Veertu Inc's vdhh (Veertu Desktop Hosted Hypervisor) (last known location: https://github.com/veertuinc/vdhh) with some minor changes, the most significant of which were:
 
-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_xsave_buf) due to historical differences + QEMU needing to handle more emulation 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);
 
     x86cpu = X86_CPU(cpu);
-    x86cpu->env.kvm_xsave_buf = qemu_memalign(4096, 4096);
+    x86cpu->env.xsave_buf = qemu_memalign(4096, 4096);
 
     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)
 
     struct X86XSaveArea *xsave;
 
-    xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
+    xsave = X86_CPU(cpu_state)->env.xsave_buf;
 
     x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave);
 
@@ -163,7 +163,7 @@ void hvf_get_xsave(CPUState *cpu_state)
 {
     struct X86XSaveArea *xsave;
 
-    xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
+    xsave = X86_CPU(cpu_state)->env.xsave_buf;
 
     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)
     }
 
     if (has_xsave) {
-        env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
+        env->xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
     }
     cpu->kvm_msr_buf = g_malloc0(MSR_BUF_SIZE);
 
@@ -1639,7 +1639,7 @@ ASSERT_OFFSET(XSAVE_PKRU, pkru_state);
 static int kvm_put_xsave(X86CPU *cpu)
 {
     CPUX86State *env = &cpu->env;
-    X86XSaveArea *xsave = env->kvm_xsave_buf;
+    X86XSaveArea *xsave = env->xsave_buf;
 
     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 = &cpu->env;
-    X86XSaveArea *xsave = env->kvm_xsave_buf;
+    X86XSaveArea *xsave = env->xsave_buf;
     int ret;
 
     if (!has_xsave) {
-- 
2.16.1

  reply	other threads:[~2018-09-16 12:46 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-16 12:46 [QEMU PATCH v2 0/2]: KVM: i386: Add support for save and restore nested state Liran Alon
2018-09-16 12:46 ` [Qemu-devel] " Liran Alon
2018-09-16 12:46 ` Liran Alon [this message]
2018-09-16 12:46   ` [Qemu-devel] [QEMU PATCH v2 1/2] i386: Compile CPUX86State xsave_buf only when support KVM or HVF Liran Alon
2018-09-16 12:46 ` [QEMU PATCH v2 2/2] KVM: i386: Add support for save and restore nested state Liran Alon
2018-09-16 12:46   ` [Qemu-devel] " Liran Alon
2018-10-08 17:21 ` [QEMU PATCH v2 0/2]: " Liran Alon
2018-10-08 17:21   ` [Qemu-devel] " Liran Alon
2018-10-15 18:10   ` Liran Alon
2018-10-15 18:10     ` [Qemu-devel] " Liran Alon
2018-10-31  1:03     ` Liran Alon
2018-10-31  1:03       ` [Qemu-devel] " Liran Alon
2018-10-31 18:17       ` Eduardo Habkost
2018-10-31 18:17         ` [Qemu-devel] " Eduardo Habkost
2018-10-31 18:19         ` Paolo Bonzini
2018-10-31 18:19           ` [Qemu-devel] " Paolo Bonzini
2018-10-31 18:50           ` Liran Alon
2018-10-31 18:50             ` [Qemu-devel] " Liran Alon
2018-10-31 18:59             ` Dr. David Alan Gilbert
2018-10-31 18:59               ` [Qemu-devel] " Dr. David Alan Gilbert
2018-10-31 23:17               ` Liran Alon
2018-10-31 23:17                 ` [Qemu-devel] " Liran Alon
2018-11-01 13:10                 ` Dr. David Alan Gilbert
2018-11-01 13:10                   ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-01 15:23                   ` Liran Alon
2018-11-01 15:23                     ` [Qemu-devel] " Liran Alon
2018-11-01 15:56                     ` Dr. David Alan Gilbert
2018-11-01 15:56                       ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-01 16:45                       ` Jim Mattson via Qemu-devel
2018-11-01 16:45                         ` [Qemu-devel] " Jim Mattson
2018-11-02  3:46                         ` Liran Alon
2018-11-02  3:46                           ` [Qemu-devel] " Liran Alon
2018-11-02  9:40                           ` Paolo Bonzini
2018-11-02  9:40                             ` [Qemu-devel] " Paolo Bonzini
2018-11-02 12:35                             ` Dr. David Alan Gilbert
2018-11-02 12:35                               ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-02 12:40                               ` Daniel P. Berrangé
2018-11-02 12:40                                 ` [Qemu-devel] " Daniel P. Berrangé
2018-11-04 22:12                               ` Paolo Bonzini
2018-11-04 22:12                                 ` [Qemu-devel] " Paolo Bonzini
2018-11-02 12:59                             ` Liran Alon
2018-11-02 12:59                               ` [Qemu-devel] " Liran Alon
2018-11-02 16:44                               ` Jim Mattson via Qemu-devel
2018-11-02 16:44                                 ` [Qemu-devel] " Jim Mattson
2018-11-02 16:58                                 ` Daniel P. Berrangé
2018-11-02 16:58                                   ` [Qemu-devel] " Daniel P. Berrangé
2018-11-02 17:01                                   ` Jim Mattson via Qemu-devel
2018-11-02 17:01                                     ` [Qemu-devel] " Jim Mattson
2018-11-02 16:54                             ` Daniel P. Berrangé
2018-11-02 16:54                               ` [Qemu-devel] " Daniel P. Berrangé
2018-11-02 16:58                               ` Dr. David Alan Gilbert
2018-11-02 16:58                                 ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-04 22:19                               ` Paolo Bonzini
2018-11-04 22:19                                 ` [Qemu-devel] " Paolo Bonzini
2018-11-12 16:18                                 ` Daniel P. Berrangé
2018-11-12 16:18                                   ` [Qemu-devel] " Daniel P. Berrangé
2018-11-12 16:50                                   ` Dr. David Alan Gilbert
2018-11-12 16:50                                     ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-12 16:53                                     ` Paolo Bonzini
2018-11-12 16:53                                       ` [Qemu-devel] " Paolo Bonzini
2018-11-12 16:54                                     ` Daniel P. Berrangé
2018-11-12 16:54                                       ` [Qemu-devel] " Daniel P. Berrangé
2018-11-13  0:00                                       ` Liran Alon
2018-11-13  0:00                                         ` [Qemu-devel] " Liran Alon
2018-11-13  0:07                                         ` Jim Mattson via Qemu-devel
2018-11-13  0:07                                           ` [Qemu-devel] " Jim Mattson
2018-11-13  0:09                                           ` Liran Alon
2018-11-13  0:09                                             ` [Qemu-devel] " Liran Alon
2018-11-12 23:58                                     ` Liran Alon
2018-11-12 23:58                                       ` [Qemu-devel] " Liran Alon
2018-11-02 16:39                           ` Jim Mattson via Qemu-devel
2018-11-02 16:39                             ` [Qemu-devel] " Jim Mattson
2018-11-03  2:02                             ` Liran Alon
2018-11-03  2:02                               ` [Qemu-devel] " Liran Alon
2018-11-08  0:13                               ` Liran Alon
2018-11-08  0:13                                 ` [Qemu-devel] " Liran Alon
2018-11-08  0:45                                 ` Jim Mattson via Qemu-devel
2018-11-08  0:45                                   ` [Qemu-devel] " Jim Mattson
2018-11-08  9:50                                   ` Paolo Bonzini
2018-11-08  9:50                                     ` [Qemu-devel] " Paolo Bonzini
2018-11-08  9:57                                     ` Liran Alon
2018-11-08  9:57                                       ` [Qemu-devel] " Liran Alon
2018-11-08 17:02                                       ` Paolo Bonzini
2018-11-08 17:02                                         ` [Qemu-devel] " Paolo Bonzini
2018-11-08 18:41                                         ` Liran Alon
2018-11-08 18:41                                           ` [Qemu-devel] " Liran Alon
2018-11-08 20:34                                           ` Paolo Bonzini
2018-11-08 20:34                                             ` [Qemu-devel] " Paolo Bonzini
2018-11-12 14:51                                           ` Dr. David Alan Gilbert
2018-11-12 14:51                                             ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-01 19:03                       ` Liran Alon
2018-11-01 19:03                         ` [Qemu-devel] " Liran Alon
2018-11-01 19:07                         ` Dr. David Alan Gilbert
2018-11-01 19:07                           ` [Qemu-devel] " Dr. David Alan Gilbert
2018-11-01 19:41                           ` Jim Mattson via Qemu-devel
2018-11-01 19:41                             ` [Qemu-devel] " Jim Mattson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180916124631.39016-2-liran.alon@oracle.com \
    --to=liran.alon@oracle.com \
    --cc=ehabkost@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.