Re: [PATCH 1/2] selftests: harness: remove unneeded __constructor_order_last()

2024-05-17 Thread Masahiro Yamada
On Sat, May 18, 2024 at 8:26 AM Kees Cook  wrote:
>
> On Fri, May 17, 2024 at 08:45:05PM +0900, Masahiro Yamada wrote:
> > __constructor_order_last() is unneeded.
> >
> > If __constructor_order_last() is not called on reverse-order systems,
> > __constructor_order will remain 0 instead of being set to
> > _CONSTRUCTOR_ORDER_BACKWARD (= -1).
> >
> > __LIST_APPEND() will still take the 'else' branch, so there is no
> > difference in the behavior.
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  .../selftests/drivers/s390x/uvdevice/test_uvdevice.c   |  6 --
> >  tools/testing/selftests/hid/hid_bpf.c  |  6 --
> >  tools/testing/selftests/kselftest_harness.h| 10 +-
> >  tools/testing/selftests/rtc/rtctest.c  |  7 ---
> >  4 files changed, 1 insertion(+), 28 deletions(-)
> >
> > diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c 
> > b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> > index ea0cdc37b44f..7ee7492138c6 100644
> > --- a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> > +++ b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> > @@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr)
> >   att_inval_addr_test(>uvio_attest.meas_addr, _metadata, self);
> >  }
> >
> > -static void __attribute__((constructor)) __constructor_order_last(void)
> > -{
> > - if (!__constructor_order)
> > - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
> > -}
> > -
> >  int main(int argc, char **argv)
> >  {
> >   int fd = open(UV_PATH, O_ACCMODE);
> > diff --git a/tools/testing/selftests/hid/hid_bpf.c 
> > b/tools/testing/selftests/hid/hid_bpf.c
> > index 2cf96f818f25..f47feef2aced 100644
> > --- a/tools/testing/selftests/hid/hid_bpf.c
> > +++ b/tools/testing/selftests/hid/hid_bpf.c
> > @@ -853,12 +853,6 @@ static int libbpf_print_fn(enum libbpf_print_level 
> > level,
> >   return 0;
> >  }
> >
> > -static void __attribute__((constructor)) __constructor_order_last(void)
> > -{
> > - if (!__constructor_order)
> > - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
> > -}
> > -
> >  int main(int argc, char **argv)
> >  {
> >   /* Use libbpf 1.0 API mode */
> > diff --git a/tools/testing/selftests/kselftest_harness.h 
> > b/tools/testing/selftests/kselftest_harness.h
> > index ba3ddeda24bf..60c1cf5b0f0d 100644
> > --- a/tools/testing/selftests/kselftest_harness.h
> > +++ b/tools/testing/selftests/kselftest_harness.h
> > @@ -444,12 +444,6 @@
> >   * Use once to append a main() to the test file.
> >   */
> >  #define TEST_HARNESS_MAIN \
> > - static void __attribute__((constructor)) \
> > - __constructor_order_last(void) \
> > - { \
> > - if (!__constructor_order) \
> > - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
> > - } \
> >   int main(int argc, char **argv) { \
> >   return test_harness_run(argc, argv); \
> >   }
>
> This won't work. All constructors are executed, so we have to figure
> out which is run _first_. Switching this to a boolean means we gain no
> information about ordering: it'll always be set to "true".



It will be set to "true" eventually,
but __LIST_APPEND() still sees "false"
on backward-order systems.




Let's see how the following is expanded.


 #include "kselftest_harness.h"

 TEST(foo) { ... }

 TEST(bar) { ... }



You will get something as follows:



void _attribute__((constructor)) __constructor_order_first(void)
{
__constructor_order_forward = true;
}

void __attribute__((constructor)) _register_foo(void)
{
  __register_test(_object); // call __LIST_APPEND() for foo
}


void __attribute__((constructor)) _register_bar(void)
{
  __register_test(_object); // call __LIST_APPEND() for bar
}




On forward-order systems, the constructors are executed in this order:


  __constructor_order_first() -> _register_foo() -> _register_bar()


So, __LIST_APPEND will see "true".




On backward-order systems, the constructors are executed in this order:


  _register_bar() -> _register_foo() -> __constructor_order_first()


So, __LIST_APPEND will see "false" since __construtor_order_first()
has not been called yet.



Correct me if I am wrong.




> We need to
> detect which constructor sets it first so that we can walk the lists
> (that are built via all the constructors in between)


You have a wrong assumption here.

TEST() macros may not be placed in-between.


   #include "kselftest_harness.h"

   TEST_HARNESS_MAIN
   TEST(foo) { ... }
   TEST(bar) { ... }


This is perfectly correct code, because there is no reason to force
"Please put TEST_HARNESS_MAIN at the end of the file".

It is just a "coding style".


If the test code were written in such style with
the current harness implementation, __constructor_order
would be zero instead of _CONSTRUCTOR_ORDER_BACKWARD
on backward-order systems.
__LIST_APPEND() still 

Re: [PATCH net-next v9 05/14] netdev: netdevice devmem allocator

2024-05-17 Thread David Wei
On 2024-05-10 16:21, Mina Almasry wrote:
> +/* This returns the absolute dma_addr_t calculated from
> + * net_iov_owner(niov)->owner->base_dma_addr, not the page_pool-owned
> + * niov->dma_addr.
> + *
> + * The absolute dma_addr_t is a dma_addr_t that is always uncompressed.
> + *
> + * The page_pool-owner niov->dma_addr is the absolute dma_addr compressed 
> into
> + * an unsigned long. Special handling is done when the unsigned long is 
> 32-bit
> + * but the dma_addr_t is 64-bit.
> + *
> + * In general code looking for the dma_addr_t should use net_iov_dma_addr(),
> + * while page_pool code looking for the unsigned long dma_addr which mirrors
> + * the field in struct page should use niov->dma_addr.
> + */
> +static inline dma_addr_t net_iov_dma_addr(const struct net_iov *niov)
> +{
> + struct dmabuf_genpool_chunk_owner *owner = net_iov_owner(niov);
> +
> + return owner->base_dma_addr +
> +((dma_addr_t)net_iov_idx(niov) << PAGE_SHIFT);
> +}

This part feels like devmem TCP specific, yet the function is in
netmem.h. Please consider moving it into devmem.{h,c} which makes it
less likely that people not reading your comment will try using it.

> +
> +static inline struct net_devmem_dmabuf_binding *
> +net_iov_binding(const struct net_iov *niov)
> +{
> + return net_iov_owner(niov)->binding;
> +}
> +
>  /* netmem */
>  
>  /**
> diff --git a/net/core/devmem.c b/net/core/devmem.c
> index d82f92d7cf9ce..1f90e23a81441 100644
> --- a/net/core/devmem.c
> +++ b/net/core/devmem.c
> @@ -54,6 +54,42 @@ void __net_devmem_dmabuf_binding_free(struct 
> net_devmem_dmabuf_binding *binding)
>   kfree(binding);
>  }
>  
> +struct net_iov *
> +net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
> +{
> + struct dmabuf_genpool_chunk_owner *owner;
> + unsigned long dma_addr;
> + struct net_iov *niov;
> + ssize_t offset;
> + ssize_t index;
> +
> + dma_addr = gen_pool_alloc_owner(binding->chunk_pool, PAGE_SIZE,
> + (void **));
> + if (!dma_addr)
> + return NULL;
> +
> + offset = dma_addr - owner->base_dma_addr;
> + index = offset / PAGE_SIZE;
> + niov = >niovs[index];
> +
> + niov->dma_addr = 0;
> +
> + net_devmem_dmabuf_binding_get(binding);
> +
> + return niov;
> +}
> +
> +void net_devmem_free_dmabuf(struct net_iov *niov)
> +{
> + struct net_devmem_dmabuf_binding *binding = net_iov_binding(niov);
> + unsigned long dma_addr = net_iov_dma_addr(niov);
> +
> + if (gen_pool_has_addr(binding->chunk_pool, dma_addr, PAGE_SIZE))
> + gen_pool_free(binding->chunk_pool, dma_addr, PAGE_SIZE);
> +
> + net_devmem_dmabuf_binding_put(binding);
> +}
> +
>  /* Protected by rtnl_lock() */
>  static DEFINE_XARRAY_FLAGS(net_devmem_dmabuf_bindings, XA_FLAGS_ALLOC1);
>  



[PATCH] selftests: drivers/s390x: Use SKIP() during FIXTURE_SETUP

2024-05-17 Thread Kees Cook
Instead of mixing selftest harness and ksft helpers, perform SKIP
testing from the FIXTURE_SETUPs. This also means TEST_HARNESS_MAIN does
not need to be open-coded.

Signed-off-by: Kees Cook 
---
Cc: Christian Borntraeger 
Cc: Janosch Frank 
Cc: Claudio Imbrenda 
Cc: David Hildenbrand 
Cc: Shuah Khan 
Cc: Masahiro Yamada 
Cc: k...@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
---
I wasn't able to build or run test this, since it's very s390 specific, it 
seems?
---
 .../drivers/s390x/uvdevice/test_uvdevice.c| 32 ---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c 
b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
index ea0cdc37b44f..9622fac42597 100644
--- a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
+++ b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
@@ -18,6 +18,16 @@
 
 #define UV_PATH  "/dev/uv"
 #define BUFFER_SIZE 0x200
+
+#define open_uv() \
+do { \
+   self->uv_fd = open(UV_PATH, O_ACCMODE); \
+   if (self->uv_fd < 0) \
+   SKIP(return, "No uv-device or cannot access " UV_PATH  "\n" \
+"Enable CONFIG_S390_UV_UAPI and check the access 
rights on " \
+UV_PATH ".\n"); \
+} while (0)
+
 FIXTURE(uvio_fixture) {
int uv_fd;
struct uvio_ioctl_cb uvio_ioctl;
@@ -37,7 +47,7 @@ FIXTURE_VARIANT_ADD(uvio_fixture, att) {
 
 FIXTURE_SETUP(uvio_fixture)
 {
-   self->uv_fd = open(UV_PATH, O_ACCMODE);
+   open_uv();
 
self->uvio_ioctl.argument_addr = (__u64)self->buffer;
self->uvio_ioctl.argument_len = variant->arg_size;
@@ -159,7 +169,7 @@ FIXTURE(attest_fixture) {
 
 FIXTURE_SETUP(attest_fixture)
 {
-   self->uv_fd = open(UV_PATH, O_ACCMODE);
+   open_uv();
 
self->uvio_ioctl.argument_addr = (__u64)>uvio_attest;
self->uvio_ioctl.argument_len = sizeof(self->uvio_attest);
@@ -257,20 +267,4 @@ TEST_F(attest_fixture, att_inval_addr)
att_inval_addr_test(>uvio_attest.meas_addr, _metadata, self);
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
-int main(int argc, char **argv)
-{
-   int fd = open(UV_PATH, O_ACCMODE);
-
-   if (fd < 0)
-   ksft_exit_skip("No uv-device or cannot access " UV_PATH  "\n"
-  "Enable CONFIG_S390_UV_UAPI and check the access 
rights on "
-  UV_PATH ".\n");
-   close(fd);
-   return test_harness_run(argc, argv);
-}
+TEST_HARNESS_MAIN
-- 
2.34.1




[PATCH] selftests: hid: Do not open-code TEST_HARNESS_MAIN

2024-05-17 Thread Kees Cook
Avoid open-coding TEST_HARNESS_MAIN. (It might change, for example.)

Signed-off-by: Kees Cook 
---
Cc: Jiri Kosina 
Cc: Benjamin Tissoires 
Cc: Shuah Khan 
Cc: Masahiro Yamada 
Cc: linux-in...@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/hid/hid_bpf.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/hid/hid_bpf.c 
b/tools/testing/selftests/hid/hid_bpf.c
index f825623e3edc..943fa62a4f78 100644
--- a/tools/testing/selftests/hid/hid_bpf.c
+++ b/tools/testing/selftests/hid/hid_bpf.c
@@ -961,17 +961,11 @@ static int libbpf_print_fn(enum libbpf_print_level level,
return 0;
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
-int main(int argc, char **argv)
+static void __attribute__((constructor)) __one_time_init(void)
 {
/* Use libbpf 1.0 API mode */
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
libbpf_set_print(libbpf_print_fn);
-
-   return test_harness_run(argc, argv);
 }
+
+TEST_HARNESS_MAIN
-- 
2.34.1




[PATCH] selftests: rtc: rtctest: Do not open-code TEST_HARNESS_MAIN

2024-05-17 Thread Kees Cook
Argument processing is specific to the test harness code. Any optional
information needs to be passed via environment variables. Move alternate
path to the RTC_DEV environment variable. Also do not open-code
TEST_HARNESS_MAIN because its definition may change.

Additionally, setup checking can be done in the FIXTURE_SETUP(). With
this adjustment, also improve the error reporting when the device cannot
be opened.

Signed-off-by: Kees Cook 
---
Cc: Alexandre Belloni 
Cc: Shuah Khan 
Cc: Masahiro Yamada 
Cc: linux-...@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/rtc/Makefile  |  2 +-
 tools/testing/selftests/rtc/rtctest.c | 66 +--
 2 files changed, 13 insertions(+), 55 deletions(-)

diff --git a/tools/testing/selftests/rtc/Makefile 
b/tools/testing/selftests/rtc/Makefile
index 55198ecc04db..654f9d58da3c 100644
--- a/tools/testing/selftests/rtc/Makefile
+++ b/tools/testing/selftests/rtc/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDLIBS += -lrt -lpthread -lm
 
 TEST_GEN_PROGS = rtctest
diff --git a/tools/testing/selftests/rtc/rtctest.c 
b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..41cfefcc20e1 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -30,7 +30,18 @@ FIXTURE(rtc) {
 };
 
 FIXTURE_SETUP(rtc) {
+   char *alternate = getenv("RTC_DEV");
+
+   if (alternate)
+   rtc_file = alternate;
+
self->fd = open(rtc_file, O_RDONLY);
+
+   if (self->fd == -1 && errno == ENOENT)
+   SKIP(return, "Skipping test since %s does not exist", rtc_file);
+   EXPECT_NE(-1, self->fd) {
+   TH_LOG("%s: %s\n", rtc_file, strerror(errno));
+   }
 }
 
 FIXTURE_TEARDOWN(rtc) {
@@ -41,10 +52,6 @@ TEST_F(rtc, date_read) {
int rc;
struct rtc_time rtc_tm;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
/* Read the RTC time/date */
rc = ioctl(self->fd, RTC_RD_TIME, _tm);
ASSERT_NE(-1, rc);
@@ -88,10 +95,6 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 
2) {
struct rtc_time rtc_tm;
time_t start_rtc_read, prev_rtc_read;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
TH_LOG("Continuously reading RTC time for %ds (with %dms breaks after 
every read).",
   READ_LOOP_DURATION_SEC, READ_LOOP_SLEEP_MS);
 
@@ -126,10 +129,6 @@ TEST_F_TIMEOUT(rtc, uie_read, NUM_UIE + 2) {
int i, rc, irq = 0;
unsigned long data;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
/* Turn on update interrupts */
rc = ioctl(self->fd, RTC_UIE_ON, 0);
if (rc == -1) {
@@ -155,10 +154,6 @@ TEST_F(rtc, uie_select) {
int i, rc, irq = 0;
unsigned long data;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
/* Turn on update interrupts */
rc = ioctl(self->fd, RTC_UIE_ON, 0);
if (rc == -1) {
@@ -198,10 +193,6 @@ TEST_F(rtc, alarm_alm_set) {
time_t secs, new;
int rc;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
rc = ioctl(self->fd, RTC_RD_TIME, );
ASSERT_NE(-1, rc);
 
@@ -256,10 +247,6 @@ TEST_F(rtc, alarm_wkalm_set) {
time_t secs, new;
int rc;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
rc = ioctl(self->fd, RTC_RD_TIME, );
ASSERT_NE(-1, rc);
 
@@ -308,10 +295,6 @@ TEST_F_TIMEOUT(rtc, alarm_alm_set_minute, 65) {
time_t secs, new;
int rc;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
rc = ioctl(self->fd, RTC_RD_TIME, );
ASSERT_NE(-1, rc);
 
@@ -366,10 +349,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
time_t secs, new;
int rc;
 
-   if (self->fd == -1 && errno == ENOENT)
-   SKIP(return, "Skipping test since %s does not exist", rtc_file);
-   ASSERT_NE(-1, self->fd);
-
rc = ioctl(self->fd, RTC_RD_TIME, );
ASSERT_NE(-1, rc);
 
@@ -410,25 +389,4 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
ASSERT_EQ(new, secs);
 }
 
-static void 

Re: [PATCH 1/2] selftests: harness: remove unneeded __constructor_order_last()

2024-05-17 Thread Kees Cook
On Fri, May 17, 2024 at 08:45:05PM +0900, Masahiro Yamada wrote:
> __constructor_order_last() is unneeded.
> 
> If __constructor_order_last() is not called on reverse-order systems,
> __constructor_order will remain 0 instead of being set to
> _CONSTRUCTOR_ORDER_BACKWARD (= -1).
> 
> __LIST_APPEND() will still take the 'else' branch, so there is no
> difference in the behavior.
> 
> Signed-off-by: Masahiro Yamada 
> ---
> 
>  .../selftests/drivers/s390x/uvdevice/test_uvdevice.c   |  6 --
>  tools/testing/selftests/hid/hid_bpf.c  |  6 --
>  tools/testing/selftests/kselftest_harness.h| 10 +-
>  tools/testing/selftests/rtc/rtctest.c  |  7 ---
>  4 files changed, 1 insertion(+), 28 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c 
> b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> index ea0cdc37b44f..7ee7492138c6 100644
> --- a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> +++ b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
> @@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr)
>   att_inval_addr_test(>uvio_attest.meas_addr, _metadata, self);
>  }
>  
> -static void __attribute__((constructor)) __constructor_order_last(void)
> -{
> - if (!__constructor_order)
> - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
> -}
> -
>  int main(int argc, char **argv)
>  {
>   int fd = open(UV_PATH, O_ACCMODE);
> diff --git a/tools/testing/selftests/hid/hid_bpf.c 
> b/tools/testing/selftests/hid/hid_bpf.c
> index 2cf96f818f25..f47feef2aced 100644
> --- a/tools/testing/selftests/hid/hid_bpf.c
> +++ b/tools/testing/selftests/hid/hid_bpf.c
> @@ -853,12 +853,6 @@ static int libbpf_print_fn(enum libbpf_print_level level,
>   return 0;
>  }
>  
> -static void __attribute__((constructor)) __constructor_order_last(void)
> -{
> - if (!__constructor_order)
> - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
> -}
> -
>  int main(int argc, char **argv)
>  {
>   /* Use libbpf 1.0 API mode */
> diff --git a/tools/testing/selftests/kselftest_harness.h 
> b/tools/testing/selftests/kselftest_harness.h
> index ba3ddeda24bf..60c1cf5b0f0d 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -444,12 +444,6 @@
>   * Use once to append a main() to the test file.
>   */
>  #define TEST_HARNESS_MAIN \
> - static void __attribute__((constructor)) \
> - __constructor_order_last(void) \
> - { \
> - if (!__constructor_order) \
> - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
> - } \
>   int main(int argc, char **argv) { \
>   return test_harness_run(argc, argv); \
>   }

This won't work. All constructors are executed, so we have to figure
out which is run _first_. Switching this to a boolean means we gain no
information about ordering: it'll always be set to "true". We need to
detect which constructor sets it first so that we can walk the lists
(that are built via all the constructors in between) in the correct
order.

> @@ -846,7 +840,6 @@ static struct __fixture_metadata *__fixture_list = 
> &_fixture_global;
>  static int __constructor_order;
>  
>  #define _CONSTRUCTOR_ORDER_FORWARD   1
> -#define _CONSTRUCTOR_ORDER_BACKWARD -1
>  
>  static inline void __register_fixture(struct __fixture_metadata *f)
>  {
> @@ -1272,8 +1265,7 @@ static int test_harness_run(int argc, char **argv)
>  
>  static void __attribute__((constructor)) __constructor_order_first(void)
>  {
> - if (!__constructor_order)
> - __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
> + __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
>  }
>  
>  #endif  /* __KSELFTEST_HARNESS_H */
> diff --git a/tools/testing/selftests/rtc/rtctest.c 
> b/tools/testing/selftests/rtc/rtctest.c
> index 63ce02d1d5cc..9647b14b47c5 100644
> --- a/tools/testing/selftests/rtc/rtctest.c
> +++ b/tools/testing/selftests/rtc/rtctest.c
> @@ -410,13 +410,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
>   ASSERT_EQ(new, secs);
>  }
>  
> -static void __attribute__((constructor))
> -__constructor_order_last(void)
> -{
> - if (!__constructor_order)
> - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
> -}
> -
>  int main(int argc, char **argv)
>  {
>   switch (argc) {

A better question is why these tests are open-coding the execution of
"main"...

-- 
Kees Cook



Re: [PATCH 0/2] selftests: harness: refactor __constructor_order

2024-05-17 Thread Kees Cook
On Fri, May 17, 2024 at 08:45:04PM +0900, Masahiro Yamada wrote:
> 
> This series refactors __constructor_order because
> __constructor_order_last() is unneeded.
> 
> BTW, the comments in kselftest_harness.h was confusing to me.
> 
> As far as I tested, all arches executed constructors in the forward
> order.
> 
> [test code]
> 
>   #include 
> 
>   static int x;
> 
>   static void __attribute__((constructor)) increment(void)
>   {
>x += 1;
>   }
> 
>   static void __attribute__((constructor)) multiply(void)
>   {
>   x *= 2;
>   }
> 
>   int main(void)
>   {
>   printf("foo = %d\n", x);
>   return 0;
>   }
> 
> It should print 2 for forward order systems, 1 for reverse order systems.
> 
> I executed it on some archtes by using QEMU. I always got 2.

IIRC, and it was a long time ago now, it was actually a difference
between libc implementations where I encountered the problem. Maybe
glibc vs Bionic?

-Kees

-- 
Kees Cook



Re: [PATCH net v3] selftests: net: local_termination: annotate the expected failures

2024-05-17 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski :

On Thu, 16 May 2024 08:25:13 -0700 you wrote:
> Vladimir said when adding this test:
> 
>   The bridge driver fares particularly badly [...] mainly because
>   it does not implement IFF_UNICAST_FLT.
> 
> See commit 90b9566aa5cd ("selftests: forwarding: add a test for
> local_termination.sh").
> 
> [...]

Here is the summary with links:
  - [net,v3] selftests: net: local_termination: annotate the expected failures
https://git.kernel.org/netdev/net/c/fe56d6e4a99a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html





Re: [PATCHv2 net] selftests/net: use tc rule to filter the na packet

2024-05-17 Thread Simon Horman
On Fri, May 17, 2024 at 12:04:20PM -0700, Jakub Kicinski wrote:
> On Fri, 17 May 2024 10:14:02 +0100 Simon Horman wrote:
> > Jakub, is there a way to tell how long a test took to execute?
> > Perhaps it's obvious, but I couldn't see it.
> 
> It's not obvious, and it was broken. There's an 'info' file with
> extra metadata in the directory with results:
> 
> https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/599300/39-arp-ndisc-untracked-subnets-sh/info
> 
> but it's currently reporting fractional seconds rather than total
> seconds:
> 
> https://github.com/linux-netdev/nipa/commit/fb7c45fd3b68b379b7bceb8f79c8df06aaf53ee0
> 
> Once we have a proper DB (any day now), I'll add it to the JSON output
> so it appears in the web UI.

Great, thanks.



Re: [PATCHv2 net] selftests/net: use tc rule to filter the na packet

2024-05-17 Thread Jakub Kicinski
On Fri, 17 May 2024 10:14:02 +0100 Simon Horman wrote:
> Jakub, is there a way to tell how long a test took to execute?
> Perhaps it's obvious, but I couldn't see it.

It's not obvious, and it was broken. There's an 'info' file with
extra metadata in the directory with results:

https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/599300/39-arp-ndisc-untracked-subnets-sh/info

but it's currently reporting fractional seconds rather than total
seconds:

https://github.com/linux-netdev/nipa/commit/fb7c45fd3b68b379b7bceb8f79c8df06aaf53ee0

Once we have a proper DB (any day now), I'll add it to the JSON output
so it appears in the web UI.



Re: [PATCH] kunit: tool: Build compile_commands.json

2024-05-17 Thread Nathan Chancellor
Hi Brendan,

On Thu, May 16, 2024 at 07:40:53PM +, Brendan Jackman wrote:
> compile_commands.json is used by clangd[1] to provide code navigation
> and completion functionality to editors. See [2] for an example
> configuration that includes this functionality for VSCode.
> 
> It can currently be built manually when using kunit.py, by running:
> 
>   ./scripts/clang-tools/gen_compile_commands.py -d .kunit
> 
> With this change however, it's built automatically so you don't need to
> manually keep it up to date.
> 
> Unlike the manual approach, having make build the compile_commands.json
> means that it appears in the build output tree instead of at the root of
> the source tree, so you'll need to add --compile-commands-dir=.kunit to
> your clangd args for it to be found. This might turn out to be pretty
> annoying, I'm not sure yet. If so maybe we can later add some hackery to
> kunit.py to work around it.
> 
> [1] https://clangd.llvm.org/
> [2] https://github.com/FlorentRevest/linux-kernel-vscode
> 
> Signed-off-by: Brendan Jackman 

This makes sense to do automatically in my opinion, as Python will
already be available (which is the only dependency of
gen_compile_commands.py as far as I am aware) and it should not take
that long to generate.

Reviewed-by: Nathan Chancellor 

> ---
>  tools/testing/kunit/kunit_kernel.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/kunit/kunit_kernel.py 
> b/tools/testing/kunit/kunit_kernel.py
> index 7254c110ff23..61931c4926fd 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -72,7 +72,8 @@ class LinuxSourceTreeOperations:
>   raise ConfigError(e.output.decode())
>  
>   def make(self, jobs: int, build_dir: str, make_options: 
> Optional[List[str]]) -> None:
> - command = ['make', 'ARCH=' + self._linux_arch, 'O=' + 
> build_dir, '--jobs=' + str(jobs)]
> + command = ['make', 'all', 'compile_commands.json', 'ARCH=' + 
> self._linux_arch,
> +'O=' + build_dir, '--jobs=' + str(jobs)]
>   if make_options:
>   command.extend(make_options)
>   if self._cross_compile:
> 
> ---
> base-commit: 3c999d1ae3c75991902a1a7dad0cb62c2a3008b4
> change-id: 20240516-kunit-compile-commands-d994074fc2be
> 
> Best regards,
> -- 
> Brendan Jackman 
> 
> 



Re: [PATCH v5 07/16] riscv: add ISA extensions validation callback

2024-05-17 Thread Conor Dooley
On Fri, May 17, 2024 at 04:52:47PM +0200, Clément Léger wrote:
> Since a few extensions (Zicbom/Zicboz) already needs validation and
> future ones will need it as well (Zc*) add a validate() callback to
> struct riscv_isa_ext_data. This require to rework the way extensions are
> parsed and split it in two phases. First phase is isa string or isa
> extension list parsing and consists in enabling all the extensions in a
> temporary bitmask (source isa) without any validation. The second step
> "resolves" the final isa bitmap, handling potential missing dependencies.
> The mechanism is quite simple and simply validate each extension
> described in the source bitmap before enabling it in the resolved isa
> bitmap. validate() callbacks can return either 0 for success,
> -EPROBEDEFER if extension needs to be validated again at next loop. A
> previous ISA bitmap is kept to avoid looping multiple times if an
> extension dependencies are never satisfied until we reach a stable
> state. In order to avoid any potential infinite looping, allow looping
> a maximum of the number of extension we handle. Zicboz and Zicbom
> extensions are modified to use this validation mechanism.

I wish we weren't doin' it at all, but since we have to, I think what
you've got here is good.
Reviewed-by: Conor Dooley 

Do you want me to send some patches for the F/V stuff we discussed
previously?

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v5 05/16] KVM: riscv: selftests: Add Zimop extension to get-reg-list test

2024-05-17 Thread Anup Patel
On Fri, May 17, 2024 at 8:23 PM Clément Léger  wrote:
>
> The KVM RISC-V allows Zimop extension for Guest/VM so add this
> extension to get-reg-list test.
>
> Signed-off-by: Clément Léger 

LGTM.

Reviewed-by: Anup Patel 
Acked-by: Anup Patel 

Regards,
Anup

> ---
>  tools/testing/selftests/kvm/riscv/get-reg-list.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c 
> b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> index b882b7b9b785..40107bb61975 100644
> --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
> +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> @@ -67,6 +67,7 @@ bool filter_reg(__u64 reg)
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZIHINTNTL:
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZIHPM:
> +   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZIMOP:
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZKND:
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZKNE:
> case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
> KVM_RISCV_ISA_EXT_ZKNH:
> @@ -432,6 +433,7 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
> KVM_ISA_EXT_ARR(ZIHINTNTL),
> KVM_ISA_EXT_ARR(ZIHINTPAUSE),
> KVM_ISA_EXT_ARR(ZIHPM),
> +   KVM_ISA_EXT_ARR(ZIMOP),
> KVM_ISA_EXT_ARR(ZKND),
> KVM_ISA_EXT_ARR(ZKNE),
> KVM_ISA_EXT_ARR(ZKNH),
> @@ -955,6 +957,7 @@ KVM_ISA_EXT_SIMPLE_CONFIG(zifencei, ZIFENCEI);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zihintntl, ZIHINTNTL);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zihintpause, ZIHINTPAUSE);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zihpm, ZIHPM);
> +KVM_ISA_EXT_SIMPLE_CONFIG(zimop, ZIMOP);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zknd, ZKND);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zkne, ZKNE);
>  KVM_ISA_EXT_SIMPLE_CONFIG(zknh, ZKNH);
> @@ -1010,6 +1013,7 @@ struct vcpu_reg_list *vcpu_configs[] = {
> _zihintntl,
> _zihintpause,
> _zihpm,
> +   _zimop,
> _zknd,
> _zkne,
> _zknh,
> --
> 2.43.0
>



Re: [PATCH v5 04/16] RISC-V: KVM: Allow Zimop extension for Guest/VM

2024-05-17 Thread Anup Patel
On Fri, May 17, 2024 at 8:23 PM Clément Léger  wrote:
>
> Extend the KVM ISA extension ONE_REG interface to allow KVM user space
> to detect and enable Zimop extension for Guest/VM.
>
> Signed-off-by: Clément Léger 

LGTM.

Reviewed-by: Anup Patel 
Acked-by: Anup Patel 

Regards,
Anup

> ---
>  arch/riscv/include/uapi/asm/kvm.h | 1 +
>  arch/riscv/kvm/vcpu_onereg.c  | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/arch/riscv/include/uapi/asm/kvm.h 
> b/arch/riscv/include/uapi/asm/kvm.h
> index b1c503c2959c..35a12aa1953e 100644
> --- a/arch/riscv/include/uapi/asm/kvm.h
> +++ b/arch/riscv/include/uapi/asm/kvm.h
> @@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID {
> KVM_RISCV_ISA_EXT_ZFA,
> KVM_RISCV_ISA_EXT_ZTSO,
> KVM_RISCV_ISA_EXT_ZACAS,
> +   KVM_RISCV_ISA_EXT_ZIMOP,
> KVM_RISCV_ISA_EXT_MAX,
>  };
>
> diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c
> index f4a6124d25c9..c6ee763422f2 100644
> --- a/arch/riscv/kvm/vcpu_onereg.c
> +++ b/arch/riscv/kvm/vcpu_onereg.c
> @@ -60,6 +60,7 @@ static const unsigned long kvm_isa_ext_arr[] = {
> KVM_ISA_EXT_ARR(ZIHINTNTL),
> KVM_ISA_EXT_ARR(ZIHINTPAUSE),
> KVM_ISA_EXT_ARR(ZIHPM),
> +   KVM_ISA_EXT_ARR(ZIMOP),
> KVM_ISA_EXT_ARR(ZKND),
> KVM_ISA_EXT_ARR(ZKNE),
> KVM_ISA_EXT_ARR(ZKNH),
> @@ -137,6 +138,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned 
> long ext)
> case KVM_RISCV_ISA_EXT_ZIHINTNTL:
> case KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
> case KVM_RISCV_ISA_EXT_ZIHPM:
> +   case KVM_RISCV_ISA_EXT_ZIMOP:
> case KVM_RISCV_ISA_EXT_ZKND:
> case KVM_RISCV_ISA_EXT_ZKNE:
> case KVM_RISCV_ISA_EXT_ZKNH:
> --
> 2.43.0
>



[PATCH v5 16/16] KVM: riscv: selftests: Add Zcmop extension to get-reg-list test

2024-05-17 Thread Clément Léger
The KVM RISC-V allows Zcmop extension for Guest/VM so add this
extension to get-reg-list test.

Signed-off-by: Clément Léger 
Reviewed-by: Anup Patel 
Acked-by: Anup Patel 
---
 tools/testing/selftests/kvm/riscv/get-reg-list.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c 
b/tools/testing/selftests/kvm/riscv/get-reg-list.c
index 61cad4514197..9604c8ece787 100644
--- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
+++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
@@ -59,6 +59,7 @@ bool filter_reg(__u64 reg)
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCB:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCD:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCF:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCMOP:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFA:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFH:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFHMIN:
@@ -429,6 +430,7 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
KVM_ISA_EXT_ARR(ZCB),
KVM_ISA_EXT_ARR(ZCD),
KVM_ISA_EXT_ARR(ZCF),
+   KVM_ISA_EXT_ARR(ZCMOP),
KVM_ISA_EXT_ARR(ZFA),
KVM_ISA_EXT_ARR(ZFH),
KVM_ISA_EXT_ARR(ZFHMIN),
@@ -957,6 +959,7 @@ KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA),
 KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB),
 KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD),
 KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF),
+KVM_ISA_EXT_SIMPLE_CONFIG(zcmop, ZCMOP);
 KVM_ISA_EXT_SIMPLE_CONFIG(zfa, ZFA);
 KVM_ISA_EXT_SIMPLE_CONFIG(zfh, ZFH);
 KVM_ISA_EXT_SIMPLE_CONFIG(zfhmin, ZFHMIN);
@@ -1017,6 +1020,7 @@ struct vcpu_reg_list *vcpu_configs[] = {
_zcb,
_zcd,
_zcf,
+   _zcmop,
_zfa,
_zfh,
_zfhmin,
-- 
2.43.0




[PATCH v5 15/16] RISC-V: KVM: Allow Zcmop extension for Guest/VM

2024-05-17 Thread Clément Léger
Extend the KVM ISA extension ONE_REG interface to allow KVM user space
to detect and enable Zcmop extension for Guest/VM.

Signed-off-by: Clément Léger 
Reviewed-by: Anup Patel 
Acked-by: Anup Patel 
---
 arch/riscv/include/uapi/asm/kvm.h | 1 +
 arch/riscv/kvm/vcpu_onereg.c  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/riscv/include/uapi/asm/kvm.h 
b/arch/riscv/include/uapi/asm/kvm.h
index 57db3fea679f..0366389a0bae 100644
--- a/arch/riscv/include/uapi/asm/kvm.h
+++ b/arch/riscv/include/uapi/asm/kvm.h
@@ -172,6 +172,7 @@ enum KVM_RISCV_ISA_EXT_ID {
KVM_RISCV_ISA_EXT_ZCB,
KVM_RISCV_ISA_EXT_ZCD,
KVM_RISCV_ISA_EXT_ZCF,
+   KVM_RISCV_ISA_EXT_ZCMOP,
KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c
index 7d47fc910bd9..af4fefa189af 100644
--- a/arch/riscv/kvm/vcpu_onereg.c
+++ b/arch/riscv/kvm/vcpu_onereg.c
@@ -52,6 +52,7 @@ static const unsigned long kvm_isa_ext_arr[] = {
KVM_ISA_EXT_ARR(ZCB),
KVM_ISA_EXT_ARR(ZCD),
KVM_ISA_EXT_ARR(ZCF),
+   KVM_ISA_EXT_ARR(ZCMOP),
KVM_ISA_EXT_ARR(ZFA),
KVM_ISA_EXT_ARR(ZFH),
KVM_ISA_EXT_ARR(ZFHMIN),
@@ -136,6 +137,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned 
long ext)
case KVM_RISCV_ISA_EXT_ZCB:
case KVM_RISCV_ISA_EXT_ZCD:
case KVM_RISCV_ISA_EXT_ZCF:
+   case KVM_RISCV_ISA_EXT_ZCMOP:
case KVM_RISCV_ISA_EXT_ZFA:
case KVM_RISCV_ISA_EXT_ZFH:
case KVM_RISCV_ISA_EXT_ZFHMIN:
-- 
2.43.0




[PATCH v5 14/16] riscv: hwprobe: export Zcmop ISA extension

2024-05-17 Thread Clément Léger
Export Zcmop ISA extension through hwprobe.

Signed-off-by: Clément Léger 
---
 Documentation/arch/riscv/hwprobe.rst  | 4 
 arch/riscv/include/uapi/asm/hwprobe.h | 1 +
 arch/riscv/kernel/sys_hwprobe.c   | 1 +
 3 files changed, 6 insertions(+)

diff --git a/Documentation/arch/riscv/hwprobe.rst 
b/Documentation/arch/riscv/hwprobe.rst
index cad84f51412d..9a77b7d14539 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -216,6 +216,10 @@ The following keys are defined:
("Zcf doesn't exist on RV64 as it contains no instructions") of
riscv-code-size-reduction.
 
+  * :c:macro:`RISCV_HWPROBE_EXT_ZCMOP`: The Zcmop May-Be-Operations extension 
is
+   supported as defined in the RISC-V ISA manual starting from commit
+   c732a4f39a4 ("Zcmop is ratified/1.0").
+
 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
   information about the selected set of processors.
 
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h 
b/arch/riscv/include/uapi/asm/hwprobe.h
index 652b2373729f..3a3d6a2b4f48 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -65,6 +65,7 @@ struct riscv_hwprobe {
 #defineRISCV_HWPROBE_EXT_ZCB   (1ULL << 39)
 #defineRISCV_HWPROBE_EXT_ZCD   (1ULL << 40)
 #defineRISCV_HWPROBE_EXT_ZCF   (1ULL << 41)
+#defineRISCV_HWPROBE_EXT_ZCMOP (1ULL << 42)
 #define RISCV_HWPROBE_KEY_CPUPERF_05
 #defineRISCV_HWPROBE_MISALIGNED_UNKNOWN(0 << 0)
 #defineRISCV_HWPROBE_MISALIGNED_EMULATED   (1 << 0)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 11def345a42d..34c95eaf8cd1 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -115,6 +115,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
EXT_KEY(ZIMOP);
EXT_KEY(ZCA);
EXT_KEY(ZCB);
+   EXT_KEY(ZCMOP);
 
if (has_vector()) {
EXT_KEY(ZVBB);
-- 
2.43.0




[PATCH v5 13/16] riscv: add ISA extension parsing for Zcmop

2024-05-17 Thread Clément Léger
Add parsing for Zcmop ISA extension which was ratified in commit
b854a709c00 ("Zcmop is ratified/1.0") of the riscv-isa-manual.

Signed-off-by: Clément Léger 
---
 arch/riscv/include/asm/hwcap.h | 1 +
 arch/riscv/kernel/cpufeature.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
index a5836fa6b998..aaaf23f204ac 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -85,6 +85,7 @@
 #define RISCV_ISA_EXT_ZCB  76
 #define RISCV_ISA_EXT_ZCD  77
 #define RISCV_ISA_EXT_ZCF  78
+#define RISCV_ISA_EXT_ZCMOP79
 
 #define RISCV_ISA_EXT_XLINUXENVCFG 127
 
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 3bb2ef52a38b..0a40fa1faa04 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -290,6 +290,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_DATA_VALIDATE(zcb, RISCV_ISA_EXT_ZCB, 
riscv_ext_zca_depends),
__RISCV_ISA_EXT_DATA_VALIDATE(zcd, RISCV_ISA_EXT_ZCD, 
riscv_ext_zcd_validate),
__RISCV_ISA_EXT_DATA_VALIDATE(zcf, RISCV_ISA_EXT_ZCF, 
riscv_ext_zcf_validate),
+   __RISCV_ISA_EXT_DATA_VALIDATE(zcmop, RISCV_ISA_EXT_ZCMOP, 
riscv_ext_zca_depends),
__RISCV_ISA_EXT_DATA(zba, RISCV_ISA_EXT_ZBA),
__RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB),
__RISCV_ISA_EXT_DATA(zbc, RISCV_ISA_EXT_ZBC),
-- 
2.43.0




[PATCH v5 12/16] dt-bindings: riscv: add Zcmop ISA extension description

2024-05-17 Thread Clément Léger
Add description for the Zcmop (Compressed May-Be-Operations) ISA
extension which was ratified in commit c732a4f39a4 ("Zcmop is
ratified/1.0") of the riscv-isa-manual.

Signed-off-by: Clément Léger 
Acked-by: Conor Dooley 
---
 .../devicetree/bindings/riscv/extensions.yaml| 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml 
b/Documentation/devicetree/bindings/riscv/extensions.yaml
index 39084c58d4e4..acad4d9d96ab 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -252,6 +252,11 @@ properties:
 merged in the riscv-isa-manual by commit dbc79cf28a2 ("Initial seed
 of zc.adoc to src tree.").
 
+- const: zcmop
+  description:
+The standard Zcmop extension version 1.0, as ratified in commit
+c732a4f39a4 ("Zcmop is ratified/1.0") of the riscv-isa-manual.
+
 - const: zfa
   description:
 The standard Zfa extension for additional floating point
@@ -559,6 +564,13 @@ properties:
 const: zca
 - contains:
 const: f
+  # Zcmop depends on Zca
+  - if:
+  contains:
+const: zcmop
+then:
+  contains:
+const: zca
 
 allOf:
   # Zcf extension does not exist on rv64
-- 
2.43.0




[PATCH v5 11/16] KVM: riscv: selftests: Add some Zc* extensions to get-reg-list test

2024-05-17 Thread Clément Léger
The KVM RISC-V allows Zca, Zcf, Zcd and Zcb extensions for Guest/VM so
add these extensions to get-reg-list test.

Signed-off-by: Clément Léger 
Reviewed-by: Anup Patel 
Acked-by: Anup Patel 
---
 tools/testing/selftests/kvm/riscv/get-reg-list.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c 
b/tools/testing/selftests/kvm/riscv/get-reg-list.c
index 40107bb61975..61cad4514197 100644
--- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
+++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
@@ -55,6 +55,10 @@ bool filter_reg(__u64 reg)
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZBKC:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZBKX:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZBS:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCA:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCB:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCD:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZCF:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFA:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFH:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZFHMIN:
@@ -421,6 +425,10 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
KVM_ISA_EXT_ARR(ZBKC),
KVM_ISA_EXT_ARR(ZBKX),
KVM_ISA_EXT_ARR(ZBS),
+   KVM_ISA_EXT_ARR(ZCA),
+   KVM_ISA_EXT_ARR(ZCB),
+   KVM_ISA_EXT_ARR(ZCD),
+   KVM_ISA_EXT_ARR(ZCF),
KVM_ISA_EXT_ARR(ZFA),
KVM_ISA_EXT_ARR(ZFH),
KVM_ISA_EXT_ARR(ZFHMIN),
@@ -945,6 +953,10 @@ KVM_ISA_EXT_SIMPLE_CONFIG(zbkb, ZBKB);
 KVM_ISA_EXT_SIMPLE_CONFIG(zbkc, ZBKC);
 KVM_ISA_EXT_SIMPLE_CONFIG(zbkx, ZBKX);
 KVM_ISA_EXT_SIMPLE_CONFIG(zbs, ZBS);
+KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA),
+KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB),
+KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD),
+KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF),
 KVM_ISA_EXT_SIMPLE_CONFIG(zfa, ZFA);
 KVM_ISA_EXT_SIMPLE_CONFIG(zfh, ZFH);
 KVM_ISA_EXT_SIMPLE_CONFIG(zfhmin, ZFHMIN);
@@ -1001,6 +1013,10 @@ struct vcpu_reg_list *vcpu_configs[] = {
_zbkc,
_zbkx,
_zbs,
+   _zca,
+   _zcb,
+   _zcd,
+   _zcf,
_zfa,
_zfh,
_zfhmin,
-- 
2.43.0




[PATCH v5 10/16] RISC-V: KVM: Allow Zca, Zcf, Zcd and Zcb extensions for Guest/VM

2024-05-17 Thread Clément Léger
Extend the KVM ISA extension ONE_REG interface to allow KVM user space
to detect and enable Zca, Zcf, Zcd and Zcb extensions for Guest/VM.

Signed-off-by: Clément Léger 
Reviewed-by: Anup Patel 
Acked-by: Anup Patel 
---
 arch/riscv/include/uapi/asm/kvm.h | 4 
 arch/riscv/kvm/vcpu_onereg.c  | 8 
 2 files changed, 12 insertions(+)

diff --git a/arch/riscv/include/uapi/asm/kvm.h 
b/arch/riscv/include/uapi/asm/kvm.h
index 35a12aa1953e..57db3fea679f 100644
--- a/arch/riscv/include/uapi/asm/kvm.h
+++ b/arch/riscv/include/uapi/asm/kvm.h
@@ -168,6 +168,10 @@ enum KVM_RISCV_ISA_EXT_ID {
KVM_RISCV_ISA_EXT_ZTSO,
KVM_RISCV_ISA_EXT_ZACAS,
KVM_RISCV_ISA_EXT_ZIMOP,
+   KVM_RISCV_ISA_EXT_ZCA,
+   KVM_RISCV_ISA_EXT_ZCB,
+   KVM_RISCV_ISA_EXT_ZCD,
+   KVM_RISCV_ISA_EXT_ZCF,
KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c
index c6ee763422f2..7d47fc910bd9 100644
--- a/arch/riscv/kvm/vcpu_onereg.c
+++ b/arch/riscv/kvm/vcpu_onereg.c
@@ -48,6 +48,10 @@ static const unsigned long kvm_isa_ext_arr[] = {
KVM_ISA_EXT_ARR(ZBKC),
KVM_ISA_EXT_ARR(ZBKX),
KVM_ISA_EXT_ARR(ZBS),
+   KVM_ISA_EXT_ARR(ZCA),
+   KVM_ISA_EXT_ARR(ZCB),
+   KVM_ISA_EXT_ARR(ZCD),
+   KVM_ISA_EXT_ARR(ZCF),
KVM_ISA_EXT_ARR(ZFA),
KVM_ISA_EXT_ARR(ZFH),
KVM_ISA_EXT_ARR(ZFHMIN),
@@ -128,6 +132,10 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned 
long ext)
case KVM_RISCV_ISA_EXT_ZBKC:
case KVM_RISCV_ISA_EXT_ZBKX:
case KVM_RISCV_ISA_EXT_ZBS:
+   case KVM_RISCV_ISA_EXT_ZCA:
+   case KVM_RISCV_ISA_EXT_ZCB:
+   case KVM_RISCV_ISA_EXT_ZCD:
+   case KVM_RISCV_ISA_EXT_ZCF:
case KVM_RISCV_ISA_EXT_ZFA:
case KVM_RISCV_ISA_EXT_ZFH:
case KVM_RISCV_ISA_EXT_ZFHMIN:
-- 
2.43.0




[PATCH v5 09/16] riscv: hwprobe: export Zca, Zcf, Zcd and Zcb ISA extensions

2024-05-17 Thread Clément Léger
Export Zca, Zcf, Zcd and Zcb ISA extension through hwprobe.

Signed-off-by: Clément Léger 
---
 Documentation/arch/riscv/hwprobe.rst  | 20 
 arch/riscv/include/uapi/asm/hwprobe.h |  4 
 arch/riscv/kernel/sys_hwprobe.c   |  4 
 3 files changed, 28 insertions(+)

diff --git a/Documentation/arch/riscv/hwprobe.rst 
b/Documentation/arch/riscv/hwprobe.rst
index 48be38e0b788..cad84f51412d 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -196,6 +196,26 @@ The following keys are defined:
supported as defined in the RISC-V ISA manual starting from commit
58220614a5f ("Zimop is ratified/1.0").
 
+  * :c:macro:`RISCV_HWPROBE_EXT_ZCA`: The Zca extension part of Zc* standard
+   extensions for code size reduction, as ratified in commit 8be3419c1c0
+   ("Zcf doesn't exist on RV64 as it contains no instructions") of
+   riscv-code-size-reduction.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZCB`: The Zcb extension part of Zc* standard
+   extensions for code size reduction, as ratified in commit 8be3419c1c0
+   ("Zcf doesn't exist on RV64 as it contains no instructions") of
+   riscv-code-size-reduction.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZCD`: The Zcd extension part of Zc* standard
+   extensions for code size reduction, as ratified in commit 8be3419c1c0
+   ("Zcf doesn't exist on RV64 as it contains no instructions") of
+   riscv-code-size-reduction.
+
+  * :c:macro:`RISCV_HWPROBE_EXT_ZCF`: The Zcf extension part of Zc* standard
+   extensions for code size reduction, as ratified in commit 8be3419c1c0
+   ("Zcf doesn't exist on RV64 as it contains no instructions") of
+   riscv-code-size-reduction.
+
 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
   information about the selected set of processors.
 
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h 
b/arch/riscv/include/uapi/asm/hwprobe.h
index 3b16a12204b1..652b2373729f 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -61,6 +61,10 @@ struct riscv_hwprobe {
 #defineRISCV_HWPROBE_EXT_ZICOND(1ULL << 35)
 #defineRISCV_HWPROBE_EXT_ZIHINTPAUSE   (1ULL << 36)
 #defineRISCV_HWPROBE_EXT_ZIMOP (1ULL << 37)
+#defineRISCV_HWPROBE_EXT_ZCA   (1ULL << 38)
+#defineRISCV_HWPROBE_EXT_ZCB   (1ULL << 39)
+#defineRISCV_HWPROBE_EXT_ZCD   (1ULL << 40)
+#defineRISCV_HWPROBE_EXT_ZCF   (1ULL << 41)
 #define RISCV_HWPROBE_KEY_CPUPERF_05
 #defineRISCV_HWPROBE_MISALIGNED_UNKNOWN(0 << 0)
 #defineRISCV_HWPROBE_MISALIGNED_EMULATED   (1 << 0)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index fc6f4238f0b3..11def345a42d 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -113,6 +113,8 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
EXT_KEY(ZICOND);
EXT_KEY(ZIHINTPAUSE);
EXT_KEY(ZIMOP);
+   EXT_KEY(ZCA);
+   EXT_KEY(ZCB);
 
if (has_vector()) {
EXT_KEY(ZVBB);
@@ -133,6 +135,8 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
EXT_KEY(ZFH);
EXT_KEY(ZFHMIN);
EXT_KEY(ZFA);
+   EXT_KEY(ZCD);
+   EXT_KEY(ZCF);
}
 #undef EXT_KEY
}
-- 
2.43.0




[PATCH v5 08/16] riscv: add ISA parsing for Zca, Zcf, Zcd and Zcb

2024-05-17 Thread Clément Léger
The Zc* standard extension for code reduction introduces new extensions.
This patch adds support for Zca, Zcf, Zcd and Zcb. Zce, Zcmt and Zcmp
are left out of this patch since they are targeting microcontrollers/
embedded CPUs instead of application processors.

Signed-off-by: Clément Léger 
---
 arch/riscv/include/asm/cpufeature.h |  3 ++
 arch/riscv/include/asm/hwcap.h  |  4 +++
 arch/riscv/kernel/cpufeature.c  | 44 -
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/cpufeature.h 
b/arch/riscv/include/asm/cpufeature.h
index 1a148cd67e0e..8611e1c8ec2d 100644
--- a/arch/riscv/include/asm/cpufeature.h
+++ b/arch/riscv/include/asm/cpufeature.h
@@ -46,6 +46,9 @@ void riscv_user_isa_enable(void);
 
 #define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 
0, NULL)
 
+#define __RISCV_ISA_EXT_DATA_VALIDATE(_name, _id, _validate) \
+   _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0, _validate)
+
 /* Used to declare pure "lasso" extension (Zk for instance) */
 #define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \
_RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, \
diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
index b1896dade74c..a5836fa6b998 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -81,6 +81,10 @@
 #define RISCV_ISA_EXT_ZTSO 72
 #define RISCV_ISA_EXT_ZACAS73
 #define RISCV_ISA_EXT_ZIMOP74
+#define RISCV_ISA_EXT_ZCA  75
+#define RISCV_ISA_EXT_ZCB  76
+#define RISCV_ISA_EXT_ZCD  77
+#define RISCV_ISA_EXT_ZCF  78
 
 #define RISCV_ISA_EXT_XLINUXENVCFG 127
 
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index fa4ad73b770a..3bb2ef52a38b 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -103,6 +103,29 @@ static int riscv_ext_zicboz_validate(const struct 
riscv_isa_ext_data *data,
return 0;
 }
 
+static int riscv_ext_zca_depends(const struct riscv_isa_ext_data *data,
+const unsigned long *isa_bitmap)
+{
+   return __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_ZCA) ? 
0 : -EPROBE_DEFER;
+}
+static int riscv_ext_zcd_validate(const struct riscv_isa_ext_data *data,
+ const unsigned long *isa_bitmap)
+{
+   return __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_ZCA) &&
+  __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_d) ? 0 
: -EPROBE_DEFER;
+}
+
+static int riscv_ext_zcf_validate(const struct riscv_isa_ext_data *data,
+ const unsigned long *isa_bitmap)
+{
+#ifdef CONFIG_64BIT
+   return -EINVAL;
+#else
+   return __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_ZCA) &&
+  __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_f) ? 0 
: -EPROBE_DEFER;
+#endif
+}
+
 static const unsigned int riscv_zk_bundled_exts[] = {
RISCV_ISA_EXT_ZBKB,
RISCV_ISA_EXT_ZBKC,
@@ -183,6 +206,21 @@ static const unsigned int riscv_xlinuxenvcfg_exts[] = {
RISCV_ISA_EXT_XLINUXENVCFG
 };
 
+/*
+ * Zc* spec states that:
+ * - C always implies Zca
+ * - C+F implies Zcf (RV32 only)
+ * - C+D implies Zcd
+ *
+ * These extensions will be enabled and then validated depending on the
+ * availability of F/D RV32.
+ */
+static const unsigned int riscv_c_exts[] = {
+   RISCV_ISA_EXT_ZCA,
+   RISCV_ISA_EXT_ZCF,
+   RISCV_ISA_EXT_ZCD,
+};
+
 /*
  * The canonical order of ISA extension names in the ISA string is defined in
  * chapter 27 of the unprivileged specification.
@@ -229,7 +267,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_DATA(f, RISCV_ISA_EXT_f),
__RISCV_ISA_EXT_DATA(d, RISCV_ISA_EXT_d),
__RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q),
-   __RISCV_ISA_EXT_DATA(c, RISCV_ISA_EXT_c),
+   __RISCV_ISA_EXT_SUPERSET(c, RISCV_ISA_EXT_c, riscv_c_exts),
__RISCV_ISA_EXT_DATA(v, RISCV_ISA_EXT_v),
__RISCV_ISA_EXT_DATA(h, RISCV_ISA_EXT_h),
__RISCV_ISA_EXT_SUPERSET_VALIDATE(zicbom, RISCV_ISA_EXT_ZICBOM, 
riscv_xlinuxenvcfg_exts,
@@ -248,6 +286,10 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_DATA(zfa, RISCV_ISA_EXT_ZFA),
__RISCV_ISA_EXT_DATA(zfh, RISCV_ISA_EXT_ZFH),
__RISCV_ISA_EXT_DATA(zfhmin, RISCV_ISA_EXT_ZFHMIN),
+   __RISCV_ISA_EXT_DATA(zca, RISCV_ISA_EXT_ZCA),
+   __RISCV_ISA_EXT_DATA_VALIDATE(zcb, RISCV_ISA_EXT_ZCB, 
riscv_ext_zca_depends),
+   __RISCV_ISA_EXT_DATA_VALIDATE(zcd, RISCV_ISA_EXT_ZCD, 
riscv_ext_zcd_validate),
+   __RISCV_ISA_EXT_DATA_VALIDATE(zcf, RISCV_ISA_EXT_ZCF, 
riscv_ext_zcf_validate),
__RISCV_ISA_EXT_DATA(zba, RISCV_ISA_EXT_ZBA),
__RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB),
__RISCV_ISA_EXT_DATA(zbc, 

[PATCH v5 07/16] riscv: add ISA extensions validation callback

2024-05-17 Thread Clément Léger
Since a few extensions (Zicbom/Zicboz) already needs validation and
future ones will need it as well (Zc*) add a validate() callback to
struct riscv_isa_ext_data. This require to rework the way extensions are
parsed and split it in two phases. First phase is isa string or isa
extension list parsing and consists in enabling all the extensions in a
temporary bitmask (source isa) without any validation. The second step
"resolves" the final isa bitmap, handling potential missing dependencies.
The mechanism is quite simple and simply validate each extension
described in the source bitmap before enabling it in the resolved isa
bitmap. validate() callbacks can return either 0 for success,
-EPROBEDEFER if extension needs to be validated again at next loop. A
previous ISA bitmap is kept to avoid looping multiple times if an
extension dependencies are never satisfied until we reach a stable
state. In order to avoid any potential infinite looping, allow looping
a maximum of the number of extension we handle. Zicboz and Zicbom
extensions are modified to use this validation mechanism.

Signed-off-by: Clément Léger 
---
 arch/riscv/include/asm/cpufeature.h |  23 ++--
 arch/riscv/kernel/cpufeature.c  | 198 +---
 2 files changed, 135 insertions(+), 86 deletions(-)

diff --git a/arch/riscv/include/asm/cpufeature.h 
b/arch/riscv/include/asm/cpufeature.h
index 88723ac2d26e..1a148cd67e0e 100644
--- a/arch/riscv/include/asm/cpufeature.h
+++ b/arch/riscv/include/asm/cpufeature.h
@@ -35,23 +35,27 @@ extern u32 riscv_vlenb_of;
 
 void riscv_user_isa_enable(void);
 
-#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size) { 
\
-   .name = #_name, 
\
-   .property = #_name, 
\
-   .id = _id,  
\
-   .subset_ext_ids = _subset_exts, 
\
-   .subset_ext_size = _subset_exts_size
\
+#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, 
_validate) {  \
+   .name = #_name, 
\
+   .property = #_name, 
\
+   .id = _id,  
\
+   .subset_ext_ids = _subset_exts, 
\
+   .subset_ext_size = _subset_exts_size,   
\
+   .validate = _validate   
\
 }
 
-#define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 
0)
+#define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 
0, NULL)
 
 /* Used to declare pure "lasso" extension (Zk for instance) */
 #define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \
-   _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, 
ARRAY_SIZE(_bundled_exts))
+   _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, \
+   ARRAY_SIZE(_bundled_exts), NULL)
 
 /* Used to declare extensions that are a superset of other extensions (Zvbb 
for instance) */
 #define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \
-   _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts))
+   _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), NULL)
+#define __RISCV_ISA_EXT_SUPERSET_VALIDATE(_name, _id, _sub_exts, _validate) \
+   _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), 
_validate)
 
 #if defined(CONFIG_RISCV_MISALIGNED)
 bool check_unaligned_access_emulated_all_cpus(void);
