From owner-svn-src-stable@FreeBSD.ORG Thu Sep 4 18:24:48 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7B167FF8; Thu, 4 Sep 2014 18:24:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D03B1257; Thu, 4 Sep 2014 18:24:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s84IOmin072435; Thu, 4 Sep 2014 18:24:48 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s84IOlKi072433; Thu, 4 Sep 2014 18:24:47 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201409041824.s84IOlKi072433@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Thu, 4 Sep 2014 18:24:47 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Sep 2014 18:24:48 -0000 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); } +