From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:53:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 773FB66746D; Thu, 12 Aug 2021 08:53:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlgSx2LRsz4Sfy; Thu, 12 Aug 2021 08:53:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F3C562010F; Thu, 12 Aug 2021 08:53:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17C8rKS7063582; Thu, 12 Aug 2021 08:53:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8rKkD063581; Thu, 12 Aug 2021 08:53:20 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:53:20 GMT Message-Id: <202108120853.17C8rKkD063581@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 17b6ee961382 - main - Enable arm64 SError exceptions in the kernel MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17b6ee96138220a164d632f0be69d3df77bdd61a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:53:21 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=17b6ee96138220a164d632f0be69d3df77bdd61a commit 17b6ee96138220a164d632f0be69d3df77bdd61a Author: Andrew Turner AuthorDate: 2021-08-09 16:30:44 +0000 Commit: Andrew Turner CommitDate: 2021-08-12 08:53:06 +0000 Enable arm64 SError exceptions in the kernel These are needed to signal to the kernel when a Reliability, Availability, and Serviceability (RAS) exception has triggered. Reviewed by: mhorne Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31477 --- sys/arm64/arm64/exception.S | 24 ++++++++++++++---------- sys/arm64/arm64/machdep.c | 6 ++++++ sys/arm64/arm64/vm_machdep.c | 4 ++-- sys/arm64/include/armreg.h | 8 ++------ sys/arm64/include/cpufunc.h | 7 +++++++ 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S index 67233daf4442..413b9523eb06 100644 --- a/sys/arm64/arm64/exception.S +++ b/sys/arm64/arm64/exception.S @@ -75,23 +75,25 @@ __FBSDID("$FreeBSD$"); ldr x0, [x18, #(PC_CURTHREAD)] bl dbg_monitor_enter - msr daifclr, #DAIF_D /* Enable the debug exception */ -.endif + + /* Unmask debug and SError exceptions */ + msr daifclr, #(DAIF_D | DAIF_A) +.else /* + * Unmask debug and SError exceptions. * For EL1, debug exceptions are conditionally unmasked in * do_el1h_sync(). */ + msr daifclr, #(DAIF_A) +.endif .endm .macro restore_registers el -.if \el == 1 /* - * Disable interrupts and debug exceptions, x18 may change in the - * interrupt exception handler. For EL0 exceptions, do_ast already - * did this. + * Mask all exceptions, x18 may change in the interrupt exception + * handler. */ - msr daifset, #(DAIF_D | DAIF_INTR) -.endif + msr daifset, #(DAIF_ALL) .if \el == 0 ldr x0, [x18, #PC_CURTHREAD] mov x1, sp @@ -147,8 +149,10 @@ __FBSDID("$FreeBSD$"); /* Make sure the IRQs are enabled before calling ast() */ bic x19, x19, #PSR_I 1: - /* Disable interrupts */ - msr daifset, #(DAIF_D | DAIF_INTR) + /* + * Mask interrupts while checking the ast pending flag + */ + msr daifset, #(DAIF_INTR) /* Read the current thread flags */ ldr x1, [x18, #PC_CURTHREAD] /* Load curthread */ diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index be9bddf23062..bce3baf8e1ec 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -931,6 +931,12 @@ init_proc0(vm_offset_t kstack) thread0.td_pcb->pcb_vfpcpu = UINT_MAX; thread0.td_frame = &proc0_tf; pcpup->pc_curpcb = thread0.td_pcb; + + /* + * Unmask SError exceptions. They are used to signal a RAS failure, + * or other hardware error. + */ + serror_enable(); } typedef struct { diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index a7b02e98959f..bf7641074317 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -112,7 +112,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) /* Setup to release spin count in fork_exit(). */ td2->td_md.md_spinlock_count = 1; - td2->td_md.md_saved_daif = td1->td_md.md_saved_daif & ~DAIF_I_MASKED; + td2->td_md.md_saved_daif = PSR_DAIF_DEFAULT; } void @@ -186,7 +186,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0) /* Setup to release spin count in fork_exit(). */ td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_daif = td0->td_md.md_saved_daif & ~DAIF_I_MASKED; + td->td_md.md_saved_daif = PSR_DAIF_DEFAULT; } /* diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 8c7c535e4277..bc6d34cb3c1a 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -124,12 +124,6 @@ #define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK) #define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT)) -/* DAIF - Interrupt Mask Bits */ -#define DAIF_D_MASKED (1 << 9) -#define DAIF_A_MASKED (1 << 8) -#define DAIF_I_MASKED (1 << 7) -#define DAIF_F_MASKED (1 << 6) - /* DAIFSet/DAIFClear */ #define DAIF_D (1 << 3) #define DAIF_A (1 << 2) @@ -1078,6 +1072,8 @@ #define PSR_A 0x00000100 #define PSR_D 0x00000200 #define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F) +/* The default DAIF mask. These bits are valid in spsr_el1 and daif */ +#define PSR_DAIF_DEFAULT (PSR_F) #define PSR_IL 0x00100000 #define PSR_SS 0x00200000 #define PSR_V 0x10000000 diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h index 7f13972e838b..94af62380de3 100644 --- a/sys/arm64/include/cpufunc.h +++ b/sys/arm64/include/cpufunc.h @@ -147,6 +147,13 @@ intr_enable(void) __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_INTR) ")"); } +static __inline void +serror_enable(void) +{ + + __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_A) ")"); +} + static __inline register_t get_midr(void) {