Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/acpi.h>
0003 #include <linux/export.h>
0004 
0005 #include <xen/hvc-console.h>
0006 
0007 #include <asm/io_apic.h>
0008 #include <asm/hypervisor.h>
0009 #include <asm/e820/api.h>
0010 
0011 #include <xen/xen.h>
0012 #include <asm/xen/interface.h>
0013 #include <asm/xen/hypercall.h>
0014 
0015 #include <xen/interface/memory.h>
0016 
0017 #include "xen-ops.h"
0018 
0019 /*
0020  * PVH variables.
0021  *
0022  * The variable xen_pvh needs to live in a data segment since it is used
0023  * after startup_{32|64} is invoked, which will clear the .bss segment.
0024  */
0025 bool __ro_after_init xen_pvh;
0026 EXPORT_SYMBOL_GPL(xen_pvh);
0027 
0028 void __init xen_pvh_init(struct boot_params *boot_params)
0029 {
0030     u32 msr;
0031     u64 pfn;
0032 
0033     xen_pvh = 1;
0034     xen_domain_type = XEN_HVM_DOMAIN;
0035     xen_start_flags = pvh_start_info.flags;
0036 
0037     msr = cpuid_ebx(xen_cpuid_base() + 2);
0038     pfn = __pa(hypercall_page);
0039     wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
0040 
0041     if (xen_initial_domain())
0042         x86_init.oem.arch_setup = xen_add_preferred_consoles;
0043     x86_init.oem.banner = xen_banner;
0044 
0045     xen_efi_init(boot_params);
0046 }
0047 
0048 void __init mem_map_via_hcall(struct boot_params *boot_params_p)
0049 {
0050     struct xen_memory_map memmap;
0051     int rc;
0052 
0053     memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
0054     set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
0055     rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
0056     if (rc) {
0057         xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
0058         BUG();
0059     }
0060     boot_params_p->e820_entries = memmap.nr_entries;
0061 }