Re: [PATCH v2 11/27] riscv mmu: teach pte_mkwrite to manufacture shadow stack PTEs

2024-03-28 Thread Deepak Gupta
On Thu, Mar 28, 2024 at 9:46 PM Deepak Gupta wrote: > > pte_mkwrite creates PTEs with WRITE encodings for underlying arch. Underlying > arch can have two types of writeable mappings. One that can be written using > regular store instructions. Another one that can only be written using >

Re: [PATCH v2 04/27] riscv: zicfiss/zicfilp enumeration

2024-03-28 Thread Deepak Gupta
> > > > +- const: zicfilp > > + description: > > +The standard Zicfilp extension for enforcing forward edge > > control-flow > > +integrity as ratified in commit 0036ff2 of riscv-cfi. > > + > > +- const: zicfiss > > + description: > > +

Re: [PATCH v2 04/27] riscv: zicfiss/zicfilp enumeration

2024-03-28 Thread Stefan O'Rear
On Fri, Mar 29, 2024, at 12:44 AM, Deepak Gupta wrote: > Adds description in dt-bindings (extensions.yaml) > > This patch adds support for detecting zicfiss and zicfilp. zicfiss and zicfilp > stands for unprivleged integer spec extension for shadow stack and branch > tracking on indirect branches,

[PATCH v2 27/27] kselftest/riscv: kselftest for user mode cfi

2024-03-28 Thread Deepak Gupta
Adds kselftest for RISC-V control flow integrity implementation for user mode. There is not a lot going on in kernel for enabling landing pad for user mode. Thus kselftest simply enables landing pad for the binary and a signal handler is registered for SIGSEGV. Any control flow violation are

[PATCH v2 26/27] riscv: Documentation for shadow stack on riscv

2024-03-28 Thread Deepak Gupta
Adding documentation on shadow stack for user mode on riscv and kernel interfaces exposed so that user tasks can enable it. Signed-off-by: Deepak Gupta --- Documentation/arch/riscv/zicfiss.rst | 169 +++ 1 file changed, 169 insertions(+) create mode 100644

[PATCH v2 25/27] riscv: Documentation for landing pad / indirect branch tracking

2024-03-28 Thread Deepak Gupta
Adding documentation on landing pad aka indirect branch tracking on riscv and kernel interfaces exposed so that user tasks can enable it. Signed-off-by: Deepak Gupta --- Documentation/arch/riscv/zicfilp.rst | 104 +++ 1 file changed, 104 insertions(+) create mode 100644

[PATCH v2 24/27] riscv: create a config for shadow stack and landing pad instr support

2024-03-28 Thread Deepak Gupta
This patch creates a config for shadow stack support and landing pad instr support. Shadow stack support and landing instr support can be enabled by selecting `CONFIG_RISCV_USER_CFI`. Selecting `CONFIG_RISCV_USER_CFI` wires up path to enumerate CPU support and if cpu support exists, kernel will

[PATCH v2 23/27] riscv/ptrace: riscv cfi status and state via ptrace and in core files

2024-03-28 Thread Deepak Gupta
Expose a new register type NT_RISCV_USER_CFI for risc-v cfi status and state. Intentionally both landing pad and shadow stack status and state are rolled into cfi state. Creating two different NT_RISCV_USER_XXX would not be useful and wastage of a note type. Enabling or disabling of feature is not

[PATCH v2 22/27] riscv signal: Save and restore of shadow stack for signal

2024-03-28 Thread Deepak Gupta
Save shadow stack pointer in sigcontext structure while delivering signal. Restore shadow stack pointer from sigcontext on sigreturn. As part of save operation, kernel uses `ssamoswap` to save snapshot of current shadow stack on shadow stack itself (can be called as a save token). During restore

[PATCH v2 21/27] riscv sigcontext: adding cfi state field in sigcontext

2024-03-28 Thread Deepak Gupta
Shadow stack needs to be saved and restored on signal delivery and signal return. sigcontext embedded in ucontext is extendible. Adding cfi state in there which can be used to save cfi state before signal delivery and restore cfi state on sigreturn Signed-off-by: Deepak Gupta ---

[PATCH v2 20/27] riscv/traps: Introduce software check exception

2024-03-28 Thread Deepak Gupta
zicfiss / zicfilp introduces a new exception to priv isa `software check exception` with cause code = 18. This patch implements software check exception. Additionally it implements a cfi violation handler which checks for code in xtval If xtval=2, it means that sw check exception happened

[PATCH v2 19/27] riscv/kernel: update __show_regs to print shadow stack register

2024-03-28 Thread Deepak Gupta
Updating __show_regs to print captured shadow stack pointer as well. On tasks where shadow stack is disabled, it'll simply print 0. Signed-off-by: Deepak Gupta --- arch/riscv/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/process.c

