[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/7] exec.c: Use subpages for large unaligned mappin
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 6/7] exec.c: Use subpages for large unaligned mappings |
Date: |
Fri, 3 Aug 2012 11:51:05 +0100 |
From: Tyler Hall <address@hidden>
Registering a multi-page memory region that is non-page-aligned results
in a subpage from the start to the page boundary, some number of full
pages, and possibly another subpage from the last page boundary to the
end. The full pages will have a value for offset_within_region that is
not a multiple of TARGET_PAGE_SIZE. Accesses through softmmu are unable
to handle this and will segfault.
Handling full pages through subpages is not optimal, but only
non-page-aligned mappings take the penalty.
Signed-off-by: Tyler Hall <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Reviewed-by: Avi Kivity <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
exec.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/exec.c b/exec.c
index 27b100c..e6ac3e7 100644
--- a/exec.c
+++ b/exec.c
@@ -2305,10 +2305,15 @@ void
cpu_register_physical_memory_log(MemoryRegionSection *section,
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
}
- now = remain;
- now.size &= TARGET_PAGE_MASK;
- if (now.size) {
- register_multipage(&now);
+ while (remain.size >= TARGET_PAGE_SIZE) {
+ now = remain;
+ if (remain.offset_within_region & ~TARGET_PAGE_MASK) {
+ now.size = TARGET_PAGE_SIZE;
+ register_subpage(&now);
+ } else {
+ now.size &= TARGET_PAGE_MASK;
+ register_multipage(&now);
+ }
remain.size -= now.size;
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
--
1.7.10.4
- [Qemu-devel] [PULL 0/7] Trivial patches for 22 July to 3 August 2012, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 3/7] remove unused include of error.h, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 2/7] qom: Clean libuser object and dependency files, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 1/7] usb: Clean common object and dependency files, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 5/7] exec.c: Fix off-by-one error in register_subpage, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 7/7] exec.c: Remove out of date comment, Stefan Hajnoczi, 2012/08/03
- [Qemu-devel] [PATCH 6/7] exec.c: Use subpages for large unaligned mappings,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 4/7] socket: clean up redundant assignment, Stefan Hajnoczi, 2012/08/03
- Re: [Qemu-devel] [PULL 0/7] Trivial patches for 22 July to 3 August 2012, Stefan Hajnoczi, 2012/08/03