Skip to content

arch/arm: consolidate A/R interrupt, cache and SMP support and preserve classic ARM vectors - #22816

Open
hujun260 wants to merge 33 commits into
apache:masterfrom
hujun260:apache_20261202_1
Open

hujun260 wants to merge 33 commits into
apache:masterfrom
hujun260:apache_20261202_1

Conversation

@hujun260

@hujun260 hujun260 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

arch/arm: consolidate A/R interrupt, cache and SMP support and preserve classic ARM vectors

Summary

ARMv7-A, ARMv7-R and ARMv8-R maintained separate copies of interrupt, cache and CPU support code. Move the common implementations to arch/arm/src/arm_a_r so fixes can be made once. Share the exception vectors with classic ARM without assuming that an ARM926EJ-S can execute the newer exception entry and return instructions.

  • Interrupts and exceptions: Consolidate the GICv2 driver and its configuration, including legacy PCI IRQ selection for multiple PCI domains. Share FIQ dispatch, the vector table, exception handlers, user-context save and FPU support.
  • Cache and multiprocessor support: Consolidate CP15 cache operations, the PL310 L2 cache driver and headers, CPU information, SCU support, SMP calls and secondary CPU startup. Move the global timer capability to a common ARM option.
  • Boot and system control: Use BOOT_SDRAM_DATA in place of the ARMv7-R/ARMv8-R MEMINIT options. Unify the profile-specific alignment trap, cache policy, I-cache/D-cache disable and SCTLR options used during startup.

Impact

The shared assembly preserves two exception-frame layouts. Classic ARM uses banked exception registers and keeps its normal vector table in .text in the architecture library. Newer A/R profiles retain their SRS/RFE path and directly linked vector table. The internal ARCH_ARM_CLASSIC selector is derived from the CPU selection; boards do not need to set it explicitly. Both Make and CMake select the shared sources.

Out-of-tree configurations that explicitly set the old profile-specific symbols should migrate to the corresponding common options. Examples include CONFIG_ARM_GICV2_LEGACY_IRQ, CONFIG_ARM_L2CC_PL310, CONFIG_ARM_ALIGNMENT_TRAP, CONFIG_ARM_ICACHE_DISABLE and CONFIG_ARM_DCACHE_DISABLE.

The series also explicitly enables CONFIG_DEBUG_FULLOPT in quickfeather:nsh. That board configuration change is separate from the A/R consolidation.

Testing

Targeted Linux Make builds used tools/configure.sh -l <board>:<config> followed by make -j20 EXTRAFLAGS='-Wno-cpp -Werror'. The linked ELF and vector-table object were inspected with arm-none-eabi-nm and arm-none-eabi-objdump -h.

Configuration Result What was verified
ntosd-dm320:nettest (ARM926EJ-S) Build and link passed The classic exception path assembled; the vector table was 64 bytes in .text, with no .hyp_vectors section.
qemu-armv7a:smp (Cortex-A7) Build and link passed The vector table was 64 bytes in .vectors; the object retained its separate .hyp_vectors section.

These checks cover the classic and ARMv7-A build paths, not every configuration in the series. The full 13-shard ARM CI run was stopped before completion. No full-matrix pass, ARMv7-R/ARMv8-R runtime result, or on-hardware validation is claimed.

Related to #21984

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

GUIDINGLI
GUIDINGLI previously approved these changes Dec 4, 2026
@hujun260

hujun260 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

open

@hujun260 hujun260 reopened this Dec 4, 2026
@hujun260
hujun260 marked this pull request as draft December 4, 2026 10:50
hujun260 and others added 27 commits December 6, 2026 10:39
Rename CONFIG_ARMV7A_HAVE_GTM to CONFIG_ARM_HAVE_GTM and move
its Kconfig definition from arch/arm/src/armv7-a/Kconfig to the
top-level arch/arm/Kconfig, making the Global Timer (GTM) option
available to all ARM A/R profile architectures.

Update all chip-level Kconfig selections and gtm.h references
to use the renamed config symbol accordingly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The Snoop Control Unit (SCU) driver was duplicated across armv7-a,
armv7-r, and armv8-r directories with nearly identical implementations.
Consolidate them into the common arm_a_r directory to eliminate
code duplication.

Update CMakeLists.txt and Make.defs for all affected architectures
to build arm_scu.c from its new shared location.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The SCU (Snoop Control Unit) header was duplicated across armv7-a,
armv7-r, and armv8-r directories. Consolidate them into the common
arm_a_r directory using the most complete version from armv7-r,
adding missing SNSAC register and port0 control bit definitions.

