On 09/01/2018 00:19, Jim Mattson wrote: >>>> + vmx_disable_intercept_for_msr(MSR_IA32_SPEC_CTRL, false); >>>> + vmx_disable_intercept_for_msr(MSR_IA32_PRED_CMD, false); >>> I have a lot of changes to MSR permission bitmap handling, but these >>> intercepts should only be disabled when guest_cpuid_has(vcpu, >>> X86_FEATURE_SPEC_CTRL). >> That's harder to backport and not strictly necessary (just like >> e.g. we don't check guest CPUID bits before emulation). I agree that >> your version is better, but I think the above is fine as a minimal >> fix. > > Due to the impacts that spec_ctrl has on the neighboring hyperthread, > one may want to disable MSRs 0x48 and 0x49 for a particular VM. We do > this by masking off CPUID.(EAX=7, ECX=0).EDX[26] and CPUID.(EAX=7, > ECX=0).EDX[27] from the userspace agent. However, with your patch, > *any* VCPU gets unrestricted access to these MSRs, without any > mechanism for disabling them. Yes, I agree that having the check is superior. However, I also want to get there step by step. >>>> + if (have_spec_ctrl) { >>>> + rdmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); >>>> + if (vmx->spec_ctrl) >>>> + wrmsrl(MSR_IA32_SPEC_CTRL, 0); >>>> + } >>>> + >>> >>> I know the VM-exit MSR load and store lists are probably slower, but >>> I'm a little uncomfortable restoring the host's IA32_SPEC_CTRL MSR >>> late if the guest has it clear and the host has it set. >> >> There is no indirect branch before though, isn't it? > > I guess that depends on how you define "before." --verbose? :-/ Paolo