Re: [RFC PATCH v2 04/11] KVM: VMX: Add IA32_SPEC_CTRL virtualization support

From: Chao Gao
Date: Mon Apr 17 2023 - 22:08:11 EST


On Mon, Apr 17, 2023 at 11:17:36AM +0800, Binbin Wu wrote:
>
>On 4/14/2023 2:25 PM, Chao Gao wrote:
>> From: Zhang Chen <chen.zhang@xxxxxxxxx>
>>
>> Currently KVM disables interception of IA32_SPEC_CTRL after a non-0 is
>> written to IA32_SPEC_CTRL by guest. Then, guest is allowed to write any
>> value to hardware.
>>
>> "virtualize IA32_SPEC_CTRL" is a new tertiary vm-exec control. This
>> feature allows KVM to specify that certain bits of the IA32_SPEC_CTRL
>> MSR cannot be modified by guest software.
>>
>> Two VMCS fields are added:
>>
>> IA32_SPEC_CTRL_MASK: bits that guest software cannot modify
>> IA32_SPEC_CTRL_SHADOW: value that guest software expects to be in the
>> IA32_SPEC_CTRL MSR
>>
>> On rdmsr, the shadow value is returned. on wrmsr, EDX:EAX is written
>> to the IA32_SPEC_CTRL_SHADOW and (cur_val & mask) | (EDX:EAX & ~mask)
>> is written to the IA32_SPEC_CTRL MSR, where
>> * cur_val is the original value of IA32_SPEC_CTRL MSR
>> * mask is the value of IA32_SPEC_CTRL_MASK
>>
>> Add a mask e.g.,
>
>e.g. or i.e. ?

Yes, here should be "i.e.".

>> +static inline void vmx_set_guest_spec_ctrl(struct vcpu_vmx *vmx, u64 val)
>> +{
>> + vmx->guest_spec_ctrl = val;
>> +
>> + /*
>> + * For simplicity, always keep IA32_SPEC_CTRL_SHADOW up-to-date,
>> + * regardless of the MSR intercept state.
>
>It is better to use "IA32_SPEC_CTRL"  explicitly instead of "the MSR" to
>avoid misunderstand.

Agreed. Will do.