Skip to content

Commit c17f122

Browse files
committed
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
2 parents 3a7e02c + 4c00673 commit c17f122

File tree

6 files changed

+74
-64
lines changed

6 files changed

+74
-64
lines changed

arch/x86/include/asm/xen/hypervisor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ void xen_arch_unregister_cpu(int num);
6262
#ifdef CONFIG_PVH
6363
void __init xen_pvh_init(struct boot_params *boot_params);
6464
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
7065
#endif
7166

7267
/* Lazy mode for batching updates / context switch */

arch/x86/platform/pvh/enlighten.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ static void __init init_pvh_bootparams(bool xen_guest)
7575
} else
7676
xen_raw_printk("Warning: Can fit ISA range into e820\n");
7777

78-
if (xen_guest)
79-
xen_reserve_extra_memory(&pvh_bootparams);
80-
8178
pvh_bootparams.hdr.cmd_line_ptr =
8279
pvh_start_info.cmdline_paddr;
8380

arch/x86/xen/enlighten_pvh.c

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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>
@@ -27,54 +28,6 @@
2728
bool __ro_after_init xen_pvh;
2829
EXPORT_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+
}

arch/x86/xen/multicalls.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ struct mc_debug_data {
5454

5555
static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
5656
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) =
5858
&mc_debug_data_early;
59+
static struct mc_debug_data __percpu *mc_debug_data_ptr;
5960
DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);
6061

6162
static struct static_key mc_debug __ro_after_init;
@@ -70,16 +71,20 @@ static int __init xen_parse_mc_debug(char *arg)
7071
}
7172
early_param("xen_mc_debug", xen_parse_mc_debug);
7273

74+
void mc_percpu_init(unsigned int cpu)
75+
{
76+
per_cpu(mc_debug_data, cpu) = per_cpu_ptr(mc_debug_data_ptr, cpu);
77+
}
78+
7379
static int __init mc_debug_enable(void)
7480
{
75-
struct mc_debug_data __percpu *mcdb;
7681
unsigned long flags;
7782

7883
if (!mc_debug_enabled)
7984
return 0;
8085

81-
mcdb = alloc_percpu(struct mc_debug_data);
82-
if (!mcdb) {
86+
mc_debug_data_ptr = alloc_percpu(struct mc_debug_data);
87+
if (!mc_debug_data_ptr) {
8388
pr_err("xen_mc_debug inactive\n");
8489
static_key_slow_dec(&mc_debug);
8590
return -ENOMEM;
@@ -88,7 +93,7 @@ static int __init mc_debug_enable(void)
8893
/* Be careful when switching to percpu debug data. */
8994
local_irq_save(flags);
9095
xen_mc_flush();
91-
mc_debug_data = mcdb;
96+
mc_percpu_init(0);
9297
local_irq_restore(flags);
9398

9499
pr_info("xen_mc_debug active\n");
@@ -150,7 +155,7 @@ void xen_mc_flush(void)
150155
trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx);
151156

152157
if (static_key_false(&mc_debug)) {
153-
mcdb = this_cpu_ptr(mc_debug_data);
158+
mcdb = __this_cpu_read(mc_debug_data);
154159
memcpy(mcdb->entries, b->entries,
155160
b->mcidx * sizeof(struct multicall_entry));
156161
}
@@ -230,7 +235,7 @@ struct multicall_space __xen_mc_entry(size_t args)
230235

231236
ret.mc = &b->entries[b->mcidx];
232237
if (static_key_false(&mc_debug)) {
233-
struct mc_debug_data *mcdb = this_cpu_ptr(mc_debug_data);
238+
struct mc_debug_data *mcdb = __this_cpu_read(mc_debug_data);
234239

235240
mcdb->caller[b->mcidx] = __builtin_return_address(0);
236241
mcdb->argsz[b->mcidx] = args;

arch/x86/xen/smp_pv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static int xen_pv_kick_ap(unsigned int cpu, struct task_struct *idle)
305305
return rc;
306306

307307
xen_pmu_init(cpu);
308+
mc_percpu_init(cpu);
308309

309310
/*
310311
* Why is this a BUG? If the hypercall fails then everything can be

arch/x86/xen/xen-ops.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ void xen_mc_callback(void (*fn)(void *), void *data);
257257
*/
258258
struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
259259

260+
/* Do percpu data initialization for multicalls. */
261+
void mc_percpu_init(unsigned int cpu);
262+
260263
extern bool is_xen_pmu;
261264

262265
irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);

0 commit comments

Comments
 (0)