Remove the redundant copies from armv7-a and armv8-r directories.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The SMP inter-processor call handler (arm_smpcall.c) was duplicated
across armv7-a, armv7-r, and armv8-r directories with identical
implementations. Consolidate them into the common arm_a_r directory
and remove the redundant copies.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The SMP CPU startup code (arm_cpustart.c) was duplicated across
armv7-a, armv7-r, and armv8-r directories. Move it into the common
arm_a_r directory and update CONFIG_SMP_NCPUS/this_cpu() to the
preferred CONFIG_NCPUS/up_cpu_index() APIs.

Remove the redundant copies from armv7-r and armv8-r, and update
CMakeLists.txt and Make.defs for all affected architectures.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The cpuinfo procfs implementation was duplicated across armv7-a,
armv7-r, and armv8-r directories. Consolidate them into the common
arm_a_r directory, using CONFIG_ARCH_ARMV8R to select the correct
architecture version string for the model name output.

Remove the redundant copies from armv7-r and armv8-r, and update
CMakeLists.txt and Make.defs for all affected architectures.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The CP15 cache operations implementation (cp15_cacheops.c) was
duplicated across armv7-a, armv7-r, and armv8-r directories with
identical content. Consolidate them into the common arm_a_r
directory to eliminate code duplication.

Remove the redundant copies from armv7-r and armv8-r, and update
CMakeLists.txt and Make.defs for all affected architectures.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove the dup and align the CFI declare.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Signed-off-by: hujun5 <hujun5@xiaomi.com>
The save user context assembly (arm_saveusercontext.S) was duplicated
across arm, armv7-a, armv7-r, and armv8-r directories. Consolidate
them into the common arm_a_r directory to eliminate redundancy, since
all ARM A/R profiles share the same context save/restore logic.

Remove the standalone copies from arm, armv7-r, and armv8-r, and
update CMakeLists.txt and Make.defs for all affected architectures.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Consolidate the exception vector table (arm_vectortab.S) from arm,
armv7-a, armv7-r, and armv8-r directories into the common arm_a_r
directory. Unify the vector start symbol name to _vector_start
across all architectures and conditionally include the hyp_vectors
section only when CONFIG_ARCH_ARMV8R is defined.

Update linker scripts, arm_head.S, and arm_cpuhead.S references to
use the renamed _vector_start symbol accordingly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The FPU configuration and comparison files (arm_fpuconfig.S and
arm_fpucmp.c) were duplicated across armv7-a, armv7-r, and armv8-r
directories with identical implementations. Consolidate them into
the common arm_a_r directory to eliminate code duplication.

Remove the redundant copies from armv7-r and armv8-r, and update
CMakeLists.txt and Make.defs for all affected architectures.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The L2 cache controller headers (l2cc.h and l2cc_pl310.h) were
duplicated across armv7-a, armv7-r, and armv8-r directories with
identical content. Consolidate them into the common arm_a_r
directory to eliminate code duplication.

Remove the redundant copies from armv7-a, armv7-r, and armv8-r
directories and update include guards to reflect the new location.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move arm_l2cc_pl310.c from armv7-a into the shared arm_a_r directory
and relocate L2CC-related Kconfig options from armv7-a/armv7-r/armv8-r
Kconfig files to the top-level arch/arm/Kconfig. Rename config symbols
from ARMV7A_* prefix to ARM_* to reflect their architecture-neutral
scope.

Update all chip Kconfig selections, defconfigs, and board references
to use the renamed ARM_HAVE_L2CC_PL310 and ARM_L2CC_PL310 symbols.

ARMv8-R only needs a Make-side removal: its CMake list had no local
PL310 entry. Both build systems now select PL310 in arm_a_r.
[skip-cmake-parity]

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace the architecture-specific ARMV7R_HAVE_DECODEFIQ and
ARMV8R_HAVE_DECODEFIQ Kconfig options with the common
ARCH_HAVE_HIPRI_INTERRUPT symbol. This removes duplicated FIQ handler
configuration from armv7-r and armv8-r Kconfig files and updates all
references in tms570, qemu-cortexr52, and fvp-armv8r platform code to
use the unified symbol, making high-priority interrupt support
consistent across ARM-R profile chips.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The armv7-a, armv7-r and armv8-r architectures each had their own copy
of cp15_cacheops.h with nearly identical content. The armv7-a and
armv7-r copies contained a bug where cache maintenance assembly macros
incorrectly used MRC (read) instead of MCR (write) for CP15 operations
such as ICIALLUIS, DCIMVAC, DCCMVAC, etc. Unify these into a single
file under arch/arm/src/arm_a_r/ based on the correct armv8-r version
which properly uses MCR, and remove the redundant per-architecture
copies.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove the redundant ARMV7R_MEMINIT and ARMV8R_MEMINIT Kconfig symbols
which were just architecture-specific aliases for BOOT_SDRAM_DATA.
Use BOOT_SDRAM_DATA directly in arm_head.S, tms570_boot.c and the
TMS570 Kconfig selection. Also add the missing BOOT_SDRAM_DATA guard
around arm_data_initialize() in armv8-r arm_head.S, which previously
called it unconditionally even when RAM was not yet ready.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace the per-architecture ARMV7A_ALIGNMENT_TRAP, ARMV7R_ALIGNMENT_TRAP
and ARMV8R_ALIGNMENT_TRAP Kconfig options with a single ARM_ALIGNMENT_TRAP
symbol defined in the top-level arch/arm/Kconfig. Update all arm_head.S
and arm_cpuhead.S files across armv7-a, armv7-r and armv8-r to reference
the unified config, eliminating duplicated Kconfig definitions that had
identical semantics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace the per-architecture ARM_CACHE_ROUND_ROBIN, ARMV7A_CACHE_ROUND_ROBIN,
ARMV7R_CACHE_ROUND_ROBIN and ARMV8R_CACHE_ROUND_ROBIN Kconfig options
with a single ARM_CACHE_ROUND_ROBIN symbol in the top-level arch/arm/Kconfig.
Update all arm_head.S and arm_cpuhead.S references across arm, armv7-a,
armv7-r and armv8-r to use the unified config, removing duplicated
definitions that had identical semantics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace the per-architecture ARM_DCACHE_DISABLE, ARMV7A_DCACHE_DISABLE,
ARMV7R_DCACHE_DISABLE and ARMV8R_DCACHE_DISABLE Kconfig options with a
single ARM_DCACHE_DISABLE symbol in the top-level arch/arm/Kconfig.
Update all arm_head.S, arm_cpuhead.S and imx6 Kconfig references across
arm, armv7-a, armv7-r and armv8-r to use the unified config, removing
duplicated definitions with identical semantics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace the per-architecture ARM_ICACHE_DISABLE, ARMV7A_ICACHE_DISABLE,
ARMV7R_ICACHE_DISABLE and ARMV8R_ICACHE_DISABLE Kconfig options with a
single ARM_ICACHE_DISABLE symbol in the top-level arch/arm/Kconfig.
Update all arm_head.S and arm_cpuhead.S references across arm, armv7-a,
armv7-r and armv8-r to use the unified config, removing duplicated
definitions with identical semantics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move duplicated SCTLR-related Kconfig options from armv7-r/Kconfig and
armv8-r/Kconfig into the common arch/arm/Kconfig. Rename the config
symbols from ARMV7R_/ARMV8R_ prefix to a shared ARM_ prefix, including
CCP15BEN, BACKGROUND_REGION, DIV0_FAULT, FAST_INTERRUPT, IMPL_VECTORS
and NONMASKABLE_FIQ, and update all references in arm_head.S and
arm_cpuhead.S for both architectures accordingly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Refactor exception_entry/exception_exit macros to maximize code sharing
between ARMv7+ and ARMv5/v6 paths. The shared code (stmdb/ldmia for
register save/restore, FPU save/restore, stack frame layout) is written
once, with minimal #if __ARM_ARCH guards only around instructions that
differ:

  - srsdb/cpsid vs msr cpsr_c (mode switch and LR+SPSR save)
  - cps vs msr cpsr_c + manual spsr restore (exception exit)
  - rfeia vs ldmia {r15}^ (exception return)

Also fix nested preprocessor indentation style per review feedback.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Enable normal optimization while retaining debug symbols for the NSH configurations on the i.MX95 EVK and MR-NAVQ95B.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
The kernel data and BSS use 6168 bytes of the 6 KiB kernel SRAM region before accounting for the 1 KiB IDLE stack. Allocate libc temporary buffers on demand and preallocate two messages each for thread and IRQ context.

With GNU EABI the kernel now uses 4744 bytes, leaving 376 bytes between the top of the IDLE stack and user SRAM.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Beforefix, cpu-n tls init by cpu0 nx_start tls_init_info, but when
nx_smp_start, tls will overwrite by CONFIG_STACK_COLORATION.
We should call stack_color in .C to avoid this.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Keep the buckboost image within the 64 KiB flash limit while retaining the interactive shell and the smps command.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Keep the Clang-built image within the 128 KiB flash limit while retaining the interactive shell and FAT filesystem commands.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
@hujun260
hujun260 dismissed stale reviews from GUIDINGLI and xiaoxiang781216 via d1564c0 December 6, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Area: Documentation Improvements or additions to documentation Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants