From patchwork Tue Sep 10 10:11:35 2024 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: 13798273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51451ECE582 for ; Tue, 10 Sep 2024 10:12:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D79938D0057; Tue, 10 Sep 2024 06:12:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D29C38D002B; Tue, 10 Sep 2024 06:12:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAC9A8D0057; Tue, 10 Sep 2024 06:12:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9A5B18D0056 for ; Tue, 10 Sep 2024 06:12:14 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5268A1214A7 for ; Tue, 10 Sep 2024 10:12:14 +0000 (UTC) X-FDA: 82548413388.26.93A595D Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf06.hostedemail.com (Postfix) with ESMTP id 6C7DD180002 for ; Tue, 10 Sep 2024 10:12:12 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=PC67wB7s; dkim=pass header.d=linutronix.de header.s=2020e header.b=C16MkPeq; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf06.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725963105; a=rsa-sha256; cv=none; b=7pZCAqLN9vmkSNJq9qdeYVpECj6xMeNyu+UKWHOcFB8Xxm46PPWDTHk3Zq66dy+3Ejke+F lcN382rq3SMG+ef0nyojnXVBZxFpuelM4a9oMPD62tddSmlILzj12XtJ81mbj2kZbnSnj7 x5AJGjs1a+2zYDSS/O0h2IOkMtd3z7M= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=PC67wB7s; dkim=pass header.d=linutronix.de header.s=2020e header.b=C16MkPeq; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf06.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725963105; h=from:from:sender: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:dkim-signature; bh=Aw53a5Rvwg/dU49bAIlP8Mu7Fhnc5e3mxIRp66Y411k=; b=2KQvLtiwiJhRsRj8ciJk9Fi9jyWKljhLl8EPKsbL9pJds4pNzAvtV4/J+UpEivY84IWV0F JclzveYrSqz4eFFa+vd4AdBSmEKFKCG9fmo7nFZRjGQZEO5ssnwyAKx/QY9JoDxPgEubl5 Rrota+MMFcTR3SH4sEOdSc5yclYOMZw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1725963130; 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=Aw53a5Rvwg/dU49bAIlP8Mu7Fhnc5e3mxIRp66Y411k=; b=PC67wB7sXxnn4OzWOcNiWmHW9UUtULit/pRNW8fo3ldFj7Irb3D20na336QuimHP9p/SUV 7wQ1g3yZM1S4WGkviH6mInOqJAyRftYYaK2xaW4Adfxp6Xk+itHHAOpplmNurQCkeiDNKX sjulgHoMQUVy/q+X6FIqx1krqgJTVFpC8F3TrAvLdnb5HatqZQ6ls9z7BRuqi97YMpXaNy lhf49TrA+TVn3ZTEpYogQtJcNwLm1smr/n+BEeRv3J9PsZc2bYCu7TN986PnVGH0mHJrBM kpDOaIac7COg73qIfnrsPKyIEOfMabNofqumL5vkN2YklNiWXzpOK8FcJix5IA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1725963130; 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=Aw53a5Rvwg/dU49bAIlP8Mu7Fhnc5e3mxIRp66Y411k=; b=C16MkPeqF9S7M7bBC6sXXAP7mUCI7b5tJ7gNYAZnlHkMFKP1dNonJsD2yrupPYBhccmGdH Q2wX/OcjlQntVxCg== Date: Tue, 10 Sep 2024 12:11:35 +0200 Subject: [PATCH 1/2] x86: vdso: Remove ifdeffery around page setup variants MIME-Version: 1.0 Message-Id: <20240910-x86-vdso-ifdef-v1-1-877c9df9b081@linutronix.de> References: <20240910-x86-vdso-ifdef-v1-0-877c9df9b081@linutronix.de> In-Reply-To: <20240910-x86-vdso-ifdef-v1-0-877c9df9b081@linutronix.de> To: Andy Lutomirski , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Eric Biederman , Kees Cook , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1725963129; l=3300; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=8arqUqlv9Yca0CDTv97whbQWjAlS4Kk1slWC0wCJ1a0=; b=tapd06fgPweJXzTdfvCva07z0vfQI3KpTMKs/6gmn6mpk0TXnR8+iMC3arJc2Q7MsFdajtJ2Y 2XIfiRst9gKCaWCbE/KrAF2i/9S55t0Lv+7/gb1NU/Hoa2zq898/mxd X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspam-User: X-Rspamd-Queue-Id: 6C7DD180002 X-Rspamd-Server: rspam01 X-Stat-Signature: 489agmdq51cc5dxgujdpazonyndz31qq X-HE-Tag: 1725963132-831465 X-HE-Meta: U2FsdGVkX1+xrBBAkHRZ16yHnKae/Zz0nY4lSJKoDM+H5RB3tHyYe260Uhf6RqU7ps0/WgRHFfGVzhh48cPrwwbJQA69MVby3o7Dhd0GfisLtn/KSGiZw3Jzw+EMJ+qkTUNcR3XC+GXpIiZhN0vrVffnsjaLNWQUqaZKN4GMOzUBmpZub8TD+2jhls3kjuaGOn3gYf5P/ASI1ogrb2ZajZtioG7hIfY+y22dYO2iYUyHuOWEEBqZYOm0DBoOToSyREta2pzXu4iab4zgrWMX3UXojOhiiB6kYtVq2YZF3tqjo7Msxp59M0CuBLRQkpiHma4gcnJmtT2rPIrzdWwQvXAJaZVcW+z2Eoh2jotS3X0mm/eLWaUSNnXJnkRssrARsP4Ilxli8PPcwq4ihRgYJPg3jJsKKJw4lPWhIDom9AAXZ61Bhrqg5Axd1FHwNnZq4dWHE+K3F80/USaowE7zNzZYCVZYHg1Gmz4I4SObJKybxHHAKslF+0BWU98gnhPRTn2xdx9eU8QqKI3ellxi+XavTYDPascDrTFIgWEsf2d9VmuhH1eG5HnY3NdmIrvhfmbSIgCjR62K4p1qffrMdQw63D3bkhdPsxIfVk5aVbL/LteKUJ1cHFCkVcbNuN2h0m7RHfFNjrHb32s5AAn+W7TwLGAhatM8dHi8tlCQuQFjlmxKOCzEX8iSYez7s1Ne6pav1YeUiI/Fr2KmOmJhIjdoxbAi9Os0O7U/+dweiAiMEzaeq5D8X0zbJ6Txao6oSlcuBw4LZXHvNZez7UX/A14imsETS2Vla0Ye+eOiGJFZF1gLB2xCHBJIgAOd6OdbhVvR81G6sJcC1FgTF5lBNz0nFgqiWb0nfe8kVyNYK2c4X9BkrCsWFeT7TNIU77KKKeEtOaedyxralfSL2UIWdsaa7wPjl+8zqufxMsxkLB3y0bVOb0UwiiMeu/DzHBPZmVLM/YsjYZhxrFvEc+/ zABhT0Mk 38SLwB95YD9qGWyITL9RjsrKTD2R7bBlheeBmE+yvc4ES7ETAT70DNWo8idy5ChBTyJqUmuhpeWaA+RiQDNUndj9Z2rmOag5/vUDqvwRZ+D2AdGB4y9er7t83U4T9Hq/2kVZaOZwXigrYwBnOhJDhjTaJhgyfCceX94VrV6X8qZ2gveTssuNbcQmgkgrkcSzGLIhfooVIUFto8qhNSjAf+9Lcq2VWyqhGOuslv0FMw86lg1VkXSw0UfqAYd4kFmfItIZMbSUVqGkhmRCXFTg3kd/aeRebgCLjSobft5QTKdoYKux3Bh7lFzJNfRYRd0BMGOckKZzXnWaUM9MPcLAY09vmAY7oRARbg2a8NuduOZ9AbGXSRjWvmpsiNqENvcsdTS8Pt6OD4G4UBa8gdDL94bc6Gg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replace the open-coded ifdefs in C sources files with IS_ENABLED(). This makes the code easier to read and enables the compiler to typecheck also the disabled parts, before optimizing them away. To make this work, also remove the ifdefs from declarations of used variables. Signed-off-by: Thomas Weißschuh --- arch/x86/entry/vdso/vma.c | 31 ++++++++++++------------------- arch/x86/include/asm/elf.h | 4 ---- arch/x86/include/asm/vdso.h | 8 -------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 6d83ceb7f1ba..9059b9d96393 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -300,7 +300,6 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr) return map_vdso(image, addr); } -#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) static int load_vdso32(void) { if (vdso32_enabled != 1) /* Other values all mean "disabled" */ @@ -308,39 +307,33 @@ static int load_vdso32(void) return map_vdso(&vdso_image_32, 0); } -#endif -#ifdef CONFIG_X86_64 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { - if (!vdso64_enabled) - return 0; + if (IS_ENABLED(CONFIG_X86_64)) { + if (!vdso64_enabled) + return 0; + + return map_vdso(&vdso_image_64, 0); + } - return map_vdso(&vdso_image_64, 0); + return load_vdso32(); } #ifdef CONFIG_COMPAT int compat_arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp, bool x32) { -#ifdef CONFIG_X86_X32_ABI - if (x32) { + if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) { if (!vdso64_enabled) return 0; return map_vdso(&vdso_image_x32, 0); } -#endif -#ifdef CONFIG_IA32_EMULATION - return load_vdso32(); -#else + + if (IS_ENABLED(CONFIG_IA32_EMULATION)) + return load_vdso32(); + return 0; -#endif -} -#endif -#else -int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) -{ - return load_vdso32(); } #endif diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 1fb83d47711f..d5a5dadc1cbe 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -75,12 +75,8 @@ typedef struct user_i387_struct elf_fpregset_t; #include -#ifdef CONFIG_X86_64 extern unsigned int vdso64_enabled; -#endif -#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) extern unsigned int vdso32_enabled; -#endif /* * This is used to ensure we don't load something for the wrong architecture. diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h index d7f6592b74a9..3f45bcc60b4d 100644 --- a/arch/x86/include/asm/vdso.h +++ b/arch/x86/include/asm/vdso.h @@ -33,17 +33,9 @@ struct vdso_image { long sym_vdso32_rt_sigreturn_landing_pad; }; -#ifdef CONFIG_X86_64 extern const struct vdso_image vdso_image_64; -#endif - -#ifdef CONFIG_X86_X32_ABI extern const struct vdso_image vdso_image_x32; -#endif - -#if defined CONFIG_X86_32 || defined CONFIG_COMPAT extern const struct vdso_image vdso_image_32; -#endif extern int __init init_vdso_image(const struct vdso_image *image);