From nobody Sat Feb 7 08:23:08 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A226E25B663 for ; Fri, 23 Jan 2026 22:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769206553; cv=none; b=C+btUNanwD/Kl1RdjEbg9lVfgjijYHEkzM2PPruqVBuNLKvWurgivcBPnccTPPDig8/6YeJR1WsBvlgKBTlDf94coi7Cv96Vbc3RHbtsw13eZFvG8RkGUI7Ppv1UiH3WmWXj9nby/S5c9ErlfNIW4SDEfGheP65uavLWK6pIIsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769206553; c=relaxed/simple; bh=46gVXhJmvDN4ENPIvVKEe8ZMPqDeAwPrwixf5xf7Oes=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uMEetbl6x6mG/zc5FnxrwqW4i9PnHPON/s/Jigo8bSash0NAPRvNs7TJ+kSDQCVWSZOig/YAY6RYXg3tn982eXQTPm4g7Rn9PyVcgo2wbCfZpZLuveJWCVebdQBe3XKiKD6yCFhUcvYPV98GU+rrnqx21tW0xijSIb08Fv5WP9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aIMP9JjC; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aIMP9JjC" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-81e81fbbb8cso2649733b3a.3 for ; Fri, 23 Jan 2026 14:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769206550; x=1769811350; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=YMN/+EmMPsPAQZ8tSzzUwRBwXKzIBVH9d7FNpF2H/to=; b=aIMP9JjCKsTlX0JQ5UGgqQj394P1girbl11S2SVAeZTVjT0V7ELuVmDWet2wMSjYJG mNfikb0BI7RCIOuNmhMSG7zWicVMtk6MjeKXcQ+XFN/RcFXfp3swE0Iz/nqD8FSZFij9 TSpiac2/P0BCT2gx/4y5uJp92BNHOKJCJDvxPJ9i492I98ZjNxLV58ghyP7Hvuiovn0H E3tzIE2Rz2rlYt1gtVhfHyrUbdCCfdVGNHVUyo+490vGZx57eWEjHNpv2te229/OCJj+ q2yXl7sIYWWZUWhfeWkOm3Zi3/i+EZfilWGOtH774cujcZn+TQl3lvS9DwOoIfHjVQVa FOWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769206550; x=1769811350; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YMN/+EmMPsPAQZ8tSzzUwRBwXKzIBVH9d7FNpF2H/to=; b=njw0N6YZg3KzFtMHX4uLZPxCKX2IZWpFTJZ0fWEuxh5VJlI2AXTFtYLwK939QGTcnT H9Y3AjvZW1yoRV1YELkc2POoGyKa9hl08fQmHwKnr865TN77gSKOXIGKsv3dfe+4G2Tz 4VTj4LdPbqfWOg1W/EyUSde9W3ONO57uaChMhPRrx7Rac1wEe5atz8okxNxNjjBGVzSb FGDWzbd8tUYr8QbEKj33jXnCbd5AopqCwtU/KRkl/+FQsl3tNFSFSO3lCAMSv5cjE8LK YYHVVrgd6dMEXVNGwDHvKCzj1gD3TtLok16+TqYMcsuWvilfZLh9sbB6txRtUtxIc54l 4C9w== X-Forwarded-Encrypted: i=1; AJvYcCVYh1G8jMmQRiMqhLiBCpRyUweu26T8GGOx2Zhlz56gKASHXQV/7IahqWfIzSfotZWBW8WcQvlduZ4Vixc=@vger.kernel.org X-Gm-Message-State: AOJu0YzR0lmgQiAT0Mk2tWwES1Y83Fc2zBjuoq0qsL7nmxqUD24sdZ0P vd7AGmXgV5QL2vthLMwxOIqR80ipFc/IZdTXtGvH91psIYjVmObjYGWHbHGXm2Kk3dmX0jrhwku g7nSZFQ== X-Received: from pfbgu11.prod.google.com ([2002:a05:6a00:4e4b:b0:7dd:8bba:6394]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:80b:b0:823:1276:9a86 with SMTP id d2e1a72fcca58-82317e09c62mr3960900b3a.39.1769206549876; Fri, 23 Jan 2026 14:15:49 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Jan 2026 14:15:42 -0800 In-Reply-To: <20260123221542.2498217-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260123221542.2498217-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260123221542.2498217-4-seanjc@google.com> Subject: [PATCH 3/3] KVM: VMX: Print out "bad" offsets+value on VMCS config mismatch From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mathias Krause , John Allen , Rick Edgecombe , Chao Gao , Binbin Wu , Xiaoyao Li , Jim Mattson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When kvm-intel.ko refuses to load due to a mismatched VMCS config, print all mismatching offsets+values to make it easier to debug goofs during development, and it to make it at least feasible to triage failures that occur during production. E.g. if a physical core is flaky or is running with the "wrong" microcode patch loaded, then a CPU can get a legitimate mismatch even without KVM bugs. Print the mismatches as 32-bit values as a compromise between hand coding every field (to provide precise information) and printing individual bytes (requires more effort to deduce the mismatch bit(s)). All fields in the VMCS config are either 32-bit or 64-bit values, i.e. in many cases, printing 32-bit values will be 100% precise, and in the others it's close enough, especially when considering that MSR values are split into EDX:EAX anyways. E.g. on mismatch CET entry/exit controls, KVM will print: kvm_intel: VMCS config on CPU 0 doesn't match reference config: Offset 76 REF =3D 0x107fffff, CPU0 =3D 0x007fffff, mismatch =3D 0x10000= 000 Offset 84 REF =3D 0x0010f3ff, CPU0 =3D 0x0000f3ff, mismatch =3D 0x00100= 000 Opportunistically tweak the wording on the initial error message to say "mismatch" instead of "inconsistent", as the VMCS config itself isn't inconsistent, and the wording conflates the cross-CPU compatibility check with the error_on_inconsistent_vmcs_config knob that treats inconsistent VMCS configurations as errors (e.g. if a CPU supports CET entry controls but no CET exit controls). Cc: Jim Mattson Signed-off-by: Sean Christopherson Reviewed-by: Chao Gao --- arch/x86/kvm/vmx/vmx.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 7d373e32ea9c..700a8c47b4ca 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2962,8 +2962,22 @@ int vmx_check_processor_compat(void) } if (nested) nested_vmx_setup_ctls_msrs(&vmcs_conf, vmx_cap.ept); + if (memcmp(&vmcs_config, &vmcs_conf, sizeof(struct vmcs_config))) { - pr_err("Inconsistent VMCS config on CPU %d\n", cpu); + u32 *gold =3D (void *)&vmcs_config; + u32 *mine =3D (void *)&vmcs_conf; + int i; + + BUILD_BUG_ON(sizeof(struct vmcs_config) % sizeof(u32)); + + pr_err("VMCS config on CPU %d doesn't match reference config:\n", cpu); + for (i =3D 0; i < sizeof(struct vmcs_config) / sizeof(u32); i++) { + if (gold[i] =3D=3D mine[i]) + continue; + + pr_cont(" Offset %lu REF =3D 0x%08x, CPU%u =3D 0x%08x, mismatch =3D 0x= %08x\n", + i * sizeof(u32), gold[i], cpu, mine[i], gold[i] ^ mine[i]); + } return -EIO; } return 0; --=20 2.52.0.457.g6b5491de43-goog