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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to