On Thu, Jan 11, 2018 at 05:32:19PM -0800, Ashok Raj wrote:
> @@ -1711,11 +1715,18 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu)
>       __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER);
>       kvm_vcpu_uninit(vcpu);
>       kmem_cache_free(kvm_vcpu_cache, svm);
> +    /* 
> +     * The VMCB could be recycled, causing a false negative in svm_vcpu_load;
> +     * block speculative execution.
> +     */
> +     if (boot_cpu_has(X86_FEATURE_PRED_CMD))
> +        native_wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB);
>  }

> @@ -3837,6 +3839,12 @@ static void free_loaded_vmcs(struct loaded_vmcs 
> *loaded_vmcs)
>       free_vmcs(loaded_vmcs->vmcs);
>       loaded_vmcs->vmcs = NULL;
>       WARN_ON(loaded_vmcs->shadow_vmcs != NULL);
> +    /*
> +     * The VMCS could be recycled, causing a false negative in vmx_vcpu_load
> +     * block speculative execution.
> +     */
> +     if (boot_cpu_has(X86_FEATURE_SPEC_CTRL))
> +        native_wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB);
>  }

Whitespace damage.

Also, why not introduce a helper like:

static inline flush_ibpb(void)
{
        if (static_cpu_has(X86_FEATURE_SPEC_CTRL))
                native_write_msr(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB);
}

?

Reply via email to