From: Tyler Hall <tylerwhall@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Tyler Hall <tylerwhall@gmail.com>
Subject: [Qemu-trivial] [PATCH 2/2] exec.c: Use subpages for large unaligned mappings
Date: Wed, 25 Jul 2012 18:45:04 -0400 [thread overview]
Message-ID: <1343256304-32029-2-git-send-email-tylerwhall@gmail.com> (raw)
In-Reply-To: <1343256304-32029-1-git-send-email-tylerwhall@gmail.com>
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 <tylerwhall@gmail.com>
---
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.11
WARNING: multiple messages have this Message-ID (diff)
From: Tyler Hall <tylerwhall@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Tyler Hall <tylerwhall@gmail.com>
Subject: [Qemu-devel] [PATCH 2/2] exec.c: Use subpages for large unaligned mappings
Date: Wed, 25 Jul 2012 18:45:04 -0400 [thread overview]
Message-ID: <1343256304-32029-2-git-send-email-tylerwhall@gmail.com> (raw)
In-Reply-To: <1343256304-32029-1-git-send-email-tylerwhall@gmail.com>
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 <tylerwhall@gmail.com>
---
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.11
next prev parent reply other threads:[~2012-07-25 22:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-25 22:45 [Qemu-trivial] [PATCH 1/2] exec.c: Fix off-by-one error in register_subpage Tyler Hall
2012-07-25 22:45 ` [Qemu-devel] " Tyler Hall
2012-07-25 22:45 ` Tyler Hall [this message]
2012-07-25 22:45 ` [Qemu-devel] [PATCH 2/2] exec.c: Use subpages for large unaligned mappings Tyler Hall
2012-08-01 13:02 ` [Qemu-trivial] " Avi Kivity
2012-08-01 13:02 ` Avi Kivity
2012-08-01 10:42 ` [Qemu-trivial] [PATCH 1/2] exec.c: Fix off-by-one error in register_subpage Stefan Hajnoczi
2012-08-01 10:42 ` [Qemu-devel] " Stefan Hajnoczi
2012-08-01 12:52 ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2012-08-01 12:52 ` [Qemu-devel] [Qemu-trivial] " Peter Maydell
2012-08-01 12:56 ` [Qemu-trivial] [Qemu-devel] " Avi Kivity
2012-08-01 12:56 ` Avi Kivity
2012-08-01 13:01 ` [Qemu-trivial] " Stefan Hajnoczi
2012-08-01 13:01 ` Stefan Hajnoczi
2012-08-01 13:03 ` [Qemu-trivial] " Avi Kivity
2012-08-01 13:03 ` Avi Kivity
2012-08-03 9:55 ` [Qemu-trivial] " Stefan Hajnoczi
2012-08-03 9:55 ` [Qemu-devel] " Stefan Hajnoczi
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=1343256304-32029-2-git-send-email-tylerwhall@gmail.com \
--to=tylerwhall@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.