134660 Commits
Author SHA1 Message Date
Richard Henderson d29412cca5 Merge tag 'pull-riscv-to-apply-20261027' of https://github.com/alistair23/qemu into staging
RISC-V PR for 11.2

* Add experimental Zvabd extension support
* Mask vsepc according to IALIGN
* Reset vCPU on VM reset via MP_STATE_INIT_RECEIVED
* Improve modeling of the Atlantis UART
* Fix IOMMU entry leak with ioatc-limit=0
* Fix integer handling issues in k230_gsdma and k230_decomp_gzip
* Reclaim invalidated IOATC entries for IOMMU
* Duct tape fix for QMP and RV profiles introspection
* Move RISC-V 'Z' CPU properties section to removed features
* Use TSO barriers instead of full barriers for Ztso
* Make mnstatus.MNPELP writable with Zicfilp
* Gate envcfg CBO fields on extensions
* Fix stale PMP state across reset
* Use 1ULL for a value we're going to shift by 63
* Remove unused IMISC macro
* Encode debug translation ranges in IOMMU
* Allow regular mstatus MPV/GVA writes again
* Fix uninitialised upper half in pmu_timer_trigger_irq
* Fix CPU state access on big-endian hosts

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmrgREAACgkQr3yVEwxT
# gBPBHxAAmIzV1LXJAxQTvU46+1j+4+mSvGr37byb1iU8yg+dJCNtYpFLHKdNjF0Q
# Fn+5uBL+QJC3rEA0Xbq6iF4EP2GO8t/Qm4rElLmWCw1xzraj7RAZrNJHWCebLp1j
# PLS53gINaQNIuE6DC91mwcuWanKo7q+tvOiwcShaVyUH771J1+1xVOkpcbkQaVrZ
# a54IfHIcs4TIsKrpmxCJPkEuBcL4VtaK5JwcqbeCQQ68v7L7qQpec75t9idr3o25
# Pn/BOsHwkXoJ1qxFuY61JGhUpFKUzZIqd6HKqwv4SENZY+O87J79R9X/HU9H17xh
# B75+h91ZFSZ2luNd2vZCCMx4vOXuCa+YE/m0ZmyyjJnGLA4LHRoeFRmUUu5Dxzkn
# kP+psnaeUfcI6W71d8Dcqov1g1O7MBdVrQD1hzK8IeAuYL438cLZpo9WT6TVX5cn
# /DRCyDR4f6uzf8Lnh0wItJGzSUlW2xadFLu357KsJ0+lpytpmYolOBxUGJXtJu2g
# BSfgQX9y9xhszCbFopngunu3guOlDoHZEJ9l29+tXicezvJxXw+FRyc4EU3onRtz
# zXGWa7sN4XGifzoDorbVcWGpOT2w2LI1himS4N9qXWNCZ4s115xENMVCMDRt6a9Z
# aZRyBib2nbrrgnO4JJbxBUe/MViBfQlc+AuqMmEwrwdP3LRBbZA=
# =qxZ6
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 27 Oct 2026 01:27:12 AM CDT
# gpg:                using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013
# gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6AE9 02B6 A7CA 877D 6D65  9296 AF7C 9513 0C53 8013

