Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm/pmap Misc changes in RISC-V. Start changing the memo...



details:   https://anonhg.NetBSD.org/src/rev/5bf1bb501817
branches:  trunk
changeset: 999428:5bf1bb501817
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Jun 01 12:42:27 2019 +0000

description:
Misc changes in RISC-V. Start changing the memory layout, too.

diffstat:

 common/lib/libc/arch/riscv/atomic/Makefile.inc |   4 +-
 sys/arch/riscv/compile/Makefile                |   3 ++
 sys/arch/riscv/conf/GENERIC                    |   8 ++---
 sys/arch/riscv/conf/Makefile.riscv             |   5 +--
 sys/arch/riscv/conf/files.riscv                |  11 +-------
 sys/arch/riscv/include/cpu.h                   |   9 +++---
 sys/arch/riscv/include/elf_machdep.h           |   5 ++-
 sys/arch/riscv/include/mutex.h                 |   4 +-
 sys/arch/riscv/include/param.h                 |   6 +---
 sys/arch/riscv/include/pmap.h                  |  21 ++++++++++++---
 sys/arch/riscv/include/pte.h                   |  33 ++++++-------------------
 sys/arch/riscv/include/vmparam.h               |  30 +++++++----------------
 sys/arch/riscv/riscv/core_machdep.c            |   4 +-
 sys/arch/riscv/riscv/genassym.cf               |   4 +-
 sys/arch/riscv/riscv/locore.S                  |  10 +++++--
 sys/arch/riscv/riscv/pmap_machdep.c            |  14 +++++++---
 sys/uvm/pmap/pmap.h                            |   5 +++-
 17 files changed, 80 insertions(+), 96 deletions(-)

diffs (truncated from 503 to 300 lines):

diff -r 570722d8d58a -r 5bf1bb501817 common/lib/libc/arch/riscv/atomic/Makefile.inc
--- a/common/lib/libc/arch/riscv/atomic/Makefile.inc    Sat Jun 01 10:58:12 2019 +0000
+++ b/common/lib/libc/arch/riscv/atomic/Makefile.inc    Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.3 2019/04/17 07:40:34 mrg Exp $
+#      $NetBSD: Makefile.inc,v 1.4 2019/06/01 12:42:27 maxv Exp $
 
 .for op in add and cas nand or sub swap xor
 sizes=32
@@ -27,7 +27,7 @@
 
 .endif #LIB
 
-.if ${LIB} == "c"
+.if defined(LIB) && ${LIB} == "c"
 SRCS.atomic+=  atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c
 .endif
 
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/compile/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/compile/Makefile   Sat Jun 01 12:42:27 2019 +0000
@@ -0,0 +1,3 @@
+#      $NetBSD: Makefile,v 1.1 2019/06/01 12:42:27 maxv Exp $
+
+.include <bsd.prog.mk>
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/conf/GENERIC
--- a/sys/arch/riscv/conf/GENERIC       Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/conf/GENERIC       Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.9 2018/08/01 20:04:13 maxv Exp $
+# $NetBSD: GENERIC,v 1.10 2019/06/01 12:42:27 maxv Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.9 $"
+#ident                 "GENERIC-$Revision: 1.10 $"
 
 maxusers       64              # estimated number of users
 
@@ -74,9 +74,7 @@
 include        "conf/compat_netbsd70.config"
 
 options        COMPAT_OSSAUDIO
-options        COMPAT_NETBSD32
-#options       COMPAT_LINUX
-#options       COMPAT_LINUX32  # req. COMPAT_LINUX and COMPAT_NETBSD32
+#options       COMPAT_NETBSD32
 #options       EXEC_ELF32
 
 # Wedge support
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/conf/Makefile.riscv
--- a/sys/arch/riscv/conf/Makefile.riscv        Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/conf/Makefile.riscv        Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.riscv,v 1.3 2018/09/22 12:24:03 rin Exp $
+#      $NetBSD: Makefile.riscv,v 1.4 2019/06/01 12:42:27 maxv Exp $
 
 # Makefile for NetBSD
 #
