From nobody Sat Jul 25 04:53:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 76BA539446B; Fri, 17 Jul 2026 21:44:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324681; cv=fail; b=NsuacNiCpO4rktUALBpYB2Rh3K3rujVeI6/8+AJWZ4OAKdVMXeHAo1tOyyLxCSNG/LTNJiVYj9Vi2qUwQpKg39dXN4Aox0f4bD1OGwCHJQneGlTtmnTCeV5Fz8OF+655rwXeU/dECd395t2hZPJANJPS3Ogn1z5O+xxV62OKies= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324681; c=relaxed/simple; bh=0sDq6vyH4eOOFzyn6+paGhgU72x7Rc3AiJXffLYIC1g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=aL0FcbL29ovF+IVenrRYKQPjKi3gTzuTG6bNa3Zf4scdEj8LO//xEvHlExlFsTawAx2sa0WTvUzvz5x2Yc4OPe44cmJG5KgCv4b9VdyXdG7Onv1JCZJ5wsGK4/pAEJ9hZ7DLlE7EYdaCQXg3nSLaXSDFIxkg0N+doncsNYkBNYs= ARC-Authentication-Results: i=2; 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=BeGI70K8; arc=fail smtp.client-ip=198.175.65.16 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="BeGI70K8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784324675; x=1815860675; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=0sDq6vyH4eOOFzyn6+paGhgU72x7Rc3AiJXffLYIC1g=; b=BeGI70K8RfeNDnI1MtBfA/Q6udJ5o8wxjkK84pjihO3DI/l54oTlAMSt QbofXwZijVd0tcGeZqaYqtYMdwzQ8kUu6TE9v9WfyvgfLY+jgi7DQ/oij dmNGc80XuVyNBkyepAscc8dBdbPWNdQteGJqA3dbuJxofOhu1z66ZCVpi NH23t+/iRP+TK1r2u+plrhoXlVPtBuRCNn9YLVPACk6WXnoF6aYOub8kx C4uPxENDP0cTFXkzhWL13hZsQgBQFvDppCwrQbI4ri/ULqUP+tTxog6q4 VvnHG+aFhQhw+i89YX1avwEz95kO6aDhBvrX0+nWfUR8tlkKaCyn9TmlB g==; X-CSE-ConnectionGUID: AVYpaJMJQ5+ug0gpmJ3fBw== X-CSE-MsgGUID: EVTYKH2jQb6Je1Eivs8hew== X-IronPort-AV: E=McAfee;i="6800,10657,11849"; a="85201763" X-IronPort-AV: E=Sophos;i="6.25,170,1779174000"; d="scan'208";a="85201763" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2026 14:44:31 -0700 X-CSE-ConnectionGUID: 9Dhl4UEwS8qqTnEjRyvAJA== X-CSE-MsgGUID: 25B7OvnbSHWItKSo9tCDBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,170,1779174000"; d="scan'208";a="255720255" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2026 14:44:30 -0700 Received: from FMSMSX902.amr.corp.intel.com (10.18.126.91) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 17 Jul 2026 14:44:30 -0700 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX902.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43 via Frontend Transport; Fri, 17 Jul 2026 14:44:30 -0700 Received: from CH1PR05CU001.outbound.protection.outlook.com (52.101.193.4) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 17 Jul 2026 14:44:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NtXeuExi6vQL1AyhkgD5q7e2G8VrZ8UrygluHvPzHUiPlhh6KmSTtibmv2vHTgMDQBMnw1z2wPkFR+a/Bweuv1sIE1uQK2UYaC0cb3yKkr1g35whbO3Bggoaq/MvnH8ZHWqse93pgUl24Bh7sNGH1x4yK8Y4uap61PxpGvIylg9I0+VTWsHo6Cc79Gs11CZAAViHDZyVTc6wlLiq3iuh6KNrVAAtx+UV5yxC1ndVtnbkBzLfaw1nSMoZwORVlggmmx57nMM0pz89fGZOjEf6xaT1726KqTDOgdrdiYYfTSoNgERRDPJICJ5MmKzKs71KrxFzTZeCjyc+8oCtn7IlCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C2Bric1CtwvThvUfIyHBRZkdgKKy9dxd02UePg7BtQg=; b=n2rOl83s5hNVQHmDkM1tQ95VqwFTCb62srFGTgX1i0Qo+VRJslH1T3nwVA1/H0bL9ilPqY7IDMn/UlBgY9rFN0yAPefvCSSIAhHGQxyr0RRCW/iI8/KGikhkHzmEi+G0/H7qybx3pA9li7Pe2vwWmi1kinFi5aImVmCAEtm1tLWGTvNTVtOcgvUg5y73IrbpK1MqX+Acsuu6DgAy1DwBDqbpp54+DwUV1zg/aud0VPu9CtbQwWDsSS/7A5xIY/zC8tbZei12BcaG+S/vkJ13J73atkyjKIzH5BFJXYkrKpc15d78J4aDG5uXzAen+esZUeQDlNWW2XkO1yolIJSasA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB5645.namprd11.prod.outlook.com (2603:10b6:a03:3b9::19) by DS0PR11MB6541.namprd11.prod.outlook.com (2603:10b6:8:d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 21:44:26 +0000 Received: from SJ0PR11MB5645.namprd11.prod.outlook.com ([fe80::fb19:f933:8bb3:b42e]) by SJ0PR11MB5645.namprd11.prod.outlook.com ([fe80::fb19:f933:8bb3:b42e%4]) with mapi id 15.21.0223.012; Fri, 17 Jul 2026 21:44:26 +0000 From: Peter Fang To: Dave Hansen , Kiryl Shutsemau , Rick Edgecombe , "Kuppuswamy Sathyanarayanan" CC: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , "H. Peter Anvin" , , , , Xiaoyao Li , Binbin Wu , Peter Fang Subject: [PATCH v2 1/2] x86/tdx: Add helper to query maximum TD Quote size Date: Fri, 17 Jul 2026 14:43:11 -0700 Message-ID: <20260717214349.4075994-2-peter.fang@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260717214349.4075994-1-peter.fang@intel.com> References: <20260717214349.4075994-1-peter.fang@intel.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To SJ0PR11MB5645.namprd11.prod.outlook.com (2603:10b6:a03:3b9::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR11MB5645:EE_|DS0PR11MB6541:EE_ X-MS-Office365-Filtering-Correlation-Id: 336ca6e6-a8b5-4f98-d865-08dee44c92ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|23010399003|366016|10067099003|56012099006|11063799006|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 6nxbOp87/kGmGL1mTCSzWcRJpYSnXoXHlfTqNzQzxisB5Blm2iHEdLbBOcrfCGtYQUo6RUq08snrKvrgW5IGr9FIm3YqaLOJChIbY79wauH/oCJuK1+983zb/Qlk1P0L1oCEtcMArNKYMVcVtVDqJzbDShGH6m9Wx0+rZcG/f7UvWJDebLKrVpJpWfHwRWIMHIhcUzAfnEo1ySVAVinpEVLGljoS9NBi5hoCWx57bWDzbKdBkzt7sf26Cc1BN053zUtv4dwrT8Ej6/l+QQD7WRya7L2A6a/KwwtUg0d38KhVQ+xx7Q4pdNRC9MxVDyz0vdiMX4x0Mgw1KMeRArvG5iT37EdOMbKsCBOSyH6zE2cy7aGQOVhsSg7F4WGDwg9Ue0cmj0XVU9DAtyQ7lhuCm7X9uHyzpwaXvCbTUhH5RvDFSl4yNFry1zFxlYcxdLeGZ5Oi2cUWOhzBnq/Bcfar+WcuTZvO65bryOHOsj2+4mB3iqw5eT3E51gKIwOmqMvacOcJJsD5SJeVZYjvn9Rjj0hfGFGU0tv/Yn9LYxCntOgxucvI+dcK4J6eQRG/2YB28vqe8zLKPcWnsFEtxDFVu/kNPYPKeA/eUMiIZAhpS8PnuxQmYK5iwLh43rGPhVPwIchSzL2PnkDOzswiM5MYa0Bu7kJsrGDpeCpsn4dzkQg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR11MB5645.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(23010399003)(366016)(10067099003)(56012099006)(11063799006)(6133799003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aOXCUtHAbkyGMkPL2XK2jz/WAg6Pk31uTqatqBS3R85x0ZdvgGim6SJeVEpM?= =?us-ascii?Q?o5AJZW0fYSGgFMRYfLNrTmPD7Lx8ZRMa/2PHZ9ogwNuvLB9GsCEoviL+4HjA?= =?us-ascii?Q?Dp9a8nadu+lNEDBRCE5zuNI3pbi00R08emQoEebO1GRgqsV8RwSx19yo73E5?= =?us-ascii?Q?4ZQPQzqxZdvulNRe3aCtVRN/IvLdfOpyYm/xyEeV7XP84FVLXfOItuW6QsuQ?= =?us-ascii?Q?vknHZuCOT9DrtpQlOAuys3evRbLpTkpodlhfzm71qBmKJIQUQcVBmREDdC3h?= =?us-ascii?Q?dlolcnjN5mOwyUcOVB7BTulRwb+tXERNlrDTiqS3x7AWqj2dDWtP23c8NAC7?= =?us-ascii?Q?O1JEe7VQjoAC6YXxB+eTfnwIjVrRe6tTJyqjmrJlrHy1KTAx+XwacOcwmEMj?= =?us-ascii?Q?ghaRtm1CeaIE8SiN+vM742ujANW9LcDr7rrm1O38v9U+ofLBlksnF8XJMWTn?= =?us-ascii?Q?nuED3nxPZkXT+Ot9u61VH3C5QGlN7jBCucMgwFB2ur9gsB9bULrzO9crGYx9?= =?us-ascii?Q?0hf+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FruTb9bBdG1?= =?us-ascii?Q?DIdSCLHqJB1Umf/SezlVg79saOAXBAv/9XvUgaxgBhrqL5Fi66Db4lWnF7ze?= =?us-ascii?Q?OqzwQMmGzCUGycxXoNF8YmbyQa9dOM4V2VA/PcO2+KGKr53WJ0v/EByuMPBq?= =?us-ascii?Q?aGF7Axr5+VWTIz3ZV4kopmzfH3W6puQ2SqaZFpJYDrt6TuSj5IMHzOL36PS7?= =?us-ascii?Q?E7k6i/tgoJIsBrg4uCHVldZuJaVaW2ddWUz3z9EuDXSIS9k3lJF6l+NsWR3j?= =?us-ascii?Q?Usc1QctoK++D5WaWXXHuGigJbiFxpn9B5BN74rntLU42ChGjZhOCBx3PNhFA?= =?us-ascii?Q?fQkU8NrYkQ=3D=3D?= X-Exchange-RoutingPolicyChecked: HWzcVs4UPQNUcZP23NXijyK/5mh5mwKVMQQzfMPkJ4w1YfwPQlP3SiFBE6mdUsmnDRHKozrpys+XQE2Th5hka5v3EuNZ/IBywg6W0yOAgauG9uB9WjCmjUEQKpDUY+omjO9snCOQGLVq+EKZM+xGt03tt9JCVFXe5TD1JYaM6BJQfeDUwJEHaeaECp06Xhi+60mra84KqfE61kp0pHMPwl8hgBra7sksBpxl2BA+iO/eVI3ckSXifuEjpmF8vAvZ2lSEkizzQt56Z/SOhYpGXXVYfCHNGERrZ1As1H+hu12NaWDbt6xput8WQQARqnazP9wVMn2Y5J//WPf67h/56w== X-MS-Exchange-CrossTenant-Network-Message-Id: 336ca6e6-a8b5-4f98-d865-08dee44c92ac X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5645.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 21:44:26.4225 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Gi93RnBaN+xb3078cpFfSZZVwJx5wOF7sXrkHDAK+gCU9a0yKF7cPOldlmFibjt9SDHEfCTb/NOeSghLO79qow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB6541 X-OriginatorOrg: intel.com Content-Type: text/plain; charset="utf-8" TDX attestation report ("Quote") sizes can grow with newer cryptographic schemes, so guests can no longer rely on a fixed-size buffer for the Quote. Newer TDX modules report the maximum Quote size via a TD-scope metadata field. Add a helper to query the size instead of exposing tdg_vm_rd() directly, as it can read arbitrary metadata fields. Thanks to Xu Yilun for suggesting this in an off-list discussion. Reviewed-by: Kiryl Shutsemau (Meta) Reviewed-by: Xiaoyao Li Reviewed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Peter Fang Reviewed-by: Binbin Wu --- v2: - Keep the explicit (u32) cast to document the metadata field width. [Binb= in] - Note that Xu Yilun's suggestion was made in an off-list discussion. [Sat= hya] - Drop the Assisted-by tags, as the code was not written by AI. --- arch/x86/coco/tdx/tdx.c | 19 +++++++++++++++++++ arch/x86/include/asm/shared/tdx.h | 1 + arch/x86/include/asm/tdx.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 29b6f1ed59ec..fa2ed012e736 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -198,6 +198,25 @@ u64 tdx_hcall_get_quote(u8 *buf, size_t size) } EXPORT_SYMBOL_GPL(tdx_hcall_get_quote); =20 +/** + * tdx_get_max_quote_size() - Get the maximum TD Quote size + * + * Read the maximum size of a TD Quote from a 4-byte TD metadata field. Th= e TDX + * guest driver uses it to size the buffer for Quote retrieval. Older TDX + * modules do not support this field and return an error. + * + * Return: Maximum Quote size in bytes on success, or 0 on failure. + */ +u32 tdx_get_max_quote_size(void) +{ + u64 val, ret; + + ret =3D tdg_vm_rd(TDCS_QUOTE_MAX_SIZE, &val); + + return ret ? 0 : (u32)val; +} +EXPORT_SYMBOL_GPL(tdx_get_max_quote_size); + static void __noreturn tdx_panic(const char *msg) { struct tdx_module_args args =3D { diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/share= d/tdx.h index f20e91d7ac35..a58751321613 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -50,6 +50,7 @@ /* TDX TD-Scope Metadata. To be used by TDG.VM.WR and TDG.VM.RD */ #define TDCS_CONFIG_FLAGS 0x1110000300000016 #define TDCS_TD_CTLS 0x1110000300000017 +#define TDCS_QUOTE_MAX_SIZE 0x9010000200000008 #define TDCS_NOTIFY_ENABLES 0x9100000000000010 #define TDCS_TOPOLOGY_ENUM_CONFIGURED 0x9100000000000019 =20 diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 89e97d5761d8..a75dbbe004bd 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -83,6 +83,8 @@ int tdx_mcall_extend_rtmr(u8 index, u8 *data); =20 u64 tdx_hcall_get_quote(u8 *buf, size_t size); =20 +u32 tdx_get_max_quote_size(void); + void __init tdx_dump_attributes(u64 td_attr); void __init tdx_dump_td_ctls(u64 td_ctls); =20 --=20 2.53.0 From nobody Sat Jul 25 04:53:31 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 AA122395AED; Fri, 17 Jul 2026 21:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324683; cv=fail; b=G3iiT9qXyytSK0lhjn8I/Lfv9z2//2Y6NRPCAlPqcD8oKKA8CdHHyz05Ayq0GmEYvDf/4INWtmCQRWjFzKeFnZdqet5LqcC3btMmmcwDLRA4uEvOiUWxcSKkZKoPFPttARMDSlCzMvz/IQuG0MAyngx91R17RWzCXqSx+sQ6QA8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324683; c=relaxed/simple; bh=Xqn0je3Z8D9qo8RLkkHH9IMJk24CatgIXy7cu2XbBfA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=dqfBhRSEi3orEaIqmbdgozUFa8kkZ1de9aVILWPxXlZR3Nz9V/EEXjIHOYb+DHez/Vhl2GSzeJoXiIOvmxihb/3tNmYvhOiVq8NJzgswxbT2jfB2WbY8pW6gHWdn/maP2Ns9FLIe7Wsi/11PrpJeKId3lHhEwj0Ll3gZCEQWUB4= ARC-Authentication-Results: i=2; 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=gJvp65tW; arc=fail smtp.client-ip=198.175.65.16 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="gJvp65tW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784324679; x=1815860679; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Xqn0je3Z8D9qo8RLkkHH9IMJk24CatgIXy7cu2XbBfA=; b=gJvp65tWOf0Q7RM/xsRZ4p8CKbnCE8VNUBMZYLTGILs54RIj7RL+sRh8 uAhlLwl3eTxeT50zf2gjUnIIU5hKcxTVnO2H0Sed8fNaZjKDgZH4BsKgK KoYtO7rn/6rbPhh5VjdkpWRgibblebVT35V9r5BPQpcxonK4BOBGluDre ejXHPQZtS/yCPoBbn6xlYJces9m/zWrFFmw3jDJDMHqirfMnaiutbPbQ9 ArPiKlPOyRkpD2DaafzPsr1iBkRfTtLsimti8otoLaRnn1t+7lJmm4S8P jvRO0aHYOv8TYMQ7cZd1OCH9kL/N2wc0+wa4QM4FD4FUJ7WgfA0VESWyN Q==; X-CSE-ConnectionGUID: yNOkfZ/jTtmbE6G9cIIMeA== X-CSE-MsgGUID: VMCKH2BsRtiSX6Zv3ULJeg== X-IronPort-AV: E=McAfee;i="6800,10657,11849"; a="85201770" X-IronPort-AV: E=Sophos;i="6.25,170,1779174000"; d="scan'208";a="85201770" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2026 14:44:32 -0700 X-CSE-ConnectionGUID: Z1ARqyysSNSw3Qi33GSCsA== X-CSE-MsgGUID: yyAskRuNT2OO9wQ5RQZTCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,170,1779174000"; d="scan'208";a="255720258" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2026 14:44:32 -0700 Received: from FMSMSX902.amr.corp.intel.com (10.18.126.91) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 17 Jul 2026 14:44:31 -0700 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX902.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43 via Frontend Transport; Fri, 17 Jul 2026 14:44:31 -0700 Received: from CH1PR05CU001.outbound.protection.outlook.com (52.101.193.4) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.43; Fri, 17 Jul 2026 14:44:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yuLeyba4WR9edN458tuxsoHldRZadGsxgZbbS7WvcQ0va11mzDMxl5ku+AEQOrhQkueO/BbbAa5t4QMam3CRDz4CEtsbhBSorvQhLA6Nr3QVBfLgtr22LR7mTQ/yIsfzmUUM24g8lNcZjBWqM22f/xgnUjzWDMuryCu05wzz3yJz2IS2WD+sFZsISLsiAlsmxKWRxf0fZJOLK4puQeZJmtXtl9kuz0u+/ifBWJCsSEUZ33QAEg3IHjZRpqCTeaH5pQkZywwLuatTTp1EgAaxiL4jeac0r2rR0y3SstEuREYtmjsE+zqSJd21KcQkVIWpVk/CFxHL2/ux+csPKMdl4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r/s6fsslQzdczx83jXRzdCWaojr6VSFC5T4H6AzYqnM=; b=AetDf7bAiINuWM6vC/zwaG35kQuZr+3CHLF2HhVbRClyVKaSOoIn7XLiGjX3ROfoQX9m3/J0oTFJEGqNyiYcQI3tsGGGT4kYaORpuOm/wUO9baK6RjLtuca7zIOQ6eVvk2UG/hRqC7q/opmVwwVxMqNIY5RPt5bERG/iBDoa2Ojnh69AqVEbURA+whWrN66dz9h2Cu3qLtXvXSlV19as4ymyzB1JUJAZCJC8g4sJVSkvjYJBTXfWRaNUlZAgsVbBdqeNFrQGnwD3lKrd/Tlr7o4nltBLfcBq+bWD+KhvFKFxif4br9+epziv9B47Gxn8aqyYeScx70mELT4c66t8cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB5645.namprd11.prod.outlook.com (2603:10b6:a03:3b9::19) by DS0PR11MB6541.namprd11.prod.outlook.com (2603:10b6:8:d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 21:44:27 +0000 Received: from SJ0PR11MB5645.namprd11.prod.outlook.com ([fe80::fb19:f933:8bb3:b42e]) by SJ0PR11MB5645.namprd11.prod.outlook.com ([fe80::fb19:f933:8bb3:b42e%4]) with mapi id 15.21.0223.012; Fri, 17 Jul 2026 21:44:27 +0000 From: Peter Fang To: Dave Hansen , Kiryl Shutsemau , Rick Edgecombe , "Kuppuswamy Sathyanarayanan" CC: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , "H. Peter Anvin" , , , , Xiaoyao Li , Binbin Wu , Peter Fang Subject: [PATCH v2 2/2] virt: tdx-guest: Allocate Quote buffer dynamically Date: Fri, 17 Jul 2026 14:43:12 -0700 Message-ID: <20260717214349.4075994-3-peter.fang@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260717214349.4075994-1-peter.fang@intel.com> References: <20260717214349.4075994-1-peter.fang@intel.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To SJ0PR11MB5645.namprd11.prod.outlook.com (2603:10b6:a03:3b9::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR11MB5645:EE_|DS0PR11MB6541:EE_ X-MS-Office365-Filtering-Correlation-Id: f12346e6-af95-40fa-b564-08dee44c9306 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|23010399003|366016|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: nTCvVnZmmdX695EuBQPeQPXBRG8XkgRk2qzJiQ2wjS7JzNjOLJmb//l8mjrwBUoqBAmq7p+GVqhC15PrD5PiMWfvdyO8m+tuKPGdgxcI0mf8WgwRSkVuyiD+YECZ5BG1VrwM2i/chmRrEwxe+ey3bJCwcZDoEXTd+tgPefhpfC20eADj/ejr8dY0BxEz7RCiIZvwznV+gGxB56B0+HGK98O26ndxJFDnDNWAposU4qcD2OAkaErtjPOOwVptyCG/pDVG59S8ey5qJIlMIgz8K34bGFNfzbKnO7pFcGklAKVO9Us+kTSYM2NWrb4sKeW9lXqTANgMTxQltHOl3BfA0QMOFFnkWFOcNrPyvF8CPNUWnCK8kKafXAbTvH1rt3rdKn5JCCEKR5QNy98i1/0c8iAEWU384YACKdwfKqB5xLwz5oNy4vPFbQ1LzY/U9KencXrTTO6n7WIzMSXLI/W7/k8OsosZHFXKeeW/cmKSXmuhthzdh9gahGNFA2OVZwSf5HtAjl71TrUcBOKP29kD3mGvQGnsLQNAjvchfl6k6Qj0sPXC6ORTdqhTEvhN1R5bKR2orAxlsHtED55ga+usQB/UMUEvN7K0jnX87NdXiZAraPfuWbW9paJ0t9H+2rVI6l1GtoEIQLlXKV92WAw36XUN16UmwdVAoG//uHd3Lk8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR11MB5645.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(23010399003)(366016)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =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SsQ=3D=3D?= X-Exchange-RoutingPolicyChecked: o8zuk5FwlwkaHFl6vO5wQCv0Qm6SDyOos8hoJz0NZL3G0HeAT8whOhFOJDM4YOFG53JZZUUV/QIiCpKiUv8fDojhlo0h+KUrUgkwyG5HISS4IiSCuokseXrSPIDQz3MgqEQmthxoKIdmslLZRiXHwiiV3VxERkrKQrNC/x7fYIeWL024W4FsZO1Cw+pC9+7nQp/SWsbzrwn2JbTsPjmNc7SdPVN+DNpIQYCMGO5ENYYyyq/J+3QVaQ/+PjotZ2sHe4QXcd48jE+g8amDr30qSA06Ot5l6Nx12YULmzTQAtnEehKrStKl1hqA+Xsk1KwkBU56cNltWCXOvac4n+z3zg== X-MS-Exchange-CrossTenant-Network-Message-Id: f12346e6-af95-40fa-b564-08dee44c9306 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5645.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 21:44:26.9804 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IX5wzc2lN/eDqrp2h3FRwj08sbnUBvuTNhIFsG2VfZOLVFgEz+W+wkH9lk2LHE0EM50EXiBnmWvjzg+MspIriQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB6541 X-OriginatorOrg: intel.com Content-Type: text/plain; charset="utf-8" From: Kuppuswamy Sathyanarayanan The TDX attestation driver currently uses a fixed 128 KB Quote buffer shared with the host VMM. This may be too small for Quotes using schemes such as post-quantum cryptography (PQC), where larger certificate chains can increase the Quote size significantly. Allocate the Quote buffer based on the size reported by the TDX module instead of always reserving a fixed-size buffer. This avoids wasting memory on platforms that do not require larger Quotes. Older platforms fall back to the default 128 KB buffer. Because the Quote buffer must be physically contiguous, its size is bound by the buddy allocator's maximum page order (4 MB), which should be sufficient for current attestation needs. struct tdx_quote_buf has a trailing flexible array, so use struct_size_t() to calculate the buffer size. Signed-off-by: Kuppuswamy Sathyanarayanan Reviewed-by: Kiryl Shutsemau (Meta) Reviewed-by: Binbin Wu Signed-off-by: Peter Fang --- v2: - Use struct_size_t() instead of offsetof() to compute the buffer size. [K= iryl, Binbin] - Pass __GFP_NOWARN to alloc_pages_exact() so an oversized size fails quie= tly. [sashiko] - Reword the description to avoid implying Quotes can exceed the 4 MB limi= t. [Binbin] - Rename quote_data_size to quote_data_len. [Sathya] - Drop the Assisted-by tags, as the code was not written by AI. --- drivers/virt/coco/tdx-guest/tdx-guest.c | 55 ++++++++++++++++++------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/td= x-guest/tdx-guest.c index d0303e31e816..ce2c2ef74676 100644 --- a/drivers/virt/coco/tdx-guest/tdx-guest.c +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c @@ -162,7 +162,7 @@ static void tdx_mr_deinit(const struct attribute_group = *mr_grp) * DICE-based attestation uses layered evidence that requires * larger Quote size (~100K). */ -#define GET_QUOTE_BUF_SIZE SZ_128K +#define GET_QUOTE_DEFAULT_BUF_SIZE SZ_128K =20 #define GET_QUOTE_CMD_VER 1 =20 @@ -170,7 +170,7 @@ static void tdx_mr_deinit(const struct attribute_group = *mr_grp) #define GET_QUOTE_SUCCESS 0 #define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff =20 -#define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_b= uf)) +#define TDX_QUOTE_BUF_LEN(n) struct_size_t(struct tdx_quote_buf, data, n) =20 /* struct tdx_quote_buf: Format of Quote request buffer. * @version: Quote format version, filled by TD. @@ -191,8 +191,9 @@ struct tdx_quote_buf { u8 data[]; }; =20 -/* Quote data buffer */ +/* Quote data buffer and length */ static void *quote_data; +static size_t quote_data_len; =20 /* Lock to streamline quote requests */ static DEFINE_MUTEX(quote_lock); @@ -209,9 +210,8 @@ static long tdx_get_report0(struct tdx_report_req __use= r *req) USER_SOCKPTR(req->tdreport)); } =20 -static void free_quote_buf(void *buf) +static void free_quote_buf(void *buf, size_t len) { - size_t len =3D PAGE_ALIGN(GET_QUOTE_BUF_SIZE); unsigned int count =3D len >> PAGE_SHIFT; =20 if (set_memory_encrypted((unsigned long)buf, count)) { @@ -222,19 +222,44 @@ static void free_quote_buf(void *buf) free_pages_exact(buf, len); } =20 -static void *alloc_quote_buf(void) +static size_t get_quote_buf_size(void) { - size_t len =3D PAGE_ALIGN(GET_QUOTE_BUF_SIZE); - unsigned int count =3D len >> PAGE_SHIFT; + size_t buf_size =3D GET_QUOTE_DEFAULT_BUF_SIZE; + u32 quote_size; + + quote_size =3D tdx_get_max_quote_size(); + + if (quote_size) + /* Reported size does not include GetQuote header */ + buf_size =3D TDX_QUOTE_BUF_LEN(quote_size); + + return PAGE_ALIGN(buf_size); +} + +static void *alloc_quote_buf(size_t *buflen) +{ + unsigned int count; + size_t len; void *addr; =20 - addr =3D alloc_pages_exact(len, GFP_KERNEL | __GFP_ZERO); + len =3D get_quote_buf_size(); + + /* + * This fails if the requested size exceeds the buddy allocator's + * maximum order. Use __GFP_NOWARN since the size comes from the host + * and should fail quietly rather than warn. + */ + addr =3D alloc_pages_exact(len, GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN); if (!addr) return NULL; =20 + count =3D len >> PAGE_SHIFT; + if (set_memory_decrypted((unsigned long)addr, count)) return NULL; =20 + *buflen =3D len; + return addr; } =20 @@ -285,7 +310,7 @@ static int tdx_report_new_locked(struct tsm_report *rep= ort, void *data) if (desc->inblob_len !=3D TDX_REPORTDATA_LEN) return -EINVAL; =20 - memset(quote_data, 0, GET_QUOTE_BUF_SIZE); + memset(quote_data, 0, quote_data_len); =20 /* Update Quote buffer header */ quote_buf->version =3D GET_QUOTE_CMD_VER; @@ -296,7 +321,7 @@ static int tdx_report_new_locked(struct tsm_report *rep= ort, void *data) if (ret) return ret; =20 - err =3D tdx_hcall_get_quote(quote_data, GET_QUOTE_BUF_SIZE); + err =3D tdx_hcall_get_quote(quote_data, quote_data_len); if (err) { pr_err("GetQuote hypercall failed, status:%llx\n", err); return -EIO; @@ -315,7 +340,7 @@ static int tdx_report_new_locked(struct tsm_report *rep= ort, void *data) =20 out_len =3D READ_ONCE(quote_buf->out_len); =20 - if (out_len > TDX_QUOTE_MAX_LEN) + if (TDX_QUOTE_BUF_LEN(out_len) > quote_data_len) return -EFBIG; =20 buf =3D kvmemdup(quote_buf->data, out_len, GFP_KERNEL); @@ -417,7 +442,7 @@ static int __init tdx_guest_init(void) if (ret) goto deinit_mr; =20 - quote_data =3D alloc_quote_buf(); + quote_data =3D alloc_quote_buf("e_data_len); if (!quote_data) { pr_err("Failed to allocate Quote buffer\n"); ret =3D -ENOMEM; @@ -431,7 +456,7 @@ static int __init tdx_guest_init(void) return 0; =20 free_quote: - free_quote_buf(quote_data); + free_quote_buf(quote_data, quote_data_len); free_misc: misc_deregister(&tdx_misc_dev); deinit_mr: @@ -444,7 +469,7 @@ module_init(tdx_guest_init); static void __exit tdx_guest_exit(void) { tsm_report_unregister(&tdx_tsm_ops); - free_quote_buf(quote_data); + free_quote_buf(quote_data, quote_data_len); misc_deregister(&tdx_misc_dev); tdx_mr_deinit(tdx_attr_groups[0]); } --=20 2.53.0