Re: [PATCH-for-9.0 3/4] hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs

2024-04-08 Thread Philippe Mathieu-Daudé
On 4/4/24 21:13, Philippe Mathieu-Daudé wrote: Replace qemu_bh_new_guarded() by virtio_bh_new_guarded() so the bus and device use the same guard. Otherwise the DMA-reentrancy protection can be bypassed. Cc: qemu-sta...@nongnu.org Suggested-by: Alexander Bulekov Signed-off-by: Philippe Mathieu-D

Re: [PATCH 1/1] virtio-net: fix bug 1451 aka "assert(!virtio_net_get_subqueue(nc)->async_tx.elem); "

2024-04-08 Thread Jason Wang
On Fri, Apr 5, 2024 at 7:22 PM Alexey Dobriyan wrote: > > Don't send zero length packets in virtio_net_flush_tx(). > > Reproducer from https://gitlab.com/qemu-project/qemu/-/issues/1451 > creates small packet (1 segment, len = 10 == n->guest_hdr_len), > destroys queue. > > "if (n->host_hdr_len !=

Re: [PATCH] hw/virtio: Add support for VDPA network simulation devices

2024-04-08 Thread Jason Wang
On Mon, Mar 18, 2024 at 8:41 PM Michael S. Tsirkin wrote: > > On Thu, Mar 14, 2024 at 11:24:33AM +0800, Jason Wang wrote: > > On Thu, Mar 14, 2024 at 3:52 AM Michael S. Tsirkin wrote: > > > > > > On Wed, Mar 13, 2024 at 07:51:08PM +0100, Thomas Weißschuh wrote: > > > > On 2024-02-21 15:38:02+0800

[PATCH v2] vhost: don't set vring call if guest notifiers is not enabled

2024-04-08 Thread lyx634449800
When conducting performance testing using testpmd in the guest os, it was observed that the performance was lower compared to the scenario of direct vfio-pci usage. In the commit 96a3d98d2cdbd897ff5ab33427aa4cfb94077665, the author provided a good solution. However, because the guest OS's driver(e

Re: [PATCH-for-9.0 0/4] hw/virtio: Protect from more DMA re-entrancy bugs

