mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 01:46:51 +07:00
a43fb7da53
We need to refactor PVH entry code so that support for other hypervisors like Qemu/KVM can be added more easily. The original design for PVH entry in Xen guests relies on being able to obtain the memory map from the hypervisor using a hypercall. When we extend the PVH entry ABI to support other hypervisors like Qemu/KVM, a new mechanism will be added that allows the guest to get the memory map without needing to use hypercalls. For Xen guests, the hypercall approach will still be supported. In preparation for adding support for other hypervisors, we can move the code that uses hypercalls into the Xen specific file. This will allow us to compile kernels in the future without CONFIG_XEN that are still capable of being booted as a Qemu/KVM guest via the PVH entry point. Signed-off-by: Maran Wilson <maran.wilson@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/acpi.h>
|
|
|
|
#include <xen/hvc-console.h>
|
|
|
|
#include <asm/io_apic.h>
|
|
#include <asm/hypervisor.h>
|
|
#include <asm/e820/api.h>
|
|
|
|
#include <xen/xen.h>
|
|
#include <asm/xen/interface.h>
|
|
#include <asm/xen/hypercall.h>
|
|
|
|
#include <xen/interface/memory.h>
|
|
|
|
/*
|
|
* PVH variables.
|
|
*
|
|
* The variable xen_pvh needs to live in the data segment since it is used
|
|
* after startup_{32|64} is invoked, which will clear the .bss segment.
|
|
*/
|
|
bool xen_pvh __attribute__((section(".data"))) = 0;
|
|
|
|
void __init xen_pvh_init(void)
|
|
{
|
|
u32 msr;
|
|
u64 pfn;
|
|
|
|
xen_pvh = 1;
|
|
xen_start_flags = pvh_start_info.flags;
|
|
|
|
msr = cpuid_ebx(xen_cpuid_base() + 2);
|
|
pfn = __pa(hypercall_page);
|
|
wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
|
|
}
|
|
|
|
void __init mem_map_via_hcall(struct boot_params *boot_params_p)
|
|
{
|
|
struct xen_memory_map memmap;
|
|
int rc;
|
|
|
|
memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
|
|
set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
|
|
rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
|
|
if (rc) {
|
|
xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
|
|
BUG();
|
|
}
|
|
boot_params_p->e820_entries = memmap.nr_entries;
|
|
}
|