[PATCH v3 05.5/14] x86/svm: Decouple types in struct nestedsvm

Andrew Cooper posted 1 patch 1 year, 2 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230224210616.2818727-1-andrew.cooper3@citrix.com
xen/arch/x86/hvm/svm/nestedsvm.c             | 4 ++--
xen/arch/x86/include/asm/hvm/svm/nestedsvm.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH v3 05.5/14] x86/svm: Decouple types in struct nestedsvm
Posted by Andrew Cooper 1 year, 2 months ago
struct nestedvm uses mostly plain integer types, except for virt_ext_t which
is a union wrapping two bitfield names.  But the nested virt logic only ever
deals with it as full opaque register.

Switch it to being a plain uint64_t, allowing us to hide even more of the SVM
internal infrastructure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Xenia Ragiadakou <burzalodowa@gmail.com>

This allows virt_ext_t to move out of the public vmcb.h along with all other
vmcb types.
---
 xen/arch/x86/hvm/svm/nestedsvm.c             | 4 ++--
 xen/arch/x86/include/asm/hvm/svm/nestedsvm.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 92316c6624ce..153a37f2f227 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -164,7 +164,7 @@ 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_virt_ext = 0;
 
     svm->ns_hap_enabled = 0;
     svm->ns_vmcb_guestcr3 = 0;
@@ -526,7 +526,7 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
 
     /* LBR and other virtualization */
     if ( !clean.lbr )
-        svm->ns_virt_ext = ns_vmcb->virt_ext;
+        svm->ns_virt_ext = ns_vmcb->virt_ext.bytes;
 
     n2vmcb->virt_ext.bytes =
         n1vmcb->virt_ext.bytes | ns_vmcb->virt_ext.bytes;
diff --git a/xen/arch/x86/include/asm/hvm/svm/nestedsvm.h b/xen/arch/x86/include/asm/hvm/svm/nestedsvm.h
index 94d45d2e8d47..184248bbd7c5 100644
--- a/xen/arch/x86/include/asm/hvm/svm/nestedsvm.h
+++ b/xen/arch/x86/include/asm/hvm/svm/nestedsvm.h
@@ -44,7 +44,7 @@ struct nestedsvm {
     uint32_t ns_general2_intercepts;
 
     /* Cached real lbr and other virtual extentions of the l2 guest */
-    virt_ext_t ns_virt_ext;
+    uint64_t ns_virt_ext;
 
     /* Cached real MSR permission bitmaps of the l2 guest */
     unsigned long *ns_cached_msrpm;
-- 
2.30.2
Re: [PATCH v3 05.5/14] x86/svm: Decouple types in struct nestedsvm
Posted by Xenia Ragiadakou 1 year, 2 months ago
On 2/24/23 23:06, Andrew Cooper wrote:
> struct nestedvm uses mostly plain integer types, except for virt_ext_t which
> is a union wrapping two bitfield names.  But the nested virt logic only ever
> deals with it as full opaque register.
> 
> Switch it to being a plain uint64_t, allowing us to hide even more of the SVM
> internal infrastructure.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Xenia Ragiadakou <burzalodowa@gmail.com>

-- 
Xenia
Re: [PATCH v3 05.5/14] x86/svm: Decouple types in struct nestedsvm
Posted by Andrew Cooper 1 year, 2 months ago
On 27/02/2023 8:52 am, Xenia Ragiadakou wrote:
>
> On 2/24/23 23:06, Andrew Cooper wrote:
>> struct nestedvm uses mostly plain integer types, except for
>> virt_ext_t which
>> is a union wrapping two bitfield names.  But the nested virt logic
>> only ever
>> deals with it as full opaque register.
>>
>> Switch it to being a plain uint64_t, allowing us to hide even more of
>> the SVM
>> internal infrastructure.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> Reviewed-by: Xenia Ragiadakou <burzalodowa@gmail.com>
>

On second thoughts, the fact that this patch compiles means its a
write-only variable.

Lemme experiment quickly with an alternate patch.

~Andrew