qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Igor Mammedov <imammedo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	Gavin Shan <gshan@redhat.com>, Zhenyu Zhang <zhenyzha@redhat.com>
Subject: [PULL 6/6] hostmem: Apply merge property after the memory region is initialized
Date: Tue, 24 Sep 2024 12:03:29 +0200	[thread overview]
Message-ID: <20240924100329.248738-7-david@redhat.com> (raw)
In-Reply-To: <20240924100329.248738-1-david@redhat.com>

From: Gavin Shan <gshan@redhat.com>

The semantic change has been introduced by commit 5becdc0ab0 ("hostmem:
simplify the code for merge and dump properties") even it clarifies that
no senmatic change has been introduced. After the commit, the merge
property can be applied even the corresponding memory region isn't
initialized yet. This leads to crash dump by the following command
lines.

  # /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64  \
    -accel kvm  -machine virt -cpu host                      \
    -object memory-backend-ram,id=mem-memN0,size=4096M,merge=off
    :
    qemu-system-aarch64: ../system/memory.c:2419: memory_region_get_ram_ptr: \
    Assertion `mr->ram_block' failed.

Fix it by applying the merge property only when the memory region is
initialized.

Message-ID: <20240915233117.478169-1-gshan@redhat.com>
Fixes: 5becdc0ab083 ("hostmem: simplify the code for merge and dump properties")
Reported-by: Zhenyu Zhang <zhenyzha@redhat.com>
Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 backends/hostmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 4e5576a4ad..181446626a 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -178,7 +178,7 @@ static void host_memory_backend_set_merge(Object *obj, bool value, Error **errp)
         return;
     }
 
-    if (!host_memory_backend_mr_inited(backend) &&
+    if (host_memory_backend_mr_inited(backend) &&
         value != backend->merge) {
         void *ptr = memory_region_get_ram_ptr(&backend->mr);
         uint64_t sz = memory_region_size(&backend->mr);
-- 
2.46.1



  parent reply	other threads:[~2024-09-24 10:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 10:03 [PULL 0/6] Host Memory Backends and Memory devices queue 2024-09-24 David Hildenbrand
2024-09-24 10:03 ` [PULL 1/6] virtio: kconfig: memory devices are PCI only David Hildenbrand
2024-09-24 10:03 ` [PULL 2/6] reset: Use ResetType for qemu_devices_reset() and MachineClass::reset() David Hildenbrand
2024-09-24 10:03 ` [PULL 3/6] reset: Add RESET_TYPE_WAKEUP David Hildenbrand
2024-09-24 10:03 ` [PULL 4/6] virtio-mem: Use new Resettable framework instead of LegacyReset David Hildenbrand
2024-09-24 10:03 ` [PULL 5/6] virtio-mem: Add support for suspend+wake-up with plugged memory David Hildenbrand
2024-09-24 10:03 ` David Hildenbrand [this message]
2024-09-27  9:32 ` [PULL 0/6] Host Memory Backends and Memory devices queue 2024-09-24 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240924100329.248738-7-david@redhat.com \
    --to=david@redhat.com \
    --cc=gshan@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zhenyzha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).