Commit Graph

248 Commits

Author SHA1 Message Date
mio
faa689c0f0
Merge systemz to the latest uc2 codebase 2021-12-26 22:58:32 +01:00
lazymio
cddc9cf2ed
Fix arm post init 2021-12-25 00:16:51 +01:00
lazymio
5b3a9e1024
Add test for arm v8 2021-12-24 23:45:57 +01:00
lazymio
4f73d75ea8
Fix #1500 2021-12-23 21:46:27 +01:00
lazymio
ef6f8a2427
Fix x86 CPUID 2021-12-22 23:39:41 +01:00
lazymio
7bb0abb977
Format 2021-12-22 20:37:15 +01:00
lazymio
7bb756249a
Better design of cpuid instruction hook 2021-12-22 20:36:56 +01:00
Quentin DUCASSE
033e79abac Added cache flush after code patching in unit tests for arm64 and riscv 2021-12-17 14:55:08 +01:00
Dimitris Glynos
63a445cbba
fxsave / fxsave64 should store the floating point instruction pointer (fpip) (#1467)
* fxsave / fxsave64 should store the floating point instruction pointer (fpip)
- fxsave / fxsave64 happen to be used as GetPC code in exploits

* unit tests for the storage of FPIP in fxsave (x86) and fxsave64 (x64)
2021-12-13 08:40:32 +08:00
Quentin DUCASSE
549274f44c Code patching tests for riscv and arm64 2021-12-10 15:27:54 +01:00
Nguyen Anh Quynh
b042a6a01d add missing files 2021-12-06 04:28:13 +08:00
lazymio
8a0ca8715e
Fix SR read/write and a test 2021-12-04 23:22:28 +01:00
lazymio
221cde18df
Write CPSR as it is initiated from instructions to allow regs switch 2021-11-24 17:10:51 +01:00
lazymio
78e0ddbc4d
Fix mmio unmap 2021-11-24 00:18:19 +01:00
lazymio
4ed1c4cff9
Fix test name typo 2021-11-23 23:24:53 +01:00
Sven Bartscher
3e2580ef9e Add test case for #1497 2021-11-23 22:47:20 +01:00
lazymio
e11cc16e54
Implement high-resolution clock for mingw64 in test_ctl 2021-11-23 14:15:18 +01:00
lazymio
ccfb66611f
Move test to test_mem 2021-11-23 00:41:49 +01:00
Sven Bartscher
b35dbb90b2 Add test case for #1495 2021-11-22 18:48:16 +01:00
lazymio
907ec5095d
Fix a stackoverflow in tests 2021-11-21 19:28:45 +01:00
lazymio
fc467edbc6
Fix 32bit target getting wrong offset for mmio 2021-11-16 22:40:57 +01:00
lazymio
247ffbe0e8
Support nested uc_emu_start calls 2021-11-16 21:07:03 +01:00
lazymio
640251e1aa
Leave out size parameter in callback 2021-11-09 00:21:34 +01:00
lazymio
35017a614f
Slightly change UC_CTL_TB_REMOVE_CACHE 2021-11-08 22:09:33 +01:00
lazymio
e836b62e01
Minor fix for uc_ctl 2021-11-08 20:40:02 +01:00
lazymio
2f61592ff9
Fix uc_mem_protect 2021-11-07 20:37:58 +01:00
lazymio
c6fdbb3735
Add RISCV CSR registers 2021-11-07 20:36:04 +01:00
lazymio
01d7e454b7
Fix typo 2021-11-04 20:59:07 +01:00
lazymio
3aa2788586
Format 2021-11-04 18:39:52 +01:00
lazymio
dfbffa44ec
Support changing cpu model for ARM 2021-11-04 18:37:10 +01:00
lazymio
3e4b4af7d3
Support change page size 2021-11-04 17:03:30 +01:00
lazymio
67e2386da6
Add test and close #1477 2021-11-03 21:40:13 +01:00
lazymio
1a82248292
Add test for #992 2021-11-03 21:17:57 +01:00
lazymio
9818840f4e
Add tests for UC_HOOK_TCG_OPCODE 2021-11-03 20:56:45 +01:00
lazymio
58edb2abe7
Format 2021-11-03 13:28:12 +01:00
lazymio
09aa0f944f
Merge QDucasse:riscv_extension_d
Fix and close #1469

Fix test for riscv float points

Fix the riscv cpu config we left out
2021-11-03 13:20:46 +01:00
lazymio
eb75d459f0
Add a regression test for invalidating empty TB and have a better solution 2021-11-03 01:07:06 +01:00
lazymio
b7e82d460c
Expose more TB related stuff 2021-11-01 22:11:43 +01:00
lazymio
14e175394b
Fix Win32 time function for test_ctl 2021-11-01 19:43:30 +01:00
lazymio
9704618595
Fix test for Android due to clock() not working 2021-11-01 15:33:36 +01:00
lazymio
cee44b0464
Add tests and samples to show how to control TB cache 2021-11-01 14:46:01 +01:00
lazymio
fb45b287ba
Add multiple exits mechanism and tests&samples 2021-11-01 14:00:43 +01:00
lazymio
147cb62240
Add uc_close 2021-11-01 10:23:47 +01:00
lazymio
3dd2e0f95d
Basic implementation of uc_ctl 2021-11-01 00:39:36 +01:00
lazymio
84abf1d3a4
A stronger test and handle addr_end = 0 2021-10-31 21:01:55 +01:00
lazymio
4bcf1c4a7c
Flush TB at exit with a better approach instead of flushing tlb in uc1 2021-10-31 19:43:56 +01:00
lazymio
8e6f7e4fba
Add a regression test 2021-10-31 15:56:58 +01:00
lazymio
e62b0ef255
Add clang-format and format code to qemu code style 2021-10-29 12:44:49 +02:00
lazymio
9131856506
More tests 2021-10-26 11:32:57 +02:00
Aurimas Blažulionis
160045a910
Binary search mapped blocks 2021-10-20 20:49:55 +01:00
mio
91451aa2f5
Add a new unit test file 2021-10-20 21:27:22 +02:00
mio
30f0e24407
Merge remote-tracking branch 'qducasse/riscv_pc_update' into dev 2021-10-19 23:08:41 +02:00
Quentin DUCASSE
5fd90ca1ef Added 3 steps unit test 2021-10-19 17:20:10 +02:00
Quentin DUCASSE
47f986fc93 Unit test POC for RISCV issue 2021-10-19 17:12:52 +02:00
mio
6d0d0897f8
Fix Rust build and CI.
Add a test for ppc and fix ppc on windows.
2021-10-17 02:11:38 +02:00
mio
9d8a309fbf
Allow user to instrument cpuid instruction 2021-10-05 17:15:49 +02:00
mio
bccc7f2fb7
Remove NULL tcg arg and add a test for sysenter 2021-10-04 18:50:42 +02:00
mio
2d043d387d
Change mips model to add DSP 2021-10-03 23:10:39 +02:00
Nguyen Anh Quynh
aaaea14214 import Unicorn2 2021-10-03 22:14:44 +08:00
Nguyen Anh Quynh
ac68fd441d fix test_x86.c 2020-05-25 00:04:07 +08:00
Nguyen Anh Quynh
fbef45b18f remove UC_ERR_TIMEOUT, so timeout on uc_emu_start() is not considered error. added UC_QUERY_TIMEOUT to query exit reason 2020-05-24 23:54:45 +08:00
Chen Huitao
2c66acf4ee
fix #1246 (#1254)
* fix finding python path which only has python3.

* fix #1246, arm host issue.

* skip assembler tests on non-x86 host.

* update macro of dummy value.

* fix MSVC macro.

* update dummy array value macro.

* restore to original qemu code.
2020-05-18 19:57:44 +08:00
Dominik Maier
9fedbd96f4
fixed leaks in test cases (#1247) 2020-05-02 18:18:18 +08:00
David CARLIER
72f7598387 Tests, fixes on third platform. (#1168)
MT linkage fix mainly.
2019-12-29 00:18:40 +08:00
ζeh Matt
3a3bc0c22d Timeout error (#1173)
* Implement timeout state and new error for such case

* Adjust test_i386_loop sample

* Adjust test_i386_loop test
2019-12-29 00:16:54 +08:00
Jean-Baptiste Cayrou
b1995b4b8a Fix C syntax mistake in test_gdt_idt_x86.c (#867)
Now 'make test' command works
2017-08-07 10:31:10 +08:00
Stephen
da21bd0589 Start moving examples in S files (#851)
* Move assembly to S files

* more assembly files

* osx compilation change

* makefile mistake

* add objcopy from crosstool

* use gobjcopy on osx

* start cmocka install cleanup

* move wget to directory option

* move back to cd

* fix copy

* First cut

* free allocated memory

* bad idea

too much switching between python and c

* add debug

* cleanup bad size
2017-06-25 10:14:22 +08:00
Stephen
7f116846c0 MSYS test (#852)
* MSYS test

using new cmocka msys package

* Update .appveyor.yml

* temp package install

before real ones get uploaded to db

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update Makefile

* Update test_x86_shl_enter_leave.c

* Update Makefile

* Update threaded_emu_start.c

* Update .appveyor.yml

* remove unused install
2017-06-25 10:11:35 +08:00
Nguyen Anh Quynh
206819bd98 cleanup after msvc port 2017-01-22 21:27:17 +08:00
Nguyen Anh Quynh
f9f184e719 test: fix missng pthread functions 2017-01-21 22:29:07 +08:00
xorstream
770c5616e2 Automated leading tab to spaces conversion. 2017-01-21 12:28:22 +11:00
xorstream
837d3787c0 Fix for read()/write() conflict with unistd.h in test_mem_map.c. 2017-01-21 01:39:49 +11:00
xorstream
fac6a66860 platform.h move #3 2017-01-21 00:13:21 +11:00
xorstream
1aeaf5c40d This code should now build the x86_x64-softmmu part 2. 2017-01-19 22:50:28 +11:00
Nguyen Anh Quynh
bc569f5a54 rename API uc_mem_free() to uc_free(). see #662 2017-01-10 20:59:14 +08:00
Nguyen Anh Quynh
fdbbdc6216 rename uc_context_free() to uc_mem_free(). see #373 2017-01-09 20:52:14 +08:00
me
87e8532e67 regress: link on Linux with -lrt 2016-12-26 14:16:56 +08:00
Stephen
75d90aff52 Make cleanup (#666)
* make cleanup

* Update .travis.yml
Update eflags_nosync.c
Update sigill2.c
Update ro_mem_test.c
Update ro_mem_test.c
Update nr_mem_test.c
Update mem_fuzz.c
Update mem_double_unmap.c
Update emu_stop_in_hook_overrun.c
Update eflags_nosync.c
remove unused
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update mem_64_c.c
Update mem_64_c.c
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update .travis.yml
try android ndk build
Update unicorn.py
Update unicorn.py
Update Makefile
Update unicorn.py
Update unicorn.py
remove an untrue comment

if a dll/so/dylib gets loaded at runtime is dependent on many different factors, primarily the LD/DYLD paths. Those do not always include the current working directory
Update Makefile
Update .appveyor.yml
Update .travis.yml
Update Makefile
Update .appveyor.yml
Fix bad sample

* Update Makefile

* Update Makefile

* Update install-cmocka-linux.sh

* remove verbose option from tar

* add upgrade to pacman for cmake

* pacman double update, needed to get new packages

* enable cmocka unit testing

* rejigger commands to fail on any step

should get fails in msys builds for cmocka

* fix quote

* make cmocka in cygwin only

* add msys cache
2016-11-19 17:17:48 +08:00
Stephen
bc08bfda67 Unit testing in CI (#651)
- in appveyor, install clang and cmake in cygwin, enable package upgrades, and build cmocka and enable testing for gcc only
- in `gitignore`, ignore generated cmocka folder
- in travis, use brew in osx to install cmocka, and enable testing for gcc and clang on os x and linux
- in `Makefile`, change to use `uname -s` to determine os type
- make `install-cmocka-linux.sh`, a simple shell script to download and install cmocka on linux
- in `bindings/Makefile`, enable `make -c` to call subdirectory makefiles instead of `cd [dir] && make` and include environment variables for runtime access to generated libraries
- in `samples/Makefile`, change to use `uname -s` to determine os type, remove `clean_bins` from `all` command, and include `Werror` for compile strictness
- in `tests/unit/Makefile`, add `cflags` for compile time access to cmocka headers and library, include execute vars for runtime access to cmocka and unicorn libs
- in `tests/unit/test_tb_x86.c`, comment out assert that would not compile
2016-10-22 00:21:10 +08:00
Andrew Dutcher
ea54204952 Tweak some names in a few places, encapsulate the uc_context struct to hide it from users for some reason 2016-10-10 14:04:51 -07:00
Andrew Dutcher
1ab2154fe5 Change save/restore API to have explicit alloc/free functions. Python has explicit save/update functions. 2016-10-07 11:39:42 -07:00
Nguyen Anh Quynh
73577cbcd1 rename uc_regstate_restore to uc_context_restore, uc_context_save to uc_context_save 2016-10-07 10:03:19 +08:00
Nguyen Anh Quynh
b7cdbe7a88 Merge branch 'feat/reg_save_restore' of https://github.com/rhelmot/unicorn into rhelmot-feat/reg_save_restore 2016-10-07 09:57:07 +08:00
Stephen
0137a66c61 Update test_hang.c 2016-10-05 10:29:16 -07:00
Stephen
f2998f14cd Update test_hang.c 2016-10-05 09:20:36 -07:00
Andrew Dutcher
e3b0e52013 Rename save/restore functions to match the style of the rest of the API 2016-09-28 21:21:44 -07:00
Andrew Dutcher
3deb9fdcad Fix save/restore to work while emulation is not active 2016-09-08 14:41:34 -07:00
Andrew Dutcher
f2af98942b Added (failing?) test for reg save/restore 2016-08-31 20:25:28 -05:00
Nguyen Anh Quynh
40ea64af19 Merge branch 'feat/xmm_regs' of https://github.com/rhelmot/unicorn into rhelmot-feat/xmm_regs 2016-08-23 06:52:45 +08:00
nnn
64e6fbc480 Fixed printf format specifier 2016-08-20 22:34:14 -07:00
nnn
d77fd18915 Fixed multiple bugs in test_x86_rip_bug.c
Fixed format warning in test_hang.c
2016-08-20 22:23:51 -07:00
nnn
4a67727f81 Updated Makefile 2016-08-20 18:47:45 -07:00
Neil
06fc5d1ea9 Add files via upload
Unit Test for Issue #534
2016-08-20 21:35:23 -04:00
Andrew Dutcher
b1f03a02f2 Add tests for xmm register read/write 2016-08-14 19:26:32 -07:00
samothtronicien
92f97da49f bit of refactoring 2016-07-31 19:45:46 +02:00
samothtronicien
f1041a2615 renamed to test_x86_shl_enter_leave.c 2016-07-31 03:23:00 +02:00
samothtronicien
ae8e34173a added tests with enter/leave 2016-07-31 03:19:52 +02:00
samothtronicien
1ecc5abdbc fixed typo: test_x86_shl_pf -> test_x86_shl 2016-07-30 16:44:54 +02:00
samothtronicien
8120b7732e added test_x86_shl_pf to makefile 2016-07-30 16:42:51 +02:00
samothtronicien
c1cd06ec52 ported test to C 2016-07-30 16:41:40 +02:00
samothtronicien
6c3eecb2a3 added unit test for x86
This test highlight the issue with the SHL instruction in the form (SHL r, CL), the flags values retrieved in the code hook are not correct.
2016-07-30 04:18:12 +02:00
Nguyen Anh Quynh
6193be73b7 tests: more flexible .gitignore for tests/unit/ 2016-06-16 09:14:32 +08:00
nuko32
9b46a22cd5 final refactoring for test_hang 2016-06-15 20:52:28 +02:00
nuko32
3bec4b2cf1 refactored test_hang and fixed indentations 2016-06-15 20:44:22 +02:00
jndok
c6db9febe7 added ARM64 hang test 2016-06-15 19:18:51 +02:00
Zach Riggle
93063d089b Add ASAN build target with UNICORN_ASAN or via './make.sh asan' 2016-04-20 16:16:06 -07:00
Nguyen Anh Quynh
ad6bb8c9f8 unit: fix test_hookcounts.c 2016-03-20 01:54:37 +08:00
Nguyen Anh Quynh
0af4baac31 unit: fix warnings in printing uint64_t in test_hookcounts.c 2016-03-17 17:49:22 +08:00
egberts
ac21e74641 Issues #465
Pull Request #466
Added one more test case
Fixed two test case into passing (for a total of 3 passing out of 7)
2016-03-16 11:49:25 -07:00
egberts
ab5ed15044 Issue #465 - Enhanced test for more scenarios; fixed some semantic bugs. 2016-03-16 10:54:20 -07:00
egberts
347d863365 Issue #465 hook_count_cb doesn't stop at n instructions; unit test file 2015-10-03 22:52:15 -07:00
Nicolas PLANEL
1087ba9dea [query] add UC_QUERY_PAGE_SIZE uc_query helper
Return the current page size used by the current arch.
Useful to call uc_mem_map() with memory/size aligned.

Signed-off-by: Nicolas PLANEL <nplanel@redhat.com>
2016-03-04 15:54:24 +11:00
Nguyen Anh Quynh
aabcb95f01 unit: remove ^M from test_x86_soft_paging.c 2016-02-22 14:02:28 +08:00
Nguyen Anh Quynh
2f28f3f210 unit: make test_x86_soft_paging.c compilable. also update .gitignore for its binary 2016-02-22 14:01:00 +08:00
Ramirez57
2ab2b229ce test case: x86 guest paging
Test case for x86 paging using virtual addresses mapped by Unicorn, as well as unmapped.

Attempting to read/write from virtual address ranges unmapped by Unicorn wrongly causes protection faults, even when the virtual address points to read/write regions of Unicorn memory.
2016-02-22 00:03:14 -05:00
Nguyen Anh Quynh
871cdb692f Merge branch 'hook' 2016-02-17 09:37:17 +08:00
coco
bfbe91834e two more testcases 2016-02-11 15:02:14 +01:00
Nguyen Anh Quynh
a7a1dcc661 uc_hook_add(): add begin & end arguments for all hook types. also update Python binding after this change 2016-02-11 08:02:13 +08:00
Nguyen Anh Quynh
6478a24404 Merge branch 'gdt_idt' of https://github.com/cseagle/unicorn into cseagle-gdt_idt 2016-02-06 17:31:42 +08:00
Chris Eagle
49b9f4f8da uc_x86_mmr type available in qemu/target-i386/unicorn.c 2016-02-04 19:09:41 -08:00
Chris Eagle
59f7bf3be7 file perms 2016-02-04 16:48:27 -08:00
Chris Eagle
e59382e030 updated gdtr/idtr/ldtr/tr read/write code 2016-02-04 16:44:52 -08:00
coco
1e13777c91 added memory fuzzer and 2 resulting testcases 2016-02-04 19:57:20 +01:00
Chris Eagle
9977054a15 add support for setting gdtr, idtr, ldtr, and tr programatically 2016-02-03 09:22:29 -08:00
Nguyen Anh Quynh
e42aba760f fix a typo in test_tb_x86.c 2016-01-31 14:07:35 +08:00
Nguyen Anh Quynh
32b9deca04 unit: use UC_HOOK_MEM_VALID for test_tb_x86.c 2016-01-31 13:14:11 +08:00
Nguyen Anh Quynh
1fb5416f4a unit: simplify test_tb_x86.c 2016-01-31 13:06:42 +08:00
Nguyen Anh Quynh
a5020c69bb Merge pull request #408 from egberts/master
Pull Request for Issue #364: Invalidating Translation Cache after self-modifying code
2016-01-31 10:37:04 +08:00
steve
fc22a359e2 Issue #364 - Move RIP/PC closer next to the offending self-modifying code
which modified the 2nd next instruction (imul) in which that escaped
our wonderful ability to invalidate the
instruction translation cache in which we badly need to pick up the
self-modification being made.
2016-01-30 19:30:17 -05:00
Nguyen Anh Quynh
5a04bcb115 allow to change PC during callback. this solves issue #210 2016-01-28 14:06:17 +08:00
Ryan Hileman
33180b5afa add test for multiple basic block hooks 2016-01-22 18:42:14 -08:00
Nguyen Anh Quynh
840eb54f05 Revert "arm64: fix the access to tcg_op_defs[] in arm64 backend (issue #387)"
This reverts commit 3000ca6abf.
2016-01-22 11:33:36 +08:00
Nguyen Anh Quynh
3000ca6abf arm64: fix the access to tcg_op_defs[] in arm64 backend (issue #387) 2016-01-22 11:33:28 +08:00
Nguyen Anh Quynh
6f0a01293d unit: fix some compilation warnings in test_tb_x86.c 2016-01-17 10:06:00 +08:00
steve
f0dac63b69 In response to issue #364, a unit test case has been created
for exercising proper flushing of the instruction translation cache.
2016-01-16 18:05:32 -05:00
Nguyen Anh Quynh
91501bc2d1 unit: modify the testcase #349 to reflect the recent change on the semantics of uc_mem_map() 2015-12-30 09:19:34 +08:00
Nguyen Anh Quynh
6e534417f1 unit: change clang -> CC 2015-12-30 08:50:58 +08:00
coco
fa2da819b6 added test for unmap of doubly mapped region 2015-12-28 22:02:31 +01:00
Nguyen Anh Quynh
ed319bda0b x86: identity map guest address to host address. this fixes issue #300 2015-12-24 09:51:17 +08:00
Nguyen Anh Quynh
771f9f7c3b fix conflicts when merging map-ptr branch to master branch 2015-12-17 08:12:02 +08:00
Nguyen Anh Quynh
0e62ebc038 unit: fix compilation warning for test_mem_high.c 2015-12-12 00:58:49 +08:00
coco
14e75252a5 added testcase for the values read from high addresses 2015-12-10 16:18:22 +01:00
coco
e4fe6b58b4 added test for memory quirks 2015-12-08 18:23:06 +01:00
Ryan Hileman
230cbd5330 add permissions to map_ptr api 2015-11-28 11:28:31 -08:00
Ryan Hileman
6d21ebabea implement host-controlled memory mapping for #261 2015-11-27 23:30:36 -08:00
Nguyen Anh Quynh
9e64cba6ec Rename some hook related enums:
- UC_ERR_READ_INVALID -> UC_ERR_READ_UNMAPPED
 - UC_ERR_WRITE_INVALID -> UC_ERR_WRITE_UNMAPPED
 - UC_ERR_FETCH_INVALID -> UC_ERR_FETCH_UNMAPPED
 - UC_MEM_READ_INVALID -> UC_MEM_READ_UNMAPPED
 - UC_MEM_WRITE_INVALID -> UC_MEM_WRITE_UNMAPPED
 - UC_MEM_FETCH_INVALID -> UC_MEM_FETCH_UNMAPPED
 - UC_HOOK_MEM_READ_INVALID -> UC_HOOK_MEM_READ_UNMAPPED
 - UC_HOOK_MEM_WRITE_INVALID -> UC_HOOK_MEM_WRITE_UNMAPPED
 - UC_HOOK_MEM_FETCH_INVALID -> UC_HOOK_MEM_FETCH_UNMAPPED
 - UC_HOOK_MEM_INVALID -> UC_HOOK_MEM_UNMAPPED

This also renames some newly added macros to use _INVALID postfix:

 - UC_HOOK_MEM_READ_ERR -> UC_HOOK_MEM_READ_INVALID
 - UC_HOOK_MEM_WRITE_ERR -> UC_HOOK_MEM_WRITE_INVALID
 - UC_HOOK_MEM_FETCH_ERR -> UC_HOOK_MEM_FETCH_INVALID
 - UC_HOOK_MEM_ERR -> UC_HOOK_MEM_INVALID

Fixed all the bindings Java, Go & Python.
2015-09-30 14:46:55 +08:00
Nguyen Anh Quynh
90eb8f2e72 This commit continues the PR #111
- Allow to register handler separately for invalid memory access
- Add new memory events for hooking:
   - UC_MEM_READ_INVALID, UC_MEM_WRITE_INVALID, UC_MEM_FETCH_INVALID
   - UC_HOOK_MEM_READ_PROT, UC_HOOK_MEM_WRITE_PROT, UC_HOOK_MEM_FETCH_PROT
- Rename UC_ERR_EXEC_PROT to UC_ERR_FETCH_PROT
- Change API uc_hook_add() so event type @type can be combined from hooking types
2015-09-24 14:18:02 +08:00
danghvu
3c1d65ea66 Reorganize test directories 2015-09-21 20:47:45 -05:00