Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus-6.11-rc1a-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
"Two fixes for issues introduced in this merge window:

- fix enhanced debugging in the Xen multicall handling

- two patches fixing a boot failure when running as dom0 in PVH mode"

* tag 'for-linus-6.11-rc1a-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
x86/xen: fix memblock_reserve() usage on PVH
x86/xen: move xen_reserve_extra_memory()
xen: fix multicall debug data referencing

+74 -64
-5
arch/x86/include/asm/xen/hypervisor.h
··· 62 62 #ifdef CONFIG_PVH 63 63 void __init xen_pvh_init(struct boot_params *boot_params); 64 64 void __init mem_map_via_hcall(struct boot_params *boot_params_p); 65 - #ifdef CONFIG_XEN_PVH 66 - void __init xen_reserve_extra_memory(struct boot_params *bootp); 67 - #else 68 - static inline void xen_reserve_extra_memory(struct boot_params *bootp) { } 69 - #endif 70 65 #endif 71 66 72 67 /* Lazy mode for batching updates / context switch */
-3
arch/x86/platform/pvh/enlighten.c
··· 75 75 } else 76 76 xen_raw_printk("Warning: Can fit ISA range into e820\n"); 77 77 78 - if (xen_guest) 79 - xen_reserve_extra_memory(&pvh_bootparams); 80 - 81 78 pvh_bootparams.hdr.cmd_line_ptr = 82 79 pvh_start_info.cmdline_paddr; 83 80
+58 -49
arch/x86/xen/enlighten_pvh.c
··· 9 9 #include <asm/io_apic.h> 10 10 #include <asm/hypervisor.h> 11 11 #include <asm/e820/api.h> 12 + #include <asm/setup.h> 12 13 13 14 #include <xen/xen.h> 14 15 #include <asm/xen/interface.h> ··· 28 27 bool __ro_after_init xen_pvh; 29 28 EXPORT_SYMBOL_GPL(xen_pvh); 30 29 31 - void __init xen_pvh_init(struct boot_params *boot_params) 32 - { 33 - u32 msr; 34 - u64 pfn; 35 - 36 - xen_pvh = 1; 37 - xen_domain_type = XEN_HVM_DOMAIN; 38 - xen_start_flags = pvh_start_info.flags; 39 - 40 - msr = cpuid_ebx(xen_cpuid_base() + 2); 41 - pfn = __pa(hypercall_page); 42 - wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); 43 - 44 - if (xen_initial_domain()) 45 - x86_init.oem.arch_setup = xen_add_preferred_consoles; 46 - x86_init.oem.banner = xen_banner; 47 - 48 - xen_efi_init(boot_params); 49 - 50 - if (xen_initial_domain()) { 51 - struct xen_platform_op op = { 52 - .cmd = XENPF_get_dom0_console, 53 - }; 54 - int ret = HYPERVISOR_platform_op(&op); 55 - 56 - if (ret > 0) 57 - xen_init_vga(&op.u.dom0_console, 58 - min(ret * sizeof(char), 59 - sizeof(op.u.dom0_console)), 60 - &boot_params->screen_info); 61 - } 62 - } 63 - 64 - void __init mem_map_via_hcall(struct boot_params *boot_params_p) 65 - { 66 - struct xen_memory_map memmap; 67 - int rc; 68 - 69 - memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table); 70 - set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table); 71 - rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); 72 - if (rc) { 73 - xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc); 74 - BUG(); 75 - } 76 - boot_params_p->e820_entries = memmap.nr_entries; 77 - } 78 - 79 30 /* 80 31 * Reserve e820 UNUSABLE regions to inflate the memory balloon. 81 32 * ··· 42 89 * hypervisor should notify us which memory ranges are suitable for creating 43 90 * foreign mappings, but that's not yet implemented. 44 91 */ 45 - void __init xen_reserve_extra_memory(struct boot_params *bootp) 92 + static void __init pvh_reserve_extra_memory(void) 46 93 { 94 + struct boot_params *bootp = &boot_params; 47 95 unsigned int i, ram_pages = 0, extra_pages; 48 96 49 97 for (i = 0; i < bootp->e820_entries; i++) { ··· 94 140 95 141 xen_add_extra_mem(PFN_UP(e->addr), pages); 96 142 } 143 + } 144 + 145 + static void __init pvh_arch_setup(void) 146 + { 147 + pvh_reserve_extra_memory(); 148 + 149 + if (xen_initial_domain()) 150 + xen_add_preferred_consoles(); 151 + } 152 + 153 + void __init xen_pvh_init(struct boot_params *boot_params) 154 + { 155 + u32 msr; 156 + u64 pfn; 157 + 158 + xen_pvh = 1; 159 + xen_domain_type = XEN_HVM_DOMAIN; 160 + xen_start_flags = pvh_start_info.flags; 161 + 162 + msr = cpuid_ebx(xen_cpuid_base() + 2); 163 + pfn = __pa(hypercall_page); 164 + wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); 165 + 166 + x86_init.oem.arch_setup = pvh_arch_setup; 167 + x86_init.oem.banner = xen_banner; 168 + 169 + xen_efi_init(boot_params); 170 + 171 + if (xen_initial_domain()) { 172 + struct xen_platform_op op = { 173 + .cmd = XENPF_get_dom0_console, 174 + }; 175 + int ret = HYPERVISOR_platform_op(&op); 176 + 177 + if (ret > 0) 178 + xen_init_vga(&op.u.dom0_console, 179 + min(ret * sizeof(char), 180 + sizeof(op.u.dom0_console)), 181 + &boot_params->screen_info); 182 + } 183 + } 184 + 185 + void __init mem_map_via_hcall(struct boot_params *boot_params_p) 186 + { 187 + struct xen_memory_map memmap; 188 + int rc; 189 + 190 + memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table); 191 + set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table); 192 + rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); 193 + if (rc) { 194 + xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc); 195 + BUG(); 196 + } 197 + boot_params_p->e820_entries = memmap.nr_entries; 97 198 }
+12 -7
arch/x86/xen/multicalls.c
··· 54 54 55 55 static DEFINE_PER_CPU(struct mc_buffer, mc_buffer); 56 56 static struct mc_debug_data mc_debug_data_early __initdata; 57 - static struct mc_debug_data __percpu *mc_debug_data __refdata = 57 + static DEFINE_PER_CPU(struct mc_debug_data *, mc_debug_data) = 58 58 &mc_debug_data_early; 59 + static struct mc_debug_data __percpu *mc_debug_data_ptr; 59 60 DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags); 60 61 61 62 static struct static_key mc_debug __ro_after_init; ··· 71 70 } 72 71 early_param("xen_mc_debug", xen_parse_mc_debug); 73 72 73 + void mc_percpu_init(unsigned int cpu) 74 + { 75 + per_cpu(mc_debug_data, cpu) = per_cpu_ptr(mc_debug_data_ptr, cpu); 76 + } 77 + 74 78 static int __init mc_debug_enable(void) 75 79 { 76 - struct mc_debug_data __percpu *mcdb; 77 80 unsigned long flags; 78 81 79 82 if (!mc_debug_enabled) 80 83 return 0; 81 84 82 - mcdb = alloc_percpu(struct mc_debug_data); 83 - if (!mcdb) { 85 + mc_debug_data_ptr = alloc_percpu(struct mc_debug_data); 86 + if (!mc_debug_data_ptr) { 84 87 pr_err("xen_mc_debug inactive\n"); 85 88 static_key_slow_dec(&mc_debug); 86 89 return -ENOMEM; ··· 93 88 /* Be careful when switching to percpu debug data. */ 94 89 local_irq_save(flags); 95 90 xen_mc_flush(); 96 - mc_debug_data = mcdb; 91 + mc_percpu_init(0); 97 92 local_irq_restore(flags); 98 93 99 94 pr_info("xen_mc_debug active\n"); ··· 155 150 trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx); 156 151 157 152 if (static_key_false(&mc_debug)) { 158 - mcdb = this_cpu_ptr(mc_debug_data); 153 + mcdb = __this_cpu_read(mc_debug_data); 159 154 memcpy(mcdb->entries, b->entries, 160 155 b->mcidx * sizeof(struct multicall_entry)); 161 156 } ··· 235 230 236 231 ret.mc = &b->entries[b->mcidx]; 237 232 if (static_key_false(&mc_debug)) { 238 - struct mc_debug_data *mcdb = this_cpu_ptr(mc_debug_data); 233 + struct mc_debug_data *mcdb = __this_cpu_read(mc_debug_data); 239 234 240 235 mcdb->caller[b->mcidx] = __builtin_return_address(0); 241 236 mcdb->argsz[b->mcidx] = args;
+1
arch/x86/xen/smp_pv.c
··· 305 305 return rc; 306 306 307 307 xen_pmu_init(cpu); 308 + mc_percpu_init(cpu); 308 309 309 310 /* 310 311 * Why is this a BUG? If the hypercall fails then everything can be
+3
arch/x86/xen/xen-ops.h
··· 257 257 */ 258 258 struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size); 259 259 260 + /* Do percpu data initialization for multicalls. */ 261 + void mc_percpu_init(unsigned int cpu); 262 + 260 263 extern bool is_xen_pmu; 261 264 262 265 irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);