From: Joshua Lant <joshualant@gmail.com>
To: linux-cxl@vger.kernel.org
Cc: jic23@kernel.org, Joshua Lant <joshualant@gmail.com>
Subject: [QEMU PATCH 1/2] cxl-type3: Properly unmap the memory-backend on device exit
Date: Wed, 20 May 2026 15:16:47 +0100 [thread overview]
Message-ID: <20260520141816.3240010-3-joshualant@gmail.com> (raw)
In-Reply-To: <20260520141816.3240010-2-joshualant@gmail.com>
Currently the memory backend remains mapped, meaning that if the device owning
the backend is hot-removed, it cannot be readded in the same QEMU instance.
Fixes: 5fcc499ee34 ("mem/cxl_type3: Add read and write functions for associated hostmem.")
Signed-off-by: Joshua Lant <joshualant@gmail.com>
---
hw/mem/cxl_type3.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index 4739239da3..105526edd4 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -1049,12 +1049,15 @@ err_free_special_ops:
g_free(regs->special_ops);
if (ct3d->dc.host_dc) {
cxl_destroy_dc_regions(ct3d);
+ host_memory_backend_set_mapped(ct3d->dc.host_dc, false);
address_space_destroy(&ct3d->dc.host_dc_as);
}
if (ct3d->hostpmem) {
+ host_memory_backend_set_mapped(ct3d->hostpmem, false);
address_space_destroy(&ct3d->hostpmem_as);
}
if (ct3d->hostvmem) {
+ host_memory_backend_set_mapped(ct3d->hostvmem, false);
address_space_destroy(&ct3d->hostvmem_as);
}
}
@@ -1072,12 +1075,15 @@ static void ct3_exit(PCIDevice *pci_dev)
cxl_destroy_cci(&ct3d->cci);
if (ct3d->dc.host_dc) {
cxl_destroy_dc_regions(ct3d);
+ host_memory_backend_set_mapped(ct3d->dc.host_dc, false);
address_space_destroy(&ct3d->dc.host_dc_as);
}
if (ct3d->hostpmem) {
+ host_memory_backend_set_mapped(ct3d->hostpmem, false);
address_space_destroy(&ct3d->hostpmem_as);
}
if (ct3d->hostvmem) {
+ host_memory_backend_set_mapped(ct3d->hostvmem, false);
address_space_destroy(&ct3d->hostvmem_as);
}
}
--
2.47.3
next prev parent reply other threads:[~2026-05-20 14:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 14:16 [QEMU PATCH 0/2] cxl: fixes for hot-removal of devices Joshua Lant
2026-05-20 14:16 ` Joshua Lant [this message]
2026-05-20 14:16 ` [QEMU PATCH 2/2] cxl_downstream: enable power controller present capability Joshua Lant
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=20260520141816.3240010-3-joshualant@gmail.com \
--to=joshualant@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
/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