From f03cce2a7dce1ef3e80716902f3eadde9117ad73 Mon Sep 17 00:00:00 2001 From: miod Date: Mon, 20 Nov 2023 16:10:37 +0000 Subject: [PATCH] Make sure the low two bits of stvec are always zero (since we don't use vectored exceptions) by adding an alignment constraint to cpu_exception_handler. --- sys/arch/riscv64/riscv64/exception.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/arch/riscv64/riscv64/exception.S b/sys/arch/riscv64/riscv64/exception.S index 1fe16a33c4d..c9eb9b3467c 100644 --- a/sys/arch/riscv64/riscv64/exception.S +++ b/sys/arch/riscv64/riscv64/exception.S @@ -1,4 +1,4 @@ -/* $OpenBSD: exception.S,v 1.6 2022/12/02 12:27:08 jca Exp $ */ +/* $OpenBSD: exception.S,v 1.7 2023/11/20 16:10:37 miod Exp $ */ /*- * Copyright (c) 2015-2018 Ruslan Bukin @@ -208,6 +208,12 @@ 2: .endm + /* + * cpu_exception_handler needs to be aligned to a 32-bit + * boundary, but ENTRY() only enforces 16-bit alignment. + */ + .text + .p2align 2 ENTRY(cpu_exception_handler) csrrw sp, sscratch, sp beqz sp, 1f -- 2.20.1