mbox series

[v5,0/2] arm64: Implement getrandom() in vDSO

Message ID 20240903120948.13743-1-adhemerval.zanella@linaro.org (mailing list archive)
Headers show
Series arm64: Implement getrandom() in vDSO | expand

Message

Adhemerval Zanella Netto Sept. 3, 2024, 12:09 p.m. UTC
Implement stack-less ChaCha20 and wire it with the generic vDSO
getrandom code.  The first patch is Mark's fix to the alternatives
system in the vDSO, while the the second is the actual vDSO work.

Changes from v4:
- Improve BE handling.

Changes from v3:
- Use alternative_has_cap_likely instead of ALTERNATIVE.
- Header/include and comment fixups.

Changes from v2:
- Refactor Makefile to use same flags for vgettimeofday and
  vgetrandom.
- Removed rodata usage and fixed BE on vgetrandom-chacha.S.

Changes from v1:
- Fixed style issues and typos.
- Added fallback for systems without NEON support.
- Avoid use of non-volatile vector registers in neon chacha20.
- Use c-getrandom-y for vgetrandom.c.
- Fixed TIMENS vdso_rnd_data access.

Adhemerval Zanella (1):
  arm64: vdso: wire up getrandom() vDSO implementation

Mark Rutland (1):
  arm64: alternative: make alternative_has_cap_likely() VDSO compatible

 arch/arm64/Kconfig                          |   1 +
 arch/arm64/include/asm/alternative-macros.h |   4 +
 arch/arm64/include/asm/mman.h               |   6 +-
 arch/arm64/include/asm/vdso.h               |   6 +
 arch/arm64/include/asm/vdso/getrandom.h     |  50 ++++++
 arch/arm64/include/asm/vdso/vsyscall.h      |  10 ++
 arch/arm64/kernel/vdso.c                    |   6 -
 arch/arm64/kernel/vdso/Makefile             |  25 ++-
 arch/arm64/kernel/vdso/vdso                 |   1 +
 arch/arm64/kernel/vdso/vdso.lds.S           |   4 +
 arch/arm64/kernel/vdso/vgetrandom-chacha.S  | 172 ++++++++++++++++++++
 arch/arm64/kernel/vdso/vgetrandom.c         |  15 ++
 tools/arch/arm64/vdso                       |   1 +
 tools/include/linux/compiler.h              |   4 +
 tools/testing/selftests/vDSO/Makefile       |   3 +-
 15 files changed, 292 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm64/include/asm/vdso/getrandom.h
 create mode 120000 arch/arm64/kernel/vdso/vdso
 create mode 100644 arch/arm64/kernel/vdso/vgetrandom-chacha.S
 create mode 100644 arch/arm64/kernel/vdso/vgetrandom.c
 create mode 120000 tools/arch/arm64/vdso

Comments

Will Deacon Sept. 4, 2024, 12:05 p.m. UTC | #1
+Ard as he had helpful comments on the previous version.

On Tue, Sep 03, 2024 at 12:09:15PM +0000, Adhemerval Zanella wrote:
> Implement stack-less ChaCha20 and wire it with the generic vDSO
> getrandom code.  The first patch is Mark's fix to the alternatives
> system in the vDSO, while the the second is the actual vDSO work.
> 
> Changes from v4:
> - Improve BE handling.
> 
> Changes from v3:
> - Use alternative_has_cap_likely instead of ALTERNATIVE.
> - Header/include and comment fixups.
> 
> Changes from v2:
> - Refactor Makefile to use same flags for vgettimeofday and
>   vgetrandom.
> - Removed rodata usage and fixed BE on vgetrandom-chacha.S.
> 
> Changes from v1:
> - Fixed style issues and typos.
> - Added fallback for systems without NEON support.
> - Avoid use of non-volatile vector registers in neon chacha20.
> - Use c-getrandom-y for vgetrandom.c.
> - Fixed TIMENS vdso_rnd_data access.
> 
> Adhemerval Zanella (1):
>   arm64: vdso: wire up getrandom() vDSO implementation
> 
> Mark Rutland (1):
>   arm64: alternative: make alternative_has_cap_likely() VDSO compatible
> 
>  arch/arm64/Kconfig                          |   1 +
>  arch/arm64/include/asm/alternative-macros.h |   4 +
>  arch/arm64/include/asm/mman.h               |   6 +-
>  arch/arm64/include/asm/vdso.h               |   6 +
>  arch/arm64/include/asm/vdso/getrandom.h     |  50 ++++++
>  arch/arm64/include/asm/vdso/vsyscall.h      |  10 ++
>  arch/arm64/kernel/vdso.c                    |   6 -
>  arch/arm64/kernel/vdso/Makefile             |  25 ++-
>  arch/arm64/kernel/vdso/vdso                 |   1 +
>  arch/arm64/kernel/vdso/vdso.lds.S           |   4 +
>  arch/arm64/kernel/vdso/vgetrandom-chacha.S  | 172 ++++++++++++++++++++
>  arch/arm64/kernel/vdso/vgetrandom.c         |  15 ++
>  tools/arch/arm64/vdso                       |   1 +
>  tools/include/linux/compiler.h              |   4 +
>  tools/testing/selftests/vDSO/Makefile       |   3 +-
>  15 files changed, 292 insertions(+), 16 deletions(-)
>  create mode 100644 arch/arm64/include/asm/vdso/getrandom.h
>  create mode 120000 arch/arm64/kernel/vdso/vdso
>  create mode 100644 arch/arm64/kernel/vdso/vgetrandom-chacha.S
>  create mode 100644 arch/arm64/kernel/vdso/vgetrandom.c
>  create mode 120000 tools/arch/arm64/vdso
> 
> -- 
> 2.43.0
>
Ard Biesheuvel Sept. 4, 2024, 12:28 p.m. UTC | #2
On Wed, 4 Sept 2024 at 14:05, Will Deacon <will@kernel.org> wrote:
>
> +Ard as he had helpful comments on the previous version.
>

