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

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/jailhouse.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/kernel/jailhouse.c (Version linux-6.12-rc7) and /arch/m68k/kernel/jailhouse.c (Version linux-4.17.19)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * Jailhouse paravirt_ops implementation          
  4  *                                                
  5  * Copyright (c) Siemens AG, 2015-2017            
  6  *                                                
  7  * Authors:                                       
  8  *  Jan Kiszka <jan.kiszka@siemens.com>           
  9  */                                               
 10                                                   
 11 #include <linux/acpi_pmtmr.h>                     
 12 #include <linux/kernel.h>                         
 13 #include <linux/reboot.h>                         
 14 #include <linux/serial_8250.h>                    
 15 #include <linux/acpi.h>                           
 16 #include <asm/apic.h>                             
 17 #include <asm/io_apic.h>                          
 18 #include <asm/acpi.h>                             
 19 #include <asm/cpu.h>                              
 20 #include <asm/hypervisor.h>                       
 21 #include <asm/i8259.h>                            
 22 #include <asm/irqdomain.h>                        
 23 #include <asm/pci_x86.h>                          
 24 #include <asm/reboot.h>                           
 25 #include <asm/setup.h>                            
 26 #include <asm/jailhouse_para.h>                   
 27                                                   
 28 static struct jailhouse_setup_data setup_data;    
 29 #define SETUP_DATA_V1_LEN       (sizeof(setup_    
 30 #define SETUP_DATA_V2_LEN       (SETUP_DATA_V1    
 31                                                   
 32 static unsigned int precalibrated_tsc_khz;        
 33                                                   
 34 static void jailhouse_setup_irq(unsigned int i    
 35 {                                                 
 36         struct mpc_intsrc mp_irq = {              
 37                 .type           = MP_INTSRC,      
 38                 .irqtype        = mp_INT,         
 39                 .irqflag        = MP_IRQPOL_AC    
 40                 .srcbusirq      = irq,            
 41                 .dstirq         = irq,            
 42         };                                        
 43         mp_save_irq(&mp_irq);                     
 44 }                                                 
 45                                                   
 46 static uint32_t jailhouse_cpuid_base(void)        
 47 {                                                 
 48         if (boot_cpu_data.cpuid_level < 0 ||      
 49             !boot_cpu_has(X86_FEATURE_HYPERVIS    
 50                 return 0;                         
 51                                                   
 52         return hypervisor_cpuid_base("Jailhous    
 53 }                                                 
 54                                                   
 55 static uint32_t __init jailhouse_detect(void)     
 56 {                                                 
 57         return jailhouse_cpuid_base();            
 58 }                                                 
 59                                                   
 60 static void jailhouse_get_wallclock(struct tim    
 61 {                                                 
 62         memset(now, 0, sizeof(*now));             
 63 }                                                 
 64                                                   
 65 static void __init jailhouse_timer_init(void)     
 66 {                                                 
 67         lapic_timer_period = setup_data.v1.api    
 68 }                                                 
 69                                                   
 70 static unsigned long jailhouse_get_tsc(void)      
 71 {                                                 
 72         return precalibrated_tsc_khz;             
 73 }                                                 
 74                                                   
 75 static void __init jailhouse_x2apic_init(void)    
 76 {                                                 
 77 #ifdef CONFIG_X86_X2APIC                          
 78         if (!x2apic_enabled())                    
 79                 return;                           
 80         /*                                        
 81          * We do not have access to IR inside     
 82          * we have to run in physical mode.       
 83          */                                       
 84         x2apic_phys = 1;                          
 85         /*                                        
 86          * This will trigger the switch to api    
 87          * ensure that only this APIC driver p    
 88          */                                       
 89         default_acpi_madt_oem_check("", "");      
 90 #endif                                            
 91 }                                                 
 92                                                   
 93 static void __init jailhouse_parse_smp_config(    
 94 {                                                 
 95         struct ioapic_domain_cfg ioapic_cfg =     
 96                 .type = IOAPIC_DOMAIN_STRICT,     
 97                 .ops = &mp_ioapic_irqdomain_op    
 98         };                                        
 99         unsigned int cpu;                         
100                                                   
101         jailhouse_x2apic_init();                  
102                                                   
103         register_lapic_address(0xfee00000);       
104                                                   
105         for (cpu = 0; cpu < setup_data.v1.num_    
106                 topology_register_apic(setup_d    
107                                                   
108         smp_found_config = 1;                     
109                                                   
110         if (setup_data.v1.standard_ioapic) {      
111                 mp_register_ioapic(0, 0xfec000    
112                                                   
113                 if (IS_ENABLED(CONFIG_SERIAL_8    
114                     setup_data.hdr.version < 2    
115                         /* Register 1:1 mappin    
116                         jailhouse_setup_irq(3)    
117                         jailhouse_setup_irq(4)    
118                 }                                 
119         }                                         
120 }                                                 
121                                                   
122 static void jailhouse_no_restart(void)            
123 {                                                 
124         pr_notice("Jailhouse: Restart not supp    
125         machine_halt();                           
126 }                                                 
127                                                   
128 static int __init jailhouse_pci_arch_init(void    
129 {                                                 
130         pci_direct_init(1);                       
131                                                   
132         /*                                        
133          * There are no bridges on the virtual    
134          * thus no other way to discover all d    
135          * Respect any overrides via the comma    
136          */                                       
137         if (pcibios_last_bus < 0)                 
138                 pcibios_last_bus = 0xff;          
139                                                   
140 #ifdef CONFIG_PCI_MMCONFIG                        
141         if (setup_data.v1.pci_mmconfig_base) {    
142                 pci_mmconfig_add(0, 0, pcibios    
143                                  setup_data.v1    
144                 pci_mmcfg_arch_init();            
145         }                                         
146 #endif                                            
147                                                   
148         return 0;                                 
149 }                                                 
150                                                   
151 #ifdef CONFIG_SERIAL_8250                         
152 static inline bool jailhouse_uart_enabled(unsi    
153 {                                                 
154         return setup_data.v2.flags & BIT(uart_    
155 }                                                 
156                                                   
157 static void jailhouse_serial_fixup(int port, s    
158                                    u32 *capabi    
159 {                                                 
160         static const u16 pcuart_base[] = {0x3f    
161         unsigned int n;                           
162                                                   
163         for (n = 0; n < ARRAY_SIZE(pcuart_base    
164                 if (pcuart_base[n] != up->ioba    
165                         continue;                 
166                                                   
167                 if (jailhouse_uart_enabled(n))    
168                         pr_info("Enabling UART    
169                                 up->iobase);      
170                         jailhouse_setup_irq(up    
171                 } else {                          
172                         /* Deactivate UART if     
173                         up->iobase = 0;           
174                 }                                 
175                 break;                            
176         }                                         
177 }                                                 
178                                                   
179 static void __init jailhouse_serial_workaround    
180 {                                                 
181         /*                                        
182          * There are flags inside setup_data t    
183          * platform UARTs since setup data ver    
184          *                                        
185          * In case of version 1, we don't know    
186          * this case, unconditionally register    
187          * 3 and 4.                               
188          */                                       
189         if (setup_data.hdr.version > 1)           
190                 serial8250_set_isa_configurato    
191 }                                                 
192 #else /* !CONFIG_SERIAL_8250 */                   
193 static inline void jailhouse_serial_workaround    
194 {                                                 
195 }                                                 
196 #endif /* CONFIG_SERIAL_8250 */                   
197                                                   
198 static void __init jailhouse_init_platform(voi    
199 {                                                 
200         u64 pa_data = boot_params.hdr.setup_da    
201         unsigned long setup_data_len;             
202         struct setup_data header;                 
203         void *mapping;                            
204                                                   
205         x86_init.irqs.pre_vector_init             
206         x86_init.timers.timer_init                
207         x86_init.mpparse.find_mptable             
208         x86_init.mpparse.early_parse_smp_cfg      
209         x86_init.mpparse.parse_smp_cfg            
210         x86_init.pci.arch_init                    
211                                                   
212         x86_platform.calibrate_cpu                
213         x86_platform.calibrate_tsc                
214         x86_platform.get_wallclock                
215         x86_platform.legacy.rtc                   
216         x86_platform.legacy.warm_reset            
217         x86_platform.legacy.i8042                 
218                                                   
219         legacy_pic                                
220                                                   
221         machine_ops.emergency_restart             
222                                                   
223         while (pa_data) {                         
224                 mapping = early_memremap(pa_da    
225                 memcpy(&header, mapping, sizeo    
226                 early_memunmap(mapping, sizeof    
227                                                   
228                 if (header.type == SETUP_JAILH    
229                         break;                    
230                                                   
231                 pa_data = header.next;            
232         }                                         
233                                                   
234         if (!pa_data)                             
235                 panic("Jailhouse: No valid set    
236                                                   
237         /* setup data must at least contain th    
238         if (header.len < sizeof(setup_data.hdr    
239                 goto unsupported;                 
240                                                   
241         pa_data += offsetof(struct setup_data,    
242         setup_data_len = min_t(unsigned long,     
243                                (unsigned long)    
244         mapping = early_memremap(pa_data, setu    
245         memcpy(&setup_data, mapping, setup_dat    
246         early_memunmap(mapping, setup_data_len    
247                                                   
248         if (setup_data.hdr.version == 0 ||        
249             setup_data.hdr.compatible_version     
250                 JAILHOUSE_SETUP_REQUIRED_VERSI    
251             (setup_data.hdr.version == 1 && he    
252             (setup_data.hdr.version >= 2 && he    
253                 goto unsupported;                 
254                                                   
255         pmtmr_ioport = setup_data.v1.pm_timer_    
256         pr_debug("Jailhouse: PM-Timer IO Port:    
257                                                   
258         precalibrated_tsc_khz = setup_data.v1.    
259         setup_force_cpu_cap(X86_FEATURE_TSC_KN    
260                                                   
261         pci_probe = 0;                            
262                                                   
263         /*                                        
264          * Avoid that the kernel complains abo    
265          * are none in a non-root cell.           
266          */                                       
267         disable_acpi();                           
268                                                   
269         jailhouse_serial_workaround();            
270         return;                                   
271                                                   
272 unsupported:                                      
273         panic("Jailhouse: Unsupported setup da    
274 }                                                 
275                                                   
276 bool jailhouse_paravirt(void)                     
277 {                                                 
278         return jailhouse_cpuid_base() != 0;       
279 }                                                 
280                                                   
281 static bool __init jailhouse_x2apic_available(    
282 {                                                 
283         /*                                        
284          * The x2APIC is only available if the    
285          * does not support switching between     
286          */                                       
287         return x2apic_enabled();                  
288 }                                                 
289                                                   
290 const struct hypervisor_x86 x86_hyper_jailhous    
291         .name                   = "Jailhouse",    
292         .detect                 = jailhouse_de    
293         .init.init_platform     = jailhouse_in    
294         .init.x2apic_available  = jailhouse_x2    
295         .ignore_nopv            = true,           
296 };                                                
297                                                   

~ [ 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