Skip to content

Commit 33120a2

Browse files
committed
Merge tag 'for-linus-7.0-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - fix running as Xen PVH guest in 32-bit mode without PAE - fix PV device handling for suspend/resume when running as a Xen guest - clean up workqueue usage - fix the Xen balloon driver for PVH dom0 - introduce the possibility to use hypercalls for console messages in unprivileged guests - enable Xen dom0 use of virtio devices in nested virtualization setups - simplify the xen-mcelog driver * tag 'for-linus-7.0-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xenbus: Rename helpers to freeze/thaw/restore xenbus: Use .freeze/.thaw to handle xenbus devices xen/mcelog: simplify MCE_GETCLEAR_FLAGS using xchg() xen/balloon: improve accuracy of initial balloon target for dom0 Partial revert "x86/xen: fix balloon target initialization for PVH dom0" xen: introduce xen_console_io option xen/virtio: Don't use grant-dma-ops when running as Dom0 x86/xen/pvh: Enable PAE mode for 32-bit guest only when CONFIG_X86_PAE is set xen: privcmd: WQ_PERCPU added to alloc_workqueue users xen/events: replace use of system_wq with system_percpu_wq
2 parents 45bf4bc + c307b6d commit 33120a2

14 files changed

Lines changed: 89 additions & 42 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8437,6 +8437,11 @@ Kernel parameters
84378437
save/restore/migration must be enabled to handle larger
84388438
domains.
84398439

8440+
xen_console_io [XEN,EARLY]
8441+
Boolean option to enable/disable the usage of the Xen
8442+
console_io hypercalls to read and write to the console.
8443+
Mostly useful for debugging and development.
8444+
84408445
xen_emul_unplug= [HW,X86,XEN,EARLY]
84418446
Unplug Xen emulated devices
84428447
Format: [unplug0,][unplug1]

arch/x86/platform/pvh/head.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ SYM_CODE_START(pvh_start_xen)
9191

9292
leal rva(early_stack_end)(%ebp), %esp
9393

94+
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
9495
/* Enable PAE mode. */
9596
mov %cr4, %eax
9697
orl $X86_CR4_PAE, %eax
9798
mov %eax, %cr4
99+
#endif
98100

99101
#ifdef CONFIG_X86_64
100102
/* Enable Long mode. */

arch/x86/xen/enlighten.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ int __init arch_xen_unpopulated_init(struct resource **res)
470470
* driver to know how much of the physmap is unpopulated and
471471
* set an accurate initial memory target.
472472
*/
473-
xen_released_pages += xen_extra_mem[i].n_pfns;
473+
xen_unpopulated_pages += xen_extra_mem[i].n_pfns;
474474
/* Zero so region is not also added to the balloon driver. */
475475
xen_extra_mem[i].n_pfns = 0;
476476
}

drivers/tty/hvc/hvc_xen.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ static DEFINE_SPINLOCK(xencons_lock);
5151

5252
/* ------------------------------------------------------------------ */
5353

