m/node: also log to ttyS1

Some systems have their serial console connected to ttyS1, not ttyS0.
We currently have no way of passing this information to the system as we
lock down boot parameters and
there is significant risk in letting people change this, both in terms
of security (some kernel parameters can affect the integrity of the OS)
as well as availability as such a setting needs to be respected by both
A and B loaders, thus any misconfiguration could make the node
non-functional without an obvious way to roll back.

Thus this just adds ttyS1 to the list of serial consoles for the time
being. When we have such a mechanism, we'll likely undo the hardcoding
of all consoles anyways.

Fixes #216

Change-Id: I2f35edad049ceae1bb5cfc22b89bf6a1664cfbf8
Reviewed-on: https://review.monogon.dev/c/monogon/+/1625
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/node/BUILD.bazel b/metropolis/node/BUILD.bazel
index 942a9ab..7ff504f 100644
--- a/metropolis/node/BUILD.bazel
+++ b/metropolis/node/BUILD.bazel
@@ -112,7 +112,7 @@
 
 efi_unified_kernel_image(
     name = "kernel_efi",
-    cmdline = "console=ttyS0,115200 console=tty0 quiet rootfstype=erofs init=/init",
+    cmdline = "console=ttyS0,115200 console=ttyS1,115200 console=tty0 quiet rootfstype=erofs init=/init",
     initrd = [":ucode"],
     kernel = "//third_party/linux",
     os_release = ":os-release-info",
diff --git a/metropolis/node/build/earlydev.fsspec b/metropolis/node/build/earlydev.fsspec
index 1e32803..a7d2ea4 100644
--- a/metropolis/node/build/earlydev.fsspec
+++ b/metropolis/node/build/earlydev.fsspec
@@ -31,7 +31,7 @@
 >
 
 
-# Metropolis core logs to /dev/ttyS0 and /dev/tty0 by default, we want
+# Metropolis core logs to /dev/ttyS{0,1} and /dev/tty0 by default, we want
 # these to also be present before devtmpfs is mounted so that minit can
 # log there, too.
 special_file <
@@ -46,3 +46,9 @@
     major: 4 minor: 64
     mode: 0660 uid: 0 gid: 0
 >
+special_file <
+    path: "/dev/ttyS1"
+    type: CHARACTER_DEV
+    major: 4 minor: 65
+    mode: 0660 uid: 0 gid: 0
+>
\ No newline at end of file
diff --git a/metropolis/node/core/main.go b/metropolis/node/core/main.go
index 08eb39a..715a7ac 100644
--- a/metropolis/node/core/main.go
+++ b/metropolis/node/core/main.go
@@ -48,7 +48,7 @@
 	lt := logtree.New()
 
 	// Set up logger for Metropolis. Currently logs everything to /dev/tty0 and
-	// /dev/ttyS0.
+	// /dev/ttyS{0,1}.
 	consoles := []console{
 		{
 			path:     "/dev/tty0",
@@ -58,6 +58,10 @@
 			path:     "/dev/ttyS0",
 			maxWidth: 120,
 		},
+		{
+			path:     "/dev/ttyS1",
+			maxWidth: 120,
+		},
 	}
 	// Alternative channel that crash handling writes to, and which gets distributed
 	// to the consoles.
diff --git a/metropolis/node/core/minit/main.c b/metropolis/node/core/minit/main.c
index 4677c8e..d92f7ed 100644
--- a/metropolis/node/core/minit/main.c
+++ b/metropolis/node/core/minit/main.c
@@ -29,7 +29,7 @@
 
 void handle_signal(pid_t child_pid, int signum);
 
-#define NUM_CONSOLES 3
+#define NUM_CONSOLES 4
 FILE *consoles[NUM_CONSOLES] = {};
 
 // open_consoles populates the consoles array with FILE pointers to opened
@@ -39,6 +39,7 @@
     consoles[0] = fopen("/dev/console", "w");
     consoles[1] = fopen("/dev/tty0", "w");
     consoles[2] = fopen("/dev/ttyS0", "w");
+    consoles[3] = fopen("/dev/ttyS1", "w");
 
     // Set all open consoles to be line-buffered.
     for (int i = 0; i < NUM_CONSOLES; i++) {