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

fixup! target/hexagon: Implement modify SSR #117

Closed
wants to merge 126 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
2045200
docs: Add hexagon sysemu docs
androm3da Apr 30, 2024
241cc69
docs/system: Add hexagon CPU emulation
androm3da Oct 26, 2024
b7231a5
target/hexagon: Fix badva reference, delete CAUSE
androm3da Aug 8, 2024
19dd0d3
target/hexagon: Add missing A_CALL attr, hintjumpr to multi_cof
androm3da May 18, 2024
e904d8e
target/hexagon: Handle system/guest registers in gen_analyze_funcs.py…
androm3da May 18, 2024
8466d39
target/hexagon: Make gen_exception_end_tb non-static
androm3da May 20, 2024
3f0468f
target/hexagon: Switch to tag_ignore(), generate via get_{user,sys}_t…
androm3da May 18, 2024
7a771c2
target/hexagon: Add privilege check, use tag_ignore()
androm3da May 18, 2024
da8f7b2
target/hexagon: Add memory order definition
androm3da May 20, 2024
0510bd9
target/hexagon: Add a placeholder fp exception
androm3da May 20, 2024
bd14b24
target/hexagon: Add guest, system reg number defs
androm3da May 20, 2024
d347106
target/hexagon: Add guest, system reg number state
androm3da May 29, 2024
2d20666
target/hexagon: Add TCG values for sreg, greg
androm3da May 20, 2024
3531e81
target/hexagon: Add guest/sys reg writes to DisasContext
androm3da May 20, 2024
9381990
target/hexagon: Add imported macro, attr defs for sysemu
androm3da May 20, 2024
9e9dc6f
target/hexagon: Define DCache states
androm3da Sep 9, 2024
d4fc5ac
target/hexagon: Add new macro definitions for sysemu
androm3da May 20, 2024
cd1e7c9
target/hexagon: Add handlers for guest/sysreg r/w
androm3da May 20, 2024
a8a9e5f
target/hexagon: Add placeholder greg/sreg r/w helpers
androm3da May 20, 2024
80be3b3
target/hexagon: Add vmstate representation
androm3da Sep 8, 2024
5130dc1
target/hexagon: Make A_PRIV, "J2_trap*" insts need_env()
androm3da May 27, 2024
f1c9234
target/hexagon: Define register fields for system regs
androm3da May 24, 2024
27524d8
target/hexagon: Implement do_raise_exception()
androm3da Sep 5, 2024
def1e39
target/hexagon: Add system reg insns
androm3da May 29, 2024
b5ff4a1
target/hexagon: Add sysemu TCG overrides
androm3da Jul 8, 2024
ebf9a5e
target/hexagon: Add implicit attributes to sysemu macros
androm3da Sep 12, 2024
e289130
target/hexagon: Add TCG overrides for int handler insts
androm3da Jul 25, 2024
9f4f09c
target/hexagon: Add TCG overrides for thread ctl
androm3da Jul 25, 2024
d3ba152
target/hexagon: Add TCG overrides for rte, nmi
androm3da Jul 25, 2024
37cdda1
target/hexagon: Add sreg_{read,write} helpers
androm3da Jul 26, 2024
17e8de0
target/hexagon: Initialize htid, modectl regs
androm3da Aug 9, 2024
ffa17bf
target/hexagon: Add locks, id, next_PC to state
androm3da Aug 10, 2024
931df7e
target/hexagon: Add a TLB count property
androm3da Aug 10, 2024
c5fd25d
target/hexagon: Add {TLB,k0}lock, cause code, wait_next_pc
androm3da Aug 16, 2024
7370869
target/hexagon: Add stubs for modify_ssr/get_exe_mode
androm3da Aug 16, 2024
49c7e05
target/hexagon: Add gdb support for sys regs
androm3da Aug 27, 2024
93c4434
target/hexagon: Add initial MMU model
androm3da Aug 26, 2024
81ff994
target/hexagon: Add IRQ events
androm3da Aug 27, 2024
19eef6b
target/hexagon: Add clear_wait_mode() definition
androm3da Aug 27, 2024
31d286a
target/hexagon: Define f{S,G}ET_FIELD macros
androm3da Aug 27, 2024
253e5a9
target/hexagon: Add hex_interrupts support
androm3da Aug 27, 2024
15c46e7
target/hexagon: Implement ciad helper
androm3da Aug 28, 2024
b0c8a1e
target/hexagon: Implement {c,}swi helpers
androm3da Aug 28, 2024
bf9c3e9
target/hexagon: Implement iassign{r,w} helpers
androm3da Aug 28, 2024
dc6c61d
target/hexagon: Implement start/stop helpers
androm3da Aug 28, 2024
93c6f07
target/hexagon: Implement modify SSR
androm3da Aug 28, 2024
0686121
target/hexagon: Implement {g,s}etimask helpers
androm3da Aug 28, 2024
ab22000
target/hexagon: Implement wait helper
androm3da Aug 28, 2024
5b213b2
target/hexagon: Implement get_exe_mode()
androm3da Aug 28, 2024
2c8b39f
target/hexagon: Implement arch_get_system_reg()
androm3da Aug 28, 2024
9badeaf
target/hexagon: Implement arch_{s,g}et_{thread,system}_reg()
androm3da Aug 28, 2024
1d8abce
target/hexagon: Add representation to count cycles
androm3da Aug 29, 2024
c981d0f
target/hexagon: Add implementation of cycle counters
androm3da Aug 29, 2024
31f146c
target/hexagon: Implement modify_syscfg()
androm3da Aug 29, 2024
1428a5a
target/hexagon: Add system event, cause codes
androm3da Sep 4, 2024
3a4cbdd
target/hexagon: Implement hex_tlb_entry_get_perm()
androm3da Sep 4, 2024
0108f4d
target/hexagon: Implement hex_tlb_lookup_by_asid()
androm3da Sep 4, 2024
4a3837b
target/hexagon: Implement software interrupt
androm3da Sep 4, 2024
2b8d255
target/hexagon: Implement exec_interrupt, set_irq
androm3da Sep 5, 2024
89b73a4
target/hexagon: Implement hexagon_tlb_fill()
androm3da Sep 5, 2024
93cc29e
target/hexagon: Implement siad inst
androm3da Sep 5, 2024
d88274b
target/hexagon: Implement hexagon_resume_threads()
androm3da Sep 5, 2024
de58b1f
target/hexagon: Implement setprio, resched
androm3da Sep 5, 2024
d13160e
target/hexagon: Add sysemu_ops, cpu_get_phys_page_debug()
androm3da Sep 5, 2024
30d7806
target/hexagon: Add exec-start-addr prop
androm3da Sep 5, 2024
f61be7c
target/hexagon: Add hexagon_cpu_mmu_index()
androm3da Sep 5, 2024
c7c312d
target/hexagon: Decode trap1, rte as COF
androm3da Sep 6, 2024
8b250e3
target/hexagon: Implement hexagon_find_last_irq()
androm3da Sep 8, 2024
a7a836b
target/hexagon: Implement modify_ssr, resched, pending_interrupt
androm3da Sep 9, 2024
4b0ca01
target/hexagon: Add pkt_ends_tb to translation
androm3da Sep 9, 2024
0a248ed
target/hexagon: Add next_PC, {s,g}reg writes
androm3da Sep 9, 2024
5801c28
target/hexagon: Add implicit sysreg writes
androm3da Sep 9, 2024
f9a4cd9
target/hexagon: Define system, guest reg names
androm3da Sep 11, 2024
aa7e50f
target/hexagon: initialize sys/guest reg TCGvs
androm3da Sep 11, 2024
e50db34
target/hexagon: Add TLB, k0 {un,}lock
androm3da Sep 12, 2024
586fb1d
target/hexagon: Define gen_precise_exception()
androm3da Sep 12, 2024
075acfd
target/hexagon: Add TCG overrides for transfer insts
androm3da Sep 18, 2024
f9be945
target/hexagon: Add support for loadw_phys
androm3da Sep 18, 2024
cf7672d
target/hexagon: Add guest reg reading functionality
quic-mathbern Dec 6, 2024
8680556
target/hexagon: Add pcycle setting functionality
androm3da Dec 11, 2024
ad8187b
hw/intc: Add l2vic interrupt controller
SidManning Nov 8, 2023
d6117a2
hw/hexagon: Add machine configs for sysemu
androm3da Dec 2, 2023
d461527
hw/hexagon: Add v68, sa8775-cdsp0 defs
androm3da Oct 16, 2024
8f13a19
hw/hexagon: Add support for cfgbase
SidManning Dec 18, 2024
73027d5
hw/hexagon: Modify "Standalone" symbols
androm3da Oct 22, 2024
956a584
target/hexagon: add build config for softmmu
androm3da Dec 2, 2023
7ca0105
hw/hexagon: Define hexagon "virt" machine
androm3da Jul 29, 2024
b6781d6
tests/functional: Add a hexagon minivm test
androm3da Oct 26, 2024
accfc12
target/hexagon: s/pkt_has_store/pkt_has_scalar_store
androm3da Sep 9, 2024
dcdbedc
target/hexagon: Add a QTimer address prop
androm3da Jan 3, 2025
a83401d
hw/timer: Add QTimer device
SidManning Nov 8, 2023
6b6f61d
docs: Add hexagon VM info
androm3da Jul 9, 2024
741f72d
target/hexagon: Implement hexagon_read_timer()
androm3da Jan 3, 2025
6d2a618
semihosting: add the "usefs" feature
quic-mathbern Jan 28, 2025
28c35de
semihosting: add option for extended open() modes
quic-mathbern Jan 29, 2025
4723707
semihosting: extract GET_ARG() to its own function
quic-mathbern Jan 29, 2025
1507f40
semihosting: add optional callbacks
quic-mathbern Jan 29, 2025
2d2ac38
semihosting: add config opt to use stdio
quic-mathbern Jan 29, 2025
8b899c7
Hexagon: add aux functions for guest mem load/store
quic-mathbern Jan 29, 2025
39c7521
Hexagon: add semihosting support
quic-mathbern Jan 29, 2025
ed8d25f
Hexagon: add main arch-specific semihosting operations
quic-mathbern Jan 29, 2025
0c2c809
Hexagon: add COREDUMP semihosting operation
quic-mathbern Jan 29, 2025
4af457c
Hexagon: add {OPEN|READ|CLOSE}_DIR semihosting operations
quic-mathbern Jan 29, 2025
060b9cb
Hexagon: add semihosting check-tcg test
quic-mathbern Jan 29, 2025
03cac59
target/hexagon: fill in the 'rev' system register
quic-mathbern Feb 5, 2025
47c3323
target/hexagon: print full name of control regs
quic-mathbern Feb 5, 2025
f90a6aa
target/hexagon: fix system register names with -d in_asm
quic-mathbern Feb 5, 2025
d744f70
target/hexagon: reset registers on cpu_reset
quic-mathbern Feb 5, 2025
f58f976
tests/tcg/hexagon: add MMU tests
quic-mathbern Feb 5, 2025
2d874e7
tests/tcg/hexagon: add interrupt and priority tests
quic-mathbern Feb 5, 2025
635bc94
tests/tcg/hexagon: add tests for system registers
quic-mathbern Feb 5, 2025
08f40fe
tests/tcg/hexagon: add HVX tests
quic-mathbern Feb 5, 2025
bf9981b
tests/tcg/hexagon: add l2vic tests
quic-mathbern Feb 5, 2025
95156cb
target/hexagon: add utimer reg impl
androm3da Sep 24, 2024
2a13487
Hexagon (target/hexagon) Make "info tlb" work in qemu monitor
taylorsimpson Oct 29, 2024
f61c415
target/hexagon: Add instruction definitions
quic-mliebel Feb 27, 2025
4481d3e
FIXME: target/hexagon: Add qfloat files
quic-mliebel Feb 27, 2025
0105db0
target/hexagon: Add macro imports
quic-mliebel Feb 27, 2025
9ac9acd
target/hexagon: Update encoding of vunpackob
quic-mliebel Mar 5, 2025
e34591d
target/hexagon: Add encodings
quic-mliebel Mar 5, 2025
a1f5ecf
target/hexagon: Add simple qfloat test
quic-mliebel Mar 5, 2025
8ad8932
FIXME: Merge qtmr_rg0/rg1 into just qtmr_region
SidManning Mar 7, 2025
806002a
FIXME: Add unimplemented DMA instructions
androm3da Mar 9, 2025
d0afff7
fixup! target/hexagon: Implement ciad helper
SidManning Mar 20, 2025
c314988
fixup! target/hexagon: Define register fields for system regs
SidManning Mar 20, 2025
4a01e25
fixup! target/hexagon: Implement modify SSR
SidManning Mar 21, 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
11 changes: 11 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,25 @@ Hexagon TCG CPUs
M: Brian Cain <[email protected]>
S: Supported
F: target/hexagon/
F: hw/intc/l2vic.[ch]
F: hw/hexagon/
F: hw/timer/qct-qtimer.c
F: include/hw/hexagon/
F: include/hw/timer/qct-qtimer.h
X: target/hexagon/idef-parser/
X: target/hexagon/gen_idef_parser_funcs.py
F: linux-user/hexagon/
F: tests/tcg/hexagon/
F: disas/hexagon.c
F: configs/targets/hexagon-linux-user/default.mak
F: configs/devices/hexagon-softmmu/default.mak
F: docker/dockerfiles/debian-hexagon-cross.docker
F: gdb-xml/hexagon*.xml
F: docs/system/target-hexagon.rst
F: docs/devel/hexagon-sys.rst
F: docs/devel/hexagon-l2vic.rst
F: tests/functional/test_hexagon_minivm.py
F: docs/devel/hexagon-vm.rst
T: git https://github.com/quic/qemu.git hex-next

