|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen/arm: deviate MISRA R11.8 for capability enable callbacks
MISRA C Rule 11.8 forbids casts that remove the const qualifier from the pointed-to type. enable_cpu_capabilities() and enable_nonboot_cpu_caps() cast a const struct arm_cpu_capabilities pointer to void * so that it can be passed to the capability enable callback, either directly or through stop_machine_run(). The callback type takes void * by convention. Existing enable implementations treat the pointer as const and do not modify the object. Document both casts with SAF-15-safe comment. No functional changes. Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx> --- Test CI pipeline: https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/3081209229 --- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/cpufeature.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 3584cb90c6..67f8ed9869 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -124,6 +124,14 @@ }, { "id": "SAF-15-safe", + "analyser": { + "eclair": "MC3A2.R11.8" + }, + "name": "Rule 11.8: cast const capabilities to void * for enable callback", + "text": "The Arm CPU capability enable callback takes void * to match the generic callback convention. The cast removes const only to pass a const struct arm_cpu_capabilities * into that signature. Existing enable implementations treat the pointer as const and do not modify the object." + }, + { + "id": "SAF-16-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c index 8d8cd19a96..4d2b183a62 100644 --- a/xen/arch/arm/cpufeature.c +++ b/xen/arch/arm/cpufeature.c @@ -72,6 +72,7 @@ void __init enable_cpu_capabilities(const struct arm_cpu_capabilities *caps) * an IPI, giving us a PSTATE that disappears when we * return. */ + /* SAF-15-safe R11.8 cast const caps to void * for enable callback */ ret = stop_machine_run(caps->enable, (void *)caps, NR_CPUS); /* stop_machine_run should never fail at this stage of the boot. */ BUG_ON(ret); @@ -108,6 +109,7 @@ int enable_nonboot_cpu_caps(const struct arm_cpu_capabilities *caps) if ( caps->enable ) { + /* SAF-15-safe R11.8 cast const caps to void * for enable callback */ int ret = caps->enable((void *)caps); if ( ret ) -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |