[PATCH 2/2] kselftest/arm64: Verify HWCAP2_SVE_B16B16

2023-09-15 Thread Mark Brown
Validate that SVE B16B16 support is reported correctly and consistently to userspace. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/hwcap.c | 13 + 1 file changed, 13 insertions(+) diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests

[PATCH 0/2] Report FEAT_SVE_B16B16 to userspace

2023-09-15 Thread Mark Brown
SVE 2.1 introduced a new feature FEAT_SVE_B16B16 which adds instructions supporting the BFloat16 floating point format. Report this to userspace through the ID registers and hwcap. Signed-off-by: Mark Brown --- Mark Brown (2): arm64/sve: Report FEAT_SVE_B16B16 to userspace kselftest

[PATCH 1/2] arm64/sve: Report FEAT_SVE_B16B16 to userspace

2023-09-15 Thread Mark Brown
SVE 2.1 introduced a new feature FEAT_SVE_B16B16 which adds instructions supporting the BFloat16 floating point format. Report this to userspace through the ID registers and hwcap. Reported-by: Peter Maydell Signed-off-by: Mark Brown --- Documentation/arch/arm64/cpu-feature-registers.rst | 2

Re: [PATCH] selftests/user_events: Fix to unmount tracefs when test created mount

2023-09-15 Thread Mark Brown
On Fri, Sep 15, 2023 at 10:27:54PM +, Beau Belgrave wrote: > Fix to unmount tracefs if the self-test mounted it to allow testing. > If tracefs was already mounted, this does nothing. Reviewed-by: Mark Brown signature.asc Description: PGP signature

Re: [PATCH] kselftest/alsa: pcm-test: Report cards declared in config but missing

2023-09-20 Thread Mark Brown
o be > present on the system is missing. This allows the configuration files to > not only be used to detect missing PCM devices (which is currently > possible) but also that the soundcard hasn't been registered at all. Reviewed-by: Mark Brown signature.asc Description: PGP signature

[PATCH] kselftest/arm64: Validate SVCR in streaming SVE stress test

2023-09-22 Thread Mark Brown
In the ZA and ZT test programs we explicitly validate that PSTATE.ZA is as expected on each loop but we do not do the equivalent for our streaming SVE test, add a check that we are still in streaming mode on every loop in case that goes wrong. Signed-off-by: Mark Brown --- tools/testing

[PATCH 0/3] selftests: timers: Convert some more of the timers tests to KTAP

2023-09-27 Thread Mark Brown
don't really benefit from KTAP and there were a couple where the conversion was a bit more complex so I've left them for now. Signed-off-by: Mark Brown --- Mark Brown (3): kselftest: Add a ksft_perror() helper selftests: timers: Convert posix_timers test to generate KTAP

[PATCH 1/3] kselftest: Add a ksft_perror() helper

2023-09-27 Thread Mark Brown
the table of strings required doesn't seem like a good fit for what it's trying to do so when we're using that only print the errno. Signed-off-by: Mark Brown --- tools/testing/selftests/kselftest.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tools/testing

[PATCH 2/3] selftests: timers: Convert posix_timers test to generate KTAP output

2023-09-27 Thread Mark Brown
. As part of this fix the printing of diagnostics in the unlikely event that the pthread APIs fail, these were using perror() but the API functions directly return an error code instead of setting errno. Signed-off-by: Mark Brown --- tools/testing/selftests/timers/posix_timers.c | 81

[PATCH 3/3] selftests: timers: Convert nsleep-lat test to generate KTAP output

2023-09-27 Thread Mark Brown
. Signed-off-by: Mark Brown --- tools/testing/selftests/timers/nsleep-lat.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/selftests/timers/nsleep-lat.c index eb3e79ed7b4a..edb5acacf214 100644

[PATCH 0/2] kselftest/exec: Convert execveat test to KTAP output

2023-09-28 Thread Mark Brown
ies timers test changes. Signed-off-by: Mark Brown --- Mark Brown (2): kselftest: Add a ksft_perror() helper selftests/exec: Convert execveat test to generate KTAP output tools/testing/selftests/exec/execveat.c | 87 - tools/testing/selftests/kselftest.

[PATCH 1/2] kselftest: Add a ksft_perror() helper

2023-09-28 Thread Mark Brown
the table of strings required doesn't seem like a good fit for what it's trying to do so when we're using that only print the errno. Signed-off-by: Mark Brown --- tools/testing/selftests/kselftest.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tools/testing

[PATCH 2/2] selftests/exec: Convert execveat test to generate KTAP output

2023-09-28 Thread Mark Brown
: Mark Brown --- tools/testing/selftests/exec/execveat.c | 87 - 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c index 67bf7254a48f..bf79d664c8e6 100644 --- a/tools/testing

Re: [PATCH 1/2] kselftest: Add a ksft_perror() helper

2023-09-29 Thread Mark Brown
On Thu, Sep 28, 2023 at 05:48:22PM -0700, Kees Cook wrote: > > nolibc doesn't have a strerror() and adding the table of strings required > > doesn't seem like a good fit for what it's trying to do so when we're using > > that only print the errno. > Oh, interesting... what environment ends up wit

Re: [PATCH 1/2] kselftest: Add a ksft_perror() helper

2023-10-01 Thread Mark Brown
On Fri, Sep 29, 2023 at 10:31:56AM -0700, Kees Cook wrote: > On Fri, Sep 29, 2023 at 09:50:53AM +0200, Mark Brown wrote: > > Like I say it's for nolibc - it's just some header files (all in the > > kernel source), while it generally aims to be libc compatible it'

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-02 Thread Mark Brown
On Thu, Sep 28, 2023 at 05:59:25PM +0100, Szabolcs Nagy wrote: > The 08/23/2023 14:11, Catalin Marinas wrote: > > > and there is user code doing raw clone threads (such threads are > > > technically not allowed to call into libc) it's not immediately > > > clear to me if having gcs in those thread

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-03 Thread Mark Brown
On Mon, Oct 02, 2023 at 09:43:25PM +, Edgecombe, Rick P wrote: > If ARM is thinking of doing things differently than x86, you might > think about how you weight those tradeoffs. Like, it might be silly to > worry about clone() support if something else ends up breaking > compatibility majorly.

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-03 Thread Mark Brown
On Tue, Oct 03, 2023 at 09:45:56AM +0100, Szabolcs Nagy wrote: > clone3 seems to have features that are only available in clone3 and > not exposed (reasonably) in libc apis so ppl will use clone3 directly > and those will be hard to fix for gcs (you have to convince upstream > to add future arm64

Re: [PATCH v1 05/20] arm64: context switch POR_EL0 register

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:08PM +0100, Joey Gouly wrote: > +/* Initial value for Permission Overlay Extension for EL0 */ > +#define POR_EL0_INIT UL(0x7) Might be useful to explain why this is the default (and possibly also define in terms of the constants for POR values)? > +static void permi

Re: [PATCH v1 01/20] arm64/sysreg: add system register POR_EL{0,1}

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:04PM +0100, Joey Gouly wrote: > Add POR_EL{0,1} according to DDI0601 2023-03. Reviewed-by: Mark Brown signature.asc Description: PGP signature

Re: [PATCH v1 07/20] arm64: enable the Permission Overlay Extension for EL0

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:10PM +0100, Joey Gouly wrote: > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -400,6 +400,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr2[] = { > }; > > static const struct arm64_ftr_bits ftr_id_aa64mmfr3[] = { > + A

Re: [PATCH v1 07/20] arm64: enable the Permission Overlay Extension for EL0

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:10PM +0100, Joey Gouly wrote: > Expose a HWCAP and ID_AA64MMFR3_EL1_S1POE to userspace, so they can be used to > check if the CPU supports the feature. Please also add the new hwcap to the hwcaps self test. signature.asc Description: PGP signature

Re: [PATCH v1 02/20] arm64/sysreg: update CPACR_EL1 register

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:05PM +0100, Joey Gouly wrote: > Add E0POE bit that traps accesses to POR_EL0 from EL0. > Updated according to DDI0601 2023-03. Reviewed-by: Mark Brown It's also up to date with DDI 0601 2023-09 it seems. signature.asc Description: PGP signature

Re: [PATCH v1 15/20] arm64: add POE signal support

2023-10-05 Thread Mark Brown
On Wed, Sep 27, 2023 at 03:01:18PM +0100, Joey Gouly wrote: > Add PKEY support to signals, by saving and restoring POR_EL0 from the > stackframe. It'd be nice to have at least a basic test that validates that we generate a POE signal frame when expected, though that should be a very minor thing w

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-06 Thread Mark Brown
On Thu, Oct 05, 2023 at 06:23:10PM +0100, Catalin Marinas wrote: > It's not just the default size that I dislike (I think the x86 > RLIMIT_STACK or clone3() stack_size is probably good enough) but the > kernel allocating the shadow stack and inserting it into the user > address space. The actual t

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-06 Thread Mark Brown
On Fri, Oct 06, 2023 at 07:29:45AM -0500, Eric W. Biederman wrote: > Mark Brown writes: > >> It's not just the default size that I dislike (I think the x86 > >> RLIMIT_STACK or clone3() stack_size is probably good enough) but the > >> kernel allocating the sha

[PATCH v6 00/38] arm64/gcs: Provide support for GCS in userspace

2023-10-09 Thread Mark Brown
rg/lkml/20230213045351.3945824-1-de...@rivosinc.com/ Pending feedback from Catalin: - Use clone3() paramaters to size/place the GCS. - Switch copy_to_user_gcs() to be put_user_gcs(). Signed-off-by: Mark Brown --- Changes in v6: - Rebase onto v6.6-rc3. - Add some more gcsb_dsync() barriers foll

[PATCH v6 01/38] arm64/mm: Restructure arch_validate_flags() for extensibility

2023-10-09 Thread Mark Brown
. Signed-off-by: Mark Brown --- arch/arm64/include/asm/mman.h | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h index 5966ee4a6154..c21849ffdd88 100644 --- a/arch/arm64/include/asm/mman.h +++ b/arch/arm64

[PATCH v6 02/38] prctl: arch-agnostic prctl for shadow stack

2023-10-09 Thread Mark Brown
locking interface reworked. The set status prctl() is also reworked to just set flags, if setting/reading the shadow stack pointer is required this could be a separate prctl. Signed-off-by: Mark Brown --- include/linux/mm.h | 4 include/uapi/linux/prctl.h | 22

[PATCH v6 03/38] mman: Add map_shadow_stack() flags

2023-10-09 Thread Mark Brown
stack marker suitable for use by unwinders should be added above that. For arm64 the top of stack marker is all bits 0. Signed-off-by: Mark Brown --- arch/x86/include/uapi/asm/mman.h | 3 --- include/uapi/asm-generic/mman.h | 4 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a

[PATCH v6 04/38] arm64: Document boot requirements for Guarded Control Stacks

2023-10-09 Thread Mark Brown
FEAT_GCS introduces a number of new system registers, we require that access to these registers is not trapped when we identify that the feature is detected. Signed-off-by: Mark Brown --- Documentation/arch/arm64/booting.rst | 22 ++ 1 file changed, 22 insertions(+) diff

[PATCH v6 05/38] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-09 Thread Mark Brown
Add some documentation of the userspace ABI for Guarded Control Stacks. Signed-off-by: Mark Brown --- Documentation/arch/arm64/gcs.rst | 233 + Documentation/arch/arm64/index.rst | 1 + 2 files changed, 234 insertions(+) diff --git a/Documentation/arch

[PATCH v6 06/38] arm64/sysreg: Add new system registers for GCS

2023-10-09 Thread Mark Brown
FEAT_GCS introduces a number of new system registers. Add the registers available up to EL2 to sysreg as per DDI0601 2022-12. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 55 + 1 file changed, 55 insertions(+) diff --git a/arch/arm64

[PATCH v6 07/38] arm64/sysreg: Add definitions for architected GCS caps

2023-10-09 Thread Mark Brown
The architecture defines a format for guarded control stack caps, used to mark the top of an unused GCS in order to limit the potential for exploitation via stack switching. Add definitions associated with these. Signed-off-by: Mark Brown --- arch/arm64/include/asm/sysreg.h | 20

[PATCH v6 08/38] arm64/gcs: Add manual encodings of GCS instructions

2023-10-09 Thread Mark Brown
sufficiently fast paths for this to be a problem. Note that GCSSTTR is used to store to EL0. Signed-off-by: Mark Brown --- arch/arm64/include/asm/gcs.h | 51 arch/arm64/include/asm/uaccess.h | 22 + 2 files changed, 73 insertions(+) diff --git

[PATCH v6 09/38] arm64/gcs: Provide copy_to_user_gcs()

2023-10-09 Thread Mark Brown
than u64 due to sparse. Signed-off-by: Mark Brown --- arch/arm64/include/asm/uaccess.h | 20 1 file changed, 20 insertions(+) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 22e10e79f56a..24aa804e95a7 100644 --- a/arch/arm64/include

[PATCH v6 10/38] arm64/cpufeature: Runtime detection of Guarded Control Stack (GCS)

2023-10-09 Thread Mark Brown
Add a cpufeature for GCS, allowing other code to conditionally support it at runtime. Signed-off-by: Mark Brown --- arch/arm64/include/asm/cpufeature.h | 6 ++ arch/arm64/kernel/cpufeature.c | 16 arch/arm64/tools/cpucaps| 1 + 3 files changed, 23

[PATCH v6 11/38] arm64/mm: Allocate PIE slots for EL0 guarded control stack

2023-10-09 Thread Mark Brown
to copy. Since the actual effect is defined using PIE the specific bit pattern used does not matter to the hardware but we choose two values which differ only in PTE_WRITE in order to help share code with non-PIE cases. Signed-off-by: Mark Brown --- arch/arm64/include/asm/pgtable-prot.h | 14

[PATCH v6 13/38] arm64/mm: Map pages for guarded control stack

2023-10-09 Thread Mark Brown
Map pages flagged as being part of a GCS as such rather than using the full set of generic VM flags. This is done using a conditional rather than extending the size of protection_map since that would make for a very sparse array. Signed-off-by: Mark Brown --- arch/arm64/include/asm/mman.h | 9

[PATCH v6 14/38] KVM: arm64: Manage GCS registers for guests

2023-10-09 Thread Mark Brown
GCS introduces a number of system registers for EL1 and EL0, on systems with GCS we need to context switch them and expose them to VMMs to allow guests to use GCS. Traps are already disabled. Signed-off-by: Mark Brown --- arch/arm64/include/asm/kvm_host.h | 12 arch/arm64

[PATCH v6 12/38] mm: Define VM_SHADOW_STACK for arm64 when we support GCS

2023-10-09 Thread Mark Brown
Use VM_HIGH_ARCH_5 for guarded control stack pages. Signed-off-by: Mark Brown --- Documentation/filesystems/proc.rst | 2 +- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 12 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a

[PATCH v6 15/38] arm64/gcs: Allow GCS usage at EL0 and EL1

2023-10-09 Thread Mark Brown
There is a control HCRX_EL2.GCSEn which must be set to allow GCS features to take effect at lower ELs and also fine grained traps for GCS usage at EL0 and EL1. Configure all these to allow GCS usage by EL0 and EL1. Signed-off-by: Mark Brown --- arch/arm64/include/asm/el2_setup.h | 17

[PATCH v6 16/38] arm64/idreg: Add overrride for GCS

2023-10-09 Thread Mark Brown
Hook up an override for GCS, allowing it to be disabled from the command line by specifying arm64.nogcs in case there are problems. Signed-off-by: Mark Brown --- Documentation/admin-guide/kernel-parameters.txt | 6 ++ arch/arm64/kernel/idreg-override.c | 2 ++ 2 files changed

[PATCH v6 18/38] arm64/traps: Handle GCS exceptions

2023-10-09 Thread Mark Brown
ating any GCS fault as fatal. Signed-off-by: Mark Brown --- arch/arm64/include/asm/esr.h | 28 +++- arch/arm64/include/asm/exception.h | 2 ++ arch/arm64/kernel/entry-common.c | 23 +++ arch/arm64/kernel/traps.c | 11 +++ 4

[PATCH v6 17/38] arm64/hwcap: Add hwcap for GCS

2023-10-09 Thread Mark Brown
Provide a hwcap to enable userspace to detect support for GCS. Signed-off-by: Mark Brown --- Documentation/arch/arm64/elf_hwcaps.rst | 3 +++ arch/arm64/include/asm/hwcap.h | 1 + arch/arm64/include/uapi/asm/hwcap.h | 1 + arch/arm64/kernel/cpufeature.c | 3 +++ arch/arm64

[PATCH v6 19/38] arm64/mm: Handle GCS data aborts

2023-10-09 Thread Mark Brown
it attempts to do GCS operations outside a GCS. Signed-off-by: Mark Brown --- arch/arm64/mm/fault.c | 79 +-- 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 2e5d1e238af9

[PATCH v6 20/38] arm64/gcs: Context switch GCS state for EL0

2023-10-09 Thread Mark Brown
been disabled. Signed-off-by: Mark Brown --- arch/arm64/include/asm/gcs.h | 24 arch/arm64/include/asm/processor.h | 6 arch/arm64/kernel/process.c| 56 ++ arch/arm64/mm/Makefile | 1 + arch/arm64/mm/gcs.c

[PATCH v6 21/38] arm64/gcs: Allocate a new GCS for threads with GCS enabled

2023-10-09 Thread Mark Brown
the GCS can easily detect the end of the region. Signed-off-by: Mark Brown --- arch/arm64/include/asm/gcs.h | 7 +++ arch/arm64/kernel/process.c | 36 + arch/arm64/mm/gcs.c | 47 3 files changed, 90

[PATCH v6 22/38] arm64/gcs: Implement shadow stack prctl() interface

2023-10-09 Thread Mark Brown
fault reporting. Since it is not an expected use case and since it presents some complications in determining what to do with previously initialsed data on the GCS attempts to reenable GCS after this are rejected. This can be revisted if a use case arises. Signed-off-by: Mark Brown --- arch/arm64

[PATCH v6 23/38] arm64/mm: Implement map_shadow_stack()

2023-10-09 Thread Mark Brown
de has not yet been rebased to v6.5-rc1 this includes the architecture neutral parts of Rick Edgecmbe's "x86/shstk: Introduce map_shadow_stack syscall". Signed-off-by: Mark Brown --- arch/arm64/mm/gcs.c | 61 ++- include/uapi/asm-gene

[PATCH v6 25/38] arm64/signal: Expose GCS state in signal frames

2023-10-09 Thread Mark Brown
, there is a conflict between specifying GCSPR_EL0 and allocation of a new GCS and this is not an ancticipated use case. We also enforce GCS configuration locking on signal return. Signed-off-by: Mark Brown --- arch/arm64/include/uapi/asm/sigcontext.h | 9 +++ arch/arm64/kernel/signal.c

[PATCH v6 24/38] arm64/signal: Set up and restore the GCS context for signal handlers

2023-10-09 Thread Mark Brown
stack switch instructions. Signed-off-by: Mark Brown --- arch/arm64/include/asm/gcs.h | 2 + arch/arm64/kernel/signal.c | 130 +-- arch/arm64/mm/gcs.c | 1 + 3 files changed, 128 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm

[PATCH v6 26/38] arm64/ptrace: Expose GCS via ptrace and core files

2023-10-09 Thread Mark Brown
Provide a new register type NT_ARM_GCS reporting the current GCS mode and pointer for EL0. Due to the interactions with allocation and deallocation of Guarded Control Stacks we do not permit any changes to the GCS mode via ptrace, only GCSPR_EL0 may be changed. Signed-off-by: Mark Brown

[PATCH v6 33/38] kselftest/arm64: Add very basic GCS test program

2023-10-09 Thread Mark Brown
This test program just covers the basic GCS ABI, covering aspects of the ABI as standalone features without attempting to integrate things. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/Makefile| 2 +- tools/testing/selftests/arm64/gcs/.gitignore | 1 + tools/testing

[PATCH v6 34/38] kselftest/arm64: Add a GCS test program built with the system libc

2023-10-09 Thread Mark Brown
There are things like threads which nolibc struggles with which we want to add coverage for, and the ABI allows us to test most of these even if libc itself does not understand GCS so add a test application built using the system libc. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64

[PATCH v6 35/38] kselftest/arm64: Add test coverage for GCS mode locking

2023-10-09 Thread Mark Brown
to not do that in the build system but there are no such toolchains yet so it is not yet an issue. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/gcs/.gitignore| 1 + tools/testing/selftests/arm64/gcs/Makefile | 2 +- tools/testing/selftests/arm64/gcs/gcs-locki

[PATCH v6 36/38] selftests/arm64: Add GCS signal tests

2023-10-09 Thread Mark Brown
Do some testing of the signal handling for GCS, checking that a GCS frame has the expected information in it and that the expected signals are delivered with invalid operations. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/.gitignore| 1 + .../selftests/arm64/signal

[PATCH v6 37/38] kselftest/arm64: Add a GCS stress test

2023-10-09 Thread Mark Brown
are inserted when moving a GCS using task to another CPU. The test runs for a configurable amount of time, defaulting to 10 seconds. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/gcs/.gitignore | 2 + tools/testing/selftests/arm64/gcs/Makefile | 6 +- tools/testing

[PATCH v6 38/38] kselftest/arm64: Enable GCS for the FP stress tests

2023-10-09 Thread Mark Brown
they continue to work as before on systems without GCS. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/assembler.h | 15 +++ tools/testing/selftests/arm64/fp/fpsimd-test.S | 2 ++ tools/testing/selftests/arm64/fp/sve-test.S| 2 ++ tools/testing/selftests/arm64/

[PATCH v6 28/38] kselftest/arm64: Verify the GCS hwcap

2023-10-09 Thread Mark Brown
Add coverage of the GCS hwcap to the hwcap selftest, using a read of GCSPR_EL0 to generate SIGILL without having to worry about enabling GCS. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/hwcap.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tools

[PATCH v6 30/38] kselftest/arm64: Add framework support for GCS to signal handling tests

2023-10-09 Thread Mark Brown
Teach the framework about the GCS signal context, avoiding warnings on the unknown context. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/testcases/testcases.c | 7 +++ tools/testing/selftests/arm64/signal/testcases/testcases.h | 1 + 2 files changed, 8 insertions

[PATCH v6 27/38] arm64: Add Kconfig for Guarded Control Stack (GCS)

2023-10-09 Thread Mark Brown
Provide a Kconfig option allowing the user to select if GCS support is built into the kernel. Signed-off-by: Mark Brown --- arch/arm64/Kconfig | 19 +++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b10515c0200b..d235e725177b 100644

[PATCH v6 29/38] kselftest/arm64: Add GCS as a detected feature in the signal tests

2023-10-09 Thread Mark Brown
In preparation for testing GCS related signal handling add it as a feature we check for in the signal handling support code. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/test_signals.h | 2 ++ tools/testing/selftests/arm64/signal/test_signals_utils.c | 3 +++ 2 files

[PATCH v6 32/38] kselftest/arm64: Always run signals tests with GCS enabled

2023-10-09 Thread Mark Brown
anything with stacks that would cause problems with GCS we can sidestep this issue by unconditionally enabling GCS on startup and exiting with a call to exit() rather than a return from main(). Signed-off-by: Mark Brown --- .../testing/selftests/arm64/signal/test_signals.c | 17

[PATCH v6 31/38] kselftest/arm64: Allow signals tests to specify an expected si_code

2023-10-09 Thread Mark Brown
Currently we ignore si_code unless the expected signal is a SIGSEGV, in which case we enforce it being SEGV_ACCERR. Allow test cases to specify exactly which si_code should be generated so we can validate this, and test for other segfault codes. Signed-off-by: Mark Brown --- .../testing

Re: [PATCH v1 15/20] arm64: add POE signal support

2023-10-09 Thread Mark Brown
On Thu, Oct 05, 2023 at 03:34:29PM +0100, Mark Brown wrote: > On Wed, Sep 27, 2023 at 03:01:18PM +0100, Joey Gouly wrote: > > Add PKEY support to signals, by saving and restoring POR_EL0 from the > > stackframe. > It'd be nice to have at least a basic test that validates t

Re: [PATCH v1 05/20] arm64: context switch POR_EL0 register

2023-10-10 Thread Mark Brown
On Tue, Oct 10, 2023 at 10:54:23AM +0100, Joey Gouly wrote: > On Thu, Oct 05, 2023 at 03:14:50PM +0100, Mark Brown wrote: > > On Wed, Sep 27, 2023 at 03:01:08PM +0100, Joey Gouly wrote: > > > + if (alternative_has_cap_unlikely(ARM64_HAS_S1POE)) { > > Why the _unlikely h

Re: [PATCH v1 15/20] arm64: add POE signal support

2023-10-10 Thread Mark Brown
On Tue, Oct 10, 2023 at 10:58:02AM +0100, Joey Gouly wrote: > On Mon, Oct 09, 2023 at 03:49:29PM +0100, Mark Brown wrote: > > Actually, now I think about it we at least need an update to the frame > > parser in userspace so it knows about the new frame. Without that it'll

Re: [PATCH v1 15/20] arm64: add POE signal support

2023-10-10 Thread Mark Brown
On Tue, Oct 10, 2023 at 10:57:02AM +0100, Joey Gouly wrote: > On Thu, Oct 05, 2023 at 03:34:29PM +0100, Mark Brown wrote: > > On Wed, Sep 27, 2023 at 03:01:18PM +0100, Joey Gouly wrote: > > > Add PKEY support to signals, by saving and restoring POR_EL0 from the > > &g

[PATCH] KVM: selftests: Initialise dynamically allocated configuration names

2023-10-12 Thread Mark Brown
-list test code") Signed-off-by: Mark Brown --- tools/testing/selftests/kvm/get-reg-list.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index be7bf5224434..dd62a6976c0d 100644 --- a/tools/testing/sel

[PATCH v2] KVM: selftests: Initialise dynamically allocated configuration names

2023-10-17 Thread Mark Brown
oduce vcpu configs") Reviewed-by: Andrew Jones Signed-off-by: Mark Brown --- Changes in v2: - Update Fixes: tag. - Link to v1: https://lore.kernel.org/r/20231013-kvm-get-reg-list-str-init-v1-1-034f370ff...@kernel.org --- tools/testing/selftests/kvm/get-reg-list.c | 1 + 1 file changed, 1

[PATCH] selftests/clone3: Report descriptive test names

2023-10-17 Thread Mark Brown
done in a moderately invasive fashion where we move from a sequence of function calls to having an array of test parameters. This hopefully also makes it a little easier to see what the tests are doing when looking at both the source and the logs. Signed-off-by: Mark Brown --- tools/testing/s

Re: [PATCH v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks

2023-10-19 Thread Mark Brown
On Thu, Oct 05, 2023 at 06:23:10PM +0100, Catalin Marinas wrote: > I haven't checked how many clone() or clone3() uses outside the libc are > (I tried some quick search in Debian but did not dig into the specifics > to see how generic that code is). I agree that having to change valid > cases outs

[PATCH] selftests/clone3: Skip new time namespace test when unsupported

2023-10-19 Thread Mark Brown
ize = 0, .expected = 0, .test_mode = CLONE3_ARGS_NO_TEST, + .filter = timens_unsupported, }, { .name = "exit signal (SIGCHLD) in flags", --- base-commit: 8d4099dd0727acfc8b0f644eacaf852f9d5dc649 change-id: 20231019-kselftest-clone3-time-ns-730b6f4187c7 Best regards, -- Mark Brown

Re: [PATCH] selftests/clone3: Skip new time namespace test when unsupported

2023-10-20 Thread Mark Brown
On Thu, Oct 19, 2023 at 04:35:38PM -0700, Andrew Morton wrote: > On Fri, 20 Oct 2023 00:08:12 +0100 Mark Brown wrote: > > Use a filter function to skip the time namespace test on systems with > > !CONFIG_TIME_NS. This reworks a fix originally done by Tiezhu Yang prior > >

[PATCH RFC RFT 0/5] fork: Support shadow stacks in clone3()

2023-10-23 Thread Mark Brown
cs-v6-0-78e55deaa...@kernel.org/ [2] https://lore.kernel.org/r/20231018-kselftest-clone3-output-v1-1-12b7c50ea...@kernel.org Signed-off-by: Mark Brown --- Mark Brown (5): mm: Introduce ARCH_HAS_USER_SHADOW_STACK fork: Add shadow stack support to clone3() selftests/clone3: Factor

[PATCH RFC RFT 1/5] mm: Introduce ARCH_HAS_USER_SHADOW_STACK

2023-10-23 Thread Mark Brown
Since multiple architectures have support for shadow stacks and we need to select support for this feature in several places in the generic code provide a generic config option that the architectures can select. Suggested-by: David Hildenbrand Signed-off-by: Mark Brown --- arch/x86/Kconfig

[PATCH RFC RFT 2/5] fork: Add shadow stack support to clone3()

2023-10-23 Thread Mark Brown
that into the shadow stack code rather than individual fields. Signed-off-by: Mark Brown --- arch/x86/include/asm/shstk.h | 11 +++ arch/x86/kernel/process.c| 2 +- arch/x86/kernel/shstk.c | 36 +++- include/linux/sched/task.h | 2 ++ include

[PATCH RFC RFT 4/5] selftests/clone3: Allow tests to flag if -E2BIG is a valid error code

2023-10-23 Thread Mark Brown
lone3() may return -E2BIG due to the use of newer struct versions. Currently no tests need this but it will become an issue for testing clone3() support for shadow stacks, the support for shadow stacks is already present on x86. Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3.

[PATCH RFC RFT 3/5] selftests/clone3: Factor more of main loop into test_clone3()

2023-10-23 Thread Mark Brown
change. Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3.c | 77 - 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c index 9429d361059e..afe383689a67

[PATCH RFC RFT 5/5] kselftest/clone3: Test shadow stack support

2023-10-23 Thread Mark Brown
map_shadow_stack(). Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3.c | 97 +++ tools/testing/selftests/clone3/clone3_selftests.h | 5 ++ 2 files changed, 102 insertions(+) diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests

Re: [PATCH RFC RFT 2/5] fork: Add shadow stack support to clone3()

2023-10-23 Thread Mark Brown
On Mon, Oct 23, 2023 at 04:32:22PM +, Edgecombe, Rick P wrote: > On Mon, 2023-10-23 at 14:20 +0100, Mark Brown wrote: > +Some security folks I *think* I captured everyone for future versions but I might've missed some, it's a long Cc list. > > Add parameters to c

[PATCH 00/21] arm64: Support for 2023 DPISA extensions

2023-10-26 Thread Mark Brown
ogram that duplicates the boilerplace for tracing a target and doesn't actually run the traced program. Signed-off-by: Mark Brown --- Mark Brown (21): arm64/sysreg: Add definition for ID_AA64PFR2_EL1 arm64/sysreg: Update ID_AA64ISAR2_EL1 defintion for DDI0601 2023-09 arm64/sysreg:

[PATCH 01/21] arm64/sysreg: Add definition for ID_AA64PFR2_EL1

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines a new system register ID_AA64PFR2_EL1 which enumerates FPMR and some new MTE features. Add a definition of this register. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 21 + 1 file changed, 21 insertions(+) diff --git a/arch/arm64/tools

[PATCH 02/21] arm64/sysreg: Update ID_AA64ISAR2_EL1 defintion for DDI0601 2023-09

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines some new fields in previously RES0 space in ID_AA64ISAR2_EL1, together with one new enum value. Update the system register definition to reflect this. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 24 ++-- 1 file changed, 22 insertions(+), 2

[PATCH 03/21] arm64/sysreg: Add definition for ID_AA64ISAR3_EL1

2023-10-26 Thread Mark Brown
DDI0601 2023-09 adds a new system register ID_AA64ISAR3_EL1 enumerating new floating point and TLB invalidation features. Add a defintion for it. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 17 + 1 file changed, 17 insertions(+) diff --git a/arch/arm64/tools/sysreg

[PATCH 04/21] arm64/sysreg: Add definition for ID_AA64FPFR0_EL1

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines a new feature register ID_AA64FPFR0_EL1 which enumerates a number of FP8 related features. Add a definition for it. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 29 + 1 file changed, 29 insertions(+) diff --git a/arch/arm64/tools

[PATCH 05/21] arm64/sysreg: Update ID_AA64SMFR0_EL1 definition for DDI0601 2023-09

2023-10-26 Thread Mark Brown
The 2023-09 release of DDI0601 defines a number of new feature enumeration fields in ID_AA64SMFR0_EL1. Add these fields. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 30 +++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/arch/arm64/tools

[PATCH 07/21] arm64/sysreg: Update HCRX_EL2 definition for DDI0601 2023-09

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines new fields in HCRX_EL2 controlling access to new system registers, update our definition of HCRX_EL2 to reflect this. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/tools/sysreg b

[PATCH 06/21] arm64/sysreg: Update SCTLR_EL1 for DDI0601 2023-09

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines some new fields in SCTLR_EL1 controlling new MTE and floating point features. Update our sysreg definition to reflect these. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/tools

[PATCH 08/21] arm64/sysreg: Add definition for FPMR

2023-10-26 Thread Mark Brown
DDI0601 2023-09 defines a new sysrem register FPMR (Floating Point Mode Register) which configures the new FP8 features. Add a definition of this register. Signed-off-by: Mark Brown --- arch/arm64/tools/sysreg | 23 +++ 1 file changed, 23 insertions(+) diff --git a/arch

[PATCH 10/21] arm64/fpsimd: Enable host kernel access to FPMR

2023-10-26 Thread Mark Brown
. Signed-off-by: Mark Brown --- arch/arm64/include/asm/kvm_arm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 1095c6647e96..ef033c6c745c 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include

[PATCH 09/21] arm64/cpufeature: Hook new identification registers up to cpufeature

2023-10-26 Thread Mark Brown
The 2023 architecture extensions have defined several new ID registers, hook them up to the cpufeature code so we can add feature checks and hwcaps based on their contents. Signed-off-by: Mark Brown --- arch/arm64/include/asm/cpu.h | 3 +++ arch/arm64/kernel/cpufeature.c | 28

[PATCH 13/21] arm64/ptrace: Expose FPMR via ptrace

2023-10-26 Thread Mark Brown
Add a new regset to expose FPMR via ptrace. It is not added to the FPSIMD registers since that structure is exposed elsewhere without any allowance for extension we don't add there. Signed-off-by: Mark Brown --- arch/arm64/kernel/ptrace.c | 42 ++ in

[PATCH 11/21] arm64/fpsimd: Support FEAT_FPMR

2023-10-26 Thread Mark Brown
means that it is not practical to extend that directly. Signed-off-by: Mark Brown --- arch/arm64/include/asm/cpufeature.h | 5 + arch/arm64/include/asm/fpsimd.h | 2 ++ arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/processor.h | 2 ++ arch/arm64/kernel/cpufeature.c

[PATCH 12/21] arm64/signal: Add FPMR signal handling

2023-10-26 Thread Mark Brown
Expose FPMR in the signal context on systems where it is supported. The kernel validates the exact size of the FPSIMD registers so we can't readily add it to fpsimd_context without disruption. Signed-off-by: Mark Brown --- arch/arm64/include/uapi/asm/sigcontext.h | 8 + arch/arm64/k

[PATCH 17/21] kselftest/arm64: Handle FPMR context in generic signal frame parser

2023-10-26 Thread Mark Brown
Teach the generic signal frame parsing code about the newly added FPMR frame, avoiding warnings every time one is generated. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/testcases/testcases.c | 8 tools/testing/selftests/arm64/signal/testcases/testcases.h | 1 + 2

[PATCH 16/21] arm64/hwcap: Define hwcaps for 2023 DPISA features

2023-10-26 Thread Mark Brown
The 2023 architecture extensions include a large number of floating point features, most of which simply add new instructions. Add hwcaps so that userspace can enumerate these features. Signed-off-by: Mark Brown --- Documentation/arch/arm64/elf_hwcaps.rst | 49

[PATCH 18/21] kselftest/arm64: Add basic FPMR test

2023-10-26 Thread Mark Brown
Verify that a FPMR frame is generated on systems that support FPMR and not generated otherwise. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/.gitignore| 1 + .../arm64/signal/testcases/fpmr_siginfo.c | 82 ++ 2 files changed, 83 insertions

[PATCH 15/21] KVM: arm64: Support FEAT_FPMR for guests

2023-10-26 Thread Mark Brown
FPMR specific trap and rely on the floating point access trap to detect guest floating point usage. Signed-off-by: Mark Brown --- arch/arm64/include/asm/kvm_arm.h| 2 +- arch/arm64/include/asm/kvm_host.h | 4 +++- arch/arm64/kvm/fpsimd.c | 20

  1   2   3   4   5   6   7   8   9   >