Commit Graph

855 Commits

Author SHA1 Message Date
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
05e29b4507 Implement UC_ARM64_REG_WSP 2024-10-02 16:03:59 +08:00
mio
d30ba77c71 Refine warning 2024-10-02 16:03:58 +08:00
mio
9f935f505e Revert previous break changes that return UC_ERR_ARG for non-existing registers
But print a warning instead
2024-10-02 16:03:58 +08:00
elicn
ff06b145e1 Fix I0-7 registers write 2024-09-30 18:52:37 +03:00
elicn
9af1df6543 Add read and write support for i386 ZMM0-31 2024-09-28 22:17:06 +03:00
elicn
5164dbd609 Add read and write support for i386 YMM8-31 2024-09-28 22:16:45 +03:00
elicn
e3675162ba Add read and write support for i386 XMM16-31 2024-09-28 22:15:00 +03:00
elicn
6cb9bfe5c0 Avoid updating CR3 when writing CR1 and CR2 2024-09-28 22:11:54 +03:00
elicn
433bb163d9 Add read and write cases for i386 CR8 2024-09-28 22:11:01 +03:00
mio
d87791329f Add a cmake option 2024-09-21 22:16:02 +08:00
mio
80f0898740 Merge remote-tracking branch 'bits/revive-qemu-logs' into dev 2024-09-21 22:09:07 +08:00
mio
920d076e51 Remove page-collection-locs 2024-09-21 22:03:44 +08:00
mio
6cc7e1d431 Also only reset if hooks are installed 2024-09-21 21:52:38 +08:00
mio
8816883bb3 Fix TLB for snapshots 2024-09-21 21:49:01 +08:00
mio
2cd227f804 Update symbols for tlb_reset_dirty_by_vaddr 2024-09-21 20:54:24 +08:00
mio
8f74405031 Update symbols 2024-09-21 20:51:35 +08:00
Andrei Warkentin
d01035767e notdirty_write: fix store-related performance problems
Every store would always cause the tb_invalidate_phys_page_fast path to be invoked,
amounting to a 40x slowdown of stores compared to loads.

Change this code to only worry about TB invalidation for regions marked as
executable (i.e. emulated executable).

Even without uc_set_native_thunks, this change fixes most of the performance
issues seen with thunking to native calls.

Signed-off-by: Andrei Warkentin <andrei.warkentin@intel.com>
2024-09-21 20:50:43 +08:00
9427f0a553 Merge pull request #1991 from apparentlymart/b-riscv-invalidinsn-pcadj
riscv: Invalid 32-bit instruction should not decrement pc
2024-09-21 18:26:59 +08:00
mio
a5fa548049 Fix qemu_vfree implementation on MINGW
Also correctly release bounce.buffer
2024-09-21 17:58:15 +08:00
Jose Martins
58f1a612e8 target/riscv: fix wfi exception behavior
The wfi exception trigger behavior should take into account user mode,
hstatus.vtw, and the fact the an wfi might raise different types of
exceptions depending on various factors:

If supervisor mode is not present:

- an illegal instruction exception should be generated if user mode
executes and wfi instruction and mstatus.tw = 1.

If supervisor mode is present:

- when a wfi instruction is executed, an illegal exception should be triggered
if either the current mode is user or the mode is supervisor and mstatus.tw is
set.

Plus, if the hypervisor extensions are enabled:

- a virtual instruction exception should be raised when a wfi is executed from
virtual-user or virtual-supervisor and hstatus.vtw is set.

Signed-off-by: Jose Martins <josemartins90@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20210420213656.85148-1-josemartins90@gmail.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2024-09-03 13:44:55 -07:00
Martin Atkins
ac1b37421d riscv: Invalid 32-bit instruction should not decrement pc
This line appears to be trying to undo the effect of adding 4 to pc above,
but does so incorrectly and so ends up returning with next_pc earlier than
it was prior to decoding.

This causes the translator to malfunction because it does not expect
pc_next to decrease during decoding: this is effectively reporting that
the invalid construction has a negative size, which is impossible. The
decoder uses the increase in next_pc to decide the translation block size,
but converts it to uint16_t thereby causing a block containing _only_ an
invalid instruction to be treated as having size 65532 (reinterpreted -4)
and therefore the translation loop tries to find the next translation block
at 65532 bytes after the invalid instruction, which can cause a spurious
instruction access/page fault if the page containing that address is not
mapped as executable.

In practice we don't need to readjust the pc at all here because it is
correct to report that the invalid instruction is four bytes long. This
allows the translation loop to correctly find the next instruction, and
to avoid producing spurious TLB fills that might cause incorrect exceptions.
2024-08-28 14:06:17 -07: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
BitMaskMixer
8e6499fb0b gcc compiler warning fixes (#1977)
* fix for enum-int-mismatch

* fix for unused-variable
2024-07-19 11:09:57 +08:00
Christoph Hindermann
667084153b use is_log_level_active to check if logging is enabled 2024-07-18 19:08:36 +02:00
Christoph Hindermann
45a872108b revive qemu logging by implementing macros 2024-07-18 19:08:36 +02:00
Nguyen Anh Quynh
751a4d0f03 compile warning: remove some unused vars 2024-05-02 16:26:41 +08:00
Nguyen Anh Quynh
c136b6b2bf fix some compiler warnings 2024-04-22 20:03:07 +08:00
mio
e03109d8c9 Respect users' decision for UC_ERR_INSN_INVALID 2024-03-08 17:31:27 +08:00
mio
24f898fb58 Fix #1869 2024-02-15 15:22:32 +08:00
8a1c8daca3 Add a comment 2024-02-13 19:11:22 +08:00
71c729a9d7 Define HAVE_SPRR 2024-02-13 19:09:35 +08:00
4245475514 Detect if we have valid pthread_jit_write_protect_np 2024-02-13 16:21:53 +08:00
b31081a105 Remove unused var 2024-02-13 14:38:48 +08:00
78ea3c8301 Fix m1 defines 2024-02-13 11:52:10 +08:00
a4ba7c9dd5 Add inline 2024-02-13 11:48:24 +08:00
591b562721 Fix defined 2024-02-13 11:38:49 +08:00
a6fb2a6870 Save jit state before/after callback 2024-02-13 11:13:01 +08:00
822bb527f3 M1 W^X fully supported 2024-02-12 00:10:44 +08:00
redoste
a070ea95af Backport qemu/qemu@852f933
tcg: Fix do_nonatomic_op_* vs signed operations

The smin/smax/umin/umax operations require the operands to be
properly sign extended.  Do not drop the MO_SIGN bit from the
load, and additionally extend the val input.
2024-01-24 23:41:30 +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
mio
e0eeda2362 Add arm for bad assert implementation 2024-01-03 18:07:04 +08:00
mio
3c64e9a9e7 Revert previous wrong fixes 2024-01-03 18:06:09 +08:00
mio
02e3cba4c4 HAVE_ATOMIC128 is defined as a number 2024-01-03 17:45:04 +08:00
mio
3cff3eb2d5 Don't rely on dead code elimination 2024-01-03 16:50:28 +08: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
StalkR
db63f2d9d7 qemu: fix UBSAN errors in tcg and arm translation 2023-11-14 10:23:50 +01:00
Dimitris Glynos
9d8e639c69 fix fxsave fpip value, provide tests 2023-10-26 08:42:58 +03:00
Mario Haustein
9a2583e967 fix deprecated storage-class declarations 2023-10-08 13:40:23 +02:00