@@ -39,7 +39,6 @@
 ##
 CPPFLAGS+=     -D${MACHINE}
 CFLAGS+=       -mcmodel=medany
-CFLAGS+=       -msoft-float
 .if !defined(LP64) || ${LP64} == "no"
 CFLAGS+=       -m32
 AFLAGS+=       -m32
@@ -70,7 +69,7 @@
 ## (5) link settings
 ##
 .if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
-TEXTADDR?=              0xFFFFFFFF80002000
+TEXTADDR?=              0xFFFFFFC000000000
 .else   
 TEXTADDR?=             0xC0001000
 .endif
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/conf/files.riscv
--- a/sys/arch/riscv/conf/files.riscv   Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/conf/files.riscv   Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.riscv,v 1.1 2015/03/28 16:13:56 matt Exp $
+#      $NetBSD: files.riscv,v 1.2 2019/06/01 12:42:27 maxv Exp $
 #
 
 maxpartitions  16
@@ -41,7 +41,7 @@
 file   kern/subr_disk_mbr.c                    disk
 
 file   uvm/pmap/pmap.c
-file   uvm/pmap/pmap_pv.c
+file   uvm/pmap/pmap_pvt.c
 file   uvm/pmap/pmap_segtab.c
 file   uvm/pmap/pmap_tlb.c
 
@@ -51,13 +51,6 @@
 file   arch/riscv/riscv/sig32_machdep.c        compat_netbsd32
 include "compat/netbsd32/files.netbsd32"
 
-# Linux compatibility (COMPAT_LINUX)   XXX Highly experimental
-#include "compat/ossaudio/files.ossaudio"
-#include "compat/linux/files.linux"
-#include "compat/linux/arch/riscv/files.linux_riscv"
-#file  arch/riscv/riscv/linux_trap.c           compat_linux
-#file  arch/riscv/riscv/linux_syscall.c        compat_linux
-
 device mainbus { [instance=-1] }
 attach mainbus at root
 file   arch/riscv/riscv/mainbus.c              mainbus
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/cpu.h
--- a/sys/arch/riscv/include/cpu.h      Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/cpu.h      Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.4 2015/04/01 21:55:03 matt Exp $ */
+/* $NetBSD: cpu.h,v 1.5 2019/06/01 12:42:28 maxv Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -68,11 +68,10 @@
        volatile u_int ci_intr_depth;
 
        tlb_asid_t ci_pmap_asid_cur;
-#if 0
-       union pmap_pdetab *ci_pmap_user_pdetab;
+
+       union pmap_segtab *ci_pmap_user_segtab;
 #ifdef _LP64
-       union pmap_pdetab *ci_pmap_user_pde0tab;
-#endif
+       union pmap_segtab *ci_pmap_user_seg0tab;
 #endif
 
        struct evcnt ci_ev_fpu_saves;
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/elf_machdep.h
--- a/sys/arch/riscv/include/elf_machdep.h      Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/elf_machdep.h      Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: elf_machdep.h,v 1.6 2017/11/06 03:47:48 christos Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.7 2019/06/01 12:42:28 maxv Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -46,10 +46,11 @@
                case EM_RISCV:          \
                        break;
 
-#define        KERN_ELFSIZE            32
 #ifdef _LP64
+#define        KERN_ELFSIZE            64
 #define ARCH_ELFSIZE           64      /* MD native binary size */
 #else
+#define        KERN_ELFSIZE            32
 #define ARCH_ELFSIZE           32      /* MD native binary size */
 #endif
 
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/mutex.h
--- a/sys/arch/riscv/include/mutex.h    Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/mutex.h    Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mutex.h,v 1.1 2014/09/19 17:36:26 matt Exp $   */
+/*     $NetBSD: mutex.h,v 1.2 2019/06/01 12:42:28 maxv Exp $   */
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
 }
 
 static inline bool
