qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] s390x/pv: Fix spurious warning with asynchronous teardown
@ 2023-05-10 10:55 Claudio Imbrenda
  2023-05-10 10:55 ` [PATCH v2 1/1] " Claudio Imbrenda
  0 siblings, 1 reply; 4+ messages in thread
From: Claudio Imbrenda @ 2023-05-10 10:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, borntraeger, nsg, nrb, frankja, pasic, mhartmay,
	thuth

Kernel commit 292a7d6fca33 ("KVM: s390: pv: fix asynchronous teardown
for small VMs") causes the KVM_PV_ASYNC_CLEANUP_PREPARE ioctl to fail
if the VM is not larger than 2GiB. QEMU would attempt it and fail,
print an error message, and then proceed with a normal teardown.

Avoid attempting to use asynchronous teardown altogether when the VM is
not larger than 2 GiB. This will avoid triggering the error message and
also avoid pointless overhead; normal teardown is fast enough for small
VMs.

v1->v2:
* Use 2GiB as threshold, the same as the kernel [thomas]
* Pass the machine state to s390_pv_vm_try_disable_async instead of
  using qdev_get_machine() [thomas]
* Update and improve patch description and comments

Claudio Imbrenda (1):
  s390x/pv: Fix spurious warning with asynchronous teardown

 hw/s390x/pv.c              | 10 ++++++++--
 hw/s390x/s390-virtio-ccw.c |  2 +-
 include/hw/s390x/pv.h      |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

-- 
2.40.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] s390x/pv: Fix spurious warning with asynchronous teardown
  2023-05-10 10:55 [PATCH v2 0/1] s390x/pv: Fix spurious warning with asynchronous teardown Claudio Imbrenda
@ 2023-05-10 10:55 ` Claudio Imbrenda
  2023-05-15  8:45   ` Thomas Huth
  2023-05-15  8:57   ` Thomas Huth
  0 siblings, 2 replies; 4+ messages in thread
From: Claudio Imbrenda @ 2023-05-10 10:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, borntraeger, nsg, nrb, frankja, pasic, mhartmay,
	thuth

Kernel commit 292a7d6fca33 ("KVM: s390: pv: fix asynchronous teardown
for small VMs") causes the KVM_PV_ASYNC_CLEANUP_PREPARE ioctl to fail
if the VM is not larger than 2GiB. QEMU would attempt it and fail,
print an error message, and then proceed with a normal teardown.

Avoid attempting to use asynchronous teardown altogether when the VM is
not larger than 2 GiB. This will avoid triggering the error message and
also avoid pointless overhead; normal teardown is fast enough for small
VMs.

Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Fixes: c3a073c610 ("s390x/pv: Add support for asynchronous teardown for reboot")
Link: https://lore.kernel.org/all/20230421085036.52511-2-imbrenda@linux.ibm.com/
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 hw/s390x/pv.c              | 10 ++++++++--
 hw/s390x/s390-virtio-ccw.c |  2 +-
 include/hw/s390x/pv.h      |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 49ea38236c..b63f3784c6 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -13,6 +13,7 @@
 
 #include <linux/kvm.h>
 
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
@@ -115,7 +116,7 @@ static void *s390_pv_do_unprot_async_fn(void *p)
      return NULL;
 }
 
-bool s390_pv_vm_try_disable_async(void)
+bool s390_pv_vm_try_disable_async(S390CcwMachineState *ms)
 {
     /*
      * t is only needed to create the thread; once qemu_thread_create
@@ -123,7 +124,12 @@ bool s390_pv_vm_try_disable_async(void)
      */
     QemuThread t;
 
-    if (!kvm_check_extension(kvm_state, KVM_CAP_S390_PROTECTED_ASYNC_DISABLE)) {
+    /*
+     * If the feature is not present or if the VM is not larger than 2 GiB,
+     * KVM_PV_ASYNC_CLEANUP_PREPARE fill fail; no point in attempting it.
+     */
+    if ((MACHINE(ms)->maxram_size <= 2 * GiB) ||
+        !kvm_check_extension(kvm_state, KVM_CAP_S390_PROTECTED_ASYNC_DISABLE)) {
         return false;
     }
     if (s390_pv_cmd(KVM_PV_ASYNC_CLEANUP_PREPARE, NULL) != 0) {
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index e6f2c62625..2516b89b32 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -330,7 +330,7 @@ static inline void s390_do_cpu_ipl(CPUState *cs, run_on_cpu_data arg)
 
 static void s390_machine_unprotect(S390CcwMachineState *ms)
 {
-    if (!s390_pv_vm_try_disable_async()) {
+    if (!s390_pv_vm_try_disable_async(ms)) {
         s390_pv_vm_disable();
     }
     ms->pv = false;
diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h
index 966306a9db..6766557fb7 100644
--- a/include/hw/s390x/pv.h
+++ b/include/hw/s390x/pv.h
@@ -41,7 +41,7 @@ static inline bool s390_is_pv(void)
 int s390_pv_query_info(void);
 int s390_pv_vm_enable(void);
 void s390_pv_vm_disable(void);
-bool s390_pv_vm_try_disable_async(void);
+bool s390_pv_vm_try_disable_async(S390CcwMachineState *ms);
 int s390_pv_set_sec_parms(uint64_t origin, uint64_t length);
 int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak);
 void s390_pv_prep_reset(void);
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] s390x/pv: Fix spurious warning with asynchronous teardown
  2023-05-10 10:55 ` [PATCH v2 1/1] " Claudio Imbrenda
@ 2023-05-15  8:45   ` Thomas Huth
  2023-05-15  8:57   ` Thomas Huth
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2023-05-15  8:45 UTC (permalink / raw)
  To: Claudio Imbrenda, qemu-devel
  Cc: qemu-s390x, borntraeger, nsg, nrb, frankja, pasic, mhartmay

On 10/05/2023 12.55, Claudio Imbrenda wrote:
> Kernel commit 292a7d6fca33 ("KVM: s390: pv: fix asynchronous teardown
> for small VMs") causes the KVM_PV_ASYNC_CLEANUP_PREPARE ioctl to fail
> if the VM is not larger than 2GiB. QEMU would attempt it and fail,
> print an error message, and then proceed with a normal teardown.
> 
> Avoid attempting to use asynchronous teardown altogether when the VM is
> not larger than 2 GiB. This will avoid triggering the error message and
> also avoid pointless overhead; normal teardown is fast enough for small
> VMs.
> 
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Fixes: c3a073c610 ("s390x/pv: Add support for asynchronous teardown for reboot")
> Link: https://lore.kernel.org/all/20230421085036.52511-2-imbrenda@linux.ibm.com/
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>   hw/s390x/pv.c              | 10 ++++++++--
>   hw/s390x/s390-virtio-ccw.c |  2 +-
>   include/hw/s390x/pv.h      |  2 +-
>   3 files changed, 10 insertions(+), 4 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] s390x/pv: Fix spurious warning with asynchronous teardown
  2023-05-10 10:55 ` [PATCH v2 1/1] " Claudio Imbrenda
  2023-05-15  8:45   ` Thomas Huth
@ 2023-05-15  8:57   ` Thomas Huth
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2023-05-15  8:57 UTC (permalink / raw)
  To: Claudio Imbrenda, qemu-devel
  Cc: qemu-s390x, borntraeger, nsg, nrb, frankja, pasic, mhartmay

On 10/05/2023 12.55, Claudio Imbrenda wrote:
> Kernel commit 292a7d6fca33 ("KVM: s390: pv: fix asynchronous teardown
> for small VMs") causes the KVM_PV_ASYNC_CLEANUP_PREPARE ioctl to fail
> if the VM is not larger than 2GiB. QEMU would attempt it and fail,
> print an error message, and then proceed with a normal teardown.
> 
> Avoid attempting to use asynchronous teardown altogether when the VM is
> not larger than 2 GiB. This will avoid triggering the error message and
> also avoid pointless overhead; normal teardown is fast enough for small
> VMs.
> 
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Fixes: c3a073c610 ("s390x/pv: Add support for asynchronous teardown for reboot")
> Link: https://lore.kernel.org/all/20230421085036.52511-2-imbrenda@linux.ibm.com/
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
...
> diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h
> index 966306a9db..6766557fb7 100644
> --- a/include/hw/s390x/pv.h
> +++ b/include/hw/s390x/pv.h
> @@ -41,7 +41,7 @@ static inline bool s390_is_pv(void)
>   int s390_pv_query_info(void);
>   int s390_pv_vm_enable(void);
>   void s390_pv_vm_disable(void);
> -bool s390_pv_vm_try_disable_async(void);
> +bool s390_pv_vm_try_disable_async(S390CcwMachineState *ms);
>   int s390_pv_set_sec_parms(uint64_t origin, uint64_t length);
>   int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak);
>   void s390_pv_prep_reset(void);

I'll squash this on top to fix a build failure on non-s390x host systems:

diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h
--- a/include/hw/s390x/pv.h
+++ b/include/hw/s390x/pv.h
@@ -61,7 +61,7 @@ static inline bool s390_is_pv(void) { return false; }
  static inline int s390_pv_query_info(void) { return 0; }
  static inline int s390_pv_vm_enable(void) { return 0; }
  static inline void s390_pv_vm_disable(void) {}
-static inline bool s390_pv_vm_try_disable_async(void) { return false; }
+static inline bool s390_pv_vm_try_disable_async(S390CcwMachineState *ms) { return false; }
  static inline int s390_pv_set_sec_parms(uint64_t origin, uint64_t length) { return 0; }
  static inline int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak) { return 0; }
  static inline void s390_pv_prep_reset(void) {}

  Thomas



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-15  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 10:55 [PATCH v2 0/1] s390x/pv: Fix spurious warning with asynchronous teardown Claudio Imbrenda
2023-05-10 10:55 ` [PATCH v2 1/1] " Claudio Imbrenda
2023-05-15  8:45   ` Thomas Huth
2023-05-15  8:57   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).