[PATCH v3 17/17] selftests: riscv: Support xtheadvector in vector tests

2024-04-20 Thread Charlie Jenkins
Extend existing vector tests to be compatible with the xtheadvector instruction set. Signed-off-by: Charlie Jenkins --- .../selftests/riscv/vector/v_exec_initval_nolibc.c | 23 -- tools/testing/selftests/riscv/vector/v_helpers.c | 17 +++- tools/testing/selftests/riscv/vector/v_helpers.h

[PATCH v3 16/17] selftests: riscv: Fix vector tests

2024-04-20 Thread Charlie Jenkins
Overhaul the riscv vector tests to use kselftest_harness to help the test cases correctly report the results and decouple the individual test cases from each other. With this refactoring, only run the test cases is vector is reported and properly report the test case as skipped otherwise. The v_ini

[PATCH v3 15/17] riscv: hwprobe: Document thead vendor extensions and xtheadvector extension

2024-04-20 Thread Charlie Jenkins
Document support for thead vendor extensions using the key RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 and xtheadvector extension using the key RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR. Signed-off-by: Charlie Jenkins --- Documentation/arch/riscv/hwprobe.rst | 10 ++ 1 file changed, 10 insertions(+

[PATCH v3 14/17] riscv: hwprobe: Add thead vendor extension probing

2024-04-20 Thread Charlie Jenkins
Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0" which allows userspace to probe for the new RISCV_ISA_VENDOR_EXT_XTHEADVECTOR vendor extension. This new key will allow userspace code to probe for which thead vendor extensions are supported. This API is modeled to be consistent with RI

[PATCH v3 13/17] riscv: vector: Support xtheadvector save/restore

2024-04-20 Thread Charlie Jenkins
Use alternatives to add support for xtheadvector vector save/restore routines. Signed-off-by: Charlie Jenkins --- arch/riscv/Kconfig.vendor | 13 ++ arch/riscv/include/asm/csr.h | 6 + arch/riscv/include/asm/switch_to.h | 2 +- arch/riscv/include/asm/vector.h

[PATCH v3 11/17] riscv: csr: Add CSR encodings for VCSR_VXRM/VCSR_VXSAT

2024-04-20 Thread Charlie Jenkins
The VXRM vector csr for xtheadvector has an encoding of 0xa and VXSAT has an encoding of 0x9. Co-developed-by: Heiko Stuebner Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/csr.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/a

[PATCH v3 10/17] RISC-V: define the elements of the VCSR vector CSR

2024-04-20 Thread Charlie Jenkins
From: Heiko Stuebner The VCSR CSR contains two elements VXRM[2:1] and VXSAT[0]. Define constants for those to access the elements in a readable way. Acked-by: Guo Ren Reviewed-by: Conor Dooley Signed-off-by: Heiko Stuebner Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/csr.h | 5

[PATCH v3 09/17] riscv: drivers: Convert xandespmu to use the vendor extension framework

2024-04-20 Thread Charlie Jenkins
Migrate xandespmu out of riscv_isa_ext and into a new Andes-specific vendor namespace. Signed-off-by: Charlie Jenkins --- arch/riscv/Kconfig.vendor| 10 +++ arch/riscv/include/asm/hwcap.h | 1 - arch/riscv/include/asm/vendor_extensions/andes.h | 19

[PATCH v3 08/17] riscv: Introduce vendor variants of extension helpers

2024-04-20 Thread Charlie Jenkins
Vendor extensions are maintained in per-vendor structs (separate from standard extensions which live in riscv_isa). Create vendor variants for the existing extension helpers to interface with the riscv_isa_vendor bitmaps. There is a good amount of overlap between these functions, so the alternative

[PATCH v3 07/17] riscv: Extend cpufeature.c to detect vendor extensions

2024-04-20 Thread Charlie Jenkins
Separate vendor extensions out into one struct per vendor instead of adding vendor extensions onto riscv_isa_ext. Signed-off-by: Charlie Jenkins --- arch/riscv/Kconfig | 2 + arch/riscv/Kconfig.vendor| 9 +++ arch/riscv/include/asm/cpufeatu

[PATCH v3 06/17] riscv: Fix extension subset checking

2024-04-20 Thread Charlie Jenkins
This loop is supposed to check if ext->subset_ext_ids[j] is valid, rather than if ext->subset_ext_ids[i] is valid, before setting the extension id ext->subset_ext_ids[j] in isainfo->isa. Signed-off-by: Charlie Jenkins Reviewed-by: Conor Dooley Fixes: 0d8295ed975b ("riscv: add ISA extension parsi

[PATCH v3 05/17] riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree

2024-04-20 Thread Charlie Jenkins
The D1/D1s SoCs support xtheadvector so it can be included in the devicetree. Also include vlenb for the cpu. Signed-off-by: Charlie Jenkins --- arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/boot/dts/allwinner/sun20

[PATCH v3 04/17] riscv: vector: Use vlenb from DT

2024-04-20 Thread Charlie Jenkins
If vlenb is provided in the device tree, prefer that over reading the vlenb csr. Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/cpufeature.h | 2 ++ arch/riscv/kernel/cpufeature.c | 26 ++ arch/riscv/kernel/vector.c | 13 + 3 files ch

[PATCH v3 03/17] dt-bindings: riscv: cpus: add a vlen register length property

2024-04-20 Thread Charlie Jenkins
From: Conor Dooley Add a property analogous to the vlenb CSR so that software can detect the vector length of each CPU prior to it being brought online. Currently software has to assume that the vector length read from the boot CPU applies to all possible CPUs. On T-Head CPUs implementing pre-rat

[PATCH v3 02/17] dt-bindings: riscv: Add xtheadvector ISA extension description

2024-04-20 Thread Charlie Jenkins
The xtheadvector ISA extension is described on the T-Head extension spec Github page [1] at commit 95358cb2cca9. Link: https://github.com/T-head-Semi/thead-extension-spec/blob/95358cb2cca9489361c61d335e03d3134b14133f/xtheadvector.adoc [1] Signed-off-by: Charlie Jenkins Reviewed-by: Conor Doole

[PATCH v3 01/17] riscv: cpufeature: Fix thead vector hwcap removal

2024-04-20 Thread Charlie Jenkins
The riscv_cpuinfo struct that contains mvendorid and marchid is not populated until all harts are booted which happens after the DT parsing. Use the vendorid/archid values from the DT if available or assume all harts have the same values as the boot hart as a fallback. Fixes: d82f32202e0d ("RISC-V

[PATCH v3 00/17] riscv: Support vendor extensions and xtheadvector

2024-04-20 Thread Charlie Jenkins
This patch series ended up much larger than expected, please bear with me! The goal here is to support vendor extensions, starting at probing the device tree and ending with reporting to userspace. The main design objective was to allow vendors to operate independently of each other. This has been

Re: [PATCH net-next 3/4] netlink: support all extack types in dumps

2024-04-20 Thread David Ahern
On 4/19/24 8:35 PM, Jakub Kicinski wrote: > Note that when this commit message refers to netlink dump > it only means the actual dumping part, the parsing / dump > start is handled by the same code as "doit". > > Commit 4a19edb60d02 ("netlink: Pass extack to dump handlers") > added support for ret

Re: [PATCH net-next 2/4] netlink: move extack writing helpers

2024-04-20 Thread David Ahern
On 4/19/24 8:35 PM, Jakub Kicinski wrote: > Next change will need them in netlink_dump_done(), pure move. > > Signed-off-by: Jakub Kicinski > --- > net/netlink/af_netlink.c | 126 +++ > 1 file changed, 63 insertions(+), 63 deletions(-) > Reviewed-by: David A

Re: [PATCH net-next 1/4] netdev: support dumping a single netdev in qstats

2024-04-20 Thread David Ahern
On 4/19/24 8:35 PM, Jakub Kicinski wrote: > Having to filter the right ifindex in the tests is a bit tedious. > Add support for dumping qstats for a single ifindex. > > Signed-off-by: Jakub Kicinski > --- > Documentation/netlink/specs/netdev.yaml | 1 + > net/core/netdev-genl-gen.c

[PATCH] selftests: mm: fix linker error for inline function

2024-04-20 Thread Amer Al Shanawany
add 'static' keyword to 'sys_mprotect()' to link properly, otherwise the test won't build. gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 /usr/bin/ld: /tmp/cc7yeABp.o: in function `test_seal_elf': seal_elf.c:(.text+0x7af): undefined reference to `sys_mprotect' /usr/bin/ld: seal_elf.c:(.text+0x82c): un

Re: [PATCH 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer drift correction

2024-04-20 Thread David Woodhouse
On Fri, 2024-04-19 at 16:54 -0700, Chen, Zide wrote: > > However, the selftest hangs: > > [Apr19 16:15] kselftest: Running tests in kvm > [Apr19 16:16] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: > [  +0.000628] rcu:  78-...0: (1 GPs behind) > idle=3c8c/1/0x4000 softirq

[PATCH] selftests/bpf: Add ring_buffer__consume_n test.

2024-04-20 Thread Andrea Righi
Add a testcase for the ring_buffer__consume_n() API. The test produces multiple samples in a ring buffer, using a sys_getpid() fentry prog, and consumes them from user-space in batches, rather than consuming all of them greedily, like ring_buffer__consume() does. Link: https://lore.kernel.org/lk

Re: [PATCH] selftests: filesystems: add missing stddef header

2024-04-20 Thread Amer Al Shanawany
On 4/19/24 18:45, Muhammad Usama Anjum wrote: > On 4/17/24 9:16 PM, Amer Al Shanawany wrote: >> fix compiler warning and errors when compiling statmount test. > The error description or the compiler with version is required to reproduce > the error easily. I'm unable to reproduce the error by gcc 1

[PATCH bpf-next 5/5] selftests/bpf: Use make_sockaddr in test_sock_addr

2024-04-20 Thread Geliang Tang
From: Geliang Tang This patch uses public helper make_sockaddr() exported in network_helpers.h instead of the local defined function mk_sockaddr() in test_sock_addr.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sock_addr.c | 62 -

[PATCH bpf-next 4/5] selftests/bpf: Use connect_to_addr in test_sock_addr

2024-04-20 Thread Geliang Tang
From: Geliang Tang This patch uses public network helper connect_to_addr() exported in network_helpers.h instead of the local defined function connect_to_server() in test_sock_addr.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sock_addr.c |

[PATCH bpf-next 3/5] selftests/bpf: Use start_server_addr in test_sock_addr

2024-04-20 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in test_sock_addr.c, use the newly added public helper start_server_addr() instead of the local defined function start_server(). This can avoid duplicate code. In order to use functions defined in network_helpers.c in test_sock_addr.c, Makefile needs

[PATCH bpf-next 2/5] selftests/bpf: Use log_err in open_netns/close_netns

2024-04-20 Thread Geliang Tang
From: Geliang Tang ASSERT helpers defined in test_progs.h shouldn't be used in public functions like open_netns() and close_netns(). Since they depend on test__fail() which defined in test_progs.c. Public functions may be used not only in test_progs.c, but in other tests like test_sock_addr.c in

[PATCH bpf-next 0/5] use network helpers, part 2

2024-04-20 Thread Geliang Tang
From: Geliang Tang This patchset uses more network helpers in test_sock_addr.c, but first of all, patch 2 is needed to make network_helpers.c independent of test_progs.c. Then network_helpers.h can be included into test_sock_addr.c without compile errors. Patch 1 and patch 2 address Martin's com

[PATCH bpf-next 1/5] selftests/bpf: Fix a fd leak in error paths in open_netns

2024-04-20 Thread Geliang Tang
From: Geliang Tang As Martin mentioned in review comment, there is an existing bug that orig_netns_fd will be leaked in the later "goto fail;" case after open("/proc/self/ns/net") in open_netns() in network_helpers.c. This patch adds "close(token->orig_netns_fd);" before "free(token);" to fix it.

Re: [PATCH 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer drift correction

2024-04-20 Thread David Woodhouse
On 20 April 2024 00:54:05 BST, "Chen, Zide" wrote: > > >On 4/19/2024 11:43 AM, David Woodhouse wrote: >> On 19 April 2024 19:40:06 BST, David Woodhouse wrote: >>> On 19 April 2024 18:13:16 BST, "Chen, Zide" wrote: I'm wondering what's the underling theory that we definitely can achieve

[PATCH bpf-next v2 16/16] selftests/bpf: wq: add bpf_wq_start() checks

2024-04-20 Thread Benjamin Tissoires
Allows to test if allocation/free works Signed-off-by: Benjamin Tissoires --- changes in v2: - remove #define CLOCK_MONOTONIC 1 leftover --- tools/testing/selftests/bpf/bpf_experimental.h | 1 + tools/testing/selftests/bpf/prog_tests/wq.c| 22 ++ tools/testing/selftest

[PATCH bpf-next v2 15/16] bpf: add bpf_wq_start

2024-04-20 Thread Benjamin Tissoires
again, copy/paste from bpf_timer_start(). Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped spinlock and use READ_ONCE() instead --- kernel/bpf/helpers.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 85d3f

[PATCH bpf-next v2 14/16] selftests/bpf: add checks for bpf_wq_set_callback()

2024-04-20 Thread Benjamin Tissoires
We assign the callback and set everything up. The actual tests of these callbacks will be done when bpf_wq_start() is available. Signed-off-by: Benjamin Tissoires --- changes in v2: - removed mark_precise checks - adapted without BPF_F_WQ_SLEEPABLE --- tools/testing/selftests/bpf/bpf_experimen

[PATCH bpf-next v2 13/16] bpf: wq: add bpf_wq_set_callback_impl

2024-04-20 Thread Benjamin Tissoires
To support sleepable async callbacks, we need to tell push_async_cb() whether the cb is sleepable or not. The verifier now detects that we are in bpf_wq_set_callback_impl and can allow a sleepable callback to happen. Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped flags check fo

[PATCH bpf-next v2 12/16] selftests/bpf: wq: add bpf_wq_init() checks

2024-04-20 Thread Benjamin Tissoires
Allows to test if allocation/free works Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped mark_precise checks --- tools/testing/selftests/bpf/bpf_experimental.h | 1 + tools/testing/selftests/bpf/prog_tests/wq.c | 8 +++ tools/testing/selftests/bpf/progs/wq.c | 10

[PATCH bpf-next v2 11/16] bpf: wq: add bpf_wq_init

2024-04-20 Thread Benjamin Tissoires
We need to teach the verifier about the second argument which is declared as void * but which is of type KF_ARG_PTR_TO_MAP. We could have dropped this extra case if we declared the second argument as struct bpf_map *, but that means users will have to do extra casting to have their program compile.

[PATCH bpf-next v2 10/16] selftests/bpf: add bpf_wq tests

2024-04-20 Thread Benjamin Tissoires
We simply try in all supported map types if we can store/load a bpf_wq. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/bpf/prog_tests/wq.c | 11 +++ tools/testing/selftests/bpf/progs/wq.c | 135 2 files changed, 146 inserti

[PATCH bpf-next v2 09/16] bpf: allow struct bpf_wq to be embedded in arraymaps and hashmaps

2024-04-20 Thread Benjamin Tissoires
Currently bpf_wq_cancel_and_free() is just a placeholder as there is no memory allocation for bpf_wq just yet. Again, duplication of the bpf_timer approach Signed-off-by: Benjamin Tissoires --- changes in v2: - removed extra fallthrough --- include/linux/bpf.h | 2 ++ kernel/bpf/arraymap.c

[PATCH bpf-next v2 08/16] bpf: add support for KF_ARG_PTR_TO_WORKQUEUE

2024-04-20 Thread Benjamin Tissoires
Introduce support for KF_ARG_PTR_TO_WORKQUEUE. The kfuncs will use bpf_wq as argument and that will be recognized as workqueue argument by verifier. bpf_wq_kern casting can happen inside kfunc, but using bpf_wq in argument makes life easier for users who work with non-kern type in BPF progs. Dupli

[PATCH bpf-next v2 07/16] bpf: verifier: bail out if the argument is not a map

2024-04-20 Thread Benjamin Tissoires
When a kfunc is declared with a KF_ARG_PTR_TO_MAP, we should have reg->map_ptr set to a non NULL value, otherwise, that means that the underlying type is not a map. Signed-off-by: Benjamin Tissoires --- new in v2 --- kernel/bpf/verifier.c | 5 + 1 file changed, 5 insertions(+) diff --git

[PATCH bpf-next v2 06/16] tools: sync include/uapi/linux/bpf.h

2024-04-20 Thread Benjamin Tissoires
cp include/uapi/linux/bpf.h tools/include/uapi/linux/bpf.h Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/include/uapi/linux/bpf.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index cee0a7915c08..e4ae8

[PATCH bpf-next v2 05/16] bpf: add support for bpf_wq user type

2024-04-20 Thread Benjamin Tissoires
Mostly a copy/paste from the bpf_timer API, without the initialization and free, as they will be done in a separate patch. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- include/linux/bpf.h | 11 ++- include/uapi/linux/bpf.h | 4 kernel/bpf/btf.c | 17 +++

[PATCH bpf-next v2 04/16] bpf: replace bpf_timer_cancel_and_free with a generic helper

2024-04-20 Thread Benjamin Tissoires
Same reason than most bpf_timer* functions, we need almost the same for workqueues. So extract the generic part out of it so bpf_wq_cancel_and_free can reuse it. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 42 +- 1 f

[PATCH bpf-next v2 03/16] bpf: replace bpf_timer_set_callback with a generic helper

2024-04-20 Thread Benjamin Tissoires
In the same way we have a generic __bpf_async_init(), we also need to share code between timer and workqueue for the set_callback call. We just add an unused flags parameter, as it will be used for workqueues. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 2

[PATCH bpf-next v2 02/16] bpf: replace bpf_timer_init with a generic helper

2024-04-20 Thread Benjamin Tissoires
No code change except for the new flags argument being stored in the local data struct. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 91 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/ker

[PATCH bpf-next v2 01/16] bpf: make timer data struct more generic

2024-04-20 Thread Benjamin Tissoires
To be able to add workqueues and reuse most of the timer code, we need to make bpf_hrtimer more generic. There is no code change except that the new struct gets a new u64 flags attribute. We are still below 2 cache lines, so this shouldn't impact the current running codes. The ordering is also ch

[PATCH bpf-next v2 00/16] Introduce bpf_wq

2024-04-20 Thread Benjamin Tissoires
This is a followup of sleepable bpf_timer[0]. When discussing sleepable bpf_timer, it was thought that we should give a try to bpf_wq, as the 2 APIs are similar but distinct enough to justify a new one. So here it is. I tried to keep as much as possible common code in kernel/bpf/helpers.c but I

Re: [PATCH bpf-next v3 07/11] bpf: Fix a false rejection caused by AND operation

2024-04-20 Thread Xu Kuohai
On 4/20/2024 7:00 AM, Eduard Zingerman wrote: On Thu, 2024-04-11 at 20:27 +0800, Xu Kuohai wrote: From: Xu Kuohai With lsm return value check, the no-alu32 version test_libbpf_get_fd_by_id_opts is rejected by the verifier, and the log says: 0: R1=ctx() R10=fp0 ; int BPF_PROG(check_acces