mbox series

[v2,0/4] arm64: Allow the compat vdso to be disabled at runtime

Message ID 20200706163802.1836732-1-maz@kernel.org (mailing list archive)
Headers show
Series arm64: Allow the compat vdso to be disabled at runtime | expand

Message

Marc Zyngier July 6, 2020, 4:37 p.m. UTC
The relatively recent introduction of the compat vdso on arm64 has
overlooked its interactions with some of the interesting errata
workarounds, such as ARM64_ERRATUM_1418040 (and its older 1188873
incarnation).

This erratum requires the 64bit kernel to trap 32bit accesses to the
virtual counter and emulate it. When the workaround was introduced,
the compat vdso simply wasn't a thing. Now that the patches have
landed in mainline, we trap the CVTVCT accesses from the vdso.

This can end-up in a nasty loop in the vdso, where the sequence number
changes on each trap, never stabilising, and leaving userspace in a
bit of a funny state (which is why we disable the vdso in most similar
cases). This erratum mentionned above is a bit special in the sense
that in only requires to trap AArch32 accesses, and 64bit tasks can be
left alone. Consequently, the vdso is never disabled and AArch32 tasks
are affected.

Obviously, we really want to retain the 64bit vdso in this case. To
that effect, this series offers a way to disable the 32bit view of the
vdso without impacting its 64bit counterpart, by providing a
"no-compat" vdso clock_mode, and plugging this feature into the
1418040 detection code.

Lastly, I've tagged a rework of the 1414080 workaround (which had been
posted separately) at the end of the series so that it limits its
effect to 32bit tasks exclusively (so far, it forces the userspace
access bit on 64bit tasks, and we may need to leave it disabled in the
future...).

* From v1:
  - Reworked following Mark's feedback (patches #2 and #3)
  - Reworked patch #4 after Will's comments
  - patches #1 to #3 are now cc stable
  - Applied Mark's AB to patch #1

Marc Zyngier (4):
  arm64: Introduce a way to disable the 32bit vdso
  arm64: arch_timer: Allow an workaround descriptor to disable compat
    vdso
  arm64: arch_timer: Disable the compat vdso for cores affected by
    ARM64_WORKAROUND_1418040
  arm64: Rework ARM_ERRATUM_1414080 handling

 arch/arm64/include/asm/arch_timer.h           |  1 +
 arch/arm64/include/asm/vdso/clocksource.h     |  7 +++-
 .../include/asm/vdso/compat_gettimeofday.h    |  8 +++-
 arch/arm64/kernel/entry.S                     | 40 +++++++++++--------
 drivers/clocksource/arm_arch_timer.c          | 11 +++++
 5 files changed, 48 insertions(+), 19 deletions(-)

Comments

Will Deacon July 8, 2020, 10:02 p.m. UTC | #1
On Mon, 6 Jul 2020 17:37:58 +0100, Marc Zyngier wrote:
> The relatively recent introduction of the compat vdso on arm64 has
> overlooked its interactions with some of the interesting errata
> workarounds, such as ARM64_ERRATUM_1418040 (and its older 1188873
> incarnation).
> 
> This erratum requires the 64bit kernel to trap 32bit accesses to the
> virtual counter and emulate it. When the workaround was introduced,
> the compat vdso simply wasn't a thing. Now that the patches have
> landed in mainline, we trap the CVTVCT accesses from the vdso.
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/4] arm64: Introduce a way to disable the 32bit vdso
      https://git.kernel.org/arm64/c/97884ca8c292
[2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso
      https://git.kernel.org/arm64/c/c1fbec4ac0d7
[3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040
      https://git.kernel.org/arm64/c/4b661d6133c5
[4/4] arm64: Rework ARM_ERRATUM_1414080 handling
      https://git.kernel.org/arm64/c/dc802f2bc020

Cheers,