|
|
a6baaf |
From 251adb595eb7e39e9368cb7ed07f9a4c42d28d2c Mon Sep 17 00:00:00 2001
|
|
|
a6baaf |
From: Jon Maloy <jmaloy@redhat.com>
|
|
|
a6baaf |
Date: Wed, 21 Apr 2021 22:30:06 -0400
|
|
|
a6baaf |
Subject: [PATCH 7/8] softmmu/memory: Log invalid memory accesses
|
|
|
a6baaf |
MIME-Version: 1.0
|
|
|
a6baaf |
Content-Type: text/plain; charset=UTF-8
|
|
|
a6baaf |
Content-Transfer-Encoding: 8bit
|
|
|
a6baaf |
|
|
|
a6baaf |
RH-Author: Jon Maloy <jmaloy@redhat.com>
|
|
|
a6baaf |
Message-id: <20210421223006.19650-7-jmaloy@redhat.com>
|
|
|
a6baaf |
Patchwork-id: 101481
|
|
|
a6baaf |
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH v2 6/6] softmmu/memory: Log invalid memory accesses
|
|
|
a6baaf |
Bugzilla: 1944621
|
|
|
a6baaf |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
a6baaf |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
a6baaf |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
a6baaf |
|
|
|
a6baaf |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
a6baaf |
|
|
|
a6baaf |
Log invalid memory accesses with as GUEST_ERROR.
|
|
|
a6baaf |
|
|
|
a6baaf |
This is particularly useful since commit 5d971f9e67 which reverted
|
|
|
a6baaf |
("memory: accept mismatching sizes in memory_region_access_valid").
|
|
|
a6baaf |
|
|
|
a6baaf |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
a6baaf |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a6baaf |
Message-Id: <20201005152725.2143444-1-philmd@redhat.com>
|
|
|
a6baaf |
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
|
|
|
a6baaf |
|
|
|
a6baaf |
(cherry picked from commit 21786c7e59847b1612406ff394958f22e5b323f8)
|
|
|
a6baaf |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
a6baaf |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a6baaf |
---
|
|
|
a6baaf |
memory.c | 16 ++++++++++++++++
|
|
|
a6baaf |
1 file changed, 16 insertions(+)
|
|
|
a6baaf |
|
|
|
a6baaf |
diff --git a/memory.c b/memory.c
|
|
|
a6baaf |
index 0cfcb72a5a..660df8159a 100644
|
|
|
a6baaf |
--- a/memory.c
|
|
|
a6baaf |
+++ b/memory.c
|
|
|
a6baaf |
@@ -14,6 +14,7 @@
|
|
|
a6baaf |
*/
|
|
|
a6baaf |
|
|
|
a6baaf |
#include "qemu/osdep.h"
|
|
|
a6baaf |
+#include "qemu/log.h"
|
|
|
a6baaf |
#include "qapi/error.h"
|
|
|
a6baaf |
#include "cpu.h"
|
|
|
a6baaf |
#include "exec/memory.h"
|
|
|
a6baaf |
@@ -1353,10 +1354,18 @@ bool memory_region_access_valid(MemoryRegion *mr,
|
|
|
a6baaf |
{
|
|
|
a6baaf |
if (mr->ops->valid.accepts
|
|
|
a6baaf |
&& !mr->ops->valid.accepts(mr->opaque, addr, size, is_write, attrs)) {
|
|
|
a6baaf |
+ qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr "
|
|
|
a6baaf |
+ "0x%" HWADDR_PRIX ", size %u, "
|
|
|
a6baaf |
+ "region '%s', reason: rejected\n",
|
|
|
a6baaf |
+ addr, size, memory_region_name(mr));
|
|
|
a6baaf |
return false;
|
|
|
a6baaf |
}
|
|
|
a6baaf |
|
|
|
a6baaf |
if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
|
|
|
a6baaf |
+ qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr "
|
|
|
a6baaf |
+ "0x%" HWADDR_PRIX ", size %u, "
|
|
|
a6baaf |
+ "region '%s', reason: unaligned\n",
|
|
|
a6baaf |
+ addr, size, memory_region_name(mr));
|
|
|
a6baaf |
return false;
|
|
|
a6baaf |
}
|
|
|
a6baaf |
|
|
|
a6baaf |
@@ -1367,6 +1376,13 @@ bool memory_region_access_valid(MemoryRegion *mr,
|
|
|
a6baaf |
|
|
|
a6baaf |
if (size > mr->ops->valid.max_access_size
|
|
|
a6baaf |
|| size < mr->ops->valid.min_access_size) {
|
|
|
a6baaf |
+ qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr "
|
|
|
a6baaf |
+ "0x%" HWADDR_PRIX ", size %u, "
|
|
|
a6baaf |
+ "region '%s', reason: invalid size "
|
|
|
a6baaf |
+ "(min:%u max:%u)\n",
|
|
|
a6baaf |
+ addr, size, memory_region_name(mr),
|
|
|
a6baaf |
+ mr->ops->valid.min_access_size,
|
|
|
a6baaf |
+ mr->ops->valid.max_access_size);
|
|
|
a6baaf |
return false;
|
|
|
a6baaf |
}
|
|
|
a6baaf |
return true;
|
|
|
a6baaf |
--
|
|
|
a6baaf |
2.27.0
|
|
|
a6baaf |
|