-riscv_mutex_spinbit_locked_p(kmutex_t *__mtx)
+riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx)
 {
        return (__mtx->mtx_owner & MTX_LOCK) != 0;
 }
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/param.h
--- a/sys/arch/riscv/include/param.h    Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/param.h    Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.2 2019/01/07 22:00:32 jdolecek Exp $ */
+/* $NetBSD: param.h,v 1.3 2019/06/01 12:42:28 maxv Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -66,11 +66,7 @@
 #define NKMEMPAGES_MAX_DEFAULT (2048UL * 1024 * 1024)
 #define NKMEMPAGES_MIN_DEFAULT (128UL * 1024 * 1024)
 
-#ifdef _LP64
-#define PGSHIFT                13
-#else
 #define PGSHIFT                12
-#endif
 #define        NBPG            (1 << PGSHIFT)
 #define PGOFSET                (NBPG - 1)
 
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/pmap.h
--- a/sys/arch/riscv/include/pmap.h     Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/pmap.h     Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
+/* $NetBSD: pmap.h,v 1.2 2019/06/01 12:42:28 maxv Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,12 +42,12 @@
 #include <sys/pool.h>
 #include <sys/evcnt.h>
 
+#include <uvm/uvm_physseg.h>
 #include <uvm/pmap/vmpagemd.h>
 
 #include <riscv/pte.h>
 
-#define        PMAP_SEGTABSIZE         (__SHIFTOUT(PTE_PPN0, PTE_PPN0) + 1)
-#define        PMAP_PDETABSIZE         (__SHIFTOUT(PTE_PPN0, PTE_PPN0) + 1)
+#define        PMAP_SEGTABSIZE         NPTEPG
 
 #define NBSEG          (NBPG*NPTEPG)
 #ifdef _LP64
@@ -76,6 +76,15 @@
 
 #define pmap_phys_address(x)           (x)
 
+#ifndef __BSD_PTENTRY_T__
+#define __BSD_PTENTRY_T__
+#ifdef _LP64
+#define PRIxPTE         PRIx64
+#else
+#define PRIxPTE         PRIx32
+#endif
+#endif /* __BSD_PTENTRY_T__ */
+
 #define PMAP_NEED_PROCWR
 static inline void
 pmap_procwr(struct proc *p, vaddr_t va, vsize_t len)
@@ -96,6 +105,7 @@
 #define __HAVE_PMAP_MD
 struct pmap_md {
        paddr_t md_ptbr;
+       pd_entry_t *md_pdetab;
 };
 
 struct vm_page *
@@ -112,6 +122,7 @@
 
 void   pmap_md_pdetab_activate(struct pmap *);
 void   pmap_md_pdetab_init(struct pmap *);
+bool   pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t);
 
 #ifdef __PMAP_PRIVATE
 static inline void
@@ -166,9 +177,9 @@
 struct vm_page_md {
        uintptr_t mdpg_dummy[3];
 };
-#endif /* !__HVE_VM_PAGE_MD */
+__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3);
 
-__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3);
+#endif /* !__HAVE_VM_PAGE_MD */
 
 #endif /* MODULAR || _MODULE */
 
diff -r 570722d8d58a -r 5bf1bb501817 sys/arch/riscv/include/pte.h
--- a/sys/arch/riscv/include/pte.h      Sat Jun 01 10:58:12 2019 +0000
+++ b/sys/arch/riscv/include/pte.h      Sat Jun 01 12:42:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pte.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
+/* $NetBSD: pte.h,v 1.2 2019/06/01 12:42:28 maxv Exp $ */
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -239,30 +239,6 @@
        *ptep = pte;
 }
 
-static inline pd_entry_t
-pte_invalid_pde(void)
-{
-       return 0;
-}
-
-static inline pd_entry_t
-pte_pde_pdetab(paddr_t pa)
-{
-       return PTE_V | PTE_G | PTE_T | pa;
-}
-
-static inline pd_entry_t
-pte_pde_ptpage(paddr_t pa)
-{
-       return PTE_V | PTE_G | PTE_T | pa;
-}
-
-static inline bool
-pte_pde_valid_p(pd_entry_t pde)
-{
-       return (pde & (PTE_V|PTE_T)) == (PTE_V|PTE_T);



Home | Main Index | Thread Index | Old Index