Commit graph

5883 commits

Author SHA1 Message Date
William Tambe
15fa9a8ed8 arch: x86: remove arch specific dependencies from DYNAMIC_BOOTARGS
CONFIG_DYNAMIC_BOOTARGS currently depends on CONFIG_MULTIBOOT_INFO
and CONFIG_BUILD_OUTPUT_EFI which are x86 specific.

This change removes those dependencies so that another architecture
can use CONFIG_DYNAMIC_BOOTARGS without the x86 specifc features.

Signed-off-by: William Tambe <williamt@cadence.com>
2025-03-13 07:22:53 +01:00
Alberto Escolar Piedras
41c576888a arch/posix posix_core.h: Remove native_posix mention
That target does not exist anymore.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 19:05:12 +01:00
Alberto Escolar Piedras
942ef41f5d arch/posix posix_cheats.h: Clarify two comments
native_posix does not exist anymore. This header still applies for
targets setting CONFIG_NATIVE_APPLICATION until this option is removed.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 19:05:12 +01:00
Alberto Escolar Piedras
5c4be68b3c arch/posix/CMakeLists.txt: Move comment to correct place
This comment "moved" over the years as more code was added.
Let's put it where it belongs, and simplify it a bit.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 19:05:12 +01:00
Krzysztof Chruściński
0ec2ad577d arch: arm: cortex_m: Add sys_trace_idle_exit calls
Add calls to sys_trace_idle_exit when leaving idle state. It is
used to track CPU load.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-12 14:03:48 +00:00
Alberto Escolar Piedras
c52f625387 arch/posix/Kconfig: Remove mention of native_posix
This target board does not exist anymore.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 02:27:36 +01:00
Alberto Escolar Piedras
454ec337f1 arch posix: Clarify comment in posix_cheats.h
Clarify an old comment

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 02:27:36 +01:00
Yangbo Lu
627a3b83cd arch: arm: cortex_m: handle multi-level interrupts in irq init
Multi-level interrupts should be handled in irq init. Only level1
interrupts going directly to interrupt controller need to be
initialized.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-03-11 18:54:40 +01:00
Yangbo Lu
b4f2553cd8 arch: arm: irq: allow custom irq control for multi-level interrupts
Custom irq control for multi-level interrupts should be allowed.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-03-11 18:54:40 +01:00
Jordan Yates
06d7fe8bed arch: update USERSPACE dependencies
These symbols only need to exist if `USERSPACE` is enabled, not just if
the architecture supports it.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 20:25:23 +01:00
Peter Mitsis
427f2c60da kernel: arch: add directed IPIs to x86/intel64
Adds support for directed IPIs to x86/intel64. Use of direct IPIs
can further reduce the number of schedule IPIs sent and processed
in a system. Fewer IPI related ISRs mean that ...
 1. Application code is interrupted less frequently
 2. Lower likelihood of scheduler spinlock contention

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-03-07 20:22:40 +01:00
Alberto Escolar Piedras
7f93a80537 native/posix arch: Add option to enable building of nsi_errno component
Add a new kconfig option to enable building the new component provided
in the native simulator, nsi_errno, which allows converting the errno
value between libCs.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 19:56:30 +01:00
Sudan Landge
b4fb5d38eb Revert "arch: arm: cortex_m: pm_s2ram: Rework S2RAM mark functions"
What is the change?
 - This reverts commit 474d4c3249

Why do we need this change?
 - This commit was added because Cortex-M didn't have a valid
   stack to make required functionality work however,
   the previous commit fixes this and makes interrupt stack
   available for use. This removes Arm specific limitation from
   these generic APIs so revert the commit to reflect the same.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-03-07 19:46:01 +01:00
Sudan Landge
7beff12b06 arch: arm: refactor pm_s2ram
What is the change?
 - APIs `pm_s2ram_mark_set` and `pm_s2ram_mark_check_and_clear`,
   used to set/check pm_s2ram magic marker,
   no longer have Arm specific limitations.

Why is this needed?
 - These APIs are generic and should not have arch specific dependency.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-03-07 19:46:01 +01:00
