a19a21
From 655e723a5190206302f6cc4f2e794563b8e1c226 Mon Sep 17 00:00:00 2001
a19a21
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
a19a21
Date: Wed, 24 Feb 2021 11:30:36 -0500
a19a21
Subject: [PATCH 3/4] x86/cpu: Populate SVM CPUID feature bits
a19a21
a19a21
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
a19a21
Message-id: <20210224113037.15599-4-dgilbert@redhat.com>
a19a21
Patchwork-id: 101200
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 3/4] x86/cpu: Populate SVM CPUID feature bits
a19a21
Bugzilla: 1790620
a19a21
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a19a21
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
a19a21
RH-Acked-by: Peter Xu <peterx@redhat.com>
a19a21
a19a21
From: Wei Huang <wei.huang2@amd.com>
a19a21
a19a21
Newer AMD CPUs will add CPUID_0x8000000A_EDX[28] bit, which indicates
a19a21
that SVM instructions (VMRUN/VMSAVE/VMLOAD) will trigger #VMEXIT before
a19a21
CPU checking their EAX against reserved memory regions. This change will
a19a21
allow the hypervisor to avoid intercepting #GP and emulating SVM
a19a21
instructions. KVM turns on this CPUID bit for nested VMs. In order to
a19a21
support it, let us populate this bit, along with other SVM feature bits,
a19a21
in FEAT_SVM.
a19a21
a19a21
Signed-off-by: Wei Huang <wei.huang2@amd.com>
a19a21
Message-Id: <20210126202456.589932-1-wei.huang2@amd.com>
a19a21
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
a19a21
(cherry picked from commit 5447089c2b3b084b51670af36fc86ee3979e04be)
a19a21
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a19a21
---
a19a21
 target/i386/cpu.c |  6 +++---
a19a21
 target/i386/cpu.h | 24 ++++++++++++++----------
a19a21
 2 files changed, 17 insertions(+), 13 deletions(-)
a19a21
a19a21
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
a19a21
index f6a9ed84b3..7227c803c3 100644
a19a21
--- a/target/i386/cpu.c
a19a21
+++ b/target/i386/cpu.c
a19a21
@@ -1026,11 +1026,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
a19a21
             "npt", "lbrv", "svm-lock", "nrip-save",
a19a21
             "tsc-scale", "vmcb-clean",  "flushbyasid", "decodeassists",
a19a21
             NULL, NULL, "pause-filter", NULL,
a19a21
-            "pfthreshold", NULL, NULL, NULL,
a19a21
-            NULL, NULL, NULL, NULL,
a19a21
-            NULL, NULL, NULL, NULL,
a19a21
+            "pfthreshold", "avic", NULL, "v-vmsave-vmload",
a19a21
+            "vgif", NULL, NULL, NULL,
a19a21
             NULL, NULL, NULL, NULL,
a19a21
             NULL, NULL, NULL, NULL,
a19a21
+            "svme-addr-chk", NULL, NULL, NULL,
a19a21
         },
a19a21
         .cpuid = { .eax = 0x8000000A, .reg = R_EDX, },
a19a21
         .tcg_features = TCG_SVM_FEATURES,
a19a21
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
a19a21
index f5a4efcec6..e1b67910c2 100644
a19a21
--- a/target/i386/cpu.h
a19a21
+++ b/target/i386/cpu.h
a19a21
@@ -667,16 +667,20 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
a19a21
 #define CPUID_EXT3_PERFCORE (1U << 23)
a19a21
 #define CPUID_EXT3_PERFNB  (1U << 24)
a19a21
 
a19a21
-#define CPUID_SVM_NPT          (1U << 0)
a19a21
-#define CPUID_SVM_LBRV         (1U << 1)
a19a21
-#define CPUID_SVM_SVMLOCK      (1U << 2)
a19a21
-#define CPUID_SVM_NRIPSAVE     (1U << 3)
a19a21
-#define CPUID_SVM_TSCSCALE     (1U << 4)
a19a21
-#define CPUID_SVM_VMCBCLEAN    (1U << 5)
a19a21
-#define CPUID_SVM_FLUSHASID    (1U << 6)
a19a21
-#define CPUID_SVM_DECODEASSIST (1U << 7)
a19a21
-#define CPUID_SVM_PAUSEFILTER  (1U << 10)
a19a21
-#define CPUID_SVM_PFTHRESHOLD  (1U << 12)
a19a21
+#define CPUID_SVM_NPT             (1U << 0)
a19a21
+#define CPUID_SVM_LBRV            (1U << 1)
a19a21
+#define CPUID_SVM_SVMLOCK         (1U << 2)
a19a21
+#define CPUID_SVM_NRIPSAVE        (1U << 3)
a19a21
+#define CPUID_SVM_TSCSCALE        (1U << 4)
a19a21
+#define CPUID_SVM_VMCBCLEAN       (1U << 5)
a19a21
+#define CPUID_SVM_FLUSHASID       (1U << 6)
a19a21
+#define CPUID_SVM_DECODEASSIST    (1U << 7)
a19a21
+#define CPUID_SVM_PAUSEFILTER     (1U << 10)
a19a21
+#define CPUID_SVM_PFTHRESHOLD     (1U << 12)
a19a21
+#define CPUID_SVM_AVIC            (1U << 13)
a19a21
+#define CPUID_SVM_V_VMSAVE_VMLOAD (1U << 15)
a19a21
+#define CPUID_SVM_VGIF            (1U << 16)
a19a21
+#define CPUID_SVM_SVME_ADDR_CHK   (1U << 28)
a19a21
 
a19a21
 /* Support RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
a19a21
 #define CPUID_7_0_EBX_FSGSBASE          (1U << 0)
a19a21
-- 
a19a21
2.27.0
a19a21