Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Sep 2014 18:24:47 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r271113 - in stable/10/sys/powerpc: aim powerpc
Message-ID:  <201409041824.s84IOlKi072433@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Thu Sep  4 18:24:47 2014
New Revision: 271113
URL: http://svnweb.freebsd.org/changeset/base/271113

Log:
  MFC r268880:
  Allow mappings of memory not previously direct-mapped by the kernel when
  calling mmap on /dev/mem and add a handler for the possible userland
  machine checks that may result. Remove some pointless and wrong copy/paste
  that has been in here for a decade as well.
  
  This results in a /dev/mem with identical semantics to the x86 version.

Modified:
  stable/10/sys/powerpc/aim/trap.c
  stable/10/sys/powerpc/powerpc/mem.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/powerpc/aim/trap.c
==============================================================================
--- stable/10/sys/powerpc/aim/trap.c	Thu Sep  4 18:18:29 2014	(r271112)
+++ stable/10/sys/powerpc/aim/trap.c	Thu Sep  4 18:24:47 2014	(r271113)
@@ -269,6 +269,15 @@ trap(struct trapframe *frame)
 			}
 			break;
 
+		case EXC_MCHK:
+			/*
+			 * Note that this may not be recoverable for the user
+			 * process, depending on the type of machine check,
+			 * but it at least prevents the kernel from dying.
+			 */
+			sig = SIGBUS;
+			break;
+
 		default:
 			trap_fatal(frame);
 		}

Modified: stable/10/sys/powerpc/powerpc/mem.c
==============================================================================
--- stable/10/sys/powerpc/powerpc/mem.c	Thu Sep  4 18:18:29 2014	(r271112)
+++ stable/10/sys/powerpc/powerpc/mem.c	Thu Sep  4 18:24:47 2014	(r271113)
@@ -179,22 +179,13 @@ memmmap(struct cdev *dev, vm_ooffset_t o
 {
 	int i;
 
-	/*
-	 * /dev/mem is the only one that makes sense through this
-	 * interface.  For /dev/kmem any physaddr we return here
-	 * could be transient and hence incorrect or invalid at
-	 * a later time.
-	 */
-	if (dev2unit(dev) != CDEV_MINOR_MEM)
-		return (-1);
-
-	/* Only direct-mapped addresses. */
-	if (mem_valid(offset, 0)
-	    && pmap_dev_direct_mapped(offset, 0))
+	if (dev2unit(dev) == CDEV_MINOR_MEM)
+		*paddr = offset;
+	else if (dev2unit(dev) == CDEV_MINOR_KMEM)
+		*paddr = vtophys(offset);
+	else
 		return (EFAULT);
 
-	*paddr = offset;
-
 	for (i = 0; i < mem_range_softc.mr_ndesc; i++) {
 		if (!(mem_range_softc.mr_desc[i].mr_flags & MDF_ACTIVE))
 			continue;
@@ -231,9 +222,7 @@ ppc_mrinit(struct mem_range_softc *sc)
 	sc->mr_cap = 0;
 	sc->mr_ndesc = 8; /* XXX: Should be dynamically expandable */
 	sc->mr_desc = malloc(sc->mr_ndesc * sizeof(struct mem_range_desc),
-	    M_MEMDESC, M_NOWAIT | M_ZERO);
-	if (sc->mr_desc == NULL)
-		panic("%s: malloc returns NULL", __func__);
+	    M_MEMDESC, M_WAITOK | M_ZERO);
 }
 
 static int
@@ -328,3 +317,4 @@ memioctl(struct cdev *dev __unused, u_lo
 	}
 	return (error);
 }
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409041824.s84IOlKi072433>