On 20.05.2022 15:37, Roger Pau Monne wrote: > --- a/xen/arch/x86/hvm/vmx/vmx.c > +++ b/xen/arch/x86/hvm/vmx/vmx.c > @@ -3007,6 +3007,8 @@ static const struct lbr_info { > { MSR_GM_LASTBRANCH_0_FROM_IP, NUM_MSR_GM_LASTBRANCH_FROM_TO }, > { MSR_GM_LASTBRANCH_0_TO_IP, NUM_MSR_GM_LASTBRANCH_FROM_TO }, > { 0, 0 } > +}, no_lbr[] = { > + {0, 0} > };
Instead of introducing this and ... > @@ -3070,6 +3072,21 @@ static const struct lbr_info *last_branch_msr_get(void) > /* Goldmont */ > case 0x5c: case 0x5f: > return gm_lbr; > + > + default: > + if ( cpu_has_pdcm ) > + { > + uint64_t cap; > + > + rdmsrl(MSR_IA32_PERF_CAPABILITIES, cap); > + if ( (cap & MSR_IA32_PERF_CAP_LBR_FORMAT) == 0x3f ) > + /* > + * On processors that do not support model-specific LBRs, > + * PERF_CAPABILITIES.LBR_FMT will have the value 0x3f. > + */ > + return no_lbr; ... doing this MSR read every time, can't you store a mask value once during boot, which you apply to msr_content ... > @@ -3521,6 +3538,8 @@ static int cf_check vmx_msr_write_intercept( > return X86EMUL_OKAY; > } > > + if ( lbr->count ) > + { > for ( ; lbr->count; lbr++ ) > { > unsigned int i; ... ahead of the bigger if() enclosing this code (thus also avoiding the need to re-indent)? Jan