From nobody Sat Jul 25 23:41:28 2026 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (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 336D63446AD for ; Sat, 11 Jul 2026 10:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764083; cv=none; b=AbtbuQZVu1/InwBZm7wjvuczBfU1qumvGHHOMEaSlI3V1EOC9qytsHjglw0hAMu/RwAw5ycBa4iD1v+60M0byC6rSttKdWMkqkZ1zevwEMHuXPWNVem++QFWKQ57FUgC9M/B+5/dEAnzVJbYLyBsnLCeb88nuGhBhI7PIQu7aUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764083; c=relaxed/simple; bh=B/7vjjGQ846mvBrqjPHXSmexP863zQRhj+GS0fit7qs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SdxiqdrTPSY11CSBvi3Or+OzExLgSqqk8iitP7TyeBGoCNbof/S6pjiITo5zMmgYVsILhiXYcy2eJDDEwrsZLyWutWJUwzgplVb4eMSLbsTv1w7QT7cmo8y7a1irDzy9S7rDBYG8cH2+Uc9gHaNfgdzPjUc8ue4iqglsxtcKr1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=wGiCh9gu; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="wGiCh9gu" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783764079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PdwuQWYTp04Iu5vMRYQmp4uQKNb0dMqdO+c1bic/th4=; b=wGiCh9guRTiOBsDIvggNZoS2HtlDYpE1AZn5HyFXIcqIxGNZMTwdLAI1H6G0AIKQ50jWGS J2Ybh1QotzGIgz7f96gf8uGtfcbDeIhvfOx/WKM2Y/KDPrL4GQidqXW5d39XcyK77QhgYb uIaWeD7jxM7r7ajUkKTVGOlUFK+C75M= From: Thorsten Blum To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH 1/3] x86/sgx: Remove unused TCS definitions Date: Sat, 11 Jul 2026 12:00:55 +0200 Message-ID: <20260711100053.739588-6-thorsten.blum@linux.dev> In-Reply-To: <20260711100053.739588-5-thorsten.blum@linux.dev> References: <20260711100053.739588-5-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2513; i=thorsten.blum@linux.dev; h=from:subject; bh=B/7vjjGQ846mvBrqjPHXSmexP863zQRhj+GS0fit7qs=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFlBImE3568IE9t55adxk++y83J9d1Z/ln/popCnob574 rnFOhNXdZSyMIhxMciKKbI8mPVjhm9pTeUmk4idMHNYmUCGMHBxCsBE3O4y/PeKttt/IvNsxPr9 8/m8k5ymSAtr7S248bK551XLy1yV/lqGf6ZqK59vm55e+PRORM2PjscLjbXlslyeHOpq6Gacnp6 gzAoA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The TCS structure was added with commit 70d3b8ddcd20 ("x86/sgx: Add SGX architectural data structures"), but has never had an in-tree user. Remove the unused TCS structure and its corresponding definitions. Signed-off-by: Thorsten Blum Acked-by: Kai Huang Reviewed-by: Jarkko Sakkinen --- arch/x86/include/asm/sgx.h | 50 -------------------------------------- 1 file changed, 50 deletions(-) diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h index 04958459a7ca..fe106c55a593 100644 --- a/arch/x86/include/asm/sgx.h +++ b/arch/x86/include/asm/sgx.h @@ -193,56 +193,6 @@ struct sgx_secs { u8 reserved4[3834]; } __packed; =20 -/** - * enum sgx_tcs_flags - execution flags for TCS - * @SGX_TCS_DBGOPTIN: If enabled allows single-stepping and breakpoints - * inside an enclave. It is cleared by EADD but can - * be set later with EDBGWR. - */ -enum sgx_tcs_flags { - SGX_TCS_DBGOPTIN =3D 0x01, -}; - -#define SGX_TCS_RESERVED_MASK GENMASK_ULL(63, 1) -#define SGX_TCS_RESERVED_SIZE 4024 - -/** - * struct sgx_tcs - Thread Control Structure (TCS) - * @state: used to mark an entered TCS - * @flags: execution flags (cleared by EADD) - * @ssa_offset: SSA stack offset relative to the enclave base - * @ssa_index: the current SSA frame index (cleard by EADD) - * @nr_ssa_frames: the number of frame in the SSA stack - * @entry_offset: entry point offset relative to the enclave base - * @exit_addr: address outside the enclave to exit on an exception or - * interrupt - * @fs_offset: offset relative to the enclave base to become FS - * segment inside the enclave - * @gs_offset: offset relative to the enclave base to become GS - * segment inside the enclave - * @fs_limit: size to become a new FS-limit (only 32-bit enclaves) - * @gs_limit: size to become a new GS-limit (only 32-bit enclaves) - * - * Thread Control Structure (TCS) is an enclave page visible in its address - * space that defines an entry point inside the enclave. A thread enters i= nside - * an enclave by supplying address of TCS to ENCLU(EENTER). A TCS can be e= ntered - * by only one thread at a time. - */ -struct sgx_tcs { - u64 state; - u64 flags; - u64 ssa_offset; - u32 ssa_index; - u32 nr_ssa_frames; - u64 entry_offset; - u64 exit_addr; - u64 fs_offset; - u64 gs_offset; - u32 fs_limit; - u32 gs_limit; - u8 reserved[SGX_TCS_RESERVED_SIZE]; -} __packed; - /** * struct sgx_pageinfo - an enclave page descriptor * @addr: address of the enclave page From nobody Sat Jul 25 23:41:28 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 D8DEB3559F2; Sat, 11 Jul 2026 10:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764085; cv=none; b=IIDa8NxiuPNhNRZU6EMvy+QJTSUZ2xLgk93jMgrl5xQ6Tl+jEftHcJFvi4JSs+aVFqnps23AtHm2YbFSPghYKvErgFoAabY1y9w47+H9OdZyHzfwEGWMMnBdmdtl5kyceDboAeqodMlr3k56S7XutSAZAM0Dsj7ae1vgIB3P4QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764085; c=relaxed/simple; bh=1qU4mKWUigMvJRHBuKaHv0I60ezML+jv7EZsMtdq5lE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kdDxIX7qmyORaacSMHmCOluQDAk0ujS08zZXtWY2eD2Fw656RFGMenptOhN3vwR/DHf1P9tyQfnCw2Fk9l4AkUBt3D/AjYyKgBwpeB2RzOxQh+46VRzbUHgSOMiqD4qRYQlK4guyVvXn7QC1cpRkvY7XJFnE4PRDV8uNQcJyi78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RFxmFK3i; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RFxmFK3i" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783764081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1IAi3dsjEzI+J9vi3IABnMe+p9SB6MgQaxiaAcXQ8PI=; b=RFxmFK3idpEpUJrH4SOyd2qmkBVDaY3EGCQP/0ZHlRu7Xn+BM4VSzHNVBQJINgsC6jywsB JpuhCtbSxLjybc40Jml5r8rrkWjdZfijZcdBBSXJgV/+fRttS2td8V9LE6RgG0PzTXPpWi rrYaHNzneRHXxnkNIUQ8t/9gHTJXTpg= From: Thorsten Blum To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH 2/3] x86/sgx: Remove unused size and count definitions Date: Sat, 11 Jul 2026 12:00:56 +0200 Message-ID: <20260711100053.739588-7-thorsten.blum@linux.dev> In-Reply-To: <20260711100053.739588-5-thorsten.blum@linux.dev> References: <20260711100053.739588-5-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1405; i=thorsten.blum@linux.dev; h=from:subject; bh=1qU4mKWUigMvJRHBuKaHv0I60ezML+jv7EZsMtdq5lE=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFlBImEx+5p4HGTKCv2sY+/lRBku+uupO8va/8/ZqPoDf 29OdbnXUcrCIMbFICumyPJg1o8ZvqU1lZtMInbCzGFlAhnCwMUpABMRimBkeO1a+afQ8vO7U3un W07q8S/lsZj0hvfGvE2HDWfrO6iIpzP8d+L8kzOhT7CpeoXwieZd2xSED9Rf3To1/tC7zdcrBDa t4gIA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The definitions were added with commit 70d3b8ddcd20 ("x86/sgx: Add SGX architectural data structures"), but have never been used. The SIGSTRUCT reserved field sizes are also redundant because the structure uses literal sizes instead. Remove them. Signed-off-by: Thorsten Blum Acked-by: Kai Huang Reviewed-by: Jarkko Sakkinen --- arch/x86/include/asm/sgx.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h index fe106c55a593..af5cd6ce9010 100644 --- a/arch/x86/include/asm/sgx.h +++ b/arch/x86/include/asm/sgx.h @@ -108,9 +108,6 @@ enum sgx_miscselect { =20 #define SGX_MISC_RESERVED_MASK GENMASK_ULL(63, 1) =20 -#define SGX_SSA_GPRS_SIZE 184 -#define SGX_SSA_MISC_EXINFO_SIZE 16 - /** * enum sgx_attribute - the attributes field in &struct sgx_secs * @SGX_ATTR_INIT: Enclave can be entered (is initialized). @@ -227,7 +224,6 @@ enum sgx_page_type { SGX_PAGE_TYPE_TRIM, }; =20 -#define SGX_NR_PAGE_TYPES 5 #define SGX_PAGE_TYPE_MASK GENMASK(7, 0) =20 /** @@ -288,11 +284,6 @@ struct sgx_pcmd { u8 mac[16]; } __packed __aligned(128); =20 -#define SGX_SIGSTRUCT_RESERVED1_SIZE 84 -#define SGX_SIGSTRUCT_RESERVED2_SIZE 20 -#define SGX_SIGSTRUCT_RESERVED3_SIZE 32 -#define SGX_SIGSTRUCT_RESERVED4_SIZE 12 - /** * struct sgx_sigstruct_header - defines author of the enclave * @header1: constant byte string From nobody Sat Jul 25 23:41:28 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 8C69037A825 for ; Sat, 11 Jul 2026 10:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764087; cv=none; b=bwDuBAaCW3g9dTIfY+fWkrUuGVmAhKs9cI/fzfvtunOklBNEydZj5uXRn8xhubklcJoyKR6iQwwBoluqURR2vXATH2o4Vg9roB68Ks7PwW+QmsBdo1mZQsujeCeHj2c8L0hLu5dcuWi5LDovuUhrhrbVaj+2grvkz5PO6oz//ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783764087; c=relaxed/simple; bh=uicDhczzY9VBKgysdtMLeZry5lCZAiLOnQM1bwm4XS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iEIdjC3HcYxd6KEm9V+Yey+PYw5VRu1pW4Wut23n4XKZYbbcP2Y5Nqmd3jJcopd7Ztu/bu1jfvNEt1UgxdaXTXGoN8n/hu3DmD5BFtsfNdV7X1V68P94f9DZm6UbfKv+0zhMbjBv4ZeGa2+IPyhbpXmOWkYqcm0OkAbgVqxbaZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=rh9aQqy8; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="rh9aQqy8" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783764082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sX97vORY2u/kl3BsdFam7e+/+bCiog5xLoh/i123rfI=; b=rh9aQqy8BypyyzWW/ITjF6kvd7lmTWjHHoQMHHLnyfv+jmVZJd9+GvHPSHusIPRoiVW5Oo ikJzqS3+EQKAijsTtGXK5vn6Pql+DfDQQWOSA5yeojxEJ1nHSHxi+8/Mcu9FJ7xYm5NP8d HQZoe1EbJtD6F8C3UkbsmgiisRs1gfk= From: Thorsten Blum To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH 3/3] x86/sgx: Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit() Date: Sat, 11 Jul 2026 12:00:57 +0200 Message-ID: <20260711100053.739588-8-thorsten.blum@linux.dev> In-Reply-To: <20260711100053.739588-5-thorsten.blum@linux.dev> References: <20260711100053.739588-5-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1085; i=thorsten.blum@linux.dev; h=from:subject; bh=uicDhczzY9VBKgysdtMLeZry5lCZAiLOnQM1bwm4XS0=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFlBIuGrv0aLrTha83Jt8kTPjiPMxsGrbtb+/evvvm9qz lHPhc8qOkpZGMS4GGTFFFkezPoxw7e0pnKTScROmDmsTCBDGLg4BWAi5U4M/11LnboafhzMVX+4 MKbz2paXljs2X7vnOfP6YmsP94CAyRsYfrMz8gjOOeixZdWqg9kvmpUk/d/Js77Kc+q+nMxyfMO 2KG4A X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Both sgx_ioc_enclave_init() and __sgx_virt_einit() use the same 304-byte launch token. Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit() instead of maintaining a second local definition, ensuring the token initialization and validation paths use the same size. Signed-off-by: Thorsten Blum Reviewed-by: Jarkko Sakkinen Reviewed-by: Kai Huang --- arch/x86/kernel/cpu/sgx/virt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c index db6806c40483..fa9173a9384a 100644 --- a/arch/x86/kernel/cpu/sgx/virt.c +++ b/arch/x86/kernel/cpu/sgx/virt.c @@ -394,9 +394,8 @@ static int __sgx_virt_einit(void __user *sigstruct, voi= d __user *token, * All other checks deferred to ENCLS itself. Also see comment * for @secs in sgx_virt_ecreate(). */ -#define SGX_EINITTOKEN_SIZE 304 if (WARN_ON_ONCE(!access_ok(sigstruct, sizeof(struct sgx_sigstruct)) || - !access_ok(token, SGX_EINITTOKEN_SIZE) || + !access_ok(token, SGX_LAUNCH_TOKEN_SIZE) || !access_ok(secs, PAGE_SIZE))) return -EINVAL;