cryptospore / rpms / qemu-kvm

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