[PATCH v4 08/18] riscv: misaligned: move emulated access uniformity check in a function

2025-03-17 Thread Clément Léger
Split the code that check for the uniformity of misaligned accesses performance on all cpus from check_unaligned_access_emulated_all_cpus() to its own function which will be used for delegation check. No functional changes intended. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arc

Re: [PATCH v4 1/2] compiler_types: Introduce __flex_counter() and family

2025-03-17 Thread Kees Cook
On Mon, Mar 17, 2025 at 10:43:38AM +0100, Przemek Kitszel wrote: > On 3/17/25 10:26, Przemek Kitszel wrote: > > On 3/15/25 04:15, Kees Cook wrote: > > > Introduce __flex_counter() which wraps __builtin_counted_by_ref(), > > > as newly introduced by GCC[1] and Clang[2]. Use of __flex_counter() > > >

Re: [PATCH v8 12/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2025-03-17 Thread Jason Gunthorpe
On Tue, Mar 11, 2025 at 10:43:08AM -0700, Nicolin Chen wrote: > > > +int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state *state, > > > + struct arm_smmu_nested_domain > > > *nested_domain) > > > +{ > > > + struct arm_smmu_vmaster *vmaster; > > > + unsigned

[PATCH v4 12/18] riscv: misaligned: use get_user() instead of __get_user()

2025-03-17 Thread Clément Léger
Now that we can safely handle user memory accesses while in the misaligned access handlers, use get_user() instead of __get_user() to have user memory access checks. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps_misaligned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v4 13/18] Documentation/sysctl: add riscv to unaligned-trap supported archs

2025-03-17 Thread Clément Léger
riscv supports the "unaligned-trap" sysctl variable, add it to the list of supported architectures. Signed-off-by: Clément Léger --- Documentation/admin-guide/sysctl/kernel.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/

[PATCH v4 17/18] RISC-V: KVM: add support for FWFT SBI extension

2025-03-17 Thread Clément Léger
Add basic infrastructure to support the FWFT extension in KVM. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arch/riscv/include/asm/kvm_host.h | 4 + arch/riscv/include/asm/kvm_vcpu_sbi.h | 1 + arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h | 29 +++ arch/riscv/incl

[PATCH v4 16/18] RISC-V: KVM: add SBI extension reset callback

2025-03-17 Thread Clément Léger
Currently, only the STA extension needed a reset function but that's going to be the case for FWFT as well. Add a reset callback that can be implemented by SBI extensions. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arch/riscv/include/asm/kvm_host.h | 1 - arch/riscv/include

[PATCH v4 00/18] riscv: add SBI FWFT misaligned exception delegation support

2025-03-17 Thread Clément Léger
The SBI Firmware Feature extension allows the S-mode to request some specific features (either hardware or software) to be enabled. This series uses this extension to request misaligned access exception delegation to S-mode in order to let the kernel handle it. It also adds support for the KVM FWFT

[PATCH v4 03/18] riscv: sbi: add FWFT extension interface

2025-03-17 Thread Clément Léger
This SBI extensions enables supervisor mode to control feature that are under M-mode control (For instance, Svadu menvcfg ADUE bit, Ssdbltrp DTE, etc). Add an interface to set local features for a specific cpu mask as well as for the online cpu mask. Signed-off-by: Clément Léger --- arch/riscv/i

[PATCH v4 05/18] riscv: misaligned: request misaligned exception from SBI

2025-03-17 Thread Clément Léger
Now that the kernel can handle misaligned accesses in S-mode, request misaligned access exception delegation from SBI. This uses the FWFT SBI extension defined in SBI version 3.0. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arch/riscv/include/asm/cpufeature.h| 3 +- arch

[PATCH v4 10/18] riscv: misaligned: factorize trap handling

2025-03-17 Thread Clément Léger
misaligned accesses traps are not nmi and should be treated as normal one using irqentry_enter()/exit(). Since both load/store and user/kernel should use almost the same path and that we are going to add some code around that, factorize it. Signed-off-by: Clément Léger --- arch/riscv/kernel/trap

[PATCH v4 09/18] riscv: misaligned: add a function to check misalign trap delegability

2025-03-17 Thread Clément Léger
Checking for the delegability of the misaligned access trap is needed for the KVM FWFT extension implementation. Add a function to get the delegability of the misaligned trap exception. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arch/riscv/include/asm/cpufeature.h | 5 + a

