forked from Mirrors/opensbi
		
	lib: sbi_init: Don't allow HARTID greater than SBI_HARTMASK_MAX_BITS
We only allow HARTs with HARTID less than SBI_HARTMASK_MAX_BITS in sbi_init() function so that sbi_hartmask can safely used across OpenSBI sources. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -12,6 +12,7 @@
 | 
			
		||||
#include <sbi/sbi_console.h>
 | 
			
		||||
#include <sbi/sbi_ecall.h>
 | 
			
		||||
#include <sbi/sbi_hart.h>
 | 
			
		||||
#include <sbi/sbi_hartmask.h>
 | 
			
		||||
#include <sbi/sbi_hsm.h>
 | 
			
		||||
#include <sbi/sbi_ipi.h>
 | 
			
		||||
#include <sbi/sbi_platform.h>
 | 
			
		||||
@@ -215,7 +216,8 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
 | 
			
		||||
	u32 hartid			= sbi_current_hartid();
 | 
			
		||||
	const struct sbi_platform *plat = sbi_platform_ptr(scratch);
 | 
			
		||||
 | 
			
		||||
	if (sbi_platform_hart_disabled(plat, hartid))
 | 
			
		||||
	if ((SBI_HARTMASK_MAX_BITS <= hartid) ||
 | 
			
		||||
	    sbi_platform_hart_disabled(plat, hartid))
 | 
			
		||||
		sbi_hart_hang();
 | 
			
		||||
 | 
			
		||||
	if (atomic_add_return(&coldboot_lottery, 1) == 1)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user