Re: [PATCH] x86: vmx: Allow direct access to MSR_IA32_SPEC_CTRL

From: Andy Lutomirski
Date: Sun Jan 28 2018 - 15:40:48 EST



> On Jan 28, 2018, at 12:21 PM, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> wrote:
>
>> On January 28, 2018 2:29:10 PM EST, KarimAllah Ahmed <karahmed@xxxxxxxxx> wrote:
>> Add direct access to MSR_IA32_SPEC_CTRL for guests. This is needed for
>> guests
>> that will only mitigate Spectre V2 through IBRS+IBPB and will not be
>> using a
>> retpoline+IBPB based approach.
>>
>> To avoid the overhead of atomically saving and restoring the
>> MSR_IA32_SPEC_CTRL
>> for guests that do not actually use the MSR, only add_atomic_switch_msr
>> when a
>> non-zero is written to it.
>
>
> We tried this and found that it was about 3% slower that doing the old way of rdmsr and wrmsr.
>

Do you mean that the host would intercept the guest WRMSR and do WRMSR itself? I would suggest that doing so is inconsistent with the docs. As specified, doing WRMSR to write 1 to IBRS does *not* protect the guest.

For that matter, what are the semantics of VMRESUME doing a write to IBRS as part of its MSR switch? Is it treated as IBRS=1 from guest context?