@@ -90,6 +94,7 @@ struct riscv_isa_ext_data {
const char *property;
const unsigned int *subset_ext_ids;
const unsigned int subset_ext_size;
+   int (*validate)(const struct riscv_isa_ext_data *data, const unsigned 
long *isa_bitmap);
 };
 
 extern const struct riscv_isa_ext_data riscv_isa_ext[];
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 41f8ae22e7a0..fa4ad73b770a 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -75,32 +75,32 @@ bool __riscv_isa_extension_available(const unsigned long 
*isa_bitmap, unsigned i
 }
 EXPORT_SYMBOL_GPL(__riscv_isa_extension_available);
 
-static bool riscv_isa_extension_check(int id)
+static int riscv_ext_zicbom_validate(const struct riscv_isa_ext_data *data,
+const unsigned long *isa_bitmap)
 {
-   switch (id) {
-   case RISCV_ISA_EXT_ZICBOM:
-   if (!riscv_cbom_block_size) {
-   pr_err("Zicbom detected in ISA string, disabling as no 
cbom-block-size found\n");
-   return false;
-   } else if 

[PATCH v5 06/16] dt-bindings: riscv: add Zca, Zcf, Zcd and Zcb ISA extension description

2024-05-17 Thread Clément Léger
Add description for Zca, Zcf, Zcd and Zcb extensions which are part the
Zc* standard extensions for code size reduction. Additional validation
rules are added since Zcb depends on Zca, Zcf, depends on Zca and F, Zcd
depends on Zca and D and finally, Zcf can not be present on rv64.

Signed-off-by: Clément Léger 
Reviewed-by: Conor Dooley 
---
 .../devicetree/bindings/riscv/extensions.yaml | 78 +++
 1 file changed, 78 insertions(+)

diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml 
b/Documentation/devicetree/bindings/riscv/extensions.yaml
index b9100addeb90..39084c58d4e4 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -220,6 +220,38 @@ properties:
 instructions as ratified at commit 6d33919 ("Merge pull request 
#158
 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
 
+- const: zca
+  description: |
+The Zca extension part of Zc* standard extensions for code size
+reduction, as ratified in commit 8be3419c1c0 ("Zcf doesn't exist on
+RV64 as it contains no instructions") of riscv-code-size-reduction,
+merged in the riscv-isa-manual by commit dbc79cf28a2 ("Initial seed
+of zc.adoc to src tree.").
+
+- const: zcb
+  description: |
+The Zcb extension part of Zc* standard extensions for code size
+reduction, as ratified in commit 8be3419c1c0 ("Zcf doesn't exist on
+RV64 as it contains no instructions") of riscv-code-size-reduction,
+merged in the riscv-isa-manual by commit dbc79cf28a2 ("Initial seed
+of zc.adoc to src tree.").
+
+- const: zcd
+  description: |
+The Zcd extension part of Zc* standard extensions for code size
+reduction, as ratified in commit 8be3419c1c0 ("Zcf doesn't exist on
+RV64 as it contains no instructions") of riscv-code-size-reduction,
+merged in the riscv-isa-manual by commit dbc79cf28a2 ("Initial seed
+of zc.adoc to src tree.").
+
+- const: zcf
+  description: |
+The Zcf extension part of Zc* standard extensions for code size
+reduction, as ratified in commit 8be3419c1c0 ("Zcf doesn't exist on
+RV64 as it contains no instructions") of riscv-code-size-reduction,
+merged in the riscv-isa-manual by commit dbc79cf28a2 ("Initial seed
+of zc.adoc to src tree.").
+
 - const: zfa
   description:
 The standard Zfa extension for additional floating point
@@ -499,5 +531,51 @@ properties:
 The T-HEAD specific 0.7.1 vector implementation as written in
 
https://github.com/T-head-Semi/thead-extension-spec/blob/95358cb2cca9489361c61d335e03d3134b14133f/xtheadvector.adoc.
 
+allOf:
+  # Zcb depends on Zca
+  - if:
+  contains:
+const: zcb
+then:
+  contains:
+const: zca
+  # Zcd depends on Zca and D
+  - if:
+  contains:
+const: zcd
+then:
+  allOf:
+- contains:
+const: zca
+- contains:
+const: d
+  # Zcf depends on Zca and F
+  - if:
+  contains:
+const: zcf
+then:
+  allOf:
+- contains:
+const: zca
+- contains:
+const: f
+
+allOf:
+  # Zcf extension does not exist on rv64
+  - if:
+  properties:
+riscv,isa-extensions:
+  contains:
+const: zcf
+riscv,isa-base:
+  contains:
+const: rv64i
+then:
+  properties:
+riscv,isa-extensions:
+  not:
+contains:
+  const: zcf
+
 additionalProperties: true
 ...
-- 
2.43.0




[PATCH v5 05/16] KVM: riscv: selftests: Add Zimop extension to get-reg-list test

2024-05-17 Thread Clément Léger
The KVM RISC-V allows Zimop extension for Guest/VM so add this
extension to get-reg-list test.

Signed-off-by: Clément Léger 
---
 tools/testing/selftests/kvm/riscv/get-reg-list.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c 
b/tools/testing/selftests/kvm/riscv/get-reg-list.c
index b882b7b9b785..40107bb61975 100644
--- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
+++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
@@ -67,6 +67,7 @@ bool filter_reg(__u64 reg)
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZIHINTNTL:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZIHPM:
+   case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZIMOP:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZKND:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZKNE:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | 
KVM_RISCV_ISA_EXT_ZKNH:
@@ -432,6 +433,7 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
KVM_ISA_EXT_ARR(ZIHINTNTL),
KVM_ISA_EXT_ARR(ZIHINTPAUSE),
KVM_ISA_EXT_ARR(ZIHPM),
+   KVM_ISA_EXT_ARR(ZIMOP),
KVM_ISA_EXT_ARR(ZKND),
KVM_ISA_EXT_ARR(ZKNE),
KVM_ISA_EXT_ARR(ZKNH),
@@ -955,6 +957,7 @@ KVM_ISA_EXT_SIMPLE_CONFIG(zifencei, ZIFENCEI);
 KVM_ISA_EXT_SIMPLE_CONFIG(zihintntl, ZIHINTNTL);
 KVM_ISA_EXT_SIMPLE_CONFIG(zihintpause, ZIHINTPAUSE);
 KVM_ISA_EXT_SIMPLE_CONFIG(zihpm, ZIHPM);
+KVM_ISA_EXT_SIMPLE_CONFIG(zimop, ZIMOP);
 KVM_ISA_EXT_SIMPLE_CONFIG(zknd, ZKND);
 KVM_ISA_EXT_SIMPLE_CONFIG(zkne, ZKNE);
 KVM_ISA_EXT_SIMPLE_CONFIG(zknh, ZKNH);
@@ -1010,6 +1013,7 @@ struct vcpu_reg_list *vcpu_configs[] = {
_zihintntl,
_zihintpause,
_zihpm,
+   _zimop,
_zknd,
_zkne,
_zknh,
-- 
2.43.0




[PATCH v5 03/16] riscv: hwprobe: export Zimop ISA extension

2024-05-17 Thread Clément Léger
Export Zimop ISA extension through hwprobe.

Signed-off-by: Clément Léger 
---
 Documentation/arch/riscv/hwprobe.rst  | 4 
 arch/riscv/include/uapi/asm/hwprobe.h | 1 +
 arch/riscv/kernel/sys_hwprobe.c   | 1 +
 3 files changed, 6 insertions(+)

diff --git a/Documentation/arch/riscv/hwprobe.rst 
b/Documentation/arch/riscv/hwprobe.rst
index 204cd4433af5..48be38e0b788 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -192,6 +192,10 @@ The following keys are defined:
supported as defined in the RISC-V ISA manual starting from commit
d8ab5c78c207 ("Zihintpause is ratified").
 
+  * :c:macro:`RISCV_HWPROBE_EXT_ZIMOP`: The Zimop May-Be-Operations extension 
is
+   supported as defined in the RISC-V ISA manual starting from commit
+   58220614a5f ("Zimop is ratified/1.0").
+
 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
   information about the selected set of processors.
 
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h 
b/arch/riscv/include/uapi/asm/hwprobe.h
index 31c570cbd1c5..3b16a12204b1 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -60,6 +60,7 @@ struct riscv_hwprobe {
 #defineRISCV_HWPROBE_EXT_ZACAS (1ULL << 34)
 #defineRISCV_HWPROBE_EXT_ZICOND(1ULL << 35)
 #defineRISCV_HWPROBE_EXT_ZIHINTPAUSE   (1ULL << 36)
+#defineRISCV_HWPROBE_EXT_ZIMOP (1ULL << 37)
 #define RISCV_HWPROBE_KEY_CPUPERF_05
 #defineRISCV_HWPROBE_MISALIGNED_UNKNOWN(0 << 0)
 #defineRISCV_HWPROBE_MISALIGNED_EMULATED   (1 << 0)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 969ef3d59dbe..fc6f4238f0b3 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -112,6 +112,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
EXT_KEY(ZACAS);
EXT_KEY(ZICOND);
EXT_KEY(ZIHINTPAUSE);
+   EXT_KEY(ZIMOP);
 
if (has_vector()) {
EXT_KEY(ZVBB);
-- 
2.43.0




[PATCH v5 04/16] RISC-V: KVM: Allow Zimop extension for Guest/VM

2024-05-17 Thread Clément Léger
Extend the KVM ISA extension ONE_REG interface to allow KVM user space
to detect and enable Zimop extension for Guest/VM.

Signed-off-by: Clément Léger 
---
 arch/riscv/include/uapi/asm/kvm.h | 1 +
 arch/riscv/kvm/vcpu_onereg.c  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/riscv/include/uapi/asm/kvm.h 
b/arch/riscv/include/uapi/asm/kvm.h
index b1c503c2959c..35a12aa1953e 100644
--- a/arch/riscv/include/uapi/asm/kvm.h
+++ b/arch/riscv/include/uapi/asm/kvm.h
@@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID {
KVM_RISCV_ISA_EXT_ZFA,
KVM_RISCV_ISA_EXT_ZTSO,
KVM_RISCV_ISA_EXT_ZACAS,
+   KVM_RISCV_ISA_EXT_ZIMOP,
KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c
index f4a6124d25c9..c6ee763422f2 100644
--- a/arch/riscv/kvm/vcpu_onereg.c
+++ b/arch/riscv/kvm/vcpu_onereg.c
@@ -60,6 +60,7 @@ static const unsigned long kvm_isa_ext_arr[] = {
KVM_ISA_EXT_ARR(ZIHINTNTL),
KVM_ISA_EXT_ARR(ZIHINTPAUSE),
KVM_ISA_EXT_ARR(ZIHPM),
+   KVM_ISA_EXT_ARR(ZIMOP),
KVM_ISA_EXT_ARR(ZKND),
KVM_ISA_EXT_ARR(ZKNE),
KVM_ISA_EXT_ARR(ZKNH),
@@ -137,6 +138,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned 
long ext)
case KVM_RISCV_ISA_EXT_ZIHINTNTL:
case KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
case KVM_RISCV_ISA_EXT_ZIHPM:
+   case KVM_RISCV_ISA_EXT_ZIMOP:
case KVM_RISCV_ISA_EXT_ZKND:
case KVM_RISCV_ISA_EXT_ZKNE:
case KVM_RISCV_ISA_EXT_ZKNH:
-- 
2.43.0




[PATCH v5 02/16] riscv: add ISA extension parsing for Zimop

2024-05-17 Thread Clément Léger
Add parsing for Zimop ISA extension which was ratified in commit
58220614a5f of the riscv-isa-manual.

Signed-off-by: Clément Léger 
---
 arch/riscv/include/asm/hwcap.h | 1 +
 arch/riscv/kernel/cpufeature.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
index 1f2d2599c655..b1896dade74c 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -80,6 +80,7 @@
 #define RISCV_ISA_EXT_ZFA  71
 #define RISCV_ISA_EXT_ZTSO 72
 #define RISCV_ISA_EXT_ZACAS73
+#define RISCV_ISA_EXT_ZIMOP74
 
 #define RISCV_ISA_EXT_XLINUXENVCFG 127
 
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 2993318b8ea2..41f8ae22e7a0 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -241,6 +241,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_DATA(zihintntl, RISCV_ISA_EXT_ZIHINTNTL),
__RISCV_ISA_EXT_DATA(zihintpause, RISCV_ISA_EXT_ZIHINTPAUSE),
__RISCV_ISA_EXT_DATA(zihpm, RISCV_ISA_EXT_ZIHPM),
+   __RISCV_ISA_EXT_DATA(zimop, RISCV_ISA_EXT_ZIMOP),
__RISCV_ISA_EXT_DATA(zacas, RISCV_ISA_EXT_ZACAS),
__RISCV_ISA_EXT_DATA(zfa, RISCV_ISA_EXT_ZFA),
__RISCV_ISA_EXT_DATA(zfh, RISCV_ISA_EXT_ZFH),
-- 
2.43.0




[PATCH v5 01/16] dt-bindings: riscv: add Zimop ISA extension description

2024-05-17 Thread Clément Léger
Add description for the Zimop (May-Be-Operations) ISA extension which
was ratified in commit 58220614a5f of the riscv-isa-manual.

Signed-off-by: Clément Léger 
---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml 
b/Documentation/devicetree/bindings/riscv/extensions.yaml
index 99d2a9e8c52d..b9100addeb90 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -363,6 +363,11 @@ properties:
 ratified in the 20191213 version of the unprivileged ISA
 specification.
 
+- const: zimop
+  description:
+The standard Zimop extension version 1.0, as ratified in commit
+58220614a5f ("Zimop is ratified/1.0") of the riscv-isa-manual.
+
 - const: ztso
   description:
 The standard Ztso extension for total store ordering, as ratified
-- 
2.43.0




[PATCH v5 00/16] Add support for a few Zc* extensions, Zcmop and Zimop

2024-05-17 Thread Clément Léger
Add support for (yet again) more RVA23U64 missing extensions. Add
support for Zimop, Zcmop, Zca, Zcf, Zcd and Zcb extensions ISA string
parsing, hwprobe and kvm support. Zce, Zcmt and Zcmp extensions have
been left out since they target microcontrollers/embedded CPUs and are
not needed by RVA23U64.

Since Zc* extensions states that C implies Zca, Zcf (if F and RV32), Zcd
(if D), this series modifies the way ISA string is parsed and now does
it in two phases. First one parses the string and the second one
validates it for the final ISA description.

Link: 
https://lore.kernel.org/linux-riscv/20240404103254.1752834-1-cle...@rivosinc.com/
 [1]
Link: https://lore.kernel.org/all/20240409143839.558784-1-cle...@rivosinc.com/ 
[2]

---

v5:
 - Merged in Zimop to avoid any uneeded series dependencies
 - Rework dependency resolution loop to loop on source isa first rather
   than on all extensions.
 - Disabled extensions in source isa once set in resolved isa
 - Rename riscv_resolve_isa() parameters

v4:
 - Modify validate() callbacks to return 0, -EPROBEDEFER or another
   error.
 - v3: https://lore.kernel.org/all/20240423124326.2532796-1-cle...@rivosinc.com/

v3:
 - Fix typo "exists" -> "exist"
 - Remove C implies Zca, Zcd, Zcf, dt-bindings rules
 - Rework ISA string resolver to handle dependencies
 - v2: https://lore.kernel.org/all/20240418124300.1387978-1-cle...@rivosinc.com/

v2:
 - Add Zc* dependencies validation in dt-bindings
 - v1: https://lore.kernel.org/lkml/20240410091106.749233-1-cle...@rivosinc.com/

Clément Léger (16):
  dt-bindings: riscv: add Zimop ISA extension description
  riscv: add ISA extension parsing for Zimop
  riscv: hwprobe: export Zimop ISA extension
  RISC-V: KVM: Allow Zimop extension for Guest/VM
  KVM: riscv: selftests: Add Zimop extension to get-reg-list test
  dt-bindings: riscv: add Zca, Zcf, Zcd and Zcb ISA extension
description
  riscv: add ISA extensions validation callback
  riscv: add ISA parsing for Zca, Zcf, Zcd and Zcb
  riscv: hwprobe: export Zca, Zcf, Zcd and Zcb ISA extensions
  RISC-V: KVM: Allow Zca, Zcf, Zcd and Zcb extensions for Guest/VM
  KVM: riscv: selftests: Add some Zc* extensions to get-reg-list test
  dt-bindings: riscv: add Zcmop ISA extension description
  riscv: add ISA extension parsing for Zcmop
  riscv: hwprobe: export Zcmop ISA extension
  RISC-V: KVM: Allow Zcmop extension for Guest/VM
  KVM: riscv: selftests: Add Zcmop extension to get-reg-list test

 Documentation/arch/riscv/hwprobe.rst  |  28 ++
 .../devicetree/bindings/riscv/extensions.yaml |  95 +++
 arch/riscv/include/asm/cpufeature.h   |  26 +-
 arch/riscv/include/asm/hwcap.h|   6 +
 arch/riscv/include/uapi/asm/hwprobe.h |   6 +
 arch/riscv/include/uapi/asm/kvm.h |   6 +
 arch/riscv/kernel/cpufeature.c| 244 --
 arch/riscv/kernel/sys_hwprobe.c   |   6 +
 arch/riscv/kvm/vcpu_onereg.c  |  12 +
 .../selftests/kvm/riscv/get-reg-list.c|  24 ++
 10 files changed, 366 insertions(+), 87 deletions(-)

-- 
2.43.0




Re: [PATCH v4 65/66] selftests/wireguard: Drop define _GNU_SOURCE

2024-05-17 Thread Jason A. Donenfeld
On Fri, May 10, 2024 at 12:07:22AM +, Edward Liaw wrote:
> _GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
> redefinition warnings.
> 
> Signed-off-by: Edward Liaw 
> ---
>  tools/testing/selftests/wireguard/qemu/init.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/wireguard/qemu/init.c 
> b/tools/testing/selftests/wireguard/qemu/init.c
> index 3e49924dd77e..08113f3c6189 100644
> --- a/tools/testing/selftests/wireguard/qemu/init.c
> +++ b/tools/testing/selftests/wireguard/qemu/init.c
> @@ -2,8 +2,6 @@
>  /*
>   * Copyright (C) 2015-2019 Jason A. Donenfeld . All Rights 
> Reserved.
>   */
> -
> -#define _GNU_SOURCE
>  #include 
>  #include 
>  #include 
> -- 

But this file doesn't use lib.mk.



Re: [PATCH net v3] selftests: net: local_termination: annotate the expected failures

2024-05-17 Thread Petr Machata


Hangbin Liu  writes:

> On Thu, May 16, 2024 at 08:25:13AM -0700, Jakub Kicinski wrote:
>> Vladimir said when adding this test:
>> 
>>   The bridge driver fares particularly badly [...] mainly because
>>   it does not implement IFF_UNICAST_FLT.
>> 
>> See commit 90b9566aa5cd ("selftests: forwarding: add a test for
>> local_termination.sh").
>> 
>> We don't want to hide the known gaps, but having a test which
>> always fails prevents us from catching regressions. Report
>> the cases we know may fail as XFAIL.
>> 
>> Signed-off-by: Jakub Kicinski 

I'm still confused that the failure was shown for $rcv_if_name==bridge,
yet we are testing $h1==veth. But mechanically the code is correct.

Reviewed-by: Petr Machata 



[PATCH 2/2] selftests: harness: rename __constructor_order for clarification

2024-05-17 Thread Masahiro Yamada
Now, __constructor_order is boolean; 1 for forward-order systems,
0 for reverse-order systems while parsing __LIST_APPEND().

Change it into a bool variable, and rename it for clarification.

Signed-off-by: Masahiro Yamada 
---

 tools/testing/selftests/kselftest_harness.h | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/kselftest_harness.h 
b/tools/testing/selftests/kselftest_harness.h
index 60c1cf5b0f0d..55f96037582b 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -774,7 +774,7 @@
item->prev = item; \
return; \
} \
-   if (__constructor_order == _CONSTRUCTOR_ORDER_FORWARD) { \
+   if (__constructor_order_forward) { \
item->next = NULL; \
item->prev = head->prev; \
item->prev->next = item; \
@@ -837,9 +837,7 @@ struct __test_xfail {
}
 
 static struct __fixture_metadata *__fixture_list = &_fixture_global;
-static int __constructor_order;
-
-#define _CONSTRUCTOR_ORDER_FORWARD   1
+static bool __constructor_order_forward;
 
 static inline void __register_fixture(struct __fixture_metadata *f)
 {
@@ -891,7 +889,7 @@ static inline bool __test_passed(struct __test_metadata 
*metadata)
  * list so tests are run in source declaration order.
  * https://gcc.gnu.org/onlinedocs/gccint/Initialization.html
  * However, it seems not all toolchains do this correctly, so use
- * __constructor_order to detect which direction is called first
+ * __constructor_order_foward to detect which direction is called first
  * and adjust list building logic to get things running in the right
  * direction.
  */
@@ -1265,7 +1263,7 @@ static int test_harness_run(int argc, char **argv)
 
 static void __attribute__((constructor)) __constructor_order_first(void)
 {
-   __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
+   __constructor_order_forward = true;
 }
 
 #endif  /* __KSELFTEST_HARNESS_H */
-- 
2.40.1




[PATCH 1/2] selftests: harness: remove unneeded __constructor_order_last()

2024-05-17 Thread Masahiro Yamada
__constructor_order_last() is unneeded.

If __constructor_order_last() is not called on reverse-order systems,
__constructor_order will remain 0 instead of being set to
_CONSTRUCTOR_ORDER_BACKWARD (= -1).

__LIST_APPEND() will still take the 'else' branch, so there is no
difference in the behavior.

Signed-off-by: Masahiro Yamada 
---

 .../selftests/drivers/s390x/uvdevice/test_uvdevice.c   |  6 --
 tools/testing/selftests/hid/hid_bpf.c  |  6 --
 tools/testing/selftests/kselftest_harness.h| 10 +-
 tools/testing/selftests/rtc/rtctest.c  |  7 ---
 4 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c 
b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
index ea0cdc37b44f..7ee7492138c6 100644
--- a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
+++ b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
@@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr)
att_inval_addr_test(>uvio_attest.meas_addr, _metadata, self);
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
int fd = open(UV_PATH, O_ACCMODE);
diff --git a/tools/testing/selftests/hid/hid_bpf.c 
b/tools/testing/selftests/hid/hid_bpf.c
index 2cf96f818f25..f47feef2aced 100644
--- a/tools/testing/selftests/hid/hid_bpf.c
+++ b/tools/testing/selftests/hid/hid_bpf.c
@@ -853,12 +853,6 @@ static int libbpf_print_fn(enum libbpf_print_level level,
return 0;
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
/* Use libbpf 1.0 API mode */
diff --git a/tools/testing/selftests/kselftest_harness.h 
b/tools/testing/selftests/kselftest_harness.h
index ba3ddeda24bf..60c1cf5b0f0d 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -444,12 +444,6 @@
  * Use once to append a main() to the test file.
  */
 #define TEST_HARNESS_MAIN \
-   static void __attribute__((constructor)) \
-   __constructor_order_last(void) \
-   { \
-   if (!__constructor_order) \
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
-   } \
int main(int argc, char **argv) { \
return test_harness_run(argc, argv); \
}
@@ -846,7 +840,6 @@ static struct __fixture_metadata *__fixture_list = 
&_fixture_global;
 static int __constructor_order;
 
 #define _CONSTRUCTOR_ORDER_FORWARD   1
-#define _CONSTRUCTOR_ORDER_BACKWARD -1
 
 static inline void __register_fixture(struct __fixture_metadata *f)
 {
@@ -1272,8 +1265,7 @@ static int test_harness_run(int argc, char **argv)
 
 static void __attribute__((constructor)) __constructor_order_first(void)
 {
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
+   __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
 }
 
 #endif  /* __KSELFTEST_HARNESS_H */
diff --git a/tools/testing/selftests/rtc/rtctest.c 
b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..9647b14b47c5 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -410,13 +410,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
ASSERT_EQ(new, secs);
 }
 
-static void __attribute__((constructor))
-__constructor_order_last(void)
-{
-   if (!__constructor_order)
-   __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
switch (argc) {
-- 
2.40.1




[PATCH 0/2] selftests: harness: refactor __constructor_order

2024-05-17 Thread Masahiro Yamada


This series refactors __constructor_order because
__constructor_order_last() is unneeded.

BTW, the comments in kselftest_harness.h was confusing to me.

As far as I tested, all arches executed constructors in the forward
order.

[test code]

  #include 

  static int x;

  static void __attribute__((constructor)) increment(void)
  {
   x += 1;
  }

  static void __attribute__((constructor)) multiply(void)
  {
  x *= 2;
  }

  int main(void)
  {
  printf("foo = %d\n", x);
  return 0;
  }

It should print 2 for forward order systems, 1 for reverse order systems.

I executed it on some archtes by using QEMU. I always got 2.



Masahiro Yamada (2):
  selftests: harness: remove unneeded __constructor_order_last()
  selftests: harness: rename __constructor_order for clarification

 .../drivers/s390x/uvdevice/test_uvdevice.c |  6 --
 tools/testing/selftests/hid/hid_bpf.c  |  6 --
 tools/testing/selftests/kselftest_harness.h| 18 --
 tools/testing/selftests/rtc/rtctest.c  |  7 ---
 4 files changed, 4 insertions(+), 33 deletions(-)

-- 
2.40.1




Re: [PATCHv2 net] selftests/net: use tc rule to filter the na packet

2024-05-17 Thread Simon Horman
On Fri, May 17, 2024 at 09:03:27AM +0800, Hangbin Liu wrote:
> Test arp_ndisc_untracked_subnets use tcpdump to filter the unsolicited
> and untracked na messages. It set -e before calling tcpdump. But if
> tcpdump filters 0 packet, it will return none zero, and cause the script
> to exit.
> 
> Instead of using slow tcpdump to capture packets, let's using tc rule
> to filter out the na message.
> 
> At the same time, fix function setup_v6 which only needs one parameter.
> Move all the related helpers from forwarding lib.sh to net lib.sh.
> 
> Fixes: 0ea7b0a454ca ("selftests: net: arp_ndisc_untracked_subnets: test for 
> arp_accept and accept_untracked_na")
> Signed-off-by: Hangbin Liu 

I see that, as of writing, the last two runs of this test have succeeded.
Which doesn't seem to have occurred since 9th May. So this does seem
positive, albeit perhaps a bit too soon to call.

Jakub, is there a way to tell how long a test took to execute?
Perhaps it's obvious, but I couldn't see it.

Code changes look good to me.

Reviewed-by: Simon Horman 



Re: [PATCH net v3] selftests: net: local_termination: annotate the expected failures

2024-05-17 Thread Hangbin Liu
On Thu, May 16, 2024 at 08:25:13AM -0700, Jakub Kicinski wrote:
> Vladimir said when adding this test:
> 
>   The bridge driver fares particularly badly [...] mainly because
>   it does not implement IFF_UNICAST_FLT.
> 
> See commit 90b9566aa5cd ("selftests: forwarding: add a test for
> local_termination.sh").
> 
> We don't want to hide the known gaps, but having a test which
> always fails prevents us from catching regressions. Report
> the cases we know may fail as XFAIL.
> 
> Signed-off-by: Jakub Kicinski 
> ---
> CC: liuhang...@gmail.com
> CC: sh...@kernel.org
> CC: linux-kselftest@vger.kernel.org
> CC: Petr Machata 
> CC: vladimir.olt...@nxp.com
> 
> v3:
>  - use xfail_on_veth correctly as a "prefix" call
>  - dropping Vladimir's tags since the code is quite different now
> v2: https://lore.kernel.org/r/20240509235553.5740-1-k...@kernel.org/
>  - remove duplicated log_test_xfail
> v1: https://lore.kernel.org/all/20240509235553.5740-1-k...@kernel.org/
> ---
>  .../net/forwarding/local_termination.sh   | 30 +++
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh 
> b/tools/testing/selftests/net/forwarding/local_termination.sh
> index c5b0cbc85b3e..4b364cdf3ef0 100755
> --- a/tools/testing/selftests/net/forwarding/local_termination.sh
> +++ b/tools/testing/selftests/net/forwarding/local_termination.sh
> @@ -155,25 +155,30 @@ run_test()
>   "$smac > $MACVLAN_ADDR, ethertype IPv4 (0x0800)" \
>   true
>  
> - check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \
> - "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \
> - false
> + xfail_on_veth $h1 \
> + check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \
> + "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \
> + false
>  
>   check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \
>   "$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \
>   true
>  
> - check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, allmulti" \
> - "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \
> - false
> + xfail_on_veth $h1 \
> + check_rcv $rcv_if_name \
> + "Unicast IPv4 to unknown MAC address, allmulti" \
> + "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \
> + false
>  
>   check_rcv $rcv_if_name "Multicast IPv4 to joined group" \
>   "$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \
>   true
>  
> - check_rcv $rcv_if_name "Multicast IPv4 to unknown group" \
> - "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \
> - false
> + xfail_on_veth $h1 \
> + check_rcv $rcv_if_name \
> + "Multicast IPv4 to unknown group" \
> + "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 
> (0x0800)" \
> + false
>  
>   check_rcv $rcv_if_name "Multicast IPv4 to unknown group, promisc" \
>   "$smac > $UNKNOWN_MACV4_MC_ADDR2, ethertype IPv4 (0x0800)" \
> @@ -187,9 +192,10 @@ run_test()
>   "$smac > $JOINED_MACV6_MC_ADDR, ethertype IPv6 (0x86dd)" \
>   true
>  
> - check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \
> - "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \
> - false
> + xfail_on_veth $h1 \
> + check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \
> + "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 
> (0x86dd)" \
> + false
>  
>   check_rcv $rcv_if_name "Multicast IPv6 to unknown group, promisc" \
>   "$smac > $UNKNOWN_MACV6_MC_ADDR2, ethertype IPv6 (0x86dd)" \
> -- 
> 2.45.0
> 

Reviewed-by: Hangbin Liu 



Re: [PATCH net v3] selftests: net: local_termination: annotate the expected failures

2024-05-17 Thread Simon Horman
On Thu, May 16, 2024 at 08:25:13AM -0700, Jakub Kicinski wrote:
> Vladimir said when adding this test:
> 
>   The bridge driver fares particularly badly [...] mainly because
>   it does not implement IFF_UNICAST_FLT.
> 
> See commit 90b9566aa5cd ("selftests: forwarding: add a test for
> local_termination.sh").
> 
> We don't want to hide the known gaps, but having a test which
> always fails prevents us from catching regressions. Report
> the cases we know may fail as XFAIL.
> 
> Signed-off-by: Jakub Kicinski 

I agree that XFAIL is appropriate for cases like this - the test
is expected to fail and this can act like a TODO.

I also looked over how xfail_on_veth works and this usage seems
correct to me.

Reviewed-by: Simon Horman 



Re: [PATCH] selftest: rtc: Add to check rtc alarm status for alarm related test

2024-05-17 Thread Joseph Jang




On 2024/5/17 4:08 PM, Alexandre Belloni wrote:

On 17/05/2024 15:53:58+0800, Joseph Jang wrote:



On 2024/5/17 3:19 PM, Alexandre Belloni wrote:

On 16/05/2024 19:28:47-0700, Joseph Jang wrote:

In alarm_wkalm_set and alarm_wkalm_set_minute test, they use different
ioctl (RTC_ALM_SET/RTC_WKALM_SET) for alarm feature detection. They will
skip testing if RTC_ALM_SET/RTC_WKALM_SET ioctl returns an EINVAL error
code. This design may miss detecting real problems when the
efi.set_wakeup_time() return errors and then RTC_ALM_SET/RTC_WKALM_SET
ioctl returns an EINVAL error code with RTC_FEATURE_ALARM enabled.

In order to make rtctest more explicit and robust, we propose to use
RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
running alarm related tests. If the kernel does not support RTC_PARAM_GET
ioctl interface, we will fallback to check the presence of "alarm" in
/proc/driver/rtc.

The rtctest requires the read permission on /dev/rtc0. The rtctest will
be skipped if the /dev/rtc0 is not readable.



This change as to be separated. Also, I'm not sure what happened with
https://lore.kernel.org/all/20230717175251.54390-1-atulpant.li...@gmail.com/



I apply above patch and seems like still cannot detect the read
permission on /dev/rtc0. I guess the 'F_OK' just check the `/dev/rtc0`
was there.

I share the error logs by following for your reference.

TAP version 13
1..1
# timeout set to 210
# selftests: rtc: rtctest
# TAP version 13
# 1..8
# # Starting 8 tests from 1 test cases.
# #  RUN   rtc.date_read ...
# # rtctest.c:53:date_read:Expected -1 (-1) != self->fd (-1)
# # date_read: Test terminated by assertion
# #  FAIL  rtc.date_read

Not sure if we could skip the testing by following change ?

FIXTURE_SETUP(rtc) {
+ if (access(rtc_file, R_OK) != 0)
+ SKIP(return, "Skipping test since cannot access %s, perhaps
miss sudo",
+  rtc_file)
+
   self->fd = open(rtc_file, O_RDONLY);
}

And I make sure we need root permission to access `/dev/rtc0`.



There is no need to test for every tests of the suite, the check could
be done once. To be clear, you don't need to be root to access the RTC,
you need CAP_SYS_TIME and CAP_SYS_RESOURCE.



Thank you so much ~ not sure if we could have the following change ?

Use `access(rtc_file, R_OK)` to check read permission on
`/dev/rtc0` in main(). And user could try to figure out why cannot
access rtc file by themselves.

@@ -430,5 +433,11 @@ int main(int argc, char **argv)
return 1;
}

+   // Run the test if rtc_file is valid
+   if (access(rtc_file, R_OK) == 0)
+   ret = test_harness_run(argc, argv);
+   else
+		ksft_exit_fail_msg("[ERROR]: Cannot access rtc file %s - Exiting\n", 
rtc_file);

+
+   return ret;





Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
as optional")

Reviewed-by: Jeremy Szu 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Joseph Jang 
---
   tools/testing/selftests/rtc/Makefile  |  2 +-
   tools/testing/selftests/rtc/rtctest.c | 72 +++
   2 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/rtc/Makefile 
b/tools/testing/selftests/rtc/Makefile
index 55198ecc04db..6e3a98fb24ba 100644
--- a/tools/testing/selftests/rtc/Makefile
+++ b/tools/testing/selftests/rtc/Makefile
@@ -1,5 +1,5 @@
   # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
   LDLIBS += -lrt -lpthread -lm
   TEST_GEN_PROGS = rtctest
diff --git a/tools/testing/selftests/rtc/rtctest.c 
b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..aa47b17fbd1a 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -8,6 +8,7 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -24,12 +25,17 @@
   #define READ_LOOP_SLEEP_MS 11
   static char *rtc_file = "/dev/rtc0";
+static char *rtc_procfs = "/proc/driver/rtc";
   FIXTURE(rtc) {
int fd;
   };
   FIXTURE_SETUP(rtc) {
+   if (access(rtc_file, R_OK) != 0)
+   SKIP(return, "Skipping test since cannot access %s, perhaps miss 
sudo",
+rtc_file);



+
self->fd = open(rtc_file, O_RDONLY);
   }
@@ -82,6 +88,36 @@ static void nanosleep_with_retries(long ns)
}
   }
+static bool is_rtc_alarm_supported(int fd)
+{
+   struct rtc_param param = { 0 };
+   int rc;
+   char buf[1024] = { 0 };
+
+   /* Validate kernel reflects unsupported RTC alarm state */
+   param.param = RTC_PARAM_FEATURES;
+   param.index = 0;
+   rc = ioctl(fd, RTC_PARAM_GET, );
+   if (rc < 0) {
+   /* Fallback to read rtc procfs */
+   fd = open(rtc_procfs, O_RDONLY);


I think I was clear on the previous thread, no new users of the procfs
interface. You can carry this n your own tree but that 

Re: [PATCH] kselftest/alsa: Ensure _GNU_SOURCE is defined

2024-05-17 Thread Takashi Iwai
On Thu, 16 May 2024 17:27:33 +0200,
Mark Brown wrote:
> 
> The pcmtest driver tests use the kselftest harness which requires that
> _GNU_SOURCE is defined but nothing causes it to be defined.  Since the
> KHDR_INCLUDES Makefile variable has had the required define added let's
> use that, this should provide some futureproofing.
> 
> Fixes: daef47b89efd ("selftests: Compile kselftest headers with 
> -D_GNU_SOURCE")
> Signed-off-by: Mark Brown 

The commit isn't yet in the Linus upstream tree but only in
linux-next.  I guess it's better to put the fix in the tree (Shuah's?)
that introduced this change.  So feel free to take my ack:

Acked-by: Takashi Iwai 


thanks,

Takashi

> ---
>  tools/testing/selftests/alsa/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/alsa/Makefile 
> b/tools/testing/selftests/alsa/Makefile
> index 5af9ba8a4645..c1ce39874e2b 100644
> --- a/tools/testing/selftests/alsa/Makefile
> +++ b/tools/testing/selftests/alsa/Makefile
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  #
>  
> -CFLAGS += $(shell pkg-config --cflags alsa)
> +CFLAGS += $(shell pkg-config --cflags alsa) $(KHDR_INCLUDES)
>  LDLIBS += $(shell pkg-config --libs alsa)
>  ifeq ($(LDLIBS),)
>  LDLIBS += -lasound
> 
> ---
> base-commit: 3c999d1ae3c75991902a1a7dad0cb62c2a3008b4
> change-id: 20240516-kselftest-fix-gnu-source-81ddd00870a8
> 
> Best regards,
> -- 
> Mark Brown 
> 



Re: [PATCH] selftest: rtc: Add to check rtc alarm status for alarm related test

2024-05-17 Thread Alexandre Belloni
On 17/05/2024 15:53:58+0800, Joseph Jang wrote:
> 
> 
> On 2024/5/17 3:19 PM, Alexandre Belloni wrote:
> > On 16/05/2024 19:28:47-0700, Joseph Jang wrote:
> > > In alarm_wkalm_set and alarm_wkalm_set_minute test, they use different
> > > ioctl (RTC_ALM_SET/RTC_WKALM_SET) for alarm feature detection. They will
> > > skip testing if RTC_ALM_SET/RTC_WKALM_SET ioctl returns an EINVAL error
> > > code. This design may miss detecting real problems when the
> > > efi.set_wakeup_time() return errors and then RTC_ALM_SET/RTC_WKALM_SET
> > > ioctl returns an EINVAL error code with RTC_FEATURE_ALARM enabled.
> > > 
> > > In order to make rtctest more explicit and robust, we propose to use
> > > RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
> > > running alarm related tests. If the kernel does not support RTC_PARAM_GET
> > > ioctl interface, we will fallback to check the presence of "alarm" in
> > > /proc/driver/rtc.
> > > 
> > > The rtctest requires the read permission on /dev/rtc0. The rtctest will
> > > be skipped if the /dev/rtc0 is not readable.
> > > 
> > 
> > This change as to be separated. Also, I'm not sure what happened with
> > https://lore.kernel.org/all/20230717175251.54390-1-atulpant.li...@gmail.com/
> > 
> 
> I apply above patch and seems like still cannot detect the read
> permission on /dev/rtc0. I guess the 'F_OK' just check the `/dev/rtc0`
> was there.
> 
> I share the error logs by following for your reference.
> 
> TAP version 13
> 1..1
> # timeout set to 210
> # selftests: rtc: rtctest
> # TAP version 13
> # 1..8
> # # Starting 8 tests from 1 test cases.
> # #  RUN   rtc.date_read ...
> # # rtctest.c:53:date_read:Expected -1 (-1) != self->fd (-1)
> # # date_read: Test terminated by assertion
> # #  FAIL  rtc.date_read
> 
> Not sure if we could skip the testing by following change ?
> 
> FIXTURE_SETUP(rtc) {
> + if (access(rtc_file, R_OK) != 0)
> + SKIP(return, "Skipping test since cannot access %s, perhaps
> miss sudo",
> +  rtc_file)
> +
>   self->fd = open(rtc_file, O_RDONLY);
> }
> 
> And I make sure we need root permission to access `/dev/rtc0`.
> 

There is no need to test for every tests of the suite, the check could
be done once. To be clear, you don't need to be root to access the RTC,
you need CAP_SYS_TIME and CAP_SYS_RESOURCE.

> 
> 
> > > Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
> > > as optional")
> > > 
> > > Reviewed-by: Jeremy Szu 
> > > Reviewed-by: Matthew R. Ochs 
> > > Signed-off-by: Joseph Jang 
> > > ---
> > >   tools/testing/selftests/rtc/Makefile  |  2 +-
> > >   tools/testing/selftests/rtc/rtctest.c | 72 +++
> > >   2 files changed, 53 insertions(+), 21 deletions(-)
> > > 
> > > diff --git a/tools/testing/selftests/rtc/Makefile 
> > > b/tools/testing/selftests/rtc/Makefile
> > > index 55198ecc04db..6e3a98fb24ba 100644
> > > --- a/tools/testing/selftests/rtc/Makefile
> > > +++ b/tools/testing/selftests/rtc/Makefile
> > > @@ -1,5 +1,5 @@
> > >   # SPDX-License-Identifier: GPL-2.0
> > > -CFLAGS += -O3 -Wl,-no-as-needed -Wall
> > > +CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
> > >   LDLIBS += -lrt -lpthread -lm
> > >   TEST_GEN_PROGS = rtctest
> > > diff --git a/tools/testing/selftests/rtc/rtctest.c 
> > > b/tools/testing/selftests/rtc/rtctest.c
> > > index 63ce02d1d5cc..aa47b17fbd1a 100644
> > > --- a/tools/testing/selftests/rtc/rtctest.c
> > > +++ b/tools/testing/selftests/rtc/rtctest.c
> > > @@ -8,6 +8,7 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > >   #include 
> > >   #include 
> > > @@ -24,12 +25,17 @@
> > >   #define READ_LOOP_SLEEP_MS 11
> > >   static char *rtc_file = "/dev/rtc0";
> > > +static char *rtc_procfs = "/proc/driver/rtc";
> > >   FIXTURE(rtc) {
> > >   int fd;
> > >   };
> > >   FIXTURE_SETUP(rtc) {
> > > + if (access(rtc_file, R_OK) != 0)
> > > + SKIP(return, "Skipping test since cannot access %s, perhaps 
> > > miss sudo",
> > > +  rtc_file);
> > 
> > > +
> > >   self->fd = open(rtc_file, O_RDONLY);
> > >   }
> > > @@ -82,6 +88,36 @@ static void nanosleep_with_retries(long ns)
> > >   }
> > >   }
> > > +static bool is_rtc_alarm_supported(int fd)
> > > +{
> > > + struct rtc_param param = { 0 };
> > > + int rc;
> > > + char buf[1024] = { 0 };
> > > +
> > > + /* Validate kernel reflects unsupported RTC alarm state */
> > > + param.param = RTC_PARAM_FEATURES;
> > > + param.index = 0;
> > > + rc = ioctl(fd, RTC_PARAM_GET, );
> > > + if (rc < 0) {
> > > + /* Fallback to read rtc procfs */
> > > + fd = open(rtc_procfs, O_RDONLY);
> > 
> > I think I was clear on the previous thread, no new users of the procfs
> > interface. You can carry this n your own tree but that can't be
> > upstream.
> > 
> 
> Okay ~ If we use RTC_PARAM_GET ioctl to detect rtc feature only, not
> sure if that is okay for 

Re: [PATCH] selftest: rtc: Add to check rtc alarm status for alarm related test

2024-05-17 Thread Joseph Jang




On 2024/5/17 3:19 PM, Alexandre Belloni wrote:

On 16/05/2024 19:28:47-0700, Joseph Jang wrote:

In alarm_wkalm_set and alarm_wkalm_set_minute test, they use different
ioctl (RTC_ALM_SET/RTC_WKALM_SET) for alarm feature detection. They will
skip testing if RTC_ALM_SET/RTC_WKALM_SET ioctl returns an EINVAL error
code. This design may miss detecting real problems when the
efi.set_wakeup_time() return errors and then RTC_ALM_SET/RTC_WKALM_SET
ioctl returns an EINVAL error code with RTC_FEATURE_ALARM enabled.

In order to make rtctest more explicit and robust, we propose to use
RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
running alarm related tests. If the kernel does not support RTC_PARAM_GET
ioctl interface, we will fallback to check the presence of "alarm" in
/proc/driver/rtc.

The rtctest requires the read permission on /dev/rtc0. The rtctest will
be skipped if the /dev/rtc0 is not readable.



This change as to be separated. Also, I'm not sure what happened with
https://lore.kernel.org/all/20230717175251.54390-1-atulpant.li...@gmail.com/



I apply above patch and seems like still cannot detect the read
permission on /dev/rtc0. I guess the 'F_OK' just check the `/dev/rtc0`
was there.

I share the error logs by following for your reference.

TAP version 13
1..1
# timeout set to 210
# selftests: rtc: rtctest
# TAP version 13
# 1..8
# # Starting 8 tests from 1 test cases.
# #  RUN   rtc.date_read ...
# # rtctest.c:53:date_read:Expected -1 (-1) != self->fd (-1)
# # date_read: Test terminated by assertion
# #  FAIL  rtc.date_read

Not sure if we could skip the testing by following change ?

FIXTURE_SETUP(rtc) {
+ if (access(rtc_file, R_OK) != 0)
+ SKIP(return, "Skipping test since cannot access %s, 
perhaps miss sudo",

+  rtc_file)
+
  self->fd = open(rtc_file, O_RDONLY);
}

And I make sure we need root permission to access `/dev/rtc0`.




Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
as optional")

Reviewed-by: Jeremy Szu 
Reviewed-by: Matthew R. Ochs 
Signed-off-by: Joseph Jang 
---
  tools/testing/selftests/rtc/Makefile  |  2 +-
  tools/testing/selftests/rtc/rtctest.c | 72 +++
  2 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/rtc/Makefile 
b/tools/testing/selftests/rtc/Makefile
index 55198ecc04db..6e3a98fb24ba 100644
--- a/tools/testing/selftests/rtc/Makefile
+++ b/tools/testing/selftests/rtc/Makefile
@@ -1,5 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
  LDLIBS += -lrt -lpthread -lm
  
  TEST_GEN_PROGS = rtctest

diff --git a/tools/testing/selftests/rtc/rtctest.c 
b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..aa47b17fbd1a 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -8,6 +8,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -24,12 +25,17 @@
  #define READ_LOOP_SLEEP_MS 11
  
  static char *rtc_file = "/dev/rtc0";

+static char *rtc_procfs = "/proc/driver/rtc";
  
  FIXTURE(rtc) {

int fd;
  };
  
  FIXTURE_SETUP(rtc) {

+   if (access(rtc_file, R_OK) != 0)
+   SKIP(return, "Skipping test since cannot access %s, perhaps miss 
sudo",
+rtc_file);



+
self->fd = open(rtc_file, O_RDONLY);
  }
  
@@ -82,6 +88,36 @@ static void nanosleep_with_retries(long ns)

}
  }
  
+static bool is_rtc_alarm_supported(int fd)

+{
+   struct rtc_param param = { 0 };
+   int rc;
+   char buf[1024] = { 0 };
+
+   /* Validate kernel reflects unsupported RTC alarm state */
+   param.param = RTC_PARAM_FEATURES;
+   param.index = 0;
+   rc = ioctl(fd, RTC_PARAM_GET, );
+   if (rc < 0) {
+   /* Fallback to read rtc procfs */
+   fd = open(rtc_procfs, O_RDONLY);


I think I was clear on the previous thread, no new users of the procfs
interface. You can carry this n your own tree but that can't be
upstream.



Okay ~ If we use RTC_PARAM_GET ioctl to detect rtc feature only, not
sure if that is okay for upstream ?

Thank you,
Joseph.




Re: [PATCH] selftest: rtc: Add to check rtc alarm status for alarm related test

2024-05-17 Thread Alexandre Belloni
On 16/05/2024 19:28:47-0700, Joseph Jang wrote:
> In alarm_wkalm_set and alarm_wkalm_set_minute test, they use different
> ioctl (RTC_ALM_SET/RTC_WKALM_SET) for alarm feature detection. They will
> skip testing if RTC_ALM_SET/RTC_WKALM_SET ioctl returns an EINVAL error
> code. This design may miss detecting real problems when the
> efi.set_wakeup_time() return errors and then RTC_ALM_SET/RTC_WKALM_SET
> ioctl returns an EINVAL error code with RTC_FEATURE_ALARM enabled.
> 
> In order to make rtctest more explicit and robust, we propose to use
> RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
> running alarm related tests. If the kernel does not support RTC_PARAM_GET
> ioctl interface, we will fallback to check the presence of "alarm" in
> /proc/driver/rtc.
> 
> The rtctest requires the read permission on /dev/rtc0. The rtctest will
> be skipped if the /dev/rtc0 is not readable.
> 

This change as to be separated. Also, I'm not sure what happened with
https://lore.kernel.org/all/20230717175251.54390-1-atulpant.li...@gmail.com/

> Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
> as optional")
> 
> Reviewed-by: Jeremy Szu 
> Reviewed-by: Matthew R. Ochs 
> Signed-off-by: Joseph Jang 
> ---
>  tools/testing/selftests/rtc/Makefile  |  2 +-
>  tools/testing/selftests/rtc/rtctest.c | 72 +++
>  2 files changed, 53 insertions(+), 21 deletions(-)
> 
> diff --git a/tools/testing/selftests/rtc/Makefile 
> b/tools/testing/selftests/rtc/Makefile
> index 55198ecc04db..6e3a98fb24ba 100644
> --- a/tools/testing/selftests/rtc/Makefile
> +++ b/tools/testing/selftests/rtc/Makefile
> @@ -1,5 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0
> -CFLAGS += -O3 -Wl,-no-as-needed -Wall
> +CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
>  LDLIBS += -lrt -lpthread -lm
>  
>  TEST_GEN_PROGS = rtctest
> diff --git a/tools/testing/selftests/rtc/rtctest.c 
> b/tools/testing/selftests/rtc/rtctest.c
> index 63ce02d1d5cc..aa47b17fbd1a 100644
> --- a/tools/testing/selftests/rtc/rtctest.c
> +++ b/tools/testing/selftests/rtc/rtctest.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -24,12 +25,17 @@
>  #define READ_LOOP_SLEEP_MS 11
>  
>  static char *rtc_file = "/dev/rtc0";
> +static char *rtc_procfs = "/proc/driver/rtc";
>  
>  FIXTURE(rtc) {
>   int fd;
>  };
>  
>  FIXTURE_SETUP(rtc) {
> + if (access(rtc_file, R_OK) != 0)
> + SKIP(return, "Skipping test since cannot access %s, perhaps 
> miss sudo",
> +  rtc_file);

> +
>   self->fd = open(rtc_file, O_RDONLY);
>  }
>  
> @@ -82,6 +88,36 @@ static void nanosleep_with_retries(long ns)
>   }
>  }
>  
> +static bool is_rtc_alarm_supported(int fd)
> +{
> + struct rtc_param param = { 0 };
> + int rc;
> + char buf[1024] = { 0 };
> +
> + /* Validate kernel reflects unsupported RTC alarm state */
> + param.param = RTC_PARAM_FEATURES;
> + param.index = 0;
> + rc = ioctl(fd, RTC_PARAM_GET, );
> + if (rc < 0) {
> + /* Fallback to read rtc procfs */
> + fd = open(rtc_procfs, O_RDONLY);

I think I was clear on the previous thread, no new users of the procfs
interface. You can carry this n your own tree but that can't be
upstream.

> + if (fd != -1) {
> + rc = read(fd, buf, sizeof(buf));
> + close(fd);
> +
> + /* Check for the presence of "alarm" in the buf */
> + if (strstr(buf, "alarm") == NULL)
> + return false;
> + } else
> + return false;
> + } else {
> + if ((param.uvalue & _BITUL(RTC_FEATURE_ALARM)) == 0)
> + return false;
> + }
> +
> + return true;
> +}
> +
>  TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) {
>   int rc;
>   long iter_count = 0;
> @@ -202,6 +238,9 @@ TEST_F(rtc, alarm_alm_set) {
>   SKIP(return, "Skipping test since %s does not exist", rtc_file);
>   ASSERT_NE(-1, self->fd);
>  
> + if (!is_rtc_alarm_supported(self->fd))
> + SKIP(return, "Skipping test since alarms are not supported.");
> +
>   rc = ioctl(self->fd, RTC_RD_TIME, );
>   ASSERT_NE(-1, rc);
>  
> @@ -209,11 +248,7 @@ TEST_F(rtc, alarm_alm_set) {
>   gmtime_r(, (struct tm *));
>  
>   rc = ioctl(self->fd, RTC_ALM_SET, );
> - if (rc == -1) {
> - ASSERT_EQ(EINVAL, errno);
> - TH_LOG("skip alarms are not supported.");
> - return;
> - }
> + ASSERT_NE(-1, rc);
>  
>   rc = ioctl(self->fd, RTC_ALM_READ, );
>   ASSERT_NE(-1, rc);
> @@ -260,6 +295,9 @@ TEST_F(rtc, alarm_wkalm_set) {
>   SKIP(return, "Skipping test since %s does not exist", rtc_file);
>   ASSERT_NE(-1, self->fd);
>  
> + if (!is_rtc_alarm_supported(self->fd))
> +   

[PATCH bpf-next] selftests/bpf: Fix prog numbers in test_sockmap

2024-05-17 Thread Geliang Tang
From: Geliang Tang 

bpf_prog5 and bpf_prog7 are removed from progs/test_sockmap_kern.h in
commit d79a32129b21 ("bpf: Selftests, remove prints from sockmap tests"),
now there are only 9 progs in it, not 11:

SEC("sk_skb1")
int bpf_prog1(struct __sk_buff *skb)
SEC("sk_skb2")
int bpf_prog2(struct __sk_buff *skb)
SEC("sk_skb3")
int bpf_prog3(struct __sk_buff *skb)
SEC("sockops")
int bpf_sockmap(struct bpf_sock_ops *skops)
SEC("sk_msg1")
int bpf_prog4(struct sk_msg_md *msg)
SEC("sk_msg2")
int bpf_prog6(struct sk_msg_md *msg)
SEC("sk_msg3")
int bpf_prog8(struct sk_msg_md *msg)
SEC("sk_msg4")
int bpf_prog9(struct sk_msg_md *msg)
SEC("sk_msg5")
int bpf_prog10(struct sk_msg_md *msg)

This patch updates the array sizes of prog_fd[], prog_attach_type[] and
prog_type[] from 11 to 9 accordingly.

Fixes: d79a32129b21 ("bpf: Selftests, remove prints from sockmap tests")
Signed-off-by: Geliang Tang 
---
 tools/testing/selftests/bpf/test_sockmap.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_sockmap.c 
b/tools/testing/selftests/bpf/test_sockmap.c
index 92752f5eeded..4499b3cfc3a6 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -63,7 +63,7 @@ int passed;
 int failed;
 int map_fd[9];
 struct bpf_map *maps[9];
-int prog_fd[11];
+int prog_fd[9];
 
 int txmsg_pass;
 int txmsg_redir;
@@ -1793,8 +1793,6 @@ int prog_attach_type[] = {
BPF_SK_MSG_VERDICT,
BPF_SK_MSG_VERDICT,
BPF_SK_MSG_VERDICT,
-   BPF_SK_MSG_VERDICT,
-   BPF_SK_MSG_VERDICT,
 };
 
 int prog_type[] = {
@@ -1807,8 +1805,6 @@ int prog_type[] = {
BPF_PROG_TYPE_SK_MSG,
BPF_PROG_TYPE_SK_MSG,
BPF_PROG_TYPE_SK_MSG,
-   BPF_PROG_TYPE_SK_MSG,
-   BPF_PROG_TYPE_SK_MSG,
 };
 
 static int populate_progs(char *bpf_file)
-- 
2.43.0




kselftest/next kselftest-seccomp: 6 runs, 7 regressions (v6.9-8287-g31a59b76b978)

2024-05-17 Thread kernelci.org bot
kselftest/next kselftest-seccomp: 6 runs, 7 regressions 
(v6.9-8287-g31a59b76b978)

This legacy KernelCI providing this report will shutdown sometime
soon in favor of our new KernelCI infra. Not all tests are being
migrated.
If you are still using this report and want us to prioritize your
usecase in the new system, please let us know at
kerne...@lists.linux.dev

Regressions Summary
---

platform | arch  | lab   | compiler | defconfig 
   | regressions
-+---+---+--+--+
meson-gxl-s905x-libretech-cc | arm64 | lab-broonie   | gcc-10   | 
defconfig+kselftest  | 2  
mt8173-elm-hana  | arm64 | lab-collabora | gcc-10   | 
defconfig+kse...4-chromebook | 2  
mt8183-kukui-...uniper-sku16 | arm64 | lab-collabora | gcc-10   | 
defconfig+kse...4-chromebook | 1  
mt8192-asurada-spherion-r0   | arm64 | lab-collabora | gcc-10   | 
defconfig+kse...4-chromebook | 2  

  Details:  
https://kernelci.org/test/job/kselftest/branch/next/kernel/v6.9-8287-g31a59b76b978/plan/kselftest-seccomp/

  Test: kselftest-seccomp
  Tree: kselftest
  Branch:   next
  Describe: v6.9-8287-g31a59b76b978
  URL:  
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
  SHA:  31a59b76b9780a9b2d385024e2d6d0d051bb06a5 


Test Regressions
 


platform | arch  | lab   | compiler | defconfig 
   | regressions
-+---+---+--+--+
meson-gxl-s905x-libretech-cc | arm64 | lab-broonie   | gcc-10   | 
defconfig+kselftest  | 2  

  Details: https://kernelci.org/test/plan/id/6646ea71e49c6a41ee4c432c

  Results: 105 PASS, 2 FAIL, 0 SKIP
  Full config: defconfig+kselftest
  Compiler:gcc-10 (aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110)
  Plain log:   
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm64/defconfig+kselftest/gcc-10/lab-broonie/kselftest-seccomp-meson-gxl-s905x-libretech-cc.txt
  HTML log:
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm64/defconfig+kselftest/gcc-10/lab-broonie/kselftest-seccomp-meson-gxl-s905x-libretech-cc.html
  Rootfs:  
http://storage.kernelci.org/images/rootfs/debian/bookworm-kselftest/20240313.0/arm64/initrd.cpio.gz
 


  * kselftest-seccomp.seccomp_seccomp_benchmark: 
https://kernelci.org/test/case/id/6646ea71e49c6a41ee4c432e
new failure (last pass: v6.9-rc4-32-g693fe2f6a9ea) 

  * kselftest-seccomp.seccomp_seccomp_benchmark_entry_2_bitmapped: 
https://kernelci.org/test/case/id/6646ea71e49c6a41ee4c4330
new failure (last pass: v6.9-rc4-32-g693fe2f6a9ea) 
 


platform | arch  | lab   | compiler | defconfig 
   | regressions
-+---+---+--+--+
mt8173-elm-hana  | arm64 | lab-collabora | gcc-10   | 
defconfig+kse...4-chromebook | 2  

  Details: https://kernelci.org/test/plan/id/6646e74283cd144db94c442a

  Results: 105 PASS, 2 FAIL, 0 SKIP
  Full config: defconfig+kselftest+arm64-chromebook
  Compiler:gcc-10 (aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110)
  Plain log:   
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm64/defconfig+kselftest+arm64-chromebook/gcc-10/lab-collabora/kselftest-seccomp-mt8173-elm-hana.txt
  HTML log:
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm64/defconfig+kselftest+arm64-chromebook/gcc-10/lab-collabora/kselftest-seccomp-mt8173-elm-hana.html
  Rootfs:  
http://storage.kernelci.org/images/rootfs/debian/bookworm-kselftest/20240313.0/arm64/initrd.cpio.gz
 


  * kselftest-seccomp.seccomp_seccomp_benchmark: 
https://kernelci.org/test/case/id/6646e74283cd144db94c442c
new failure (last pass: v6.9-rc4-32-g693fe2f6a9ea) 

  * 
kselftest-seccomp.seccomp_seccomp_benchmark_per-filter_last_2_diff_per-filter_filters_4:
 https://kernelci.org/test/case/id/6646e74283cd144db94c4431
new failure (last pass: v6.9-rc4-32-g693fe2f6a9ea) 
 


platform | arch  | lab   | compiler | defconfig 
   | regressions
-+---+---+--+--+
mt8183-kukui-...uniper-sku16 | arm64 | lab-collabora | gcc-10   | 
defconfig+kse...4-chromebook | 1  

  Details: https://kernelci.org/test/plan/id/6646e90e6ac9380c2b4c4320

  Results: 0 PASS, 1 FAIL, 0 SKIP
  Full config: defconfig+kselftest+arm64-chromebook
  Compiler:gcc-10 (aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110)
  Plain log:   

kselftest/next kselftest-livepatch: 2 runs, 1 regressions (v6.9-8287-g31a59b76b978)

2024-05-17 Thread kernelci.org bot
kselftest/next kselftest-livepatch: 2 runs, 1 regressions 
(v6.9-8287-g31a59b76b978)

This legacy KernelCI providing this report will shutdown sometime
soon in favor of our new KernelCI infra. Not all tests are being
migrated.
If you are still using this report and want us to prioritize your
usecase in the new system, please let us know at
kerne...@lists.linux.dev

Regressions Summary
---

platform| arch | lab   | compiler | defconfig   
 | regressions
+--+---+--+--+
imx6q-sabrelite | arm  | lab-collabora | gcc-10   | 
multi_v7_defconfig+kselftest | 1  

  Details:  
https://kernelci.org/test/job/kselftest/branch/next/kernel/v6.9-8287-g31a59b76b978/plan/kselftest-livepatch/

  Test: kselftest-livepatch
  Tree: kselftest
  Branch:   next
  Describe: v6.9-8287-g31a59b76b978
  URL:  
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
  SHA:  31a59b76b9780a9b2d385024e2d6d0d051bb06a5 


Test Regressions
 


platform| arch | lab   | compiler | defconfig   
 | regressions
+--+---+--+--+
imx6q-sabrelite | arm  | lab-collabora | gcc-10   | 
multi_v7_defconfig+kselftest | 1  

  Details: https://kernelci.org/test/plan/id/6646e7728813c2beb54c4309

  Results: 1 PASS, 1 FAIL, 0 SKIP
  Full config: multi_v7_defconfig+kselftest
  Compiler:gcc-10 (arm-linux-gnueabihf-gcc (Debian 10.2.1-6) 10.2.1 
20210110)
  Plain log:   
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm/multi_v7_defconfig+kselftest/gcc-10/lab-collabora/kselftest-livepatch-imx6q-sabrelite.txt
  HTML log:
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm/multi_v7_defconfig+kselftest/gcc-10/lab-collabora/kselftest-livepatch-imx6q-sabrelite.html
  Rootfs:  
http://storage.kernelci.org/images/rootfs/debian/bookworm-kselftest/20240313.0/armhf/initrd.cpio.gz
 


  * kselftest-livepatch.shardfile-livepatch: 
https://kernelci.org/test/case/id/6646e7728813c2beb54c430b
failing since 92 days (last pass: v6.8-rc1, first fail: 
v6.8-rc1-32-g345e8abe4c355)

2024-05-17T05:22:14.386921  / # 

2024-05-17T05:22:14.396909  

2024-05-17T05:22:19.540722  / # export 
NFS_ROOTFS='/var/lib/lava/dispatcher/tmp/13854313/extract-nfsrootfs-h8_h7jqp'

2024-05-17T05:22:19.557695  export 
NFS_ROOTFS='/var/lib/lava/dispatcher/tmp/13854313/extract-nfsrootfs-h8_h7jqp'

2024-05-17T05:22:21.784837  / # export NFS_SERVER_IP='192.168.201.1'

2024-05-17T05:22:21.795705  export NFS_SERVER_IP='192.168.201.1'

2024-05-17T05:22:21.913710  / # #

2024-05-17T05:22:21.923089  #

2024-05-17T05:22:22.040178  / # export SHELL=/bin/bash

2024-05-17T05:22:22.051641  export SHELL=/bin/bash
 
... (83 line(s) more)  
  



kselftest/next kselftest-lkdtm: 5 runs, 1 regressions (v6.9-8287-g31a59b76b978)

2024-05-17 Thread kernelci.org bot
kselftest/next kselftest-lkdtm: 5 runs, 1 regressions (v6.9-8287-g31a59b76b978)

This legacy KernelCI providing this report will shutdown sometime
soon in favor of our new KernelCI infra. Not all tests are being
migrated.
If you are still using this report and want us to prioritize your
usecase in the new system, please let us know at
kerne...@lists.linux.dev

Regressions Summary
---

platform| arch | lab   | compiler | defconfig   
 | regressions
+--+---+--+--+
imx6q-sabrelite | arm  | lab-collabora | gcc-10   | 
multi_v7_defconfig+kselftest | 1  

  Details:  
https://kernelci.org/test/job/kselftest/branch/next/kernel/v6.9-8287-g31a59b76b978/plan/kselftest-lkdtm/

  Test: kselftest-lkdtm
  Tree: kselftest
  Branch:   next
  Describe: v6.9-8287-g31a59b76b978
  URL:  
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
  SHA:  31a59b76b9780a9b2d385024e2d6d0d051bb06a5 


Test Regressions
 


platform| arch | lab   | compiler | defconfig   
 | regressions
+--+---+--+--+
imx6q-sabrelite | arm  | lab-collabora | gcc-10   | 
multi_v7_defconfig+kselftest | 1  

  Details: https://kernelci.org/test/plan/id/6646e8cef167b1cf9e4c446b

  Results: 62 PASS, 4 FAIL, 21 SKIP
  Full config: multi_v7_defconfig+kselftest
  Compiler:gcc-10 (arm-linux-gnueabihf-gcc (Debian 10.2.1-6) 10.2.1 
20210110)
  Plain log:   
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm/multi_v7_defconfig+kselftest/gcc-10/lab-collabora/kselftest-lkdtm-imx6q-sabrelite.txt
  HTML log:
https://storage.kernelci.org//kselftest/next/v6.9-8287-g31a59b76b978/arm/multi_v7_defconfig+kselftest/gcc-10/lab-collabora/kselftest-lkdtm-imx6q-sabrelite.html
  Rootfs:  
http://storage.kernelci.org/images/rootfs/debian/bookworm-kselftest/20240313.0/armhf/initrd.cpio.gz
 


  * kselftest-lkdtm.lkdtm_FORTIFY_MEM_MEMBER_sh: 
https://kernelci.org/test/case/id/6646e8cef167b1cf9e4c446f
new failure (last pass: v6.9-rc7-44-g2c3b8f8f37c6)