qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v9 7/8] memory: abort on re-entrancy in debug builds


From: Alexander Bulekov
Subject: [PATCH v9 7/8] memory: abort on re-entrancy in debug builds
Date: Wed, 26 Apr 2023 12:19:50 -0400

This is useful for using unit-tests/fuzzing to detect bugs introduced by
the re-entrancy guard mechanism into devices that are intentionally
re-entrant.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 softmmu/memory.c | 3 +++
 util/async.c     | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index af9365bb81..d038633a6c 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -547,6 +547,9 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
         !mr->ram_device && !mr->ram && !mr->rom_device && !mr->readonly) {
         if (mr->dev->mem_reentrancy_guard.engaged_in_io) {
             trace_memory_region_reentrant_io(get_cpu_index(), mr, addr, size);
+#ifdef DEBUG
+            abort();
+#endif
             return MEMTX_ACCESS_ERROR;
         }
         mr->dev->mem_reentrancy_guard.engaged_in_io = true;
diff --git a/util/async.c b/util/async.c
index a9b528c370..2dc9389e0d 100644
--- a/util/async.c
+++ b/util/async.c
@@ -160,6 +160,9 @@ void aio_bh_call(QEMUBH *bh)
         last_engaged_in_io = bh->reentrancy_guard->engaged_in_io;
         if (bh->reentrancy_guard->engaged_in_io) {
             trace_reentrant_aio(bh->ctx, bh->name);
+#ifdef DEBUG
+            abort();
+#endif
         }
         bh->reentrancy_guard->engaged_in_io = true;
     }
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]