aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-08-12 08:13:23 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-08-12 08:13:23 -0700
commit6add03bec031682a16ea73305469fa4c603b387e (patch)
tree79285544e4a484e0631a97263a6d7bf5caa37790
parenta6b1c53e79d08a99a28cc3e67a3e1a7c34102d6b (diff)
parentdbbf89751b14aa5d281bad3af273e9ffaae82262 (diff)
Merge tag 'linux-user-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging
Pull request linux-user 20220812 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmL2LIUSHGxhdXJlbnRA # dml2aWVyLmV1AAoJEPMMOL0/L748L8QP/iHtv9fsHZe7ANCMd2UjpPo5CZTJxMEa # T8muaNasIJPoZbQR5WJRsCT8j5lNriWYA/xEBYGYlzvn/ZBK+NnUlBYrRFUX3LwQ # Oim9gBYReW7nkv2m1Vr5mYXeC1bth4GMqycHSjwJtosYJsp/oTpcQE22/iG3MFBW # azu+yM/QV7yuoi6EFyuUq5hefQE139W333x01c3qsekVY4cr4Bc81cpsQhWw/4Y4 # e32byrT39vtBvRlC/CuikZXyMqbD+nK+hESkJ9oqI73raC4PaCg10WNHMr1m/pw1 # ITPeH6iphVmyOckidHsbBLDkC4FQEVNo9R4j13Nk2gqU3VyLk73Say2GGvXrUEBJ # a50XvV897N1M8ZiRUifYnNgawtO7sIOuQViofQtCcIfal9h2AV5Zjnm/5tJXGpnB # F0U7hi5bootHtJFMLCBOWLhWVT7SNrzi1ijCFs2irj6grSyvJ9LU7yRHj0pOVC43 # WopdzPuxBWye8jRo2YgDQx5BZkBtlmWJgfbhYL3QVFX5wp8vqAgdXl0dXqdid5RN # 5RCdBj9HAFwEUqL8n4LVI0EbrjI/IQlVwhZmBjQx3lBh4o08d7AUGUSQnZHDcy3C # W6dTkfqPleqdOw5xS9Rw3rHJPHcuGWQNA4MMyvztbMivU/TYN7fwBdXouI9KeeBk # wfYTi+n/bkeR # =4v8b # -----END PGP SIGNATURE----- # gpg: Signature made Fri 12 Aug 2022 03:33:41 AM PDT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [undefined] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [undefined] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * tag 'linux-user-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu: linux-user/aarch64: Reset target data on MADV_DONTNEED Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r--accel/tcg/translate-all.c26
-rw-r--r--include/exec/cpu-all.h1
-rw-r--r--linux-user/mmap.c3
3 files changed, 30 insertions, 0 deletions
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index ef62a199c7..b83161a081 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2314,6 +2314,32 @@ void page_set_flags(target_ulong start, target_ulong end, int flags)
}
}
+void page_reset_target_data(target_ulong start, target_ulong end)
+{
+ target_ulong addr, len;
+
+ /*
+ * This function should never be called with addresses outside the
+ * guest address space. If this assert fires, it probably indicates
+ * a missing call to h2g_valid.
+ */
+ assert(end - 1 <= GUEST_ADDR_MAX);
+ assert(start < end);
+ assert_memory_lock();
+
+ start = start & TARGET_PAGE_MASK;
+ end = TARGET_PAGE_ALIGN(end);
+
+ for (addr = start, len = end - start;
+ len != 0;
+ len -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
+ PageDesc *p = page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
+
+ g_free(p->target_data);
+ p->target_data = NULL;
+ }
+}
+
void *page_get_target_data(target_ulong address)
{
PageDesc *p = page_find(address >> TARGET_PAGE_BITS);
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index f5bda2c3ca..491629b9ba 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -271,6 +271,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 end, int flags);
+void page_reset_target_data(target_ulong start, target_ulong end);
int page_check_range(target_ulong start, target_ulong len, int flags);
/**
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index edceaca4a8..048c4135af 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -894,6 +894,9 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
if (advice == MADV_DONTNEED &&
can_passthrough_madv_dontneed(start, end)) {
ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED));
+ if (ret == 0) {
+ page_reset_target_data(start, start + len);
+ }
}
mmap_unlock();