All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] [PATCH] linux-user/aarch64: Reset target data on MADV_DONTNEED
@ 2022-08-10 19:59 Vitaly Buka
  2022-08-10 20:03 ` Peter Maydell
  0 siblings, 1 reply; 13+ messages in thread
From: Vitaly Buka @ 2022-08-10 19:59 UTC (permalink / raw)
  To: richard.henderson; +Cc: qemu-arm, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 26 bytes --]

How can we land this one?

[-- Attachment #2: Type: text/html, Size: 47 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH] [PATCH] linux-user/aarch64: Reset target data on MADV_DONTNEED
@ 2022-07-11 22:00 Vitaly Buka
  2022-07-12  4:51 ` Richard Henderson
  0 siblings, 1 reply; 13+ messages in thread
From: Vitaly Buka @ 2022-07-11 22:00 UTC (permalink / raw)
  To: qemu-devel, qemu-arm; +Cc: Richard Henderson, Vitaly Buka

aarch64 stores MTE tags in target_date, and they should be reset by
MADV_DONTNEED.

Signed-off-by: Vitaly Buka <vitalybuka@google.com>
---
 accel/tcg/translate-all.c | 24 ++++++++++++++++++++++++
 include/exec/cpu-all.h    |  1 +
 linux-user/mmap.c         |  2 ++
 3 files changed, 27 insertions(+)

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index ef62a199c7..d6f2f1a40a 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2314,6 +2314,30 @@ 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 4e7a6be6ee..c535dfdc7c 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -894,6 +894,8 @@ 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();
 
-- 
2.37.0.144.g8ac04bfd2-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-08-16 10:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10 19:59 [PATCH] [PATCH] linux-user/aarch64: Reset target data on MADV_DONTNEED Vitaly Buka
2022-08-10 20:03 ` Peter Maydell
2022-08-10 20:32   ` Vitaly Buka
2022-08-10 20:47     ` Richard Henderson
2022-08-11  8:29       ` Laurent Vivier
2022-08-11 11:54         ` Peter Maydell
2022-08-11 12:27           ` Laurent Vivier
2022-08-11 15:18             ` Alex Bennée
2022-08-13 15:54               ` Laurent Vivier
2022-08-16  8:41                 ` Alex Bennée
2022-08-16 10:50                   ` Laurent Vivier
  -- strict thread matches above, loose matches on Subject: below --
2022-07-11 22:00 Vitaly Buka
2022-07-12  4:51 ` Richard Henderson

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.