Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A06F02D1F6B for ; Tue, 18 Nov 2025 03:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763436019; cv=none; b=cbcUHefwf7lJu1N9XQKgpCn3XHz/e62xM3Z7HFTbG7FWsoJoS+jDNsb2HFVhEA9dR9B0OwtCIOi7dGFsHu8kR0g1zdtPusgPRXLQZLoLPe2KRSzN9uFRENdLzj9dsSWkSeBQpKgb0UdEjv+5kAWModCMZZC2btFcpuSSzEg3K+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763436019; c=relaxed/simple; bh=e7ZuP6IJXLFF9a7BOtF/YskQsXWAUPGXOl3UUkfR6iA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CBNgtksUVh1sa7tDQuUeHmvUyQMmUYcB8IVQdhWiVOKVbNAp9ogXrXQBMTR1/etzYSlaA0pVEKOQ7UFH7aK+Fxl7bwB4ct5ijSeqC2uESTmOD1VCF4Ax+vJqGpN3Ch4kaqJxtcOIuxKU26Dk4ICsF5JVD8ScwHjEJ7pWLUfGy9U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=S8WlOZK4; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="S8WlOZK4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1763436018; x=1794972018; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=e7ZuP6IJXLFF9a7BOtF/YskQsXWAUPGXOl3UUkfR6iA=; b=S8WlOZK4xFnGnChV5bw23uKISGyibPMU89kAk9nP1sJvvXOp8EDd4+G3 6tusLK/Rn8vwtg0wO5bV0clsDeGW0y1YgVl7ENxFzhh6WrPOdnMZDEAtZ OMTRlNo3ieSpj5x/QrLAiOAFk3RdNdOCNyTw7sYJeiKhJyMP6RwNBiqwQ h6rRWNqDth+76NTTQ7VbTXM+v9WiVI+RavFZFPgaTsKhKfgV528WzhmJ2 9Zq5RjZc0E2BTfx8j2X2TN6yqnLPOvAxojsrRN95ucPsSGZo/uETdo2UE gdZPsHKi8HPLEQ/LjsXQn3B51X/wmCe4o69YnE50fPlB5r16cjDam44xK A==; X-CSE-ConnectionGUID: mRh/8Px8RMyD2/kYe0V+UA== X-CSE-MsgGUID: 2M6BLI9QTLaka8TsFTL0pw== X-IronPort-AV: E=McAfee;i="6800,10657,11616"; a="68053714" X-IronPort-AV: E=Sophos;i="6.19,313,1754982000"; d="scan'208";a="68053714" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2025 19:20:17 -0800 X-CSE-ConnectionGUID: EV1Ij9I/T+OobmynnrHDpQ== X-CSE-MsgGUID: ymzuKz1cSNW2o8WJr2gSKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,313,1754982000"; d="scan'208";a="221537123" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by fmviesa001.fm.intel.com with ESMTP; 17 Nov 2025 19:20:13 -0800 From: Zhao Liu To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chao Gao , Xin Li , John Allen , Babu Moger , Mathias Krause , Dapeng Mi , Zide Chen , Xiaoyao Li , Chenyi Qiang , Farrah Chen , Zhao Liu Subject: [PATCH v4 00/23] i386: Support CET for KVM Date: Tue, 18 Nov 2025 11:42:08 +0800 Message-Id: <20251118034231.704240-1-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, This the v4 series to support CET (CET-SHSTK & CET-IBT) in QEMU, which is based on the master branch at the commit 9febfa94b69b ("Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging"). And you can also find the code here: https://gitlab.com/zhao.liu/qemu/-/tree/i386-all-for-dmr-v1.1-11-17-2025 Compared to v3 [1], v4 mainly considers pl0 SSP MSR for FRED, and fixes migratable_flags for FEAT_XSAVE_XSS_LO. More details, pls refer Change Log in the following. Thanks for your review! Overview ======== Control-flow enforcement technology includes 2 x86-architectural features: - CET shadow stack (CET-SHSTK or CET-SS). - CET indirect branch tracking (CET-IBT). Intel has implemented both 2 features since Sapphire Rapids (P-core) & Sierra Forest (E-core). AMD also implemented shadow stack since Zen3 [2] - this series has considerred only-shstk case and is supposed to work on AMD platform, but I hasn't tested this on AMD. The basic CET support (patch 12-20) includes: * CET-S & CET-U supervisor xstates support. * CET CPUIDs enumeration. * CET MSRs save & load. * CET guest SSP register (KVM treats this as a special internal register - KVM_REG_GUEST_SSP) save & load. * Vmstates for MSRs & guest SSP. But before CET support, there's a lot of cleanup work needed for supervisor xstate. Before CET-S/CET-U, QEMU has already supports arch lbr as the 1st supervisor xstate. Although arch LBR has not yet been merged into KVM (still planned), this series cleans up supervisor state-related support and avoids breaking the current arch LBR in QEMU - that's what patch 2-11 are doing. Additionally, besides KVM, this series also supports CET for TDX. Change Log ========== Changes Since v3: - Fill CPUID 0xD subleaves from KVM CPUID instead of host CPUID for non-dynamic xstates (i.e., except AMX xstates for now). - Save/restore/migrate MSR_IA32_PL0_SSP for FRED. - Fix migratable_flags for FEAT_XSAVE_XSS_LO. - Refine commit message for CET TDX support. [1]: https://lore.kernel.org/qemu-devel/20251024065632.1448606-1-zhao1.liu@intel.com/ [2]: https://lore.kernel.org/all/20250908201750.98824-1-john.allen@amd.com/ Thanks and Best Regards, Zhao --- Chao Gao (1): i386/cpu: Fix supervisor xstate initialization Chenyi Qiang (1): i386/tdx: Add CET SHSTK/IBT into the supported CPUID by XFAM Xin Li (Intel) (2): i386/cpu: Save/restore SSP0 MSR for FRED i386/cpu: Migrate MSR_IA32_PL0_SSP for FRED and CET-SHSTK Yang Weijiang (5): i386/cpu: Enable xsave support for CET states i386/kvm: Add save/restore support for CET MSRs i386/kvm: Add save/restore support for KVM_REG_GUEST_SSP i386/machine: Add vmstate for cet-shstk and cet-ibt i386/cpu: Advertise CET related flags in feature words Zhao Liu (14): i386/cpu: Clean up indent style of x86_ext_save_areas[] i386/cpu: Clean up arch lbr xsave struct and comment i386/cpu: Reorganize arch lbr structure definitions i386/cpu: Make ExtSaveArea store an array of dependencies i386/cpu: Add avx10 dependency for Opmask/ZMM_Hi256/Hi16_ZMM i386/kvm: Initialize x86_ext_save_areas[] based on KVM support i386/cpu: Use x86_ext_save_areas[] for CPUID.0XD subleaves i386/cpu: Reorganize dependency check for arch lbr state i386/cpu: Drop pmu check in CPUID 0x1C encoding i386/cpu: Add missing migratable xsave features i386/cpu: Add CET support in CR4 i386/cpu: Mark cet-u & cet-s xstates as migratable i386/cpu: Enable cet-ss & cet-ibt for supported CPU models i386/tdx: Fix missing spaces in tdx_xfam_deps[] target/i386/cpu.c | 256 +++++++++++++++++++++++++++----------- target/i386/cpu.h | 110 ++++++++++++---- target/i386/helper.c | 12 ++ target/i386/kvm/kvm-cpu.c | 23 +++- target/i386/kvm/kvm.c | 117 +++++++++++++++++ target/i386/kvm/tdx.c | 20 +-- target/i386/machine.c | 78 ++++++++++++ 7 files changed, 501 insertions(+), 115 deletions(-) -- 2.34.1