From owner-svn-src-all@freebsd.org Mon Jan 25 23:04:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 095F7A4609E; Mon, 25 Jan 2016 23:04:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 D640A1F96; Mon, 25 Jan 2016 23:04:41 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0PN4ex9073594; Mon, 25 Jan 2016 23:04:40 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0PN4eEa073591; Mon, 25 Jan 2016 23:04:40 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201601252304.u0PN4eEa073591@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 25 Jan 2016 23:04:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294754 - in head/sys/arm: arm include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2016 23:04:42 -0000 Author: andrew Date: Mon Jan 25 23:04:40 2016 New Revision: 294754 URL: https://svnweb.freebsd.org/changeset/base/294754 Log: Allow us to be told about memory past the first 4GB point, but ignore it. This allows, for example, UEFI pass a memory map with some ram in this region, but for us to ignore it. This is the case when running under the qemu virt machine type. Sponsored by: ABT Systems Ltd Modified: head/sys/arm/arm/physmem.c head/sys/arm/include/ofw_machdep.h head/sys/arm/include/physmem.h Modified: head/sys/arm/arm/physmem.c ============================================================================== --- head/sys/arm/arm/physmem.c Mon Jan 25 22:58:06 2016 (r294753) +++ head/sys/arm/arm/physmem.c Mon Jan 25 23:04:40 2016 (r294754) @@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$"); #define MAX_HWCNT 10 #define MAX_EXCNT 10 +#define MAX_PHYS_ADDR 0xFFFFFFFFull + struct region { vm_paddr_t addr; vm_size_t size; @@ -273,14 +275,25 @@ insert_region(struct region *regions, si * Add a hardware memory region. */ void -arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz) +arm_physmem_hardware_region(uint64_t pa, uint64_t sz) { vm_offset_t adj; /* * Filter out the page at PA 0x00000000. The VM can't handle it, as * pmap_extract() == 0 means failure. - * + */ + if (pa == 0) { + if (sz <= PAGE_SIZE) + return; + pa = PAGE_SIZE; + sz -= PAGE_SIZE; + } else if (pa > MAX_PHYS_ADDR) { + /* This range is past usable memory, ignore it */ + return; + } + + /* * Also filter out the page at the end of the physical address space -- * if addr is non-zero and addr+size is zero we wrapped to the next byte * beyond what vm_paddr_t can express. That leads to a NULL pointer @@ -291,12 +304,8 @@ arm_physmem_hardware_region(vm_paddr_t p * pointer deref in _vm_map_lock_read(). Better to give up a megabyte * than leave some folks with an unusable system while we investigate. */ - if (pa == 0) { - if (sz <= PAGE_SIZE) - return; - pa = PAGE_SIZE; - sz -= PAGE_SIZE; - } else if (pa + sz == 0) { + if ((pa + sz) > (MAX_PHYS_ADDR - 1024 * 1024)) { + sz = MAX_PHYS_ADDR - pa + 1; if (sz <= 1024 * 1024) return; sz -= 1024 * 1024; Modified: head/sys/arm/include/ofw_machdep.h ============================================================================== --- head/sys/arm/include/ofw_machdep.h Mon Jan 25 22:58:06 2016 (r294753) +++ head/sys/arm/include/ofw_machdep.h Mon Jan 25 23:04:40 2016 (r294754) @@ -40,8 +40,8 @@ typedef uint32_t cell_t; struct mem_region { - vm_offset_t mr_start; - vm_size_t mr_size; + uint64_t mr_start; + uint64_t mr_size; }; #endif /* _MACHINE_OFW_MACHDEP_H_ */ Modified: head/sys/arm/include/physmem.h ============================================================================== --- head/sys/arm/include/physmem.h Mon Jan 25 22:58:06 2016 (r294753) +++ head/sys/arm/include/physmem.h Mon Jan 25 23:04:40 2016 (r294754) @@ -52,7 +52,7 @@ extern vm_paddr_t arm_physmem_kernaddr; #define EXFLAG_NODUMP 0x01 #define EXFLAG_NOALLOC 0x02 -void arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz); +void arm_physmem_hardware_region(uint64_t pa, uint64_t sz); void arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); void arm_physmem_init_kernel_globals(void); void arm_physmem_print_tables(void);