Eric Ackermann
b7e9b2785f llext: Support non-paired RISC-V PCREL Relocation
Currently, RISC-V's architecture-specific relocations assume that
all relocations of type R_RISCV_PCREL_LO12_I and _S are processed
immediately after the R_RISCV_PCREL_HI20 relocation that they
share a relocation target with. While this is the case most of
the time, the RISC-V PSABI specification does not guarantee that.
This commit corrects this by determining the R_RISCV_PCREL_HI20
relocation based on the symbol value of the R_RISCV_PCREL_LO12
relocation, as specified in the PSABI.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-03-07 19:44:54 +01:00
Eric Ackermann
3466dab804 llext: Add parameters to arch_elf_relocate
The RISC-V port of llext requires additional parameters for
handling non-adjacent HI20/LO12 relocations in arch_elf_relocate():
the current extension (struct llext), the current extension loader
(struct llext_loader), the current section header (elf_shdr_t) and
the current symbol (elf_sym_t).
This changes the signature of arch_elf_relocate accordingly.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-03-07 19:44:54 +01:00
Jungo Lin
d0a1945f49 arch: arm64: enhance backtrace dump check
Examine the FP and LR values of each frame to prevent nested
exceptions caused by data aborts. Sometimes, abnormal FP and LR
values are not mapped by the MMU. If we access memory addresses
based on FP or LR values, a CPU data abort will occur. This issue
often accompanies stack overflow occurrences.

Based on this, it is safe to check the validity of memory mapping
with FP and LR values before accessing them.

Signed-off-by: Jungo Lin <jungolin.tw@gmail.com>
2025-03-07 19:43:31 +01:00
Jonas Spinner
bc3a01a7e5 arch: arm64: fix spelling of "exception"
/s/expection/exception/

Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
2025-02-27 13:28:21 +00:00
Jonas Spinner
4ffe3891df arch: arm: cortex_m: fix spelling of "exceptions"
s/expections/exceptions/

Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
2025-02-27 13:28:21 +00:00
Andy Ross
029e8f9b61 arch/arm64: z_fatal_error() can return!
This isn't a FUNC_NORETURN function.  On a handled
k_sys_fatal_error_handler(), we'll end up back here.  And the
CODE_UNREACHABLE was causing code generateion bugs that prevented
return up the stack.

Note that the same pattern exists in MANY other architectures (it
seems like the original was part of x86).  But in most cases the arch
assembly isn't actually capable of handling the return to an aborted
thread frame correctly.  On arm64, it does actually work.  So fix it
here at least.

Signed-off-by: Andy Ross <andyross@google.com>
2025-02-26 10:10:29 +00:00
Emil Kieri
ed1b56b557 arch: arm: cortex_a_r: Add cfi directives to z_arm_cortex_r_svc
Add call frame information (cfi) directives to the function
z_arm_cortex_r_svc, which triggers an SVC exception whose handler will
execute a context switch. The return address stored on the stack of a
suspended thread will point into z_arm_cortex_r_svc, that is, this
function will be the starting point when a debugger tries to produce a
call stack for a suspended thread. As the function is written in
assembly, most compilers will not emit any cfi automatically. This patch
adds cfi directives manually so that the call stack can be unwound.

The added cfi directives instruct the compiler to note in the
.debug_frame section that the canonical frame address is at offset 0
from r13, i.e., from the stack pointer.

Signed-off-by: Emil Kieri <emil.kieri@iar.com>
2025-02-25 15:23:53 +00:00
Guennadi Liakhovetski
c29e0d3480 llext: xtensa: disable relative relocations for pre-located
When building pre-located LLEXTs of ET_DYN type (shared ELF object)
on Xtensa, all the R_XTENSA_RELATIVE relocations are already correct,
the current code actually breaks them by mobing the value from the
target address-space to a storage range address. Simply removing the
recalculation solves the issue.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2025-02-20 21:05:37 +01:00
Benjamin Cabé
29ed8bc21e arch: arm64: fix spelling of "below"
s/bellow/below/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:51:13 +01:00
Robin Kastberg
c858c8d6ba arch: arm: cortex_m: 'movs reg, imm' mnemonic
One nmemonic was missed by f84342828cd1

That commit said:

The ARM Thumb-1 instruction set, used by ARMv6-M and ARMv8-M Baseline
cores, does not have a valid encoding for "immediate-to-register move
without affecting flags" instruction (i.e. `mov reg, imm`), and the only
valid variant of immediate-to-register move instruction for it is `movs`,
which affects the flags.

Since none of the register initialisation instructions used here are
flag-sensitive in their context, this commit changes `mov` to `movs`.

This fixes the compilation errors with Clang/LLVM, which is more picky
about the `mov` mnemonic usage and prints out an "invalid instruction"
error when `mov reg, imm` is specified in Thumb-1 mode.

Note that GNU assembler implicitly converts `mov reg, imm` to `movs reg,
imm` when assembling in Thumb-1 mode.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-17 21:15:44 +01:00
Robin Kastberg
9ab06ec667 toolchain: iar: Add experimental IAR support
This adds experimental support for the IAR toolchain.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Robin Kastberg
f5a1585426 toolchain: iar: tls: no tls pointer offset in IAR
The IAR Toolchain currently doesn't use the two
pointer offset.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Robin Kastberg
e9a0d146cf toolchain: move some hardcoded flags to properties
Some basic flags that were hardcoded needed
to be moved to properties to be able to implement
alternative toolchains.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Wilfried Chauveau
d88575b5f8 arch: arm: cortex_a_r: move exit_exc from vector_table.S to exc.S
It makes more sense to keep the exit_exc code close to the exc code.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2025-02-14 00:45:35 +01:00
Ryan McClelland
ef232f34d0 arch: arm: fix compile issue if MEM_ATTR=n and ARM_MPU=y
It's possible to have MEM_ATTR=n and ARM_MPU=y. This fixes the compile
issue with it by compiling out the calls to define the DT mpu regions.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-13 16:43:11 +01:00
Wilfried Chauveau
caafe23891 arch: arm: cortex_m: Apply clang-format on cortex_m related code
This commit updates cortex_m related code to align it with the rules from
.clang-format. This is done to simplify future changes in these files as
we are about to implement use_switch support.

Some rules conflict with checkpatch and therefore some small part of the
code locally disable clang-format.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2025-02-13 16:42:48 +01:00
Anas Nashif
10506f8a25 x86: lakemont: split lakemont into families
Define multiple lakemont cpu families: value and performance.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-12 23:16:38 +01:00
Wilfried Chauveau
3e6dd56133 arch: arm: cortex_m: make reading tls pointer faster on v7m and v8m.main
Encoding T3 allows for an offset of up to 12bits in size allowing for a
single instruction instead of 3.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2025-02-08 10:09:10 +01:00
Wilfried Chauveau
5261680312 arch: arm: cortex_m: use local label in ASM code
Regular label are exported in the object file and cause gdb to consider
them as function start. Local labels on the other hand are not exported.
For example, using `disassemble z_arm_pendsv` after this change will
disassemble the whole function rather than stop at the first branch.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2025-02-08 08:14:07 +01:00
Björn Bergman
5a57c3b7e8 toolchain: x86: Broken -Os detection in ia32.cmake
Fix followup problems after laguage-correct zephyr COMPILE_OPTIONS

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-02-06 03:16:07 +01:00
Sudan Landge
ce60dd2a27 arch: arm: fix mpu compiler warnings
What is the change?
 - Use a macro that search for "zephyr, memory-attr" in only
   those nodes that have the property "zephyr, memory-regions".
 - Fixes #83448.

Why is this needed?
 - Using `DT_REG_ADDR` inside `DT_FOREACH_STATUS_OKAY_NODE_VARGS` can
   lead to compiler warnings if a devicetree node has an addresses
   larger than 64bits. An example of such node is wm8904 i3c with 92
   bit encoding addresses `audio_codec: wm8904@1a0000000000000000`.
   We can avoid this warning since this is not applicable for nodes
   that have the attribute "zephyr,memory-regions".

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-02-06 03:15:48 +01:00
Filip Kokosinski
ee07eba569 arch/riscv: add Zaamo and Zlrsc extension subsets
The Zaamo and Zalrsc Extension (Version v1.0.0, 2024-04-25; Ratified) split
the standard A extension into two subextensions. As of date, the `_zaamo`
and `_zlrsc` extension specifications are accepted by the upstream
in-development GCC through the `march` argument. This means that those
subextensions are not yet supported by GCC shipped with Zephyr SDK.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2025-02-05 17:49:13 +01:00
Jimmy Zheng
3804387350 arch: riscv: handle interrupt level for CLIC
CLIC supports mintstatus.MIL (RO) and mcause.MPIL (RW) for the current
interrupt level and the previous interrut level before a trap. Each ISR
must execute MRET to set mcause.MPIL back to mintstatus.MIL.

This commit introduces CONFIG_CLIC_SUPPORT_INTERRUPT_LEVEL to handle
mcause.MPIL for interrupt preemption in nested ISR, and uses
CONFIG_RISCV_ALWAYS_SWITCH_THROUGH_ECALL to ensure ISR always switch out
with MRET.

e.g.
  With CONFIG_RISCV_ALWAYS_SWITCH_THROUGH_ECALL=n, a context-switch in
  ISR may skip MRET in this flow:
  IRQ -> _isr_wrapper -> z_riscv_switch() -> retrun to arch_switch()

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2025-02-05 17:48:45 +01:00
Kalle Kietäväinen
d929b8a9fa Revert "arch: arm: cortex_m: Only trigger context switch if thread is preemptible"
This reverts commit 42036cdbca.

Architecture specific code should not do preemption checking before context
switch. This is already handled by the scheduler, so duplicating it would
be redundant and error prone. These checks used to be necessary, but the
scheduler has been rewritten since then and the checks were removed in
3a0cb2d35d (kernel: Remove legacy preemption checking, 2018-05-23).

