Commit Graph

3182 Commits

Author SHA1 Message Date
mio
ca3912d9f7 Fix undefined behavior converting TCGv_i32 to TCGv_i64 2025-02-10 21:45:34 +08:00
mio
c915d13cce Fix pc issue of tcg opcode hooks 2025-02-10 21:35:17 +08:00
mio
77a841e53d Fix signature 2025-02-10 21:29:03 +08:00
mio
2619b12cf0 set pc_start on disasm 2025-02-10 21:28:23 +08:00
mio
904efc16c0 Should use tcg_ctx->pc_start as pc 2025-02-10 21:20:39 +08:00
mio
0c7017a584 more 22.04 pinning 2025-02-10 20:27:40 +08:00
mio
8082239cc3 Allow installing on Windows 2025-02-10 15:59:46 +08:00
mio
a903fa182b Avoid null ptr deref when writing to arm context pc register 2025-02-10 15:58:28 +08:00
mio
48fb28dfbc Update documents for MMU access 2025-02-10 15:36:03 +08:00
mio
a59bb4235e Use 22.04 to avoid segfault 2025-02-10 15:02:27 +08:00
dotcirill
dc1f7a88d5 Uc hook tcg improve (#2011)
* Add handling UC_TCG_OP_FLAG_CMP for ARM

Implementation is not well-tested and complete

* Hook ARM32 CMP and CMN for cmplog
2025-02-10 15:01:21 +08:00
Shivam7-1
ada8091ccc Fix heap buffer overflow in op_cksm function (#2096)
* Fix heap-buffer-overflow in op_cksm function

* Update header
2025-02-10 14:57:08 +08:00
Daniel Roethlisberger
e166cd93bb arm64 python: Avoid nested class in insn hook for 10x hook and 10% overall speedup (#2095)
* arm64 python: Avoid nested class in insn hook for 10x hook speedup

Promote CpReg to a module-level class to address unnecessary performance
reduction.  In a real-world use case tracing the emulation of real-world
machine code, this change reduces time spent in CpReg namedtuple
construction from 10% of overall time to below 1%, for a 10x speedup of
the insn hook itself, or a 10% overall speedup.  Measured using
cProfile, python 3.13.

* upgrade distro to 22.04

* revert to 22.04 for now

* also revert for wheels

---------

Co-authored-by: mio <mio@lazym.io>
2025-02-10 14:56:34 +08:00
xndcn
1ba25def8e Fix UC_HOOK_MEM on arm32 (#2091) 2025-01-26 13:28:24 +08:00
ZakDanger
d7c0497ee3 Added start in mips16 mode support, and unit test for it - on dev branch (#2089)
Co-authored-by: ZakDanger <ZakDanger@users.noreply.github.com>
2025-01-19 17:35:40 +08:00
7f6dcc7539 Test the pc is correctly sync-ed for arm64 2025-01-18 15:38:47 +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
0c512f91a1 Fix #1643
This adds an extra op to translator to allow the block hook sync pc in the very begining
2025-01-18 15:07:22 +08:00
Z. Liu
a78d690da5 configure: add <sys/timex.h> for clock_adjtime on musl (#2085)
for glibc, if _GNU_SOURCE is defined, <time.h> will include <sys/timex.h>
but not for musl, so add "#include <sys/timex.h>"

although `man clock_adjtime` said "#include <sys/timex.h>", but it won't
work for glibc w/o "#include <time.h>", I don't known why yet.

PS it seems clock_adjtime is used nowhere?

Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
2025-01-14 08:47:54 +08:00
Daniel Roethlisberger
9682fc42f7 Allow uc_ctl_set_page_size() for arm64 (#2084) 2025-01-07 11:03:34 +08:00
8720632764 Add the unit test from saicao
Co-authored-by: Sai Cao <1665673333@qq.com>
2025-01-04 19:00:22 +08:00
Glenn Baker
8442eb6feb qemu/tcg: fix UC_HOOK_MEM_READ on aarch64. (#2028)
* qemu/tcg: fix UC_HOOK_MEM_READ on aarch64.

Directly jump into the slow path when there is any hookmem enabled. This
fixes #1908.

Signed-off-by: Glenn Baker <glenn.baker@gmx.com>

* qemu/tcg: fix UC_HOOK_MEM_READ on ppc64.

Directly jump into the slow path when there is any hookmem enabled.

Signed-off-by: Glenn Baker <glenn.baker@gmx.com>

* qemu/tcg: check for UC_HOOK_MEM_READ_AFTER.

Use has_hookmem() helper to determine wether "slow-path" TLB read is
needed. Add this helper to x86 architecture as well so that to check for
all hookmem.

Signed-off-by: Glenn Baker <glenn.baker@gmx.com>

* qemu/tcg: factor out has_hookmem().

It's the same implementation for all architectures, so factor out
has_hookmem() into tcg_uc_has_hookmem().

Signed-off-by: Glenn Baker <glenn.baker@gmx.com>

---------

Signed-off-by: Glenn Baker <glenn.baker@gmx.com>
2025-01-04 18:48:53 +08:00
mio
996ad57e34 Add an option to determine if building all-in-one objects archive 2025-01-04 17:35:09 +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
c4567ff69e Update docs about macOS compiling 2025-01-04 16:12:50 +08:00
EvianZhang
e97d084aec Add more EIP syncs for x86 target memory hooks (#2064)
Co-authored-by: lazymio <mio@lazym.io>
2025-01-04 15:59:20 +08:00
mio
6974b53588 Fix #2078
We shall only go through the else branch for code_read
2025-01-04 15:57:02 +08:00
mio
fcca82bb28 Format code 2025-01-04 15:48:54 +08:00
mio
d50bbb5d5b Add unit test from #2078 2025-01-04 15:48:32 +08:00
mio
9e35265a97 Update docs for testing 2025-01-04 15:41:05 +08:00
77d64c05c2 Add a link to FAQ 2024-12-30 21:31:24 +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
@Antelox
9cfd5cfac3 - Improved the GitHub python binding workflow: (#2072)
- Added fullMode input in workflow_dispatch
    - Take decision whether to build either in debug or release mode and if to build for all python versions according to the commit message patterns
    - Set proper artifact names
    - Removed not needed steps
    - Compacted some steps in order to leverage more the matrix feature
    - Bumped cibuildwheel action to 2.22.0
    - Run actual regress tests in place of sample scripts
- Specify optional test install in pyproject.toml with proper requirements
- Derive package version from git tags
- Add GENERATORS env var support in setup.py to specify cmake generator and minor refactoring
- Minor cleanup/refactoring for the regress test suite
- Marked some regress tests with skipIf to skip them in case of old python versions
- Marked some failing regress tests to be checked with skipIf
2024-12-29 22:24:48 +08:00
Aubrey
07e8162cca improve aarch64 feature gate in rust bindings (#2069) 2024-12-29 22:21:43 +08:00
Pedro Tôrres
2899088844 Allow Statically Linking in Go (#2067)
* unset -L and -rpath from CGO_LDFLAGS

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

* allow go statically linking

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

* fix setup.py

---------

Signed-off-by: Pedro Tôrres <t0rr3sp3dr0@gmail.com>
Co-authored-by: mio <mio@lazym.io>
2024-12-21 11:02:28 +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
mio
1cbb7b40b2 Allow have_pthread_jit_protect but not have_sprr_mrs 2024-12-20 01:04:50 +08:00
mio
a540df45a6 Only enable SPRR on physical machines 2024-12-20 00:57:19 +08:00
mio
1ad2da35e6 Fix QEMU_UNUSED_FUNC 2024-12-20 00:50:11 +08:00
13a8da8538 Check SPRR by issuing MRS 2024-12-08 14:46:28 +08:00
958ed09153 No longer need SPRR and probe it runtime 2024-12-07 23:33:34 +08:00
b7199261b5 No longer install cmake from choco due to Github Action errors 2024-12-07 22:37:32 +08:00
b0b412bc6c Only enable JIT protect support with SPRR 2024-12-07 22:35:28 +08:00
69200d4f00 Fix regression: If invalid instruction is handled, allow emulation to continue 2024-12-07 17:30:45 +08:00
3b2f54fc61 Fix regression: We should triage MIPS internal exceptions to Unicorn exceptions 2024-12-07 17:09:59 +08:00
c22651c9fe Fix regression: We should also sync npc for SPARC 2024-12-07 16:31:20 +08:00
9750d6e2fc QoL changes 2024-12-07 15:57:51 +08:00