On Thu, Jul 16, 2020 at 11:16:25AM +0800, Yang Weijiang wrote: > Dump CET VMCS states for debug purpose. Since CET kernel protection is > not enabled, if related MSRs in host are filled by mistake, warn once on > detecting it. This all can be thrown into the enabling patch. This isn't so much code that it bloats the enabling patch, and the host MSRs being lost thing is confusing without the context that KVM doesn't stuff them into the VMCS. > > Signed-off-by: Yang Weijiang <weijiang.yang@xxxxxxxxx> > --- > arch/x86/kvm/vmx/vmx.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index d465ff990094..5d4250b9dec8 100644 ... > @@ -8205,6 +8217,7 @@ static __init int hardware_setup(void) > unsigned long host_bndcfgs; > struct desc_ptr dt; > int r, i, ept_lpage_level; > + u64 cet_msr; > > store_idt(&dt); > host_idt_base = dt.address; > @@ -8365,6 +8378,16 @@ static __init int hardware_setup(void) > return r; > } > > + if (boot_cpu_has(X86_FEATURE_IBT) || boot_cpu_has(X86_FEATURE_SHSTK)) { > + rdmsrl(MSR_IA32_S_CET, cet_msr); > + WARN_ONCE(cet_msr, "KVM: CET S_CET in host will be lost!\n"); > + } > + > + if (boot_cpu_has(X86_FEATURE_SHSTK)) { > + rdmsrl(MSR_IA32_PL0_SSP, cet_msr); > + WARN_ONCE(cet_msr, "KVM: CET PL0_SSP in host will be lost!\n"); > + } Largely arbitrary, but I'd prefer to do these checks up near the BNDCFG check, just so that all of these sorts of warnings are clustered together. > + > vmx_set_cpu_caps(); > > r = alloc_kvm_area(); > -- > 2.17.2 >