Re: [PATCH v10 39/40] kselftest/arm64: Enable GCS for the FP stress tests

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > While it's a bit off topic for them the floating point stress tests do give > us some coverage of context thrashing cases, and also of active signal > delivery separate to the relatively complicated framework in the actual > signals tests. Have the tests enable GCS on startup

Re: [PATCH v10 38/40] kselftest/arm64: Add a GCS stress test

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > On Wed, Aug 07, 2024 at 07:39:54PM -0300, Thiago Jung Bauermann wrote: > >> # # Thread-4870: Failed to enable GCS > > which is printed if a basic PR_SET_SHADOW_STACK_STATUS fails immediately > the program starts executing: > > function _start > // Run with GCS >

Re: [PATCH v4 1/2] selftests: net: Create veth pair for testing in networkless kernel

2024-08-07 Thread Jakub Kicinski
On Wed, 7 Aug 2024 17:57:16 + Abhinav Jain wrote: > + ip link add veth0 type peer name veth1 That's not the right syntax.. -- pw-bot: cr

Re: [PATCH RFT v7 9/9] selftests/clone3: Test shadow stack support

2024-08-07 Thread Kees Cook
On Wed, Aug 07, 2024 at 11:03:24PM +0100, Mark Brown wrote: > On Wed, Aug 07, 2024 at 12:23:01PM -0700, Kees Cook wrote: > > On Wed, Aug 07, 2024 at 01:39:27PM +0100, Mark Brown wrote: > > > > size = args->shadow_stack_size; > > > + shstk->base = 0; > > > + shstk->size =

Re: [PATCH v10 38/40] kselftest/arm64: Add a GCS stress test

2024-08-07 Thread Mark Brown
On Wed, Aug 07, 2024 at 07:39:54PM -0300, Thiago Jung Bauermann wrote: > Mark Brown writes: > > Add a stress test which runs one more process than we have CPUs spinning > > through a very recursive function with frequent syscalls immediately prior > Unfortunately, gcs-stress still fails on my FV

Re: [PATCH v10 38/40] kselftest/arm64: Add a GCS stress test

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > Add a stress test which runs one more process than we have CPUs spinning > through a very recursive function with frequent syscalls immediately prior > to return and signals being injected every 100ms. The goal is to flag up > any scheduling related issues, for example failur

Re: [PATCH v10 37/40] kselftest/arm64: Add GCS signal tests

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/se

Re: [PATCH v10 36/40] kselftest/arm64: Add test coverage for GCS mode locking

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > Verify that we can lock individual GCS mode bits, that other modes > aren't affected and as a side effect also that every combination of > modes can be enabled. > > Normally the inability to reenable GCS after disabling it would be an > issue with testing but fortunately the

Re: [PATCH v10 35/40] kselftest/arm64: Add a GCS test program built with the system libc

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. > > Reviewed-by: Thiago Jung Bauer

Re: [PATCH v10 34/40] kselftest/arm64: Add very basic GCS test program

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > This test program just covers the basic GCS ABI, covering aspects of the > ABI as standalone features without attempting to integrate things. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests/arm64/Makefile| 2 +- >

Re: [PATCH v10 29/40] selftests/clone3: Enable arm64 shadow stack testing

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > In order to test shadow stack support in clone3() the clone3() selftests > need to have a fully inline clone3() call, provide one for arm64. > > Signed-off-by: Mark Brown > --- > tools/testing/selftests/clone3/clone3_selftests.h | 26 > +++ > 1 file cha

Re: [PATCH v10 27/40] kselftest/arm64: Verify the GCS hwcap

2024-08-07 Thread Thiago Jung Bauermann
Hello, Mark Brown writes: > 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. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests/arm64/abi/hwcap.c | 19

Re: [PATCH v2 00/15] tools/nolibc: improve LLVM/clang support

2024-08-07 Thread Shuah Khan
On 8/7/24 15:51, Thomas Weißschuh wrote: The current support for LLVM and clang in nolibc and its testsuite is very limited. * Various architectures plain do not compile * The user *has* to specify "-Os" otherwise the program crashes * Cross-compilation of the tests does not work * Using clang i

Re: [PATCH RFT v7 9/9] selftests/clone3: Test shadow stack support

2024-08-07 Thread Mark Brown
On Wed, Aug 07, 2024 at 12:23:01PM -0700, Kees Cook wrote: > On Wed, Aug 07, 2024 at 01:39:27PM +0100, Mark Brown wrote: > > size = args->shadow_stack_size; > > + shstk->base = 0; > > + shstk->size = 0; > Yup, that fixes it! > # Totals: pass:23 fail:0 xfail:0 xp

