blob: 80a79db72fcfd43c4abad268976e331f3e9a370b [file] [log] [blame]
Maran Wilson4df73632018-12-10 11:08:44 -08001// SPDX-License-Identifier: GPL-2.0
Maran Wilson8cee3972018-12-10 11:08:45 -08002#include <linux/acpi.h>
3
Maran Wilsona43fb7d2018-12-10 11:08:46 -08004#include <xen/hvc-console.h>
5
Maran Wilson8cee3972018-12-10 11:08:45 -08006#include <asm/io_apic.h>
7#include <asm/hypervisor.h>
Maran Wilsona43fb7d2018-12-10 11:08:46 -08008#include <asm/e820/api.h>
Maran Wilson8cee3972018-12-10 11:08:45 -08009
10#include <xen/xen.h>
11#include <asm/xen/interface.h>
12#include <asm/xen/hypercall.h>
Maran Wilson4df73632018-12-10 11:08:44 -080013
Maran Wilsona43fb7d2018-12-10 11:08:46 -080014#include <xen/interface/memory.h>
15
Roger Pau Monne72813bf2019-04-23 15:04:16 +020016#include "xen-ops.h"
17
Maran Wilson4df73632018-12-10 11:08:44 -080018/*
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 */
24bool xen_pvh __attribute__((section(".data"))) = 0;
Maran Wilson8cee3972018-12-10 11:08:45 -080025
Roger Pau Monne72813bf2019-04-23 15:04:16 +020026void __init xen_pvh_init(struct boot_params *boot_params)
Maran Wilson8cee3972018-12-10 11:08:45 -080027{
28 u32 msr;
29 u64 pfn;
30
31 xen_pvh = 1;
Roger Pau Monnec9f804d2019-04-23 15:04:15 +020032 xen_domain_type = XEN_HVM_DOMAIN;
Maran Wilson8cee3972018-12-10 11:08:45 -080033 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 Monne72813bf2019-04-23 15:04:16 +020038
39 xen_efi_init(boot_params);
Maran Wilson8cee3972018-12-10 11:08:45 -080040}
Maran Wilsona43fb7d2018-12-10 11:08:46 -080041
42void __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}