Re: [PATCH] hw/i386: fix short-circuit logic with non-optimizing builds

2023-11-18 Thread Michael S. Tsirkin
On Sat, Nov 18, 2023 at 10:25:31AM -0800, Daniel Hoffman wrote: > `kvm_enabled()` is compiled down to `0` and short-circuit logic is > used to remmove references to undefined symbols at the compile stage. > Some build configurations with some compilers don't attempt to > simplify this logic down in

[PATCH] hw/timer/hpet: Convert DPRINTF to trace events

2023-11-18 Thread Daniel Hoffman
This conversion is pretty straight-forward. Standardized some formatting so the +0 and +4 offset cases can recycle the same message. Signed-off-by: Daniel Hoffman --- hw/timer/hpet.c | 55 +-- hw/timer/trace-events | 16 + 2 files changed

[PATCH] hw/i386: fix short-circuit logic with non-optimizing builds

2023-11-18 Thread Daniel Hoffman
`kvm_enabled()` is compiled down to `0` and short-circuit logic is used to remmove references to undefined symbols at the compile stage. Some build configurations with some compilers don't attempt to simplify this logic down in some cases (the pattern appears to be that the literal false must be th

Re: [PATCH for-8.2] target/arm: Fix SME FMOPA (16-bit), BFMOPA

2023-11-18 Thread Philippe Mathieu-Daudé
On 17/11/23 20:31, Richard Henderson wrote: Perform the loop increment unconditionally, not nested within the predication. Cc: qemu-sta...@nongnu.org Fixes: 3916841ac75 ("target/arm: Implement FMOPA, FMOPS (widening)") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1985 Signed-off-by: R

[v2 1/2] qapi/virtio: Add feature and status bits for x-query-virtio-status

2023-11-18 Thread Hyman Huang
This patch allows to display feature and status bits in virtio-status. Applications could find it helpful to compare status and features that are numeric encoded. For example, an upper application could use the features (encoded as a number) in the output of "ovs-vsctl list interface" and the feat

[v2 2/2] vhost-user-test: Add negotiated features check

2023-11-18 Thread Hyman Huang
When a vhost-user network device is restored from an unexpected failure, the acked_features could be used as input for the VHOST_USER_SET_FEATURES command because QEMU internally backups the final features as acked_features after the guest acknowledges features during virtio-net driver initializati

[v2 0/2] vhost-user-test: Add negotiated features check

2023-11-18 Thread Hyman Huang
Markus made suggestions for the changes to version 2, and thanks for that as well. v2: - rebase on master. - drop the "show-bits" option. - refine the comment. v1: The patchset "Fix the virtio features negotiation flaw" fix a vhost-user negotiation flaw: c9bdc449f9 vhost-user: Fix the virtio fe

[RFC] Flexible SR-IOV support for virtio-net

2023-11-18 Thread Akihiko Odaki
Hi, We are planning to add PCIe SR-IOV support to the virtio-net driver for Windows ("NetKVM")[1], and we want a SR-IOV feature for virtio-net emulation code in QEMU to test it. I expect there are other people interested in such a feature, considering that people are using igb[2] to test SR-I

[PATCH RESEND v7 05/19] tap: Call tap_receive_iov() from tap_receive()

2023-11-18 Thread Akihiko Odaki
From: Akihiko Odaki This will save duplicate logic found in both of tap_receive_iov() and tap_receive(). Suggested-by: "Zhang, Chen" Signed-off-by: Akihiko Odaki --- net/tap.c | 35 +-- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/net/tap.c b/

[PATCH RESEND v7 18/19] ebpf: Refactor tun_rss_steering_prog()

2023-11-18 Thread Akihiko Odaki
This saves branches and makes later BPF program changes easier. Signed-off-by: Akihiko Odaki --- tools/ebpf/rss.bpf.c | 26 +++--- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c index 22c75d5912..012af38df1 100644 -

[PATCH RESEND v7 06/19] tap: Shrink zeroed virtio-net header

2023-11-18 Thread Akihiko Odaki
tap prepends a zeroed virtio-net header when writing a packet to a tap with virtio-net header enabled but not in use. This only happens when s->host_vnet_hdr_len == sizeof(struct virtio_net_hdr). Signed-off-by: Akihiko Odaki --- net/tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) di

[PATCH RESEND v7 19/19] ebpf: Add a separate target for skeleton

2023-11-18 Thread Akihiko Odaki
This generalizes the rule to generate the skeleton and allows to add another. Signed-off-by: Akihiko Odaki --- tools/ebpf/Makefile.ebpf | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/ebpf/Makefile.ebpf b/tools/ebpf/Makefile.ebpf index 3391e7ce08..572ca5

[PATCH RESEND v7 11/19] virtio-net: Report RSS warning at device realization

2023-11-18 Thread Akihiko Odaki
From: Akihiko Odaki Warning about RSS fallback at device realization allows the user to notice the configuration problem early. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/net/virtio-net.

[PATCH RESEND v7 03/19] net: Move virtio-net header length assertion

2023-11-18 Thread Akihiko Odaki
The virtio-net header length assertion should happen for any clients. Signed-off-by: Akihiko Odaki --- net/net.c | 5 + net/tap.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/net/net.c b/net/net.c index f603030dd6..2e7c3fcc2a 100644 --- a/net/net.c +++ b/net/net.c

[PATCH RESEND v7 14/19] ebpf: Fix RSS error handling

2023-11-18 Thread Akihiko Odaki
calculate_rss_hash() was using hash value 0 to tell if it calculated a hash, but the hash value may be 0 on a rare occasion. Have a distinct bool value for correctness. Fixes: f3fa412de2 ("ebpf: Added eBPF RSS program.") Signed-off-by: Akihiko Odaki --- tools/ebpf/rss.bpf.c | 20 +++-

[PATCH RESEND v7 15/19] ebpf: Use standard section name

2023-11-18 Thread Akihiko Odaki
It makes easier to play with bpftool by allowing it to infer the program type. It also makes it unnecessary to set the program type manually when loading the program in ebpf_rss_load(). Signed-off-by: Akihiko Odaki --- ebpf/rss.bpf.skeleton.h | 1514 --- ebpf/

[PATCH RESEND v7 09/19] virtio-net: Unify the logic to update NIC state for RSS

2023-11-18 Thread Akihiko Odaki
The code to attach or detach the eBPF program to RSS were duplicated so unify them into one function to save some code. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 90 ++--- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/hw/net/

[PATCH RESEND v7 13/19] virtio-net: Do not write hashes to peer buffer

2023-11-18 Thread Akihiko Odaki
The peer buffer is qualified with const and not meant to be modified. It also prevents enabling VIRTIO_NET_F_HASH_REPORT for peers without virtio-net header support. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 36 +--- 1 file changed, 17 insertions(+),

[PATCH RESEND v7 01/19] tap: Remove tap_probe_vnet_hdr_len()

2023-11-18 Thread Akihiko Odaki
It was necessary since an Linux older than 2.6.35 may implement the virtio-net header but may not allow to change its length. Remove it since such an old Linux is no longer supported. Signed-off-by: Akihiko Odaki Acked-by: Michael S. Tsirkin --- net/tap_int.h | 1 - net/tap-bsd.c | 5

[PATCH RESEND v7 10/19] virtio-net: Return an error when vhost cannot enable RSS

2023-11-18 Thread Akihiko Odaki
vhost requires eBPF for RSS. When eBPF is not available, virtio-net implicitly disables RSS even if the user explicitly requests it. Return an error instead of implicitly disabling RSS if RSS is requested but not available. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 98 ++

[PATCH RESEND v7 17/19] ebpf: Return 0 when configuration fails

2023-11-18 Thread Akihiko Odaki
The kernel interprets the returned value as an unsigned 32-bit so -1 will mean queue 4294967295, which is awkward. Return 0 instead. Signed-off-by: Akihiko Odaki --- ebpf/rss.bpf.skeleton.h | 1339 +++ tools/ebpf/rss.bpf.c|2 +- 2 files changed, 670 in

[PATCH RESEND v7 04/19] net: Remove receive_raw()

