[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 8/8] memory: abort on re-entrancy in debug builds
From: |
Alexander Bulekov |
Subject: |
[PATCH v8 8/8] memory: abort on re-entrancy in debug builds |
Date: |
Fri, 21 Apr 2023 10:27:36 -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>
---
softmmu/memory.c | 3 +++
util/async.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/softmmu/memory.c b/softmmu/memory.c
index a11ee3e30d..5390f91db6 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
- Re: [PATCH v8 1/8] memory: prevent dma-reentracy issues, (continued)
- [PATCH v8 3/8] checkpatch: add qemu_bh_new/aio_bh_new checks, Alexander Bulekov, 2023/04/21
- [PATCH v8 2/8] async: Add an optional reentrancy guard to the BH API, Alexander Bulekov, 2023/04/21
- [PATCH v8 5/8] memory: Allow disabling re-entrancy checking per-MR, Alexander Bulekov, 2023/04/21
- [PATCH v8 4/8] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded, Alexander Bulekov, 2023/04/21
- [PATCH v8 6/8] lsi53c895a: disable reentrancy detection for script RAM, Alexander Bulekov, 2023/04/21
- [PATCH v8 7/8] bcm2835_property: disable reentrancy detection for iomem, Alexander Bulekov, 2023/04/21
- [PATCH v8 8/8] memory: abort on re-entrancy in debug builds,
Alexander Bulekov <=
- Re: [PATCH v8 0/8] memory: prevent dma-reentracy issues, Thomas Huth, 2023/04/25