Make sure the low two bits of stvec are always zero (since we don't use
authormiod <miod@openbsd.org>
Mon, 20 Nov 2023 16:10:37 +0000 (16:10 +0000)
committermiod <miod@openbsd.org>
Mon, 20 Nov 2023 16:10:37 +0000 (16:10 +0000)
vectored exceptions) by adding an alignment constraint to cpu_exception_handler.

sys/arch/riscv64/riscv64/exception.S

index 1fe16a3..c9eb9b3 100644 (file)
@@ -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 <br@bsdpad.com>
 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