Skip to content

Commit 97884ca

Browse files
Marc Zyngierwilldeacon
authored andcommitted
arm64: Introduce a way to disable the 32bit vdso
We have a class of errata (grouped under the ARM64_WORKAROUND_1418040 banner) that force the trapping of counter access from 32bit EL0. We would normally disable the whole vdso for such defect, except that it would disable it for 64bit userspace as well, which is a shame. Instead, add a new vdso_clock_mode, which signals that the vdso isn't usable for compat tasks. This gets checked in the new vdso_clocksource_ok() helper, now provided for the 32bit vdso. Signed-off-by: Marc Zyngier <[email protected]> Acked-by: Mark Rutland <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent b8c1c9f commit 97884ca

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#ifndef __ASM_VDSOCLOCKSOURCE_H
33
#define __ASM_VDSOCLOCKSOURCE_H
44

5-
#define VDSO_ARCH_CLOCKMODES \
6-
VDSO_CLOCKMODE_ARCHTIMER
5+
#define VDSO_ARCH_CLOCKMODES \
6+
/* vdso clocksource for both 32 and 64bit tasks */ \
7+
VDSO_CLOCKMODE_ARCHTIMER, \
8+
/* vdso clocksource for 64bit tasks only */ \
9+
VDSO_CLOCKMODE_ARCHTIMER_NOCOMPAT
710

811
#endif

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
111111
* update. Return something. Core will do another round and then
112112
* see the mode change and fallback to the syscall.
113113
*/
114-
if (clock_mode == VDSO_CLOCKMODE_NONE)
114+
if (clock_mode != VDSO_CLOCKMODE_ARCHTIMER)
115115
return 0;
116116

117117
/*
@@ -152,6 +152,12 @@ static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
152152
return ret;
153153
}
154154

155+
static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
156+
{
157+
return vd->clock_mode == VDSO_CLOCKMODE_ARCHTIMER;
158+
}
159+
#define vdso_clocksource_ok vdso_clocksource_ok
160+
155161
#endif /* !__ASSEMBLY__ */
156162

157163
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */

0 commit comments

Comments
 (0)