* tag 'pull-riscv-to-apply-20261027' of https://github.com/alistair23/qemu: (29 commits)
  target/riscv: Fix CPU state access on big-endian hosts
  target/riscv: fix uninitialised upper half in pmu_timer_trigger_irq()
  target/riscv/csr.c: allow regular mstatus MPV/GVA writes again
  hw/riscv/riscv-iommu: encode debug translation ranges
  include/hw/intc/riscv_imsic.h: remove unused macro
  target/riscv: Use 1ULL for a value we're going to shift by 63
  target/riscv: pmp: reset the derived PMP bounds and rule count
  target/riscv: pmp: clear A and L on every implemented PMP entry at reset
  target/riscv: gate envcfg CBO fields on extensions
  target/riscv: make mnstatus.MNPELP writable with Zicfilp
  target/riscv: Use TSO barriers instead of full barriers for Ztso
  docs: Move RISC-V 'Z' CPU properties section to removed features
  target/riscv/cpu.c: duct tape fix for QMP + RV profiles introspection
  hw/riscv/riscv-iommu: reclaim invalidated IOATC entries
  hw/riscv/riscv-iommu: serialize IOATC accesses
  hw/dma: fix k230_gsdma integer handling issues
  qtest: fix k230_decomp_gzip test integer handling issues
  hw/misc: use hwaddr for the k230_decomp_gzip input address
  hw/misc: fix calculating input address overflow in k230_decomp_gzip
  hw/misc: fix calculating output address overflow in k230_decomp_gzip
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 14:27:13 -05:00
Richard Henderson 284dc6d036 Merge tag 's390x-20261026' of https://gitlab.com/efarman/qemu into staging
s390x fixes/features for 11.2:
 - Implement resizable vt220 console
 - Deprecate dependencies of deprecated features
 - Reclaim DMA slots during, for example, guest reboot
 - MAINTAINERS updates

# -----BEGIN PGP SIGNATURE-----
#
# iIsEABYKADMWIQQB3Dhbwk4ZE3uUN6KmTx4R4Fx3tAUCat9bfhUcZmFybWFuQGxp
# bnV4LmlibS5jb20ACgkQpk8eEeBcd7S3cAD/TgRQLU3bVmRldeDwAJIca3EG1O1m
# tAJ+uLxcGTBgeY8BANYOrWc3WU+oez472RyUamEkmEnM+xjrt1Wd5amO3eoI
# =6GYD
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 26 Oct 2026 08:54:06 AM CDT
# gpg:                using EDDSA key 01DC385BC24E19137B9437A2A64F1E11E05C77B4
# gpg:                issuer "farman@linux.ibm.com"
# gpg: Good signature from "Eric Farman <farman@linux.ibm.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: D2C6 0504 C9E8 F568 CFE5  87B5 3827 B212 71BF 9562
#      Subkey fingerprint: 01DC 385B C24E 1913 7B94  37A2 A64F 1E11 E05C 77B4

* tag 's390x-20261026' of https://gitlab.com/efarman/qemu:
  MAINTAINERS: Update s390 boot reviewer
  MAINTAINERS: Add other s390x tree
  s390x/pci: reclaim DMA slots upon IOMMU disable
  s390x/sclpconsole: implement resizing for vt220 consoles
  target/s390x: mark feats dependent on deprecated feats as deprecated
  target/s390x: externalize feat dependency array

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 14:26:53 -05:00
Richard Henderson 9b77fa7a4f Merge tag 'pull-hex-20261027' of https://github.com/qualcomm/qemu into staging
hexagon: v85, DSP machines, singlestep, bugfixes

- v85 scalar: atomics, CFI/_rb, vector stack
- new DSP machines: SM8975 NSP, SA8797P NSP0, SC8480XP NSP0, SA8775P CDSP0,
QCS6490 CDSP.
- bugfixes:
    - coverity, ubsan findings in semihosting, decoder
    - handling framekey w/dealloc_return
