Date: Wed, 5 Feb 2020 20:32:37 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357594 - head/sys/riscv/riscv Message-ID: <202002052032.015KWbpN001608@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Feb 5 20:32:37 2020 New Revision: 357594 URL: https://svnweb.freebsd.org/changeset/base/357594 Log: Use csr_read() to read sstatus instead of inline assembly. While here, remove a local variable to avoid the CSR read in non-debug kernels. Reviewed by: mhorne MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23511 Modified: head/sys/riscv/riscv/trap.c Modified: head/sys/riscv/riscv/trap.c ============================================================================== --- head/sys/riscv/riscv/trap.c Wed Feb 5 20:11:08 2020 (r357593) +++ head/sys/riscv/riscv/trap.c Wed Feb 5 20:32:37 2020 (r357594) @@ -245,12 +245,10 @@ void do_trap_supervisor(struct trapframe *frame) { uint64_t exception; - uint64_t sstatus; /* Ensure we came from supervisor mode, interrupts disabled */ - __asm __volatile("csrr %0, sstatus" : "=&r" (sstatus)); - KASSERT((sstatus & (SSTATUS_SPP | SSTATUS_SIE)) == SSTATUS_SPP, - ("We must came from S mode with interrupts disabled")); + KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == + SSTATUS_SPP, ("Came from S mode with interrupts enabled")); exception = (frame->tf_scause & EXCP_MASK); if (frame->tf_scause & EXCP_INTR) { @@ -305,7 +303,6 @@ do_trap_user(struct trapframe *frame) { uint64_t exception; struct thread *td; - uint64_t sstatus; struct pcb *pcb; td = curthread; @@ -313,9 +310,8 @@ do_trap_user(struct trapframe *frame) pcb = td->td_pcb; /* Ensure we came from usermode, interrupts disabled */ - __asm __volatile("csrr %0, sstatus" : "=&r" (sstatus)); - KASSERT((sstatus & (SSTATUS_SPP | SSTATUS_SIE)) == 0, - ("We must came from U mode with interrupts disabled")); + KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == 0, + ("Came from U mode with interrupts enabled")); exception = (frame->tf_scause & EXCP_MASK); if (frame->tf_scause & EXCP_INTR) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002052032.015KWbpN001608>