Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions arch/arm/core/cortex_m/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ config ARMV8_M_DSP
This option signifies the use of an ARMv8-M processor
implementation supporting the DSP Extension.

config ARMV8_M_CDE_CP0
bool
depends on ARMV8_M_MAINLINE
help
Comment on lines +293 to +296

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Other arm toolchains leave cde disabled 🐞 Bug ≡ Correctness

The new compiler-feature handling covers GCC and Clang but leaves armclang and IAR generating their
existing CPU flags without enabling CP0 CDE. Builds selecting ARMV8_M_CDE_CP0 through either
toolchain therefore do not receive the promised compiler feature, and CDE-dependent source cannot
use it as configured.
Agent Prompt
## Issue description
Selecting the new CDE option does not enable the compiler feature when building with armclang or IAR.

## Fix Focus Areas
- cmake/compiler/armclang/target.cmake[17-29]
- cmake/compiler/iar/target.cmake[75-82]
- arch/arm/core/cortex_m/Kconfig[293-301]

## Recommended Fix
Add each toolchain's supported CDE CP0 configuration flags where available; otherwise explicitly reject the option for that toolchain rather than silently leaving the requested feature disabled.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

This option signifies the use of an ARMv8-M processor implementation
with an Arm Custom Datapath Extension (CDE) coprocessor on CP0. The
compiler is told to enable the cdecp0 feature so the CDE intrinsics
from arm_cde.h can be used. The SoC is responsible for enabling access
to the coprocessor (CPACR) before it is used.

config ARMV8_1_M_MVEI
bool
depends on ARMV8_1_M_MAINLINE
Expand Down
7 changes: 6 additions & 1 deletion cmake/compiler/clang/target_arm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

set(ARM_C_FLAGS)

list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU})
if(CONFIG_ARMV8_M_CDE_CP0)
# Clang takes the CDE feature on -mcpu rather than -march
list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU}+cdecp0)
else()
list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU})
endif()

if(CONFIG_COMPILER_ISA_THUMB2)
list(APPEND ARM_C_FLAGS -mthumb)
Expand All @@ -20,7 +25,7 @@
set(FORCE_FP_HARDABI TRUE)
endif()

if (CONFIG_FP_HARDABI OR FORCE_FP_HARDABI)

Check failure on line 28 in cmake/compiler/clang/target_arm.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/compiler/clang/target_arm.cmake:28 CMakeStyle See https://docs.zephyrproject.org/latest/contribute/style/cmake.html for more details.
list(APPEND ARM_C_FLAGS -mfloat-abi=hard)
elseif(CONFIG_FP_SOFTABI)
list(APPEND ARM_C_FLAGS -mfloat-abi=softfp)
Expand Down
10 changes: 9 additions & 1 deletion cmake/compiler/gcc/target_arm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

set(ARM_C_FLAGS)

list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU})
if(DEFINED GCC_M_ARCH)
# The CPU alone cannot express the requested architecture features
list(APPEND ARM_C_FLAGS -march=${GCC_M_ARCH})
if(DEFINED GCC_M_TUNE)
list(APPEND ARM_C_FLAGS -mtune=${GCC_M_TUNE})
endif()
else()
list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU})
endif()

if(CONFIG_COMPILER_ISA_THUMB2)
list(APPEND ARM_C_FLAGS -mthumb)
Expand All @@ -25,7 +33,7 @@
set(FORCE_FP_HARDABI TRUE)
endif()

if (CONFIG_FP_HARDABI OR FORCE_FP_HARDABI)

Check failure on line 36 in cmake/compiler/gcc/target_arm.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/compiler/gcc/target_arm.cmake:36 CMakeStyle See https://docs.zephyrproject.org/latest/contribute/style/cmake.html for more details.
list(APPEND ARM_C_FLAGS -mfloat-abi=hard)
elseif(CONFIG_FP_SOFTABI)
list(APPEND ARM_C_FLAGS -mfloat-abi=softfp)
Expand All @@ -33,7 +41,7 @@
endif()

if(CONFIG_FP16)
if (CONFIG_FP16_IEEE)

Check failure on line 44 in cmake/compiler/gcc/target_arm.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/compiler/gcc/target_arm.cmake:44 CMakeStyle See https://docs.zephyrproject.org/latest/contribute/style/cmake.html for more details.
list(APPEND ARM_C_FLAGS -mfp16-format=ieee)
elseif(CONFIG_FP16_ALT)
list(APPEND ARM_C_FLAGS -mfp16-format=alternative)
Expand Down
19 changes: 19 additions & 0 deletions cmake/gcc-m-cpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ if("${ARCH}" STREQUAL "arm")
else()
message(FATAL_ERROR "Expected CONFIG_CPU_CORTEX_x to be defined")
endif()

if(CONFIG_ARMV8_M_CDE_CP0)
# GCC does not accept the cdecp0 feature on -mcpu, so select the
# architecture explicitly and keep the CPU for tuning.
if(CONFIG_ARMV8_1_M_MAINLINE)
set(GCC_M_ARCH armv8.1-m.main)
else()
set(GCC_M_ARCH armv8-m.main)
endif()
if(CONFIG_ARMV8_1_M_MVEF)
string(APPEND GCC_M_ARCH +mve.fp)
elseif(CONFIG_ARMV8_1_M_MVEI)
string(APPEND GCC_M_ARCH +mve)
elseif(CONFIG_ARMV8_M_DSP)
string(APPEND GCC_M_ARCH +dsp)
endif()
string(APPEND GCC_M_ARCH +cdecp0)
string(REGEX REPLACE "\\+.*" "" GCC_M_TUNE ${GCC_M_CPU})
endif()
elseif("${ARCH}" STREQUAL "arm64")
if(CONFIG_CPU_CORTEX_A53)
set(GCC_M_CPU cortex-a53)
Expand Down
1 change: 1 addition & 0 deletions soc/ti/am13/am13e/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
config SOC_AM13E23019
select ARM
select ARMV8_M_DSP
select ARMV8_M_CDE_CP0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Cde applications fault on am13 🐞 Bug ≡ Correctness

SOC_AM13E23019 selects ARMV8_M_CDE_CP0, but AM13 startup does not enable CP0 access in the
coprocessor access control register. After reset, an application that uses the newly enabled CDE
intrinsics can execute a CP0 instruction while access remains disabled.
Agent Prompt
## Issue description
AM13 advertises CDE CP0 to the compiler without enabling access to CP0 before applications can use it.

## Fix Focus Areas
- soc/ti/am13/am13e/Kconfig[7-13]
- soc/ti/am13/am13e/soc.c[8-36]

## Recommended Fix
Enable the appropriate CP0 access in AM13's early startup path before CDE instructions can execute. Verify the access setting for the intended execution contexts, or defer selecting the option until startup provides that guarantee.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

select BUILD_OUTPUT_BIN
select BUILD_OUTPUT_HEX
select CPU_CORTEX_M33
Expand Down
8 changes: 8 additions & 0 deletions tests/arch/arm/arm_cde_cp0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.28.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(arm_cde_cp0)

target_sources(app PRIVATE src/main.c)
12 changes: 12 additions & 0 deletions tests/arch/arm/arm_cde_cp0/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2026 Texas Instruments Incorporated
# SPDX-License-Identifier: Apache-2.0

# ARMV8_M_CDE_CP0 is normally selected by the SoC. Select it here so that the
# option can be exercised on any Armv8-M Mainline target.
config TEST_ARM_CDE_CP0
bool "Build with the CDE coprocessor on CP0 enabled"
default y
depends on ARMV8_M_MAINLINE
select ARMV8_M_CDE_CP0

source "Kconfig.zephyr"
1 change: 1 addition & 0 deletions tests/arch/arm/arm_cde_cp0/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: Apache-2.0
31 changes: 31 additions & 0 deletions tests/arch/arm/arm_cde_cp0/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2026 Texas Instruments Incorporated
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <arm_cde.h>

/*
* Build-only check that CONFIG_ARMV8_M_CDE_CP0 makes the compiler accept CDE
* instructions on coprocessor 0. The code is never run, since whether CP0 is
* implemented and enabled depends on the SoC.
*/

#ifndef __ARM_FEATURE_CDE
#error "CDE is not enabled by the compiler flags"
#endif

#if !(__ARM_FEATURE_CDE_COPROC & BIT(0))
#error "CDE coprocessor 0 is not enabled by the compiler flags"
#endif

int main(void)
{
uint32_t val = __arm_cx1(0, 0);

val = __arm_cx2(0, val, 0);

return (int)val;
}
13 changes: 13 additions & 0 deletions tests/arch/arm/arm_cde_cp0/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
arch.arm.cde_cp0:
Comment on lines +1 to +2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. The cde build test never enters twister 🐞 Bug ≡ Correctness

The new test manifest is named tests.yaml, whereas this branch's Twister discovery recognizes
testcase.yaml for tests. Its directory is skipped during test discovery, so neither the build nor
its compiler-feature checks run.
Agent Prompt
## Issue description
Twister cannot discover the new build-only test because its manifest has the wrong filename for this branch.

## Fix Focus Areas
- tests/arch/arm/arm_cde_cp0/tests.yaml[1-13]

## Recommended Fix
Rename `tests.yaml` to `testcase.yaml`, retaining its contents, and verify that Twister discovers the CDE scenario.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

tags:
- arm
build_only: true
arch_allow:
- arm
platform_allow:
- mps2/an521/cpu0
- mps2/an521/cpu0/ns
- mps3/corstone300/an547
- mps4/corstone315/fvp
- lp_am13e230
Loading