Skip to content

Commit 0c314cd

Browse files
t-8chKAGA-KOKO
authored andcommitted
arm64: vdso: Work around invalid absolute relocations from GCC
All vDSO code needs to be completely position independent. Symbol references are marked as hidden so the compiler emits PC-relative relocations. However GCC emits absolute relocations for symbol-relative references with an offset >= 64KiB. After recent refactorings in the vDSO code 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. Fixes: 83a2a6b ("vdso/gettimeofday: Prepare do_hres_timens() for introduction of struct vdso_clock") Reported-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/all/20250430-vdso-absolute-reloc-v2-1-5efcc3bc4b26@linutronix.de Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120002 Closes: https://lore.kernel.org/lkml/aApGPAoctq_eoE2g@t14ultra/
1 parent b71f980 commit 0c314cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/arm64/include/asm/vdso/gettimeofday.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
9999
return res;
100100
}
101101

102+
#if IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB)
103+
static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void)
104+
{
105+
const struct vdso_time_data *ret = &vdso_u_time_data;
106+
107+
/* Work around invalid absolute relocations */
108+
OPTIMIZER_HIDE_VAR(ret);
109+
110+
return ret;
111+
}
112+
#define __arch_get_vdso_u_time_data __arch_get_vdso_u_time_data
113+
#endif /* IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB) */
114+
102115
#endif /* !__ASSEMBLY__ */
103116

104117
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */

0 commit comments

Comments
 (0)