lib: sbi: Fix 32/64 bits variable compatibility
authorLiush <liush.damon@gmail.com>
Fri, 19 Jun 2020 03:55:19 +0000 (11:55 +0800)
committerAnup Patel <anup@brainfault.org>
Sat, 20 Jun 2020 03:17:11 +0000 (08:47 +0530)
commit9bd5f8f17d31f8989525643a04da87d090fe3033
tree1b5fd5df76e41be87991fbefdbda4d8f42796f12
parentdb56ef367cd6dc9dab94076f4c8a3fa9d91bd1f2
lib: sbi: Fix 32/64 bits variable compatibility

On RV64,"unsigned long" is 64bit and "unsigned int" is 32bit. So in
function "pmp_get" and "pmp_set", if "pmpcfg_shift >= 32", "0xff << pmpcfg_shift"
will go beyond "unsigned int" width. This patch tries to fix this issue.

In function 'pmp_get':
cfgmask = (0xff << pmpcfg_shift);
-->
cfgmask = (0xffUL << pmpcfg_shift);
In function 'pmp_set':
cfgmask = ~(0xff << pmpcfg_shift);
-->
cfgmask = ~(0xffUL << pmpcfg_shift);

Signed-off-by: Liush <liush.damon@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
lib/sbi/riscv_asm.c