[Qemu-commits] [qemu/qemu] 1d3b82: hv-balloon: avoid alloca() usage

2024-03-09 Thread Peter Maydell via Qemu-commits
  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 1d3b82eabb1ad6b6fdeae0d94f2fb37506a351af
  
https://github.com/qemu/qemu/commit/1d3b82eabb1ad6b6fdeae0d94f2fb37506a351af
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hv-balloon.c

  Log Message:
  ---
  hv-balloon: avoid alloca() usage

alloca() is frowned upon, replace it with g_malloc0() + g_autofree.

Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: David Hildenbrand 
Signed-off-by: Maciej S. Szmigiero 


  Commit: 546987284a7da9106bbead1063553cbfe7ddd697
  
https://github.com/qemu/qemu/commit/546987284a7da9106bbead1063553cbfe7ddd697
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hv-balloon.c
M include/hw/hyperv/dynmem-proto.h

  Log Message:
  ---
  hv-balloon: define dm_hot_add_with_region to avoid Coverity warning

Since the presence of a hot add memory region is optional in hot add
request message it wasn't part of this message declaration
(struct dm_hot_add).

Instead, the code allocated such enlarged message by simply adding the
necessary size for this extra field to the size of basic hot add message
struct.

However, Coverity considers accessing this extra member to be
an out-of-bounds access, even thought the memory is actually there.

Fix this by adding an extended variant of this message that explicitly has
an additional union dm_mem_page_range at its end.

CID: #1523903
Signed-off-by: Maciej S. Szmigiero 


  Commit: 6093637b4d32875f98cd59696ffc5f26884aa0b4
  
https://github.com/qemu/qemu/commit/6093637b4d32875f98cd59696ffc5f26884aa0b4
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hyperv.c
M hw/hyperv/vmbus.c
M include/hw/hyperv/hyperv.h
M target/i386/kvm/hyperv-stub.c
M target/i386/kvm/hyperv.c
M target/i386/kvm/hyperv.h
M target/i386/kvm/kvm.c

  Log Message:
  ---
  vmbus: Print a warning when enabled without the recommended set of features

Some Windows versions crash at boot or fail to enable the VMBus device if
they don't see the expected set of Hyper-V features (enlightenments).

Since this provides poor user experience let's warn user if the VMBus
device is enabled without the recommended set of Hyper-V features.

The recommended set is the minimum set of Hyper-V features required to make
the VMBus device work properly in Windows Server versions 2016, 2019 and
2022.

Acked-by: Paolo Bonzini 
Signed-off-by: Maciej S. Szmigiero 


  Commit: 9876359990dd4c8a48de65cf5e1c3d13e96a7f4e
  
https://github.com/qemu/qemu/commit/9876359990dd4c8a48de65cf5e1c3d13e96a7f4e
  Author: Sven Schnelle 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/scsi/lsi53c895a.c
M hw/scsi/trace-events

  Log Message:
  ---
  hw/scsi/lsi53c895a: add timer to scripts processing

HP-UX 10.20 seems to make the lsi53c895a spinning on a memory location
under certain circumstances. As the SCSI controller and CPU are not
running at the same time this loop will never finish. After some
time, the check loop interrupts with a unexpected device disconnect.
This works, but is slow because the kernel resets the scsi controller.
Instead of signaling UDC, start a timer and exit the loop. Until the
timer fires, the CPU can process instructions which might changes the
memory location.

The limit of instructions is also reduced because scripts running on
the SCSI processor are usually very short. This keeps the time until
the loop is exit short.

Suggested-by: Peter Maydell 
Signed-off-by: Sven Schnelle 
Message-ID: <20240229204407.1699260-1-sv...@stackframe.org>
Signed-off-by: Paolo Bonzini 


  Commit: 012b170173bcaa14b9bc26209e0813311ac78489
  
https://github.com/qemu/qemu/commit/012b170173bcaa14b9bc26209e0813311ac78489
  Author: Dmitrii Gavrilov 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M system/qdev-monitor.c

  Log Message:
  ---
  system/qdev-monitor: move drain_call_rcu call under if (!dev) in 
qmp_device_add()

Original goal of addition of drain_call_rcu to qmp_device_add was to cover
the failure case of qdev_device_add. It seems call of drain_call_rcu was
misplaced in 7bed89958bfbf40df what led to waiting for pending RCU callbacks
under happy path too. What led to overall performance degradation of
qmp_device_add.

In this patch call of drain_call_rcu moved under handling of failure of
qdev_device_add.

Signed-off-by: Dmitrii Gavrilov 
Message-ID: <20231103105602.90475-1-ds-g...@yandex-team.ru>
Fixes: 7bed89958bf ("device_core: use drain_call_rcu in in qmp_device_add", 
2020-10-12)
Cc: qemu-sta...@nongnu.org
Signed-off-by: Paolo Bonzini 


  Commit: 5d402bd9aef3fdf9fbaa387db8be8318c9a37d0a
  
https://github.com/qemu/qemu/commit/5d402bd9aef3fdf9fbaa387db8be8318c9a37d0a
  Author: Akihiko Odaki 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  

[Qemu-commits] [qemu/qemu] 1d3b82: hv-balloon: avoid alloca() usage

