Hexagon system emulation - Part 1/3
v3 cover Hexagon system emulation - Part 1/3
This is Part 1 of the hexagon system emulation (sysemu) patch series, providing the foundational target infrastructure needed for full-system emulation of the Qualcomm Hexagon DSP.
Changes since v2:
- Rebased onto latest tip
- Refactored TLB from embedded CPUHexagonTLBContext struct to a proper QOM SysBusDevice (TYPE_HEXAGON_TLB).
- Folded "Add initial MMU model" into "Add stubs for modify_ssr/ get_exe_mode" since the TLB QOM device, hex_mmu.h, and hex_mmu.c are now introduced together
- Folded "Add gdb support for sys regs" into earlier patches
- Significantly reduced attribute definitions in attribs_def.h.inc
- Added #ifndef CONFIG_USER_ONLY guards around hexagon_sregnames[]
and hexagon_gregnames[] extern declarations in internal.h
- Adapted to tip removing gen_tcg_func_table.py; added empty stubs for tag_ignored instructions in gen_tcg_funcs.py
- Absorbed "initialize sys/guest reg TCGvs" commit into "Add TCG values for sreg, greg"
- Used hex_dump_mmu_entry() helper in MMU model for cleaner TLB dump
- Cleaned up system register names (s59-s63 placeholder convention)
- Fixed 0xffffffffULL -> 0xffffffff for UINT32 properties
Previous versions:
v2: https://lore.kernel.org/qemu-devel/[email protected]/
v1: https://lore.kernel.org/qemu-devel/[email protected]/
Brian Cain (37):
docs: Add hexagon sysemu docs
docs/system: Add hexagon CPU emulation
target/hexagon: Fix badva reference, delete CAUSE target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof target/hexagon: Handle system/guest registers in gen_analyze_funcs.py
and hex_common.py
target/hexagon: Make gen_exception_end_tb non-static target/hexagon: Switch to tag_ignore(), generate via
get_{user,sys}_tags() target/hexagon: Add system event, cause codes target/hexagon: Add privilege check, use tag_ignore() target/hexagon: Add memory order definition target/hexagon: Add a placeholder fp exception target/hexagon: Add guest, system reg number defs target/hexagon: Add guest, system reg number state target/hexagon: Add TCG values for sreg, greg target/hexagon: Add guest/sys reg writes to DisasContext target/hexagon: Add imported macro, attr defs for sysemu target/hexagon: Add new macro definitions for sysemu target/hexagon: Add handlers for guest/sysreg r/w target/hexagon: Add placeholder greg/sreg r/w helpers target/hexagon: Add vmstate representation target/hexagon: Make A_PRIV, "J2_trap*" insts need_env() target/hexagon: Define register fields for system regs target/hexagon: Implement do_raise_exception() target/hexagon: Add system reg insns target/hexagon: Add sysemu TCG overrides target/hexagon: Add implicit attributes to sysemu macros target/hexagon: Add TCG overrides for int handler insts target/hexagon: Add TCG overrides for thread ctl target/hexagon: Add TCG overrides for rte, nmi target/hexagon: Add sreg_{read,write} helpers target/hexagon: Add locks, id, next_PC to state target/hexagon: Add a TLB count property target/hexagon: Add {TLB,k0}lock, cause code, wait_next_pc target/hexagon: Add stubs for modify_ssr/get_exe_mode target/hexagon: Add clear_wait_mode() definition target/hexagon: Define f{S,G}ET_FIELD macros target/hexagon: Add hex_interrupts support
MAINTAINERS | 3 + docs/devel/hexagon-sys.rst | 112 +++++ docs/devel/index-internals.rst | 1 + docs/system/hexagon/cdsp.rst | 12 + docs/system/hexagon/emulation.rst | 15 + docs/system/target-hexagon.rst | 103 +++++ docs/system/targets.rst | 1 + include/hw/hexagon/hexagon_tlb.h | 47 ++ target/hexagon/cpu-param.h | 9 + target/hexagon/cpu.h | 69 ++- target/hexagon/cpu_bits.h | 82 +++- target/hexagon/cpu_helper.h | 45 ++ target/hexagon/gen_tcg.h | 9 + target/hexagon/gen_tcg_sys.h | 102 +++++ target/hexagon/helper.h | 22 + target/hexagon/hex_interrupts.h | 15 + target/hexagon/hex_mmu.h | 25 ++ target/hexagon/hex_regs.h | 115 +++++ target/hexagon/internal.h | 17 + target/hexagon/macros.h | 35 +- target/hexagon/sys_macros.h | 237 ++++++++++ target/hexagon/translate.h | 43 ++ target/hexagon/attribs_def.h.inc | 49 ++- target/hexagon/reg_fields_def.h.inc | 96 ++++ hw/hexagon/hexagon_tlb.c | 457 +++++++++++++++++++ linux-user/hexagon/cpu_loop.c | 16 + target/hexagon/arch.c | 5 + target/hexagon/cpu.c | 57 ++- target/hexagon/cpu_helper.c | 91 ++++ target/hexagon/genptr.c | 151 +++++++ target/hexagon/hex_interrupts.c | 332 ++++++++++++++ target/hexagon/hex_mmu.c | 273 ++++++++++++ target/hexagon/machine.c | 32 ++ target/hexagon/op_helper.c | 139 +++++- target/hexagon/translate.c | 32 +- target/hexagon/gen_analyze_funcs.py | 21 +- target/hexagon/gen_helper_funcs.py | 26 +- target/hexagon/gen_helper_protos.py | 23 +- target/hexagon/gen_idef_parser_funcs.py | 2 + target/hexagon/gen_op_attribs.py | 2 +- target/hexagon/gen_opcodes_def.py | 5 +- target/hexagon/gen_tcg_funcs.py | 35 +- target/hexagon/hex_common.py | 176 +++++++- target/hexagon/imported/encode_pp.def | 128 +++++- target/hexagon/imported/macros.def | 558 ++++++++++++++++++++++++ target/hexagon/imported/system.idef | 244 ++++++++++- target/hexagon/meson.build | 14 +- 47 files changed, 3978 insertions(+), 105 deletions(-) create mode 100644 docs/devel/hexagon-sys.rst create mode 100644 docs/system/hexagon/cdsp.rst create mode 100644 docs/system/hexagon/emulation.rst create mode 100644 docs/system/target-hexagon.rst create mode 100644 include/hw/hexagon/hexagon_tlb.h create mode 100644 target/hexagon/cpu_helper.h create mode 100644 target/hexagon/gen_tcg_sys.h create mode 100644 target/hexagon/hex_interrupts.h create mode 100644 target/hexagon/hex_mmu.h create mode 100644 target/hexagon/sys_macros.h create mode 100644 hw/hexagon/hexagon_tlb.c create mode 100644 target/hexagon/cpu_helper.c create mode 100644 target/hexagon/hex_interrupts.c create mode 100644 target/hexagon/hex_mmu.c create mode 100644 target/hexagon/machine.c mode change 100755 => 100644 target/hexagon/imported/macros.def
Signature · 1 line
2.34.1
PATCH v3 7/37 target/hexagon: Switch to tag_ignore(), generate via get_{user, sys}_tags()
From: Brian Cain <[email protected]>
--- target/hexagon/gen_helper_funcs.py | 26 ++++++++++--------------- target/hexagon/gen_helper_protos.py | 23 +++++++++++----------- target/hexagon/gen_idef_parser_funcs.py | 2 ++ target/hexagon/gen_op_attribs.py | 2 +- target/hexagon/gen_opcodes_def.py | 5 ++++- 5 files changed, 29 insertions(+), 29 deletions(-)
target/hexagon/gen_helper_funcs.py +10 -16
@@ -104,29 +104,23 @@ def main(): tagimms = hex_common.get_tagimms() with open(args.out, "w") as f: - for tag in hex_common.tags: - ## Skip the priv instructions - if "A_PRIV" in hex_common.attribdict[tag]: - continue - ## Skip the guest instructions - if "A_GUEST" in hex_common.attribdict[tag]: - continue - ## Skip the floating point instructions - if "A_FPOP" in hex_common.attribdict[tag]: - continue - ## Skip the diag instructions - if tag == "Y6_diag": - continue - if tag == "Y6_diag0": - continue - if tag == "Y6_diag1": + for tag in hex_common.get_user_tags(): + if hex_common.tag_ignore(tag): continue if hex_common.skip_qemu_helper(tag): continue if hex_common.is_idef_parser_enabled(tag): continue + gen_helper_function(f, tag, tagregs, tagimms) + f.write("#if !defined(CONFIG_USER_ONLY)\n") + for tag in hex_common.get_sys_tags(): + if hex_common.skip_qemu_helper(tag): + continue + if hex_common.is_idef_parser_enabled(tag): + continue gen_helper_function(f, tag, tagregs, tagimms) + f.write("#endif\n") if __name__ == "__main__":
target/hexagon/gen_helper_protos.py +12 -11
@@ -59,27 +59,28 @@ def main(): tagimms = hex_common.get_tagimms() with open(args.out, "w") as f: - for tag in hex_common.tags: - ## Skip the priv instructions - if "A_PRIV" in hex_common.attribdict[tag]: + for tag in hex_common.get_user_tags(): + if hex_common.tag_ignore(tag): continue - ## Skip the guest instructions - if "A_GUEST" in hex_common.attribdict[tag]: - continue - ## Skip the diag instructions - if tag == "Y6_diag": - continue - if tag == "Y6_diag0": + + if hex_common.skip_qemu_helper(tag): continue - if tag == "Y6_diag1": + if hex_common.is_idef_parser_enabled(tag): continue + gen_helper_prototype(f, tag, tagregs, tagimms) + + f.write("#if !defined(CONFIG_USER_ONLY)\n") + for tag in hex_common.get_sys_tags(): + if hex_common.tag_ignore(tag): + continue if hex_common.skip_qemu_helper(tag): continue if hex_common.is_idef_parser_enabled(tag): continue gen_helper_prototype(f, tag, tagregs, tagimms) + f.write("#endif\n") if __name__ == "__main__":
target/hexagon/gen_idef_parser_funcs.py +2 -0
@@ -60,6 +60,8 @@ def main(): f.write('#include "macros.h.inc"\n\n') for tag in hex_common.tags: + if hex_common.tag_ignore(tag): + continue ## Skip the priv instructions if "A_PRIV" in hex_common.attribdict[tag]: continue
target/hexagon/gen_op_attribs.py +1 -1
@@ -38,7 +38,7 @@ def main(): ## Generate all the attributes associated with each instruction ## with open(args.out, "w") as f: - for tag in hex_common.tags: + for tag in hex_common.get_all_tags(): f.write( f"OP_ATTRIB({tag},ATTRIBS(" f'{",".join(sorted(hex_common.attribdict[tag]))}))\n'
target/hexagon/gen_opcodes_def.py +4 -1
@@ -37,7 +37,10 @@ def main(): ## Generate a list of all the opcodes ## with open(args.out, "w") as f: - for tag in hex_common.tags: + for tag in hex_common.get_user_tags(): + f.write(f"OPCODE({tag}),\n") + + for tag in hex_common.get_sys_tags(): f.write(f"OPCODE({tag}),\n")
Signature · 1 line
2.34.1
PATCH v3 1/37 docs: Add hexagon sysemu docs
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- MAINTAINERS | 3 + docs/devel/hexagon-sys.rst | 112 +++++++++++++++++++++++++++++++++ docs/devel/index-internals.rst | 1 + docs/system/hexagon/cdsp.rst | 12 ++++ docs/system/target-hexagon.rst | 102 ++++++++++++++++++++++++++++++ docs/system/targets.rst | 1 + 6 files changed, 231 insertions(+) create mode 100644 docs/devel/hexagon-sys.rst create mode 100644 docs/system/hexagon/cdsp.rst create mode 100644 docs/system/target-hexagon.rst
MAINTAINERS +3 -0
@@ -246,6 +246,9 @@ F: disas/hexagon.c F: configs/targets/hexagon-linux-user/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml +F: docs/system/target-hexagon.rst +F: docs/system/hexagon/cdsp.rst +F: docs/devel/hexagon-sys.rst T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parser
docs/devel/hexagon-sys.rst new file +112 -0
112 lines not on this page · raw message
docs/devel/index-internals.rst +1 -0
@@ -14,6 +14,7 @@ Details about QEMU's various subsystems including how to add features to them. block-coroutine-wrapper clocks ebpf_rss + hexagon-sys migration/index multi-process reset
docs/system/hexagon/cdsp.rst new file +12 -0
@@ -0,0 +1,12 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Compute DSP +=========== + +A Hexagon CDSP is designed as a computation offload device for an SoC. The +``V66G_1024`` machine contains: + +* L2VIC interrupt controller +* QTimer timer device + +This machine will support any Hexagon CPU, but will default to ``v66``.
docs/system/target-hexagon.rst new file +102 -0
102 lines not on this page · raw message
docs/system/targets.rst +1 -0
@@ -30,3 +30,4 @@ Contents: target-sparc64 target-i386 target-xtensa + target-hexagon
Signature · 1 line
2.34.1
PATCH v3 2/37 docs/system: Add hexagon CPU emulation
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- MAINTAINERS | 2 +- docs/system/hexagon/emulation.rst | 15 +++++++++++++++ docs/system/target-hexagon.rst | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 docs/system/hexagon/emulation.rst
MAINTAINERS +1 -1
@@ -247,7 +247,7 @@ F: configs/targets/hexagon-linux-user/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst -F: docs/system/hexagon/cdsp.rst +F: docs/system/hexagon/ F: docs/devel/hexagon-sys.rst T: git https://github.com/quic/qemu.git hex-next
docs/system/hexagon/emulation.rst new file +15 -0
@@ -0,0 +1,15 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. _Hexagon Emulation: + +Hexagon CPU architecture support +================================ + +QEMU's TCG emulation includes support for v65, v66, v67, v68, v69, v71, v73. +It also has support for the following architecture extensions: + +- HVX (Hexagon Vector eXtensions) + +For information on the specifics of the HVX extension, please refer +to the `Qualcomm Hexagon V73 HVX Programmer's Reference Manual +<https://docs.qualcomm.com/bundle/publicresource/80-N2040-53.pdf>`_.
docs/system/target-hexagon.rst +1 -0
@@ -98,5 +98,6 @@ is not yet implemented in QEMU hexagon. Hexagon Features ================ .. toctree:: + hexagon/emulation hexagon/cdsp
Signature · 1 line
2.34.1
PATCH v3 3/37 target/hexagon: Fix badva reference, delete CAUSE
In reply to Brian CainFrom: Brian Cain <[email protected]>
The BADVA reg is referred to with the wrong identifier. The CAUSE reg field of SSR is not yet modeled, we will dump the SSR in a subsequent commit.
--- target/hexagon/cpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
target/hexagon/cpu.c +9 -2
@@ -117,6 +117,14 @@ static void print_reg(FILE *f, CPUHexagonState *env, int regnum) hexagon_regnames[regnum], value); } +#ifndef CONFIG_USER_ONLY +static void print_sreg (FILE *f,CPUHexagonState *env,int regnum) +{ +qemu_fprintf (f," %s = 0x" TARGET_FMT_lx"\n" , + hexagon_sregnames[regnum], env->t_sreg[regnum]); +} +#endif +static void print_vreg (FILE *f,CPUHexagonState *env,int regnum,bool skip_if_zero) {
@@ -216,8 +224,7 @@ static void hexagon_dump(CPUHexagonState *env, FILE *f, int flags)qemu_fprintf (f," cs0 = 0x00000000\n" );qemu_fprintf (f," cs1 = 0x00000000\n" );#else -print_reg (f, env,HEX_REG_CAUSE ); -print_reg (f, env,HEX_REG_BADVA ); +print_sreg (f, env,HEX_SREG_BADVA );print_reg (f, env,HEX_REG_CS0 );print_reg (f, env,HEX_REG_CS1 );#endif
Signature · 1 line
2.34.1
Re: [PATCH v3 03/37] target/hexagon: Fix badva reference, delete CAUSE
Quoted 16 lines · Brian Cain
From: Brian Cain <[email protected]>
The BADVA reg is referred to with the wrong identifier. The CAUSE reg field of SSR is not yet modeled, we will dump the SSR in a subsequent commit.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)target/hexagon/cpu.c +0
-0
target/hexagon/cpu.c static void print_reg(FILE *f, CPUHexagonState *env, int regnum) · line 121
Quoted 5 lines
target/hexagon/cpu.c +2
-0@@ -117,6 +117,14 @@ static void print_reg(FILE *f, CPUHexagonState *env, int regnum) hexagon_regnames[regnum], value); } +#ifndef CONFIG_USER_ONLY +static void print_sreg (FILE *f,CPUHexagonState *env,int regnum)
Kinda nitpicking, @env could be const. Otherwise,
Quoted 4 lines
target/hexagon/cpu.c +4
-0+{ +qemu_fprintf (f," %s = 0x" TARGET_FMT_lx"\n" , + hexagon_sregnames[regnum], env->t_sreg[regnum]); +}
Re: [PATCH v3 03/37] target/hexagon: Fix badva reference, delete CAUSE
In reply to Brian CainQuoted 16 lines · Brian Cain
From: Brian Cain <[email protected]>
The BADVA reg is referred to with the wrong identifier. The CAUSE reg field of SSR is not yet modeled, we will dump the SSR in a subsequent commit.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)target/hexagon/cpu.c +0
-0
target/hexagon/cpu.c static void print_reg(FILE *f, CPUHexagonState *env, · line 126
Quoted 10 lines
target/hexagon/cpu.c +5
-0@@ -117,6 +117,14 @@ static void print_reg(FILE *f, CPUHexagonState *env, int regnum) hexagon_regnames[regnum], value); } +#ifndef CONFIG_USER_ONLY +static void print_sreg (FILE *f,CPUHexagonState *env,int regnum) +{ +qemu_fprintf (f," %s = 0x" TARGET_FMT_lx"\n" , + hexagon_sregnames[regnum], env->t_sreg[regnum]);
There are both t_sreg (thread) and g_sreg (global). Either use arch_get_system_reg to get the value or change the name of the function to print_t_sreg.
Quoted 4 lines
target/hexagon/cpu.c +3
-0+} +#endif +
PATCH v3 4/37 target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/hex_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
target/hexagon/hex_common.py +5 -1
@@ -247,7 +247,11 @@ def need_next_PC(tag): def need_pkt_has_multi_cof(tag): - return "A_COF" in attribdict[tag] + if "A_JUMP" in attribdict[tag] or "A_CALL" in attribdict[tag]: + if tag == "J4_hintjumpr": + return False + return True + return False def need_pkt_need_commit(tag):
Signature · 1 line
2.34.1
Re: [PATCH v3 04/37] target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
Quoted 12 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/hex_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)target/hexagon/hex_common.py +0
-0
target/hexagon/hex_common.py def need_next_PC(tag): · line 253
Quoted 8 lines
target/hexagon/hex_common.py +4
-1@@ -247,7 +247,11 @@ def need_next_PC(tag): def need_pkt_has_multi_cof(tag): - return "A_COF" in attribdict[tag] + if "A_JUMP" in attribdict[tag] or "A_CALL" in attribdict[tag]: + if tag == "J4_hintjumpr": + return False + return True
Alternatively:
if attribdict[tag] in ['A_JUMP', 'A_CALL']:
return tag != "J4_hintjumpr"Quoted 4 lines
target/hexagon/hex_common.py +1
-0+ return False def need_pkt_need_commit(tag):
Re: [PATCH v3 04/37] target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/hex_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)target/hexagon/hex_common.py +0
-0target/hexagon/hex_common.py def need_next_PC(tag): · line 251
Quoted 6 lines
target/hexagon/hex_common.py +4
-1@@ -247,7 +247,11 @@ def need_next_PC(tag): def need_pkt_has_multi_cof(tag): - return "A_COF" in attribdict[tag] + if "A_JUMP" in attribdict[tag] or "A_CALL" in attribdict[tag]: + if tag == "J4_hintjumpr": + return False + return TrueAlternatively:
Quoted 2 lines
if attribdict[tag] in ['A_JUMP', 'A_CALL']:
return tag != "J4_hintjumpr"I don't think this is valid, but set intersection would work
if attribdict[tag] & {'A_JUMP', 'A_CALL'}:
return tag != "J4_hintjumpr"
return FalseSignature · 2 lines
Anton Johansson rev.ng Labs Srl.
Re: [PATCH v3 04/37] target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
Quoted 23 lines · Anton Johansson
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/hex_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)target/hexagon/hex_common.py +0
-0target/hexagon/hex_common.py def need_next_PC(tag): · line 251
Quoted 6 lines
target/hexagon/hex_common.py +4
-1@@ -247,7 +247,11 @@ def need_next_PC(tag): def need_pkt_has_multi_cof(tag): - return "A_COF" in attribdict[tag] + if "A_JUMP" in attribdict[tag] or "A_CALL" in attribdict[tag]: + if tag == "J4_hintjumpr": + return False + return TrueAlternatively:
Quoted 4 lines
Quoted 2 lines
if attribdict[tag] in ['A_JUMP', 'A_CALL']: return tag != "J4_hintjumpr"I don't think this is valid,
Doh I was too quick and mis-understood that code :/
Quoted 5 lines
but set intersection would work
if attribdict[tag] & {'A_JUMP', 'A_CALL'}: return tag != "J4_hintjumpr" return False
Nice!
PATCH v3 5/37 target/hexagon: Handle system/guest registers in gen_analyze_funcs.py and hex_common.py
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/gen_analyze_funcs.py | 21 +++- target/hexagon/hex_common.py | 161 ++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 3 deletions(-)
target/hexagon/gen_analyze_funcs.py +18 -3
@@ -22,6 +22,8 @@ import string import hex_common +def has_analyze_func(reg, mode): + return callable(getattr(reg, f"analyze_{mode}", None)) ## ## Generate the code to analyze the instruction
@@ -42,6 +44,14 @@ def gen_analyze_func(f, tag, regs, imms): f.write(f"static void analyze_{tag}(DisasContext *ctx)\n") f.write("{\n") + if hex_common.tag_ignore(tag): + f.write("}\n\n") + return + + if ("A_PRIV" in hex_common.attribdict[tag] or + "A_GUEST" in hex_common.attribdict[tag]): + f.write("#ifndef CONFIG_USER_ONLY\n") + f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") if (hex_common.is_hvx_insn(tag)): if hex_common.has_hvx_helper(tag):
@@ -58,13 +68,14 @@ def gen_analyze_func(f, tag, regs, imms): for regno, register in enumerate(regs): reg_type, reg_id = register reg = hex_common.get_register(tag, reg_type, reg_id) - reg.decl_reg_num(f, regno) + if has_analyze_func(reg, "read") or has_analyze_func(reg, "write"): + reg.decl_reg_num(f, regno) ## Analyze the register reads for regno, register in enumerate(regs): reg_type, reg_id = register reg = hex_common.get_register(tag, reg_type, reg_id) - if reg.is_read(): + if reg.is_read() and has_analyze_func(reg, "read"): reg.analyze_read(f, regno) f.write(" mark_implicit_reads(ctx);\n")
@@ -73,11 +84,15 @@ def gen_analyze_func(f, tag, regs, imms): for regno, register in enumerate(regs): reg_type, reg_id = register reg = hex_common.get_register(tag, reg_type, reg_id) - if reg.is_written(): + if reg.is_written() and has_analyze_func(reg, "write"): reg.analyze_write(f, tag, regno) f.write(" mark_implicit_writes(ctx);\n") + if ("A_PRIV" in hex_common.attribdict[tag] or + "A_GUEST" in hex_common.attribdict[tag]): + f.write("#endif /* !CONFIG_USER_ONLY */\n") + f.write("}\n\n")
target/hexagon/hex_common.py +161 -0
191 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 05/37] target/hexagon: Handle system/guest registers in gen_analyze_funcs.py and hex_common.py
Quoted 14 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/gen_analyze_funcs.py | 21 +++- target/hexagon/hex_common.py | 161 ++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 3 deletions(-)target/hexagon/gen_analyze_funcs.py +0
-0
target/hexagon/gen_analyze_funcs.py line 27
Quoted 6 lines
target/hexagon/gen_analyze_funcs.py +2
-0@@ -22,6 +22,8 @@ import string import hex_common +def has_analyze_func(reg, mode): + return callable(getattr(reg, f"analyze_{mode}", None))
Is this check needed? Why not make sure every reg has the needed analyze function?
Quoted 11 lines
target/hexagon/hex_common.py +4
-0+class GuestRegister(Register): + def gen_check_impl(self, f, regno): + if self.is_written(): + f.write(code_fmt(f"""\
target/hexagon/hex_common.py def analyze_write(self, f, tag, regno): · line 1068
Quoted 10 lines
target/hexagon/hex_common.py +10
-0+ if (!greg_writable(insn->regno[{regno}], + {str(self.is_pair()).lower()})) {{ + return; + }} + """)) + else: + f.write(code_fmt(f"""\ + check_greg_impl(insn->regno[{regno}], + {str(self.is_pair()).lower()}); + """))
What is gen_check_impl used for?
Otherwise
Re: [PATCH v3 05/37] target/hexagon: Handle system/guest registers in gen_analyze_funcs.py and hex_common.py
In reply to Brian CainQuoted 22 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/gen_analyze_funcs.py | 21 +++- target/hexagon/hex_common.py | 161 ++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 3 deletions(-)target/hexagon/gen_analyze_funcs.py +2
-0@@ -22,6 +22,8 @@ import string import hex_common +def has_analyze_func(reg, mode): + return callable(getattr(reg, f"analyze_{mode}", None)) ## ## Generate the code to analyze the instruction
target/hexagon/gen_analyze_funcs.py def gen_analyze_func(f, tag, regs, imms): · line 53
Quoted 10 lines
target/hexagon/gen_analyze_funcs.py +7
-0@@ -42,6 +44,14 @@ def gen_analyze_func(f, tag, regs, imms): f.write(f"static void analyze_{tag}(DisasContext *ctx)\n") f.write("{\n") + if hex_common.tag_ignore(tag): + f.write("}\n\n") + return + + if ("A_PRIV" in hex_common.attribdict[tag] or + "A_GUEST" in hex_common.attribdict[tag]): + f.write("#ifndef CONFIG_USER_ONLY\n")
use hex_common.is_sysemu_tag(tag) here instead!
target/hexagon/gen_analyze_funcs.py def gen_analyze_func(f, tag, regs, imms): · line 72
Quoted 11 lines
target/hexagon/gen_analyze_funcs.py +3
-1+ f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") if (hex_common.is_hvx_insn(tag)): if hex_common.has_hvx_helper(tag):@@ -58,13 +68,14 @@ def gen_analyze_func(f, tag, regs, imms): for regno, register in enumerate(regs): reg_type, reg_id = register reg = hex_common.get_register(tag, reg_type, reg_id) - reg.decl_reg_num(f, regno) + if has_analyze_func(reg, "read") or has_analyze_func(reg, "write"): + reg.decl_reg_num(f, regno)
I'm not a huge fan of redirecting control flow based on whether or not the register class has certain functions, feels hard to follow. It's also unclear to me why this is needed, I assume we have some registers where reg.is_read()/reg.is_written() are false but we still want to emit analyze code for them?
Quoted 13 lines
target/hexagon/gen_analyze_funcs.py +1
-1## Analyze the register reads for regno, register in enumerate(regs): reg_type, reg_id = register reg = hex_common.get_register(tag, reg_type, reg_id) - if reg.is_read(): + if reg.is_read() and has_analyze_func(reg, "read"): reg.analyze_read(f, regno) f.write(" mark_implicit_reads(ctx);\n")@@ -73,11 +84,15 @@ def gen_analyze_func(f, tag, regs, imms): for regno, register in enumerate(regs): reg_type, reg_id = register
target/hexagon/gen_analyze_funcs.py def gen_analyze_func(f, tag, regs, imms): · line 94
Quoted 10 lines
target/hexagon/gen_analyze_funcs.py +4
-1reg = hex_common.get_register(tag, reg_type, reg_id) - if reg.is_written(): + if reg.is_written() and has_analyze_func(reg, "write"): reg.analyze_write(f, tag, regno) f.write(" mark_implicit_writes(ctx);\n") + if ("A_PRIV" in hex_common.attribdict[tag] or + "A_GUEST" in hex_common.attribdict[tag]): + f.write("#endif /* !CONFIG_USER_ONLY */\n")
and use hex_common.is_sysemu_tag(tag) here also
Quoted 20 lines
target/hexagon/gen_analyze_funcs.py +1
-0+ f.write("}\n\n")target/hexagon/hex_common.py +8
-0@@ -33,6 +33,42 @@ overrides = {} # tags with helper overrides idef_parser_enabled = {} # tags enabled for idef-parser + +def is_sysemu_tag(tag): + return "A_PRIV" in attribdict[tag] or "A_GUEST" in attribdict[tag] + + +def tag_ignore(tag): + tag_skips = ( + "Y6_diag",
target/hexagon/hex_common.py line 53
Quoted 10 lines
target/hexagon/hex_common.py +10
-0+ "Y6_diag0", + "Y6_diag1", + ) + attr_skips = ( + "A_FAKEINSN", + "A_MAPPING", + "A_CONDMAPPING", + ) + return tag in tag_skips or \ + any(attr in attribdict[tag] for attr in attr_skips)
Up to you if you think this is easier to read or not, but you could make attr_skips a set and do set intsersection instead
attr_skips = {
"A_FAKEINSN",
"A_MAPPING",
"A_CONDMAPPING",
}
return tag in tag_skips or attribdict[tag] & attr_skipsSignature · 2 lines
Anton Johansson rev.ng Labs Srl.
PATCH v3 6/37 target/hexagon: Make gen_exception_end_tb non-static
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/translate.h | 2 ++ target/hexagon/translate.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
target/hexagon/translate.h +2 -0
@@ -282,6 +282,8 @@ extern TCGv hex_vstore_addr[VSTORES_MAX];extern TCGv hex_vstore_size[VSTORES_MAX ];extern TCGv hex_vstore_pending[VSTORES_MAX ]; +void hex_gen_exception_end_tb (DisasContext *ctx,int excp); +void process_store (DisasContext *ctx,int slot_num);FIELD (PROBE_PKT_SCALAR_STORE_S0 ,MMU_IDX ,0 ,2 )
target/hexagon/translate.c +3 -3
@@ -189,7 +189,7 @@ static void gen_end_tb(DisasContext *ctx) ctx->base.is_jmp =DISAS_NORETURN ; } -static void gen_exception_end_tb (DisasContext *ctx,int excp) +void hex_gen_exception_end_tb (DisasContext *ctx,int excp) {gen_exec_counters (ctx);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->next_PC);
@@ -207,7 +207,7 @@ static void gen_exception_decode_fail(DisasContext *ctx, int nwords, int excp)gen_exec_counters (ctx);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], fail_pc); -gen_exception_raw (excp); +gen_exception (excp, fail_pc); ctx->base.is_jmp =DISAS_NORETURN ; ctx->base.pc_next = fail_pc; }
@@ -590,7 +590,7 @@ static void gen_insn(DisasContext *ctx) ctx->insn->generate (ctx);mark_store_width (ctx); }else { -gen_exception_end_tb (ctx,HEX_CAUSE_INVALID_OPCODE ); +hex_gen_exception_end_tb (ctx,HEX_CAUSE_INVALID_OPCODE ); } }
Signature · 1 line
2.34.1
Re: [PATCH v3 06/37] target/hexagon: Make gen_exception_end_tb non-static
Hi Brian,
Quoted 36 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/translate.h | 2 ++ target/hexagon/translate.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)target/hexagon/translate.h +2
-0@@ -282,6 +282,8 @@ extern TCGv hex_vstore_addr[VSTORES_MAX];extern TCGv hex_vstore_size[VSTORES_MAX ];extern TCGv hex_vstore_pending[VSTORES_MAX ]; +void hex_gen_exception_end_tb (DisasContext *ctx,int excp); +void process_store (DisasContext *ctx,int slot_num);FIELD (PROBE_PKT_SCALAR_STORE_S0 ,MMU_IDX ,0 ,2 )target/hexagon/translate.c +1
-1@@ -189,7 +189,7 @@ static void gen_end_tb(DisasContext *ctx) ctx->base.is_jmp =DISAS_NORETURN ; } -static void gen_exception_end_tb (DisasContext *ctx,int excp) +void hex_gen_exception_end_tb (DisasContext *ctx,int excp) {gen_exec_counters (ctx);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->next_PC);
target/hexagon/translate.c static void gen_exception_decode_fail(DisasContext *ctx, int nwords, int excp) · line 210
Quoted 5 lines
target/hexagon/translate.c +1
-1@@ -207,7 +207,7 @@ static void gen_exception_decode_fail(DisasContext *ctx, int nwords, int excp)gen_exec_counters (ctx);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], fail_pc); -gen_exception_raw (excp); +gen_exception (excp, fail_pc);
gen_exception() is not introduced in this series, future commit https://github.com/quic/qemu/commit/ff8ac066dd8d
rename gen_exception_raw() to it. I don't expect this commit to build.
Maybe keep the gen_exception_raw(excp) call in this commit and convert to gen_exception(excp, fail_pc) in ff8ac066dd8d?
Quoted 12 lines
target/hexagon/translate.c +1
-1ctx->base.is_jmp =DISAS_NORETURN ; ctx->base.pc_next = fail_pc; }@@ -590,7 +590,7 @@ static void gen_insn(DisasContext *ctx) ctx->insn->generate (ctx);mark_store_width (ctx); }else { -gen_exception_end_tb (ctx,HEX_CAUSE_INVALID_OPCODE ); +hex_gen_exception_end_tb (ctx,HEX_CAUSE_INVALID_OPCODE ); } }
PATCH v3 8/37 target/hexagon: Add system event, cause codes
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 9 +++++ target/hexagon/cpu_bits.h | 75 ++++++++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 9 deletions(-)
target/hexagon/cpu.h +9 -0
@@ -44,6 +44,15 @@#define MMU_USER_IDX 0 +#define HEXAGON_CPU_IRQ_0 0 +#define HEXAGON_CPU_IRQ_1 1 +#define HEXAGON_CPU_IRQ_2 2 +#define HEXAGON_CPU_IRQ_3 3 +#define HEXAGON_CPU_IRQ_4 4 +#define HEXAGON_CPU_IRQ_5 5 +#define HEXAGON_CPU_IRQ_6 6 +#define HEXAGON_CPU_IRQ_7 7 + typedef struct { target_ulong va; uint32_t width;
target/hexagon/cpu_bits.h +66 -9
86 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 9/37 target/hexagon: Add privilege check, use tag_ignore()
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 1 + linux-user/hexagon/cpu_loop.c | 16 +++++++++++++++ target/hexagon/cpu.c | 1 + target/hexagon/translate.c | 8 ++++++++ target/hexagon/gen_tcg_funcs.py | 35 +++++++++++++++++++++------------ 5 files changed, 48 insertions(+), 13 deletions(-)
target/hexagon/cpu.h +1 -0
@@ -85,6 +85,7 @@ typedef struct { typedef struct CPUArchState { target_ulong gpr[TOTAL_PER_THREAD_REGS]; target_ulong pred[NUM_PREGS]; + target_ulong cause_code; /* For comparing with LLDB on target - see adjust_stack_ptrs function */ target_ulong last_pc_dumped;
linux-user/hexagon/cpu_loop.c +16 -0
@@ -22,6 +22,7 @@#include "qemu.h" #include "user-internals.h" #include "user/cpu_loop.h" +#include "target/hexagon/internal.h" #include "signal-common.h" #include "internal.h"
@@ -60,6 +61,21 @@ void cpu_loop(CPUHexagonState *env) env->gpr[0 ] = ret; }break ; +case HEX_EVENT_PRECISE : +switch (env->cause_code) { +case HEX_CAUSE_PRIV_USER_NO_GINSN : +case HEX_CAUSE_PRIV_USER_NO_SINSN : +case HEX_CAUSE_INVALID_PACKET : +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , + env->gpr[HEX_REG_PC ]); +break ; +default : +EXCP_DUMP (env,"\nqemu: unhandled CPU precise exception " +"cause code 0x%x - aborting\n" , + env->cause_code); +exit (EXIT_FAILURE ); + } +break ;case HEX_CAUSE_PC_NOT_ALIGNED :force_sig_fault (TARGET_SIGBUS ,TARGET_BUS_ADRALN , env->gpr[HEX_REG_R31 ]);
target/hexagon/cpu.c +1 -0
@@ -306,6 +306,7 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status);/* Default NaN value: sign bit set, all frac bits set */ set_float_default_nan_pattern (0b11111111 , &env->fp_status); + env->cause_code =HEX_EVENT_NONE ; } static void hexagon_cpu_disas_set_info(const CPUState *cs,
target/hexagon/translate.c +8 -0
@@ -65,6 +65,10 @@ TCGv hex_vstore_addr[VSTORES_MAX];TCGv hex_vstore_size[VSTORES_MAX ];TCGv hex_vstore_pending[VSTORES_MAX ]; +#ifndef CONFIG_USER_ONLY +TCGv hex_cause_code; +#endif +static const char *const hexagon_prednames[] = {"p0" ,"p1" ,"p2" ,"p3" };
@@ -1153,4 +1157,8 @@ void hexagon_translate_init(void) offsetof(CPUHexagonState, vstore_pending[i]), vstore_pending_names[i]); } +#ifndef CONFIG_USER_ONLY + hex_cause_code =tcg_global_mem_new (tcg_env, + offsetof(CPUHexagonState , cause_code),"cause_code" ); +#endif }
target/hexagon/gen_tcg_funcs.py +22 -13
@@ -21,7 +21,7 @@ import re import string import hex_common - +from textwrap import dedent ## ## Generate the TCG code to call the helper
@@ -49,6 +49,18 @@ def gen_tcg_func(f, tag, regs, imms): f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") + if "A_PRIV" in hex_common.attribdict[tag]: + f.write(dedent("""\ +#ifdef CONFIG_USER_ONLY + hex_gen_exception_end_tb(ctx, HEX_CAUSE_PRIV_USER_NO_SINSN); +#else +""")) + if "A_GUEST" in hex_common.attribdict[tag]: + f.write(dedent("""\ +#ifdef CONFIG_USER_ONLY + hex_gen_exception_end_tb(ctx, HEX_CAUSE_PRIV_USER_NO_GINSN); +#else +""")) if hex_common.need_ea(tag): f.write(" TCGv EA G_GNUC_UNUSED = tcg_temp_new();\n")
@@ -100,6 +112,11 @@ def gen_tcg_func(f, tag, regs, imms): if reg.is_written(): reg.gen_write(f, tag) + if ( + "A_PRIV" in hex_common.attribdict[tag] + or "A_GUEST" in hex_common.attribdict[tag] + ): + f.write("#endif /* CONFIG_USER_ONLY */\n") f.write("}\n\n")
@@ -124,18 +141,10 @@ def main(): f.write('#include "idef-generated-emitter.h.inc"\n\n') for tag in hex_common.tags: - ## Skip the priv instructions - if "A_PRIV" in hex_common.attribdict[tag]: - continue - ## Skip the guest instructions - if "A_GUEST" in hex_common.attribdict[tag]: - continue - ## Skip the diag instructions - if tag == "Y6_diag": - continue - if tag == "Y6_diag0": - continue - if tag == "Y6_diag1": + if hex_common.tag_ignore(tag): + f.write(f"static void generate_{tag}" + f"(DisasContext *ctx)\n") + f.write("{\n}\n\n") continue gen_def_tcg_func(f, tag, tagregs, tagimms)
Signature · 1 line
2.34.1
Re: [PATCH v3 09/37] target/hexagon: Add privilege check, use tag_ignore()
Quoted 34 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 1 + linux-user/hexagon/cpu_loop.c | 16 +++++++++++++++ target/hexagon/cpu.c | 1 + target/hexagon/translate.c | 8 ++++++++ target/hexagon/gen_tcg_funcs.py | 35 +++++++++++++++++++++------------ 5 files changed, 48 insertions(+), 13 deletions(-)linux-user/hexagon/cpu_loop.c +6
-0@@ -22,6 +22,7 @@#include "qemu.h" #include "user-internals.h" #include "user/cpu_loop.h" +#include "target/hexagon/internal.h" #include "signal-common.h" #include "internal.h" @@ -60,6 +61,21 @@ void cpu_loop(CPUHexagonState *env) env->gpr[0 ] = ret; }break ; +case HEX_EVENT_PRECISE : +switch (env->cause_code) { +case HEX_CAUSE_PRIV_USER_NO_GINSN : +case HEX_CAUSE_PRIV_USER_NO_SINSN : +case HEX_CAUSE_INVALID_PACKET :
linux-user/hexagon/cpu_loop.c void cpu_loop(CPUHexagonState *env) · line 78
Quoted 10 lines
linux-user/hexagon/cpu_loop.c +10
-0+force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , + env->gpr[HEX_REG_PC ]); +break ; +default : +EXCP_DUMP (env,"\nqemu: unhandled CPU precise exception " +"cause code 0x%x - aborting\n" , + env->cause_code); +exit (EXIT_FAILURE ); + } +break ;
Just a comment (not blocking anything), I'm confused here because the series is about system emulation but you add code to user emulation.
PATCH v3 10/37 target/hexagon: Add memory order definition
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu-param.h | 5 +++++ 1 file changed, 5 insertions(+)
target/hexagon/cpu-param.h +5 -0
@@ -23,4 +23,9 @@#define TARGET_PHYS_ADDR_SPACE_BITS 36#define TARGET_VIRT_ADDR_SPACE_BITS 32 +/* +* Hexagon processors have a strong memory model. +*/ +#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL) +#endif
Signature · 1 line
2.34.1
Re: [PATCH v3 10/37] target/hexagon: Add memory order definition
Quoted 12 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu-param.h | 5 +++++ 1 file changed, 5 insertions(+)target/hexagon/cpu-param.h +0
-0
target/hexagon/cpu-param.h line 29
Quoted 7 lines
target/hexagon/cpu-param.h +4
-0@@ -23,4 +23,9 @@#define TARGET_PHYS_ADDR_SPACE_BITS 36#define TARGET_VIRT_ADDR_SPACE_BITS 32 +/* +* Hexagon processors have a strong memory model. +*/ +#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL)
This definition is poisoned since commit 98c7c146988.
Commit 7dc2af9786e ("tcg: Remove the TCG_GUEST_DEFAULT_MO definition globally") already sets hexagon_tcg_ops::guest_default_memory_order = TCG_MO_ALL.
Maybe just drop this patch?
PATCH v3 11/37 target/hexagon: Add a placeholder fp exception
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/arch.c | 5 +++++ 1 file changed, 5 insertions(+)
target/hexagon/arch.c +5 -0
@@ -208,6 +208,11 @@ void arch_fpop_start(CPUHexagonState *env)* model it in qemu user mode. */ #define RAISE_FP_EXCEPTION do {} while (0) +#else +/* +* To be implemented. +*/ +#define RAISE_FP_EXCEPTION do { g_assert_not_reached(); } while (0)#endif #define SOFTFLOAT_TEST_FLAG (FLAG ,MYF ,MYE ) \
Signature · 1 line
2.34.1
PATCH v3 12/37 target/hexagon: Add guest, system reg number defs
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 5 ++ target/hexagon/hex_regs.h | 115 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+)
target/hexagon/cpu.h +5 -0
@@ -20,6 +20,11 @@#include "fpu/softfloat-types.h" +#define NUM_GREGS 32 +#define GREG_WRITES_MAX 2 +#define NUM_SREGS 64 +#define SREG_WRITES_MAX 2 +#include "cpu-qom.h" #include "exec/cpu-common.h" #include "exec/cpu-defs.h"
target/hexagon/hex_regs.h +115 -0
119 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 12/37] target/hexagon: Add guest, system reg number defs
Quoted 13 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 5 ++ target/hexagon/hex_regs.h | 115 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+)target/hexagon/cpu.h +0
-0
target/hexagon/cpu.h line 28
Quoted 9 lines
target/hexagon/cpu.h +5
-0@@ -20,6 +20,11 @@#include "fpu/softfloat-types.h" +#define NUM_GREGS 32 +#define GREG_WRITES_MAX 2 +#define NUM_SREGS 64 +#define SREG_WRITES_MAX 2 +
Guard with #ifndef CONFIG_USER_ONLY
Quoted 116 lines
target/hexagon/cpu.h +0
-0#include "cpu-qom.h" #include "exec/cpu-common.h" #include "
exec/cpu-defs.h"target/hexagon/hex_regs.h +105
-0@@ -81,4 +81,119 @@ enum { HEX_REG_UTIMERHI = 63, }; +#ifndef CONFIG_USER_ONLY + +#define HEX_GREG_VALUES \ + DECL_HEX_GREG(G0, 0) \ + DECL_HEX_GREG(GELR, 0) \ + DECL_HEX_GREG(G1, 1) \ + DECL_HEX_GREG(GSR, 1) \ + DECL_HEX_GREG(G2, 2) \ + DECL_HEX_GREG(GOSP, 2) \ + DECL_HEX_GREG(G3, 3) \ + DECL_HEX_GREG(GBADVA, 3) \ + DECL_HEX_GREG(GCYCLE_1T, 10) \ + DECL_HEX_GREG(GCYCLE_2T, 11) \ + DECL_HEX_GREG(GCYCLE_3T, 12) \ + DECL_HEX_GREG(GCYCLE_4T, 13) \ + DECL_HEX_GREG(GCYCLE_5T, 14) \ + DECL_HEX_GREG(GCYCLE_6T, 15) \ + DECL_HEX_GREG(GPMUCNT4, 16) \ + DECL_HEX_GREG(GPMUCNT5, 17) \ + DECL_HEX_GREG(GPMUCNT6, 18) \ + DECL_HEX_GREG(GPMUCNT7, 19) \ + DECL_HEX_GREG(GPCYCLELO, 24) \ + DECL_HEX_GREG(GPCYCLEHI, 25) \ + DECL_HEX_GREG(GPMUCNT0, 26) \ + DECL_HEX_GREG(GPMUCNT1, 27) \ + DECL_HEX_GREG(GPMUCNT2, 28) \ + DECL_HEX_GREG(GPMUCNT3, 29) \ + DECL_HEX_GREG_DONE + +#define DECL_HEX_GREG_DONE +#define DECL_HEX_GREG (name, val) HEX_GREG_ ##name = val, +enum hex_greg { +HEX_GREG_VALUES +}; +#undef DECL_HEX_GREG +#undef DECL_HEX_GREG_DONE + +#define DECL_HEX_GREG_DONE 0 +#define DECL_HEX_GREG (_, val) (1 << val) | +static inline bool greg_implemented (enum hex_greg greg) +{ +#if NUM_GREGS >32 +#error "NUM_GREGS too large for greg_implemented(): update `impl_bitmap`" +#endif +static int32_t impl_bitmap =HEX_GREG_VALUES ; +return impl_bitmap & (1 << greg); +} +#undef DECL_HEX_GREG +#undef DECL_HEX_GREG_DONE + +#endif /* CONFIG_USER_ONLY */ + +enum { +HEX_SREG_SGP0 =0 , +HEX_SREG_SGP1 =1 , +HEX_SREG_STID =2 , +HEX_SREG_ELR =3 , +HEX_SREG_BADVA0 =4 , +HEX_SREG_BADVA1 =5 , +HEX_SREG_SSR =6 , +HEX_SREG_CCR =7 , +HEX_SREG_HTID =8 , +HEX_SREG_BADVA =9 , +HEX_SREG_IMASK =10 , +HEX_SREG_GEVB =11 , +HEX_SREG_GLB_START =16 , +HEX_SREG_EVB =16 , +HEX_SREG_MODECTL =17 , +HEX_SREG_SYSCFG =18 , +HEX_SREG_IPENDAD =20 , +HEX_SREG_VID =21 , +HEX_SREG_VID1 =22 , +HEX_SREG_BESTWAIT =23 , +HEX_SREG_IEL =24 , +HEX_SREG_SCHEDCFG =25 , +HEX_SREG_IAHL =26 , +HEX_SREG_CFGBASE =27 , +HEX_SREG_DIAG =28 , +HEX_SREG_REV =29 , +HEX_SREG_PCYCLELO =30 , +HEX_SREG_PCYCLEHI =31 , +HEX_SREG_ISDBST =32 , +HEX_SREG_ISDBCFG0 =33 , +HEX_SREG_ISDBCFG1 =34 , +HEX_SREG_LIVELOCK =35 , +HEX_SREG_BRKPTPC0 =36 , +HEX_SREG_BRKPTCFG0 =37 , +HEX_SREG_BRKPTPC1 =38 , +HEX_SREG_BRKPTCFG1 =39 , +HEX_SREG_ISDBMBXIN =40 , +HEX_SREG_ISDBMBXOUT =41 , +HEX_SREG_ISDBEN =42 , +HEX_SREG_ISDBGPR =43 , +HEX_SREG_PMUCNT4 =44 , +HEX_SREG_PMUCNT5 =45 , +HEX_SREG_PMUCNT6 =46 , +HEX_SREG_PMUCNT7 =47 , +HEX_SREG_PMUCNT0 =48 , +HEX_SREG_PMUCNT1 =49 , +HEX_SREG_PMUCNT2 =50 , +HEX_SREG_PMUCNT3 =51 , +HEX_SREG_PMUEVTCFG =52 , +HEX_SREG_PMUSTID0 =53 , +HEX_SREG_PMUEVTCFG1 =54 , +HEX_SREG_PMUSTID1 =55 ,
target/hexagon/hex_regs.h enum { · line 198
Quoted 10 lines
target/hexagon/hex_regs.h +9
-0+HEX_SREG_TIMERLO =56 , +HEX_SREG_TIMERHI =57 , +HEX_SREG_PMUCFG =58 , +HEX_SREG_S59 =59 , +HEX_SREG_S60 =60 , +HEX_SREG_S61 =61 , +HEX_SREG_S62 =62 , + HEX_SREG_S63 = 63, +};
Put these inside the #ifndef CONFIG_USER_ONLY (see #endif just above the enum).
Quoted 6 lines
target/hexagon/hex_regs.h +1
-0+#endif
--
2.34.1
PATCH v3 13/37 target/hexagon: Add guest, system reg number state
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 7 +++++++ target/hexagon/cpu.c | 4 ++++ 2 files changed, 11 insertions(+)
target/hexagon/cpu.h +7 -0
@@ -97,6 +97,13 @@ typedef struct CPUArchState {target_ulong stack_start;uint8_t slot_cancelled; + +#ifndef CONFIG_USER_ONLY +/* Some system registers are per thread and some are global. */ +target_ulong t_sreg[NUM_SREGS ]; + +target_ulong greg[NUM_GREGS ]; +#endif target_ulong new_value_usr;MemLog mem_log_stores[STORES_MAX ];
target/hexagon/cpu.c +4 -0
@@ -306,6 +306,10 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status);/* Default NaN value: sign bit set, all frac bits set */ set_float_default_nan_pattern (0b11111111 , &env->fp_status); +#ifndef CONFIG_USER_ONLY +memset (env->t_sreg,0 ,sizeof (target_ulong) *NUM_SREGS ); +memset (env->greg,0 ,sizeof (target_ulong) *NUM_GREGS ); +#endif env->cause_code =HEX_EVENT_NONE ; }
Signature · 1 line
2.34.1
Re: [PATCH v3 13/37] target/hexagon: Add guest, system reg number state
Quoted 14 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 7 +++++++ target/hexagon/cpu.c | 4 ++++ 2 files changed, 11 insertions(+)target/hexagon/cpu.h +0
-0
target/hexagon/cpu.h typedef struct CPUArchState { · line 105
Quoted 9 lines
target/hexagon/cpu.h +6
-0@@ -97,6 +97,13 @@ typedef struct CPUArchState {target_ulong stack_start;uint8_t slot_cancelled; + +#ifndef CONFIG_USER_ONLY +/* Some system registers are per thread and some are global. */ +target_ulong t_sreg[NUM_SREGS ]; + +target_ulong greg[NUM_GREGS ];
Please do not add more target_ulong uses. Hexagon register size is 32-bit, so use uint32_t for unsigned register type.
PATCH v3 14/37 target/hexagon: Add TCG values for sreg, greg
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/translate.h | 5 +++++ target/hexagon/translate.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)
target/hexagon/translate.h +5 -0
@@ -281,6 +281,11 @@ extern TCGv_i64 hex_llsc_val_i64;extern TCGv hex_vstore_addr[VSTORES_MAX ];extern TCGv hex_vstore_size[VSTORES_MAX ];extern TCGv hex_vstore_pending[VSTORES_MAX ]; +#ifndef CONFIG_USER_ONLY +extern TCGv hex_greg[NUM_GREGS ]; +extern TCGv hex_t_sreg[NUM_SREGS ]; +#endif +void hex_gen_exception_end_tb (DisasContext *ctx,int excp);
target/hexagon/translate.c +16 -0
@@ -66,6 +66,8 @@ TCGv hex_vstore_size[VSTORES_MAX];TCGv hex_vstore_pending[VSTORES_MAX ];#ifndef CONFIG_USER_ONLY +TCGv hex_greg[NUM_GREGS ]; +TCGv hex_t_sreg[NUM_SREGS ];TCGv hex_cause_code;#endif
@@ -1099,6 +1101,20 @@ void hexagon_translate_init(void)opcode_init (); +#ifndef CONFIG_USER_ONLY +for (i =0 ; i <NUM_GREGS ; i++) { + hex_greg[i] =tcg_global_mem_new (tcg_env, + offsetof(CPUHexagonState, greg[i]), + hexagon_gregnames[i]); + } +for (i =0 ; i <NUM_SREGS ; i++) { +if (i <HEX_SREG_GLB_START ) { + hex_t_sreg[i] =tcg_global_mem_new (tcg_env, + offsetof(CPUHexagonState, t_sreg[i]), + hexagon_sregnames[i]); + } + } +#endif for (i =0 ; i <TOTAL_PER_THREAD_REGS ; i++) { hex_gpr[i] =tcg_global_mem_new (tcg_env, offsetof(CPUHexagonState, gpr[i]),
Signature · 1 line
2.34.1
Re: [PATCH v3 14/37] target/hexagon: Add TCG values for sreg, greg
Quoted 13 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/translate.h | 5 +++++ target/hexagon/translate.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)target/hexagon/translate.h +0
-0
target/hexagon/translate.h extern TCGv_i64 hex_llsc_val_i64; · line 286
Quoted 6 lines
target/hexagon/translate.h +3
-0@@ -281,6 +281,11 @@ extern TCGv_i64 hex_llsc_val_i64;extern TCGv hex_vstore_addr[VSTORES_MAX ];extern TCGv hex_vstore_size[VSTORES_MAX ];extern TCGv hex_vstore_pending[VSTORES_MAX ]; +#ifndef CONFIG_USER_ONLY +extern TCGv hex_greg[NUM_GREGS ]; +extern TCGv hex_t_sreg[NUM_SREGS ];
Hexagon has 32-bit registers, so please use TCGv_i32 ...
Quoted 19 lines
target/hexagon/translate.h +2
-0+#endif +void hex_gen_exception_end_tb (DisasContext *ctx,int excp);target/hexagon/translate.c +2
-0@@ -66,6 +66,8 @@ TCGv hex_vstore_size[VSTORES_MAX];TCGv hex_vstore_pending[VSTORES_MAX ];#ifndef CONFIG_USER_ONLY +TCGv hex_greg[NUM_GREGS ]; +TCGv hex_t_sreg[NUM_SREGS ];TCGv hex_cause_code;#endif
target/hexagon/translate.c void hexagon_translate_init(void) · line 1106
Quoted 6 lines
target/hexagon/translate.c +3
-0@@ -1099,6 +1101,20 @@ void hexagon_translate_init(void)opcode_init (); +#ifndef CONFIG_USER_ONLY +for (i =0 ; i <NUM_GREGS ; i++) { + hex_greg[i] = tcg_global_mem_new(tcg_env,
... and tcg_global_mem_new_i32().
Quoted 14 lines
target/hexagon/translate.c +11
-0+ offsetof(CPUHexagonState, greg[i]), + hexagon_gregnames[i]); + } +for (i =0 ; i <NUM_SREGS ; i++) { +if (i <HEX_SREG_GLB_START ) { + hex_t_sreg[i] =tcg_global_mem_new (tcg_env, + offsetof(CPUHexagonState, t_sreg[i]), + hexagon_sregnames[i]); + } + } +#endif for (i =0 ; i <TOTAL_PER_THREAD_REGS ; i++) { hex_gpr[i] =tcg_global_mem_new (tcg_env, offsetof(CPUHexagonState, gpr[i]),
Re: [PATCH v3 14/37] target/hexagon: Add TCG values for sreg, greg
In reply to Brian CainQuoted 8 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/translate.h | 5 +++++ target/hexagon/translate.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)
PATCH v3 15/37 target/hexagon: Add guest/sys reg writes to DisasContext
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/translate.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
target/hexagon/translate.h +36 -0
@@ -40,6 +40,14 @@ typedef struct DisasContext {DECLARE_BITMAP (regs_written,TOTAL_PER_THREAD_REGS );DECLARE_BITMAP (predicated_regs,TOTAL_PER_THREAD_REGS );bool implicit_usr_write; +#ifndef CONFIG_USER_ONLY +int greg_log[GREG_WRITES_MAX ]; +int greg_log_idx; +int sreg_log[SREG_WRITES_MAX ]; +int sreg_log_idx; +TCGv t_sreg_new_value[NUM_SREGS ]; +TCGv greg_new_value[NUM_GREGS ]; +#endif int preg_log[PRED_WRITES_MAX ];int preg_log_idx;DECLARE_BITMAP (pregs_written,NUM_PREGS );
@@ -80,6 +88,34 @@ typedef struct DisasContext {bool is_gather_store_insn (DisasContext *ctx); +#ifndef CONFIG_USER_ONLY +static inline void ctx_log_greg_write (DisasContext *ctx,int rnum) +{ +if (rnum <=HEX_GREG_G3 ) { + ctx->greg_log[ctx->greg_log_idx] = rnum; + ctx->greg_log_idx++; + } +} + +static inline void ctx_log_greg_write_pair (DisasContext *ctx,int rnum) +{ +ctx_log_greg_write (ctx, rnum); +ctx_log_greg_write (ctx, rnum +1 ); +} + +static inline void ctx_log_sreg_write (DisasContext *ctx,int rnum) +{ + ctx->sreg_log[ctx->sreg_log_idx] = rnum; + ctx->sreg_log_idx++; +} + +static inline void ctx_log_sreg_write_pair (DisasContext *ctx,int rnum) +{ +ctx_log_sreg_write (ctx, rnum); +ctx_log_sreg_write (ctx, rnum +1 ); +} +#endif +static inline void ctx_log_pred_write (DisasContext *ctx,int pnum) {if (!test_bit (pnum, ctx->pregs_written)) {
Signature · 1 line
2.34.1
Re: [PATCH v3 15/37] target/hexagon: Add guest/sys reg writes to DisasContext
Quoted 13 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/translate.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)target/hexagon/translate.h +0
-0
target/hexagon/translate.h typedef struct DisasContext { · line 49
Quoted 10 lines
target/hexagon/translate.h +7
-0@@ -40,6 +40,14 @@ typedef struct DisasContext {DECLARE_BITMAP (regs_written,TOTAL_PER_THREAD_REGS );DECLARE_BITMAP (predicated_regs,TOTAL_PER_THREAD_REGS );bool implicit_usr_write; +#ifndef CONFIG_USER_ONLY +int greg_log[GREG_WRITES_MAX ]; +int greg_log_idx; +int sreg_log[SREG_WRITES_MAX ]; +int sreg_log_idx; +TCGv t_sreg_new_value[NUM_SREGS ]; +TCGv greg_new_value[NUM_GREGS ];
TCGv_i32.
target/hexagon/translate.h typedef struct DisasContext { · line 94
Quoted 12 lines
target/hexagon/translate.h +5
-0+#endif int preg_log[PRED_WRITES_MAX ];int preg_log_idx;DECLARE_BITMAP (pregs_written,NUM_PREGS );@@ -80,6 +88,34 @@ typedef struct DisasContext {bool is_gather_store_insn (DisasContext *ctx); +#ifndef CONFIG_USER_ONLY +static inline void ctx_log_greg_write (DisasContext *ctx,int rnum) +{ +if (rnum <=HEX_GREG_G3 ) {
Shouldn't we assert(rnum > HEX_GREG_G3)?
target/hexagon/translate.h typedef struct DisasContext { · line 102
Quoted 8 lines
target/hexagon/translate.h +8
-0+ ctx->greg_log[ctx->greg_log_idx] = rnum; + ctx->greg_log_idx++; + } +} + +static inline void ctx_log_greg_write_pair (DisasContext *ctx,int rnum) +{ +ctx_log_greg_write (ctx, rnum);
Should we assert(!(rnum % 2))?
Quoted 2 lines
target/hexagon/translate.h +2
-0+ctx_log_greg_write (ctx, rnum +1 ); +}
PATCH v3 16/37 target/hexagon: Add imported macro, attr defs for sysemu
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/attribs_def.h.inc | 49 ++- target/hexagon/imported/macros.def | 558 +++++++++++++++++++++++++++++ 2 files changed, 601 insertions(+), 6 deletions(-) mode change 100755 => 100644 target/hexagon/imported/macros.def
target/hexagon/attribs_def.h.inc +43 -6
@@ -52,6 +52,9 @@ DEF_ATTRIB(REGWRSIZE_4B, "Memory width is 4 bytes", "", "") DEF_ATTRIB(REGWRSIZE_8B, "Memory width is 8 bytes", "", "") DEF_ATTRIB(MEMLIKE, "Memory-like instruction", "", "") DEF_ATTRIB(MEMLIKE_PACKET_RULES, "follows Memory-like packet rules", "", "") +DEF_ATTRIB(CACHEOP, "Cache operation", "", "") +DEF_ATTRIB(COPBYADDRESS, "Cache operation by address", "", "") +DEF_ATTRIB(COPBYIDX, "Cache operation by index", "", "") DEF_ATTRIB(RELEASE, "Releases a lock", "", "") DEF_ATTRIB(ACQUIRE, "Acquires a lock", "", "")
@@ -101,23 +104,44 @@ DEF_ATTRIB(ROPS_3, "Compound instruction worth 3 RISC-ops", "", "") /* access to implicit registers */ DEF_ATTRIB(IMPLICIT_WRITES_LR, "Writes the link register", "", "UREG.LR") +DEF_ATTRIB(IMPLICIT_READS_LR, "Reads the link register", "UREG.LR", "") +DEF_ATTRIB(IMPLICIT_READS_LC0, "Reads loop count for loop 0", "UREG.LC0", "") +DEF_ATTRIB(IMPLICIT_READS_LC1, "Reads loop count for loop 1", "UREG.LC1", "") +DEF_ATTRIB(IMPLICIT_READS_SA0, "Reads start address for loop 0", "UREG.SA0", "") +DEF_ATTRIB(IMPLICIT_READS_SA1, "Reads start address for loop 1", "UREG.SA1", "") +DEF_ATTRIB(IMPLICIT_WRITES_PC, "Writes the program counter", "", "UREG.PC") +DEF_ATTRIB(IMPLICIT_READS_PC, "Reads the program counter", "UREG.PC", "") DEF_ATTRIB(IMPLICIT_WRITES_SP, "Writes the stack pointer", "", "UREG.SP") +DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the stack pointer", "UREG.SP", "") DEF_ATTRIB(IMPLICIT_WRITES_FP, "Writes the frame pointer", "", "UREG.FP") +DEF_ATTRIB(IMPLICIT_READS_FP, "Reads the frame pointer", "UREG.FP", "") +DEF_ATTRIB(IMPLICIT_WRITES_GP, "Writes the GP register", "", "UREG.GP") +DEF_ATTRIB(IMPLICIT_READS_GP, "Reads the GP register", "UREG.GP", "") DEF_ATTRIB(IMPLICIT_WRITES_LC0, "Writes loop count for loop 0", "", "UREG.LC0") DEF_ATTRIB(IMPLICIT_WRITES_LC1, "Writes loop count for loop 1", "", "UREG.LC1") DEF_ATTRIB(IMPLICIT_WRITES_SA0, "Writes start addr for loop 0", "", "UREG.SA0") DEF_ATTRIB(IMPLICIT_WRITES_SA1, "Writes start addr for loop 1", "", "UREG.SA1") +DEF_ATTRIB(IMPLICIT_WRITES_R00, "Writes Register 0", "", "UREG.R00") DEF_ATTRIB(IMPLICIT_WRITES_P0, "Writes Predicate 0", "", "UREG.P0") DEF_ATTRIB(IMPLICIT_WRITES_P1, "Writes Predicate 1", "", "UREG.P1") DEF_ATTRIB(IMPLICIT_WRITES_P2, "Writes Predicate 1", "", "UREG.P2") DEF_ATTRIB(IMPLICIT_WRITES_P3, "May write Predicate 3", "", "UREG.P3") -DEF_ATTRIB(IMPLICIT_READS_PC, "Reads the PC register", "", "") -DEF_ATTRIB(IMPLICIT_READS_P0, "Reads the P0 register", "", "") -DEF_ATTRIB(IMPLICIT_READS_P1, "Reads the P1 register", "", "") -DEF_ATTRIB(IMPLICIT_READS_P2, "Reads the P2 register", "", "") -DEF_ATTRIB(IMPLICIT_READS_P3, "Reads the P3 register", "", "") +DEF_ATTRIB(IMPLICIT_READS_R00, "Reads Register 0", "UREG.R00", "") +DEF_ATTRIB(IMPLICIT_READS_P0, "Reads Predicate 0", "UREG.P0", "") +DEF_ATTRIB(IMPLICIT_READS_P1, "Reads Predicate 1", "UREG.P1", "") +DEF_ATTRIB(IMPLICIT_READS_P3, "Reads Predicate 3", "UREG.P3", "") +DEF_ATTRIB(IMPLICIT_READS_Q3, "Reads Vector Predicate 3", "UREG.Q3", "") +DEF_ATTRIB(IMPLICIT_READS_CS, "Reads the CS/M register", "UREG.CS", "") DEF_ATTRIB(IMPLICIT_WRITES_USR, "May write USR", "", "") -DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the SP register", "", "") +DEF_ATTRIB(IMPLICIT_WRITES_CCR, "Writes CCR register", "", "UREG.CCR") +DEF_ATTRIB(IMPLICIT_WRITES_GOSP, "Writes GOSP register", "", "UREG.GOSP") +DEF_ATTRIB(IMPLICIT_WRITES_SSR, "Writes SSR register", "", "UREG.SSR") +DEF_ATTRIB(IMPLICIT_WRITES_SGP0, "Writes SGP0 register", "", "UREG.SGP0") +DEF_ATTRIB(IMPLICIT_WRITES_SGP1, "Writes SGP1 register", "", "UREG.SGP1") +DEF_ATTRIB(IMPLICIT_WRITES_IMASK_ANYTHREAD, + "Writes IMASK for any thread", "", "") +DEF_ATTRIB(IMPLICIT_WRITES_STID_PRIO_ANYTHREAD, + "Writes STID priority for any thread", "", "") DEF_ATTRIB(COMMUTES, "The operation is communitive", "", "") DEF_ATTRIB(DEALLOCRET, "dealloc_return", "", "") DEF_ATTRIB(DEALLOCFRAME, "deallocframe", "", "")
@@ -137,9 +161,15 @@ DEF_ATTRIB(RESTRICT_SLOT3ONLY, "Must execute on slot3", "", "") DEF_ATTRIB(RESTRICT_NOSLOT1, "No slot 1 instruction in parallel", "", "") DEF_ATTRIB(RESTRICT_PREFERSLOT0, "Try to encode into slot 0", "", "") DEF_ATTRIB(RESTRICT_PACKET_AXOK, "May exist with A-type or X-type", "", "") +DEF_ATTRIB(RESTRICT_SINGLE_MEM_FIRST, "Single memory op must be first", "", "") +DEF_ATTRIB(RESTRICT_SLOT1_AOK, "Slot 1 is allowed", "", "") DEF_ATTRIB(ICOP, "Instruction cache op", "", "") +DEF_ATTRIB(EXCEPTION_SWI, "Software interrupt exception", "", "") +DEF_ATTRIB(DMA, "DMA instruction", "", "") +DEF_ATTRIB(NO_TIMING_LOG, "Does not get logged to the timing model", "", "") + DEF_ATTRIB(HWLOOP0_END, "Ends HW loop0", "", "") DEF_ATTRIB(HWLOOP1_END, "Ends HW loop1", "", "") DEF_ATTRIB(RET_TYPE, "return type", "", "")
@@ -151,6 +181,10 @@ DEF_ATTRIB(DCFETCH, "dcfetch type", "", "") DEF_ATTRIB(L2FETCH, "Instruction is l2fetch type", "", "") +DEF_ATTRIB(DCTAGOP, "Data cache tag operation", "", "") +DEF_ATTRIB(ICTAGOP, "Instruction cache tag operation", "", "") +DEF_ATTRIB(L2TAGOP, "L2 cache tag operation", "", "") + DEF_ATTRIB(ICINVA, "icinva", "", "") DEF_ATTRIB(DCCLEANINVA, "dccleaninva", "", "")
@@ -166,6 +200,9 @@ DEF_ATTRIB(NOTE_LATEPRED, "The predicate can not be used as a .new", "", "") DEF_ATTRIB(NOTE_NVSLOT0, "Can execute only in slot 0 (ST)", "", "") DEF_ATTRIB(NOTE_NOVP, "Cannot be paired with a HVX permute instruction", "", "") DEF_ATTRIB(NOTE_VA_UNARY, "Combined with HVX ALU op (must be unary)", "", "") +DEF_ATTRIB(NOTE_SLOT1_AOK, "Slot 1 is allowed", "", "") +DEF_ATTRIB(NOTE_GUEST, "Guest mode instruction", "", "") +DEF_ATTRIB(NOTE_BADTAG_UNDEF, "Bad tag results in undefined behavior", "", "") /* V6 MMVector Notes for Documentation */ DEF_ATTRIB(NOTE_SHIFT_RESOURCE, "Uses the HVX shift resource.", "", "")
target/hexagon/imported/macros.def +558 -0
651 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 17/37 target/hexagon: Add new macro definitions for sysemu
In reply to Brian CainFrom: Brian Cain <[email protected]>
Also: add nop TCG overrides for break, unpause, fetchbo; add TCG override for dczeroa_nt (non-temporal variant of dczeroa).
break: this hardware breakpoint instruction is used with the in-silicon debugger feature, this is not modeled.
unpause: this instruction is used to resume hardware threads that are stalled by pause instructions. pause is modeled as a nop, or in RR mode as an EXCP_YIELD. This instruction is safe to ignore.
Since prefetch functions are not modeled, fetchbo is safe to ignore.
--- target/hexagon/cpu_bits.h | 7 ++ target/hexagon/gen_tcg.h | 9 ++ target/hexagon/macros.h | 25 +++- target/hexagon/sys_macros.h | 237 ++++++++++++++++++++++++++++++++++++ target/hexagon/op_helper.c | 1 + 5 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 target/hexagon/sys_macros.h
target/hexagon/cpu_bits.h +7 -0
@@ -97,6 +97,13 @@ enum hex_cause { HEX_CAUSE_INT7 = 0x0c7, }; +enum data_cache_state { +HEX_DC_STATE_INVALID =0x0 , +HEX_DC_STATE_VALID =0x1 , +HEX_DC_STATE_RESERVED =0x2 , +HEX_DC_STATE_UNUSED_WT =0x3 , +}; +#define PACKET_WORDS_MAX 4static inline uint32_t parse_bits (uint32_t encoding)
target/hexagon/gen_tcg.h +9 -0
@@ -488,6 +488,7 @@/* dczeroa clears the 32 byte cache line at the address given */ #define fGEN_TCG_Y2_dczeroa (SHORTCODE ) SHORTCODE +#define fGEN_TCG_Y2_dczeroa_nt (SHORTCODE ) SHORTCODE/* In linux-user mode, these are not modelled, suppress compiler warning */ #define fGEN_TCG_Y2_dcinva (SHORTCODE ) \
@@ -1132,6 +1133,9 @@ RdV, tcg_constant_tl(0)); \ } while (0) +#define fGEN_TCG_Y2_break (SHORTCODE ) +#define fGEN_TCG_J2_unpause (SHORTCODE ) +#define fGEN_TCG_J2_pause (SHORTCODE ) \ do { \ uiV = uiV; \
@@ -1341,6 +1345,11 @@ RsV = RsV; \ uiV = uiV; \ } while (0) +#define fGEN_TCG_Y2_dcfetchbo_nt (SHORTCODE ) \ + do { \ + RsV = RsV; \ + uiV = uiV; \ + } while (0)#define fGEN_TCG_L2_loadw_aq (SHORTCODE ) SHORTCODE#define fGEN_TCG_L4_loadd_aq (SHORTCODE ) SHORTCODE
target/hexagon/macros.h +24 -1
@@ -631,8 +631,18 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#define fCONSTLL (A ) A##LL#define fECHO (A ) (A) -#define fTRAP (TRAPTYPE ,IMM ) helper_raise_exception(env, HEX_EXCP_TRAP0) +#ifdef CONFIG_USER_ONLY +#define fTRAP (TRAPTYPE ,IMM ) \ + do { \ + hexagon_raise_exception_err(env, HEX_EVENT_TRAP0, PC); \ + } while (0) +#endif + +#define fDO_TRACE (SREG ) +#define fBREAK () +#define fUNPAUSE ()#define fPAUSE (IMM ) +#define fDCFETCH (REG )#define fALIGN_REG_FIELD_VALUE (FIELD ,VAL ) \ ((VAL) << reg_field_info[FIELD].offset)
@@ -654,5 +664,18 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#define fBRANCH_SPECULATE_STALL (DOTNEWVAL ,JUMP_COND ,SPEC_DIR ,HINTBITNUM , \STRBITNUM )/* Nothing */ +#ifdef CONFIG_USER_ONLY +/* +* This macro can only be true in guest mode. +* In user mode, the 4 VIRTINSN's can't be reached +*/ +#define fTRAP1_VIRTINSN (IMM ) (false) +#define fVIRTINSN_SPSWAP (IMM ,REG ) g_assert_not_reached() +#define fVIRTINSN_GETIE (IMM ,REG ) g_assert_not_reached() +#define fVIRTINSN_SETIE (IMM ,REG ) g_assert_not_reached() +#define fVIRTINSN_RTE (IMM ,REG ) g_assert_not_reached() +#endif + +#define fPREDUSE_TIMING ()#endif
target/hexagon/sys_macros.h new file +237 -0
237 lines not on this page · raw message
target/hexagon/op_helper.c +1 -0
@@ -24,6 +24,7 @@#include "cpu.h" #include "internal.h" #include "macros.h" +#include "sys_macros.h" #include "arch.h" #include "hex_arch_types.h" #include "fma_emu.h"
Signature · 1 line
2.34.1
Re: [PATCH v3 17/37] target/hexagon: Add new macro definitions for sysemu
Quoted 30 lines · Brian Cain
From: Brian Cain <[email protected]>
Also: add nop TCG overrides for break, unpause, fetchbo; add TCG override for
dczeroa_nt(non-temporal variant of dczeroa).break: this hardware breakpoint instruction is used with the in-silicon debugger feature, this is not modeled.
unpause: this instruction is used to resume hardware threads that are stalled by pause instructions. pause is modeled as a nop, or in RR mode as an
EXCP_YIELD. This instruction is safe to ignore.Since prefetch functions are not modeled, fetchbo is safe to ignore.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu_bits.h | 7 ++ target/hexagon/gen_tcg.h | 9 ++ target/hexagon/macros.h | 25 +++- target/hexagon/sys_macros.h | 237 ++++++++++++++++++++++++++++++++++++ target/hexagon/op_helper.c | 1 + 5 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 target/hexagon/sys_macros.htarget/hexagon/cpu_bits.h +0
-0@@ -97,6 +97,13 @@ enum hex_cause { HEX_CAUSE_INT7 = 0x0c7,
target/hexagon/cpu_bits.h enum hex_cause { · line 107
Quoted 10 lines
target/hexagon/cpu_bits.h +7
-0}; +enum data_cache_state { +HEX_DC_STATE_INVALID =0x0 , +HEX_DC_STATE_VALID =0x1 , +HEX_DC_STATE_RESERVED =0x2 , +HEX_DC_STATE_UNUSED_WT =0x3 , +}; +
Are these needed?
Quoted 31 lines
target/hexagon/sys_macros.h new file +21
-0@@ -0,0 +1,237 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_SYS_MACROS_H +#define HEXAGON_SYS_MACROS_H + +/* +* Macro definitions for Hexagon system mode +*/ + +#ifndef CONFIG_USER_ONLY + +#define READ_SGP0 () (env->t_sreg[HEX_SREG_SGP0]) +#define READ_SGP1 () (env->t_sreg[HEX_SREG_SGP1]) +#define READ_SGP10 () ((uint64_t)(env->t_sreg[HEX_SREG_SGP0]) | \ + ((uint64_t)(env->t_sreg[HEX_SREG_SGP1]) << 32)) + +#define WRITE_SGP0 (VAL ) log_sreg_write(env, HEX_SREG_SGP0, VAL,slot)
+#defineWRITE_SGP1(VAL)log_sreg_write(env,HEX_SREG_SGP1, VAL,
slot)
target/hexagon/sys_macros.h line 28
Quoted 6 lines
target/hexagon/sys_macros.h new file +6
-0+#define WRITE_SGP10 (VAL ) \ + do { \ + log_sreg_write(env, HEX_SREG_SGP0, (VAL) & 0xFFFFFFFF, slot); \ + log_sreg_write(env, HEX_SREG_SGP1, (VAL) >> 32, slot); \ + } while (0) +
Are these READ/WRITE macros needed? They look like remnants of the old generators?
Otherwise
PATCH v3 18/37 target/hexagon: Add handlers for guest/sysreg r/w
In reply to Brian CainFrom: Brian Cain <[email protected]>
This commit provides handlers to generate TCG for guest and system register reads and writes. They will be leveraged by a future commit.
--- target/hexagon/genptr.c | 147 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+)
target/hexagon/genptr.c +147 -0
@@ -23,6 +23,7 @@#include "exec/helper-gen.h" #include "insn.h" #include "opcodes.h" +#include "sys_macros.h" #include "translate.h" #define QEMU_GENERATE /* Used internally by macros.h */ #include "macros.h"
@@ -120,6 +121,152 @@ TCGv get_result_pred(DisasContext *ctx, int pnum) } } +#ifndef CONFIG_USER_ONLY +G_GNUC_UNUSED +static bool greg_writable(int rnum, bool pair) +{ +if (pair) { +if (rnum <HEX_GREG_G3 ) { +return true; + } +qemu_log_mask (LOG_UNIMP , +"Warning: ignoring write to guest register pair G%d:%d\n" , + rnum +1 , rnum); + }else { +if (rnum <=HEX_GREG_G3 ) { +return true; + } +qemu_log_mask (LOG_UNIMP , +"Warning: ignoring write to guest register G%d\n" , rnum); + } +return false; +} + +G_GNUC_UNUSED +static void check_greg_impl(int rnum, bool pair) +{ +if (pair && (!greg_implemented (rnum) || !greg_implemented (rnum +1 ))) { +qemu_log_mask (LOG_UNIMP , +"Warning: guest register pair G%d:%d is unimplemented or " +"reserved. Read will yield 0.\n" , + rnum +1 , rnum); + }else if (!pair && !greg_implemented (rnum)) { +qemu_log_mask (LOG_UNIMP , +"Warning: guest register G%d is unimplemented or reserved." +" Read will yield 0.\n" , rnum); + } +} + +G_GNUC_UNUSED +static inline void gen_log_greg_write(DisasContext *ctx, int rnum, TCGv val) +{ +tcg_gen_mov_tl (ctx->greg_new_value[rnum], val); +} + +G_GNUC_UNUSED +static void gen_log_greg_write_pair(DisasContext *ctx, int rnum, TCGv_i64 val) +{ +TCGv val32 =tcg_temp_new (); + +/* Low word */ +tcg_gen_extrl_i64_i32 (val32, val); +gen_log_greg_write (ctx, rnum, val32); + +/* High word */ +tcg_gen_extrh_i64_i32 (val32, val); +gen_log_greg_write (ctx, rnum +1 , val32); +} + +static const target_ulong sreg_immut_masks[NUM_SREGS ] = { + [HEX_SREG_STID ] =0xff00ff00 , + [HEX_SREG_ELR ] =0x00000003 , + [HEX_SREG_SSR ] =0x00008000 , + [HEX_SREG_CCR ] =0x10e0ff24 , + [HEX_SREG_HTID ] =IMMUTABLE , + [HEX_SREG_IMASK ] =0xffff0000 , + [HEX_SREG_GEVB ] =0x000000ff , +}; + +G_GNUC_UNUSED +static void gen_log_sreg_write(DisasContext *ctx, int rnum, TCGv val) +{ +const target_ulong reg_mask = sreg_immut_masks[rnum]; + +if (reg_mask !=IMMUTABLE ) { +if (rnum <HEX_SREG_GLB_START ) { +gen_masked_reg_write (val, hex_t_sreg[rnum], reg_mask); +tcg_gen_mov_tl (ctx->t_sreg_new_value[rnum], val); + }else { +gen_helper_sreg_write_masked (tcg_env,tcg_constant_i32 (rnum), val); + } + } +} + +G_GNUC_UNUSED +static void gen_log_sreg_write_pair(DisasContext *ctx, int rnum, TCGv_i64 val) +{ +TCGv val32 =tcg_temp_new (); + +/* Low word */ +tcg_gen_extrl_i64_i32 (val32, val); +gen_log_sreg_write (ctx, rnum, val32); + +/* High word */ +tcg_gen_extrh_i64_i32 (val32, val); +gen_log_sreg_write (ctx, rnum +1 , val32); +} + +G_GNUC_UNUSED +static void gen_read_sreg(TCGv dst, int reg_num) +{ +if (reg_num >=HEX_SREG_GLB_START || reg_num ==HEX_SREG_BADVA ) { +gen_helper_sreg_read (dst, tcg_env,tcg_constant_i32 (reg_num)); + }else { +tcg_gen_mov_tl (dst, hex_t_sreg[reg_num]); + } +} + +G_GNUC_UNUSED +static void gen_read_sreg_pair(TCGv_i64 dst, int reg_num) +{ +if (reg_num <HEX_SREG_GLB_START ) { +if (reg_num +1 ==HEX_SREG_BADVA ) { +TCGv badva =tcg_temp_new (); +gen_helper_sreg_read (badva, tcg_env, +tcg_constant_tl (HEX_SREG_BADVA )); +tcg_gen_concat_i32_i64 (dst, hex_t_sreg[reg_num], badva); + }else { +tcg_gen_concat_i32_i64 (dst, hex_t_sreg[reg_num], + hex_t_sreg[reg_num +1 ]); + } + }else { +gen_helper_sreg_read_pair (dst, tcg_env,tcg_constant_tl (reg_num)); + } +} + +G_GNUC_UNUSED +static void gen_read_greg(TCGv dst, int reg_num) +{ +if (reg_num <=HEX_GREG_G3 ) { +tcg_gen_mov_tl (dst, hex_greg[reg_num]); + }else { +gen_helper_greg_read (dst, tcg_env,tcg_constant_tl (reg_num)); + } +} + +G_GNUC_UNUSED +static void gen_read_greg_pair(TCGv_i64 dst, int reg_num) +{ +if (reg_num ==HEX_GREG_G0 || reg_num ==HEX_GREG_G2 ) { +tcg_gen_concat_i32_i64 (dst, hex_greg[reg_num], + hex_greg[reg_num +1 ]); + }else { +gen_helper_greg_read_pair (dst, tcg_env,tcg_constant_tl (reg_num)); + } +} +#endif + +void gen_pred_write (DisasContext *ctx,int pnum,TCGv val) {TCGv pred =get_result_pred (ctx, pnum);
Signature · 1 line
2.34.1
Re: [PATCH v3 18/37] target/hexagon: Add handlers for guest/sysreg r/w
Quoted 10 lines · Brian Cain
From: Brian Cain <[email protected]>
This commit provides handlers to generate TCG for guest and system register reads and writes. They will be leveraged by a future commit.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/genptr.c | 147 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+)
PATCH v3 19/37 target/hexagon: Add placeholder greg/sreg r/w helpers
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/helper.h | 9 +++++++++ target/hexagon/op_helper.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
target/hexagon/helper.h +9 -0
@@ -107,3 +107,12 @@ DEF_HELPER_4(probe_noshuf_load, void, env, i32, int, int) DEF_HELPER_2(probe_pkt_scalar_store_s0, void, env, int) DEF_HELPER_2(probe_hvx_stores, void, env, int) DEF_HELPER_2(probe_pkt_scalar_hvx_stores, void, env, int) + +#if !defined(CONFIG_USER_ONLY ) +DEF_HELPER_2(sreg_read, i32, env, i32) +DEF_HELPER_2(sreg_read_pair, i64, env, i32) +DEF_HELPER_2(greg_read, i32, env, i32) +DEF_HELPER_2(greg_read_pair, i64, env, i32) +DEF_HELPER_3(sreg_write, void, env, i32, i32) +DEF_HELPER_3(sreg_write_pair, void, env, i32, i64) +#endif
target/hexagon/op_helper.c +34 -0
@@ -1370,6 +1370,40 @@ void HELPER(vwhist128qm)(CPUHexagonState *env, int32_t uiV) } } +#ifndef CONFIG_USER_ONLY +void HELPER (sreg_write )(CPUHexagonState *env,uint32_t reg,uint32_t val) +{ +g_assert_not_reached (); +} + +void HELPER (sreg_write_pair )(CPUHexagonState *env,uint32_t reg,uint64_t val) + +{ +g_assert_not_reached (); +} + +uint32_t HELPER (sreg_read )(CPUHexagonState *env,uint32_t reg) +{ +g_assert_not_reached (); +} + +uint64_t HELPER (sreg_read_pair )(CPUHexagonState *env,uint32_t reg) +{ +g_assert_not_reached (); +} + +uint32_t HELPER (greg_read )(CPUHexagonState *env,uint32_t reg) +{ +g_assert_not_reached (); +} + +uint64_t HELPER (greg_read_pair )(CPUHexagonState *env,uint32_t reg) +{ +g_assert_not_reached (); +} +#endif + +/* These macros can be referenced in the generated helper functions */ #define warn (...)/* Nothing */ #define fatal (...) g_assert_not_reached();
Signature · 1 line
2.34.1
PATCH v3 20/37 target/hexagon: Add vmstate representation
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/internal.h | 4 ++++ target/hexagon/cpu.c | 3 +++ target/hexagon/machine.c | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 target/hexagon/machine.c
target/hexagon/internal.h +4 -0
@@ -31,4 +31,8 @@ void hexagon_debug(CPUHexagonState *env);extern const char *const hexagon_regnames[TOTAL_PER_THREAD_REGS ]; +#ifndef CONFIG_USER_ONLY +extern const VMStateDescription vmstate_hexagon_cpu; +#endif +#endif
target/hexagon/cpu.c +3 -0
@@ -386,6 +386,9 @@ static void hexagon_cpu_class_init(ObjectClass *c, const void *data) cc->gdb_stop_before_watchpoint = true; cc->gdb_core_xml_file ="hexagon-core.xml" ; cc->disas_set_info = hexagon_cpu_disas_set_info; +#ifndef CONFIG_USER_ONLY + dc->vmsd = &vmstate_hexagon_cpu; +#endif cc->tcg_ops = &hexagon_tcg_ops; }
target/hexagon/machine.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "migration/cpu.h" +#include "cpu.h" + +const VMStateDescription vmstate_hexagon_cpu = { + .name ="cpu" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (parent_obj, HexagonCPU,0 , vmstate_cpu_common, CPUState), +VMSTATE_UINTTL_ARRAY (env.gpr, HexagonCPU,TOTAL_PER_THREAD_REGS ), +VMSTATE_UINTTL_ARRAY (env.pred, HexagonCPU,NUM_PREGS ), +VMSTATE_UINTTL_ARRAY (env.t_sreg, HexagonCPU,NUM_SREGS ), +VMSTATE_UINTTL_ARRAY (env.greg, HexagonCPU,NUM_GREGS ), +VMSTATE_END_OF_LIST () + }, +};
Signature · 1 line
2.34.1
Re: [PATCH v3 20/37] target/hexagon: Add vmstate representation
Quoted 50 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/internal.h | 4 ++++ target/hexagon/cpu.c | 3 +++ target/hexagon/machine.c | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+)create mode 100644
target/hexagon/machine.ctarget/hexagon/internal.h +4
-0@@ -31,4 +31,8 @@ void hexagon_debug(CPUHexagonState *env);extern const char *const hexagon_regnames[TOTAL_PER_THREAD_REGS ]; +#ifndef CONFIG_USER_ONLY +extern const VMStateDescription vmstate_hexagon_cpu; +#endif +#endif target/hexagon/cpu.c +3
-0@@ -386,6 +386,9 @@ static void hexagon_cpu_class_init(ObjectClass *c, const void *data) cc->gdb_stop_before_watchpoint = true; cc->gdb_core_xml_file ="hexagon-core.xml" ; cc->disas_set_info = hexagon_cpu_disas_set_info; +#ifndef CONFIG_USER_ONLY + dc->vmsd = &vmstate_hexagon_cpu; +#endif cc->tcg_ops = &hexagon_tcg_ops; }target/hexagon/machine.c new file +6
-0@@ -0,0 +1,23 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +
target/hexagon/machine.c line 16
Quoted 10 lines
target/hexagon/machine.c new file +10
-0+#include "qemu/osdep.h" +#include "migration/cpu.h" +#include "cpu.h" + +const VMStateDescription vmstate_hexagon_cpu = { + .name ="cpu" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (parent_obj, HexagonCPU,0 , vmstate_cpu_common, CPUState),
We shouldn't need that (the parent should be migrated by himself), but I'll defer to migration experts here.
target/hexagon/machine.c line 20
Quoted 4 lines
target/hexagon/machine.c new file +4
-0+VMSTATE_UINTTL_ARRAY (env.gpr, HexagonCPU,TOTAL_PER_THREAD_REGS ), +VMSTATE_UINTTL_ARRAY (env.pred, HexagonCPU,NUM_PREGS ), +VMSTATE_UINTTL_ARRAY (env.t_sreg, HexagonCPU,NUM_SREGS ), + VMSTATE_UINTTL_ARRAY(env.greg, HexagonCPU, NUM_GREGS),
VMSTATE_UINTTL_ARRAY() is about to be removed (as it doesn't scale for heterogeneous emulation). Please use VMSTATE_UINT32_ARRAY() instead.
Quoted 3 lines
target/hexagon/machine.c new file +3
-0+VMSTATE_END_OF_LIST () + }, +};
PATCH v3 21/37 target/hexagon: Make A_PRIV, "J2_trap*" insts need_env()
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/hex_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/hexagon/hex_common.py +3 -1
@@ -251,7 +251,9 @@ def need_env(tag): "A_LOAD" in attribdict[tag] or "A_CVI_GATHER" in attribdict[tag] or "A_CVI_SCATTER" in attribdict[tag] or - "A_IMPLICIT_WRITES_USR" in attribdict[tag]) + "A_IMPLICIT_WRITES_USR" in attribdict[tag] or + "A_PRIV" in attribdict[tag] or + "J2_trap" in tag) def need_slot(tag):
Signature · 1 line
2.34.1
PATCH v3 22/37 target/hexagon: Define register fields for system regs
In reply to Brian CainFrom: Brian Cain <[email protected]>
Define the register fields for ssr, schedcfg, stid, bestwait, ccr, modectl, imask, ipendad.
Define the fields for TLB entries.
--- target/hexagon/reg_fields_def.h.inc | 96 +++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
target/hexagon/reg_fields_def.h.inc +96 -0
@@ -39,3 +39,99 @@ DEF_REG_FIELD(USR_FPDBZE, 26, 1) DEF_REG_FIELD(USR_FPOVFE, 27, 1) DEF_REG_FIELD(USR_FPUNFE, 28, 1) DEF_REG_FIELD(USR_FPINPE, 29, 1) + +DEF_REG_FIELD(IPENDAD_IAD, 16, 16) +DEF_REG_FIELD(IPENDAD_IPEND, 0, 16) + +DEF_REG_FIELD(SCHEDCFG_EN, 8, 1) +DEF_REG_FIELD(SCHEDCFG_INTNO, 0, 4) +DEF_REG_FIELD(BESTWAIT_PRIO, 0, 9) + + +/* PTE (aka TLB entry) fields */ +DEF_REG_FIELD(PTE_PPD, 0, 24) +DEF_REG_FIELD(PTE_C, 24, 4) +DEF_REG_FIELD(PTE_U, 28, 1) +DEF_REG_FIELD(PTE_R, 29, 1) +DEF_REG_FIELD(PTE_W, 30, 1) +DEF_REG_FIELD(PTE_X, 31, 1) +DEF_REG_FIELD(PTE_VPN, 32, 20) +DEF_REG_FIELD(PTE_ASID, 52, 7) +DEF_REG_FIELD(PTE_ATR0, 59, 1) +DEF_REG_FIELD(PTE_ATR1, 60, 1) +DEF_REG_FIELD(PTE_PA35, 61, 1) +DEF_REG_FIELD(PTE_G, 62, 1) +DEF_REG_FIELD(PTE_V, 63, 1) + +/* SYSCFG fields */ +DEF_REG_FIELD(SYSCFG_MMUEN, 0, 1) +DEF_REG_FIELD(SYSCFG_ICEN, 1, 1) +DEF_REG_FIELD(SYSCFG_DCEN, 2, 1) +DEF_REG_FIELD(SYSCFG_ISDBTRUSTED, 3, 1) +DEF_REG_FIELD(SYSCFG_GIE, 4, 1) +DEF_REG_FIELD(SYSCFG_ISDBREADY, 5, 1) +DEF_REG_FIELD(SYSCFG_PCYCLEEN, 6, 1) +DEF_REG_FIELD(SYSCFG_V2X, 7, 1) +DEF_REG_FIELD(SYSCFG_IGNOREDABORT, 8, 1) +DEF_REG_FIELD(SYSCFG_PM, 9, 1) +DEF_REG_FIELD(SYSCFG_TLBLOCK, 11, 1) +DEF_REG_FIELD(SYSCFG_K0LOCK, 12, 1) +DEF_REG_FIELD(SYSCFG_BQ, 13, 1) +DEF_REG_FIELD(SYSCFG_PRIO, 14, 1) +DEF_REG_FIELD(SYSCFG_DMT, 15, 1) +DEF_REG_FIELD(SYSCFG_L2CFG, 16, 3) +DEF_REG_FIELD(SYSCFG_ITCM, 19, 1) +DEF_REG_FIELD(SYSCFG_L2NWA, 21, 1) +DEF_REG_FIELD(SYSCFG_L2NRA, 22, 1) +DEF_REG_FIELD(SYSCFG_L2WB, 23, 1) +DEF_REG_FIELD(SYSCFG_L2P, 24, 1) +DEF_REG_FIELD(SYSCFG_SLVCTL0, 25, 2) +DEF_REG_FIELD(SYSCFG_SLVCTL1, 27, 2) +DEF_REG_FIELD(SYSCFG_L2PARTSIZE, 29, 2) +DEF_REG_FIELD(SYSCFG_L2GCA, 31, 1) + +/* SSR fields */ +DEF_REG_FIELD(SSR_CAUSE, 0, 8) +DEF_REG_FIELD(SSR_ASID, 8, 7) +DEF_REG_FIELD(SSR_UM, 16, 1) +DEF_REG_FIELD(SSR_EX, 17, 1) +DEF_REG_FIELD(SSR_IE, 18, 1) +DEF_REG_FIELD(SSR_GM, 19, 1) +DEF_REG_FIELD(SSR_V0, 20, 1) +DEF_REG_FIELD(SSR_V1, 21, 1) +DEF_REG_FIELD(SSR_BVS, 22, 1) +DEF_REG_FIELD(SSR_CE, 23, 1) +DEF_REG_FIELD(SSR_PE, 24, 1) +DEF_REG_FIELD(SSR_BP, 25, 1) +DEF_REG_FIELD(SSR_XE2, 26, 1) +DEF_REG_FIELD(SSR_XA, 27, 3) +DEF_REG_FIELD(SSR_SS, 30, 1) +DEF_REG_FIELD(SSR_XE, 31, 1) + +/* misc registers */ +DEF_REG_FIELD(IMASK_MASK, 0, 16) + +DEF_REG_FIELD(STID_PRIO, 16, 8) +DEF_REG_FIELD(STID_STID, 0, 8) + +/* MODECTL fields */ +DEF_REG_FIELD(MODECTL_E, 0, 8) +DEF_REG_FIELD(MODECTL_W, 16, 8) + +DEF_REG_FIELD(CCR_L1ICP, 0, 2) +DEF_REG_FIELD(CCR_L1DCP, 3, 2) +DEF_REG_FIELD(CCR_L2CP, 6, 2) + +DEF_REG_FIELD(CCR_HFI, 16, 1) +DEF_REG_FIELD(CCR_HFD, 17, 1) +DEF_REG_FIELD(CCR_HFIL2, 18, 1) +DEF_REG_FIELD(CCR_HFDL2, 19, 1) +DEF_REG_FIELD(CCR_SFD, 20, 1) + +DEF_REG_FIELD(CCR_GIE, 24, 1) +DEF_REG_FIELD(CCR_GTE, 25, 1) +DEF_REG_FIELD(CCR_GEE, 26, 1) +DEF_REG_FIELD(CCR_GRE, 27, 1) +DEF_REG_FIELD(CCR_VV1, 29, 1) +DEF_REG_FIELD(CCR_VV2, 30, 1) +DEF_REG_FIELD(CCR_VV3, 31, 1)
Signature · 1 line
2.34.1
PATCH v3 33/37 target/hexagon: Add {TLB, k0}lock, cause code, wait_next_pc
In reply to Brian CainFrom: Brian Cain <[email protected]>
{TLB,k0}lock counts are used to represent the TLB, k0 locks among hardware threads.
wait_next_pc represents the program counter to set when resuming from a wait-for-interrupts state.
cause_code contains the precise exception cause.This will be used by subsequent commits.
--- target/hexagon/cpu.h | 3 +++ target/hexagon/cpu.c | 4 ++++ target/hexagon/machine.c | 2 ++ 3 files changed, 9 insertions(+)
target/hexagon/cpu.h +3 -0
@@ -130,11 +130,14 @@ typedef struct CPUArchState {target_ulong t_sreg[NUM_SREGS ];target_ulong greg[NUM_GREGS ]; +target_ulong wait_next_pc;/* This alias of CPUState.cpu_index is used by imported sources: */ target_ulong threadId;hex_lock_state_t tlb_lock_state;hex_lock_state_t k0_lock_state; +target_ulong tlb_lock_count; +target_ulong k0_lock_count;#endif target_ulong next_PC;target_ulong new_value_usr;
target/hexagon/cpu.c +4 -0
@@ -317,7 +317,11 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type) env->threadId = cs->cpu_index; env->tlb_lock_state =HEX_LOCK_UNLOCKED ; env->k0_lock_state =HEX_LOCK_UNLOCKED ; + env->tlb_lock_count =0 ; + env->k0_lock_count =0 ; env->next_PC =0 ; + env->wait_next_pc =0 ; + env->cause_code =HEX_EVENT_NONE ;#endif env->cause_code =HEX_EVENT_NONE ; }
target/hexagon/machine.c +2 -0
@@ -24,6 +24,8 @@ const VMStateDescription vmstate_hexagon_cpu = { VMSTATE_UINTTL(env.tlb_lock_count, HexagonCPU), VMSTATE_UINTTL(env.k0_lock_count, HexagonCPU), VMSTATE_UINTTL(env.threadId, HexagonCPU), + VMSTATE_UINTTL(env.cause_code, HexagonCPU), + VMSTATE_UINTTL(env.wait_next_pc, HexagonCPU),VMSTATE_END_OF_LIST () }, };
Signature · 1 line
2.34.1
PATCH v3 23/37 target/hexagon: Implement do_raise_exception()
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/internal.h | 5 +++++ target/hexagon/op_helper.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+)
target/hexagon/internal.h +5 -0
@@ -31,6 +31,11 @@ void hexagon_debug(CPUHexagonState *env);extern const char *const hexagon_regnames[TOTAL_PER_THREAD_REGS ]; +void G_NORETURN do_raise_exception(CPUHexagonState *env, +uint32_t exception, +target_ulong PC , +uintptr_t retaddr); +#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_hexagon_cpu;#endif
target/hexagon/op_helper.c +19 -0
@@ -37,6 +37,25 @@#define SF_MANTBITS 23/* Exceptions processing helpers */ +G_NORETURN +void do_raise_exception(CPUHexagonState *env, uint32_t exception, +target_ulong PC ,uintptr_t retaddr) +{ +CPUState *cs =env_cpu (env); +#ifdef CONFIG_USER_ONLY +qemu_log_mask (CPU_LOG_INT ,"%s: 0x%08x\n" , __func__, exception); +#else +qemu_log_mask (CPU_LOG_INT ,"%s: 0x%08x, @ %08" PRIx32"\n" , + __func__, exception,PC ); + +ASSERT_DIRECT_TO_GUEST_UNSET (env, exception); +#endif + + env->gpr[HEX_REG_PC ] =PC ; + cs->exception_index = exception; +cpu_loop_exit_restore (cs, retaddr); +} + G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,uint32_t exception,uintptr_t pc)
Signature · 1 line
2.34.1
Re: [PATCH v3 23/37] target/hexagon: Implement do_raise_exception()
Quoted 33 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/internal.h | 5 +++++ target/hexagon/op_helper.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+)target/hexagon/internal.h +5
-0@@ -31,6 +31,11 @@ void hexagon_debug(CPUHexagonState *env);extern const char *const hexagon_regnames[TOTAL_PER_THREAD_REGS ]; +void G_NORETURN do_raise_exception(CPUHexagonState *env, +uint32_t exception, +target_ulong PC , +uintptr_t retaddr); +#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_hexagon_cpu;#endif target/hexagon/op_helper.c +1
-0@@ -37,6 +37,25 @@#define SF_MANTBITS 23/* Exceptions processing helpers */ +G_NORETURN
target/hexagon/op_helper.c line 50
Quoted 10 lines
target/hexagon/op_helper.c +9
-0+void do_raise_exception (CPUHexagonState *env,uint32_t exception, +target_ulong PC ,uintptr_t retaddr) +{ +CPUState *cs =env_cpu (env); +#ifdef CONFIG_USER_ONLY +qemu_log_mask (CPU_LOG_INT ,"%s: 0x%08x\n" , __func__, exception); +#else +qemu_log_mask (CPU_LOG_INT ,"%s: 0x%08x, @ %08" PRIx32"\n" , + __func__, exception,PC );
Just print this in both user and system mode.
Also, use PRIx32 instead of the x in the format string.
target/hexagon/op_helper.c
Quoted 3 lines
target/hexagon/op_helper.c +2
-0+ +ASSERT_DIRECT_TO_GUEST_UNSET (env, exception);
Consider defining this macro to a nop in user mode. Then you don't need the #ifdef CONFIG_USER_ONLY in this function.
target/hexagon/op_helper.c line 55
Quoted 3 lines
target/hexagon/op_helper.c +1
-0+#endif
Otherwise
PATCH v3 24/37 target/hexagon: Add system reg insns
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/imported/encode_pp.def | 128 ++++++++++++-- target/hexagon/imported/system.idef | 244 ++++++++++++++++++++++++-- 2 files changed, 345 insertions(+), 27 deletions(-)
target/hexagon/imported/encode_pp.def +114 -14
@@ -382,15 +382,18 @@ DEF_ENC32(L4_return_fnew_pt, ICLASS_LD" 011 0 000 sssss PP1110vv ---ddddd") DEF_ENC32(L4_return_tnew_pnt, ICLASS_LD" 011 0 000 sssss PP0010vv ---ddddd") DEF_ENC32(L4_return_fnew_pnt, ICLASS_LD" 011 0 000 sssss PP1010vv ---ddddd") -DEF_ENC32(L2_loadw_locked,ICLASS_LD" 001 0 000 sssss PP000--- 000ddddd") - +/** Load Acquire Store Release Encoding **/ +DEF_ENC32(L2_loadw_locked, ICLASS_LD" 001 0 000 sssss PP000--- 000ddddd") +DEF_ENC32(L4_loadd_locked, ICLASS_LD" 001 0 000 sssss PP010--- 000ddddd") DEF_ENC32(L2_loadw_aq, ICLASS_LD" 001 0 000 sssss PP001--- 000ddddd") DEF_ENC32(L4_loadd_aq, ICLASS_LD" 001 0 000 sssss PP011--- 000ddddd") -DEF_ENC32(R6_release_at_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --0011dd") -DEF_ENC32(R6_release_st_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --1011dd") + +DEF_ENC32(S2_storew_locked, ICLASS_ST" 000 01 01sssss PP-ttttt ----00dd") +DEF_ENC32(S4_stored_locked, ICLASS_ST" 000 01 11sssss PP0ttttt ----00dd") + DEF_ENC32(S2_storew_rl_at_vi, ICLASS_ST" 000 01 01sssss PP-ttttt --0010dd") DEF_ENC32(S2_storew_rl_st_vi, ICLASS_ST" 000 01 01sssss PP-ttttt --1010dd")
@@ -398,17 +401,15 @@ DEF_ENC32(S2_storew_rl_st_vi, ICLASS_ST" 000 01 01sssss PP-ttttt --1010dd") DEF_ENC32(S4_stored_rl_at_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --0010dd") DEF_ENC32(S4_stored_rl_st_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --1010dd") -DEF_ENC32(L4_loadd_locked,ICLASS_LD" 001 0 000 sssss PP010--- 000ddddd") -DEF_EXT_SPACE(EXTRACTW, ICLASS_LD" 001 0 000 iiiii PP0iiiii -01iiiii") +DEF_ENC32(R6_release_at_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --0011dd") +DEF_ENC32(R6_release_st_vi, ICLASS_ST" 000 01 11sssss PP0ttttt --1011dd") + +DEF_EXT_SPACE(EXTRACTW, ICLASS_LD" 001 0 000 iiiii PP0iiiii 001iiiii") DEF_ENC32(Y2_dcfetchbo, ICLASS_LD" 010 0 000 sssss PP0--iii iiiiiiii") - - - - /*******************************/ /* */ /* */
@@ -488,13 +489,17 @@ STD_PST_ENC(rinew, "1 101","10ttt") /* x bus/cache */ /* x store/cache */ DEF_ENC32(S2_allocframe, ICLASS_ST" 000 01 00xxxxx PP000iii iiiiiiii") -DEF_ENC32(S2_storew_locked,ICLASS_ST" 000 01 01sssss PP-ttttt ----00dd") -DEF_ENC32(S4_stored_locked,ICLASS_ST" 000 01 11sssss PP0ttttt ----00dd") +DEF_ENC32(Y5_l2locka, ICLASS_ST" 000 01 11sssss PP1----- ------dd") DEF_ENC32(Y2_dczeroa, ICLASS_ST" 000 01 10sssss PP0----- --------") DEF_ENC32(Y2_barrier, ICLASS_ST" 100 00 00----- PP------ 000-----") DEF_ENC32(Y2_syncht, ICLASS_ST" 100 00 10----- PP------ --------") +DEF_ENC32(Y2_l2kill, ICLASS_ST" 100 00 01----- PP-000-- --------") +DEF_ENC32(Y5_l2gunlock, ICLASS_ST" 100 00 01----- PP-010-- --------") +DEF_ENC32(Y5_l2gclean, ICLASS_ST" 100 00 01----- PP-100-- --------") +DEF_ENC32(Y5_l2gcleaninv, ICLASS_ST" 100 00 01----- PP-110-- --------") +DEF_ENC32(Y2_l2cleaninvidx,ICLASS_ST" 100 00 11sssss PP------ --------")
@@ -502,9 +507,28 @@ DEF_ENC32(Y2_dccleana, ICLASS_ST" 000 00 00sssss PP------ --------") DEF_ENC32(Y2_dcinva, ICLASS_ST" 000 00 01sssss PP------ --------") DEF_ENC32(Y2_dccleaninva, ICLASS_ST" 000 00 10sssss PP------ --------") -DEF_ENC32(Y4_l2fetch, ICLASS_ST" 011 00 00sssss PP-ttttt 000-----") +/* Super */ +DEF_ENC32(Y2_dckill, ICLASS_ST" 001 00 00----- PP------ --------") +DEF_ENC32(Y2_dccleanidx, ICLASS_ST" 001 00 01sssss PP------ --------") +DEF_ENC32(Y2_dcinvidx, ICLASS_ST" 001 00 10sssss PP------ --------") +DEF_ENC32(Y2_dccleaninvidx,ICLASS_ST" 001 00 11sssss PP------ --------") + +DEF_ENC32(Y2_dctagw ,ICLASS_ST" 010 00 00sssss PP-ttttt --------") +DEF_ENC32(Y2_dctagr ,ICLASS_ST" 010 00 01sssss PP------ ---ddddd") + +DEF_ENC32(Y4_l2tagw ,ICLASS_ST" 010 00 10sssss PP0ttttt --------") +DEF_ENC32(Y4_l2tagr ,ICLASS_ST" 010 00 11sssss PP------ ---ddddd") + +DEF_ENC32(Y4_l2fetch, ICLASS_ST" 011 00 00sssss PP-ttttt 000-----") +DEF_ENC32(Y5_l2cleanidx, ICLASS_ST" 011 00 01sssss PP------ --------") +DEF_ENC32(Y5_l2invidx, ICLASS_ST" 011 00 10sssss PP------ --------") +DEF_ENC32(Y5_l2unlocka, ICLASS_ST" 011 00 11sssss PP------ --------") DEF_ENC32(Y5_l2fetch, ICLASS_ST" 011 01 00sssss PP-ttttt --------") +DEF_ENC32(Y6_l2gcleanpa, ICLASS_ST" 011 01 01----- PP-ttttt --------") +DEF_ENC32(Y6_l2gcleaninvpa,ICLASS_ST" 011 01 10----- PP-ttttt --------") + + /*******************************/ /* */ /* */
@@ -547,13 +571,23 @@ DEF_ENC32(J2_jumprfnewpt, ICLASS_J" 0011 011sssss PP-11-uu --------") DEF_FIELDROW_DESC32(ICLASS_J" 0100 -------- PP------ --------","[#4] (#u8) ") DEF_ENC32(J2_trap0, ICLASS_J" 0100 00------ PP-iiiii ---iii--") -DEF_ENC32(J2_pause, ICLASS_J" 0100 01------ PP-iiiii ---iii--") +DEF_ENC32(J2_trap1, ICLASS_J" 0100 10-xxxxx PP-iiiii ---iii--") +DEF_ENC32(J2_pause, ICLASS_J" 0100 01----ii PP-iiiii ---iii--") + +DEF_FIELDROW_DESC32(ICLASS_J" 0101 -------- PP------ --------","[#5] Rd=(Rs) ") +DEF_ENC32(Y2_icdatar, ICLASS_J" 0101 101sssss PP------ ---ddddd") +DEF_ENC32(Y2_ictagr, ICLASS_J" 0101 111sssss PP------ ---ddddd") +DEF_ENC32(Y2_ictagw, ICLASS_J" 0101 110sssss PP0ttttt --------") +DEF_ENC32(Y2_icdataw, ICLASS_J" 0101 110sssss PP1ttttt --------") DEF_FIELDROW_DESC32(ICLASS_J" 0110 -------- PP------ --------","[#6] icop(Rs) ") DEF_ENC32(Y2_icinva, ICLASS_J" 0110 110sssss PP000--- --------") +DEF_ENC32(Y2_icinvidx, ICLASS_J" 0110 110sssss PP001--- --------") +DEF_ENC32(Y2_ickill, ICLASS_J" 0110 110----- PP010--- --------") DEF_FIELDROW_DESC32(ICLASS_J" 0111 -------- PP------ --------","[#7] () ") DEF_ENC32(Y2_isync, ICLASS_J" 0111 11000000 PP0---00 00000010") +DEF_ENC32(J2_rte, ICLASS_J" 0111 111----- PP00---- 000-----") /* JUMP */ DEF_FIELDROW_DESC32(ICLASS_J" 100- -------- PP------ --------","[#8,9] PC=(#r22)")
@@ -738,12 +772,19 @@ DEF_ENC32(J2_jumprltezpt,ICLASS_CR" 0001 11isssss PPi1iiii iiiiiii-") DEF_FIELDROW_DESC32( ICLASS_CR" 0010 -------- PP------ --------","[#2] Cd=Rs ") DEF_ENC32(A2_tfrrcr, ICLASS_CR" 0010 001sssss PP------ ---ddddd") +DEF_ENC32(G4_tfrgrcr, ICLASS_CR" 0010 000sssss PP------ ---ddddd") +DEF_ENC32(Y4_trace, ICLASS_CR" 0010 010sssss PP------ 000-----") +DEF_ENC32(Y6_diag, ICLASS_CR" 0010 010sssss PP------ 001-----") +DEF_ENC32(Y6_diag0, ICLASS_CR" 0010 010sssss PP-ttttt 010-----") +DEF_ENC32(Y6_diag1, ICLASS_CR" 0010 010sssss PP-ttttt 011-----") DEF_FIELDROW_DESC32( ICLASS_CR" 0011 -------- PP------ --------","[#3] Cdd=Rss ") DEF_ENC32(A4_tfrpcp, ICLASS_CR" 0011 001sssss PP------ ---ddddd") +DEF_ENC32(G4_tfrgpcp, ICLASS_CR" 0011 000sssss PP------ ---ddddd") DEF_FIELDROW_DESC32( ICLASS_CR" 1000 -------- PP------ --------","[#8] Rdd=Css ") DEF_ENC32(A4_tfrcpp, ICLASS_CR" 1000 000sssss PP------ ---ddddd") +DEF_ENC32(G4_tfrgcpp, ICLASS_CR" 1000 001sssss PP------ ---ddddd") DEF_FIELDROW_DESC32( ICLASS_CR" 1001 -------- PP------ --------","[#9] (#r8,#U10)") DEF_ENC32(J2_ploop1si, ICLASS_CR" 1001 101IIIII PP-iiiii IIIii-II")
@@ -754,6 +795,7 @@ DEF_ENC32(J2_loop1i, ICLASS_CR" 1001 001IIIII PP-iiiii IIIii-II") DEF_FIELDROW_DESC32( ICLASS_CR" 1010 -------- PP------ --------","[#10] Rd=Cs ") DEF_ENC32(A2_tfrcrr, ICLASS_CR" 1010 000sssss PP------ ---ddddd") +DEF_ENC32(G4_tfrgcrr, ICLASS_CR" 1010 001sssss PP------ ---ddddd") DEF_ENC32(C4_addipc, ICLASS_CR" 1010 01001001 PP-iiiii i--ddddd")
@@ -781,6 +823,64 @@ DEF_ENC32(C4_fastcorner9_not, ICLASS_CR"1011 0001--ss PP1---tt 1--1--dd") +/* Supervisor CR ops */ +/* Interrupts */ +DEF_FIELDROW_DESC32( ICLASS_CR" 0100 -------- PP------ --------","[#4] (Rs,Pt)") +DEF_ENC32(Y2_swi, ICLASS_CR" 0100 000sssss PP------ 000-----") +DEF_ENC32(Y2_cswi, ICLASS_CR" 0100 000sssss PP------ 001-----") +DEF_ENC32(Y2_iassignw, ICLASS_CR" 0100 000sssss PP------ 010-----") +DEF_ENC32(Y2_ciad, ICLASS_CR" 0100 000sssss PP------ 011-----") +DEF_ENC32(Y2_setimask, ICLASS_CR" 0100 100sssss PP----tt 000-----") +DEF_ENC32(Y2_setprio, ICLASS_CR" 0100 100sssss PP----tt 001-----") +DEF_ENC32(Y4_siad, ICLASS_CR" 0100 100sssss PP------ 011-----") + +DEF_ENC32(Y2_wait, ICLASS_CR" 0100 010sssss PP------ 000-----") +DEF_ENC32(Y2_resume, ICLASS_CR" 0100 010sssss PP------ 001-----") +DEF_ENC32(Y2_stop, ICLASS_CR" 0100 011sssss PP------ 000-----") +DEF_ENC32(Y2_start, ICLASS_CR" 0100 011sssss PP------ 001-----") +DEF_ENC32(Y4_nmi, ICLASS_CR" 0100 011sssss PP------ 010-----") + +DEF_FIELDROW_DESC32( ICLASS_CR" 0101 -------- PP------ --------","[#5] Rx ") +DEF_ENC32(Y2_crswap0, ICLASS_CR" 0101 000xxxxx PP------ --------") +DEF_ENC32(Y4_crswap1, ICLASS_CR" 0101 001xxxxx PP------ --------") + +DEF_FIELDROW_DESC32( ICLASS_CR" 0110 -------- PP------ --------","[#6] Rd=(Rs)") +DEF_ENC32(Y2_getimask, ICLASS_CR" 0110 000sssss PP------ ---ddddd") +DEF_ENC32(Y2_iassignr, ICLASS_CR" 0110 011sssss PP------ ---ddddd") + +DEF_FIELDROW_DESC32( ICLASS_CR" 0111 -------- PP------ --------","[#7] cr=Rs ") +DEF_ENC32(Y2_tfrsrcr, ICLASS_CR" 0111 00-sssss PP------ -ddddddd") + +DEF_FIELDROW_DESC32( ICLASS_CR" 1100 -------- PP------ --------","[#12] ") +DEF_ENC32(Y2_break, ICLASS_CR" 1100 001----- PP------ 000-----") +DEF_ENC32(Y2_tlblock, ICLASS_CR" 1100 001----- PP------ 001-----") +DEF_ENC32(Y2_tlbunlock,ICLASS_CR" 1100 001----- PP------ 010-----") +DEF_ENC32(Y2_k0lock, ICLASS_CR" 1100 001----- PP------ 011-----") +DEF_ENC32(Y2_k0unlock, ICLASS_CR" 1100 001----- PP------ 100-----") +DEF_ENC32(Y2_tlbp, ICLASS_CR" 1100 100sssss PP------ ---ddddd") +DEF_ENC32(Y5_tlboc, ICLASS_CR" 1100 111sssss PP------ ---ddddd") +DEF_ENC32(Y5_tlbasidi, ICLASS_CR" 1100 101sssss PP------ --------") +DEF_ENC32(Y2_tlbr, ICLASS_CR" 1100 010sssss PP------ ---ddddd") +DEF_ENC32(Y2_tlbw, ICLASS_CR" 1100 000sssss PP0ttttt --------") +DEF_ENC32(Y5_ctlbw, ICLASS_CR" 1100 110sssss PP0ttttt ---ddddd") + +DEF_FIELDROW_DESC32( ICLASS_CR" 1101 -------- PP------ --------","[#13] Rxx ") +DEF_ENC32(Y4_crswap10, ICLASS_CR" 1101 10-xxxxx PP------ ---00000") +DEF_ENC32(Y4_tfrspcp, ICLASS_CR" 1101 00-sssss PP------ -ddddddd") + +DEF_FIELDROW_DESC32( ICLASS_CR" 1110 -------- PP------ --------","[#14] Rd=cr ") +DEF_ENC32(Y2_tfrscrr, ICLASS_CR" 1110 1sssssss PP------ ---ddddd") + +DEF_FIELDROW_DESC32( ICLASS_CR" 1111 -------- PP------ --------","[#15] Rdd=Sss ") +DEF_ENC32(Y4_tfrscpp, ICLASS_CR" 1111 0sssssss PP------ ---ddddd") + + + + + + + + /*******************************/ /* */ /* */
target/hexagon/imported/system.idef +231 -13
272 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 24/37] target/hexagon: Add system reg insns
Quoted 8 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/imported/encode_pp.def | 128 ++++++++++++-- target/hexagon/imported/system.idef | 244 ++++++++++++++++++++++++-- 2 files changed, 345 insertions(+), 27 deletions(-)
PATCH v3 25/37 target/hexagon: Add sysemu TCG overrides
In reply to Brian CainFrom: Brian Cain <[email protected]>
Define TCG overrides for setprio(), crswap(,sgp{0,1,1:0}).
--- target/hexagon/cpu_helper.h | 34 ++++++++++++++++++++++++++++++ target/hexagon/gen_tcg_sys.h | 40 ++++++++++++++++++++++++++++++++++++ target/hexagon/helper.h | 1 + target/hexagon/genptr.c | 4 ++++ target/hexagon/op_helper.c | 7 +++++++ target/hexagon/hex_common.py | 2 ++ target/hexagon/meson.build | 13 ++++++------ 7 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 target/hexagon/cpu_helper.h create mode 100644 target/hexagon/gen_tcg_sys.h
target/hexagon/cpu_helper.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_CPU_HELPER_H +#define HEXAGON_CPU_HELPER_H + +static inline void arch_set_thread_reg (CPUHexagonState *env,uint32_t reg, +uint32_t val) +{ +g_assert (reg <TOTAL_PER_THREAD_REGS ); +g_assert_not_reached (); +} + +static inline uint32_t arch_get_thread_reg (CPUHexagonState *env,uint32_t reg) +{ +g_assert (reg <TOTAL_PER_THREAD_REGS ); +g_assert_not_reached (); +} + +static inline void arch_set_system_reg (CPUHexagonState *env,uint32_t reg, +uint32_t val) +{ +g_assert_not_reached (); +} + +static inline uint32_t arch_get_system_reg (CPUHexagonState *env,uint32_t reg) +{ +g_assert_not_reached (); +} + +#endif
target/hexagon/gen_tcg_sys.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GEN_TCG_SYS_H +#define HEXAGON_GEN_TCG_SYS_H + +#define fGEN_TCG_Y2_setprio (SHORTCODE ) \ + gen_helper_setprio(tcg_env, PtV, RsV) + +#define fGEN_TCG_Y2_crswap0 (SHORTCODE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_mov_tl(tmp, RxV); \ + tcg_gen_mov_tl(RxV, hex_t_sreg[HEX_SREG_SGP0]); \ + tcg_gen_mov_tl(ctx->t_sreg_new_value[HEX_SREG_SGP0], tmp); \ + } while (0) + +#define fGEN_TCG_Y4_crswap1 (SHORTCODE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_mov_tl(tmp, RxV); \ + tcg_gen_mov_tl(RxV, hex_t_sreg[HEX_SREG_SGP1]); \ + tcg_gen_mov_tl(ctx->t_sreg_new_value[HEX_SREG_SGP1], tmp); \ + } while (0) + +#define fGEN_TCG_Y4_crswap10 (SHORTCODE ) \ + do { \ + TCGv_i64 tmp = tcg_temp_new_i64(); \ + tcg_gen_mov_i64(tmp, RxxV); \ + tcg_gen_concat_i32_i64(RxxV, \ + hex_t_sreg[HEX_SREG_SGP0], \ + hex_t_sreg[HEX_SREG_SGP1]); \ + tcg_gen_extrl_i64_i32(ctx->t_sreg_new_value[HEX_SREG_SGP0], tmp); \ + tcg_gen_extrh_i64_i32(ctx->t_sreg_new_value[HEX_SREG_SGP1], tmp); \ + } while (0) + +#endif
target/hexagon/helper.h +1 -0
@@ -115,4 +115,5 @@ DEF_HELPER_2(greg_read, i32, env, i32) DEF_HELPER_2(greg_read_pair, i64, env, i32) DEF_HELPER_3(sreg_write, void, env, i32, i32) DEF_HELPER_3(sreg_write_pair, void, env, i32, i64) +DEF_HELPER_3(setprio, void, env, i32, i32)#endif
target/hexagon/genptr.c +4 -0
@@ -31,6 +31,10 @@#undef QEMU_GENERATE#include "gen_tcg.h" #include "gen_tcg_hvx.h" +#ifndef CONFIG_USER_ONLY +#include "gen_tcg_sys.h" +#endif +#include "genptr.h" TCGv gen_read_reg (TCGv result,int num)
target/hexagon/op_helper.c +7 -0
@@ -31,6 +31,7 @@#include "mmvec/mmvec.h" #include "mmvec/macros.h" #include "op_helper.h" +#include "cpu_helper.h" #include "translate.h" #define SF_BIAS 127
@@ -1420,6 +1421,12 @@ uint64_t HELPER(greg_read_pair)(CPUHexagonState *env, uint32_t reg) {g_assert_not_reached (); } + +void HELPER (setprio )(CPUHexagonState *env,uint32_t thread,uint32_t prio) +{ +g_assert_not_reached (); +} +#endif
target/hexagon/hex_common.py +2 -0
@@ -1364,6 +1364,7 @@ def parse_common_args(desc): parser.add_argument("semantics", help="semantics file") parser.add_argument("overrides", help="overrides file") parser.add_argument("overrides_vec", help="vector overrides file") + parser.add_argument("overrides_sys", help="system overrides file") parser.add_argument("out", help="output file") parser.add_argument("--idef-parser", help="file of instructions translated by idef-parser")
@@ -1371,6 +1372,7 @@ def parse_common_args(desc): read_semantics_file(args.semantics) read_overrides_file(args.overrides) read_overrides_file(args.overrides_vec) + read_overrides_file(args.overrides_sys) if args.idef_parser: read_idef_parser_enabled_file(args.idef_parser) calculate_attribs()
target/hexagon/meson.build +7 -6
@@ -20,6 +20,7 @@ hexagon_ss = ss.source_set() hex_common_py = 'hex_common.py' gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h' gen_tcg_hvx_h = meson.current_source_dir() / 'gen_tcg_hvx.h' +gen_tcg_sys_h = meson.current_source_dir() / 'gen_tcg_sys.h' idef_parser_dir = meson.current_source_dir() / 'idef-parser' #
@@ -337,12 +338,12 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs # Setup input and dependencies for the next step, this depends on whether or # not idef-parser is enabled helper_dep = [semantics_generated, idef_generated_tcg_c, idef_generated_tcg] - helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, '--idef-parser', idef_generated_list] + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, '--idef-parser', idef_generated_list] else # Setup input and dependencies for the next step, this depends on whether or # not idef-parser is enabled helper_dep = [semantics_generated] - helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h] + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h] endif #
@@ -356,7 +357,7 @@ helper_protos_generated = custom_target( 'helper_protos_generated.h.inc', output: 'helper_protos_generated.h.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], command: [python, files('gen_helper_protos.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(helper_protos_generated)
@@ -365,7 +366,7 @@ helper_funcs_generated = custom_target( 'helper_funcs_generated.c.inc', output: 'helper_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(helper_funcs_generated)
@@ -374,7 +375,7 @@ tcg_funcs_generated = custom_target( 'tcg_funcs_generated.c.inc', output: 'tcg_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], command: [python, files('gen_tcg_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(tcg_funcs_generated)
@@ -383,7 +384,7 @@ analyze_funcs_generated = custom_target( 'analyze_funcs_generated.c.inc', output: 'analyze_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(analyze_funcs_generated)
Signature · 1 line
2.34.1
Re: [PATCH v3 25/37] target/hexagon: Add sysemu TCG overrides
Quoted 5 lines · Brian Cain
From: Brian Cain <[email protected]>
Define TCG overrides for
setprio(),crswap(,sgp{0,1,1:0}).Signed-off-by Brian Cain <[email protected]>
Quoted 12 lines
--- target/hexagon/cpu_helper.h | 34 ++++++++++++++++++++++++++++++ target/hexagon/gen_tcg_sys.h | 40 ++++++++++++++++++++++++++++++++++++ target/hexagon/helper.h | 1 + target/hexagon/genptr.c | 4 ++++ target/hexagon/op_helper.c | 7 +++++++ target/hexagon/hex_common.py | 2 ++ target/hexagon/meson.build | 13 ++++++------ 7 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 target/hexagon/cpu_helper.h create mode 100644 target/hexagon/gen_tcg_sys.h
PATCH v3 26/37 target/hexagon: Add implicit attributes to sysemu macros
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/hex_common.py | 3 +++ 1 file changed, 3 insertions(+)
target/hexagon/hex_common.py +3 -0
@@ -129,8 +129,11 @@ def calculate_attribs(): add_qemu_macro_attrib("fTRAP", "A_IMPLICIT_READS_PC") add_qemu_macro_attrib("fSET_OVERFLOW", "A_IMPLICIT_WRITES_USR") add_qemu_macro_attrib("fSET_LPCFG", "A_IMPLICIT_WRITES_USR") + add_qemu_macro_attrib("fCLEAR_RTE_EX", "A_IMPLICIT_WRITES_SSR") add_qemu_macro_attrib("fLOAD", "A_SCALAR_LOAD") add_qemu_macro_attrib("fSTORE", "A_SCALAR_STORE") + add_qemu_macro_attrib("fSET_K0_LOCK", "A_IMPLICIT_READS_PC") + add_qemu_macro_attrib("fSET_TLB_LOCK", "A_IMPLICIT_READS_PC") add_qemu_macro_attrib('fLSBNEW0', 'A_IMPLICIT_READS_P0') add_qemu_macro_attrib('fLSBNEW0NOT', 'A_IMPLICIT_READS_P0') add_qemu_macro_attrib('fREAD_P0', 'A_IMPLICIT_READS_P0')
Signature · 1 line
2.34.1
PATCH v3 27/37 target/hexagon: Add TCG overrides for int handler insts
In reply to Brian CainFrom: Brian Cain <[email protected]>
Define TCG overrides for {c,}swi {c,s}iad, iassign{r,w}, {s,g}etimask instructions.
--- target/hexagon/gen_tcg_sys.h | 25 ++++++++++++++++++++++ target/hexagon/helper.h | 8 ++++++++ target/hexagon/op_helper.c | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+)
target/hexagon/gen_tcg_sys.h +25 -0
@@ -7,6 +7,31 @@#ifndef HEXAGON_GEN_TCG_SYS_H #define HEXAGON_GEN_TCG_SYS_H +/* System mode instructions */ +#define fGEN_TCG_Y2_swi (SHORTCODE ) \ + gen_helper_swi(tcg_env, RsV) + +#define fGEN_TCG_Y2_cswi (SHORTCODE ) \ + gen_helper_cswi(tcg_env, RsV) + +#define fGEN_TCG_Y2_ciad (SHORTCODE ) \ + gen_helper_ciad(tcg_env, RsV) + +#define fGEN_TCG_Y4_siad (SHORTCODE ) \ + gen_helper_siad(tcg_env, RsV) + +#define fGEN_TCG_Y2_iassignw (SHORTCODE ) \ + gen_helper_iassignw(tcg_env, RsV) + +#define fGEN_TCG_Y2_iassignr (SHORTCODE ) \ + gen_helper_iassignr(RdV, tcg_env, RsV) + +#define fGEN_TCG_Y2_getimask (SHORTCODE ) \ + gen_helper_getimask(RdV, tcg_env, RsV) + +#define fGEN_TCG_Y2_setimask (SHORTCODE ) \ + gen_helper_setimask(tcg_env, PtV, RsV) +#define fGEN_TCG_Y2_setprio (SHORTCODE ) \ gen_helper_setprio(tcg_env, PtV, RsV)
target/hexagon/helper.h +8 -0
@@ -109,6 +109,14 @@ DEF_HELPER_2(probe_hvx_stores, void, env, int) DEF_HELPER_2(probe_pkt_scalar_hvx_stores, void, env, int)#if !defined(CONFIG_USER_ONLY ) +DEF_HELPER_2(swi, void, env, i32) +DEF_HELPER_2(cswi, void, env, i32) +DEF_HELPER_2(ciad, void, env, i32) +DEF_HELPER_2(siad, void, env, i32) +DEF_HELPER_2(iassignw, void, env, i32) +DEF_HELPER_2(iassignr, i32, env, i32) +DEF_HELPER_2(getimask, i32, env, i32) +DEF_HELPER_3(setimask, void, env, i32, i32) DEF_HELPER_2(sreg_read, i32, env, i32) DEF_HELPER_2(sreg_read_pair, i64, env, i32)DEF_HELPER_2 (greg_read, i32, env, i32)
target/hexagon/op_helper.c +40 -0
@@ -1391,6 +1391,46 @@ void HELPER(vwhist128qm)(CPUHexagonState *env, int32_t uiV) }#ifndef CONFIG_USER_ONLY +void HELPER (ciad )(CPUHexagonState *env,uint32_t mask) +{ +g_assert_not_reached (); +} + +void HELPER (siad )(CPUHexagonState *env,uint32_t mask) +{ +g_assert_not_reached (); +} + +void HELPER (swi )(CPUHexagonState *env,uint32_t mask) +{ +g_assert_not_reached (); +} + +void HELPER (cswi )(CPUHexagonState *env,uint32_t mask) +{ +g_assert_not_reached (); +} + +void HELPER (iassignw )(CPUHexagonState *env,uint32_t src) +{ +g_assert_not_reached (); +} + +uint32_t HELPER (iassignr )(CPUHexagonState *env,uint32_t src) +{ +g_assert_not_reached (); +} + +uint32_t HELPER (getimask )(CPUHexagonState *env,uint32_t tid) +{ +g_assert_not_reached (); +} + +void HELPER (setimask )(CPUHexagonState *env,uint32_t pred,uint32_t imask) +{ +g_assert_not_reached (); +} +void HELPER (sreg_write )(CPUHexagonState *env,uint32_t reg,uint32_t val) {g_assert_not_reached ();
Signature · 1 line
2.34.1
PATCH v3 28/37 target/hexagon: Add TCG overrides for thread ctl
In reply to Brian CainFrom: Brian Cain <[email protected]>
Define TCG overrides for start, stop, wait, resume instructions.
--- target/hexagon/gen_tcg_sys.h | 18 ++++++++++++++++++ target/hexagon/helper.h | 4 ++++ target/hexagon/op_helper.c | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+)
target/hexagon/gen_tcg_sys.h +18 -0
@@ -62,4 +62,22 @@tcg_gen_extrh_i64_i32 (ctx->t_sreg_new_value[HEX_SREG_SGP1 ], tmp); \ } while (0) +#define fGEN_TCG_Y2_wait (SHORTCODE ) \ + do { \ + RsV = RsV; \ + gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt->pc)); \ + } while (0) + +#define fGEN_TCG_Y2_resume (SHORTCODE ) \ + gen_helper_resume(tcg_env, RsV) + +#define fGEN_TCG_Y2_start (SHORTCODE ) \ + gen_helper_start(tcg_env, RsV) + +#define fGEN_TCG_Y2_stop (SHORTCODE ) \ + do { \ + RsV = RsV; \ + gen_helper_stop(tcg_env); \ + } while (0) +#endif
target/hexagon/helper.h +4 -0
@@ -124,4 +124,8 @@ DEF_HELPER_2(greg_read_pair, i64, env, i32) DEF_HELPER_3(sreg_write, void, env, i32, i32) DEF_HELPER_3(sreg_write_pair, void, env, i32, i64) DEF_HELPER_3(setprio, void, env, i32, i32) +DEF_HELPER_2(start, void, env, i32) +DEF_HELPER_1(stop, void, env) +DEF_HELPER_2(wait, void, env, i32) +DEF_HELPER_2(resume, void, env, i32)#endif
target/hexagon/op_helper.c +20 -0
@@ -1421,6 +1421,26 @@ uint32_t HELPER(iassignr)(CPUHexagonState *env, uint32_t src)g_assert_not_reached (); } +void HELPER (start )(CPUHexagonState *env,uint32_t imask) +{ +g_assert_not_reached (); +} + +void HELPER (stop )(CPUHexagonState *env) +{ +g_assert_not_reached (); +} + +void HELPER (wait )(CPUHexagonState *env,target_ulong PC ) +{ +g_assert_not_reached (); +} + +void HELPER (resume )(CPUHexagonState *env,uint32_t mask) +{ +g_assert_not_reached (); +} +uint32_t HELPER (getimask )(CPUHexagonState *env,uint32_t tid) {g_assert_not_reached ();
Signature · 1 line
2.34.1
PATCH v3 29/37 target/hexagon: Add TCG overrides for rte, nmi
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/gen_tcg_sys.h | 19 +++++++++++++++++++ target/hexagon/helper.h | 1 + target/hexagon/op_helper.c | 4 ++++ 3 files changed, 24 insertions(+)
target/hexagon/gen_tcg_sys.h +19 -0
@@ -80,4 +80,23 @@gen_helper_stop (tcg_env); \ } while (0) +/* +* rte (return from exception) +* Clear the EX bit in SSR +* Jump to ELR + */ +#define fGEN_TCG_J2_rte (SHORTCODE ) \ + do { \ + TCGv new_ssr = tcg_temp_new(); \ + tcg_gen_deposit_tl(new_ssr, hex_t_sreg[HEX_SREG_SSR], \ + tcg_constant_tl(0), \ + reg_field_info[SSR_EX].offset, \ + reg_field_info[SSR_EX].width); \ + gen_log_sreg_write(ctx, HEX_SREG_SSR, new_ssr); \ + gen_jumpr(ctx, hex_t_sreg[HEX_SREG_ELR]); \ + } while (0) + +#define fGEN_TCG_Y4_nmi (SHORTCODE ) \ + gen_helper_nmi(tcg_env, RsV) +#endif
target/hexagon/helper.h +1 -0
@@ -128,4 +128,5 @@ DEF_HELPER_2(start, void, env, i32) DEF_HELPER_1(stop, void, env) DEF_HELPER_2(wait, void, env, i32) DEF_HELPER_2(resume, void, env, i32) +DEF_HELPER_2(nmi, void, env, i32)#endif
target/hexagon/op_helper.c +4 -0
@@ -1487,6 +1487,10 @@ void HELPER(setprio)(CPUHexagonState *env, uint32_t thread, uint32_t prio) g_assert_not_reached(); } +void HELPER (nmi )(CPUHexagonState *env,uint32_t thread_mask) +{ +g_assert_not_reached (); +}#endif
Signature · 1 line
2.34.1
PATCH v3 30/37 target/hexagon: Add sreg_{read,write} helpers
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu_helper.h | 8 +++++ target/hexagon/helper.h | 3 +- target/hexagon/cpu.c | 1 - target/hexagon/cpu_helper.c | 70 +++++++++++++++++++++++++++++++++++++ target/hexagon/op_helper.c | 28 ++++++++++----- target/hexagon/meson.build | 1 + 6 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 target/hexagon/cpu_helper.c
target/hexagon/cpu_helper.h +8 -0
@@ -7,6 +7,14 @@#ifndef HEXAGON_CPU_HELPER_H #define HEXAGON_CPU_HELPER_H +uint32_t hexagon_get_pmu_counter (CPUHexagonState *cur_env,int index); +uint64_t hexagon_get_sys_pcycle_count (CPUHexagonState *env); +uint32_t hexagon_get_sys_pcycle_count_low (CPUHexagonState *env); +uint32_t hexagon_get_sys_pcycle_count_high (CPUHexagonState *env); +void hexagon_set_sys_pcycle_count (CPUHexagonState *env,uint64_t ); +void hexagon_set_sys_pcycle_count_low (CPUHexagonState *env,uint32_t ); +void hexagon_set_sys_pcycle_count_high (CPUHexagonState *env,uint32_t ); +static inline void arch_set_thread_reg (CPUHexagonState *env,uint32_t reg,uint32_t val) {
target/hexagon/helper.h +1 -2
@@ -121,8 +121,7 @@ DEF_HELPER_2(sreg_read, i32, env, i32) DEF_HELPER_2(sreg_read_pair, i64, env, i32) DEF_HELPER_2(greg_read, i32, env, i32) DEF_HELPER_2(greg_read_pair, i64, env, i32) -DEF_HELPER_3(sreg_write, void, env, i32, i32) -DEF_HELPER_3(sreg_write_pair, void, env, i32, i64) +DEF_HELPER_3(sreg_write_masked, void, env, i32, i32) DEF_HELPER_3(setprio, void, env, i32, i32) DEF_HELPER_2(start, void, env, i32)DEF_HELPER_1 (stop, void, env)
target/hexagon/cpu.c +0 -1
@@ -338,7 +338,6 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)qemu_init_vcpu (cs);cpu_reset (cs); - mcc->parent_realize (dev, errp); }
target/hexagon/cpu_helper.c new file +70 -0
70 lines not on this page · raw message
target/hexagon/op_helper.c +20 -8
@@ -19,9 +19,10 @@#include "qemu/log.h" #include "accel/tcg/cpu-ldst.h" #include "accel/tcg/probe.h" +#include "qemu/main-loop.h" +#include "cpu.h" #include "exec/helper-proto.h" #include "fpu/softfloat.h" -#include "cpu.h" #include "internal.h" #include "macros.h" #include "sys_macros.h"
@@ -1451,25 +1452,36 @@ void HELPER(setimask)(CPUHexagonState *env, uint32_t pred, uint32_t imask)g_assert_not_reached (); } -void HELPER (sreg_write )(CPUHexagonState *env,uint32_t reg,uint32_t val) +void HELPER (sreg_write_masked )(CPUHexagonState *env,uint32_t reg,uint32_t val) { -g_assert_not_reached (); +BQL_LOCK_GUARD (); +arch_set_system_reg_masked (env, reg, val); } -void HELPER (sreg_write_pair )(CPUHexagonState *env,uint32_t reg,uint64_t val) - +static inline QEMU_ALWAYS_INLINE uint32_t sreg_read(CPUHexagonState *env, +uint32_t reg) { -g_assert_not_reached (); +g_assert (bql_locked ()); +if (reg <HEX_SREG_GLB_START ) { +return env->t_sreg[reg]; + } +HexagonCPU *cpu =env_archcpu (env); +return cpu->globalregs ? +hexagon_globalreg_read (cpu->globalregs, reg, env->threadId) :0 ; }uint32_t HELPER (sreg_read )(CPUHexagonState *env,uint32_t reg) { -g_assert_not_reached (); +BQL_LOCK_GUARD (); +return sreg_read (env, reg); }uint64_t HELPER (sreg_read_pair )(CPUHexagonState *env,uint32_t reg) { -g_assert_not_reached (); +BQL_LOCK_GUARD (); + +return deposit64 ((uint64_t )sreg_read (env, reg),32 ,32 , +sreg_read (env, reg +1 )); }uint32_t HELPER (greg_read )(CPUHexagonState *env,uint32_t reg)
target/hexagon/meson.build +1 -0
@@ -240,6 +240,7 @@ hexagon_ss.add(files( 'cpu.c', 'translate.c', 'op_helper.c', + 'cpu_helper.c', 'gdbstub.c', 'genptr.c', 'reg_fields.c',
Signature · 1 line
2.34.1
Re: [PATCH v3 30/37] target/hexagon: Add sreg_{read,write} helpers
Quoted 32 lines · Brian Cain
From: Brian Cain <[email protected]>
Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu_helper.h | 8 +++++ target/hexagon/helper.h | 3 +- target/hexagon/cpu.c | 1 - target/hexagon/cpu_helper.c | 70 +++++++++++++++++++++++++++++++++++++ target/hexagon/op_helper.c | 28 ++++++++++----- target/hexagon/meson.build | 1 + 6 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 target/hexagon/cpu_helper.ctarget/hexagon/cpu.c +0
-1@@ -338,7 +338,6 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)qemu_init_vcpu (cs );cpu_reset (cs); - mcc->parent_realize (dev, errp); }target/hexagon/cpu_helper.c new file +0
-0
target/hexagon/cpu_helper.c line 7
Quoted 7 lines
target/hexagon/cpu_helper.c new file +7
-0@@ -0,0 +1,70 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef CONFIG_USER_ONLY
Is the complete file guarded by this when all is said and done? If so, remove the guard and put it in the softmmu file list in meson.build.
Otherwise
PATCH v3 31/37 target/hexagon: Add locks, id, next_PC to state
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 34 +++++++++++++++++++++++++++++++++- target/hexagon/cpu.c | 4 ++++ target/hexagon/machine.c | 6 ++++++ 3 files changed, 43 insertions(+), 1 deletion(-)
target/hexagon/cpu.h +33 -1
@@ -46,8 +46,34 @@#define VSTORES_MAX 2#define CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU +#ifndef CONFIG_USER_ONLY +#define CPU_INTERRUPT_SWI CPU_INTERRUPT_TGT_INT_0 +#define CPU_INTERRUPT_K0_UNLOCK CPU_INTERRUPT_TGT_INT_1 +#define CPU_INTERRUPT_TLB_UNLOCK CPU_INTERRUPT_TGT_INT_2 + +#define HEX_CPU_MODE_USER 1 +#define HEX_CPU_MODE_GUEST 2 +#define HEX_CPU_MODE_MONITOR 3 + +#define HEX_EXE_MODE_OFF 1 +#define HEX_EXE_MODE_RUN 2 +#define HEX_EXE_MODE_WAIT 3 +#define HEX_EXE_MODE_DEBUG 4 +#endif + +#define MMU_USER_IDX 0 +#ifndef CONFIG_USER_ONLY +#define MMU_GUEST_IDX 1 +#define MMU_KERNEL_IDX 2 + +typedef enum { +HEX_LOCK_UNLOCKED =0 , +HEX_LOCK_WAITING =1 , +HEX_LOCK_OWNER =2 , +HEX_LOCK_QUEUED =3 +}hex_lock_state_t ; +#endif -#define MMU_USER_IDX 0#define HEXAGON_CPU_IRQ_0 0#define HEXAGON_CPU_IRQ_1 1
@@ -103,7 +129,13 @@ typedef struct CPUArchState {target_ulong t_sreg[NUM_SREGS ];target_ulong greg[NUM_GREGS ]; + +/* This alias of CPUState.cpu_index is used by imported sources: */ +target_ulong threadId; +hex_lock_state_t tlb_lock_state; +hex_lock_state_t k0_lock_state;#endif +target_ulong next_PC;target_ulong new_value_usr;MemLog mem_log_stores[STORES_MAX ];
target/hexagon/cpu.c +4 -0
@@ -309,6 +309,10 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)#ifndef CONFIG_USER_ONLY memset (env->t_sreg,0 ,sizeof (target_ulong) *NUM_SREGS );memset (env->greg,0 ,sizeof (target_ulong) *NUM_GREGS ); + env->threadId = cs->cpu_index; + env->tlb_lock_state =HEX_LOCK_UNLOCKED ; + env->k0_lock_state =HEX_LOCK_UNLOCKED ; + env->next_PC =0 ;#endif env->cause_code =HEX_EVENT_NONE ; }
target/hexagon/machine.c +6 -0
@@ -18,6 +18,12 @@ const VMStateDescription vmstate_hexagon_cpu = { VMSTATE_UINTTL_ARRAY(env.pred, HexagonCPU, NUM_PREGS), VMSTATE_UINTTL_ARRAY(env.t_sreg, HexagonCPU, NUM_SREGS), VMSTATE_UINTTL_ARRAY(env.greg, HexagonCPU, NUM_GREGS), + VMSTATE_UINTTL(env.next_PC, HexagonCPU), + VMSTATE_UINT32(env.tlb_lock_state, HexagonCPU), + VMSTATE_UINT32(env.k0_lock_state, HexagonCPU), + VMSTATE_UINTTL(env.tlb_lock_count, HexagonCPU), + VMSTATE_UINTTL(env.k0_lock_count, HexagonCPU), + VMSTATE_UINTTL(env.threadId, HexagonCPU),VMSTATE_END_OF_LIST () }, };
Signature · 1 line
2.34.1
PATCH v3 32/37 target/hexagon: Add a TLB count property
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 2 ++ target/hexagon/cpu.c | 5 +++++ 2 files changed, 7 insertions(+)
target/hexagon/cpu.h +2 -0
@@ -44,6 +44,7 @@#define REG_WRITES_MAX 32#define PRED_WRITES_MAX 5/* 4 insns + endloop */ #define VSTORES_MAX 2 +#define MAX_TLB_ENTRIES 1024#define CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU#ifndef CONFIG_USER_ONLY
@@ -181,6 +182,7 @@ struct ArchCPU {bool lldb_compat;target_ulong lldb_stack_adjust;bool short_circuit; +struct HexagonTLBState *tlb; };#include "cpu_bits.h"
target/hexagon/cpu.c +5 -0
@@ -23,6 +23,7 @@#include "qapi/error.h" #include "hw/core/qdev-properties.h" #include "fpu/softfloat-helpers.h" +#include "hw/hexagon/hexagon_tlb.h" #include "tcg/tcg.h" #include "exec/gdbstub.h" #include "accel/tcg/cpu-ops.h"
@@ -50,6 +51,10 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model) }static const Property hexagon_cpu_properties[] = { +#if !defined(CONFIG_USER_ONLY) +DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , + HexagonTLBState *), +#endifDEFINE_PROP_BOOL ("lldb-compat" , HexagonCPU, lldb_compat, false),DEFINE_PROP_UNSIGNED ("lldb-stack-adjust" , HexagonCPU, lldb_stack_adjust,0 , qdev_prop_uint32, target_ulong),
Signature · 1 line
2.34.1
Re: [PATCH v3 32/37] target/hexagon: Add a TLB count property
Quoted 15 lines · Brian Cain
From: Brian Cain <[email protected]>
Reviewed-by Taylor Simpson <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 2 ++ target/hexagon/cpu.c | 5 +++++ 2 files changed, 7 insertions(+)target/hexagon/cpu.c +0
-0
target/hexagon/cpu.c line 26
Quoted 4 lines
target/hexagon/cpu.c +1
-0@@ -23,6 +23,7 @@#include "qapi/error.h" #include "hw/core/qdev-properties.h" #include "fpu/softfloat-helpers.h" +#include "hw/hexagon/hexagon_tlb.h"
This file is added in patch #34 of this series.
Quoted 14 lines
target/hexagon/cpu.c +4
-0#include "tcg/tcg.h" #include "exec/gdbstub.h" #include "accel/tcg/cpu-ops.h" @@ -50,6 +51,10 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model) }static const Property hexagon_cpu_properties[] = { +#if !defined(CONFIG_USER_ONLY) +DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , + HexagonTLBState *), +#endifDEFINE_PROP_BOOL ("lldb-compat" , HexagonCPU, lldb_compat, false),DEFINE_PROP_UNSIGNED ("lldb-stack-adjust" , HexagonCPU, lldb_stack_adjust,0 , qdev_prop_uint32, target_ulong),
PATCH v3 34/37 target/hexagon: Add stubs for modify_ssr/get_exe_mode
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- include/hw/hexagon/hexagon_tlb.h | 47 ++++ target/hexagon/cpu-param.h | 4 + target/hexagon/cpu.h | 7 + target/hexagon/cpu_helper.h | 2 + target/hexagon/hex_mmu.h | 25 ++ target/hexagon/internal.h | 8 + hw/hexagon/hexagon_tlb.c | 457 +++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 24 +- target/hexagon/cpu_helper.c | 8 + target/hexagon/hex_mmu.c | 273 ++++++++++++++++++ target/hexagon/machine.c | 1 + target/hexagon/translate.c | 2 +- 12 files changed, 856 insertions(+), 2 deletions(-) create mode 100644 include/hw/hexagon/hexagon_tlb.h create mode 100644 target/hexagon/hex_mmu.h create mode 100644 hw/hexagon/hexagon_tlb.c create mode 100644 target/hexagon/hex_mmu.c
include/hw/hexagon/hexagon_tlb.h new file +47 -0
@@ -0,0 +1,47 @@ +/* +* Hexagon TLB QOM Device +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_HEXAGON_TLB_H +#define HW_HEXAGON_TLB_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "exec/hwaddr.h" +#include "exec/mmu-access-type.h" +#include "exec/target_long.h" + +#define TYPE_HEXAGON_TLB "hexagon-tlb" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonTLBState, HEXAGON_TLB) + +struct HexagonTLBState { +SysBusDevice parent_obj; + +uint32_t num_entries; +uint64_t *entries; +}; + +uint64_t hexagon_tlb_read (HexagonTLBState *tlb,uint32_t index); +void hexagon_tlb_write (HexagonTLBState *tlb,uint32_t index,uint64_t value); + +bool hexagon_tlb_find_match (HexagonTLBState *tlb,uint32_t asid, +target_ulong VA ,MMUAccessType access_type, +hwaddr *PA ,int *prot,uint64_t *size, +int32_t *excp,int *cause_code,int mmu_idx); + +uint32_t hexagon_tlb_lookup (HexagonTLBState *tlb,uint32_t asid, +uint32_t VA ,int *cause_code); + +int hexagon_tlb_check_overlap (HexagonTLBState *tlb,uint64_t entry, +uint64_t index); + +void hexagon_tlb_dump (HexagonTLBState *tlb); + +bool hexagon_tlb_dump_entry (FILE *f,uint64_t entry); + +uint32_t hexagon_tlb_get_num_entries (HexagonTLBState *tlb); + +#endif /* HW_HEXAGON_TLB_H */
target/hexagon/cpu-param.h +4 -0
@@ -18,7 +18,11 @@#ifndef HEXAGON_CPU_PARAM_H #define HEXAGON_CPU_PARAM_H +#ifdef CONFIG_USER_ONLY #define TARGET_PAGE_BITS 16/* 64K pages */ +#else +#define TARGET_PAGE_BITS 12/* 4K pages */ +#endif #define TARGET_PHYS_ADDR_SPACE_BITS 36#define TARGET_VIRT_ADDR_SPACE_BITS 32
target/hexagon/cpu.h +7 -0
@@ -36,6 +36,9 @@#error "Hexagon does not support system emulation"#endif +#ifndef CONFIG_USER_ONLY +#endif +#define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
@@ -185,12 +188,16 @@ struct ArchCPU {bool lldb_compat;target_ulong lldb_stack_adjust;bool short_circuit; +#ifndef CONFIG_USER_ONLY struct HexagonTLBState *tlb; +uint32_t htid; +#endif };#include "cpu_bits.h" FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1) +FIELD(TB_FLAGS, MMU_INDEX, 1, 3) G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env, uint32_t exception,
target/hexagon/cpu_helper.h +2 -0
@@ -14,6 +14,8 @@ uint32_t hexagon_get_sys_pcycle_count_high(CPUHexagonState *env);void hexagon_set_sys_pcycle_count (CPUHexagonState *env,uint64_t );void hexagon_set_sys_pcycle_count_low (CPUHexagonState *env,uint32_t );void hexagon_set_sys_pcycle_count_high (CPUHexagonState *env,uint32_t ); +void hexagon_modify_ssr (CPUHexagonState *env,uint32_t new,uint32_t old); +int get_exe_mode (CPUHexagonState *env);static inline void arch_set_thread_reg (CPUHexagonState *env,uint32_t reg,uint32_t val)
target/hexagon/hex_mmu.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_MMU_H +#define HEXAGON_MMU_H + +#include "cpu.h" + +extern void hex_tlbw (CPUHexagonState *env,uint32_t index,uint64_t value); +extern uint32_t hex_tlb_lookup (CPUHexagonState *env,uint32_t ssr,uint32_t VA ); +extern void hex_mmu_on (CPUHexagonState *env); +extern void hex_mmu_off (CPUHexagonState *env); +extern void hex_mmu_mode_change (CPUHexagonState *env); +extern bool hex_tlb_find_match (CPUHexagonState *env,target_ulong VA , +MMUAccessType access_type,hwaddr *PA ,int *prot, +uint64_t *size,int32_t *excp,int mmu_idx); +extern int hex_tlb_check_overlap (CPUHexagonState *env,uint64_t entry, +uint64_t index); +extern void hex_tlb_lock (CPUHexagonState *env); +extern void hex_tlb_unlock (CPUHexagonState *env); +void dump_mmu (CPUHexagonState *env); +#endif
target/hexagon/internal.h +8 -0
@@ -36,6 +36,14 @@ void G_NORETURN do_raise_exception(CPUHexagonState *env,target_ulong PC , uintptr_t retaddr); +#define hexagon_cpu_mmu_enabled (env) ({ \ + HexagonCPU *cpu = env_archcpu(env); \ + cpu->globalregs ? \ + GET_SYSCFG_FIELD(SYSCFG_MMUEN, \ + arch_get_system_reg(env, HEX_SREG_SYSCFG)) : \ + 0; \ +}) +#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_hexagon_cpu;#endif
hw/hexagon/hexagon_tlb.c new file +457 -0
457 lines not on this page · raw message
target/hexagon/cpu.c +23 -1
@@ -27,6 +27,13 @@#include "tcg/tcg.h" #include "exec/gdbstub.h" #include "accel/tcg/cpu-ops.h" +#include "cpu_helper.h" +#include "hex_mmu.h" + +#ifndef CONFIG_USER_ONLY +#include "sys_macros.h" +#include "accel/tcg/cpu-ldst.h" +#endif static void hexagon_v66_cpu_init (Object *obj) { }static void hexagon_v67_cpu_init (Object *obj) { }
@@ -54,6 +61,7 @@ static const Property hexagon_cpu_properties[] = {#if !defined(CONFIG_USER_ONLY )DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , HexagonTLBState *), +DEFINE_PROP_UINT32 ("htid" , HexagonCPU, htid,0 ), #endifDEFINE_PROP_BOOL ("lldb-compat" , HexagonCPU, lldb_compat, false), DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, 0,
@@ -280,6 +288,13 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs)hexagon_raise_exception_err (env,HEX_CAUSE_PC_NOT_ALIGNED ,0 ); } +#ifndef CONFIG_USER_ONLY + hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX , +cpu_mmu_index (env_cpu (env), false)); +#else + hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,MMU_USER_IDX ); +#endif +return (TCGTBCPUState ){ .pc = pc, .flags = hex_flags }; }
@@ -297,6 +312,7 @@ static void hexagon_restore_state_to_opc(CPUState *cs,cpu_env (cs)->gpr[HEX_REG_PC ] = data[0 ]; } +static void hexagon_cpu_reset_hold (Object *obj,ResetType type) {CPUState *cs =CPU (obj);
@@ -312,9 +328,14 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)/* Default NaN value: sign bit set, all frac bits set */ set_float_default_nan_pattern (0b11111111 , &env->fp_status);#ifndef CONFIG_USER_ONLY +HexagonCPU *cpu =HEXAGON_CPU (cs); +memset (env->t_sreg,0 ,sizeof (target_ulong) *NUM_SREGS );memset (env->greg,0 ,sizeof (target_ulong) *NUM_GREGS ); - env->threadId = cs->cpu_index; + + env->t_sreg[HEX_SREG_HTID ] = cpu->htid; + env->threadId = cpu->htid; +hexagon_cpu_soft_reset (env); env->tlb_lock_state =HEX_LOCK_UNLOCKED ; env->k0_lock_state =HEX_LOCK_UNLOCKED ; env->tlb_lock_count =0 ;
@@ -350,6 +371,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp) gdb_find_static_feature("hexagon-hvx.xml"), 0);qemu_init_vcpu (cs); +cpu_reset (cs); mcc->parent_realize (dev, errp); }
target/hexagon/cpu_helper.c +8 -0
@@ -66,5 +66,13 @@ void hexagon_set_sys_pcycle_count(CPUHexagonState *env, uint64_t cycles) g_assert_not_reached(); } +void hexagon_modify_ssr (CPUHexagonState *env,uint32_t new,uint32_t old) +{ +g_assert_not_reached (); +} +int get_exe_mode (CPUHexagonState *env) +{ +g_assert_not_reached (); +}#endif
target/hexagon/hex_mmu.c new file +273 -0
273 lines not on this page · raw message
target/hexagon/machine.c +1 -0
@@ -26,6 +26,7 @@ const VMStateDescription vmstate_hexagon_cpu = { VMSTATE_UINTTL(env.threadId, HexagonCPU), VMSTATE_UINTTL(env.cause_code, HexagonCPU), VMSTATE_UINTTL(env.wait_next_pc, HexagonCPU), +VMSTATE_END_OF_LIST () }, };
target/hexagon/translate.c +1 -1
@@ -987,7 +987,7 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase,HexagonCPU *hex_cpu =env_archcpu (cpu_env (cs));uint32_t hex_flags = dcbase->tb->flags; - ctx->mem_idx =MMU_USER_IDX ; + ctx->mem_idx =FIELD_EX32 (hex_flags,TB_FLAGS ,MMU_INDEX ); ctx->num_packets =0 ; ctx->num_insns =0 ; ctx->num_hvx_insns =0 ;
Signature · 1 line
2.34.1
PATCH v3 35/37 target/hexagon: Add clear_wait_mode() definition
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu_helper.h | 1 + target/hexagon/cpu_helper.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
target/hexagon/cpu_helper.h +1 -0
@@ -16,6 +16,7 @@ void hexagon_set_sys_pcycle_count_low(CPUHexagonState *env, uint32_t);void hexagon_set_sys_pcycle_count_high (CPUHexagonState *env,uint32_t );void hexagon_modify_ssr (CPUHexagonState *env,uint32_t new,uint32_t old);int get_exe_mode (CPUHexagonState *env); +void clear_wait_mode (CPUHexagonState *env);static inline void arch_set_thread_reg (CPUHexagonState *env,uint32_t reg,uint32_t val)
target/hexagon/cpu_helper.c +13 -0
@@ -71,6 +71,19 @@ void hexagon_modify_ssr(CPUHexagonState *env, uint32_t new, uint32_t old)g_assert_not_reached (); } +void clear_wait_mode (CPUHexagonState *env) +{ +g_assert (bql_locked ()); + +HexagonCPU *cpu =env_archcpu (env); +if (cpu->globalregs) { +const uint32_t modectl =arch_get_system_reg (env,HEX_SREG_MODECTL ); +uint32_t thread_wait_mask =GET_FIELD (MODECTL_W , modectl); + thread_wait_mask &= ~(0x1 << env->threadId); +SET_SYSTEM_FIELD (env,HEX_SREG_MODECTL ,MODECTL_W , thread_wait_mask); + } +} +int get_exe_mode (CPUHexagonState *env) {g_assert_not_reached ();
Signature · 1 line
2.34.1
PATCH v3 36/37 target/hexagon: Define f{S,G}ET_FIELD macros
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/macros.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
target/hexagon/macros.h +10 -0
@@ -653,6 +653,16 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift) reg_field_info[FIELD].width, \ reg_field_info[FIELD].offset) +#define fGET_FIELD (VAL ,FIELD ) \ + fEXTRACTU_BITS(VAL, \ + reg_field_info[FIELD].width, \ + reg_field_info[FIELD].offset) +#define fSET_FIELD (VAL ,FIELD ,NEWVAL ) \ + fINSERT_BITS(VAL, \ + reg_field_info[FIELD].width, \ + reg_field_info[FIELD].offset, \ + (NEWVAL)) +#ifdef QEMU_GENERATE #define fDCZEROA (REG ) \ do { \
Signature · 1 line
2.34.1
PATCH v3 37/37 target/hexagon: Add hex_interrupts support
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- target/hexagon/cpu.h | 1 + target/hexagon/hex_interrupts.h | 15 ++ target/hexagon/cpu.c | 2 + target/hexagon/hex_interrupts.c | 332 ++++++++++++++++++++++++++++++++ 4 files changed, 350 insertions(+) create mode 100644 target/hexagon/hex_interrupts.h create mode 100644 target/hexagon/hex_interrupts.c
target/hexagon/cpu.h +1 -0
@@ -190,6 +190,7 @@ struct ArchCPU {bool short_circuit;#ifndef CONFIG_USER_ONLY struct HexagonTLBState *tlb; +uint32_t l2vic_base_addr;uint32_t htid;#endif };
target/hexagon/hex_interrupts.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEX_INTERRUPTS_H +#define HEX_INTERRUPTS_H + +bool hex_check_interrupts (CPUHexagonState *env); +void hex_clear_interrupts (CPUHexagonState *env,uint32_t mask,uint32_t type); +void hex_raise_interrupts (CPUHexagonState *env,uint32_t mask,uint32_t type); +void hex_interrupt_update (CPUHexagonState *env); + +#endif
target/hexagon/cpu.c +2 -0
@@ -61,6 +61,8 @@ static const Property hexagon_cpu_properties[] = {#if !defined(CONFIG_USER_ONLY )DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , HexagonTLBState *), +DEFINE_PROP_UINT32 ("l2vic-base-addr" , HexagonCPU, l2vic_base_addr, +0xffffffff ),DEFINE_PROP_UINT32 ("htid" , HexagonCPU, htid,0 ), #endif DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, lldb_compat, false),
target/hexagon/hex_interrupts.c new file +332 -0
332 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 37/37] target/hexagon: Add hex_interrupts support
Quoted 20 lines · Brian Cain
From: Brian Cain <[email protected]>
Co-authored-by Taylor Simpson <[email protected]>Co-authored-by Sid Manning <[email protected]>Co-authored-by Michael Lambert <[email protected]>Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 1 + target/hexagon/hex_interrupts.h | 15 ++ target/hexagon/cpu.c | 2 + target/hexagon/hex_interrupts.c | 332 ++++++++++++++++++++++++++++++++ 4 files changed, 350 insertions(+)create mode 100644
target/hexagon/hex_interrupts.hcreate mode 100644target/hexagon/hex_interrupts.ctarget/hexagon/cpu.h +0
-0
target/hexagon/cpu.h struct ArchCPU { · line 193
Quoted 4 lines
target/hexagon/cpu.h +1
-0@@ -190,6 +190,7 @@ struct ArchCPU {bool short_circuit;#ifndef CONFIG_USER_ONLY struct HexagonTLBState *tlb; +uint32_t l2vic_base_addr;
This field is never used (nor in
https://github.com/quic/qemu/tree/bcain/sysemu_review).
Quoted 18 lines
target/hexagon/cpu.h +0
-0uint32_t htid;#endif };target/hexagon/cpu.c +2
-0@@ -61,6 +61,8 @@ static const Property hexagon_cpu_properties[] = {#if !defined(CONFIG_USER_ONLY )DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , HexagonTLBState *), +DEFINE_PROP_UINT32 ("l2vic-base-addr" , HexagonCPU, l2vic_base_addr, +0xffffffff ),DEFINE_PROP_UINT32 ("htid" , HexagonCPU, htid,0 ), #endif DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, lldb_compat, false),