From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 36ED22550D5 for ; Wed, 28 Jan 2026 01:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769564594; cv=none; b=Dn13+KQvph75vz6fuJBV08elkFTZO3QxcE9PlTkPeuSStl8V6tM1QDpev+SBsqsxonxRWVwRbUsYERxz/i0eUJl56+K4koRNyMCCv8R819oAAhi/va3JYEqrLxJ4MHAfnf8IRovu0wQj4QyNchFLtcJzEGzUKAhcVAkxAyI/4Ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769564594; c=relaxed/simple; bh=j0s1qIzuHKm1Dt5CuSHj15PHrJ3Ost58ZGpP/cKvDbk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=eTbj+jJmtaEogswsHFnGAT53EDEahblfREc5PDijv/IzREcdpmFQkAjpPONAcM9bp8o0ti8MKzOVdo3vuRStGfWCpPtulywDU2To1QrAxsywOFTR55AccT8IV7odrr1IL1slpqHN3U51zxd6whcMtdRi2HcjPVIcEZ3f1Ga4lJQ= 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=UCPC9bjb; arc=none smtp.client-ip=209.85.214.201 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="UCPC9bjb" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2a0e952f153so33845465ad.0 for ; Tue, 27 Jan 2026 17:43:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769564592; x=1770169392; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=vJtM9RKlKBtslM9posblyhDH9U56GZnbtFwtuNq2ynE=; b=UCPC9bjbs+4WHilB9klEFXlxC8y1XF1xD7GjEkXsGkP5JyaHzEsw3VzLuIn+YMlMoE dRLNBQn/WZWLgk59RIxc8rDf6WZ0nQOmCZSANuCf86cpBUMpdtODILINGdKbwN/gVEun wIW7dqzaLdSM76KQrFHO5QRKC7qjQUqj7gX0mjn2ZV1Cb6muzIZt6Wz+XraImR5fJYyM 0UuD9qhbrB8ypyQuXPHgPe4EqAzsRFpxd5lQNxFKeA44S+eYHXzJfDRyxsyMmDCnAW1L P38P4qRyAB3A4ld/ZBbR8DSQGE1R33T0VflKhwIs9QZL2WcbPt4wh1TIvO/8xKvcWvu2 +CEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769564592; x=1770169392; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vJtM9RKlKBtslM9posblyhDH9U56GZnbtFwtuNq2ynE=; b=rwPcs7eQ9EOcSuXzjCtV/gVQGFScoSTWj1Y58xd4wvXmvMPOG73o4EkjpDJiqawnR/ G60N8zVuFTt1sfAX8BBRjw3vRtKh3JL1lM0g8HLSEsiSaZBy5wio2jp5tSPeSIE9NPBM QVCi4B5cuEWaackAy35Ql0P3StCqXTSiyejydzHQhe7s6h1PC/i96UTxSnX+R5JB6m75 FZyuFOi+vSYd2m/XBtHACCvL4i4n5DdbFBLL/QYO2igBZIHwWnVzjSC3JETTje49t4ik gVptRs0uMVtukF8VHvvRFdGjPMwUod1XMM1ei7Qt6G8SZ2sYGtNX48xrm44Wt7Hni7se QOTg== X-Forwarded-Encrypted: i=1; AJvYcCXlUmOXUFB6LEL+nzdb7WN3GJuwidcb0LFIyITdfncWQbF0f3idz/NBI4sBUiVukPEAQuUVowx/35Bu+Dk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7ROlZOXQo9U8TcnJLOuYKOkcijc1NJAVjT4DOwGEGNTy/TDn3 cGggKzMBRl+kCS2TGagqbuw1HpH81HGHee0LlGcWcLCszBYOLe27PYqJXasmEUuAQbjEdtJKYWU /4NrUKw== X-Received: from pgbee1.prod.google.com ([2002:a05:6a02:4581:b0:c1d:2c61:149a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:8d:b0:366:2360:8f7 with SMTP id adf61e73a8af0-38ec628988fmr3941038637.14.1769564592551; Tue, 27 Jan 2026 17:43:12 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 27 Jan 2026 17:43:07 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260128014310.3255561-1-seanjc@google.com> Subject: [PATCH v2 0/3] KVM: x86: CET vs. nVMX fix and hardening 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-Type: text/plain; charset="UTF-8" Fix a bug where KVM will clear IBT and SHSTK bits after nested VMX MSRs have been configured, e.g. if the kernel is built with CONFIG_X86_CET=y but CONFIG_X86_KERNEL_IBT=n. The late clearing results in kvm-intel.ko refusing to load as the CPU compatible checks generate their VMCS configs with IBT=n and SHSTK=n, ultimately causing a mismatch on the CET entry and exit controls. Patch 2 hardens against similar bugs in the future by adding a flag and WARNs to yell if KVM sets or clear feature flags outside of the dedicated flow. Patch 3 adds (very, very) long overdue printing of the mistmatching offsets in the VMCS configs. Chao, I didn't include any of your Reviewed-by's, as every patch changed quite a bit from v1. v2: - Isolate kvm_setup_xss_caps() from kvm_finalize_cpu_caps(). [Xiaoyao] - Fix the pr_cont() printing. [Chao] v1: https://lore.kernel.org/all/20260123221542.2498217-1-seanjc@google.com Sean Christopherson (3): KVM: x86: Explicitly configure supported XSS from {svm,vmx}_set_cpu_caps() KVM: x86: Harden against unexpected adjustments to kvm_cpu_caps KVM: VMX: Print out "bad" offsets+value on VMCS config mismatch arch/x86/kvm/cpuid.c | 10 ++++++++-- arch/x86/kvm/cpuid.h | 12 +++++++++++- arch/x86/kvm/svm/svm.c | 6 +++++- arch/x86/kvm/vmx/vmx.c | 23 +++++++++++++++++++++-- arch/x86/kvm/x86.c | 30 +++++++++++++++++------------- arch/x86/kvm/x86.h | 2 ++ 6 files changed, 64 insertions(+), 19 deletions(-) base-commit: e81f7c908e1664233974b9f20beead78cde6343a -- 2.52.0.457.g6b5491de43-goog