hvf: Avoid mapping regions < PAGE_SIZE as ram
PATCH 1/1 hvf: Avoid mapping regions < PAGE_SIZE as ram
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions.
So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead.
--- accel/hvf/hvf-accel-ops.c | 6 ++++++ 1 file changed, 6 insertions(+)
accel/hvf/hvf-accel-ops.c +6 -0
@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) } } +if (int128_get64 (section->size) & (qemu_real_host_page_size -1 ) || + section->offset_within_address_space & (qemu_real_host_page_size -1 )) { +/* Not page aligned, so we can not map as RAM */ + add = false; + } + mem =hvf_find_overlap_slot ( section->offset_within_address_space,int128_get64 (section->size));
Signature · 1 line
2.30.1 (Apple Git-130)
Hi Alex,
Quoted 16 lines · Alexander Graf
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions.
So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead.
Signed-off-by Alexander Graf <[email protected]>--- accel/hvf/hvf-accel-ops.c | 6 ++++++ 1 file changed, 6 insertions(+)accel/hvf/hvf-accel-ops.c +0
-0
accel/hvf/hvf-accel-ops.c static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) · line 139
Quoted 5 lines
accel/hvf/hvf-accel-ops.c +2
-0@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) } } +if (int128_get64 (section->size) & (qemu_real_host_page_size -1 ) || + section->offset_within_address_space & (qemu_real_host_page_size -1 )) {
Could we use QEMU_IS_ALIGNED() instead?
Quoted 8 lines
accel/hvf/hvf-accel-ops.c +4
-0+/* Not page aligned, so we can not map as RAM */ + add = false; + } + mem =hvf_find_overlap_slot ( section->offset_within_address_space,int128_get64 (section->size));
Paolo Bonzini
AppliedQuoted 19 lines · Alexander Graf
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions.
So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead.
Signed-off-by Alexander Graf <[email protected]>--- accel/hvf/hvf-accel-ops.c | 6 ++++++ 1 file changed, 6 insertions(+)accel/hvf/hvf-accel-ops.c +0
-0@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) } }
accel/hvf/hvf-accel-ops.c static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) · line 146
Quoted 10 lines
accel/hvf/hvf-accel-ops.c +6
-0+if (int128_get64 (section->size) & (qemu_real_host_page_size -1 ) || + section->offset_within_address_space & (qemu_real_host_page_size -1 )) { +/* Not page aligned, so we can not map as RAM */ + add = false; + } + mem =hvf_find_overlap_slot ( section->offset_within_address_space,int128_get64 (section->size));
Queued, thanks.
Paolo
Quoted 25 lines · Paolo Bonzini
Quoted 24 lines · Alexander Graf
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions.
So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead.
Signed-off-by Alexander Graf <[email protected]>---
accel/hvf/hvf-accel-ops.c| 6 ++++++1 file changed, 6 insertions(+)accel/hvf/hvf-accel-ops.c +0
-0@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) } }+ if (
int128_get64(section->size)& (qemu_real_host_page_size- 1) || +section->offset_within_address_space& (qemu_real_host_page_size- 1)) {
+ /* Not page aligned, so we can not map as RAM */
+ add = false;
Quoted 8 lines
Quoted 6 lines
+ }
+
mem =hvf_find_overlap_slot( section->offset_within_address_space, int128_get64(section->size));Queued, thanks.
You probably want v2 instead :)
Alex
Quoted 14 lines · Alexander Graf
Quoted 14 lines
Quoted 13 lines
}
}
+ if (int128_get64(section->size)& (qemu_real_host_page_size- 1) || +section->offset_within_address_space& (qemu_real_host_page_size- 1)) {
+ /* Not page aligned, so we can not map as RAM */
+ add = false;
+ }
+
mem =hvf_find_overlap_slot( section->offset_within_address_space, int128_get64(section->size));
Quoted 4 lines
Quoted 1 line
Queued, thanks.
You probably want v2 instead :)
That's actually what I had applied. :)
Paolo