Skip to content

Commit a701f37

Browse files
committed
Merge tag 'for-linus-5.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - A bunch of minor cleanups - A fix for kexec in Xen dom0 when executed on a high cpu number - A fix for resuming after suspend of a Xen guest with assigned PCI devices - A fix for a crash due to not disabled preemption when resuming as Xen dom0 * tag 'for-linus-5.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: fix is_xen_pmu() xen: don't hang when resuming PCI device arch:x86:xen: Remove unnecessary assignment in xen_apic_read() xen/grant-table: remove readonly parameter from functions xen/grant-table: remove gnttab_*transfer*() functions drivers/xen: use helper macro __ATTR_RW x86/xen: Fix kerneldoc warning xen: delay xen_hvm_init_time_ops() if kdump is boot on vcpu>=32 xen: use time_is_before_eq_jiffies() instead of open coding it
2 parents 7203062 + de2ae40 commit a701f37

26 files changed

+94
-193
lines changed

arch/x86/xen/apic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static u32 xen_apic_read(u32 reg)
5151
.interface_version = XENPF_INTERFACE_VERSION,
5252
.u.pcpu_info.xen_cpuid = 0,
5353
};
54-
int ret = 0;
54+
int ret;
5555

5656
/* Shouldn't need this as APIC is turned off for PV, and we only
5757
* get called on the bootup processor. But just in case. */

arch/x86/xen/pmu.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,7 @@ irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id)
506506
return ret;
507507
}
508508

509-
bool is_xen_pmu(int cpu)
510-
{
511-
return (get_xenpmu_data() != NULL);
512-
}
509+
bool is_xen_pmu;
513510

514511
void xen_pmu_init(int cpu)
515512
{
@@ -520,7 +517,7 @@ void xen_pmu_init(int cpu)
520517

521518
BUILD_BUG_ON(sizeof(struct xen_pmu_data) > PAGE_SIZE);
522519

523-
if (xen_hvm_domain())
520+
if (xen_hvm_domain() || (cpu != 0 && !is_xen_pmu))
524521
return;
525522

526523
xenpmu_data = (struct xen_pmu_data *)get_zeroed_page(GFP_KERNEL);
@@ -541,7 +538,8 @@ void xen_pmu_init(int cpu)
541538
per_cpu(xenpmu_shared, cpu).xenpmu_data = xenpmu_data;
542539
per_cpu(xenpmu_shared, cpu).flags = 0;
543540

544-
if (cpu == 0) {
541+
if (!is_xen_pmu) {
542+
is_xen_pmu = true;
545543
perf_register_guest_info_callbacks(&xen_guest_cbs);
546544
xen_pmu_arch_init();
547545
}

arch/x86/xen/pmu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <xen/interface/xenpmu.h>
66

7+
extern bool is_xen_pmu;
8+
79
irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
810
#ifdef CONFIG_XEN_HAVE_VPMU
911
void xen_pmu_init(int cpu);
@@ -12,7 +14,6 @@ void xen_pmu_finish(int cpu);
1214
static inline void xen_pmu_init(int cpu) {}
1315
static inline void xen_pmu_finish(int cpu) {}
1416
#endif
15-
bool is_xen_pmu(int cpu);
1617
bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err);
1718
bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err);
1819
int pmu_apic_update(uint32_t reg);

arch/x86/xen/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ static void __init xen_reserve_xen_mfnlist(void)
719719
}
720720

