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