- handle singlestep exception
- performance improvements: TLB flush, l2vic
- test coverage
- MTTCG fixes: enabling MTTCG exposed races in lock/interrupts and ciad.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmrgtXAACgkQGlSvuOVk
# bDKC0A//WTrd7fSFsLP2wGMbsRrXgfOl+xa4B0aqi3agQrH8Q4Gk3f0JbJILi0QJ
# nRPyOkTDYbqQdvA7u2uJ2qZSZlaaPNJK5M9QPI43MSPrxF7hapvuSjympHXa9fpB
# Uy+opBzlx2/d7AlVnYe6m6eYVRtyiVgnskS56au4RtHkie+PL9kahsvtXkJbd2ci
# riAzVr1Swcd+uHDxHdn/9OkD1z1Ym1BIJsezTDdsX+HDx/rTR9REDMOG5DPU3tSe
# jaj+TmO3wtO/OtmZIHnKwPEQQJJuvfyNgIyN2hIFTSG/CSXZmZA8wG1G7bzk8+fr
# lHcC9+Kz7wsfaDOnoYtP/Kox3QkCSH759mSLblSJB1SRIfl0FxxIAGdr7c65wQYH
# Kt8qT15rDI3mdTs/IVcBkN62pKPXjuwjwTlR7dzi81DPk8LtxUDw68hIWVXqsNsl
# brOk9bbLgwmIAwt+tTL2D7gysNGD/pekWNA52V3bVBHgM/Mi54VSr76nP25WiaJX
# lWfbVdANpUWmvrec0y5f/sQSK89TF6INu2kkke5/+XlbCfVV4/ZJIpZP5Us1hTyS
# sV4anuskTN6jQM1ro5zvP5BCfNpnWTSZu+PEpyxmPNSpesSzxzFtkSx1SiEKEe53
# zgOAeP9tNsnFSSVTrm5ddZawiVpS53AnNYq4y5Eb64uUEdottCg=
# =+PH4
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 27 Oct 2026 09:30:08 AM CDT
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <brian.cain@oss.qualcomm.com>" [unknown]
# gpg:                 aka "Brian Cain (QUIC) <quic_bcain@quicinc.com>" [unknown]
# gpg:                 aka "Brian Cain <bcain@kernel.org>" [unknown]
# gpg:                 aka "Brian Cain (QuIC) <bcain@quicinc.com>" [unknown]
# gpg:                 aka "Brian Cain (CAF) <bcain@codeaurora.org>" [unknown]
# gpg:                 aka "bcain" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20261027' of https://github.com/qualcomm/qemu: (42 commits)
  scripts/clean_functional_cache: tolerate missing .stamp files
  hw/intc/hex-l2vic: find the next pending irq a word at a time
  target/hexagon: only flush the softtlb when SSR.ASID changes
  target/hexagon: flush the softtlb once per tlbinvasid
  target/hexagon: avoid negative slot shift
  target/hexagon: reset implicit USR write state
  target/hexagon: assert qfloat shift
  hw/intc: ciad should forward its mask to l2vic
  target/hexagon: drop a pending HALT when resuming
  target/hexagon: check exception_index in has_work
  target/hexagon: acquire BQL before reading interrupt state
  tests/functional/hexagon: boot DSP firmware
  hw/hexagon: add subsystem-base property
  hw/hexagon: serialize config table as little endian
  hw/hexagon: add v79NA1 machine
  hw/hexagon: add the SM8975 NSP machine
  hw/hexagon: add the SA8797P NSP0 machine
  hw/hexagon: add the SC8480XP NSP0 machine
  hw/hexagon: add the SA8775P CDSP machine
  hw/hexagon: add the QCS6490 CDSP machine
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 11:41:22 -05:00
Brian Cain 16dba888bd scripts/clean_functional_cache: tolerate missing .stamp files
Assets cached before the stamp files were introduced have no
corresponding .stamp file.  The script already copes with that when
reading the timestamp, by assuming the QEMU v10.1 release date, which
makes such assets eligible for removal.

However, since commit c1bb594fe4, removing the asset also
unconditionally unlinks its .stamp file.  For these old entries that
file does not exist, so unlink() raises FileNotFoundError and the
script aborts after deleting the first such asset, leaving the rest of
the cache uncleaned and returning an error.

Pass missing_ok=True so that a missing .stamp file is not an error.

Fixes: c1bb594fe4 ("scripts/clean_functional_cache: Remove also .stamp files")
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain eab716163b hw/intc/hex-l2vic: find the next pending irq a word at a time
l2vic_update_all() called l2vic_update() for each of the 1024 irqs, and
every call rescanned all of int_status for an active vid.  ciad runs it
on each interrupt return, so this was a hot function for an OS boot.

Check once whether a vid is active, then deliver the lowest irq that is
both pending and enabled by scanning int_pending & int_enable a word at
a time.  The delivered irq is unchanged.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain cea71fe0ce target/hexagon: only flush the softtlb when SSR.ASID changes
hexagon_modify_ssr() flushed the softtlb on any change to SSR.EX, UM, GM,
or ASID, but only ASID affects translation.  EX/UM/GM just pick the mode,
which is already captured in mmu_idx.

EX toggles on every exception entry/rte, so the flush created a feedback
loop where a TLB miss wiped the softtlb and guaranteed the next accesses
missed too.

Rename hex_mmu_mode_change() to hex_mmu_asid_change() to match what now
triggers it, and narrow it to this thread's mmu indices: the ASID lives in
the thread's private SSR, so other CPUs are unaffected.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 238a609024 target/hexagon: flush the softtlb once per tlbinvasid
tlbinvasid cleared each matching JTLB entry via fTLBW(), and these would
hit hex_tlbw()'s flush.  tlbinvasid could trigger several full flushes.

Since the softtlb isn't ASID-tagged, clear all matching valid bits first
and flush once.

The hardware threads share one JTLB but have their own softtlb, so the
flush has to be broadcast to every CPU rather than just the one running
the invalidation.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 1ccd6cd497 target/hexagon: avoid negative slot shift
Invalid packets can exhaust the available instruction slots while
decode_set_slot_number() searches for a valid one.  We would then try to
evaluate a negative shift before returning the packet as invalid.

Detected by clang's UBSan.

Link: https://lore.kernel.org/qemu-devel/CAFEAcA8CYaJ=jAyc29RSdUMD_SWquJqz4fNQyW7oCrWithZhYA@mail.gmail.com/
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain c151b407a5 target/hexagon: reset implicit USR write state
implicit_usr_write is per-packet DC state. It was not cleared before
analyzing the next packet. Reset it together with the other per-packet
state.

When running qfloat_v81 ubsan reported:

    target/hexagon/translate.c:725:32: runtime error: load of value 192,
    which is not a valid value for type '_Bool'
    target/hexagon/translate.c:874:12: runtime error: load of value 192,
    which is not a valid value for type '_Bool'

Fixes: 3e98496691 ("Hexagon (target/hexagon) Implicit writes to USR don't force packet commit")
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 2626ebe8a8 target/hexagon: assert qfloat shift
The midpoint rounding thresholds shift by "shift - 3", which Coverity flagged
as potential undefined behavior.

The legacy add and multiply paths select exp such that the normalized result
is at most one bit above it. With the largest legacy fraction width of 23 bits,
shift is at least 41.  We can safely assert this here.

Link: https://lore.kernel.org/qemu-devel/CAFEAcA_WJ-PYCfiiu44uTQiDoc58_9Ky3uEd-9g14nPgDPT__g@mail.gmail.com/
Fixes: 2633da1e12 ("target/hexagon: add the QFloat logic")
Resolves: Coverity CID 1688240
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain e600f0f9e9 hw/intc: ciad should forward its mask to l2vic
ciad cleared the last interrupt the L2VIC delivered regardless of its
mask.  So a ciad for any other interrupt would get applied incorrectly.

Only clear the active interrupt when the ciad acknowledges the CPU
interrupt that its VID group is delivered on, and only if that interrupt
was taken or set with siad.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain f3aefe24fb target/hexagon: drop a pending HALT when resuming
A thread entering wait mode raises CPU_INTERRUPT_HALT on itself and only
takes it once its TB ends.  If another thread resumes it in between, the
HALT is still pending.

Clear the HALT on resume.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 30311dc0e5 target/hexagon: check exception_index in has_work
Without this check, a halted thread that gets an NMI while
its modectl E-bit is still set won't wake if no interrupt_request bits
happen to be pending.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain d9c1429f7c target/hexagon: acquire BQL before reading interrupt state
Move BQL_LOCK_GUARD() to the top of hex_check_interrupts.

