enlighten_pvh.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/acpi.h>
  3. #include <linux/export.h>
  4. #include <xen/hvc-console.h>
  5. #include <asm/io_apic.h>
  6. #include <asm/hypervisor.h>
  7. #include <asm/e820/api.h>
  8. #include <xen/xen.h>
  9. #include <asm/xen/interface.h>
  10. #include <asm/xen/hypercall.h>
  11. #include <xen/interface/memory.h>
  12. #include "xen-ops.h"
  13. /*
  14. * PVH variables.
  15. *
  16. * The variable xen_pvh needs to live in a data segment since it is used
  17. * after startup_{32|64} is invoked, which will clear the .bss segment.
  18. */
  19. bool __ro_after_init xen_pvh;
  20. EXPORT_SYMBOL_GPL(xen_pvh);
  21. void __init xen_pvh_init(struct boot_params *boot_params)
  22. {
  23. u32 msr;
  24. u64 pfn;
  25. xen_pvh = 1;
  26. xen_domain_type = XEN_HVM_DOMAIN;
  27. xen_start_flags = pvh_start_info.flags;
  28. msr = cpuid_ebx(xen_cpuid_base() + 2);
  29. pfn = __pa(hypercall_page);
  30. wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
  31. if (xen_initial_domain())
  32. x86_init.oem.arch_setup = xen_add_preferred_consoles;
  33. x86_init.oem.banner = xen_banner;
  34. xen_efi_init(boot_params);
  35. if (xen_initial_domain()) {
  36. struct xen_platform_op op = {
  37. .cmd = XENPF_get_dom0_console,
  38. };
  39. int ret = HYPERVISOR_platform_op(&op);
  40. if (ret > 0)
  41. xen_init_vga(&op.u.dom0_console,
  42. min(ret * sizeof(char),
  43. sizeof(op.u.dom0_console)),
  44. &boot_params->screen_info);
  45. }
  46. }
  47. void __init mem_map_via_hcall(struct boot_params *boot_params_p)
  48. {
  49. struct xen_memory_map memmap;
  50. int rc;
  51. memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
  52. set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
  53. rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
  54. if (rc) {
  55. xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
  56. BUG();
  57. }
  58. boot_params_p->e820_entries = memmap.nr_entries;
  59. }