Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Always set PTEs using atomics. There are too many ...



details:   https://anonhg.NetBSD.org/src/rev/4c35aeec7e95
branches:  trunk
changeset: 970243:4c35aeec7e95
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Mar 17 18:17:07 2020 +0000

description:
Always set PTEs using atomics.  There are too many assumptions to go wrong.

diffstat:

 sys/arch/amd64/include/pmap.h |  5 +++--
 sys/arch/i386/include/pmap.h  |  7 +++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 06ad75229773 -r 4c35aeec7e95 sys/arch/amd64/include/pmap.h
--- a/sys/arch/amd64/include/pmap.h     Tue Mar 17 17:18:49 2020 +0000
+++ b/sys/arch/amd64/include/pmap.h     Tue Mar 17 18:17:07 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.64 2019/11/14 16:23:52 maxv Exp $   */
+/*     $NetBSD: pmap.h,v 1.65 2020/03/17 18:17:07 ad Exp $     */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -202,7 +202,8 @@
 #ifndef XENPV
 #define pmap_pa2pte(a)                 (a)
 #define pmap_pte2pa(a)                 ((a) & PTE_FRAME)
-#define pmap_pte_set(p, n)             do { *(p) = (n); } while (0)
+#define pmap_pte_set(p, n)             \
+    (void)atomic_swap_ulong((volatile unsigned long *)p, n)
 #define pmap_pte_cas(p, o, n)          atomic_cas_64((p), (o), (n))
 #define pmap_pte_testset(p, n)         \
     atomic_swap_ulong((volatile unsigned long *)p, n)
diff -r 06ad75229773 -r 4c35aeec7e95 sys/arch/i386/include/pmap.h
--- a/sys/arch/i386/include/pmap.h      Tue Mar 17 17:18:49 2020 +0000
+++ b/sys/arch/i386/include/pmap.h      Tue Mar 17 18:17:07 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.123 2019/03/09 09:09:56 maxv Exp $  */
+/*     $NetBSD: pmap.h,v 1.124 2020/03/17 18:17:07 ad Exp $    */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -294,10 +294,11 @@
 #ifndef XENPV
 #define pmap_pa2pte(a)                 (a)
 #define pmap_pte2pa(a)                 ((a) & PTE_FRAME)
-#define pmap_pte_set(p, n)             do { *(p) = (n); } while (0)
 #define pmap_pte_flush()               /* nothing */
 
 #ifdef PAE
+#define pmap_pte_set(p, n)             \
+    (void)atomic_swap_64((volatile uint64_t *)p, n)
 #define pmap_pte_cas(p, o, n)          atomic_cas_64((p), (o), (n))
 #define pmap_pte_testset(p, n)         \
     atomic_swap_64((volatile uint64_t *)p, n)
@@ -306,6 +307,8 @@
 #define pmap_pte_clearbits(p, b)       \
     atomic_and_64((volatile uint64_t *)p, ~(b))
 #else /* PAE */
+#define pmap_pte_set(p, n)             \
+    (void)atomic_swap_ulong((volatile unsigned long *)p, n)
 #define pmap_pte_cas(p, o, n)          atomic_cas_32((p), (o), (n))
 #define pmap_pte_testset(p, n)         \
     atomic_swap_ulong((volatile unsigned long *)p, n)



Home | Main Index | Thread Index | Old Index