qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
@ 2018-01-15 16:52 Claudio Imbrenda
  2018-01-15 18:53 ` Christian Borntraeger
  2018-01-18 16:20 ` Cornelia Huck
  0 siblings, 2 replies; 9+ messages in thread
From: Claudio Imbrenda @ 2018-01-15 16:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: cohuck

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 <imbrenda@linux.vnet.ibm.com>
Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes device")
---
 hw/s390x/s390-stattrib-kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
index 41770a7..480551c 100644
--- a/hw/s390x/s390-stattrib-kvm.c
+++ b/hw/s390x/s390-stattrib-kvm.c
@@ -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));
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-15 16:52 [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests Claudio Imbrenda
@ 2018-01-15 18:53 ` Christian Borntraeger
  2018-01-18 16:20 ` Cornelia Huck
  1 sibling, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2018-01-15 18:53 UTC (permalink / raw)
  To: Claudio Imbrenda, qemu-devel; +Cc: cohuck, qemu-s390x

CCing qemu-s390x.

On 01/15/2018 05:52 PM, Claudio Imbrenda wrote:
> 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 <imbrenda@linux.vnet.ibm.com>
> Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes device")
> ---
>  hw/s390x/s390-stattrib-kvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
> index 41770a7..480551c 100644
> --- a/hw/s390x/s390-stattrib-kvm.c
> +++ b/hw/s390x/s390-stattrib-kvm.c
> @@ -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));
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-15 16:52 [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests Claudio Imbrenda
  2018-01-15 18:53 ` Christian Borntraeger
@ 2018-01-18 16:20 ` Cornelia Huck
  2018-01-18 16:52   ` Claudio Imbrenda
  1 sibling, 1 reply; 9+ messages in thread
From: Cornelia Huck @ 2018-01-18 16:20 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Mon, 15 Jan 2018 17:52:02 +0100
Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:

> 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 <imbrenda@linux.vnet.ibm.com>
> Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes device")
> ---
>  hw/s390x/s390-stattrib-kvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
> index 41770a7..480551c 100644
> --- a/hw/s390x/s390-stattrib-kvm.c
> +++ b/hw/s390x/s390-stattrib-kvm.c
> @@ -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?

> +            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));

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 16:20 ` Cornelia Huck
@ 2018-01-18 16:52   ` Claudio Imbrenda
  2018-01-18 17:02     ` Cornelia Huck
  0 siblings, 1 reply; 9+ messages in thread
From: Claudio Imbrenda @ 2018-01-18 16:52 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 17:20:34 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

> On Mon, 15 Jan 2018 17:52:02 +0100
> Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> 
> > 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 <imbrenda@linux.vnet.ibm.com>
> > Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes
> > device") ---
> >  hw/s390x/s390-stattrib-kvm.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > --- a/hw/s390x/s390-stattrib-kvm.c
> > +++ b/hw/s390x/s390-stattrib-kvm.c
> > @@ -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.

> > +            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.

> > +            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));  
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 16:52   ` Claudio Imbrenda
@ 2018-01-18 17:02     ` Cornelia Huck
  2018-01-18 17:23       ` Claudio Imbrenda
  0 siblings, 1 reply; 9+ messages in thread
From: Cornelia Huck @ 2018-01-18 17:02 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 17:52:29 +0100
Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:

> On Thu, 18 Jan 2018 17:20:34 +0100
> Cornelia Huck <cohuck@redhat.com> wrote:
> 
> > On Mon, 15 Jan 2018 17:52:02 +0100
> > Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> >   
> > > 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 <imbrenda@linux.vnet.ibm.com>
> > > Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes
> > > device") ---
> > >  hw/s390x/s390-stattrib-kvm.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > > --- a/hw/s390x/s390-stattrib-kvm.c
> > > +++ b/hw/s390x/s390-stattrib-kvm.c
> > > @@ -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.

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.

> 
> > > +            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.
> 
> > > +            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));    
> >   
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 17:02     ` Cornelia Huck
@ 2018-01-18 17:23       ` Claudio Imbrenda
  2018-01-18 17:25         ` Cornelia Huck
  0 siblings, 1 reply; 9+ messages in thread
From: Claudio Imbrenda @ 2018-01-18 17:23 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 18:02:40 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

> On Thu, 18 Jan 2018 17:52:29 +0100
> Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> 
> > On Thu, 18 Jan 2018 17:20:34 +0100
> > Cornelia Huck <cohuck@redhat.com> wrote:
> >   
> > > On Mon, 15 Jan 2018 17:52:02 +0100
> > > Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> > >     
> > > > 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 <imbrenda@linux.vnet.ibm.com>
> > > > Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes
> > > > device") ---
> > > >  hw/s390x/s390-stattrib-kvm.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > > > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > > > --- a/hw/s390x/s390-stattrib-kvm.c
> > > > +++ b/hw/s390x/s390-stattrib-kvm.c
> > > > @@ -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.  
> 
> 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

> But maybe I'm simply too tired.

looks like it :)

> >   
> > > > +            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.
> >   
> > > > +            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));      
> > >     
> >   
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 17:23       ` Claudio Imbrenda
@ 2018-01-18 17:25         ` Cornelia Huck
  2018-01-18 17:33           ` Claudio Imbrenda
  0 siblings, 1 reply; 9+ messages in thread
From: Cornelia Huck @ 2018-01-18 17:25 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 18:23:17 +0100
Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:

> On Thu, 18 Jan 2018 18:02:40 +0100
> Cornelia Huck <cohuck@redhat.com> wrote:
> 
> > On Thu, 18 Jan 2018 17:52:29 +0100
> > Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> >   
> > > On Thu, 18 Jan 2018 17:20:34 +0100
> > > Cornelia Huck <cohuck@redhat.com> wrote:
> > >     
> > > > On Mon, 15 Jan 2018 17:52:02 +0100
> > > > Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> > > >       
> > > > > 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 <imbrenda@linux.vnet.ibm.com>
> > > > > Fixes: 903fd80b03243476 ("s390x/migration: Storage attributes
> > > > > device") ---
> > > > >  hw/s390x/s390-stattrib-kvm.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > > > > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > > > > --- a/hw/s390x/s390-stattrib-kvm.c
> > > > > +++ b/hw/s390x/s390-stattrib-kvm.c
> > > > > @@ -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.    
> > 
> > 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".

> 
> > But maybe I'm simply too tired.  
> 
> looks like it :)
> 
> > >     
> > > > > +            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.
> > >     
> > > > > +            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));        
> > > >       
> > >     
> >   
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 17:25         ` Cornelia Huck
@ 2018-01-18 17:33           ` Claudio Imbrenda
  2018-01-18 17:40             ` Cornelia Huck
  0 siblings, 1 reply; 9+ messages in thread
From: Claudio Imbrenda @ 2018-01-18 17:33 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 18:25:47 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

...
[snip]

> > > > > > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > > > > > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > > > > > --- a/hw/s390x/s390-stattrib-kvm.c
> > > > > > +++ b/hw/s390x/s390-stattrib-kvm.c
> > > > > > @@ -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.      
> > > 
> > > 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".

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]
...

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

* Re: [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests
  2018-01-18 17:33           ` Claudio Imbrenda
@ 2018-01-18 17:40             ` Cornelia Huck
  0 siblings, 0 replies; 9+ messages in thread
From: Cornelia Huck @ 2018-01-18 17:40 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: qemu-devel, qemu-s390x, Christian Borntraeger

On Thu, 18 Jan 2018 18:33:51 +0100
Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:

> On Thu, 18 Jan 2018 18:25:47 +0100
> Cornelia Huck <cohuck@redhat.com> wrote:
> 
> ...
> [snip]
> 
> > > > > > > diff --git a/hw/s390x/s390-stattrib-kvm.c
> > > > > > > b/hw/s390x/s390-stattrib-kvm.c index 41770a7..480551c 100644
> > > > > > > --- a/hw/s390x/s390-stattrib-kvm.c
> > > > > > > +++ b/hw/s390x/s390-stattrib-kvm.c
> > > > > > > @@ -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.        
> > > > 
> > > > 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".  
> 
> 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.

So the moral is: If you're wrong, be really wrong? :)

> 
> 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.

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

end of thread, other threads:[~2018-01-18 17:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 16:52 [Qemu-devel] [PATCH v1 1/1] s390x: fix storage attributes migration for non-small guests Claudio Imbrenda
2018-01-15 18:53 ` Christian Borntraeger
2018-01-18 16:20 ` Cornelia Huck
2018-01-18 16:52   ` Claudio Imbrenda
2018-01-18 17:02     ` Cornelia Huck
2018-01-18 17:23       ` Claudio Imbrenda
2018-01-18 17:25         ` Cornelia Huck
2018-01-18 17:33           ` Claudio Imbrenda
2018-01-18 17:40             ` Cornelia Huck

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).