There was a race with hex_interrupt_update on other vCPU threads when
enabling MTTCG.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 464a8cc8b0 tests/functional/hexagon: boot DSP firmware
Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted
code is allowed.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 478270e839 hw/hexagon: add subsystem-base property
Let the hexagon-sim-style machines their QDSP6 subsystem, and with it the
l2vic and QTimer.

The config table's subsystem base is updated to align with the chosen
address.

Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 8b326ddc22 hw/hexagon: serialize config table as little endian
Config table entries are host-endian values but are consumed by the
little-endian Hexagon guest. Serialize the ROM backing storage explicitly.

Fixes: 197870349f ("hw/hexagon: add hex-subsys")
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 91a71f4cd7 hw/hexagon: add v79NA1 machine
Add the Hexagon V79NA_1 simulator machine, with the config table of the
v79 core and eight CPUs by default.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 4dff005e1d hw/hexagon: add the SM8975 NSP machine
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain ef47ed9557 hw/hexagon: add the SA8797P NSP0 machine
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 3687a9e59c hw/hexagon: add the SC8480XP NSP0 machine
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain a1df9d1158 hw/hexagon: add the SA8775P CDSP machine
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 1107d374c7 hw/hexagon: add the QCS6490 CDSP machine
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 0853cdd882 hw/misc: add the QDSP6SS PLL, RCG
Firmware brings a Hexagon DSP's clocks up by programming a PLL and polling
its lock-detect.  Then it asks the RCG to switch to the new clock.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 1c2534662d hw/hexagon: convert virt board to hex-board
Build the virt machine with the hex-board helpers instead of its own
copies, and drop the machine state that nothing used.  The machine, its
device tree and its devices are unchanged; virt writes interrupts as the
bare line number.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 0a6b670b6b hw/hexagon: introduce hex-board abstraction
Move what virt.c does to build a board out of it into helpers in a new
hex-board.c, so that other Hexagon machines that describe themselves
with a generated device tree can reuse it.

This will be used by future commits.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 10e6e332b2 hw/hexagon: let a machine place its DDR
hex_subsys_create() always maps the main DDR at address 0.  This is appropriate
for hexagon-sim-style machines, but real SoCs map it elsewhere.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 5b6dfdf800 target/hexagon: fix semihosting ACCESS filename handling
HEX_SYS_ACCESS wrote a NUL byte past its fixed-size filename buffer when
the guest string filled it. Use lock_user_string() to avoid the out-of-bounds
write.

Fixes: 7711fdba88 ("target/hexagon: add main arch-specific semihosting operations")
Resolves: Coverity CID 1685942
Link: https://lore.kernel.org/all/CAFEAcA9MOs6VfHf2UHZ8z4cdvaB+7DY6hJb2emYZ2aLSe-t6iw@mail.gmail.com/
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 97c1bb79fc target/hexagon: fix semihosting STAT filename handling
HEX_SYS_STAT could pass an unterminated local filename buffer to stat()
when the guest string filled it. Use lock_user_string() to map the guest
string safely.

Fixes: 7711fdba88 ("target/hexagon: add main arch-specific semihosting operations")
Link: https://lore.kernel.org/all/CAFEAcA9MOs6VfHf2UHZ8z4cdvaB+7DY6hJb2emYZ2aLSe-t6iw@mail.gmail.com/
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 1a824dabff target/hexagon: fix semihosting OPEN filename handling
HEX_SYS_OPEN copied guest bytes into a fixed-size buffer until it found a
NUL. A missing terminator could overrun that buffer. Use lock_user() with
the ABI filename length and validate its terminating NUL before opening it.

