s390x: fix storage attributes migration for non-small guests
PATCH 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. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
--- hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390x/s390-stattrib-kvm.c +2 -2
@@ -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
CCing qemu-s390x.
Quoted 36 lines · Claudio Imbrenda
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>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@@ -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));
Quoted 18 lines · On Mon, 15 Jan 2018 17:52:02 +0100 Claudio Imbrenda…
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>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 +0
-0
hw/s390x/s390-stattrib-kvm.c static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) · line 119
Quoted 4 lines
hw/s390x/s390-stattrib-kvm.c +0
-1@@ -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);
Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
Quoted 13 lines
hw/s390x/s390-stattrib-kvm.c +2
-1+ 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));
Quoted 16 lines · On Thu, 18 Jan 2018 17:20:34 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Jan 2018 17:52:02 +0100 Claudio Imbrenda…
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>Fixes 903fd80b03243476 ("s390x/migration: Storage attributesdevice") ---
hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
hw/s390x/s390-stattrib-kvm.c static void · line 119
Quoted 10 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-1@@ -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);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
what do you mean?
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Quoted 10 lines
Quoted 10 lines
hw/s390x/s390-stattrib-kvm.c +1
-0+ 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);
and here we fill in the last pieces if there are any leftovers, which at this point are guaranteed to be smaller than len.
Quoted 6 lines
Quoted 5 lines
+ 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));
Quoted 33 lines · On Thu, 18 Jan 2018 17:52:29 +0100 Claudio Imbrenda…
Quoted 16 lines · On Thu, 18 Jan 2018 17:20:34 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Jan 2018 17:52:02 +0100 Claudio Imbrenda…
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>Fixes 903fd80b03243476 ("s390x/migration: Storage attributesdevice") ---
hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 13 lines
hw/s390x/s390-stattrib-kvm.c static void · line 119
Quoted 10 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-1@@ -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);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
Quoted 5 lines
what do you mean?
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Yes, but the problem is that your offset is too long, isn't it? (Where cx + len <= max, but you use an offset of cx * len which may be > max.)
But maybe I'm simply too tired.
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
hw/s390x/s390-stattrib-kvm.c +1
-0+ 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);and here we fill in the last pieces if there are any leftovers, which at this point are guaranteed to be smaller than len.
Quoted 6 lines
Quoted 5 lines
+ 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));
Quoted 38 lines · On Thu, 18 Jan 2018 18:02:40 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 35 lines · On Thu, 18 Jan 2018 17:52:29 +0100 Claudio Imbrenda…
Quoted 16 lines · On Thu, 18 Jan 2018 17:20:34 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Jan 2018 17:52:02 +0100 Claudio Imbrenda…
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>Fixes 903fd80b03243476 ("s390x/migration: Storage attributesdevice") ---
hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 13 lines
Quoted 10 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-0@@ -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);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
what do you mean?
Quoted 8 lines
Quoted 4 lines
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Yes, but the problem is that your offset is too long, isn't it? (Where cx + len <= max, but you use an offset of cx * len which may be > max.)
which is exactly why I'm removing that line. look at the very beginning of the line, there is a -
the replacement line (the one that starts with a +) has only cx
Quoted 1 line
But maybe I'm simply too tired.
looks like it :)
Quoted 23 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
+ 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 voidkvm_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);and here we fill in the last pieces if there are any leftovers, which at this point are guaranteed to be smaller than len.
Quoted 6 lines
Quoted 5 lines
+ 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));
Quoted 46 lines · On Thu, 18 Jan 2018 18:23:17 +0100 Claudio Imbrenda…
Quoted 43 lines · On Thu, 18 Jan 2018 18:02:40 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 39 lines · On Thu, 18 Jan 2018 17:52:29 +0100 Claudio Imbrenda…
Quoted 16 lines · On Thu, 18 Jan 2018 17:20:34 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Jan 2018 17:52:02 +0100 Claudio Imbrenda…
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM. Migration itself was successful, but storage attributes were not migrated completely.
This patch fixes the migration of all storage attributes, even when the guest have large amounts of memory.
Signed-off-by Claudio Imbrenda <[email protected]>Fixes 903fd80b03243476 ("s390x/migration: Storage attributesdevice") ---
hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 13 lines
Quoted 10 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-0@@ -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);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
what do you mean?
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Quoted 8 lines
Quoted 3 lines
Yes, but the problem is that your offset is too long, isn't it? (Where cx + len <= max, but you use an offset of cx * len which may be > max.)
which is exactly why I'm removing that line. look at the very beginning of the line, there is a -
the replacement line (the one that starts with a +) has only cx
Err, yes :) I simply wanted to comment that this looks worse than "not migrated completely".
Quoted 29 lines
Quoted 2 lines
But maybe I'm simply too tired.
looks like it :)
Quoted 23 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
+ 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 voidkvm_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);and here we fill in the last pieces if there are any leftovers, which at this point are guaranteed to be smaller than len.
Quoted 6 lines
Quoted 5 lines
+ 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));
On Thu, 18 Jan 2018 18:25:47 +0100
Cornelia Huck <[email protected]> wrote:
...
[snip]
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-0@@ -116,7 +116,7 @@ static void
kvm_s390_stattrib_synchronize(S390StAttribState *sa)forQuoted 8 lines
Quoted 5 lines
(cx = 0; cx + len <= max; cx += len) { clog.start_gfn = cx; clog.count = len;- clog.values = (uint64_t)(sas->incoming_buffer
+ cx
* len);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
Quoted 6 lines
what do you mean?
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Yes, but the problem is that your offset is too long, isn't it? (Where cx + len <= max, but you use an offset of cx * len which may be > max.)
Quoted 7 lines
Quoted 4 lines
which is exactly why I'm removing that line. look at the very beginning of the line, there is a -
the replacement line (the one that starts with a +) has only cx
Err, yes :) I simply wanted to comment that this looks worse than "not migrated completely".
yeah, that's true :) but the offset ended up big enough to always get -EFAULT from the kernel and get ignored by qemu afterwards, which then resulted in not all values being migrated.
should I change the description to explain the issue in more detail?
[snip]
...
Quoted 35 lines · On Thu, 18 Jan 2018 18:33:51 +0100 Claudio Imbrenda…
On Thu, 18 Jan 2018 18:25:47 +0100
Cornelia Huck <[email protected]> wrote:...
[snip]Quoted 29 lines
Quoted 29 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0
-0
b/hw/s390x/s390-stattrib-kvm.cindex 41770a7..480551c 100644hw/s390x/s390-stattrib-kvm.c +0
-0@@ -116,7 +116,7 @@ static void
kvm_s390_stattrib_synchronize(S390StAttribState *sa)forQuoted 8 lines
Quoted 5 lines
(cx = 0; cx + len <= max; cx += len) { clog.start_gfn = cx; clog.count = len;- clog.values = (uint64_t)(sas->incoming_buffer
+ cx
* len);Hm, doesn't that even imply that you reference an area beyond the buffer, as the <= max check does not catch this?
what do you mean?
Quoted 8 lines
Quoted 4 lines
cx + len <= max catches the cases where you would write beyond the end of the buffer. if cx + len == max then we are filling the buffer to the last byte. and we will get out at the next iteration.
Yes, but the problem is that your offset is too long, isn't it? (Where cx + len <= max, but you use an offset of cx * len which may be > max.)
which is exactly why I'm removing that line. look at the very beginning of the line, there is a -
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
the replacement line (the one that starts with a +) has only cx
Err, yes :) I simply wanted to comment that this looks worse than "not migrated completely".
yeah, that's true :) but the offset ended up big enough to always get
-EFAULTfrom the kernel and get ignored by qemu afterwards, which then resulted in not all values being migrated.
So the moral is: If you're wrong, be really wrong? :)
Quoted 2 lines
should I change the description to explain the issue in more detail?
Just mentioning something like out-of-bounds due to wrong offset or so would be good.