xref: /linux/arch/x86/xen/enlighten_pvh.c (revision 72813bfbf0276a97c82af038efb5f02dcdd9e310)
14df7363eSMaran Wilson // SPDX-License-Identifier: GPL-2.0
28cee3974SMaran Wilson #include <linux/acpi.h>
38cee3974SMaran Wilson 
4a43fb7daSMaran Wilson #include <xen/hvc-console.h>
5a43fb7daSMaran Wilson 
68cee3974SMaran Wilson #include <asm/io_apic.h>
78cee3974SMaran Wilson #include <asm/hypervisor.h>
8a43fb7daSMaran Wilson #include <asm/e820/api.h>
98cee3974SMaran Wilson 
108cee3974SMaran Wilson #include <xen/xen.h>
118cee3974SMaran Wilson #include <asm/xen/interface.h>
128cee3974SMaran Wilson #include <asm/xen/hypercall.h>
134df7363eSMaran Wilson 
14a43fb7daSMaran Wilson #include <xen/interface/memory.h>
15a43fb7daSMaran Wilson 
16*72813bfbSRoger Pau Monne #include "xen-ops.h"
17*72813bfbSRoger Pau Monne 
184df7363eSMaran Wilson /*
194df7363eSMaran Wilson  * PVH variables.
204df7363eSMaran Wilson  *
214df7363eSMaran Wilson  * The variable xen_pvh needs to live in the data segment since it is used
224df7363eSMaran Wilson  * after startup_{32|64} is invoked, which will clear the .bss segment.
234df7363eSMaran Wilson  */
244df7363eSMaran Wilson bool xen_pvh __attribute__((section(".data"))) = 0;
258cee3974SMaran Wilson 
26*72813bfbSRoger Pau Monne void __init xen_pvh_init(struct boot_params *boot_params)
278cee3974SMaran Wilson {
288cee3974SMaran Wilson 	u32 msr;
298cee3974SMaran Wilson 	u64 pfn;
308cee3974SMaran Wilson 
318cee3974SMaran Wilson 	xen_pvh = 1;
32c9f804d6SRoger Pau Monne 	xen_domain_type = XEN_HVM_DOMAIN;
338cee3974SMaran Wilson 	xen_start_flags = pvh_start_info.flags;
348cee3974SMaran Wilson 
358cee3974SMaran Wilson 	msr = cpuid_ebx(xen_cpuid_base() + 2);
368cee3974SMaran Wilson 	pfn = __pa(hypercall_page);
378cee3974SMaran Wilson 	wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
38*72813bfbSRoger Pau Monne 
39*72813bfbSRoger Pau Monne 	xen_efi_init(boot_params);
408cee3974SMaran Wilson }
41a43fb7daSMaran Wilson 
42a43fb7daSMaran Wilson void __init mem_map_via_hcall(struct boot_params *boot_params_p)
43a43fb7daSMaran Wilson {
44a43fb7daSMaran Wilson 	struct xen_memory_map memmap;
45a43fb7daSMaran Wilson 	int rc;
46a43fb7daSMaran Wilson 
47a43fb7daSMaran Wilson 	memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
48a43fb7daSMaran Wilson 	set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
49a43fb7daSMaran Wilson 	rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
50a43fb7daSMaran Wilson 	if (rc) {
51a43fb7daSMaran Wilson 		xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
52a43fb7daSMaran Wilson 		BUG();
53a43fb7daSMaran Wilson 	}
54a43fb7daSMaran Wilson 	boot_params_p->e820_entries = memmap.nr_entries;
55a43fb7daSMaran Wilson }
56