Thread (69 messages) 69 messages, 5 authors, 2026-02-20

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

From: Mi, Dapeng <hidden>
Date: 2026-01-09 00:30:00
Also in: kvm, kvm-riscv, kvmarm, linux-perf-users, linux-riscv, lkml, loongarch

On 1/9/2026 4:04 AM, Sean Christopherson wrote:
On Mon, Dec 08, 2025, Dapeng Mi wrote:
quoted
On 12/6/2025 8:17 AM, Sean Christopherson wrote:
quoted
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.


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help