git: 9fc7fe642757 - main - bhyve: improve console error reporting on arm64

From: Roman Bogorodskiy <novel_at_FreeBSD.org>
Date: Wed, 07 Jan 2026 17:12:22 UTC
The branch main has been updated by novel:

URL: https://cgit.FreeBSD.org/src/commit/?id=9fc7fe6427579f1c82a371588df6fd6af3b83dfd

commit 9fc7fe6427579f1c82a371588df6fd6af3b83dfd
Author:     Roman Bogorodskiy <novel@FreeBSD.org>
AuthorDate: 2026-01-04 13:59:34 +0000
Commit:     Roman Bogorodskiy <novel@FreeBSD.org>
CommitDate: 2026-01-07 17:06:45 +0000

    bhyve: improve console error reporting on arm64
    
    Currently, on arm64, if bhyve fails to initialize the console,
    it falls into assert(), which does not look particularly pretty
    for users.
    
    Replace the assert with proper error handling so bhyve prints
    a meaningful error message and exits with status code 4 (error).
    That matches the behavior on amd64.
    
    Approved by:            markj
    Reviewed by:            markj
    Differential Revision:  https://reviews.freebsd.org/D54504
---
 usr.sbin/bhyve/aarch64/bhyverun_machdep.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
index e099df0559a1..10018d082f7e 100644
--- a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
+++ b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
@@ -270,7 +270,7 @@ mmio_uart_mem_handler(struct vcpu *vcpu __unused, int dir,
 	return (0);
 }
 
-static bool
+static int
 init_mmio_uart(struct vmctx *ctx)
 {
 	struct uart_pl011_softc *sc;
@@ -280,14 +280,14 @@ init_mmio_uart(struct vmctx *ctx)
 
 	path = get_config_value("console");
 	if (path == NULL)
-		return (false);
+		return (1);
 
 	sc = uart_pl011_init(mmio_uart_intr_assert, mmio_uart_intr_deassert,
 	    ctx);
 	if (uart_pl011_tty_open(sc, path) != 0) {
 		EPRINTLN("Unable to initialize backend '%s' for mmio uart",
 		    path);
-		assert(0);
+		return (-1);
 	}
 
 	bzero(&mr, sizeof(struct mem_range));
@@ -301,7 +301,7 @@ init_mmio_uart(struct vmctx *ctx)
 	error = register_mem(&mr);
 	assert(error == 0);
 
-	return (true);
+	return (0);
 }
 
 static void
@@ -414,8 +414,11 @@ bhyve_init_platform(struct vmctx *ctx, struct vcpu *bsp)
 		return (error);
 	}
 
-	if (init_mmio_uart(ctx))
+	error = init_mmio_uart(ctx);
+	if (error == 0)
 		fdt_add_uart(UART_MMIO_BASE, UART_MMIO_SIZE, UART_INTR);
+	else if (error < 0)
+		return (error);
 	init_mmio_rtc(ctx);
 	fdt_add_rtc(RTC_MMIO_BASE, RTC_MMIO_SIZE, RTC_INTR);
 	fdt_add_timer();