From nobody Sat Nov 30 07:39:10 2024 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 03091188A38 for ; Tue, 10 Sep 2024 10:12: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=1725963133; cv=none; b=LQkkXu6h3ZSqE7IU3aHNve1EU4Qn8PMrcuxRIyp+26dV8CPE8zaW4SAHDr4IGEB7lFaA7KMxbFhHjqas/yNdj0UpKDoNUZEA3Qy2eD4dz4rg5n4AfC1G9EPkKmqtLlYodxrFtQHSc7q1q+wV3kzeJ46CjWTXJwUxUI4Nrmmzqrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963133; c=relaxed/simple; bh=8arqUqlv9Yca0CDTv97whbQWjAlS4Kk1slWC0wCJ1a0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NxBDVRm0uaA9/xzmo1Fq5uiQByzH1T2Lne6EWDos4jZvO693cE/UGRkstvt64+Li/WuO/RV7ugLYRbdXRcjCTNy46nU174Kxj0mHDCAFfg0hEOhaf2mBAHTih/pqQHwH4XKZSvZ0pu/3cB8oZ7x1e/+FEat3m8gUBf1zT+eS3j4= 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=PC67wB7s; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=C16MkPeq; 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="PC67wB7s"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="C16MkPeq" 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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= 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=C3=9Fschuh --- 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, unsig= ned long addr) return map_vdso(image, addr); } =20 -#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) static int load_vdso32(void) { if (vdso32_enabled !=3D 1) /* Other values all mean "disabled" */ @@ -308,39 +307,33 @@ static int load_vdso32(void) =20 return map_vdso(&vdso_image_32, 0); } -#endif =20 -#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); + } =20 - return map_vdso(&vdso_image_64, 0); + return load_vdso32(); } =20 #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 =20 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; =20 #include =20 -#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 =20 /* * This is used to ensure we don't load something for the wrong architectu= re. 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; }; =20 -#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 =20 extern int __init init_vdso_image(const struct vdso_image *image); =20 --=20 2.46.0 From nobody Sat Nov 30 07:39:10 2024 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 7527B18A6D2 for ; Tue, 10 Sep 2024 10:12: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=1725963133; cv=none; b=V6j0QaPFk+wQBCz0Iu7dMxK+JJYyZ32zjqlTwtHneDbD9IcKSpoQXrr31oMUl2zqzlf22TKcrJCL2Ym1Zjl5q34OLBqDbos7i5zbilGhilGuikeRKWHUTuOkG7T4udp/yIkYF44NG08oMXQT5ZUXH4dJqMWlwdgAtvqQvLiDHB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963133; c=relaxed/simple; bh=CPeEQPomon0NN9hvYJGJq0EYPts0p9GT5vjukg23S/E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hdBqn7i5jWb3a84OIwAKb49oqNQIh4pNijN/z2rtCtSsVOzV9lJt7+Td+dFFOPehw483bJD6owZWvrtdsoszbB9W6XE0CWfVXKcbU/GtNQ6xjN7RD5Q9r3ka3cLaOps7j6XruZ2cJciTmlhJnrhi+vlL98Xy4+FIZNHsrYQ4g8E= 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=DUMJCp6G; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sTC9Mk9a; 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="DUMJCp6G"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sTC9Mk9a" 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=b8g6RfBCA+wrHgvUyJpXjlSeY1WblZvtq0QubmmLmGE=; b=DUMJCp6GuJqMeuEgOoMS/uXiZ8i9y+Vwy0Vf8y6OQUZg3Z03wUgdbvkzaan3S/NcLciCiZ GFaac2r6ey5LKPqSj5NAkQI7nqGQypQd81aX2RqsUFW/X27hWolKAeGgZ8bpt+ReqYJGR2 9PBzKtdDiHcuSXWOKq9RFQKD6PkpK0LkxPp8a9da5CEQC+1HmfaYt+RxjQcOEuf9WMNE0+ AeyCC2vbPojWOhXtFJVNJlUOrYAO2r0UKDNLsjbr3I3RzbKesiFTlP5CV29JQyvD/tuEzO H7qiXJgetoatGPKz4qglIlPsw/EduznrZpzxbfjHmAZqwp/orFPOaiFDGxXKog== 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=b8g6RfBCA+wrHgvUyJpXjlSeY1WblZvtq0QubmmLmGE=; b=sTC9Mk9aV3zglGwb7YyFbRPPOeOq0+O4vFdendmV63xsimF0jFa93Z0fx9yQQW7CsK0IYa tPCJQihsSf5tWVDQ== Date: Tue, 10 Sep 2024 12:11:36 +0200 Subject: [PATCH 2/2] x86: vdso: Remove redundant ifdeffery around in_ia32_syscall() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240910-x86-vdso-ifdef-v1-2-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=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1725963129; l=1673; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=CPeEQPomon0NN9hvYJGJq0EYPts0p9GT5vjukg23S/E=; b=6fIxdpbyKGs151uLINYPcvYcZRrBnUjDTlUtPTWMZXB3yrTogS7CNFivTzA+rsqsxIYTDUal+ kxO0LL0o9ZpDPswGKcoyBX8tJ0Mg6n1aao+VymNwEg3uQRNNKUq77t4 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The ifdefs only guard code that is also guarded by in_ia32_syscall(), which already contains the same ifdefs itself. Signed-off-by: Thomas Wei=C3=9Fschuh --- arch/x86/entry/vdso/vma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 9059b9d96393..ab2b011471e0 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -75,7 +75,6 @@ static vm_fault_t vdso_fault(const struct vm_special_mapp= ing *sm, static void vdso_fix_landing(const struct vdso_image *image, struct vm_area_struct *new_vma) { -#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION if (in_ia32_syscall() && image =3D=3D &vdso_image_32) { struct pt_regs *regs =3D current_pt_regs(); unsigned long vdso_land =3D image->sym_int80_landing_pad; @@ -86,7 +85,6 @@ static void vdso_fix_landing(const struct vdso_image *ima= ge, if (regs->ip =3D=3D old_land_addr) regs->ip =3D new_vma->vm_start + vdso_land; } -#endif } =20 static int vdso_mremap(const struct vm_special_mapping *sm, @@ -339,7 +337,6 @@ int compat_arch_setup_additional_pages(struct linux_bin= prm *bprm, =20 bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs) { -#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) const struct vdso_image *image =3D current->mm->context.vdso_image; unsigned long vdso =3D (unsigned long) current->mm->context.vdso; =20 @@ -348,7 +345,6 @@ bool arch_syscall_is_vdso_sigreturn(struct pt_regs *reg= s) regs->ip =3D=3D vdso + image->sym_vdso32_rt_sigreturn_landing_pad) return true; } -#endif return false; } =20 --=20 2.46.0