From 0f6296b86303a33577b09ef08e0a0e23296d6b0c Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 13 May 2021 06:44:11 +0000 Subject: [PATCH] When doing AST processing: 1) block interrupts, then check for ASTs 2) if no ASTs, return with interrupts blocked, so they can be re-enabled ATOMICALLY in the return to userspace 3) if an AST happened, then re-enable interrupts, call ast(), then goto 1 ok jsg@ --- sys/arch/riscv64/riscv64/exception.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/arch/riscv64/riscv64/exception.S b/sys/arch/riscv64/riscv64/exception.S index 316447f99aa..719f9ab9c8b 100644 --- a/sys/arch/riscv64/riscv64/exception.S +++ b/sys/arch/riscv64/riscv64/exception.S @@ -1,4 +1,4 @@ -/* $OpenBSD: exception.S,v 1.3 2021/05/10 05:58:20 jsg Exp $ */ +/* $OpenBSD: exception.S,v 1.4 2021/05/13 06:44:11 kettenis Exp $ */ /*- * Copyright (c) 2015-2018 Ruslan Bukin @@ -183,9 +183,8 @@ .endm .macro do_ast - /* Disable interrupts */ - csrr a4, sstatus 1: + /* Disable interrupts */ csrci sstatus, (SSTATUS_SIE) /* Check for astpending */ @@ -196,8 +195,8 @@ sw x0, P_ASTPENDING(a1) - /* Restore interrupts */ - csrw sstatus, a4 + /* Enable interrupts */ + csrsi sstatus, (SSTATUS_SIE) /* handle the ast */ mv a0, sp -- 2.20.1