qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aidan Khoury <aidan@revers.engineering>
To: qemu-devel@nongnu.org
Cc: sunilmut@microsoft.com, Aidan Khoury <aidan@revers.engineering>
Subject: [PATCH] WHPX: Add support for device backed memory regions
Date: Wed, 27 Jul 2022 15:00:12 -0300	[thread overview]
Message-ID: <20220727180012.45615-1-aidan@revers.engineering> (raw)

Due to skipping the mapping of read only device memory, Windows
Hypervisor Platform would fail to emulate such memory accesses when booting
OVMF EDK2 firmware. This patch adds ROM device memory region support
for WHPX since the Windows Hypervisor Platform supports mapping read-only
device memory, which allows successful booting of OVMF EDK2 firmware.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/513
          https://gitlab.com/qemu-project/qemu/-/issues/934
Buglink: https://bugs.launchpad.net/bugs/1821595

Signed-off-by: Aidan Khoury <aidan@revers.engineering>
---
 target/i386/whpx/whpx-all.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b22a3314b4..7a61df1135 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2363,11 +2363,18 @@ static void whpx_process_section(MemoryRegionSection *section, int add)
     MemoryRegion *mr = section->mr;
     hwaddr start_pa = section->offset_within_address_space;
     ram_addr_t size = int128_get64(section->size);
+    bool is_romd = false;
     unsigned int delta;
     uint64_t host_va;
 
     if (!memory_region_is_ram(mr)) {
-        return;
+        if (memory_region_is_romd(mr)) {
+            is_romd = true;
+            warn_report("WHPX: ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
+                        start_pa, start_pa + size);
+        } else {
+            return;
+        }
     }
 
     delta = qemu_real_host_page_size() - (start_pa & ~qemu_real_host_page_mask());
@@ -2386,7 +2393,7 @@ static void whpx_process_section(MemoryRegionSection *section, int add)
             + section->offset_within_region + delta;
 
     whpx_update_mapping(start_pa, size, (void *)(uintptr_t)host_va, add,
-                        memory_region_is_rom(mr), mr->name);
+                        memory_region_is_rom(mr) || is_romd, mr->name);
 }
 
 static void whpx_region_add(MemoryListener *listener,
-- 
2.37.1




             reply	other threads:[~2022-07-27 20:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 18:00 Aidan Khoury [this message]
2022-07-30  8:39 ` [PATCH] WHPX: Add support for device backed memory regions Helge Konetzka
2024-04-30  9:59   ` Philippe Mathieu-Daudé

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=20220727180012.45615-1-aidan@revers.engineering \
    --to=aidan@revers.engineering \
    --cc=qemu-devel@nongnu.org \
    --cc=sunilmut@microsoft.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).