xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen/HVM: Add guarding logic for VMX specific code
@ 2016-08-29 12:01 Suravee Suthikulpanit
  2016-08-29 14:36 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 2+ messages in thread
From: Suravee Suthikulpanit @ 2016-08-29 12:01 UTC (permalink / raw)
  To: xen-devel
  Cc: andrew.cooper3, Wei Liu, Suravee Suthikulpanit, jbeulich,
	sherry.hurwitz

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.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
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(-)

diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 314881a..5d463e0 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -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_);                 \
 })
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xen/HVM: Add guarding logic for VMX specific code
  2016-08-29 12:01 [PATCH] xen/HVM: Add guarding logic for VMX specific code Suravee Suthikulpanit
@ 2016-08-29 14:36 ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 2+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-08-29 14:36 UTC (permalink / raw)
  To: Suravee Suthikulpanit
  Cc: andrew.cooper3, sherry.hurwitz, Wei Liu, jbeulich, xen-devel

On Mon, Aug 29, 2016 at 07:01:23AM -0500, Suravee Suthikulpanit wrote:
> 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).

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

structure.

> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> ---
> 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(-)
> 
> diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
> index 314881a..5d463e0 100644
> --- a/xen/include/asm-x86/hvm/hvm.h
> +++ b/xen/include/asm-x86/hvm/hvm.h
> @@ -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_);                 \
>  })
>  
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-29 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-29 12:01 [PATCH] xen/HVM: Add guarding logic for VMX specific code Suravee Suthikulpanit
2016-08-29 14:36 ` Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).