2024-04-08 Thread Mauro Matteo Cascella
Hi, On Thu, Apr 4, 2024 at 9:13 PM Philippe Mathieu-Daudé wrote: > > Gerd suggested to use the transport guard to protect the > device from DMA re-entrancy abuses. This was assigned CVE-2024-3446. > Philippe Mathieu-Daudé (4): > hw/virtio: Introduce virtio_bh_new_guarded() helper > hw/displ

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Yuri Benditovich
On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki wrote: > > On 2024/04/08 7:09, Yuri Benditovich wrote: > > On Wed, Apr 3, 2024 at 2:12 PM Akihiko Odaki > > wrote: > >> > >> The peer buffer is qualified with const and not meant to be modified. > > > > IMHO, this buffer is not so 'const' (although th

Re: [PATCH for-9.1 v3 08/11] contrib/vhost-user-blk: enable it on any POSIX system

2024-04-08 Thread Stefano Garzarella
On Thu, Apr 04, 2024 at 04:00:38PM +0200, Philippe Mathieu-Daudé wrote: Hi Stefano, Hi Phil! On 4/4/24 14:23, Stefano Garzarella wrote: Let's make the code more portable by using the "qemu/bswap.h" API and adding defines from block/file-posix.c to support O_DIRECT in other systems (e.g. mac

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Akihiko Odaki
On 2024/04/08 16:40, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki wrote: On 2024/04/08 7:09, Yuri Benditovich wrote: On Wed, Apr 3, 2024 at 2:12 PM Akihiko Odaki wrote: The peer buffer is qualified with const and not meant to be modified. IMHO, this buffer is not

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Yuri Benditovich
On Mon, Apr 8, 2024 at 10:42 AM Akihiko Odaki wrote: > > On 2024/04/08 16:40, Yuri Benditovich wrote: > > On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki > > wrote: > >> > >> On 2024/04/08 7:09, Yuri Benditovich wrote: > >>> On Wed, Apr 3, 2024 at 2:12 PM Akihiko Odaki > >>> wrote: > >

Re: [PATCH-for-9.0] hw/sd/sdhci: Discard excess of data written to Buffer Data Port register

2024-04-08 Thread Mauro Matteo Cascella
On Thu, Apr 4, 2024 at 10:55 AM Philippe Mathieu-Daudé wrote: > > Per "SD Host Controller Standard Specification Version 3.00": > > * 1.7 Buffer Control > > - 1.7.1 Control of Buffer Pointer > > (3) Buffer Control with Block Size > > In case of write operation, the buffer accumulates t

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Akihiko Odaki
On 2024/04/08 16:54, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 10:42 AM Akihiko Odaki wrote: On 2024/04/08 16:40, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki wrote: On 2024/04/08 7:09, Yuri Benditovich wrote: On Wed, Apr 3, 2024 at 2:12 PM Akihiko Odaki wrot

Re: [PATCH for-9.1 v3 09/11] hostmem: add a new memory backend based on POSIX shm_open()

2024-04-08 Thread Stefano Garzarella
On Thu, Apr 04, 2024 at 04:09:34PM +0200, David Hildenbrand wrote: On 04.04.24 14:23, Stefano Garzarella wrote: shm_open() creates and opens a new POSIX shared memory object. A POSIX shared memory object allows creating memory backend with an associated file descriptor that can be shared with ex

Re: [PATCH for-9.1 v3 00/11] vhost-user: support any POSIX system (tested on macOS, FreeBSD, OpenBSD)

2024-04-08 Thread Stefano Garzarella
FYI I'll be on PTO till May 2nd, I'll send the v4 when I'm back ASAP. Thanks, Stefano On Thu, Apr 04, 2024 at 02:23:19PM +0200, Stefano Garzarella wrote: v1: https://patchew.org/QEMU/20240228114759.44758-1-sgarz...@redhat.com/ v2: https://patchew.org/QEMU/20240326133936.125332-1-sgarz...@redhat

Re: [PATCH for-9.1 v3 09/11] hostmem: add a new memory backend based on POSIX shm_open()

2024-04-08 Thread David Hildenbrand
On 08.04.24 09:58, Stefano Garzarella wrote: On Thu, Apr 04, 2024 at 04:09:34PM +0200, David Hildenbrand wrote: On 04.04.24 14:23, Stefano Garzarella wrote: shm_open() creates and opens a new POSIX shared memory object. A POSIX shared memory object allows creating memory backend with an associa

Re: [PATCH] Makefile: preserve --jobserver-auth argument when calling ninja

2024-04-08 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Yuri Benditovich
On Mon, Apr 8, 2024 at 10:57 AM Akihiko Odaki wrote: > > On 2024/04/08 16:54, Yuri Benditovich wrote: > > On Mon, Apr 8, 2024 at 10:42 AM Akihiko Odaki > > wrote: > >> > >> On 2024/04/08 16:40, Yuri Benditovich wrote: > >>> On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki > >>> wrote: > > >>>

Re: [PATCH v9 16/20] virtio-net: Do not write hashes to peer buffer

2024-04-08 Thread Akihiko Odaki
On 2024/04/08 17:06, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 10:57 AM Akihiko Odaki wrote: On 2024/04/08 16:54, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 10:42 AM Akihiko Odaki wrote: On 2024/04/08 16:40, Yuri Benditovich wrote: On Mon, Apr 8, 2024 at 4:30 AM Akihiko Odaki wr

Re: [PATCH for-9.1 v3 09/11] hostmem: add a new memory backend based on POSIX shm_open()

2024-04-08 Thread Stefano Garzarella
On Mon, Apr 08, 2024 at 10:03:15AM +0200, David Hildenbrand wrote: On 08.04.24 09:58, Stefano Garzarella wrote: On Thu, Apr 04, 2024 at 04:09:34PM +0200, David Hildenbrand wrote: On 04.04.24 14:23, Stefano Garzarella wrote: shm_open() creates and opens a new POSIX shared memory object. A POSIX

[PATCH v2 00/10] Add a host IOMMU device abstraction

2024-04-08 Thread Zhenzhong Duan
Based on Joao's suggestion, the iommufd nesting prerequisite series [1] is further splitted to host IOMMU device abstract part and vIOMMU check part. This series implements the 1st part. This split also faciliates the dirty tracking series [2] and virtio-iommu series [3] to depend on 1st part. Th

[PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device

2024-04-08 Thread Zhenzhong Duan
HIODIOMMUFD represents a host IOMMU device under iommufd backend. Currently it includes only public iommufd handle and device id. which could be used to get hw IOMMU information. When nested translation is supported in future, vIOMMU is going to have iommufd related operations like attaching/deta

[PATCH v2 04/10] vfio/iommufd: Introduce HIODIOMMUFDVFIO device

2024-04-08 Thread Zhenzhong Duan
HIODIOMMUFDVFIO represents a host IOMMU device under VFIO iommufd backend. It will be created during VFIO device attaching and passed to vIOMMU. It includes a link to VFIODevice so that we can do VFIO device specific hwpt attaching/detaching. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vf

[PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd_backend_get_device_info()

2024-04-08 Thread Zhenzhong Duan
Introduce a helper function iommufd_backend_get_device_info() to get host IOMMU related information through iommufd uAPI. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 4 backends/iommufd.c | 23 ++- 2 f

[PATCH v2 02/10] vfio: Introduce HIODLegacyVFIO device

2024-04-08 Thread Zhenzhong Duan
HIODLegacyVFIO represents a host IOMMU device under VFIO legacy container backend. It includes a link to VFIODevice. Suggested-by: Eric Auger Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 11 +++ hw/vfio/container.c | 11 +++

[PATCH v2 10/10] vfio: Pass HostIOMMUDevice to vIOMMU

2024-04-08 Thread Zhenzhong Duan
With HostIOMMUDevice passed, vIOMMU can check compatibility with host IOMMU, call into IOMMUFD specific methods, etc. Originally-by: Yi Liu Signed-off-by: Nicolin Chen Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 20 +++- 1 file changed, 15 insertion

[PATCH v2 07/10] backends/iommufd: Implement get_host_iommu_info() callback

2024-04-08 Thread Zhenzhong Duan
It calls iommufd_backend_get_device_info() to get host IOMMU related information. Define a common structure HIOD_IOMMUFD_INFO to describe the info returned from kernel. Currently only vtd, but easy to add arm smmu when kernel supports. Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h

[PATCH v2 01/10] backends: Introduce abstract HostIOMMUDevice

2024-04-08 Thread Zhenzhong Duan
Introduce HostIOMMUDevice as an abstraction of host IOMMU device. get_host_iommu_info() is used to get host IOMMU info, different backends can have different implementations and result format. Introduce a macro CONFIG_HOST_IOMMU_DEVICE to define the usage for VFIO, and VDPA in the future. Sugges

[PATCH v2 05/10] vfio: Implement get_host_iommu_info() callback

2024-04-08 Thread Zhenzhong Duan
Utilize iova_ranges to calculate host IOMMU address width and package it in HIOD_LEGACY_INFO for vIOMMU usage. HIOD_LEGACY_INFO will be used by both VFIO and VDPA so declare it in host_iommu_device.h. Signed-off-by: Zhenzhong Duan --- include/sysemu/host_iommu_device.h | 10 ++ hw/vfio/

[PATCH v2 08/10] vfio: Create host IOMMU device instance

2024-04-08 Thread Zhenzhong Duan
Create host IOMMU device instance and initialize it based on backend. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/container.c | 5 + hw/vfio/iommufd.c | 8 3 files changed, 14 insertions(+) diff --git a/include/hw/vfio/vfio-c

[PATCH v2 09/10] hw/pci: Introduce pci_device_set/unset_iommu_device()

2024-04-08 Thread Zhenzhong Duan
From: Yi Liu This adds pci_device_set/unset_iommu_device() to set/unset HostIOMMUDevice for a given PCI device. Caller of set should fail if set operation fails. Extract out pci_device_get_iommu_bus_devfn() to facilitate implementation of pci_device_set/unset_iommu_device(). Signed-off-by: Yi L

[PATCH-for-9.0? 2/3] hw/block/nand: Have blk_load() return boolean indicating success

2024-04-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé --- hw/block/nand.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index 6fa9038bb5..3627c799b5 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -84,7 +84,11 @@ struct NANDFlashState {

[PATCH-for-9.0? 0/3] hw/block/nand: Fix out-of-bound access in NAND block buffer

2024-04-08 Thread Philippe Mathieu-Daudé
Fix for https://gitlab.com/qemu-project/qemu/-/issues/1446 Philippe Mathieu-Daudé (3): hw/block/nand: Factor nand_load_iolen() method out hw/block/nand: Have blk_load() return boolean indicating success hw/block/nand: Fix out-of-bound access in NAND block buffer hw/block/nand.c | 50 ++

[PATCH-for-9.0? 3/3] hw/block/nand: Fix out-of-bound access in NAND block buffer

2024-04-08 Thread Philippe Mathieu-Daudé
nand_command() and nand_getio() don't check @offset points into the block, nor the available data length (s->iolen) is not negative. In order to fix: - check the offset is in range in nand_blk_load_NAND_PAGE_SIZE(), - do not set @iolen if blk_load() failed. Reproducer: $ cat << EOF | qemu-sys

[PATCH-for-9.0? 1/3] hw/block/nand: Factor nand_load_iolen() method out

2024-04-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé --- hw/block/nand.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index d1435f2207..6fa9038bb5 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -243,9 +243,25 @@ s

Re: [PATCH-for-9.0? 3/3] hw/block/nand: Fix out-of-bound access in NAND block buffer

2024-04-08 Thread Philippe Mathieu-Daudé
On 8/4/24 10:36, Philippe Mathieu-Daudé wrote: nand_command() and nand_getio() don't check @offset points into the block, nor the available data length (s->iolen) is not negative. In order to fix: - check the offset is in range in nand_blk_load_NAND_PAGE_SIZE(), - do not set @iolen if blk_load(

[PATCH v2 4/5] intel_iommu: Check for compatibility with legacy device

2024-04-08 Thread Zhenzhong Duan
Currently only stage-2 translation is supported which is backed by shadow page table on host side. So we don't need exact matching of each bit of cap/ecap between vIOMMU and host. However, we can still ensure compatibility of host and vIOMMU's address width at least, i.e., vIOMMU's aw-bits <= host

[PATCH v2 0/5] Check host IOMMU compatilibity with vIOMMU

2024-04-08 Thread Zhenzhong Duan
Hi, Based on Joao's suggestion, the iommufd nesting prerequisite series [1] is further splitted to host IOMMU device abstract part [2] and vIOMMU check part. This series implements the 2nd part. 1st part implements get_host_iommu_info() callback which vIOMMU can call to get host IOMMU info. For l

[PATCH v2 1/5] intel_iommu: Extract out vtd_cap_init() to initialize cap/ecap

2024-04-08 Thread Zhenzhong Duan
Extract cap/ecap initialization in vtd_cap_init() to make code cleaner. No functional change intended. Reviewed-by: Eric Auger Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 93 --- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git

[PATCH v2 2/5] intel_iommu: Implement set/unset_iommu_device() callback

2024-04-08 Thread Zhenzhong Duan
From: Yi Liu Implement set/unset_iommu_device() callback in Intel vIOMMU. In set call, a new structure VTDHostIOMMUDevice which holds a reference to HostIOMMUDevice is stored in hash table indexed by PCI BDF. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i3

[PATCH v2 3/5] intel_iommu: Add a framework to do compatibility check with host IOMMU cap/ecap

2024-04-08 Thread Zhenzhong Duan
From: Yi Liu If check fails, the host side device(either vfio or vdpa device) should not be passed to guest. Implementation details for different backends will be in following patches. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 35 +

[PATCH v2 5/5] intel_iommu: Check for compatibility with iommufd backed device

2024-04-08 Thread Zhenzhong Duan
Currently only stage-2 translation is supported which is backed by shadow page table on host side. So we don't need exact matching of each bit of cap/ecap between vIOMMU and host. However, we can still ensure compatibility of host and vIOMMU's address width at least, i.e., vIOMMU's aw-bits <= host

Re: [PATCH v4] nbd/server: do not poll within a coroutine context

2024-04-08 Thread Vladimir Sementsov-Ogievskiy
On 05.04.24 20:44, Eric Blake wrote: From: Zhu Yangyang Coroutines are not supposed to block. Instead, they should yield. The client performs TLS upgrade outside of an AIOContext, during synchronous handshake; this still requires g_main_loop. But the server responds to TLS upgrade inside a co

Re: [PATCH-for-9.1 2/7] yank: Restrict to system emulation

2024-04-08 Thread Paolo Bonzini
On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé wrote: > > The yank feature is not used in user emulation. But it is used in block layer tools. The simplest thing here is probably to move it under have_block instead. Paolo > Signed-off-by: Philippe Mathieu-Daudé > --- > util/meson.build

Re: [PATCH-for-9.1 4/7] util/qemu-config: Extract QMP commands to qemu-config-qmp.c

2024-04-08 Thread Paolo Bonzini
On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé wrote: > > QMP is irrelevant for user emulation. Extract the code > related to QMP in a different source file, which won't > be build for user emulation binaries. This avoid pulling > pointless code. > > Signed-off-by: Philippe Mathieu-Daudé >

Re: [PATCH v2] sh4: mac.w: implement saturation arithmetic logic

2024-04-08 Thread Yoshinori Sato
On Sat, 06 Apr 2024 08:38:04 +0900, Zack Buhman wrote: > > The saturation arithmetic logic in helper_macw is not correct. > > I tested and verified this behavior on a SH7091, the general pattern > is a code sequence such as: > > sets > > mov.l _mach,r2 > lds r2,mach > mo

Re: [PATCH 30/32] target/rx: Use translator_ld*

2024-04-08 Thread Yoshinori Sato
On Fri, 05 Apr 2024 19:24:57 +0900, Richard Henderson wrote: > > Cc: Yoshinori Sato > Signed-off-by: Richard Henderson > --- > target/rx/translate.c | 27 ++- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/target/rx/translate.c b/target/rx/translat

Re: [PATCH] target/sh4: add missing CHECK_NOT_DELAY_SLOT

2024-04-08 Thread Yoshinori Sato
On Mon, 08 Apr 2024 00:07:05 +0900, Zack Buhman wrote: > > CHECK_NOT_DELAY_SLOT is correctly applied to the branch-related > instructions, but not to the PC-relative mov* instructions. > > I verified the existence of an illegal slot exception on a SH7091 when > any of these instructions are attem

Re: [PATCH] hcd-ohci: Fix inconsistency when resetting ohci root hubs

2024-04-08 Thread Philippe Mathieu-Daudé
On 30/8/22 05:30, Qiang Liu wrote: I found an assertion failure in usb_cancel_packet() and posted my analysis in https://gitlab.com/qemu-project/qemu/-/issues/1180. I think this issue is because the inconsistency when resetting ohci root hubs. There are two ways to reset ohci root hubs: 1) throu

Re: [PATCH] target/i386: fix direction of "32-bit MMU" test

2024-04-08 Thread Philippe Mathieu-Daudé
On 5/4/24 19:30, Michael Tokarev wrote: 01.04.2024 09:02, Michael Tokarev: Anyone can guess why this rather trivial and obviously correct patch causes segfaults in a few tests in staging-7.2 - when run in tcg mode, namely:    pxe-test    migration-test    boot-serial-test    bios-tables-test

[PATCH] Revert "hw/virtio: Add support for VDPA network simulation devices"

2024-04-08 Thread Michael S. Tsirkin
This reverts commit cd341fd1ffded978b2aa0b5309b00be7c42e347c. The patch adds non-upstream code in include/standard-headers/linux/virtio_pci.h which would make maintainance harder. Revert for now. Suggested-by: Jason Wang Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-pci.h

Re: [PATCH-for-9.1 3/7] monitor: Rework stubs to simplify user emulation linking

2024-04-08 Thread Paolo Bonzini
On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé wrote: > > Currently monitor stubs are scattered in 3 files. > > Merge these stubs in 2 files, a generic one (monitor-core) > included in all builds (in particular user emulation), and > a less generic one to be included by tools and system emu

Re: [PATCH] Revert "hw/virtio: Add support for VDPA network simulation devices"

2024-04-08 Thread Peter Maydell
On Mon, 8 Apr 2024 at 10:48, Michael S. Tsirkin wrote: > > This reverts commit cd341fd1ffded978b2aa0b5309b00be7c42e347c. > > The patch adds non-upstream code in > include/standard-headers/linux/virtio_pci.h > which would make maintainance harder. > > Revert for now. > > Suggested-by: Jason Wang >

[PATCH-for-9.0? 1/2] hw/misc/applesmc: Do not call DeviceReset() from DeviceRealize()

2024-04-08 Thread Philippe Mathieu-Daudé
QDev core layer always call DeviceReset() after DeviceRealize(), no need to do it manually. Remove the extra call. Signed-off-by: Philippe Mathieu-Daudé --- hw/misc/applesmc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 72300d0cbc..8e65816da6

[PATCH-for-9.0? 2/2] hw/misc/applesmc: Fix memory leak in reset() handler

2024-04-08 Thread Philippe Mathieu-Daudé
AppleSMCData is allocated with g_new0() in applesmc_add_key(): release it with g_free(). Leaked since commit 1ddda5cd36 ("AppleSMC device emulation"). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2272 Reported-by: Zheyu Ma Signed-off-by: Philippe Mathieu-Daudé --- hw/misc/applesmc.c

[PATCH-for-9.0? 0/2] hw/misc/applesmc: Fix memory leak

2024-04-08 Thread Philippe Mathieu-Daudé
Fix for https://gitlab.com/qemu-project/qemu/-/issues/2272 Philippe Mathieu-Daudé (2): hw/misc/applesmc: Do not call DeviceReset() from DeviceRealize() hw/misc/applesmc: Fix memory leak in reset() handler hw/misc/applesmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.41.0

Re: [PATCH] Revert "hw/virtio: Add support for VDPA network simulation devices"

2024-04-08 Thread Cornelia Huck
On Mon, Apr 08 2024, "Michael S. Tsirkin" wrote: > This reverts commit cd341fd1ffded978b2aa0b5309b00be7c42e347c. > > The patch adds non-upstream code in > include/standard-headers/linux/virtio_pci.h > which would make maintainance harder. > > Revert for now. > > Suggested-by: Jason Wang > Signed

Re: [PATCH-for-9.0 3/4] hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs

2024-04-08 Thread Michael S. Tsirkin
On Mon, Apr 08, 2024 at 09:14:39AM +0200, Philippe Mathieu-Daudé wrote: > On 4/4/24 21:13, Philippe Mathieu-Daudé wrote: > > Replace qemu_bh_new_guarded() by virtio_bh_new_guarded() > > so the bus and device use the same guard. Otherwise the > > DMA-reentrancy protection can be bypassed. > > > > C

Re: [PATCH-for-9.1 5/7] hw/core: Restrict reset handlers API to system emulation

2024-04-08 Thread Paolo Bonzini
On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé wrote: > > Headers in include/sysemu/ are specific to system > emulation and should not be used in user emulation. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/core/reset.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/

Re: [PATCH 1/2] virtio-net: Fix vhost virtqueue notifiers for RSS

2024-04-08 Thread Michael S. Tsirkin
On Tue, Mar 26, 2024 at 07:06:29PM +0900, Akihiko Odaki wrote: > virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask() > checked VIRTIO_NET_F_MQ to know there are multiple queues, but > VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue, > which is set to true

Re: [PATCH] Revert "hw/virtio: Add support for VDPA network simulation devices"

2024-04-08 Thread Michael S. Tsirkin
On Mon, Apr 08, 2024 at 10:51:57AM +0100, Peter Maydell wrote: > On Mon, 8 Apr 2024 at 10:48, Michael S. Tsirkin wrote: > > > > This reverts commit cd341fd1ffded978b2aa0b5309b00be7c42e347c. > > > > The patch adds non-upstream code in > > include/standard-headers/linux/virtio_pci.h > > which would

[PATCH-for-9.0?] hw/net/smc91c111: Fix out of bounds access in packets buffer

2024-04-08 Thread Philippe Mathieu-Daudé
While the Packet Number Register is 6-bit wide and could hold up to 64 packets [*] our implementation is clamped at 4 packets. Reproducer: $ cat << EOF | qemu-system-arm -display none \ -machine mainstone,accel=qtest \ -qtest std

Re: [PATCH-for-9.0?] hw/net/smc91c111: Fix out of bounds access in packets buffer

2024-04-08 Thread Philippe Mathieu-Daudé
On 8/4/24 12:27, Philippe Mathieu-Daudé wrote: While the Packet Number Register is 6-bit wide and could hold up to 64 packets [*] our implementation is clamped at 4 packets. Reproducer: $ cat << EOF | qemu-system-arm -display none \ -machine mainstone,accel=

Re: [PATCH-for-9.0? 1/2] hw/misc/applesmc: Do not call DeviceReset() from DeviceRealize()

2024-04-08 Thread Peter Maydell
On Mon, 8 Apr 2024 at 10:52, Philippe Mathieu-Daudé wrote: > > QDev core layer always call DeviceReset() after DeviceRealize(), > no need to do it manually. Remove the extra call. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/misc/applesmc.c | 1 - > 1 file changed, 1 deletion(-) > > diff

Re: [PATCH-for-9.0? 2/2] hw/misc/applesmc: Fix memory leak in reset() handler

2024-04-08 Thread Peter Maydell
On Mon, 8 Apr 2024 at 10:53, Philippe Mathieu-Daudé wrote: > > AppleSMCData is allocated with g_new0() in applesmc_add_key(): > release it with g_free(). > > Leaked since commit 1ddda5cd36 ("AppleSMC device emulation"). > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2272 > Reported-by

[PATCH-for-9.0? 0/2] hw/net/lan9118: Fix overflow in TX FIFO

2024-04-08 Thread Philippe Mathieu-Daudé
Fix for https://gitlab.com/qemu-project/qemu/-/issues/2267 Philippe Mathieu-Daudé (2): hw/net/lan9118: Replace magic '2048' value by 'PKT_SIZE' definition hw/net/lan9118: Fix overflow in TX FIFO hw/net/lan9118.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.41.0

[PATCH-for-9.0? 1/2] hw/net/lan9118: Replace magic '2048' value by 'PKT_SIZE' definition

2024-04-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé --- hw/net/lan9118.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 47ff25b441..7be0430ac5 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -150,6 +150,8 @@ do { printf("lan9118: "

[PATCH-for-9.0? 2/2] hw/net/lan9118: Fix overflow in TX FIFO

2024-04-08 Thread Philippe Mathieu-Daudé
When the TX FIFO is full, raise the TX Status FIFO Overflow (TXSO) flag, "Generated when the TX Status FIFO overflows" [*]. Broken since model introduction in commit 2a42499017 ("LAN9118 emulation"). When using the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/2267 we get: hw/n

Re: [PATCH-for-9.1 3/7] monitor: Rework stubs to simplify user emulation linking

2024-04-08 Thread Philippe Mathieu-Daudé
On 8/4/24 11:50, Paolo Bonzini wrote: On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé wrote: Currently monitor stubs are scattered in 3 files. Merge these stubs in 2 files, a generic one (monitor-core) included in all builds (in particular user emulation), and a less generic one to be i

Re: [PATCH-for-9.0 3/4] hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs

2024-04-08 Thread Philippe Mathieu-Daudé
On 8/4/24 12:08, Michael S. Tsirkin wrote: On Mon, Apr 08, 2024 at 09:14:39AM +0200, Philippe Mathieu-Daudé wrote: On 4/4/24 21:13, Philippe Mathieu-Daudé wrote: Replace qemu_bh_new_guarded() by virtio_bh_new_guarded() so the bus and device use the same guard. Otherwise the DMA-reentrancy prote

[PATCH] kvm: error out of kvm_irqchip_add_msi_route() in case of full route table

2024-04-08 Thread Igor Mammedov
subj is calling kvm_add_routing_entry() which simply extends KVMState::irq_routes::entries[] but doesn't check if number of routes goes beyond limit the kernel is willing to accept. Which later leads toi the assert qemu-kvm: ../accel/kvm/kvm-all.c:1833: kvm_irqchip_commit_routes: Assertion `r

Re: [PATCH-for-9.0? 2/2] hw/misc/applesmc: Fix memory leak in reset() handler

2024-04-08 Thread Philippe Mathieu-Daudé
On 8/4/24 12:34, Peter Maydell wrote: On Mon, 8 Apr 2024 at 10:53, Philippe Mathieu-Daudé wrote: AppleSMCData is allocated with g_new0() in applesmc_add_key(): release it with g_free(). Leaked since commit 1ddda5cd36 ("AppleSMC device emulation"). Resolves: https://gitlab.com/qemu-project/qe

How to use pxb-pcie in correct way?

2024-04-08 Thread Marcin Juszkiewicz
For quite a while I am experimenting with PCI Express setup on SBSA-Ref system. And finally decided to write. We want to play with NUMA setup and "pxb-pcie" can be assigned to NUMA node other than cpu0 one. But adding it makes other cards dissapear... When I boot sbsa-ref I have plain PCIe se

[PATCH RESEND 2/2] scsi-disk: Fix crash of VMs configured with the CDROM device

2024-04-08 Thread Hyman Huang
When configuring VMs with the CDROM device using the USB bus in Libvirt, do as follows: The destination Qemu process crashed, causing the VM migration to fail; the backtrace reveals the following: Program terminated with signal SIGSEGV, Segmentation fault. 0 __memmove_sse2_una

[PATCH RESEND 0/2] Fix crash of VMs configured with the CDROM device

2024-04-08 Thread Hyman Huang
This patchset fixes the crash of VMs configured with the CDROM device on the destination during live migration. See the commit message for details. The previous patchset does not show up at https://patchew.org/QEMU. Just resend it to ensure the email gets to the inbox. Please review. Yong Hyman

[PATCH RESEND 1/2] scsi-disk: Introduce the migrate_emulate_scsi_request field

2024-04-08 Thread Hyman Huang
To indicate to the destination whether or not emulational SCSI requests are sent, introduce the migrate_emulate_scsi_request in struct SCSIDiskState. It seeks to achieve migration backend compatibility. This commit sets the stage for the next one, which addresses the crash of a VM configured with

Re: [PATCH-for-9.0] hw/sd/sdhci: Discard excess of data written to Buffer Data Port register

2024-04-08 Thread Peter Maydell
On Thu, 4 Apr 2024 at 09:56, Philippe Mathieu-Daudé wrote: > > Per "SD Host Controller Standard Specification Version 3.00": > > * 1.7 Buffer Control > > - 1.7.1 Control of Buffer Pointer > > (3) Buffer Control with Block Size > > In case of write operation, the buffer accumulates the

Re: [PATCH-for-9.0? 1/2] hw/net/lan9118: Replace magic '2048' value by 'PKT_SIZE' definition

2024-04-08 Thread Peter Maydell
On Mon, 8 Apr 2024 at 11:53, Philippe Mathieu-Daudé wrote: > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/net/lan9118.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > Reviewed-by: Peter Maydell thanks -- PMM

Re: [PATCH] xen-hvm: Avoid livelock while handling buffered ioreqs

2024-04-08 Thread Ross Lagerwall
On Sat, Apr 6, 2024 at 11:58 AM Durrant, Paul wrote: > > On 04/04/2024 15:08, Ross Lagerwall wrote: > > A malicious or buggy guest may generated buffered ioreqs faster than > > QEMU can process them in handle_buffered_iopage(). The result is a > > livelock - QEMU continuously processes ioreqs on t

Re: [PATCH] xen-hvm: Avoid livelock while handling buffered ioreqs

2024-04-08 Thread Paul Durrant
On 08/04/2024 14:00, Ross Lagerwall wrote: On Sat, Apr 6, 2024 at 11:58 AM Durrant, Paul wrote: On 04/04/2024 15:08, Ross Lagerwall wrote: A malicious or buggy guest may generated buffered ioreqs faster than QEMU can process them in handle_buffered_iopage(). The result is a livelock - QEMU co

Re: [PATCH] xen-hvm: Avoid livelock while handling buffered ioreqs

2024-04-08 Thread Paul Durrant
On 04/04/2024 15:08, Ross Lagerwall wrote: A malicious or buggy guest may generated buffered ioreqs faster than QEMU can process them in handle_buffered_iopage(). The result is a livelock - QEMU continuously processes ioreqs on the main thread without iterating through the main loop which prevent

Re: [PATCH 9/9] accel/tcg: Improve can_do_io management

2024-04-08 Thread Jørgen Hansen
On 4/7/24 00:32, Richard Henderson wrote: > We already attempted to set and clear can_do_io before the first > and last insns, but only used the initial value of max_insns and > the call to translator_io_start to find those insns. > > Now that we track insn_start in DisasContextBase, and now that

Re: [PATCH-for-9.1 v2 2/3] migration: Remove RDMA protocol handling

2024-04-08 Thread Jinpu Wang
Hi Peter, On Tue, Apr 2, 2024 at 11:24 PM Peter Xu wrote: > > On Mon, Apr 01, 2024 at 11:26:25PM +0200, Yu Zhang wrote: > > Hello Peter und Zhjian, > > > > Thank you so much for letting me know about this. I'm also a bit surprised > > at > > the plan for deprecating the RDMA migration subsystem.

[RFC PATCH v2 00/13] SMMUv3 nested translation support

2024-04-08 Thread Mostafa Saleh
Currently, QEMU supports emulating either stage-1 or stage-2 SMMUs but not nested instances. This patch series adds support for nested translation in SMMUv3, this is controlled by property “arm-smmuv3.stage=nested”, and advertised to guests as (IDR0.S1P == 1 && IDR0.S2P == 2) Main changes(architec

[RFC PATCH v2 03/13] hw/arm/smmu: Consolidate ASID and VMID types

2024-04-08 Thread Mostafa Saleh
ASID and VMID used to be uint16_t in the translation config, however, in other contexts they can be int as -1 in case of TLB invalidation, to represent all(don’t care). When stage-2 was added asid was set to -1 in stage-2 and vmid to -1 in stage-1 configs. However, that meant they were set as (6553

[RFC PATCH v2 04/13] hw/arm/smmuv3: Translate CD and TT using stage-2 table

2024-04-08 Thread Mostafa Saleh
According to the user manual (ARM IHI 0070 F.b), In "5.2 Stream Table Entry": [51:6] S1ContextPtr If Config[1] == 1 (stage 2 enabled), this pointer is an IPA translated by stage 2 and the programmed value must be within the range of the IAS. In "5.4.1 CD notes": The translation table walks per

[RFC PATCH v2 05/13] hw/arm/smmu-common: Support nested translation

2024-04-08 Thread Mostafa Saleh
When nested translation is requested, do the following: - Translate stage-1 IPA using stage-2 to a physical address. - Translate stage-1 PTW walks using stage-2. - Combine both to create a single TLB entry, for that we choose the smallest entry to cache, which means that if the smallest entry

[RFC PATCH v2 10/13] hw/arm/smmuv3: Advertise S2FWB

2024-04-08 Thread Mostafa Saleh
QEMU doesn's support memory attributes, so FWB is NOP, this might change in the future if memory attributre would be supported. Signed-off-by: Mostafa Saleh --- hw/arm/smmuv3.c | 8 1 file changed, 8 insertions(+) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index da47411410..0e367c7

[RFC PATCH v2 01/13] hw/arm/smmu: Use enum for SMMU stage

2024-04-08 Thread Mostafa Saleh
Currently, translation stage is represented as an int, where 1 is stage-1 and 2 is stage-2, when nested is added, 3 would be confusing to represent nesting, so we use an enum instead. While keeping the same values, this is useful for: - Doing tricks with bit masks, where BIT(0) is stage-1 and BIT

[RFC PATCH v2 13/13] hw/arm/virt: Set SMMU OAS based on CPU PARANGE

2024-04-08 Thread Mostafa Saleh
Use the new SMMU property to make the SMMU OAS match the CPU PARANGE. That's according to SMMU manual ARM IHI 0070F.b: 6.3.6 SMMU_IDR5, OAS must match the system physical address size. Signed-off-by: Mostafa Saleh --- hw/arm/virt.c | 14 -- target/arm/cpu.h | 2 ++ target

[RFC PATCH v2 02/13] hw/arm/smmu: Split smmuv3_translate()

2024-04-08 Thread Mostafa Saleh
smmuv3_translate() does everything from STE/CD parsing to TLB lookup and PTW. Soon, when nesting is supported, stage-1 data (tt, CD) needs to be translated using stage-2. Split smmuv3_translate() to 3 functions: - smmu_translate(): in smmu-common.c, which does the TLB lookup, PTW, TLB insertio

[RFC PATCH v2 08/13] hw/arm/smmuv3: Support nested SMMUs in smmuv3_notify_iova()

2024-04-08 Thread Mostafa Saleh
IOMMUTLBEvent only understands IOVA, for stage-2 only SMMUs keep the implementation, while only notify for stage-1 invalidation in case of nesting. Signed-off-by: Mostafa Saleh --- hw/arm/smmuv3.c | 23 +++ hw/arm/trace-events | 2 +- 2 files changed, 16 insertions(+), 9

[RFC PATCH v2 07/13] hw/arm/smmu: Support nesting in the rest of commands

2024-04-08 Thread Mostafa Saleh
Some commands need rework for nesting, as they used to assume S1 and S2 are mutually exclusive: - CMD_TLBI_NH_ASID: Consider VMID if stage-2 is supported - CMD_TLBI_NH_ALL: Consider VMID if stage-2 is supported, otherwise invalidate everything, this required a new vmid invalidation function fo

[RFC PATCH v2 12/13] hw/arm/smmuv3: Add property for OAS

2024-04-08 Thread Mostafa Saleh
Add property that sets the OAS of the SMMU, this in not used in this patch. Signed-off-by: Mostafa Saleh --- hw/arm/smmuv3-internal.h | 3 ++- hw/arm/smmuv3.c | 29 - include/hw/arm/smmuv3.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --

[RFC PATCH v2 11/13] hw/arm/smmu: Refactor SMMU OAS

2024-04-08 Thread Mostafa Saleh
SMMUv3 OAS is hardcoded to 44 bits, for nested configurations that can be a problem as stage-2 might be shared with the CPU which might have different PARANGE, and according to SMMU manual ARM IHI 0070F.b: 6.3.6 SMMU_IDR5, OAS must match the system physical address size. This patch doesn't cha

[RFC PATCH v2 09/13] hw/arm/smmuv3: Support and advertise nesting

2024-04-08 Thread Mostafa Saleh
Everything is in place, add the last missing bits: - Handle fault checking according to the actual PTW event and not the the translation stage. - Consolidate parsing of STE cfg and setting translation stage. Advertise nesting if stage requested is "nested". Signed-off-by: Mostafa Saleh --- hw

[RFC PATCH v2 06/13] hw/arm/smmu: Support nesting in smmuv3_range_inval()

2024-04-08 Thread Mostafa Saleh
With nesting, we would need to invalidate IPAs without over-invalidating stage-1 IOVAs. This can be done by distinguishing IPAs in the TLBs by having ASID=-1. To achieve that, rework the invalidation for IPAs to have a separate function, while for IOVA invalidation ASID=-1 means invalidate for all

Re: [PATCH v4] nbd/server: do not poll within a coroutine context

2024-04-08 Thread Eric Blake
On Mon, Apr 08, 2024 at 11:46:39AM +0300, Vladimir Sementsov-Ogievskiy wrote: > On 05.04.24 20:44, Eric Blake wrote: > > From: Zhu Yangyang > > > > Coroutines are not supposed to block. Instead, they should yield. > > > > The client performs TLS upgrade outside of an AIOContext, during > > synch

[PATCH-for-9.0? 0/2] hw/sd/sdcard: Avoid OOB in sd_read_byte()

2024-04-08 Thread Philippe Mathieu-Daudé
Since this is Fix day, I went over this old bug: https://gitlab.com/qemu-project/qemu/-/issues/487 It happens to be a QEMU implementation detail not really related to the spec. Philippe Mathieu-Daudé (2): hw/sd/sdcard: Avoid OOB in sd_read_byte() during unexpected CMD switch hw/sd/sdcard: Asse

[RFC PATCH-for-9.0? 1/2] hw/sd/sdcard: Avoid OOB in sd_read_byte() during unexpected CMD switch

2024-04-08 Thread Philippe Mathieu-Daudé
For multi-bytes commands, our implementation uses the @data_start and @data_offset fields to track byte access. We initialize the command start/offset in buffer once. Malicious guest might abuse by switching command while staying in the 'transfer' state, switching command buffer size, and our imple

[PATCH-for-9.1 2/2] hw/sd/sdcard: Assert @data_offset is in range

2024-04-08 Thread Philippe Mathieu-Daudé
Prevent out-of-bound access with assertions. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 16d8d52a78..c081211582 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1875,6 +1875,7 @@ void sd_write_

Re: [PATCH-for-9.0? 2/2] hw/net/lan9118: Fix overflow in TX FIFO

2024-04-08 Thread Peter Maydell
On Mon, 8 Apr 2024 at 11:52, Philippe Mathieu-Daudé wrote: > > When the TX FIFO is full, raise the TX Status FIFO Overflow (TXSO) > flag, "Generated when the TX Status FIFO overflows" [*]. This doesn't sound right. The TX Status FIFO and the TX Data FIFO are separate FIFOs, and the TX FIFO has it

  1   2   3   >