Page MenuHomeFreeBSD

D32873.1775841018.diff
No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None

D32873.1775841018.diff

Index: sys/amd64/include/vmparam.h
===================================================================
--- sys/amd64/include/vmparam.h
+++ sys/amd64/include/vmparam.h
@@ -233,6 +233,8 @@
#define VM_MAX_ADDRESS UPT_MAX_ADDRESS
#define VM_MIN_ADDRESS (0)
+#define VM_MAX_PHYS_ADDRESS (cpu_getmaxphyaddr())
+
/*
* 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
Index: sys/arm/include/vmparam.h
===================================================================
--- sys/arm/include/vmparam.h
+++ sys/arm/include/vmparam.h
@@ -139,6 +139,8 @@
#endif
#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
+#define VM_MAX_PHYS_ADDRESS 0xFFFFFFFFull
+
#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
#define USRSTACK SHAREDPAGE
Index: sys/arm64/include/vmparam.h
===================================================================
--- sys/arm64/include/vmparam.h
+++ sys/arm64/include/vmparam.h
@@ -152,6 +152,8 @@
#define VM_MIN_ADDRESS (0x0000000000000000UL)
#define VM_MAX_ADDRESS (0xffffffffffffffffUL)
+#define VM_MAX_PHYS_ADDRESS VM_MAX_ADDRESS
+
/* 512 GiB of kernel addresses */
#define VM_MIN_KERNEL_ADDRESS (0xffff000000000000UL)
#define VM_MAX_KERNEL_ADDRESS (0xffff008000000000UL)
Index: sys/i386/include/vmparam.h
===================================================================
--- sys/i386/include/vmparam.h
+++ sys/i386/include/vmparam.h
@@ -172,6 +172,8 @@
#define VM_MAX_ADDRESS VADDR(PTDPTDI, 0)
#define VM_MIN_ADDRESS ((vm_offset_t)0)
+#define VM_MAX_PHYS_ADDRESS (cpu_getmaxphyaddr())
+
#define PMAP_TRM_MIN_ADDRESS VM_MAXUSER_ADDRESS
#define PMAP_TRM_MAX_ADDRESS 0xffffffff
Index: sys/kern/subr_physmem.c
===================================================================
--- sys/kern/subr_physmem.c
+++ sys/kern/subr_physmem.c
@@ -40,6 +40,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/physmem.h>
+#include <machine/md_var.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
@@ -62,15 +63,9 @@
#define MAX_EXCNT 16
#endif
-#if defined(__arm__)
-#define MAX_PHYS_ADDR 0xFFFFFFFFull
-#elif defined(__aarch64__) || defined(__riscv)
-#define MAX_PHYS_ADDR 0xFFFFFFFFFFFFFFFFull
-#endif
-
struct region {
vm_paddr_t addr;
- vm_size_t size;
+ vm_ooffset_t size;
uint32_t flags;
};
@@ -166,8 +161,9 @@
availsz = 0;
acnt = 0;
for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) {
- start = hwp->addr;
- end = hwp->size + start;
+ /* Operate on page boundaries. Partial pages aren't usable. */
+ start = round_page(hwp->addr);
+ end = trunc_page(hwp->size + start);
totalmem += atop((vm_offset_t)(end - start));
for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) {
/*
@@ -176,8 +172,9 @@
*/
if ((exp->flags & exflags) == 0)
continue;
- xstart = exp->addr;
- xend = exp->size + xstart;
+ /* Whole page is excluded. */
+ xstart = trunc_page(exp->addr);
+ xend = round_page(exp->size + xstart);
/*
* If the excluded region ends before this hw region,
* continue checking with the next excluded region.
@@ -336,7 +333,7 @@
*/
static size_t
insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr,
- vm_size_t size, uint32_t flags)
+ vm_ooffset_t size, uint32_t flags)
{
size_t i;
vm_paddr_t nend, rend;
@@ -393,7 +390,6 @@
int
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
@@ -404,7 +400,7 @@
return (0);
pa = PAGE_SIZE;
sz -= PAGE_SIZE;
- } else if (pa > MAX_PHYS_ADDR) {
+ } else if (pa > VM_MAX_PHYS_ADDRESS) {
/* This range is past usable memory, ignore it */
return (ERANGE);
}
@@ -420,21 +416,13 @@
* 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 + sz) > (MAX_PHYS_ADDR - 1024 * 1024)) {
- sz = MAX_PHYS_ADDR - pa + 1;
+ if ((pa + sz) > (VM_MAX_PHYS_ADDRESS - 1024 * 1024)) {
+ sz = VM_MAX_PHYS_ADDRESS - pa + 1;
if (sz <= 1024 * 1024)
return (0);
sz -= 1024 * 1024;
}
- /*
- * Round the starting address up to a page boundary, and truncate the
- * ending page down to a page boundary.
- */
- adj = round_page(pa) - pa;
- pa = round_page(pa);
- sz = trunc_page(sz - adj);
-
if (sz == 0)
return (EINVAL);
if (hwcnt == nitems(hwregions))
@@ -447,17 +435,8 @@
* Add an exclusion region.
*/
int
-physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t exflags)
+physmem_exclude_region(uint64_t pa, uint64_t sz, uint32_t exflags)
{
- vm_offset_t adj;
-
- /*
- * Truncate the starting address down to a page boundary, and round the
- * ending page up to a page boundary.
- */
- adj = pa - trunc_page(pa);
- pa = trunc_page(pa);
- sz = round_page(sz + adj);
if (excnt == nitems(exregions))
return (E2BIG);
Index: sys/mips/include/vmparam.h
===================================================================
--- sys/mips/include/vmparam.h
+++ sys/mips/include/vmparam.h
@@ -79,6 +79,8 @@
#define VM_MIN_ADDRESS ((vm_offset_t)0x00000000)
#define VM_MAX_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0xffffffff)
+#define VM_MAX_PHYS_ADDRESS VM_MAX_ADDRESS
+
#define VM_MINUSER_ADDRESS ((vm_offset_t)0x00000000)
#ifdef __mips_n64
Index: sys/powerpc/include/vmparam.h
===================================================================
--- sys/powerpc/include/vmparam.h
+++ sys/powerpc/include/vmparam.h
@@ -104,6 +104,7 @@
#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32
#define VM_MAX_ADDRESS 0xffffffff
#endif
+#define VM_MAX_PHYS_ADDRESS VM_MAX_ADDRESS
#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
Index: sys/riscv/include/vmparam.h
===================================================================
--- sys/riscv/include/vmparam.h
+++ sys/riscv/include/vmparam.h
@@ -147,6 +147,8 @@
#define VM_MIN_ADDRESS (0x0000000000000000UL)
#define VM_MAX_ADDRESS (0xffffffffffffffffUL)
+#define VM_MAX_PHYS_ADDRESS VM_MAX_ADDRESS
+
#define VM_MIN_KERNEL_ADDRESS (0xffffffc000000000UL)
#define VM_MAX_KERNEL_ADDRESS (0xffffffc800000000UL)
Index: sys/sys/physmem.h
===================================================================
--- sys/sys/physmem.h
+++ sys/sys/physmem.h
@@ -50,7 +50,7 @@
#define EXFLAG_NOALLOC 0x02
int physmem_hardware_region(uint64_t pa, uint64_t sz);
-int physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
+int physmem_exclude_region(uint64_t pa, uint64_t sz, uint32_t flags);
size_t physmem_avail(vm_paddr_t *avail, size_t maxavail);
void physmem_init_kernel_globals(size_t *pa_idx, size_t *da_idx);
void physmem_print_tables(void);

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 10, 5:10 PM (9 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28317796
Default Alt Text
D32873.1775841018.diff (6 KB)

Event Timeline