From: BALATON Zoltan <balaton@eik.bme.hu>
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org
Subject: [PATCH 1/2] log: Add separate debug option for logging invalid memory accesses
Date: Thu, 19 Jan 2023 22:40:32 +0100 (CET) [thread overview]
Message-ID: <20230119214032.4BF1E7457E7@zero.eik.bme.hu> (raw)
Currently -d guest_errors enables logging of different invalid actions
by the guest such as misusing hardware, accessing missing features or
invalid memory areas. The memory access logging can be quite verbose
which obscures the other messages enabled by this debug switch so
separate it by adding a new -d memaccess option to make it possible to
control it independently of other guest error logs.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
include/qemu/log.h | 1 +
softmmu/memory.c | 6 +++---
softmmu/physmem.c | 2 +-
util/log.c | 2 ++
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/qemu/log.h b/include/qemu/log.h
index c5643d8dd5..4bf0a65a85 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -35,6 +35,7 @@ bool qemu_log_separate(void);
/* LOG_STRACE is used for user-mode strace logging. */
#define LOG_STRACE (1 << 19)
#define LOG_PER_THREAD (1 << 20)
+#define LOG_MEM_ACCESS (1 << 21)
/* Lock/unlock output. */
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 9d64efca26..0a9fa67d32 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1379,7 +1379,7 @@ bool memory_region_access_valid(MemoryRegion *mr,
{
if (mr->ops->valid.accepts
&& !mr->ops->valid.accepts(mr->opaque, addr, size, is_write, attrs)) {
- qemu_log_mask(LOG_GUEST_ERROR, "Invalid %s at addr 0x%" HWADDR_PRIX
+ qemu_log_mask(LOG_MEM_ACCESS, "Invalid %s at addr 0x%" HWADDR_PRIX
", size %u, region '%s', reason: rejected\n",
is_write ? "write" : "read",
addr, size, memory_region_name(mr));
@@ -1387,7 +1387,7 @@ bool memory_region_access_valid(MemoryRegion *mr,
}
if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
- qemu_log_mask(LOG_GUEST_ERROR, "Invalid %s at addr 0x%" HWADDR_PRIX
+ qemu_log_mask(LOG_MEM_ACCESS, "Invalid %s at addr 0x%" HWADDR_PRIX
", size %u, region '%s', reason: unaligned\n",
is_write ? "write" : "read",
addr, size, memory_region_name(mr));
@@ -1401,7 +1401,7 @@ bool memory_region_access_valid(MemoryRegion *mr,
if (size > mr->ops->valid.max_access_size
|| size < mr->ops->valid.min_access_size) {
- qemu_log_mask(LOG_GUEST_ERROR, "Invalid %s at addr 0x%" HWADDR_PRIX
+ qemu_log_mask(LOG_MEM_ACCESS, "Invalid %s at addr 0x%" HWADDR_PRIX
", size %u, region '%s', reason: invalid size "
"(min:%u max:%u)\n",
is_write ? "write" : "read",
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index bf585e45a8..bca679ee01 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -2792,7 +2792,7 @@ static bool flatview_access_allowed(MemoryRegion *mr, MemTxAttrs attrs,
if (memory_region_is_ram(mr)) {
return true;
}
- qemu_log_mask(LOG_GUEST_ERROR,
+ qemu_log_mask(LOG_MEM_ACCESS,
"Invalid access to non-RAM device at "
"addr 0x%" HWADDR_PRIX ", size %" HWADDR_PRIu ", "
"region '%s'\n", addr, len, memory_region_name(mr));
diff --git a/util/log.c b/util/log.c
index 7837ff9917..a3c097f320 100644
--- a/util/log.c
+++ b/util/log.c
@@ -495,6 +495,8 @@ const QEMULogItem qemu_log_items[] = {
"log every user-mode syscall, its input, and its result" },
{ LOG_PER_THREAD, "tid",
"open a separate log file per thread; filename must contain '%d'" },
+ { LOG_MEM_ACCESS, "memaccess",
+ "log invalid memory accesses" },
{ 0, NULL, NULL },
};
--
2.30.6
next reply other threads:[~2023-01-19 21:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 21:40 BALATON Zoltan [this message]
2023-01-31 14:28 ` [PATCH 1/2] log: Add separate debug option for logging invalid memory accesses BALATON Zoltan
2023-02-07 16:33 ` BALATON Zoltan
2023-02-13 11:41 ` Thomas Huth
2023-02-13 14:45 ` Peter Xu
2023-02-13 14:47 ` BALATON Zoltan
2023-02-13 14:58 ` Philippe Mathieu-Daudé
2023-02-13 15:09 ` Philippe Mathieu-Daudé
2023-02-13 16:36 ` BALATON Zoltan
2023-02-13 16:20 ` BALATON Zoltan
2023-02-13 16:15 ` Peter Xu
2023-02-13 16:34 ` BALATON Zoltan
2023-02-13 17:17 ` Peter Xu
2023-02-13 17:26 ` Philippe Mathieu-Daudé
2023-02-13 18:34 ` BALATON Zoltan
2023-02-13 21:25 ` Peter Xu
2023-02-13 22:43 ` BALATON Zoltan
2023-02-28 22:19 ` BALATON Zoltan
2023-02-13 13:45 ` Philippe Mathieu-Daudé
2023-02-13 14:32 ` BALATON Zoltan
-- strict thread matches above, loose matches on Subject: below --
2024-10-06 16:49 [PATCH 0/2] Separate memory access logs from guest_errors BALATON Zoltan
2024-10-06 16:49 ` [PATCH 1/2] log: Add separate debug option for logging invalid memory accesses BALATON Zoltan
2024-10-14 14:13 ` Peter Maydell
2024-10-14 16:48 ` BALATON Zoltan
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=20230119214032.4BF1E7457E7@zero.eik.bme.hu \
--to=balaton@eik.bme.hu \
--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).