From e33eb0e1210ee7344530b7456a8cc978ccff87e0 Mon Sep 17 00:00:00 2001 From: Andrew Lukoshko Date: Thu, 21 Aug 2025 15:29:01 +0000 Subject: [PATCH] Add RISC-V support by David Abdurachmanov --- config.yaml | 15 ++++++ files/0001-Add-support-for-riscv64.patch | 64 ++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 config.yaml create mode 100644 files/0001-Add-support-for-riscv64.patch diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..beeae4f --- /dev/null +++ b/config.yaml @@ -0,0 +1,15 @@ +actions: + - modify_release: + - suffix: ".alma.1" + enabled: true + + - changelog_entry: + - name: "Andrew Lukoshko" + email: "alukoshko@almalinux.org" + line: + - "Add RISC-V support by David Abdurachmanov " + + - add_files: + - type: "patch" + name: "0001-Add-support-for-riscv64.patch" + number: 1001 diff --git a/files/0001-Add-support-for-riscv64.patch b/files/0001-Add-support-for-riscv64.patch new file mode 100644 index 0000000..5696c25 --- /dev/null +++ b/files/0001-Add-support-for-riscv64.patch @@ -0,0 +1,64 @@ +From b42d1b1d3fb5447c2804b56ceb864e2c8b47d54a Mon Sep 17 00:00:00 2001 +From: David Abdurachmanov +Date: Sun, 20 Apr 2025 05:49:41 +0000 +Subject: [PATCH] Add support for riscv64 + +Signed-off-by: David Abdurachmanov +--- + Makefile | 11 ++++++++++- + src/stalld.h | 2 +- + 2 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 4585b6c..5d7259c 100644 +--- a/Makefile ++++ b/Makefile +@@ -33,6 +33,11 @@ ifeq ($(ARCH),powerpc) + USE_BPF := 0 + MTUNE := -mtune=powerpc + endif ++ifeq ($(ARCH),riscv64) ++FCF_PROTECTION := "-fcf-protection=none" ++M64 := ++MTUNE := -mtune=generic-ooo ++endif + + $(info USE_BPF=$(USE_BPF)) + $(info FCF_PROTECTION=$(FCF_PROTECTION)) +@@ -125,6 +130,10 @@ endif + ifeq ($(ARCH),s390x) + CLANGARCH=-D__s390x__ + endif ++ifeq ($(ARCH),riscv64) ++CLANGARCH="-D__riscv" ++CLANGFLAGS="-D__riscv_xlen=64" ++endif + + .PHONY: all tests + +@@ -145,7 +154,7 @@ bpf/vmlinux.h: + # The .bpf.c needs to be transformed into the .bpf.o. + # The .bpf.o is then required to build the .skel.h. + bpf/stalld.bpf.o: bpf/vmlinux.h bpf/stalld.bpf.c +- @$(CLANG) -g -O2 -target bpf $(CLANGARCH) -D__TARGET_ARCH_$(ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@ ++ @$(CLANG) -g -O2 -target bpf $(CLANGARCH) $(CLANGFLAGS) -D__TARGET_ARCH_$(ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@ + @$(LLVM_STRIP) -g $@ # strip useless DWARF info + + # This is the second step: The .bpf.o object is translated into +diff --git a/src/stalld.h b/src/stalld.h +index 0c4dcee..8d2f92f 100644 +--- a/src/stalld.h ++++ b/src/stalld.h +@@ -121,7 +121,7 @@ struct stalld_backend { + #elif __arm__ + # define __NR_sched_setattr 380 + # define __NR_sched_getattr 381 +-#elif __aarch64__ || __loongarch64 ++#elif __aarch64__ || __loongarch64 || __riscv + # define __NR_sched_setattr 274 + # define __NR_sched_getattr 275 + #elif __powerpc__ +-- +2.49.0 + +