2023-11-18 Thread Akihiko Odaki
While netmap implements virtio-net header, it does not implement receive_raw(). Instead of implementing receive_raw for netmap, add virtio-net headers in the common code and use receive_iov()/receive() instead. This also fixes the buffer size for the virtio-net header. Fixes: fbbdbddec0 ("tap: all

[PATCH RESEND v7 08/19] virtio-net: Disable RSS on reset

2023-11-18 Thread Akihiko Odaki
RSS is disabled by default. Fixes: 590790297c ("virtio-net: implement RSS configuration command") Signed-off-by: Akihiko Odaki Reviewed-by: Michael Tokarev --- hw/net/virtio-net.c | 70 +++-- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a

[PATCH RESEND v7 16/19] ebpf: Simplify error handling

2023-11-18 Thread Akihiko Odaki
The error handling procedures required when rss_bpf__open() and rss_bpf__load(rss_bpf_ctx) are different so it's better to implement them separately. Signed-off-by: Akihiko Odaki --- ebpf/ebpf_rss.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ebpf/ebpf_rss.c b/

[PATCH RESEND v7 12/19] virtio-net: Always set populate_hash

2023-11-18 Thread Akihiko Odaki
The member is not cleared during reset so may have a stale value. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 40beff2262..eed5a9bc46 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-n

[PATCH RESEND v7 07/19] virtio-net: Copy header only when necessary

2023-11-18 Thread Akihiko Odaki
It is necessary to copy the header only for byte swapping. Worse, when byte swapping is not needed, the header can be larger than the buffer due to VIRTIO_NET_F_HASH_REPORT, which results in buffer overflow. Copy the header only when byte swapping is needed. Fixes: e22f0603fb ("virtio-net: refere

[PATCH RESEND v7 02/19] tap: Remove qemu_using_vnet_hdr()

2023-11-18 Thread Akihiko Odaki
Since qemu_set_vnet_hdr_len() is always called when qemu_using_vnet_hdr() is called, we can merge them and save some code. For consistency, express that the virtio-net header is not in use by returning 0 with qemu_get_vnet_hdr_len() instead of having a dedicated function, qemu_get_using_vnet_hdr()

[PATCH RESEND v7 00/19] virtio-net RSS/hash report fixes and improvements

2023-11-18 Thread Akihiko Odaki
Based-on: <20230524064704.47711-1-akihiko.od...@daynix.com> ("[PATCH 0/2] net: Update MemReentrancyGuard for NIC") This series contains fixes and improvements for virtio-net RSS and hash reporting feature. V6 -> V7: Dropped patch "virtio-net: Do not clear VIRTIO_NET_F_HASH_REPORT". Dropped th

[PATCH v7 01/19] tap: Remove tap_probe_vnet_hdr_len()

2023-11-18 Thread Akihiko Odaki
It was necessary since an Linux older than 2.6.35 may implement the virtio-net header but may not allow to change its length. Remove it since such an old Linux is no longer supported. Signed-off-by: Akihiko Odaki Acked-by: Michael S. Tsirkin --- net/tap_int.h | 1 - net/tap-bsd.c | 5

[PATCH v7 03/19] net: Move virtio-net header length assertion

2023-11-18 Thread Akihiko Odaki
The virtio-net header length assertion should happen for any clients. Signed-off-by: Akihiko Odaki --- net/net.c | 5 + net/tap.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/net/net.c b/net/net.c index f603030dd6..2e7c3fcc2a 100644 --- a/net/net.c +++ b/net/net.c

[PATCH v7 00/19] virtio-net RSS/hash report fixes and improvements

2023-11-18 Thread Akihiko Odaki
Based-on: <20230524064704.47711-1-akihiko.od...@daynix.com> ("[PATCH 0/2] net: Update MemReentrancyGuard for NIC") This series contains fixes and improvements for virtio-net RSS and hash reporting feature. V6 -> V7: Dropped patch "virtio-net: Do not clear VIRTIO_NET_F_HASH_REPORT". Dropped th

[PATCH v7 02/19] tap: Remove qemu_using_vnet_hdr()

2023-11-18 Thread Akihiko Odaki
Since qemu_set_vnet_hdr_len() is always called when qemu_using_vnet_hdr() is called, we can merge them and save some code. For consistency, express that the virtio-net header is not in use by returning 0 with qemu_get_vnet_hdr_len() instead of having a dedicated function, qemu_get_using_vnet_hdr()

[PATCH v7 04/19] net: Remove receive_raw()

2023-11-18 Thread Akihiko Odaki
While netmap implements virtio-net header, it does not implement receive_raw(). Instead of implementing receive_raw for netmap, add virtio-net headers in the common code and use receive_iov()/receive() instead. This also fixes the buffer size for the virtio-net header. Fixes: fbbdbddec0 ("tap: all