Thanks for the cc

> On Tue, Sep 03, 2024 at 12:09:15PM +0000, Adhemerval Zanella wrote:
> > Implement stack-less ChaCha20 and wire it with the generic vDSO
> > getrandom code.  The first patch is Mark's fix to the alternatives
> > system in the vDSO, while the the second is the actual vDSO work.
> >
> > Changes from v4:
> > - Improve BE handling.
> >
> > Changes from v3:
> > - Use alternative_has_cap_likely instead of ALTERNATIVE.
> > - Header/include and comment fixups.
> >
> > Changes from v2:
> > - Refactor Makefile to use same flags for vgettimeofday and
> >   vgetrandom.
> > - Removed rodata usage and fixed BE on vgetrandom-chacha.S.
> >
> > Changes from v1:
> > - Fixed style issues and typos.
> > - Added fallback for systems without NEON support.
> > - Avoid use of non-volatile vector registers in neon chacha20.
> > - Use c-getrandom-y for vgetrandom.c.
> > - Fixed TIMENS vdso_rnd_data access.
> >
> > Adhemerval Zanella (1):
> >   arm64: vdso: wire up getrandom() vDSO implementation
> >
> > Mark Rutland (1):
> >   arm64: alternative: make alternative_has_cap_likely() VDSO compatible
> >

This looks ok to me now

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Jason A. Donenfeld Sept. 4, 2024, 1:53 p.m. UTC | #3
On Wed, Sep 04, 2024 at 02:28:32PM +0200, Ard Biesheuvel wrote:
> On Wed, 4 Sept 2024 at 14:05, Will Deacon <will@kernel.org> wrote:
> >
> > +Ard as he had helpful comments on the previous version.
> >
> 
> Thanks for the cc
> 
> > On Tue, Sep 03, 2024 at 12:09:15PM +0000, Adhemerval Zanella wrote:
> > > Implement stack-less ChaCha20 and wire it with the generic vDSO
> > > getrandom code.  The first patch is Mark's fix to the alternatives
> > > system in the vDSO, while the the second is the actual vDSO work.
> > >
> > > Changes from v4:
> > > - Improve BE handling.
> > >
> > > Changes from v3:
> > > - Use alternative_has_cap_likely instead of ALTERNATIVE.
> > > - Header/include and comment fixups.
> > >
> > > Changes from v2:
> > > - Refactor Makefile to use same flags for vgettimeofday and
> > >   vgetrandom.
> > > - Removed rodata usage and fixed BE on vgetrandom-chacha.S.
> > >
> > > Changes from v1:
> > > - Fixed style issues and typos.
> > > - Added fallback for systems without NEON support.
> > > - Avoid use of non-volatile vector registers in neon chacha20.
> > > - Use c-getrandom-y for vgetrandom.c.
> > > - Fixed TIMENS vdso_rnd_data access.
> > >
> > > Adhemerval Zanella (1):
> > >   arm64: vdso: wire up getrandom() vDSO implementation
> > >
> > > Mark Rutland (1):
> > >   arm64: alternative: make alternative_has_cap_likely() VDSO compatible
> > >
> 
> This looks ok to me now
> 
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

Great. Thanks a bunch for your reviews, Ard.

Will, if you want to Ack this, I'll queue it up with the other getrandom
vDSO patches for 6.12.

