Page MenuHomeFreeBSD

D46123.diff
No OneTemporary

D46123.diff

diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c
--- a/sys/x86/xen/hvm.c
+++ b/sys/x86/xen/hvm.c
@@ -47,6 +47,7 @@
#include <machine/cpu.h>
#include <machine/md_var.h>
#include <machine/metadata.h>
+#include <machine/pc/bios.h>
#include <machine/smp.h>
#include <x86/apicreg.h>
@@ -548,3 +549,52 @@
return (regs[0] & XEN_HVM_CPUID_IOMMU_MAPPINGS);
}
+
+int
+xen_arch_init_physmem(device_t dev, struct rman *mem)
+{
+ static struct bios_smap smap[128];
+ struct xen_memory_map memmap = {
+ .nr_entries = nitems(smap),
+ };
+ unsigned int i;
+ int error;
+
+ set_xen_guest_handle(memmap.buffer, smap);
+ error = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
+ if (error != 0)
+ return (error);
+
+ /*
+ * Fill with UNUSABLE regions, as it's always fine to use those for
+ * foreign mappings, they will never be populated.
+ */
+ for (i = 0; i < memmap.nr_entries; i++) {
+ const vm_paddr_t max_phys = cpu_getmaxphyaddr();
+ vm_paddr_t start, end;
+
+ if (smap[i].type != SMAP_TYPE_ACPI_ERROR)
+ continue;
+
+ start = round_page(smap[i].base);
+ /* In 32bit mode we possibly need to truncate the addresses. */
+ end = MIN(trunc_page(smap[i].base + smap[i].length) - 1,
+ max_phys);
+
+ if (start >= end)
+ continue;
+
+ if (bootverbose != 0)
+ device_printf(dev,
+ "scratch mapping region @ [%016jx, %016jx]\n",
+ start, end);
+
+ error = rman_manage_region(mem, start, end);
+ if (error != 0)
+ device_printf(dev,
+ "unable to add scratch region [%016jx, %016jx]: %d\n",
+ start, end, error);
+ }
+
+ return (0);
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 7:58 PM (10 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15735340
Default Alt Text
D46123.diff (1 KB)

Event Timeline