Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140069834
D27095.id79312.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D27095.id79312.diff
View Options
Index: sys/amd64/vmm/vmm.c
===================================================================
--- sys/amd64/vmm/vmm.c
+++ sys/amd64/vmm/vmm.c
@@ -49,12 +49,12 @@
#include <sys/vnode.h>
#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_extern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_param.h>
#include <vm/vm_pager.h>
#include <vm/vm_kern.h>
#include <vm/vnode_pager.h>
@@ -473,7 +473,7 @@
if (name == NULL || strlen(name) >= VM_MAX_NAMELEN)
return (EINVAL);
- vmspace = VMSPACE_ALLOC(0, VM_MAXUSER_ADDRESS);
+ vmspace = VMSPACE_ALLOC(0, VM_MAXUSER_ADDRESS_LA48);
if (vmspace == NULL)
return (ENOMEM);
Index: usr.sbin/bhyve/pci_emul.c
===================================================================
--- usr.sbin/bhyve/pci_emul.c
+++ usr.sbin/bhyve/pci_emul.c
@@ -33,6 +33,9 @@
#include <sys/param.h>
#include <sys/linker_set.h>
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
#include <ctype.h>
#include <errno.h>
@@ -46,6 +49,8 @@
#include <machine/vmm.h>
#include <machine/vmm_snapshot.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
#include <vmmapi.h>
#include "acpi.h"
@@ -98,6 +103,7 @@
static uint64_t pci_emul_iobase;
static uint64_t pci_emul_membase32;
static uint64_t pci_emul_membase64;
+static uint64_t pci_emul_memlim64;
#define PCI_EMUL_IOBASE 0x2000
#define PCI_EMUL_IOLIMIT 0x10000
@@ -108,9 +114,6 @@
#define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE
-#define PCI_EMUL_MEMBASE64 0xD000000000UL
-#define PCI_EMUL_MEMLIMIT64 0xFD00000000UL
-
static struct pci_devemu *pci_emul_finddev(char *name);
static void pci_lintr_route(struct pci_devinst *pi);
static void pci_lintr_update(struct pci_devinst *pi);
@@ -622,9 +625,9 @@
* Some drivers do not work well if the 64-bit BAR is allocated
* above 4GB. Allow for this by allocating small requests under
* 4GB unless then allocation size is larger than some arbitrary
- * number (32MB currently).
+ * number (128MB currently).
*/
- if (size > 32 * 1024 * 1024) {
+ if (size > 128 * 1024 * 1024) {
/*
* XXX special case for device requiring peer-peer DMA
*/
@@ -632,7 +635,7 @@
baseptr = &hostbase;
else
baseptr = &pci_emul_membase64;
- limit = PCI_EMUL_MEMLIMIT64;
+ limit = pci_emul_memlim64;
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64 |
PCIM_BAR_MEM_PREFETCH;
@@ -1101,12 +1104,25 @@
struct slotinfo *si;
struct funcinfo *fi;
size_t lowmem;
- int bus, slot, func;
- int error;
+ uint64_t cpu_maxphysaddr, pci_emul_memresv64;
+ u_int regs[4];
+ int bus, slot, func, error;
pci_emul_iobase = PCI_EMUL_IOBASE;
pci_emul_membase32 = vm_get_lowmem_limit(ctx);
- pci_emul_membase64 = PCI_EMUL_MEMBASE64;
+
+ do_cpuid(0x80000008, regs);
+ cpu_maxphysaddr = 1ULL << (regs[0] & 0xff);
+ if (cpu_maxphysaddr > VM_MAXUSER_ADDRESS_LA48)
+ cpu_maxphysaddr = VM_MAXUSER_ADDRESS_LA48;
+ pci_emul_memresv64 = cpu_maxphysaddr / 4;
+ /*
+ * Max power of 2 that is less then
+ * cpu_maxphysaddr - pci_emul_memresv64.
+ */
+ pci_emul_membase64 = 1ULL << (flsl(cpu_maxphysaddr -
+ pci_emul_memresv64) - 1);
+ pci_emul_memlim64 = cpu_maxphysaddr;
for (bus = 0; bus < MAXBUSES; bus++) {
if ((bi = pci_businfo[bus]) == NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 20, 8:12 PM (8 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27090874
Default Alt Text
D27095.id79312.diff (3 KB)
Attached To
Mode
D27095: bhyve: avoid allocating BARs above the end of supported physical addresses
Attached
Detach File
Event Timeline
Log In to Comment