Commit Graph

315 Commits

Author SHA1 Message Date
mio 87c0b86248
Format code 2024-09-21 17:59:23 +08:00
mio a5fa548049
Fix qemu_vfree implementation on MINGW
Also correctly release bounce.buffer
2024-09-21 17:58:15 +08:00
BitMaskMixer 8e6499fb0b
gcc compiler warning fixes (#1977)
* fix for enum-int-mismatch

* fix for unused-variable
2024-07-19 11:09:57 +08:00
PhilippTakacs 7d8b06b704
snapshot restore don't remove terminating regions (#1968) 2024-06-29 22:36:02 +08:00
lazymio 71c729a9d7
Define HAVE_SPRR 2024-02-13 19:09:35 +08:00
lazymio aef3bd4a27
Fix defines in uc.c 2024-02-13 12:11:27 +08:00
lazymio a6fb2a6870
Save jit state before/after callback 2024-02-13 11:13:01 +08:00
lazymio 822bb527f3
M1 W^X fully supported 2024-02-12 00:10:44 +08:00
Takacs, Philipp d9d2c4e581 fix uc_mem write with cow when using upper half of the address
uc->target_page_align is a uint32_t. When the binary not will only
invert the 32 bit of the value. Used this in a binary and operator with
a uint64_t will case the upper 32bit of the address to be 0. Therefor
the bug only appears when the upper 32bit of the address are used.

Now a local uint64_t variable is used for the alignemend and the test
uses a not page alligned address which does not fit in 32bit.
2024-01-15 14:20:29 +01:00
Takacs, Philipp 8d3bf02041 fix cow when using uc_mem_write
memory_cow expect the address and size to be aligned on pagesize.
2024-01-10 15:54:46 +01:00
lazymio 6801e156aa
Format code 2023-08-06 21:53:42 +08:00
Takacs, Philipp df18756234 implement uc_mem_unmap with snapshots
still has todos and need tests
2023-07-11 11:51:44 +02:00
Takacs, Philipp 716c8f1c4c handle snapshots over context_save context_restore 2023-07-11 11:51:44 +02:00
Takacs, Philipp 80bd825420 implement simple memory snapshot mechanismus
Uses Copy on Write to make it posible to restore the memory state after a snapshot
was made. To restore all MemoryRegions created after the snapshot are removed.
2023-07-11 11:51:40 +02:00
Takacs, Philipp 065af19dc5 use address_space_translate to find memory mapping
first version has bugs
2023-07-11 11:47:50 +02:00
Robert Xiao 2b80ab425b Return new UC_ERR_OVERFLOW instead of UC_ERR_NOMEM when reg buffer is too small 2023-06-16 15:30:59 -07:00
Robert Xiao 30d202b89e Simplify reg_read/reg_write, obtaining a perf boost.
Single reg_read/reg_write is now about 25% faster.
2023-06-16 15:23:42 -07:00
Robert Xiao 074566cf69 Slight refactoring to reduce code duplication.
This also comes with a performance bump due to inlining of reg_read/reg_write
(as they're only called once now) and the unlikely() on CHECK_REG_TYPE.
2023-06-16 15:23:42 -07:00
Robert Xiao 4055a5ab10 Implement uc_reg_{read,write}{,_batch}2 APIs.
These APIs take size parameters, which can be used to properly bounds-check the
inputs and outputs for various registers. Additionally, all backends now throw
UC_ERR_ARG if the input register numbers are invalid.

Completes #1831.
2023-06-16 15:23:42 -07:00
Robert Xiao d7a806c026 Reformat code with format.sh 2023-06-16 15:23:41 -07:00
mio 8dffbc159c
Add uc_ctl_get/set_tcg_buffer_size
We still need this API because the virtual memory address space of

32 bits os is only 4GB and we default need 1G per instance

Credits to @ZehMatt for original idea

Co-authored-by: ζeh Matt <5415177+ZehMatt@users.noreply.github.com>
2023-06-10 23:36:02 +02:00
mio f8c7969d65
Revert "Add uc_ctl_get/set_tcg_buffer_size"
This reverts commit 3145e3c426 because not
properly co-authoer-ed.
2023-06-10 23:29:56 +02:00
mio 3145e3c426
Add uc_ctl_get/set_tcg_buffer_size 2023-06-10 16:08:29 +02:00
Takacs, Philipp 54870cca0e remove unused function cmp_vaddr 2023-05-08 15:32:58 +02:00
Takacs, Philipp 8b2c477578 clear the TLB cache in uc_ctl_flush_tlb
uc_ctl_flush_tlb implies that the tlb is flushed. This change adds
UC_CTL_TLB_FLUSH which clears the TLB and set the uc_ctl_flush_tlb
alias to UC_CTL_TLB_FLUSH. Also adds a uc_ctl_flush_tb alias for
UC_CTL_TB_FLUSH.
2023-03-28 14:11:41 +02:00
Takacs, Philipp e96ac42b2e Remove MMU hacks
Unicorn has included some ugly hacks to provide a envirement where vaddr == paddr.
These hacks where to use the full 64 bit mappings on x86 without init the mmu
and some memory redirect for MIPS.

The UC_TLB_CPU mode defaults to vaddr == paddr, therfor these hacks aren't
required anymore.
2023-03-28 14:02:17 +02:00
Takacs, Philipp e25419bb2d add virtuall tlb
this virtuall tlb allows to use mmu indipendent of the architectur
2023-03-28 13:50:11 +02:00
Choongwoo Han 0a38a0bf17 Fix test failure 2023-03-20 18:41:59 -07:00
Choongwoo Han 8f2841ecdb Cache index for find_memory_region 2023-03-20 17:07:15 -07:00
Takacs, Philipp b7b1a4d6b4 difference between stop_request and quit_request
quit_request is for internal use. This means the IP register was updated and
qemu needs to rebuild the translation blocks.

stop_request is set by the user (uc_emu_stop) to indecate that unicorn sould
stop emulating.
2023-03-07 14:38:49 +01:00
Nguyen Anh Quynh eb118528b1 rename memory_mapping() to find_memory_region() and simplify mem_map() 2023-02-06 17:59:16 +08:00
Takacs, Philipp a490ece557 Do not search for the RAMBlock in split_region
The MemoryRegion already contains a pointer to the RAMBlock. So it is
not necesary to search for it.
2023-01-18 16:24:06 +01:00
mio 563104fa91
IP register is 2 bytes 2022-10-28 17:44:17 +02:00
mio 3c18ddcc41
Fix PC write for PPC32/64 2022-10-28 16:23:50 +02:00
mio 98980c904c
Pass the correct size integers 2022-10-28 15:59:14 +02:00
mio 19d8876e23
Deep copy for arm cpu state 2022-10-01 00:14:08 +02:00
mio 3d028882ed Fix wrong cput model check in uc_ctl 2022-07-23 20:49:00 +08:00
lazymio 6d61aec82f
Format code 2022-06-02 14:46:26 +02:00
lazymio fdd129fd30
Remember the regions a hook has intrumented and clear cache on deletion 2022-06-02 14:46:02 +02:00
lazymio 739fa45f50
Remove unused mmio 2022-06-01 23:43:53 +02:00
lazymio 289034538d
Cleaner implementation for uc_mem_prot on mmio regions 2022-05-28 23:46:06 +02:00
lazymio 2a6529348c
Support uc_mem_protect on mmio regions
Also make mmio ranges return the correct errors on wrong protection
2022-05-28 23:33:43 +02:00
lazymio 94cac9dfb4
Fix fallthrough in uc_ctl_tb_flush 2022-05-10 23:48:44 +02:00
lazymio 345b63ee96
Only exit TB if pc is within the memory range 2022-05-07 00:16:31 +02:00
Eric Poole cfee2139a0
TriCore Support (#1568)
* TriCore Support

python sample

* Update sample_tricore.py

Correct attribution

* Update sample_tricore.py

Fixed byte code to execute properly.

* Update sample_tricore.py

Removed testing artifact

* Added tricore msvc config-file.h

* Added STATIC to tricore config and added helper methods to symbol file generation.

* Update op_helper.c

Use built in crc32

* Fix tricore samples and small code blocks are now handled properly

* Add CPU types

* Generate bindings

* Format code

Co-authored-by: lazymio <mio@lazym.io>
2022-04-29 23:11:34 +02:00
lazymio aab93926dc
Fix a bug when nested uc_emu_start deletes a hook 2022-04-26 01:17:59 +02:00
lazymio 4e22744679
Support flushing translation blocks and flush when we don't need count hook 2022-04-26 01:17:58 +02:00
lazymio e8129b6f66
Revert "Fix https://github.com/unicorn-engine/unicorn/issues/1590" 2022-04-16 17:59:15 +02:00
lazymio 034844f7f9
Merge pull request #1592 from liyansong2018/mybranch1
Fix https://github.com/unicorn-engine/unicorn/issues/1590
2022-04-16 17:52:30 +02:00
lazymio c379d1bfe4
Format code 2022-04-16 17:50:12 +02:00