[PATCH v2 14/15] selftests/nolibc: use correct clang target for s390/powerz

2024-08-07 Thread Thomas Weißschuh
The target names between GCC and clang differ for s390. While GCC uses "s390", clang uses "powerz". This mapping is not handled by tools/scripts/Makefile.include, so do it in the nolibc-test Makefile. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 3 +++ 1 file cha

[PATCH v2 03/15] tools/nolibc: powerpc: limit stack-protector workaround to GCC

2024-08-07 Thread Thomas Weißschuh
As mentioned in the comment, the workaround for __attribute__((no_stack_protector)) is only necessary on GCC. Avoid applying the workaround on clang, as clang does not recognize __attribute__((__optimize__)) and would fail. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-powerpc.h

[PATCH v2 11/15] selftests/nolibc: add cc-option compatible with clang cross builds

2024-08-07 Thread Thomas Weißschuh
The cc-option macro from Build.include is not compatible with clang cross builds, as it does not respect the "--target" and similar flags, set up by Mekfile.include. Provide a custom variant which works correctly. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selfte

[PATCH v2 10/15] selftests/nolibc: add support for LLVM= parameter

2024-08-07 Thread Thomas Weißschuh
Makefile.include can modify CC and CFLAGS for usage with clang. Make use of it. Makefile.include is currently used to handle the O= variable. This is incompatible with the LLVM= handling as for O= it has to be included as early as possible, while for LLVM= it needs to be included after CFLAGS are

[PATCH v2 06/15] tools/nolibc: compiler: use attribute((naked)) if available

2024-08-07 Thread Thomas Weißschuh
The current entrypoint attributes optimize("Os", "omit-frame-pointer") are intended to avoid all compiler generated code, like function porologue and epilogue. This is the exact usecase implemented by the attribute "naked". Unfortunately this is not implemented by GCC for all targets, so only use

[PATCH v2 07/15] selftests/nolibc: report failure if no testcase passed

2024-08-07 Thread Thomas Weißschuh
When nolibc-test is so broken, it doesn't even start, don't report success. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/te

[PATCH v2 12/15] selftests/nolibc: run-tests.sh: avoid overwriting CFLAGS_EXTRA

2024-08-07 Thread Thomas Weißschuh
If the user specified their own CFLAGS_EXTRA these should not be overwritten by `-e`. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selftests/nolibc/run-tests.sh | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc

[PATCH v2 13/15] selftests/nolibc: don't use libgcc when building with clang

2024-08-07 Thread Thomas Weißschuh
The logic in clang to find the libgcc.a from a GCC toolchain for a specific ABI does not work reliably and can lead to errors. Instead disable libgcc when building with clang, as it's not needed anyways. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 11 +--

[PATCH v2 09/15] selftests/nolibc: determine $(srctree) first

2024-08-07 Thread Thomas Weißschuh
The nolibc-test Makefile includes various other Makefiles from the tree. At first these are included with relative paths like "../../../build/Build.include" but as soon as $(srctree) is set up, the inclusions use that instead to build full paths. To keep the style of inclusions consistent, perform

[PATCH v2 15/15] selftests/nolibc: run-tests.sh: allow building through LLVM

2024-08-07 Thread Thomas Weißschuh
The nolibc tests can now be properly built with LLVM. Expose this through run-tests.sh. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selftests/nolibc/run-tests.sh | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/no

[PATCH v2 08/15] selftests/nolibc: avoid passing NULL to printf("%s")

2024-08-07 Thread Thomas Weißschuh
Clang on higher optimization levels detects that NULL is passed to printf("%s") and warns about it. While printf() from nolibc gracefully handles that NULL, it is undefined behavior as per POSIX, so the warning is reasonable. Avoid the warning by transforming NULL into a non-NULL placeholder. Sign

[PATCH v2 05/15] tools/nolibc: move entrypoint specifics to compiler.h

2024-08-07 Thread Thomas Weißschuh
The specific attributes for the _start entrypoint are duplicated for each architecture. Deduplicate it into a dedicated #define into compiler.h. The macros are similar to attribute((naked)), so adopt that naming. This make the code shorter and will make it easier to adapt for clang compatibility.

[PATCH v2 02/15] tools/nolibc: mips: load current function to $t9

2024-08-07 Thread Thomas Weißschuh
The MIPS calling convention requires the address of the current function to be available in $t9. This was not done so far. For GCC this seems to have worked, but when compiled with clang the executable segfault instantly. Properly load the address of _start_c() into $t9 before calling it. Signed-

