* [PATCH 0/2] OpenSBI LLVM related fixes @ 2024-12-10 4:16 Anup Patel 2024-12-10 4:16 ` [PATCH 1/2] lib: utils/fdt_cppc_rpmi: Fix compile error with LLVM Anup Patel 2024-12-10 4:16 ` [PATCH 2/2] Makefile: Don't enable V-extension using -march option Anup Patel 0 siblings, 2 replies; 10+ messages in thread From: Anup Patel @ 2024-12-10 4:16 UTC (permalink / raw) To: opensbi This series does few LLVM related fixes encountered using "Ubuntu clang version 18.1.3 (1ubuntu1)". These patches can also be found in the riscv_llvm_compile_fixes_v1 branch at: https://github.com/avpatel/opensbi.git Anup Patel (2): lib: utils/fdt_cppc_rpmi: Fix compile error with LLVM Makefile: Don't enable V-extension using -march option Makefile | 8 ++++---- lib/sbi/sbi_trap_v_ldst.c | 5 +++-- lib/utils/cppc/fdt_cppc_rpmi.c | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] lib: utils/fdt_cppc_rpmi: Fix compile error with LLVM 2024-12-10 4:16 [PATCH 0/2] OpenSBI LLVM related fixes Anup Patel @ 2024-12-10 4:16 ` Anup Patel 2024-12-10 4:16 ` [PATCH 2/2] Makefile: Don't enable V-extension using -march option Anup Patel 1 sibling, 0 replies; 10+ messages in thread From: Anup Patel @ 2024-12-10 4:16 UTC (permalink / raw) To: opensbi The following error is observed when compiling fdt_cppc_rpmi driver using LLVM: lib/utils/cppc/fdt_cppc_rpmi.c:87:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions] 87 | u64 db_val_u64 = 0; To fix the above issue, move the variable declaration at the start of function. Fixes: 591a98bdd549 ("lib: utils/cppc: Add RPMI CPPC driver") Signed-off-by: Anup Patel <apatel@ventanamicro.com> --- lib/utils/cppc/fdt_cppc_rpmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils/cppc/fdt_cppc_rpmi.c b/lib/utils/cppc/fdt_cppc_rpmi.c index 26e2d4f6..b6789901 100644 --- a/lib/utils/cppc/fdt_cppc_rpmi.c +++ b/lib/utils/cppc/fdt_cppc_rpmi.c @@ -59,6 +59,11 @@ static void rpmi_cppc_fc_db_trigger(struct rpmi_cppc *cppc) u8 db_val_u8 = 0; u16 db_val_u16 = 0; u32 db_val_u32 = 0; +#if __riscv_xlen != 32 + u64 db_val_u64 = 0; +#else + u32 db_val_u32_hi = 0; +#endif switch (cppc->fc_db_width) { case RPMI_CPPC_FAST_CHANNEL_DB_WIDTH_8: @@ -84,14 +89,12 @@ static void rpmi_cppc_fc_db_trigger(struct rpmi_cppc *cppc) break; case RPMI_CPPC_FAST_CHANNEL_DB_WIDTH_64: #if __riscv_xlen != 32 - u64 db_val_u64 = 0; db_val_u64 = readq((void *)cppc->fc_db_addr); db_val_u64 = cppc->fc_db_setmask | (db_val_u64 & cppc->fc_db_preservemask); writeq(db_val_u64, (void *)cppc->fc_db_addr); #else - u32 db_val_u32_hi = 0; db_val_u32 = readl((void *)cppc->fc_db_addr); db_val_u32_hi = readl((void *)(cppc->fc_db_addr + 4)); -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 4:16 [PATCH 0/2] OpenSBI LLVM related fixes Anup Patel 2024-12-10 4:16 ` [PATCH 1/2] lib: utils/fdt_cppc_rpmi: Fix compile error with LLVM Anup Patel @ 2024-12-10 4:16 ` Anup Patel 2024-12-10 5:05 ` Xiang W 2024-12-10 5:08 ` Jessica Clarke 1 sibling, 2 replies; 10+ messages in thread From: Anup Patel @ 2024-12-10 4:16 UTC (permalink / raw) To: opensbi Enabling V-extension using -march option causes OpenSBI boot-time hang with LLVM compiler. As a work-around, don't enable V-extension using -march option and instead use a custom OpenSBI specific define inform availability of V-extension to lib/sbi/sbi_trap_v_ldst.c. Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") Signed-off-by: Anup Patel <apatel@ventanamicro.com> --- Makefile | 8 ++++---- lib/sbi/sbi_trap_v_ldst.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 5ac95a0f..7e0a1399 100644 --- a/Makefile +++ b/Makefile @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) # Check whether the assembler and the compiler support the Vector extension -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q riscv.*vector && echo y || echo n) ifneq ($(OPENSBI_LD_PIE),y) $(error Your linker does not support creating PIEs, opensbi requires this.) @@ -298,9 +298,6 @@ endif ifndef PLATFORM_RISCV_ISA ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc - ifeq ($(CC_SUPPORT_VECT), y) - PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v - endif ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei endif @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls # Optionally supported flags +ifeq ($(CC_SUPPORT_VECT),y) +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize +endif ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) CFLAGS += -mno-save-restore endif diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c index 9929215c..75b79baa 100644 --- a/lib/sbi/sbi_trap_v_ldst.c +++ b/lib/sbi/sbi_trap_v_ldst.c @@ -17,7 +17,8 @@ #include <sbi/sbi_unpriv.h> #include <sbi/sbi_trap.h> -#ifdef __riscv_vector +#ifdef OPENSBI_CC_SUPPORT_VECT + #define VLEN_MAX 65536 static inline void set_vreg(ulong vlenb, ulong which, @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, { return 0; } -#endif /* __riscv_vector */ +#endif /* OPENSBI_CC_SUPPORT_VECT */ -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 4:16 ` [PATCH 2/2] Makefile: Don't enable V-extension using -march option Anup Patel @ 2024-12-10 5:05 ` Xiang W 2024-12-10 5:16 ` Anup Patel 2024-12-10 5:08 ` Jessica Clarke 1 sibling, 1 reply; 10+ messages in thread From: Xiang W @ 2024-12-10 5:05 UTC (permalink / raw) To: opensbi ? 2024-12-10?? 09:46 +0530?Anup Patel??? > Enabling V-extension using -march option causes OpenSBI boot-time > hang with LLVM compiler. > > As a work-around, don't enable V-extension using -march option and > instead use a custom OpenSBI specific define inform availability of > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > --- > ?Makefile????????????????? | 8 ++++---- > ?lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > ?2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/Makefile b/Makefile > index 5ac95a0f..7e0a1399 100644 > --- a/Makefile > +++ b/Makefile > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > ?CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c > /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > ? > ?# Check whether the assembler and the compiler support the Vector extension > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q > riscv.*vector && echo y || echo n) > ? > ?ifneq ($(OPENSBI_LD_PIE),y) > ?$(error Your linker does not support creating PIEs, opensbi requires this.) > @@ -298,9 +298,6 @@ endif > ?ifndef PLATFORM_RISCV_ISA > ?? ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > ???? PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > -??? ifeq ($(CC_SUPPORT_VECT), y) > -????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > -??? endif > ???? ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > ?????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > ???? endif > @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) > ?CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata- > sections > ?CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls > ?# Optionally supported flags > +ifeq ($(CC_SUPPORT_VECT),y) > +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize > +endif Suggest adding an else branch to add $(warning) to indicate that the toolchain needs to be updated. Regards, Xiang W > ?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) > ?CFLAGS += -mno-save-restore > ?endif > diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c > index 9929215c..75b79baa 100644 > --- a/lib/sbi/sbi_trap_v_ldst.c > +++ b/lib/sbi/sbi_trap_v_ldst.c > @@ -17,7 +17,8 @@ > ?#include <sbi/sbi_unpriv.h> > ?#include <sbi/sbi_trap.h> > ? > -#ifdef __riscv_vector > +#ifdef OPENSBI_CC_SUPPORT_VECT > + > ?#define VLEN_MAX 65536 > ? > ?static inline void set_vreg(ulong vlenb, ulong which, > @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, > ?{ > ? return 0; > ?} > -#endif /* __riscv_vector? */ > +#endif /* OPENSBI_CC_SUPPORT_VECT? */ > -- > 2.43.0 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 5:05 ` Xiang W @ 2024-12-10 5:16 ` Anup Patel 2024-12-11 2:41 ` Xiang W 0 siblings, 1 reply; 10+ messages in thread From: Anup Patel @ 2024-12-10 5:16 UTC (permalink / raw) To: opensbi On Tue, Dec 10, 2024 at 10:35?AM Xiang W <wxjstz@126.com> wrote: > > ? 2024-12-10?? 09:46 +0530?Anup Patel??? > > Enabling V-extension using -march option causes OpenSBI boot-time > > hang with LLVM compiler. > > > > As a work-around, don't enable V-extension using -march option and > > instead use a custom OpenSBI specific define inform availability of > > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > --- > > Makefile | 8 ++++---- > > lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index 5ac95a0f..7e0a1399 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > > CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c > > /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > > > > # Check whether the assembler and the compiler support the Vector extension > > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q > > riscv.*vector && echo y || echo n) > > > > ifneq ($(OPENSBI_LD_PIE),y) > > $(error Your linker does not support creating PIEs, opensbi requires this.) > > @@ -298,9 +298,6 @@ endif > > ifndef PLATFORM_RISCV_ISA > > ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > > PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > > - ifeq ($(CC_SUPPORT_VECT), y) > > - PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > > - endif > > ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > > PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > > endif > > @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) > > CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata- > > sections > > CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls > > # Optionally supported flags > > +ifeq ($(CC_SUPPORT_VECT),y) > > +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize > > +endif > Suggest adding an else branch to add $(warning) to indicate that the toolchain needs to be updated. I don't think such a warning is needed. The Linux kernel also does not warn about it. Regards, Anup > > Regards, > Xiang W > > ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) > > CFLAGS += -mno-save-restore > > endif > > diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c > > index 9929215c..75b79baa 100644 > > --- a/lib/sbi/sbi_trap_v_ldst.c > > +++ b/lib/sbi/sbi_trap_v_ldst.c > > @@ -17,7 +17,8 @@ > > #include <sbi/sbi_unpriv.h> > > #include <sbi/sbi_trap.h> > > > > -#ifdef __riscv_vector > > +#ifdef OPENSBI_CC_SUPPORT_VECT > > + > > #define VLEN_MAX 65536 > > > > static inline void set_vreg(ulong vlenb, ulong which, > > @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, > > { > > return 0; > > } > > -#endif /* __riscv_vector */ > > +#endif /* OPENSBI_CC_SUPPORT_VECT */ > > -- > > 2.43.0 > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 5:16 ` Anup Patel @ 2024-12-11 2:41 ` Xiang W 2024-12-11 2:58 ` Jessica Clarke 0 siblings, 1 reply; 10+ messages in thread From: Xiang W @ 2024-12-11 2:41 UTC (permalink / raw) To: opensbi ? 2024-12-10?? 10:46 +0530?Anup Patel??? > On Tue, Dec 10, 2024 at 10:35?AM Xiang W <wxjstz@126.com> wrote: > > > > ? 2024-12-10?? 09:46 +0530?Anup Patel??? > > > Enabling V-extension using -march option causes OpenSBI boot-time > > > hang with LLVM compiler. > > > > > > As a work-around, don't enable V-extension using -march option and > > > instead use a custom OpenSBI specific define inform availability of > > > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > > > > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > > --- > > > ?Makefile????????????????? | 8 ++++---- > > > ?lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > > > ?2 files changed, 7 insertions(+), 6 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 5ac95a0f..7e0a1399 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > > > ?CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c > > > /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > > > > > > ?# Check whether the assembler and the compiler support the Vector extension > > > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > > > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep > > > -q > > > riscv.*vector && echo y || echo n) > > > > > > ?ifneq ($(OPENSBI_LD_PIE),y) > > > ?$(error Your linker does not support creating PIEs, opensbi requires this.) > > > @@ -298,9 +298,6 @@ endif > > > ?ifndef PLATFORM_RISCV_ISA > > > ?? ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > > > ???? PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > > > -??? ifeq ($(CC_SUPPORT_VECT), y) > > > -????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > > > -??? endif > > > ???? ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > > > ?????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > > > ???? endif > > > @@ -363,6 +360,9 @@ GENFLAGS? +=????? $(firmware-genflags-y) > > > ?CFLAGS?????????????? =?????? -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections - > > > fdata- > > > sections > > > ?CFLAGS?????????????? +=????? -fno-omit-frame-pointer -fno-optimize-sibling-calls > > > ?# Optionally supported flags > > > +ifeq ($(CC_SUPPORT_VECT),y) > > > +CFLAGS?????????????? +=????? -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize > > > +endif > > Suggest adding an else branch to add $(warning) to indicate that the toolchain needs to be updated. > > I don't think such a warning is needed. The Linux kernel also does not > warn about it. If the warning is not added to the makefile, it can only be used to generateOPENSBI_CC_SUPPORT_VECT macros in place of the __riscv_vector macros, which only adds to the complexity. It is recommended to remove the detection of the v extension from the makefile and revert to using __riscv_vector in? sbi_trap_v_ldst.c. Regards, Xiang W > > Regards, > Anup > > > > > Regards, > > Xiang W > > > ?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) > > > ?CFLAGS?????????????? +=????? -mno-save-restore > > > ?endif > > > diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c > > > index 9929215c..75b79baa 100644 > > > --- a/lib/sbi/sbi_trap_v_ldst.c > > > +++ b/lib/sbi/sbi_trap_v_ldst.c > > > @@ -17,7 +17,8 @@ > > > ?#include <sbi/sbi_unpriv.h> > > > ?#include <sbi/sbi_trap.h> > > > > > > -#ifdef __riscv_vector > > > +#ifdef OPENSBI_CC_SUPPORT_VECT > > > + > > > ?#define VLEN_MAX 65536 > > > > > > ?static inline void set_vreg(ulong vlenb, ulong which, > > > @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, > > > ?{ > > > ????? return 0; > > > ?} > > > -#endif /* __riscv_vector? */ > > > +#endif /* OPENSBI_CC_SUPPORT_VECT? */ > > > -- > > > 2.43.0 > > > > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-11 2:41 ` Xiang W @ 2024-12-11 2:58 ` Jessica Clarke 2024-12-11 3:25 ` Xiang W 0 siblings, 1 reply; 10+ messages in thread From: Jessica Clarke @ 2024-12-11 2:58 UTC (permalink / raw) To: opensbi On 11 Dec 2024, at 02:41, Xiang W <wxjstz@126.com> wrote: > > ? 2024-12-10?? 10:46 +0530?Anup Patel??? >> On Tue, Dec 10, 2024 at 10:35?AM Xiang W <wxjstz@126.com> wrote: >>> >>> ? 2024-12-10?? 09:46 +0530?Anup Patel??? >>>> Enabling V-extension using -march option causes OpenSBI boot-time >>>> hang with LLVM compiler. >>>> >>>> As a work-around, don't enable V-extension using -march option and >>>> instead use a custom OpenSBI specific define inform availability of >>>> V-extension to lib/sbi/sbi_trap_v_ldst.c. >>>> >>>> Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") >>>> Signed-off-by: Anup Patel <apatel@ventanamicro.com> >>>> --- >>>> Makefile | 8 ++++---- >>>> lib/sbi/sbi_trap_v_ldst.c | 5 +++-- >>>> 2 files changed, 7 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/Makefile b/Makefile >>>> index 5ac95a0f..7e0a1399 100644 >>>> --- a/Makefile >>>> +++ b/Makefile >>>> @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib >>>> CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c >>>> /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) >>>> >>>> # Check whether the assembler and the compiler support the Vector extension >>>> -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) >>>> +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep >>>> -q >>>> riscv.*vector && echo y || echo n) >>>> >>>> ifneq ($(OPENSBI_LD_PIE),y) >>>> $(error Your linker does not support creating PIEs, opensbi requires this.) >>>> @@ -298,9 +298,6 @@ endif >>>> ifndef PLATFORM_RISCV_ISA >>>> ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) >>>> PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc >>>> - ifeq ($(CC_SUPPORT_VECT), y) >>>> - PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v >>>> - endif >>>> ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) >>>> PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei >>>> endif >>>> @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) >>>> CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections - >>>> fdata- >>>> sections >>>> CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls >>>> # Optionally supported flags >>>> +ifeq ($(CC_SUPPORT_VECT),y) >>>> +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize >>>> +endif >>> Suggest adding an else branch to add $(warning) to indicate that the toolchain needs to be updated. >> >> I don't think such a warning is needed. The Linux kernel also does not >> warn about it. > If the warning is not added to the makefile, it can only be used to generateOPENSBI_CC_SUPPORT_VECT macros in place of the __riscv_vector macros, which > only adds to the complexity. It is recommended to remove the detection of the > v extension from the makefile and revert to using __riscv_vector in > sbi_trap_v_ldst.c. Without V enabled you won?t get __riscv_vector defined. Enabling V outside of code that?s explicitly expecting to use vectors is wrong, as discussed before. Defining __riscv_vector manually would also be wrong, and could break compiler headers. The only correct approach is to have a different macro defined, with V not in the default -march. Jess > Regards, > Xiang W >> >> Regards, >> Anup >> >>> >>> Regards, >>> Xiang W >>>> ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) >>>> CFLAGS += -mno-save-restore >>>> endif >>>> diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c >>>> index 9929215c..75b79baa 100644 >>>> --- a/lib/sbi/sbi_trap_v_ldst.c >>>> +++ b/lib/sbi/sbi_trap_v_ldst.c >>>> @@ -17,7 +17,8 @@ >>>> #include <sbi/sbi_unpriv.h> >>>> #include <sbi/sbi_trap.h> >>>> >>>> -#ifdef __riscv_vector >>>> +#ifdef OPENSBI_CC_SUPPORT_VECT >>>> + >>>> #define VLEN_MAX 65536 >>>> >>>> static inline void set_vreg(ulong vlenb, ulong which, >>>> @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, >>>> { >>>> return 0; >>>> } >>>> -#endif /* __riscv_vector */ >>>> +#endif /* OPENSBI_CC_SUPPORT_VECT */ >>>> -- >>>> 2.43.0 >>>> >>>> >>> > > > > -- > opensbi mailing list > opensbi at lists.infradead.org > http://lists.infradead.org/mailman/listinfo/opensbi ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-11 2:58 ` Jessica Clarke @ 2024-12-11 3:25 ` Xiang W 0 siblings, 0 replies; 10+ messages in thread From: Xiang W @ 2024-12-11 3:25 UTC (permalink / raw) To: opensbi ? 2024-12-11?? 02:58 +0000?Jessica Clarke??? > On 11 Dec 2024, at 02:41, Xiang W <wxjstz@126.com> wrote: > > > > ? 2024-12-10?? 10:46 +0530?Anup Patel??? > > > On Tue, Dec 10, 2024 at 10:35?AM Xiang W <wxjstz@126.com> wrote: > > > > > > > > ? 2024-12-10?? 09:46 +0530?Anup Patel??? > > > > > Enabling V-extension using -march option causes OpenSBI boot-time > > > > > hang with LLVM compiler. > > > > > > > > > > As a work-around, don't enable V-extension using -march option and > > > > > instead use a custom OpenSBI specific define inform availability of > > > > > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > > > > > > > > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > > > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > > > > --- > > > > > ?Makefile????????????????? | 8 ++++---- > > > > > ?lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > > > > > ?2 files changed, 7 insertions(+), 6 deletions(-) > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > index 5ac95a0f..7e0a1399 100644 > > > > > --- a/Makefile > > > > > +++ b/Makefile > > > > > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > > > > > ?CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x > > > > > c > > > > > /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > > > > > > > > > > ?# Check whether the assembler and the compiler support the Vector extension > > > > > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > > > > > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | > > > > > grep > > > > > -q > > > > > riscv.*vector && echo y || echo n) > > > > > > > > > > ?ifneq ($(OPENSBI_LD_PIE),y) > > > > > ?$(error Your linker does not support creating PIEs, opensbi requires this.) > > > > > @@ -298,9 +298,6 @@ endif > > > > > ?ifndef PLATFORM_RISCV_ISA > > > > > ?? ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > > > > > ???? PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > > > > > -??? ifeq ($(CC_SUPPORT_VECT), y) > > > > > -????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > > > > > -??? endif > > > > > ???? ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > > > > > ?????? PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > > > > > ???? endif > > > > > @@ -363,6 +360,9 @@ GENFLAGS? +=????? $(firmware-genflags-y) > > > > > ?CFLAGS?????????????? =?????? -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections > > > > > - > > > > > fdata- > > > > > sections > > > > > ?CFLAGS?????????????? +=????? -fno-omit-frame-pointer -fno-optimize-sibling-calls > > > > > ?# Optionally supported flags > > > > > +ifeq ($(CC_SUPPORT_VECT),y) > > > > > +CFLAGS?????????????? +=????? -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize > > > > > +endif > > > > Suggest adding an else branch to add $(warning) to indicate that the toolchain needs to be updated. > > > > > > I don't think such a warning is needed. The Linux kernel also does not > > > warn about it. > > If the warning is not added to the makefile, it can only be used to generateOPENSBI_CC_SUPPORT_VECT macros in place of the __riscv_vector > > macros, which > > only adds to the complexity. It is recommended to remove the detection of the > > v extension from the makefile and revert to using __riscv_vector in > > sbi_trap_v_ldst.c. > > Without V enabled you won?t get __riscv_vector defined. Enabling V > outside of code that?s explicitly expecting to use vectors is wrong, as > discussed before. Defining __riscv_vector manually would also be wrong, > and could break compiler headers. The only correct approach is to have > a different macro defined, with V not in the default -march. > Thank for the reply Regards, Xiang W > Jess > > > Xiang W > > > > > > Regards, > > > Anup > > > > > > > > > > > Regards, > > > > Xiang W > > > > > ?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) > > > > > ?CFLAGS?????????????? +=????? -mno-save-restore > > > > > ?endif > > > > > diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c > > > > > index 9929215c..75b79baa 100644 > > > > > --- a/lib/sbi/sbi_trap_v_ldst.c > > > > > +++ b/lib/sbi/sbi_trap_v_ldst.c > > > > > @@ -17,7 +17,8 @@ > > > > > ?#include <sbi/sbi_unpriv.h> > > > > > ?#include <sbi/sbi_trap.h> > > > > > > > > > > -#ifdef __riscv_vector > > > > > +#ifdef OPENSBI_CC_SUPPORT_VECT > > > > > + > > > > > ?#define VLEN_MAX 65536 > > > > > > > > > > ?static inline void set_vreg(ulong vlenb, ulong which, > > > > > @@ -340,4 +341,4 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, > > > > > ?{ > > > > > ????? return 0; > > > > > ?} > > > > > -#endif /* __riscv_vector? */ > > > > > +#endif /* OPENSBI_CC_SUPPORT_VECT? */ > > > > > -- > > > > > 2.43.0 > > > > > > > > > > > > > > > > > > > > > > -- > > opensbi mailing list > > opensbi at lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/opensbi > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 4:16 ` [PATCH 2/2] Makefile: Don't enable V-extension using -march option Anup Patel 2024-12-10 5:05 ` Xiang W @ 2024-12-10 5:08 ` Jessica Clarke 2024-12-10 5:17 ` Anup Patel 1 sibling, 1 reply; 10+ messages in thread From: Jessica Clarke @ 2024-12-10 5:08 UTC (permalink / raw) To: opensbi On 10 Dec 2024, at 04:16, Anup Patel <apatel@ventanamicro.com> wrote: > > Enabling V-extension using -march option causes OpenSBI boot-time > hang with LLVM compiler. > > As a work-around, don't enable V-extension using -march option and > instead use a custom OpenSBI specific define inform availability of > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > --- > Makefile | 8 ++++---- > lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/Makefile b/Makefile > index 5ac95a0f..7e0a1399 100644 > --- a/Makefile > +++ b/Makefile > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > > # Check whether the assembler and the compiler support the Vector extension > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q riscv.*vector && echo y || echo n) > > ifneq ($(OPENSBI_LD_PIE),y) > $(error Your linker does not support creating PIEs, opensbi requires this.) > @@ -298,9 +298,6 @@ endif > ifndef PLATFORM_RISCV_ISA > ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > - ifeq ($(CC_SUPPORT_VECT), y) > - PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > - endif > ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > endif > @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) > CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections > CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls > # Optionally supported flags > +ifeq ($(CC_SUPPORT_VECT),y) > +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize The latter isn?t needed now you don?t enable V. Clang ignores it, even, it?s a flag that?s tied to GCC?s internals. Jess ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Makefile: Don't enable V-extension using -march option 2024-12-10 5:08 ` Jessica Clarke @ 2024-12-10 5:17 ` Anup Patel 0 siblings, 0 replies; 10+ messages in thread From: Anup Patel @ 2024-12-10 5:17 UTC (permalink / raw) To: opensbi On Tue, Dec 10, 2024 at 10:38?AM Jessica Clarke <jrtc27@jrtc27.com> wrote: > > On 10 Dec 2024, at 04:16, Anup Patel <apatel@ventanamicro.com> wrote: > > > > Enabling V-extension using -march option causes OpenSBI boot-time > > hang with LLVM compiler. > > > > As a work-around, don't enable V-extension using -march option and > > instead use a custom OpenSBI specific define inform availability of > > V-extension to lib/sbi/sbi_trap_v_ldst.c. > > > > Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > --- > > Makefile | 8 ++++---- > > lib/sbi/sbi_trap_v_ldst.c | 5 +++-- > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index 5ac95a0f..7e0a1399 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -190,7 +190,7 @@ CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib > > CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y) > > > > # Check whether the assembler and the compiler support the Vector extension > > -CC_SUPPORT_VECT := $(shell echo | $(CC) -dM -E -march=rv$(OPENSBI_CC_XLEN)gv - | grep -q riscv.*vector && echo y || echo n) > > +CC_SUPPORT_VECT := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q riscv.*vector && echo y || echo n) > > > > ifneq ($(OPENSBI_LD_PIE),y) > > $(error Your linker does not support creating PIEs, opensbi requires this.) > > @@ -298,9 +298,6 @@ endif > > ifndef PLATFORM_RISCV_ISA > > ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) > > PLATFORM_RISCV_ISA := rv$(PLATFORM_RISCV_XLEN)imafdc > > - ifeq ($(CC_SUPPORT_VECT), y) > > - PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)v > > - endif > > ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y) > > PLATFORM_RISCV_ISA := $(PLATFORM_RISCV_ISA)_zicsr_zifencei > > endif > > @@ -363,6 +360,9 @@ GENFLAGS += $(firmware-genflags-y) > > CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections > > CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls > > # Optionally supported flags > > +ifeq ($(CC_SUPPORT_VECT),y) > > +CFLAGS += -DOPENSBI_CC_SUPPORT_VECT -fno-tree-vectorize > > The latter isn?t needed now you don?t enable V. Clang ignores it, even, > it?s a flag that?s tied to GCC?s internals. > It's a left-over from an alternate patch which I was working on. I will drop this option in the next revision. Regards, Anup ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-12-11 3:25 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-10 4:16 [PATCH 0/2] OpenSBI LLVM related fixes Anup Patel 2024-12-10 4:16 ` [PATCH 1/2] lib: utils/fdt_cppc_rpmi: Fix compile error with LLVM Anup Patel 2024-12-10 4:16 ` [PATCH 2/2] Makefile: Don't enable V-extension using -march option Anup Patel 2024-12-10 5:05 ` Xiang W 2024-12-10 5:16 ` Anup Patel 2024-12-11 2:41 ` Xiang W 2024-12-11 2:58 ` Jessica Clarke 2024-12-11 3:25 ` Xiang W 2024-12-10 5:08 ` Jessica Clarke 2024-12-10 5:17 ` Anup Patel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox