tcg patch queue
Subsystems (2)
The following changes since commit 7a1dc45af581d2b643cdbf33c01fd96271616fbd:
Merge tag 'pull-target-arm-20240126' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-01-26 18:16:35 +0000)
are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240130
for you to fetch changes up to ec1d32af123e7f13d98754a72bcaa7aa8c8e9d27:
target/i386: Extract x86_cpu_exec_halt() from accel/tcg/ (2024-01-29 21:04:10 +1000)
----------------------------------------------------------------
linux-user: Allow gdbstub to ignore page protection
cpu-exec: simplify jump cache management include/exec: Cleanups toward building accel/tcg once
----------------------------------------------------------------
Anton Johansson (9):
include/exec: Move vaddr defines to separate file hw/core: Include vaddr.h from cpu.h
target: Use vaddr in gen_intermediate_code include/exec: Use vaddr in DisasContextBase for virtual addresses include/exec: typedef abi_ptr to vaddr
include/exec: Move PAGE_* macros to common header include/exec: Move cpu_*()/cpu_env() to common header include/hw/core: Move do_interrupt in TCGCPUOps include/hw/core: Remove i386 conditional on fake_user_interrupt
Ilya Leoshkevich (8):
linux-user: Allow gdbstub to ignore page protection tests/tcg: Factor out gdbstub test functions tests/tcg: Add the PROT_NONE gdbstub test
target: Make qemu_target_page_mask() available for *-user accel/tcg: Make use of qemu_target_page_mask() in perf.c
tcg: Make tb_cflags() usable from target-agnostic code accel/tcg: Remove #ifdef TARGET_I386 from perf.c accel/tcg: Move perf and debuginfo support to tcg/
Paolo Bonzini (1):
cpu-exec: simplify jump cache management
Philippe Mathieu-Daudé (9):
accel/tcg/cpu-exec: Use RCU_READ_LOCK_GUARD accel/tcg: Rename tcg_ss[] -> tcg_specific_ss[] in meson accel/tcg: Rename tcg_cpus_destroy() -> tcg_cpu_destroy() accel/tcg: Rename tcg_cpus_exec() -> tcg_cpu_exec() accel/tcg: Un-inline icount_exit_request() for clarity accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler target/i386: Extract x86_need_replay_interrupt() from accel/tcg/ accel/tcg: Introduce TCGCPUOps::cpu_exec_halt() handler target/i386: Extract x86_cpu_exec_halt() from accel/tcg/
Richard Henderson (4):
include/qemu: Add TCGCPUOps typedef to typedefs.h target/loongarch: Constify loongarch_tcg_ops accel/tcg: Use CPUState.cc instead of CPU_GET_CLASS in cpu-exec.c accel/tcg: Inline need_replay_interrupt
accel/tcg/tb-jmp-cache.h | 8 +-
accel/tcg/tcg-accel-ops.h | 4 +-
include/exec/cpu-all.h | 49 -----
include/exec/cpu-common.h | 69 +++++--
include/exec/cpu_ldst.h | 4 +-
include/exec/exec-all.h | 6 -
include/exec/translation-block.h | 6 +
include/exec/translator.h | 8 +-
include/exec/vaddr.h | 18 ++
include/hw/core/cpu.h | 7 +-
include/hw/core/tcg-cpu-ops.h | 19 +-
include/qemu/typedefs.h | 1 +
{accel => include}/tcg/debuginfo.h | 4 +-
{accel => include}/tcg/perf.h | 4 +-
target/i386/tcg/helper-tcg.h | 2 +
target/mips/tcg/translate.h | 3 +-
accel/tcg/cpu-exec.c | 223 +++++++++------------
accel/tcg/tcg-accel-ops-mttcg.c | 4 +-
accel/tcg/tcg-accel-ops-rr.c | 4 +-
accel/tcg/tcg-accel-ops.c | 4 +-
accel/tcg/translate-all.c | 2 +-
bsd-user/signal.c | 4 +-
cpu-target.c | 78 +++++--
hw/core/loader.c | 2 +-
linux-user/elfload.c | 2 +-
linux-user/exit.c | 2 +-
linux-user/main.c | 2 +-
linux-user/signal.c | 4 +-
system/physmem.c | 5 -
system/vl.c | 2 +-
target/alpha/cpu.c | 2 +-
target/alpha/translate.c | 2 +-
target/arm/cpu.c | 2 +-
target/arm/tcg/cpu32.c | 2 +-
target/arm/tcg/translate.c | 2 +-
target/avr/cpu.c | 2 +-
target/avr/translate.c | 2 +-
target/cris/cpu.c | 4 +-
target/cris/translate.c | 2 +-
target/hexagon/cpu.c | 2 +-
target/hexagon/translate.c | 5 +-
target/hppa/cpu.c | 2 +-
target/hppa/translate.c | 2 +-
target/i386/tcg/sysemu/seg_helper.c | 23 +++
target/i386/tcg/tcg-cpu.c | 4 +-
target/i386/tcg/translate.c | 2 +-
target/loongarch/cpu.c | 2 +-
target/loongarch/tcg/translate.c | 2 +-
target/m68k/cpu.c | 2 +-
target/m68k/translate.c | 4 +-
target/microblaze/cpu.c | 2 +-
target/microblaze/translate.c | 2 +-
target/mips/cpu.c | 2 +-
target/mips/tcg/translate.c | 14 +-
target/nios2/cpu.c | 2 +-
target/nios2/translate.c | 2 +-
target/openrisc/cpu.c | 2 +-
target/openrisc/translate.c | 2 +-
target/ppc/cpu_init.c | 2 +-
target/ppc/translate.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 2 +-
target/riscv/translate.c | 2 +-
target/rx/cpu.c | 2 +-
target/rx/translate.c | 2 +-
target/s390x/cpu.c | 2 +-
target/s390x/tcg/translate.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sh4/translate.c | 2 +-
target/sparc/cpu.c | 2 +-
target/sparc/translate.c | 2 +-
target/target-common.c | 10 +
target/tricore/cpu.c | 2 +-
target/tricore/translate.c | 2 +-
target/xtensa/cpu.c | 2 +-
target/xtensa/translate.c | 2 +-
{accel/tcg => tcg}/debuginfo.c | 3 +-
{accel/tcg => tcg}/perf.c | 14 +-
tcg/tcg.c | 2 +-
tests/tcg/multiarch/prot-none.c | 40 ++++
accel/tcg/meson.build | 16 +-
target/meson.build | 2 +
tcg/meson.build | 5 +
tests/guest-debug/run-test.py | 7 +-
tests/guest-debug/test_gdbstub.py | 60 ++++++
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 34 +---
tests/tcg/aarch64/gdbstub/test-sve.py | 33 +--
tests/tcg/multiarch/Makefile.target | 9 +-
tests/tcg/multiarch/gdbstub/interrupt.py | 47 +----
tests/tcg/multiarch/gdbstub/memory.py | 39 +---
tests/tcg/multiarch/gdbstub/prot-none.py | 36 ++++
tests/tcg/multiarch/gdbstub/registers.py | 41 +---
tests/tcg/multiarch/gdbstub/sha1.py | 38 +---
tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 39 +---
.../tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | 37 +---
.../multiarch/gdbstub/test-thread-breakpoint.py | 37 +---
tests/tcg/s390x/gdbstub/test-signals-s390x.py | 42 +---
tests/tcg/s390x/gdbstub/test-svc.py | 39 +---
97 files changed, 580 insertions(+), 730 deletions(-)
create mode 100644 include/exec/vaddr.h
rename {accel => include}/tcg/debuginfo.h (96%)
rename {accel => include}/tcg/perf.h (95%)
create mode 100644 target/target-common.c
rename {accel/tcg => tcg}/debuginfo.c (98%)
rename {accel/tcg => tcg}/perf.c (97%)
create mode 100644 tests/tcg/multiarch/prot-none.c
create mode 100644 tests/guest-debug/test_gdbstub.py
create mode 100644 tests/tcg/multiarch/gdbstub/prot-none.py[PULL 02/31] include/exec: Move vaddr defines to separate file
From: Anton Johansson <[email protected]>
Needed to work around circular includes. vaddr is currently defined in cpu-common.h and needed by hw/core/cpu.h, but cpu-common.h also need cpu.h to know the size of the CPUState.
[Maybe we can instead move parts of cpu-common.h w. hw/core/cpu.h to sort out the circular inclusion.]
Message-Id: <[email protected]>
--- include/exec/cpu-common.h | 13 +------------ include/exec/vaddr.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 include/exec/vaddr.h
include/exec/cpu-common.h +1 -12
@@ -3,6 +3,7 @@/* CPU interfaces that are target independent. */ +#include "exec/vaddr.h" #ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" #endif
@@ -14,18 +15,6 @@#define EXCP_YIELD 0x10004/* cpu wants to yield timeslice to another */ #define EXCP_ATOMIC 0x10005/* stop-the-world and emulate atomic */ -/** -* vaddr: -* Type wide enough to contain any #target_ulong virtual address. -*/ -typedef uint64_t vaddr ; -#define VADDR_PRId PRId64 -#define VADDR_PRIu PRIu64 -#define VADDR_PRIo PRIo64 -#define VADDR_PRIx PRIx64 -#define VADDR_PRIX PRIX64 -#define VADDR_MAX UINT64_MAX -void cpu_exec_init_all (void );void cpu_exec_step_atomic (CPUState *cpu);
include/exec/vaddr.h new file +18 -0
@@ -0,0 +1,18 @@ +/* Define vaddr. */ + +#ifndef VADDR_H +#define VADDR_H + +/** +* vaddr: +* Type wide enough to contain any #target_ulong virtual address. +*/ +typedef uint64_t vaddr ; +#define VADDR_PRId PRId64 +#define VADDR_PRIu PRIu64 +#define VADDR_PRIo PRIo64 +#define VADDR_PRIx PRIx64 +#define VADDR_PRIX PRIX64 +#define VADDR_MAX UINT64_MAX + +#endif
Signature · 1 line
2.34.1
[PULL 01/31] cpu-exec: simplify jump cache management
In reply to Richard HendersonFrom: Paolo Bonzini <[email protected]>
Unless I'm missing something egregious, the jmp cache is only every populated with a valid entry by the same thread that reads the cache. Therefore, the contents of any valid entry are always consistent and there is no need for any acquire/release magic.
Indeed ->tb has to be accessed with atomics, because concurrent invalidations would otherwise cause data races. But ->pc is only ever accessed by one thread, and accesses to ->tb and ->pc within tb_lookup can never race with another tb_lookup. While the TranslationBlock (especially the flags) could be modified by a concurrent invalidation, store-release and load-acquire operations on the cache entry would not add any additional ordering beyond what you get from performing the accesses within a single thread.
Because of this, there is really nothing to win in splitting the CF_PCREL and !CF_PCREL paths. It is easier to just always use the ->pc field in the jump cache.
I noticed this while working on splitting commit 8ed558ec0cb ("accel/tcg: Introduce TARGET_TB_PCREL", 2022-10-04) into multiple pieces, for the sake of finding a more fine-grained bisection result for https://gitlab.com/qemu-project/qemu/-/issues/2092.
It does not (and does not intend to) fix that issue; therefore it may make sense to not commit it until the root cause of issue #2092 is found.
Message-Id: <[email protected]>
--- accel/tcg/tb-jmp-cache.h | 8 +++-- accel/tcg/cpu-exec.c | 66 ++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 46 deletions(-)
accel/tcg/tb-jmp-cache.h +5 -3
@@ -13,9 +13,11 @@#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)/* -* Accessed in parallel; all accesses to 'tb' must be atomic. -* For CF_PCREL, accesses to 'pc' must be protected by a -* load_acquire/store_release to 'tb'. +* Invalidated in parallel; all accesses to 'tb' must be atomic. +* A valid entry is read/written by a single CPU, therefore there is +* no need for qatomic_rcu_read() and pc is always consistent with a +* non-NULL value of 'tb'. Strictly speaking pc is only needed for +* CF_PCREL, but it's used always for simplicity. */ struct CPUJumpCache {struct rcu_head rcu;
accel/tcg/cpu-exec.c +23 -43
80 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 11/31] linux-user: Allow gdbstub to ignore page protection
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
gdbserver ignores page protection by virtue of using /proc/$pid/mem. Teach qemu gdbstub to do this too. This will not work if /proc is not mounted; accept this limitation.
One alternative is to temporarily grant the missing PROT_* bit, but this is inherently racy. Another alternative is self-debugging with ptrace(POKE), which will break if QEMU itself is being debugged - a much more severe limitation.
Message-Id: <[email protected]>
--- cpu-target.c | 78 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 15 deletions(-)
cpu-target.c +63 -15
@@ -382,6 +382,9 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,vaddr l, page;void * p;uint8_t *buf = ptr; +ssize_t written; +int ret =-1 ; +int fd =-1 ;while (len >0 ) { page = addr &TARGET_PAGE_MASK ;
@@ -389,30 +392,75 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,if (l > len) l = len; flags =page_get_flags (page); -if (!(flags &PAGE_VALID )) -return -1 ; +if (!(flags &PAGE_VALID )) { + goto out_close; + }if (is_write) { -if (!(flags &PAGE_WRITE )) -return -1 ; +if (flags &PAGE_WRITE ) { +/* XXX: this code should not depend on lock_user */ + p =lock_user (VERIFY_WRITE , addr, l,0 ); +if (!p) { + goto out_close; + } +memcpy (p, buf, l); +unlock_user (p, addr, l); + }else { +/* Bypass the host page protection using ptrace. */ +if (fd ==-1 ) { + fd =open ("/proc/self/mem" ,O_WRONLY ); +if (fd ==-1 ) { + goto out; + } + } +/* +* If there is a TranslationBlock and we weren't bypassing the +* host page protection, the memcpy() above would SEGV, +* ultimately leading to page_unprotect(). So invalidate the +* translations manually. Both invalidation and pwrite() must +* be under mmap_lock() in order to prevent the creation of +* another TranslationBlock in between. +*/ +mmap_lock (); +tb_invalidate_phys_range (addr, addr + l -1 ); + written =pwrite (fd, buf, l, + (off_t )(uintptr_t )g2h_untagged (addr)); +mmap_unlock (); +if (written != l) { + goto out_close; + } + } + }else if (flags &PAGE_READ ) {/* XXX: this code should not depend on lock_user */ -if (!(p =lock_user (VERIFY_WRITE , addr, l,0 ))) -return -1 ; -memcpy (p, buf, l); -unlock_user (p, addr, l); - }else { -if (!(flags &PAGE_READ )) -return -1 ; -/* XXX: this code should not depend on lock_user */ -if (!(p =lock_user (VERIFY_READ , addr, l,1 ))) -return -1 ; + p =lock_user (VERIFY_READ , addr, l,1 ); +if (!p) { + goto out_close; + }memcpy (buf, p, l);unlock_user (p, addr,0 ); + }else { +/* Bypass the host page protection using ptrace. */ +if (fd ==-1 ) { + fd =open ("/proc/self/mem" ,O_RDONLY ); +if (fd ==-1 ) { + goto out; + } + } +if (pread (fd, buf, l, + (off_t )(uintptr_t )g2h_untagged (addr)) != l) { + goto out_close; + } } len -= l; buf += l; addr += l; } -return 0 ; + ret =0 ; +out_close: +if (fd !=-1 ) { +close (fd); + } +out: +return ret; }#endif
Signature · 1 line
2.34.1
[PULL 12/31] tests/tcg: Factor out gdbstub test functions
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Both the report() function as well as the initial gdbstub test sequence are copy-pasted into ~10 files with slight modifications. This indicates that they are indeed generic, so factor them out. While at it, add a few newlines to make the formatting closer to PEP-8.
Message-Id: <[email protected]>
--- tests/guest-debug/run-test.py | 7 ++- tests/guest-debug/test_gdbstub.py | 60 +++++++++++++++++++ tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 34 +---------- tests/tcg/aarch64/gdbstub/test-sve.py | 33 +--------- tests/tcg/multiarch/gdbstub/interrupt.py | 47 ++------------- tests/tcg/multiarch/gdbstub/memory.py | 39 +----------- tests/tcg/multiarch/gdbstub/registers.py | 41 ++----------- tests/tcg/multiarch/gdbstub/sha1.py | 38 ++---------- .../multiarch/gdbstub/test-proc-mappings.py | 39 +----------- .../multiarch/gdbstub/test-qxfer-auxv-read.py | 37 +----------- .../gdbstub/test-thread-breakpoint.py | 37 +----------- tests/tcg/s390x/gdbstub/test-signals-s390x.py | 42 +------------ tests/tcg/s390x/gdbstub/test-svc.py | 39 +----------- 13 files changed, 98 insertions(+), 395 deletions(-) create mode 100644 tests/guest-debug/test_gdbstub.py
tests/guest-debug/run-test.py +6 -1
@@ -97,7 +97,12 @@ def log(output, msg): sleep(1) log(output, "GDB CMD: %s" % (gdb_cmd)) - result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr) + gdb_env = dict(os.environ) + gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep) + gdb_pythonpath.append(os.path.dirname(os.path.realpath(__file__))) + gdb_env["PYTHONPATH"] = os.pathsep.join(gdb_pythonpath) + result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr, + env=gdb_env) # A result of greater than 128 indicates a fatal signal (likely a # crash due to gdb internal failure). That's a problem for GDB and
tests/guest-debug/test_gdbstub.py new file +60 -0
60 lines not on this page · raw message
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +2 -32
@@ -8,19 +8,10 @@ # import gdb -import sys +from test_gdbstub import main, report initial_vlen = 0 -failcount = 0 -def report(cond, msg): - "Report success/fail of test" - if cond: - print ("PASS: %s" % (msg)) - else: - print ("FAIL: %s" % (msg)) - global failcount - failcount += 1 class TestBreakpoint(gdb.Breakpoint): def __init__(self, sym_name="__sve_ld_done"):
@@ -64,26 +55,5 @@ def run_test(): gdb.execute("c") -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - report(arch.name() == "aarch64", "connected to aarch64") -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -try: - # Run the actual tests - run_test() -except: - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - import code - code.InteractiveConsole(locals=globals()).interact() - raise - -print("All tests complete: %d failures" % failcount) -exit(failcount) +main(run_test, expected_arch="aarch64")
tests/tcg/aarch64/gdbstub/test-sve.py +2 -31
@@ -6,20 +6,10 @@ # import gdb -import sys +from test_gdbstub import main, report MAGIC = 0xDEADBEEF -failcount = 0 - -def report(cond, msg): - "Report success/fail of test" - if cond: - print ("PASS: %s" % (msg)) - else: - print ("FAIL: %s" % (msg)) - global failcount - failcount += 1 def run_test(): "Run through the tests one by one"
@@ -54,24 +44,5 @@ def run_test(): report(str(v.type) == "uint64_t", "size of %s" % (reg)) report(int(v) == MAGIC, "%s is 0x%x" % (reg, MAGIC)) -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - report(arch.name() == "aarch64", "connected to aarch64") -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -try: - # Run the actual tests - run_test() -except: - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - -print("All tests complete: %d failures" % failcount) - -exit(failcount) +main(run_test, expected_arch="aarch64")
tests/tcg/multiarch/gdbstub/interrupt.py +5 -42
62 lines not on this page · raw message
tests/tcg/multiarch/gdbstub/memory.py +2 -37
@@ -9,18 +9,7 @@ import gdb import sys - -failcount = 0 - - -def report(cond, msg): - "Report success/fail of test" - if cond: - print("PASS: %s" % (msg)) - else: - print("FAIL: %s" % (msg)) - global failcount - failcount += 1 +from test_gdbstub import main, report def check_step():
@@ -99,29 +88,5 @@ def run_test(): report(cbp.hit_count == 0, "didn't reach backstop") -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - print("ATTACHED: %s" % arch.name()) -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - -try: - # Run the actual tests - run_test() -except (gdb.error): - print("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - pass - -# Finally kill the inferior and exit gdb with a count of failures -gdb.execute("kill") -exit(failcount) +main(run_test)
tests/tcg/multiarch/gdbstub/registers.py +6 -35
71 lines not on this page · raw message
tests/tcg/multiarch/gdbstub/sha1.py +4 -34
@@ -7,19 +7,11 @@ # import gdb -import sys +from test_gdbstub import main, report + initial_vlen = 0 -failcount = 0 -def report(cond, msg): - "Report success/fail of test" - if cond: - print("PASS: %s" % (msg)) - else: - print("FAIL: %s" % (msg)) - global failcount - failcount += 1 def check_break(sym_name): "Setup breakpoint, continue and check we stopped."
@@ -35,6 +27,7 @@ def check_break(sym_name): bp.delete() + def run_test(): "Run through the tests one by one"
@@ -57,28 +50,5 @@ def run_test(): # finally check we don't barf inspecting registers gdb.execute("info registers") -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - print("ATTACHED: %s" % arch.name()) -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - -try: - # Run the actual tests - run_test() -except (gdb.error): - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - pass - -print("All tests complete: %d failures" % failcount) -exit(failcount) +main(run_test)
tests/tcg/multiarch/gdbstub/test-proc-mappings.py +2 -37
@@ -3,20 +3,7 @@ This runs as a sourced script (via -x, via run-test.py).""" from __future__ import print_function import gdb -import sys - - -n_failures = 0 - - -def report(cond, msg): - """Report success/fail of a test""" - if cond: - print("PASS: {}".format(msg)) - else: - print("FAIL: {}".format(msg)) - global n_failures - n_failures += 1 +from test_gdbstub import main, report def run_test():
@@ -37,26 +24,4 @@ def run_test(): # report("/sha1" in mappings, "Found the test binary name in the mappings") -def main(): - """Prepare the environment and run through the tests""" - try: - inferior = gdb.selected_inferior() - print("ATTACHED: {}".format(inferior.architecture().name())) - except (gdb.error, AttributeError): - print("SKIPPING (not connected)") - exit(0) - - if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - - try: - # Run the actual tests - run_test() - except gdb.error: - report(False, "GDB Exception: {}".format(sys.exc_info()[0])) - print("All tests complete: %d failures" % n_failures) - exit(n_failures) - - -main() +main(run_test)
tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py +2 -35
@@ -6,18 +6,8 @@ # import gdb -import sys +from test_gdbstub import main, report -failcount = 0 - -def report(cond, msg): - "Report success/fail of test" - if cond: - print ("PASS: %s" % (msg)) - else: - print ("FAIL: %s" % (msg)) - global failcount - failcount += 1 def run_test(): "Run through the tests one by one"
@@ -26,28 +16,5 @@ def run_test(): report(isinstance(auxv, str), "Fetched auxv from inferior") report(auxv.find("sha1"), "Found test binary name in auxv") -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - print("ATTACHED: %s" % arch.name()) -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - -try: - # Run the actual tests - run_test() -except (gdb.error): - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - pass - -print("All tests complete: %d failures" % failcount) -exit(failcount) +main(run_test)
tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py +2 -35
@@ -6,18 +6,8 @@ # import gdb -import sys +from test_gdbstub import main, report -failcount = 0 - -def report(cond, msg): - "Report success/fail of test" - if cond: - print ("PASS: %s" % (msg)) - else: - print ("FAIL: %s" % (msg)) - global failcount - failcount += 1 def run_test(): "Run through the tests one by one"
@@ -29,28 +19,5 @@ def run_test(): frame = gdb.selected_frame() report(str(frame.function()) == "thread1_func", "break @ %s"%frame) -# -# This runs as the script it sourced (via -x, via run-test.py) -# -try: - inferior = gdb.selected_inferior() - arch = inferior.architecture() - print("ATTACHED: %s" % arch.name()) -except (gdb.error, AttributeError): - print("SKIPPING (not connected)", file=sys.stderr) - exit(0) -if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - -try: - # Run the actual tests - run_test() -except (gdb.error): - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - pass - -print("All tests complete: %d failures" % failcount) -exit(failcount) +main(run_test)
tests/tcg/s390x/gdbstub/test-signals-s390x.py +3 -39
53 lines not on this page · raw message
tests/tcg/s390x/gdbstub/test-svc.py +2 -37
@@ -3,20 +3,7 @@ This runs as a sourced script (via -x, via run-test.py).""" from __future__ import print_function import gdb -import sys - - -n_failures = 0 - - -def report(cond, msg): - """Report success/fail of a test""" - if cond: - print("PASS: {}".format(msg)) - else: - print("FAIL: {}".format(msg)) - global n_failures - n_failures += 1 +from test_gdbstub import main, report def run_test():
@@ -35,26 +22,4 @@ def run_test(): gdb.execute("si") -def main(): - """Prepare the environment and run through the tests""" - try: - inferior = gdb.selected_inferior() - print("ATTACHED: {}".format(inferior.architecture().name())) - except (gdb.error, AttributeError): - print("SKIPPING (not connected)") - exit(0) - - if gdb.parse_and_eval('$pc') == 0: - print("SKIP: PC not set") - exit(0) - - try: - # Run the actual tests - run_test() - except gdb.error: - report(False, "GDB Exception: {}".format(sys.exc_info()[0])) - print("All tests complete: %d failures" % n_failures) - exit(n_failures) - - -main() +main(run_test)
Signature · 1 line
2.34.1
[PULL 15/31] target: Make qemu_target_page_mask() available for *-user
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Currently qemu_target_page_mask() is usable only from the softmmu code. Make it possible to use it from the *-user code as well.
Message-ID: <[email protected]>
Message-Id: <[email protected]>
--- system/physmem.c | 5 ----- target/target-common.c | 10 ++++++++++ target/meson.build | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 target/target-common.c
system/physmem.c +0 -5
@@ -3431,11 +3431,6 @@ size_t qemu_target_page_size(void)return TARGET_PAGE_SIZE ; } -int qemu_target_page_mask (void ) -{ -return TARGET_PAGE_MASK ; -} -int qemu_target_page_bits (void ) {return TARGET_PAGE_BITS ;
target/target-common.c new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "qemu/osdep.h" + +#include "cpu.h" +#include "exec/target_page.h" + +int qemu_target_page_mask (void ) +{ +return TARGET_PAGE_MASK ; +}
target/meson.build +2 -0
@@ -19,3 +19,5 @@ subdir('sh4') subdir('sparc') subdir('tricore') subdir('xtensa') + +specific_ss.add(files('target-common.c'))
Signature · 1 line
2.34.1
[PULL 20/31] accel/tcg: Rename tcg_ss[] -> tcg_specific_ss[] in meson
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
tcg_ss[] source set contains target-specific units. Rename it as 'tcg_specific_ss[]' for clarity.
Message-Id: <[email protected]>
--- accel/tcg/meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
accel/tcg/meson.build +6 -6
@@ -1,8 +1,8 @@ -tcg_ss = ss.source_set() common_ss.add(when: 'CONFIG_TCG', if_true: files( 'cpu-exec-common.c', )) -tcg_ss.add(files( +tcg_specific_ss = ss.source_set() +tcg_specific_ss.add(files( 'tcg-all.c', 'cpu-exec.c', 'tb-maint.c',
@@ -11,12 +11,12 @@ tcg_ss.add(files( 'translate-all.c', 'translator.c', )) -tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) -tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) +tcg_specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) +tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) if get_option('plugins') - tcg_ss.add(files('plugin-gen.c')) + tcg_specific_ss.add(files('plugin-gen.c')) endif -specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) +specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( 'cputlb.c',
Signature · 1 line
2.34.1
[PULL 21/31] accel/tcg: Rename tcg_cpus_destroy() -> tcg_cpu_destroy()
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
tcg_cpus_destroy() operates on a single vCPU, rename it as 'tcg_cpu_destroy'.
Message-Id: <[email protected]>
--- accel/tcg/tcg-accel-ops.h | 2 +- accel/tcg/tcg-accel-ops-mttcg.c | 2 +- accel/tcg/tcg-accel-ops-rr.c | 2 +- accel/tcg/tcg-accel-ops.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
accel/tcg/tcg-accel-ops.h +1 -1
@@ -14,7 +14,7 @@#include "sysemu/cpus.h" -void tcg_cpus_destroy (CPUState *cpu); +void tcg_cpu_destroy (CPUState *cpu);int tcg_cpus_exec (CPUState *cpu);void tcg_handle_interrupt (CPUState *cpu,int mask);void tcg_cpu_init_cflags (CPUState *cpu,bool parallel);
accel/tcg/tcg-accel-ops-mttcg.c +1 -1
@@ -118,7 +118,7 @@ static void *mttcg_cpu_thread_fn(void *arg)qemu_wait_io_event (cpu); }while (!cpu->unplug ||cpu_can_run (cpu)); -tcg_cpus_destroy (cpu); +tcg_cpu_destroy (cpu);bql_unlock ();rcu_remove_force_rcu_notifier (&force_rcu.notifier);rcu_unregister_thread ();
accel/tcg/tcg-accel-ops-rr.c +1 -1
@@ -131,7 +131,7 @@ static void rr_deal_with_unplugged_cpus(void)CPU_FOREACH (cpu) {if (cpu->unplug && !cpu_can_run (cpu)) { -tcg_cpus_destroy (cpu); +tcg_cpu_destroy (cpu);break ; } }
accel/tcg/tcg-accel-ops.c +1 -1
@@ -63,7 +63,7 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) cpu->tcg_cflags |= cflags; } -void tcg_cpus_destroy (CPUState *cpu) +void tcg_cpu_destroy (CPUState *cpu) {cpu_thread_signal_destroyed (cpu); }
Signature · 1 line
2.34.1
[PULL 17/31] tcg: Make tb_cflags() usable from target-agnostic code
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Currently tb_cflags() is defined in exec-all.h, which is not usable from target-agnostic code. Move it to translation-block.h, which is.
Message-ID: <[email protected]>
Message-Id: <[email protected]>
--- include/exec/exec-all.h | 6 ------ include/exec/translation-block.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-)
include/exec/exec-all.h +0 -6
@@ -459,12 +459,6 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size,#endif -/* Hide the qatomic_read to make code a little easier on the eyes */ -static inline uint32_t tb_cflags (const TranslationBlock *tb) -{ -return qatomic_read (&tb->cflags); -} -static inline tb_page_addr_t tb_page_addr0 (const TranslationBlock *tb) {#ifdef CONFIG_USER_ONLY
include/exec/translation-block.h +6 -0
@@ -145,4 +145,10 @@ struct TranslationBlock {/* The alignment given to TranslationBlock during allocation. */ #define CODE_GEN_ALIGN 16 +/* Hide the qatomic_read to make code a little easier on the eyes */ +static inline uint32_t tb_cflags (const TranslationBlock *tb) +{ +return qatomic_read (&tb->cflags); +} +#endif /* EXEC_TRANSLATION_BLOCK_H */
Signature · 1 line
2.34.1
[PULL 10/31] include/hw/core: Remove i386 conditional on fake_user_interrupt
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
Always include fake_user_interrupt in user-only build, despite only being used for i386. This will enable cpu-exec.c to be compiled only once.
Message-ID: <[email protected]>
--- include/hw/core/tcg-cpu-ops.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/hw/core/tcg-cpu-ops.h +2 -3
@@ -50,7 +50,7 @@ struct TCGCPUOps {void (*debug_excp_handler)(CPUState *cpu);#ifdef NEED_CPU_H -#if defined(CONFIG_USER_ONLY ) && defined(TARGET_I386 ) +#ifdef CONFIG_USER_ONLY /** * @fake_user_interrupt: Callback for 'fake exception' handling. *
@@ -58,8 +58,7 @@ struct TCGCPUOps {* cpu execution loop (hack for x86 user mode). */ void (*fake_user_interrupt)(CPUState *cpu); -#endif /* !CONFIG_USER_ONLY || !TARGET_I386 */ -#ifdef CONFIG_USER_ONLY +/** * record_sigsegv: * @cpu: cpu context
Signature · 1 line
2.34.1
[PULL 22/31] accel/tcg: Rename tcg_cpus_exec() -> tcg_cpu_exec()
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
tcg_cpus_exec() operates on a single vCPU, rename it as 'tcg_cpu_exec'.
Message-Id: <[email protected]>
--- accel/tcg/tcg-accel-ops.h | 2 +- accel/tcg/tcg-accel-ops-mttcg.c | 2 +- accel/tcg/tcg-accel-ops-rr.c | 2 +- accel/tcg/tcg-accel-ops.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
accel/tcg/tcg-accel-ops.h +1 -1
@@ -15,7 +15,7 @@#include "sysemu/cpus.h" void tcg_cpu_destroy (CPUState *cpu); -int tcg_cpus_exec (CPUState *cpu); +int tcg_cpu_exec (CPUState *cpu);void tcg_handle_interrupt (CPUState *cpu,int mask);void tcg_cpu_init_cflags (CPUState *cpu,bool parallel);
accel/tcg/tcg-accel-ops-mttcg.c +1 -1
@@ -92,7 +92,7 @@ static void *mttcg_cpu_thread_fn(void *arg)if (cpu_can_run (cpu)) {int r;bql_unlock (); - r =tcg_cpus_exec (cpu); + r =tcg_cpu_exec (cpu);bql_lock ();switch (r) {case EXCP_DEBUG :
accel/tcg/tcg-accel-ops-rr.c +1 -1
@@ -258,7 +258,7 @@ static void *rr_cpu_thread_fn(void *arg)if (icount_enabled ()) {icount_prepare_for_run (cpu, cpu_budget); } - r =tcg_cpus_exec (cpu); + r =tcg_cpu_exec (cpu);if (icount_enabled ()) {icount_process_data (cpu); }
accel/tcg/tcg-accel-ops.c +1 -1
@@ -68,7 +68,7 @@ void tcg_cpu_destroy(CPUState *cpu)cpu_thread_signal_destroyed (cpu); } -int tcg_cpus_exec (CPUState *cpu) +int tcg_cpu_exec (CPUState *cpu) {int ret;assert (tcg_enabled ());
Signature · 1 line
2.34.1
[PULL 08/31] include/exec: Move cpu_*()/cpu_env() to common header
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
Functions are target independent.
Message-Id: <[email protected]>
--- include/exec/cpu-all.h | 25 ------------------------- include/exec/cpu-common.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-)
include/exec/cpu-all.h +0 -25
@@ -384,33 +384,8 @@ static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr)#endif /* !CONFIG_USER_ONLY */ -/* accel/tcg/cpu-exec.c */ -int cpu_exec (CPUState *cpu); -/* Validate correct placement of CPUArchState. */ QEMU_BUILD_BUG_ON (offsetof(ArchCPU , parent_obj) !=0 );QEMU_BUILD_BUG_ON (offsetof(ArchCPU , env) !=sizeof (CPUState)); -/** -* env_archcpu(env) -* @env: The architecture environment -* -* Return the ArchCPU associated with the environment. -*/ -static inline ArchCPU *env_archcpu (CPUArchState *env) -{ -return (void *)env -sizeof (CPUState); -} - -/** -* env_cpu(env) -* @env: The architecture environment -* -* Return the CPUState associated with the environment. -*/ -static inline CPUState *env_cpu (CPUArchState *env) -{ -return (void *)env -sizeof (CPUState); -} -#endif /* CPU_ALL_H */
include/exec/cpu-common.h +26 -0
@@ -7,6 +7,7 @@#ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" #endif +#include "hw/core/cpu.h" #define EXCP_INTERRUPT 0x10000/* async interruption */ #define EXCP_HLT 0x10001/* hlt instruction reached */
@@ -236,4 +237,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);*/ #define PAGE_PASSTHROUGH 0x0800 +/* accel/tcg/cpu-exec.c */ +int cpu_exec (CPUState *cpu); + +/** +* env_archcpu(env) +* @env: The architecture environment +* +* Return the ArchCPU associated with the environment. +*/ +static inline ArchCPU *env_archcpu (CPUArchState *env) +{ +return (void *)env -sizeof (CPUState); +} + +/** +* env_cpu(env) +* @env: The architecture environment +* +* Return the CPUState associated with the environment. +*/ +static inline CPUState *env_cpu (CPUArchState *env) +{ +return (void *)env -sizeof (CPUState); +} +#endif /* CPU_COMMON_H */
Signature · 1 line
2.34.1
[PULL 19/31] accel/tcg: Move perf and debuginfo support to tcg/
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
tcg/ should not depend on accel/tcg/, but perf and debuginfo support provided by the latter are being used by tcg/tcg.c.
Since that's the only user, move both to tcg/.
Message-ID: <[email protected]>
Message-Id: <[email protected]>
---
{accel => include}/tcg/debuginfo.h | 4 ++--
{accel => include}/tcg/perf.h | 4 ++--
accel/tcg/translate-all.c | 2 +-
hw/core/loader.c | 2 +-
linux-user/elfload.c | 2 +-
linux-user/exit.c | 2 +-
linux-user/main.c | 2 +-
system/vl.c | 2 +-
{accel/tcg => tcg}/debuginfo.c | 3 +--
{accel/tcg => tcg}/perf.c | 7 +++----
tcg/tcg.c | 2 +-
accel/tcg/meson.build | 4 ----
tcg/meson.build | 5 +++++
13 files changed, 20 insertions(+), 21 deletions(-)
rename {accel => include}/tcg/debuginfo.h (96%)
rename {accel => include}/tcg/perf.h (95%)
rename {accel/tcg => tcg}/debuginfo.c (98%)
rename {accel/tcg => tcg}/perf.c (99%)include/tcg/debuginfo.h renamed from accel/tcg/debuginfo.h +2 -2
@@ -4,8 +4,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef ACCEL_TCG_DEBUGINFO_H -#define ACCEL_TCG_DEBUGINFO_H +#ifndef TCG_DEBUGINFO_H +#define TCG_DEBUGINFO_H #include "qemu/bitops.h"
include/tcg/perf.h renamed from accel/tcg/perf.h +2 -2
@@ -4,8 +4,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef ACCEL_TCG_PERF_H -#define ACCEL_TCG_PERF_H +#ifndef TCG_PERF_H +#define TCG_PERF_H #if defined(CONFIG_TCG ) && defined(CONFIG_LINUX )/* Start writing perf-<pid>.map. */
accel/tcg/translate-all.c +1 -1
@@ -63,7 +63,7 @@#include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#include "perf.h" +#include "tcg/perf.h" #include "tcg/insn-start-words.h" TBContext tb_ctx;
hw/core/loader.c +1 -1
@@ -62,7 +62,7 @@#include "hw/boards.h" #include "qemu/cutils.h" #include "sysemu/runstate.h" -#include "accel/tcg/debuginfo.h" +#include "tcg/debuginfo.h" #include <zlib.h>
linux-user/elfload.c +1 -1
@@ -22,7 +22,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "target_signal.h" -#include "accel/tcg/debuginfo.h" +#include "tcg/debuginfo.h" #ifdef TARGET_ARM #include "target/arm/cpu-features.h"
linux-user/exit.c +1 -1
@@ -17,7 +17,7 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #include "gdbstub/syscalls.h" #include "qemu.h" #include "user-internals.h"
linux-user/main.c +1 -1
@@ -54,7 +54,7 @@#include "signal-common.h" #include "loader.h" #include "user-mmap.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h"
system/vl.c +1 -1
@@ -96,7 +96,7 @@#endif #include "sysemu/qtest.h" #ifdef CONFIG_TCG -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #endif #include "disas/disas.h"
tcg/debuginfo.c renamed from accel/tcg/debuginfo.c +1 -2
@@ -6,11 +6,10 @@#include "qemu/osdep.h" #include "qemu/lockable.h" +#include "tcg/debuginfo.h" #include <elfutils/libdwfl.h> -#include "debuginfo.h" -static QemuMutex lock;static Dwfl *dwfl;static const Dwfl_Callbacks dwfl_callbacks = {
tcg/perf.c renamed from accel/tcg/perf.c +3 -4
@@ -11,13 +11,12 @@#include "qemu/osdep.h" #include "elf.h" #include "exec/target_page.h" -#include "exec/exec-all.h" +#include "exec/translation-block.h" #include "qemu/timer.h" +#include "tcg/debuginfo.h" +#include "tcg/perf.h" #include "tcg/tcg.h" -#include "debuginfo.h" -#include "perf.h" -static FILE *safe_fopen_w (const char *path) {int saved_errno;
tcg/tcg.c +1 -1
@@ -55,7 +55,7 @@#include "tcg/tcg-ldst.h" #include "tcg/tcg-temp-internal.h" #include "tcg-internal.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #ifdef CONFIG_USER_ONLY #include "exec/user/guest-base.h" #endif
accel/tcg/meson.build +0 -4
@@ -16,10 +16,6 @@ tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) if get_option('plugins') tcg_ss.add(files('plugin-gen.c')) endif -tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) -if host_os == 'linux' - tcg_ss.add(files('perf.c')) -endif specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
tcg/meson.build +5 -0
@@ -22,6 +22,11 @@ if get_option('tcg_interpreter') tcg_ss.add(files('tci.c')) endif +tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) +if host_os == 'linux' + tcg_ss.add(files('perf.c')) +endif + tcg_ss = tcg_ss.apply({}) libtcg_user = static_library('tcg_user',
Signature · 1 line
2.34.1
[PULL 25/31] target/loongarch: Constify loongarch_tcg_ops
In reply to Richard Henderson--- target/loongarch/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/loongarch/cpu.c +1 -1
@@ -734,7 +734,7 @@ void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" -static TCGCPUOps loongarch_tcg_ops = { +static const TCGCPUOps loongarch_tcg_ops = { .initialize = loongarch_translate_init, .synchronize_from_tb = loongarch_cpu_synchronize_from_tb, .restore_state_to_opc = loongarch_restore_state_to_opc,
Signature · 1 line
2.34.1
[PULL 03/31] hw/core: Include vaddr.h from cpu.h
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
cpu-common.h is only needed for vaddr
Message-Id: <[email protected]>
--- include/hw/core/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/core/cpu.h +1 -1
@@ -22,8 +22,8 @@#include "hw/qdev-core.h" #include "disas/dis-asm.h" -#include "exec/cpu-common.h" #include "exec/hwaddr.h" +#include "exec/vaddr.h" #include "exec/memattrs.h" #include "exec/tlb-common.h" #include "qapi/qapi-types-run-state.h"
Signature · 1 line
2.34.1
[PULL 29/31] accel/tcg: Inline need_replay_interrupt
In reply to Richard HendersonThe function is now trivial, and with inlining we can re-use the calling function's tcg_ops variable.
--- accel/tcg/cpu-exec.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
accel/tcg/cpu-exec.c +2 -15
@@ -765,20 +765,6 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)return false; } -#ifndef CONFIG_USER_ONLY -/* -* CPU_INTERRUPT_POLL is a virtual event which gets converted into a -* "real" interrupt event later. It does not need to be recorded for -* replay purposes. -*/ -static inline bool need_replay_interrupt (CPUState *cpu,int interrupt_request) -{ -const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; -return !tcg_ops->need_replay_interrupt - || tcg_ops->need_replay_interrupt (interrupt_request); -} -#endif /* !CONFIG_USER_ONLY */ -static inline bool icount_exit_request (CPUState *cpu) {if (!icount_enabled ()) {
@@ -862,7 +848,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,if (tcg_ops->cpu_exec_interrupt && tcg_ops->cpu_exec_interrupt (cpu, interrupt_request)) { -if (need_replay_interrupt (cpu, interrupt_request)) { +if (!tcg_ops->need_replay_interrupt || + tcg_ops->need_replay_interrupt (interrupt_request)) {replay_interrupt (); }/*
Signature · 1 line
2.34.1
[PULL 14/31] accel/tcg/cpu-exec: Use RCU_READ_LOCK_GUARD
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
Replace the manual rcu_read_(un)lock calls in cpu_exec().
Message-Id: <[email protected]>
--- accel/tcg/cpu-exec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
accel/tcg/cpu-exec.c +1 -3
@@ -1050,7 +1050,7 @@ int cpu_exec(CPUState *cpu)return EXCP_HALTED ; } -rcu_read_lock (); +RCU_READ_LOCK_GUARD ();cpu_exec_enter (cpu);/*
@@ -1064,8 +1064,6 @@ int cpu_exec(CPUState *cpu) ret =cpu_exec_setjmp (cpu, &sc);cpu_exec_exit (cpu); -rcu_read_unlock (); -return ret; }
Signature · 1 line
2.34.1
[PULL 18/31] accel/tcg: Remove #ifdef TARGET_I386 from perf.c
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Preparation for moving perf.c to tcg/.
This affects only profiling guest code, which has code in a non-0 based segment, e.g., 16-bit code, which is not particularly important.
Message-ID: <[email protected]>
Message-Id: <[email protected]>
--- accel/tcg/perf.c | 4 ---- 1 file changed, 4 deletions(-)
accel/tcg/perf.c +0 -4
@@ -337,10 +337,6 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb, q[insn].address = gen_insn_data[insn * start_words +0 ];if (tb_cflags (tb) &CF_PCREL ) { q[insn].address |= (guest_pc &qemu_target_page_mask ()); - }else { -#if defined(TARGET_I386 ) - q[insn].address -= tb->cs_base; -#endif } q[insn].flags =DEBUGINFO_SYMBOL | (jitdump ?DEBUGINFO_LINE :0 ); }
Signature · 1 line
2.34.1
[PULL 31/31] target/i386: Extract x86_cpu_exec_halt() from accel/tcg/
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
Move this x86-specific code out of the generic accel/tcg/.
Message-Id: <[email protected]>
--- target/i386/tcg/helper-tcg.h | 1 + accel/tcg/cpu-exec.c | 12 ------------ target/i386/tcg/sysemu/seg_helper.c | 13 +++++++++++++ target/i386/tcg/tcg-cpu.c | 1 + 4 files changed, 15 insertions(+), 12 deletions(-)
target/i386/tcg/helper-tcg.h +1 -0
@@ -39,6 +39,7 @@ QEMU_BUILD_BUG_ON(TCG_PHYS_ADDR_BITS > TARGET_PHYS_ADDR_SPACE_BITS);*/ void x86_cpu_do_interrupt (CPUState *cpu);#ifndef CONFIG_USER_ONLY +void x86_cpu_exec_halt (CPUState *cpu);bool x86_need_replay_interrupt (int interrupt_request);bool x86_cpu_exec_interrupt (CPUState *cpu,int int_req);#endif
accel/tcg/cpu-exec.c +0 -12
@@ -30,9 +30,6 @@#include "qemu/rcu.h" #include "exec/log.h" #include "qemu/main-loop.h" -#if defined(TARGET_I386 ) && !defined(CONFIG_USER_ONLY ) -#include "hw/i386/apic.h" -#endif #include "sysemu/cpus.h" #include "exec/cpu-all.h" #include "sysemu/cpu-timers.h"
@@ -666,15 +663,6 @@ static inline bool cpu_handle_halt(CPUState *cpu)if (cpu->halted) {const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; -#if defined(TARGET_I386 ) -if (cpu->interrupt_request &CPU_INTERRUPT_POLL ) { -X86CPU *x86_cpu =X86_CPU (cpu); -bql_lock (); -apic_poll_irq (x86_cpu->apic_state); -cpu_reset_interrupt (cpu,CPU_INTERRUPT_POLL ); -bql_unlock (); - } -#endif /* TARGET_I386 */ if (tcg_ops->cpu_exec_halt) { tcg_ops->cpu_exec_halt (cpu); }
target/i386/tcg/sysemu/seg_helper.c +13 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/log.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/cpu_ldst.h"
@@ -127,6 +128,18 @@ void x86_cpu_do_interrupt(CPUState *cs) } } +void x86_cpu_exec_halt (CPUState *cpu) +{ +if (cpu->interrupt_request &CPU_INTERRUPT_POLL ) { +X86CPU *x86_cpu =X86_CPU (cpu); + +bql_lock (); +apic_poll_irq (x86_cpu->apic_state); +cpu_reset_interrupt (cpu,CPU_INTERRUPT_POLL ); +bql_unlock (); + } +} +bool x86_need_replay_interrupt (int interrupt_request) {/*
target/i386/tcg/tcg-cpu.c +1 -0
@@ -119,6 +119,7 @@ static const TCGCPUOps x86_tcg_ops = {#else .tlb_fill = x86_cpu_tlb_fill, .do_interrupt = x86_cpu_do_interrupt, + .cpu_exec_halt = x86_cpu_exec_halt, .cpu_exec_interrupt = x86_cpu_exec_interrupt, .do_unaligned_access = x86_cpu_do_unaligned_access, .debug_excp_handler = breakpoint_handler,
Signature · 1 line
2.34.1
[PULL 16/31] accel/tcg: Make use of qemu_target_page_mask() in perf.c
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Stop using TARGET_PAGE_MASK in order to make perf.c more target-agnostic.
Message-ID: <[email protected]>
Message-Id: <[email protected]>
--- accel/tcg/perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
accel/tcg/perf.c +2 -1
@@ -10,6 +10,7 @@#include "qemu/osdep.h" #include "elf.h" +#include "exec/target_page.h" #include "exec/exec-all.h" #include "qemu/timer.h" #include "tcg/tcg.h"
@@ -335,7 +336,7 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,/* FIXME: This replicates the restore_state_to_opc() logic. */ q[insn].address = gen_insn_data[insn * start_words +0 ];if (tb_cflags (tb) &CF_PCREL ) { - q[insn].address |= (guest_pc &TARGET_PAGE_MASK ); + q[insn].address |= (guest_pc &qemu_target_page_mask ()); }else {#if defined(TARGET_I386 ) q[insn].address -= tb->cs_base;
Signature · 1 line
2.34.1
[PULL 05/31] include/exec: Use vaddr in DisasContextBase for virtual addresses
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
Updates target/ QEMU_LOG macros to use VADDR_PRIx for printing updated DisasContextBase fields.
Message-Id: <[email protected]>
--- include/exec/translator.h | 6 +++--- target/mips/tcg/translate.h | 3 ++- target/hexagon/translate.c | 3 ++- target/m68k/translate.c | 2 +- target/mips/tcg/translate.c | 12 ++++++------ 5 files changed, 14 insertions(+), 12 deletions(-)
include/exec/translator.h +3 -3
@@ -79,8 +79,8 @@ typedef enum DisasJumpType {*/ typedef struct DisasContextBase { TranslationBlock *tb; - target_ulong pc_first; - target_ulong pc_next; + vaddr pc_first; + vaddr pc_next; DisasJumpType is_jmp; int num_insns; int max_insns;
@@ -235,7 +235,7 @@ void translator_fake_ldb(uint8_t insn8, abi_ptr pc);* Translators can use this to enforce the rule that only single-insn * translation blocks are allowed to cross page boundaries. */ -static inline bool is_same_page (const DisasContextBase *db,target_ulong addr) +static inline bool is_same_page (const DisasContextBase *db,vaddr addr) {return ((addr ^ db->pc_first) &TARGET_PAGE_MASK ) ==0 ; }
target/mips/tcg/translate.h +2 -1
@@ -202,7 +202,8 @@ extern TCGv bcond; do { \ if (MIPS_DEBUG_DISAS) { \ qemu_log_mask(CPU_LOG_TB_IN_ASM, \ - TARGET_FMT_lx ": %08x Invalid %s %03x %03x %03x\n", \ + "%016" VADDR_PRIx \ + ": %08x Invalid %s %03x %03x %03x\n", \ ctx->base.pc_next, ctx->opcode, op, \ ctx->opcode >> 26, ctx->opcode & 0x3F, \ ((ctx->opcode >> 16) & 0x1F)); \
target/hexagon/translate.c +2 -1
@@ -234,7 +234,8 @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx,g_assert (ctx->base.num_insns ==1 ); } -HEX_DEBUG_LOG ("decode_packet: pc = 0x%x\n" , ctx->base.pc_next); +HEX_DEBUG_LOG ("decode_packet: pc = 0x%" VADDR_PRIx"\n" , + ctx->base.pc_next);HEX_DEBUG_LOG (" words = { " );for (int i =0 ; i < nwords; i++) {HEX_DEBUG_LOG ("0x%x, " , words[i]);
target/m68k/translate.c +1 -1
@@ -1457,7 +1457,7 @@ DISAS_INSN(undef)* for the 680x0 series, as well as those that are implemented * but actually illegal for CPU32 or pre-68020. */ -qemu_log_mask (LOG_UNIMP ,"Illegal instruction: %04x @ %08x\n" , +qemu_log_mask (LOG_UNIMP ,"Illegal instruction: %04x @ %" VADDR_PRIx"\n" , insn, s->base.pc_next);gen_exception (s, s->base.pc_next,EXCP_ILLEGAL ); }
target/mips/tcg/translate.c +6 -6
@@ -4585,8 +4585,8 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc,if (ctx->hflags &MIPS_HFLAG_BMASK ) {#ifdef MIPS_DEBUG_DISAS -LOG_DISAS ("Branch in delay / forbidden slot at PC 0x" - TARGET_FMT_lx"\n" , ctx->base.pc_next); +LOG_DISAS ("Branch in delay / forbidden slot at PC 0x%016" + VADDR_PRIx"\n" , ctx->base.pc_next);#endif gen_reserved_instruction (ctx); goto out;
@@ -9061,8 +9061,8 @@ static void gen_compute_branch1_r6(DisasContext *ctx, uint32_t op,if (ctx->hflags &MIPS_HFLAG_BMASK ) {#ifdef MIPS_DEBUG_DISAS -LOG_DISAS ("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx -"\n" , ctx->base.pc_next); +LOG_DISAS ("Branch in delay / forbidden slot at PC 0x%016" + VADDR_PRIx"\n" , ctx->base.pc_next);#endif gen_reserved_instruction (ctx);return ;
@@ -11274,8 +11274,8 @@ static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,if (ctx->hflags &MIPS_HFLAG_BMASK ) {#ifdef MIPS_DEBUG_DISAS -LOG_DISAS ("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx -"\n" , ctx->base.pc_next); +LOG_DISAS ("Branch in delay / forbidden slot at PC 0x%016" + VADDR_PRIx"\n" , ctx->base.pc_next);#endif gen_reserved_instruction (ctx);return ;
Signature · 1 line
2.34.1
[PULL 27/31] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
In order to make accel/tcg/ target agnostic,
introduce the need_replay_interrupt() handler.
Message-Id: <[email protected]>
--- include/hw/core/tcg-cpu-ops.h | 5 +++++ accel/tcg/cpu-exec.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
include/hw/core/tcg-cpu-ops.h +5 -0
@@ -166,6 +166,11 @@ struct TCGCPUOps {*/ bool (*io_recompile_replay_branch)(CPUState *cpu,const TranslationBlock *tb); +/** +* @need_replay_interrupt: Return %true if @interrupt_request +* needs to be recorded for replay purposes. +*/ +bool (*need_replay_interrupt)(int interrupt_request);#endif /* !CONFIG_USER_ONLY */ #endif /* NEED_CPU_H */
accel/tcg/cpu-exec.c +5 -3
@@ -771,12 +771,14 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)* "real" interrupt event later. It does not need to be recorded for * replay purposes. */ -static inline bool need_replay_interrupt (int interrupt_request) +static inline bool need_replay_interrupt (CPUState *cpu,int interrupt_request) {#if defined(TARGET_I386 )return !(interrupt_request &CPU_INTERRUPT_POLL );#else -return true; +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; +return !tcg_ops->need_replay_interrupt + || tcg_ops->need_replay_interrupt (interrupt_request);#endif }#endif /* !CONFIG_USER_ONLY */
@@ -864,7 +866,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,if (tcg_ops->cpu_exec_interrupt && tcg_ops->cpu_exec_interrupt (cpu, interrupt_request)) { -if (need_replay_interrupt (interrupt_request)) { +if (need_replay_interrupt (cpu, interrupt_request)) {replay_interrupt (); }/*
Signature · 1 line
2.34.1
[PULL 23/31] accel/tcg: Un-inline icount_exit_request() for clarity
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
Convert packed logic to dumb icount_exit_request() helper. No functional change intended.
Message-Id: <[email protected]>
--- accel/tcg/cpu-exec.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
accel/tcg/cpu-exec.c +12 -4
@@ -777,6 +777,17 @@ static inline bool need_replay_interrupt(int interrupt_request) }#endif /* !CONFIG_USER_ONLY */ +static inline bool icount_exit_request (CPUState *cpu) +{ +if (!icount_enabled ()) { +return false; + } +if (cpu->cflags_next_tb !=-1 && !(cpu->cflags_next_tb &CF_USE_ICOUNT )) { +return false; + } +return cpu->neg.icount_decr.u16.low + cpu->icount_extra ==0 ; +} +static inline bool cpu_handle_interrupt (CPUState *cpu,TranslationBlock **last_tb) {
@@ -882,10 +893,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, }/* Finally, check if we need to exit to the main loop. */ -if (unlikely (qatomic_read (&cpu->exit_request)) - || (icount_enabled () - && (cpu->cflags_next_tb ==-1 || cpu->cflags_next_tb &CF_USE_ICOUNT ) - && cpu->neg.icount_decr.u16.low + cpu->icount_extra ==0 )) { +if (unlikely (qatomic_read (&cpu->exit_request)) ||icount_exit_request (cpu)) {qatomic_set (&cpu->exit_request,0 );if (cpu->exception_index ==-1 ) { cpu->exception_index =EXCP_INTERRUPT ;
Signature · 1 line
2.34.1
[PULL 28/31] target/i386: Extract x86_need_replay_interrupt() from accel/tcg/
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
Move this x86-specific code out of the generic accel/tcg/.
Message-Id: <[email protected]>
--- target/i386/tcg/helper-tcg.h | 1 + accel/tcg/cpu-exec.c | 4 ---- target/i386/tcg/sysemu/seg_helper.c | 10 ++++++++++ target/i386/tcg/tcg-cpu.c | 1 + 4 files changed, 12 insertions(+), 4 deletions(-)
target/i386/tcg/helper-tcg.h +1 -0
@@ -39,6 +39,7 @@ QEMU_BUILD_BUG_ON(TCG_PHYS_ADDR_BITS > TARGET_PHYS_ADDR_SPACE_BITS);*/ void x86_cpu_do_interrupt (CPUState *cpu);#ifndef CONFIG_USER_ONLY +bool x86_need_replay_interrupt (int interrupt_request);bool x86_cpu_exec_interrupt (CPUState *cpu,int int_req);#endif
accel/tcg/cpu-exec.c +0 -4
@@ -773,13 +773,9 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)*/ static inline bool need_replay_interrupt (CPUState *cpu,int interrupt_request) { -#if defined(TARGET_I386 ) -return !(interrupt_request &CPU_INTERRUPT_POLL ); -#else const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;return !tcg_ops->need_replay_interrupt || tcg_ops->need_replay_interrupt (interrupt_request); -#endif }#endif /* !CONFIG_USER_ONLY */
target/i386/tcg/sysemu/seg_helper.c +10 -0
@@ -127,6 +127,16 @@ void x86_cpu_do_interrupt(CPUState *cs) } } +bool x86_need_replay_interrupt (int interrupt_request) +{ +/* +* CPU_INTERRUPT_POLL is a virtual event which gets converted into a +* "real" interrupt event later. It does not need to be recorded for +* replay purposes. +*/ +return !(interrupt_request &CPU_INTERRUPT_POLL ); +} +bool x86_cpu_exec_interrupt (CPUState *cs,int interrupt_request) {X86CPU *cpu =X86_CPU (cs);
target/i386/tcg/tcg-cpu.c +1 -0
@@ -123,6 +123,7 @@ static const TCGCPUOps x86_tcg_ops = { .do_unaligned_access = x86_cpu_do_unaligned_access, .debug_excp_handler = breakpoint_handler, .debug_check_breakpoint = x86_debug_check_breakpoint, + .need_replay_interrupt = x86_need_replay_interrupt,#endif /* !CONFIG_USER_ONLY */ };
Signature · 1 line
2.34.1
[PULL 30/31] accel/tcg: Introduce TCGCPUOps::cpu_exec_halt() handler
In reply to Richard HendersonFrom: Philippe Mathieu-Daudé <[email protected]>
In order to make accel/tcg/ target agnostic,
introduce the cpu_exec_halt() handler.
Message-Id: <[email protected]>
--- include/hw/core/tcg-cpu-ops.h | 2 ++ accel/tcg/cpu-exec.c | 5 +++++ 2 files changed, 7 insertions(+)
include/hw/core/tcg-cpu-ops.h +2 -0
@@ -112,6 +112,8 @@ struct TCGCPUOps {void (*do_interrupt)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); +/** @cpu_exec_halt: Callback for handling halt in cpu_exec */ +void (*cpu_exec_halt)(CPUState *cpu);/** * @tlb_fill: Handle a softmmu tlb miss *
accel/tcg/cpu-exec.c +5 -0
@@ -664,6 +664,8 @@ static inline bool cpu_handle_halt(CPUState *cpu) { #ifndef CONFIG_USER_ONLY if (cpu->halted) { + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + #if defined(TARGET_I386) if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { X86CPU *x86_cpu = X86_CPU(cpu);
@@ -673,6 +675,9 @@ static inline bool cpu_handle_halt(CPUState *cpu) bql_unlock(); }#endif /* TARGET_I386 */ +if (tcg_ops->cpu_exec_halt) { + tcg_ops->cpu_exec_halt (cpu); + }if (!cpu_has_work (cpu)) {return true; }
Signature · 1 line
2.34.1
[PULL 09/31] include/hw/core: Move do_interrupt in TCGCPUOps
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
The ifdef out of which it is moved is not quite right: do_interrupt is only needed for system mode. Move it to the top of a different ifdef block, which preserves its position within the structure for that case.
Message-Id: <[email protected]>
--- include/hw/core/tcg-cpu-ops.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
include/hw/core/tcg-cpu-ops.h +2 -5
@@ -58,11 +58,6 @@ struct TCGCPUOps {* cpu execution loop (hack for x86 user mode). */ void (*fake_user_interrupt)(CPUState *cpu); -#else -/** -* @do_interrupt: Callback for interrupt handling. -*/ -void (*do_interrupt)(CPUState *cpu);#endif /* !CONFIG_USER_ONLY || !TARGET_I386 */ #ifdef CONFIG_USER_ONLY /**
@@ -114,6 +109,8 @@ struct TCGCPUOps {void (*record_sigbus)(CPUState *cpu,vaddr addr,MMUAccessType access_type,uintptr_t ra);#else +/** @do_interrupt: Callback for interrupt handling. */ +void (*do_interrupt)(CPUState *cpu);/** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request);/**
Signature · 1 line
2.34.1
[PULL 07/31] include/exec: Move PAGE_* macros to common header
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
These don't vary across targets and are used in soon-to-be common code (cputlb.c).
Message-Id: <[email protected]>
--- include/exec/cpu-all.h | 24 ------------------------ include/exec/cpu-common.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 24 deletions(-)
include/exec/cpu-all.h +0 -24
@@ -171,34 +171,10 @@ extern const TargetPageBits target_page;#define TARGET_PAGE_ALIGN (addr) ROUND_UP((addr), TARGET_PAGE_SIZE) -/* same as PROT_xxx */ -#define PAGE_READ 0x0001 -#define PAGE_WRITE 0x0002 -#define PAGE_EXEC 0x0004 -#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) -#define PAGE_VALID 0x0008 -/* -* Original state of the write flag (used when tracking self-modifying code) -*/ -#define PAGE_WRITE_ORG 0x0010 -/* -* Invalidate the TLB entry immediately, helpful for s390x -* Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() -*/ -#define PAGE_WRITE_INV 0x0020 -/* For use with page_set_flags: page is being replaced; target_data cleared. */ -#define PAGE_RESET 0x0040 -/* For linux-user, indicates that the page is MAP_ANON. */ -#define PAGE_ANON 0x0080 -#if defined(CONFIG_BSD ) && defined(CONFIG_USER_ONLY )/* FIXME: Code that sets/uses this is broken and needs to go away. */ #define PAGE_RESERVED 0x0100#endif -/* Target-specific bits that will be used via page_get_flags(). */ -#define PAGE_TARGET_1 0x0200 -#define PAGE_TARGET_2 0x0400 -/* * For linux-user, indicates that the page is mapped with the same semantics * in both guest and host.
include/exec/cpu-common.h +30 -0
@@ -206,4 +206,34 @@ G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc); G_NORETURN void cpu_loop_exit(CPUState *cpu); G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); +/* same as PROT_xxx */ +#define PAGE_READ 0x0001 +#define PAGE_WRITE 0x0002 +#define PAGE_EXEC 0x0004 +#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) +#define PAGE_VALID 0x0008 +/* +* Original state of the write flag (used when tracking self-modifying code) +*/ +#define PAGE_WRITE_ORG 0x0010 +/* +* Invalidate the TLB entry immediately, helpful for s390x +* Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() +*/ +#define PAGE_WRITE_INV 0x0020 +/* For use with page_set_flags: page is being replaced; target_data cleared. */ +#define PAGE_RESET 0x0040 +/* For linux-user, indicates that the page is MAP_ANON. */ +#define PAGE_ANON 0x0080 + +/* Target-specific bits that will be used via page_get_flags(). */ +#define PAGE_TARGET_1 0x0200 +#define PAGE_TARGET_2 0x0400 + +/* +* For linux-user, indicates that the page is mapped with the same semantics +* in both guest and host. +*/ +#define PAGE_PASSTHROUGH 0x0800 +#endif /* CPU_COMMON_H */
Signature · 1 line
2.34.1
[PULL 26/31] accel/tcg: Use CPUState.cc instead of CPU_GET_CLASS in cpu-exec.c
In reply to Richard HendersonCPU_GET_CLASS does runtime type checking; use the cached copy of the class instead.
--- accel/tcg/cpu-exec.c | 109 ++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 53 deletions(-)
accel/tcg/cpu-exec.c +56 -53
@@ -343,9 +343,9 @@ static bool check_for_breakpoints_slow(CPUState *cpu, vaddr pc,#ifdef CONFIG_USER_ONLY g_assert_not_reached ();#else -CPUClass *cc =CPU_GET_CLASS (cpu); -assert (cc->tcg_ops->debug_check_breakpoint); - match_bp = cc->tcg_ops->debug_check_breakpoint (cpu); +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; +assert (tcg_ops->debug_check_breakpoint); + match_bp = tcg_ops->debug_check_breakpoint (cpu);#endif }
@@ -462,10 +462,11 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)* counter hit zero); we must restore the guest PC to the address * of the start of the TB. */ -CPUClass *cc =CPU_GET_CLASS (cpu); +CPUClass *cc = cpu->cc; +const TCGCPUOps *tcg_ops = cc->tcg_ops; -if (cc->tcg_ops->synchronize_from_tb) { - cc->tcg_ops->synchronize_from_tb (cpu, last_tb); +if (tcg_ops->synchronize_from_tb) { + tcg_ops->synchronize_from_tb (cpu, last_tb); }else {tcg_debug_assert (!(tb_cflags (last_tb) &CF_PCREL ));assert (cc->set_pc);
@@ -497,19 +498,19 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)static void cpu_exec_enter (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; -if (cc->tcg_ops->cpu_exec_enter) { - cc->tcg_ops->cpu_exec_enter (cpu); +if (tcg_ops->cpu_exec_enter) { + tcg_ops->cpu_exec_enter (cpu); } }static void cpu_exec_exit (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; -if (cc->tcg_ops->cpu_exec_exit) { - cc->tcg_ops->cpu_exec_exit (cpu); +if (tcg_ops->cpu_exec_exit) { + tcg_ops->cpu_exec_exit (cpu); } }
@@ -685,7 +686,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)static inline void cpu_handle_debug_exception (CPUState *cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;CPUWatchpoint *wp;if (!cpu->watchpoint_hit) {
@@ -694,8 +695,8 @@ static inline void cpu_handle_debug_exception(CPUState *cpu) } } -if (cc->tcg_ops->debug_excp_handler) { - cc->tcg_ops->debug_excp_handler (cpu); +if (tcg_ops->debug_excp_handler) { + tcg_ops->debug_excp_handler (cpu); } }
@@ -712,6 +713,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)#endif return false; } +if (cpu->exception_index >=EXCP_INTERRUPT ) {/* exit request from the cpu execution loop */ *ret = cpu->exception_index;
@@ -720,43 +722,45 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) } cpu->exception_index =-1 ;return true; - }else { -#if defined(CONFIG_USER_ONLY ) -/* if user mode only, we simulate a fake exception -which will be handled outside the cpu execution -loop */ -#if defined(TARGET_I386 ) -CPUClass *cc =CPU_GET_CLASS (cpu); - cc->tcg_ops->fake_user_interrupt (cpu); -#endif /* TARGET_I386 */ - *ret = cpu->exception_index; - cpu->exception_index =-1 ; -return true; -#else -if (replay_exception ()) { -CPUClass *cc =CPU_GET_CLASS (cpu); -bql_lock (); - cc->tcg_ops->do_interrupt (cpu); -bql_unlock (); - cpu->exception_index =-1 ; + } -if (unlikely (cpu->singlestep_enabled)) { -/* -* After processing the exception, ensure an EXCP_DEBUG is -* raised when single-stepping so that GDB doesn't miss the -* next instruction. -*/ - *ret =EXCP_DEBUG ; -cpu_handle_debug_exception (cpu); -return true; - } - }else if (!replay_has_interrupt ()) { -/* give a chance to iothread in replay mode */ - *ret =EXCP_INTERRUPT ; +#if defined(CONFIG_USER_ONLY ) +/* +* If user mode only, we simulate a fake exception which will be +* handled outside the cpu execution loop. +*/ +#if defined(TARGET_I386 ) +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + tcg_ops->fake_user_interrupt (cpu); +#endif /* TARGET_I386 */ + *ret = cpu->exception_index; + cpu->exception_index =-1 ; +return true; +#else +if (replay_exception ()) { +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + +bql_lock (); + tcg_ops->do_interrupt (cpu); +bql_unlock (); + cpu->exception_index =-1 ; + +if (unlikely (cpu->singlestep_enabled)) { +/* +* After processing the exception, ensure an EXCP_DEBUG is +* raised when single-stepping so that GDB doesn't miss the +* next instruction. +*/ + *ret =EXCP_DEBUG ; +cpu_handle_debug_exception (cpu);return true; } -#endif + }else if (!replay_has_interrupt ()) { +/* give a chance to iothread in replay mode */ + *ret =EXCP_INTERRUPT ; +return true; } +#endif return false; }
@@ -856,10 +860,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { -CPUClass *cc =CPU_GET_CLASS (cpu); +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; -if (cc->tcg_ops->cpu_exec_interrupt && - cc->tcg_ops->cpu_exec_interrupt (cpu, interrupt_request)) { +if (tcg_ops->cpu_exec_interrupt && + tcg_ops->cpu_exec_interrupt (cpu, interrupt_request)) {if (need_replay_interrupt (interrupt_request)) {replay_interrupt (); }
@@ -1078,10 +1082,9 @@ int cpu_exec(CPUState *cpu)bool tcg_exec_realizefn (CPUState *cpu,Error **errp) {static bool tcg_target_initialized; -CPUClass *cc =CPU_GET_CLASS (cpu);if (!tcg_target_initialized) { - cc->tcg_ops->initialize (); + cpu->cc->tcg_ops->initialize (); tcg_target_initialized = true; }
Signature · 1 line
2.34.1
[PULL 04/31] target: Use vaddr in gen_intermediate_code
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
Makes gen_intermediate_code() signature target agnostic so the function can be called from accel/tcg/translate-all.c without target specifics.
Message-Id: <[email protected]>
--- include/exec/translator.h | 2 +- target/alpha/translate.c | 2 +- target/arm/tcg/translate.c | 2 +- target/avr/translate.c | 2 +- target/cris/translate.c | 2 +- target/hexagon/translate.c | 2 +- target/hppa/translate.c | 2 +- target/i386/tcg/translate.c | 2 +- target/loongarch/tcg/translate.c | 2 +- target/m68k/translate.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/tcg/translate.c | 2 +- target/nios2/translate.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/translate.c | 2 +- target/riscv/translate.c | 2 +- target/rx/translate.c | 2 +- target/s390x/tcg/translate.c | 2 +- target/sh4/translate.c | 2 +- target/sparc/translate.c | 2 +- target/tricore/translate.c | 2 +- target/xtensa/translate.c | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-)
include/exec/translator.h +1 -1
@@ -33,7 +33,7 @@* the target-specific DisasContext, and then invoke translator_loop. */ void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc); +vaddr pc,void *host_pc);/** * DisasJumpType:
target/alpha/translate.c +1 -1
@@ -2971,7 +2971,7 @@ static const TranslatorOps alpha_tr_ops = { };void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;translator_loop (cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base);
target/arm/tcg/translate.c +1 -1
@@ -9691,7 +9691,7 @@ static const TranslatorOps thumb_translator_ops = {/* generate intermediate code for basic block 'tb'. */ void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc = { };const TranslatorOps *ops = &arm_translator_ops;
target/avr/translate.c +1 -1
@@ -2805,7 +2805,7 @@ static const TranslatorOps avr_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc = { };translator_loop (cs, tb, max_insns, pc, host_pc, &avr_tr_ops, &dc.base);
target/cris/translate.c +1 -1
@@ -3172,7 +3172,7 @@ static const TranslatorOps cris_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;translator_loop (cs, tb, max_insns, pc, host_pc, &cris_tr_ops, &dc.base);
target/hexagon/translate.c +1 -1
@@ -1154,7 +1154,7 @@ static const TranslatorOps hexagon_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/hppa/translate.c +1 -1
@@ -4631,7 +4631,7 @@ static const TranslatorOps hppa_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;translator_loop (cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base);
target/i386/tcg/translate.c +1 -1
@@ -7088,7 +7088,7 @@ static const TranslatorOps i386_tr_ops = {/* generate intermediate code for basic block 'tb'. */ void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;
target/loongarch/tcg/translate.c +1 -1
@@ -343,7 +343,7 @@ static const TranslatorOps loongarch_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/m68k/translate.c +1 -1
@@ -6088,7 +6088,7 @@ static const TranslatorOps m68k_tr_ops = { };void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;translator_loop (cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base);
target/microblaze/translate.c +1 -1
@@ -1792,7 +1792,7 @@ static const TranslatorOps mb_tr_ops = { };void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;translator_loop (cpu, tb, max_insns, pc, host_pc, &mb_tr_ops, &dc.base);
target/mips/tcg/translate.c +1 -1
@@ -15554,7 +15554,7 @@ static const TranslatorOps mips_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/nios2/translate.c +1 -1
@@ -1036,7 +1036,7 @@ static const TranslatorOps nios2_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;translator_loop (cs, tb, max_insns, pc, host_pc, &nios2_tr_ops, &dc.base);
target/openrisc/translate.c +1 -1
@@ -1658,7 +1658,7 @@ static const TranslatorOps openrisc_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/ppc/translate.c +1 -1
@@ -7518,7 +7518,7 @@ static const TranslatorOps ppc_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/riscv/translate.c +1 -1
@@ -1287,7 +1287,7 @@ static const TranslatorOps riscv_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/rx/translate.c +1 -1
@@ -2266,7 +2266,7 @@ static const TranslatorOps rx_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;
target/s390x/tcg/translate.c +1 -1
@@ -6547,7 +6547,7 @@ static const TranslatorOps s390x_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc;
target/sh4/translate.c +1 -1
@@ -2317,7 +2317,7 @@ static const TranslatorOps sh4_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx;
target/sparc/translate.c +1 -1
@@ -5327,7 +5327,7 @@ static const TranslatorOps sparc_tr_ops = { };void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc = {};
target/tricore/translate.c +1 -1
@@ -8472,7 +8472,7 @@ static const TranslatorOps tricore_tr_ops = {void gen_intermediate_code (CPUState *cs,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext ctx; translator_loop(cs, tb, max_insns, pc, host_pc,
target/xtensa/translate.c +1 -1
@@ -1239,7 +1239,7 @@ static const TranslatorOps xtensa_translator_ops = { };void gen_intermediate_code (CPUState *cpu,TranslationBlock *tb,int *max_insns, -target_ulong pc,void *host_pc) +vaddr pc,void *host_pc) {DisasContext dc = {}; translator_loop(cpu, tb, max_insns, pc, host_pc,
Signature · 1 line
2.34.1
[PULL 06/31] include/exec: typedef abi_ptr to vaddr
In reply to Richard HendersonFrom: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
--- include/exec/cpu_ldst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/exec/cpu_ldst.h +2 -2
@@ -121,8 +121,8 @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)h2g_nocheck (x); \ })#else -typedef target_ulong abi_ptr ; -#define TARGET_ABI_FMT_ptr TARGET_FMT_lx +typedef vaddr abi_ptr ; +#define TARGET_ABI_FMT_ptr VADDR_PRIx#endif uint32_t cpu_ldub_data (CPUArchState *env,abi_ptr ptr);
Signature · 1 line
2.34.1
[PULL 24/31] include/qemu: Add TCGCPUOps typedef to typedefs.h
In reply to Richard HendersonQEMU coding style recommends using structure typedefs.
--- include/hw/core/cpu.h | 5 +---- include/qemu/typedefs.h | 1 + bsd-user/signal.c | 4 ++-- linux-user/signal.c | 4 ++-- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/arm/tcg/cpu32.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 4 ++-- target/hexagon/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 26 files changed, 29 insertions(+), 31 deletions(-)
include/hw/core/cpu.h +1 -4
@@ -90,9 +90,6 @@ typedef enum MMUAccessType {typedef struct CPUWatchpoint CPUWatchpoint ; -/* see tcg-cpu-ops.h */ -struct TCGCPUOps ; -/* see accel-cpu.h */ struct AccelCPUClass ;
@@ -177,7 +174,7 @@ struct CPUClass {const struct SysemuCPUOps *sysemu_ops;/* when TCG is not available, this pointer is NULL */ -const struct TCGCPUOps *tcg_ops; +const TCGCPUOps *tcg_ops;/* * if not NULL, this is called in order for the CPUClass to initialize
include/qemu/typedefs.h +1 -0
@@ -131,6 +131,7 @@ typedef struct Range Range;typedef struct ReservedRegion ReservedRegion ;typedef struct SHPCDevice SHPCDevice ;typedef struct SSIBus SSIBus ; +typedef struct TCGCPUOps TCGCPUOps ;typedef struct TCGHelperInfo TCGHelperInfo ;typedef struct TranslationBlock TranslationBlock ;typedef struct VirtIODevice VirtIODevice ;
bsd-user/signal.c +2 -2
@@ -1022,7 +1022,7 @@ void process_pending_signals(CPUArchState *env)void cpu_loop_exit_sigsegv (CPUState *cpu,target_ulong addr,MMUAccessType access_type,bool maperr,uintptr_t ra) { -const struct TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops;if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv (cpu, addr, access_type, maperr, ra);
@@ -1038,7 +1038,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,void cpu_loop_exit_sigbus (CPUState *cpu,target_ulong addr,MMUAccessType access_type,uintptr_t ra) { -const struct TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops;if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus (cpu, addr, access_type, ra);
linux-user/signal.c +2 -2
@@ -671,7 +671,7 @@ void force_sigsegv(int oldsig)void cpu_loop_exit_sigsegv (CPUState *cpu,target_ulong addr,MMUAccessType access_type,bool maperr,uintptr_t ra) { -const struct TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops;if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv (cpu, addr, access_type, maperr, ra);
@@ -687,7 +687,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,void cpu_loop_exit_sigbus (CPUState *cpu,target_ulong addr,MMUAccessType access_type,uintptr_t ra) { -const struct TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops; +const TCGCPUOps *tcg_ops =CPU_GET_CLASS (cpu)->tcg_ops;if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus (cpu, addr, access_type, ra);
target/alpha/cpu.c +1 -1
@@ -203,7 +203,7 @@ static const struct SysemuCPUOps alpha_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps alpha_tcg_ops = { +static const TCGCPUOps alpha_tcg_ops = { .initialize = alpha_translate_init, .restore_state_to_opc = alpha_restore_state_to_opc,
target/arm/cpu.c +1 -1
@@ -2458,7 +2458,7 @@ static const struct SysemuCPUOps arm_sysemu_ops = {#endif #ifdef CONFIG_TCG -static const struct TCGCPUOps arm_tcg_ops = { +static const TCGCPUOps arm_tcg_ops = { .initialize = arm_translate_init, .synchronize_from_tb = arm_cpu_synchronize_from_tb, .debug_excp_handler = arm_debug_excp_handler,
target/arm/tcg/cpu32.c +1 -1
@@ -1018,7 +1018,7 @@ static void pxa270c5_initfn(Object *obj) cpu->reset_sctlr =0x00000078 ; } -static const struct TCGCPUOps arm_v7m_tcg_ops = { +static const TCGCPUOps arm_v7m_tcg_ops = { .initialize = arm_translate_init, .synchronize_from_tb = arm_cpu_synchronize_from_tb, .debug_excp_handler = arm_debug_excp_handler,
target/avr/cpu.c +1 -1
@@ -210,7 +210,7 @@ static const struct SysemuCPUOps avr_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps avr_tcg_ops = { +static const TCGCPUOps avr_tcg_ops = { .initialize = avr_cpu_tcg_init, .synchronize_from_tb = avr_cpu_synchronize_from_tb, .restore_state_to_opc = avr_restore_state_to_opc,
target/cris/cpu.c +2 -2
@@ -178,7 +178,7 @@ static const struct SysemuCPUOps cris_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps crisv10_tcg_ops = { +static const TCGCPUOps crisv10_tcg_ops = { .initialize = cris_initialize_crisv10_tcg, .restore_state_to_opc = cris_restore_state_to_opc,
@@ -189,7 +189,7 @@ static const struct TCGCPUOps crisv10_tcg_ops = {#endif /* !CONFIG_USER_ONLY */ }; -static const struct TCGCPUOps crisv32_tcg_ops = { +static const TCGCPUOps crisv32_tcg_ops = { .initialize = cris_initialize_tcg, .restore_state_to_opc = cris_restore_state_to_opc,
target/hexagon/cpu.c +1 -1
@@ -337,7 +337,7 @@ static void hexagon_cpu_init(Object *obj)#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps hexagon_tcg_ops = { +static const TCGCPUOps hexagon_tcg_ops = { .initialize = hexagon_translate_init, .synchronize_from_tb = hexagon_cpu_synchronize_from_tb, .restore_state_to_opc = hexagon_restore_state_to_opc,
target/hppa/cpu.c +1 -1
@@ -170,7 +170,7 @@ static const struct SysemuCPUOps hppa_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps hppa_tcg_ops = { +static const TCGCPUOps hppa_tcg_ops = { .initialize = hppa_translate_init, .synchronize_from_tb = hppa_cpu_synchronize_from_tb, .restore_state_to_opc = hppa_restore_state_to_opc,
target/i386/tcg/tcg-cpu.c +1 -1
@@ -106,7 +106,7 @@ static bool x86_debug_check_breakpoint(CPUState *cs)#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps x86_tcg_ops = { +static const TCGCPUOps x86_tcg_ops = { .initialize = tcg_x86_init, .synchronize_from_tb = x86_cpu_synchronize_from_tb, .restore_state_to_opc = x86_restore_state_to_opc,
target/loongarch/cpu.c +1 -1
@@ -734,7 +734,7 @@ void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" -static struct TCGCPUOps loongarch_tcg_ops = { +static TCGCPUOps loongarch_tcg_ops = { .initialize = loongarch_translate_init, .synchronize_from_tb = loongarch_cpu_synchronize_from_tb, .restore_state_to_opc = loongarch_restore_state_to_opc,
target/m68k/cpu.c +1 -1
@@ -525,7 +525,7 @@ static const struct SysemuCPUOps m68k_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps m68k_tcg_ops = { +static const TCGCPUOps m68k_tcg_ops = { .initialize = m68k_tcg_init, .restore_state_to_opc = m68k_restore_state_to_opc,
target/microblaze/cpu.c +1 -1
@@ -387,7 +387,7 @@ static const struct SysemuCPUOps mb_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps mb_tcg_ops = { +static const TCGCPUOps mb_tcg_ops = { .initialize = mb_tcg_init, .synchronize_from_tb = mb_cpu_synchronize_from_tb, .restore_state_to_opc = mb_restore_state_to_opc,
target/mips/cpu.c +1 -1
@@ -549,7 +549,7 @@ static const struct SysemuCPUOps mips_sysemu_ops = {* NB: cannot be const, as some elements are changed for specific * mips hardware (see hw/mips/jazz.c). */ -static const struct TCGCPUOps mips_tcg_ops = { +static const TCGCPUOps mips_tcg_ops = { .initialize = mips_tcg_init, .synchronize_from_tb = mips_cpu_synchronize_from_tb, .restore_state_to_opc = mips_restore_state_to_opc,
target/nios2/cpu.c +1 -1
@@ -354,7 +354,7 @@ static const struct SysemuCPUOps nios2_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps nios2_tcg_ops = { +static const TCGCPUOps nios2_tcg_ops = { .initialize = nios2_tcg_init, .restore_state_to_opc = nios2_restore_state_to_opc,
target/openrisc/cpu.c +1 -1
@@ -213,7 +213,7 @@ static const struct SysemuCPUOps openrisc_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps openrisc_tcg_ops = { +static const TCGCPUOps openrisc_tcg_ops = { .initialize = openrisc_translate_init, .synchronize_from_tb = openrisc_cpu_synchronize_from_tb, .restore_state_to_opc = openrisc_restore_state_to_opc,
target/ppc/cpu_init.c +1 -1
@@ -7332,7 +7332,7 @@ static const struct SysemuCPUOps ppc_sysemu_ops = {#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps ppc_tcg_ops = { +static const TCGCPUOps ppc_tcg_ops = { .initialize = ppc_translate_init, .restore_state_to_opc = ppc_restore_state_to_opc,
target/riscv/tcg/tcg-cpu.c +1 -1
@@ -129,7 +129,7 @@ static void riscv_restore_state_to_opc(CPUState *cs, env->bins = data[1 ]; } -static const struct TCGCPUOps riscv_tcg_ops = { +static const TCGCPUOps riscv_tcg_ops = { .initialize = riscv_translate_init, .synchronize_from_tb = riscv_cpu_synchronize_from_tb, .restore_state_to_opc = riscv_restore_state_to_opc,
target/rx/cpu.c +1 -1
@@ -178,7 +178,7 @@ static const struct SysemuCPUOps rx_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps rx_tcg_ops = { +static const TCGCPUOps rx_tcg_ops = { .initialize = rx_translate_init, .synchronize_from_tb = rx_cpu_synchronize_from_tb, .restore_state_to_opc = rx_restore_state_to_opc,
target/s390x/cpu.c +1 -1
@@ -319,7 +319,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps s390_tcg_ops = { +static const TCGCPUOps s390_tcg_ops = { .initialize = s390x_translate_init, .restore_state_to_opc = s390x_restore_state_to_opc,
target/sh4/cpu.c +1 -1
@@ -237,7 +237,7 @@ static const struct SysemuCPUOps sh4_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps superh_tcg_ops = { +static const TCGCPUOps superh_tcg_ops = { .initialize = sh4_translate_init, .synchronize_from_tb = superh_cpu_synchronize_from_tb, .restore_state_to_opc = superh_restore_state_to_opc,
target/sparc/cpu.c +1 -1
@@ -874,7 +874,7 @@ static const struct SysemuCPUOps sparc_sysemu_ops = {#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps sparc_tcg_ops = { +static const TCGCPUOps sparc_tcg_ops = { .initialize = sparc_tcg_init, .synchronize_from_tb = sparc_cpu_synchronize_from_tb, .restore_state_to_opc = sparc_restore_state_to_opc,
target/tricore/cpu.c +1 -1
@@ -173,7 +173,7 @@ static const struct SysemuCPUOps tricore_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps tricore_tcg_ops = { +static const TCGCPUOps tricore_tcg_ops = { .initialize = tricore_tcg_init, .synchronize_from_tb = tricore_cpu_synchronize_from_tb, .restore_state_to_opc = tricore_restore_state_to_opc,
target/xtensa/cpu.c +1 -1
@@ -222,7 +222,7 @@ static const struct SysemuCPUOps xtensa_sysemu_ops = {#include "hw/core/tcg-cpu-ops.h" -static const struct TCGCPUOps xtensa_tcg_ops = { +static const TCGCPUOps xtensa_tcg_ops = { .initialize = xtensa_translate_init, .debug_excp_handler = xtensa_breakpoint_handler, .restore_state_to_opc = xtensa_restore_state_to_opc,
Signature · 1 line
2.34.1
[PULL 13/31] tests/tcg: Add the PROT_NONE gdbstub test
In reply to Richard HendersonFrom: Ilya Leoshkevich <[email protected]>
Make sure that qemu gdbstub, like gdbserver, allows reading from and writing to PROT_NONE pages.
Message-Id: <[email protected]>
--- tests/tcg/multiarch/prot-none.c | 40 ++++++++++++++++++++++++ tests/tcg/multiarch/Makefile.target | 9 +++++- tests/tcg/multiarch/gdbstub/prot-none.py | 36 +++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/prot-none.c create mode 100644 tests/tcg/multiarch/gdbstub/prot-none.py
tests/tcg/multiarch/prot-none.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Test that GDB can access PROT_NONE pages. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include <assert.h> +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <unistd.h> + +void break_here (void *q) +{ +} + +int main (void ) +{ +long pagesize =sysconf (_SC_PAGESIZE); +void *p, *q; +int err; + + p =mmap (NULL , pagesize *2 ,PROT_READ |PROT_WRITE , +MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +assert (p !=MAP_FAILED ); + q = p + pagesize -1 ; +strcpy (q,"42" ); + + err =mprotect (p, pagesize *2 ,PROT_NONE ); +assert (err ==0 ); + +break_here (q); + + err =mprotect (p, pagesize *2 ,PROT_READ ); +assert (err ==0 ); +if (getenv ("PROT_NONE_PY" )) { +assert (strcmp (q,"24" ) ==0 ); + } + +return EXIT_SUCCESS ; +}
tests/tcg/multiarch/Makefile.target +8 -1
@@ -101,13 +101,20 @@ run-gdbstub-registers: sha512 --bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \ checking register enumeration) +run-gdbstub-prot-none: prot-none + $(call run-test, $@, env PROT_NONE_PY=1 $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \ + accessing PROT_NONE memory) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support") endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ - run-gdbstub-registers + run-gdbstub-registers run-gdbstub-prot-none # ARM Compatible Semi Hosting Tests #
tests/tcg/multiarch/gdbstub/prot-none.py new file +36 -0
@@ -0,0 +1,36 @@ +"""Test that GDB can access PROT_NONE pages. + +This runs as a sourced script (via -x, via run-test.py). + +SPDX-License-Identifier: GPL-2.0-or-later +""" +import ctypes +from test_gdbstub import main, report + + +def probe_proc_self_mem(): + buf = ctypes.create_string_buffer(b'aaa') + try: + with open("/proc/self/mem", "rb") as fp: + fp.seek(ctypes.addressof(buf)) + return fp.read(3) == b'aaa' + except OSError: + return False + + +def run_test(): + """Run through the tests one by one""" + if not probe_proc_self_mem: + print("SKIP: /proc/self/mem is not usable") + exit(0) + gdb.Breakpoint("break_here") + gdb.execute("continue") + val = gdb.parse_and_eval("*(char[2] *)q").string() + report(val == "42", "{} == 42".format(val)) + gdb.execute("set *(char[3] *)q = \"24\"") + gdb.execute("continue") + exitcode = int(gdb.parse_and_eval("$_exitcode")) + report(exitcode == 0, "{} == 0".format(exitcode)) + + +main(run_test)
Signature · 1 line
2.34.1
Re: [PULL 13/31] tests/tcg: Add the PROT_NONE gdbstub test
Quoted 16 lines · Richard Henderson
From: Ilya Leoshkevich <[email protected]>
Make sure that qemu gdbstub, like gdbserver, allows reading from and writing to
PROT_NONEpages.Signed-off-by Ilya Leoshkevich <[email protected]>Message-Id: <[email protected]>
Signed-off-by Richard Henderson <[email protected]>---
tests/tcg/multiarch/prot-none.c | 40
++++++++++++++++++++++++
tests/tcg/multiarch/Makefile.target | 9 +++++-tests/tcg/multiarch/gdbstub/prot-none.py| 36 +++++++++++++++++++++3 files changed, 84 insertions(+), 1 deletion(-)create mode 100644
tests/tcg/multiarch/prot-none.ccreate mode 100644tests/tcg/multiarch/gdbstub/prot-none.py
[...]
Quoted 20 lines
tests/tcg/multiarch/gdbstub/prot-none.py new file +13
-0@@ -0,0 +1,36 @@ +"""Test that GDB can access PROT_NONE pages. + +This runs as a sourced script (via -x, via run-test.py). + +SPDX-License-Identifier: GPL-2.0-or-later +""" +import ctypes +from test_gdbstub import main, report + + +def probe_proc_self_mem(): + buf = ctypes.create_string_buffer(b'aaa') + try:
tests/tcg/multiarch/gdbstub/prot-none.py line 23
Quoted 10 lines
tests/tcg/multiarch/gdbstub/prot-none.py new file +10
-0+ with open("/proc/self/mem", "rb") as fp: + fp.seek(ctypes.addressof(buf)) + return fp.read(3) == b'aaa' + except OSError: + return False + + +def run_test(): + """Run through the tests one by one""" + if not probe_proc_self_mem:
I noticed that I made an embarrassing typo here: this should be not probe_proc_self_mem(). I posted a v5 with the correction.
[...]
Peter Maydell
AppliedQuoted 9 lines · Richard Henderson
The following changes since commit
7a1dc45af581d2b643cdbf33c01fd96271616fbd:Merge tag 'pull-target-arm-20240126' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-01-26 18:16:35 +0000)
are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240130
Quoted 8 lines
for you to fetch changes up to
ec1d32af123e7f13d98754a72bcaa7aa8c8e9d27:target/i386: Extract
x86_cpu_exec_halt()from accel/tcg/ (2024-01-29 21:04:10 +1000)----------------------------------------------------------------
linux-user: Allow gdbstub to ignore page protection
cpu-exec: simplify jump cache managementinclude/exec: Cleanups toward building accel/tcg once
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.
-- PMM