From owner-svn-src-head@FreeBSD.ORG Sat Jan 3 01:28:59 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D987C772; Sat, 3 Jan 2015 01:28:59 +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 AB4F11E02; Sat, 3 Jan 2015 01:28:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t031Sxll080822; Sat, 3 Jan 2015 01:28:59 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t031SxiF080819; Sat, 3 Jan 2015 01:28:59 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201501030128.t031SxiF080819@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 3 Jan 2015 01:28:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276600 - in head/sys/amd64: amd64 include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jan 2015 01:29:00 -0000 Author: kib Date: Sat Jan 3 01:28:58 2015 New Revision: 276600 URL: https://svnweb.freebsd.org/changeset/base/276600 Log: For /dev/mem and /dev/kmem accesses, avoid asserting that addresses are within direct map. We want to return error instead of panicing. PR: 194995 Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/mem.c head/sys/amd64/include/vmparam.h Modified: head/sys/amd64/amd64/mem.c ============================================================================== --- head/sys/amd64/amd64/mem.c Sat Jan 3 00:31:52 2015 (r276599) +++ head/sys/amd64/amd64/mem.c Sat Jan 3 01:28:58 2015 (r276600) @@ -98,7 +98,7 @@ memrw(struct cdev *dev, struct uio *uio, kmemphys: o = v & PAGE_MASK; c = min(uio->uio_resid, (u_int)(PAGE_SIZE - o)); - vd = PHYS_TO_DMAP(v); + vd = PHYS_TO_DMAP_RAW(v); if (vd < DMAP_MIN_ADDRESS || (vd > DMAP_MIN_ADDRESS + dmaplimit && vd <= DMAP_MAX_ADDRESS) || @@ -112,7 +112,7 @@ kmemphys: v = uio->uio_offset; if (v >= DMAP_MIN_ADDRESS && v < DMAP_MAX_ADDRESS) { - v = DMAP_TO_PHYS(v); + v = DMAP_TO_PHYS_RAW(v); goto kmemphys; } Modified: head/sys/amd64/include/vmparam.h ============================================================================== --- head/sys/amd64/include/vmparam.h Sat Jan 3 00:31:52 2015 (r276599) +++ head/sys/amd64/include/vmparam.h Sat Jan 3 01:28:58 2015 (r276600) @@ -183,6 +183,8 @@ #define VM_MAX_ADDRESS UPT_MAX_ADDRESS #define VM_MIN_ADDRESS (0) +#define PHYS_TO_DMAP_RAW(x) ((x) | DMAP_MIN_ADDRESS) +#define DMAP_TO_PHYS_RAW(x) ((x) & ~DMAP_MIN_ADDRESS) /* * XXX Allowing dmaplimit == 0 is a temporary workaround for vt(4) efifb's * early use of PHYS_TO_DMAP before the mapping is actually setup. This works @@ -193,14 +195,14 @@ KASSERT(dmaplimit == 0 || (x) < dmaplimit, \ ("physical address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ - (x) | DMAP_MIN_ADDRESS; }) + PHYS_TO_DMAP_RAW(x); }) #define DMAP_TO_PHYS(x) ({ \ KASSERT((x) < (DMAP_MIN_ADDRESS + dmaplimit) && \ (x) >= DMAP_MIN_ADDRESS, \ ("virtual address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ - (x) & ~DMAP_MIN_ADDRESS; }) + DMAP_TO_PHYS_RAW(x); }) /* * How many physical pages per kmem arena virtual page.