Enable UBSAN on ppc
v2 cover Enable UBSAN on ppc
Extend Andrew's UBSAN enablement work to ppc.
Changes in v2:
- Drop opal.c unaligned access patch
- Enable -fno-sanitize=alignment like x86 does
Andrew Cooper (1):
PPC: Activate UBSAN in testing
automation/gitlab-ci/build.yaml | 3 +++ xen/arch/ppc/Kconfig | 1 + xen/arch/ppc/arch.mk | 6 ++++++ xen/arch/ppc/include/asm/processor.h | 2 ++ xen/arch/ppc/stubs.c | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-)
--
2.30.2
PATCH v2 1/1 PPC: Activate UBSAN in testing
From: Andrew Cooper <[email protected]>
Also enable -fno-sanitize=alignment like x86 since support for unaligned accesses is guaranteed by the ISA and the existing OPAL setup code relies on it.
---
Changes in v2:
- Add -fno-sanitize=alignment flag per discussion in v1
automation/gitlab-ci/build.yaml | 3 +++ xen/arch/ppc/Kconfig | 1 + xen/arch/ppc/arch.mk | 6 ++++++ xen/arch/ppc/include/asm/processor.h | 2 ++ xen/arch/ppc/stubs.c | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-)
automation/gitlab-ci/build.yaml +3 -0
@@ -352,6 +352,9 @@ debian-12-ppc64le-gcc-debug: CONTAINER: debian:12-ppc64le KBUILD_DEFCONFIG: ppc64_defconfig HYPERVISOR_ONLY: y + EXTRA_XEN_CONFIG: | + CONFIG_UBSAN=y + CONFIG_UBSAN_FATAL=y debian-12-riscv64-gcc-debug: extends: .gcc-riscv64-cross-build-debug
xen/arch/ppc/Kconfig +1 -0
@@ -2,6 +2,7 @@ config PPC def_bool y select FUNCTION_ALIGNMENT_4B select HAS_DEVICE_TREE + select HAS_UBSAN select HAS_VMAP config PPC64
xen/arch/ppc/arch.mk +6 -0
@@ -7,3 +7,9 @@ CFLAGS += -m64 -mlittle-endian -mcpu=$(ppc-march-y) CFLAGS += -mstrict-align -mcmodel=medium -mabi=elfv2 -fPIC -mno-altivec -mno-vsx -msoft-float LDFLAGS += -m elf64lppc + +ifeq ($(CONFIG_UBSAN),y) +# Don't enable alignment sanitisation since Power ISA guarantees hardware +# support for unaligned accesses. +$(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment) +endif
xen/arch/ppc/include/asm/processor.h +2 -0
@@ -219,6 +219,8 @@ static inline void noreturn die(void)*/ #define cpu_relax () asm volatile ( "or %r1, %r1, %r1; or %r2, %r2, %r2" ) +#define dump_execution_state () run_in_exception_handler(show_execution_state) +#endif /* __ASSEMBLY__ */ #endif /* _ASM_PPC_PROCESSOR_H */
xen/arch/ppc/stubs.c +1 -1
@@ -47,7 +47,7 @@ void send_timer_event(struct vcpu *v)void show_execution_state (const struct cpu_user_regs *regs) { -BUG_ON ("unimplemented" ); +printk ("TODO: Implement show_execution_state(regs)\n" ); }void arch_hypercall_tasklet_result (struct vcpu *v,long res)
--
2.30.2
Re: [PATCH v2 1/1] PPC: Activate UBSAN in testing
Quoted 8 lines · Shawn Anastasio
From: Andrew Cooper <[email protected]>
Also enable -fno-sanitize=alignment like x86 since support for unaligned accesses is guaranteed by the ISA and the existing OPAL setup code relies on it.
Signed-off-by Andrew Cooper <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>
Re: [PATCH v2 1/1] PPC: Activate UBSAN in testing (for 4.20?)
Quoted 10 lines · Jan Beulich
Quoted 8 lines · Shawn Anastasio
From: Andrew Cooper <[email protected]>
Also enable -fno-sanitize=alignment like x86 since support for unaligned accesses is guaranteed by the ISA and the existing OPAL setup code relies on it.
Signed-off-by Andrew Cooper <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>Acked-by Jan Beulich <[email protected]>
Thanks. I've committed this.
Oleksii, seeing as how simple it ended up, and seeing as how you're currently writing the release notes for 4.20 while excluding PPC from the list...
Views on this sneaking in at the last moment?
~Andrew
Re: [PATCH v2 1/1] PPC: Activate UBSAN in testing (for 4.20?)
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Shawn Anastasio
From: Andrew Cooper<[email protected]>
Also enable -fno-sanitize=alignment like x86 since support for unaligned accesses is guaranteed by the ISA and the existing OPAL setup code relies on it.
Signed-off-by Andrew Cooper<[email protected]>Signed-off-by Shawn Anastasio<[email protected]>
Quoted 8 lines
Quoted 1 line
Acked-by Jan Beulich<[email protected]>Thanks. I've committed this.
Oleksii, seeing as how simple it ended up, and seeing as how you're currently writing the release notes for 4.20 while excluding PPC from the list...
Views on this sneaking in at the last moment?
As it touches only PPC part, then I am okay to have it in 4.20:
I'll update release notes too then.
Thanks.
~ Oleksii