diff --git a/qemu/aarch64.h b/qemu/aarch64.h index f863b035..67f38b47 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_aarch64 #define address_space_map address_space_map_aarch64 #define address_space_read address_space_read_aarch64 +#define address_space_read_continue address_space_read_continue_aarch64 #define address_space_rw address_space_rw_aarch64 #define address_space_translate address_space_translate_aarch64 #define address_space_translate_for_iotlb address_space_translate_for_iotlb_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index ecb2f459..b11e33da 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_aarch64eb #define address_space_map address_space_map_aarch64eb #define address_space_read address_space_read_aarch64eb +#define address_space_read_continue address_space_read_continue_aarch64eb #define address_space_rw address_space_rw_aarch64eb #define address_space_translate address_space_translate_aarch64eb #define address_space_translate_for_iotlb address_space_translate_for_iotlb_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 7e3f3024..63f56667 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_arm #define address_space_map address_space_map_arm #define address_space_read address_space_read_arm +#define address_space_read_continue address_space_read_continue_arm #define address_space_rw address_space_rw_arm #define address_space_translate address_space_translate_arm #define address_space_translate_for_iotlb address_space_translate_for_iotlb_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index bc8016bf..5c2df45c 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_armeb #define address_space_map address_space_map_armeb #define address_space_read address_space_read_armeb +#define address_space_read_continue address_space_read_continue_armeb #define address_space_rw address_space_rw_armeb #define address_space_translate address_space_translate_armeb #define address_space_translate_for_iotlb address_space_translate_for_iotlb_armeb diff --git a/qemu/exec.c b/qemu/exec.c index c99a3036..252dfa6b 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1795,24 +1795,19 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) return l; } -MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - const uint8_t *buf, int len) +static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, + int len, hwaddr addr1, + hwaddr l, MemoryRegion *mr) { - hwaddr l; uint8_t *ptr; uint64_t val; - hwaddr addr1; - MemoryRegion *mr; MemTxResult result = MEMTX_OK; // Unicorn: commented out //bool release_lock = false; - // Unicorn: commented out - //rcu_read_lock(); - while (len > 0) { - l = len; - - mr = address_space_translate(as, addr, &addr1, &l, true); + for (;;) { if (!mr) return true; @@ -1867,6 +1862,13 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, len -= l; buf += l; addr += l; + + if (!len) { + break; + } + + l = len; + mr = address_space_translate(as, addr, &addr1, &l, true); } // Unicorn: commented out //rcu_read_unlock(); @@ -1874,24 +1876,40 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, return result; } -MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len) +MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, + const uint8_t *buf, int len) { hwaddr l; - uint8_t *ptr; - uint64_t val; hwaddr addr1; MemoryRegion *mr; MemTxResult result = MEMTX_OK; + + if (len > 0) { + // Unicorn: commented out + //rcu_read_lock(); + l = len; + mr = address_space_translate(as, addr, &addr1, &l, true); + result = address_space_write_continue(as, addr, attrs, buf, len, + addr1, l, mr); + // Unicorn: commented out + //rcu_read_unlock(); + } + + return result; +} + +MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, + int len, hwaddr addr1, hwaddr l, + MemoryRegion *mr) +{ + uint8_t *ptr; + uint64_t val; + MemTxResult result = MEMTX_OK; // Unicorn: commented out //bool release_lock = false; - // Unicorn: commented out - //rcu_read_lock(); - while (len > 0) { - l = len; - mr = address_space_translate(as, addr, &addr1, &l, false); - + for (;;) { if (!memory_access_is_direct(mr, false)) { /* I/O case */ // Unicorn: commented out @@ -1940,11 +1958,36 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, len -= l; buf += l; addr += l; + + if (!len) { + break; + } + + l = len; + mr = address_space_translate(as, addr, &addr1, &l, false); } - // Unicorn: commented out - //rcu_read_unlock(); + return result; +} +MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, + uint8_t *buf, int len) +{ + hwaddr l; + hwaddr addr1; + MemoryRegion *mr; + MemTxResult result = MEMTX_OK; + + if (len > 0) { + // Unicorn: commented out + //rcu_read_lock(); + l = len; + mr = address_space_translate(as, addr, &addr1, &l, false); + result = address_space_read_continue(as, addr, attrs, buf, len, + addr1, l, mr); + // Unicorn: commented out + //rcu_read_unlock(); + } return result; } diff --git a/qemu/header_gen.py b/qemu/header_gen.py index d8bce1ac..f3311ea6 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -99,6 +99,7 @@ symbols = ( 'address_space_lookup_region', 'address_space_map', 'address_space_read', + 'address_space_read_continue', 'address_space_rw', 'address_space_translate', 'address_space_translate_for_iotlb', diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index aaab4d7d..dd8a8901 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -1077,7 +1077,6 @@ void *address_space_map(AddressSpace *as, hwaddr addr, void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, int is_write, hwaddr access_len); - void memory_register_types(struct uc_struct *uc); MemoryRegion *memory_map(struct uc_struct *uc, hwaddr begin, size_t size, uint32_t perms); @@ -1085,6 +1084,12 @@ MemoryRegion *memory_map_ptr(struct uc_struct *uc, hwaddr begin, size_t size, ui void memory_unmap(struct uc_struct *uc, MemoryRegion *mr); int memory_free(struct uc_struct *uc); +/* Internal functions, part of the implementation of address_space_read. */ +MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, + int len, hwaddr addr1, hwaddr l, + MemoryRegion *mr); + #endif #endif diff --git a/qemu/m68k.h b/qemu/m68k.h index 9926a2a6..f57b95bb 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_m68k #define address_space_map address_space_map_m68k #define address_space_read address_space_read_m68k +#define address_space_read_continue address_space_read_continue_m68k #define address_space_rw address_space_rw_m68k #define address_space_translate address_space_translate_m68k #define address_space_translate_for_iotlb address_space_translate_for_iotlb_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 7808743d..49fa40d3 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_mips #define address_space_map address_space_map_mips #define address_space_read address_space_read_mips +#define address_space_read_continue address_space_read_continue_mips #define address_space_rw address_space_rw_mips #define address_space_translate address_space_translate_mips #define address_space_translate_for_iotlb address_space_translate_for_iotlb_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 71a378c4..034a81f8 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_mips64 #define address_space_map address_space_map_mips64 #define address_space_read address_space_read_mips64 +#define address_space_read_continue address_space_read_continue_mips64 #define address_space_rw address_space_rw_mips64 #define address_space_translate address_space_translate_mips64 #define address_space_translate_for_iotlb address_space_translate_for_iotlb_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 3e2cab0a..e6a6622f 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_mips64el #define address_space_map address_space_map_mips64el #define address_space_read address_space_read_mips64el +#define address_space_read_continue address_space_read_continue_mips64el #define address_space_rw address_space_rw_mips64el #define address_space_translate address_space_translate_mips64el #define address_space_translate_for_iotlb address_space_translate_for_iotlb_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index dbb10be6..12d31d75 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_mipsel #define address_space_map address_space_map_mipsel #define address_space_read address_space_read_mipsel +#define address_space_read_continue address_space_read_continue_mipsel #define address_space_rw address_space_rw_mipsel #define address_space_translate address_space_translate_mipsel #define address_space_translate_for_iotlb address_space_translate_for_iotlb_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index 257cf274..b1b471eb 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_powerpc #define address_space_map address_space_map_powerpc #define address_space_read address_space_read_powerpc +#define address_space_read_continue address_space_read_continue_powerpc #define address_space_rw address_space_rw_powerpc #define address_space_translate address_space_translate_powerpc #define address_space_translate_for_iotlb address_space_translate_for_iotlb_powerpc diff --git a/qemu/sparc.h b/qemu/sparc.h index c5d4c014..4967d7fc 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_sparc #define address_space_map address_space_map_sparc #define address_space_read address_space_read_sparc +#define address_space_read_continue address_space_read_continue_sparc #define address_space_rw address_space_rw_sparc #define address_space_translate address_space_translate_sparc #define address_space_translate_for_iotlb address_space_translate_for_iotlb_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 2f489182..60c716be 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_sparc64 #define address_space_map address_space_map_sparc64 #define address_space_read address_space_read_sparc64 +#define address_space_read_continue address_space_read_continue_sparc64 #define address_space_rw address_space_rw_sparc64 #define address_space_translate address_space_translate_sparc64 #define address_space_translate_for_iotlb address_space_translate_for_iotlb_sparc64 diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 81349429..2c18d299 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -93,6 +93,7 @@ #define address_space_lookup_region address_space_lookup_region_x86_64 #define address_space_map address_space_map_x86_64 #define address_space_read address_space_read_x86_64 +#define address_space_read_continue address_space_read_continue_x86_64 #define address_space_rw address_space_rw_x86_64 #define address_space_translate address_space_translate_x86_64 #define address_space_translate_for_iotlb address_space_translate_for_iotlb_x86_64