Commit graph

2356 commits

Author SHA1 Message Date
Carles Cufi
dc006e6b5f arch: arm: cortex-m: Reduce ZLI latency by not disabling them in wrapper
The difference between __irq_disable() and irq_lock() is that the former
essentially translates to `cpsid i`, whereas `irq_lock()` translates to
setting BASEPRI (on cores with BASEPRI). This means that using
irq_lock() does not disable zero-latency interrupts (ZLIs), which
reduces the potential execution latency of ZLIs.

In both isr_wrapper and _arch_isr_direct_pm() (which is just
really an implementation of ISR_DIRECT_PM()), we were using
__irq_disable() to disable all interrups, including ZLIs. But the code
executed with interrupts disabled handles waking up from idle, and so
must only be protected against regular interrupts being executed, not
ZLIs, which should have no effect on the correct execution of the code.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-06-06 20:11:18 +01:00
Mathieu Choplain
c8c0c294b1 arch: arm: cortex_a_r: use correct name for TLB Conflict Abort
Commit 87719828ac introduced FSR definitions
for ARMv7-A/R; however, the value 16 which is documented in the ARM[1] as
a "TLB Conflict Abort", was introduced as "TLB Conflict Fault" instead and
described as a "Table Conflict Fault".

Update all affected files to use the ARM's naming for this error instead.

[1] Architecture Reference Manual (Document ID: ARM DDI 0406C.d)
    "ARM Architecture Reference Manual for ARMv7-A and ARMv7-R Edition"

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-05-31 07:01:36 -04:00
Sudan Landge
35b5fb3bd6 arch: arm: cortex_m: Add support for PACBTI flags
Introduce a Kconfig choice to select Pointer Authentication and Branch
Target Identification (PACBTI) features on Armv8.1-M Mainline CPUs.
The available options map to supported `-mbranch-protection` levels
(`standard`, `pac-ret`, `bti`, and combinations) documented at
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
These options enable hardware-assisted control-flow integrity mechanisms on
targets like Cortex-M85, and require a toolchain with PACBTI support, such
as GCC 14.2 or newer.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-05-31 06:55:18 -04:00
Manuel Argüelles
63ebf4d23f Revert "arch: arm: mpu: fix erratum 1013783-B"
This reverts commit 983b1d088c.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2025-05-31 05:57:18 -04:00
Manuel Argüelles
983b1d088c arch: arm: mpu: fix erratum 1013783-B
Due to erratum 1013783-B, speculative accesses might be performed
to normal memory unmapped in the MPU. This can be avoided by using
MPU region 0 to cover all unmapped memory and make this region
execute-never and inaccessible.

Note that this applies when CPU Cortex-M7 implements MPU and D-cache.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2025-05-29 20:17:14 +02:00
Sudan Landge
2ddec2f0a9 arch: arm: update to use CMSIS_6 compatible macros
Zephyr switched to using CMSIS_6 module in f726cb51
which breaks certain boards like `nucleo_h745zi_q/stm32h745xx/m7` when
CONFIG_CORTEX_M_DWT, CONFIG_TIMING_FUNCTIONS are enabled and cmsis from
`module/hal/cmsis` is not available (deleted explicitly after west
update).

This commit adds a provision to be able to use CMSIS_6 macros when the
module cmsis is not available.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-05-23 17:40:55 -04:00
Sudan Landge
8c02ffc6dd arch: arm: enable pxn support at arch level
Move PXN support selection to arch so that it is enabled
for all Armv8.1-m socs.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-05-14 14:09:31 +02:00
Mathieu Choplain
77378a8c75 arch: arm: pm_s2ram: fix compatibility with ARMv6-M again
The original 'arch_pm_s2ram_resume' implementation saved lr on the stack
using 'push {lr}' and restored it using 'pop {lr}'. However, the Thumb-1
'pop' does not support lr as a target register, so this code would not
compile for ARMv6-M or ARMv8-M Baseline. r0 was added to these push/pop
later in 2590c48d40.

In 474d4c3249, arch_pm_s2ram* functions were
modified to no longer use the stack, which incidentally "fixed" this issue.
b4fb5d38eb reverted this commit and brought
back 'pop {r0, lr}' as-is, without taking compatibility into account.

Modify the sequence to use "pop {r0, pc}" which is supported on all
ARM M-profile implementations (v6/v7/v8 Baseline/v8 Mainline), and
add comments to (hopefully) prevent this issue from re-appearing.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-05-13 17:46:40 +02:00
Robert Hancock
0e248419b7 arch: arm: cortex_a_r: Fix memory corruption when disabling dcache
On the Xilinx MPSoC (Cortex-R5) platform, erratic operation was often
seen when an operation which disabled the dcache, such as sys_reboot,
was performed. Usually this manifested as an undefined instruction trap
due to the CPU jumping to an invalid memory address.

It appears the problem was due to dirty cache lines being present at the
time the cache is disabled. Once the cache is disabled, the CPU will
ignore the cache contents and read the possibly out-of-date data in main
memory. Likewise, since the cache was being cleaned after it was already
disabled, if the CPU had already written through changes to some memory
locations, cleaning the cache at that point would potentially overwrite
those changes with older data.

The fact that the arch_dcache_flush_and_invd_all function was being
called to do the cleaning and invalidation also contributed to this
problem, because it is a non-inline function which means the compiler
will generate memory writes to the stack when the function is called and
returns. Corruption of the stack can result in the CPU ending up jumping
to garbage addresses when trying to return from functions.

To avoid this problem, the cache is now cleaned and invalidated prior to
the dcache being disabled. This is done by directly calling the
L1C_CleanInvalidateDCacheAll function, which, as it is declared as force
inline, should help ensure there are no memory accesses, which would
populate new cache lines, between the cache cleaning and disabling the
cache.

Ideally, for maximum safety, the cache cleaning and cache disabling
should be done in assembler code, to guarantee that there are no memory
accesses generated by the compiler during these operations. However, the
present change does appear to solve this issue.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-13 17:46:28 +02:00
Robert Hancock
54eeb7bee8 arch: arm: arm_mpu_v7m: Fix unsupported Cortex-R access permission mode
This file previously defined an MPU access permission mode of 0x7 which
corresponded to privileged read-only, unprivileged read-only, similar to
mode 0x6. However, it appears that at least Cortex-R5 does not support
this mode, defining 0x7 as UNP (Unpredictable) or a value which should
not be used.

This value was in turn referenced by the REGION_FLASH_ATTR macro, which
caused the offending value to be used when a memory region was declared
as DT_MEM_ARM(ATTR_MPU_FLASH) in the device tree, causing such regions
to not work properly on Cortex-R5.

Since 0x6 is supported by both Cortex-M and Cortex-R and does the same
thing, there is no reason to use 0x7. Remove the RO_Msk definition which
referenced it, and change REGION_FLASH_ATTR to use P_RO_U_RO_Msk instead.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-13 17:44:40 +02:00
Alex Fabre
e163b2ca0e arm: exception: fix comparison of int of different signs
Clang 20.1.0 -Wsign-compare warning on int being compared with uint32_t.

Signed-off-by: Alex Fabre <alex.fabre@rtone.fr>
2025-05-13 10:05:52 +02:00
Damian Krolik
222e0fcd06 debug: coredump: support dumping stack top only
Add Kconfig option to dump only a portion of stack from the
current stack pointer to the stack end. This is enough to
let gdb reconstruct the stack trace and can significantly
reduce the dump size. This is crucial if the core dump needs
to be sent over radio.

Additionally, add another option to set the limit for the
dumped stack portion.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2025-05-12 19:19:25 +02:00
Daniel Leung
92ebb2eb69 kernel: remove kernel/internal/smp.h
There is no need for kernel/internal/smp.h as SOF does not call
z_sched_ipi(). Actually... git log over there has no mention of
z_sched_ipi() anywhere, just arch_sched_ipi().

And include <ksched.h> for source using z_sched_ipi() since
they are using scheduling functions, and would be the correct
file to include.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-04-29 02:42:09 +02:00
Dominik Ermel
ebd8803bd1 arch: arm: cortex_m: Rephrase comment on IRQ decrement
Move and rephrase the comment to better explain reason why obtained
IRQ number is decremented.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2025-04-25 19:00:15 +02:00
Martin Hoff
136fe24453 arch: arm: cortex_m: generalizing SRAM vector table relocation
Allow to place the vector table section in SRAM with
CONFIG_SRAM_VECTOR_TABLE option for all cortex-m architecture that
have VTOR register.

Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
2025-04-25 11:03:54 +02:00
Martin Hoff
a085cfcd99 arch: add dependencie for CONFIG_SRAM_VECTOR_TABLE
Move SRAM_VECTOR_TABLE symbol from general Kconfig to Arch Kconfig
because it depends on the architecture possibility to relocate the
vector table.

Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
2025-04-25 11:03:54 +02:00
Eivind Jølsgard
ab341e0afe arch: arm: core: cortex_m: Make relocate_vector_table weak
Allow relocate_vector_table() to be overwritten. This is necessary if
the IRQ vector table is handled proprietary, e.g. before the zephyr
kernel is initialized. In this case we want this function to be empty to
avoid overriding the previous configuration.

Co-authored-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
2025-04-09 15:23:25 +02:00
Julien Racki
87719828ac arch: arm: Adding fault description for the cortex A7
Add support for processing the Fault Status Registers and recoverable
data abort for the cortex A7.

Based on Cortex-A7 MPCore Technical Reference Manual (ARM DDI 0406).
(see https://developer.arm.com/documentation/ddi0406)

Signed-off-by: Julien Racki <julien.racki@st.com>
2025-04-04 09:35:03 +02:00
Julien Racki
6d1cb00627 arch: arm: Add Cortex-A7 support
Pass the correct -mfpu and -mcpu flags to the compiler when building
for the Cortex-A7.

Signed-off-by: Julien Racki <julien.racki@st.com>
2025-04-04 09:35:03 +02:00
Tom Hughes
11d70c61e5 everywhere: Replace diagnostic pragmas with TOOLCHAIN_* macros
The TOOLCHAIN_DISABLE_WARNING/TOOLCHAIN_ENABLE_WARNING macros are easier
to read and compiler agnostic.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-03-20 21:57:47 +01:00
Sudan Landge
637bd8f587 arch: arm: Add PXN attr for userspace MPU regions
What is the change?
 - PXN attributes is set for static mpu regions such that
   __ramfunc and __ram_text_reloc having userspace code
   cannot be executed in privileged mode.
 - Updated the notable change section to inform about the change in
   behaviour of code executed from __ramfunc and __ram_text_reloc MPU
   regions.

Why do we need this change?
 - The current static MPU regions allows executing userspace/unprivileged
   code from privileged mode which may not be expected and can lead to
   secure privileged escalation attacks.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-03-20 12:17:11 +01:00
Sudan Landge
d7c629696d arch: arm: Add PXN support for Armv8.1-M
What is the change?
This commit adds support for Armv8.1-M MPU architecture's PXN attribute.
This includes support for configuring MPU regions with PXN via
custom mpu_config, devicetree and static mpu_config.
The existing MPU region attribute macros are updated to retain existing
behaviour with this change with an addition of REGION_RAM_ATTR_PXN to be
used if one needs to configure a RAM region with PXN MPU attribute.

Why do we need this change?
Armv8.1-M architecture introduced a new MPU region attribute called
Privilege eXecute Never (PXN).
If an MPU region is configured with the PXN attribute set and if the,
processor attempts to execute code in this region while at
privileged level, a Memory Management Fault exception is triggered.

This ensures that specific tasks are executed only in unprivileged mode
and helps in preventing secure privilege escalation attacks.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-03-20 12:17:11 +01:00
Lars-Ove Karlsson
413c06b1ea arch: arm: Replaced __volatile__ with volatile
IAR doesn't support the __volatile__ keyword, and since the
toolchain.h isn't included by these arm-specific files and
other arm-specific files already uses volatile, I've made
them all use volatile.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-03-17 16:24:51 +01:00
Robert Hancock
61ae560e73 arch: arm: cortex_a_r: Flush entire I-cache on arch_icache_invd_range
Previously, the arch_icache_invd_range function simply returned
-ENOTSUP for Cortex A/R. However, this causes a correctness issue when
the processor modifies memory and then executes it as instructions, like
the LLEXT subsystem does. The CPU might not see the up-to-date instructions
in memory.

This caused an LLEXT test failure when running on an emulated Cortex-R5
in QEMU with caches enabled. QEMU doesn't actually emulate the cache,
but it does seem to need the ISB barrier that is executed as part of the
cache invalidate operation in order to handle self-modifying code
properly.

These CPUs do in fact support a selective I-cache invalidate operation
(ICIMVAU) but the CMSIS library doesn't currently support it. For now,
just invalidate the entire I-cache when an icache_invd_range operation
is performed.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-03-17 02:20:50 +01:00
Robert Hancock
e36d4fafd2 arch: arm: cortex_a_r: Cortex-R5 has I/D caches
Cortex-R5 has instruction and data caches present so update Kconfig
accordingly.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-03-17 02:20:50 +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
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
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
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
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
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
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
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
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
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
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
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
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
Sudan Landge
743fe63651 arch: arm: fix: pm_s2ram with CONFIG_DEBUG_THREAD_INFO
What is the change?
 - Fixes #83660 allowing device to now enter suspend mode even if
   CONFIG_DEBUG_THREAD_INFO is enabled.

Why is this needed?
 - z_sys_post_kernel was cleared as part of #d778d5c
   to "allow debuggers to display the correct thread state after
   the first 3 instructions have run".
   This is not required while resuming from suspend and
   it prevents the device from entering suspend so,
   move it out of resume path.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-01-14 15:39:30 +01:00
Nicolas Pitre
7a3124d866 kernel: move current thread pointer management to core code
Define the generic _current directly and get rid of the generic
arch_current_get().

The SMP default implementation is now known as z_smp_current_get().
It is no longer inlined which saves significant binary size (about 10%
for some random test case I checked).

Introduce z_current_thread_set() and use it in place of
arch_current_thread_set() for updating the current thread pointer
given this is not necessarily an architecture specific operation.
The architecture specific optimization, when enabled, should only care
about its own things and not have to also update the generic
_current_cpu->current copy.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-01-10 07:49:08 +01:00
Nicolas Pitre
46aa6717ff Revert "arch: deprecate _current"
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").

This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.

The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.

Hence this revert.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-01-10 07:49:08 +01:00
Samuel Chee
d9eed167d0 arm: mpu: Unify ARM_MPU kconfig definitions
Previously, there were two separate Kconfig definitions
of ARM_MPU located at:
- arch/arm/core/mpu/Kconfig
- arch/arm64/core/cortex_r/Kconfig

This lead to incomplete default settings and unexpected
missing configurations.

This commit combines the two into a single unified definition
now located at arch/common/Kconfig to prevent this.

Signed-off-by: Samuel Chee <samche01@arm.com>
2025-01-09 11:55:22 +01:00
Hessel van der Molen
8316f097ce arch: arm: cortex_m: pm_s2ram: fix system_off rv as rv of s2ram_suspend
The return value of the system_off call is overwritten by the the call to
pm_s2ram_mark_check_and_clear. As arch_pm_s2ram_suspend needs to specify
why system_off failed, we need to make sure the rv of system_off is moved
to a safe register before calling pm_s2ram_mark_check_and_clear and moved
to r0 als rv of arch_pm_s2ram_suspend when the suspend call exits.

Signed-off-by: Hessel van der Molen <hvandermolen@dexels.com>
2025-01-03 17:11:09 +00:00