Hexagon idef-parser
Expand Down
8 changes: 8 additions & 0 deletions configs/devices/hexagon-softmmu/default.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Default configuration for hexagon-softmmu

# Uncomment the following lines to disable these optional devices:

# Boards are selected by default, uncomment to keep out of the build.
# CONFIG_HEX_VIRT=y
# CONFIG_HEX_DSP=y
# CONFIG_L2VIC=y
10 changes: 10 additions & 0 deletions configs/targets/hexagon-softmmu.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Default configuration for hexagon-softmmu

TARGET_ARCH=hexagon
TARGET_SUPPORTS_MTTCG=y
TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml
TARGET_LONG_BITS=32
TARGET_NEED_FDT=y
CONFIG_SEMIHOSTING=y
CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
CONFIG_SEMIHOSTING_USE_STDIO=y
59 changes: 59 additions & 0 deletions docs/devel/hexagon-l2vic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Hexagon L2 Vectored Interrupt Controller
========================================


.. code-block:: none

+-------+
| | +----------------+
| l2vic | | hexagon core |
| | | |
| +-----| | |
------> |VID0 >------------->irq2 -\ |
------> | | | | |
... > | | | | |
------> | | | <int steering> |
| +-----| | / | | \ |
| ... | | | | | | |
| +-----| | t0 t1 t2 t3 ...|
------> |VIDN | | |
------> | | | |
------> | | | |
------> | | | |
| +-----| | |
| | |Global SREG File|
| State | | |
| [ ]|<============|=>[VID ] |
| [ ]|<============|=>[VID1] |
| [ ]| | |
| [ ]| | |
| | | |
+-------+ +----------------+

