From nobody Thu Feb 22 10:31:27 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TgTvg6hwvz5CM83; Thu, 22 Feb 2024 10:31:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TgTvg4d3Gz4kw0; Thu, 22 Feb 2024 10:31:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708597887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3RRZtIl3/J9FjMp1uKOtt4pkZHgZlgy6Hm7j7OSZTDU=; b=cyfUNGFBMtEelkgQ+mr2ipWs9FMiL3WoJaM4wMjm1YckqaM+vcJv00iEN1eMIonzn7EgGQ qlTlibwu5/9kHG6RQeWTvYnqMFCrOUXdH5gAKSfz5W9wq628SWhJDwCtYJw6loeCmLooUT k7ToS7DIqbmikFFnWhWIhWA+7dMnkcWpjYv5AIIKwmYjMSTxufbPvQ3/q1IrYgjjPi3LmX InFm63oq7uSbEPr4h2YMUwUN91fqkwBcNEE9XJlk2+PiS8ll4uhHHJecYjkLsynhZwZmhS MwEmqeQ225GQSjCKobWilBSkskV2Orin1zL8Xtav3ONpdTdhC8NtjrGH5sgrJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708597887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3RRZtIl3/J9FjMp1uKOtt4pkZHgZlgy6Hm7j7OSZTDU=; b=ipxwYyciVb76hNIZPEAyd/ov5ammg+KNweS9SWQkBQX7U9waO3hp1RyzdBBOLlevKKAUwo H4JI+99ar7Rb8VyhT8JV933ReZchVsYEyFXnAxJPCZbitzuvZKnsWOU5qVdReFJ99SmVPQ Tgab+EC/Mvo2kHxRAzod/7HFPvzAlVKBKsmGF7Qdm2787kICDiXkhhubDu/OVaTlq5YWzU IZ95Xv0KaN/s4u41e1gHYkd9T6kBYNfBURvPH/U8J7KAXKtjAoVlHyBihQDRkTe+leUz/Q Mo3wVrGNAZIV8f2A4KAWyr8JReQkehVvPQpoc+C9y9RCPfkDO5r4YEL4WQEC4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708597887; a=rsa-sha256; cv=none; b=McxPtlneBxB+xRMvSJuFX1UcCI/SZ8cibMkKLSSQW8rr7Lb98HZWLOZ42GRQ6vo0vLwfvZ JFCMeXb+bHoxEcBl2Tq7TbitqoJzMIMlFVOfZ74CXjW2CtT5JD4ls3y4UiWoWp8861UV8P lwZmN76PeFQPqKuHZ9jvavnwEXma8Wdiag05hGHw4L6Bkyf5cEX/YGcofw6e8CR6tOqoP9 zkZ+ZXC67jMIkRQfs3tl1MjttQIWtj0D1ldxR2FcyPnnQKQn3xgOMO0NvIHMxhPIZApINv 0QW5cPSTkxxzyWRfG1+zNDo74/ym8A+a1YGOCStG+OL5/4rcRh4KoY4KDi9yQA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TgTvg3jSszSKJ; Thu, 22 Feb 2024 10:31:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41MAVREt018291; Thu, 22 Feb 2024 10:31:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41MAVRsT018288; Thu, 22 Feb 2024 10:31:27 GMT (envelope-from git) Date: Thu, 22 Feb 2024 10:31:27 GMT Message-Id: <202402221031.41MAVRsT018288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Roger Pau =?utf-8?Q?Monn=C3=A9?= Subject: git: 4401b0685163 - main - x86/cpu: introduce an optional hook for early hypervisor initialization List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4401b0685163c0a460c1f41b107225b0b0ee2062 Auto-Submitted: auto-generated The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=4401b0685163c0a460c1f41b107225b0b0ee2062 commit 4401b0685163c0a460c1f41b107225b0b0ee2062 Author: Roger Pau MonnĂ© AuthorDate: 2024-02-02 10:36:52 +0000 Commit: Roger Pau MonnĂ© CommitDate: 2024-02-22 10:08:05 +0000 x86/cpu: introduce an optional hook for early hypervisor initialization Hypervisor detection is done very early on x86, and so can be used to also do some very early hypervisor related initialization. Such initialization is required when running as a Xen PVH guest, as for example the PIT needs to be replaced with an hypervisor based timecounter. Introduce an optional hook that gets called as part of the early hypervisor detection. No functional change intended. Sponsored by: Cloud Software Group Reviewed by: markj kib Differential revision: https://reviews.freebsd.org/D43763 --- sys/x86/x86/identcpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index df24c5bddffd..6df138bccba1 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -1343,6 +1343,7 @@ SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL); static struct { const char *vm_cpuid; int vm_guest; + void (*init)(void); } vm_cpuids[] = { { "XenVMMXenVMM", VM_GUEST_XEN }, /* XEN */ { "Microsoft Hv", VM_GUEST_HV }, /* Microsoft Hyper-V */ @@ -1355,6 +1356,7 @@ static struct { static void identify_hypervisor_cpuid_base(void) { + void (*init_fn)(void) = NULL; u_int leaf, regs[4]; int i; @@ -1391,6 +1393,7 @@ identify_hypervisor_cpuid_base(void) if (strncmp((const char *)®s[1], vm_cpuids[i].vm_cpuid, 12) == 0) { vm_guest = vm_cpuids[i].vm_guest; + init_fn = vm_cpuids[i].init; break; } @@ -1423,10 +1426,13 @@ identify_hypervisor_cpuid_base(void) * preferred. */ vm_guest != VM_GUEST_HV) - return; + break; } } } + + if (init_fn != NULL) + init_fn(); } void