Re: [patch 2/2] x86/kvm/vmx: Prevent split lock detection induced #AC wreckage

From: Thomas Gleixner
Date: Thu Apr 02 2020 - 12:57:16 EST


Sean Christopherson <sean.j.christopherson@xxxxxxxxx> writes:
> On Thu, Apr 02, 2020 at 02:33:00PM +0200, Thomas Gleixner wrote:
>> Mark the module with MOD_INFO(sld_safe, "Y") so the module loader does not
>> force SLD off.
>
> Some comments below. But, any objection to taking Xiaoyao's patches that
> do effectively the same things, minus the MOD_INFO()? I'll repost them in
> reply to this thread.

If they are sane, I don't have a problem. But TBH, I really couldn't be
bothered to actually scan my mails whether there surfaced something sane
by now. Writing that up was just faster :)

I'll have look.

>> +static bool guest_handles_ac(struct kvm_vcpu *vcpu)
>> +{
>> + /*
>> + * If guest has alignment checking enabled in CR0 and activated in
>> + * eflags, then the #AC originated from CPL3 and the guest is able
>> + * to handle it. It does not matter whether this is a regular or
>> + * a split lock operation induced #AC.
>> + */
>> + if (vcpu->arch.cr0 & X86_CR0_AM &&
>
> Technically not required since KVM doesn't let the gets toggle CR0.AM at
> will, but going through kvm_read_cr0{_bits}() is preferred.

You're the expert here.

>> + vmx_get_rflags(vcpu) & X86_EFLAGS_AC)
>
> I don't think this is correct. A guest could trigger a split-lock #AC at
> CPL0 with EFLAGS.AC=1 and CR0.AM=1, and then panic because it didn't expect
> #AC at CPL0.

Indeed.

Thanks,

tglx