Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc powerpc: Implement pv-tracking for unmanage...
details: https://anonhg.NetBSD.org/src/rev/6aaaecde891a
branches: trunk
changeset: 361597:6aaaecde891a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Feb 16 23:31:13 2022 +0000
description:
powerpc: Implement pv-tracking for unmanaged pages.
Needed for drm.
diffstat:
sys/arch/powerpc/conf/files.powerpc | 3 +-
sys/arch/powerpc/include/oea/pmap.h | 18 +++++++--
sys/arch/powerpc/include/pmap.h | 4 +-
sys/arch/powerpc/oea/pmap.c | 69 +++++++++++++++++++++++++++++-------
sys/arch/powerpc/oea/pmap_kernel.c | 10 ++++-
5 files changed, 82 insertions(+), 22 deletions(-)
diffs (254 lines):
diff -r 8f0f79789364 -r 6aaaecde891a sys/arch/powerpc/conf/files.powerpc
--- a/sys/arch/powerpc/conf/files.powerpc Wed Feb 16 23:30:52 2022 +0000
+++ b/sys/arch/powerpc/conf/files.powerpc Wed Feb 16 23:31:13 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.powerpc,v 1.98 2021/03/05 06:06:34 rin Exp $
+# $NetBSD: files.powerpc,v 1.99 2022/02/16 23:31:13 riastradh Exp $
defflag opt_altivec.h ALTIVEC K_ALTIVEC PPC_HAVE_SPE
defflag opt_openpic.h OPENPIC_DISTRIBUTE
@@ -51,6 +51,7 @@
file arch/powerpc/oea/pmap64_bridge.c ppc_oea64_bridge
file arch/powerpc/oea/pmap_kernel.c ppc_oea | ppc_oea64 | ppc_oea64_bridge | ppc_oea601
file arch/powerpc/powerpc/trap.c ppc_oea | ppc_oea64 | ppc_oea64_bridge | ppc_oea601
+file uvm/pmap/pmap_pvt.c ppc_oea | ppc_oea601 | ppc_oea64
# PPC BookE (MPC85xx) Family files
file arch/powerpc/booke/booke_machdep.c ppc_booke
diff -r 8f0f79789364 -r 6aaaecde891a sys/arch/powerpc/include/oea/pmap.h
--- a/sys/arch/powerpc/include/oea/pmap.h Wed Feb 16 23:30:52 2022 +0000
+++ b/sys/arch/powerpc/include/oea/pmap.h Wed Feb 16 23:31:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.35 2021/03/12 04:57:42 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.36 2022/02/16 23:31:13 riastradh Exp $ */
/*-
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -90,6 +90,7 @@
void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
void (*pmapop_unwire)(pmap_t, vaddr_t);
void (*pmapop_page_protect)(struct vm_page *, vm_prot_t);
+ void (*pmapop_pv_protect)(paddr_t, vm_prot_t);
bool (*pmapop_query_bit)(struct vm_page *, int);
bool (*pmapop_clear_bit)(struct vm_page *, int);
@@ -247,11 +248,20 @@
#define __HAVE_VM_PAGE_MD
+struct pmap_page {
+ unsigned int pp_attrs;
+ struct pvo_head pp_pvoh;
+#ifdef MODULAR
+ uintptr_t pp_dummy[3];
+#endif
+};
+
struct vm_page_md {
- unsigned int mdpg_attrs;
- struct pvo_head mdpg_pvoh;
+ struct pmap_page mdpg_pp;
+#define mdpg_attrs mdpg_pp.pp_attrs
+#define mdpg_pvoh mdpg_pp.pp_pvoh
#ifdef MODULAR
- uintptr_t mdpg_dummy[3];
+#define mdpg_dummy mdpg_pp.pp_dummy
#endif
};
diff -r 8f0f79789364 -r 6aaaecde891a sys/arch/powerpc/include/pmap.h
--- a/sys/arch/powerpc/include/pmap.h Wed Feb 16 23:30:52 2022 +0000
+++ b/sys/arch/powerpc/include/pmap.h Wed Feb 16 23:31:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.40 2020/07/06 08:17:01 rin Exp $ */
+/* $NetBSD: pmap.h,v 1.41 2022/02/16 23:31:13 riastradh Exp $ */
#ifndef _POWERPC_PMAP_H_
#define _POWERPC_PMAP_H_
@@ -22,6 +22,8 @@
#endif /* !_MODULE */
+#include <uvm/pmap/pmap_pvt.h>
+
#if !defined(_LOCORE) && (defined(MODULAR) || defined(_MODULE))
/*
* Both BOOKE and OEA use __HAVE_VM_PAGE_MD but IBM4XX doesn't so define
diff -r 8f0f79789364 -r 6aaaecde891a sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c Wed Feb 16 23:30:52 2022 +0000
+++ b/sys/arch/powerpc/oea/pmap.c Wed Feb 16 23:31:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.108 2022/02/16 23:31:13 riastradh Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2022/02/16 23:31:13 riastradh Exp $");
#define PMAP_NOOPNAMES
@@ -214,6 +214,7 @@
STATIC void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
STATIC void pmap_unwire(pmap_t, vaddr_t);
STATIC void pmap_page_protect(struct vm_page *, vm_prot_t);
+STATIC void pmap_pv_protect(paddr_t, vm_prot_t);
STATIC bool pmap_query_bit(struct vm_page *, int);
STATIC bool pmap_clear_bit(struct vm_page *, int);
@@ -645,12 +646,16 @@
{
struct vm_page *pg;
struct vm_page_md *md;
+ struct pmap_page *pp;
pg = PHYS_TO_VM_PAGE(pa);
if (pg_p != NULL)
*pg_p = pg;
- if (pg == NULL)
+ if (pg == NULL) {
+ if ((pp = pmap_pv_tracked(pa)) != NULL)
+ return &pp->pp_pvoh;
return NULL;
+ }
md = VM_PAGE_TO_MD(pg);
return &md->mdpg_pvoh;
}
@@ -663,13 +668,26 @@
return &md->mdpg_pvoh;
}
+static inline void
+pmap_pp_attr_clear(struct pmap_page *pp, int ptebit)
+{
+
+ pp->pp_attrs &= ptebit;
+}
static inline void
pmap_attr_clear(struct vm_page *pg, int ptebit)
{
struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
- md->mdpg_attrs &= ~ptebit;
+ pmap_pp_attr_clear(&md->mdpg_pp, ptebit);
+}
+
+static inline int
+pmap_pp_attr_fetch(struct pmap_page *pp)
+{
+
+ return pp->pp_attrs;
}
static inline int
@@ -677,7 +695,7 @@
{
struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
- return md->mdpg_attrs;
+ return pmap_pp_attr_fetch(&md->mdpg_pp);
}
static inline void
@@ -2274,11 +2292,8 @@
PMAP_UNLOCK();
}
-/*
- * Lower the protection on the specified physical page.
- */
-void
-pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
+static void
+pmap_pp_protect(struct pmap_page *pp, paddr_t pa, vm_prot_t prot)
{
struct pvo_head *pvo_head, pvol;
struct pvo_entry *pvo, *next_pvo;
@@ -2298,14 +2313,14 @@
*/
if ((prot & VM_PROT_READ) == 0) {
DPRINTFN(EXEC, "[pmap_page_protect: %#" _PRIxpa ": clear-exec]\n",
- VM_PAGE_TO_PHYS(pg));
- if (pmap_attr_fetch(pg) & PTE_EXEC) {
+ pa);
+ if (pmap_pp_attr_fetch(pp) & PTE_EXEC) {
PMAPCOUNT(exec_uncached_page_protect);
- pmap_attr_clear(pg, PTE_EXEC);
+ pmap_pp_attr_clear(pp, PTE_EXEC);
}
}
- pvo_head = vm_page_to_pvoh(pg);
+ pvo_head = &pp->pp_pvoh;
for (pvo = LIST_FIRST(pvo_head); pvo != NULL; pvo = next_pvo) {
next_pvo = LIST_NEXT(pvo, pvo_vlink);
PMAP_PVO_CHECK(pvo); /* sanity check */
@@ -2356,6 +2371,32 @@
}
/*
+ * Lower the protection on the specified physical page.
+ */
+void
+pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
+{
+ struct vm_page_md *md = VM_PAGE_TO_MD(pg);
+
+ pmap_pp_protect(&md->mdpg_pp, VM_PAGE_TO_PHYS(pg), prot);
+}
+
+/*
+ * Lower the protection on the physical page at the specified physical
+ * address, which may not be managed and so may not have a struct
+ * vm_page.
+ */
+void
+pmap_pv_protect(paddr_t pa, vm_prot_t prot)
+{
+ struct pmap_page *pp;
+
+ if ((pp = pmap_pv_tracked(pa)) == NULL)
+ return;
+ pmap_pp_protect(pp, pa, prot);
+}
+
+/*
* Activate the address space for the specified process. If the process
* is the current process, load the new MMU context.
*/
diff -r 8f0f79789364 -r 6aaaecde891a sys/arch/powerpc/oea/pmap_kernel.c
--- a/sys/arch/powerpc/oea/pmap_kernel.c Wed Feb 16 23:30:52 2022 +0000
+++ b/sys/arch/powerpc/oea/pmap_kernel.c Wed Feb 16 23:31:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_kernel.c,v 1.12 2021/03/02 01:47:44 thorpej Exp $ */
+/* $NetBSD: pmap_kernel.c,v 1.13 2022/02/16 23:31:13 riastradh Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: pmap_kernel.c,v 1.12 2021/03/02 01:47:44 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: pmap_kernel.c,v 1.13 2022/02/16 23:31:13 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_altivec.h"
@@ -215,6 +215,12 @@
(*pmapops->pmapop_page_protect)(pg, prot);
}
+void
+pmap_pv_protect(paddr_t pa, vm_prot_t prot)
+{
+ (*pmapops->pmapop_pv_protect)(pa, prot);
+}
+
bool
pmap_query_bit(struct vm_page *pg, int ptebit)
{
Home |
Main Index |
Thread Index |
Old Index