Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 If hvm_start_info has no memmap_entries, fa...
details: https://anonhg.NetBSD.org/src/rev/e71d76816c27
branches: trunk
changeset: 932264:e71d76816c27
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun May 03 17:22:03 2020 +0000
description:
If hvm_start_info has no memmap_entries, fall back to XENMEM_memory_map
hypercall.
diffstat:
sys/arch/x86/x86/x86_machdep.c | 60 +++++++++++++++++++++++++++++------------
1 files changed, 42 insertions(+), 18 deletions(-)
diffs (88 lines):
diff -r 9b045ca8ff40 -r e71d76816c27 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c Sun May 03 16:32:16 2020 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c Sun May 03 17:22:03 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_machdep.c,v 1.141 2020/05/02 16:44:36 bouyer Exp $ */
+/* $NetBSD: x86_machdep.c,v 1.142 2020/05/03 17:22:03 bouyer Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.141 2020/05/02 16:44:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.142 2020/05/03 17:22:03 bouyer Exp $");
#include "opt_modular.h"
#include "opt_physmem.h"
@@ -846,6 +846,45 @@
}
}
+#ifdef XEN
+static void
+x86_add_xen_clusters(void)
+{
+ if (hvm_start_info->memmap_entries > 0) {
+ struct hvm_memmap_table_entry *map_entry;
+ map_entry = (void *)((uintptr_t)hvm_start_info->memmap_paddr + KERNBASE);
+ for (int i = 0; i < hvm_start_info->memmap_entries; i++) {
+ if (map_entry[i].size < PAGE_SIZE)
+ continue;
+ switch(map_entry[i].type) {
+ case XEN_HVM_MEMMAP_TYPE_RAM:
+ x86_add_cluster(map_entry[i].addr,
+ map_entry[i].size, BIM_Memory);
+ break;
+ case XEN_HVM_MEMMAP_TYPE_ACPI:
+ x86_add_cluster(map_entry[i].addr,
+ map_entry[i].size, BIM_ACPI);
+ break;
+ }
+ }
+ } else {
+ struct xen_memory_map memmap;
+ static struct _xen_mmap {
+ struct btinfo_memmap bim;
+ struct bi_memmap_entry map[128]; /* same as FreeBSD */
+ } __packed xen_mmap;
+ int err;
+
+ memmap.nr_entries = 128;
+ set_xen_guest_handle(memmap.buffer, &xen_mmap.bim.entry[0]);
+ if ((err = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap))
+ < 0)
+ panic("XENMEM_memory_map %d", err);
+ xen_mmap.bim.num = memmap.nr_entries;
+ x86_parse_clusters(&xen_mmap.bim);
+ }
+}
+#endif /* XEN */
/*
* init_x86_clusters: retrieve the memory clusters provided by the BIOS, and
* initialize mem_clusters.
@@ -862,22 +901,7 @@
*/
#ifdef XEN
if (vm_guest == VM_GUEST_XENPVH) {
- struct hvm_memmap_table_entry *map_entry;
- map_entry = (void *)((uintptr_t)hvm_start_info->memmap_paddr + KERNBASE);
- for (int i = 0; i < hvm_start_info->memmap_entries; i++) {
- if (map_entry[i].size < PAGE_SIZE)
- continue;
- switch(map_entry[i].type) {
- case XEN_HVM_MEMMAP_TYPE_RAM:
- x86_add_cluster(map_entry[i].addr,
- map_entry[i].size, BIM_Memory);
- break;
- case XEN_HVM_MEMMAP_TYPE_ACPI:
- x86_add_cluster(map_entry[i].addr,
- map_entry[i].size, BIM_ACPI);
- break;
- }
- }
+ x86_add_xen_clusters();
}
#endif /* XEN */
Home |
Main Index |
Thread Index |
Old Index