[PATCH v6 39/44] KVM: VMX: Bug the VM if either MSR auto-load list is full

Mi, Dapeng dapeng1.mi at linux.intel.com
Thu Jan 8 16:29:50 PST 2026


On 1/9/2026 4:04 AM, Sean Christopherson wrote:
> On Mon, Dec 08, 2025, Dapeng Mi wrote:
>> On 12/6/2025 8:17 AM, Sean Christopherson wrote:
>>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>>> index 38491962b2c1..2c50ebf4ff1b 100644
>>> --- a/arch/x86/kvm/vmx/vmx.c
>>> +++ b/arch/x86/kvm/vmx/vmx.c
>>> @@ -1098,6 +1098,7 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
>>>  {
>>>  	int i, j = 0;
>>>  	struct msr_autoload *m = &vmx->msr_autoload;
>>> +	struct kvm *kvm = vmx->vcpu.kvm;
>>>  
>>>  	switch (msr) {
>>>  	case MSR_EFER:
>>> @@ -1134,12 +1135,10 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
>>>  	i = vmx_find_loadstore_msr_slot(&m->guest, msr);
>>>  	j = vmx_find_loadstore_msr_slot(&m->host, msr);
>>>  
>>> -	if ((i < 0 && m->guest.nr == MAX_NR_LOADSTORE_MSRS) ||
>>> -	    (j < 0 &&  m->host.nr == MAX_NR_LOADSTORE_MSRS)) {
>>> -		printk_once(KERN_WARNING "Not enough msr switch entries. "
>>> -				"Can't add msr %x\n", msr);
>>> +	if (KVM_BUG_ON(i < 0 && m->guest.nr == MAX_NR_LOADSTORE_MSRS, kvm) ||
>>> +	    KVM_BUG_ON(j < 0 &&  m->host.nr == MAX_NR_LOADSTORE_MSRS, kvm))
>> nit: Remove one extra space before "m->host.nr".
> Oh, that's intentional, so that the rest of the line is aligned with the "guest"
> line above.

Good to know. Thanks.





More information about the linux-riscv mailing list