Commit c17f1224 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 3a7e02c0 4c006734
...@@ -62,11 +62,6 @@ void xen_arch_unregister_cpu(int num); ...@@ -62,11 +62,6 @@ void xen_arch_unregister_cpu(int num);
#ifdef CONFIG_PVH #ifdef CONFIG_PVH
void __init xen_pvh_init(struct boot_params *boot_params); void __init xen_pvh_init(struct boot_params *boot_params);
void __init mem_map_via_hcall(struct boot_params *boot_params_p); void __init mem_map_via_hcall(struct boot_params *boot_params_p);
#ifdef CONFIG_XEN_PVH
void __init xen_reserve_extra_memory(struct boot_params *bootp);
#else
static inline void xen_reserve_extra_memory(struct boot_params *bootp) { }
#endif
#endif #endif
/* Lazy mode for batching updates / context switch */ /* Lazy mode for batching updates / context switch */
......
...@@ -75,9 +75,6 @@ static void __init init_pvh_bootparams(bool xen_guest) ...@@ -75,9 +75,6 @@ static void __init init_pvh_bootparams(bool xen_guest)
} else } else
xen_raw_printk("Warning: Can fit ISA range into e820\n"); xen_raw_printk("Warning: Can fit ISA range into e820\n");
if (xen_guest)
xen_reserve_extra_memory(&pvh_bootparams);
pvh_bootparams.hdr.cmd_line_ptr = pvh_bootparams.hdr.cmd_line_ptr =
pvh_start_info.cmdline_paddr; pvh_start_info.cmdline_paddr;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <asm/io_apic.h> #include <asm/io_apic.h>
#include <asm/hypervisor.h> #include <asm/hypervisor.h>
#include <asm/e820/api.h> #include <asm/e820/api.h>
#include <asm/setup.h>
#include <xen/xen.h> #include <xen/xen.h>
#include <asm/xen/interface.h> #include <asm/xen/interface.h>
...@@ -27,54 +28,6 @@ ...@@ -27,54 +28,6 @@
bool __ro_after_init xen_pvh; bool __ro_after_init xen_pvh;
EXPORT_SYMBOL_GPL(xen_pvh); EXPORT_SYMBOL_GPL(xen_pvh);
void __init xen_pvh_init(struct boot_params *boot_params)
{
u32 msr;
u64 pfn;
xen_pvh = 1;
xen_domain_type = XEN_HVM_DOMAIN;
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));
if (xen_initial_domain())
x86_init.oem.arch_setup = xen_add_preferred_consoles;
x86_init.oem.banner = xen_banner;
xen_efi_init(boot_params);
if (xen_initial_domain()) {
struct xen_platform_op op = {
.cmd = XENPF_get_dom0_console,
};
int ret = HYPERVISOR_platform_op(&op);
if (ret > 0)
xen_init_vga(&op.u.dom0_console,
min(ret * sizeof(char),
sizeof(op.u.dom0_console)),
&boot_params->screen_info);
}
}
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;
}
/* /*
* Reserve e820 UNUSABLE regions to inflate the memory balloon. * Reserve e820 UNUSABLE regions to inflate the memory balloon.
* *
...@@ -89,8 +42,9 @@ void __init mem_map_via_hcall(struct boot_params *boot_params_p) ...@@ -89,8 +42,9 @@ void __init mem_map_via_hcall(struct boot_params *boot_params_p)
* hypervisor should notify us which memory ranges are suitable for creating * hypervisor should notify us which memory ranges are suitable for creating
* foreign mappings, but that's not yet implemented. * foreign mappings, but that's not yet implemented.
*/ */
void __init xen_reserve_extra_memory(struct boot_params *bootp) static void __init pvh_reserve_extra_memory(void)
{ {
struct boot_params *bootp = &boot_params;
unsigned int i, ram_pages = 0, extra_pages; unsigned int i, ram_pages = 0, extra_pages;
for (i = 0; i < bootp->e820_entries; i++) { for (i = 0; i < bootp->e820_entries; i++) {
...@@ -141,3 +95,58 @@ void __init xen_reserve_extra_memory(struct boot_params *bootp) ...@@ -141,3 +95,58 @@ void __init xen_reserve_extra_memory(struct boot_params *bootp)
xen_add_extra_mem(PFN_UP(e->addr), pages); xen_add_extra_mem(PFN_UP(e->addr), pages);
} }
} }
static void __init pvh_arch_setup(void)
{
pvh_reserve_extra_memory();
if (xen_initial_domain())
xen_add_preferred_consoles();
}
void __init xen_pvh_init(struct boot_params *boot_params)
{
u32 msr;
u64 pfn;
xen_pvh = 1;
xen_domain_type = XEN_HVM_DOMAIN;
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));
x86_init.oem.arch_setup = pvh_arch_setup;
x86_init.oem.banner = xen_banner;
xen_efi_init(boot_params);
if (xen_initial_domain()) {
struct xen_platform_op op = {
.cmd = XENPF_get_dom0_console,
};
int ret = HYPERVISOR_platform_op(&op);
if (ret > 0)
xen_init_vga(&op.u.dom0_console,
min(ret * sizeof(char),
sizeof(op.u.dom0_console)),
&boot_params->screen_info);
}
}
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;
}
...@@ -54,8 +54,9 @@ struct mc_debug_data { ...@@ -54,8 +54,9 @@ struct mc_debug_data {
static DEFINE_PER_CPU(struct mc_buffer, mc_buffer); static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
static struct mc_debug_data mc_debug_data_early __initdata; static struct mc_debug_data mc_debug_data_early __initdata;
static struct mc_debug_data __percpu *mc_debug_data __refdata = static DEFINE_PER_CPU(struct mc_debug_data *, mc_debug_data) =
&mc_debug_data_early; &mc_debug_data_early;
static struct mc_debug_data __percpu *mc_debug_data_ptr;
DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags); DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);
static struct static_key mc_debug __ro_after_init; static struct static_key mc_debug __ro_after_init;
...@@ -70,16 +71,20 @@ static int __init xen_parse_mc_debug(char *arg) ...@@ -70,16 +71,20 @@ static int __init xen_parse_mc_debug(char *arg)
} }
early_param("xen_mc_debug", xen_parse_mc_debug); early_param("xen_mc_debug", xen_parse_mc_debug);
void mc_percpu_init(unsigned int cpu)
{
per_cpu(mc_debug_data, cpu) = per_cpu_ptr(mc_debug_data_ptr, cpu);
}
static int __init mc_debug_enable(void) static int __init mc_debug_enable(void)
{ {
struct mc_debug_data __percpu *mcdb;
unsigned long flags; unsigned long flags;
if (!mc_debug_enabled) if (!mc_debug_enabled)
return 0; return 0;
mcdb = alloc_percpu(struct mc_debug_data); mc_debug_data_ptr = alloc_percpu(struct mc_debug_data);
if (!mcdb) { if (!mc_debug_data_ptr) {
pr_err("xen_mc_debug inactive\n"); pr_err("xen_mc_debug inactive\n");
static_key_slow_dec(&mc_debug); static_key_slow_dec(&mc_debug);
return -ENOMEM; return -ENOMEM;
...@@ -88,7 +93,7 @@ static int __init mc_debug_enable(void) ...@@ -88,7 +93,7 @@ static int __init mc_debug_enable(void)
/* Be careful when switching to percpu debug data. */ /* Be careful when switching to percpu debug data. */
local_irq_save(flags); local_irq_save(flags);
xen_mc_flush(); xen_mc_flush();
mc_debug_data = mcdb; mc_percpu_init(0);
local_irq_restore(flags); local_irq_restore(flags);
pr_info("xen_mc_debug active\n"); pr_info("xen_mc_debug active\n");
...@@ -150,7 +155,7 @@ void xen_mc_flush(void) ...@@ -150,7 +155,7 @@ void xen_mc_flush(void)
trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx); trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx);
if (static_key_false(&mc_debug)) { if (static_key_false(&mc_debug)) {
mcdb = this_cpu_ptr(mc_debug_data); mcdb = __this_cpu_read(mc_debug_data);
memcpy(mcdb->entries, b->entries, memcpy(mcdb->entries, b->entries,
b->mcidx * sizeof(struct multicall_entry)); b->mcidx * sizeof(struct multicall_entry));
} }
...@@ -230,7 +235,7 @@ struct multicall_space __xen_mc_entry(size_t args) ...@@ -230,7 +235,7 @@ struct multicall_space __xen_mc_entry(size_t args)
ret.mc = &b->entries[b->mcidx]; ret.mc = &b->entries[b->mcidx];
if (static_key_false(&mc_debug)) { if (static_key_false(&mc_debug)) {
struct mc_debug_data *mcdb = this_cpu_ptr(mc_debug_data); struct mc_debug_data *mcdb = __this_cpu_read(mc_debug_data);
mcdb->caller[b->mcidx] = __builtin_return_address(0); mcdb->caller[b->mcidx] = __builtin_return_address(0);
mcdb->argsz[b->mcidx] = args; mcdb->argsz[b->mcidx] = args;
......
...@@ -305,6 +305,7 @@ static int xen_pv_kick_ap(unsigned int cpu, struct task_struct *idle) ...@@ -305,6 +305,7 @@ static int xen_pv_kick_ap(unsigned int cpu, struct task_struct *idle)
return rc; return rc;
xen_pmu_init(cpu); xen_pmu_init(cpu);
mc_percpu_init(cpu);
/* /*
* Why is this a BUG? If the hypercall fails then everything can be * Why is this a BUG? If the hypercall fails then everything can be
......
...@@ -257,6 +257,9 @@ void xen_mc_callback(void (*fn)(void *), void *data); ...@@ -257,6 +257,9 @@ void xen_mc_callback(void (*fn)(void *), void *data);
*/ */
struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size); struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
/* Do percpu data initialization for multicalls. */
void mc_percpu_init(unsigned int cpu);
extern bool is_xen_pmu; extern bool is_xen_pmu;
irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id); irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment