From: Ben Dooks <ben.dooks@codethink.co.uk>
To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk,
roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [RFC 01/15] riscv: add initial kconfig and build flags for big-endian
Date: Fri, 20 Dec 2024 15:57:47 +0000 [thread overview]
Message-ID: <20241220155801.1988785-2-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk>
this is the initial kconfig and makefile updates to get a base
big-endian build for arch/riscv. Will require header updates
for IO code and features whcih are known to not work.
---
arch/riscv/Kconfig | 22 ++++++++++++++++++++++
arch/riscv/Makefile | 15 ++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index fa8f2da87a0a..e352e022ed4a 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -426,6 +426,28 @@ choice
bool "medium any code model"
endchoice
+choice
+ prompt "Data endian"
+ default CPU_LITTLE_ENDIAN
+ help
+ Configure the endiannes of data access performed by the CPU.
+ This will require system to be booted from M mode in big endian
+ and the userland to be compiled for the same endian-ness.
+
+config CPU_BIG_ENDIAN
+ bool "Build big-endian kernel"
+ depends on EXPERT
+ help
+ Say Y if you want to run big-endian kernel and userspace
+ Set for expert as this experimental
+
+config CPU_LITTLE_ENDIAN
+ bool "Build little-endian kernel (default)"
+ help
+ Say Y if you want to run little-endian kernel and userspace
+ This is the default for most distributions
+endchoice
+
config MODULE_SECTIONS
bool
select HAVE_MOD_ARCH_SPECIFIC
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index d469db9f46f4..535cbbb76f5c 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -21,6 +21,11 @@ else
endif
endif
+ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
+KBUILD_CPPFLAGS += -mbig-endian -D__RISCVEB__
+CHECKFLAGS += -D__RISCVEB__
+endif
+
ifeq ($(CONFIG_CMODEL_MEDLOW),y)
KBUILD_CFLAGS_MODULE += -mcmodel=medany
endif
@@ -28,13 +33,17 @@ endif
export BITS
ifeq ($(CONFIG_ARCH_RV64I),y)
BITS := 64
- UTS_MACHINE := riscv64
+ ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
+ UTS_MACHINE := riscv64_be
+ KBUILD_LDFLAGS += -melf64briscv
+ else
+ UTS_MACHINE := riscv64
+ KBUILD_LDFLAGS += -melf64lriscv
+ endif
KBUILD_CFLAGS += -mabi=lp64
KBUILD_AFLAGS += -mabi=lp64
- KBUILD_LDFLAGS += -melf64lriscv
-
KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 --target=riscv64imac-unknown-none-elf \
-Cno-redzone
else
--
2.37.2.352.g3c44437643
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-12-20 15:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 15:57 RFC: riscv64 big endian system attempt Ben Dooks
2024-12-20 15:57 ` Ben Dooks [this message]
2024-12-20 15:57 ` [RFC 02/15] add __RISCVEB__ to byteorder.h Ben Dooks
2024-12-20 15:57 ` [RFC 03/15] riscv: disable vector if big-endian, gcc unsupported option Ben Dooks
2024-12-20 15:57 ` [RFC 04/15] riscv: word-at-atime: move to generic if we're big endian Ben Dooks
2024-12-20 15:57 ` [RFC 05/15] riscv: asm: use .insn for making custom instructioons Ben Dooks
2024-12-20 15:57 ` [RFC 06/15] intiial header work Ben Dooks
2024-12-20 15:57 ` [RFC 07/15] kconfig: remove CONFIG_COMAPT for big-endian (compat cods doesn't build atm) Ben Dooks
2024-12-20 15:57 ` [RFC 08/15] defconfig: add our build config Ben Dooks
2024-12-20 15:57 ` [RFC 09/15] temp: remove various library optimisations Ben Dooks
2024-12-20 15:57 ` [RFC 10/15] riscv: fixup use of natural endian on instructions Ben Dooks
2024-12-20 15:57 ` [RFC 11/15] add todo on fpu Ben Dooks
2024-12-20 15:57 ` [RFC 12/15] riscv: bpf: big endian fixes, updated BPF_ALU ops Ben Dooks
2024-12-20 15:57 ` [RFC 13/15] riscv: probes: sort out endian-ness Ben Dooks
2024-12-20 15:58 ` [RFC 14/15] riscv: ftrace big endian updates Ben Dooks
2024-12-20 15:58 ` [RFC 15/15] riscv: traps: make insn fetch common in unknown instruction Ben Dooks
2024-12-20 19:53 ` RFC: riscv64 big endian system attempt Olof Johansson
2025-01-09 17:46 ` Palmer Dabbelt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241220155801.1988785-2-ben.dooks@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=felix.chong@codethink.co.uk \
--cc=lawrence.hunter@codethink.co.uk \
--cc=linux-riscv@lists.infradead.org \
--cc=roan.richmond@codethink.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox