From: Wei Yang <richardw.yang@linux.intel.com>
To: qemu-devel@nongnu.org
Cc: rth@twiddle.net, pbonzini@redhat.com,
Wei Yang <richardw.yang@linux.intel.com>
Subject: [Qemu-devel] [PATCH] exec.c: remove an unnecessary condition in flatview_add_to_dispatch()
Date: Mon, 4 Mar 2019 14:51:02 +0800 [thread overview]
Message-ID: <20190304065102.26447-1-richardw.yang@linux.intel.com> (raw)
flatview_add_to_dispatch() registers page based on the condition of
*section*, which may looks like this:
|s|PPPPPPP|s|
where s stands for subpage and P for page.
The procedure of this function could be described as:
- register first subpage
- register page
- register last subpage
This means only the first offset_within_address_space could be not
TARGET_PAGE_SIZE aligned. During the wile loop, this will not happen.
This patch just removes the unnecessary condition and adds some comment
to clarify it.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
exec.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/exec.c b/exec.c
index 518064530b..e6221d52ba 100644
--- a/exec.c
+++ b/exec.c
@@ -1599,12 +1599,26 @@ static void register_multipage(FlatView *fv,
phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index);
}
+/*
+ * The range in *section* may look like this:
+ *
+ * |s|PPPPPPP|s|
+ *
+ * where s stands for subpage and P for page.
+ *
+ * The procedure in following function could be described as:
+ *
+ * - register first subpage
+ * - register page
+ * - register last subpage
+ */
void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section)
{
MemoryRegionSection now = *section, remain = *section;
Int128 page_size = int128_make64(TARGET_PAGE_SIZE);
if (now.offset_within_address_space & ~TARGET_PAGE_MASK) {
+ /* register first subpage */
uint64_t left = TARGET_PAGE_ALIGN(now.offset_within_address_space)
- now.offset_within_address_space;
@@ -1619,11 +1633,10 @@ void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section)
remain.offset_within_region += int128_get64(now.size);
now = remain;
if (int128_lt(remain.size, page_size)) {
- register_subpage(fv, &now);
- } else if (remain.offset_within_address_space & ~TARGET_PAGE_MASK) {
- now.size = page_size;
+ /* register last subpage */
register_subpage(fv, &now);
} else {
+ /* register page */
now.size = int128_and(now.size, int128_neg(page_size));
register_multipage(fv, &now);
}
--
2.19.1
next reply other threads:[~2019-03-04 6:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 6:51 Wei Yang [this message]
2019-03-04 9:55 ` [Qemu-devel] [PATCH] exec.c: remove an unnecessary condition in flatview_add_to_dispatch() Paolo Bonzini
2019-03-04 21:21 ` Wei Yang
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=20190304065102.26447-1-richardw.yang@linux.intel.com \
--to=richardw.yang@linux.intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).