Commit Graph

3253 Commits

Author SHA1 Message Date
elicn
754194c7e8 Improve documentation 2024-09-19 17:04:21 +03:00
elicn
2da154721b Remove repr surplus method 2024-09-19 17:00:33 +03:00
elicn
7deb613a3c Reduce namespace clutter 2024-09-19 16:58:03 +03:00
379791ad56 Merge pull request #1995 from apparentlymart/f-qemu-backport-wfi-umode
[QEMU backport] riscv: fix wfi exception behavior
2024-09-04 15:36:00 +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
atipls
da9b95501c Update zig bindings to 0.13.0 2024-08-08 10:15:50 +02: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
scribam
1ed4c43ff3 Update cmake minimum required to version 3.5 (#1976) 2024-07-19 11:08:13 +08:00
scribam
feb166d475 Update github workflows (#1975) 2024-07-19 11:06:53 +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
449950cac7 update the FAQ section with a how-to enable the logging 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
PhilippTakacs
7d8b06b704 snapshot restore don't remove terminating regions (#1968) 2024-06-29 22:36:02 +08:00
Arsenii es3n1n
ddd6b7c254 build: allow CMAKE_MSVC_RUNTIME_LIBRARY #1958 (#1960) 2024-06-12 14:46:13 +08:00
Bet4
abefcb2f89 Remove using of distutils (#1964)
* Remove using of distutils

* Upgrade setuptools to fix CI

* Use Python 3.7 in build_wheel.sh
2024-06-12 14:45:23 +08:00
Jordan Moore
c39e80231c Update Zig bindings to Zig 0.12.0 (#1951)
* update zig bindings to Zig 0.12.0

* support zig package manager

* Fix zig macos ci build

* Make the macos build use 1 process instead of hitting the macos
  process limit immediately, utilize the build.zig `-Dparallel
  false` option for macos ci
* Split the macos ci into a new build stage (out of the ubuntu,
  macos build maxtrix), to allow for multiple architecture builds
  in the future after the zig bindings improve
2024-05-06 21:02:24 +08:00
Nguyen Anh Quynh
751a4d0f03 compile warning: remove some unused vars 2024-05-02 16:26:41 +08:00
mio
85b289d074 Use correct lib path 2024-04-30 18:06:30 +08:00
mio
da84208d89 Hide symbols for unicorn-common 2024-04-29 11:55:06 +08:00
Nguyễn Anh Khoa
38091b3046 Add unicorn_py3 folder to setup.py (#1942)
* Add unicorn_py3 folder to setup.py

* Run sample in CI

* Fix pip install & py2 breakage

---------

Co-authored-by: mio <mio@lazym.io>
2024-04-28 00:11:05 +08:00
Nguyen Anh Quynh
c136b6b2bf fix some compiler warnings 2024-04-22 20:03:07 +08:00
Charles Ferguson
ef34d92b2f Add hooks doc written by @gerph 2024-04-19 18:41:28 +08:00
cff94a4a56 Merge pull request #1932 from lockbox/rust-conditional-compilation
Rust conditional compilation
2024-03-28 19:29:23 +08:00
lockbox
c850db1125 Inherit architecture support from cfg features
While the bindings conditionally compile code based on the cfg
flags, we still include the architecture support in emitted rust
code. This patch removes the ability to refer to architectures
that cannot possibly be supported.
2024-03-27 17:30:53 -04:00
lockbox
30b99601d2 apply default rust 2021 formatting 2024-03-27 16:54:51 -04:00
b4f2ac9aab Merge pull request #1930 from lockbox/address-typo
Address typo in documentation of address in memory event callbacks
2024-03-20 13:52:31 +08:00
lockbox
321de00f36 [typo]: Correctly document address parameter in mem hook callbacks 2024-03-18 17:51:35 -04: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
mio
e03109d8c9 Respect users' decision for UC_ERR_INSN_INVALID 2024-03-08 17:31:27 +08:00
mio
a9a54aed2f Fix for xcode build 2024-03-08 17:28:46 +08:00
mio
4c4d582fcb Also add _repr_ for UcReg 2024-03-08 17:07:08 +08:00
mio
13f17e5b3f Apply repr for C structs 2024-03-08 16:48:31 +08:00
mio
9463d00c3e Merge remote-tracking branch 'origin/dev' into dev 2024-03-08 16:20:58 +08:00
mio
dae2391bb0 Apply fix for linux2 2024-03-08 16:19:53 +08:00
mio
399f204787 Merge elicn's work 2024-03-08 16:16:12 +08:00
0bca8df694 Merge pull request #1796 from bet4it/dylib
Fix dynamic linkage on msvc
2024-03-08 15:16:36 +08:00
ba92f79c9e Merge pull request #1823 from unicorn-engine/restore-py2
[RFC] Restore py2 compatibility by using 2 files
2024-03-08 15:12:24 +08: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
Mark Giraud
00680412d3 feat: Add start and end address to rust block hook binding 2024-02-26 11:20:27 +01: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
7012e4599b Remove debugging session 2024-02-13 16:22:16 +08:00
4245475514 Detect if we have valid pthread_jit_write_protect_np 2024-02-13 16:21:53 +08:00
67deee7771 dbg 2024-02-13 14:46:08 +08:00
b31081a105 Remove unused var 2024-02-13 14:38:48 +08:00