@@ -213,7 +213,7 @@ config RISCV
select TRACE_IRQFLAGS_SUPPORT
select UACCESS_MEMCPY if !MMU
select USER_STACKTRACE_SUPPORT
- select ZONE_DMA32 if 64BIT
+ select ZONE_DMA32 if 64BIT && !ABI_RV64ILP32
config RUSTC_SUPPORTS_RISCV
def_bool y
@@ -298,6 +298,7 @@ config PAGE_OFFSET
config KASAN_SHADOW_OFFSET
hex
depends on KASAN_GENERIC
+ default 0x70000000 if ABI_RV64ILP32
default 0xdfffffff00000000 if 64BIT
default 0xffffffff if 32BIT
@@ -341,7 +342,7 @@ config FIX_EARLYCON_MEM
config ILLEGAL_POINTER_VALUE
hex
- default 0 if 32BIT
+ default 0 if 32BIT || ABI_RV64ILP32
default 0xdead000000000000 if 64BIT
config PGTABLE_LEVELS
@@ -418,6 +419,13 @@ config ARCH_RV64I
endchoice
+config ABI_RV64ILP32
+ bool "ABI RV64ILP32"
+ depends on 64BIT
+ help
+ Compile linux kernel self into RV64ILP32 ABI of RISC-V psabi
+ specification.
+
# We must be able to map all physical memory into the kernel, but the compiler
# is still a bit more efficient when generating code if it's setup in a manner
# such that it can only map 2GiB of memory.
@@ -30,10 +30,21 @@ ifeq ($(CONFIG_ARCH_RV64I),y)
BITS := 64
UTS_MACHINE := riscv64
+ifeq ($(CONFIG_ABI_RV64ILP32),y)
+ KBUILD_CPPFLAGS += -mabi=ilp32
+
+ KBUILD_CFLAGS += -mabi=ilp32
+ KBUILD_AFLAGS += -mabi=ilp32
+
+ KBUILD_LDFLAGS += -melf32lriscv
+else
+ KBUILD_CPPFLAGS += -mabi=lp64
+
KBUILD_CFLAGS += -mabi=lp64
KBUILD_AFLAGS += -mabi=lp64
KBUILD_LDFLAGS += -melf64lriscv
+endif
KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 --target=riscv64imac-unknown-none-elf \
-Cno-redzone
@@ -41,6 +52,8 @@ else
BITS := 32
UTS_MACHINE := riscv32
+ KBUILD_CPPFLAGS += -mabi=ilp32
+
KBUILD_CFLAGS += -mabi=ilp32
KBUILD_AFLAGS += -mabi=ilp32
KBUILD_LDFLAGS += -melf32lriscv
@@ -224,6 +237,10 @@ PHONY += rv32_nommu_virt_defconfig
rv32_nommu_virt_defconfig:
$(Q)$(MAKE) -f $(srctree)/Makefile nommu_virt_defconfig 32-bit.config
+PHONY += rv64ilp32_defconfig
+rv64ilp32_defconfig:
+ $(Q)$(MAKE) -f $(srctree)/Makefile defconfig rv64ilp32.config
+
define archhelp
echo ' Image - Uncompressed kernel image (arch/riscv/boot/Image)'
echo ' Image.gz - Compressed kernel image (arch/riscv/boot/Image.gz)'
new file mode 100644
@@ -0,0 +1 @@
+CONFIG_ABI_RV64ILP32=y