From patchwork Wed Feb 26 11:44:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868692 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D99212153F0; Wed, 26 Feb 2025 11:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570313; cv=none; b=tLs43/6pR/Zf5AWiVk17O0AZ3MoZbu2pYiQSsWTFP+zQNti/p6rIvAK2lYaI+iiD+Wsno1ZdwqUnuYujqXJgvXiZwGpSduNawbJnaBy5GuXQR/Z9xOtyipxnlE0BEym2sbie0DXdKj50xuwsUD6D5YXAYD/Veas/XRreqtdQeac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570313; c=relaxed/simple; bh=jOcl4jChzaOfnuMhe6CWOzQik5bw/m/LULE4SM4Wwic=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=slEANvLYB6GT+rp68VMrNuXkUtqT2tmFi97k1CQDy1DM2sX1Vn07QJ0Ei+sKWlqRpRyByYa53W7+gZaYv+lvr2owcoWsEmKidQ3z8b/xsR+hpYkF2IEk36mUnthbTdCkvYFqVX4LXV+I2R58purhVquUq1Q98e76v3YEX2fmzpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JPxjA3rj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NogC8iL5; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JPxjA3rj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NogC8iL5" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lMDiGbYVSI2UFf1LCxWO6nyQEZB+Om9MsywMKZqQgCo=; b=JPxjA3rjz6xx4GTC7I8oaWdo6JKP5/SU+MZYtxrPCtbpIT6X3MBJTtspm+D3CEgeb/rGz0 TIwScseTkmK+tv0QaLucWZcdi7zu5lWTZllLIPEth+U6QNA7ZDutG838PWSniAlvZ5ahWC 0LU6v2uQDsmxRX5nsy9c/Cis8PC/Q1IHXZb+7MWEbaxt9tUHqJ7kKtA4EYETE4lsDIKZpa HJfXRZJvOSLXJNl442y+s1e545AMCTgZpPgaVWCujHEFBcobNhSRSsLqNr7p75EmCu1fCB 3UPM8em6xc+wLNOxbvByppfB07n2A/LCz2/v9s/kEJqPMEna1tDWxq6xKKZ3vQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lMDiGbYVSI2UFf1LCxWO6nyQEZB+Om9MsywMKZqQgCo=; b=NogC8iL5YzrQpwMRQZ93LpyvPa5B8vMn/uJTGvcGCDvF9ORegZ4u77l7P0pYsd9hV5eT+D tm/sp4VhOqmVeBCg== Date: Wed, 26 Feb 2025 12:44:41 +0100 Subject: [PATCH v2 02/16] elf, uapi: Add definition for STN_UNDEF Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-2-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=885; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=jOcl4jChzaOfnuMhe6CWOzQik5bw/m/LULE4SM4Wwic=; b=qt2UpwulQT6NmPqm+BCm/x9gmi8yb5q4QxLrpncjEM195FECfP4GUiMb0tEXnI6jNVxzs5MLk c8OLcJCsa1SBT8bdPVaKrK+Hc3gm7a3UVHR9oQ0/xyDKxXTMTcKdumk X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The definition is used by tools/testing/selftests/vDSO/parse_vdso.c. To be able to build the vDSO selftests without a libc dependency, add the definition to the kernels own UAPI headers. Link: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.symtab.html Reviewed-by: Kees Cook Signed-off-by: Thomas Weißschuh --- include/uapi/linux/elf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index b44069d29cecc0f9de90ee66bfffd2137f4275a8..448695c7364042b10682acc8223eb6053ad039dd 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -125,6 +125,8 @@ typedef __s64 Elf64_Sxword; #define STB_GLOBAL 1 #define STB_WEAK 2 +#define STN_UNDEF 0 + #define STT_NOTYPE 0 #define STT_OBJECT 1 #define STT_FUNC 2 From patchwork Wed Feb 26 11:44:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868691 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 96A26216382; Wed, 26 Feb 2025 11:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570314; cv=none; b=r27b98fVZDNu0aRdGf92yaM2J5KlXZ2jZRd1aLYE+ClN81026t+1GeleFmk6Ljf9UcaL7URaEWm6g+RR5kSMZc9QTzmh1MwQ4X4lsdS99VBeiJdeIVKOcCJNdZVH0zeZ6AXzhBsoZkRfjSs0GEwY/M6OKfwlEtn+wlFnVw+eV7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570314; c=relaxed/simple; bh=+jGgP1cF5BHMiA98EteeT7PCwWeU0cio2XCj4TkDXXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kyNfnKbeGkAZ22/C7rcEOcbTGekM7i0qy/SthwbUPYJ1Oyar2Pl0FPtohSRZfPUN8/r5tljTPhZT+0TgyE6LrBoaXwwe5hmB8N59S5Bcsv5OnP+io86qsxiefAs9Idvl4GKQ7UEiX0cmMKIlYy1YihzRX1ueWfnfummNEbVNSG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=avECu8S3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Oo4q/cfI; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="avECu8S3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Oo4q/cfI" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qc8k85QrRUfIwluNEgaOEIrDWlVHw34Ed+H+vO4zIyU=; b=avECu8S3jx/pmCIQJWaK+0SD8K6JT8SgvRapY9TNb39IEaKuSR+tpzWW6pZsMs+Bd64mxD DpVplJ5rC26o+kIErleSVbg4O3iGhlxVke2dumC3pDlpKiwmWMrh0p/omecDYpsTABSN4C r/BK/yxqHtoK1vts2FOv7jcQ5gYb/fd2F6ZDOIb3VQmuZYlTL8MOotoscRQHlG9jXFEmiO wz0a8tD8Dnhod6Pc31rssOViwZsomH2L8EN+qKX52SYScbEn6SfOcamhUKcuUKK3kXGTxF V2zaBkDidKTVBO3dw/gcnLp/iLX6mG+o9/sdPc6alFF7Xdwg7QGXU1TxvpEltA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qc8k85QrRUfIwluNEgaOEIrDWlVHw34Ed+H+vO4zIyU=; b=Oo4q/cfIBwhbzTTkHfzTQKj/4rS6c1d4wrt8XU482oeVg1WZfUBNM9SXPS1Er6+/GUn+Kp 4NKpgPB/18f2H0Bw== Date: Wed, 26 Feb 2025 12:44:42 +0100 Subject: [PATCH v2 03/16] elf, uapi: Add definition for DT_GNU_HASH Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-3-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=992; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=+jGgP1cF5BHMiA98EteeT7PCwWeU0cio2XCj4TkDXXs=; b=gffFwpFiMY0sSE9DKpvTyzzTsHUi6gqoqQGzj2IUwlbRWYjFFxwMFVEexOzQSI0o+6k2ojfcr 0YglZp5OTQgB6tOuZ7VpMYH7szsVzIHB0ASp/JLSQ82MOQMT0FTpFk7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The definition is used by tools/testing/selftests/vDSO/parse_vdso.c. To be able to build the vDSO selftests without a libc dependency, add the define to the kernels own UAPI headers. Link: https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/libc-ddefs.html Reviewed-by: Kees Cook Signed-off-by: Thomas Weißschuh --- include/uapi/linux/elf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 448695c7364042b10682acc8223eb6053ad039dd..c5383cc7bb13c931fea083de5243c4006f795006 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -107,6 +107,7 @@ typedef __s64 Elf64_Sxword; #define DT_VALRNGLO 0x6ffffd00 #define DT_VALRNGHI 0x6ffffdff #define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 #define DT_ADDRRNGHI 0x6ffffeff #define DT_VERSYM 0x6ffffff0 #define DT_RELACOUNT 0x6ffffff9 From patchwork Wed Feb 26 11:44:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868690 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7CCFD218AB7; Wed, 26 Feb 2025 11:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570316; cv=none; b=rKvt1WT955fMl3ZXRbTmzqWHTCTLlUDmIick66jvoY1xZNlau9VTkeJQFiNHWdP4Ym8UrzXSD8BEH5DIv3qmh4GK6x5mbDcGJFxizGXbho+utr3s4AnGdrfoLZ7Q8RlIcH0UDfDeyfiDw7ILxSB8zR36OJhkdSgCFp25c5H57R0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570316; c=relaxed/simple; bh=uMbwFQSW2wbApezo9DQH/BnNIMdQZar0Ezqf7xcu58Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tOHnOyprnXNDpEfMVs64HjCHzqg44moomc+HhS+1qn4jLtEPsMU4Nmtt2uUBPp9JbRBhTjbWB/hlU/RlrsNgFuNuADDiPJF7wvnsyOPmL5ZkYPnkVIAXDRDWsFS36bssOhqKD9wSo3DietNlarPUiE2DUPbjqZSb/Yge8ajC00s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dC7RWRst; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=p2wJLYMt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dC7RWRst"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p2wJLYMt" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k9pJvPJRoot4AT1h69bhn9vc1GanKxm+mtfLKQnaoF4=; b=dC7RWRst00MR9iLmG1iI2b5cbgzkgiVwWBn0rDD4HVIfYUSuYojRsR/TmE4RQmWGHNvJ+2 77jKMGmT7QUb9GGXEH6BgCtKx8H2mDwpZPu9v2GWMPYLr040SgXS/LOxwnpTo5AXAvjjZY 0UU6ZLw7D5pTQxbFsvxUZ6RqphD15YS0/KLoZ6u6FY3NZ3pmHV5l9GfiT3txGa8oC1LpO9 MhPkybzWhm7Gdxj4aYuI8CpcXmYHNdOhgqXHolufvud1+ZYWcvb9jwmZLUQgm+1HQxQxJU m2uujyAmHrqemW05yghgOO+PufC36Ypuvo1WUGAYMciRvy0yHbKhKp3QIVZGZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k9pJvPJRoot4AT1h69bhn9vc1GanKxm+mtfLKQnaoF4=; b=p2wJLYMtdpFHXL/9QycDKpVmsl95tT5ehlvebqkIkYEFtNGrVIsnpJyr+1WpYjd9T61LR7 YjJ8/JUjJsaEohCQ== Date: Wed, 26 Feb 2025 12:44:44 +0100 Subject: [PATCH v2 05/16] elf, uapi: Add type ElfXX_Versym Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-5-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=1126; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=uMbwFQSW2wbApezo9DQH/BnNIMdQZar0Ezqf7xcu58Y=; b=7CvId9mvKa9//HzXCxvhR1VmXOx23JW3X291jiX1R+XcNhWx5UgmMqTiFxZ+a3AXSWFC+nXzl /gMgqN7haSpDrF2zUs3SczycGbg7PP7Jvfv59hjA3ElJYqWD8Q0IvHT X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The types are used by tools/testing/selftests/vDSO/parse_vdso.c. To be able to build the vDSO selftests without a libc dependency, add the types to the kernels own UAPI headers. As documented by elf(5). Reviewed-by: Kees Cook Signed-off-by: Thomas Weißschuh --- include/uapi/linux/elf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index d040f12ff1c0ae3dde5c371c81d6089118fbe8ed..8846fe03ca5b836c96aad1be6d8fb9daf3d4b1d9 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -11,6 +11,7 @@ typedef __u16 Elf32_Half; typedef __u32 Elf32_Off; typedef __s32 Elf32_Sword; typedef __u32 Elf32_Word; +typedef __u16 Elf32_Versym; /* 64-bit ELF base types. */ typedef __u64 Elf64_Addr; @@ -21,6 +22,7 @@ typedef __s32 Elf64_Sword; typedef __u32 Elf64_Word; typedef __u64 Elf64_Xword; typedef __s64 Elf64_Sxword; +typedef __u16 Elf64_Versym; /* These constants are for the segment types stored in the image headers */ #define PT_NULL 0 From patchwork Wed Feb 26 11:44:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868689 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 610D221884A; Wed, 26 Feb 2025 11:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570318; cv=none; b=Wy+ChhYP4ffju/rCjBt25l94Xh3P4PSL4iWtyfaOlDYtdv4YJYFlJ9qEtiwXhHri7sOJYsYL0fsDyQki2JbBEc398chwg4ZR34ruvjmNQWddho7uIeDTvAFDQyToq7+0KzDnlG3GcTFB0eJ6n/bsD3rhv8dxM8e4gImyvfDztXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570318; c=relaxed/simple; bh=f0elSrf4G5nhNoS671eA0MwXLIFN+3JjK3K2nUIR4+Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nngNxJ/uKWTIuvTQQPBxju3r3QRbllVyYE15Ad4Z9E8CCnhjgeLTKruU8y7mKKIhcfLq/lykAMVGxdRCXpGo3LnfPGtODP9GUwkGjXqqgVSKmZY55QgWz+LzEa2UUO7lEfzOsNYIr9tKgtGdMNHPonR62Wcx7G6WOFdnjrZkkS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YjdFSRuy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NqgJ2Fef; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YjdFSRuy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NqgJ2Fef" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bkCRw2BpQUYAjvfhyaUo+iyDwhLAUESJLqMGOQ+XVwI=; b=YjdFSRuyb91zkSTPvJ8cgiS1svich7dObnXdLP24CYPu3D5EQrrVweJJQnvReCGRuxeEdn 5XC6Grer4PT+zGmGd6bcuCUeAwpG1bX7ALed3vso/6rIEnY1OdfnW21BzlLJQNzTJnRcDK V+gfY+69wDAOWdpsPYUa9GK5r9CE8RIAPU44kjN53A1d7DqSKuuBPb6Uxa5YJcevVAhlB3 o6Bp+HknlhyCZejpdymUi+tbdQ6TvwDg+UbYoFvfthEvK0BtqLFrTALKt2tEKMyqBtn6U7 R2HcDJIS2PgQDgXU+7guk0pzWRZJGKt0LVC+MqiTCk5oQFhCw4hMxJDalLXqoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bkCRw2BpQUYAjvfhyaUo+iyDwhLAUESJLqMGOQ+XVwI=; b=NqgJ2FefRdRXfd22mRV3zWNKN+hKj9Uq/0fpZT08jqL33unPCrnhLCKAx/UEbIOAznpOpz kSX0oMt34JymlVBQ== Date: Wed, 26 Feb 2025 12:44:45 +0100 Subject: [PATCH v2 06/16] elf, uapi: Add types ElfXX_Verdef and ElfXX_Veraux Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-6-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=1560; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=f0elSrf4G5nhNoS671eA0MwXLIFN+3JjK3K2nUIR4+Y=; b=XqArEjVM/ETm9hIaH7qXWZUILAITcT9I7PEhlL1NXqPj1HuOR3bmJ792iqIy/A/oOqMP2t3ft TQ3c8kUy3wZC2IHOaunkr6mjGBwCzhkfBG0tTSfQNu+CFOefmVG+fa2 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The types are used by tools/testing/selftests/vDSO/parse_vdso.c. To be able to build the vDSO selftests without a libc dependency, add the types to the kernels own UAPI headers. Link: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html#VERDEFEXTS Reviewed-by: Kees Cook Signed-off-by: Thomas Weißschuh --- include/uapi/linux/elf.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 8846fe03ca5b836c96aad1be6d8fb9daf3d4b1d9..49f9f90458d8ca8e7b8f823d32be0a719ff827b3 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -491,4 +491,34 @@ typedef struct elf64_note { /* Bits for GNU_PROPERTY_AARCH64_FEATURE_1_BTI */ #define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0) +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + #endif /* _UAPI_LINUX_ELF_H */ From patchwork Wed Feb 26 11:44:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868687 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C4C6E218ADF; Wed, 26 Feb 2025 11:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570319; cv=none; b=j1z2uZOCTcHUVvlabQuOZxpcU3fFCIPD4yozKguSDsdP88nDeocxXLZxUhEyEIr/50KgCeld0jhmrj27O5ZGd40/4l+VD25+ArFWfTIhRDczE4xRnvwesHdGSVARLZfxYqX2OmLYcibV8XRKo77IMAXeMN14rm1e/3PVH5na99s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570319; c=relaxed/simple; bh=5wSxSpPLrEhh+gEr44hMdOh4WtecZqa6aJNR6ugfHyA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dmxUD7qKuiPYLJpVeAyVtrT0eUSO3W7eSVvmGvMS1sS3cXuPRP8XjjObmIB5ZON1ikQWb/XY+fkDoG9dp3toK6qNQlTlfXggrJve6a5M5P/S45xcnmezkzQXEWXFbFfRTnleJsB22q9xMCq/d+3by/FIAPyAsRAV0gpWT1Ciyu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=17zjm4CL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ATETiKS9; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="17zjm4CL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ATETiKS9" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sg4NMO0TZ19i20OrdzLqOif4PPEkfQYWtb9RkA9dHw4=; b=17zjm4CLLeklyRGkjGNJUT6dyi/EaNLJ66/Orf0Vql6bRWGPa9DxIHb7yFdqQh+CHjDJKd ylukAkuv0u0p9fyqQNIk/87d9ILxLD/dlYDW5tuUOSXOG+9iDOyWKlNTEZZf3NWg8U8dmj HOxCDCvDHLjXP38Xh3+45S19VhdBVfD8EzvsfwtwYIOgLDhj59JwM4D48BUObjzI30vwI0 wZQVvDjsTiHS/lgEQ6j5fahbxNPX6f4fpIbDcJpNlcYx7gA00BHlbNBe7b69vj/l9HFFDo 6FMRooMRSXsRsiBQMmdE+m3+3aFQr/ubQTIwBEptlUeTxzjMfymob0BBMtDGtg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sg4NMO0TZ19i20OrdzLqOif4PPEkfQYWtb9RkA9dHw4=; b=ATETiKS904wPHfcAdAYV09qIKPEFBRhVaI5xBN3eGTd9JEs5pvKXxrqLDYVqMp19MfDqRC I7/TQ0RsEWfh3SDg== Date: Wed, 26 Feb 2025 12:44:46 +0100 Subject: [PATCH v2 07/16] tools/include: Add uapi/linux/elf.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-7-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=18079; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=5wSxSpPLrEhh+gEr44hMdOh4WtecZqa6aJNR6ugfHyA=; b=0EZb+KlxjcJstWu/+5/7Wz5q/XR25S07F/LUW8i1SySbQ7/v+t+ouqnU38M6s9mnFiympLwN2 2+0JGUJ8MmUDdIuzQoCO2mLrfaVwJspLp3MMfDO9k4z7QeBF5MI+H4K X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= It will be used by the vDSO selftests. Signed-off-by: Thomas Weißschuh --- tools/include/uapi/linux/elf.h | 524 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 524 insertions(+) diff --git a/tools/include/uapi/linux/elf.h b/tools/include/uapi/linux/elf.h new file mode 100644 index 0000000000000000000000000000000000000000..3d0935a11613bbcf8c381188de3a10bafd6cc29f --- /dev/null +++ b/tools/include/uapi/linux/elf.h @@ -0,0 +1,524 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_ELF_H +#define _LINUX_ELF_H + +#include +#include + +/* 32-bit ELF base types. */ +typedef __u32 Elf32_Addr; +typedef __u16 Elf32_Half; +typedef __u32 Elf32_Off; +typedef __s32 Elf32_Sword; +typedef __u32 Elf32_Word; +typedef __u16 Elf32_Versym; + +/* 64-bit ELF base types. */ +typedef __u64 Elf64_Addr; +typedef __u16 Elf64_Half; +typedef __s16 Elf64_SHalf; +typedef __u64 Elf64_Off; +typedef __s32 Elf64_Sword; +typedef __u32 Elf64_Word; +typedef __u64 Elf64_Xword; +typedef __s64 Elf64_Sxword; +typedef __u16 Elf64_Versym; + +/* These constants are for the segment types stored in the image headers */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_TLS 7 /* Thread local storage segment */ +#define PT_LOOS 0x60000000 /* OS-specific */ +#define PT_HIOS 0x6fffffff /* OS-specific */ +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff +#define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550) +#define PT_GNU_STACK (PT_LOOS + 0x474e551) +#define PT_GNU_RELRO (PT_LOOS + 0x474e552) +#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) + + +/* ARM MTE memory tag segment type */ +#define PT_AARCH64_MEMTAG_MTE (PT_LOPROC + 0x2) + +/* + * Extended Numbering + * + * If the real number of program header table entries is larger than + * or equal to PN_XNUM(0xffff), it is set to sh_info field of the + * section header at index 0, and PN_XNUM is set to e_phnum + * field. Otherwise, the section header at index 0 is zero + * initialized, if it exists. + * + * Specifications are available in: + * + * - Oracle: Linker and Libraries. + * Part No: 817–1984–19, August 2011. + * https://docs.oracle.com/cd/E18752_01/pdf/817-1984.pdf + * + * - System V ABI AMD64 Architecture Processor Supplement + * Draft Version 0.99.4, + * January 13, 2010. + * http://www.cs.washington.edu/education/courses/cse351/12wi/supp-docs/abi.pdf + */ +#define PN_XNUM 0xffff + +/* These constants define the different elf file types */ +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + +/* This is the info that is needed to parse the dynamic section of the file */ +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_ENCODING 32 +#define OLD_DT_LOOS 0x60000000 +#define DT_LOOS 0x6000000d +#define DT_HIOS 0x6ffff000 +#define DT_VALRNGLO 0x6ffffd00 +#define DT_VALRNGHI 0x6ffffdff +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_VERSYM 0x6ffffff0 +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa +#define DT_FLAGS_1 0x6ffffffb +#define DT_VERDEF 0x6ffffffc +#define DT_VERDEFNUM 0x6ffffffd +#define DT_VERNEED 0x6ffffffe +#define DT_VERNEEDNUM 0x6fffffff +#define OLD_DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff + +/* This info is needed when parsing the symbol table */ +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 + +#define STN_UNDEF 0 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 + +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + +#define ELF_ST_BIND(x) ((x) >> 4) +#define ELF_ST_TYPE(x) ((x) & 0xf) +#define ELF32_ST_BIND(x) ELF_ST_BIND(x) +#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x) +#define ELF64_ST_BIND(x) ELF_ST_BIND(x) +#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x) + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Sword d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Sxword d_tag; /* entry tag value */ + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; + +/* The following are used with relocations */ +#define ELF32_R_SYM(x) ((x) >> 8) +#define ELF32_R_TYPE(x) ((x) & 0xff) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) + +typedef struct elf32_rel { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct elf64_rel { + Elf64_Addr r_offset; /* Location at which to apply the action */ + Elf64_Xword r_info; /* index and type of relocation */ +} Elf64_Rel; + +typedef struct elf32_rela { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct elf64_rela { + Elf64_Addr r_offset; /* Location at which to apply the action */ + Elf64_Xword r_info; /* index and type of relocation */ + Elf64_Sxword r_addend; /* Constant addend used to compute value */ +} Elf64_Rela; + +typedef struct elf32_sym { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; +} Elf32_Sym; + +typedef struct elf64_sym { + Elf64_Word st_name; /* Symbol name, index in string tbl */ + unsigned char st_info; /* Type and binding attributes */ + unsigned char st_other; /* No defined meaning, 0 */ + Elf64_Half st_shndx; /* Associated section index */ + Elf64_Addr st_value; /* Value of the symbol */ + Elf64_Xword st_size; /* Associated symbol size */ +} Elf64_Sym; + + +#define EI_NIDENT 16 + +typedef struct elf32_hdr { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; /* Entry point */ + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct elf64_hdr { + unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + +/* These constants define the permissions on sections in the program + header, p_flags. */ +#define PF_R 0x4 +#define PF_W 0x2 +#define PF_X 0x1 + +typedef struct elf32_phdr { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct elf64_phdr { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment, file & memory */ +} Elf64_Phdr; + +/* sh_type */ +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_NUM 12 +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_RELA_LIVEPATCH 0x00100000 +#define SHF_RO_AFTER_INIT 0x00200000 +#define SHF_MASKPROC 0xf0000000 + +/* special section indexes */ +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_HIPROC 0xff1f +#define SHN_LIVEPATCH 0xff20 +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_HIRESERVE 0xffff + +typedef struct elf32_shdr { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct elf64_shdr { + Elf64_Word sh_name; /* Section name, index in string tbl */ + Elf64_Word sh_type; /* Type of section */ + Elf64_Xword sh_flags; /* Miscellaneous section attributes */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Size of section in bytes */ + Elf64_Word sh_link; /* Index of another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +#define EI_MAG0 0 /* e_ident[] indexes */ +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_OSABI 7 +#define EI_PAD 8 + +#define ELFMAG0 0x7f /* EI_MAG */ +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define ELFCLASSNONE 0 /* EI_CLASS */ +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define ELFDATANONE 0 /* e_ident[EI_DATA] */ +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +#define EV_NONE 0 /* e_version, EI_VERSION */ +#define EV_CURRENT 1 +#define EV_NUM 2 + +#define ELFOSABI_NONE 0 +#define ELFOSABI_LINUX 3 + +#ifndef ELF_OSABI +#define ELF_OSABI ELFOSABI_NONE +#endif + +/* + * Notes used in ET_CORE. Architectures export some of the arch register sets + * using the corresponding note types via the PTRACE_GETREGSET and + * PTRACE_SETREGSET requests. + * The note name for these types is "LINUX", except NT_PRFPREG that is named + * "CORE". + */ +#define NT_PRSTATUS 1 +#define NT_PRFPREG 2 +#define NT_PRPSINFO 3 +#define NT_TASKSTRUCT 4 +#define NT_AUXV 6 +/* + * Note to userspace developers: size of NT_SIGINFO note may increase + * in the future to accomodate more fields, don't assume it is fixed! + */ +#define NT_SIGINFO 0x53494749 +#define NT_FILE 0x46494c45 +#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ +#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ +#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ +#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ +#define NT_PPC_TAR 0x103 /* Target Address Register */ +#define NT_PPC_PPR 0x104 /* Program Priority Register */ +#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */ +#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */ +#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */ +#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */ +#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */ +#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */ +#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */ +#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */ +#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address Register */ +#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority Register */ +#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control Register */ +#define NT_PPC_PKEY 0x110 /* Memory Protection Keys registers */ +#define NT_PPC_DEXCR 0x111 /* PowerPC DEXCR registers */ +#define NT_PPC_HASHKEYR 0x112 /* PowerPC HASHKEYR register */ +#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ +#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ +#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ +/* Old binutils treats 0x203 as a CET state */ +#define NT_X86_SHSTK 0x204 /* x86 SHSTK state */ +#define NT_X86_XSAVE_LAYOUT 0x205 /* XSAVE layout description */ +#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */ +#define NT_S390_TIMER 0x301 /* s390 timer register */ +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ +#define NT_S390_CTRS 0x304 /* s390 control registers */ +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ +#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ +#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ +#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ +#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 upper half */ +#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */ +#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers */ +#define NT_S390_GS_BC 0x30c /* s390 guarded storage broadcast control block */ +#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation */ +#define NT_S390_PV_CPU_DATA 0x30e /* s390 protvirt cpu dump data */ +#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ +#define NT_ARM_TLS 0x401 /* ARM TLS register */ +#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ +#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ +#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ +#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension registers */ +#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication code masks */ +#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */ +#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */ +#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */ +#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* arm64 ptr auth enabled keys (prctl()) */ +#define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers */ +#define NT_ARM_ZA 0x40c /* ARM SME ZA registers */ +#define NT_ARM_ZT 0x40d /* ARM SME ZT registers */ +#define NT_ARM_FPMR 0x40e /* ARM floating point mode register */ +#define NT_ARM_POE 0x40f /* ARM POE registers */ +#define NT_ARM_GCS 0x410 /* ARM GCS state */ +#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */ +#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */ +#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */ +#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode */ +#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers */ +#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */ +#define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */ +#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged address control (prctl()) */ +#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ +#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */ +#define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */ +#define NT_LOONGARCH_LASX 0xa03 /* LoongArch Loongson Advanced SIMD Extension registers */ +#define NT_LOONGARCH_LBT 0xa04 /* LoongArch Loongson Binary Translation registers */ +#define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */ +#define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */ + +/* Note types with note name "GNU" */ +#define NT_GNU_PROPERTY_TYPE_0 5 + +/* Note header in a PT_NOTE section */ +typedef struct elf32_note { + Elf32_Word n_namesz; /* Name size */ + Elf32_Word n_descsz; /* Content size */ + Elf32_Word n_type; /* Content type */ +} Elf32_Nhdr; + +/* Note header in a PT_NOTE section */ +typedef struct elf64_note { + Elf64_Word n_namesz; /* Name size */ + Elf64_Word n_descsz; /* Content size */ + Elf64_Word n_type; /* Content type */ +} Elf64_Nhdr; + +/* .note.gnu.property types for EM_AARCH64: */ +#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000 + +/* Bits for GNU_PROPERTY_AARCH64_FEATURE_1_BTI */ +#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0) + +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + +#endif /* _LINUX_ELF_H */ From patchwork Wed Feb 26 11:44:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868688 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 2A8E521A436; Wed, 26 Feb 2025 11:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570318; cv=none; b=hI64Fr8mEZ4d5fyinH7jG8TrST5yIT07wtzZf3f9NHDnJusiSXb08CFeyfhMgQgOBWrd5iry4+gzYPikHxu3mGj3RR2udzwBIjRHYDDJWdd3lcl+rIYxRRhOgLuJtd9Qyd0PI7IG1SNepvhAVvSfTtp1/OV3F9aEOrKwIgHa2hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570318; c=relaxed/simple; bh=C3WrIXo4pF6mfQdzvKKu1BjqdXgy4M3jnZi0dZUjrCw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m4d/2kd79LUa5PArcFqn30DpG5VzR92EhK93My06+I+Pki3I1UZIVrhM3NYPGz0w5VQkK1f0iMffxdeW0D7c+2WAdNLpuTThiFyVDnD8VqBWJ2k3TrhW5FHkwnGTX7vcUfmC9aB6IGFKYaCdm1GhOS4Q01HTvQsTIUH+U9AiVLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nasqugvG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CWmvpnCr; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nasqugvG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CWmvpnCr" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cRuD5hbVHSSw/8cljIctKIY+Y3ZkYhQFJxv3Eq1eG8c=; b=nasqugvGFKackdKOCTch+AP72kWRqEucxypuXDsMds9gPwL8RK61E3IAURJfFRwVz6qCFV borLyAg+H0LG9tWwXNBlUwuDFwYZPS4sMuMxBeAx6ObJr9TGjNFDhtRAWyulzmylyhWtwJ P723Y+vsU/GF2dTuLScSrd42stge6MnfiMB8FerpsLUDR/zDnvtjIEmaOYfykQmjZqPh6N 9J2wj71O+zBQnyIXpq2/C7y6QezLH5rhiXHdkKjY0lULjTCFb6/K4L75NxQ/9D4sys6/zp nDlUnoAgYdIMx/DPTHflxDyqMuOQYiBxugcpuMRiDOgqbdn4WR2SX8G87j/Qbg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cRuD5hbVHSSw/8cljIctKIY+Y3ZkYhQFJxv3Eq1eG8c=; b=CWmvpnCrI4ggnNzOB2bFK5VZej2qGU4p7haIEM0fQFYcPsUdGJejZoOoBmHUpDnIp5RS2p vfN2Hj/oogOEL1BA== Date: Wed, 26 Feb 2025 12:44:49 +0100 Subject: [PATCH v2 10/16] selftests: vDSO: vdso_standalone_test_x86: Use vdso_init_form_sysinfo_ehdr Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-10-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=1895; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=C3WrIXo4pF6mfQdzvKKu1BjqdXgy4M3jnZi0dZUjrCw=; b=eQDHEgBbcQlTMN155d79X04vEswgzq72yKppWr5aBDgxbIbLYxd/IvNp2Y1YQ9/fNaQ7z11QT DAUfoLznQjjCZKLGqX216kBJX2mCS9MUbVbIRKbqrvmzEqOe0Ab+zYq X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= vdso_standalone_test_x86 is the only user of vdso_init_from_auxv(). Instead of combining the parsing the aux vector with the parsing of the vDSO, split them apart into getauxval() and the regular vdso_init_from_sysinfo_ehdr(). The implementation of getauxval() is taken from tools/include/nolibc/stdlib.h. Signed-off-by: Thomas Weißschuh --- All of this code will be deleted later again. --- .../selftests/vDSO/vdso_standalone_test_x86.c | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c index 644915862af8883131e5defd336f1bd80736fc0f..500608f89c66b5747e3d845ebc54e4c3a35b6ccd 100644 --- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c +++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "parse_vdso.h" @@ -84,6 +85,30 @@ void to_base10(char *lastdig, time_t n) } } +unsigned long getauxval(const unsigned long *auxv, unsigned long type) +{ + unsigned long ret; + + if (!auxv) + return 0; + + while (1) { + if (!auxv[0] && !auxv[1]) { + ret = 0; + break; + } + + if (auxv[0] == type) { + ret = auxv[1]; + break; + } + + auxv += 2; + } + + return ret; +} + void c_main(void **stack) { /* Parse the stack */ @@ -96,7 +121,7 @@ void c_main(void **stack) stack++; /* Now we're pointing at auxv. Initialize the vDSO parser. */ - vdso_init_from_auxv((void *)stack); + vdso_init_from_sysinfo_ehdr(getauxval((unsigned long *)stack, AT_SYSINFO_EHDR)); /* Find gettimeofday. */ typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); From patchwork Wed Feb 26 11:44:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868686 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 93A95216397; Wed, 26 Feb 2025 11:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570319; cv=none; b=LGYIBhC6i+oTJFwgBDTHJKFT5wNxP5loOD29gJ+bA5gFXuWQCVIiqFU6sOW/oMBKHtfMR535cpj7L0jgmC3UPH3wWsjDZZUrNPLZ9B3J8HHjoJ/qB81gLvpqXbDEFRIx+gsJ1NHfbWm+cHg0XwleV+upoZKPfcyqNgJXHSxCjdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570319; c=relaxed/simple; bh=NpOQuxLd7KblcjFPnaDO5YLxwLL0GxVqW0hZLzvIMGU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KZj1H0a0uk11I05o2FeQNVHdv9pZunyhVpYATaKo8WKfUyBG6Kd3u3twzuf+Ia4RNvuX+6EGmVeXVmLco2DvKdlzNozOT448A8Q74x1LOCYs3373BWRKwkdB2rPCN4iWM2krKPxMus7bbnZ92HSSI8JrpVLY1+DNrjMrl9+Pb0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bcGSb3SQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fqvj2xz2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bcGSb3SQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fqvj2xz2" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MOyFPIEiH7gm2OvTiVE+dNl/7Ao4pkwSxETN6MXhZOM=; b=bcGSb3SQiYGMOQ1VcKhYKOTrklR98D9VpgIchlARBRNfaI5sacVObkXd7dN1ZkhOKvunow mNeuEngk3Mf+7cDpevxNf+IwDZZdBgqG3QJ+TiUzrKG8RehOC1YJvQMzzJ7MCLRUnww1ii 0fkIRJOhubwv3TMvN6TIaQBaCmEXG9EFcVR0sk527PDeOwymkNj6xQoWx5+qJrJY/ha69f 1NYUiWFVSfS76ThI/0ZEJplxPmmB4diFJVHA0Bwg2upTJp3GSg4lDN9Bn63yD53LqB8TDB idMC554DjsFdYljkY2GT14KDJ5pkDlkez/jebzEgHzILbJBUIp3bC8qigg1XmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MOyFPIEiH7gm2OvTiVE+dNl/7Ao4pkwSxETN6MXhZOM=; b=fqvj2xz2Y7LBfY2kgrkILXYe7OkS3V+0WNM5iI5zyLqVWz4ncPsj5Gug6+BdviZj1p19ht J9oq5i6iiypW51BA== Date: Wed, 26 Feb 2025 12:44:51 +0100 Subject: [PATCH v2 12/16] selftests: vDSO: parse_vdso: Use UAPI headers instead of libc headers Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-12-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=1432; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=NpOQuxLd7KblcjFPnaDO5YLxwLL0GxVqW0hZLzvIMGU=; b=BydQiC7WSVdw/x16VGHd/isTYEFPQRCC8tWJqgc6V5z56jGxevn7QCMyZsO+B05AJDzv33MAK PuOScLjhZV2AIyOKJjKaNG13VKt33YtjRyhTvRtCC08kinDMNFqnNh0 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= To allow the usage of parse_vdso.c together with a limited libc like nolibc, use the kernels own elf.h and auxvec.h headers. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/Makefile | 3 +++ tools/testing/selftests/vDSO/parse_vdso.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index 1cf14a8da43803249f72fe1b09689c8834806986..bc8ca186fb877dc11740c37f1e07e45e84c2ae92 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -19,6 +19,9 @@ LDLIBS += -lgcc_s endif include ../lib.mk + +CFLAGS += $(TOOLS_INCLUDES) + $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 3638fe605e80ca41b29d43c6ac452964eef35d56..200c534cc70e2c2381fce3be5c0ebe4cb5675e84 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -19,7 +19,8 @@ #include #include #include -#include +#include +#include #include "parse_vdso.h" From patchwork Wed Feb 26 11:44:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 868685 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7D9DA21C18D; Wed, 26 Feb 2025 11:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570321; cv=none; b=JjsQQVga16kb95RMAVClgBZ+PyUfH3U8MVeC8Jl+u76OA0gVg1KT8LYyzM+VLDeP3vWgDtGv7MYchNBxLU5jMeg31IaJd+MrFL0/5vnx7iu8K8m439Yx8d+DZsxtJ3FegK6YUORdRdM7MTGmKOIZjyYalrcSoK/PBHmLzj8Ucug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740570321; c=relaxed/simple; bh=WWyAjd0lBF4CXtwQtc/ysMPL9nKJJ2TfKtJWs4lpBX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VABNOFry8B+1879UlQRKhyzZ0PtGxYDeMHeKbeYiPgARru5nHdU2zlybEfgulUNKmLxnq861DPDY9obuZEP8CdiijvSzciQFS53aR4Ugki5bsx/NlFHTBHPuczR5nwpx43CGwpzloe+1XuLaMGhTsAZV/o30NZVNW+849jEo29s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Cz89Id9c; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=J3vBFrZE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Cz89Id9c"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="J3vBFrZE" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1740570316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KmfOckZ/ezvQbsI8oO+Ny3Ym1fUd+U8v8PjgJTjlhxI=; b=Cz89Id9c4ksgUOgosrPPNmwyzc5OKRgE9qa1PugTJjc1cFpW9PuK8csLf7OB3IAY/+atTy hI/yr4MQ+kKIXKXRiQ9AXIENDMON68EnXvSPnTwm5lA67ZNS4fuGaWhEHisG4puxEmWpw6 LYUJzBPLthSFjGItdaAbEG+l8Q1kVSLGzofdX0MT9B7MLBVKiFFNZrCLmMWN+vyZwGJuOe 1MjWYMlTR6L67MoeHJySswLdQGCnAix3nrNitijKTktwZ0TXNUmrd9tYwvM7FqUdYEET62 4dJp098YriaYtQbVR5ZexqGvMNUXybnnuHIOZeqMhJXt442czFbaSrEJEX+3/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1740570316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KmfOckZ/ezvQbsI8oO+Ny3Ym1fUd+U8v8PjgJTjlhxI=; b=J3vBFrZE7Gqbw7nLy2FHLopfTbyhb8kHRu8GOflxPHt+K1mwDynfrmzJHe3nRahi4IoVcJ KzHPP2kN6U0BEbAQ== Date: Wed, 26 Feb 2025 12:44:53 +0100 Subject: [PATCH v2 14/16] selftests: vDSO: vdso_test_gettimeofday: Clean up includes Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-parse_vdso-nolibc-v2-14-28e14e031ed8@linutronix.de> References: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> In-Reply-To: <20250226-parse_vdso-nolibc-v2-0-28e14e031ed8@linutronix.de> To: Kees Cook , Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: "Jason A. Donenfeld" , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1740570307; l=803; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=WWyAjd0lBF4CXtwQtc/ysMPL9nKJJ2TfKtJWs4lpBX4=; b=+fuDixwMNSldXS0xZq4UG3e35Jkdqz3L8iCNemrw4+F22qokhU7Kj+KsVf+lfrLCvsyk+iW2X qeJLhMVLb+GDidiqgXjdZQ56hlRiXdMtCfRrci9t2Lx+m5fYoikviHj X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Some unnecessary headers are included, remove them. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_gettimeofday.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c index e31b18ffae338c1576449b54ca7f84d9816d2ecb..636a56ccf8e4e7943ca446fe3fad6897598ca77f 100644 --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c @@ -10,8 +10,6 @@ * Tested on x86, 32-bit and 64-bit. It may work on other architectures, too. */ -#include -#include #include #include #include