Skip to contentSkip to conversation

x86/svm: Decouple types in struct nestedsvm

PATCH In review Andrew Cooper 2 participants 3 messages Feb 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/svm: Decouple types in struct nestedsvm

struct nestedvm uses mostly plain integer types, except for virt_ext_t which is a union wrapping two bitfield names.

However, it turns out that this is a write-only variable. Delete it, allowing us to drop the include of vmcb.h

---
CC: Jan Beulich <[email protected]>
CC: Xenia Ragiadakou <[email protected]>

v2:
* Delete the variable entirely.

This probably means that nested lbr/vmloadsave is broken, but that wouldn't be a surprise at all.

---
 xen/arch/x86/hvm/svm/nestedsvm.c             | 5 -----
 xen/arch/x86/include/asm/hvm/svm/nestedsvm.h | 5 -----
 2 files changed, 10 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +0 -5
index 92316c6624ce..63ed9fc248e1 100644
@@ -164,7 +164,6 @@ int cf_check nsvm_vcpu_reset(struct vcpu *v)
     svm->ns_exception_intercepts = 0;
     svm->ns_general1_intercepts = 0;
     svm->ns_general2_intercepts = 0;
-    svm->ns_virt_ext.bytes = 0;
 
     svm->ns_hap_enabled = 0;
     svm->ns_vmcb_guestcr3 = 0;
@@ -524,10 +523,6 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
     /* Pending Interrupts */
     n2vmcb->event_inj = ns_vmcb->event_inj;
 
-    /* LBR and other virtualization */
-    if ( !clean.lbr )
-        svm->ns_virt_ext = ns_vmcb->virt_ext;
-
     n2vmcb->virt_ext.bytes =
         n1vmcb->virt_ext.bytes | ns_vmcb->virt_ext.bytes;
 
xen/arch/x86/include/asm/hvm/svm/nestedsvm.h +0 -5
index 94d45d2e8d47..230f818df80c 100644
@@ -20,8 +20,6 @@
 
 #include <xen/types.h>
 
-#include <asm/hvm/svm/vmcb.h>
-
 struct nestedsvm {
     bool ns_gif;
     uint64_t ns_msr_hsavepa; /* MSR HSAVE_PA value */
@@ -43,9 +41,6 @@ struct nestedsvm {
     uint32_t ns_general1_intercepts;
     uint32_t ns_general2_intercepts;
 
-    /* Cached real lbr and other virtual extentions of the l2 guest */
-    virt_ext_t ns_virt_ext;
-
     /* Cached real MSR permission bitmaps of the l2 guest */
     unsigned long *ns_cached_msrpm;
     /* Merged MSR permission bitmap */
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Andrew Cooper

struct nestedvm uses mostly plain integer types, except for virt_ext_t which is a union wrapping two bitfield names.

However, it turns out that this is a write-only variable. Delete it, allowing us to drop the include of vmcb.h

---
CC: Jan Beulich <[email protected]>
CC: Xenia Ragiadakou <[email protected]>

Quoted 5 lines

v2:
* Delete the variable entirely.

This probably means that nested lbr/vmloadsave is broken, but that wouldn't be a surprise at all.

Well, yes, short of figuring out what's missing this is probably the least bad option:

Jan

#2 lore raw
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Andrew Cooper

struct nestedvm uses mostly plain integer types, except for virt_ext_t which is a union wrapping two bitfield names.

However, it turns out that this is a write-only variable. Delete it, allowing us to drop the include of vmcb.h

---
CC: Jan Beulich <[email protected]>
CC: Xenia Ragiadakou <[email protected]>

Quoted 8 lines
Quoted 5 lines

v2:
* Delete the variable entirely.

This probably means that nested lbr/vmloadsave is broken, but that wouldn't be a surprise at all.

Well, yes, short of figuring out what's missing this is probably the least bad option:

Thanks.

I'm pretty certain a working version of nested virt won't need this cached information like this at all.  I'm pretty sure it's buggy not to be referencing the appropriate one of the 3 relevant VMCBs.

~Andrew