Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216477/?format=api
{ "id": 2216477, "url": "http://patchwork.ozlabs.org/api/patches/2216477/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260326144000.492037-1-magnuskulke@linux.microsoft.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260326144000.492037-1-magnuskulke@linux.microsoft.com>", "list_archive_url": null, "date": "2026-03-26T14:40:00", "name": "accel/mshv: skip double unmap of mem regions", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "dbc0786ee657fc778f5d1f720acb46ee00f6493b", "submitter": { "id": 90753, "url": "http://patchwork.ozlabs.org/api/people/90753/?format=api", "name": "Magnus Kulke", "email": "magnuskulke@linux.microsoft.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260326144000.492037-1-magnuskulke@linux.microsoft.com/mbox/", "series": [ { "id": 497604, "url": "http://patchwork.ozlabs.org/api/series/497604/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497604", "date": "2026-03-26T14:40:00", "name": "accel/mshv: skip double unmap of mem regions", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497604/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216477/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216477/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com\n header.a=rsa-sha256 header.s=default header.b=nSdAWIM3;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhRKF017Jz1y1G\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 01:40:47 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w5lsa-0007fz-1j; Thu, 26 Mar 2026 10:40:12 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <magnuskulke@linux.microsoft.com>)\n id 1w5lsW-0007fZ-JE\n for qemu-devel@nongnu.org; Thu, 26 Mar 2026 10:40:10 -0400", "from linux.microsoft.com ([13.77.154.182])\n by eggs.gnu.org with esmtp (Exim 4.90_1)\n (envelope-from <magnuskulke@linux.microsoft.com>) id 1w5lsU-00034G-Mn\n for qemu-devel@nongnu.org; Thu, 26 Mar 2026 10:40:08 -0400", "from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.76])\n by linux.microsoft.com (Postfix) with ESMTPSA id D220920B710C;\n Thu, 26 Mar 2026 07:40:02 -0700 (PDT)" ], "DKIM-Filter": "OpenDKIM Filter v2.11.0 linux.microsoft.com D220920B710C", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n s=default; t=1774536004;\n bh=VQvd1yPUC63N3E4bm+PKxKHtEmIfMxn1ymYCNxkvczk=;\n h=From:To:Cc:Subject:Date:From;\n b=nSdAWIM3wg6aIV5uaYp/OqPcWf6yQJFDFuxLsW4SHOahvvj+KFzpbQ2u31iXXxt1S\n EOqsSPUVEJL4t+0ZyVpts+mpt8rk7B0AQNSad9MBtH/SZzEhKRus1SI+Rci1OTXFi+\n iN5I6MnWUC6pZkwT0kBi/RiD5Vw6tQ6+dqSPWY3U=", "From": "Magnus Kulke <magnuskulke@linux.microsoft.com>", "To": "qemu-devel@nongnu.org", "Cc": "Wei Liu <liuwe@microsoft.com>, Wei Liu <wei.liu@kernel.org>,\n Magnus Kulke <magnuskulke@microsoft.com>,\n Magnus Kulke <magnuskulke@linux.microsoft.com>", "Subject": "[PATCH] accel/mshv: skip double unmap of mem regions", "Date": "Thu, 26 Mar 2026 15:40:00 +0100", "Message-Id": "<20260326144000.492037-1-magnuskulke@linux.microsoft.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=13.77.154.182;\n envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com", "X-Spam_score_int": "-42", "X-Spam_score": "-4.3", "X-Spam_bar": "----", "X-Spam_report": "(-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "This change addresses a regression that was introduced when the dynamic\nmapping handler was removed, from the MSHV controller, breaking OVMF\nsupport.\n\nWe introduce a small uaddr-indexed table to track mapped regions. The\ncurrent logic turns an add into a remove op if a rom-device region is\ncurrently not in romd_mode.\n\nWe could ignore both map + unmap for this condition, but this misses a\nthe case of a region transitioning from romd_mode=true => false. In this\ncase we still do want to unmap a region.\n\nFixes: 626e5dc999 (Remove remap overlapping mappings code)\n\nSigned-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>\n---\n accel/mshv/mem.c | 41 ++++++++++++++++++++++++++++++++++++---\n accel/mshv/mshv-all.c | 1 +\n include/system/mshv_int.h | 1 +\n 3 files changed, 40 insertions(+), 3 deletions(-)", "diff": "diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c\nindex e55c38d4db..db28dcd83c 100644\n--- a/accel/mshv/mem.c\n+++ b/accel/mshv/mem.c\n@@ -12,6 +12,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"qemu/error-report.h\"\n+#include \"qemu/main-loop.h\"\n #include \"linux/mshv.h\"\n #include \"system/address-spaces.h\"\n #include \"system/mshv.h\"\n@@ -165,6 +166,25 @@ static hwaddr align_section(MemoryRegionSection *section, hwaddr *start)\n return (size - delta) & qemu_real_host_page_mask();\n }\n \n+static bool uaddr_is_mapped(MshvMemoryListener *mml, hwaddr start_addr)\n+{\n+ assert(bql_locked());\n+\n+ return g_hash_table_contains(mml->mapped_regions,\n+ GINT_TO_POINTER(start_addr));\n+}\n+\n+static void track_region(MshvMemoryListener *mml, hwaddr start_addr, bool add)\n+{\n+ assert(bql_locked());\n+\n+ if (add) {\n+ g_hash_table_add(mml->mapped_regions, GINT_TO_POINTER(start_addr));\n+ } else {\n+ g_hash_table_remove(mml->mapped_regions, GINT_TO_POINTER(start_addr));\n+ }\n+}\n+\n void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,\n bool add)\n {\n@@ -173,15 +193,19 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,\n bool writable = !area->readonly && !area->rom_device;\n hwaddr start_addr, mr_offset, size;\n void *ram;\n+ bool is_mapped;\n MshvMemoryRegion mshv_mr = {0};\n \n size = align_section(section, &start_addr);\n trace_mshv_set_phys_mem(add, section->mr->name, start_addr);\n \n /*\n- * If the memory device is a writable non-ram area, we do not\n- * want to map it into the guest memory. If it is not a ROM device,\n- * we want to remove mshv memory mapping, so accesses will trap.\n+ * ROM devices (e.g. pflash) have ram=false, rom_device=true.\n+ * In romd_mode, they behave like RAM and should be mapped.\n+ * Outside romd_mode, accesses should trap to QEMU for emulation.\n+ *\n+ * For non-RAM, non-rom_device regions (writable MMIO), we never map.\n+ * For rom_device regions not in romd_mode, we want them unmapped.\n */\n if (!memory_region_is_ram(area)) {\n if (writable) {\n@@ -195,6 +219,15 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,\n return;\n }\n \n+ is_mapped = uaddr_is_mapped(mml, start_addr);\n+\n+ if (add && is_mapped) {\n+ return;\n+ }\n+ if (!add && !is_mapped) {\n+ return;\n+ }\n+\n mr_offset = section->offset_within_region + start_addr -\n section->offset_within_address_space;\n \n@@ -210,4 +243,6 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,\n error_report(\"Failed to set memory region\");\n abort();\n }\n+\n+ track_region(mml, start_addr, add);\n }\ndiff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c\nindex d4cc7f5371..0a30149030 100644\n--- a/accel/mshv/mshv-all.c\n+++ b/accel/mshv/mshv-all.c\n@@ -371,6 +371,7 @@ static void register_mshv_memory_listener(MshvState *s, MshvMemoryListener *mml,\n \n mml->listener = mshv_memory_listener;\n mml->listener.name = name;\n+ mml->mapped_regions = g_hash_table_new(g_direct_hash, g_direct_equal);\n memory_listener_register(&mml->listener, as);\n for (i = 0; i < s->nr_as; ++i) {\n if (!s->as[i].as) {\ndiff --git a/include/system/mshv_int.h b/include/system/mshv_int.h\nindex 35386c422f..4aa1b6962d 100644\n--- a/include/system/mshv_int.h\n+++ b/include/system/mshv_int.h\n@@ -32,6 +32,7 @@ struct AccelCPUState {\n \n typedef struct MshvMemoryListener {\n MemoryListener listener;\n+ GHashTable *mapped_regions;\n int as_id;\n } MshvMemoryListener;\n \n", "prefixes": [] }