Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
memory: stricter checks prior to unsetting engaged_in_io
engaged_in_io could be unset by an MR with re-entrancy checks disabled.
Ensure that only MRs that can set the engaged_in_io flag can unset it.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20230516084002.3813836-1-alxndr@bu.edu>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
a1xndr authored and huth committed May 22, 2023
1 parent 1afae3b commit 3884bf6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion softmmu/memory.c
Expand Up @@ -534,6 +534,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
unsigned access_size;
unsigned i;
MemTxResult r = MEMTX_OK;
bool reentrancy_guard_applied = false;

if (!access_size_min) {
access_size_min = 1;
Expand All @@ -552,6 +553,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
return MEMTX_ACCESS_ERROR;
}
mr->dev->mem_reentrancy_guard.engaged_in_io = true;
reentrancy_guard_applied = true;
}

/* FIXME: support unaligned access? */
Expand All @@ -568,7 +570,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
access_mask, attrs);
}
}
if (mr->dev) {
if (mr->dev && reentrancy_guard_applied) {
mr->dev->mem_reentrancy_guard.engaged_in_io = false;
}
return r;
Expand Down

0 comments on commit 3884bf6

Please sign in to comment.