Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch x86: Assert kpreempt_disabled() in cpu_load_pmap.



details:   https://anonhg.NetBSD.org/src/rev/fc576fa9a529
branches:  trunk
changeset: 373708:fc576fa9a529
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 25 00:31:40 2023 +0000

description:
x86: Assert kpreempt_disabled() in cpu_load_pmap.

No functional change intended.  Just makes it easier to audit
curcpu() usage.

diffstat:

 sys/arch/x86/x86/cpu.c |  7 +++++--
 sys/arch/xen/x86/cpu.c |  5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 515c8f8fa4a3 -r fc576fa9a529 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Sat Feb 25 00:09:52 2023 +0000
+++ b/sys/arch/x86/x86/cpu.c    Sat Feb 25 00:31:40 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.206 2022/09/24 11:05:18 riastradh Exp $      */
+/*     $NetBSD: cpu.c,v 1.207 2023/02/25 00:31:40 riastradh Exp $      */
 
 /*
  * Copyright (c) 2000-2020 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.206 2022/09/24 11:05:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.207 2023/02/25 00:31:40 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -1433,6 +1433,9 @@
 void
 cpu_load_pmap(struct pmap *pmap, struct pmap *oldpmap)
 {
+
+       KASSERT(kpreempt_disabled());
+
 #ifdef SVS
        if (svs_enabled && pmap_is_user(pmap)) {
                svs_pdir_switch(pmap);
diff -r 515c8f8fa4a3 -r fc576fa9a529 sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c    Sat Feb 25 00:09:52 2023 +0000
+++ b/sys/arch/xen/x86/cpu.c    Sat Feb 25 00:31:40 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.142 2022/08/20 23:48:51 riastradh Exp $      */
+/*     $NetBSD: cpu.c,v 1.143 2023/02/25 00:31:40 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.142 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.143 2023/02/25 00:31:40 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1109,6 +1109,7 @@
        cpuid_t cid = cpu_index(ci);
        int i;
 
+       KASSERT(kpreempt_disabled());
        KASSERT(pmap != pmap_kernel());
 
        mutex_enter(&ci->ci_kpm_mtx);



Home | Main Index | Thread Index | Old Index