Re: [PATCH 4/5] x86/svm: Direct access to MSR_IA32_SPEC_CTRL

From: David Woodhouse
Date: Fri Jan 12 2018 - 02:24:12 EST


On Thu, 2018-01-11 at 17:32 -0800, Ashok Raj wrote:
>
> @@ -4910,6 +4935,14 @@ static void svm_vcpu_run(struct kvm_vcpu
> *vcpu)
> Â
> ÂÂÂÂÂÂÂÂclgi();
> Â
> +ÂÂÂÂÂÂÂif (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) {
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/*
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * FIXME: lockdep_assert_irqs_disabled();
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ */
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂWARN_ON_ONCE(!irqs_disabled());
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂspec_ctrl_set(svm->spec_ctrl);
> +ÂÂÂÂÂÂÂ}
> +
> ÂÂÂÂÂÂÂÂlocal_irq_enable();
> Â

Same comments here as we've had previously. If you do this without an
'else lfence' then you need a comment showing that you've proved it's
safe.

And I don't think even using static_cpu_has() is good enough. We don't
already "rely" on that for anything but optimisations, AFAICT. Turning
a missed GCC optimisation into a security hole is not a good idea.

Attachment: smime.p7s
Description: S/MIME cryptographic signature