Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x68k/x68k Fix broken mm_md_physacc().
details: https://anonhg.NetBSD.org/src/rev/2be7290780da
branches: trunk
changeset: 985048:2be7290780da
user: isaki <isaki%NetBSD.org@localhost>
date: Fri Aug 06 04:21:56 2021 +0000
description:
Fix broken mm_md_physacc().
- Fix access to main memory and extended memory.
This makes /dev/mem work again.
- Introduce kauth(9) to access unmanaged memory area.
Now you can read/write the internal I/O space via /dev/mem when
securelevel = -1.
Thanks ryo@, tsutsui@ for advices and reviews.
diffstat:
sys/arch/x68k/x68k/machdep.c | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diffs (54 lines):
diff -r 48f48b0bb514 -r 2be7290780da sys/arch/x68k/x68k/machdep.c
--- a/sys/arch/x68k/x68k/machdep.c Thu Aug 05 22:36:07 2021 +0000
+++ b/sys/arch/x68k/x68k/machdep.c Fri Aug 06 04:21:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $ */
+/* $NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -1252,15 +1252,28 @@
int
mm_md_physacc(paddr_t pa, vm_prot_t prot)
{
- uvm_physseg_t i;
+ int i;
+
+ /* Main memory */
+ if (phys_basemem_seg.start <= pa && pa < phys_basemem_seg.end)
+ return 0;
- for (i = uvm_physseg_get_first(); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
- if (uvm_physseg_valid_p(i) == false)
- break;
+#ifdef EXTENDED_MEMORY
+ for (i = 0; i < EXTMEM_SEGS; i++) {
+ if (phys_extmem_seg[i].start == phys_extmem_seg[i].end)
+ continue;
+ if (phys_extmem_seg[i].start <= pa &&
+ pa < phys_extmem_seg[i].end) {
+ return 0;
+ }
+ }
+#endif
- if (ctob(uvm_physseg_get_start(i)) <= pa &&
- pa < ctob(uvm_physseg_get_end(i)))
- return 0;
+ /* I/O space */
+ if (INTIOBASE <= pa && pa < INTIOTOP) {
+ return kauth_authorize_machdep(kauth_cred_get(),
+ KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
}
+
return EFAULT;
}
Home |
Main Index |
Thread Index |
Old Index