mbox series

[Stable-5.4,0/3] arm64: Allow the compat vdso to be disabled at runtime

Message ID 20200715125614.3240269-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 15, 2020, 12:56 p.m. UTC
This is a backport of the series that recently went into 5.8. Note
that the first patch is more a complete rewriting than a backport, as
the vdso implementation in 5.4 doesn't have much in common with
mainline. This affects the 32bit arch code in a benign way.

It has seen very little testing, as I don't have the HW that triggers
this issue. I have run it in VMs by faking the CPU MIDR, and nothing
caught fire. Famous last words.

The original cover letter follows.

	M.

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.


Marc Zyngier (3):
  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

 arch/arm/include/asm/clocksource.h            | 11 ++++++++++-
 arch/arm/kernel/vdso.c                        |  2 +-
 arch/arm64/include/asm/arch_timer.h           |  1 +
 arch/arm64/include/asm/clocksource.h          |  5 ++++-
 arch/arm64/include/asm/vdso/clocksource.h     | 14 ++++++++++++++
 .../include/asm/vdso/compat_gettimeofday.h    |  5 +++--
 arch/arm64/include/asm/vdso/gettimeofday.h    |  6 ++++--
 arch/arm64/include/asm/vdso/vsyscall.h        |  4 +---
 drivers/clocksource/arm_arch_timer.c          | 19 +++++++++++++++----
 9 files changed, 53 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm64/include/asm/vdso/clocksource.h

Comments

Greg KH July 16, 2020, 11:58 a.m. UTC | #1
On Wed, Jul 15, 2020 at 01:56:11PM +0100, Marc Zyngier wrote:
> This is a backport of the series that recently went into 5.8. Note
> that the first patch is more a complete rewriting than a backport, as
> the vdso implementation in 5.4 doesn't have much in common with
> mainline. This affects the 32bit arch code in a benign way.
> 
> It has seen very little testing, as I don't have the HW that triggers
> this issue. I have run it in VMs by faking the CPU MIDR, and nothing
> caught fire. Famous last words.

These are also needed in 5.7.y, right?  If so, I need that series before
I can take this one as we don't want people moving to a newer kernel and
suffer regressions :(

thanks,

greg k-h
Marc Zyngier July 17, 2020, 8:02 a.m. UTC | #2
Hi Greg,

On 2020-07-16 12:58, Greg KH wrote:
> On Wed, Jul 15, 2020 at 01:56:11PM +0100, Marc Zyngier wrote:
>> This is a backport of the series that recently went into 5.8. Note
>> that the first patch is more a complete rewriting than a backport, as
>> the vdso implementation in 5.4 doesn't have much in common with
>> mainline. This affects the 32bit arch code in a benign way.
>> 
>> It has seen very little testing, as I don't have the HW that triggers
>> this issue. I have run it in VMs by faking the CPU MIDR, and nothing
>> caught fire. Famous last words.
> 
> These are also needed in 5.7.y, right?  If so, I need that series 
> before
> I can take this one as we don't want people moving to a newer kernel 
> and
> suffer regressions :(

The original mainline changes:

4b661d6133c5 arm64: arch_timer: Disable the compat vdso for cores 
affected by ARM64_WORKAROUND_1418040
c1fbec4ac0d7 arm64: arch_timer: Allow an workaround descriptor to 
disable compat vdso
97884ca8c292 arm64: Introduce a way to disable the 32bit vdso

do apply cleanly to stable-5.7. Do you want me to resend them 
separately,
or will you pick the patches directly from mainline?

Thanks,

         M.
Greg KH July 17, 2020, 9:33 a.m. UTC | #3
On Fri, Jul 17, 2020 at 09:02:06AM +0100, Marc Zyngier wrote:
> Hi Greg,
> 
> On 2020-07-16 12:58, Greg KH wrote:
> > On Wed, Jul 15, 2020 at 01:56:11PM +0100, Marc Zyngier wrote:
> > > This is a backport of the series that recently went into 5.8. Note
> > > that the first patch is more a complete rewriting than a backport, as
> > > the vdso implementation in 5.4 doesn't have much in common with
> > > mainline. This affects the 32bit arch code in a benign way.
> > > 
> > > It has seen very little testing, as I don't have the HW that triggers
> > > this issue. I have run it in VMs by faking the CPU MIDR, and nothing
> > > caught fire. Famous last words.
> > 
> > These are also needed in 5.7.y, right?  If so, I need that series before
> > I can take this one as we don't want people moving to a newer kernel and
> > suffer regressions :(
> 
> The original mainline changes:
> 
> 4b661d6133c5 arm64: arch_timer: Disable the compat vdso for cores affected
> by ARM64_WORKAROUND_1418040
> c1fbec4ac0d7 arm64: arch_timer: Allow an workaround descriptor to disable
> compat vdso
> 97884ca8c292 arm64: Introduce a way to disable the 32bit vdso
> 
> do apply cleanly to stable-5.7. Do you want me to resend them separately,
> or will you pick the patches directly from mainline?

Hm, cherry-pick seems to work due to file renames, let me try this
again...
Greg KH July 17, 2020, 9:47 a.m. UTC | #4
On Fri, Jul 17, 2020 at 11:33:57AM +0200, Greg KH wrote:
> On Fri, Jul 17, 2020 at 09:02:06AM +0100, Marc Zyngier wrote:
> > Hi Greg,
> > 
> > On 2020-07-16 12:58, Greg KH wrote:
> > > On Wed, Jul 15, 2020 at 01:56:11PM +0100, Marc Zyngier wrote:
> > > > This is a backport of the series that recently went into 5.8. Note
> > > > that the first patch is more a complete rewriting than a backport, as
> > > > the vdso implementation in 5.4 doesn't have much in common with
> > > > mainline. This affects the 32bit arch code in a benign way.
> > > > 
> > > > It has seen very little testing, as I don't have the HW that triggers
> > > > this issue. I have run it in VMs by faking the CPU MIDR, and nothing
> > > > caught fire. Famous last words.
> > > 
> > > These are also needed in 5.7.y, right?  If so, I need that series before
> > > I can take this one as we don't want people moving to a newer kernel and
> > > suffer regressions :(
> > 
> > The original mainline changes:
> > 
> > 4b661d6133c5 arm64: arch_timer: Disable the compat vdso for cores affected
> > by ARM64_WORKAROUND_1418040
> > c1fbec4ac0d7 arm64: arch_timer: Allow an workaround descriptor to disable
> > compat vdso
> > 97884ca8c292 arm64: Introduce a way to disable the 32bit vdso
> > 
> > do apply cleanly to stable-5.7. Do you want me to resend them separately,
> > or will you pick the patches directly from mainline?
> 
> Hm, cherry-pick seems to work due to file renames, let me try this
> again...

Ok, my fault, these are already all in 5.7.9, sorry for the noise.  I'll
go queue these up now.

greg "I need more coffee..." k-h