Fixes: 7711fdba88 ("target/hexagon: add main arch-specific semihosting operations")
Link: https://lore.kernel.org/all/CAFEAcA9MOs6VfHf2UHZ8z4cdvaB+7DY6hJb2emYZ2aLSe-t6iw@mail.gmail.com/
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain c8221c47c0 target/hexagon: use get_user*() for semihosting arguments
Link: https://lore.kernel.org/qemu-devel/CAFEAcA9EL10xpPx_0YD-q6YcWWP9-iwcyG8x0s1yQhKB-XQGXQ@mail.gmail.com/
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 21a446d057 tests/tcg/hexagon: add v85 scalar tests
Add tests for: vallocframe, atomics, trap2, CFI/restricted branches, and
scalar fp instructions.

New instructions not yet supported by the toolchain are manually encoded
with .word directives.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 37f482c0f8 target/hexagon: add vsf* instructions
Implement the v83 two-lane scalar floating-point arithmetic instructions.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain e35867b9ca target/hexagon: implement control flow integrity (CFI)
Implement v83 restricted indirect-control-flow instructions and validate
their targets.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain eada2cdbcf target/hexagon: preserve callr target when Rs is LR
gen_callr wrote the link register before consuming the target, so
"callr r31" jumped to the new return address instead of the old LR
value.  Copy the target to a temporary first.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 1191c395b0 target/hexagon: reject reserved L4_loadw_phys encoding from v83
Bit 7 of L4_loadw_phys is valid through v81 but reserved starting
with v83. Decode it as a legacy don't-care bit, then reject it for v83
and later.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 5ce4818b43 target/hexagon: add v83 trap2 and vector stack instructions
Add decode and translation for trap2 and the vallocframe and vdeallocframe
instruction forms introduced with v83. Model vector stack overflow as a
precise exception and report it to linux-user as SIGSEGV.

Teach the IDEF parser about VSP and vector frame checks. Describe the
vallocframe and vdeallocframe instruction semantics in system.idef, and move
the vector stack overflow check into a shared TCG generator helper.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 4399fc1909 target/hexagon: add v85 scalar atomics
The scalar atomic instructions are able to perform a word or double-word
read-modify-write atomically.

Also add the v85 dcfetch_multi instruction, which prefetches multiple
data cache lines.  It is modelled as a no-op, as other dcfetch
instructions are.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain b4b0949c2e linux-user/hexagon: report ISA HWCAP through v85
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain d8e8aa98d2 hw/hexagon: add v85 machines
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain ef328b0c21 Hexagon: add v85 CPU model
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain 301aeb558d target/hexagon: sort tag_rev_info entries by version
The V79 QFloat entries were placed after the V81 entries.  Move them
before the V81 block, and group V6_vconv_bf_qf32 with the other V81
entries.  No functional change.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Brian Cain fe95b99e6f target/hexagon: implement SSR.SS single-step
SSR.SS enables a single-step debug event after each packet executed in
user or guest mode.

