As part of a project I was experimenting with compiler warning options
that partial covers coding standard rules from e.g., MISRA 2012. An
example is Wconversion, and the narrower sign-conversion, sign-compare,
pointer-arch, cast-qual. E.g., Wconversion covers MISRA 2012 10.3 (and
parially 10.4, 10.1).
Before enabling those, I've enabled some other warnings to filter out
definition/declaration "issues" that would clutter the compilation
otherwise. Specifically (Patch 0001), I've added: -Wextra -Wundef
-Wnested-externs -Wshadow -Wredundant-decls -Wdeprecated
The warnings were not too many (most of them related to
unused-parameters), but there were some interesting ones e.g.:
hypervisor: provide dedicated declaration for __page_pool and __text_start in
globals.h
hypervisor: introduce uptr_t (depending on the wordsize) and define size_t
accordingly
hypervisor, arm-common: provide an explicit uint INVALID_CPU_ID
The patch series fixes the warnings generated by "-Wextra -Wundef
-Wnested-externs -Wshadow -Wredundant-decls -Wdeprecated", and two small
bugs:
x86: bitops: only x86_64 is supported, avoid picking the wrong default suffix
arm64: smmu: fix double negative
Up to "0024 x86: bitops: only x86_64 is supported, avoid picking the
wrong default suffix", the series is the same for both master and next.
These two
arm64: smmu: Wsign-compare: make iterator uint
arm64: smmu: fix double negative
are only next related.
I've compile-checked x86, arm, arm64, and tested arm64 (ZCU102), but I don't
have a suitable arm / x86 physical targets and I'm still figuring out
a crash I have on qemu-x86 (can reproduce with plain jailhouse-image
qemu image).
I don't know if there's interest in extending the compiler flags with
warnings about code structure, but since the code compiles cleanly with
the patches, I thought about sharing them.
Additional info:
gcc (Debian 10.2.0-13) 10.2.0
JFTR:
Wcast-qual generates 276 warnings on arm64 (but they looks ~ the same,
it could be feasible fixing them) Wconversion + Wpointer-arith are a
worse beast (~ 1400 occurrences), and the "int" return convention in
Linux doesn't make it easy to cleanly fix them.
Andrea Bastoni (26):
hypervisor: add extra warning flags
hypervisor: protect inclusion of string.h
hypervisor: protect inclusion of processor.h
arm-common: provide unsigned int PSCI_INVALID_ADDRESS
arm-common: fix old-style defs, sign-comparison warnings
hypervisor: provide dedicated declaration for __page_pool and
__text_start in globals.h
arm64: smmu-v3: avoid shadowing smmu and fix sign-comparison
hypervisor, arm-common: provide an explicit uint INVALID_CPU_ID
hypervisor, arm-common, arm64: keep compiler happy about unused
parameters.
hypervisor: mmio: fix Wsign-compare by casting index to u32.
hypervisor: printk: Fix Wsign-compare by casting width to int. Fix
protoype for align.
arm64: ti-pvu: fix Wsign-compare by casting size to u64.
x86: fix simple Wsign-compare warnings
x86: unused parameters. Keep compiler happy.
x86: apic: Wsign-compare change to uint and update comparison check
accordingly
x86: iommu: Wshadow, fault_reporting_cpu is global
x86: cat: fix Wsign-compare
x86: vtd: fix Wsign-compare
hypervisor: introduce uptr_t (depending on the wordsize) and define
size_t accordingly
arm: Wunused-parameter: keep compiler happy
arm, arm-common: Wsign-compare: arm_dcaches_flush(): take unsigned
long as size
hypervisor: Wsign-compare: force the "right" promotion direction
x86: control, vcpu: force cast to prevent Wsign-compare
x86: bitops: only x86_64 is supported, avoid picking the wrong default
suffix
arm64: smmu: Wsign-compare: make iterator uint
arm64: smmu: fix double negative
hypervisor/Makefile | 4 ++++
hypervisor/arch/arm-common/gic-v2.c | 12 ++++++-----
hypervisor/arch/arm-common/gic-v3.c | 9 ++++----
.../arch/arm-common/include/asm/dcaches.h | 2 +-
hypervisor/arch/arm-common/include/asm/psci.h | 2 +-
hypervisor/arch/arm-common/irqchip.c | 4 ++--
hypervisor/arch/arm-common/lib.c | 2 +-
hypervisor/arch/arm-common/paging.c | 8 ++++---
hypervisor/arch/arm-common/pci.c | 13 ++++++++++++
hypervisor/arch/arm-common/psci.c | 4 ++--
hypervisor/arch/arm-common/uart-imx-lpuart.c | 1 +
hypervisor/arch/arm-common/uart-imx.c | 1 +
hypervisor/arch/arm-common/uart-mvebu.c | 1 +
hypervisor/arch/arm-common/uart-xuartps.c | 1 +
hypervisor/arch/arm/control.c | 2 +-
hypervisor/arch/arm/iommu.c | 5 +++++
hypervisor/arch/arm/mmio.c | 1 +
hypervisor/arch/arm/mmu_hyp.c | 4 ++--
hypervisor/arch/arm/traps.c | 2 ++
hypervisor/arch/arm64/mmio.c | 2 ++
hypervisor/arch/arm64/smmu-v3.c | 19 ++++++++++++-----
hypervisor/arch/arm64/smmu.c | 5 +++--
hypervisor/arch/arm64/ti-pvu.c | 2 +-
hypervisor/arch/arm64/traps.c | 1 +
hypervisor/arch/x86/amd_iommu.c | 14 +++++++++++++
hypervisor/arch/x86/apic.c | 4 ++--
hypervisor/arch/x86/cat.c | 3 ++-
hypervisor/arch/x86/control.c | 2 +-
hypervisor/arch/x86/include/asm/bitops.h | 2 +-
hypervisor/arch/x86/iommu.c | 2 +-
hypervisor/arch/x86/ivshmem.c | 2 ++
hypervisor/arch/x86/paging.c | 2 +-
hypervisor/arch/x86/setup.c | 1 +
hypervisor/arch/x86/svm.c | 2 +-
hypervisor/arch/x86/vcpu.c | 2 +-
hypervisor/arch/x86/vmx.c | 1 +
hypervisor/arch/x86/vtd.c | 11 +++++-----
hypervisor/control.c | 4 +++-
hypervisor/include/jailhouse/control.h | 5 +++--
hypervisor/include/jailhouse/globals.h | 21 +++++++++++++++++++
hypervisor/include/jailhouse/percpu.h | 3 +--
hypervisor/include/jailhouse/processor.h | 4 ++++
hypervisor/include/jailhouse/string.h | 10 +++++++--
hypervisor/include/jailhouse/types.h | 8 +++++++
hypervisor/include/jailhouse/unit.h | 2 +-
hypervisor/lib.c | 6 +++---
hypervisor/mmio.c | 2 +-
hypervisor/paging.c | 7 +++++--
hypervisor/pci.c | 8 ++++++-
hypervisor/printk.c | 6 +++---
hypervisor/setup.c | 7 +++----
51 files changed, 182 insertions(+), 66 deletions(-)
create mode 100644 hypervisor/include/jailhouse/globals.h
--
2.28.0
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/20201021145404.100463-1-andrea.bastoni%40tum.de.