Maran Wilson | 4df7363 | 2018-12-10 11:08:44 -0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 2 | #include <linux/acpi.h> |
| 3 | |
Maran Wilson | a43fb7d | 2018-12-10 11:08:46 -0800 | [diff] [blame] | 4 | #include <xen/hvc-console.h> |
| 5 | |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 6 | #include <asm/io_apic.h> |
| 7 | #include <asm/hypervisor.h> |
Maran Wilson | a43fb7d | 2018-12-10 11:08:46 -0800 | [diff] [blame] | 8 | #include <asm/e820/api.h> |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 9 | |
| 10 | #include <xen/xen.h> |
| 11 | #include <asm/xen/interface.h> |
| 12 | #include <asm/xen/hypercall.h> |
Maran Wilson | 4df7363 | 2018-12-10 11:08:44 -0800 | [diff] [blame] | 13 | |
Maran Wilson | a43fb7d | 2018-12-10 11:08:46 -0800 | [diff] [blame] | 14 | #include <xen/interface/memory.h> |
| 15 | |
Roger Pau Monne | 72813bf | 2019-04-23 15:04:16 +0200 | [diff] [blame] | 16 | #include "xen-ops.h" |
| 17 | |
Maran Wilson | 4df7363 | 2018-12-10 11:08:44 -0800 | [diff] [blame] | 18 | /* |
| 19 | * PVH variables. |
| 20 | * |
| 21 | * The variable xen_pvh needs to live in the data segment since it is used |
| 22 | * after startup_{32|64} is invoked, which will clear the .bss segment. |
| 23 | */ |
| 24 | bool xen_pvh __attribute__((section(".data"))) = 0; |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 25 | |
Roger Pau Monne | 72813bf | 2019-04-23 15:04:16 +0200 | [diff] [blame] | 26 | void __init xen_pvh_init(struct boot_params *boot_params) |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 27 | { |
| 28 | u32 msr; |
| 29 | u64 pfn; |
| 30 | |
| 31 | xen_pvh = 1; |
Roger Pau Monne | c9f804d | 2019-04-23 15:04:15 +0200 | [diff] [blame] | 32 | xen_domain_type = XEN_HVM_DOMAIN; |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 33 | xen_start_flags = pvh_start_info.flags; |
| 34 | |
| 35 | msr = cpuid_ebx(xen_cpuid_base() + 2); |
| 36 | pfn = __pa(hypercall_page); |
| 37 | wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); |
Roger Pau Monne | 72813bf | 2019-04-23 15:04:16 +0200 | [diff] [blame] | 38 | |
| 39 | xen_efi_init(boot_params); |
Maran Wilson | 8cee397 | 2018-12-10 11:08:45 -0800 | [diff] [blame] | 40 | } |
Maran Wilson | a43fb7d | 2018-12-10 11:08:46 -0800 | [diff] [blame] | 41 | |
| 42 | void __init mem_map_via_hcall(struct boot_params *boot_params_p) |
| 43 | { |
| 44 | struct xen_memory_map memmap; |
| 45 | int rc; |
| 46 | |
| 47 | memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table); |
| 48 | set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table); |
| 49 | rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); |
| 50 | if (rc) { |
| 51 | xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc); |
| 52 | BUG(); |
| 53 | } |
| 54 | boot_params_p->e820_entries = memmap.nr_entries; |
| 55 | } |