Skip to contentSkip to conversation

xen/HVM: Add guarding logic for VMX specific code

PATCH In review Suravee Suthikulpanit 2 participants 2 messages Aug 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/HVM: Add guarding logic for VMX specific code

The struct hvm_domain.vmx is defined in a union along with the svm. This can causes issue for SVM since this code is used in the common scheduling code for x86. The logic must check for cpu_has_vmx before accessing the hvm_domain.vmx sturcture.

---
Note: I ran into an issue while working on the upcoming patch series for AMD Advance Virtual Interrupt Controller patch series, which will use the hvm_domain.svm structure.

 xen/include/asm-x86/hvm/hvm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/hvm/hvm.h +1 -1
index 314881a..5d463e0 100644
@@ -611,7 +611,7 @@ unsigned long hvm_cr4_guest_reserved_bits(const struct vcpu *v, bool_t restore);
     struct vcpu *v_ = (v);                                      \
     struct domain *d_ = v_->domain;                             \
     if ( has_hvm_container_domain(d_) &&                        \
-         d_->arch.hvm_domain.vmx.vcpu_block )                   \
+         (cpu_has_vmx && d_->arch.hvm_domain.vmx.vcpu_block) )  \
         d_->arch.hvm_domain.vmx.vcpu_block(v_);                 \
 })
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Suravee Suthikulpanit

The struct hvm_domain.vmx is defined in a union along with the svm. This can causes issue for SVM since this code is used in the common

You scared me with the 'can causes'!

Digging in the pahole output - it It can't cause any issues right now as the 'struct svm_domain' is zero size (so no AMD code making changes) so the value at offset 16 is always zero (alloc_domain_struct clears it).

Quoted 2 lines

scheduling code for x86. The logic must check for cpu_has_vmx before accessing the hvm_domain.vmx sturcture.

structure.

Quoted 2 lines
Quoted 31 lines
Cc Wei Liu <[email protected]>
Cc Jan Beulich <[email protected]>

---
Note: I ran into an issue while working on the upcoming patch series for AMD Advance Virtual Interrupt Controller patch series, which will use the hvm_domain.svm structure.

 xen/include/asm-x86/hvm/hvm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/hvm/hvm.h +1 -1
index 314881a..5d463e0 100644
@@ -611,7 +611,7 @@ unsigned long hvm_cr4_guest_reserved_bits(const struct vcpu *v, bool_t restore);
     struct vcpu *v_ = (v);                                      \
     struct domain *d_ = v_->domain;                             \
     if ( has_hvm_container_domain(d_) &&                        \
-         d_->arch.hvm_domain.vmx.vcpu_block )                   \
+         (cpu_has_vmx && d_->arch.hvm_domain.vmx.vcpu_block) )  \
         d_->arch.hvm_domain.vmx.vcpu_block(v_);                 \
 })
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel