Compile accel/tcg once (partially)
Subsystems (2)
cover Compile accel/tcg once (partially)
Based on an older version of rth/tcg-next and some patches by me, Philippe, and Richard (most of which have since been merged), base branch here
https://gitlab.com/AntonJohansson/qemu/-/tree/feature/accel-tcg-once-base
Rebase is in the works, but should not affect the larger parts of this patchset that I'm looking for feedback on.
This patchset moves forward with the single binary/compile once work and tries to compile translation units in accel/tcg/ once for system mode. The following files are compiled once in this patchset
cputlb.c
tcg-all.c
tcg-runtime.c
tcg-runtime-gvec.c
tb-maint.c
plugin-gen.c
translate-all.c
and debuginfo.c is also moved to common_ss as it doesn't contain any target specifics. Work still remains for
cpu-exec.c (TARGET_I386 ifdefs)
translator.c (tswap(), ldl_p() and friends)
Brackets [...] in patch names are temporary and indicate patches that "belong" together and can be split out easier.
Major changes which I'm looking for feedback on:
- [PAGE_VARY] patches:
Switches to variable page sizes as a default for all system mode targets, meaning TARGET_PAGE_* and TLB_* become target independent.
- "Uninline cpu_mmu_index()"/"Uninline cpu_get_tb_cpu_state()":
Uninlines cpu_mmu_index() (used by cputlb.c) and cpu_get_tb_cpu_state() (used by translate-all.c) so they can be called from accel/tcg without pulling in target specifics.
- "Wrap target macros in functions":
Introduces wrapper functions in cpu-target.c around target macros that I'm not sure how to deal with.
Anton Johansson (34):
target: [PAGE_VARY] Use PAGE_VARY for all softmmu targets
target: [PAGE_VARY] Move TARGET_PAGE_BITS_MIN to TargetPageBits
exec: [PAGE_VARY] Move TARGET_PAGE_BITS_VARY to common header
exec: [PAGE_VARY] Unpoison TARGET_PAGE_* macros for system mode target/tricore: [VADDR] Use target_ulong for EA
exec: [VADDR] Move vaddr defines to separate file hw/core: [VADDR] Include vaddr.h from cpu.h
target: [VADDR] Use vaddr in gen_intermediate_code
exec: [VADDR] Use vaddr in DisasContextBase for virtual addresses
exec: [VADDR] typedef abi_ptr to vaddr
[IGNORE] Squash of header code shuffling
target: Uninline cpu_mmu_index()
target: Uninline cpu_get_tb_cpu_state()
exec: [CPUTLB] Move PAGE_* macros to common header
exec: [CPUTLB] Move TLB_*/tlb_*() to common header
exec: [CPUTLB] Move cpu_*()/cpu_env() to common header hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps accel/stubs: [CPUTLB] Move xen.h stubs to xen-stub.c accel/tcg: [CPUTLB] Use TCGContext.addr_type instead of
TARGET_LONG_BITS
accel/tcg: [CPUTLB] Use TCGContext.guest_mo for memory ordering accel/tcg: [CPUTLB] Use tcg_ctx->tlb_dyn_max_bits accel/tcg: [CPUTLB] Move CPU_TLB_DYN_[DEFAULT|MIN]* to cputlb.c
tcg: [CPUTLB] Add mo_te field to TCGContext accel/tcg: [CPUTLB] Set mo_te in TCGContext
accel/tcg: [CPUTLB] Use tcg_ctx->mo_te instead of MO_TE Wrap target macros in functions
accel/tcg: Make translate-all.c target independent accel/tcg: Make plugin-gen.c target independent accel/tcg: Make tb-maint.c target indpendent accel/tcg: Make tcg-all.c target indpendent
accel/tcg: Make tcg-runtime-gvec.c target independent accel/tcg: Make tcg-runtime.c target independent accel/tcg: Make translator.c (partially) target independent accel/tcg: Compile (a few files) once for system-mode
accel/tcg/internal-target.h | 11 +- accel/tcg/tb-hash.h | 4 +- hw/s390x/s390-virtio-hcall.h | 2 + include/exec/cpu-all.h | 156 +------------- include/exec/cpu-common.h | 185 ++++++++++++++++- include/exec/cpu-defs.h | 7 +- include/exec/cpu_ldst-target.h | 52 +++++ include/exec/cpu_ldst.h | 95 +++------ include/exec/exec-all.h | 347 +------------------------------ include/exec/exec-common.h | 367 +++++++++++++++++++++++++++++++++ include/exec/memory-internal.h | 2 +- include/exec/page-vary.h | 1 + include/exec/poison.h | 2 + include/exec/ram_addr.h | 3 +- include/exec/translator.h | 8 +- include/exec/vaddr.h | 18 ++ include/hw/core/cpu.h | 11 +- include/hw/core/tcg-cpu-ops.h | 32 +-- include/qemu/plugin-memory.h | 1 - include/sysemu/xen.h | 27 --- include/tcg/tcg.h | 1 + target/alpha/cpu-param.h | 6 + target/alpha/cpu.h | 20 -- target/arm/cpu-param.h | 2 +- target/arm/cpu.h | 16 -- target/avr/cpu-param.h | 6 + target/avr/cpu.h | 24 --- target/cris/cpu-param.h | 7 + target/cris/cpu.h | 14 -- target/hexagon/cpu.h | 21 -- target/hppa/cpu-param.h | 6 + target/hppa/cpu.h | 55 ----- target/i386/cpu-param.h | 6 + target/i386/cpu.h | 16 -- target/loongarch/cpu-param.h | 5 + target/loongarch/cpu.h | 23 --- target/m68k/cpu-param.h | 6 + target/m68k/cpu.h | 20 -- target/microblaze/cpu-param.h | 6 +- target/microblaze/cpu.h | 23 --- target/mips/cpu-param.h | 2 +- target/mips/cpu.h | 23 +-- target/mips/tcg/translate.h | 3 +- target/nios2/cpu-param.h | 5 +- target/nios2/cpu.h | 18 -- target/openrisc/cpu-param.h | 8 +- target/openrisc/cpu.h | 22 -- target/ppc/cpu-param.h | 6 + target/ppc/cpu.h | 21 -- target/riscv/cpu-param.h | 7 + target/riscv/cpu.h | 5 - target/rx/cpu-param.h | 8 +- target/rx/cpu.h | 14 -- target/s390x/cpu-param.h | 8 +- target/s390x/cpu.h | 53 ----- target/sh4/cpu-param.h | 4 +- target/sh4/cpu.h | 25 --- target/sparc/cpu-param.h | 17 +- target/sparc/cpu.h | 63 ------ target/tricore/cpu-param.h | 8 +- target/tricore/cpu.h | 17 -- target/xtensa/cpu-param.h | 8 +- target/xtensa/cpu.h | 73 ------- accel/stubs/xen-stub.c | 12 ++ accel/tcg/cpu-exec.c | 1 + accel/tcg/cputlb.c | 51 +++-- accel/tcg/plugin-gen.c | 15 +- accel/tcg/tb-maint.c | 47 +++-- accel/tcg/tcg-all.c | 25 +-- accel/tcg/tcg-runtime-gvec.c | 2 +- accel/tcg/tcg-runtime.c | 2 +- accel/tcg/translate-all.c | 40 ++-- accel/tcg/translator.c | 16 +- cpu-target.c | 62 ++++++ page-vary-common.c | 1 + page-vary-target.c | 4 +- plugins/core.c | 1 + target/alpha/cpu.c | 19 ++ target/alpha/translate.c | 2 +- target/arm/cpu.c | 6 + target/arm/tcg/translate.c | 6 +- target/avr/cpu.c | 23 +++ target/avr/translate.c | 2 +- target/cris/cpu.c | 14 ++ target/cris/translate.c | 2 +- target/hexagon/cpu.c | 21 ++ target/hexagon/translate.c | 5 +- target/hppa/cpu.c | 59 ++++++ target/hppa/translate.c | 2 +- target/i386/cpu.c | 16 ++ target/i386/tcg/translate.c | 2 +- target/loongarch/cpu.c | 23 +++ target/loongarch/translate.c | 2 +- target/m68k/cpu.c | 21 ++ target/m68k/translate.c | 4 +- target/microblaze/cpu.c | 23 +++ target/microblaze/translate.c | 2 +- target/mips/cpu.c | 23 +++ target/mips/tcg/translate.c | 14 +- target/nios2/cpu.c | 18 ++ target/nios2/translate.c | 2 +- target/openrisc/cpu.c | 22 ++ target/openrisc/translate.c | 2 +- target/ppc/cpu.c | 20 ++ target/ppc/translate.c | 2 +- target/riscv/cpu_helper.c | 2 +- target/riscv/translate.c | 2 +- target/rx/cpu.c | 14 ++ target/rx/translate.c | 2 +- target/s390x/cpu.c | 55 +++++ target/s390x/tcg/translate.c | 2 +- target/sh4/cpu.c | 28 +++ target/sh4/translate.c | 2 +- target/sparc/cpu.c | 63 ++++++ target/sparc/gdbstub.c | 3 + target/sparc/translate.c | 2 +- target/tricore/cpu.c | 17 ++ target/tricore/op_helper.c | 8 +- target/tricore/translate.c | 2 +- target/xtensa/cpu.c | 72 +++++++ target/xtensa/translate.c | 2 +- accel/tcg/meson.build | 57 +++-- 122 files changed, 1656 insertions(+), 1345 deletions(-) create mode 100644 include/exec/cpu_ldst-target.h create mode 100644 include/exec/exec-common.h create mode 100644 include/exec/vaddr.h
Signature · 1 line
2.43.0
RFC PATCH 1/34 target: [PAGE_VARY] Use PAGE_VARY for all softmmu targets
Allows for future commits to use TargetPageBits to access page bits and mask, thus making TARGET_PAGE_* independent of softmmu target.
In the future, this will also be important fo allowing heterogeneous CPUs on the same board.
--- target/alpha/cpu-param.h | 6 ++++++ target/avr/cpu-param.h | 6 ++++++ target/cris/cpu-param.h | 7 +++++++ target/hppa/cpu-param.h | 6 ++++++ target/i386/cpu-param.h | 6 ++++++ target/loongarch/cpu-param.h | 5 +++++ target/m68k/cpu-param.h | 6 ++++++ target/microblaze/cpu-param.h | 6 ++++-- target/nios2/cpu-param.h | 5 ++++- target/openrisc/cpu-param.h | 8 +++++++- target/ppc/cpu-param.h | 6 ++++++ target/riscv/cpu-param.h | 7 +++++++ target/rx/cpu-param.h | 8 +++++++- target/s390x/cpu-param.h | 8 +++++++- target/sh4/cpu-param.h | 4 +++- target/sparc/cpu-param.h | 17 +++++++++++++++-- target/tricore/cpu-param.h | 8 +++++++- target/xtensa/cpu-param.h | 8 +++++--- 18 files changed, 114 insertions(+), 13 deletions(-)
target/alpha/cpu-param.h +6 -0
@@ -9,7 +9,13 @@#define ALPHA_CPU_PARAM_H #define TARGET_LONG_BITS 64 + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 13 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 13 +#endif /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44
target/avr/cpu-param.h +6 -0
@@ -28,7 +28,13 @@* should be implemented as a device and not memory * 2. SRAM starts at the address 0x0100 */ +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 8 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 8 +#endif +#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24
target/cris/cpu-param.h +7 -0
@@ -9,7 +9,14 @@#define CRIS_CPU_PARAM_H #define TARGET_LONG_BITS 32 + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 13 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 13 +#endif +#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32
target/hppa/cpu-param.h +6 -0
@@ -28,6 +28,12 @@# define TARGET_VIRT_ADDR_SPACE_BITS 64# define TARGET_PHYS_ADDR_SPACE_BITS 32#endif + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif #endif
target/i386/cpu-param.h +6 -0
@@ -22,6 +22,12 @@# define TARGET_PHYS_ADDR_SPACE_BITS 36# define TARGET_VIRT_ADDR_SPACE_BITS 32#endif + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif #endif
target/loongarch/cpu-param.h +5 -0
@@ -12,6 +12,11 @@#define TARGET_PHYS_ADDR_SPACE_BITS 48#define TARGET_VIRT_ADDR_SPACE_BITS 48 +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 14 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 14 +#endif #endif
target/m68k/cpu-param.h +6 -0
@@ -14,7 +14,13 @@* and m68k linux uses 4k pages * use the smallest one */ +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif +#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32
target/microblaze/cpu-param.h +4 -2
@@ -20,13 +20,15 @@#define TARGET_LONG_BITS 32#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 +/* FIXME: MB uses variable pages down to 1K but linux only uses 4k. */ +#define TARGET_PAGE_BITS 12#else #define TARGET_LONG_BITS 64#define TARGET_PHYS_ADDR_SPACE_BITS 64#define TARGET_VIRT_ADDR_SPACE_BITS 64 +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12#endif -/* FIXME: MB uses variable pages down to 1K but linux only uses 4k. */ -#define TARGET_PAGE_BITS 12#endif
target/nios2/cpu-param.h +4 -1
@@ -9,12 +9,15 @@#define NIOS2_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 12 +#define TARGET_PHYS_ADDR_SPACE_BITS 32#ifdef CONFIG_USER_ONLY # define TARGET_VIRT_ADDR_SPACE_BITS 31 +# define TARGET_PAGE_BITS 12#else # define TARGET_VIRT_ADDR_SPACE_BITS 32 +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12#endif #endif
target/openrisc/cpu-param.h +7 -1
@@ -9,8 +9,14 @@#define OPENRISC_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 13#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_BITS 13 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 13 +#endif +#endif
target/ppc/cpu-param.h +6 -0
@@ -31,6 +31,12 @@# define TARGET_PHYS_ADDR_SPACE_BITS 36# define TARGET_VIRT_ADDR_SPACE_BITS 32#endif + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif #endif
target/riscv/cpu-param.h +7 -0
@@ -17,7 +17,14 @@# define TARGET_PHYS_ADDR_SPACE_BITS 34/* 22-bit PPN */ # define TARGET_VIRT_ADDR_SPACE_BITS 32/* sv32 */ #endif + +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 12/* 4 KiB Pages */ +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12/* 4 KiB Pages */ +#endif +/* * The current MMU Modes are: * - U mode 0b000
target/rx/cpu-param.h +7 -1
@@ -20,9 +20,15 @@#define RX_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 12#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif +#endif
target/s390x/cpu-param.h +7 -1
@@ -9,8 +9,14 @@#define S390_CPU_PARAM_H #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 12#define TARGET_PHYS_ADDR_SPACE_BITS 64#define TARGET_VIRT_ADDR_SPACE_BITS 64 +#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_BITS 12 +#else +#define TARGET_PAGE_BITS_VARY +#define TARGET_PAGE_BITS_MIN 12 +#endif +#endif
target/sh4/cpu-param.h +3 -1
@@ -9,12 +9,14 @@#define SH4_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 12/* 4k */ #define TARGET_PHYS_ADDR_SPACE_BITS 32#ifdef CONFIG_USER_ONLY # define TARGET_VIRT_ADDR_SPACE_BITS 31 +# define TARGET_PAGE_BITS 12/* 4k */ #else # define TARGET_VIRT_ADDR_SPACE_BITS 32 +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12/* 4k */ #endif #endif
target/sparc/cpu-param.h +15 -2
@@ -9,7 +9,6 @@#ifdef TARGET_SPARC64 # define TARGET_LONG_BITS 64 -# define TARGET_PAGE_BITS 13/* 8k */ # define TARGET_PHYS_ADDR_SPACE_BITS 41# ifdef TARGET_ABI32 # define TARGET_VIRT_ADDR_SPACE_BITS 32
@@ -18,9 +17,23 @@# endif #else # define TARGET_LONG_BITS 32 -# define TARGET_PAGE_BITS 12/* 4k */ # define TARGET_PHYS_ADDR_SPACE_BITS 36# define TARGET_VIRT_ADDR_SPACE_BITS 32#endif +#ifdef CONFIG_USER_ONLY +# ifdef TARGET_SPARC64 +# define TARGET_PAGE_BITS 13/* 8k */ +# else +# define TARGET_PAGE_BITS 12/* 4k */ +# endif +#else +# define TARGET_PAGE_BITS_VARY +# ifdef TARGET_SPARC64 +# define TARGET_PAGE_BITS_MIN 13/* 8k */ +# else +# define TARGET_PAGE_BITS_MIN 12/* 4k */ +# endif +#endif +#endif
target/tricore/cpu-param.h +7 -1
@@ -9,8 +9,14 @@#define TRICORE_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 14#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#ifdef CONFIG_USER_ONLY +# define TARGET_PAGE_BITS 14 +#else +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 14 +#endif +#endif
target/xtensa/cpu-param.h +5 -3
@@ -9,12 +9,14 @@#define XTENSA_CPU_PARAM_H #define TARGET_LONG_BITS 32 -#define TARGET_PAGE_BITS 12#define TARGET_PHYS_ADDR_SPACE_BITS 32#ifdef CONFIG_USER_ONLY -#define TARGET_VIRT_ADDR_SPACE_BITS 30 +# define TARGET_VIRT_ADDR_SPACE_BITS 30 +# define TARGET_PAGE_BITS 12#else -#define TARGET_VIRT_ADDR_SPACE_BITS 32 +# define TARGET_VIRT_ADDR_SPACE_BITS 32 +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12#endif #endif
Signature · 1 line
2.43.0
Re: [RFC PATCH 01/34] target: [PAGE_VARY] Use PAGE_VARY for all softmmu targets
Quoted 5 lines · Anton Johansson
Allows for future commits to use TargetPageBits to access page bits and mask, thus making TARGET_PAGE_* independent of softmmu target.
In the future, this will also be important fo allowing heterogeneous CPUs on the same board.
Yeah I carry an almost similar patch :)
Quoted 21 lines
Signed-off-by Anton Johansson <[email protected]>--- target/alpha/cpu-param.h | 6 ++++++ target/avr/cpu-param.h | 6 ++++++ target/cris/cpu-param.h | 7 +++++++ target/hppa/cpu-param.h | 6 ++++++ target/i386/cpu-param.h | 6 ++++++ target/loongarch/cpu-param.h | 5 +++++ target/m68k/cpu-param.h | 6 ++++++ target/microblaze/cpu-param.h | 6 ++++-- target/nios2/cpu-param.h | 5 ++++- target/openrisc/cpu-param.h | 8 +++++++- target/ppc/cpu-param.h | 6 ++++++ target/riscv/cpu-param.h | 7 +++++++ target/rx/cpu-param.h | 8 +++++++- target/s390x/cpu-param.h | 8 +++++++- target/sh4/cpu-param.h | 4 +++- target/sparc/cpu-param.h | 17 +++++++++++++++-- target/tricore/cpu-param.h | 8 +++++++- target/xtensa/cpu-param.h | 8 +++++--- 18 files changed, 114 insertions(+), 13 deletions(-)
Re: [RFC PATCH 01/34] target: [PAGE_VARY] Use PAGE_VARY for all softmmu targets
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Anton Johansson
Allows for future commits to use TargetPageBits to access page bits and mask, thus making TARGET_PAGE_* independent of softmmu target.
In the future, this will also be important fo allowing heterogeneous CPUs on the same board.
Yeah I carry an almost similar patch :)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Suspected there might be some overlap with this patchset:) Do you have branch I could rebase on to remove conflicts?
RFC PATCH 2/34 target: [PAGE_VARY] Move TARGET_PAGE_BITS_MIN to TargetPageBits
In reply to Anton Johansson viaTARGET_PAGE_BITS_MIN is now defined as target_page.bits_min when PAGE_VARY is used, similar to other TARGET_PAGE_* macros. We still pick whatever minimum the target specifies, however in a heterogeneous context we would want the maximum of all target_page.bits_min.
This also makes TLB_* macros target independent, and the static assert checking for TLB_* flag overlap is moved to a runtime assert in tlb_init().
[NOTE: I'm not happy with adding the TARGET_PAGE_BITS_MIN_SPECIFIC macro, maybe we can remove it and use MachineClass->minimum_page_bits instead? Other ideas?]
--- include/exec/cpu-all.h | 10 +++++----- include/exec/cpu-defs.h | 4 ++-- include/exec/page-vary.h | 1 + target/alpha/cpu-param.h | 2 +- target/arm/cpu-param.h | 2 +- target/avr/cpu-param.h | 2 +- target/cris/cpu-param.h | 2 +- target/hppa/cpu-param.h | 2 +- target/i386/cpu-param.h | 2 +- target/loongarch/cpu-param.h | 2 +- target/m68k/cpu-param.h | 2 +- target/microblaze/cpu-param.h | 2 +- target/mips/cpu-param.h | 2 +- target/nios2/cpu-param.h | 2 +- target/openrisc/cpu-param.h | 2 +- target/ppc/cpu-param.h | 2 +- target/riscv/cpu-param.h | 2 +- target/rx/cpu-param.h | 2 +- target/s390x/cpu-param.h | 2 +- target/sh4/cpu-param.h | 2 +- target/sparc/cpu-param.h | 4 ++-- target/tricore/cpu-param.h | 2 +- target/xtensa/cpu-param.h | 2 +- accel/tcg/cputlb.c | 3 +++ page-vary-common.c | 1 + page-vary-target.c | 4 ++-- target/arm/tcg/translate.c | 4 ++-- 27 files changed, 37 insertions(+), 32 deletions(-)
include/exec/cpu-all.h +5 -5
@@ -155,12 +155,15 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val# include "exec/page-vary.h" extern const TargetPageBits target_page;#ifdef CONFIG_DEBUG_TCG +#define TARGET_PAGE_BITS_MIN ({ assert(target_page.decided); \ + target_page.bits_min; })#define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bits; })#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ (target_long)target_page.mask; })#else -#define TARGET_PAGE_BITS target_page.bits -#define TARGET_PAGE_MASK ((target_long)target_page.mask) +#define TARGET_PAGE_BITS_MIN target_page.bits_min +#define TARGET_PAGE_BITS target_page.bits +#define TARGET_PAGE_MASK ((target_long)target_page.mask)#endif #define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK)#else
@@ -380,9 +383,6 @@ CPUArchState *cpu_copy(CPUArchState *env);#define TLB_SLOW_FLAGS_MASK (TLB_BSWAP | TLB_WATCHPOINT) -/* The two sets of flags must not overlap. */ -QEMU_BUILD_BUG_ON (TLB_FLAGS_MASK &TLB_SLOW_FLAGS_MASK ); -/** * tlb_hit_page: return true if page aligned @addr is a hit against the * TLB entry @tlb_addr
include/exec/cpu-defs.h +2 -2
@@ -44,8 +44,8 @@#endif #ifndef TARGET_PAGE_BITS # ifdef TARGET_PAGE_BITS_VARY -# ifndef TARGET_PAGE_BITS_MIN -# error TARGET_PAGE_BITS_MIN must be defined in cpu-param.h +# ifndef TARGET_PAGE_BITS_MIN_SPECIFIC +# error TARGET_PAGE_BITS_MIN_SPECIFIC must be defined in cpu-param.h# endif # else # error TARGET_PAGE_BITS must be defined in cpu-param.h
include/exec/page-vary.h +1 -0
@@ -22,6 +22,7 @@typedef struct {bool decided; +int bits_min;int bits;uint64_t mask; }TargetPageBits ;
target/alpha/cpu-param.h +1 -1
@@ -14,7 +14,7 @@#define TARGET_PAGE_BITS 13#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 13 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 13#endif /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */
target/arm/cpu-param.h +1 -1
@@ -29,7 +29,7 @@* have to support 1K tiny pages. */ # define TARGET_PAGE_BITS_VARY -# define TARGET_PAGE_BITS_MIN 10 +# define TARGET_PAGE_BITS_MIN_SPECIFIC 10#endif
target/avr/cpu-param.h +1 -1
@@ -32,7 +32,7 @@#define TARGET_PAGE_BITS 8#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 8 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 8#endif #define TARGET_PHYS_ADDR_SPACE_BITS 24
target/cris/cpu-param.h +1 -1
@@ -14,7 +14,7 @@#define TARGET_PAGE_BITS 13#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 13 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 13#endif #define TARGET_PHYS_ADDR_SPACE_BITS 32
target/hppa/cpu-param.h +1 -1
@@ -33,7 +33,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/i386/cpu-param.h +1 -1
@@ -27,7 +27,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/loongarch/cpu-param.h +1 -1
@@ -16,7 +16,7 @@#define TARGET_PAGE_BITS 14#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 14 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 14#endif #endif
target/m68k/cpu-param.h +1 -1
@@ -18,7 +18,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #define TARGET_PHYS_ADDR_SPACE_BITS 32
target/microblaze/cpu-param.h +1 -1
@@ -27,7 +27,7 @@#define TARGET_PHYS_ADDR_SPACE_BITS 64#define TARGET_VIRT_ADDR_SPACE_BITS 64#define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif
target/mips/cpu-param.h +1 -1
@@ -27,7 +27,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/nios2/cpu-param.h +1 -1
@@ -17,7 +17,7 @@#else # define TARGET_VIRT_ADDR_SPACE_BITS 32# define TARGET_PAGE_BITS_VARY -# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/openrisc/cpu-param.h +1 -1
@@ -16,7 +16,7 @@#define TARGET_PAGE_BITS 13#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 13 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 13#endif #endif
target/ppc/cpu-param.h +1 -1
@@ -36,7 +36,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/riscv/cpu-param.h +1 -1
@@ -22,7 +22,7 @@#define TARGET_PAGE_BITS 12/* 4 KiB Pages */ #else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12/* 4 KiB Pages */ +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12/* 4 KiB Pages */ #endif /*
target/rx/cpu-param.h +1 -1
@@ -28,7 +28,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/s390x/cpu-param.h +1 -1
@@ -16,7 +16,7 @@#define TARGET_PAGE_BITS 12#else #define TARGET_PAGE_BITS_VARY -#define TARGET_PAGE_BITS_MIN 12 +#define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
target/sh4/cpu-param.h +1 -1
@@ -16,7 +16,7 @@#else # define TARGET_VIRT_ADDR_SPACE_BITS 32# define TARGET_PAGE_BITS_VARY -# define TARGET_PAGE_BITS_MIN 12/* 4k */ +# define TARGET_PAGE_BITS_MIN_SPECIFIC 12/* 4k */ #endif #endif
target/sparc/cpu-param.h +2 -2
@@ -30,9 +30,9 @@#else # define TARGET_PAGE_BITS_VARY # ifdef TARGET_SPARC64 -# define TARGET_PAGE_BITS_MIN 13/* 8k */ +# define TARGET_PAGE_BITS_MIN_SPECIFIC 13/* 8k */ # else -# define TARGET_PAGE_BITS_MIN 12/* 4k */ +# define TARGET_PAGE_BITS_MIN_SPECIFIC 12/* 4k */ # endif #endif
target/tricore/cpu-param.h +1 -1
@@ -16,7 +16,7 @@# define TARGET_PAGE_BITS 14#else # define TARGET_PAGE_BITS_VARY -# define TARGET_PAGE_BITS_MIN 14 +# define TARGET_PAGE_BITS_MIN_SPECIFIC 14#endif #endif
target/xtensa/cpu-param.h +1 -1
@@ -16,7 +16,7 @@#else # define TARGET_VIRT_ADDR_SPACE_BITS 32# define TARGET_PAGE_BITS_VARY -# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_PAGE_BITS_MIN_SPECIFIC 12#endif #endif
accel/tcg/cputlb.c +3 -0
@@ -278,6 +278,9 @@ void tlb_init(CPUState *cpu)int64_t now =get_clock_realtime ();int i; +/* The two sets of flags must not overlap. */ +assert ((TLB_FLAGS_MASK &TLB_SLOW_FLAGS_MASK ) ==0 ); +qemu_spin_init (&cpu->neg.tlb.c.lock);/* All tlbs are initialized flushed. */
page-vary-common.c +1 -0
@@ -48,6 +48,7 @@ void finalize_target_page_bits_common(int min)if (target_page.bits ==0 ) { target_page.bits = min; } + target_page.bits_min = min; target_page.mask =-1ull << target_page.bits; target_page.decided = true; }
page-vary-target.c +2 -2
@@ -26,7 +26,7 @@bool set_preferred_target_page_bits (int bits) {#ifdef TARGET_PAGE_BITS_VARY -assert (bits >=TARGET_PAGE_BITS_MIN ); +assert (bits >=TARGET_PAGE_BITS_MIN_SPECIFIC );return set_preferred_target_page_bits_common (bits);#else return true;
@@ -36,6 +36,6 @@ bool set_preferred_target_page_bits(int bits)void finalize_target_page_bits (void ) {#ifdef TARGET_PAGE_BITS_VARY -finalize_target_page_bits_common (TARGET_PAGE_BITS_MIN ); +finalize_target_page_bits_common (TARGET_PAGE_BITS_MIN_SPECIFIC );#endif }
target/arm/tcg/translate.c +2 -2
@@ -902,8 +902,8 @@ MemOp pow2_align(unsigned i)static const MemOp mop_align[] = {0 ,MO_ALIGN_2 ,MO_ALIGN_4 ,MO_ALIGN_8 ,MO_ALIGN_16 ,/* -* FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such -* that 256-bit alignment (MO_ALIGN_32) cannot be supported: +* FIXME: TARGET_PAGE_BITS_MIN_SPECIFIC affects TLB_FLAGS_MASK +* such that 256-bit alignment (MO_ALIGN_32) cannot be supported: * see get_alignment_bits(). Enforce only 128-bit alignment for now. */ MO_ALIGN_16
Signature · 1 line
2.43.0
Re: [RFC PATCH 02/34] target: [PAGE_VARY] Move TARGET_PAGE_BITS_MIN to TargetPageBits
Quoted 4 lines · Anton Johansson
TARGET_PAGE_BITS_MINis now defined as target_page.bits_min whenPAGE_VARYis used, similar to other TARGET_PAGE_* macros. We still pick whatever minimum the target specifies, however in a heterogeneous context we would want the maximum of all target_page.bits_min.
Do we? Or do we need to reject different minimums as incompatible?
r~
RFC PATCH 3/34 exec: [PAGE_VARY] Move TARGET_PAGE_BITS_VARY to common header
In reply to Anton Johansson viaWe need to be able access the variable TARGET_PAGE_* macros in a target-independent manner.
--- include/exec/cpu-all.h | 29 ++++++++++------------------- include/exec/cpu-common.h | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 19 deletions(-)
include/exec/cpu-all.h +10 -19
@@ -149,30 +149,21 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val#include "exec/memory_ldst_phys.h.inc" #endif -/* page related stuff */ - -#ifdef TARGET_PAGE_BITS_VARY -# include "exec/page-vary.h" -extern const TargetPageBits target_page; -#ifdef CONFIG_DEBUG_TCG -#define TARGET_PAGE_BITS_MIN ({ assert(target_page.decided); \ - target_page.bits_min; }) -#define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bits; }) -#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ - (target_long)target_page.mask; }) -#else -#define TARGET_PAGE_BITS_MIN target_page.bits_min -#define TARGET_PAGE_BITS target_page.bits -#define TARGET_PAGE_MASK ((target_long)target_page.mask) -#endif -#define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) -#else +/* Non-variable page size macros */ +#ifndef TARGET_PAGE_BITS_VARY #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_ALIGN (addr) ROUND_UP((addr), TARGET_PAGE_SIZE)#endif -#define TARGET_PAGE_ALIGN (addr) ROUND_UP((addr), TARGET_PAGE_SIZE) +/* +* Check that softmmu targets are using variable page sizes, we need this +* for the TARGET_PAGE_* macros to be target independent. +*/ +#if !defined(CONFIG_USER_ONLY ) && !defined(TARGET_PAGE_BITS_VARY ) +# error Need to use TARGET_PAGE_BITS_VARY on system mode +#endif /* same as PROT_xxx */ #define PAGE_READ 0x0001
include/exec/cpu-common.h +25 -0
@@ -26,6 +26,31 @@ typedef uint64_t vaddr;#define VADDR_PRIX PRIX64#define VADDR_MAX UINT64_MAX +/** +* Variable page size macros +* +* TARGET_PAGE_BITS_VARY is assumed for softmmu targets so +* these macros are target independent. This is checked in +* cpu-all.h. +*/ +#ifndef CONFIG_USER_ONLY +# include "exec/page-vary.h" +extern const TargetPageBits target_page; +#ifdef CONFIG_DEBUG_TCG +#define TARGET_PAGE_BITS_MIN ({ assert(target_page.decided); \ + target_page.bits_min; }) +#define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bits; }) +#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ + (int)target_page.mask; }) +#else +#define TARGET_PAGE_BITS_MIN target_page.bits_min +#define TARGET_PAGE_BITS target_page.bits +#define TARGET_PAGE_MASK ((int)target_page.mask) +#endif +#define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) +#define TARGET_PAGE_ALIGN (addr) ROUND_UP((addr), TARGET_PAGE_SIZE) +#endif +void cpu_exec_init_all (void );void cpu_exec_step_atomic (CPUState *cpu);
Signature · 1 line
2.43.0
Re: [RFC PATCH 03/34] exec: [PAGE_VARY] Move TARGET_PAGE_BITS_VARY to common header
Quoted 4 lines · Anton Johansson
We need to be able access the variable TARGET_PAGE_* macros in a target-independent manner.
Signed-off-by Anton Johansson <[email protected]>
I think you should pull all of these macros into a separate header. The split here is a bit confusing.
r~
RFC PATCH 4/34 exec: [PAGE_VARY] Unpoison TARGET_PAGE_* macros for system mode
In reply to Anton Johansson viaTARGET_PAGE_* are now target-independent for softmmu targets, and can safely be accessed common code.
--- include/exec/poison.h | 2 ++ 1 file changed, 2 insertions(+)
include/exec/poison.h +2 -0
@@ -46,10 +46,12 @@#pragma GCC poison TARGET_FMT_ld#pragma GCC poison TARGET_FMT_lu +#ifdef CONFIG_USER_ONLY #pragma GCC poison TARGET_PAGE_SIZE#pragma GCC poison TARGET_PAGE_MASK#pragma GCC poison TARGET_PAGE_BITS#pragma GCC poison TARGET_PAGE_ALIGN +#endif #pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB
Signature · 1 line
2.43.0
Re: [RFC PATCH 04/34] exec: [PAGE_VARY] Unpoison TARGET_PAGE_* macros for system mode
Quoted 4 lines · Anton Johansson
TARGET_PAGE_* are now target-independent for softmmu targets, and can safely be accessed common code.
Signed-off-by Anton Johansson <[email protected]>
r~
RFC PATCH 5/34 target/tricore: [VADDR] Use target_ulong for EA
In reply to Anton Johansson viaPrepares target for typedef'ing abi_ptr to vaddr. Fixes sign extension bug that would result from abi_ptr being unsigned in the future.
Necessary to make memory access function signatures target agnostic.
--- target/tricore/op_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/tricore/op_helper.c +4 -4
@@ -2395,7 +2395,7 @@ static bool cdc_zero(target_ulong *psw)return count ==0 ; } -static void save_context_upper (CPUTriCoreState *env,int ea) +static void save_context_upper (CPUTriCoreState *env,target_ulong ea) {cpu_stl_data (env, ea, env->PCXI);cpu_stl_data (env, ea+4 ,psw_read (env));
@@ -2415,7 +2415,7 @@ static void save_context_upper(CPUTriCoreState *env, int ea)cpu_stl_data (env, ea+60 , env->gpr_d[15 ]); } -static void save_context_lower (CPUTriCoreState *env,int ea) +static void save_context_lower (CPUTriCoreState *env,target_ulong ea) {cpu_stl_data (env, ea, env->PCXI);cpu_stl_data (env, ea+4 , env->gpr_a[11 ]);
@@ -2435,7 +2435,7 @@ static void save_context_lower(CPUTriCoreState *env, int ea)cpu_stl_data (env, ea+60 , env->gpr_d[7 ]); } -static void restore_context_upper (CPUTriCoreState *env,int ea, +static void restore_context_upper (CPUTriCoreState *env,target_ulong ea,target_ulong *new_PCXI,target_ulong *new_PSW) { *new_PCXI =cpu_ldl_data (env, ea);
@@ -2456,7 +2456,7 @@ static void restore_context_upper(CPUTriCoreState *env, int ea, env->gpr_d[15 ] =cpu_ldl_data (env, ea+60 ); } -static void restore_context_lower (CPUTriCoreState *env,int ea, +static void restore_context_lower (CPUTriCoreState *env,target_ulong ea,target_ulong *ra,target_ulong *pcxi) { *pcxi =cpu_ldl_data (env, ea);
Signature · 1 line
2.43.0
Re: [RFC PATCH 05/34] target/tricore: [VADDR] Use target_ulong for EA
Quoted 9 lines · Anton Johansson
Prepares target for typedef'ing
abi_ptrto vaddr. Fixes sign extension bug that would result fromabi_ptrbeing unsigned in the future.Necessary to make memory access function signatures target agnostic.
Signed-off-by Anton Johansson<[email protected]>--- target/tricore/op_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
r~
Re: [RFC PATCH 05/34] target/tricore: [VADDR] Use target_ulong for EA
In reply to Anton Johansson viaQuoted 9 lines · Anton Johansson
Prepares target for typedef'ing
abi_ptrto vaddr. Fixes sign extension bug that would result fromabi_ptrbeing unsigned in the future.Necessary to make memory access function signatures target agnostic.
Signed-off-by Anton Johansson <[email protected]>--- target/tricore/op_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
This has been fixed on master since
commit ceada000846b0cd81c578b1da9f76d0c59536654
Author: Bastian Koppelmann <[email protected]> Date: Wed Sep 13 12:53:26 2023 +0200
target/tricore: Change effective address (ea) to target_ulong
I'm confused about the branch on which you're working...
r~
Quoted 41 lines
target/tricore/op_helper.c +4
-4@@ -2395,7 +2395,7 @@ static bool cdc_zero(target_ulong *psw)return count ==0 ; } -static void save_context_upper (CPUTriCoreState *env,int ea) +static void save_context_upper (CPUTriCoreState *env,target_ulong ea) {cpu_stl_data (env, ea, env->PCXI);cpu_stl_data (env, ea+4 ,psw_read (env));@@ -2415,7 +2415,7 @@ static void save_context_upper(CPUTriCoreState *env, int ea)cpu_stl_data (env, ea+60 , env->gpr_d[15 ]); } -static void save_context_lower (CPUTriCoreState *env,int ea) +static void save_context_lower (CPUTriCoreState *env,target_ulong ea) {cpu_stl_data (env, ea, env->PCXI);cpu_stl_data (env, ea+4 , env->gpr_a[11 ]);@@ -2435,7 +2435,7 @@ static void save_context_lower(CPUTriCoreState *env, int ea)cpu_stl_data (env, ea+60 , env->gpr_d[7 ]); } -static void restore_context_upper (CPUTriCoreState *env,int ea, +static void restore_context_upper (CPUTriCoreState *env,target_ulong ea,target_ulong *new_PCXI,target_ulong *new_PSW) { *new_PCXI =cpu_ldl_data (env, ea);@@ -2456,7 +2456,7 @@ static void restore_context_upper(CPUTriCoreState *env, int ea, env->gpr_d[15 ] =cpu_ldl_data (env, ea+60 ); } -static void restore_context_lower (CPUTriCoreState *env,int ea, +static void restore_context_lower (CPUTriCoreState *env,target_ulong ea,target_ulong *ra,target_ulong *pcxi) { *pcxi =cpu_ldl_data (env, ea);
RFC PATCH 6/34 exec: [VADDR] Move vaddr defines to separate file
In reply to Anton Johansson viaNeeded 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.]
--- include/exec/cpu-common.h | 12 ------------ include/exec/vaddr.h | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 include/exec/vaddr.h
include/exec/cpu-common.h +0 -12
@@ -14,18 +14,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 -/** * Variable page size macros *
include/exec/vaddr.h new file +18 -0
@@ -0,0 +1,18 @@ +/* Define vaddr if it exists. */ + +#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.43.0
Re: [RFC PATCH 06/34] exec: [VADDR] Move vaddr defines to separate file
include/exec/vaddr.h line 1
Quoted 3 lines · Anton Johansson
+++
b/include/exec/vaddr.hinclude/exec/vaddr.h new file +1
-0@@ -0,0 +1,18 @@ +/* Define vaddr if it exists. */
s/if it exists//
Need a license line here. Otherwise.
r~
Re: [RFC PATCH 06/34] exec: [VADDR] Move vaddr defines to separate file
In reply to Anton Johansson viaQuoted 11 lines · Anton Johansson
include/exec/cpu-common.h +0
-5@@ -14,18 +14,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 ;
include/exec/cpu-common.h line 19
Quoted 10 lines
include/exec/cpu-common.h +0
-7-#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 -/** * Variable page size macros *
This patch does not compile standalone, because the new header isn't included here.
r~
Re: [RFC PATCH 06/34] exec: [VADDR] Move vaddr defines to separate file
Quoted 15 lines · Richard Henderson
Quoted 14 lines · Anton Johansson
include/exec/cpu-common.h +0
-9@@ -14,18 +14,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
Quoted 8 lines
include/exec/cpu-common.h line 19
Quoted 6 lines
include/exec/cpu-common.h +0
-3-#define VADDR_PRIX PRIX64 -#define VADDR_MAX UINT64_MAX - /*** Variable page size macros * This patch does not compile standalone, because the new header isn't included here.
Queued with fixes.
r~
RFC PATCH 7/34 hw/core: [VADDR] Include vaddr.h from cpu.h
In reply to Anton Johansson viacpu-common.h is only needed for vaddr
--- 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.43.0
Re: [RFC PATCH 07/34] hw/core: [VADDR] Include vaddr.h from cpu.h
Quoted 6 lines · Anton Johansson
cpu-common.his only needed for vaddrSigned-off-by Anton Johansson <[email protected]>--- include/hw/core/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Richard Henderson
AppliedRe: [RFC PATCH 07/34] hw/core: [VADDR] Include vaddr.h from cpu.h
In reply to Anton Johansson viaQuoted 6 lines · Anton Johansson
cpu-common.his only needed for vaddrSigned-off-by Anton Johansson <[email protected]>--- include/hw/core/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Queued, thanks.
r~
RFC PATCH 8/34 target: [VADDR] Use vaddr in gen_intermediate_code
In reply to Anton Johansson viaMakes gen_intermediate_code() signature target agnostic so the function can be called from accel/tcg/translate-all.c without target specifics.
--- 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/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
@@ -9682,7 +9682,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
@@ -4273,7 +4273,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
@@ -7084,7 +7084,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/translate.c +1 -1
@@ -326,7 +326,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
@@ -6105,7 +6105,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
@@ -15555,7 +15555,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
@@ -1286,7 +1286,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
@@ -2271,7 +2271,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
@@ -6528,7 +6528,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
@@ -2300,7 +2300,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
@@ -5709,7 +5709,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
@@ -8448,7 +8448,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
@@ -1256,7 +1256,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.43.0
Re: [RFC PATCH 08/34] target: [VADDR] Use vaddr in gen_intermediate_code
Quoted 20 lines · Anton Johansson
Makes
gen_intermediate_code()signature target agnostic so the function can be called fromaccel/tcg/translate-all.cwithout target specifics.Signed-off-by Anton Johansson<[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/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 +-
Quoted 8 lines
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(-)
r~
Richard Henderson
AppliedRe: [RFC PATCH 08/34] target: [VADDR] Use vaddr in gen_intermediate_code
In reply to Anton Johansson viaQuoted 20 lines · Anton Johansson
Makes
gen_intermediate_code()signature target agnostic so the function can be called fromaccel/tcg/translate-all.cwithout target specifics.Signed-off-by Anton Johansson<[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/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 +-
Quoted 8 lines
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(-)
Queued, thanks.
r~
RFC PATCH 9/34 exec: [VADDR] Use vaddr in DisasContextBase for virtual addresses
In reply to Anton Johansson viaUpdates target/ QEMU_LOG macros to use VADDR_PRIx for printing updated DisasContextBase fields.
--- 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
@@ -77,8 +77,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;
@@ -231,7 +231,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
@@ -1474,7 +1474,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 ;
@@ -11275,8 +11275,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.43.0
Re: [RFC PATCH 09/34] exec: [VADDR] Use vaddr in DisasContextBase for virtual addresses
Quoted 11 lines · Anton Johansson
Updates target/
QEMU_LOGmacros to useVADDR_PRIxfor printing updated DisasContextBase fields.Signed-off-by Anton Johansson<[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(-)
r~
Richard Henderson
AppliedRe: [RFC PATCH 09/34] exec: [VADDR] Use vaddr in DisasContextBase for virtual addresses
In reply to Anton Johansson viaQuoted 11 lines · Anton Johansson
Updates target/
QEMU_LOGmacros to useVADDR_PRIxfor printing updated DisasContextBase fields.Signed-off-by Anton Johansson <[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(-)
Queued, thanks.
r~
RFC PATCH 10/34 exec: [VADDR] typedef abi_ptr to vaddr
In reply to Anton Johansson via--- 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.43.0
Re: [RFC PATCH 10/34] exec: [VADDR] typedef abi_ptr to vaddr
Quoted 10 lines · Anton Johansson
Signed-off-by Anton Johansson <[email protected]>--- include/exec/cpu_ldst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/exec/cpu_ldst.h +0
-0
include/exec/cpu_ldst.h static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len) · line 128
Quoted 10 lines
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);
r~
Richard Henderson
AppliedRe: [RFC PATCH 10/34] exec: [VADDR] typedef abi_ptr to vaddr
In reply to Anton Johansson viaQuoted 10 lines · Anton Johansson
Signed-off-by Anton Johansson <[email protected]>--- include/exec/cpu_ldst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/exec/cpu_ldst.h +0
-0
include/exec/cpu_ldst.h static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len) · line 128
Quoted 10 lines
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);
Queued, thanks.
r~
RFC PATCH 11/34 Squash of header code shuffling
In reply to Anton Johansson viaThis commit squashes header changes that are likely to change during rebase. Code is moved from common to specific headers, or vice versa to ensure that no target-specific code is pulled by accel/tcg via headers.
--- accel/tcg/tb-hash.h | 4 +- hw/s390x/s390-virtio-hcall.h | 2 + include/exec/cpu-all.h | 1 + include/exec/cpu-common.h | 2 + include/exec/cpu_ldst-target.h | 52 +++++ include/exec/cpu_ldst.h | 60 ++---- include/exec/exec-all.h | 347 +------------------------------ include/exec/exec-common.h | 367 +++++++++++++++++++++++++++++++++ include/exec/memory-internal.h | 2 +- include/exec/ram_addr.h | 3 +- include/qemu/plugin-memory.h | 1 - accel/tcg/cpu-exec.c | 1 + plugins/core.c | 1 + target/arm/cpu.c | 1 + target/sparc/gdbstub.c | 3 + 15 files changed, 459 insertions(+), 388 deletions(-) create mode 100644 include/exec/cpu_ldst-target.h create mode 100644 include/exec/exec-common.h
accel/tcg/tb-hash.h +2 -2
@@ -20,8 +20,8 @@#ifndef EXEC_TB_HASH_H #define EXEC_TB_HASH_H -#include "exec/cpu-defs.h" -#include "exec/exec-all.h" +#include "exec/exec-common.h" +#include "exec/translation-block.h" #include "qemu/xxhash.h" #include "tb-jmp-cache.h"
hw/s390x/s390-virtio-hcall.h +2 -0
@@ -12,6 +12,8 @@#ifndef HW_S390_VIRTIO_HCALL_H #define HW_S390_VIRTIO_HCALL_H +#include "qemu/osdep.h" +#include "cpu.h" #include "standard-headers/asm-s390/virtio-ccw.h" /* The only thing that we need from the old kvm_virtio.h file */
include/exec/cpu-all.h +1 -0
@@ -20,6 +20,7 @@#define CPU_ALL_H #include "exec/cpu-common.h" +#include "exec/cpu-defs.h" #include "exec/memory.h" #include "exec/tswap.h" #include "qemu/thread.h"
include/exec/cpu-common.h +2 -0
@@ -3,6 +3,8 @@/* CPU interfaces that are target independent. */ +#include "qemu/osdep.h" +#include "hw/core/cpu.h" #ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" #endif
include/exec/cpu_ldst-target.h new file +52 -0
52 lines not on this page · raw message
include/exec/cpu_ldst.h +14 -46
73 lines not on this page · raw message
include/exec/exec-all.h +10 -337
362 lines not on this page · raw message
include/exec/exec-common.h new file +367 -0
367 lines not on this page · raw message
include/exec/memory-internal.h +1 -1
@@ -20,7 +20,7 @@#ifndef MEMORY_INTERNAL_H #define MEMORY_INTERNAL_H -#include "cpu.h" +#include "exec/memory.h" #ifndef CONFIG_USER_ONLY static inline AddressSpaceDispatch *flatview_to_dispatch (FlatView *fv)
include/exec/ram_addr.h +2 -1
@@ -20,11 +20,12 @@#define RAM_ADDR_H #ifndef CONFIG_USER_ONLY -#include "cpu.h" #include "sysemu/xen.h" #include "sysemu/tcg.h" #include "exec/ramlist.h" #include "exec/ramblock.h" +#include "exec/memory.h" +#include "qemu/bitmap.h" extern uint64_t total_dirty_pages;
include/qemu/plugin-memory.h +0 -1
@@ -9,7 +9,6 @@#ifndef PLUGIN_MEMORY_H #define PLUGIN_MEMORY_H -#include "exec/cpu-defs.h" #include "exec/hwaddr.h" struct qemu_plugin_hwaddr {
accel/tcg/cpu-exec.c +1 -0
@@ -34,6 +34,7 @@#include "hw/i386/apic.h" #endif #include "sysemu/cpus.h" +#include "cpu.h" #include "exec/cpu-all.h" #include "sysemu/cpu-timers.h" #include "exec/replay-core.h"
plugins/core.c +1 -0
@@ -24,6 +24,7 @@#include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/cpu-defs.h" #include "exec/tb-flush.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h"
target/arm/cpu.c +1 -0
@@ -32,6 +32,7 @@#endif /* CONFIG_TCG */ #include "internals.h" #include "exec/exec-all.h" +#include "exec/cpu-all.h" #include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY )#include "hw/loader.h"
target/sparc/gdbstub.c +3 -0
@@ -20,6 +20,9 @@#include "qemu/osdep.h" #include "cpu.h" #include "gdbstub/helpers.h" +#if defined(TARGET_ABI32 ) && defined(CONFIG_USER_ONLY ) +#include "exec/user/abitypes.h" +#endif #ifdef TARGET_ABI32 #define gdb_get_rega (buf, val) gdb_get_reg32(buf, val)
Signature · 1 line
2.43.0
RFC PATCH 12/34 target: Uninline cpu_mmu_index()
In reply to Anton Johansson viaUninlines the target-defined cpu_mmu_index() function by moving its definition to target/*/cpu.c. This allows for compiling memory access functions in accel/tcg/cputlb.c without having to know target specifics.
--- include/exec/cpu-common.h | 10 ++++++++++ target/alpha/cpu.h | 9 --------- target/arm/cpu.h | 13 ------------- target/avr/cpu.h | 6 ------ target/cris/cpu.h | 4 ---- target/hexagon/cpu.h | 9 --------- target/hppa/cpu.h | 12 ------------ target/i386/cpu.h | 7 ------- target/loongarch/cpu.h | 12 ------------ target/m68k/cpu.h | 4 ---- target/microblaze/cpu.h | 15 --------------- target/mips/cpu.h | 14 +------------- target/nios2/cpu.h | 6 ------ target/openrisc/cpu.h | 12 ------------ target/ppc/cpu.h | 8 -------- target/riscv/cpu.h | 2 -- target/rx/cpu.h | 5 ----- target/s390x/cpu.h | 31 ------------------------------- target/sh4/cpu.h | 10 ---------- target/sparc/cpu.h | 28 ---------------------------- target/tricore/cpu.h | 5 ----- target/xtensa/cpu.h | 5 ----- target/alpha/cpu.c | 8 ++++++++ target/arm/cpu.c | 5 +++++ target/avr/cpu.c | 5 +++++ target/cris/cpu.c | 4 ++++ target/hexagon/cpu.c | 9 +++++++++ target/hppa/cpu.c | 12 ++++++++++++ target/i386/cpu.c | 7 +++++++ target/loongarch/cpu.c | 12 ++++++++++++ target/m68k/cpu.c | 5 +++++ target/microblaze/cpu.c | 16 ++++++++++++++++ target/mips/cpu.c | 14 ++++++++++++++ target/nios2/cpu.c | 6 ++++++ target/openrisc/cpu.c | 12 ++++++++++++ target/ppc/cpu.c | 9 +++++++++ target/riscv/cpu_helper.c | 2 +- target/rx/cpu.c | 5 +++++ target/s390x/cpu.c | 31 +++++++++++++++++++++++++++++++ target/sh4/cpu.c | 13 +++++++++++++ target/sparc/cpu.c | 28 ++++++++++++++++++++++++++++ target/tricore/cpu.c | 5 +++++ target/xtensa/cpu.c | 4 ++++ 43 files changed, 222 insertions(+), 217 deletions(-)
include/exec/cpu-common.h +10 -0
@@ -60,6 +60,16 @@ void cpu_list_lock(void);void cpu_list_unlock (void );unsigned int cpu_list_generation_id_get (void ); +/** +* cpu_mmu_index: +* @env: The cpu environment +* @ifetch: True for code access, false for data access. +* +* Return the core mmu index for the current translation regime. +* This function is used by generic TCG code paths. +*/ +int cpu_mmu_index (CPUArchState *env,bool ifetch); +void tcg_flush_softmmu_tlb (CPUState *cs);void tcg_flush_jmp_cache (CPUState *cs);
target/alpha/cpu.h +0 -9
@@ -380,15 +380,6 @@ enum {#define TB_FLAG_UNALIGN (1u << 1) -static inline int cpu_mmu_index (CPUAlphaState *env,bool ifetch) -{ -int ret = env->flags &ENV_FLAG_PS_USER ?MMU_USER_IDX :MMU_KERNEL_IDX ; -if (env->flags &ENV_FLAG_PAL_MODE ) { - ret =MMU_KERNEL_IDX ; - } -return ret; -} -enum {IR_V0 =0 ,IR_T0 =1 ,
target/arm/cpu.h +0 -13
@@ -3167,19 +3167,6 @@ FIELD(TBFLAG_A64, NAA, 30, 1)#define EX_TBFLAG_M32 (IN ,WHICH ) FIELD_EX32(IN.flags2, TBFLAG_M32, WHICH)#define EX_TBFLAG_AM32 (IN ,WHICH ) FIELD_EX32(IN.flags2, TBFLAG_AM32, WHICH) -/** -* cpu_mmu_index: -* @env: The cpu environment -* @ifetch: True for code access, false for data access. -* -* Return the core mmu index for the current translation regime. -* This function is used by generic TCG code paths. -*/ -static inline int cpu_mmu_index (CPUARMState *env,bool ifetch) -{ -return EX_TBFLAG_ANY (env->hflags,MMUIDX ); -} -/** * sve_vq * @env: the cpu context
target/avr/cpu.h +0 -6
@@ -172,12 +172,6 @@ static inline void set_avr_feature(CPUAVRState *env, int feature) }#define cpu_list avr_cpu_list -#define cpu_mmu_index avr_cpu_mmu_index - -static inline int avr_cpu_mmu_index (CPUAVRState *env,bool ifetch) -{ -return ifetch ?MMU_CODE_IDX :MMU_DATA_IDX ; -}void avr_cpu_tcg_init (void );
target/cris/cpu.h +0 -4
@@ -248,10 +248,6 @@ enum {/* MMU modes definitions */ #define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUCRISState *env,bool ifetch) -{ -return !!(env->pregs[PR_CCS ] &U_FLAG ); -}/* Support function regs. */ #define SFR_RW_GC_CFG 0][0
target/hexagon/cpu.h +0 -9
@@ -165,15 +165,6 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc, *flags = hex_flags; } -static inline int cpu_mmu_index (CPUHexagonState *env,bool ifetch) -{ -#ifdef CONFIG_USER_ONLY -return MMU_USER_IDX ; -#else -#error System mode not supported on Hexagon yet -#endif -} -typedef HexagonCPU ArchCPU ;void hexagon_translate_init (void );
target/hppa/cpu.h +0 -12
@@ -237,18 +237,6 @@ struct ArchCPU {#include "exec/cpu-all.h" -static inline int cpu_mmu_index (CPUHPPAState *env,bool ifetch) -{ -#ifdef CONFIG_USER_ONLY -return MMU_USER_IDX ; -#else -if (env->psw & (ifetch ?PSW_C :PSW_D )) { -return PRIV_TO_MMU_IDX (env->iaoq_f &3 ); - } -return MMU_PHYS_IDX ;/* mmu disabled */ -#endif -} -void hppa_translate_init (void );#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
target/i386/cpu.h +0 -7
@@ -2259,13 +2259,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);#define MMU_NESTED_IDX 3#define MMU_PHYS_IDX 4 -static inline int cpu_mmu_index (CPUX86State *env,bool ifetch) -{ -return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : - (!(env->hflags &HF_SMAP_MASK ) || (env->eflags &AC_MASK )) - ?MMU_KNOSMAP_IDX :MMU_KSMAP_IDX ; -} -static inline int cpu_mmu_index_kernel (CPUX86State *env) { return !(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP_IDX :
target/loongarch/cpu.h +0 -12
@@ -415,18 +415,6 @@ struct LoongArchCPUClass {#define MMU_IDX_USER MMU_PLV_USER#define MMU_IDX_DA 4 -static inline int cpu_mmu_index (CPULoongArchState *env,bool ifetch) -{ -#ifdef CONFIG_USER_ONLY -return MMU_IDX_USER ; -#else -if (FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PG )) { -return FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV ); - } -return MMU_IDX_DA ; -#endif -} -static inline bool is_la64 (CPULoongArchState *env) {return FIELD_EX32 (env->cpucfg[1 ],CPUCFG1 ,ARCH ) ==CPUCFG1_ARCH_LA64 ;
target/m68k/cpu.h +0 -4
@@ -572,10 +572,6 @@ enum {/* MMU modes definitions */ #define MMU_KERNEL_IDX 0#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUM68KState *env,bool ifetch) -{ -return (env->sr &SR_S ) ==0 ?1 :0 ; -} bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx,
target/microblaze/cpu.h +0 -15
@@ -423,21 +423,6 @@ void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, MemTxResult response, uintptr_t retaddr);#endif -static inline int cpu_mmu_index (CPUMBState *env,bool ifetch) -{ -MicroBlazeCPU *cpu =env_archcpu (env); - -/* Are we in nommu mode?. */ -if (!(env->msr &MSR_VM ) || !cpu->cfg.use_mmu) { -return MMU_NOMMU_IDX ; - } - -if (env->msr &MSR_UM ) { -return MMU_USER_IDX ; - } -return MMU_KERNEL_IDX ; -} -#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_mb_cpu;#endif
target/mips/cpu.h +1 -13
@@ -1233,19 +1233,7 @@ uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);*/ #define MMU_USER_IDX 2 -static inline int hflags_mmu_index (uint32_t hflags) -{ -if (hflags &MIPS_HFLAG_ERL ) { -return 3 ;/* ERL */ - }else { -return hflags &MIPS_HFLAG_KSU ; - } -} - -static inline int cpu_mmu_index (CPUMIPSState *env,bool ifetch) -{ -return hflags_mmu_index (env->hflags); -} +int hflags_mmu_index (uint32_t hflags);#include "exec/cpu-all.h"
target/nios2/cpu.h +0 -6
@@ -279,12 +279,6 @@ void do_nios2_semihosting(CPUNios2State *env);#define MMU_SUPERVISOR_IDX 0#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUNios2State *env,bool ifetch) -{ -return (env->ctrl[CR_STATUS ] &CR_STATUS_U ) ?MMU_USER_IDX : -MMU_SUPERVISOR_IDX ; -} -#ifndef CONFIG_USER_ONLY hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
target/openrisc/cpu.h +0 -12
@@ -376,18 +376,6 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, vaddr *pc, | (env->sr & (SR_SM | SR_DME | SR_IME | SR_OVE)); } -static inline int cpu_mmu_index (CPUOpenRISCState *env,bool ifetch) -{ -int ret =MMU_NOMMU_IDX ;/* mmu is disabled */ - -if (env->sr & (ifetch ?SR_IME :SR_DME )) { -/* The mmu is enabled; test supervisor state. */ - ret = env->sr &SR_SM ?MMU_SUPERVISOR_IDX :MMU_USER_IDX ; - } - -return ret; -} -static inline uint32_t cpu_get_sr (const CPUOpenRISCState *env) { return (env->sr
target/ppc/cpu.h +0 -8
@@ -1483,14 +1483,6 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);/* MMU modes definitions */ #define MMU_USER_IDX 0 -static inline int cpu_mmu_index (CPUPPCState *env,bool ifetch) -{ -#ifdef CONFIG_USER_ONLY -return MMU_USER_IDX ; -#else -return (env->hflags >> (ifetch ?HFLAGS_IMMU_IDX :HFLAGS_DMMU_IDX )) &7 ; -#endif -}/* Compatibility modes */ #if defined(TARGET_PPC64 )
target/riscv/cpu.h +0 -2
@@ -434,7 +434,6 @@ target_ulong riscv_cpu_get_geilen(CPURISCVState *env);void riscv_cpu_set_geilen (CPURISCVState *env,target_ulong geilen);bool riscv_cpu_vector_enabled (CPURISCVState *env);void riscv_cpu_set_virt_enabled (CPURISCVState *env,bool enable); -int riscv_cpu_mmu_index (CPURISCVState *env,bool ifetch); G_NORETURN void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
@@ -446,7 +445,6 @@ void riscv_cpu_list(void);void riscv_cpu_validate_set_extensions (RISCVCPU *cpu,Error **errp);#define cpu_list riscv_cpu_list -#define cpu_mmu_index riscv_cpu_mmu_index#ifndef CONFIG_USER_ONLY void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
target/rx/cpu.h +0 -5
@@ -151,11 +151,6 @@ static inline void cpu_get_tb_cpu_state(CPURXState *env, vaddr *pc, *flags =FIELD_DP32 (*flags,PSW ,U , env->psw_u); } -static inline int cpu_mmu_index (CPURXState *env,bool ifetch) -{ -return 0 ; -} -static inline uint32_t rx_cpu_pack_psw (CPURXState *env) {uint32_t psw =0 ;
target/s390x/cpu.h +0 -31
@@ -348,37 +348,6 @@ extern const VMStateDescription vmstate_s390_cpu;#define MMU_HOME_IDX 2#define MMU_REAL_IDX 3 -static inline int cpu_mmu_index (CPUS390XState *env,bool ifetch) -{ -#ifdef CONFIG_USER_ONLY -return MMU_USER_IDX ; -#else -if (!(env->psw.mask &PSW_MASK_DAT )) { -return MMU_REAL_IDX ; - } - -if (ifetch) { -if ((env->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_HOME ) { -return MMU_HOME_IDX ; - } -return MMU_PRIMARY_IDX ; - } - -switch (env->psw.mask &PSW_MASK_ASC ) { -case PSW_ASC_PRIMARY : -return MMU_PRIMARY_IDX ; -case PSW_ASC_SECONDARY : -return MMU_SECONDARY_IDX ; -case PSW_ASC_HOME : -return MMU_HOME_IDX ; -case PSW_ASC_ACCREG : -/* Fallthrough: access register mode is not yet supported */ -default : -abort (); - } -#endif -} -static inline void cpu_get_tb_cpu_state (CPUS390XState *env,vaddr *pc,uint64_t *cs_base,uint32_t *flags) {
target/sh4/cpu.h +0 -10
@@ -260,16 +260,6 @@ void cpu_load_tlb(CPUSH4State * env);/* MMU modes definitions */ #define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUSH4State *env,bool ifetch) -{ -/* The instruction in a RTE delay slot is fetched in privileged -mode, but executed in user mode. */ -if (ifetch && (env->flags &TB_FLAG_DELAY_SLOT_RTE )) { -return 0 ; - }else { -return (env->sr & (1u <<SR_MD )) ==0 ?1 :0 ; - } -}#include "exec/cpu-all.h"
target/sparc/cpu.h +0 -28
@@ -692,34 +692,6 @@ static inline int cpu_supervisor_mode(CPUSPARCState *env1) }#endif -static inline int cpu_mmu_index (CPUSPARCState *env,bool ifetch) -{ -#if defined(CONFIG_USER_ONLY ) -return MMU_USER_IDX ; -#elif !defined(TARGET_SPARC64 ) -if ((env->mmuregs[0 ] &MMU_E ) ==0 ) {/* MMU disabled */ -return MMU_PHYS_IDX ; - }else { -return env->psrs; - } -#else -/* IMMU or DMMU disabled. */ -if (ifetch - ? (env->lsu &IMMU_E ) ==0 || (env->pstate &PS_RED ) !=0 - : (env->lsu &DMMU_E ) ==0 ) { -return MMU_PHYS_IDX ; - }else if (cpu_hypervisor_mode (env)) { -return MMU_PHYS_IDX ; - }else if (env->tl >0 ) { -return MMU_NUCLEUS_IDX ; - }else if (cpu_supervisor_mode (env)) { -return MMU_KERNEL_IDX ; - }else { -return MMU_USER_IDX ; - } -#endif -} -static inline int cpu_interrupts_enabled (CPUSPARCState *env1) {#if !defined (TARGET_SPARC64 )
target/tricore/cpu.h +0 -5
@@ -371,11 +371,6 @@ void tricore_cpu_list(void);#define cpu_list tricore_cpu_list -static inline int cpu_mmu_index (CPUTriCoreState *env,bool ifetch) -{ -return 0 ; -} -#include "exec/cpu-all.h" FIELD (TB_FLAGS ,PRIV ,0 ,2 )
target/xtensa/cpu.h +0 -5
@@ -700,11 +700,6 @@ static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)/* MMU modes definitions */ #define MMU_USER_IDX 3 -static inline int cpu_mmu_index (CPUXtensaState *env,bool ifetch) -{ -return xtensa_get_cring (env); -} -#define XTENSA_TBFLAG_RING_MASK 0x3#define XTENSA_TBFLAG_EXCM 0x4#define XTENSA_TBFLAG_LITBASE 0x8
target/alpha/cpu.c +8 -0
@@ -25,6 +25,14 @@#include "cpu.h" #include "exec/exec-all.h" +int cpu_mmu_index (CPUAlphaState *env,bool ifetch) +{ +int ret = env->flags &ENV_FLAG_PS_USER ?MMU_USER_IDX :MMU_KERNEL_IDX ; +if (env->flags &ENV_FLAG_PAL_MODE ) { + ret =MMU_KERNEL_IDX ; + } +return ret; +}static void alpha_cpu_set_pc (CPUState *cs,vaddr value) {
target/arm/cpu.c +5 -0
@@ -49,6 +49,11 @@#include "fpu/softfloat.h" #include "cpregs.h" +int cpu_mmu_index (CPUARMState *env,bool ifetch) +{ +return EX_TBFLAG_ANY (env->hflags,MMUIDX ); +} +static void arm_cpu_set_pc (CPUState *cs,vaddr value) {ARMCPU *cpu =ARM_CPU (cs);
target/avr/cpu.c +5 -0
@@ -26,6 +26,11 @@#include "disas/dis-asm.h" #include "tcg/debug-assert.h" +int cpu_mmu_index (CPUAVRState *env,bool ifetch) +{ +return ifetch ?MMU_CODE_IDX :MMU_DATA_IDX ; +} +static void avr_cpu_set_pc (CPUState *cs,vaddr value) {AVRCPU *cpu =AVR_CPU (cs);
target/cris/cpu.c +4 -0
@@ -27,6 +27,10 @@#include "cpu.h" #include "mmu.h" +int cpu_mmu_index (CPUCRISState *env,bool ifetch) +{ +return !!(env->pregs[PR_CCS ] &U_FLAG ); +}static void cris_cpu_set_pc (CPUState *cs,vaddr value) {
target/hexagon/cpu.c +9 -0
@@ -26,6 +26,15 @@#include "tcg/tcg.h" #include "exec/gdbstub.h" +int cpu_mmu_index (CPUHexagonState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +#error System mode not supported on Hexagon yet +#endif +} +static void hexagon_v67_cpu_init (Object *obj) { }static void hexagon_v68_cpu_init (Object *obj) { }static void hexagon_v69_cpu_init (Object *obj) { }
target/hppa/cpu.c +12 -0
@@ -28,6 +28,18 @@#include "fpu/softfloat.h" #include "tcg/tcg.h" +int cpu_mmu_index (CPUHPPAState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +if (env->psw & (ifetch ?PSW_C :PSW_D )) { +return PRIV_TO_MMU_IDX (env->iaoq_f &3 ); + } +return MMU_PHYS_IDX ;/* mmu disabled */ +#endif +} +static void hppa_cpu_set_pc (CPUState *cs,vaddr value) {HPPACPU *cpu =HPPA_CPU (cs);
target/i386/cpu.c +7 -0
@@ -45,6 +45,13 @@#include "disas/capstone.h" #include "cpu-internal.h" +int cpu_mmu_index (CPUX86State *env,bool ifetch) +{ +return (env->hflags &HF_CPL_MASK ) ==3 ?MMU_USER_IDX : + (!(env->hflags &HF_SMAP_MASK ) || (env->eflags &AC_MASK )) + ?MMU_KNOSMAP_IDX :MMU_KSMAP_IDX ; +} +static void x86_cpu_realizefn (DeviceState *dev,Error **errp);/* Helpers for building CPUID[2] descriptors: */
target/loongarch/cpu.c +12 -0
@@ -20,6 +20,18 @@#include "sysemu/reset.h" #include "tcg/tcg.h" +int cpu_mmu_index (CPULoongArchState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_IDX_USER ; +#else +if (FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PG )) { +return FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV ); + } +return MMU_IDX_DA ; +#endif +} +const char *const regnames[32 ] = {"r0" ,"r1" ,"r2" ,"r3" ,"r4" ,"r5" ,"r6" ,"r7" ,"r8" ,"r9" ,"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" ,
target/m68k/cpu.c +5 -0
@@ -24,6 +24,11 @@#include "migration/vmstate.h" #include "fpu/softfloat.h" +int cpu_mmu_index (CPUM68KState *env,bool ifetch) +{ +return (env->sr &SR_S ) ==0 ?1 :0 ; +} +static void m68k_cpu_set_pc (CPUState *cs,vaddr value) {M68kCPU *cpu =M68K_CPU (cs);
target/microblaze/cpu.c +16 -0
@@ -32,6 +32,22 @@#include "fpu/softfloat-helpers.h" #include "tcg/tcg.h" +int cpu_mmu_index (CPUMBState *env,bool ifetch) +{ +MicroBlazeCPU *cpu =env_archcpu (env); + +/* Are we in nommu mode?. */ +if (!(env->msr &MSR_VM ) || !cpu->cfg.use_mmu) { +return MMU_NOMMU_IDX ; + } + +if (env->msr &MSR_UM ) { +return MMU_USER_IDX ; + } +return MMU_KERNEL_IDX ; +} + + static const struct { const char *name; uint8_t version_id;
target/mips/cpu.c +14 -0
@@ -35,6 +35,20 @@#include "semihosting/semihost.h" #include "fpu_helper.h" +int hflags_mmu_index (uint32_t hflags) +{ +if (hflags &MIPS_HFLAG_ERL ) { +return 3 ;/* ERL */ + }else { +return hflags &MIPS_HFLAG_KSU ; + } +} + +int cpu_mmu_index (CPUMIPSState *env,bool ifetch) +{ +return hflags_mmu_index (env->hflags); +} +const char regnames[32 ][3 ] = {"r0" ,"at" ,"v0" ,"v1" ,"a0" ,"a1" ,"a2" ,"a3" ,"t0" ,"t1" ,"t2" ,"t3" ,"t4" ,"t5" ,"t6" ,"t7" ,
target/nios2/cpu.c +6 -0
@@ -26,6 +26,12 @@#include "gdbstub/helpers.h" #include "hw/qdev-properties.h" +int cpu_mmu_index (CPUNios2State *env,bool ifetch) +{ +return (env->ctrl[CR_STATUS ] &CR_STATUS_U ) ?MMU_USER_IDX : +MMU_SUPERVISOR_IDX ; +} +static void nios2_cpu_set_pc (CPUState *cs,vaddr value) {Nios2CPU *cpu =NIOS2_CPU (cs);
target/openrisc/cpu.c +12 -0
@@ -25,6 +25,18 @@#include "fpu/softfloat-helpers.h" #include "tcg/tcg.h" +int cpu_mmu_index (CPUOpenRISCState *env,bool ifetch) +{ +int ret =MMU_NOMMU_IDX ;/* mmu is disabled */ + +if (env->sr & (ifetch ?SR_IME :SR_DME )) { +/* The mmu is enabled; test supervisor state. */ + ret = env->sr &SR_SM ?MMU_SUPERVISOR_IDX :MMU_USER_IDX ; + } + +return ret; +} +static void openrisc_cpu_set_pc (CPUState *cs,vaddr value) {OpenRISCCPU *cpu =OPENRISC_CPU (cs);
target/ppc/cpu.c +9 -0
@@ -27,6 +27,15 @@#include "helper_regs.h" #include "sysemu/tcg.h" +int cpu_mmu_index (CPUPPCState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +return (env->hflags >> (ifetch ?HFLAGS_IMMU_IDX :HFLAGS_DMMU_IDX )) &7 ; +#endif +} +target_ulong cpu_read_xer (const CPUPPCState *env) {if (is_isa300 (env)) {
target/riscv/cpu_helper.c +1 -1
@@ -33,7 +33,7 @@#include "debug.h" #include "tcg/oversized-guest.h" -int riscv_cpu_mmu_index (CPURISCVState *env,bool ifetch) +int cpu_mmu_index (CPURISCVState *env,bool ifetch) {#ifdef CONFIG_USER_ONLY return 0 ;
target/rx/cpu.c +5 -0
@@ -26,6 +26,11 @@#include "fpu/softfloat.h" #include "tcg/debug-assert.h" +int cpu_mmu_index (CPURXState *env,bool ifetch) +{ +return 0 ; +} +static void rx_cpu_set_pc (CPUState *cs,vaddr value) {RXCPU *cpu =RX_CPU (cs);
target/s390x/cpu.c +31 -0
@@ -41,6 +41,37 @@#define CR0_RESET 0xE0UL#define CR14_RESET 0xC2000000UL; +int cpu_mmu_index (CPUS390XState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +if (!(env->psw.mask &PSW_MASK_DAT )) { +return MMU_REAL_IDX ; + } + +if (ifetch) { +if ((env->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_HOME ) { +return MMU_HOME_IDX ; + } +return MMU_PRIMARY_IDX ; + } + +switch (env->psw.mask &PSW_MASK_ASC ) { +case PSW_ASC_PRIMARY : +return MMU_PRIMARY_IDX ; +case PSW_ASC_SECONDARY : +return MMU_SECONDARY_IDX ; +case PSW_ASC_HOME : +return MMU_HOME_IDX ; +case PSW_ASC_ACCREG : +/* Fallthrough: access register mode is not yet supported */ +default : +abort (); + } +#endif +} +#ifndef CONFIG_USER_ONLY static bool is_early_exception_psw (uint64_t mask,uint64_t addr) {
target/sh4/cpu.c +13 -0
@@ -28,6 +28,19 @@#include "fpu/softfloat-helpers.h" #include "tcg/tcg.h" +int cpu_mmu_index (CPUSH4State *env,bool ifetch) +{ +/* +* The instruction in a RTE delay slot is fetched in privileged +* mode, but executed in user mode. +*/ +if (ifetch && (env->flags &TB_FLAG_DELAY_SLOT_RTE )) { +return 0 ; + }else { +return (env->sr & (1u <<SR_MD )) ==0 ?1 :0 ; + } +} +static void superh_cpu_set_pc (CPUState *cs,vaddr value) {SuperHCPU *cpu =SUPERH_CPU (cs);
target/sparc/cpu.c +28 -0
@@ -29,6 +29,34 @@//#define DEBUG_FEATURES +int cpu_mmu_index (CPUSPARCState *env,bool ifetch) +{ +#if defined(CONFIG_USER_ONLY ) +return MMU_USER_IDX ; +#elif !defined(TARGET_SPARC64 ) +if ((env->mmuregs[0 ] &MMU_E ) ==0 ) {/* MMU disabled */ +return MMU_PHYS_IDX ; + }else { +return env->psrs; + } +#else +/* IMMU or DMMU disabled. */ +if (ifetch + ? (env->lsu &IMMU_E ) ==0 || (env->pstate &PS_RED ) !=0 + : (env->lsu &DMMU_E ) ==0 ) { +return MMU_PHYS_IDX ; + }else if (cpu_hypervisor_mode (env)) { +return MMU_PHYS_IDX ; + }else if (env->tl >0 ) { +return MMU_NUCLEUS_IDX ; + }else if (cpu_supervisor_mode (env)) { +return MMU_KERNEL_IDX ; + }else { +return MMU_USER_IDX ; + } +#endif +} +static void sparc_cpu_reset_hold (Object *obj) {CPUState *s =CPU (obj);
target/tricore/cpu.c +5 -0
@@ -24,6 +24,11 @@#include "qemu/error-report.h" #include "tcg/debug-assert.h" +int cpu_mmu_index (CPUTriCoreState *env,bool ifetch) +{ +return 0 ; +} +static inline void set_feature (CPUTriCoreState *env,int feature) { env->features |=1ULL << feature;
target/xtensa/cpu.c +4 -0
@@ -39,6 +39,10 @@#include "exec/memory.h" #endif +int cpu_mmu_index (CPUXtensaState *env,bool ifetch) +{ +return xtensa_get_cring (env); +}static void xtensa_cpu_set_pc (CPUState *cs,vaddr value) {
Signature · 1 line
2.43.0
Re: [RFC PATCH 12/34] target: Uninline cpu_mmu_index()
Quoted 4 lines · Anton Johansson
target/mips/cpu.h +0
-0@@ -1233,19 +1233,7 @@ uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);*/
target/mips/cpu.h uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env); · line 1243
Quoted 10 lines
target/mips/cpu.h +0
-8#define MMU_USER_IDX 2 -static inline int hflags_mmu_index (uint32_t hflags) -{ -if (hflags &MIPS_HFLAG_ERL ) { -return 3 ;/* ERL */ - }else { -return hflags &MIPS_HFLAG_KSU ; - } -}
Unrelated. All you need to move is...
target/mips/cpu.h uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env); · line 1248
Quoted 5 lines
target/mips/cpu.h +0
-5- -static inline int cpu_mmu_index (CPUMIPSState *env,bool ifetch) -{ -return hflags_mmu_index (env->hflags); -}
... this.
Otherwise,
r~
Richard Henderson
AppliedRe: [RFC PATCH 12/34] target: Uninline cpu_mmu_index()
In reply to Anton Johansson viaQuoted 6 lines · Anton Johansson
Uninlines the target-defined
cpu_mmu_index()function by moving its definition totarget/*/cpu.c. This allows for compiling memory access functions inaccel/tcg/cputlb.cwithout having to know target specifics.Signed-off-by Anton Johansson<[email protected]>---
Queued, thanks.
r~
RFC PATCH 13/34 target: Uninline cpu_get_tb_cpu_state()
In reply to Anton Johansson viaRequired to compile accel/tcg/translate-all.c once for softmmu targets. The function gets quite big for some targets so uninlining makes sense.
--- include/exec/cpu-common.h | 4 +++ target/alpha/cpu.h | 11 ------- target/arm/cpu.h | 3 -- target/avr/cpu.h | 18 ----------- target/cris/cpu.h | 10 ------ target/hexagon/cpu.h | 12 ------- target/hppa/cpu.h | 43 ------------------------- target/i386/cpu.h | 9 ------ target/loongarch/cpu.h | 11 ------- target/m68k/cpu.h | 16 --------- target/microblaze/cpu.h | 8 ----- target/mips/cpu.h | 9 ------ target/nios2/cpu.h | 12 ------- target/openrisc/cpu.h | 10 ------ target/ppc/cpu.h | 13 -------- target/riscv/cpu.h | 3 -- target/rx/cpu.h | 9 ------ target/s390x/cpu.h | 22 ------------- target/sh4/cpu.h | 15 --------- target/sparc/cpu.h | 35 -------------------- target/tricore/cpu.h | 12 ------- target/xtensa/cpu.h | 68 --------------------------------------- target/alpha/cpu.c | 11 +++++++ target/avr/cpu.c | 18 +++++++++++ target/cris/cpu.c | 10 ++++++ target/hexagon/cpu.c | 12 +++++++ target/hppa/cpu.c | 47 +++++++++++++++++++++++++++ target/i386/cpu.c | 9 ++++++ target/loongarch/cpu.c | 11 +++++++ target/m68k/cpu.c | 16 +++++++++ target/microblaze/cpu.c | 7 ++++ target/mips/cpu.c | 9 ++++++ target/nios2/cpu.c | 12 +++++++ target/openrisc/cpu.c | 10 ++++++ target/ppc/cpu.c | 11 +++++++ target/rx/cpu.c | 9 ++++++ target/s390x/cpu.c | 24 ++++++++++++++ target/sh4/cpu.c | 15 +++++++++ target/sparc/cpu.c | 35 ++++++++++++++++++++ target/tricore/cpu.c | 12 +++++++ target/xtensa/cpu.c | 68 +++++++++++++++++++++++++++++++++++++++ 41 files changed, 350 insertions(+), 349 deletions(-)
include/exec/cpu-common.h +4 -0
@@ -70,6 +70,10 @@ unsigned int cpu_list_generation_id_get(void);*/ int cpu_mmu_index (CPUArchState *env,bool ifetch); +void cpu_get_tb_cpu_state (CPUArchState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *pflags); + +void tcg_flush_softmmu_tlb (CPUState *cs);void tcg_flush_jmp_cache (CPUState *cs);
target/alpha/cpu.h +0 -11
@@ -452,17 +452,6 @@ void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, MemTxResult response, uintptr_t retaddr);#endif -static inline void cpu_get_tb_cpu_state (CPUAlphaState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *pflags) -{ - *pc = env->pc; - *cs_base =0 ; - *pflags = env->flags &ENV_FLAG_TB_MASK ; -#ifdef CONFIG_USER_ONLY - *pflags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; -#endif -} -#ifdef CONFIG_USER_ONLY /* Copied from linux ieee_swcr_to_fpcr. */ static inline uint64_t alpha_ieee_swcr_to_fpcr (uint64_t swcr)
target/arm/cpu.h +0 -3
@@ -3212,9 +3212,6 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env) }#endif -void cpu_get_tb_cpu_state (CPUARMState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags); -enum {QEMU_PSCI_CONDUIT_DISABLED =0 ,QEMU_PSCI_CONDUIT_SMC =1 ,
target/avr/cpu.h +0 -18
@@ -183,24 +183,6 @@ enum { TB_FLAGS_SKIP = 2, }; -static inline void cpu_get_tb_cpu_state (CPUAVRState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *pflags) -{ -uint32_t flags =0 ; - - *pc = env->pc_w *2 ; - *cs_base =0 ; - -if (env->fullacc) { - flags |=TB_FLAGS_FULL_ACCESS ; - } -if (env->skip) { - flags |=TB_FLAGS_SKIP ; - } - - *pflags = flags; -} -static inline int cpu_interrupts_enabled (CPUAVRState *env) {return env->sregI !=0 ;
target/cris/cpu.h +0 -10
@@ -261,16 +261,6 @@ enum {#include "exec/cpu-all.h" -static inline void cpu_get_tb_cpu_state (CPUCRISState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = env->dslot | - (env->pregs[PR_CCS ] & (S_FLAG |P_FLAG |U_FLAG - |X_FLAG |PFIX_FLAG )); -} -#define cpu_list cris_cpu_listvoid cris_cpu_list (void );
target/hexagon/cpu.h +0 -12
@@ -153,18 +153,6 @@ struct ArchCPU { FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1) -static inline void cpu_get_tb_cpu_state (CPUHexagonState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ -uint32_t hex_flags =0 ; - *pc = env->gpr[HEX_REG_PC ]; - *cs_base =0 ; -if (*pc == env->gpr[HEX_REG_SA0 ]) { - hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,IS_TIGHT_LOOP ,1 ); - } - *flags = hex_flags; -} -typedef HexagonCPU ArchCPU ;void hexagon_translate_init (void );
target/hppa/cpu.h +0 -43
49 lines not on this page · raw message
target/i386/cpu.h +0 -9
@@ -2278,15 +2278,6 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env)#include "hw/i386/apic.h" #endif -static inline void cpu_get_tb_cpu_state (CPUX86State *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *cs_base = env->segs[R_CS ].base; - *pc = *cs_base + env->eip; - *flags = env->hflags | - (env->eflags & (IOPL_MASK |TF_MASK |RF_MASK |VM_MASK |AC_MASK )); -} -void do_cpu_init (X86CPU *cpu);#define MCE_INJECT_BROADCAST 1
target/loongarch/cpu.h +0 -11
@@ -449,17 +449,6 @@ static inline void set_pc(CPULoongArchState *env, uint64_t value)#define HW_FLAGS_EUEN_SXE 0x08#define HW_FLAGS_VA32 0x20 -static inline void cpu_get_tb_cpu_state (CPULoongArchState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = env->CSR_CRMD & (R_CSR_CRMD_PLV_MASK |R_CSR_CRMD_PG_MASK ); - *flags |=FIELD_EX64 (env->CSR_EUEN,CSR_EUEN ,FPE ) *HW_FLAGS_EUEN_FPE ; - *flags |=FIELD_EX64 (env->CSR_EUEN,CSR_EUEN ,SXE ) *HW_FLAGS_EUEN_SXE ; - *flags |=is_va32 (env) *HW_FLAGS_VA32 ; -} -void loongarch_cpu_list (void );#define cpu_list loongarch_cpu_list
target/m68k/cpu.h +0 -16
@@ -596,22 +596,6 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,#define TB_FLAGS_TRACE 16#define TB_FLAGS_TRACE_BIT (1 << TB_FLAGS_TRACE) -static inline void cpu_get_tb_cpu_state (CPUM68KState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = (env->macsr >>4 ) &TB_FLAGS_MACSR ; -if (env->sr &SR_S ) { - *flags |=TB_FLAGS_MSR_S ; - *flags |= (env->sfc << (TB_FLAGS_SFC_S_BIT -2 )) &TB_FLAGS_SFC_S ; - *flags |= (env->dfc << (TB_FLAGS_DFC_S_BIT -2 )) &TB_FLAGS_DFC_S ; - } -if (M68K_SR_TRACE (env->sr) ==M68K_SR_TRACE_ANY_INS ) { - *flags |=TB_FLAGS_TRACE ; - } -} -void dump_mmu (CPUM68KState *env);#endif
target/microblaze/cpu.h +0 -8
@@ -404,14 +404,6 @@ void mb_tcg_init(void);/* Ensure there is no overlap between the two masks. */ QEMU_BUILD_BUG_ON (MSR_TB_MASK &IFLAGS_TB_MASK ); -static inline void cpu_get_tb_cpu_state (CPUMBState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *flags = (env->iflags &IFLAGS_TB_MASK ) | (env->msr &MSR_TB_MASK ); - *cs_base = (*flags &IMM_FLAG ? env->imm :0 ); -} -#if !defined(CONFIG_USER_ONLY ) bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx,
target/mips/cpu.h +0 -9
@@ -1344,15 +1344,6 @@ void itc_reconfigure(struct MIPSITUState *tag);/* helper.c */ target_ulong exception_resume_pc (CPUMIPSState *env); -static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->active_tc.PC; - *cs_base =0 ; - *flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK | -MIPS_HFLAG_HWRENA_ULR ); -} -/** * mips_cpu_create_with_clock: * @typename: a MIPS CPU type.
target/nios2/cpu.h +0 -12
@@ -295,16 +295,4 @@ FIELD(TBFLAGS, CRS0, 0, 1) /* Set if CRS == 0. */ FIELD(TBFLAGS, U, 1, 1) /* Overlaps CR_STATUS_U */ FIELD(TBFLAGS, R0_0, 2, 1) /* Set if R0 == 0. */ -static inline void cpu_get_tb_cpu_state (CPUNios2State *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ -unsigned crs =FIELD_EX32 (env->ctrl[CR_STATUS ],CR_STATUS ,CRS ); - - *pc = env->pc; - *cs_base =0 ; - *flags = (env->ctrl[CR_STATUS ] &CR_STATUS_U ) - | (crs ?0 :R_TBFLAGS_CRS0_MASK ) - | (env->regs[0 ] ?0 :R_TBFLAGS_R0_0_MASK ); -} -#endif /* NIOS2_CPU_H */
target/openrisc/cpu.h +0 -10
@@ -366,16 +366,6 @@ static inline void cpu_set_gpr(CPUOpenRISCState *env, int i, uint32_t val) env->shadow_gpr[0 ][i] = val; } -static inline void cpu_get_tb_cpu_state (CPUOpenRISCState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags = (env->dflag ?TB_FLAGS_DFLAG :0 ) - | (cpu_get_gpr (env,0 ) ?0 :TB_FLAGS_R0_0 ) - | (env->sr & (SR_SM |SR_DME |SR_IME |SR_OVE )); -} -static inline uint32_t cpu_get_sr (const CPUOpenRISCState *env) { return (env->sr
target/ppc/cpu.h +0 -13
@@ -2511,19 +2511,6 @@ void cpu_write_xer(CPUPPCState *env, target_ulong xer);*/ #define is_book3s_arch2x (ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B)) -#ifdef CONFIG_DEBUG_TCG -void cpu_get_tb_cpu_state (CPUPPCState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags); -#else -static inline void cpu_get_tb_cpu_state (CPUPPCState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->nip; - *cs_base =0 ; - *flags = env->hflags; -} -#endif - G_NORETURN void raise_exception(CPUPPCState *env, uint32_t exception); G_NORETURN void raise_exception_ra(CPUPPCState *env, uint32_t exception,uintptr_t raddr);
target/riscv/cpu.h +0 -3
@@ -627,9 +627,6 @@ static inline uint32_t vext_get_vlmax(RISCVCPU *cpu, target_ulong vtype)return cpu->cfg.vlen >> (sew +3 - lmul); } -void cpu_get_tb_cpu_state (CPURISCVState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *pflags); -void riscv_cpu_update_mask (CPURISCVState *env); RISCVException riscv_csrrw(CPURISCVState *env, int csrno,
target/rx/cpu.h +0 -9
@@ -142,15 +142,6 @@ void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte);#define RX_CPU_IRQ 0#define RX_CPU_FIR 1 -static inline void cpu_get_tb_cpu_state (CPURXState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; - *cs_base =0 ; - *flags =FIELD_DP32 (0 ,PSW ,PM , env->psw_pm); - *flags =FIELD_DP32 (*flags,PSW ,U , env->psw_u); -} -static inline uint32_t rx_cpu_pack_psw (CPURXState *env) {uint32_t psw =0 ;
target/s390x/cpu.h +0 -22
@@ -348,28 +348,6 @@ extern const VMStateDescription vmstate_s390_cpu;#define MMU_HOME_IDX 2#define MMU_REAL_IDX 3 -static inline void cpu_get_tb_cpu_state (CPUS390XState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ -if (env->psw.addr &1 ) { -/* -* Instructions must be at even addresses. -* This needs to be checked before address translation. -*/ - env->int_pgm_ilen =2 ;/* see s390_cpu_tlb_fill() */ -tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,0 ); - } - *pc = env->psw.addr; - *cs_base = env->ex_value; - *flags = (env->psw.mask >>FLAG_MASK_PSW_SHIFT ) &FLAG_MASK_PSW ; -if (env->cregs[0 ] &CR0_AFP ) { - *flags |=FLAG_MASK_AFP ; - } -if (env->cregs[0 ] &CR0_VECTOR ) { - *flags |=FLAG_MASK_VECTOR ; - } -} -/* PER bits from control register 9 */ #define PER_CR9_EVENT_BRANCH 0x80000000#define PER_CR9_EVENT_IFETCH 0x40000000
target/sh4/cpu.h +0 -15
@@ -357,19 +357,4 @@ static inline void cpu_write_sr(CPUSH4State *env, target_ulong sr) env->sr = sr & ~((1u << SR_M) | (1u << SR_Q) | (1u << SR_T)); } -static inline void cpu_get_tb_cpu_state (CPUSH4State *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ - *pc = env->pc; -/* For a gUSA region, notice the end of the region. */ - *cs_base = env->flags &TB_FLAG_GUSA_MASK ? env->gregs[0 ] :0 ; - *flags = env->flags - | (env->fpscr &TB_FLAG_FPSCR_MASK ) - | (env->sr &TB_FLAG_SR_MASK ) - | (env->movcal_backup ?TB_FLAG_PENDING_MOVCA :0 );/* Bit 3 */ -#ifdef CONFIG_USER_ONLY - *flags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; -#endif -} -#endif /* SH4_CPU_H */
target/sparc/cpu.h +0 -35
@@ -733,41 +733,6 @@ trap_state* cpu_tsptr(CPUSPARCState* env);#define TB_FLAG_HYPER (1 << 7)#define TB_FLAG_ASI_SHIFT 24 -static inline void cpu_get_tb_cpu_state (CPUSPARCState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *pflags) -{ -uint32_t flags; - *pc = env->pc; - *cs_base = env->npc; - flags =cpu_mmu_index (env, false); -#ifndef CONFIG_USER_ONLY -if (cpu_supervisor_mode (env)) { - flags |=TB_FLAG_SUPER ; - } -#endif -#ifdef TARGET_SPARC64 -#ifndef CONFIG_USER_ONLY -if (cpu_hypervisor_mode (env)) { - flags |=TB_FLAG_HYPER ; - } -#endif -if (env->pstate &PS_AM ) { - flags |=TB_FLAG_AM_ENABLED ; - } -if ((env->def.features &CPU_FEATURE_FLOAT ) - && (env->pstate &PS_PEF ) - && (env->fprs &FPRS_FEF )) { - flags |=TB_FLAG_FPU_ENABLED ; - } - flags |= env->asi <<TB_FLAG_ASI_SHIFT ; -#else -if ((env->def.features &CPU_FEATURE_FLOAT ) && env->psref) { - flags |=TB_FLAG_FPU_ENABLED ; - } -#endif - *pflags = flags; -} -static inline bool tb_fpu_enabled (int tb_flags) {#if defined(CONFIG_USER_ONLY )
target/tricore/cpu.h +0 -12
@@ -378,18 +378,6 @@ FIELD(TB_FLAGS, PRIV, 0, 2)void cpu_state_reset (CPUTriCoreState *s);void tricore_tcg_init (void ); -static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,vaddr *pc, -uint64_t *cs_base,uint32_t *flags) -{ -uint32_t new_flags =0 ; - *pc = env->PC; - *cs_base =0 ; - - new_flags |=FIELD_DP32 (new_flags,TB_FLAGS ,PRIV , -extract32 (env->PSW,10 ,2 )); - *flags = new_flags; -} -#define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU#define TRICORE_CPU_TYPE_NAME (model) model TRICORE_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
target/xtensa/cpu.h +0 -68
74 lines not on this page · raw message
target/alpha/cpu.c +11 -0
@@ -34,6 +34,17 @@ int cpu_mmu_index(CPUAlphaState *env, bool ifetch)return ret; } +void cpu_get_tb_cpu_state (CPUAlphaState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *pflags) +{ + *pc = env->pc; + *cs_base =0 ; + *pflags = env->flags &ENV_FLAG_TB_MASK ; +#ifdef CONFIG_USER_ONLY + *pflags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; +#endif +} +static void alpha_cpu_set_pc (CPUState *cs,vaddr value) {AlphaCPU *cpu =ALPHA_CPU (cs);
target/avr/cpu.c +18 -0
@@ -31,6 +31,24 @@ int cpu_mmu_index(CPUAVRState *env, bool ifetch)return ifetch ?MMU_CODE_IDX :MMU_DATA_IDX ; } +void cpu_get_tb_cpu_state (CPUAVRState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *pflags) +{ +uint32_t flags =0 ; + + *pc = env->pc_w *2 ; + *cs_base =0 ; + +if (env->fullacc) { + flags |=TB_FLAGS_FULL_ACCESS ; + } +if (env->skip) { + flags |=TB_FLAGS_SKIP ; + } + + *pflags = flags; +} +static void avr_cpu_set_pc (CPUState *cs,vaddr value) {AVRCPU *cpu =AVR_CPU (cs);
target/cris/cpu.c +10 -0
@@ -32,6 +32,16 @@ int cpu_mmu_index(CPUCRISState *env, bool ifetch)return !!(env->pregs[PR_CCS ] &U_FLAG ); } +void cpu_get_tb_cpu_state (CPUCRISState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags = env->dslot | + (env->pregs[PR_CCS ] & (S_FLAG |P_FLAG |U_FLAG + |X_FLAG |PFIX_FLAG )); +} +static void cris_cpu_set_pc (CPUState *cs,vaddr value) {CRISCPU *cpu =CRIS_CPU (cs);
target/hexagon/cpu.c +12 -0
@@ -35,6 +35,18 @@ int cpu_mmu_index(CPUHexagonState *env, bool ifetch)#endif } +void cpu_get_tb_cpu_state (CPUHexagonState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ +uint32_t hex_flags =0 ; + *pc = env->gpr[HEX_REG_PC ]; + *cs_base =0 ; +if (*pc == env->gpr[HEX_REG_SA0 ]) { + hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,IS_TIGHT_LOOP ,1 ); + } + *flags = hex_flags; +} +static void hexagon_v67_cpu_init (Object *obj) { }static void hexagon_v68_cpu_init (Object *obj) { }static void hexagon_v69_cpu_init (Object *obj) { }
target/hppa/cpu.c +47 -0
53 lines not on this page · raw message
target/i386/cpu.c +9 -0
@@ -52,6 +52,15 @@ int cpu_mmu_index(CPUX86State *env, bool ifetch) ? MMU_KNOSMAP_IDX : MMU_KSMAP_IDX; } +void cpu_get_tb_cpu_state (CPUX86State *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *cs_base = env->segs[R_CS ].base; + *pc = *cs_base + env->eip; + *flags = env->hflags | + (env->eflags & (IOPL_MASK |TF_MASK |RF_MASK |VM_MASK |AC_MASK )); +} +static void x86_cpu_realizefn (DeviceState *dev,Error **errp);/* Helpers for building CPUID[2] descriptors: */
target/loongarch/cpu.c +11 -0
@@ -32,6 +32,17 @@ int cpu_mmu_index(CPULoongArchState *env, bool ifetch)#endif } +void cpu_get_tb_cpu_state (CPULoongArchState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags = env->CSR_CRMD & (R_CSR_CRMD_PLV_MASK |R_CSR_CRMD_PG_MASK ); + *flags |=FIELD_EX64 (env->CSR_EUEN,CSR_EUEN ,FPE ) *HW_FLAGS_EUEN_FPE ; + *flags |=FIELD_EX64 (env->CSR_EUEN,CSR_EUEN ,SXE ) *HW_FLAGS_EUEN_SXE ; + *flags |=is_va32 (env) *HW_FLAGS_VA32 ; +} +const char *const regnames[32 ] = {"r0" ,"r1" ,"r2" ,"r3" ,"r4" ,"r5" ,"r6" ,"r7" ,"r8" ,"r9" ,"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" ,
target/m68k/cpu.c +16 -0
@@ -29,6 +29,22 @@ int cpu_mmu_index(CPUM68KState *env, bool ifetch)return (env->sr &SR_S ) ==0 ?1 :0 ; } +void cpu_get_tb_cpu_state (CPUM68KState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags = (env->macsr >>4 ) &TB_FLAGS_MACSR ; +if (env->sr &SR_S ) { + *flags |=TB_FLAGS_MSR_S ; + *flags |= (env->sfc << (TB_FLAGS_SFC_S_BIT -2 )) &TB_FLAGS_SFC_S ; + *flags |= (env->dfc << (TB_FLAGS_DFC_S_BIT -2 )) &TB_FLAGS_DFC_S ; + } +if (M68K_SR_TRACE (env->sr) ==M68K_SR_TRACE_ANY_INS ) { + *flags |=TB_FLAGS_TRACE ; + } +} +static void m68k_cpu_set_pc (CPUState *cs,vaddr value) {M68kCPU *cpu =M68K_CPU (cs);
target/microblaze/cpu.c +7 -0
@@ -47,6 +47,13 @@ int cpu_mmu_index(CPUMBState *env, bool ifetch)return MMU_KERNEL_IDX ; } +void cpu_get_tb_cpu_state (CPUMBState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *flags = (env->iflags &IFLAGS_TB_MASK ) | (env->msr &MSR_TB_MASK ); + *cs_base = (*flags &IMM_FLAG ? env->imm :0 ); +} static const struct { const char *name;
target/mips/cpu.c +9 -0
@@ -49,6 +49,15 @@ int cpu_mmu_index(CPUMIPSState *env, bool ifetch)return hflags_mmu_index (env->hflags); } +void cpu_get_tb_cpu_state (CPUMIPSState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->active_tc.PC; + *cs_base =0 ; + *flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK | +MIPS_HFLAG_HWRENA_ULR ); +} +const char regnames[32 ][3 ] = {"r0" ,"at" ,"v0" ,"v1" ,"a0" ,"a1" ,"a2" ,"a3" ,"t0" ,"t1" ,"t2" ,"t3" ,"t4" ,"t5" ,"t6" ,"t7" ,
target/nios2/cpu.c +12 -0
@@ -32,6 +32,18 @@ int cpu_mmu_index(CPUNios2State *env, bool ifetch)MMU_SUPERVISOR_IDX ; } +void cpu_get_tb_cpu_state (CPUNios2State *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ +unsigned crs =FIELD_EX32 (env->ctrl[CR_STATUS ],CR_STATUS ,CRS ); + + *pc = env->pc; + *cs_base =0 ; + *flags = (env->ctrl[CR_STATUS ] &CR_STATUS_U ) + | (crs ?0 :R_TBFLAGS_CRS0_MASK ) + | (env->regs[0 ] ?0 :R_TBFLAGS_R0_0_MASK ); +} +static void nios2_cpu_set_pc (CPUState *cs,vaddr value) {Nios2CPU *cpu =NIOS2_CPU (cs);
target/openrisc/cpu.c +10 -0
@@ -37,6 +37,16 @@ int cpu_mmu_index(CPUOpenRISCState *env, bool ifetch)return ret; } +void cpu_get_tb_cpu_state (CPUOpenRISCState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags = (env->dflag ?TB_FLAGS_DFLAG :0 ) + | (cpu_get_gpr (env,0 ) ?0 :TB_FLAGS_R0_0 ) + | (env->sr & (SR_SM |SR_DME |SR_IME |SR_OVE )); +} +static void openrisc_cpu_set_pc (CPUState *cs,vaddr value) {OpenRISCCPU *cpu =OPENRISC_CPU (cs);
target/ppc/cpu.c +11 -0
@@ -36,6 +36,17 @@ int cpu_mmu_index(CPUPPCState *env, bool ifetch)#endif } +/* debug version defined in helper_hregs */ +#ifndef CONFIG_DEBUG_TCG +void cpu_get_tb_cpu_state (CPUPPCState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->nip; + *cs_base =0 ; + *flags = env->hflags; +} +#endif +target_ulong cpu_read_xer (const CPUPPCState *env) {if (is_isa300 (env)) {
target/rx/cpu.c +9 -0
@@ -31,6 +31,15 @@ int cpu_mmu_index(CPURXState *env, bool ifetch)return 0 ; } +void cpu_get_tb_cpu_state (CPURXState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags =FIELD_DP32 (0 ,PSW ,PM , env->psw_pm); + *flags =FIELD_DP32 (*flags,PSW ,U , env->psw_u); +} +static void rx_cpu_set_pc (CPUState *cs,vaddr value) {RXCPU *cpu =RX_CPU (cs);
target/s390x/cpu.c +24 -0
@@ -72,6 +72,30 @@ int cpu_mmu_index(CPUS390XState *env, bool ifetch)#endif } +void cpu_get_tb_cpu_state (CPUS390XState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ +if (env->psw.addr &1 ) { +/* +* Instructions must be at even addresses. +* This needs to be checked before address translation. +*/ + env->int_pgm_ilen =2 ;/* see s390_cpu_tlb_fill() */ +#ifdef CONFIG_TCG +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,0 ); +#endif + } + *pc = env->psw.addr; + *cs_base = env->ex_value; + *flags = (env->psw.mask >>FLAG_MASK_PSW_SHIFT ) &FLAG_MASK_PSW ; +if (env->cregs[0 ] &CR0_AFP ) { + *flags |=FLAG_MASK_AFP ; + } +if (env->cregs[0 ] &CR0_VECTOR ) { + *flags |=FLAG_MASK_VECTOR ; + } +} +#ifndef CONFIG_USER_ONLY static bool is_early_exception_psw (uint64_t mask,uint64_t addr) {
target/sh4/cpu.c +15 -0
@@ -41,6 +41,21 @@ int cpu_mmu_index(CPUSH4State *env, bool ifetch) } } +void cpu_get_tb_cpu_state (CPUSH4State *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ + *pc = env->pc; +/* For a gUSA region, notice the end of the region. */ + *cs_base = env->flags &TB_FLAG_GUSA_MASK ? env->gregs[0 ] :0 ; + *flags = env->flags + | (env->fpscr &TB_FLAG_FPSCR_MASK ) + | (env->sr &TB_FLAG_SR_MASK ) + | (env->movcal_backup ?TB_FLAG_PENDING_MOVCA :0 );/* Bit 3 */ +#ifdef CONFIG_USER_ONLY + *flags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; +#endif +} +static void superh_cpu_set_pc (CPUState *cs,vaddr value) {SuperHCPU *cpu =SUPERH_CPU (cs);
target/sparc/cpu.c +35 -0
@@ -57,6 +57,41 @@ int cpu_mmu_index(CPUSPARCState *env, bool ifetch)#endif } +void cpu_get_tb_cpu_state (CPUSPARCState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *pflags) +{ +uint32_t flags; + *pc = env->pc; + *cs_base = env->npc; + flags =cpu_mmu_index (env, false); +#ifndef CONFIG_USER_ONLY +if (cpu_supervisor_mode (env)) { + flags |=TB_FLAG_SUPER ; + } +#endif +#ifdef TARGET_SPARC64 +#ifndef CONFIG_USER_ONLY +if (cpu_hypervisor_mode (env)) { + flags |=TB_FLAG_HYPER ; + } +#endif +if (env->pstate &PS_AM ) { + flags |=TB_FLAG_AM_ENABLED ; + } +if ((env->def.features &CPU_FEATURE_FLOAT ) + && (env->pstate &PS_PEF ) + && (env->fprs &FPRS_FEF )) { + flags |=TB_FLAG_FPU_ENABLED ; + } + flags |= env->asi <<TB_FLAG_ASI_SHIFT ; +#else +if ((env->def.features &CPU_FEATURE_FLOAT ) && env->psref) { + flags |=TB_FLAG_FPU_ENABLED ; + } +#endif + *pflags = flags; +} +static void sparc_cpu_reset_hold (Object *obj) {CPUState *s =CPU (obj);
target/tricore/cpu.c +12 -0
@@ -29,6 +29,18 @@ int cpu_mmu_index(CPUTriCoreState *env, bool ifetch)return 0 ; } +void cpu_get_tb_cpu_state (CPUTriCoreState *env,vaddr *pc, +uint64_t *cs_base,uint32_t *flags) +{ +uint32_t new_flags =0 ; + *pc = env->PC; + *cs_base =0 ; + + new_flags |=FIELD_DP32 (new_flags,TB_FLAGS ,PRIV , +extract32 (env->PSW,10 ,2 )); + *flags = new_flags; +} +static inline void set_feature (CPUTriCoreState *env,int feature) { env->features |=1ULL << feature;
target/xtensa/cpu.c +68 -0
74 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH 13/34] target: Uninline cpu_get_tb_cpu_state()
Quoted 39 lines · Anton Johansson
Required to compile
accel/tcg/translate-all.conce for softmmu targets. The function gets quite big for some targets so uninlining makes sense.Signed-off-by Anton Johansson<[email protected]>--- include/exec/cpu-common.h | 4 +++ target/alpha/cpu.h | 11 ------- target/arm/cpu.h | 3 -- target/avr/cpu.h | 18 ----------- target/cris/cpu.h | 10 ------ target/hexagon/cpu.h | 12 ------- target/hppa/cpu.h | 43 ------------------------- target/i386/cpu.h | 9 ------ target/loongarch/cpu.h | 11 ------- target/m68k/cpu.h | 16 --------- target/microblaze/cpu.h | 8 ----- target/mips/cpu.h | 9 ------ target/nios2/cpu.h | 12 ------- target/openrisc/cpu.h | 10 ------ target/ppc/cpu.h | 13 -------- target/riscv/cpu.h | 3 -- target/rx/cpu.h | 9 ------ target/s390x/cpu.h | 22 ------------- target/sh4/cpu.h | 15 --------- target/sparc/cpu.h | 35 -------------------- target/tricore/cpu.h | 12 ------- target/xtensa/cpu.h | 68 --------------------------------------- target/alpha/cpu.c | 11 +++++++ target/avr/cpu.c | 18 +++++++++++ target/cris/cpu.c | 10 ++++++ target/hexagon/cpu.c | 12 +++++++ target/hppa/cpu.c | 47 +++++++++++++++++++++++++++ target/i386/cpu.c | 9 ++++++ target/loongarch/cpu.c | 11 +++++++ target/m68k/cpu.c | 16 +++++++++ target/microblaze/cpu.c | 7 ++++ target/mips/cpu.c | 9 ++++++ target/nios2/cpu.c | 12 +++++++ target/openrisc/cpu.c | 10 ++++++
Quoted 8 lines
target/ppc/cpu.c | 11 +++++++ target/rx/cpu.c | 9 ++++++ target/s390x/cpu.c | 24 ++++++++++++++ target/sh4/cpu.c | 15 +++++++++ target/sparc/cpu.c | 35 ++++++++++++++++++++ target/tricore/cpu.c | 12 +++++++ target/xtensa/cpu.c | 68 +++++++++++++++++++++++++++++++++++++++ 41 files changed, 350 insertions(+), 349 deletions(-)
r~
Richard Henderson
AppliedRe: [RFC PATCH 13/34] target: Uninline cpu_get_tb_cpu_state()
In reply to Anton Johansson viaQuoted 5 lines · Anton Johansson
Required to compile
accel/tcg/translate-all.conce for softmmu targets. The function gets quite big for some targets so uninlining makes sense.Signed-off-by Anton Johansson<[email protected]>---
Queued, thanks.
r~
RFC PATCH 14/34 exec: [CPUTLB] Move PAGE_* macros to common header
In reply to Anton Johansson viaThese don't vary across targets and are used in soon-to-be common code (cputlb.c).
--- 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
@@ -166,34 +166,10 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val# error Need to use TARGET_PAGE_BITS_VARY on system mode#endif -/* 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
@@ -234,4 +234,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.43.0
Re: [RFC PATCH 14/34] exec: [CPUTLB] Move PAGE_* macros to common header
Quoted 8 lines · Anton Johansson
These don't vary across targets and are used in soon-to-be common code (
cputlb.c).Signed-off-by Anton Johansson<[email protected]>--- include/exec/cpu-all.h | 24 ------------------------ include/exec/cpu-common.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 24 deletions(-)
r~
Richard Henderson
AppliedRe: [RFC PATCH 14/34] exec: [CPUTLB] Move PAGE_* macros to common header
Quoted 11 lines · Richard Henderson
Quoted 8 lines · Anton Johansson
These don't vary across targets and are used in soon-to-be common code (
cputlb.c).Signed-off-by Anton Johansson<[email protected]>---
include/exec/cpu-all.h | 24 ------------------------include/exec/cpu-common.h| 30 ++++++++++++++++++++++++++++++2 files changed, 30 insertions(+), 24 deletions(-)Reviewed-by Richard Henderson <[email protected]>
Queued, thanks.
r~
RFC PATCH 15/34 exec: [CPUTLB] Move TLB_*/tlb_*() to common header
In reply to Anton Johansson viaTLB_* macros and tlb_*() functions are target independent, move to cpu-common.h.
--- include/exec/cpu-all.h | 81 -------------------------------------- include/exec/cpu-common.h | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 81 deletions(-)
include/exec/cpu-all.h +0 -81
@@ -295,87 +295,6 @@ CPUArchState *cpu_copy(CPUArchState *env); | CPU_INTERRUPT_TGT_EXT_3 \ | CPU_INTERRUPT_TGT_EXT_4) -#ifdef CONFIG_USER_ONLY - -/* -* Allow some level of source compatibility with softmmu. We do not -* support any of the more exotic features, so only invalid pages may -* be signaled by probe_access_flags(). -*/ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) -#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 2)) -#define TLB_WATCHPOINT 0 - -#else - -/* -* Flags stored in the low bits of the TLB virtual address. -* These are defined so that fast path ram access is all zeros. -* The flags all must be between TARGET_PAGE_BITS and -* maximum address alignment bit. -* -* Use TARGET_PAGE_BITS_MIN so that these bits are constant -* when TARGET_PAGE_BITS_VARY is in effect. -* -* The count, if not the placement of these bits is known -* to tcg/tcg-op-ldst.c, check_max_alignment(). -*/ -/* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) -/* Set if TLB entry references a clean RAM page. The iotlb entry will -contain the page physical address. */ -#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2)) -/* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) -/* Set if TLB entry writes ignored. */ -#define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 4)) -/* Set if the slow path must be used; more flags in CPUTLBEntryFull. */ -#define TLB_FORCE_SLOW (1 << (TARGET_PAGE_BITS_MIN - 5)) - -/* -* Use this mask to check interception with an alignment mask -* in a TCG backend. -*/ -#define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ - | TLB_FORCE_SLOW | TLB_DISCARD_WRITE) - -/* -* Flags stored in CPUTLBEntryFull.slow_flags[x]. -* TLB_FORCE_SLOW must be set in CPUTLBEntry.addr_idx[x]. -*/ -/* Set if TLB entry requires byte swap. */ -#define TLB_BSWAP (1 << 0) -/* Set if TLB entry contains a watchpoint. */ -#define TLB_WATCHPOINT (1 << 1) - -#define TLB_SLOW_FLAGS_MASK (TLB_BSWAP | TLB_WATCHPOINT) - -/** -* tlb_hit_page: return true if page aligned @addr is a hit against the -* TLB entry @tlb_addr -* -* @addr: virtual address to test (must be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit_page (uint64_t tlb_addr,vaddr addr) -{ -return addr == (tlb_addr & (TARGET_PAGE_MASK |TLB_INVALID_MASK )); -} - -/** -* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr -* -* @addr: virtual address to test (need not be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit (uint64_t tlb_addr,vaddr addr) -{ -return tlb_hit_page (tlb_addr, addr &TARGET_PAGE_MASK ); -} - -#endif /* !CONFIG_USER_ONLY */ -/* accel/tcg/cpu-exec.c */ int cpu_exec (CPUState *cpu);
include/exec/cpu-common.h +83 -0
89 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH 15/34] exec: [CPUTLB] Move TLB_*/tlb_*() to common header
Quoted 7 lines · Anton Johansson
TLB_* macros and tlb_*() functions are target independent, move to
cpu-common.h.Signed-off-by Anton Johansson<[email protected]>--- include/exec/cpu-all.h | 81 -------------------------------------- include/exec/cpu-common.h | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 81 deletions(-)
r~
RFC PATCH 16/34 exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
In reply to Anton Johansson viaFunctions are target independent.
--- include/exec/cpu-all.h | 25 ------------------------- include/exec/cpu-common.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-)
include/exec/cpu-all.h +0 -25
@@ -295,33 +295,8 @@ CPUArchState *cpu_copy(CPUArchState *env); | CPU_INTERRUPT_TGT_EXT_3 \ | CPU_INTERRUPT_TGT_EXT_4) -/* 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 +25 -0
@@ -347,4 +347,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.43.0
Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Quoted 7 lines · Anton Johansson
Functions are target independent.
Signed-off-by Anton Johansson<[email protected]>--- include/exec/cpu-all.h | 25 ------------------------- include/exec/cpu-common.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-)
r~
Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
In reply to Anton Johansson viaQuoted 22 lines · Anton Johansson
include/exec/cpu-common.h +16
-0@@ -347,4 +347,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)
include/exec/cpu-common.h G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); · line 375
Quoted 10 lines
include/exec/cpu-common.h +9
-0+* @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 */
Missing include of hw/core/cpu.h, as far as I can see?
r~
Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Quoted 26 lines · Richard Henderson
Quoted 25 lines · Anton Johansson
include/exec/cpu-common.h +20
-0@@ -347,4 +347,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. +*/
Quoted 8 lines
include/exec/cpu-common.h G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); · line 375
Quoted 6 lines
include/exec/cpu-common.h +5
-0+static inline CPUState *env_cpu (CPUArchState *env) +{ + return (void *)env - sizeof(CPUState); +} + #endif /* CPU_COMMON_H */Missing include of
hw/core/cpu.h, as far as I can see?
Queued, with this fix.
r~
RFC PATCH 17/34 hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
In reply to Anton Johansson viaTCGCPUOps contains an extra function pointer when included with NEED_CPU_H, these are moved from the middle to the end of the struct. As such offsets to target independent function pointers don't vary in target specific and independent code.
[Move target specfic fields to separate struct?]
--- include/hw/core/tcg-cpu-ops.h | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
include/hw/core/tcg-cpu-ops.h +17 -15
@@ -49,21 +49,6 @@ struct TCGCPUOps {/** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); -#ifdef NEED_CPU_H -#if defined(CONFIG_USER_ONLY ) && defined(TARGET_I386 ) -/** -* @fake_user_interrupt: Callback for 'fake exception' handling. -* -* Simulate 'fake exception' which will be handled outside the -* 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 /** * record_sigsegv:
@@ -171,8 +156,25 @@ struct TCGCPUOps {bool (*io_recompile_replay_branch)(CPUState *cpu,const TranslationBlock *tb);#endif /* !CONFIG_USER_ONLY */ + +#ifdef NEED_CPU_H +#if defined(CONFIG_USER_ONLY ) && defined(TARGET_I386 ) +/** +* @fake_user_interrupt: Callback for 'fake exception' handling. +* +* Simulate 'fake exception' which will be handled outside the +* 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 */ #endif /* NEED_CPU_H */ + };#if defined(CONFIG_USER_ONLY )
Signature · 1 line
2.43.0
Re: [RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
Quoted 8 lines · Anton Johansson
TCGCPUOps contains an extra function pointer when included with
NEED_CPU_H, these are moved from the middle to the end of the struct. As such offsets to target independent function pointers don't vary in target specific and independent code.[Move target specfic fields to separate struct?]
Signed-off-by Anton Johansson <[email protected]>
Or make these unconditional. Move fake_user_interrupt into the CONFIG_USER_ONLY block and do_interrupt into the system block.
r~
Re: [RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
Quoted 11 lines · Richard Henderson
Quoted 8 lines · Anton Johansson
TCGCPUOps contains an extra function pointer when included with
NEED_CPU_H, these are moved from the middle to the end of the struct. As such offsets to target independent function pointers don't vary in target specific and independent code.[Move target specfic fields to separate struct?]
Signed-off-by Anton Johansson <[email protected]>Or make these unconditional. Move
fake_user_interruptinto theCONFIG_USER_ONLYblock anddo_interruptinto the system block.
I have split the patch in two, made fake_user_interrupt unconditional, and queued.
r~
RFC PATCH 18/34 accel/stubs: [CPUTLB] Move xen.h stubs to xen-stub.c
In reply to Anton Johansson viaMakes xen.h header independent of softmmu target. Note:CONFIG_XEN_IS_POSSIBLE is only used define stubs in xen.h and optimize xen_enabled().
Required by cpu_physical_memory_set_dirty_range() in ram_addr.h.
--- include/sysemu/xen.h | 27 --------------------------- accel/stubs/xen-stub.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 27 deletions(-)
include/sysemu/xen.h +0 -27
@@ -12,16 +12,6 @@#include "exec/cpu-common.h" -#ifdef NEED_CPU_H -# ifdef CONFIG_XEN -# define CONFIG_XEN_IS_POSSIBLE -# endif -#else -# define CONFIG_XEN_IS_POSSIBLE -#endif - -#ifdef CONFIG_XEN_IS_POSSIBLE -extern bool xen_allowed;#define xen_enabled () (xen_allowed)
@@ -32,21 +22,4 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, struct MemoryRegion *mr, Error **errp);#endif -#else /* !CONFIG_XEN_IS_POSSIBLE */ - -#define xen_enabled () 0 -#ifndef CONFIG_USER_ONLY -static inline void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length) -{ -/* nothing */ -} -static inline void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size, -MemoryRegion *mr,Error **errp) -{ -g_assert_not_reached (); -} -#endif - -#endif /* CONFIG_XEN_IS_POSSIBLE */ -#endif
accel/stubs/xen-stub.c +12 -0
@@ -14,3 +14,15 @@ bool xen_allowed;void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { } + +#ifndef CONFIG_USER_ONLY +void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length) +{ +/* nothing */ +} +void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size, +MemoryRegion *mr,Error **errp) +{ +g_assert_not_reached (); +} +#endif
Signature · 1 line
2.43.0
Re: [RFC PATCH 18/34] accel/stubs: [CPUTLB] Move xen.h stubs to xen-stub.c
accel/stubs/xen-stub.c bool xen_allowed; · line 19
Quoted 9 lines · Anton Johansson
accel/stubs/xen-stub.c +3
-0@@ -14,3 +14,15 @@ bool xen_allowed;void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { } + +#ifndef CONFIG_USER_ONLY +void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length)
No need for ifdef here, since this file is in system_stubs_ss.
Otherwise,
r~
RFC PATCH 19/34 accel/tcg: [CPUTLB] Use TCGContext.addr_type instead of TARGET_LONG_BITS
In reply to Anton Johansson via[NOTE: We could also use target_long_bits(), which is introduced later]
--- include/exec/cpu_ldst.h | 31 ++++++++++++++++--------------- accel/tcg/cputlb.c | 34 ++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 29 deletions(-)
include/exec/cpu_ldst.h +16 -15
@@ -340,7 +340,7 @@ static inline void clear_helper_retaddr(void)#else -#include "tcg/oversized-guest.h" +#include "tcg-target-reg-bits.h" static inline uint64_t tlb_read_idx (const CPUTLBEntry *entry,MMUAccessType access_type)
@@ -353,20 +353,21 @@ static inline uint64_t tlb_read_idx(const CPUTLBEntry *entry,QEMU_BUILD_BUG_ON (offsetof(CPUTLBEntry , addr_code) !=MMU_INST_FETCH *sizeof (uint64_t )); -#if TARGET_LONG_BITS ==32 -/* Use qatomic_read, in case of addr_write; only care about low bits. */ -const uint32_t *ptr = (uint32_t *)&entry->addr_idx[access_type]; - ptr +=HOST_BIG_ENDIAN ; -return qatomic_read (ptr); -#else -const uint64_t *ptr = &entry->addr_idx[access_type]; -# if TCG_OVERSIZED_GUEST -return *ptr; -# else -/* ofs might correspond to .addr_write, so use qatomic_read */ -return qatomic_read (ptr); -# endif -#endif +if (tcg_ctx->addr_type ==TCG_TYPE_I32 ) { +/* Use qatomic_read, in case of addr_write; only care about low bits. */ +const uint32_t *ptr = (uint32_t *)&entry->addr_idx[access_type]; + ptr +=HOST_BIG_ENDIAN ; +return qatomic_read (ptr); + }else { +const uint64_t *ptr = &entry->addr_idx[access_type]; +if (TCG_TARGET_REG_BITS ==32 ) { +/* Oversized guest */ +return *ptr; + }else { +/* ofs might correspond to .addr_write, so use qatomic_read */ +return qatomic_read (ptr); + } + } }static inline uint64_t tlb_addr_write (const CPUTLBEntry *entry)
accel/tcg/cputlb.c +20 -14
@@ -41,7 +41,7 @@#include "qemu/plugin-memory.h" #endif #include "tcg/tcg-ldst.h" -#include "tcg/oversized-guest.h" +#include "tcg-target-reg-bits.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */
@@ -815,12 +815,13 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, unsigned bits) {TLBFlushRangeData d; +const unsigned long_bits = (tcg_ctx->addr_type ==TCG_TYPE_I32 ) ?32 :64 ;/* * If all bits are significant, and len is small, * this devolves to tlb_flush_page. */ -if (bits >=TARGET_LONG_BITS && len <=TARGET_PAGE_SIZE ) { +if (bits >= long_bits && len <=TARGET_PAGE_SIZE ) {tlb_flush_page_by_mmuidx (cpu, addr, idxmap);return ; }
@@ -858,12 +859,13 @@ void tlb_flush_range_by_mmuidx_all_cpus(CPUState *src_cpu, {TLBFlushRangeData d;CPUState *dst_cpu; +const unsigned long_bits = (tcg_ctx->addr_type ==TCG_TYPE_I32 ) ?32 :64 ;/* * If all bits are significant, and len is small, * this devolves to tlb_flush_page. */ -if (bits >=TARGET_LONG_BITS && len <=TARGET_PAGE_SIZE ) { +if (bits >= long_bits && len <=TARGET_PAGE_SIZE ) {tlb_flush_page_by_mmuidx_all_cpus (src_cpu, addr, idxmap);return ; }
@@ -908,12 +910,13 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu, {TLBFlushRangeData d, *p;CPUState *dst_cpu; +const unsigned long_bits = (tcg_ctx->addr_type ==TCG_TYPE_I32 ) ?32 :64 ;/* * If all bits are significant, and len is small, * this devolves to tlb_flush_page. */ -if (bits >=TARGET_LONG_BITS && len <=TARGET_PAGE_SIZE ) { +if (bits >= long_bits && len <=TARGET_PAGE_SIZE ) {tlb_flush_page_by_mmuidx_all_cpus_synced (src_cpu, addr, idxmap);return ; }
@@ -995,16 +998,19 @@ static void tlb_reset_dirty_range_locked(CPUTLBEntry *tlb_entry, addr &=TARGET_PAGE_MASK ; addr += tlb_entry->addend;if ((addr - start) < length) { -#if TARGET_LONG_BITS ==32 -uint32_t *ptr_write = (uint32_t *)&tlb_entry->addr_write; - ptr_write +=HOST_BIG_ENDIAN ; -qatomic_set (ptr_write, *ptr_write |TLB_NOTDIRTY ); -#elif TCG_OVERSIZED_GUEST - tlb_entry->addr_write |=TLB_NOTDIRTY ; -#else -qatomic_set (&tlb_entry->addr_write, - tlb_entry->addr_write |TLB_NOTDIRTY ); -#endif +if (tcg_ctx->addr_type ==TCG_TYPE_I32 ) { +/* 32-bit */ +uint32_t *ptr_write = (uint32_t *)&tlb_entry->addr_write; + ptr_write +=HOST_BIG_ENDIAN ; +qatomic_set (ptr_write, *ptr_write |TLB_NOTDIRTY ); + }else if (TCG_TARGET_REG_BITS ==32 ) { +/* Oversized guest */ + tlb_entry->addr_write |=TLB_NOTDIRTY ; + }else { +/* 64-bit */ +qatomic_set (&tlb_entry->addr_write, + tlb_entry->addr_write |TLB_NOTDIRTY ); + } } } }
Signature · 1 line
2.43.0
Re: [RFC PATCH 19/34] accel/tcg: [CPUTLB] Use TCGContext.addr_type instead of TARGET_LONG_BITS
accel/tcg/cputlb.c void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, · line 818
Quoted 5 lines · Anton Johansson
accel/tcg/cputlb.c +1
-0@@ -815,12 +815,13 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, unsigned bits) {TLBFlushRangeData d; +const unsigned long_bits = (tcg_ctx->addr_type ==TCG_TYPE_I32 ) ?32 :64 ;
No, this value isn't initialized at the correct time. We are out of scope here.
r~
RFC PATCH 20/34 accel/tcg: [CPUTLB] Use TCGContext.guest_mo for memory ordering
In reply to Anton Johansson via--- accel/tcg/internal-target.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
accel/tcg/internal-target.h +4 -7
@@ -9,8 +9,9 @@#ifndef ACCEL_TCG_INTERNAL_TARGET_H #define ACCEL_TCG_INTERNAL_TARGET_H -#include "exec/exec-all.h" +#include "exec/exec-common.h" #include "exec/translate-all.h" +#include "tcg/tcg.h" /* * Access to the various translations structures need to be serialised
@@ -108,12 +109,8 @@ extern bool one_insn_per_tb;* * This is a macro so that it's constant even without optimization. */ -#ifdef TCG_GUEST_DEFAULT_MO -# define tcg_req_mo (type) \ - ((type) & TCG_GUEST_DEFAULT_MO & ~TCG_TARGET_DEFAULT_MO) -#else -# define tcg_req_mo (type) ((type) & ~TCG_TARGET_DEFAULT_MO) -#endif +#define tcg_req_mo (type) \ + ((type) & tcg_ctx->guest_mo & ~TCG_TARGET_DEFAULT_MO)/** * cpu_req_mo:
Signature · 1 line
2.43.0
Re: [RFC PATCH 20/34] accel/tcg: [CPUTLB] Use TCGContext.guest_mo for memory ordering
accel/tcg/internal-target.h extern bool one_insn_per_tb; · line 113
Quoted 2 lines · Anton Johansson
accel/tcg/internal-target.h +2
-0+#define tcg_req_mo (type) \ + ((type) & tcg_ctx->guest_mo & ~TCG_TARGET_DEFAULT_MO)
Again, no, value is out of scope.
r~
RFC PATCH 21/34 accel/tcg: [CPUTLB] Use tcg_ctx->tlb_dyn_max_bits
In reply to Anton Johansson viaCPU_TLB_DYN_MAX_BITS depends on TARGET_VIRT_ADDR_SPACE_BITS on 64-bit hosts, and is not yet target independent.
--- accel/tcg/cputlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/cputlb.c +1 -1
@@ -172,7 +172,7 @@ static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, rate = desc->window_max_entries *100 / old_size;if (rate >70 ) { - new_size =MIN (old_size <<1 ,1 <<CPU_TLB_DYN_MAX_BITS ); + new_size =MIN (old_size <<1 ,1 << tcg_ctx->tlb_dyn_max_bits); }else if (rate <30 && window_expired) {size_t ceil =pow2ceil (desc->window_max_entries);size_t expected_rate = desc->window_max_entries *100 / ceil;
Signature · 1 line
2.43.0
Re: [RFC PATCH 21/34] accel/tcg: [CPUTLB] Use tcg_ctx->tlb_dyn_max_bits
accel/tcg/cputlb.c static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, · line 175
Quoted 6 lines · Anton Johansson
accel/tcg/cputlb.c +1
-1@@ -172,7 +172,7 @@ static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, rate = desc->window_max_entries *100 / old_size;if (rate >70 ) { - new_size =MIN (old_size <<1 ,1 <<CPU_TLB_DYN_MAX_BITS ); + new_size =MIN (old_size <<1 ,1 << tcg_ctx->tlb_dyn_max_bits);
Out of scope.
r~
RFC PATCH 22/34 accel/tcg: [CPUTLB] Move CPU_TLB_DYN_[DEFAULT|MIN]* to cputlb.c
In reply to Anton Johansson viaThese macros are only used for softmmu targets and only used in cputlb.c, move definitions there.
--- include/exec/cpu-defs.h | 3 --- accel/tcg/cputlb.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
include/exec/cpu-defs.h +0 -3
@@ -55,9 +55,6 @@#include "exec/target_long.h" #if defined(CONFIG_SOFTMMU ) && defined(CONFIG_TCG ) -#define CPU_TLB_DYN_MIN_BITS 6 -#define CPU_TLB_DYN_DEFAULT_BITS 8 -# if HOST_LONG_BITS ==32 /* Make sure we do not require a double-word shift for the TLB load */ # define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS)
accel/tcg/cputlb.c +3 -0
@@ -43,6 +43,9 @@#include "tcg/tcg-ldst.h" #include "tcg-target-reg-bits.h" +#define CPU_TLB_DYN_MIN_BITS 6 +#define CPU_TLB_DYN_DEFAULT_BITS 8 +/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ /* #define DEBUG_TLB_LOG */
Signature · 1 line
2.43.0
Re: [RFC PATCH 22/34] accel/tcg: [CPUTLB] Move CPU_TLB_DYN_[DEFAULT|MIN]* to cputlb.c
Quoted 8 lines · Anton Johansson
These macros are only used for softmmu targets and only used in
cputlb.c, move definitions there.Signed-off-by Anton Johansson<[email protected]>--- include/exec/cpu-defs.h | 3 --- accel/tcg/cputlb.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
r~
RFC PATCH 23/34 tcg: [CPUTLB] Add `mo_te` field to TCGContext
In reply to Anton Johansson viaRequired by cpu_ldub_code() and friends in cputlb.c to access the MO_TE MemOp in a target-independent way.
--- include/tcg/tcg.h | 1 + 1 file changed, 1 insertion(+)
include/tcg/tcg.h +1 -0
@@ -489,6 +489,7 @@ struct TCGContext {TCGType addr_type;/* TCG_TYPE_I32 or TCG_TYPE_I64 */ #ifdef CONFIG_SOFTMMU +MemOp mo_te;int page_mask;uint8_t page_bits;uint8_t tlb_dyn_max_bits;
Signature · 1 line
2.43.0
Re: [RFC PATCH 23/34] tcg: [CPUTLB] Add `mo_te` field to TCGContext
Quoted 13 lines · Anton Johansson
Required by
cpu_ldub_code()and friends incputlb.cto access theMO_TEMemOp in a target-independent way.Signed-off-by Anton Johansson <[email protected]>--- include/tcg/tcg.h | 1 + 1 file changed, 1 insertion(+)include/tcg/tcg.h +0
-0
include/tcg/tcg.h struct TCGContext { · line 495
Quoted 7 lines
include/tcg/tcg.h +1
-0@@ -489,6 +489,7 @@ struct TCGContext {TCGType addr_type;/* TCG_TYPE_I32 or TCG_TYPE_I64 */ #ifdef CONFIG_SOFTMMU +MemOp mo_te;int page_mask;uint8_t page_bits;uint8_t tlb_dyn_max_bits;
Not the correct scope for this.
r~
RFC PATCH 24/34 accel/tcg: [CPUTLB] Set mo_te in TCGContext
In reply to Anton Johansson viaInitializes mo_te field of TCGContext to the target endian memory order MO_TE, so it can be used within cputlb.c.
--- accel/tcg/translate-all.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
accel/tcg/translate-all.c +3 -1
@@ -47,12 +47,13 @@#include "exec/translate-all.h" #include "exec/translator.h" #include "exec/tb-flush.h" +#include "exec/log.h" +#include "exec/memop.h" #include "qemu/bitmap.h" #include "qemu/qemu-print.h" #include "qemu/main-loop.h" #include "qemu/cacheinfo.h" #include "qemu/timer.h" -#include "exec/log.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" #include "sysemu/tcg.h"
@@ -342,6 +343,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tcg_ctx->gen_tb = tb; tcg_ctx->addr_type =TARGET_LONG_BITS ==32 ?TCG_TYPE_I32 :TCG_TYPE_I64 ;#ifdef CONFIG_SOFTMMU + tcg_ctx->mo_te =MO_TE ; tcg_ctx->page_bits =TARGET_PAGE_BITS ; tcg_ctx->page_mask =TARGET_PAGE_MASK ; tcg_ctx->tlb_dyn_max_bits =CPU_TLB_DYN_MAX_BITS ;
Signature · 1 line
2.43.0
RFC PATCH 25/34 accel/tcg: [CPUTLB] Use tcg_ctx->mo_te instead of MO_TE
In reply to Anton Johansson viaMakes *_code() memory access functions target independent.
--- accel/tcg/cputlb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
accel/tcg/cputlb.c +6 -3
@@ -2988,19 +2988,22 @@ uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)uint32_t cpu_lduw_code (CPUArchState *env,abi_ptr addr) { -MemOpIdx oi =make_memop_idx (MO_TEUW ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (tcg_ctx->mo_te |MO_UW , +cpu_mmu_index (env, true));return do_ld2_mmu (env_cpu (env), addr, oi,0 ,MMU_INST_FETCH ); }uint32_t cpu_ldl_code (CPUArchState *env,abi_ptr addr) { -MemOpIdx oi =make_memop_idx (MO_TEUL ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (tcg_ctx->mo_te |MO_UL , +cpu_mmu_index (env, true));return do_ld4_mmu (env_cpu (env), addr, oi,0 ,MMU_INST_FETCH ); }uint64_t cpu_ldq_code (CPUArchState *env,abi_ptr addr) { -MemOpIdx oi =make_memop_idx (MO_TEUQ ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (tcg_ctx->mo_te |MO_UQ , +cpu_mmu_index (env, true));return do_ld8_mmu (env_cpu (env), addr, oi,0 ,MMU_INST_FETCH ); }
Signature · 1 line
2.43.0
RFC PATCH 26/34 Wrap target macros in functions
In reply to Anton Johansson viaAdds wrapper functions around common target specific macros required by accel/tcg.
--- include/hw/core/cpu.h | 9 +++++++ cpu-target.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
include/hw/core/cpu.h +9 -0
@@ -26,6 +26,7 @@#include "exec/vaddr.h" #include "exec/memattrs.h" #include "exec/tlb-common.h" +#include "exec/memop.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/rcu_queue.h"
@@ -1164,6 +1165,14 @@ void cpu_exec_unrealizefn(CPUState *cpu);* what you are doing! */ bool target_words_bigendian (void ); +bool target_supports_mttcg (void ); +bool target_has_precise_smc (void ); +int target_long_bits (void ); +int target_phys_addr_space_bits (void ); +uint8_t target_insn_start_words (void ); +uint8_t target_default_memory_order (void ); +uint8_t target_tlb_dyn_max_bits (void ); +MemOp target_endian_memory_order (void );const char *target_name (void );
cpu-target.c +62 -0
78 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH 26/34] Wrap target macros in functions
Hi Anton,
Quoted 23 lines · Anton Johansson
Adds wrapper functions around common target specific macros required by accel/tcg.
Signed-off-by Anton Johansson <[email protected]>--- include/hw/core/cpu.h | 9 +++++++ cpu-target.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)include/hw/core/cpu.h +1
-0@@ -26,6 +26,7 @@#include "exec/vaddr.h" #include "exec/memattrs.h" #include "exec/tlb-common.h" +#include "exec/memop.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/rcu_queue.h" @@ -1164,6 +1165,14 @@ void cpu_exec_unrealizefn(CPUState *cpu);* what you are doing!
include/hw/core/cpu.h void cpu_exec_unrealizefn(CPUState *cpu); · line 1175
Quoted 10 lines
include/hw/core/cpu.h +8
-0*/ bool target_words_bigendian (void ); +bool target_supports_mttcg (void ); +bool target_has_precise_smc (void ); +int target_long_bits (void ); +int target_phys_addr_space_bits (void ); +uint8_t target_insn_start_words (void ); +uint8_t target_default_memory_order (void ); +uint8_t target_tlb_dyn_max_bits (void ); +MemOp target_endian_memory_order (void );
None of these helpers take argument. I don't understand how they can be called in heterogeneous context.
Quoted 86 lines
include/hw/core/cpu.h +0
-0const char *target_name (void );cpu-target.c +62
-0@@ -39,10 +39,13 @@#include "exec/tb-flush.h" #include "exec/translate-all.h" #include "exec/log.h" +#include "exec/cpu-defs.h" #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" #include "qemu/accel.h" #include "qemu/plugin.h" +#include "tcg/tcg-mo.h" +#include "tcg/insn-start-words.h" uintptr_t qemu_host_page_size;intptr_t qemu_host_page_mask;@@ -416,6 +419,65 @@ bool target_words_bigendian(void)return TARGET_BIG_ENDIAN ; } +bool target_supports_mttcg (void ) +{ +#ifdef TARGET_SUPPORTS_MTTCG +# ifndef TCG_GUEST_DEFAULT_MO +# error "TARGET_SUPPORTS_MTTCG without TCG_GUEST_DEFAULT_MO" +# endif +return true; +#else +return false; +#endif +} + +bool target_has_precise_smc (void ) +{ +#ifdef TARGET_HAS_PRECISE_SMC +return true; +#else +return false; +#endif +} + +int target_long_bits (void ) +{ +return TARGET_LONG_BITS ; +} + +int target_phys_addr_space_bits (void ) +{ +return TARGET_PHYS_ADDR_SPACE_BITS ; +} + +uint8_t target_insn_start_words (void ) +{ +return TARGET_INSN_START_WORDS ; +} + +uint8_t target_default_memory_order (void ) +{ +#ifdef TCG_GUEST_DEFAULT_MO +return TCG_GUEST_DEFAULT_MO ; +#else +return TCG_MO_ALL ; +#endif +} + +MemOp target_endian_memory_order (void ) +{ +return MO_TE ; +} + +uint8_t target_tlb_dyn_max_bits (void ) +{ +#if defined(CONFIG_SOFTMMU ) && defined(CONFIG_TCG ) +return CPU_TLB_DYN_MAX_BITS ; +#else +return 0 ; +#endif +} +const char *target_name (void ) {return TARGET_NAME ;
Re: [RFC PATCH 26/34] Wrap target macros in functions
Quoted 31 lines · Philippe Mathieu-Daudé
Hi Anton,
Quoted 28 lines · Anton Johansson
Adds wrapper functions around common target specific macros required by accel/tcg.
Signed-off-by Anton Johansson <[email protected]>--- include/hw/core/cpu.h | 9 +++++++ cpu-target.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)include/hw/core/cpu.h +4
-0@@ -26,6 +26,7 @@#include "exec/vaddr.h" #include "exec/memattrs.h" #include "exec/tlb-common.h" +#include "exec/memop.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/rcu_queue.h" @@ -1164,6 +1165,14 @@ void cpu_exec_unrealizefn(CPUState *cpu);* what you are doing! */ bool target_words_bigendian (void ); +bool target_supports_mttcg (void ); +bool target_has_precise_smc (void ); +int target_long_bits (void );
Quoted 8 lines
include/hw/core/cpu.h void cpu_exec_unrealizefn(CPUState *cpu); · line 1175
Quoted 5 lines
include/hw/core/cpu.h +5
-0+int target_phys_addr_space_bits (void ); +uint8_t target_insn_start_words (void ); +uint8_t target_default_memory_order (void ); +uint8_t target_tlb_dyn_max_bits (void ); +MemOp target_endian_memory_order (void );None of these helpers take argument. I don't understand how they can be called in heterogeneous context.
No you're right, I was focused mostly on getting accel/tcg to compile with hetrogeneous being a goal downt the line.
I like the idea of moving these fields to a struct filled out per target, but dispatching would also work.
Re: [RFC PATCH 26/34] Wrap target macros in functions
Quoted 41 lines · Anton Johansson
Quoted 31 lines · Philippe Mathieu-Daudé
Hi Anton,
Quoted 28 lines · Anton Johansson
Adds wrapper functions around common target specific macros required by accel/tcg.
Signed-off-by Anton Johansson <[email protected]>--- include/hw/core/cpu.h | 9 +++++++ cpu-target.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)include/hw/core/cpu.h +4
-0@@ -26,6 +26,7 @@#include "exec/vaddr.h" #include "exec/memattrs.h" #include "exec/tlb-common.h" +#include "exec/memop.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/rcu_queue.h" @@ -1164,6 +1165,14 @@ void cpu_exec_unrealizefn(CPUState *cpu);* what you are doing! */ bool target_words_bigendian (void ); +bool target_supports_mttcg (void ); +bool target_has_precise_smc (void ); +int target_long_bits (void );Quoted 8 lines
include/hw/core/cpu.h void cpu_exec_unrealizefn(CPUState *cpu); · line 1175
Quoted 5 lines
include/hw/core/cpu.h +5
-0+int target_phys_addr_space_bits (void ); +uint8_t target_insn_start_words (void ); +uint8_t target_default_memory_order (void ); +uint8_t target_tlb_dyn_max_bits (void ); +MemOp target_endian_memory_order (void );None of these helpers take argument. I don't understand how they can be called in heterogeneous context.
Quoted 5 lines
No you're right, I was focused mostly on getting accel/tcg to compile with hetrogeneous being a goal downt the line.
I like the idea of moving these fields to a struct filled out per target, but dispatching would also work.
All of the bits that you're referencing in TCGContext, outside of compilation, should be treated the same way. Like Phil, I'd prefer to move these once and get the API right.
r~
RFC PATCH 27/34 accel/tcg: Make translate-all.c target independent
In reply to Anton Johansson viaMakes translate-all.c independent of softmmu target by switching
TARGET_LONG_BITS -> target_long_bits()
TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words,
target_insn_start_words(),
TCG_GUEST_DEFAULT_MO -> target_default_memory_order()
MO_TE -> target_endian_memory_order()--- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)
accel/tcg/translate-all.c +18 -20
@@ -65,7 +65,6 @@#include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" TBContext tb_ctx;
@@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp) val |= (int64_t )(byte &0x7f ) << shift; shift +=7 ; }while (byte &0x80 ); -if (shift <TARGET_LONG_BITS && (byte &0x40 )) { +if (shift <target_long_bits () && (byte &0x40 )) { val |= -(int64_t )1 << shift; }
@@ -117,7 +116,7 @@ static int64_t decode_sleb128(const uint8_t **pp)/* Encode the data collected about the instructions while compiling TB. Place the data at BLOCK, and return the number of bytes consumed. -The logical table consists of TARGET_INSN_START_WORDS target_ulong's, +The logical table consists of tcg_ctx->insn_start_words target_ulong's, which come from the target's insn_start data, followed by a uintptr_t which comes from the host pc of the end of the code implementing the insn.
@@ -128,6 +127,7 @@ static int64_t decode_sleb128(const uint8_t **pp)static int encode_search (TranslationBlock *tb,uint8_t *block) { +const uint8_t insn_start_words = tcg_ctx->insn_start_words;uint8_t *highwater = tcg_ctx->code_gen_highwater;uint64_t *insn_data = tcg_ctx->gen_insn_data;uint16_t *insn_end_off = tcg_ctx->gen_insn_end_off;
@@ -137,13 +137,13 @@ static int encode_search(TranslationBlock *tb, uint8_t *block)for (i =0 , n = tb->icount; i < n; ++i) {uint64_t prev, curr; -for (j =0 ; j <TARGET_INSN_START_WORDS ; ++j) { +for (j =0 ; j < insn_start_words; ++j) {if (i ==0 ) { prev = (!(tb_cflags (tb) &CF_PCREL ) && j ==0 ? tb->pc :0 ); }else { - prev = insn_data[(i -1 ) *TARGET_INSN_START_WORDS + j]; + prev = insn_data[(i -1 ) * insn_start_words + j]; } - curr = insn_data[i *TARGET_INSN_START_WORDS + j]; + curr = insn_data[i * insn_start_words + j]; p =encode_sleb128 (p, curr - prev); } prev = (i ==0 ?0 : insn_end_off[i -1 ]);
@@ -165,6 +165,7 @@ static int encode_search(TranslationBlock *tb, uint8_t *block)static int cpu_unwind_data_from_tb (TranslationBlock *tb,uintptr_t host_pc,uint64_t *data) { +const uint8_t insn_start_words = tcg_ctx->insn_start_words;uintptr_t iter_pc = (uintptr_t )tb->tc.ptr;const uint8_t *p = tb->tc.ptr + tb->tc.size;int i, j, num_insns = tb->icount;
@@ -175,7 +176,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc,return -1 ; } -memset (data,0 ,sizeof (uint64_t ) *TARGET_INSN_START_WORDS ); +memset (data,0 ,sizeof (uint64_t ) * insn_start_words);if (!(tb_cflags (tb) &CF_PCREL )) { data[0 ] = tb->pc; }
@@ -185,7 +186,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc,* at which the end of the insn exceeds host_pc. */ for (i =0 ; i < num_insns; ++i) { -for (j =0 ; j <TARGET_INSN_START_WORDS ; ++j) { +for (j =0 ; j < insn_start_words; ++j) { data[j] +=decode_sleb128 (&p); } iter_pc +=decode_sleb128 (&p);
@@ -203,7 +204,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc,void cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb,uintptr_t host_pc) { -uint64_t data[TARGET_INSN_START_WORDS ]; +uint64_t data[tcg_ctx->insn_start_words];int insns_left =cpu_unwind_data_from_tb (tb, host_pc, data);if (insns_left <0 ) {
@@ -341,19 +342,15 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } tcg_ctx->gen_tb = tb; - tcg_ctx->addr_type =TARGET_LONG_BITS ==32 ?TCG_TYPE_I32 :TCG_TYPE_I64 ; + tcg_ctx->addr_type =target_long_bits () ==32 ?TCG_TYPE_I32 :TCG_TYPE_I64 ;#ifdef CONFIG_SOFTMMU - tcg_ctx->mo_te =MO_TE ; + tcg_ctx->mo_te =target_endian_memory_order (); tcg_ctx->page_bits =TARGET_PAGE_BITS ; tcg_ctx->page_mask =TARGET_PAGE_MASK ; - tcg_ctx->tlb_dyn_max_bits =CPU_TLB_DYN_MAX_BITS ; -#endif - tcg_ctx->insn_start_words =TARGET_INSN_START_WORDS ; -#ifdef TCG_GUEST_DEFAULT_MO - tcg_ctx->guest_mo =TCG_GUEST_DEFAULT_MO ; -#else - tcg_ctx->guest_mo =TCG_MO_ALL ; + tcg_ctx->tlb_dyn_max_bits =target_tlb_dyn_max_bits ();#endif + tcg_ctx->insn_start_words =target_insn_start_words (); + tcg_ctx->guest_mo =target_default_memory_order (); restart_translate:trace_translate_block (tb, pc, tb->tc.ptr);
@@ -441,6 +438,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, qemu_log_in_addr_range(pc)) {FILE *logfile =qemu_log_trylock ();if (logfile) { +const uint8_t insn_start_words = tcg_ctx->insn_start_words;int code_size, data_size;const tcg_target_ulong *rx_data_gen_ptr;size_t chunk_start;
@@ -460,7 +458,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,fprintf (logfile,"OUT: [size=%d]\n" , gen_code_size);fprintf (logfile," -- guest addr 0x%016" PRIx64" + tb prologue\n" , - tcg_ctx->gen_insn_data[insn *TARGET_INSN_START_WORDS ]); + tcg_ctx->gen_insn_data[insn * insn_start_words]); chunk_start = tcg_ctx->gen_insn_end_off[insn];disas (logfile, tb->tc.ptr, chunk_start);
@@ -473,7 +471,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,size_t chunk_end = tcg_ctx->gen_insn_end_off[insn];if (chunk_end > chunk_start) {fprintf (logfile," -- guest addr 0x%016" PRIx64"\n" , - tcg_ctx->gen_insn_data[insn *TARGET_INSN_START_WORDS ]); + tcg_ctx->gen_insn_data[insn * insn_start_words]);disas (logfile, tb->tc.ptr + chunk_start, chunk_end - chunk_start); chunk_start = chunk_end;
Signature · 1 line
2.43.0
Re: [RFC PATCH 27/34] accel/tcg: Make translate-all.c target independent
Quoted 29 lines · Anton Johansson
Makes
translate-all.cindependent of softmmu target by switchingTARGET_LONG_BITS -> target_long_bits() TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words, target_insn_start_words(), TCG_GUEST_DEFAULT_MO -> target_default_memory_order() MO_TE -> target_endian_memory_order()Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)accel/tcg/translate-all.c +0
-1@@ -65,7 +65,6 @@#include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" TBContext tb_ctx;
accel/tcg/translate-all.c static int64_t decode_sleb128(const uint8_t **pp) · line 108
Quoted 5 lines
accel/tcg/translate-all.c +1
-1@@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp) val |= (int64_t )(byte &0x7f ) << shift; shift +=7 ; }while (byte &0x80 ); -if (shift <TARGET_LONG_BITS && (byte &0x40 )) { +if (shift <target_long_bits () && (byte &0x40 )) {
You just make TARGET_PAGE_SIZE etc target independent, right? So you don't need this? Or is this because of user-only still.
accel/tcg/translate-all.c static int64_t decode_sleb128(const uint8_t **pp) · line 130
Quoted 3 lines
accel/tcg/translate-all.c +1
-0static int encode_search (TranslationBlock *tb,uint8_t *block) { +const uint8_t insn_start_words = tcg_ctx->insn_start_words;
Ok, because we're still inside the compilation context.
Quoted 4 lines
static int cpu_unwind_data_from_tb(TranslationBlock *tb,
uintptr_thost_pc,uint64_t *data){
+ constuint8_tinsn_start_words=tcg_ctx->insn_start_words;
Not ok, because we're outside of the compilation context.
r~
Re: [RFC PATCH 27/34] accel/tcg: Make translate-all.c target independent
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Anton Johansson
Makes
translate-all.cindependent of softmmu target by switchingTARGET_LONG_BITS -> target_long_bits() TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words, target_insn_start_words(), TCG_GUEST_DEFAULT_MO -> target_default_memory_order() MO_TE -> target_endian_memory_order()Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)accel/tcg/translate-all.c +0
-1@@ -65,7 +65,6 @@#include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" TBContext tb_ctx;@@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp)
Quoted 8 lines
accel/tcg/translate-all.c static int64_t decode_sleb128(const uint8_t **pp) · line 108
Quoted 5 lines
accel/tcg/translate-all.c +1
-1val |= (int64_t )(byte &0x7f ) << shift; shift +=7 ; }while (byte &0x80 ); -if (shift <TARGET_LONG_BITS && (byte &0x40 )) { +if (shift <target_long_bits () && (byte &0x40 )) {You just make
TARGET_PAGE_SIZEetc target independent, right? So you don't need this? Or is this because of user-only still.
Hi, Richard!
I missed this piece of feedback previously. I don't see how TARGET_PAGE_[SIZE|BITS] would be used here. Are the values we're encoding always TARGET_PAGE_BITS in size?
//Anton
Re: [RFC PATCH 27/34] accel/tcg: Make translate-all.c target independent
Quoted 38 lines · Anton Johansson
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Anton Johansson
Makes
translate-all.cindependent of softmmu target by switchingTARGET_LONG_BITS -> target_long_bits() TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words, target_insn_start_words(), TCG_GUEST_DEFAULT_MO -> target_default_memory_order() MO_TE -> target_endian_memory_order()Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)accel/tcg/translate-all.c +0
-1@@ -65,7 +65,6 @@#include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" TBContext tb_ctx;@@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp)Quoted 8 lines
accel/tcg/translate-all.c static int64_t decode_sleb128(const uint8_t **pp) · line 108
Quoted 5 lines
accel/tcg/translate-all.c +1
-1val |= (int64_t )(byte &0x7f ) << shift; shift +=7 ; }while (byte &0x80 ); -if (shift <TARGET_LONG_BITS && (byte &0x40 )) { +if (shift <target_long_bits () && (byte &0x40 )) {You just make
TARGET_PAGE_SIZEetc target independent, right? So you don't need this? Or is this because of user-only still.
Quoted 5 lines
Hi, Richard!
I missed this piece of feedback previously. I don't see how TARGET_PAGE_[SIZE|BITS] would be used here. Are the values we're encoding always
TARGET_PAGE_BITSin size?
I was obviously tired here, since they're obviously unrelated.
However in this case I think TARGET_LONG_BITS is a red herring, and we should be using int64_t not target_long at all, and thus the shift count must be less than 64.
r~
Re: [RFC PATCH 27/34] accel/tcg: Make translate-all.c target independent
Quoted 45 lines · Richard Henderson
Quoted 38 lines · Anton Johansson
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Anton Johansson
Makes
translate-all.cindependent of softmmu target by switchingTARGET_LONG_BITS -> target_long_bits() TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words, target_insn_start_words(), TCG_GUEST_DEFAULT_MO -> target_default_memory_order() MO_TE -> target_endian_memory_order()Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)accel/tcg/translate-all.c +0
-1@@ -65,7 +65,6 @@#include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" TBContext tb_ctx;@@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp)Quoted 8 lines
accel/tcg/translate-all.c static int64_t decode_sleb128(const uint8_t **pp) · line 108
Quoted 5 lines
accel/tcg/translate-all.c +1
-1val |= (int64_t )(byte &0x7f ) << shift; shift +=7 ; }while (byte &0x80 ); -if (shift <TARGET_LONG_BITS && (byte &0x40 )) { +if (shift <target_long_bits () && (byte &0x40 )) {You just make
TARGET_PAGE_SIZEetc target independent, right? So you don't need this? Or is this because of user-only still.Quoted 5 lines
Hi, Richard!
I missed this piece of feedback previously. I don't see how TARGET_PAGE_[SIZE|BITS] would be used here. Are the values we're encoding always
TARGET_PAGE_BITSin size?
Quoted 9 lines
I was obviously tired here, since they're obviously unrelated.
However in this case I think
TARGET_LONG_BITSis a red herring, and we should be usingint64_tnottarget_longat all, and thus the shift count must be less than 64.r~
Ah I see, thanks!:) I'll give that a go then.
Signature · 2 lines
Anton Johansson rev.ng Labs Srl.
RFC PATCH 28/34 accel/tcg: Make plugin-gen.c target independent
In reply to Anton Johansson viaSwitches computation of offsets into CPUState to use that the offset between CPUState and CPUArchState is guaranteed to be sizeof(CPUState).
--- accel/tcg/plugin-gen.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
accel/tcg/plugin-gen.c +7 -8
@@ -43,10 +43,9 @@* CPU's index into a TCG temp, since the first callback did it already. */ #include "qemu/osdep.h" -#include "cpu.h" #include "tcg/tcg.h" #include "tcg/tcg-temp-internal.h" -#include "tcg/tcg-op.h" +#include "tcg/tcg-op-common.h" #include "exec/exec-all.h" #include "exec/plugin-gen.h" #include "exec/translator.h"
@@ -104,8 +103,8 @@ static void gen_empty_udata_cb(void)TCGv_ptr udata =tcg_temp_ebb_new_ptr ();tcg_gen_movi_ptr (udata,0 ); -tcg_gen_ld_i32 (cpu_index, tcg_env, - -offsetof(ArchCPU , env) + offsetof(CPUState , cpu_index)); +tcg_gen_ld_i32 (cpu_index, tcg_env, offsetof(CPUState , cpu_index) - +sizeof (CPUState));gen_helper_plugin_vcpu_udata_cb (cpu_index, udata);tcg_temp_free_ptr (udata);
@@ -138,8 +137,8 @@ static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info)tcg_gen_movi_i32 (meminfo, info);tcg_gen_movi_ptr (udata,0 ); -tcg_gen_ld_i32 (cpu_index, tcg_env, - -offsetof(ArchCPU , env) + offsetof(CPUState , cpu_index)); +tcg_gen_ld_i32 (cpu_index, tcg_env, offsetof(CPUState , cpu_index) - +sizeof (CPUState));gen_helper_plugin_vcpu_mem_cb (cpu_index, meminfo, addr, udata);
@@ -158,7 +157,7 @@ static void gen_empty_mem_helper(void)tcg_gen_movi_ptr (ptr,0 );tcg_gen_st_ptr (ptr, tcg_env, offsetof(CPUState , plugin_mem_cbs) - - offsetof(ArchCPU , env)); +sizeof (CPUState));tcg_temp_free_ptr (ptr); }
@@ -582,7 +581,7 @@ void plugin_gen_disable_mem_helpers(void)return ; }tcg_gen_st_ptr (tcg_constant_ptr (NULL ), tcg_env, - offsetof(CPUState , plugin_mem_cbs) - offsetof(ArchCPU , env)); + offsetof(CPUState , plugin_mem_cbs) -sizeof (CPUState)); } static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb,
Signature · 1 line
2.43.0
Re: [RFC PATCH 28/34] accel/tcg: Make plugin-gen.c target independent
Quoted 7 lines · Anton Johansson
Switches computation of offsets into CPUState to use that the offset between CPUState and CPUArchState is guaranteed to be sizeof(CPUState).
Signed-off-by Anton Johansson<[email protected]>--- accel/tcg/plugin-gen.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
r~
RFC PATCH 29/34 accel/tcg: Make tb-maint.c target indpendent
In reply to Anton Johansson viaUses target_has_precise_smc() and target_phys_addr_space_bits() to turn ifdefs into runtime branches.
--- accel/tcg/tb-maint.c | 47 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-)
accel/tcg/tb-maint.c +25 -22
@@ -148,14 +148,6 @@ static PageForEachNext foreach_tb_next(PageForEachNext tb, }#else -/* -* In system mode we want L1_MAP to be based on ram offsets. -*/ -#if HOST_LONG_BITS <TARGET_PHYS_ADDR_SPACE_BITS -# define L1_MAP_ADDR_SPACE_BITS HOST_LONG_BITS -#else -# define L1_MAP_ADDR_SPACE_BITS TARGET_PHYS_ADDR_SPACE_BITS -#endif /* Size of the L2 (and L3, etc) page tables. */ #define V_L2_BITS 10
@@ -186,17 +178,28 @@ struct PageDesc {void page_table_config_init (void ) { +int target_phys_addr_bits =target_phys_addr_space_bits (); +uint32_t l1_map_addr_space_bits;uint32_t v_l1_bits; +/* +* In system mode we want L1_MAP to be based on ram offsets. +*/ +if (HOST_LONG_BITS < target_phys_addr_bits) { + l1_map_addr_space_bits =HOST_LONG_BITS ; + }else { + l1_map_addr_space_bits = target_phys_addr_bits; + } +assert (TARGET_PAGE_BITS );/* The bits remaining after N lower levels of page tables. */ - v_l1_bits = (L1_MAP_ADDR_SPACE_BITS -TARGET_PAGE_BITS ) %V_L2_BITS ; + v_l1_bits = (l1_map_addr_space_bits -TARGET_PAGE_BITS ) %V_L2_BITS ;if (v_l1_bits <V_L1_MIN_BITS ) { v_l1_bits +=V_L2_BITS ; } v_l1_size =1 << v_l1_bits; - v_l1_shift =L1_MAP_ADDR_SPACE_BITS -TARGET_PAGE_BITS - v_l1_bits; + v_l1_shift = l1_map_addr_space_bits -TARGET_PAGE_BITS - v_l1_bits; v_l2_levels = v_l1_shift /V_L2_BITS -1 ;assert (v_l1_bits <=V_L1_MAX_BITS );
@@ -1045,14 +1048,15 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)TranslationBlock *tb;PageForEachNext n;tb_page_addr_t last; +const bool has_precise_smc =target_has_precise_smc ();/* * Without precise smc semantics, or when outside of a TB, * we can skip to invalidate. */ -#ifndef TARGET_HAS_PRECISE_SMC - pc =0 ; -#endif +if (!has_precise_smc) { + pc =0 ; + }if (!pc) {tb_invalidate_phys_page (addr);return false;
@@ -1102,10 +1106,13 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, {TranslationBlock *tb;PageForEachNext n; -#ifdef TARGET_HAS_PRECISE_SMC +const bool has_precise_smc =target_has_precise_smc ();bool current_tb_modified = false; -TranslationBlock *current_tb = retaddr ?tcg_tb_lookup (retaddr) :NULL ; -#endif /* TARGET_HAS_PRECISE_SMC */ +TranslationBlock *current_tb =NULL ; + +if (has_precise_smc && retaddr) { + current_tb =tcg_tb_lookup (retaddr); + }/* Range may not cross a page. */ tcg_debug_assert (((start ^ last) &TARGET_PAGE_MASK ) ==0 );
@@ -1127,8 +1134,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, tb_last = tb_start + (tb_last & ~TARGET_PAGE_MASK ); }if (!(tb_last < start || tb_start > last)) { -#ifdef TARGET_HAS_PRECISE_SMC -if (current_tb == tb && +if (has_precise_smc && current_tb == tb && (tb_cflags (current_tb) &CF_COUNT_MASK ) !=1 ) {/* * If we are modifying the current TB, we must stop
@@ -1140,7 +1146,6 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, current_tb_modified = true;cpu_restore_state_from_tb (current_cpu, current_tb, retaddr); } -#endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate__locked (tb); } }
@@ -1150,15 +1155,13 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,tlb_unprotect_code (start); } -#ifdef TARGET_HAS_PRECISE_SMC -if (current_tb_modified) { +if (has_precise_smc && current_tb_modified) {page_collection_unlock (pages);/* Force execution of one insn next time. */ current_cpu->cflags_next_tb =1 |CF_NOIRQ |curr_cflags (current_cpu);mmap_unlock ();cpu_loop_exit_noexc (current_cpu); } -#endif }/*
Signature · 1 line
2.43.0
Re: [RFC PATCH 29/34] accel/tcg: Make tb-maint.c target indpendent
Quoted 14 lines · Anton Johansson
Uses
target_has_precise_smc()andtarget_phys_addr_space_bits()to turn ifdefs into runtime branches.Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/tb-maint.c | 47 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-)accel/tcg/tb-maint.c +0
-0@@ -148,14 +148,6 @@ static PageForEachNext foreach_tb_next(PageForEachNext tb, }
accel/tcg/tb-maint.c static PageForEachNext foreach_tb_next(PageForEachNext tb, · line 158
Quoted 10 lines
accel/tcg/tb-maint.c +0
-8#else -/* -* In system mode we want L1_MAP to be based on ram offsets. -*/ -#if HOST_LONG_BITS <TARGET_PHYS_ADDR_SPACE_BITS -# define L1_MAP_ADDR_SPACE_BITS HOST_LONG_BITS -#else -# define L1_MAP_ADDR_SPACE_BITS TARGET_PHYS_ADDR_SPACE_BITS -#endif
I'm not keen on this. We can make this target independent in several ways:
(1) Use fixed constants that cover all 64 phys addr bits,
(2) Use a different data structure entirely (e.g. IntervalTree).
Preserving the existing data structure, using variables, seems like a poor choice.
Quoted 6 lines
accel/tcg/tb-maint.c +1
-0@@ -1045,14 +1048,15 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)TranslationBlock *tb;PageForEachNext n;tb_page_addr_t last; +const bool has_precise_smc =target_has_precise_smc ();
accel/tcg/tb-maint.c bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) · line 1059
Quoted 10 lines
accel/tcg/tb-maint.c +3
-3/* * Without precise smc semantics, or when outside of a TB, * we can skip to invalidate. */ -#ifndef TARGET_HAS_PRECISE_SMC - pc =0 ; -#endif +if (!has_precise_smc) { + pc =0 ; + }
Ok to this part. Split it out.
r~
RFC PATCH 30/34 accel/tcg: Make tcg-all.c target indpendent
In reply to Anton Johansson viaUses target_supports_mttcg() and target_long_bits() to turn ifdefs into runtime branches.
--- accel/tcg/tcg-all.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
accel/tcg/tcg-all.c +9 -16
@@ -28,7 +28,6 @@#include "exec/replay-core.h" #include "sysemu/cpu-timers.h" #include "tcg/tcg.h" -#include "tcg/oversized-guest.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/accel.h"
@@ -67,20 +66,13 @@ DECLARE_INSTANCE_CHECKER(TCGState, TCG_STATE,* there is one remaining limitation to check: * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) */ -static bool default_mttcg_enabled (void ) { -if (icount_enabled () ||TCG_OVERSIZED_GUEST ) { +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ; +if (icount_enabled () || oversized_guest) {return false; } -#ifdef TARGET_SUPPORTS_MTTCG -# ifndef TCG_GUEST_DEFAULT_MO -# error "TARGET_SUPPORTS_MTTCG without TCG_GUEST_DEFAULT_MO" -# endif -return true; -#else -return false; -#endif +return target_supports_mttcg (); }static void tcg_accel_instance_init (Object *obj)
@@ -137,17 +129,18 @@ static char *tcg_get_thread(Object *obj, Error **errp)static void tcg_set_thread (Object *obj,const char *value,Error **errp) {TCGState *s =TCG_STATE (obj); +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ;if (strcmp (value,"multi" ) ==0 ) { -if (TCG_OVERSIZED_GUEST ) { +if (oversized_guest) {error_setg (errp,"No MTTCG when guest word size > hosts" ); }else if (icount_enabled ()) {error_setg (errp,"No MTTCG when icount is enabled" ); }else { -#ifndef TARGET_SUPPORTS_MTTCG -warn_report ("Guest not yet converted to MTTCG - " -"you may get unexpected results" ); -#endif +if (target_supports_mttcg ()) { +warn_report ("Guest not yet converted to MTTCG - " +"you may get unexpected results" ); + } s->mttcg_enabled = true; } }else if (strcmp (value,"single" ) ==0 ) {
Signature · 1 line
2.43.0
Re: [RFC PATCH 30/34] accel/tcg: Make tcg-all.c target indpendent
Hi Anton,
Quoted 18 lines · Anton Johansson
Uses
target_supports_mttcg()andtarget_long_bits()to turn ifdefs into runtime branches.Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/tcg-all.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)static void
tcg_accel_instance_init(Object *obj)accel/tcg/tcg-all.c +1
-1@@ -137,17 +129,18 @@ static char *tcg_get_thread(Object *obj, Error **errp)static void tcg_set_thread (Object *obj,const char *value,Error **errp) {TCGState *s =TCG_STATE (obj); +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ;if (strcmp (value,"multi" ) ==0 ) { -if (TCG_OVERSIZED_GUEST ) {
accel/tcg/tcg-all.c static char *tcg_get_thread(Object *obj, Error **errp) · line 140
Quoted 10 lines
accel/tcg/tcg-all.c +2
-4+if (oversized_guest) {error_setg (errp,"No MTTCG when guest word size > hosts" ); }else if (icount_enabled ()) {error_setg (errp,"No MTTCG when icount is enabled" ); }else { -#ifndef TARGET_SUPPORTS_MTTCG -warn_report ("Guest not yet converted to MTTCG - " -"you may get unexpected results" ); -#endif +if (target_supports_mttcg ()) {
I started smth similar but then realized this call has to be per target, so put my work on hold. My plan is to have a single common tcg accelerator framework, having target-specific code handled by vcpu dispatchers. Is your plan to have each target link its own tcg?
Quoted 6 lines
accel/tcg/tcg-all.c +3
-0+warn_report ("Guest not yet converted to MTTCG - " +"you may get unexpected results" ); + } s->mttcg_enabled = true; } }else if (strcmp (value,"single" ) ==0 ) {
Re: [RFC PATCH 30/34] accel/tcg: Make tcg-all.c target indpendent
Quoted 27 lines · Philippe Mathieu-Daudé
Hi Anton,
Quoted 24 lines · Anton Johansson
Uses
target_supports_mttcg()andtarget_long_bits()to turn ifdefs into runtime branches.Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/tcg-all.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)static void
tcg_accel_instance_init(Object *obj)accel/tcg/tcg-all.c +2
-3@@ -137,17 +129,18 @@ static char *tcg_get_thread(Object *obj, Error **errp)static void tcg_set_thread (Object *obj,const char *value,Error **errp) {TCGState *s =TCG_STATE (obj); +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ;if (strcmp (value,"multi" ) ==0 ) { -if (TCG_OVERSIZED_GUEST ) { +if (oversized_guest) {error_setg (errp,"No MTTCG when guest word size > hosts" ); }else if (icount_enabled ()) {error_setg (errp,"No MTTCG when icount is enabled" ); }else { -#ifndef TARGET_SUPPORTS_MTTCG - warn_report("Guest not yet converted to MTTCG - "
Quoted 8 lines
accel/tcg/tcg-all.c static char *tcg_get_thread(Object *obj, Error **errp) · line 140
Quoted 3 lines
accel/tcg/tcg-all.c +1
-2- "you may get unexpected results"); -#endif +if (target_supports_mttcg ()) {I started smth similar but then realized this call has to be per target, so put my work on hold. My plan is to have a single common tcg accelerator framework, having target-specific code handled by vcpu dispatchers. Is your plan to have each target link its own tcg?
Yes I was leaning towards one tcg per target, but hadn't put much thought into it. I think your approach is better. This patchset was primarily focused on getting accl/tcg/ to compile once, with heterogeneous stuff coming down the line. IMO it becomes a bit easier to see what target-specific information we really need.
What do you think of a simple TargetConfig struct for information such as target_supports_mttcg() and the other functions introduced in cpu-target.c? We probably need dispatcher for other stuff but I think we can get quite far with struct.
Re: [RFC PATCH 30/34] accel/tcg: Make tcg-all.c target indpendent
In reply to Anton Johansson viaQuoted 58 lines · Anton Johansson
Uses
target_supports_mttcg()andtarget_long_bits()to turn ifdefs into runtime branches.Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/tcg-all.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)accel/tcg/tcg-all.c +5
-13@@ -28,7 +28,6 @@#include "exec/replay-core.h" #include "sysemu/cpu-timers.h" #include "tcg/tcg.h" -#include "tcg/oversized-guest.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/accel.h" @@ -67,20 +66,13 @@ DECLARE_INSTANCE_CHECKER(TCGState, TCG_STATE,* there is one remaining limitation to check: * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) */ -static bool default_mttcg_enabled (void ) { -if (icount_enabled () ||TCG_OVERSIZED_GUEST ) { +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ; +if (icount_enabled () || oversized_guest) {return false; } -#ifdef TARGET_SUPPORTS_MTTCG -# ifndef TCG_GUEST_DEFAULT_MO -# error "TARGET_SUPPORTS_MTTCG without TCG_GUEST_DEFAULT_MO" -# endif -return true; -#else -return false; -#endif +return target_supports_mttcg (); }static void tcg_accel_instance_init (Object *obj)@@ -137,17 +129,18 @@ static char *tcg_get_thread(Object *obj, Error **errp)static void tcg_set_thread (Object *obj,const char *value,Error **errp) {TCGState *s =TCG_STATE (obj); +const bool oversized_guest =target_long_bits () >TCG_TARGET_REG_BITS ;if (strcmp (value,"multi" ) ==0 ) { -if (TCG_OVERSIZED_GUEST ) { +if (oversized_guest) {error_setg (errp,"No MTTCG when guest word size > hosts" ); }else if (icount_enabled ()) {error_setg (errp,"No MTTCG when icount is enabled" ); }else { -#ifndef TARGET_SUPPORTS_MTTCG
accel/tcg/tcg-all.c static char *tcg_get_thread(Object *obj, Error **errp) · line 146
Quoted 10 lines
accel/tcg/tcg-all.c +4
-3-warn_report ("Guest not yet converted to MTTCG - " -"you may get unexpected results" ); -#endif +if (target_supports_mttcg ()) { +warn_report ("Guest not yet converted to MTTCG - " +"you may get unexpected results" ); + } s->mttcg_enabled = true; } }else if (strcmp (value,"single" ) ==0 ) {
All of this happens at startup. Are you sure you're going to have determined these values early enough for heterogeneous mode? I guess for the moment you don't care, because they're all constants supplied by functions.
r~
RFC PATCH 31/34 accel/tcg: Make tcg-runtime-gvec.c target independent
In reply to Anton Johansson viaOnly depends on cpu.h.
--- accel/tcg/tcg-runtime-gvec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/tcg-runtime-gvec.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "qemu/host-utils.h" -#include "cpu.h" +#include "qemu/bitops.h" #include "exec/helper-proto-common.h" #include "tcg/tcg-gvec-desc.h"
Signature · 1 line
2.43.0
Re: [RFC PATCH 31/34] accel/tcg: Make tcg-runtime-gvec.c target independent
Quoted 1 line · Anton Johansson
Only depends on
cpu.h.
s/Only/Doesn't/ ?
Anyway,
r~
RFC PATCH 32/34 accel/tcg: Make tcg-runtime.c target independent
In reply to Anton Johansson viaOnly depends on cpu.h.
--- accel/tcg/tcg-runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/tcg-runtime.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" #include "qemu/host-utils.h" -#include "cpu.h" +#include "qemu/atomic.h" #include "exec/helper-proto-common.h" #include "exec/cpu_ldst.h" #include "exec/exec-all.h"
Signature · 1 line
2.43.0
Re: [RFC PATCH 32/34] accel/tcg: Make tcg-runtime.c target independent
Quoted 1 line · Anton Johansson
Only depends on
cpu.h.
Likewise,
r~
Quoted 19 lines
Signed-off-by Anton Johansson <[email protected]>--- accel/tcg/tcg-runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)accel/tcg/tcg-runtime.c +1
-1@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" #include "qemu/host-utils.h" -#include "cpu.h" +#include "qemu/atomic.h" #include "exec/helper-proto-common.h" #include "exec/cpu_ldst.h" #include "exec/exec-all.h"
RFC PATCH 33/34 accel/tcg: Make translator.c (partially) target independent
In reply to Anton Johansson viaMake CPUState offset calculations target independent by using that CPUState and CPUArchState are statically guaranteed to lie next to each other in memory.
--- accel/tcg/translator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
accel/tcg/translator.c +8 -8
@@ -19,8 +19,8 @@static void gen_io_start (void ) {tcg_gen_st_i32 (tcg_constant_i32 (1 ), tcg_env, - offsetof(ArchCPU, parent_obj.neg.can_do_io) - - offsetof(ArchCPU, env)); + offsetof(CPUState, neg.can_do_io) - +sizeof (CPUState)); }bool translator_io_start (DisasContextBase *db)
@@ -53,8 +53,8 @@ static TCGOp *gen_tb_start(uint32_t cflags)TCGOp *icount_start_insn =NULL ;tcg_gen_ld_i32 (count, tcg_env, - offsetof(ArchCPU, parent_obj.neg.icount_decr.u32) - - offsetof(ArchCPU, env)); + offsetof(CPUState, neg.icount_decr.u32) - + sizeof(CPUState));if (cflags &CF_USE_ICOUNT ) {/*
@@ -82,8 +82,8 @@ static TCGOp *gen_tb_start(uint32_t cflags)if (cflags &CF_USE_ICOUNT ) {tcg_gen_st16_i32 (count, tcg_env, - offsetof(ArchCPU, parent_obj.neg.icount_decr.u16.low) - - offsetof(ArchCPU, env)); + offsetof(CPUState, neg.icount_decr.u16.low) - + sizeof(CPUState));/* * cpu->can_do_io is cleared automatically here at the beginning of * each translation block. The cost is minimal and only paid for
@@ -92,8 +92,8 @@ static TCGOp *gen_tb_start(uint32_t cflags)* go with gen_io_start(). */ tcg_gen_st_i32 (tcg_constant_i32 (0 ), tcg_env, - offsetof(ArchCPU, parent_obj.neg.can_do_io) - - offsetof(ArchCPU, env)); + offsetof(CPUState, neg.can_do_io) - +sizeof (CPUState)); }return icount_start_insn;
Signature · 1 line
2.43.0
Re: [RFC PATCH 33/34] accel/tcg: Make translator.c (partially) target independent
Quoted 8 lines · Anton Johansson
Make CPUState offset calculations target independent by using that CPUState and CPUArchState are statically guaranteed to lie next to each other in memory.
Signed-off-by Anton Johansson<[email protected]>--- accel/tcg/translator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
r~
RFC PATCH 34/34 accel/tcg: Compile (a few files) once for system-mode
In reply to Anton Johansson viaBuild a common static library for a few softmmu files.
--- accel/tcg/meson.build | 57 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-)
accel/tcg/meson.build +45 -12
@@ -1,28 +1,61 @@ -tcg_ss = ss.source_set() +tcg_specific_ss = ss.source_set() +tcg_user_ss = ss.source_set() common_ss.add(when: 'CONFIG_TCG', if_true: files( 'cpu-exec-common.c', )) -tcg_ss.add(files( - 'tcg-all.c', +common_ss.add(when: libdw, if_true: files('debuginfo.c')) + +tcg_specific_ss.add(files( 'cpu-exec.c', + 'translator.c', +)) + +tcg_user_ss.add(files( + 'user-exec.c', + 'translate-all.c', 'tb-maint.c', 'tcg-runtime-gvec.c', 'tcg-runtime.c', - 'translate-all.c', - 'translator.c', + 'tcg-all.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')) if get_option('plugins') - tcg_ss.add(files('plugin-gen.c')) + tcg_user_ss.add(files('plugin-gen.c')) endif -tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) -tcg_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c')) -specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) +tcg_specific_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: tcg_user_ss) +tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files( + 'user-exec-stub.c' +)) +tcg_specific_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c')) +specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) -specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( +have_tcg = get_option('tcg').allowed() +tcg_softmmu_ss = ss.source_set() +tcg_softmmu_ss.add(files( 'cputlb.c', + 'translate-all.c', + 'tb-maint.c', + 'tcg-runtime-gvec.c', + 'tcg-runtime.c', + 'tcg-all.c', )) +if get_option('plugins') + tcg_softmmu_ss.add(files('plugin-gen.c')) +endif +tcg_softmmu_ss = tcg_softmmu_ss.apply(config_targetos, strict: false) + +libacceltcg_softmmu = static_library('acceltcg_softmmu', + tcg_softmmu_ss.sources() + genh, + name_suffix: 'fa', + c_args: '-DCONFIG_SOFTMMU', + build_by_default: have_system and + have_tcg) + +if not get_option('tcg').allowed() + subdir_done() +endif +tcg_softmmu = declare_dependency(link_with: libacceltcg_softmmu, + dependencies: tcg_softmmu_ss.dependencies()) +system_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: tcg_softmmu) system_ss.add(when: ['CONFIG_TCG'], if_true: files( 'icount-common.c',
Signature · 1 line
2.43.0