From 1d2c60d6345a6b81c5bfd559daf413c6669f6d28 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 31 Aug 2021 15:52:59 +0000 Subject: [PATCH] Identify the paravirtual bus earlier, as we need to make sure that we have a working delay func ready before the first occurence of delay(). This is necessary on Hyper-V Gen 2 VMs where we don't use the TSC. Discussed with the hackroom ok kettenis@ --- sys/arch/amd64/amd64/identcpu.c | 13 ++++++++++++- sys/arch/amd64/amd64/mainbus.c | 8 +------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index b74955a6a61..c977e64de96 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.119 2021/08/31 15:11:54 kettenis Exp $ */ +/* $OpenBSD: identcpu.c,v 1.120 2021/08/31 15:52:59 patrick Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -41,10 +41,15 @@ #include #include "vmm.h" +#include "pvbus.h" #include #include +#if NPVBUS > 0 +#include +#endif + void replacesmap(void); void replacemeltdown(void); uint64_t cpu_freq(struct cpu_info *); @@ -522,6 +527,12 @@ identifycpu(struct cpu_info *ci) ci->ci_model += ((ci->ci_signature >> 16) & 0x0f) << 4; } +#if NPVBUS > 0 + /* Detect hypervisors early, attach the paravirtual bus later */ + if (CPU_IS_PRIMARY(ci) && cpu_ecxfeature & CPUIDECX_HV) + pvbus_identify(); +#endif + if (ci->ci_feature_flags && ci->ci_feature_flags & CPUID_TSC) { /* Has TSC, check if it's constant */ if (!strcmp(cpu_vendor, "GenuineIntel")) { diff --git a/sys/arch/amd64/amd64/mainbus.c b/sys/arch/amd64/amd64/mainbus.c index ed8bd9c4368..b74c98781a8 100644 --- a/sys/arch/amd64/amd64/mainbus.c +++ b/sys/arch/amd64/amd64/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.50 2020/05/14 13:07:11 kettenis Exp $ */ +/* $OpenBSD: mainbus.c,v 1.51 2021/08/31 15:52:59 patrick Exp $ */ /* $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */ /* @@ -167,12 +167,6 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) printf("\n"); -#if NPVBUS > 0 - /* Detect hypervisors early, attach the paravirtual bus later */ - if (cpu_ecxfeature & CPUIDECX_HV) - pvbus_identify(); -#endif - #if NEFIFB > 0 efifb_cnremap(); #endif -- 2.20.1