Pablo Greco e6a3ae
From aaec9beefcdc4e8cbef669d0115f4405498400de Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Date: Wed, 17 Apr 2019 13:57:21 +0100
Pablo Greco e6a3ae
Subject: [PATCH 04/24] s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190417135741.25297-5-cohuck@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 85786
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 04/24] s390x/storage attributes: fix CMMA_BLOCK_SIZE usage
Pablo Greco e6a3ae
Bugzilla: 1699070
Pablo Greco e6a3ae
RH-Acked-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
The macro CMMA_BLOCK_SIZE was defined but not used, and a hardcoded
Pablo Greco e6a3ae
value was instead used in the code.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
This patch fixes the value of CMMA_BLOCK_SIZE and uses it in the
Pablo Greco e6a3ae
appropriate place in the code, and fixes another case of hardcoded
Pablo Greco e6a3ae
value in the KVM backend, replacing it with the more appropriate
Pablo Greco e6a3ae
constant KVM_S390_CMMA_SIZE_MAX.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Pablo Greco e6a3ae
Message-Id: <1530787170-3101-1-git-send-email-imbrenda@linux.vnet.ibm.com>
Pablo Greco e6a3ae
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 17f4566657df51c5e0cb40f30491e058d74d63c8)
Pablo Greco e6a3ae
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 hw/s390x/s390-stattrib-kvm.c | 3 ++-
Pablo Greco e6a3ae
 hw/s390x/s390-stattrib.c     | 5 +++--
Pablo Greco e6a3ae
 2 files changed, 5 insertions(+), 3 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
Pablo Greco e6a3ae
index 480551c..c7e1f35 100644
Pablo Greco e6a3ae
--- a/hw/s390x/s390-stattrib-kvm.c
Pablo Greco e6a3ae
+++ b/hw/s390x/s390-stattrib-kvm.c
Pablo Greco e6a3ae
@@ -105,7 +105,8 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
Pablo Greco e6a3ae
     KVMS390StAttribState *sas = KVM_S390_STATTRIB(sa);
Pablo Greco e6a3ae
     MachineState *machine = MACHINE(qdev_get_machine());
Pablo Greco e6a3ae
     unsigned long max = machine->maxram_size / TARGET_PAGE_SIZE;
Pablo Greco e6a3ae
-    unsigned long cx, len = 1 << 19;
Pablo Greco e6a3ae
+    /* We do not need to reach the maximum buffer size allowed */
Pablo Greco e6a3ae
+    unsigned long cx, len = KVM_S390_SKEYS_MAX / 2;
Pablo Greco e6a3ae
     int r;
Pablo Greco e6a3ae
     struct kvm_s390_cmma_log clog = {
Pablo Greco e6a3ae
         .flags = 0,
Pablo Greco e6a3ae
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
Pablo Greco e6a3ae
index 5161a16..766f201 100644
Pablo Greco e6a3ae
--- a/hw/s390x/s390-stattrib.c
Pablo Greco e6a3ae
+++ b/hw/s390x/s390-stattrib.c
Pablo Greco e6a3ae
@@ -21,7 +21,8 @@
Pablo Greco e6a3ae
 #include "qapi/error.h"
Pablo Greco e6a3ae
 #include "qapi/qmp/qdict.h"
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-#define CMMA_BLOCK_SIZE  (1 * KiB)
Pablo Greco e6a3ae
+/* 512KiB cover 2GB of guest memory */
Pablo Greco e6a3ae
+#define CMMA_BLOCK_SIZE  (512 * KiB)
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 #define STATTR_FLAG_EOS     0x01ULL
Pablo Greco e6a3ae
 #define STATTR_FLAG_MORE    0x02ULL
Pablo Greco e6a3ae
@@ -203,7 +204,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int final)
Pablo Greco e6a3ae
     S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
Pablo Greco e6a3ae
     uint8_t *buf;
Pablo Greco e6a3ae
     int r, cx, reallen = 0, ret = 0;
Pablo Greco e6a3ae
-    uint32_t buflen = 1 << 19;   /* 512kB cover 2GB of guest memory */
Pablo Greco e6a3ae
+    uint32_t buflen = CMMA_BLOCK_SIZE;
Pablo Greco e6a3ae
     uint64_t start_gfn = sas->migration_cur_gfn;
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     buf = g_try_malloc(buflen);
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae