[Qemu-devel] [PATCH] target/i386: save EFER for 32-bit targets

Pavel Dovgalyuk posted 1 patch 4 years, 10 months ago
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/155913371654.8429.1659082639780315242.stgit@pasha-Precision-3630-Tower
Maintainers: Richard Henderson <rth@twiddle.net>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
target/i386/machine.c |   24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
[Qemu-devel] [PATCH] target/i386: save EFER for 32-bit targets
Posted by Pavel Dovgalyuk 4 years, 10 months ago
i386 (32 bit) emulation uses EFER in wrmsr and in MMU fault
processing.
But it does not included in VMState, because "efer" field is disabled with
#ifdef TARGET_X86_64

This patch adds a section for 32-bit targets which saves EFER when
it's value is non-zero.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 target/i386/machine.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/target/i386/machine.c b/target/i386/machine.c
index 225b5d433b..b5bfc5803e 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -964,6 +964,27 @@ static const VMStateDescription vmstate_svm_npt = {
     }
 };
 
+#ifndef TARGET_X86_64
+static bool intel_efer32_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->efer != 0;
+}
+
+static const VMStateDescription vmstate_efer32 = {
+    .name = "cpu/efer32",
+    .version_id = 1,
+    .minimum_version_id = 1,
+   .needed = intel_efer32_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.efer, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+#endif
+
 VMStateDescription vmstate_x86_cpu = {
     .name = "cpu",
     .version_id = 12,
@@ -1089,6 +1110,9 @@ VMStateDescription vmstate_x86_cpu = {
         &vmstate_msr_intel_pt,
         &vmstate_msr_virt_ssbd,
         &vmstate_svm_npt,
+#ifndef TARGET_X86_64
+        &vmstate_efer32,
+#endif
         NULL
     }
 };


Re: [Qemu-devel] [PATCH] target/i386: save EFER for 32-bit targets
Posted by Eduardo Habkost 4 years, 10 months ago
On Wed, May 29, 2019 at 03:41:56PM +0300, Pavel Dovgalyuk wrote:
> i386 (32 bit) emulation uses EFER in wrmsr and in MMU fault
> processing.
> But it does not included in VMState, because "efer" field is disabled with
> #ifdef TARGET_X86_64
> 
> This patch adds a section for 32-bit targets which saves EFER when
> it's value is non-zero.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>

Queued, thanks!

-- 
Eduardo

Re: [Qemu-devel] [PATCH] target/i386: save EFER for 32-bit targets
Posted by Peter Xu 4 years, 10 months ago
On Wed, May 29, 2019 at 03:41:56PM +0300, Pavel Dovgalyuk wrote:
> +static const VMStateDescription vmstate_efer32 = {
> +    .name = "cpu/efer32",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +   .needed = intel_efer32_needed,

Indent might need a touchup.  Other than that:

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu