Skip to content

RFC x86emul: address MISRA R2.6 in CONFIG_HVM=n builds

Shuaidong Chen xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86emul: mark the trimmed emulator's section-internal labels maybe-unusedxen/arch/x86/x86_emulate/x86_emulate.c+9 -92 replies
2/2misra: deviate R2.6 for the labels generated by CASE_SIMD_*automation/eclair_analysis/ECLAIR/deviations.ecl docs/misra/deviations.rst+12 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] x86emul: address MISRA R2.6 in CONFIG_HVM=n builds

With CONFIG_HVM=n, private.h defines X86EMUL_NO_FPU, X86EMUL_NO_MMX and X86EMUL_NO_SIMD, and x86_emulate.c is left with 91 unused labels, which ECLAIR reports under MISRA C:2012 Rule 2.6 (advisory). The ECLAIR jobs in automation/gitlab-ci/analyze.yaml all build with CONFIG_HVM=y, so upstream's scans don't show them today; they surfaced while analysing an HVM-less x86 configuration.

The 91 labels split in two groups:

- 9 hand-written simd_* labels whose gotos are all preprocessed out. Patch 1 marks them __maybe_unused, which the existing R2.6 deviation already covers. No functional change: the code and data sections of x86_emulate.o are unchanged.

- 82 labels produced by the CASE_SIMD_* macros, which deliberately expand to plain labels instead of case labels in this configuration. ECLAIR reports them at the macro use site, so they cannot be annotated in the source. Patch 2 extends the R2.6 deviation to them.

Reproduced on current master with clang -Wunused-label on a CONFIG_HVM=n build: 91 unused labels without the series, 82 (all CASE_SIMD_*) with patch 1. ECLAIR on an HVM-less x86 configuration:

before: https://gitlab.com/xen-project/people/amd/xen/-/jobs/17763605066
after:  https://gitlab.com/xen-project/people/amd/xen/-/jobs/17764580898

Sent as RFC for patch 2, a new deviation for reports upstream doesn't currently see:
- Is extending the R2.6 deviation acceptable here?
- Alternatives considered: folding the ':' into the macros still leaves the labels in place; expanding the macros to nothing makes the code behind them unreachable (Rule 2.1, required).
- Would an ECLAIR job for a CONFIG_HVM=n configuration be welcome?

Shuaidong Chen (2):
x86emul: mark the trimmed emulator's section-internal labels
maybe-unused
misra: deviate R2.6 for the labels generated by CASE_SIMD_*

 .../eclair_analysis/ECLAIR/deviations.ecl      |  4 +++-
 docs/misra/deviations.rst                      |  9 +++++++++
 xen/arch/x86/x86_emulate/x86_emulate.c         | 18 +++++++++---------
 3 files changed, 21 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1