From 5720dca01aa846aef724a48c8af1c05ae034abe6 Mon Sep 17 00:00:00 2001 From: mlarkin Date: Wed, 11 Jul 2018 14:48:40 +0000 Subject: [PATCH] Detect vmm(4) in the bootloader and automatically switch to the serial console at 115200 baud. tested by phessler and myself, ok deraadt --- sys/arch/amd64/stand/boot/conf.c | 4 ++-- sys/arch/amd64/stand/cdboot/conf.c | 4 ++-- sys/arch/amd64/stand/libsa/machdep.c | 26 ++++++++++++++++++++++++-- sys/arch/amd64/stand/pxeboot/conf.c | 4 ++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/sys/arch/amd64/stand/boot/conf.c b/sys/arch/amd64/stand/boot/conf.c index 0154b0b389b..37c1ffea52c 100644 --- a/sys/arch/amd64/stand/boot/conf.c +++ b/sys/arch/amd64/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.40 2018/04/18 16:34:58 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.41 2018/07/11 14:48:40 mlarkin Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -40,7 +40,7 @@ #include #include -const char version[] = "3.39"; +const char version[] = "3.40"; int debug = 1; diff --git a/sys/arch/amd64/stand/cdboot/conf.c b/sys/arch/amd64/stand/cdboot/conf.c index 7eaae57d984..41f976fc5b7 100644 --- a/sys/arch/amd64/stand/cdboot/conf.c +++ b/sys/arch/amd64/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.35 2018/04/18 16:34:58 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.36 2018/07/11 14:48:40 mlarkin Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -41,7 +41,7 @@ #include #include -const char version[] = "3.39"; +const char version[] = "3.40"; int debug = 1; diff --git a/sys/arch/amd64/stand/libsa/machdep.c b/sys/arch/amd64/stand/libsa/machdep.c index c6664ba33a9..246cda51cd8 100644 --- a/sys/arch/amd64/stand/libsa/machdep.c +++ b/sys/arch/amd64/stand/libsa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.6 2015/09/18 13:30:56 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.7 2018/07/11 14:48:40 mlarkin Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -31,6 +31,8 @@ #include "biosdev.h" #include #include +#include +#include #ifdef EFIBOOT #include "efiboot.h" @@ -44,11 +46,15 @@ volatile struct BIOS_regs BIOS_regs; #define CKPT(c) /* c */ #endif +const char *vmm_hv_signature = VMM_HV_SIGNATURE; + void machdep(void) { - int i, j; + int i, j, vmm = 0; struct i386_boot_probes *pr; + uint32_t dummy, ebx, ecx, edx; + dev_t dev; /* * The list of probe routines is now in conf.c. @@ -65,6 +71,22 @@ machdep(void) printf("\n"); } } + + CPUID(0x1, dummy, dummy, ecx, dummy); + if (ecx & CPUIDECX_HV) { + CPUID(0x40000000, dummy, ebx, ecx, edx); + if (memcmp(&ebx, &vmm_hv_signature[0], sizeof(uint32_t)) == 0 && + memcmp(&ecx, &vmm_hv_signature[4], sizeof(uint32_t)) == 0 && + memcmp(&edx, &vmm_hv_signature[8], sizeof(uint32_t)) == 0) + vmm = 1; + } + + /* Set console to com0/115200 by default in vmm */ + if (vmm) { + dev = ttydev("com0"); + cnspeed(dev, 115200); + cnset(dev); + } } int diff --git a/sys/arch/amd64/stand/pxeboot/conf.c b/sys/arch/amd64/stand/pxeboot/conf.c index fd4103a3ddb..4d40f45d7fc 100644 --- a/sys/arch/amd64/stand/pxeboot/conf.c +++ b/sys/arch/amd64/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.39 2018/04/18 16:34:58 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.40 2018/07/11 14:48:40 mlarkin Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -43,7 +43,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.39"; +const char version[] = "3.40"; int debug = 0; void (*sa_cleanup)(void) = pxe_shutdown; -- 2.20.1