The check this reverts was also incorrect, as it didn't take scheduler
locking nor meta-IRQs into account.

Fixes #80574

Signed-off-by: Kalle Kietäväinen <kalle.kietavainen@silabs.com>
2025-02-04 12:03:20 +01:00
Anisetti Avinash Krishna
9353abf162 arch: x86: core: reboot_rst_cnt: Enable support for warm reboot
Enable support for warm reboot for x86 arch as per the Reset Control
Register description.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
2025-02-04 09:19:24 +01:00
Joel Holdsworth
d640f15955 arch: riscv: Rename _Fault to z_riscv_fault
The exception fault handler function is named _Fault which is inconsistent
with all other arch-specific functions present in Zephyr. This patch
replaces the name with z_riscv_fault.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-28 23:42:06 +01:00
Joel Holdsworth
58499aca7c arch: nios2: Rename _Fault to z_nios2_fault
The exception fault handler function is named _Fault which is inconsistent
with all other arch-specific functions present in Zephyr. This patch
replaces the name with z_nios2_fault.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-28 23:42:06 +01:00
Joel Holdsworth
bdb3f4fd73 arch: nios2: Corrected a typo
An existing comment references a function "irq_oflload()", which should be
written "irq_offload()".

This issue was detecte by the GitHub CI compliance check.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-28 23:42:06 +01:00
Joel Holdsworth
d76cf5b57e arch: mips: Rename _Fault to z_mips_fault
The exception fault handler function is named _Fault which is inconsistent
with all other arch-specific functions present in Zephyr. This patch
replaces the name with z_mips_fault.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-28 23:42:06 +01:00
Joel Holdsworth
4611e169e2 arch: arc: Rename _Fault to z_arc_fault
The exception fault handler function is named _Fault which is inconsistent
with all other arch-specific functions present in Zephyr. This patch
replaces the name with z_arc_fault.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-28 23:42:06 +01:00
Abe Kohandel
9163d5852f arch: arm: mmu: Make all device memory shareable
ARM has deprecated usage of non-shareable device memory.
K_MEM_CACHE_NONE flag used by devices to map physical memory translates
to MT_DEVICE but no MATTR_SHARED attribute is set in such a request.
This results in mapping device memory that is non-shareable.

Depending on the memory interconnect of a SoC, mapping the device memory
as non-shareable can prevent access to the device. Such behavior has
been observed on the TI AM3358 SoC.

To comply with the ARM deprecation notice and prevent access issues to
device memory, all device memory is mapped as shareable.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2025-01-28 09:51:21 +01:00
Chris Friedt
75ad6e1d00 arch: x86: fatal: initialize was_valid_access
This change initializes was_valid_access in the case that
CONFIG_X86_KPTI is selected. Previously, the variable was
causing an uninitialized variable warning that would be
escalated to an error when run with twister.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-01-27 17:09:19 +01:00
Yong Cong Sin
588ccd9698 arch: remove CONFIG_LEGACY_MULTI_LEVEL_TABLE_GENERATION
`CONFIG_LEGACY_MULTI_LEVEL_TABLE_GENERATION` had been deprecated since
#66877 for 2 releases, interrupt controller drivers should have been
updated to use the new `IRQ_PARENT_ENTRY_DEFINE()` macro. Remove it.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2025-01-23 16:32:36 +01:00
Yong Cong Sin
ecc2b0fb33 arch: arm64: remove CONFIG_ARM64_ENABLE_FRAME_POINTER
`CONFIG_ARM64_ENABLE_FRAME_POINTER` had been deprecated since #72646
for 2 releases and served not functional effect, it's now time to
say goodbye.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2025-01-23 16:32:36 +01:00
Maciej Kusio
ddff91fef6 arch: Changes MPU alignment to 128 when FPU_SHARING and MPU_STACK_GUARD
With our builds for Arm M7 we are selecting FPU_SHARING and
MPU_STACK_GUARD. For that setup, we have
ARM_MPU_REGION_MIN_ALIGN_AND_SIZE=64 and
MPU_STACK_GUARD_MIN_SIZE_FLOAT=128. So worst case scenario,
we are going to have stack that is 64-byte aligned and
128-byte guard at the bottom of the buffer.

Fixes: #83714

Signed-off-by: Maciej Kusio <rysiof@gmail.com>
2025-01-22 10:48:02 +01:00
Chris Friedt
c057f91eb5 arch: x86: add missing semicolon for z_x86_kpti_is_access_ok()
The function prototype / extern declaration for
z_x86_kpti_is_access_ok() in x86_mmu.h was missing a semicolon.

Add it to avoid being surprised by compile errors in certain
circumstances.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-01-22 08:08:40 +01:00