Skip to contentSkip to conversation

s390x: fix storage attributes migration for non-small guests

PATCH Applied Claudio Imbrenda 3 participants 4 messages Jan 18, 2018 – Jan 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390x: fix storage attributes migration for non-small guests

Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM.
With such guests, the index in the buffer would go out of bounds, usually by large amounts, thus receiving -EFAULT from the kernel. Migration itself would be successful, but storage attributes would then not be migrated completely.

This patch fixes the out of bounds access, and thus migration of all storage attributes when the guest have large amounts of memory.

Fixes 903fd80b03243476 ("s390x/migration: Storage attributes device")
---
 hw/s390x/s390-stattrib-kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390x/s390-stattrib-kvm.c +2 -2
index 41770a7..480551c 100644
@@ -116,7 +116,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
         for (cx = 0; cx + len <= max; cx += len) {
             clog.start_gfn = cx;
             clog.count = len;
-            clog.values = (uint64_t)(sas->incoming_buffer + cx * len);
+            clog.values = (uint64_t)(sas->incoming_buffer + cx);
             r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog);
             if (r) {
                 error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r));
@@ -126,7 +126,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
         if (cx < max) {
             clog.start_gfn = cx;
             clog.count = max - cx;
-            clog.values = (uint64_t)(sas->incoming_buffer + cx * len);
+            clog.values = (uint64_t)(sas->incoming_buffer + cx);
             r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog);
             if (r) {
                 error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r));
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · On Thu, 18 Jan 2018 18:51:44 +0100 Claudio Imbrenda…

Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM.
With such guests, the index in the buffer would go out of bounds, usually by large amounts, thus receiving -EFAULT from the kernel. Migration itself would be successful, but storage attributes would then not be migrated completely.

Quoted 8 lines

This patch fixes the out of bounds access, and thus migration of all storage attributes when the guest have large amounts of memory.

Fixes 903fd80b03243476 ("s390x/migration: Storage attributes device")
---
 hw/s390x/s390-stattrib-kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, applied.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Claudio Imbrenda
Quoted 7 lines · Claudio Imbrenda

Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM.
With such guests, the index in the buffer would go out of bounds, usually by large amounts, thus receiving -EFAULT from the kernel. Migration itself would be successful, but storage attributes would then not be migrated completely.

Quoted 5 lines

This patch fixes the out of bounds access, and thus migration of all storage attributes when the guest have large amounts of memory.

Fixes 903fd80b03243476 ("s390x/migration: Storage attributes device")
Cc stable ?
Quoted 27 lines
---
 hw/s390x/s390-stattrib-kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390x/s390-stattrib-kvm.c +2 -2
index 41770a7..480551c 100644
@@ -116,7 +116,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
         for (cx = 0; cx + len <= max; cx += len) {
             clog.start_gfn = cx;
             clog.count = len;
-            clog.values = (uint64_t)(sas->incoming_buffer + cx * len);
+            clog.values = (uint64_t)(sas->incoming_buffer + cx);
             r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog);
             if (r) {
                 error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r));
@@ -126,7 +126,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
         if (cx < max) {
             clog.start_gfn = cx;
             clog.count = max - cx;
-            clog.values = (uint64_t)(sas->incoming_buffer + cx * len);
+            clog.values = (uint64_t)(sas->incoming_buffer + cx);
             r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog);
             if (r) {
                 error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r));
#3 lore raw
Quoted 8 lines · On Fri, 19 Jan 2018 13:17:29 +0100 Christian Borntraeger…
Quoted 7 lines · Claudio Imbrenda

Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM.
With such guests, the index in the buffer would go out of bounds, usually by large amounts, thus receiving -EFAULT from the kernel. Migration itself would be successful, but storage attributes would then not be migrated completely.

Quoted 7 lines
Quoted 5 lines

This patch fixes the out of bounds access, and thus migration of all storage attributes when the guest have large amounts of memory.

Fixes 903fd80b03243476 ("s390x/migration: Storage attributes device")
Cc stable ?

Probably doesn't hurt for an out-of-bounds error.

Quoted 6 lines
Quoted 3 lines
---
 hw/s390x/s390-stattrib-kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Updated the queued patch, thanks.