]> xenbits.xensource.com Git - xen.git/commitdiff
x86/hvm: Expose Automatic IBRS to guests
authorAlejandro Vallejo <alejandro.vallejo@cloud.com>
Tue, 30 May 2023 13:58:53 +0000 (14:58 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 30 May 2023 17:24:07 +0000 (18:24 +0100)
Expose AutoIBRS to HVM guests. EFER is swapped by VMRUN, so Xen only has to
make sure writes to EFER.AIBRSE are gated on the feature being exposed.

Hide EFER.AIBRSE from PV guests.  Xen currently has no concept of per-PV-guest
EFER settings.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/include/asm/msr-index.h
xen/arch/x86/pv/emul-priv-op.c
xen/include/public/arch-x86/cpufeatureset.h

index d7d31b53937a9b3d5b74f11cfe703ab27421eb8d..2d6e4bb9c682318683ef27fa25b39fc44bd4a123 100644 (file)
@@ -936,6 +936,9 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
     if ( (value & EFER_FFXSE) && !p->extd.ffxsr )
         return "FFXSE without feature";
 
+    if ( (value & EFER_AIBRSE) && !p->extd.auto_ibrs )
+        return "AutoIBRS without feature";
+
     return NULL;
 }
 
index 73d0af2615f3b11cb7230228306d2442fe387361..49cb334c6108a940d68f82d82817d90c08fe0f98 100644 (file)
 #define  EFER_AIBRSE                        (_AC(1, ULL) << 21) /* Automatic IBRS Enable */
 
 #define EFER_KNOWN_MASK \
-    (EFER_SCE | EFER_LME | EFER_LMA | EFER_NXE | EFER_SVME | EFER_FFXSE)
+    (EFER_SCE | EFER_LME | EFER_LMA | EFER_NXE | EFER_SVME | EFER_FFXSE | \
+     EFER_AIBRSE)
 
 #define MSR_STAR                            0xc0000081 /* legacy mode SYSCALL target */
 #define MSR_LSTAR                           0xc0000082 /* long mode SYSCALL target */
index 8a4ef9c35ead62cf686b19a8d69e377efea1cdd5..142bc4818cb5579fb6c8818352d8e4f8ad5f83d8 100644 (file)
@@ -853,8 +853,8 @@ static uint64_t guest_efer(const struct domain *d)
 {
     uint64_t val;
 
-    /* Hide unknown bits, and unconditionally hide SVME from guests. */
-    val = read_efer() & EFER_KNOWN_MASK & ~EFER_SVME;
+    /* Hide unknown bits, and unconditionally hide SVME and AIBRSE from guests. */
+    val = read_efer() & EFER_KNOWN_MASK & ~(EFER_SVME | EFER_AIBRSE);
     /*
      * Hide the 64-bit features from 32-bit guests.  SCE has
      * vendor-dependent behaviour.
index f49f71b9c91353345000a4e762d3fcbf7a434ed8..4edf9aba7ff6b76a03e1a2b8c9425dddfafff2de 100644 (file)
@@ -287,7 +287,7 @@ XEN_CPUFEATURE(AVX_IFMA,     10*32+23) /*A  AVX-IFMA Instructions */
 /* AMD-defined CPU features, CPUID level 0x80000021.eax, word 11 */
 XEN_CPUFEATURE(LFENCE_DISPATCH,    11*32+ 2) /*A  LFENCE always serializing */
 XEN_CPUFEATURE(NSCB,               11*32+ 6) /*A  Null Selector Clears Base (and limit too) */
-XEN_CPUFEATURE(AUTO_IBRS,          11*32+ 8) /*   Automatic IBRS */
+XEN_CPUFEATURE(AUTO_IBRS,          11*32+ 8) /*S  Automatic IBRS */
 XEN_CPUFEATURE(CPUID_USER_DIS,     11*32+17) /*   CPUID disable for CPL > 0 software */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.ebx, word 12 */