Skip to content

Commit

Permalink
Merge pull request #1919 from PhilippTakacs/fix_cow
Browse files Browse the repository at this point in the history
fix cow when using uc_mem_write
  • Loading branch information
wtdcode authored Jan 11, 2024
2 parents e0eeda2 + 8d3bf02 commit 5e39cc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions qemu/softmmu/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ MemoryRegion *memory_cow(struct uc_struct *uc, MemoryRegion *current, hwaddr beg
hwaddr current_offset;
MemoryRegion *ram = g_new(MemoryRegion, 1);

assert((begin & ~TARGET_PAGE_MASK) == 0);
assert((size & ~TARGET_PAGE_MASK) == 0);

if (current->container == uc->system_memory) {
make_contained(uc, current);
}
Expand Down
5 changes: 4 additions & 1 deletion uc.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,10 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes,

len = memory_region_len(uc, mr, address, size - count);
if (uc->snapshot_level && uc->snapshot_level > mr->priority) {
mr = uc->memory_cow(uc, mr, address, len);
mr = uc->memory_cow(uc, mr, address & ~uc->target_page_align,
(len + (address & uc->target_page_align) +
uc->target_page_align) &
~uc->target_page_align);
if (!mr) {
return UC_ERR_NOMEM;
}
Expand Down

0 comments on commit 5e39cc6

Please sign in to comment.