Commit graph zephyr/arch
Author SHA1 Message Date
Lauren Murphy
6e245d5d37 lib/sys: add sys prefix to word granular access functions
Adds sys_ prefix to functions and typedef of the
word granular access library, as it is a sys API.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-07-15 19:04:01 -04:00
Daniel Leung
439718a598 xtensa: remove CPU mask pin only special code path
This removes all the extra code path when pin only CPU mask
and kernel coherence are both enabled. The original idea was
that with CPU pinning only, we could skip all the stack
manipulation since threads are not going to migreate between
CPUs until they get pinned to another CPUs. However, this
creates an issue where a thread is created on one CPU and
its stack being populated for startup at this CPU. Then it
gets pinned to another CPU. The other CPU does not know that
it is first starting the thread and will need to invalidate
the cache to grab the new stack content. This problem also
applies to migration between CPUs as there is no code to
manipulate the cache on stack. To support the skipping of
cache manipulation with pin only CPU mask would require
some invasive changes to kernel. At this point, the only
Xtensa SoCs requiring kernel coherence are not using pin
only CPU mask. So we are safe to remove the special code
path, and also we unify stack coherence operations to
minimize differences.

Fixes #112850

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-07-15 19:02:55 -04:00
Andrei-Edward Popa
4b3a3f2f3f arch: arm: cortex_a_r: keep IRQs disabled during interrupt exit
The Cortex-A/R interrupt wrapper enables IRQs to support nested interrupt
handling while running the registered ISR.

Move cpsie i after the spurious IRQ check so only valid ISR calls run
with IRQs enabled, and add cpsid i after the ISR returns. This prevents
EOI and z_arm_int_exit() from running with IRQs enabled.

Signed-off-by: Andrei-Edward Popa <andrei.popa105@yahoo.com>
2026-07-15 14:50:00 -05:00
Anas Nashif
886eca6f61 arch: make ARCH_SUPPORTS_ROM_OFFSET an arch-selected capability
ARCH_SUPPORTS_ROM_OFFSET is a hidden architecture-capability option, but
it was expressed as a reverse dependency on a hard-coded arch list
(ARM, X86, ARM64, RISCV, ARC) defaulting to y. This is inconsistent with
the surrounding ARCH_SUPPORTS_* symbols (e.g. ARCH_SUPPORTS_ROM_START),
which are selected by the architectures that provide the capability, and
the allowlist drifts as architectures are added.

Turn it into a plain selected capability symbol and have the supporting
architectures select it, matching the established convention. No
functional change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-15 10:46:40 +02:00
Anas Nashif
5fa5c51ec6 arch: replace ISR_TABLES_LOCAL_DECLARATION arch allowlist with capability
ISR_TABLES_LOCAL_DECLARATION_SUPPORTED gated its availability on a
hard-coded "List of currently supported architectures" (ARM, ARM64,
RISCV). Whether an architecture supports local declaration of interrupt
tables placed by the linker is an arch property, so the arch should
declare it rather than have the option carry an allowlist that drifts.

Introduce a hidden ARCH_HAS_ISR_TABLES_LOCAL_DECLARATION capability
symbol, have the supporting architectures select it, and depend the
supported symbol on the capability instead of the arch list. The
toolchain and userspace dependencies are unchanged. No functional change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-15 10:46:40 +02:00
Anas Nashif
c21da807a9 arch: replace SEMIHOST arch allowlist with capability
CONFIG_SEMIHOST depended on a hard-coded list of architectures
(ARM, ARM64, RISCV, XTENSA). Each of these ships its own semihosting
backend under arch/*/core/semihost.c, so providing a semihosting
implementation is an architecture property that the arch should declare,
rather than having the common option maintain an allowlist that a new
arch adding a backend must remember to update.

Introduce a hidden ARCH_HAS_SEMIHOST capability symbol, have the
architectures that implement semihosting select it, and depend SEMIHOST
on the capability instead of the arch list. No functional change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-15 10:46:40 +02:00
Anas Nashif
2fbba5e3e4 arch: replace IRQ_OFFLOAD_NESTED arch allowlist with capability
IRQ_OFFLOAD_NESTED defaulted to y based on a hard-coded list of
architectures (ARM64, X86, RISCV, XTENSA). Whether irq_offload() may
legally be called in interrupt context to cause a synchronous nested
interrupt is an architecture property, so the arch itself should declare
it rather than have the option maintain an allowlist that drifts.

Introduce a hidden ARCH_HAS_IRQ_OFFLOAD_NESTED capability symbol, have
the architectures whose irq_offload() supports nesting select it, and key
the default of IRQ_OFFLOAD_NESTED off the capability instead of the list.
No functional change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-15 10:46:40 +02:00
Anas Nashif
e7893844b7 xtensa: remove dead z_arch_irq_connect_dynamic
arch/xtensa/core/irq_manage.c still defines the dynamic IRQ connect
routine under its pre-2019 z_arch_ name, which nothing references
since the z_arch_* to arch_* interface rename. The __weak
arch_irq_connect_dynamic() fallback in arch/common/dynamic_isr.c
silently took over, so the multi-level variant that routes to
z_soc_irq_connect_dynamic() never runs, and the only implementation
of that SoC hook (intel_adsp cavs) has had no caller ever since.

The common weak fallback is functionally equivalent on cavs: the
cavs intc driver registers IRQ_PARENT_ENTRY_DEFINE and
CAVS_ISR_TBL_OFFSET defaults to 2ND_LVL_ISR_TBL_OFFSET, so the
generic z_get_sw_isr_table_idx() computes the same table slot the
hand-rolled SoC hook did. Reviving the routing would also break
other multi-level Xtensa SoCs (ace, mt8xxx, imx8 DSPs) that never
provided the hook. Remove the dead functions, the hook declaration
and its cavs implementation instead.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-14 20:08:55 -04:00
Joel Holdsworth
81b6e13b36 arch: openrisc: add LLEXT ELF relocation support
Implement arch_elf_relocate() for the OpenRISC architecture to enable
the LLEXT (Linkable Loadable Extensions) subsystem.

Supported relocation types:
- R_OR1K_32, R_OR1K_32_PCREL (data)
- R_OR1K_INSN_REL_26 (26-bit PC-relative branch/jump)
- R_OR1K_HI_16_IN_INSN, R_OR1K_LO_16_IN_INSN (address pair)
- R_OR1K_AHI16 (adjusted high, sign-compensated)
- R_OR1K_SLO16 (split-immediate store encoding)
- R_OR1K_PCREL_PG21, R_OR1K_LO13, R_OR1K_SLO13 (page-relative)
- R_OR1K_TLS_LE_HI16, R_OR1K_TLS_LE_LO16, R_OR1K_TLS_LE_AHI16,
  R_OR1K_TLS_LE_SLO16, R_OR1K_TLS_TPOFF (TLS local-exec)

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-07-14 16:41:44 -04:00
Joel Holdsworth
cc7efb5279 arch: openrisc: select ARCH_HAS_CODE_DATA_RELOCATION
The OpenRISC linker script already implements CODE_DATA_RELOCATION
support, but the Kconfig symbol was never selected, preventing the
feature from being enabled.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-07-14 16:41:44 -04:00
Sudan Landge
5f5284d518 arch: arm: Report escalated non-secure SecureFaults
When Secure firmware handles a fault with a recovered Non-Secure
exception frame, keep that context through fault classification.

Use it when reporting SecureFaults so the dump makes clear that the
fault originated in Non-Secure state and escalated into Secure state.
Also include guidance for the missing or disabled Non-Secure fault
handler case, where this escalation is commonly seen.

Handle the unexpected case where an exception frame cannot be recovered
without relying on __ASSERT(). Report the failure through the fault log
and terminate through z_arm_fatal_error(), so the path remains fatal
even when assertions are disabled.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-07-14 16:39:49 -04:00
Sudan Landge
8678a37a4a arch: arm: Fix secure Cortex-M callee register reporting
The fault assembly wrapper saves r4-r11 after exception entry. When
EXC_RETURN says callee stacking was skipped, the processor has already
saved the interrupted Secure r4-r11 in the Secure additional context
block, so the wrapper's live r4-r11 are not the interrupted values.

Keep a pointer to the skipped Secure additional context and use it to
populate extra_info.callee when available, so fault dumps and other ESF
consumers report the interrupted Secure context.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-07-14 16:39:49 -04:00
Sudan Landge
4bcd74122a arch: arm: Fix secure Cortex-M ESF lookup
Secure exception entry can place an integrity signature and additional
Secure context at the top of the stack before the basic exception frame.
Detect that signature when resolving the ESF and skip the additional
context before casting the stack pointer to struct arch_esf.

When EXC_RETURN says callee stacking was skipped, treat a missing
integrity signature as an invalid frame instead of silently using the
original stack pointer as the ESF. This avoids reporting misleading
fault state when the Secure stack shape is inconsistent or corrupt.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-07-14 16:39:49 -04:00
Mykyta Poturai
c5f988e70d xen: increase xen_domctl_interface_version range
Latest Xen changed interface version to 0x18, make Zephyr compatible with
it.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
2026-07-14 09:42:13 +02:00
Mykyta Poturai
31d2bd60ff xen: increase xen_sysctl_interface_version range
Latest Xen changed interface version to 0x16, make Zephyr compatible with
it.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
2026-07-14 09:42:13 +02:00
Rishav Chakraborty
032b0ff7a4 arch: arc: mpu: add nocache memory support for MPU v6
Enables the __nocache attribute on ARCv2 with MPU v6.

Adds REGION_NOCACHE_ATTR and the DC bit to the public
 MPU header so boards can declare nocache regions.
_region_init() preserves the DC bit through region programming.
Boards opt in by adding a nocache entry to mpu_regions[],
placed first for higher priority than SRAM.
nsim_hs_mpuv6 is the first consumer.

Adds a smoke test under tests/arch/arc/arc_nocache covering placement,
alignment, and .di-based cache-bypass validation on nsim_hs_mpuv6.

Signed-off-by: Rishav Chakraborty <reshav01@gmail.com>
2026-07-13 16:16:44 -05:00
Alberto Escolar Piedras
6eeba1b541 arch: arm: fix extended frame check compilation for Cortex-A/R
Fix a compilation error when CONFIG_EXTRA_EXCEPTION_INFO is enabled
on platforms that do not define EXC_RETURN_STACK_FRAME_TYPE_Msk
(which is only defined for Cortex-M).

For Cortex-A/R devices we just default to the same code path as before
bce6f0de63

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-07-13 16:38:32 +02:00
Hongquan Li
7e05fafe16 arch: arm64: remove duplicate privileged stack default
PRIVILEGED_STACK_SIZE already has ARM64 defaults earlier in the
same Kconfig file.

The later unconditional default is never reached because the previous
unconditional default is the first matching default when FPU_SHARING is
disabled.

Remove the duplicate entry to avoid implying that the value is
overridden later.

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-07-13 10:22:51 +01:00
Mike J. Chen
bce6f0de63 arch: arm: only dump fpu registers if stack has extended frame
Check the exc_return flags to determine if the FPU registers were actually
pushed onto the stack by the exception handler and only dump them if they
are used. Otherwise the stack locations for the FPU registers are invalid
and we're just dumping garbage.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2026-07-13 09:44:49 +02:00
Appana Durga Kedareswara rao
074c711f59 arch: arm: add CONFIG_ARM_MPU_SKIP_ARCH_INIT for pre-enabled MPU
Add CONFIG_ARM_MPU_SKIP_ARCH_INIT for platforms where early boot code
(for example a TCM-resident stub) enables the MPU before z_arm_mpu_init()
runs. On Versal RPU split TCM/OCM images the kernel is linked in OCM while
reset code runs from TCM; z_arm_mpu_init() must not disable and reprogram
the MPU while the CPU is executing from an OCM-only region map.

When SCTLR.M is already set, z_arm_mpu_init() records the SoC static MPU
region count in static_regions_num and returns without touching the live
region table. That preserves the boot-time map (TCM, peripherals, OCM)
and keeps vector fetches at 0x0 executable after relocation.

SoCs that need this behavior select CONFIG_ARM_MPU_SKIP_ARCH_INIT from
their Kconfig; no Versal-specific logic is added under arch/.

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2026-07-13 09:44:27 +02:00
Josh DeWitt
162b921c7d arch: arm: Keep CONFIG_INIT_STACKS behavior consistent
Implement CONFIG_INIT_STACKS for the main stack when
CONFIG_MULTITHREADING is disabled. This keeps the config behavior
consistent between the main stack and the interrupt stack which is
memset in reset.S.

Signed-off-by: Josh DeWitt <josh.dewitt@garmin.com>
2026-07-10 11:29:38 +01:00
Anas Nashif
9d665c0dcf arch: arm64: keep user entry registers in arch_user_mode_enter
arch_user_mode_enter() pins the user entry point and its three
arguments into x0-x3 with local register variables, then executes an
eret into z_thread_entry() which expects them there. arch_irq_lock()
was called after that pinning. It is normally inlined, but when the
build disables inlining (code coverage adds -fno-inline) it becomes a
real function call placed between the register assignments and the
eret, clobbering the caller-saved x0-x3. The user thread then entered
with a garbage entry point and crashed.

Move arch_irq_lock() ahead of the register variable assignments so no
function call can sit between them and the eret. This is a latent
correctness fix independent of coverage.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-09 10:32:57 -05:00
Anas Nashif
6a71ae0a3c arch: arm64: map gcov coverage area with user access
Code built with COVERAGE_GCOV is instrumented to update per-arc
counters stored in the gcov BSS section. When userspace is enabled the
instrumented code also runs in user threads, so those counters must be
writable from EL0. The gcov BSS lives inside the zephyr_data region,
which is mapped kernel-only, and a user thread updating a counter took
a data abort.

Add a dedicated MMU flat range for the gcov area mapped P_RW_U_RW,
placed after zephyr_data so it overrides the kernel-only mapping for
that sub-range. This mirrors what x86 (gen_mmu.py) and the Cortex-M
MPU (arm_core_mpu.c) already do. The region is page aligned by the
linker, so no adjacent kernel data is exposed.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-09 10:32:57 -05:00
Fin Maaß
cc8e10eb8f arch: x86: add dt dep for X86_VERY_EARLY_CONSOLE
X86_VERY_EARLY_CONSOLE only works when
the compatible of the chosen zephyr,console is
ns16550. Add this add a dependency to the
Kconfig.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-09 07:58:11 +02:00
Fin Maaß
7ed09e6c87 arch: cache: derestrict CACHE_LINE_SIZE
There can be platforms with a dcache or icache, but
without options for cache management. It that case
we should still be able to use the DCACHE_LINE_SIZE
without CACHE_MANAGEMENT if we want to use it to
align buffers for performance.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-08 17:17:53 +01:00
Lauren Murphy
5295cb345b llext: support word granular access instr mem for xtensa
Adds LLEXT support for executing out of word granular
access instruction memory on Xtensa. This is achieved by
copying the text region onto the instruction heap
(assumed in instruction memory) but saving the
ELF address for use as the base address in
calculating relocation rel_addr (the location of the
relocation). Any rel_addr landing in the text region
is recalculated using the heap address instead.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Signed-off-by: Anthony Giardina <anthony.giardina@intel.com>
2026-07-08 17:10:58 +01:00
Lauren Murphy
7a2c4bc9d9 arch: instr mem api
Adds arch-level instruction memory API with functions
for memcpying / memsetting and determining whether a
region is in instruction memory. Implement API for
Xtensa and ESP32, with support for word granular access.
Adds definitions for instruction memory to
Xtensa ESP32 platforms.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-07-08 17:10:58 +01:00
Jonathan E. Peace
7b5a481ff3 llext: arm64: add local-exec TLS relocation support
C++ extensions referencing a thread-local symbol such as errno emit
R_AARCH64_TLSLE_ADD_TPREL_HI12/_LO12_NC relocations and carry the
symbol in an SHF_TLS section. Loading such an extension currently
fails twice over: the .tbss section collides with .bss ("Multiple
SHT_NOBITS") and the relocation types are unknown to the arm64
relocator.

An extension has no TLS block of its own; it executes in one of the
loader's threads and shares that thread's TLS block. Skip SHF_TLS
sections in llext_map_sections() since they are never mapped as
runtime regions, and resolve the two local-exec relocations in the
arm64 relocator with tpoff = st_value + addend + TCB size, per the
AArch64 variant I TLS layout.

Add a C++ test extension (scenario llext.tls) that defines errno in
.tbss at the loader's offset and round-trips a value through the
loading thread's errno slot.

Signed-off-by: Jonathan E. Peace <jep@alphabetiq.com>
2026-07-08 09:59:56 +02:00
Adrian Śliwa
cda79d7ac6 arch: riscv: Bump privileged stack size
Since 5528dee556 (`device: Add asserts to DEVICE_API_GET`), the
following tests fail with a privileged-stack overflow during the
`log_panic()` syscall:

```
west twister -p hifive_unmatched/fu740/u74 -s logging.log_user
west twister -p hifive_unleashed/fu540/u54 -s logging.log_user
```

`qemu_riscv64` passes only because its defconfig sets
`CONFIG_PRIVILEGED_STACK_SIZE=2048`, lowering it to `1024` reproduces
the failure in a similar way.

The bad commit makes stack frames bigger along the `log_panic()` flush
chain. Peak privileged-stack usage goes from just-under to just-over
1024 bytes.

Signed-off-by: Adrian Śliwa <asliwa@internships.antmicro.com>
2026-07-07 17:25:03 +01:00
Omar Naffaa
b284cdb15c drivers: interrupt_controller: APLIC IRQ affinity support
Implement and enable IRQ affinity in APLIC direct mode driver

Signed-off-by: Omar Naffaa <onaffaa@qti.qualcomm.com>
2026-07-07 17:24:52 +01:00
Ayan Kumar Halder
23d02c824b arch: arm: zimage_header: emit end-of-image LMA in zImage header
The ARM zImage header (header.S) ends with three words that follow
the Linux self-decompressor convention:

    .long   0x016f2818          // Magic number
    .long   __rom_region_start  // start address of zImage
    .long   __end               // end address of zImage

A standard ARM zImage consumer (e.g. U-Boot bootz, or the Xen arm32
kernel loader) reads the third word and computes the on-disk file
size of the zImage as (__end - __rom_region_start). Linux establishes
the same invariant in arch/arm/boot/compressed/head.S, where the
analogous field is encoded as "_edata - start", i.e. the LMA of the
last byte of the image relative to its load address.

The current zimage_header.ld emits __end with:

    KEEP(*(.image_header))
    KEEP(*(.".image_header.*"))
    __end = .;

zimage_header.ld is plugged into the linker script via the ROM_START
hook (see arch/arm/core/CMakeLists.txt) and runs immediately after
the 48-byte .image_header section is placed. At that point '.' is
still just past the header, so __end ends up only 0x30 bytes past
__rom_region_start regardless of how large the actual image is.
Every zImage built with CONFIG_ARM_ZIMAGE_HEADER=y therefore
advertises a size of 48 bytes in its header.

For Zephyr standalone this is invisible: the FVP / debugger loads
the whole file unconditionally and never consults the header. It
breaks any consumer that honours the header, though. On a Cortex-R52
FVP under Xen dom0less, the guest fails to boot:

    (XEN) Loading zImage from 11000000 to 30000000-30000030
    (XEN) CPU0: Unexpected Trap: Undefined Instruction

Xen copied only the 48 header bytes into the DomU and the guest
branched into uninitialised memory.

Fix it by computing __end the way Linux's head.S computes _edata:
take the LMA of the very last output section. Zephyr already exposes
that anchor as .last_section, and uses

    LOADADDR(.last_section) + SIZEOF(.last_section)

elsewhere for the same purpose (e.g. _flash_used in
include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld and the
equivalent cortex_m / arm64 / riscv linker scripts). The expression
is resolved lazily by the linker at final link time, so referring
to it from a ROM_START fragment that runs before .last_section is
emitted is safe.

After this change, a build of samples/hello_world for
fvp_baser_aemv8r/fvp_aemv8r_aarch32 with -DCONFIG_ARM_ZIMAGE_HEADER=y
produces a 27268-byte zephyr.bin whose header reads:

    magic = 0x016f2818
    start = 0x30000000
    end   = 0x30006a84       (end - start == file size)

`file(1)` now identifies it as "Linux kernel ARM boot executable
zImage", U-Boot bootz accepts it without complaint, and the same
binary boots cleanly as a Xen R52 dom0less DomU using Xen's standard
zImage loader path (no special payload-only handling required).

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Signed-off-by: Satya Sri <satyasri.katru@amd.com>
2026-07-06 14:50:09 +01:00
Chidvilas Yerramsetti
36d2f824c3 arch: Fixed p15 register name arm switch.S
Fix the MCR instruction in switch.S to use the 'p15' coprocessor prefix
required by ARMv7-A toolchains.

Signed-off-by: Chidvilas Yerramsetti <cyerrams@qti.qualcomm.com>
2026-07-06 10:21:36 +02:00
Chidvilas Yerramsetti
f40cabb6b9 arch: arm gic ignore special interrupt ids
Added code in arm isr_wrapper.S to handle GICv3 special INTID
(1020-1023) filtering.

Signed-off-by: Chidvilas Yerramsetti <cyerrams@qti.qualcomm.com>
2026-07-06 10:21:36 +02:00
Chidvilas Yerramsetti
b54efaee98 drivers: intc_gicv3: extend NS support to ARMv7-A
Extend the GICv3 driver's Non-Secure mode handling to cover ARMv7-A
platforms via CONFIG_ARMV7_A_NS, alongside the existing
CONFIG_ARMV8_A_NS.

Signed-off-by: Chidvilas Yerramsetti <cyerrams@qti.qualcomm.com>
2026-07-06 10:21:36 +02:00
Anas Nashif
d67bb4516a arch: riscv: fatal: do not mark z_riscv_fatal_error as unreachable
z_riscv_fatal_error() may return: when a fatal error is handled (for
example an expected fault in ztest aborting the current thread), the
generic z_fatal_error() returns and the exception exit path in isr.S
takes care of rescheduling. isr.S explicitly sets the return address
to no_reschedule before tail-calling z_riscv_fault for this reason.

The CODE_UNREACHABLE hint made LLVM place a trapping instruction
(unimp) right after the call. When the handler returned, the CPU
executed the unimp and re-entered the fault path, so tests raising
expected faults hung in an endless fatal error loop when built with
clang. GCC builds only worked by chance, falling through into
whatever code the compiler laid out after the call.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-05 15:31:30 -04:00
Filip Kokosinski
ddec762ad2 arch/riscv: support RV32I in the internal SBI
Right now, the SBI hard-codes the usage of ld/sd instructions, which are
not available on 32-bit platforms. This commit changes this to sr/lr from
`asm_macros.inc`, which automatically resolves them to proper load/store
instructions on 32-bit and 64-bit configurations. It also ensures proper
timer handling through 32-bit registers.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Co-authored-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
2026-07-03 19:25:39 -04:00
Appana Durga Kedareswara rao
5743ceb34f arch: arm64: add ARMv8-A PMUv3 driver and portable Zephyr PMU API
Add an AArch64 PMUv3 implementation behind CONFIG_ARM64_PMUV3 (pmuv3.c):
probe ID_AA64DFR0_EL1, calibrate CPU frequency (PMCCNTR_EL0 vs the
generic timer), and provide per-CPU counter configuration, enable/disable,
overflow handling, and cycle counter access. Initialization is explicit
via pmu_init() on each logical CPU that uses the PMU (no SYS_INIT).

Introduce include/zephyr/pmu.h for the portable pmu_*() API.
Architectural PMUv3 event codes (PMU_EVT_* in 0x00-0x1F) and
PMCR/PMUSERENR bit defines live in include/zephyr/arch/arm64/pmuv3.h for
AArch64 builds.

Add ARCH_HAS_PMU in arch/Kconfig (Cortex-A profiles select it); enable
CONFIG_ARM64_PMUV3 for the PMUv3 driver backend. Register access uses
explicit MRS/MSR inlines instead of read_sysreg()/write_sysreg()
statement expressions for static analysis.

Builds for versal_apu, versalnet_apu, and versal2_apu. On QEMU, PMU
access is often unavailable (-ENOTSUP). On Versal Net APU hardware with
PMU usable at the current EL, initialization succeeds.

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2026-07-02 13:07:45 +01:00
Jamie McCrae
edbd63a24a arch: openrisc: Fix missing zephyr/ include path
Fixes this missing part in includes

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:01:49 +01:00
Mike J. Chen
ba8bb9a20f arch: xtensa: change backtrace to use EXCEPTION_DUMP
The backtrace code was either calling the arch exception dump
hook or printk based on the value of its own config called
CONFIG_XTENSA_BACKTRACE_EXCEPTION_DUMP.

However, this made fault output inconsistent when CONFIG_LOG is enabled
because other output (like xtensa_dump_stack()) would use the macro
EXCEPTION_DUMP(), which would use LOG_ERR instead of printk. Fault output
would be a mix of log lines for register dumps and printk lines for
backtrace (no domains, timestamps, etc).

This commit changes backtrace to use the EXCEPTION_DUMP() macro so output
now is consistent. It also fixes an issue where if printk was going to
the logging subsystem (CONFIG_LOG_PRINTK=y), because the printk calls in
backtrace had no '\n' termination, the output would be lost in the log
format buffer.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2026-06-30 11:53:23 -04:00
Etienne Carriere
b2fdf98b3c arch: use <> to include Zephyr headers instead of ""
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.

This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
    `grep -rsl "#include \"zephyr/" arch/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 06:49:18 -04:00
Duy Nguyen
43b005d34f arch: rx: Change to new generated header file
Add zephyr/ prefix for offsets.h header

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2026-06-29 14:02:10 -05:00
Liu Qian
ab0c08a6ce arch: riscv: add Zk and Zks ISA extension support
Add RISCV_ISA_EXT_ZK (Scalar Cryptography) and RISCV_ISA_EXT_ZKS
(ShangMi Suite) Kconfig options, and append them to the GCC march
flag when enabled.

Signed-off-by: Liu Qian <liuqian.andy@picoheart.com>
2026-06-29 13:56:59 -05:00
Hiren Virapara
bc594b461c arch: xtensa: extend syscall helper to invoke levels 0-3
CONFIG_XTENSA_SYSCALL_USE_HELPER currently only routes the 4/5/6-argument
syscall invocations through out-of-line helper functions. Toolchains that
reject inline-asm fixed-register operands in inlinable functions still
fail to build the 0-3 argument variants.

Add xtensa_syscall_helper_args_0..3 and route arch_syscall_invoke0..3
through them, gated behind a new opt-in
CONFIG_XTENSA_SYSCALL_USE_HELPER_ALL (default n, depends on
XTENSA_SYSCALL_USE_HELPER). This keeps the default behaviour unchanged -
the 0-3 argument syscalls stay on the inline fast path - and only routes
the low-argument variants through the helpers for toolchains that need
it, so there is no performance impact unless the option is explicitly
enabled. The inline-asm fast path is preserved under the #else branch.

Signed-off-by: Hiren Virapara <Hiren.Virapara@amd.com>
2026-06-29 11:28:50 +02:00
Appana Durga Kedareswara rao
02796d7079 arch: arm64: coredump: override IRQ unlock with DAIF manipulation
On ARM64, synchronous exceptions leave DAIF.I set independently of the
kernel IRQ lock. The generic arch_irq_unlock(key) fallback is therefore
insufficient to re-enable IRQ delivery during the coredump window.

Override arch_coredump_fatal_irq_unlock/lock to directly manipulate the
DAIF register: save current DAIF in the cookie, then clear DAIF.I so
that NIC TX-done interrupts can fire while the UDP coredump backend
drains its send queue. arch_coredump_fatal_irq_lock restores the saved
DAIF value and returns a fresh arch_irq_lock() key for the remainder of
z_fatal_error().

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2026-06-25 22:18:57 +01:00
Abderrahmane JARMOUNI
91db2e30a8 Kconfig: fix cache line size default setting
Setting symbol default value without 'configdefault', or without
explicit 'if' checks of dependencies, results in dependency weakening.
In this case, I/DCACHE_LINE_SIZE are redefined and set to the given
default value even if the dependency D/ICACHE is not enabled.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
2026-06-25 15:22:44 +02:00
Anas Nashif
b3806c0bd6 Revert "arch: arm: mpu: declare arm_core_mpu_enable/disable in header"
This reverts commit 98dd017374.

some major breakage with this change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-25 08:13:47 -04:00
Andrej Butok
98dd017374 arch: arm: mpu: declare arm_core_mpu_enable/disable in header
The arm_core_mpu_enable() and arm_core_mpu_disable() functions were
defined in the ARM MPU driver but never declared in a header.
As a result, callers had to provide their own local `extern`
declarations to use them.

Add documented prototypes for both functions to
include/zephyr/arch/arm/mpu/arm_mpu.h and drop the redundant `extern`
declarations in arm_core_mpu.c and the userspace memory protection
test.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2026-06-25 06:18:19 -04:00
Daniel Leung
1704f47ac6 xtensa: mpu: fix idx_e may be used uninitialized
Complier complains that idx_e may be used uninitialized.
So set the default as 0 so that the for loop where it can be
used uninitialized would be an no-op.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-06-23 17:41:00 -04:00
Daniel Leung
8801f171ac xtensa: mpu: rework region add function
Some issues found with previous region add mechanism:

() Previous mechanism cannot add new entry before the first
   enabled entry.
() There are some cases where inserting a region would not
   preserve access rights and memory type correctly.

This reworks the mechanism to fix these issue. Also remove
assertion within mpu_map_region_add() and let the caller
decide what to do.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-06-23 09:11:38 -04:00
Daniel Leung
0963a24416 xtensa: mpu: replace 0xFFFFFFFFU with #define END_OF_MEMORY_ADDR
Simply to get rid of magic numbers with a more meaningful name.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-06-23 09:11:38 -04:00