From: Xiang W Date: Thu, 24 Nov 2022 03:16:05 +0000 (+0800) Subject: lib: sbi: Fix is_region_valid() X-Git-Tag: v1.3~194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc82e84329760540ec62b257c700025ba37cb7ab;p=platform%2Fkernel%2Fopensbi-spacemit.git lib: sbi: Fix is_region_valid() When order is equal to __riscv_xlen, the shift operation will not perform any operation, which will cause reg->base & (BIT(reg->order) - 1) to always be 0, and the condition has not been established. This patch fixes this bug. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index fec9074..3302213 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -146,6 +146,9 @@ static bool is_region_valid(const struct sbi_domain_memregion *reg) if (reg->order < 3 || __riscv_xlen < reg->order) return FALSE; + if (reg->order == __riscv_xlen && reg->base != 0) + return FALSE; + if (reg->base & (BIT(reg->order) - 1)) return FALSE;