[PATCH v2 18/27] riscv: Implements arch argnostic indirect branch tracking prctls

2024-03-28 Thread Deepak Gupta
prctls implemented are PR_SET_INDIR_BR_LP_STATUS / PR_GET_INDIR_BR_LP_STATUS and PR_LOCK_INDIR_BR_LP_STATUS. Signed-off-by: Deepak Gupta --- arch/riscv/include/asm/usercfi.h | 22 - arch/riscv/kernel/process.c | 5 +++ arch/riscv/kernel/usercfi.c | 76

[PATCH v2 17/27] riscv: Implements arch agnostic shadow stack prctls

2024-03-28 Thread Deepak Gupta
Implement architecture agnostic prctls() interface for setting and getting shadow stack status. prctls implemented are PR_GET_SHADOW_STACK_STATUS, PR_SET_SHADOW_STACK_STATUS and PR_LOCK_SHADOW_STACK_STATUS. As part of PR_SET_SHADOW_STACK_STATUS/PR_GET_SHADOW_STACK_STATUS, only

[PATCH v2 16/27] prctl: arch-agnostic prtcl for indirect branch tracking

2024-03-28 Thread Deepak Gupta
Three architectures (x86, aarch64, riscv) have support for indirect branch tracking feature in a very similar fashion. On a very high level, indirect branch tracking is a CPU feature where CPU tracks branches which uses memory operand to perform control transfer in program. As part of this

[PATCH v2 15/27] prctl: arch-agnostic prctl for shadow stack

2024-03-28 Thread Deepak Gupta
From: Mark Brown Three architectures (x86, aarch64, riscv) have announced support for shadow stacks with fairly similar functionality. While x86 is using arch_prctl() to control the functionality neither arm64 nor riscv uses that interface so this patch adds arch-agnostic prctl() support to get

[PATCH v2 14/27] riscv/shstk: If needed allocate a new shadow stack on clone

2024-03-28 Thread Deepak Gupta
Userspace specifies VM_CLONE to share address space and spawn new thread. `clone` allow userspace to specify a new stack for new thread. However there is no way to specify new shadow stack base address without changing API. This patch allocates a new shadow stack whenever VM_CLONE is given. In

[PATCH v2 13/27] riscv/mm: Implement map_shadow_stack() syscall

2024-03-28 Thread Deepak Gupta
As discussed extensively in the changelog for the addition of this syscall on x86 ("x86/shstk: Introduce map_shadow_stack syscall") the existing mmap() and madvise() syscalls do not map entirely well onto the security requirements for shadow stack memory since they lead to windows where memory is

[PATCH v2 12/27] riscv mmu: write protect and shadow stack

2024-03-28 Thread Deepak Gupta
`fork` implements copy on write (COW) by making pages readonly in child and parent both. ptep_set_wrprotect and pte_wrprotect clears _PAGE_WRITE in PTE. Assumption is that page is readable and on fault copy on write happens. To implement COW on such pages, clearing up W bit makes them XWR = 000.

[PATCH v2 11/27] riscv mmu: teach pte_mkwrite to manufacture shadow stack PTEs

2024-03-28 Thread Deepak Gupta
pte_mkwrite creates PTEs with WRITE encodings for underlying arch. Underlying arch can have two types of writeable mappings. One that can be written using regular store instructions. Another one that can only be written using specialized store instructions (like shadow stack stores). pte_mkwrite

[PATCH v2 10/27] riscv mm: manufacture shadow stack pte

2024-03-28 Thread Deepak Gupta
This patch implements creating shadow stack pte (on riscv). Creating shadow stack PTE on riscv means that clearing RWX and then setting W=1. Signed-off-by: Deepak Gupta --- arch/riscv/include/asm/pgtable.h | 12 1 file changed, 12 insertions(+) diff --git

[PATCH v2 09/27] riscv/mm : ensure PROT_WRITE leads to VM_READ | VM_WRITE

2024-03-28 Thread Deepak Gupta
`arch_calc_vm_prot_bits` is implemented on risc-v to return VM_READ | VM_WRITE if PROT_WRITE is specified. Similarly `riscv_sys_mmap` is updated to convert all incoming PROT_WRITE to (PROT_WRITE | PROT_READ). This is to make sure that any existing apps using PROT_WRITE still work. Earlier

[PATCH v2 08/27] mm: abstract shadow stack vma behind `arch_is_shadow_stack`

2024-03-28 Thread Deepak Gupta
x86 has used VM_SHADOW_STACK (alias to VM_HIGH_ARCH_5) to encode shadow stack VMA. VM_SHADOW_STACK is thus not possible on 32bit. Some arches may need a way to encode shadow stack on 32bit and 64bit both and they may encode this information differently in VMAs. This patch changes checks of

[PATCH v2 07/27] mm: Define VM_SHADOW_STACK for RISC-V

2024-03-28 Thread Deepak Gupta
VM_SHADOW_STACK is defined by x86 as vm flag to mark a shadow stack vma. x86 uses VM_HIGH_ARCH_5 bit but that limits shadow stack vma to 64bit only. arm64 follows same path https://lore.kernel.org/lkml/20231009-arm64-gcs-v6-12-78e55deaa...@kernel.org/#r To keep things simple, RISC-V follows the

[PATCH v2 06/27] riscv: usercfi state for task and save/restore of CSR_SSP on trap entry/exit

2024-03-28 Thread Deepak Gupta
Carves out space in arch specific thread struct for cfi status and shadow stack in usermode on riscv. This patch does following - defines a new structure cfi_status with status bit for cfi feature - defines shadow stack pointer, base and size in cfi_status structure - defines offsets to new

[PATCH v2 05/27] riscv: zicfiss/zicfilp extension csr and bit definitions

2024-03-28 Thread Deepak Gupta
zicfiss and zicfilp extension gets enabled via b3 and b2 in *envcfg CSR. menvcfg controls enabling for S/HS mode. henvcfg control enabling for VS while senvcfg controls enabling for U/VU mode. zicfilp extension extends *status CSR to hold `expected landing pad` bit. A trap or interrupt can occur

[PATCH v2 04/27] riscv: zicfiss/zicfilp enumeration

2024-03-28 Thread Deepak Gupta
Adds description in dt-bindings (extensions.yaml) This patch adds support for detecting zicfiss and zicfilp. zicfiss and zicfilp stands for unprivleged integer spec extension for shadow stack and branch tracking on indirect branches, respectively. This patch looks for zicfiss and zicfilp in

[PATCH v2 03/27] riscv/Kconfig: enable HAVE_EXIT_THREAD for riscv

2024-03-28 Thread Deepak Gupta
riscv will need an implementation for exit_thread to clean up shadow stack when thread exits. If current thread had shadow stack enabled, shadow stack is allocated by default for any new thread. Signed-off-by: Deepak Gupta --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/process.c | 5

[PATCH v2 02/27] riscv: define default value for envcfg

2024-03-28 Thread Deepak Gupta
Defines a base default value for envcfg per task. By default all tasks should have cache zeroing capability. Any future base capabilities that apply to all tasks can be turned on same way. Signed-off-by: Deepak Gupta --- arch/riscv/include/asm/csr.h | 2 ++ arch/riscv/kernel/process.c | 1 + 2

[PATCH v2 01/27] riscv: envcfg save and restore on task switching

2024-03-28 Thread Deepak Gupta
envcfg CSR defines enabling bits for cache management instructions and soon will control enabling for control flow integrity and pointer masking features. Control flow integrity enabling for forward cfi and backward cfi is controlled via envcfg and thus need to be enabled on per thread basis.

[PATCH v2 00/27] riscv control-flow integrity for usermode

2024-03-28 Thread Deepak Gupta
I had sent RFC patchset early this year (January) [7] to enable CPU assisted control-flow integrity for usermode on riscv. Since then I've been able to do more testing of the changes. As part of testing effort, compiled a rootfs with shadow stack and landing pad enabled (libraries and binaries)

[linus:master] [selftests/harness] 0710a1a73f: kernel-selftests.pidfd.pidfd_setns_test.fail

2024-03-28 Thread kernel test robot
Hello, kernel test robot noticed "kernel-selftests.pidfd.pidfd_setns_test.fail" on: commit: 0710a1a73fb45033ebb06073e374ab7d44a05f15 ("selftests/harness: Merge TEST_F_FORK() into TEST_F()") https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master [test failed on linus/master

Re: [PATCH net-next 00/14] selftests: Fixes for kernel CI

2024-03-28 Thread patchwork-bot+netdevbpf
Hello: This series was applied to netdev/net-next.git (main) by Jakub Kicinski : On Tue, 26 Mar 2024 17:54:27 +0100 you wrote: > As discussed on the bi-weekly call on Jan 30, and in mailing around > kernel CI effort, some changes are desirable in the suite of forwarding > selftests the better to

Re: [PATCH v3] selftests/mm: Fix ARM related issue with fork after pthread_create

2024-03-28 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net.git (main) by Andrew Morton : On Mon, 25 Mar 2024 19:40:52 + you wrote: > Following issue was observed while running the uffd-unit-tests selftest > on ARM devices. On x86_64 no issues were detected: > > pthread_create followed by fork caused

[PATCH v3 00/30] NT synchronization primitive driver

2024-03-28 Thread Elizabeth Figura
This patch series introduces a new char misc driver, /dev/ntsync, which is used to implement Windows NT synchronization primitives. == Background == The Wine project emulates the Windows API in user space. One particular part of that API, namely the NT synchronization primitives, have

[PATCH v3 01/30] ntsync: Introduce the ntsync driver and character device.

2024-03-28 Thread Elizabeth Figura
ntsync uses a misc device as the simplest and least intrusive uAPI interface. Each file description on the device represents an isolated NT instance, intended to correspond to a single NT virtual machine. Signed-off-by: Elizabeth Figura --- drivers/misc/Kconfig | 11 +

[PATCH v3 16/30] ntsync: Introduce alertable waits.

2024-03-28 Thread Elizabeth Figura
NT waits can optionally be made "alertable". This is a special channel for thread wakeup that is mildly similar to SIGIO. A thread has an internal single bit of "alerted" state, and if a thread is alerted while an alertable wait, the wait will return a special value, consume the "alerted" state,

[PATCH v3 13/30] ntsync: Introduce NTSYNC_IOC_SEM_READ.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtQuerySemaphore(). This returns the current count and maximum count of the semaphore. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 21 + include/uapi/linux/ntsync.h | 1 + 2 files changed, 22 insertions(+) diff

[PATCH v3 14/30] ntsync: Introduce NTSYNC_IOC_MUTEX_READ.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtQueryMutant(). This returns the recursion count, owner, and abandoned state of the mutex. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 23 +++ include/uapi/linux/ntsync.h | 1 + 2 files changed, 24 insertions(+)

[PATCH v3 15/30] ntsync: Introduce NTSYNC_IOC_EVENT_READ.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtQueryEvent(). This returns the signaled state of the event and whether it is manual-reset. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 21 + include/uapi/linux/ntsync.h | 1 + 2 files changed, 22 insertions(+)

[PATCH v3 26/30] selftests: ntsync: Add tests for alertable waits.

2024-03-28 Thread Elizabeth Figura
Test the "alert" functionality of NTSYNC_IOC_WAIT_ALL and NTSYNC_IOC_WAIT_ANY, when a wait is woken with an alert and when it is woken by an object. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 179 +- 1 file changed, 176 insertions(+), 3

[PATCH v3 06/30] ntsync: Introduce NTSYNC_IOC_CREATE_MUTEX.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtCreateMutant(). An NT mutex is recursive, with a 32-bit recursion counter. When acquired via NtWaitForMultipleObjects(), the recursion counter is incremented by one. The OS records the thread which acquired it. However, in order to keep this driver

[PATCH v3 02/30] ntsync: Introduce NTSYNC_IOC_CREATE_SEM.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtCreateSemaphore(). Semaphores are one of three types of object to be implemented in this driver, the others being mutexes and events. An NT semaphore contains a 32-bit counter, and is signaled and can be acquired when the counter is nonzero. The counter has a

[PATCH v3 04/30] ntsync: Introduce NTSYNC_IOC_WAIT_ANY.

2024-03-28 Thread Elizabeth Figura
This corresponds to part of the functionality of the NT syscall NtWaitForMultipleObjects(). Specifically, it implements the behaviour where the third argument (wait_any) is TRUE, and it does not handle alertable waits. Those features have been split out into separate patches to ease review.

[PATCH v3 03/30] ntsync: Introduce NTSYNC_IOC_SEM_POST.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtReleaseSemaphore(). This increases the semaphore's internal counter by the given value, and returns the previous value. If the counter would overflow the defined maximum, the function instead fails and returns -EOVERFLOW. Signed-off-by: Elizabeth Figura ---

[PATCH v3 05/30] ntsync: Introduce NTSYNC_IOC_WAIT_ALL.

2024-03-28 Thread Elizabeth Figura
This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are simultaneously signaled, and then acquires all of them as a single atomic operation. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 243 ++--

[PATCH v3 22/30] selftests: ntsync: Add some tests for wakeup signaling with WINESYNC_IOC_WAIT_ALL.

2024-03-28 Thread Elizabeth Figura
Test contended "wait-for-all" waits, to make sure that scheduling and wakeup logic works correctly, and that the wait only exits once objects are all simultaneously signaled. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 98 +++ 1 file

[PATCH v3 23/30] selftests: ntsync: Add some tests for manual-reset event state.

2024-03-28 Thread Elizabeth Figura
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for manual-reset events, and waiting on manual-reset events. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 89 +++ 1 file

[PATCH v3 20/30] selftests: ntsync: Add some tests for NTSYNC_IOC_WAIT_ALL.

2024-03-28 Thread Elizabeth Figura
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ALL, and when objects are considered simultaneously signaled. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 99 ++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git

[PATCH v3 21/30] selftests: ntsync: Add some tests for wakeup signaling with WINESYNC_IOC_WAIT_ANY.

2024-03-28 Thread Elizabeth Figura
Test contended "wait-for-any" waits, to make sure that scheduling and wakeup logic works correctly. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 150 ++ 1 file changed, 150 insertions(+) diff --git

[PATCH v3 12/30] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtPulseEvent(). This wakes up any waiters as if the event had been set, but does not set the event, instead resetting it if it had been signalled. Thus, for a manual-reset event, all waiters are woken, whereas for an auto-reset event, at most one waiter is

[PATCH v3 10/30] ntsync: Introduce NTSYNC_IOC_EVENT_SET.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtSetEvent(). This sets the event to the signaled state, and returns its previous state. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 37 + include/uapi/linux/ntsync.h | 1 + 2 files changed, 38

[PATCH v3 09/30] ntsync: Introduce NTSYNC_IOC_CREATE_EVENT.

2024-03-28 Thread Elizabeth Figura
This correspond to the NT syscall NtCreateEvent(). An NT event holds a single bit of state denoting whether it is signaled or unsignaled. There are two types of events: manual-reset and automatic-reset. When an automatic-reset event is acquired via a wait function, its state is reset to

[PATCH v3 08/30] ntsync: Introduce NTSYNC_IOC_MUTEX_KILL.

2024-03-28 Thread Elizabeth Figura
This does not correspond to any NT syscall. Rather, when a thread dies, it should be called by the NT emulator for each mutex. NT mutexes are robust (in the pthread sense). When an NT thread dies, any mutexes it owned are immediately released. Acquisition of those mutexes by other threads will

[PATCH v3 11/30] ntsync: Introduce NTSYNC_IOC_EVENT_RESET.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtResetEvent(). This sets the event to the unsignaled state, and returns its previous state. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 22 ++ include/uapi/linux/ntsync.h | 1 + 2 files changed, 23 insertions(+)

[PATCH v3 07/30] ntsync: Introduce NTSYNC_IOC_MUTEX_UNLOCK.

2024-03-28 Thread Elizabeth Figura
This corresponds to the NT syscall NtReleaseMutant(). This syscall decrements the mutex's recursion count by one, and returns the previous value. If the mutex is not owned by the given owner ID, the function instead fails and returns -EPERM. Signed-off-by: Elizabeth Figura ---

[PATCH v3 25/30] selftests: ntsync: Add some tests for wakeup signaling with events.

2024-03-28 Thread Elizabeth Figura
Expand the contended wait tests, which previously only covered events and semaphores, to cover events as well. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 151 +- 1 file changed, 147 insertions(+), 4 deletions(-) diff --git

[PATCH v3 24/30] selftests: ntsync: Add some tests for auto-reset event state.

2024-03-28 Thread Elizabeth Figura
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and waiting on auto-reset events. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 59 +++ 1 file

[PATCH v3 18/30] selftests: ntsync: Add some tests for mutex state.

2024-03-28 Thread Elizabeth Figura
Test mutex-specific ioctls NTSYNC_IOC_MUTEX_UNLOCK and NTSYNC_IOC_MUTEX_READ, and waiting on mutexes. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 196 ++ 1 file changed, 196 insertions(+) diff --git

[PATCH v3 17/30] selftests: ntsync: Add some tests for semaphore state.

2024-03-28 Thread Elizabeth Figura
Wine has tests for its synchronization primitives, but these are more accessible to kernel developers, and also allow us to test some edge cases that Wine does not care about. This patch adds tests for semaphore-specific ioctls NTSYNC_IOC_SEM_POST and NTSYNC_IOC_SEM_READ, and waiting on

[PATCH v3 19/30] selftests: ntsync: Add some tests for NTSYNC_IOC_WAIT_ANY.

2024-03-28 Thread Elizabeth Figura
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ANY, when objects are considered signaled or not signaled, and how they are affected by a successful wait. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 119 ++ 1 file changed, 119

[PATCH v6 5/5] KVM: arm64: selftests: Teach get-reg-list about FPMR

2024-03-28 Thread Mark Brown
FEAT_FPMR defines a new register FMPR which is available at all ELs and is discovered via ID_AA64PFR2_EL1.FPMR, add this to the set of registers that get-reg-list knows to check for with the required identification register depdendency. Signed-off-by: Mark Brown ---

[PATCH v6 4/5] KVM: arm64: selftests: Document feature registers added in 2023 extensions

2024-03-28 Thread Mark Brown
The 2023 architecture extensions allocated some previously usused feature registers, add comments mapping the names in get-reg-list as we do for the other allocated registers. Signed-off-by: Mark Brown --- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 4 ++-- 1 file changed, 2

[PATCH v6 3/5] KVM: arm64: Support FEAT_FPMR for guests

2024-03-28 Thread Mark Brown
FEAT_FPMR introduces a new system register FPMR which allows configuration of floating point behaviour, currently for FP8 specific features. Allow use of this in guests, disabling the trap while guests are running and saving and restoring the value along with the rest of the floating point state

[PATCH v6 2/5] KVM: arm64: Add newly allocated ID registers to register descriptions

2024-03-28 Thread Mark Brown
The 2023 architecture extensions have allocated some new ID registers, add them to the KVM system register descriptions so that they are visible to guests. We make the newly introduced dpISA features writeable, as well as allowing writes to ID_AA64ISAR3_EL1.CPA for FEAT_CPA which only introduces

[PATCH v6 1/5] KVM: arm64: Share all userspace hardened thread data with the hypervisor

2024-03-28 Thread Mark Brown
As part of the lazy FPSIMD state transitioning done by the hypervisor we currently share the userpsace FPSIMD state in thread->uw.fpsimd_state with the host. Since this struct is non-extensible userspace ABI we have to keep the definition as is but the addition of FPMR in the 2023 dpISA means that

[PATCH v6 0/5] KVM: arm64: Support for 2023 dpISA extensions

2024-03-28 Thread Mark Brown
This series implements support for the 2023 dpISA extensions in KVM guests, it was previously posted as part of a series with the host support but that has now been merged so only the KVM portions remain. Most of these extensions add only new instructions so the guest support consists of adding

[PATCH v3 30/30] docs: ntsync: Add documentation for the ntsync uAPI.

2024-03-28 Thread Elizabeth Figura
Add an overall explanation of the driver architecture, and complete and precise specification for its intended behaviour. Signed-off-by: Elizabeth Figura --- Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/ntsync.rst | 399 + 2 files changed,

[PATCH v3 29/30] maintainers: Add an entry for ntsync.

2024-03-28 Thread Elizabeth Figura
Add myself as maintainer, supported by CodeWeavers. Signed-off-by: Elizabeth Figura --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index aa3b947fb080..84d03d95f44b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15720,6 +15720,15 @@ T:

[PATCH v3 28/30] selftests: ntsync: Add a stress test for contended waits.

2024-03-28 Thread Elizabeth Figura
Test a more realistic usage pattern, and one with heavy contention, in order to actually exercise ntsync's internal synchronization. This test has several threads in a tight loop acquiring a mutex, modifying some shared data, and then releasing the mutex. At the end we check if the data is

[PATCH v3 27/30] selftests: ntsync: Add some tests for wakeup signaling via alerts.

2024-03-28 Thread Elizabeth Figura
Expand the alert tests to cover alerting a thread mid-wait, to test that the relevant scheduling logic works correctly. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 62 +++ 1 file changed, 62 insertions(+) diff --git

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Tejun Heo
Hello, On Thu, Mar 28, 2024 at 02:28:51PM -0700, Alexei Starovoitov wrote: > > > So filename will be one of cgroup_base_files[].name ? > > > We probably don't want psi or cgroup1_base_files in there. > > > > Would it matter? > > Few weak reasons: > . cgroup_psi_files have show/write/poll/release

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 8:10 AM Steven Rostedt wrote: > > On Thu, 28 Mar 2024 22:43:46 +0800 > 梦龙董 wrote: > > > I have done a simple benchmark on creating 1000 > > trampolines. It is slow, quite slow, which consume up to > > 60s. We can't do it this way. > > > > Now, I have a bad idea. How about

Re: kunit alltests runs broken in mainline

2024-03-28 Thread Johannes Berg
On Thu, 2024-03-28 at 14:08 -0600, Shuah Khan wrote: > On 3/26/24 04:09, David Gow wrote: > > On Tue, 26 Mar 2024 at 15:55, Johannes Berg > > wrote: > > > > > > On Tue, 2024-03-26 at 01:52 +, Jakub Kicinski wrote: > > > > > > > > I'm late to the party, but FWIW I had to toss this into

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 2:01 PM Tejun Heo wrote: > > Hello, > > On Thu, Mar 28, 2024 at 01:45:56PM -0700, Alexei Starovoitov wrote: > > On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: > > > > > > There's also cgroup.kill which would be useful for similar use cases. We > > > can > > > add

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Tejun Heo
Hello, On Thu, Mar 28, 2024 at 01:45:56PM -0700, Alexei Starovoitov wrote: > On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: > > > > There's also cgroup.kill which would be useful for similar use cases. We can > > add interface for both but idk. Let's say we have something like the > >

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: > > There's also cgroup.kill which would be useful for similar use cases. We can > add interface for both but idk. Let's say we have something like the > following (pardon the bad naming): > > bpf_cgroup_knob_write(struct cgroup *cgrp, char

Re: [RFC PATCH net-next v7 04/14] netdev: support binding dma-buf to netdevice

2024-03-28 Thread Simon Horman
On Thu, Mar 28, 2024 at 11:55:23AM -0700, Mina Almasry wrote: > On Thu, Mar 28, 2024 at 11:28 AM Simon Horman wrote: > > > > On Tue, Mar 26, 2024 at 03:50:35PM -0700, Mina Almasry wrote: > > > Add a netdev_dmabuf_binding struct which represents the > > > dma-buf-to-netdevice binding. The netlink

Re: [PATCH v5 0/3] selftests/resctrl: Simplify test cleanup functions

2024-03-28 Thread Reinette Chatre
Hi Shuah, On 3/28/2024 12:25 PM, Shuah Khan wrote: > On 3/27/24 17:08, Reinette Chatre wrote: >> On 2/27/2024 8:36 AM, Reinette Chatre wrote: >>> Could you please consider this series for inclusion? I do admit that >>> there has been a lot of resctrl selftest work recently. This should be >>> it

Re: kunit alltests runs broken in mainline

2024-03-28 Thread Shuah Khan
On 3/26/24 04:09, David Gow wrote: On Tue, 26 Mar 2024 at 15:55, Johannes Berg wrote: On Tue, 2024-03-26 at 01:52 +, Jakub Kicinski wrote: I'm late to the party, but FWIW I had to toss this into netdev testing tree as a local patch: CONFIG_NETDEVICES=y CONFIG_WLAN=y I'll send this in

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Tejun Heo
Hello, On Thu, Mar 28, 2024 at 12:46:03PM -0700, Alexei Starovoitov wrote: > To use kernel_file_open() it would need path, inode, cred. Yeah, it's more involved and potentially more controversial. That said, just to push the argument a bit further, at least for path, it'd be nice to have a

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 10:58 AM Tejun Heo wrote: > > Hello, Alexei. > > On Thu, Mar 28, 2024 at 10:32:24AM -0700, Alexei Starovoitov wrote: > > > It bothers me a bit that it's adding a dedicated interface for something > > > which already has a defined userspace interface. Would it be better to

Re: [PATCH v5 0/3] selftests/resctrl: Simplify test cleanup functions

2024-03-28 Thread Shuah Khan
On 3/27/24 17:08, Reinette Chatre wrote: Hi Shuah, On 2/27/2024 8:36 AM, Reinette Chatre wrote: Hi Shuah, Could you please consider this series for inclusion? I do admit that there has been a lot of resctrl selftest work recently. This should be it for a while as new work is still being

Re: [RFC PATCH net-next v7 04/14] netdev: support binding dma-buf to netdevice

2024-03-28 Thread Mina Almasry
On Thu, Mar 28, 2024 at 11:28 AM Simon Horman wrote: > > On Tue, Mar 26, 2024 at 03:50:35PM -0700, Mina Almasry wrote: > > Add a netdev_dmabuf_binding struct which represents the > > dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to > > rx queues on the netdevice. On the

Re: [PATCH v3] selftests: x86: skip the tests if prerequisites aren't fulfilled

2024-03-28 Thread Shuah Khan
On 3/27/24 05:17, Muhammad Usama Anjum wrote: Skip instead of failing when prerequisite conditions aren't fulfilled, such as invalid xstate values etc. This patch would make the tests show as skip when run by: make -C tools/testing/selftests/ TARGETS=x86 run_tests ... # timeout set to

Re: [PATCH v2 1/3] selftests: x86: test_vsyscall: reorder code to reduce #ifdef blocks

2024-03-28 Thread Shuah Khan
On 3/27/24 12:46, Muhammad Usama Anjum wrote: There are multiple #ifdef blocks inside functions where they return just 0 if #ifdef is false. This makes number of tests counting difficult. Move those functions inside one #ifdef block and move all of them together. This is preparatory patch for

Re: [RFC PATCH net-next v7 04/14] netdev: support binding dma-buf to netdevice

2024-03-28 Thread Simon Horman
On Tue, Mar 26, 2024 at 03:50:35PM -0700, Mina Almasry wrote: > Add a netdev_dmabuf_binding struct which represents the > dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to > rx queues on the netdevice. On the binding, the dma_buf_attach > & dma_buf_map_attachment will occur.

Re: [PATCH] Documentation: kunit: Clarify test filter format

2024-03-28 Thread Daniel Latypov
On Thu, Mar 28, 2024 at 7:20 AM 'Brendan Jackman' via KUnit Development wrote: > > It seems obvious once you know, but at first I didn't realise that the > suite name is part of this format. Document it and add example. > > Signed-off-by: Brendan Jackman > --- >

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Tejun Heo
Hello, Alexei. On Thu, Mar 28, 2024 at 10:32:24AM -0700, Alexei Starovoitov wrote: > > It bothers me a bit that it's adding a dedicated interface for something > > which already has a defined userspace interface. Would it be better to have > > kfunc wrappers for kernel_read() and kernel_write()?

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 10:22 AM Tejun Heo wrote: > > Hello, Djalal. > > On Wed, Mar 27, 2024 at 11:53:22PM +0100, Djalal Harouni wrote: > > This patch series adds support to freeze the task cgroup hierarchy > > that is on a default cgroup v2 without going through kernfs interface. > > > > For

Re: [PATCH 0/2] Fix selftests/mm build without requiring "make headers"

2024-03-28 Thread John Hubbard
On 3/28/24 2:02 AM, Muhammad Usama Anjum wrote: On 3/28/24 8:34 AM, John Hubbard wrote: Hi, As mentioned in each patch, this implements the solution that we discussed in December 2023, in [1]. This turned out to be very clean and easy. It should also be quite easy to maintain. There is

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Tejun Heo
Hello, Djalal. On Wed, Mar 27, 2024 at 11:53:22PM +0100, Djalal Harouni wrote: > This patch series adds support to freeze the task cgroup hierarchy > that is on a default cgroup v2 without going through kernfs interface. > > For some cases we want to freeze the cgroup of a task based on some >

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-28 Thread Steven Rostedt
On Thu, 28 Mar 2024 22:43:46 +0800 梦龙董 wrote: > I have done a simple benchmark on creating 1000 > trampolines. It is slow, quite slow, which consume up to > 60s. We can't do it this way. > > Now, I have a bad idea. How about we introduce > a "dynamic trampoline"? The basic logic of it can be: >

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-28 Thread 梦龙董
On Fri, Mar 15, 2024 at 4:00 PM 梦龙董 wrote: > > On Thu, Mar 14, 2024 at 8:27 AM Alexei Starovoitov > wrote: > > > > On Tue, Mar 12, 2024 at 6:53 PM 梦龙董 wrote: > [..] > > > What does "a hundred attachments max" means? Can't I > > > trace thousands of kernel functions with a bpf program of > >

[PATCH] Documentation: kunit: Clarify test filter format

2024-03-28 Thread Brendan Jackman
It seems obvious once you know, but at first I didn't realise that the suite name is part of this format. Document it and add example. Signed-off-by: Brendan Jackman --- Documentation/dev-tools/kunit/run_wrapper.rst | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git

Re: [BUG] seltests/iommu: runaway ./iommufd consuming 99% CPU after a failed assert()

2024-03-28 Thread Joao Martins
On 27/03/2024 20:04, Mirsad Todorovac wrote: > On 3/27/24 11:41, Joao Martins wrote: >> On 25/03/2024 13:52, Jason Gunthorpe wrote: >>> On Mon, Mar 25, 2024 at 12:17:28PM +, Joao Martins wrote: > However, I am not smart enough to figure out why ... > > Apparently, from the source,

Re: [PATCH v1 2/3] KVM: selftests: Change __vm_create() to create a vm without in-kernel APIC

2024-03-28 Thread Manali Shukla
Hi Andrew, Thank you for reviewing my patches. On 3/27/2024 4:57 PM, Andrew Jones wrote: > On Wed, Mar 27, 2024 at 05:42:54AM +, Manali Shukla wrote: > ... >> diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h >> b/tools/testing/selftests/kvm/include/kvm_util_base.h >> index

Re: [PATCH 0/2] Fix selftests/mm build without requiring "make headers"

2024-03-28 Thread Muhammad Usama Anjum
On 3/28/24 8:34 AM, John Hubbard wrote: > Hi, > > As mentioned in each patch, this implements the solution that we discussed in > December 2023, in [1]. This turned out to be very clean and easy. It should > also > be quite easy to maintain. There is another way. The headers should be built

Re: [RFC PATCH net-next v6 02/15] net: page_pool: create hooks for custom page providers

2024-03-28 Thread Christoph Hellwig
On Tue, Mar 26, 2024 at 01:19:20PM -0700, Mina Almasry wrote: > > Are you envisioning that dmabuf support would be added to the block > layer Yes. > (which I understand is part of the VFS and not driver specific), The block layer isn't really the VFS, it's just another core stack like the