[PATCH v2 00/15] tools/nolibc: improve LLVM/clang support

2024-08-07 Thread Thomas Weißschuh
The current support for LLVM and clang in nolibc and its testsuite is very limited. * Various architectures plain do not compile * The user *has* to specify "-Os" otherwise the program crashes * Cross-compilation of the tests does not work * Using clang is not wired up in run-tests.sh This series

[PATCH v2 04/15] tools/nolibc: compiler: introduce __nolibc_has_attribute()

2024-08-07 Thread Thomas Weißschuh
Recent compilers support __has_attribute() to check if a certain compiler attribute is supported. Unfortunately we have to first check if __has_attribute is supported in the first place and then if a specific attribute is present. These two checks can't be folded into a single condition as that wou

[PATCH v2 01/15] tools/nolibc: arm: use clang-compatible asm syntax

2024-08-07 Thread Thomas Weißschuh
The clang assembler rejects the current syntax. Switch to a syntax accepted by both GCC and clang. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-arm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/ar

Re: [PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread Jeff Xu
On Wed, Aug 7, 2024 at 2:20 PM Pedro Falcato wrote: > > On Wed, Aug 7, 2024 at 7:03 PM Jeff Xu wrote: > > Do you have any suggestions here ? I can think of two options to choose > > from: > > > > 1> use 0xd000 > > 2> allocate a memory then free it, reuse the ptr. > > Personally I'd prefer 2,

[PATCH v2] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread jeffxu
From: Jeff Xu the syscall remap accepts following: mremap(src, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, dst) when the src is sealed, the call will fail with error code: EPERM Previously, the test uses hard-coded 0xdeaddead as dst, and it will fail on the system with newer glibc installed

Re: [PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread Pedro Falcato
On Wed, Aug 7, 2024 at 7:03 PM Jeff Xu wrote: > > test_seal_mremap_move_dontunmap use 0 as new_addr, 0 indicates > allocating a new memory. > test_seal_mremap_move_dontunmap_anyaddr uses any arbitrary address as > a new address. No, MREMAP_DONTUNMAP uses the address you pass as a hint, aka you'r

Re: [PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread Jeff Xu
On Wed, Aug 7, 2024 at 11:03 AM Jeff Xu wrote: > > On Wed, Aug 7, 2024 at 9:38 AM Pedro Falcato wrote: > > > > On Wed, Aug 7, 2024 at 4:35 PM wrote: > > > > > /* shrink from 4 pages to 2 pages. */ > > > - ret2 = mremap(ptr, size, 2 * page_size, 0, 0); > > > + ret2 = sys_mrem

Re: [PATCH] tracing/selftests: Run the ownership test twice

2024-08-07 Thread Shuah Khan
On 8/7/24 14:29, Steven Rostedt wrote: On Fri, 14 Jun 2024 12:41:51 -0400 Steven Rostedt wrote: Shuah, Can you take this through your tree? Ping! -- Steve Sorry for the delay. Applied it o linux-kselftest next for Linux 6.12-rc1. thanks, -- Shuah

Re: [PATCH] selftests/uprobes: Add a basic uprobe testcase

2024-08-07 Thread Shuah Khan
On 8/7/24 14:36, Steven Rostedt wrote: On Fri, 24 May 2024 09:49:55 +0900 "Masami Hiramatsu (Google)" wrote: From: Masami Hiramatsu (Google) Add a basic uprobe testcase which checks whether add/remove/trace operations works on /bin/sh. Signed-off-by: Masami Hiramatsu (Google) Reviewed-by

[PATCH] fixup! selftests/mm: Add mseal test for no-discard madvise

2024-08-07 Thread Pedro Falcato
Adjust the mseal test's plan. Signed-off-by: Pedro Falcato --- Andrew, please squash this small fix into "selftests/mm: Add mseal test for no-discard madvise". Thank you! tools/testing/selftests/mm/mseal_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing

Re: [PATCH] selftests/uprobes: Add a basic uprobe testcase

2024-08-07 Thread Steven Rostedt
On Fri, 24 May 2024 09:49:55 +0900 "Masami Hiramatsu (Google)" wrote: > From: Masami Hiramatsu (Google) > > Add a basic uprobe testcase which checks whether add/remove/trace > operations works on /bin/sh. > > Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) Shu

Re: [PATCH] tracing/selftests: Run the ownership test twice

2024-08-07 Thread Steven Rostedt
On Fri, 14 Jun 2024 12:41:51 -0400 Steven Rostedt wrote: > Shuah, > > Can you take this through your tree? Ping! -- Steve > > -- Steve > > > On Thu, 23 May 2024 12:45:41 -0400 > Steven Rostedt wrote: > > > From: "Steven Rostedt (Google)" > > > > A regression happened where running the

[PATCH v1 14/16] iommu/arm-smmu-v3: Extract an __arm_smmu_cache_invalidate_user helper

2024-08-07 Thread Nicolin Chen
Extract a helper accepting an s2_parent input directly so the following patch can take advantage of it for viommu's cache invalidate callback, which doesn't have a nested domain but a viommu object linked to an S2 parent domain. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-s

[PATCH v1 16/16] iommu/arm-smmu-v3: Allow ATS for IOMMU_DOMAIN_NESTED

2024-08-07 Thread Nicolin Chen
From: Jason Gunthorpe Now, ATC invalidation can be done with the VIOMMU invalidation op. A guest owned IOMMU_DOMAIN_NESTED can do an ATS too. Allow it to pass in the EATS field via the vSTE words. Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm

[PATCH v1 15/16] iommu/arm-smmu-v3: Add viommu cache invalidation support

2024-08-07 Thread Nicolin Chen
Add an arm_smmu_viommu_cache_invalidate() function for user space to issue cache invalidation commands via viommu. The viommu invalidation takes the same native format of a 128-bit command, as the hwpt invalidation. Thus, reuse the same driver data structure, but make it wider to accept CMDQ_OP_AT

[PATCH v1 13/16] iommufd/viommu: Add iommufd_viommu_to_parent_domain helper

2024-08-07 Thread Nicolin Chen
Allow an IOMMU driver to convert a core-managed viommu to a nested parent domain for the info that the domain holds. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/viommu.c | 8 include/linux/iommufd.h| 8 2 files changed, 16 insertions(+) diff --git a/drivers/i

[PATCH v1 12/16] iommufd/selftest: Add coverage for IOMMU_VIOMMU_INVALIDATE ioctl

2024-08-07 Thread Nicolin Chen
Add a viommu_cache test function to cover the new IOMMU_VIOMMU_INVALIDATE ioctl with similar postive and negative cases to the existing iotlb ones. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd.c | 190 ++ tools/testing/selftests/iommu/iommufd_utils.

[PATCH v1 11/16] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_CACHE test command

2024-08-07 Thread Nicolin Chen
Similar to IOMMU_TEST_OP_MD_CHECK_IOTLB verifying a mock_domain's iotlb, IOMMU_TEST_OP_DEV_CHECK_CACHE will be used to verify a mock_dev's cache. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 5 drivers/iommu/iommufd/selftest.c | 24 ++

[PATCH v1 10/16] iommufd/selftest: Add mock_viommu_invalidate_user op

2024-08-07 Thread Nicolin Chen
Similar to the coverage of cache_invalidate_user for iotlb invalidation, add a device cache and an invalidation op to test IOMMU_VIOMMU_INVALIDATE ioctl. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 25 +++ drivers/iommu/iommufd/selftest.c | 63 +

[PATCH v1 09/16] iommufd/viommu: Make iommufd_viommu_find_device a public API

2024-08-07 Thread Nicolin Chen
Now, an IOMMU driver can use viommu to invalidate a device cache via the viommu_cache_invalidate op. Very likely, this would require the driver to lookup a virtual device ID for a physical device (or just its ID). Since the core already has a helper, make it public. Signed-off-by: Nicolin Chen --

[PATCH v1 08/16] iommufd/viommu: Add IOMMU_VIOMMU_INVALIDATE ioctl

2024-08-07 Thread Nicolin Chen
Add a new IOMMU_VIOMMU_INVALIDATE ioctl, similar to IOMMU_HWPT_INVALIDATE. This is used by the user space to flush any IOMMU specific cache that can be directed using a viommu object. Add IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3 as the initial data type whose support is in the one of the following

[PATCH v1 07/16] iommufd/viommu: Add cache_invalidate for IOMMU_VIOMMU_TYPE_DEFAULT

2024-08-07 Thread Nicolin Chen
Add a default_viommu_ops with a new op for cache invaldiation, similar to the cache_invalidate_user op in structure iommu_domain_ops, but wider. An IOMMU driver that allocated a nested domain with a core-managed viommu is able to use the same viommu pointer for this cache invalidation API. ARM SMM

[PATCH v1 06/16] iommufd/selftest: Add IOMMU_VIOMMU_SET/UNSET_VDEV_ID test coverage

2024-08-07 Thread Nicolin Chen
A core-managed VIOMMU maintains an xarray to store a list of virtual ids to mock_devs. Add test cases to cover the new IOMMU_VIOMMU_SET/UNSET_VDEV_ID ioctls. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd.c | 35 +++- tools/testing/selftests/iommu/iommuf

[PATCH v1 05/16] iommufd/viommu: Add IOMMU_VIOMMU_SET/UNSET_VDEV_ID ioctl

2024-08-07 Thread Nicolin Chen
Introduce a pair of new ioctls to set/unset a per-viommu virtual device id that should be linked to a physical device id via a struct device pointer. Continue the support IOMMU_VIOMMU_TYPE_DEFAULT for a core-managed viommu. Provide a lookup function for drivers to load device pointer by a virtual

[PATCH v1 02/16] iommu: Pass in a viommu pointer to domain_alloc_user op

2024-08-07 Thread Nicolin Chen
With a viommu object wrapping a potentially shareable S2 domain, a nested domain should be allocated by associating to a viommu instead. Driver can store this viommu pointer somewhere, so as to later use it calling viommu helpers for virtual device ID lookup and viommu invalidation. For drivers wi

[PATCH v1 04/16] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

2024-08-07 Thread Nicolin Chen
Use IOMMU_VIOMMU_TYPE_DEFAULT to cover the new IOMMU_VIOMMU_ALLOC ioctl. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd.c | 35 +++ tools/testing/selftests/iommu/iommufd_utils.h | 28 +++ 2 files changed, 63 insertions(+) diff --git a/too

[PATCH v1 03/16] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC

2024-08-07 Thread Nicolin Chen
Now a VIOMMU can wrap a shareable nested parent HWPT. So, it can act like a nested parent HWPT to allocate a nested HWPT. Support that in the IOMMU_HWPT_ALLOC ioctl handler, and update its kdoc. Also, associate a viommu to an allocating nested HWPT. Signed-off-by: Nicolin Chen --- drivers/iomm

[PATCH v1 01/16] iommufd/viommu: Add IOMMUFD_OBJ_VIOMMU and IOMMU_VIOMMU_ALLOC ioctl

2024-08-07 Thread Nicolin Chen
Add a new IOMMUFD_OBJ_VIOMMU with an iommufd_viommu structure to represent a vIOMMU instance in the user space, backed by a physical IOMMU for its HW accelerated virtualization feature, such as nested translation support for a multi-viommu-instance VM, NVIDIA CMDQ-Virtualization extension for ARM S

[PATCH v1 00/16] iommufd: Add VIOMMU infrastructure (Part-1)

2024-08-07 Thread Nicolin Chen
This series introduces a new VIOMMU infrastructure and related ioctls. IOMMUFD has been using the HWPT infrastructure for all cases, including a nested IO page table support. Yet, there're limitations for an HWPT-based structure to support some advanced HW-accelerated features, such as CMDQV on NV

Re: [PATCH 1/2] mseal: Fix is_madv_discard()

2024-08-07 Thread Andrew Morton
On Wed, 7 Aug 2024 20:25:45 +0100 Pedro Falcato wrote: > On Wed, Aug 7, 2024 at 7:58 PM Andrew Morton > wrote: > > > > On Wed, 7 Aug 2024 18:33:35 +0100 Pedro Falcato > > wrote: > > > > > is_madv_discard did its check wrong. MADV_ flags are not bitwise, > > > they're normal sequential number

Re: [PATCH 1/2] mseal: Fix is_madv_discard()

2024-08-07 Thread Pedro Falcato
On Wed, Aug 7, 2024 at 7:58 PM Andrew Morton wrote: > > On Wed, 7 Aug 2024 18:33:35 +0100 Pedro Falcato > wrote: > > > is_madv_discard did its check wrong. MADV_ flags are not bitwise, > > they're normal sequential numbers. So, for instance: > > behavior & (/* ... */ | MADV_REMOVE) > > >

Re: [PATCH RFT v7 9/9] selftests/clone3: Test shadow stack support

2024-08-07 Thread Kees Cook
On Wed, Aug 07, 2024 at 01:39:27PM +0100, Mark Brown wrote: > On Tue, Aug 06, 2024 at 10:08:44PM -0700, Kees Cook wrote: > > On Tue, Aug 06, 2024 at 04:10:02PM +0100, Mark Brown wrote: > > > > > # Running test 'Shadow stack with no token' > > > It took me a while to figure out where a thread sw

[PATCH v3 4/4] iommu/arm-smmu-v3: Implement arm_smmu_get_msi_mapping_domain

2024-08-07 Thread Nicolin Chen
In a 1-stage translation setup, a device is attached to a paging domain. In a 2-stage translation setup, a device is attached to a nested domain, which does not have the mappings for the MSI page but only an s2_parent paging domain pointer that holds the mappings. Add arm_smmu_get_msi_mapping_doma

[PATCH v3 3/4] iommufd/selftest: Add coverage for IOMMU_RESV_SW_MSI

2024-08-07 Thread Nicolin Chen
Define an IOMMU_RESV_SW_MSI region (within the mock aperture) as the ARM SMMU drivers do. Implement the get_msi_mapping_domain nested domain op to allow dma-iommu to find the correct paging domain. Add a new IOMMU_TEST_OP_MD_CHECK_SW_MSI to loopback test the MSI mapping using public dma-iommu and

[PATCH v3 2/4] iommu/dma: Support MSIs through nested domains

2024-08-07 Thread Nicolin Chen
From: Robin Murphy Currently, iommu-dma is the only place outside of IOMMUFD and drivers which might need to be aware of the stage 2 domain encapsulated within a nested domain. This would be still the RMR solution where we're using host-managed MSIs with an identity mapping at stage 1, where it i

[PATCH v3 1/4] iommufd: Reorder include files

2024-08-07 Thread Nicolin Chen
Reorder include files to alphabetic order to simplify maintenance, and separate local headers and global headers with a blank line. No functional change intended. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/device.c | 4 ++-- drivers/iommu/iommufd/fault.c | 4 ++--

[PATCH v3 0/4] iommu: Support IOMMU_RESV_SW_MSI with nesting

2024-08-07 Thread Nicolin Chen
The dma-iommu needs to find the correct domain for MSI mapping. With an IOMMU_DOMAIN_NESTED, the mapping resides in its parent paging domain. Add a get_msi_mapping_domain op for drivers to return paging domains. Add an iommufd selftest coverage for that, by doing a loopback test. Add arm_smmu_ge

Re: [PATCH 1/2] mseal: Fix is_madv_discard()

2024-08-07 Thread Andrew Morton
On Wed, 7 Aug 2024 18:33:35 +0100 Pedro Falcato wrote: > is_madv_discard did its check wrong. MADV_ flags are not bitwise, > they're normal sequential numbers. So, for instance: > behavior & (/* ... */ | MADV_REMOVE) > > tagged both MADV_REMOVE and MADV_RANDOM (bit 0 set) as > discard op

Re: [PATCH RFT v7 9/9] selftests/clone3: Test shadow stack support

2024-08-07 Thread Kees Cook
On Wed, Aug 07, 2024 at 01:39:27PM +0100, Mark Brown wrote: > On Tue, Aug 06, 2024 at 10:08:44PM -0700, Kees Cook wrote: > > On Tue, Aug 06, 2024 at 04:10:02PM +0100, Mark Brown wrote: > > > > > # Running test 'Shadow stack with no token' > > > It took me a while to figure out where a thread sw

Re: [PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread Jeff Xu
On Wed, Aug 7, 2024 at 9:38 AM Pedro Falcato wrote: > > On Wed, Aug 7, 2024 at 4:35 PM wrote: > > > /* shrink from 4 pages to 2 pages. */ > > - ret2 = mremap(ptr, size, 2 * page_size, 0, 0); > > + ret2 = sys_mremap(ptr, size, 2 * page_size, 0, 0); > > if (seal) { > >

[PATCH v4 2/2] selftests: net: Add on/off checks for non-fixed features of interface

2024-08-07 Thread Abhinav Jain
Implement on/off testing for all non-fixed features via while loop. Save the initial state so that it can be restored after on/off checks. Signed-off-by: Abhinav Jain --- tools/testing/selftests/net/netdevice.sh | 37 +++- 1 file changed, 36 insertions(+), 1 deletion(-) diff

[PATCH v4 1/2] selftests: net: Create veth pair for testing in networkless kernel

2024-08-07 Thread Abhinav Jain
Check if the netdev list is empty and create veth pair to be used for feature on/off testing. Remove the veth pair after testing is complete. Signed-off-by: Abhinav Jain --- tools/testing/selftests/net/netdevice.sh | 18 ++ 1 file changed, 18 insertions(+) diff --git a/tools/tes

[PATCH v4 0/2] Enhance network interface feature testing

2024-08-07 Thread Abhinav Jain
This small series includes fixes for creation of veth pairs for networkless kernels & adds tests for turning the different network interface features on and off in selftests/net/netdevice.sh script. Changes in v4: Move veth creation/removal to the main shell script. Tested using vng on a networkle

[PATCH 1/2] mseal: Fix is_madv_discard()

2024-08-07 Thread Pedro Falcato
is_madv_discard did its check wrong. MADV_ flags are not bitwise, they're normal sequential numbers. So, for instance: behavior & (/* ... */ | MADV_REMOVE) tagged both MADV_REMOVE and MADV_RANDOM (bit 0 set) as discard operations. This is obviously incorrect, so use a switch statement inst

[PATCH 2/2] selftests/mm: Add mseal test for no-discard madvise

2024-08-07 Thread Pedro Falcato
Add an mseal test for madvise() operations that aren't considered "discard" (e.g purely advisory ops such as MADV_RANDOM). Signed-off-by: Pedro Falcato --- tools/testing/selftests/mm/mseal_test.c | 34 + 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftes

[PATCH 0/2] mseal: Fix is_madv_discard()

2024-08-07 Thread Pedro Falcato
This small series fixes is_madv_discard() and adds a small sanity check test to selftests/mm/mseal_test. Without this patch, is_madv_discard() erroneously thinks innocent ops like MADV_RANDOM are discard operations (which they are not, and are supposed to be allowed, per the overall design). Based

Re: [PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread Pedro Falcato
On Wed, Aug 7, 2024 at 4:35 PM wrote: > /* shrink from 4 pages to 2 pages. */ > - ret2 = mremap(ptr, size, 2 * page_size, 0, 0); > + ret2 = sys_mremap(ptr, size, 2 * page_size, 0, 0); > if (seal) { > - FAIL_TEST_IF_FALSE(ret2 == MAP_FAILED); > +

[PATCH v5 00/10] selftests: kvm: s390: Add s390x ucontrol selftests

2024-08-07 Thread Christoph Schlameuss
This patch series adds a selftest suite to validate the s390x architecture specific ucontrol KVM interface. When creating a VM on s390x it is possible to create it as userspace controlled VM or in short ucontrol VM. These VMs delegates the management of the VM to userspace instead of handling most

[PATCH v5 10/10] s390: Enable KVM_S390_UCONTROL config in debug_defconfig

2024-08-07 Thread Christoph Schlameuss
To simplify testing enable UCONTROL KVM by default in debug kernels. Signed-off-by: Christoph Schlameuss Reviewed-by: Janosch Frank --- arch/s390/configs/debug_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig in

[PATCH v5 04/10] selftests: kvm: s390: Add test fixture and simple VM setup tests

2024-08-07 Thread Christoph Schlameuss
Add a uc_kvm fixture to create and destroy a ucontrol VM. * uc_sie_assertions asserts basic settings in the SIE as setup by the kernel. * uc_attr_mem_limit asserts the memory limit is max value and cannot be set (not supported). * uc_no_dirty_log asserts dirty log is not supported. Signed-off

[PATCH v5 01/10] selftests: kvm: s390: Define page sizes in shared header

2024-08-07 Thread Christoph Schlameuss
Multiple test cases need page size and shift definitions. By moving the definitions to a single architecture specific header we limit the repetition. Make use of PAGE_SIZE, PAGE_SHIFT and PAGE_MASK defines in existing code. Signed-off-by: Christoph Schlameuss Reviewed-by: Claudio Imbrenda Revie

[PATCH v5 06/10] selftests: kvm: s390: Add VM run test case

2024-08-07 Thread Christoph Schlameuss
Add test case running code interacting with registers within a ucontrol VM. * Add uc_gprs test case The test uses the same VM setup using the fixture and debug macros introduced in earlier patches in this series. Signed-off-by: Christoph Schlameuss Reviewed-by: Janosch Frank --- .../selftests

[PATCH v5 07/10] selftests: kvm: s390: Add uc_map_unmap VM test case

2024-08-07 Thread Christoph Schlameuss
Add a test case verifying basic running and interaction of ucontrol VMs. Fill the segment and page tables for allocated memory and map memory on first access. * uc_map_unmap Store and load data to mapped and unmapped memory and use pic segment translation handling to map memory on access. Sig

[PATCH v5 05/10] selftests: kvm: s390: Add debug print functions

2024-08-07 Thread Christoph Schlameuss
Add functions to simply print some basic state information in selftests. The output can be enabled by setting: #define TH_LOG_ENABLED 1 #define DEBUG 1 * print_psw: current SIE state description and VM run state * print_hex_bytes: print memory with some counting markers * print_hex: PRIN

[PATCH v5 03/10] selftests: kvm: s390: Add s390x ucontrol test suite with hpage test

2024-08-07 Thread Christoph Schlameuss
Add test suite to validate the s390x architecture specific ucontrol KVM interface. Make use of the selftest test harness. * uc_cap_hpage testcase verifies that a ucontrol VM cannot be run with hugepages. To allow testing of the ucontrol interface the kernel needs a non-default config containin

[PATCH v5 08/10] selftests: kvm: s390: Add uc_skey VM test case

2024-08-07 Thread Christoph Schlameuss
Add a test case manipulating s390 storage keys from within the ucontrol VM. Signed-off-by: Christoph Schlameuss --- .../selftests/kvm/s390x/ucontrol_test.c | 78 +++ 1 file changed, 78 insertions(+) diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/te

[PATCH v5 09/10] selftests: kvm: s390: Verify reject memory region operations for ucontrol VMs

2024-08-07 Thread Christoph Schlameuss
Add a test case verifying KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. Executing this test case on not patched kernels will cause a null pointer dereference in the host kernel. This is fixed with commit: commit 7816e58967d0 ("kvm: s390: Reject memo

[PATCH v5 02/10] selftests: kvm: s390: Add kvm_s390_sie_block definition for userspace tests

2024-08-07 Thread Christoph Schlameuss
Subsequent tests do require direct manipulation of the SIE control block. This commit introduces the SIE control block definition for use within the selftests. There are already definitions of this within the kernel. This differs in two ways. * This is the first definition of this in userspace. *

[PATCH v1] selftest mm/mseal: fix test_seal_mremap_move_dontunmap_anyaddr

2024-08-07 Thread jeffxu
From: Jeff Xu the syscall remap accepts following: sys_mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, (void*) 0xdead) when the src is sealed, the call will fail with when error code: EPERM Also remove the dependency on glibc for mremap(), the previous version of

Re: [PATCH net-next] selftests: forwarding: lib.sh: ignore "Address not found"

2024-08-07 Thread Jakub Kicinski
On Wed, 07 Aug 2024 12:08:15 +0800 Geliang Tang wrote: > I did get these errors with the latest net-next and iproute2-next. For > example, I got these errors of "bridge_mdb_port_down.sh": > > $ sudo ./bridge_mdb_port_down.sh > TEST: MDB add/del entry to port with state down [ OK

Re: [PATCH RFT v7 9/9] selftests/clone3: Test shadow stack support

2024-08-07 Thread Mark Brown
On Tue, Aug 06, 2024 at 10:08:44PM -0700, Kees Cook wrote: > On Tue, Aug 06, 2024 at 04:10:02PM +0100, Mark Brown wrote: > > > # Running test 'Shadow stack with no token' > It took me a while to figure out where a thread switches shstk (even > without this series): > kernel_clone, copy_process

Re: [PATCH v4 08/10] selftests: kvm: s390: Add uc_skey VM test case

2024-08-07 Thread Christoph Schlameuss
On Tue, 6 Aug 2024 15:39:44 +0200 Janosch Frank wrote: > On 8/2/24 5:59 PM, Christoph Schlameuss wrote: > > Add a test case manipulating s390 storage keys from within the ucontrol > > VM. > > > > Signed-off-by: Christoph Schlameuss > > --- > > .../selftests/kvm/s390x/ucontrol_test.c | 7

Re: [PATCH 1/3] selftests/exec: Build both static and non-static load_address tests

2024-08-07 Thread Muhammad Usama Anjum
On 5/9/24 11:16 AM, Kees Cook wrote: > On Wed, May 08, 2024 at 07:54:13PM -0700, John Hubbard wrote: >> Didn't we learn recently, though, that -static-pie is gcc 8.1+, while the >> kernel's minimum gcc version is 5? > > Yes, that's true. If we encounter anyone trying to build the selftests > with

Re: [PATCH net-next] selftests: forwarding: lib.sh: ignore "Address not found"

2024-08-07 Thread Ido Schimmel
On Wed, Aug 07, 2024 at 12:08:15PM +0800, Geliang Tang wrote: > On Tue, 2024-08-06 at 10:40 +0300, Ido Schimmel wrote: > > On Tue, Aug 06, 2024 at 12:20:38PM +0800, Geliang Tang wrote: > > > From: Geliang Tang > > > > > > So many "Address not found" messages occur at the end of forwarding > > > t