Skip to content

Commit 763baca

Browse files
sstabellinijgross1
authored andcommitted
xen: introduce xen_console_io option
Xen can support console_io hypercalls for any domains, not just dom0, depending on DEBUG and XSM policies. These hypercalls can be very useful for development and debugging. Introduce a kernel command line option xen_console_io to enable the usage of console_io hypercalls for any domain upon request. When xen_console_io is not specified, the current behavior is retained. Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com> Message-ID: <alpine.DEB.2.22.394.2601131522540.992863@ubuntu-linux-20-04-desktop>
1 parent dc8ea87 commit 763baca

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

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

8417+
xen_console_io [XEN,EARLY]
8418+
Boolean option to enable/disable the usage of the Xen
8419+
console_io hypercalls to read and write to the console.
8420+
Mostly useful for debugging and development.
8421+
84178422
xen_emul_unplug= [HW,X86,XEN,EARLY]
84188423
Unplug Xen emulated devices
84198424
Format: [unplug0,][unplug1]

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;

0 commit comments

Comments
 (0)