Module Name:    src
Committed By:   skrll
Date:           Tue May  3 20:12:28 UTC 2022

Modified Files:
        src/sys/arch/arm/arm: efi_machdep.c
        src/sys/arch/arm/arm32: pmap.c

Log Message:
Catch up with aarch64 TTBR0 handling in pmap_{,de}activate_efirt and
kpreempt_{en,dis}able.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/arm/efi_machdep.c
cvs rdiff -u -r1.436 -r1.437 src/sys/arch/arm/arm32/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm/efi_machdep.c
diff -u src/sys/arch/arm/arm/efi_machdep.c:1.1 src/sys/arch/arm/arm/efi_machdep.c:1.2
--- src/sys/arch/arm/arm/efi_machdep.c:1.1	Sat Apr  2 11:16:06 2022
+++ src/sys/arch/arm/arm/efi_machdep.c	Tue May  3 20:12:27 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.1 2022/04/02 11:16:06 skrll Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.2 2022/05/03 20:12:27 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.1 2022/04/02 11:16:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.2 2022/05/03 20:12:27 skrll Exp $");
 
 #include <sys/param.h>
 #include <uvm/uvm_extern.h>
@@ -50,6 +50,10 @@ static struct {
 int
 arm_efirt_md_enter(void)
 {
+	kpreempt_disable();
+
+	struct lwp * const l = curlwp;
+
 	arm_efirt_state.aert_tpidrprw = armreg_tpidrprw_read();
 
 	/* Disable the VFP.  */
@@ -65,6 +69,9 @@ arm_efirt_md_enter(void)
 	if (err)
 		return err;
 
+	if ((l->l_flag & LW_SYSTEM) == 0) {
+		pmap_deactivate(l);
+	}
 	pmap_activate_efirt();
 
 	return 0;
@@ -73,7 +80,12 @@ arm_efirt_md_enter(void)
 void
 arm_efirt_md_exit(void)
 {
+	struct lwp * const l = curlwp;
+
 	pmap_deactivate_efirt();
+	if ((l->l_flag & LW_SYSTEM) == 0) {
+		pmap_activate(l);
+	}
 
 	armreg_tpidrprw_write(arm_efirt_state.aert_tpidrprw);
 
@@ -83,6 +95,8 @@ arm_efirt_md_exit(void)
 
 	/* Remove custom fault handler */
 	cpu_unset_onfault();
+
+	kpreempt_enable();
 }
 
 

Index: src/sys/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.436 src/sys/arch/arm/arm32/pmap.c:1.437
--- src/sys/arch/arm/arm32/pmap.c:1.436	Sat Apr  9 23:38:31 2022
+++ src/sys/arch/arm/arm32/pmap.c	Tue May  3 20:12:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.436 2022/04/09 23:38:31 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.437 2022/05/03 20:12:28 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -193,7 +193,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.436 2022/04/09 23:38:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.437 2022/05/03 20:12:28 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -4986,15 +4986,16 @@ pmap_md_pdetab_deactivate(pmap_t pm)
 void
 pmap_activate_efirt(void)
 {
-	kpreempt_disable();
-
-	struct cpu_info * const ci = curcpu();
 	struct pmap * const pm = &efirt_pmap;
-	struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
 
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLARGS(maphist, " (pm=%#jx)", (uintptr_t)pm, 0, 0, 0);
 
+	KASSERT(kpreempt_disabled());
+
+	struct cpu_info * const ci = curcpu();
+	struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
+
 	PMAPCOUNT(activations);
 
 	/*
@@ -5038,6 +5039,10 @@ pmap_activate(struct lwp *l)
 	UVMHIST_CALLARGS(maphist, "l=%#jx pm=%#jx", (uintptr_t)l,
 	    (uintptr_t)npm, 0, 0);
 
+#ifdef ARM_MMU_EXTENDED
+	KASSERT(kpreempt_disabled());
+#endif
+
 	struct cpu_info * const ci = curcpu();
 
 	/*
@@ -5197,6 +5202,7 @@ pmap_deactivate(struct lwp *l)
 		(uintptr_t)pm, 0, 0);
 
 #ifdef ARM_MMU_EXTENDED
+	KASSERT(kpreempt_disabled());
 	pmap_md_pdetab_deactivate(pm);
 #else
 	/*
@@ -5219,6 +5225,7 @@ pmap_deactivate_efirt(void)
 {
 	UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist);
 
+	KASSERT(kpreempt_disabled());
 	struct cpu_info * const ci = curcpu();
 
 	/*
@@ -5234,7 +5241,6 @@ pmap_deactivate_efirt(void)
 
 	KASSERTMSG(ci->ci_pmap_asid_cur == KERNEL_PID, "ci_pmap_asid_cur %u",
 	    ci->ci_pmap_asid_cur);
-	kpreempt_enable();
 
 	UVMHIST_LOG(maphist, " <-- done", 0, 0, 0, 0);
 }

Reply via email to