721721
/**
722-
* machine_specific_memory_setup - Hook for machine specific memory setup.
722+
* xen_memory_setup - Hook for machine specific memory setup.
723723
**/
724724
char * __init xen_memory_setup(void)
725725
{

arch/x86/xen/smp_hvm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ static void __init xen_hvm_smp_prepare_boot_cpu(void)
1919
*/
2020
xen_vcpu_setup(0);
2121

22+
/*
23+
* Called again in case the kernel boots on vcpu >= MAX_VIRT_CPUS.
24+
* Refer to comments in xen_hvm_init_time_ops().
25+
*/
26+
xen_hvm_init_time_ops();
27+
2228
/*
2329
* The alternative logic (which patches the unlock/lock) runs before
2430
* the smp bootup up code is activated. Hence we need to set this up

arch/x86/xen/smp_pv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int xen_smp_intr_init_pv(unsigned int cpu)
129129
per_cpu(xen_irq_work, cpu).irq = rc;
130130
per_cpu(xen_irq_work, cpu).name = callfunc_name;
131131

132-
if (is_xen_pmu(cpu)) {
132+
if (is_xen_pmu) {
133133
pmu_name = kasprintf(GFP_KERNEL, "pmu%d", cpu);
134134
rc = bind_virq_to_irqhandler(VIRQ_XENPMU, cpu,
135135
xen_pmu_irq_handler,

arch/x86/xen/time.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,11 @@ static void xen_hvm_setup_cpu_clockevents(void)
558558

559559
void __init xen_hvm_init_time_ops(void)
560560
{
561+
static bool hvm_time_initialized;
562+
563+
if (hvm_time_initialized)
564+
return;
565+
561566
/*
562567
* vector callback is needed otherwise we cannot receive interrupts
563568
* on cpu > 0 and at this point we don't know how many cpus are
@@ -567,7 +572,22 @@ void __init xen_hvm_init_time_ops(void)
567572
return;
568573

569574
if (!xen_feature(XENFEAT_hvm_safe_pvclock)) {
570-
pr_info("Xen doesn't support pvclock on HVM, disable pv timer");
575+
pr_info_once("Xen doesn't support pvclock on HVM, disable pv timer");
576+
return;
577+
}
578+
579+
/*
580+
* Only MAX_VIRT_CPUS 'vcpu_info' are embedded inside 'shared_info'.
581+
* The __this_cpu_read(xen_vcpu) is still NULL when Xen HVM guest
582+
* boots on vcpu >= MAX_VIRT_CPUS (e.g., kexec), To access
583+
* __this_cpu_read(xen_vcpu) via xen_clocksource_read() will panic.
584+
*
585+
* The xen_hvm_init_time_ops() should be called again later after
586+
* __this_cpu_read(xen_vcpu) is available.
587+
*/
588+
if (!__this_cpu_read(xen_vcpu)) {
589+
pr_info("Delay xen_init_time_common() as kernel is running on vcpu=%d\n",
590+
xen_vcpu_nr(0));
571591
return;
572592
}
573593

@@ -577,6 +597,8 @@ void __init xen_hvm_init_time_ops(void)
577597
x86_cpuinit.setup_percpu_clockev = xen_hvm_setup_cpu_clockevents;
578598

579599
x86_platform.set_wallclock = xen_set_wallclock;
600+
601+
hvm_time_initialized = true;
580602
}
581603
#endif
582604

drivers/block/xen-blkfront.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ static void blkif_free_ring(struct blkfront_ring_info *rinfo)
12231223
list_del(&persistent_gnt->node);
12241224
if (persistent_gnt->gref != GRANT_INVALID_REF) {
12251225
gnttab_end_foreign_access(persistent_gnt->gref,
1226-
0, 0UL);
1226+
0UL);
12271227
rinfo->persistent_gnts_c--;
12281228
}
12291229
if (info->feature_persistent)
@@ -1246,7 +1246,7 @@ static void blkif_free_ring(struct blkfront_ring_info *rinfo)
12461246
rinfo->shadow[i].req.u.rw.nr_segments;
12471247
for (j = 0; j < segs; j++) {
12481248
persistent_gnt = rinfo->shadow[i].grants_used[j];
1249-
gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
1249+
gnttab_end_foreign_access(persistent_gnt->gref, 0UL);
12501250
if (info->feature_persistent)
12511251
__free_page(persistent_gnt->page);
12521252
kfree(persistent_gnt);
@@ -1261,7 +1261,7 @@ static void blkif_free_ring(struct blkfront_ring_info *rinfo)
12611261

12621262
for (j = 0; j < INDIRECT_GREFS(segs); j++) {
12631263
persistent_gnt = rinfo->shadow[i].indirect_grants[j];
1264-
gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
1264+
gnttab_end_foreign_access(persistent_gnt->gref, 0UL);
12651265
__free_page(persistent_gnt->page);
12661266
kfree(persistent_gnt);
12671267
}
@@ -1284,7 +1284,7 @@ static void blkif_free_ring(struct blkfront_ring_info *rinfo)
12841284
/* Free resources associated with old device channel. */
12851285
for (i = 0; i < info->nr_ring_pages; i++) {
12861286
if (rinfo->ring_ref[i] != GRANT_INVALID_REF) {
1287-
gnttab_end_foreign_access(rinfo->ring_ref[i], 0, 0);
1287+
gnttab_end_foreign_access(rinfo->ring_ref[i], 0);
12881288
rinfo->ring_ref[i] = GRANT_INVALID_REF;
12891289
}
12901290
}

drivers/char/tpm/xen-tpmfront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static void ring_free(struct tpm_private *priv)
332332
return;
333333

334334
if (priv->ring_ref)
335-
gnttab_end_foreign_access(priv->ring_ref, 0,
335+
gnttab_end_foreign_access(priv->ring_ref,
336336
(unsigned long)priv->shr);
337337
else
338338
free_page((unsigned long)priv->shr);

drivers/gpu/drm/xen/xen_drm_front_evtchnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void evtchnl_free(struct xen_drm_front_info *front_info,
148148

149149
/* end access and free the page */
150150
if (evtchnl->gref != GRANT_INVALID_REF)
151-
gnttab_end_foreign_access(evtchnl->gref, 0, page);
151+
gnttab_end_foreign_access(evtchnl->gref, page);
152152

153153
memset(evtchnl, 0, sizeof(*evtchnl));
154154
}

0 commit comments

Comments
 (0)