aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarcos Oduardo <marcos.oduardo@gmail.com>2026-02-23 01:11:59 +0100
committerAnup Patel <anup@brainfault.org>2026-03-09 12:13:20 +0530
commit2727c43f8dcef9f6a0c3c117e30d00de145bde11 (patch)
treea5abaea0e3db3b0c9b763d3f113f930eaa90ebbe /include
parent3baca10015393359ec46a2500c8ebe7daa9672c6 (diff)
downloadopensbi-2727c43f8dcef9f6a0c3c117e30d00de145bde11.tar.gz
opensbi-2727c43f8dcef9f6a0c3c117e30d00de145bde11.tar.bz2
opensbi-2727c43f8dcef9f6a0c3c117e30d00de145bde11.zip
lib: sbi: Fix undefined behavior in signed shifts in sbi_hart.c
UBSan detected undefined behavior in sbi_hart.c and sbi_fwft.c (in the case of sbi_fwft.c, the bug comes from a macro call defined at sbi_ecall_interface.h) caused by shifting a signed integer into the sign bit (1 << 31) This can be fixed by using the 1UL literal, ensuring defined arithmetic. Please let me know if there’s any other most suitable solution for this bug. Signed-off-by: Marcos Oduardo <marcos.oduardo@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260223001202.284612-1-marcos.oduardo@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/sbi_ecall_interface.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h
index 76624e3f..9a776f79 100644
--- a/include/sbi/sbi_ecall_interface.h
+++ b/include/sbi/sbi_ecall_interface.h
@@ -144,7 +144,7 @@ enum sbi_fwft_feature_t {
SBI_FWFT_GLOBAL_PLATFORM_END = 0xffffffff,
};
-#define SBI_FWFT_GLOBAL_FEATURE_BIT (1 << 31)
+#define SBI_FWFT_GLOBAL_FEATURE_BIT (1UL << 31)
#define SBI_FWFT_PLATFORM_FEATURE_BIT (1 << 30)
#define SBI_FWFT_SET_FLAG_LOCK (1 << 0)