Skip to content

Commit

Permalink
xtensa: add kernel ABI selection to Kconfig
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jcmvbkbc committed Mar 9, 2022
1 parent 19c5699 commit c20e111
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
35 changes: 35 additions & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ config CPU_BIG_ENDIAN
config CPU_LITTLE_ENDIAN
def_bool !CPU_BIG_ENDIAN

config CC_HAVE_CALL0_ABI
def_bool $(success,test "$(shell,echo __XTENSA_CALL0_ABI__ | $(CC) -mabi=call0 -E -P - 2>/dev/null)" = 1)

menu "Processor type and features"

choice
Expand Down Expand Up @@ -250,6 +253,38 @@ config FAST_SYSCALL_SPILL_REGISTERS

If unsure, say N.

choice
prompt "Kernel ABI"
default KERNEL_ABI_DEFAULT
help
Select ABI for the kernel code. This ABI is independent of the
supported userspace ABI and any combination of the
kernel/userspace ABI is possible and should work.

In case both kernel and userspace support only call0 ABI
all register windows support code will be omitted from the
build.

If unsure, choose the default ABI.

config KERNEL_ABI_DEFAULT
bool "Default ABI"
help
Select this option to compile kernel code with the default ABI
selected for the toolchain.
Normally cores with windowed registers option use windowed ABI and
cores without it use call0 ABI.

config KERNEL_ABI_CALL0
bool "Call0 ABI" if CC_HAVE_CALL0_ABI
help
Select this option to compile kernel code with call0 ABI even with
toolchain that defaults to windowed ABI.
When this option is not selected the default toolchain ABI will
be used for the kernel code.

endchoice

config USER_ABI_CALL0
bool

Expand Down
4 changes: 4 additions & 0 deletions arch/xtensa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ KBUILD_CFLAGS += -ffreestanding -D__linux__
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,)
KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,)
ifneq ($(CONFIG_KERNEL_ABI_CALL0),)
KBUILD_CFLAGS += -mabi=call0
KBUILD_AFLAGS += -mabi=call0
endif

KBUILD_AFLAGS += -mlongcalls -mtext-section-literals

Expand Down

0 comments on commit c20e111

Please sign in to comment.