From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: cota@braap.org, peter.maydell@linaro.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH for-8.0 06/11] accel/tcg: Pass last not end to page_reset_target_data
Date: Wed, 22 Mar 2023 08:07:39 -0700 [thread overview]
Message-ID: <20230322150744.175010-7-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230322150744.175010-1-richard.henderson@linaro.org>
Pass the address of the last byte to be changed, rather than
the first address past the last byte. This avoids overflow
when the last page of the address space is involved.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/cpu-all.h | 2 +-
accel/tcg/user-exec.c | 11 +++++------
linux-user/mmap.c | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index be99cd3621..090922e4a8 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -286,7 +286,7 @@ int walk_memory_regions(void *, walk_memory_regions_fn);
int page_get_flags(target_ulong address);
void page_set_flags(target_ulong start, target_ulong last, int flags);
-void page_reset_target_data(target_ulong start, target_ulong end);
+void page_reset_target_data(target_ulong start, target_ulong last);
int page_check_range(target_ulong start, target_ulong len, int flags);
/**
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 035f8096b2..20b6fc2f6e 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -508,7 +508,7 @@ void page_set_flags(target_ulong start, target_ulong last, int flags)
}
if (!flags || reset) {
- page_reset_target_data(start, last + 1);
+ page_reset_target_data(start, last);
inval_tb |= pageflags_unset(start, last);
}
if (flags) {
@@ -814,15 +814,14 @@ typedef struct TargetPageDataNode {
static IntervalTreeRoot targetdata_root;
-void page_reset_target_data(target_ulong start, target_ulong end)
+void page_reset_target_data(target_ulong start, target_ulong last)
{
IntervalTreeNode *n, *next;
- target_ulong last;
assert_memory_lock();
- start = start & TARGET_PAGE_MASK;
- last = TARGET_PAGE_ALIGN(end) - 1;
+ start &= TARGET_PAGE_MASK;
+ last |= ~TARGET_PAGE_MASK;
for (n = interval_tree_iter_first(&targetdata_root, start, last),
next = n ? interval_tree_iter_next(n, start, last) : NULL;
@@ -885,7 +884,7 @@ void *page_get_target_data(target_ulong address)
return t->data[(page - region) >> TARGET_PAGE_BITS];
}
#else
-void page_reset_target_data(target_ulong start, target_ulong end) { }
+void page_reset_target_data(target_ulong start, target_ulong last) { }
#endif /* TARGET_PAGE_DATA_SIZE */
/* The softmmu versions of these helpers are in cputlb.c. */
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 9c70f51d97..0aa8ae7356 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -946,7 +946,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
if (can_passthrough_madvise(start, end)) {
ret = get_errno(madvise(g2h_untagged(start), len, advice));
if ((advice == MADV_DONTNEED) && (ret == 0)) {
- page_reset_target_data(start, start + len);
+ page_reset_target_data(start, start + len - 1);
}
}
}
--
2.34.1
next prev parent reply other threads:[~2023-03-22 15:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 15:07 [PATCH for-8.0 00/11] tcg patch queue Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 01/11] util: import GTree as QTree Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 02/11] tcg: use QTree instead of GTree Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 03/11] linux-user: Diagnose misaligned -R size Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 04/11] include/exec: Change reserved_va semantics to last byte Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 05/11] accel/tcg: Pass last not end to page_set_flags Richard Henderson
2023-03-22 15:07 ` Richard Henderson [this message]
2023-03-22 15:07 ` [PATCH for-8.0 07/11] accel/tcg: Pass last not end to PAGE_FOR_EACH_TB Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 08/11] accel/tcg: Pass last not end to page_collection_lock Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 09/11] accel/tcg: Pass last not end to tb_invalidate_phys_page_range__locked Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 10/11] accel/tcg: Pass last not end to tb_invalidate_phys_range Richard Henderson
2023-03-22 15:07 ` [PATCH for-8.0 11/11] linux-user/arm: Take more care allocating commpage Richard Henderson
2023-03-27 8:38 ` Alex Bennée
2023-03-27 12:47 ` Philippe Mathieu-Daudé
2023-03-27 17:36 ` Richard Henderson
2023-03-27 19:27 ` Richard Henderson
2023-03-27 19:42 ` Alex Bennée
2023-03-26 4:51 ` [PATCH for-8.0 00/11] tcg patch queue Richard Henderson
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=20230322150744.175010-7-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=cota@braap.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@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 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).