L2VIC/Core Integration
----------------------

* hexagon core supports 8 external interrupt sources
* l2vic supports 1024 input interrupts mapped among 4 output interrupts
* l2vic has four output signals: { VID0, VID1, VID2, VID3 }
* l2vic device has a bank of registers per-VID that can be used to query
the status or assert new interrupts.
* Interrupts are 'steered' to threads based on { thread priority, 'EX' state,
thread interrupt mask, thread interrupt enable, global interrupt enable,
etc. }.
* Any hardware thread could conceivably handle any input interrupt, dependent
on state.
* The system register transfer instruction can read the VID0-VID3 values from
the l2vic when reading from hexagon core system registers "VID" and "VID1".
* When l2vic VID0 has multiple active interrupts, it pulses the VID0 output
IRQ and stores the IRQ number for the VID0 register field. Only after this
interrupt is cleared can the l2vic pulse the VID0 output IRQ again and provide
the next interrupt number on the VID0 register.
* The ``ciad`` instruction clears the l2vic input interrupt and un-disables the
core interrupt. If some/an l2vic VID0 interrupt is pending when this occurs,
the next interrupt should fire and any subseqeunt reads of the VID register
should reflect the newly raised interrupt.
* In QEMU, on an external interrupt or an unmasked-pending interrupt,
all vCPUs are triggered (has_work==true) and each will grab the IO lock
while considering the steering logic to determine whether they're the thread
that must handle the interrupt.
106 changes: 106 additions & 0 deletions docs/devel/hexagon-sys.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
.. _Hexagon-System-arch:

Hexagon System Architecture
===========================

The hexagon architecture has some unique elements which are described here.

Interrupts
----------
When interrupts arrive at a Hexagon DSP core, they are priority-steered to
be handled by an eligible hardware thread with the lowest priority.

Memory
------
Each hardware thread has an ``SSR.ASID`` field that contains its Address
Space Identifier. This value is catenated with a 32-bit virtual address -
the MMU can then resolve this extended virtual address to a physical address.

TLBs
----
The format of a TLB entry is shown below.

.. note::
The Small Core DSPs have a different TLB format which is not yet
supported.

.. admonition:: Diagram

.. code:: text

6 5 4 3
3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|v|g|x|A|A| | |
|a|l|P|1|0| ASID | Virtual Page |
|l|b| | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | |
|x|w|r|u|Cacheab| Physical Page |S|
| | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


* ASID: the address-space identifier
* A1, A0: the behavior of these cache line attributes are not modeled by QEMU.
* xP: the extra-physical bit is the most significant physical address bit.
* S: the S bit and the LSBs of the physical page indicate the page size
* val: this is the 'valid' bit, when set it indicates that page matching
should consider this entry.

.. list-table:: Page sizes
:widths: 25 25 50
:header-rows: 1

* - S-bit
- Phys page LSBs
- Page size
* - 1
- N/A
- 4kb
* - 0
- 0b1
- 16kb
* - 0
- 0b10
- 64kb
* - 0
- 0b100
- 256kb
* - 0
- 0b1000
- 1MB
* - 0
- 0b10000
- 4MB
* - 0
- 0b100000
- 16MB

* glb: if the global bit is set, the ASID is not considered when matching
TLBs.
* Cacheab: the cacheability attributes of TLBs are not modeled, these bits
are ignored.
* RWX: read-, write-, execute-, enable bits. Indicates if user programs
are permitted to read/write/execute the given page.
* U: indicates if user programs can access this page.

Scheduler
---------
The Hexagon system architecture has a feature to assist the guest OS
task scheduler. The guest OS can enable this feature by setting
``SCHEDCFG.EN``. The ``BESTWAIT`` register is programmed by the guest OS
to indicate the priority of the highest priority task waiting to run on a
hardware thread. The reschedule interrupt is triggered when any hardware
thread's priority in ``STID.PRIO`` is worse than the ``BESTWAIT``. When
it is triggered, the ``BESTWAIT.PRIO`` value is reset to 0x1ff.

HVX Coprocessor
---------------
The Supervisor Status Register field ``SSR.XA`` binds a DSP hardware thread
to one of the eight possible HVX contexts. The guest OS is responsible for
managing this resource.
Loading