~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/platform/pvh/enlighten.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/acpi.h>
  3 
  4 #include <xen/hvc-console.h>
  5 
  6 #include <asm/bootparam.h>
  7 #include <asm/io_apic.h>
  8 #include <asm/hypervisor.h>
  9 #include <asm/e820/api.h>
 10 #include <asm/x86_init.h>
 11 
 12 #include <asm/xen/interface.h>
 13 
 14 #include <xen/xen.h>
 15 #include <xen/interface/hvm/start_info.h>
 16 
 17 /*
 18  * PVH variables.
 19  *
 20  * pvh_bootparams and pvh_start_info need to live in a data segment since
 21  * they are used after startup_{32|64}, which clear .bss, are invoked.
 22  */
 23 struct boot_params __initdata pvh_bootparams;
 24 struct hvm_start_info __initdata pvh_start_info;
 25 
 26 const unsigned int __initconst pvh_start_info_sz = sizeof(pvh_start_info);
 27 
 28 static u64 __init pvh_get_root_pointer(void)
 29 {
 30         return pvh_start_info.rsdp_paddr;
 31 }
 32 
 33 /*
 34  * Xen guests are able to obtain the memory map from the hypervisor via the
 35  * HYPERVISOR_memory_op hypercall.
 36  * If we are trying to boot a Xen PVH guest, it is expected that the kernel
 37  * will have been configured to provide an override for this routine to do
 38  * just that.
 39  */
 40 void __init __weak mem_map_via_hcall(struct boot_params *ptr __maybe_unused)
 41 {
 42         xen_raw_printk("Error: Could not find memory map\n");
 43         BUG();
 44 }
 45 
 46 static void __init init_pvh_bootparams(bool xen_guest)
 47 {
 48         if ((pvh_start_info.version > 0) && (pvh_start_info.memmap_entries)) {
 49                 struct hvm_memmap_table_entry *ep;
 50                 int i;
 51 
 52                 ep = __va(pvh_start_info.memmap_paddr);
 53                 pvh_bootparams.e820_entries = pvh_start_info.memmap_entries;
 54 
 55                 for (i = 0; i < pvh_bootparams.e820_entries ; i++, ep++) {
 56                         pvh_bootparams.e820_table[i].addr = ep->addr;
 57                         pvh_bootparams.e820_table[i].size = ep->size;
 58                         pvh_bootparams.e820_table[i].type = ep->type;
 59                 }
 60         } else if (xen_guest) {
 61                 mem_map_via_hcall(&pvh_bootparams);
 62         } else {
 63                 /* Non-xen guests are not supported by version 0 */
 64                 BUG();
 65         }
 66 
 67         if (pvh_bootparams.e820_entries < E820_MAX_ENTRIES_ZEROPAGE - 1) {
 68                 pvh_bootparams.e820_table[pvh_bootparams.e820_entries].addr =
 69                         ISA_START_ADDRESS;
 70                 pvh_bootparams.e820_table[pvh_bootparams.e820_entries].size =
 71                         ISA_END_ADDRESS - ISA_START_ADDRESS;
 72                 pvh_bootparams.e820_table[pvh_bootparams.e820_entries].type =
 73                         E820_TYPE_RESERVED;
 74                 pvh_bootparams.e820_entries++;
 75         } else
 76                 xen_raw_printk("Warning: Can fit ISA range into e820\n");
 77 
 78         pvh_bootparams.hdr.cmd_line_ptr =
 79                 pvh_start_info.cmdline_paddr;
 80 
 81         /* The first module is always ramdisk. */
 82         if (pvh_start_info.nr_modules) {
 83                 struct hvm_modlist_entry *modaddr =
 84                         __va(pvh_start_info.modlist_paddr);
 85                 pvh_bootparams.hdr.ramdisk_image = modaddr->paddr;
 86                 pvh_bootparams.hdr.ramdisk_size = modaddr->size;
 87         }
 88 
 89         /*
 90          * See Documentation/arch/x86/boot.rst.
 91          *
 92          * Version 2.12 supports Xen entry point but we will use default x86/PC
 93          * environment (i.e. hardware_subarch 0).
 94          */
 95         pvh_bootparams.hdr.version = (2 << 8) | 12;
 96         pvh_bootparams.hdr.type_of_loader = ((xen_guest ? 0x9 : 0xb) << 4) | 0;
 97 
 98         x86_init.acpi.get_root_pointer = pvh_get_root_pointer;
 99 }
100 
101 /*
102  * If we are trying to boot a Xen PVH guest, it is expected that the kernel
103  * will have been configured to provide the required override for this routine.
104  */
105 void __init __weak xen_pvh_init(struct boot_params *boot_params)
106 {
107         xen_raw_printk("Error: Missing xen PVH initialization\n");
108         BUG();
109 }
110 
111 static void __init hypervisor_specific_init(bool xen_guest)
112 {
113         if (xen_guest)
114                 xen_pvh_init(&pvh_bootparams);
115 }
116 
117 /*
118  * This routine (and those that it might call) should not use
119  * anything that lives in .bss since that segment will be cleared later.
120  */
121 void __init xen_prepare_pvh(void)
122 {
123 
124         u32 msr = xen_cpuid_base();
125         bool xen_guest = !!msr;
126 
127         if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) {
128                 xen_raw_printk("Error: Unexpected magic value (0x%08x)\n",
129                                 pvh_start_info.magic);
130                 BUG();
131         }
132 
133         memset(&pvh_bootparams, 0, sizeof(pvh_bootparams));
134 
135         hypervisor_specific_init(xen_guest);
136 
137         init_pvh_bootparams(xen_guest);
138 }
139 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php