[PATCH v4 15/18] RISC-V: KVM: add SBI extension init()/deinit() functions

2025-03-17 Thread Clément Léger
The FWFT SBI extension will need to dynamically allocate memory and do init time specific initialization. Add an init/deinit callbacks that allows to do so. Signed-off-by: Clément Léger --- arch/riscv/include/asm/kvm_vcpu_sbi.h | 9 + arch/riscv/kvm/vcpu.c | 2 ++ arch/

[PATCH v4 02/18] riscv: sbi: add new SBI error mappings

2025-03-17 Thread Clément Léger
A few new errors have been added with SBI V3.0, maps them as close as possible to errno values. Signed-off-by: Clément Léger --- arch/riscv/include/asm/sbi.h | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index bb077d0c912

[PATCH v4 04/18] riscv: sbi: add SBI FWFT extension calls

2025-03-17 Thread Clément Léger
Add FWFT extension calls. This will be ratified in SBI V3.0 hence, it is provided as a separate commit that can be left out if needed. Signed-off-by: Clément Léger --- arch/riscv/kernel/sbi.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/arch

[PATCH v4 01/18] riscv: add Firmware Feature (FWFT) SBI extensions definitions

2025-03-17 Thread Clément Léger
The Firmware Features extension (FWFT) was added as part of the SBI 3.0 specification. Add SBI definitions to use this extension. Signed-off-by: Clément Léger Reviewed-by: Samuel Holland Tested-by: Samuel Holland Reviewed-by: Deepak Gupta Reviewed-by: Andrew Jones --- arch/riscv/include/asm/

[PATCH v4 07/18] riscv: misaligned: use correct CONFIG_ ifdef for misaligned_access_speed

2025-03-17 Thread Clément Léger
misaligned_access_speed is defined under CONFIG_RISCV_SCALAR_MISALIGNED but was used under CONFIG_RISCV_PROBE_UNALIGNED_ACCESS. Fix that by using the correct config option. Signed-off-by: Clément Léger Reviewed-by: Andrew Jones --- arch/riscv/kernel/traps_misaligned.c | 2 +- 1 file changed, 1

[PATCH v4 06/18] riscv: misaligned: use on_each_cpu() for scalar misaligned access probing

2025-03-17 Thread Clément Léger
schedule_on_each_cpu() was used without any good reason while documented as very slow. This call was in the boot path, so better use on_each_cpu() for scalar misaligned checking. Vector misaligned check still needs to use schedule_on_each_cpu() since it requires irqs to be enabled but that's less o

[PATCH v4 11/18] riscv: misaligned: enable IRQs while handling misaligned accesses

2025-03-17 Thread Clément Léger
We can safely reenable IRQs if they were enabled in the previous context. This allows to access user memory that could potentially trigger a page fault. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel/traps.

[PATCH v4 14/18] selftests: riscv: add misaligned access testing

2025-03-17 Thread Clément Léger
Now that the kernel can emulate misaligned access and control its behavior, add a selftest for that. This selftest tests all the currently emulated instruction (except for the RV32 compressed ones which are left as a future exercise for a RV32 user). For the FPU instructions, all the FPU registers

[PATCH v4 18/18] RISC-V: KVM: add support for SBI_FWFT_MISALIGNED_DELEG

2025-03-17 Thread Clément Léger
SBI_FWFT_MISALIGNED_DELEG needs hedeleg to be modified to delegate misaligned load/store exceptions. Save and restore it during CPU load/put. Signed-off-by: Clément Léger Reviewed-by: Deepak Gupta Reviewed-by: Andrew Jones --- arch/riscv/kvm/vcpu.c | 3 +++ arch/riscv/kvm/vcpu_sbi_fw