Jason
Will Deacon Sept. 4, 2024, 3:02 p.m. UTC | #4
On Wed, Sep 04, 2024 at 03:53:42PM +0200, Jason A. Donenfeld wrote:
> On Wed, Sep 04, 2024 at 02:28:32PM +0200, Ard Biesheuvel wrote:
> > On Wed, 4 Sept 2024 at 14:05, Will Deacon <will@kernel.org> wrote:
> > >
> > > +Ard as he had helpful comments on the previous version.
> > >
> > 
> > Thanks for the cc
> > 
> > > On Tue, Sep 03, 2024 at 12:09:15PM +0000, Adhemerval Zanella wrote:
> > > > Implement stack-less ChaCha20 and wire it with the generic vDSO
> > > > getrandom code.  The first patch is Mark's fix to the alternatives
> > > > system in the vDSO, while the the second is the actual vDSO work.
> > > >
> > > > Changes from v4:
> > > > - Improve BE handling.
> > > >
> > > > Changes from v3:
> > > > - Use alternative_has_cap_likely instead of ALTERNATIVE.
> > > > - Header/include and comment fixups.
> > > >
> > > > Changes from v2:
> > > > - Refactor Makefile to use same flags for vgettimeofday and
> > > >   vgetrandom.
> > > > - Removed rodata usage and fixed BE on vgetrandom-chacha.S.
> > > >
> > > > Changes from v1:
> > > > - Fixed style issues and typos.
> > > > - Added fallback for systems without NEON support.
> > > > - Avoid use of non-volatile vector registers in neon chacha20.
> > > > - Use c-getrandom-y for vgetrandom.c.
> > > > - Fixed TIMENS vdso_rnd_data access.
> > > >
> > > > Adhemerval Zanella (1):
> > > >   arm64: vdso: wire up getrandom() vDSO implementation
> > > >
> > > > Mark Rutland (1):
> > > >   arm64: alternative: make alternative_has_cap_likely() VDSO compatible
> > > >
> > 
> > This looks ok to me now
> > 
> > Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> 
> Great. Thanks a bunch for your reviews, Ard.
> 
> Will, if you want to Ack this, I'll queue it up with the other getrandom
> vDSO patches for 6.12.

I won't pretend to have reviewed the chacha asm, but the rest of it looks
good to me. Thanks!

Acked-by: Will Deacon <will@kernel.org>

Will
Jason A. Donenfeld Sept. 4, 2024, 3:56 p.m. UTC | #5
On Wed, Sep 4, 2024 at 5:03 PM Will Deacon <will@kernel.org> wrote:
>
> On Wed, Sep 04, 2024 at 03:53:42PM +0200, Jason A. Donenfeld wrote:
> > On Wed, Sep 04, 2024 at 02:28:32PM +0200, Ard Biesheuvel wrote:
> > > On Wed, 4 Sept 2024 at 14:05, Will Deacon <will@kernel.org> wrote:
> > > >
> > > > +Ard as he had helpful comments on the previous version.
> > > >
> > >
> > > Thanks for the cc
> > >
> > > > On Tue, Sep 03, 2024 at 12:09:15PM +0000, Adhemerval Zanella wrote:
> > > > > Implement stack-less ChaCha20 and wire it with the generic vDSO
> > > > > getrandom code.  The first patch is Mark's fix to the alternatives
> > > > > system in the vDSO, while the the second is the actual vDSO work.
> > > > >
> > > > > Changes from v4:
> > > > > - Improve BE handling.
> > > > >
> > > > > Changes from v3:
> > > > > - Use alternative_has_cap_likely instead of ALTERNATIVE.
> > > > > - Header/include and comment fixups.
> > > > >
> > > > > Changes from v2:
> > > > > - Refactor Makefile to use same flags for vgettimeofday and
> > > > >   vgetrandom.
> > > > > - Removed rodata usage and fixed BE on vgetrandom-chacha.S.
> > > > >
> > > > > Changes from v1:
> > > > > - Fixed style issues and typos.
> > > > > - Added fallback for systems without NEON support.
> > > > > - Avoid use of non-volatile vector registers in neon chacha20.
> > > > > - Use c-getrandom-y for vgetrandom.c.
> > > > > - Fixed TIMENS vdso_rnd_data access.
> > > > >
> > > > > Adhemerval Zanella (1):
> > > > >   arm64: vdso: wire up getrandom() vDSO implementation
> > > > >
> > > > > Mark Rutland (1):
> > > > >   arm64: alternative: make alternative_has_cap_likely() VDSO compatible
> > > > >
> > >
> > > This looks ok to me now
> > >
> > > Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> >
> > Great. Thanks a bunch for your reviews, Ard.
> >
> > Will, if you want to Ack this, I'll queue it up with the other getrandom
> > vDSO patches for 6.12.
>
> I won't pretend to have reviewed the chacha asm, but the rest of it looks
> good to me. Thanks!
>
> Acked-by: Will Deacon <will@kernel.org>

All applied. Thanks for the patches, Adhemerval.

Jason