diff mbox series

arm64: vdso: Add -fasynchronous-unwind-tables to cflags

Message ID 20200428133411.44092-1-vincenzo.frascino@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: vdso: Add -fasynchronous-unwind-tables to cflags | expand

Commit Message

Vincenzo Frascino April 28, 2020, 1:34 p.m. UTC
On arm64 linux gcc uses -fasynchronous-unwind-tables -funwind-tables
by default since gcc-8, so now the de facto platform ABI is to allow
unwinding from async signal handlers.

However on bare metal targets (aarch64-none-elf), and on old gcc,
async and sync unwind tables are not enabled by default to avoid
runtime memory costs.

This means if linux is built with a baremetal toolchain the vdso.so
may not have unwind tables which breaks the gcc platform ABI guarantee
in userspace.

Add -fasynchronous-unwind-tables explicitly to the vgettimeofday.o
cflags to address the ABI change.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/kernel/vdso/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Will Deacon April 29, 2020, 2:54 p.m. UTC | #1
On Tue, Apr 28, 2020 at 02:34:11PM +0100, Vincenzo Frascino wrote:
> On arm64 linux gcc uses -fasynchronous-unwind-tables -funwind-tables
> by default since gcc-8, so now the de facto platform ABI is to allow
> unwinding from async signal handlers.
> 
> However on bare metal targets (aarch64-none-elf), and on old gcc,
> async and sync unwind tables are not enabled by default to avoid
> runtime memory costs.
> 
> This means if linux is built with a baremetal toolchain the vdso.so
> may not have unwind tables which breaks the gcc platform ABI guarantee
> in userspace.
> 
> Add -fasynchronous-unwind-tables explicitly to the vgettimeofday.o
> cflags to address the ABI change.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Reported-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/kernel/vdso/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
> index 331290a0cead..b388ce4c6d5f 100644
> --- a/arch/arm64/kernel/vdso/Makefile
> +++ b/arch/arm64/kernel/vdso/Makefile
> @@ -33,7 +33,8 @@ KCOV_INSTRUMENT			:= n
>  CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny
>  
>  ifneq ($(c-gettimeofday-y),)
> -  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
> +  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) \
> +				-fasynchronous-unwind-tables

Minor comment, but why is this inside the conditional block and not part
of the CFLAGS_vgettimeofday.o directly above it?

Anyway, Szabolcs -- please can you confirm this fixes the problem for you?

Thanks,

Will
Vincenzo Frascino April 29, 2020, 3:02 p.m. UTC | #2
On 4/29/20 3:54 PM, Will Deacon wrote:
> On Tue, Apr 28, 2020 at 02:34:11PM +0100, Vincenzo Frascino wrote:
>> On arm64 linux gcc uses -fasynchronous-unwind-tables -funwind-tables
>> by default since gcc-8, so now the de facto platform ABI is to allow
>> unwinding from async signal handlers.
>>
>> However on bare metal targets (aarch64-none-elf), and on old gcc,
>> async and sync unwind tables are not enabled by default to avoid
>> runtime memory costs.
>>
>> This means if linux is built with a baremetal toolchain the vdso.so
>> may not have unwind tables which breaks the gcc platform ABI guarantee
>> in userspace.
>>
>> Add -fasynchronous-unwind-tables explicitly to the vgettimeofday.o
>> cflags to address the ABI change.
>>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Reported-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/kernel/vdso/Makefile | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
>> index 331290a0cead..b388ce4c6d5f 100644
>> --- a/arch/arm64/kernel/vdso/Makefile
>> +++ b/arch/arm64/kernel/vdso/Makefile
>> @@ -33,7 +33,8 @@ KCOV_INSTRUMENT			:= n
>>  CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny
>>  
>>  ifneq ($(c-gettimeofday-y),)
>> -  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
>> +  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) \
>> +				-fasynchronous-unwind-tables
> 
> Minor comment, but why is this inside the conditional block and not part
> of the CFLAGS_vgettimeofday.o directly above it?
>

Because I rushed the patch out without rechecking it, sorry. Going to send v2.

> Anyway, Szabolcs -- please can you confirm this fixes the problem for you?
> 
> Thanks,
> 
> Will
>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index 331290a0cead..b388ce4c6d5f 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -33,7 +33,8 @@  KCOV_INSTRUMENT			:= n
 CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny
 
 ifneq ($(c-gettimeofday-y),)
-  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
+  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) \
+				-fasynchronous-unwind-tables
 endif
 
 # Clang versions less than 8 do not support -mcmodel=tiny