[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 2/5] x86/vmx: add raw_vmx_msr_policy
> From: Sergey Dyasli [mailto:sergey.dyasli@xxxxxxxxxx] > Sent: Monday, July 24, 2017 9:48 PM > > Add calculate_vmx_raw_policy() which fills the raw_vmx_msr_policy > object (the actual contents of H/W VMX MSRs) on the boot CPU. On > secondary CPUs, this function checks that contents of VMX MSRs match > the boot CPU's contents. > > Remove lesser version of same-contents-check from vmx_init_vmcs_config(). > > Signed-off-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx> > --- > v1 --> v2: > - calculate_raw_policy() is renamed to calculate_vmx_raw_policy() > to avoid clash with the same-name function in cpuid.c > - Declaration of calculate_vmx_raw_policy() is removed from vmx.c > and added to vmcs.h > - msr variable is now unsigned in calculate_vmx_raw_policy() > - "\n" moved to the same line as the printk format string > - Replaced magic constants for available bitmap with gen_vmx_msr_mask() > - get_vmx_msr_ptr() and get_vmx_msr_val() helpers are used instead of > accessing MSR array directly > > xen/arch/x86/hvm/vmx/vmcs.c | 134 +++++++++++++++++++++------------ > ---- > xen/arch/x86/hvm/vmx/vmx.c | 2 + > xen/include/asm-x86/hvm/vmx/vmcs.h | 3 + > 3 files changed, 82 insertions(+), 57 deletions(-) > > diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c > index 33715748f0..8070ed21c8 100644 > --- a/xen/arch/x86/hvm/vmx/vmcs.c > +++ b/xen/arch/x86/hvm/vmx/vmcs.c > @@ -144,6 +144,8 @@ static void __init vmx_display_features(void) > printk(" - none\n"); > } > > +struct vmx_msr_policy __read_mostly raw_vmx_msr_policy; > + > bool vmx_msr_available(const struct vmx_msr_policy *p, uint32_t msr) > { > if ( msr < MSR_IA32_VMX_BASIC || msr > MSR_IA32_VMX_LAST ) > @@ -178,6 +180,78 @@ uint32_t gen_vmx_msr_mask(uint32_t start_msr, > uint32_t end_msr) > (start_msr - MSR_IA32_VMX_BASIC); > } > > +int calculate_vmx_raw_policy(bool bsp) calculate_raw_vmxcap_policy > +{ > + struct vmx_msr_policy policy; > + struct vmx_msr_policy *p = &policy; > + unsigned int msr; > + > + /* Raw policy is filled only on boot CPU */ > + if ( bsp ) > + p = &raw_vmx_msr_policy; > + else > + memset(&policy, 0, sizeof(policy)); memset(p, 0, sizeof(*p)); > + > + p->available = gen_vmx_msr_mask(MSR_IA32_VMX_BASIC, > MSR_IA32_VMX_VMCS_ENUM); > + for ( msr = MSR_IA32_VMX_BASIC; msr <= MSR_IA32_VMX_VMCS_ENUM; > msr++ ) > + rdmsrl(msr, *get_vmx_msr_ptr(p, msr)); move above into a function since quite some duplication below. Thanks Kevin _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |