Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: hexagon system emulation initial #99

Open
wants to merge 109 commits into
base: tip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
521f902
target/hexagon: Fix badva reference, delete CAUSE
androm3da Aug 8, 2024
1cb87d4
target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
androm3da May 18, 2024
736cebe
target/hexagon: Add System/Guest register definitions
androm3da May 18, 2024
64d2954
target/hexagon: Add some utility functions for sysemu
androm3da May 18, 2024
de05b22
target/hexagon: Make gen_exception_end_tb non-static
androm3da May 20, 2024
31efbf2
target/hexagon: Guard system insts
androm3da May 18, 2024
87b2699
target/hexagon: Switch to tag_ignore(), generate via get_{user,sys}_t…
androm3da May 18, 2024
368dd86
target/hexagon: Guard system insts, switch to tag_ignore()
androm3da May 18, 2024
8c2e641
target/hexagon: Add sysemu instructions triggering need_next_PC, mult…
androm3da May 18, 2024
ce5058f
target/hexagon: Add is_pair() method to scalars
androm3da May 18, 2024
c6fd603
gdb-xml: Add gdb-xml for hexagon sysemu
quic-mathbern Nov 8, 2023
e976e8e
target/hexagon: Add memory order definition
androm3da May 20, 2024
7220f12
target/hexagon: Add a placeholder fp exception
androm3da May 20, 2024
c0bbdbd
target/hexagon: Define page size for sysemu
androm3da May 20, 2024
f18e9bd
target/hexagon: Add guest, system reg number defs
androm3da May 20, 2024
0451994
target/hexagon: Add guest, system reg number state
androm3da May 29, 2024
b7fff0a
target/hexagon: Add TCG values for sreg, greg
androm3da May 20, 2024
7ad9f91
target/hexagon: Add guest/sys reg writes to DC
androm3da May 20, 2024
2809f85
target/hexagon: Add imported macro, attr defs for sysemu
androm3da May 20, 2024
ade7eec
target/hexagon: Define DC states
androm3da Sep 9, 2024
b961c8e
FIXME: target/hexagon: Add new macro definitions for sysemu
androm3da May 20, 2024
7ad78ae
target/hexagon: Add handlers for guest/sysreg r/w
androm3da May 20, 2024
79ccf99
target/hexagon: Add placeholder greg/sreg r/w helpers
androm3da May 20, 2024
e43d4f1
target/hexagon: Add vmstate representation
androm3da Sep 8, 2024
cd9ce8b
docs: Add hexagon sysemu docs
androm3da Apr 30, 2024
8bb107c
FIXME: docs: Add hexagon VM info
androm3da Jul 9, 2024
5836715
docs/system: Add hexagon CPU emulation
androm3da Oct 26, 2024
b894648
target/hexagon: Make A_PRIV, "J2_trap*" insts need_env()
androm3da May 27, 2024
95f9dac
target/hexagon: Define register fields for system regs
androm3da May 24, 2024
404f998
FIXME this unused fixes some errs
androm3da May 24, 2024
51ddc6c
target/hexagon: Add TCG overrides for break,unpause,fetchbo,dczeroa
androm3da May 27, 2024
3fdb2f0
target/hexagon: Implement do_raise_exception()
androm3da Sep 5, 2024
46b7c36
target/hexagon: Add system reg insns
androm3da May 29, 2024
d08ab18
target/hexagon: Add sysemu TCG overrides
androm3da Jul 8, 2024
903067d
target/hexagon: Add implicit attributes to sysemu macros
androm3da Sep 12, 2024
49b7120
target/hexagon: Add TCG overrides for int handler insts
androm3da Jul 25, 2024
17e09db
target/hexagon: Add TCG overrides for thread ctl
androm3da Jul 25, 2024
560243f
target/hexagon: Add TCG overrides for rte, nmi
androm3da Jul 25, 2024
0c3f47f
target/hexagon: Add sreg_{read,write} helpers
androm3da Jul 26, 2024
d82c776
target/hexagon: Initialize htid, modectl regs
androm3da Aug 9, 2024
f2e343c
target/hexagon: Add locks, id, next_PC to state
androm3da Aug 10, 2024
7411a69
target/hexagon: Add a TLB count property
androm3da Aug 10, 2024
ad71d23
target/hexagon: Add {TLB,k0}lock, cause code, wait_next_pc
androm3da Aug 16, 2024
3243399
target/hexagon: Add stubs for modify_ssr/get_exe_mode
androm3da Aug 16, 2024
2ce28d3
target/hexagon: Add gdb support for sys regs
androm3da Aug 27, 2024
8cc9d4a
FIXME: target/hexagon: Add initial MMU model
androm3da Aug 26, 2024
dbf9147
target/hexagon: Add IRQ events
androm3da Aug 27, 2024
29c5a16
target/hexagon: Add clear_wait_mode() definition
androm3da Aug 27, 2024
9dcba11
target/hexagon: Define f{S,G}ET_FIELD macros
androm3da Aug 27, 2024
edf745f
target/hexagon: Add hex_interrupts support
androm3da Aug 27, 2024
ea7ac92
hw/intc: Add l2vic interrupt controller
SidManning Nov 8, 2023
1ed4048
target/hexagon: Implement ciad helper
androm3da Aug 28, 2024
75bd590
target/hexagon: Implement {c,}swi helpers
androm3da Aug 28, 2024
2af5088
target/hexagon: Implement iassign{r,w} helpers
androm3da Aug 28, 2024
d905f73
target/hexagon: Implement start/stop helpers
androm3da Aug 28, 2024
a7f2da3
target/hexagon: Implement modify SSR
androm3da Aug 28, 2024
f700155
target/hexagon: Implement {g,s}etimask helpers
androm3da Aug 28, 2024
6a9cc68
target/hexagon: Implement wait helper
androm3da Aug 28, 2024
b72c595
target/hexagon: Implement get_exe_mode()
androm3da Aug 28, 2024
15e0625
target/hexagon: Implement arch_get_system_reg()
androm3da Aug 28, 2024
9fc10a7
target/hexagon: Implement arch_{s,g}et_{thread,system}_reg()
androm3da Aug 28, 2024
5026cc9
target/hexagon: Add representation to count cycles
androm3da Aug 29, 2024
9c30064
target/hexagon: Add implementation of cycle counters
androm3da Aug 29, 2024
209a966
target/hexagon: Implement modify_syscfg()
androm3da Aug 29, 2024
5186210
target/hexagon: Add system event, cause codes
androm3da Sep 4, 2024
64f749a
target/hexagon: Implement hex_tlb_entry_get_perm()
androm3da Sep 4, 2024
4e99d60
target/hexagon: Implement hex_tlb_lookup_by_asid()
androm3da Sep 4, 2024
14e3167
target/hexagon: Implement software interrupt
androm3da Sep 4, 2024
189c35b
target/hexagon: Implement exec_interrupt, set_irq
androm3da Sep 5, 2024
a1e454d
FIXME: target/hexagon: Implement hexagon_tlb_fill()
androm3da Sep 5, 2024
5df06af
target/hexagon: Implement siad inst
androm3da Sep 5, 2024
24f2069
target/hexagon: Implement hexagon_resume_threads()
androm3da Sep 5, 2024
93a8b32
target/hexagon: Implement setprio, resched
androm3da Sep 5, 2024
f0c8321
target/hexagon: Add sysemu_ops
androm3da Sep 5, 2024
ba898c1
target/hexagon: Add cpu_get_phys_page_debug()
androm3da Sep 5, 2024
223548b
target/hexagon: Add vmsd
androm3da Sep 5, 2024
5262161
target/hexagon: Add exec-start-addr prop
androm3da Sep 5, 2024
95a2d24
target/hexagon: Add hexagon_cpu_mmu_index()
androm3da Sep 5, 2024
c968627
FIXME: why remove this unreachable?
androm3da Sep 5, 2024
28c8c09
FIXME: target/hexagon: handle .new values
androm3da Sep 6, 2024
018dcf7
target/hexagon: Decode trap1, rte as COF
androm3da Sep 6, 2024
6ec1673
hw/hexagon: Add machine configs for sysemu
androm3da Dec 2, 2023
9df8d78
hw/hexagon: Add support for cfgbase
SidManning Dec 18, 2024
206e1cb
qapi: Add hexagon machine to QAPI
androm3da Oct 3, 2024
7212626
target/hexagon: add build config for softmmu
androm3da Dec 2, 2023
a72e283
target/hexagon: Implement hexagon_find_last_irq()
androm3da Sep 8, 2024
2d3237b
target/hexagon: Implement modify_ssr, resched, pending_interrupt
androm3da Sep 9, 2024
0c23a77
target/hexagon: Add pkt_ends_tb to translation
androm3da Sep 9, 2024
d819f50
FIXME target/hexagon: Add next_PC, {s,g}reg writes
androm3da Sep 9, 2024
4ace7fa
target/hexagon: s/pkt_has_store/pkt_has_scalar_store
androm3da Sep 9, 2024
aebf62b
target/hexagon: Add implicit sysreg writes
androm3da Sep 9, 2024
4433c21
FIXME target/hexagon: Omit A_SCALAR_STORE from cancelled
androm3da Sep 9, 2024
515be7f
target/hexagon: Define system, guest reg names
androm3da Sep 11, 2024
ccf017d
target/hexagon: initialize sys/guest reg TCGvs
androm3da Sep 11, 2024
2163ff5
target/hexagon: Add TLB, k0 {un,}lock
androm3da Sep 12, 2024
61f5ce8
FIXME target/hexagon: Define gen_precise_exception()
androm3da Sep 12, 2024
4237944
target/hexagon: Add TCG overrides for transfer insts
androm3da Sep 18, 2024
d4d0a5f
target/hexagon: Add support for loadw_phys
androm3da Sep 18, 2024
ea6db76
hw/hexagon: Add v68, sa8775-cdsp0 defs
androm3da Oct 16, 2024
8932b0c
hw/hexagon: Modify "Standalone" symbols
androm3da Oct 22, 2024
ab9a180
hw/hexagon: Define hexagon "virt" machine
androm3da Jul 29, 2024
55a84e3
target/hexagon: Add guest reg reading functionality
quic-mathbern Dec 6, 2024
cc1b794
target/hexagon: Add pcycle setting functionality
androm3da Dec 11, 2024
1dd8d5d
tests/functional: Add a hexagon minivm test
androm3da Oct 26, 2024
c425299
FIXME: target/hexagon: Add exit pattern for standalone programs
SidManning Dec 18, 2024
3a44861
target/hexagon: Add a QTimer address prop
androm3da Jan 3, 2025
3440997
hw/timer: Add QTimer device
SidManning Nov 8, 2023
6f08d02
target/hexagon: Implement hexagon_read_timer()
androm3da Jan 3, 2025
1298fe7
Update initialization sequence to fix l2vic interrupts
SidManning Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions target/hexagon/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,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_reg(f, env, HEX_SREG_BADVA);
print_reg(f, env, HEX_REG_CS0);
print_reg(f, env, HEX_REG_CS1);
#endif
Expand Down
2 changes: 2 additions & 0 deletions target/hexagon/cpu_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ enum hex_cause {
HEX_CAUSE_PC_NOT_ALIGNED = 0x01e,
HEX_CAUSE_PRIV_NO_UREAD = 0x024,
HEX_CAUSE_PRIV_NO_UWRITE = 0x025,
HEX_CAUSE_PRIV_USER_NO_GINSN = 0x01a,
HEX_CAUSE_PRIV_USER_NO_SINSN = 0x01b,
};

#define PACKET_WORDS_MAX 4
Expand Down
12 changes: 12 additions & 0 deletions target/hexagon/gen_analyze_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For tag_ignore's, we should bail early and never need to generate the analyze function.


if ("A_PRIV" in hex_common.attribdict[tag] or
"A_GUEST" in hex_common.attribdict[tag]):
f.write("#ifndef CONFIG_USER_ONLY\n")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be outside the function definition?

#ifndef CONFIG_USER_ONLY static void analyze_{tag}(...) { ... } #endif /* !CONFIG_USER_ONLY */


f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n")
if (hex_common.is_hvx_insn(tag)):
if hex_common.has_hvx_helper(tag):
Expand Down Expand Up @@ -74,6 +82,10 @@ def gen_analyze_func(f, tag, regs, imms):
if reg.is_written():
reg.analyze_write(f, tag, regno)

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")


Expand Down
21 changes: 9 additions & 12 deletions target/hexagon/gen_helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,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]:
for tag in hex_common.get_user_tags():
if hex_common.tag_ignore(tag):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the tag_ignore function could be added in this commit instead of target/hexagon: Add some utility functions for sysemu?

I think it makes it easier to understand the motivation behind this helper function if added together with its use here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest combining this patch with the one that defines get_user_tags

Have get_user_tags/get_sys_tags/get_all_tags remove that tag_ignore ones, so you don't have to check it here.

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_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__":
Expand Down
23 changes: 12 additions & 11 deletions target/hexagon/gen_helper_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 2 additions & 0 deletions target/hexagon/gen_idef_parser_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def main():
f.write('#include "macros.h.inc"\n\n')

for tag in hex_common.tags:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hex_common.get_user_tags()

Pretty sure idef parser doesn't deal with system instructions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure idef parser doesn't deal with system instructions.

Yeah, and we actually skip those below:

            ## 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

So we can probably remove these if's and just go with get_user_tags()

if hex_common.tag_ignore(tag):
continue
## Skip the priv instructions
if "A_PRIV" in hex_common.attribdict[tag]:
continue
Expand Down
2 changes: 1 addition & 1 deletion target/hexagon/gen_op_attribs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion target/hexagon/gen_opcodes_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap these with #ifndef CONFIG_USER_ONLY

f.write(f"OPCODE({tag}),\n")


Expand Down
14 changes: 2 additions & 12 deletions target/hexagon/gen_tcg_func_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,9 @@ def main():
f.write("#define HEXAGON_FUNC_TABLE_H\n\n")

f.write("const SemanticInsn opcode_genptr[XX_LAST_OPCODE] = {\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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you modify the get_*_tags functions to remove the tag_ignore functions, this could be

`for tag in hex_common.get_all_tags():
...

It seems like your intent is to remove all uses of hex_common.tags, correct?`

continue

f.write(f" [{tag}] = generate_{tag},\n")
Expand Down
32 changes: 19 additions & 13 deletions target/hexagon/gen_tcg_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import re
import string
import hex_common

from textwrap import dedent

##
## Generate the TCG code to call the helper
Expand Down Expand Up @@ -50,6 +50,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")

Expand Down Expand Up @@ -97,6 +109,11 @@ def gen_tcg_func(f, tag, regs, imms):
if reg.is_written():
reg.log_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")


Expand All @@ -121,18 +138,7 @@ def main():
f.write('#include "idef-generated-emitter.h.inc"\n\n')

for tag in hex_common.tags:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on prior patch regarding hex_common.get_all_tags() and tag_ignore.

## 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):
continue

gen_def_tcg_func(f, tag, tagregs, tagimms)
Expand Down
Loading