54+
static bool xen_console_io = false;
55+
static int __initdata opt_console_io = -1;
56+
57+
static int __init parse_xen_console_io(char *arg)
58+
{
59+
bool val;
60+
int ret;
61+
62+
ret = kstrtobool(arg, &val);
63+
if (ret == 0)
64+
opt_console_io = (int)val;
65+
66+
return ret;
67+
}
68+
early_param("xen_console_io", parse_xen_console_io);
69+
5470
static struct xencons_info *vtermno_to_xencons(int vtermno)
5571
{
5672
struct xencons_info *entry, *ret = NULL;
@@ -331,7 +347,7 @@ static int xen_initial_domain_console_init(void)
331347
struct xencons_info *info;
332348
unsigned long flags;
333349

334-
if (!xen_initial_domain())
350+
if (!xen_console_io)
335351
return -ENODEV;
336352

337353
info = vtermno_to_xencons(HVC_COOKIE);
@@ -369,7 +385,7 @@ void xen_console_resume(void)
369385
{
370386
struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
371387
if (info != NULL && info->irq) {
372-
if (!xen_initial_domain())
388+
if (!xen_console_io)
373389
xen_console_update_evtchn(info);
374390
rebind_evtchn_irq(info->evtchn, info->irq);
375391
}
@@ -601,7 +617,7 @@ static int __init xen_hvc_init(void)
601617
if (!xen_domain())
602618
return -ENODEV;
603619

604-
if (xen_initial_domain()) {
620+
if (xen_console_io) {
605621
ops = &dom0_hvc_ops;
606622
r = xen_initial_domain_console_init();
607623
if (r < 0)
@@ -647,14 +663,17 @@ static int __init xen_hvc_init(void)
647663
}
648664
device_initcall(xen_hvc_init);
649665

650-
static int xen_cons_init(void)
666+
static int __init xen_cons_init(void)
651667
{
652668
const struct hv_ops *ops;
653669

670+
xen_console_io = opt_console_io >= 0 ? opt_console_io :
671+
xen_initial_domain();
672+
654673
if (!xen_domain())
655674
return 0;
656675

657-
if (xen_initial_domain())
676+
if (xen_console_io)
658677
ops = &dom0_hvc_ops;
659678
else {
660679
int r;

drivers/xen/balloon.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,19 +724,33 @@ static int __init balloon_add_regions(void)
724724
static int __init balloon_init(void)
725725
{
726726
struct task_struct *task;
727+
long current_pages = 0;
728+
domid_t domid = DOMID_SELF;
727729
int rc;
728730

729731
if (!xen_domain())
730732
return -ENODEV;
731733

732734
pr_info("Initialising balloon driver\n");
733735

734-
if (xen_released_pages >= get_num_physpages()) {
735-
WARN(1, "Released pages underflow current target");
736-
return -ERANGE;
736+
if (xen_initial_domain())
737+
current_pages = HYPERVISOR_memory_op(XENMEM_current_reservation,
738+
&domid);
739+
if (current_pages <= 0) {
740+
if (xen_pv_domain()) {
741+
if (xen_released_pages >= xen_start_info->nr_pages)
742+
goto underflow;
743+
current_pages = min(xen_start_info->nr_pages -
744+
xen_released_pages, max_pfn);
745+
} else {
746+
if (xen_unpopulated_pages >= get_num_physpages())
747+
goto underflow;
748+
current_pages = get_num_physpages() -
749+
xen_unpopulated_pages;
750+
}
737751
}
738752

739-
balloon_stats.current_pages = get_num_physpages() - xen_released_pages;
753+
balloon_stats.current_pages = current_pages;
740754
balloon_stats.target_pages = balloon_stats.current_pages;
741755
balloon_stats.balloon_low = 0;
742756
balloon_stats.balloon_high = 0;
@@ -767,6 +781,10 @@ static int __init balloon_init(void)
767781
xen_balloon_init();
768782

769783
return 0;
784+
785+
underflow:
786+
WARN(1, "Released pages underflow current target");
787+
return -ERANGE;
770788
}
771789
subsys_initcall(balloon_init);
772790

drivers/xen/events/events_base.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static void lateeoi_list_add(struct irq_info *info)
581581
eoi_list);
582582
if (!elem || info->eoi_time < elem->eoi_time) {
583583
list_add(&info->eoi_list, &eoi->eoi_list);
584-
mod_delayed_work_on(info->eoi_cpu, system_wq,
584+
mod_delayed_work_on(info->eoi_cpu, system_percpu_wq,
585585
&eoi->delayed, delay);
586586
} else {
587587
list_for_each_entry_reverse(elem, &eoi->eoi_list, eoi_list) {
@@ -666,7 +666,7 @@ static void xen_irq_lateeoi_worker(struct work_struct *work)
666666
break;
667667

668668
if (now < info->eoi_time) {
669-
mod_delayed_work_on(info->eoi_cpu, system_wq,
669+
mod_delayed_work_on(info->eoi_cpu, system_percpu_wq,
670670
&eoi->delayed,
671671
info->eoi_time - now);
672672
break;
@@ -782,7 +782,7 @@ static void xen_free_irq(struct irq_info *info)
782782

783783
WARN_ON(info->refcnt > 0);
784784

785-
queue_rcu_work(system_wq, &info->rwork);
785+
queue_rcu_work(system_percpu_wq, &info->rwork);
786786
}
787787

788788
/* Not called for lateeoi events. */

drivers/xen/grant-dma-ops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ static int xen_grant_init_backend_domid(struct device *dev,
366366
if (np) {
367367
ret = xen_dt_grant_init_backend_domid(dev, np, backend_domid);
368368
of_node_put(np);
369-
} else if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT) || xen_pv_domain()) {
369+
} else if (!xen_initial_domain() &&
370+
(IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT) || xen_pv_domain())) {
370371
dev_info(dev, "Using dom0 as backend\n");
371372
*backend_domid = 0;
372373
ret = 0;

drivers/xen/mcelog.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ static long xen_mce_chrdev_ioctl(struct file *f, unsigned int cmd,
165165
case MCE_GETCLEAR_FLAGS: {
166166
unsigned flags;
167167

168-
do {
169-
flags = xen_mcelog.flags;
170-
} while (cmpxchg(&xen_mcelog.flags, flags, 0) != flags);
168+
flags = xchg(&xen_mcelog.flags, 0);
171169

172170
return put_user(flags, p);
173171
}

drivers/xen/privcmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,8 @@ static long privcmd_ioctl_irqfd(struct file *file, void __user *udata)
10911091

10921092
static int privcmd_irqfd_init(void)
10931093
{
1094-
irqfd_cleanup_wq = alloc_workqueue("privcmd-irqfd-cleanup", 0, 0);
1094+
irqfd_cleanup_wq = alloc_workqueue("privcmd-irqfd-cleanup", WQ_PERCPU,
1095+
0);
10951096
if (!irqfd_cleanup_wq)
10961097
return -ENOMEM;
10971098

drivers/xen/unpopulated-alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ static unsigned int list_count;
1818

1919
static struct resource *target_resource;
2020

21+
/* Pages to subtract from the memory count when setting balloon target. */
22+
unsigned long xen_unpopulated_pages __initdata;
23+
2124
/*
2225
* If arch is not happy with system "iomem_resource" being used for
2326
* the region allocation it can provide it's own view by creating specific

0 commit comments

Comments
 (0)