Module Name: src
Committed By: bouyer
Date: Fri Mar 24 12:28:42 UTC 2023
Modified Files:
src/sys/arch/x86/x86: consinit.c
src/sys/arch/xen/include: xen.h
src/sys/arch/xen/x86: pvh_consinit.c
Log Message:
Allow a PVH dom0 to use VGA as console: make xen_pvh_consinit() return 1 if
it handles the console and 0 otherwise (especially when console=tty0 or
console=pc is present on the command line).
In consinit() fallback to native console selection if xen_pvh_consinit()
returns 0.
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/x86/consinit.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/xen.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/xen/x86/pvh_consinit.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/x86/consinit.c
diff -u src/sys/arch/x86/x86/consinit.c:1.35 src/sys/arch/x86/x86/consinit.c:1.36
--- src/sys/arch/x86/x86/consinit.c:1.35 Mon Sep 5 14:18:51 2022
+++ src/sys/arch/x86/x86/consinit.c Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $ */
+/* $NetBSD: consinit.c,v 1.36 2023/03/24 12:28:42 bouyer Exp $ */
/*
* Copyright (c) 1998
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.35 2022/09/05 14:18:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.36 2023/03/24 12:28:42 bouyer Exp $");
#include "opt_kgdb.h"
#include "opt_puc.h"
@@ -173,8 +173,9 @@ consinit(void)
#ifdef XENPVHVM
if (vm_guest == VM_GUEST_XENPVH) {
- xen_pvh_consinit();
- return;
+ if (xen_pvh_consinit() != 0)
+ return;
+ /* fallback to native console selection, usefull for dom0 PVH */
}
#endif
if (initted)
Index: src/sys/arch/xen/include/xen.h
diff -u src/sys/arch/xen/include/xen.h:1.47 src/sys/arch/xen/include/xen.h:1.48
--- src/sys/arch/xen/include/xen.h:1.47 Sat May 2 16:44:36 2020
+++ src/sys/arch/xen/include/xen.h Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: xen.h,v 1.47 2020/05/02 16:44:36 bouyer Exp $ */
+/* $NetBSD: xen.h,v 1.48 2023/03/24 12:28:42 bouyer Exp $ */
/*
*
@@ -60,7 +60,7 @@ void xen_parse_cmdline(int, union xen_cm
void xenconscn_attach(void);
-void xen_pvh_consinit(void);
+int xen_pvh_consinit(void);
void xenprivcmd_init(void);
Index: src/sys/arch/xen/x86/pvh_consinit.c
diff -u src/sys/arch/xen/x86/pvh_consinit.c:1.2 src/sys/arch/xen/x86/pvh_consinit.c:1.3
--- src/sys/arch/xen/x86/pvh_consinit.c:1.2 Sun May 3 17:23:14 2020
+++ src/sys/arch/xen/x86/pvh_consinit.c Fri Mar 24 12:28:42 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pvh_consinit.c,v 1.2 2020/05/03 17:23:14 bouyer Exp $ */
+/* $NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $ */
/*
* Copyright (c) 2020 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.2 2020/05/03 17:23:14 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $");
#include "xencons.h"
#include <sys/param.h>
@@ -51,7 +51,7 @@ static struct consdev pvh_xencons = {
};
-void
+int
xen_pvh_consinit(void)
{
/*
@@ -59,21 +59,35 @@ xen_pvh_consinit(void)
* boot stage.
*/
static int initted = 0;
+ if (xendomain_is_dom0()) {
+ union xen_cmdline_parseinfo xcp;
+ xen_parse_cmdline(XEN_PARSE_CONSOLE, &xcp);
+#ifdef CONS_OVERRIDE
+ if (strcmp(default_consinfo.devname, "tty0") == 0 ||
+ strcmp(default_consinfo.devname, "pc") == 0) {
+#else
+ if (strcmp(xcp.xcp_console, "tty0") == 0 || /* linux name */
+ strcmp(xcp.xcp_console, "pc") == 0) { /* NetBSD name */
+#endif /* CONS_OVERRIDE */
+ return 0; /* native console code will do it */
+ }
+ }
if (initted == 0 && !xendomain_is_dom0()) {
/* pmap not up yet, fall back to printk() */
cn_tab = &pvh_xencons;
initted++;
- return;
+ return 1;
} else if (initted > 1) {
- return;
+ return 1;
}
initted++;
if (xendomain_is_dom0()) {
+ /* we know we're using Xen's console at this point */
xenconscn_attach(); /* no ring in this case */
initted++; /* don't init console twice */
- return;
+ return 1;
}
-
+
#if NXENCONS > 0
/* we can now map the xencons rings. */
struct xen_hvm_param xen_hvm_param;
@@ -98,6 +112,7 @@ xen_pvh_consinit(void)
xen_start_info.console.domU.evtchn = xen_hvm_param.value;
xenconscn_attach();
#endif
+ return 1;
}
static int