* [PATCH] WHPX: Add support for device backed memory regions
@ 2022-07-27 18:00 Aidan Khoury
2022-07-30 8:39 ` Helge Konetzka
0 siblings, 1 reply; 3+ messages in thread
From: Aidan Khoury @ 2022-07-27 18:00 UTC (permalink / raw)
To: qemu-devel; +Cc: sunilmut, Aidan Khoury
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] WHPX: Add support for device backed memory regions
2022-07-27 18:00 [PATCH] WHPX: Add support for device backed memory regions Aidan Khoury
@ 2022-07-30 8:39 ` Helge Konetzka
2024-04-30 9:59 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Helge Konetzka @ 2022-07-30 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Aidan Khoury
Am 27.07.22 um 20:00 schrieb Aidan Khoury:
> 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,
Test was successful on Windows 10 Pro, 21H1, build & test environment
MSYS2, MINGW64
Tested-by: Helge Konetzka <hk@zapateado.de>
Test execution after building and installing patched MSys2/Mingw64 package:
$ cp /mingw64/share/qemu/edk2-i386-vars.fd ./
$ qemu-system-x86_64 \
-M q35 \
-m 1536 \
-accel whpx,kernel-irqchip=off \
-drive
file=/mingw64/share/qemu/edk2-x86_64-code.fd,if=pflash,format=raw,readonly=on
\
-drive file=edk2-i386-vars.fd,if=pflash,format=raw,readonly=off \
-cdrom openSUSE-Leap-15.3-GNOME-Live-x86_64-Media.iso
Windows Hypervisor Platform accelerator is operational
D:\msys64\mingw64\bin\qemu-system-x86_64.exe: warning: WHPX: ROMD region
0x00000000ffc84000->0x0000000100000000
D:\msys64\mingw64\bin\qemu-system-x86_64.exe: warning: WHPX: ROMD region
0x00000000ffc00000->0x00000000ffc84000
qemu: warning: WHPX: ROMD region 0x00000000ffc00000->0x00000000ffc84000
qemu: warning: WHPX: ROMD region 0x00000000ffc00000->0x00000000ffc84000
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] WHPX: Add support for device backed memory regions
2022-07-30 8:39 ` Helge Konetzka
@ 2024-04-30 9:59 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-30 9:59 UTC (permalink / raw)
To: Aidan Khoury, qemu-devel
Cc: Helge Konetzka, Gerd Hoffmann, Paolo Bonzini, Laszlo Ersek
(old patch)
Cc'ing Paolo, Gerd
(and Laszlo for https://edk2.groups.io/g/discuss/topic/83941304)
On 30/7/22 10:39, Helge Konetzka wrote:
> Am 27.07.22 um 20:00 schrieb Aidan Khoury:
>> 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,
>
> Test was successful on Windows 10 Pro, 21H1, build & test environment
> MSYS2, MINGW64
>
> Tested-by: Helge Konetzka <hk@zapateado.de>
>
> Test execution after building and installing patched MSys2/Mingw64 package:
>
> $ cp /mingw64/share/qemu/edk2-i386-vars.fd ./
> $ qemu-system-x86_64 \
> -M q35 \
> -m 1536 \
> -accel whpx,kernel-irqchip=off \
> -drive
> file=/mingw64/share/qemu/edk2-x86_64-code.fd,if=pflash,format=raw,readonly=on \
> -drive file=edk2-i386-vars.fd,if=pflash,format=raw,readonly=off \
> -cdrom openSUSE-Leap-15.3-GNOME-Live-x86_64-Media.iso
>
> Windows Hypervisor Platform accelerator is operational
> D:\msys64\mingw64\bin\qemu-system-x86_64.exe: warning: WHPX: ROMD region
> 0x00000000ffc84000->0x0000000100000000
> D:\msys64\mingw64\bin\qemu-system-x86_64.exe: warning: WHPX: ROMD region
> 0x00000000ffc00000->0x00000000ffc84000
> qemu: warning: WHPX: ROMD region 0x00000000ffc00000->0x00000000ffc84000
> qemu: warning: WHPX: ROMD region 0x00000000ffc00000->0x00000000ffc84000
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-30 9:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-27 18:00 [PATCH] WHPX: Add support for device backed memory regions Aidan Khoury
2022-07-30 8:39 ` Helge Konetzka
2024-04-30 9:59 ` Philippe Mathieu-Daudé
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).