Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh3/sh3 Add missing NULL check for __pmap_pv_alloc(...
details: https://anonhg.NetBSD.org/src/rev/a62df2ee5a5f
branches: trunk
changeset: 985633:a62df2ee5a5f
user: rin <rin%NetBSD.org@localhost>
date: Thu Sep 02 08:02:33 2021 +0000
description:
Add missing NULL check for __pmap_pv_alloc() (== pool_get() with
PR_NOWAIT) in __pmap_pv_enter().
Then, handle this failure in pmap_enter(); return ENOMEM if
PMAP_CANFAIL, and panic otherwise.
diffstat:
sys/arch/sh3/sh3/pmap.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diffs (72 lines):
diff -r c67c6282d847 -r a62df2ee5a5f sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c Thu Sep 02 07:55:56 2021 +0000
+++ b/sys/arch/sh3/sh3/pmap.c Thu Sep 02 08:02:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $ */
+/* $NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -77,7 +77,7 @@
};
#define __pmap_pv_alloc() pool_get(&__pmap_pv_pool, PR_NOWAIT)
#define __pmap_pv_free(pv) pool_put(&__pmap_pv_pool, (pv))
-STATIC void __pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t);
+STATIC int __pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t);
STATIC void __pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t);
STATIC void *__pmap_pv_page_alloc(struct pool *, int);
STATIC void __pmap_pv_page_free(struct pool *, void *);
@@ -365,8 +365,11 @@
return (0);
/* Add to physical-virtual map list of this page */
- __pmap_pv_enter(pmap, pg, va);
-
+ if (__pmap_pv_enter(pmap, pg, va)) {
+ if (flags & PMAP_CANFAIL)
+ return ENOMEM;
+ panic("%s: __pmap_pv_enter failed", __func__);
+ }
} else { /* bus-space (always uncached map) */
if (kva) {
entry |= PG_V | PG_SH |
@@ -458,11 +461,11 @@
}
/*
- * void __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t vaddr):
+ * int __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t vaddr):
* Insert physical-virtual map to vm_page.
* Assume pre-existed mapping is already removed.
*/
-void
+int
__pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t va)
{
struct vm_page_md *pvh;
@@ -495,11 +498,16 @@
/* Register pv map */
pvh = VM_PAGE_TO_MD(pg);
pv = __pmap_pv_alloc();
+ if (pv == NULL) {
+ splx(s);
+ return ENOMEM;
+ }
pv->pv_pmap = pmap;
pv->pv_va = va;
SLIST_INSERT_HEAD(&pvh->pvh_head, pv, pv_link);
splx(s);
+ return 0;
}
void
Home |
Main Index |
Thread Index |
Old Index