From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [RFC v1 05/15] vmx: Initialize VT-d Posted-Interrupts Descriptor Date: Thu, 26 Mar 2015 18:53:49 +0000 Message-ID: <551455BD.2020204@citrix.com> References: <1427286717-4093-1-git-send-email-feng.wu@intel.com> <1427286717-4093-6-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1427286717-4093-6-git-send-email-feng.wu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Feng Wu , xen-devel@lists.xen.org Cc: yang.z.zhang@intel.com, kevin.tian@intel.com, keir@xen.org, JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org On 25/03/15 12:31, Feng Wu wrote: > This patch initializes the VT-d Posted-interrupt Descriptor. > > Signed-off-by: Feng Wu > --- > xen/arch/x86/hvm/vmx/vmcs.c | 3 +++ > xen/include/asm-x86/hvm/vmx/vmx.h | 21 ++++++++++++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c > index d614638..942f4b7 100644 > --- a/xen/arch/x86/hvm/vmx/vmcs.c > +++ b/xen/arch/x86/hvm/vmx/vmcs.c > @@ -1004,6 +1004,9 @@ static int construct_vmcs(struct vcpu *v) > > if ( cpu_has_vmx_posted_intr_processing ) > { > + if ( iommu_intpost == 1 ) Being a boolean, please shorten this to "if ( iommu_intpost )" > + pi_desc_init(v); > + > __vmwrite(PI_DESC_ADDR, virt_to_maddr(&v->arch.hvm_vmx.pi_desc)); > __vmwrite(POSTED_INTR_NOTIFICATION_VECTOR, posted_intr_vector); > } > diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h > index ecc5e17..3cd75eb 100644 > --- a/xen/include/asm-x86/hvm/vmx/vmx.h > +++ b/xen/include/asm-x86/hvm/vmx/vmx.h > @@ -28,6 +28,9 @@ > #include > #include > #include > +#include > + > +extern uint8_t posted_intr_vector; > > typedef union { > struct { > @@ -146,6 +149,23 @@ static inline unsigned long pi_get_pir(struct pi_desc *pi_desc, int group) > return xchg(&pi_desc->pir[group], 0); > } > > +static inline void pi_desc_init(struct vcpu *v) > +{ > + uint32_t dest; > + > + pi_clear_sn(&v->arch.hvm_vmx.pi_desc); This is called during construct_vmcs(). You safely rely on the fact that all memory is safely zeroed, so you don't need this clear bit, nor the lower setting of ndm. > + v->arch.hvm_vmx.pi_desc.nv = posted_intr_vector; > + > + /* Physical mode for Notificaiton Event */ > + v->arch.hvm_vmx.pi_desc.ndm = 0; > + dest = cpu_physical_id(v->processor); > + > + if ( x2apic_enabled ) > + v->arch.hvm_vmx.pi_desc.ndst = dest; > + else > + v->arch.hvm_vmx.pi_desc.ndst = (dest << 8) & 0xFF00; What takes care of ensuring that this ndst field gets updated whenever v->processor changes? ~Andrew > +} > + > /* > * Exit Reasons > */ > @@ -265,7 +285,6 @@ static inline unsigned long pi_get_pir(struct pi_desc *pi_desc, int group) > #define MODRM_EAX_ECX ".byte 0xc1\n" /* EAX, ECX */ > > extern u64 vmx_ept_vpid_cap; > -extern uint8_t posted_intr_vector; > > #define cpu_has_vmx_ept_exec_only_supported \ > (vmx_ept_vpid_cap & VMX_EPT_EXEC_ONLY_SUPPORTED)