|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 3/3] xen/arm: stack check instrumentation
Hi Stewart, On 29/07/2024 15:24, Stewart Hildebrand wrote: Use the -finstrument-functions option to check that the stack pointer is
Is the feature supported by both clang and GCC? If so, which from versions?
From README, this is what we currently support.
- For ARM 32-bit:
- GCC 4.9 or later
- GNU Binutils 2.24 or later
- For ARM 64-bit:
- GCC 5.1 or later
- GNU Binutils 2.24 or later
We don't mention Clang, but I would expect a clang from 4-5 years should
still be Arm (not cross-compile as we never fully added the support).
valid upon each function entry. Only enable it for debug builds due to the overhead introduced. How much overhead is it? We use debug builds during the dev cycle, so we need to make sure this is not noticeable. In any case, it would be better if this new option is under its own kconfig options. We can separately decide whether it is on or off by default when CONFIG_DEBUG=y. See above. I would consider to use ~0 because this is very unlikely to be used as an offset (at least on arm64). --- xen/arch/arm/arch.mk | 1 + xen/arch/arm/arm64/head.S | 4 +++ xen/arch/arm/domain.c | 3 +++ xen/arch/arm/include/asm/page.h | 2 ++ xen/arch/arm/include/asm/traps.h | 8 ++++++ xen/arch/arm/setup.c | 4 +++ xen/arch/arm/smpboot.c | 3 +++ xen/arch/arm/traps.c | 45 ++++++++++++++++++++++++++++++++ 8 files changed, 70 insertions(+) diff --git a/xen/arch/arm/arch.mk b/xen/arch/arm/arch.mk index 022dcda19224..c39cb65d183d 100644 --- a/xen/arch/arm/arch.mk +++ b/xen/arch/arm/arch.mk @@ -12,6 +12,7 @@ CFLAGS-$(CONFIG_ARM_32) += -mno-unaligned-access CFLAGS-$(CONFIG_ARM_64) += -mcpu=generic CFLAGS-$(CONFIG_ARM_64) += -mgeneral-regs-only # No fp registers etc $(call cc-option-add,CFLAGS-$(CONFIG_ARM_64),CC,-mno-outline-atomics) +CFLAGS-$(CONFIG_DEBUG) += -finstrument-functionsifneq ($(filter command line environment,$(origin CONFIG_EARLY_PRINTK)),) I would add a comment explaining what we are doing.
Loooking at the code below. Aside the stack pointer part, nothing seems specific to Arm. So maybe this could be moved to common code? +DEFINE_PER_CPU(unsigned int, stack_check_nesting); +DEFINE_PER_CPU(unsigned char *, stack_base); I think this could be "const unsigned char *" as the stack should not be modified directly. The top of the stack is used to store struct cpu_info. So you want to substract its size (see arch_vcpu_create()). Looking at the use, it only seems to be used as "print/panic once". So maybe use a bool to avoid any overflow. I would consider to call panic(). But is it safe to call any of this if we blew the stack? IOW, should we have a buffer? Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |