Commit Graph

552 Commits

Author SHA1 Message Date
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
PhilippTakacs
e8ca3cbea5 Optimize memory handling (#1963)
* optimize ram block handling

Save the last element of the ram_list. This allows to
faster find where to add new elements when they are not
bigger then page size.

* save ram_list freed

this keeps the optimization for find_ram_offset() intact after snapshot
restore.

* cow only clear the tlb of affected pages

* update flatview when possible

Building each flatview new when the memory has changed is quite
expensive when many MemoryRegions are used. This is an issue when using
snapshots.

* update benchmark for new api

* save flatview in context

this avoids rebuilding the flatview when restore a context.

* init context flatview with zero

* address_space_dispatch_clear remove subpage with higher priority

* docutemnt the options for UC_CTL_CONTEXT_MODE

Specialy stress that with UC_CTL_CONTEXT_MEMORY it is not possible to
use the context with a different unicorn object.
2024-10-16 21:51:13 +08:00
Eli
fea3411803 Minor Python regress fixes (#2030)
* Fix erronous method name

* Uncomment known failures

* Opportunistic improvements
2024-10-13 16:35:42 +08:00
mio
fbf34af81c Fix off-by-one bug and add a unit test 2024-10-13 15:19:05 +08:00
Eli
9f578946d5 Revamp Python regression tests suite (#2022)
* Fix Python regression test suite (partial)

* Fix Python regression test suite

* Add a test for mapping at high addresses

* Add ctl tests
2024-10-13 13:14:10 +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
Eli
ac4872be4c Support additional API on Python 3 bindings (#2016)
* Styling and commets fixes

* Add errno API support

* Improve OOP approach by adjusting the way reg types are selected

* Leverage new approach to deduplicate reg_read and reg_write code

* Adjust reg_read_batch

* Add support for reg_write_batch

* Adjust x86 MSR accessors

* Turn asserts into descriptive exceptions

* Improve comments and styling

* Fix ARM memcpy neon regression test

* Modify canonicals import

* Introduce ARM CP reg accessors
2024-10-06 23:14:03 +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
PhilippTakacs
7d8b06b704 snapshot restore don't remove terminating regions (#1968) 2024-06-29 22:36:02 +08:00
Nguyen Anh Quynh
c136b6b2bf fix some compiler warnings 2024-04-22 20:03:07 +08:00
227ff1d8bd Merge pull request #1928 from mlgiraud/feat/add_start_end_to_hook
Feature: Bindings: add start end to block hook
2024-03-11 19:50:46 +08:00
Mark Giraud
d4f5bf1be2 fix: Fix rust test that was missing a parameter 2024-03-11 12:31:54 +01:00
d1da4de080 Merge pull request #1929 from xclusivor/master
Remove semicolons in python files
2024-03-08 15:10:58 +08:00
xclusivor
4a694d8a30 remove semicolons 2024-03-06 02:15:02 -05:00
f3323469d0 Format 2024-02-12 00:10:58 +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
dotcirill
b0ea433772 Fix PPC32 fault when timer-spr access
Access to TB, DEC registers was lead to crash
spr_read_decr and others are changed to spr_read_generic
spr_write_decr and others are changed to spr_write_generic
2023-12-06 01:58:50 +03:00
Dimitris Glynos
9d8e639c69 fix fxsave fpip value, provide tests 2023-10-26 08:42:58 +03:00
Mario Haustein
5983b399d8 use full prototypes for functions without parameters 2023-10-08 13:39:13 +02:00
Mark Giraud
f081af002a test: Add test to reproduce cow+vtlb error 2023-08-24 11:44:21 +02: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
Takacs, Philipp
f6cfe1092b vtlb only cache access permisions required for the operation
see #1845
2023-07-17 12:54:38 +02: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
550265f3c1 snapshot benchmark
simple benchmark for the snapshots
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
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
Nguyen Anh Quynh
3bba11c402 remove all legacy DYNLOAD code 2023-06-22 12:19:06 +08:00
Robert Xiao
b041345a73 Fix RISCV test_riscv32_fp_move test
RISCV FP registers are 64-bit in size, even in 32-bit mode, because they can
hold doubles. The test even uses the double-precision instruction fmv.d. Thus,
the reads should be reading 64-bit registers.
2023-06-16 15:23:43 -07: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
bde3cd7dae Merge pull request #1812 from ks0777/ctl_rust
add rust bindings for uc_ctl
2023-04-24 16:25:34 +02:00
Mio
bbbc7856ac Invalidate tb cache once mapping is removed 2023-04-12 20:56:54 +08:00
Philipp Takacs
a9f0dabc64 rust add tlb callback 2023-04-05 18:57:22 +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
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
5e2074da6a Merge pull request #1808 from kallisti5/haiku-fix-2023
build: Fixes for Haiku
2023-03-26 12:17:23 +08:00
Alexander von Gluck IV
d504e3a004 build: Fixes for Haiku
* Haiku is fully posix, so can be lumped together with most unix cases
2023-03-22 13:58:10 -05:00
mio
11fcbad9ff Remove redundant printf 2023-03-12 20:28:01 +01: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
mio
133504b504 Fix wrong IP in x86_16 because of cs_base not substracted 2023-02-20 20:21:56 +01:00
mio
e9c1c17f6d Fix endianess detection 2022-11-16 15:16:49 +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