From nobody Sat Feb 7 08:07:35 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 BFCFA257844 for ; Wed, 28 Jan 2026 01:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769564600; cv=none; b=AvZOOhWtHgX+MLENuK+qzIhcYcOKpGqByT0Zr+rGU0AB9LfTUfQehePP1qgDbCyAWjxEOnCl9/AfZz9AIk9RhI2+Gs7G9QMxNKjY6NFUDKhq47T9oOQrZwoJQHZ0Z4eGCGutoLhUqoghlyOcoQ74XESKiZRcJ6zQU0Q8Rr3VG5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769564600; c=relaxed/simple; bh=4El7qL7PVPZa0aprqlCvyq41SKfmYL6SM5DDRrMwQkk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gEXk04HsfzaZRh7qk43WckBcS56D9R2MMz+U/Ucy2fqZywnouJ3V8OeQnl6fF+/ZS7U4UZCuQML+2yDWzz44kKVT6aJI0WMSKX1QjrdCzc0Ke3+Ptc32JGYwfvuRugS1zNfGn1XiydYif9+n38J3xV/lIEcb77NFSu6TOBJuyxA= 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=HYfuDvbo; arc=none smtp.client-ip=209.85.216.73 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="HYfuDvbo" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-34ab459c051so12240443a91.0 for ; Tue, 27 Jan 2026 17:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769564598; x=1770169398; 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=EsE5fDwgRpoSCOUNzOT/fBkqra7ip2Uh79gr2v+01xE=; b=HYfuDvbodAz/bNo070L71s6v0EibEE5YcvqyoNHPdIo4PhCsUO68vYlk1Lmck+nET8 lLnWY6gKlVGqWuIkDZF48VZuHc3bc5Sk8UweL6rDudrceQuKIYTkxwYQYXlOdz5XKsFu 7NAm3gYkYfDSGIgzYqHRpuy4VmzX7/ZEgmSh4J6Q66Zwza5g5ojSrPp5hkXWYta88Sur Y7D/8YQozg7M3bJ3RpwwvsmFkbtZyrE16IHKwcRN0JYszhfH5WapGBGDN8/+CbhTXXi4 fyGSgBCHZw7AniBPY/AAX1hlojPoSCH+igkl6dR1/0Lf59fPq84oloKN+DbnC0j4GBxA QlFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769564598; x=1770169398; 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=EsE5fDwgRpoSCOUNzOT/fBkqra7ip2Uh79gr2v+01xE=; b=mSEE1sgJ4CUnwaioFW3MY5MIfBGq4YoSXahYUqaqOgyzguYQ7bfFJwY3o//uaJGzXh IDdr8WO2KXhXslhhKpvKn1AUeDkiQ2WeJSj+qko/C3rBxRFl0gbProCuDsHScgrgSPN0 FeG3DZObA44bp8AjLgnliH+Of9pMXnO59o9DufjsphedaAjqWOeh0seMMzQnY5t4lZ1K myzdSFD9j9xR4mjE8xVRm5LwN83ZYlestvEmv/u4aiv7DXglu8NsZnu96NbWZbRsOb/5 SuUO/isodzCsg79Gk/TOENBa5vKHQbuQu+OQzFj2OuK/LRGLIIPp2OPwnWorOO8PvwsZ WQ7Q== X-Forwarded-Encrypted: i=1; AJvYcCVGoA1G80+ry488QoUK2WjApZzdcp2dLVN82Pqvrb+B3FfdCp1P+xo64tKB+OgaKOnugYLOJlAVwCohLag=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+8w99v6MR2UALY/8wDiB1FvCHXqPeNe9n97oYWGllHoF1E3at 5sElaWTDUiQ7zBIX+L/GDVCL+LBBeZnAju1a6WcZVMCQg/5kcXFBksP6V5k0s4ntIbE5yaTyDeu 78zQ5rQ== X-Received: from pjrx13.prod.google.com ([2002:a17:90a:bc8d:b0:34c:811d:e3ca]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d404:b0:352:bd7c:ddbd with SMTP id 98e67ed59e1d1-353fed846d8mr3252257a91.23.1769564598099; Tue, 27 Jan 2026 17:43:18 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 27 Jan 2026 17:43:10 -0800 In-Reply-To: <20260128014310.3255561-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: <20260128014310.3255561-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260128014310.3255561-4-seanjc@google.com> Subject: [PATCH v2 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: Binbin Wu Reviewed-by: Xiaoyao Li --- arch/x86/kvm/vmx/vmx.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 93ec1e6181e4..11bb4b933227 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2962,8 +2962,23 @@ 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:", cpu); + for (i =3D 0; i < sizeof(struct vmcs_config) / sizeof(u32); i++) { + if (gold[i] =3D=3D mine[i]) + continue; + + pr_cont("\n Offset %u REF =3D 0x%08x, CPU%u =3D 0x%08x, mismatch =3D 0= x%08x", + i * (int)sizeof(u32), gold[i], cpu, mine[i], gold[i] ^ mine[i]); + } + pr_cont("\n"); return -EIO; } return 0; --=20 2.52.0.457.g6b5491de43-goog