2024-03-09 Thread Peter Maydell via Qemu-commits
  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: 1d3b82eabb1ad6b6fdeae0d94f2fb37506a351af
  
https://github.com/qemu/qemu/commit/1d3b82eabb1ad6b6fdeae0d94f2fb37506a351af
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hv-balloon.c

  Log Message:
  ---
  hv-balloon: avoid alloca() usage

alloca() is frowned upon, replace it with g_malloc0() + g_autofree.

Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: David Hildenbrand 
Signed-off-by: Maciej S. Szmigiero 


  Commit: 546987284a7da9106bbead1063553cbfe7ddd697
  
https://github.com/qemu/qemu/commit/546987284a7da9106bbead1063553cbfe7ddd697
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hv-balloon.c
M include/hw/hyperv/dynmem-proto.h

  Log Message:
  ---
  hv-balloon: define dm_hot_add_with_region to avoid Coverity warning

Since the presence of a hot add memory region is optional in hot add
request message it wasn't part of this message declaration
(struct dm_hot_add).

Instead, the code allocated such enlarged message by simply adding the
necessary size for this extra field to the size of basic hot add message
struct.

However, Coverity considers accessing this extra member to be
an out-of-bounds access, even thought the memory is actually there.

Fix this by adding an extended variant of this message that explicitly has
an additional union dm_mem_page_range at its end.

CID: #1523903
Signed-off-by: Maciej S. Szmigiero 


  Commit: 6093637b4d32875f98cd59696ffc5f26884aa0b4
  
https://github.com/qemu/qemu/commit/6093637b4d32875f98cd59696ffc5f26884aa0b4
  Author: Maciej S. Szmigiero 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/hyperv/hyperv.c
M hw/hyperv/vmbus.c
M include/hw/hyperv/hyperv.h
M target/i386/kvm/hyperv-stub.c
M target/i386/kvm/hyperv.c
M target/i386/kvm/hyperv.h
M target/i386/kvm/kvm.c

  Log Message:
  ---
  vmbus: Print a warning when enabled without the recommended set of features

Some Windows versions crash at boot or fail to enable the VMBus device if
they don't see the expected set of Hyper-V features (enlightenments).

Since this provides poor user experience let's warn user if the VMBus
device is enabled without the recommended set of Hyper-V features.

The recommended set is the minimum set of Hyper-V features required to make
the VMBus device work properly in Windows Server versions 2016, 2019 and
2022.

Acked-by: Paolo Bonzini 
Signed-off-by: Maciej S. Szmigiero 


  Commit: 9876359990dd4c8a48de65cf5e1c3d13e96a7f4e
  
https://github.com/qemu/qemu/commit/9876359990dd4c8a48de65cf5e1c3d13e96a7f4e
  Author: Sven Schnelle 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M hw/scsi/lsi53c895a.c
M hw/scsi/trace-events

  Log Message:
  ---
  hw/scsi/lsi53c895a: add timer to scripts processing

HP-UX 10.20 seems to make the lsi53c895a spinning on a memory location
under certain circumstances. As the SCSI controller and CPU are not
running at the same time this loop will never finish. After some
time, the check loop interrupts with a unexpected device disconnect.
This works, but is slow because the kernel resets the scsi controller.
Instead of signaling UDC, start a timer and exit the loop. Until the
timer fires, the CPU can process instructions which might changes the
memory location.

The limit of instructions is also reduced because scripts running on
the SCSI processor are usually very short. This keeps the time until
the loop is exit short.

Suggested-by: Peter Maydell 
Signed-off-by: Sven Schnelle 
Message-ID: <20240229204407.1699260-1-sv...@stackframe.org>
Signed-off-by: Paolo Bonzini 


  Commit: 012b170173bcaa14b9bc26209e0813311ac78489
  
https://github.com/qemu/qemu/commit/012b170173bcaa14b9bc26209e0813311ac78489
  Author: Dmitrii Gavrilov 
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
M system/qdev-monitor.c

  Log Message:
  ---
  system/qdev-monitor: move drain_call_rcu call under if (!dev) in 
qmp_device_add()

Original goal of addition of drain_call_rcu to qmp_device_add was to cover
the failure case of qdev_device_add. It seems call of drain_call_rcu was
misplaced in 7bed89958bfbf40df what led to waiting for pending RCU callbacks
under happy path too. What led to overall performance degradation of
qmp_device_add.

In this patch call of drain_call_rcu moved under handling of failure of
qdev_device_add.

Signed-off-by: Dmitrii Gavrilov 
Message-ID: <20231103105602.90475-1-ds-g...@yandex-team.ru>
Fixes: 7bed89958bf ("device_core: use drain_call_rcu in in qmp_device_add", 
2020-10-12)
Cc: qemu-sta...@nongnu.org
Signed-off-by: Paolo Bonzini 


  Commit: 5d402bd9aef3fdf9fbaa387db8be8318c9a37d0a
  
https://github.com/qemu/qemu/commit/5d402bd9aef3fdf9fbaa387db8be8318c9a37d0a
  Author: Akihiko Odaki 
  Date:   2024-03-08 (Fri, 08 Mar 2024)