Carry the state in a new SS_ACTIVE TB flag.  When it is set, translate
one packet per TB and raise HEX_EVENT_DEBUG w/PC at the next packet (which
becomes ELR).

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:23:27 -07:00
Richard Henderson ab2e62917c Merge tag 'pull-tcg-20261025' of https://gitlab.com/rth7680/qemu into staging
tcg: Generic expansion of integer opcodes.
tcg: Annontate functions with QEMU_*_NONNULL

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmrdrUUdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV94cwf/TIqi1eLGIahM5hMc
# cfA9qRrVUiTt+cEcGolcsHAkrThzURLb+gXsSsnzo+GZ6RUkBuo9cclWZAhPyQo6
# LC7V1cWe8J7+0MKoN8Rk3sOQv2wYhzr2Ybj0Q3QGTlJy+TqpncCcyysbiJOO9eiu
# +9Wqc9sM1hXcGfSr+CCdAgdWQIOl8OggYl7K3tZ2FgQyFD3fsNDjcPLsZJuuK4C+
# PY9pc4ih0ZYfXceZ7OL31edXA43gZSqETLCYoJ18WHgyZGUeRObVdbiktV9GGf6V
# INYQ8sVn+OJyBjqCpO1V7nobzIIACXw3Nzehrzkj7KgvoLwqCgPuJhjXASQfqoXL
# Fyw/RA==
# =vukX
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 25 Oct 2026 02:18:29 AM CDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-tcg-20261025' of https://gitlab.com/rth7680/qemu: (100 commits)
  tcg: Annontate functions in tcg-op-common.h with QEMU_*_NONNULL
  tcg: Generic expansion of remaining atomic operations
  tcg: Generic expansion of tcg_gen_{non}atomic_cmpxchg_chk
  tcg: Generic expansion of tcg_gen_qemu_st_chk
  tcg: Generic expansion of tcg_gen_qemu_ld_chk
  tcg: Generic expansion of tcg_gen_dup_*
  tcg: Generic expansion of tcg_gen_st16_*
  tcg: Generic expansion of tcg_gen_st8_*
  tcg: Generic expansion of tcg_gen_st_*
  tcg: Generic expansion of tcg_gen_ld16u_*
  tcg: Generic expansion of tcg_gen_ld16s_*
  tcg: Generic expansion of tcg_gen_ld8u_*
  tcg: Generic expansion of tcg_gen_ld8s_*
  tcg: Generic expansion of tcg_gen_ld_*
  tcg: Generic expansion of tcg_gen_revbit8_*
  tcg: Split out tcg_gen_bitswap
  tcg: Generic expansion of tcg_gen_bswap16_*
  tcg: Use unsigned for flags for bswap and revbit operations
  tcg: Generic expansion of tcg_gen_muls2_*
  tcg: Generic expansion of tcg_gen_mulu2_*
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 09:22:37 -05:00
Brian Cain 990d307eeb target/hexagon: fix allocframe FRAMEKEY scrambling
The architecture scrambles only the LR word of the {FP, LR} frame that
allocframe stores.  With the idef parser enabled, fFRAME_SCRAMBLE built
the XOR key with FRAMEKEY in both halves of the 64-bit value, so the
stored FP was scrambled as well.

deallocframe is also parser-generated and applies the same incorrect
transform a second time, which masks the error.  dealloc_return uses the
hand-written TCG implementation that correctly descrambles only LR, so
it leaves FP corrupt when returning from a frame allocated by the parser.

Add a regression test that sets a nonzero FRAMEKEY, allocates a frame,
and returns through dealloc_return to validate the restored FP.

Uncovered by testing some boot images using QuRT.

Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:22:24 -07:00
Marco Liebel f3935498e6 hw/hexagon: add V73NC_1 machine
Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-10-27 07:22:24 -07:00
Richard Henderson 2c0584588c Merge tag 'pbouvier/pr/multi_target-20261024' of https://gitlab.com/p-b-o/qemu into staging
Changes:
- [PATCH v2 00/11] multi-target: prefix helpers with target prefix (Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>)
  Link: https://lore.kernel.org/qemu-devel/20261024163249.77855-1-pierrick.bouvier@oss.qualcomm.com
- [PATCH v3 0/9] multi-target: add riscv64-softmmu (Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>)
  Link: https://lore.kernel.org/qemu-devel/20261024061616.27381-1-pierrick.bouvier@oss.qualcomm.com

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEN8FWlNi6l2Sxlz/btEQ30ZwoYt8FAmrc7KoACgkQtEQ30Zwo
# Yt9AtQv/emGY3zTTlV+hBUs1wktL5RS75ODu3q2xw+GLmF/lj93PBcxy1ExOtIQl
# 77TU/FHZdGHK4fRRJkqigo5YJmR+zaghjbPydyNQca6EOLvIWvkmIXnPRP1AaxDz
# e2cXzVfvazXUpJDrt47nxY8869lWXTDXpzQ55PpgXEHxfNQSbG/PzZWV6ZHujM/t
# c08PR7kZjlu10bAUCGX4OUVV0LBpAzdV2vxg1Vs2vhJv93B2wo3AfCOHv8oAYgrQ
# ZZFCJY/hWHAOJQy5zHdWcfoOOO0X65gJhV9/hQPs0bTn0pbPZI+p7z58o8S4rjm3
# 9mU680pevHqvURTe07Fu9uYx6d2lAN7h8Y7mwnMEE94wOqOBIQSiebzVttRyDTQ1
# E8XzOvnqBbW7JegSzJzn8LnDme0Ee92+TgQT4pRxJXqr89D+14tGqj8riu0+oojI
# DTUdEvyyqN7E0InvobmOrLtp+qfR+O/emEKmGBqbNNV2qSQV40vFInTLV2BTsK7/
# 7rRkf9St
# =CRFI
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Oct 2026 12:36:42 PM CDT
# gpg:                using RSA key 37C15694D8BA9764B1973FDBB44437D19C2862DF
# gpg: Good signature from "Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 37C1 5694 D8BA 9764 B197  3FDB B444 37D1 9C28 62DF

