2018-12-10 11:08:44 -08:00
// SPDX-License-Identifier: GPL-2.0
2018-12-10 11:08:45 -08:00
# include <linux/acpi.h>
2021-09-30 14:21:13 +02:00
# include <linux/export.h>
2018-12-10 11:08:45 -08:00
2018-12-10 11:08:46 -08:00
# include <xen/hvc-console.h>
2018-12-10 11:08:45 -08:00
# include <asm/io_apic.h>
# include <asm/hypervisor.h>
2018-12-10 11:08:46 -08:00
# include <asm/e820/api.h>
2018-12-10 11:08:45 -08:00
# include <xen/xen.h>
# include <asm/xen/interface.h>
# include <asm/xen/hypercall.h>
2018-12-10 11:08:44 -08:00
2018-12-10 11:08:46 -08:00
# include <xen/interface/memory.h>
2019-04-23 15:04:16 +02:00
# include "xen-ops.h"
2018-12-10 11:08:44 -08:00
/*
* PVH variables .
*
2021-09-30 14:21:13 +02:00
* The variable xen_pvh needs to live in a data segment since it is used
2018-12-10 11:08:44 -08:00
* after startup_ { 32 | 64 } is invoked , which will clear the . bss segment .
*/
2021-09-30 14:21:13 +02:00
bool __ro_after_init xen_pvh ;
EXPORT_SYMBOL_GPL ( xen_pvh ) ;
2018-12-10 11:08:45 -08:00
2019-04-23 15:04:16 +02:00
void __init xen_pvh_init ( struct boot_params * boot_params )
2018-12-10 11:08:45 -08:00
{
u32 msr ;
u64 pfn ;
xen_pvh = 1 ;
2019-04-23 15:04:15 +02:00
xen_domain_type = XEN_HVM_DOMAIN ;
2018-12-10 11:08:45 -08:00
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 ) ) ;
2019-04-23 15:04:16 +02:00
2021-09-30 14:19:16 +02:00
if ( xen_initial_domain ( ) )
x86_init . oem . arch_setup = xen_add_preferred_consoles ;
2021-09-30 14:19:48 +02:00
x86_init . oem . banner = xen_banner ;
2021-09-30 14:19:16 +02:00
2019-04-23 15:04:16 +02:00
xen_efi_init ( boot_params ) ;
2023-03-13 15:45:48 +01:00
if ( xen_initial_domain ( ) ) {
struct xen_platform_op op = {
. cmd = XENPF_get_dom0_console ,
} ;
2023-03-21 09:03:26 +01:00
int ret = HYPERVISOR_platform_op ( & op ) ;
2023-03-13 15:45:48 +01:00
if ( ret > 0 )
xen_init_vga ( & op . u . dom0_console ,
min ( ret * sizeof ( char ) ,
sizeof ( op . u . dom0_console ) ) ,
& boot_params - > screen_info ) ;
}
2018-12-10 11:08:45 -08:00
}
2018-12-10 11:08:46 -08:00
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 ;
}