blob: bcae606bbc5cfd3145aefb4f3bf2c11b5e07afe0 [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>
Jan Beulich9c111122021-09-30 14:21:13 +02003#include <linux/export.h>
Maran Wilson8cee3972018-12-10 11:08:45 -08004
Maran Wilsona43fb7d2018-12-10 11:08:46 -08005#include <xen/hvc-console.h>
6
Maran Wilson8cee3972018-12-10 11:08:45 -08007#include <asm/io_apic.h>
8#include <asm/hypervisor.h>
Maran Wilsona43fb7d2018-12-10 11:08:46 -08009#include <asm/e820/api.h>
Maran Wilson8cee3972018-12-10 11:08:45 -080010
11#include <xen/xen.h>
12#include <asm/xen/interface.h>
13#include <asm/xen/hypercall.h>
Maran Wilson4df73632018-12-10 11:08:44 -080014
Maran Wilsona43fb7d2018-12-10 11:08:46 -080015#include <xen/interface/memory.h>
16
Roger Pau Monne72813bf2019-04-23 15:04:16 +020017#include "xen-ops.h"
18
Maran Wilson4df73632018-12-10 11:08:44 -080019/*
20 * PVH variables.
21 *
Jan Beulich9c111122021-09-30 14:21:13 +020022 * The variable xen_pvh needs to live in a data segment since it is used
Maran Wilson4df73632018-12-10 11:08:44 -080023 * after startup_{32|64} is invoked, which will clear the .bss segment.
24 */
Jan Beulich9c111122021-09-30 14:21:13 +020025bool __ro_after_init xen_pvh;
26EXPORT_SYMBOL_GPL(xen_pvh);
Maran Wilson8cee3972018-12-10 11:08:45 -080027
Roger Pau Monne72813bf2019-04-23 15:04:16 +020028void __init xen_pvh_init(struct boot_params *boot_params)
Maran Wilson8cee3972018-12-10 11:08:45 -080029{
30 u32 msr;
31 u64 pfn;
32
33 xen_pvh = 1;
Roger Pau Monnec9f804d2019-04-23 15:04:15 +020034 xen_domain_type = XEN_HVM_DOMAIN;
Maran Wilson8cee3972018-12-10 11:08:45 -080035 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 Monne72813bf2019-04-23 15:04:16 +020040
Jan Beulich4d1ab432021-09-30 14:19:16 +020041 if (xen_initial_domain())
42 x86_init.oem.arch_setup = xen_add_preferred_consoles;
Jan Beulich079c4ba2021-09-30 14:19:48 +020043 x86_init.oem.banner = xen_banner;
Jan Beulich4d1ab432021-09-30 14:19:16 +020044
Roger Pau Monne72813bf2019-04-23 15:04:16 +020045 xen_efi_init(boot_params);
Maran Wilson8cee3972018-12-10 11:08:45 -080046}
Maran Wilsona43fb7d2018-12-10 11:08:46 -080047
48void __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}