riscv: treat undefined exception codes as reserved
Undefined exception codes currently lead to an out-of-bounds array access. Prevent this by treating undefined exception codes as "reserved". Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Rick Chen <rick@andestech.com>
This commit is contained in:
		
							parent
							
								
									5a441736b7
								
							
						
					
					
						commit
						e8b522b1df
					
				|  | @ -81,6 +81,10 @@ static void _exit_trap(ulong code, ulong epc, struct pt_regs *regs) | ||||||
| 		"Store/AMO page fault", | 		"Store/AMO page fault", | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | 	if (code < ARRAY_SIZE(exception_code)) { | ||||||
| 		printf("exception code: %ld , %s , epc %lx , ra %lx\n", | 		printf("exception code: %ld , %s , epc %lx , ra %lx\n", | ||||||
| 		       code, exception_code[code], epc, regs->ra); | 		       code, exception_code[code], epc, regs->ra); | ||||||
|  | 	} else { | ||||||
|  | 		printf("Reserved\n"); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue