All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal()
@ 2021-08-02 15:22 David Hildenbrand
  2021-08-02 15:26 ` Philippe Mathieu-Daudé
  2021-08-03 21:14 ` [PATCH v1] " Peter Xu
  0 siblings, 2 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-08-02 15:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Peter Xu, David Hildenbrand

When adding RAM_NORESERVE, we forgot to remove the old assertion when
adding the updated one, most probably when reworking the patches or
rebasing. We can easily crash QEMU by adding
  -object memory-backend-ram,id=mem0,size=500G,reserve=off
to the QEMU cmdline:
  qemu-system-x86_64: ../softmmu/physmem.c:2146: qemu_ram_alloc_internal:
  Assertion `(ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC))
  == 0' failed.

Fix it by removing the old assertion.

Fixes: 8dbe22c6868b ("memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap()")
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 softmmu/physmem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 3c1912a1a0..2e18947598 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -2143,7 +2143,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
     RAMBlock *new_block;
     Error *local_err = NULL;
 
-    assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC)) == 0);
     assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC |
                           RAM_NORESERVE)) == 0);
     assert(!host ^ (ram_flags & RAM_PREALLOC));
-- 
2.31.1



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

* Re: [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal()
  2021-08-02 15:22 [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal() David Hildenbrand
@ 2021-08-02 15:26 ` Philippe Mathieu-Daudé
  2021-08-02 15:27   ` [PATCH-for-6.1] " Philippe Mathieu-Daudé
  2021-08-03 21:14 ` [PATCH v1] " Peter Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-02 15:26 UTC (permalink / raw)
  To: David Hildenbrand, qemu-devel; +Cc: Paolo Bonzini, Peter Xu

On 8/2/21 5:22 PM, David Hildenbrand wrote:
> When adding RAM_NORESERVE, we forgot to remove the old assertion when
> adding the updated one, most probably when reworking the patches or
> rebasing. We can easily crash QEMU by adding
>   -object memory-backend-ram,id=mem0,size=500G,reserve=off
> to the QEMU cmdline:
>   qemu-system-x86_64: ../softmmu/physmem.c:2146: qemu_ram_alloc_internal:
>   Assertion `(ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC))
>   == 0' failed.

Oops.

> Fix it by removing the old assertion.
> 
> Fixes: 8dbe22c6868b ("memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap()")
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  softmmu/physmem.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index 3c1912a1a0..2e18947598 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -2143,7 +2143,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
>      RAMBlock *new_block;
>      Error *local_err = NULL;
>  
> -    assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC)) == 0);
>      assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC |
>                            RAM_NORESERVE)) == 0);
>      assert(!host ^ (ram_flags & RAM_PREALLOC));
> 



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

* Re: [PATCH-for-6.1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal()
  2021-08-02 15:26 ` Philippe Mathieu-Daudé
@ 2021-08-02 15:27   ` Philippe Mathieu-Daudé
  2021-08-02 15:30     ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-02 15:27 UTC (permalink / raw)
  To: David Hildenbrand, qemu-devel; +Cc: Paolo Bonzini, Peter Xu

6.1 material btw.

On 8/2/21 5:26 PM, Philippe Mathieu-Daudé wrote:
> On 8/2/21 5:22 PM, David Hildenbrand wrote:
>> When adding RAM_NORESERVE, we forgot to remove the old assertion when
>> adding the updated one, most probably when reworking the patches or
>> rebasing. We can easily crash QEMU by adding
>>   -object memory-backend-ram,id=mem0,size=500G,reserve=off
>> to the QEMU cmdline:
>>   qemu-system-x86_64: ../softmmu/physmem.c:2146: qemu_ram_alloc_internal:
>>   Assertion `(ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC))
>>   == 0' failed.
> 
> Oops.
> 
>> Fix it by removing the old assertion.
>>
>> Fixes: 8dbe22c6868b ("memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap()")
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
>> ---
>>  softmmu/physmem.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
>> index 3c1912a1a0..2e18947598 100644
>> --- a/softmmu/physmem.c
>> +++ b/softmmu/physmem.c
>> @@ -2143,7 +2143,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
>>      RAMBlock *new_block;
>>      Error *local_err = NULL;
>>  
>> -    assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC)) == 0);
>>      assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC |
>>                            RAM_NORESERVE)) == 0);
>>      assert(!host ^ (ram_flags & RAM_PREALLOC));
>>
> 



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

* Re: [PATCH-for-6.1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal()
  2021-08-02 15:27   ` [PATCH-for-6.1] " Philippe Mathieu-Daudé
@ 2021-08-02 15:30     ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-08-02 15:30 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Peter Xu

On 02.08.21 17:27, Philippe Mathieu-Daudé wrote:
> 6.1 material btw.

Indeed, should have tagged that right away. thanks!


-- 
Thanks,

David / dhildenb



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

* Re: [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal()
  2021-08-02 15:22 [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal() David Hildenbrand
  2021-08-02 15:26 ` Philippe Mathieu-Daudé
@ 2021-08-03 21:14 ` Peter Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Xu @ 2021-08-03 21:14 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: Paolo Bonzini, Philippe Mathieu-Daudé, qemu-devel

On Mon, Aug 02, 2021 at 05:22:38PM +0200, David Hildenbrand wrote:
> When adding RAM_NORESERVE, we forgot to remove the old assertion when
> adding the updated one, most probably when reworking the patches or
> rebasing. We can easily crash QEMU by adding
>   -object memory-backend-ram,id=mem0,size=500G,reserve=off
> to the QEMU cmdline:
>   qemu-system-x86_64: ../softmmu/physmem.c:2146: qemu_ram_alloc_internal:
>   Assertion `(ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC))
>   == 0' failed.
> 
> Fix it by removing the old assertion.
> 
> Fixes: 8dbe22c6868b ("memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap()")
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu



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

end of thread, other threads:[~2021-08-03 21:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 15:22 [PATCH v1] softmmu/physmem: fix wrong assertion in qemu_ram_alloc_internal() David Hildenbrand
2021-08-02 15:26 ` Philippe Mathieu-Daudé
2021-08-02 15:27   ` [PATCH-for-6.1] " Philippe Mathieu-Daudé
2021-08-02 15:30     ` David Hildenbrand
2021-08-03 21:14 ` [PATCH v1] " Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.