Skip to content

Commit c20e111

Browse files
committed
xtensa: add kernel ABI selection to Kconfig
Add choice to use default or call0 ABI for the kernel code. If call0 ABI is chosen add '-mabi=call0' to the flags. The toolchain support for this option is rather new so only enable it when the compiler supports it. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent 19c5699 commit c20e111

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

arch/xtensa/Kconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ config CPU_BIG_ENDIAN
9292
config CPU_LITTLE_ENDIAN
9393
def_bool !CPU_BIG_ENDIAN
9494

95+
config CC_HAVE_CALL0_ABI
96+
def_bool $(success,test "$(shell,echo __XTENSA_CALL0_ABI__ | $(CC) -mabi=call0 -E -P - 2>/dev/null)" = 1)
97+
9598
menu "Processor type and features"
9699

97100
choice
@@ -250,6 +253,38 @@ config FAST_SYSCALL_SPILL_REGISTERS
250253

251254
If unsure, say N.
252255

256+
choice
257+
prompt "Kernel ABI"
258+
default KERNEL_ABI_DEFAULT
259+
help
260+
Select ABI for the kernel code. This ABI is independent of the
261+
supported userspace ABI and any combination of the
262+
kernel/userspace ABI is possible and should work.
263+
264+
In case both kernel and userspace support only call0 ABI
265+
all register windows support code will be omitted from the
266+
build.
267+
268+
If unsure, choose the default ABI.
269+
270+
config KERNEL_ABI_DEFAULT
271+
bool "Default ABI"
272+
help
273+
Select this option to compile kernel code with the default ABI
274+
selected for the toolchain.
275+
Normally cores with windowed registers option use windowed ABI and
276+
cores without it use call0 ABI.
277+
278+
config KERNEL_ABI_CALL0
279+
bool "Call0 ABI" if CC_HAVE_CALL0_ABI
280+
help
281+
Select this option to compile kernel code with call0 ABI even with
282+
toolchain that defaults to windowed ABI.
283+
When this option is not selected the default toolchain ABI will
284+
be used for the kernel code.
285+
286+
endchoice
287+
253288
config USER_ABI_CALL0
254289
bool
255290

arch/xtensa/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ KBUILD_CFLAGS += -ffreestanding -D__linux__
3535
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
3636
KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,)
3737
KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,)
38+
ifneq ($(CONFIG_KERNEL_ABI_CALL0),)
39+
KBUILD_CFLAGS += -mabi=call0
40+
KBUILD_AFLAGS += -mabi=call0
41+
endif
3842

3943
KBUILD_AFLAGS += -mlongcalls -mtext-section-literals
4044

0 commit comments

Comments
 (0)