Commit Graph

99 Commits

Author SHA1 Message Date
mio
acb638c40a Further fix incorrect register size 2025-04-14 13:12:26 +08:00
mio
81a04e222a Fix incorret register size 2025-04-14 13:09:43 +08:00
mio
ed5d47b338 Fixup cr register on be (s390x) 2025-04-14 13:04:20 +08:00
mio
59ff63a90d Fix cr3 2025-04-14 12:42:28 +08:00
mio
b20dc83055 Remove extra printing 2025-04-14 12:40:16 +08:00
mio
2728d8da4f Fix cr0/cr4 should be uint32_t 2025-04-14 12:39:53 +08:00
mio
542d2f241f Fixup again 2025-04-14 12:14:27 +08:00
mio
58f954bf75 Fix x86 mmu test on s390x 2025-04-14 12:12:37 +08:00
mio
324397f8d2 Fix wrong pc type 2025-04-14 00:03:32 +08:00
mio
d85a372435 fix several tests due to not properly bswap on s390x 2025-04-13 23:24:11 +08:00
mio
c9e6fdc4e8 Add PC tests for IN/CPUID 2025-04-12 23:22:31 +08:00
mio
015e2f27ff Add a test to check memory hooks pc sync 2025-04-12 22:52:24 +08:00
PhilippTakacs
65ed715081 Snapshot use after free (#2125)
* memory snapshots fix use after free on flatview copy

When restoring a snapshot with memory the flatview must be restored
before the memory reagions are filtered. Because the
AddressSpaceDispatcher also has pointer to the MemoryRegions and on copy
they need to be cleared. The memory_filter_subregions function frees
MemoryRegions which are not used at the time of the snapshot.

* fix some memleaks in tests

These tests has forgott to call uc_close(uc), which lead to memory
leaks. Found by the LeakSanitizer.

* memory snapshots correct clean up container memory regions

* Fix further stackoverflow in tests

---------

Co-authored-by: mio <mio@lazym.io>
2025-03-06 23:23:02 +08:00
mio
795d7cbdf0 Fix testing 2025-02-18 11:03:21 +08:00
ab565729e7 Format code 2025-01-18 15:18:49 +08:00
a0fa2c1249 Fix a warning 2025-01-18 15:18:37 +08:00
99c57a8ecf Add a test for #1643 2025-01-18 15:17:47 +08:00
mio
80f0dac6f0 Fix warning 2025-01-04 17:21:02 +08:00
mio
2c688bae73 Remove the outdated hack to zero all code gen buffer
This shall also improve performance

Fix #2001
2025-01-04 17:05:34 +08:00
mio
fcca82bb28 Format code 2025-01-04 15:48:54 +08:00
Michael-c0de
4f417c3f11 patch multiple UC_HOOK_MEM callbacks for unaligned access (#2063)
* patch multiple UC_HOOK_MEM callbacks for unaligned access

* update test_x86.c for #2063

* update test_x86.c for build on win

---------

Co-authored-by: yaojiale2024@iscas.ac.cn <yaojiale2024@iscas.ac.cn>
Co-authored-by: lazymio <mio@lazym.io>
2024-12-29 23:24:32 +08:00
Pedro Tôrres
7737e7b436 make i386 instructions RDTSC and RDTSCP hookable (#2066)
* instruction hooks for RDTSC and RDTSCP

Signed-off-by: Pedro Tôrres <t0rr3sp3dr0@gmail.com>

* update hookable instruction list

Signed-off-by: Pedro Tôrres <t0rr3sp3dr0@gmail.com>

* test RDTSC and RDTSCP instruction hooks

Signed-off-by: Pedro Tôrres <t0rr3sp3dr0@gmail.com>

---------

Signed-off-by: Pedro Tôrres <t0rr3sp3dr0@gmail.com>
Co-authored-by: mio <mio@lazym.io>
2024-12-20 17:17:23 +08:00
PhilippTakacs
ab23d4ceb0 Optimize Notdirty write (#2031)
* enable notdirty_write for snapshots when possible

Snapshots only happens when the priority of the memory region is smaller
then the snapshot_level. After a snapshot notdirty can be set.

* disable notdirty_write for self modifying code

When SMC access the memory region more then once the
tb must be rebuild multible times.

fixes #2029

* notdirty_write better hook check

Check all relevant memory hooks before enabling notdirty write.
This also checks if the memory hook is registered for the affected
region. So it is possible to use notdirty write and have some hooks
on different addresses.

* notdirty_write check for addr_write in snapshot case

* self modifying code clear recursive mem access

when self modifying code does unaligned memory accese sometimes
uc->size_recur_mem is changed but for notdirty write not changed back.
This causes mem_hooks to be missed. To fix this uc->size_recur_mem is
set to 0 before each cpu_exec() call.
2024-11-01 00:02:11 +08:00
0886e53572 Format code 2024-10-06 23:32:16 +08:00
851914c8d0 Fix segfault if tlb is flushed in the hooks 2024-10-06 23:31:46 +08:00
mio
87c0b86248 Format code 2024-09-21 17:59:23 +08:00
Duncan Ogilvie
87610baa3f Fix emulator detection (#1966)
* Add a quick test helper macro to test_x86.c

* Add regression tests for bswap and rex prefixes

* Properly ignore REX prefixes when appropriate

* Fix bswap ax emulator detection
2024-07-19 11:11:21 +08:00
Nguyen Anh Quynh
c136b6b2bf fix some compiler warnings 2024-04-22 20:03:07 +08:00
f3323469d0 Format 2024-02-12 00:10:58 +08:00
Dimitris Glynos
9d8e639c69 fix fxsave fpip value, provide tests 2023-10-26 08:42:58 +03:00
6801e156aa Format code 2023-08-06 21:53:42 +08:00
30bc08611b Add a unit test for #1717 2023-08-06 21:53:04 +08:00
mio
aee4038526 Fix test_x86_0xff_lcall test 2023-07-07 18:50:55 +08:00
mio
2325f41ead Add a unit test for a7a5d187e7 2023-06-30 20:28:59 +08:00
Robert Xiao
d7a806c026 Reformat code with format.sh 2023-06-16 15:23:41 -07:00
Takacs, Philipp
073c4b74ca load_helper only call cpu_loop_exit() when emulation is running
The load_helper is sometimes called from register writes. When the load
fails check if emulation is running before jump out of the emulated code.
2023-05-09 14:58:40 +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
Takacs, Philipp
7f1eb4532d add basic mmu tests
Some simple tests for diffrent mmu.
Basicly add some tlb entries, enable the mmu try to read from virtual address

The aarm64 test was provided by imre-kis-arm in #1718
2023-03-28 13:50:11 +02:00
mio
133504b504 Fix wrong IP in x86_16 because of cs_base not substracted 2023-02-20 20:21:56 +01:00
mio
fc193ffe24 Fix missing macros 2022-10-28 17:55:39 +02:00
mio
a40bf26263 Disable test_x86_unaligned_access on be hosts 2022-10-28 17:53:20 +02:00
mio
428ed8fd21 Fix test_x86_unaligned_access for big endian hosts 2022-10-28 17:47:55 +02:00
mio
4b961a8ef6 Apply fix for big endian hosts per #1710 2022-10-28 16:20:20 +02:00
Nguyen Anh Quynh
b99ec09c90 tests: remove unused var 2022-10-12 14:43:01 +08:00
Mio
a0e119c6f0 Format code 2022-08-31 23:27:24 +08:00
mio
bdb141aeef Disable unaligned access test on ppc and aarch64
The memoy read operations on these architectures are inlined

e.g. ldur on aarch64
2022-08-14 15:42:37 +02:00
mio
419d710c4a Return true when we handled the memory events 2022-08-14 13:37:25 +02:00
mio
2c00546c6e Merge rhelmot's fix 2022-08-14 13:35:54 +02:00
Mio
d6d57834b0 Format code 2022-07-23 19:27:37 +08:00