From nobody Mon Feb 9 00:46:55 2026 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 6E00E2D0291 for ; Tue, 29 Apr 2025 12:56:07 +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=1745931369; cv=none; b=qD3l8Yfp8CVCH9nEsT2JwAdToB3YH1CWnzCXb4JmjIh+d5W+ZthXrs3K+WA1pfLjN23cZqnpLBuhd31Vquil55Z3qU7dIjorN2VYfNdxx9lc+WoABaGDEzmEqgInggJAd+Fo9GAHafvDM7YIagIbtPiK+zsVjUw4oZI89c4a0vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745931369; c=relaxed/simple; bh=INK9Od3tUzX/v4E46BjhJMmtIlN+Zo0XqWPW2JYr1OI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DUisiUhB3kh2PbvziMhGHstibOBBSkALcYYIy7Y2VBVpT6hB8HgQCdozmcHd6R+OV/UsSPcqUme5fGTN5OndZALDG/VUazrnkCH5DMUjK/DHUBAxRdk+bViGiM/CQO1/esZvI3uhDsvexUG7qbf51HjjjTFCWJeiabVGL95c/MQ= 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=wvbJc/Ar; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f+nwILJs; 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="wvbJc/Ar"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f+nwILJs" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745931365; 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=GqICM7uyVMGkK7SLU64r2+T/eRW2AwS+gh4wbVwSSF0=; b=wvbJc/ArYz1G3ydNa8bWB5oxdrBWIlXYZSgO5X9Ef/NZ/950vJu5OrkYd/A/NNcEzE20S9 xnRyfqMC6SP75SeayKrFJGFzrpBqJUd4fM6zsL0sx0ahPVVz5BiqK3jb2MEWMvKTgN27au qMXB3ezK1iYtPMy86rAfi7D+4rZJfVzLizWvo6Td3F926mGM08G9MeObGhQZqwit9poywc zva3wxdcQIpxMLDa7VymSbfgKkcO9+xRi2Zh0T8xqDt2pcLygWAV177uJZOrsR5d+lNaVr AIcmNla/V7Cs+TTs4Uh4BGtaElBi+e4nJv2U/3pibo8bTdVTYHs0cN3cRI38xQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745931365; 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=GqICM7uyVMGkK7SLU64r2+T/eRW2AwS+gh4wbVwSSF0=; b=f+nwILJsoAH1P+BArqTVCbZ0crHGk6dErfsx4KHdfW7CTMl/agpQXI0EkV9JZLWJGvVvSV ea2j/wKDDehz+pBw== Date: Tue, 29 Apr 2025 14:55:36 +0200 Subject: [PATCH 1/2] arm64: vdso: Work around invalid absolute relocations from GCC 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: <20250429-vdso-absolute-reloc-v1-1-987a0afd10b5@linutronix.de> References: <20250429-vdso-absolute-reloc-v1-0-987a0afd10b5@linutronix.de> In-Reply-To: <20250429-vdso-absolute-reloc-v1-0-987a0afd10b5@linutronix.de> To: Catalin Marinas , Will Deacon , Nam Cao , Anna-Maria Behnsen , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jan Stancek , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1745931364; l=1838; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=INK9Od3tUzX/v4E46BjhJMmtIlN+Zo0XqWPW2JYr1OI=; b=5ulHzGKF8eFCCLAu6Yp7Cqqk1q0uP93WsZLqtT+NWoE32DIh15DiO4tlLvTLbzAIl1hroMJFj yiovnOdkrEtDrIZnMX0N/vkD6WmdCNt1E1kYrlSvz+ove/PIVfAnVfb X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All vDSO code needs to be completely position independent. Symbol references are marked as hidden so the compiler is forced to emit PC-relative relocations. However GCC emits absolute relocations for symbol-relative references with an offset >=3D 64KiB. This is the case in __arch_get_vdso_u_timens_data() with a page size of 64KiB. Work around the issue by preventing the optimizer from seeing the offsets. Reported-by: Jan Stancek Closes: https://lore.kernel.org/lkml/aApGPAoctq_eoE2g@t14ultra/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D120002 Fixes: 83a2a6b8cfc5 ("vdso/gettimeofday: Prepare do_hres_timens() for intro= duction of struct vdso_clock") Signed-off-by: Thomas Wei=C3=9Fschuh --- arch/arm64/include/asm/vdso/gettimeofday.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/includ= e/asm/vdso/gettimeofday.h index 92a2b59a9f3df4d20feb483e6d8ebd1d813b7932..3322c7047d84fecae316a2904f1= adec0cb458f6f 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -99,6 +99,19 @@ static __always_inline u64 __arch_get_hw_counter(s32 clo= ck_mode, return res; } =20 +#if IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB) +static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time= _data(void) +{ + const struct vdso_time_data *ret =3D &vdso_u_time_data; + + /* Work around invalid absolute relocations */ + OPTIMIZER_HIDE_VAR(ret); + + return ret; +} +#define __arch_get_vdso_u_time_data __arch_get_vdso_u_time_data +#endif /* IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB= ) */ + #endif /* !__ASSEMBLY__ */ =20 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */ --=20 2.49.0 From nobody Mon Feb 9 00:46:55 2026 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 E6A812D1918 for ; Tue, 29 Apr 2025 12:56:07 +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=1745931369; cv=none; b=lQE3klng3PilJnJmqPNk5JG6cUJ4khLGDpTRcui57Fs4CvbKLyjsT4w8KG2CT0G6ABjqNanRBn6q6PCFX6H1DjQKIV/YgiOLJMXfIg4b3kDySu1GFY8+TrEIFp6Mma/NKF4YjbaZY2k1YM1qEFmnCswMQ2OLRGrOgVFJ6LSNrR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745931369; c=relaxed/simple; bh=9ioab1t8nXmZsDjk3HszCYql2zzBu0n7CbR97op4z8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IOVwwZMAssunmMdfv7Sxrs19VRfHgD0fD7vpQFR7ZNPi+KnjlwjQcjNFXBIJAjq2AAiv12139jEWWLyrRKlHFmxyvleba5GT/CC/PcQKkLITXZms2QAl8+TUvHt/eo9KXdyZl+v0mSy2Za3Uruxf2xXgchJlwdxVGBTR7Z9ijdw= 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=D83lzDxK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZzP2ctHO; 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="D83lzDxK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZzP2ctHO" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745931366; 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=0g0kq1GJUBlyV/4mQJ3oyVCKLrTdBKzHhBh0h2Qg2mo=; b=D83lzDxKEAZKLS4xvhsGKAkVZ2FickjGHV3/zzSVppOCWil0Tbzc8wufIlnJBVvuWYsyuk C8iU/e6zFpn8ZBPdEDk3grjFVTFOr3Sei/Le6LRc7T3cpYi9Hasga/O+D6cQNV2zM4bULR kZPbmKxFEjVeONu4cmYT0ds/CMFMyKilPUyuQp/ObDMg6hu1orxhWQuBiiVD9TuphEJDOY SCWByvzmGiyVJ0rC7Zy1xGukru3pBwY/X6NiR7kEvNaRXMsm1TOxuohBy32eFegUWyH6hS 0AqpHeDkWwBiTTAAfITX5ZI92CyKnliNE0NnvbbTKF0Etr4y9+ksLsHW05Y/Gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745931366; 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=0g0kq1GJUBlyV/4mQJ3oyVCKLrTdBKzHhBh0h2Qg2mo=; b=ZzP2ctHOk/iRiYGC2HJzCvIlvid5mdyxGKtuWdGZmF4K/4eRWmqmwAyb8IOOgI8EvFysi9 lBdHmjUTAvjfzcBQ== Date: Tue, 29 Apr 2025 14:55:37 +0200 Subject: [PATCH 2/2] vdso: Reject absolute relocations during build 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: <20250429-vdso-absolute-reloc-v1-2-987a0afd10b5@linutronix.de> References: <20250429-vdso-absolute-reloc-v1-0-987a0afd10b5@linutronix.de> In-Reply-To: <20250429-vdso-absolute-reloc-v1-0-987a0afd10b5@linutronix.de> To: Catalin Marinas , Will Deacon , Nam Cao , Anna-Maria Behnsen , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jan Stancek , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1745931364; l=1750; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=9ioab1t8nXmZsDjk3HszCYql2zzBu0n7CbR97op4z8s=; b=GqG+9nPu7ZpzsSRTLeO2J+RE6AibS1nmAQY+eWO/BXhGhDl4ouHvQk/DiwhEMyISnB+xhLsVj EaQ8sXrRPAnBp0itVvNsR/q6jLtqLGyAfNgi6F8tfv7Q58pRYAmmuOb X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All vDSO code needs to be completely position independent. Symbol references are marked as hidden so the compiler is forced to emit PC-relative relocations. If the compiler does however emit an absolute relocation this will be resolved by the linker and break at runtime. Introduce a build-time check for absolute relocations. The check is done on the object files as the relocations will not exist anymore in the final DSO. As there is no extension point for the compilation of each object file perform the validation in vdso_check. Link: https://lore.kernel.org/lkml/aApGPAoctq_eoE2g@t14ultra/ Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vdso/Makefile.include | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vdso/Makefile.include b/lib/vdso/Makefile.include index cedbf15f80874d4bb27c097244bc5b11272f261c..18fcc94e4d6bf7abf374c7a9533= 49e7ad75f8a18 100644 --- a/lib/vdso/Makefile.include +++ b/lib/vdso/Makefile.include @@ -12,7 +12,12 @@ c-getrandom-$(CONFIG_VDSO_GETRANDOM) :=3D $(addprefix $(= GENERIC_VDSO_DIR), getrand # # As a workaround for some GNU ld ports which produce unneeded R_*_NONE # dynamic relocations, ignore R_*_NONE. +# +# Also validate that no absolute relocations are present in the object fil= es themselves. quiet_cmd_vdso_check =3D VDSOCHK $@ cmd_vdso_check =3D if $(READELF) -rW $@ | grep -v _NONE | grep -q " = R_\w*_"; \ then (echo >&2 "$@: dynamic relocations are not supported"; \ + rm -f $@; /bin/false); fi && \ + if $(READELF) -rW $(filter %.o, $(real-prereqs)) | grep -q " R_\w= *_ABS"; \ + then (echo >&2 "$@: absolute relocations are not supported"; \ rm -f $@; /bin/false); fi --=20 2.49.0