Merge tag 'lkmm.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck...
[linux-block.git] / arch / x86 / xen / enlighten_pvh.c
CommitLineData
4df7363e 1// SPDX-License-Identifier: GPL-2.0
8cee3974 2#include <linux/acpi.h>
9c11112c 3#include <linux/export.h>
8cee3974 4
a43fb7da
MW
5#include <xen/hvc-console.h>
6
8cee3974
MW
7#include <asm/io_apic.h>
8#include <asm/hypervisor.h>
a43fb7da 9#include <asm/e820/api.h>
8cee3974
MW
10
11#include <xen/xen.h>
12#include <asm/xen/interface.h>
13#include <asm/xen/hypercall.h>
4df7363e 14
a43fb7da
MW
15#include <xen/interface/memory.h>
16
72813bfb
RPM
17#include "xen-ops.h"
18
4df7363e
MW
19/*
20 * PVH variables.
21 *
9c11112c 22 * The variable xen_pvh needs to live in a data segment since it is used
4df7363e
MW
23 * after startup_{32|64} is invoked, which will clear the .bss segment.
24 */
9c11112c
JB
25bool __ro_after_init xen_pvh;
26EXPORT_SYMBOL_GPL(xen_pvh);
8cee3974 27
72813bfb 28void __init xen_pvh_init(struct boot_params *boot_params)
8cee3974
MW
29{
30 u32 msr;
31 u64 pfn;
32
33 xen_pvh = 1;
c9f804d6 34 xen_domain_type = XEN_HVM_DOMAIN;
8cee3974
MW
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));
72813bfb 40
4d1ab432
JB
41 if (xen_initial_domain())
42 x86_init.oem.arch_setup = xen_add_preferred_consoles;
079c4baa 43 x86_init.oem.banner = xen_banner;
4d1ab432 44
72813bfb 45 xen_efi_init(boot_params);
934ef33e
JB
46
47 if (xen_initial_domain()) {
48 struct xen_platform_op op = {
49 .cmd = XENPF_get_dom0_console,
50 };
aadbd07f 51 int ret = HYPERVISOR_platform_op(&op);
934ef33e
JB
52
53 if (ret > 0)
54 xen_init_vga(&op.u.dom0_console,
55 min(ret * sizeof(char),
56 sizeof(op.u.dom0_console)),
57 &boot_params->screen_info);
58 }
8cee3974 59}
a43fb7da
MW
60
61void __init mem_map_via_hcall(struct boot_params *boot_params_p)
62{
63 struct xen_memory_map memmap;
64 int rc;
65
66 memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
67 set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
68 rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
69 if (rc) {
70 xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
71 BUG();
72 }
73 boot_params_p->e820_entries = memmap.nr_entries;
74}