pv.c (ad7dd5149910a7bc5ff5353a54393e64e3e74690) pv.c (77cb05db0cee0b052cc1a75da0741eb404eed473)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
3 *
4 * Copyright (c) 2004 Christian Limpach.
5 * Copyright (c) 2004-2006,2008 Kip Macy
6 * Copyright (c) 2008 The NetBSD Foundation, Inc.
7 * Copyright (c) 2013 Roger Pau Monné <roger.pau@citrix.com>
8 * All rights reserved.

--- 54 unchanged lines hidden (view full) ---

63#include <machine/intr_machdep.h>
64#include <x86/apicvar.h>
65#include <x86/init.h>
66#include <machine/pc/bios.h>
67#include <machine/smp.h>
68#include <machine/intr_machdep.h>
69#include <machine/md_var.h>
70#include <machine/metadata.h>
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
3 *
4 * Copyright (c) 2004 Christian Limpach.
5 * Copyright (c) 2004-2006,2008 Kip Macy
6 * Copyright (c) 2008 The NetBSD Foundation, Inc.
7 * Copyright (c) 2013 Roger Pau Monné <roger.pau@citrix.com>
8 * All rights reserved.

--- 54 unchanged lines hidden (view full) ---

63#include <machine/intr_machdep.h>
64#include <x86/apicvar.h>
65#include <x86/init.h>
66#include <machine/pc/bios.h>
67#include <machine/smp.h>
68#include <machine/intr_machdep.h>
69#include <machine/md_var.h>
70#include <machine/metadata.h>
71#include <machine/cpu.h>
71
72#include <xen/xen-os.h>
73#include <xen/hvm.h>
74#include <xen/hypervisor.h>
75#include <xen/xenstore/xenstorevar.h>
76#include <xen/xen_pv.h>
77
78#include <contrib/xen/arch-x86/hvm/start_info.h>

--- 59 unchanged lines hidden (view full) ---

138 start_info = (struct hvm_start_info *)(start_info_paddr + KERNBASE);
139 if (start_info->magic != XEN_HVM_START_MAGIC_VALUE) {
140 xc_printf("Unknown magic value in start_info struct: %#x\n",
141 start_info->magic);
142 HYPERVISOR_shutdown(SHUTDOWN_crash);
143 }
144
145 /*
72
73#include <xen/xen-os.h>
74#include <xen/hvm.h>
75#include <xen/hypervisor.h>
76#include <xen/xenstore/xenstorevar.h>
77#include <xen/xen_pv.h>
78
79#include <contrib/xen/arch-x86/hvm/start_info.h>

--- 59 unchanged lines hidden (view full) ---

139 start_info = (struct hvm_start_info *)(start_info_paddr + KERNBASE);
140 if (start_info->magic != XEN_HVM_START_MAGIC_VALUE) {
141 xc_printf("Unknown magic value in start_info struct: %#x\n",
142 start_info->magic);
143 HYPERVISOR_shutdown(SHUTDOWN_crash);
144 }
145
146 /*
146 * The hvm_start_into structure is always appended after loading
147 * the kernel and modules.
147 * Select the higher address to use as physfree: either after
148 * start_info, after the kernel, after the memory map or after any of
149 * the modules. We assume enough memory to be available after the
150 * selected address for the needs of very early memory allocations.
148 */
151 */
149 physfree = roundup2(start_info_paddr + PAGE_SIZE, PAGE_SIZE);
152 physfree = roundup2(start_info_paddr + sizeof(struct hvm_start_info),
153 PAGE_SIZE);
154 physfree = MAX(roundup2((vm_paddr_t)_end - KERNBASE, PAGE_SIZE),
155 physfree);
150
156
157 if (start_info->memmap_paddr != 0)
158 physfree = MAX(roundup2(start_info->memmap_paddr +
159 start_info->memmap_entries *
160 sizeof(struct hvm_memmap_table_entry), PAGE_SIZE),
161 physfree);
162
163 if (start_info->modlist_paddr != 0) {
164 unsigned int i;
165
166 if (start_info->nr_modules == 0) {
167 xc_printf(
168 "ERROR: modlist_paddr != 0 but nr_modules == 0\n");
169 HYPERVISOR_shutdown(SHUTDOWN_crash);
170 }
171 mod = (struct hvm_modlist_entry *)
172 (start_info->modlist_paddr + KERNBASE);
173 for (i = 0; i < start_info->nr_modules; i++)
174 physfree = MAX(roundup2(mod[i].paddr + mod[i].size,
175 PAGE_SIZE), physfree);
176 }
177
151 xatp.domid = DOMID_SELF;
152 xatp.idx = 0;
153 xatp.space = XENMAPSPACE_shared_info;
154 xatp.gpfn = atop(physfree);
155 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) {
156 xc_printf("ERROR: failed to setup shared_info page\n");
157 HYPERVISOR_shutdown(SHUTDOWN_crash);
158 }

--- 4 unchanged lines hidden (view full) ---

163 * Init a static kenv using a free page. The contents will be filled
164 * from the parse_preload_data hook.
165 */
166 kenv = (void *)(physfree + KERNBASE);
167 physfree += PAGE_SIZE;
168 bzero_early(kenv, PAGE_SIZE);
169 init_static_kenv(kenv, PAGE_SIZE);
170
178 xatp.domid = DOMID_SELF;
179 xatp.idx = 0;
180 xatp.space = XENMAPSPACE_shared_info;
181 xatp.gpfn = atop(physfree);
182 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) {
183 xc_printf("ERROR: failed to setup shared_info page\n");
184 HYPERVISOR_shutdown(SHUTDOWN_crash);
185 }

--- 4 unchanged lines hidden (view full) ---

190 * Init a static kenv using a free page. The contents will be filled
191 * from the parse_preload_data hook.
192 */
193 kenv = (void *)(physfree + KERNBASE);
194 physfree += PAGE_SIZE;
195 bzero_early(kenv, PAGE_SIZE);
196 init_static_kenv(kenv, PAGE_SIZE);
197
171 if (start_info->modlist_paddr != 0) {
172 if (start_info->modlist_paddr >= physfree) {
173 xc_printf(
174 "ERROR: unexpected module list memory address\n");
175 HYPERVISOR_shutdown(SHUTDOWN_crash);
176 }
177 if (start_info->nr_modules == 0) {
178 xc_printf(
179 "ERROR: modlist_paddr != 0 but nr_modules == 0\n");
180 HYPERVISOR_shutdown(SHUTDOWN_crash);
181 }
182 mod = (struct hvm_modlist_entry *)
183 (start_info->modlist_paddr + KERNBASE);
184 if (mod[0].paddr >= physfree) {
185 xc_printf("ERROR: unexpected module memory address\n");
186 HYPERVISOR_shutdown(SHUTDOWN_crash);
187 }
188 }
189
190 /* Set the hooks for early functions that diverge from bare metal */
191 init_ops = xen_pvh_init_ops;
192 hvm_start_flags = start_info->flags;
193
194 /* Now we can jump into the native init function */
195 return (hammer_time(0, physfree));
196}
197

--- 213 unchanged lines hidden ---
198 /* Set the hooks for early functions that diverge from bare metal */
199 init_ops = xen_pvh_init_ops;
200 hvm_start_flags = start_info->flags;
201
202 /* Now we can jump into the native init function */
203 return (hammer_time(0, physfree));
204}
205

--- 213 unchanged lines hidden ---