* tag 'pbouvier/pr/multi_target-20261024' of https://gitlab.com/p-b-o/qemu:
  meson.build: list all remaining softmmu targets as comments
  meson.build: add riscv64-softmmu to multi-target
  target/riscv/kvm: restrict kvm-accel-riscv-cpu to riscv targets
  target/riscv/tcg: restrict tcg-accel-riscv-cpu to riscv targets
  target/riscv: rename virt_acpi_setup to riscv_virt_acpi_setup
  hw/riscv/virt: restrict scope of virt_is_acpi_enabled to this file
  test/unit/multi-target: check QOM types can be initialized with any target
  hw/riscv/virt: make machine available for riscv targets only
  target-info: add target_base_riscv
  target/tricore: remove explicit target specific prefix
  target/rx: remove explicit target specific prefix
  target/or1k: remove explicit target specific prefix
  target/microblaze: remove explicit target specific prefix
  target/hppa: remove explicit target specific prefix
  target/hexagon: remove explicit target specific prefix
  target/alpha: remove explicit target specific prefix
  tcg: prefix helpers with target base architecture
  target/sparc: define crypto helpers using HELPER macro
  tcg: introduce HELPER_INFO macro
  target/rx: define and call helpers using HELPER macro

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 06:08:01 -05:00
Anton Johansson bf67d56f28 target/riscv: Fix CPU state access on big-endian hosts
mstatus and mstatus_hs are uint64_t but accessed through

  tcg_gen_[ld|st]_tl(..., offsetof(mstatus))

which on a big-endian host running riscv32 incorrectly accesses the
top 32 bits rather than the lower bits.

Widen the operations to 64 bit so the lower bits are modified.

Fixes: 284d697c74 ("target/riscv: Merge m/vsstatus and m/vsstatush into one uint64_t unit")
Reviewed-by: Tommaso Califano <tcalifano@redhat.com>
Signed-off-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20261023063025.8827-1-anjo@rev.ng>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2026-10-27 10:26:46 +10:00
Eric Farman 2ddae8799c MAINTAINERS: Update s390 boot reviewer
Josh picked up some recent fixes in this area, and offered to help
with reviews as well. Let's free up some of Jason's plate.

Thank you, both!

Cc: Jared Rossi <jrossi@linux.ibm.com>
Cc: Jason Herne <jjherne@linux.ibm.com>
Cc: Joshua Daley <jdaley@linux.ibm.com>
Acked-by: Jared Rossi <jrossi@linux.ibm.com>
Acked-by: Joshua Daley <jdaley@linux.ibm.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20261023151229.1196404-3-farman@linux.ibm.com
Signed-off-by: Eric Farman <farman@linux.ibm.com>
2026-10-26 08:10:58 -04:00
Eric Farman 008d6efb55 MAINTAINERS: Add other s390x tree
Add my gitlab tree alongside Cornelia's

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20261023151229.1196404-2-farman@linux.ibm.com
Signed-off-by: Eric Farman <farman@linux.ibm.com>
2026-10-26 08:10:58 -04:00