99#include <asm/io_apic.h>
1010#include <asm/hypervisor.h>
1111#include <asm/e820/api.h>
12+ #include <asm/setup.h>
1213
1314#include <xen/xen.h>
1415#include <asm/xen/interface.h>
2728bool __ro_after_init xen_pvh ;
2829EXPORT_SYMBOL_GPL (xen_pvh );
2930
30- void __init xen_pvh_init (struct boot_params * boot_params )
31- {
32- u32 msr ;
33- u64 pfn ;
34-
35- xen_pvh = 1 ;
36- xen_domain_type = XEN_HVM_DOMAIN ;
37- xen_start_flags = pvh_start_info .flags ;
38-
39- msr = cpuid_ebx (xen_cpuid_base () + 2 );
40- pfn = __pa (hypercall_page );
41- wrmsr_safe (msr , (u32 )pfn , (u32 )(pfn >> 32 ));
42-
43- if (xen_initial_domain ())
44- x86_init .oem .arch_setup = xen_add_preferred_consoles ;
45- x86_init .oem .banner = xen_banner ;
46-
47- xen_efi_init (boot_params );
48-
49- if (xen_initial_domain ()) {
50- struct xen_platform_op op = {
51- .cmd = XENPF_get_dom0_console ,
52- };
53- int ret = HYPERVISOR_platform_op (& op );
54-
55- if (ret > 0 )
56- xen_init_vga (& op .u .dom0_console ,
57- min (ret * sizeof (char ),
58- sizeof (op .u .dom0_console )),
59- & boot_params -> screen_info );
60- }
61- }
62-
63- void __init mem_map_via_hcall (struct boot_params * boot_params_p )
64- {
65- struct xen_memory_map memmap ;
66- int rc ;
67-
68- memmap .nr_entries = ARRAY_SIZE (boot_params_p -> e820_table );
69- set_xen_guest_handle (memmap .buffer , boot_params_p -> e820_table );
70- rc = HYPERVISOR_memory_op (XENMEM_memory_map , & memmap );
71- if (rc ) {
72- xen_raw_printk ("XENMEM_memory_map failed (%d)\n" , rc );
73- BUG ();
74- }
75- boot_params_p -> e820_entries = memmap .nr_entries ;
76- }
77-
7831/*
7932 * Reserve e820 UNUSABLE regions to inflate the memory balloon.
8033 *
@@ -89,8 +42,9 @@ void __init mem_map_via_hcall(struct boot_params *boot_params_p)
8942 * hypervisor should notify us which memory ranges are suitable for creating
9043 * foreign mappings, but that's not yet implemented.
9144 */
92- void __init xen_reserve_extra_memory ( struct boot_params * bootp )
45+ static void __init pvh_reserve_extra_memory ( void )
9346{
47+ struct boot_params * bootp = & boot_params ;
9448 unsigned int i , ram_pages = 0 , extra_pages ;
9549
9650 for (i = 0 ; i < bootp -> e820_entries ; i ++ ) {
@@ -141,3 +95,58 @@ void __init xen_reserve_extra_memory(struct boot_params *bootp)
14195 xen_add_extra_mem (PFN_UP (e -> addr ), pages );
14296 }
14397}
98+
99+ static void __init pvh_arch_setup (void )
100+ {
101+ pvh_reserve_extra_memory ();
102+
103+ if (xen_initial_domain ())
104+ xen_add_preferred_consoles ();
105+ }
106+
107+ void __init xen_pvh_init (struct boot_params * boot_params )
108+ {
109+ u32 msr ;
110+ u64 pfn ;
111+
112+ xen_pvh = 1 ;
113+ xen_domain_type = XEN_HVM_DOMAIN ;
114+ xen_start_flags = pvh_start_info .flags ;
115+
116+ msr = cpuid_ebx (xen_cpuid_base () + 2 );
117+ pfn = __pa (hypercall_page );
118+ wrmsr_safe (msr , (u32 )pfn , (u32 )(pfn >> 32 ));
119+
120+ x86_init .oem .arch_setup = pvh_arch_setup ;
121+ x86_init .oem .banner = xen_banner ;
122+
123+ xen_efi_init (boot_params );
124+
125+ if (xen_initial_domain ()) {
126+ struct xen_platform_op op = {
127+ .cmd = XENPF_get_dom0_console ,
128+ };
129+ int ret = HYPERVISOR_platform_op (& op );
130+
131+ if (ret > 0 )
132+ xen_init_vga (& op .u .dom0_console ,
133+ min (ret * sizeof (char ),
134+ sizeof (op .u .dom0_console )),
135+ & boot_params -> screen_info );
136+ }
137+ }
138+
139+ void __init mem_map_via_hcall (struct boot_params * boot_params_p )
140+ {
141+ struct xen_memory_map memmap ;
142+ int rc ;
143+
144+ memmap .nr_entries = ARRAY_SIZE (boot_params_p -> e820_table );
145+ set_xen_guest_handle (memmap .buffer , boot_params_p -> e820_table );
146+ rc = HYPERVISOR_memory_op (XENMEM_memory_map , & memmap );
147+ if (rc ) {
148+ xen_raw_printk ("XENMEM_memory_map failed (%d)\n" , rc );
149+ BUG ();
150+ }
151+ boot_params_p -> e820_entries = memmap .nr_entries ;
152+ }
0 commit comments