Re: [PATCH v8 12/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2025-03-17 Thread Nicolin Chen
On Mon, Mar 17, 2025 at 12:44:23PM -0300, Jason Gunthorpe wrote: > On Tue, Mar 11, 2025 at 10:43:08AM -0700, Nicolin Chen wrote: > > > > +int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state > > > > *state, > > > > + struct arm_smmu_nested_domain > >

Re: [PATCH v9 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vEVENTQ)

2025-03-17 Thread Jason Gunthorpe
On Tue, Mar 11, 2025 at 12:44:18PM -0700, Nicolin Chen wrote: > As the vIOMMU infrastructure series part-3, this introduces a new vEVENTQ > object. The existing FAULT object provides a nice notification pathway to > the user space with a queue already, so let vEVENTQ reuse that. > > Mimicing the H

Re: [PATCH v8 12/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2025-03-17 Thread Jason Gunthorpe
On Mon, Mar 17, 2025 at 11:49:14AM -0700, Nicolin Chen wrote: > On Mon, Mar 17, 2025 at 12:44:23PM -0300, Jason Gunthorpe wrote: > > On Tue, Mar 11, 2025 at 10:43:08AM -0700, Nicolin Chen wrote: > > > > > +int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state > > > > > *state, > > > > >

Re: [PATCH] Documentation: kcsan: fix "Plain Accesses and Data Races" URL in kcsan.rst

2025-03-17 Thread Jonathan Corbet
Ignacio Encinas Rubio writes: > On 15/3/25 3:41, Akira Yokosawa wrote: >> This might be something Jon would like to keep secret, but ... >> >> See the message and the thread it belongs at: >> >> >> https://lore.kernel.org/lkml/pine.lnx.4.44l0.1907310947340.1497-100...@iolanthe.rowland.org/

Re: [PATCH net-next v9 3/6] tun: Introduce virtio-net hash feature

2025-03-17 Thread Jason Wang
On Mon, Mar 17, 2025 at 3:07 PM Akihiko Odaki wrote: > > On 2025/03/17 10:12, Jason Wang wrote: > > On Wed, Mar 12, 2025 at 1:03 PM Akihiko Odaki > > wrote: > >> > >> On 2025/03/12 11:35, Jason Wang wrote: > >>> On Tue, Mar 11, 2025 at 2:11 PM Akihiko Odaki > >>> wrote: > > On 2025/0

Re: [PATCH net-next v11 00/10] tun: Introduce virtio-net hashing feature

2025-03-17 Thread Lei Yang
QE tested this series of patches v11 under linux-next repo with virtio-net regression tests, everything works fine. Tested-by: Lei Yang On Tue, Mar 18, 2025 at 8:29 AM Jason Wang wrote: > > On Mon, Mar 17, 2025 at 6:58 PM Akihiko Odaki > wrote: > > > > virtio-net have two usage of hashes: one

Re: [PATCH v4] docs: clarify rules wrt tagging other people

2025-03-17 Thread Jonathan Corbet
Jonathan Corbet writes: > Sorry for being slow ... but also, I guess, for not communicating my > point very well. My concern wasn't about somebody not wanting to appear > in the repository at all; it was more with somebody not wanting their > tag in a specific patch where they had not offered it

Re: [PATCH net-next v11 00/10] tun: Introduce virtio-net hashing feature

2025-03-17 Thread Jason Wang
On Mon, Mar 17, 2025 at 6:58 PM Akihiko Odaki wrote: > > virtio-net have two usage of hashes: one is RSS and another is hash > reporting. Conventionally the hash calculation was done by the VMM. > However, computing the hash after the queue was chosen defeats the > purpose of RSS. > > Another appr

[PATCH net-next v11 01/10] virtio_net: Add functions for hashing

2025-03-17 Thread Akihiko Odaki
They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki Tested-by: Lei Yang --- include/linux/virtio_net.h | 188 + 1 file changed, 188 insertions(+) diff --git a/include/linux/virtio_net.h b/include/l

[PATCH net-next v11 09/10] selftest: tap: Add tests for virtio-net ioctls

2025-03-17 Thread Akihiko Odaki
They only test the ioctls are wired up to the implementation common with tun as it is already tested for tun. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/tap.c | 97 ++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/tools/test

[PATCH net-next v11 05/10] tun: Introduce virtio-net hash feature

2025-03-17 Thread Akihiko Odaki
Add ioctls and storage required for the virtio-net hash feature to TUN. Signed-off-by: Akihiko Odaki --- drivers/net/Kconfig| 1 + drivers/net/tun.c | 54 ++ include/linux/skbuff.h | 3 +++ net/core/skbuff.c | 4 4 files chang

[PATCH net-next v11 00/10] tun: Introduce virtio-net hashing feature

2025-03-17 Thread Akihiko Odaki
virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen defeats the purpose of RSS. Another approach is to use eBPF steering program. This approach has another dow

[PATCH net-next v11 03/10] tun: Allow steering eBPF program to fall back

2025-03-17 Thread Akihiko Odaki
This clarifies a steering eBPF program takes precedence over the other steering algorithms. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 +++ drivers/net/tun.c | 28 +--- include/uapi/linux/if_tun.h | 9 +

[PATCH net-next v11 02/10] net: flow_dissector: Export flow_keys_dissector_symmetric

2025-03-17 Thread Akihiko Odaki
flow_keys_dissector_symmetric is useful to derive a symmetric hash and to know its source such as IPv4, IPv6, TCP, and UDP. Signed-off-by: Akihiko Odaki Tested-by: Lei Yang --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c| 3 ++- 2 files changed, 3 insertions(+), 1 deletion

[PATCH net-next v11 04/10] tun: Add common virtio-net hash feature code

2025-03-17 Thread Akihiko Odaki
Add common code required for the features being added to TUN and TAP. They will be enabled for each of them in following patches. Added Features == Hash reporting -- Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, an

[PATCH net-next v11 06/10] tap: Introduce virtio-net hash feature

2025-03-17 Thread Akihiko Odaki
Add ioctls and storage required for the virtio-net hash feature to TAP. Signed-off-by: Akihiko Odaki --- drivers/net/ipvlan/ipvtap.c | 2 +- drivers/net/macvtap.c | 2 +- drivers/net/tap.c | 70 + include/linux/if_tap.h | 4 ++-

[PATCH net-next v11 08/10] selftest: tun: Add tests for virtio-net hashing

2025-03-17 Thread Akihiko Odaki
The added tests confirm tun can perform RSS for all supported hash types to select the receive queue and report hash values. Signed-off-by: Akihiko Odaki Tested-by: Lei Yang --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c| 455 +++

[PATCH net-next v11 10/10] vhost/net: Support VIRTIO_NET_F_HASH_REPORT

2025-03-17 Thread Akihiko Odaki
VIRTIO_NET_F_HASH_REPORT allows to report hash values calculated on the host. When VHOST_NET_F_VIRTIO_NET_HDR is employed, it will report no hash values (i.e., the hash_report member is always set to VIRTIO_NET_HASH_REPORT_NONE). Otherwise, the values reported by the underlying socket will be repor

[PATCH net-next v11 07/10] selftest: tun: Test vnet ioctls without device

2025-03-17 Thread Akihiko Odaki
Ensure that vnet ioctls result in EBADFD when the underlying device is deleted. Signed-off-by: Akihiko Odaki Tested-by: Lei Yang --- tools/testing/selftests/net/tun.c | 38 ++ 1 file changed, 38 insertions(+) diff --git a/tools/testing/selftests/net/tun.c b

Re: [PATCH net-next v9 3/6] tun: Introduce virtio-net hash feature

2025-03-17 Thread Akihiko Odaki
On 2025/03/17 10:12, Jason Wang wrote: On Wed, Mar 12, 2025 at 1:03 PM Akihiko Odaki wrote: On 2025/03/12 11:35, Jason Wang wrote: On Tue, Mar 11, 2025 at 2:11 PM Akihiko Odaki wrote: On 2025/03/11 9:38, Jason Wang wrote: On Mon, Mar 10, 2025 at 3:45 PM Akihiko Odaki wrote: On 2025/03/

Re: [PATCH net-next v10 06/10] tap: Introduce virtio-net hash feature

2025-03-17 Thread Paolo Abeni
On 3/13/25 8:01 AM, Akihiko Odaki wrote: > @@ -998,6 +1044,16 @@ static long tap_ioctl(struct file *file, unsigned int > cmd, > rtnl_unlock(); > return ret; > > + case TUNGETVNETHASHCAP: > + return tun_vnet_ioctl_gethashcap(argp); > + > + case TUNS

Re: [PATCH v4 1/2] compiler_types: Introduce __flex_counter() and family

2025-03-17 Thread Przemek Kitszel
On 3/15/25 04:15, Kees Cook wrote: Introduce __flex_counter() which wraps __builtin_counted_by_ref(), as newly introduced by GCC[1] and Clang[2]. Use of __flex_counter() allows access to the counter member of a struct's flexible array member when it has been annotated with __counted_by(). Introd

Re: [PATCH v4 1/2] compiler_types: Introduce __flex_counter() and family

2025-03-17 Thread Przemek Kitszel
On 3/17/25 10:26, Przemek Kitszel wrote: On 3/15/25 04:15, Kees Cook wrote: Introduce __flex_counter() which wraps __builtin_counted_by_ref(), as newly introduced by GCC[1] and Clang[2]. Use of __flex_counter() allows access to the counter member of a struct's flexible array member when it has b