]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: log page table changes under -d page
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 5 Dec 2019 12:25:15 +0000 (12:25 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Thu, 19 Dec 2019 08:20:16 +0000 (08:20 +0000)
The CPU_LOG_PAGE flag is woefully underused and could stand to do
extra duty tracking page changes. If the user doesn't want to see the
details as things change they still have the tracepoints available.

We push the locking into log_page_dump and pass a reason for the
banner text.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20191205122518.10010-5-alex.bennee@linaro.org>

bsd-user/main.c
include/exec/log.h
linux-user/main.c
linux-user/mmap.c

index 470a8bf79ed7a659628b4ef3b71e1add1ddf678e..7f4e3cd6271a2bcbf613860aaede568c6d085b22 100644 (file)
@@ -963,7 +963,7 @@ int main(int argc, char **argv)
 
     if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
         qemu_log("guest_base  0x%lx\n", guest_base);
-        log_page_dump();
+        log_page_dump("binary load");
 
         qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
         qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
index 9bd1e4aa20bc119df7045031ebbfc88f66f07523..fcc7b9e00ba866a96b1a361424dc2f9806f6e23c 100644 (file)
@@ -69,15 +69,14 @@ static inline void log_disas(void *code, unsigned long size)
 
 #if defined(CONFIG_USER_ONLY)
 /* page_dump() output to the log file: */
-static inline void log_page_dump(void)
+static inline void log_page_dump(const char *operation)
 {
-    QemuLogFile *logfile;
-    rcu_read_lock();
-    logfile = atomic_rcu_read(&qemu_logfile);
+    FILE *logfile = qemu_log_lock();
     if (logfile) {
-        page_dump(logfile->fd);
+        qemu_log("page layout changed following %s\n", operation);
+        page_dump(logfile);
     }
-    rcu_read_unlock();
+    qemu_log_unlock(logfile);
 }
 #endif
 #endif
index 6ff7851e86f68290ad87d8924ee96121f2e6d98f..8718d03ee21c33e0f4c282758fae6928d9b4a907 100644 (file)
@@ -826,7 +826,7 @@ int main(int argc, char **argv, char **envp)
 
     if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
         qemu_log("guest_base  0x%lx\n", guest_base);
-        log_page_dump();
+        log_page_dump("binary load");
 
         qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
         qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
index 0b1b43ac3c060e4f306ed46ab94c80b9a1f1b27a..3d90fa459ca60711eec764abc3c60ac4cdc9f3d6 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "trace.h"
+#include "exec/log.h"
 #include "qemu.h"
 
 //#define DEBUG_MMAP
@@ -539,10 +540,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     page_set_flags(start, start + len, prot | PAGE_VALID);
  the_end:
     trace_target_mmap_complete(start);
-#ifdef DEBUG_MMAP
-    page_dump(stdout);
-    printf("\n");
-#endif
+    if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
+        log_page_dump(__func__);
+    }
     tb_invalidate_phys_range(start, start + len);
     mmap_unlock();
     return start;