From nobody Fri Feb 03 16:50:33 2023 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 4P7hVL3Lwsz3kWD4; Fri, 3 Feb 2023 16:50:34 +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 4P7hVL0nzLz3tjR; Fri, 3 Feb 2023 16:50:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675443034; 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=4dw0ukH2H2R7Sj63TzJwOpJKmxkKhKkmD8jaPq50QYc=; b=SRO8aM41QdRGVfJ9Ne+H7EiCnUpA3aYz3iqEponOkfS8n6b3mzuWBcsq8hyLJkTTnR8G5w D1SDapcctTDFGaQ4f1noscUZTLZUZt5vEysQXCXt3pfcQpnFtEFkx/aKAKmn9oN7A+G9HR h2P/4xbcInp3MMgNKsmuu9X8FwNdvsezIs6ggq8hURMNApB6PAQOsD5Yd7Kgz1hhvqvFyj lDeJBv2WhQlHAOhHpuMTff1gjJlhs5yTVUMXA5QUYrCVN8ZURsSWO2sPxNr6p6IgbXvcnu 8YBhSrY78pc6QOMpMX4+IzxDb9LWOZ1O1TPKj+WrQBXC9zlsalzLaFweWaJjbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675443034; 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=4dw0ukH2H2R7Sj63TzJwOpJKmxkKhKkmD8jaPq50QYc=; b=bIKLalzhRixUBaruOTY8Ud+9RVAYFPwRhFl2ibW6Mml5Zas42HZFn65BP3lvPfsz112O+u FehxRylrfG79Uxj9P2QBv9HDQGBGwm9Jxtw1KRFv7vqWdrzoeZq15El9e8FN3N0561/Pv+ OD2TPAoT1cQy5owJqDrOUsekTOAFxlTYxxVEbjfq6BAx0nmG2SQGT9fCK6kq5fDLe5Dldo TbHnBjaC0Hvczid9+u1+DO8dIRYYh9qo6iiZiEaecxUut8nuKa9gzDXrM37h/Ww3Ou0zJO P9JL6OfhIIrgssnqEuato7zyEy/tB3p4gNUw2dTqF5sl0fvQRMZ0C0QyUQaN1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675443034; a=rsa-sha256; cv=none; b=hfSDEc/CI9iHEj+TTaqUkyvIlkcg9vbbDYWxHyu9iYnU7i2hhrNLqceqUgRcmALOLHdUJG 0LiXFQPs68FV7EnjPW86m1kMbmg34JDe7VhT1xTOCTG7u9GBq2pIeCehghNjZghxzeSGCA rnNX66uLOXlsNmOUXxuLxMFq3tJpOPuOydgwXoNcwOq/BHFrrqUncNnQctVq92KLhiwmS2 Tyd1L2Ai8BwLofrNT5pjBIUVuAPudP28ZDYynAsUELhp+x2laVmjf84Sg0cvtLEo2oVjTm nSULNNo1yp5L2gZ9c8gjCpBkR/Z7yHIQtFeA1D0PS604ARbu11Vw2gJ67yW9Fw== 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 4P7hVK6vqTzhv0; Fri, 3 Feb 2023 16:50:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 313GoXeJ009111; Fri, 3 Feb 2023 16:50:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 313GoXrl009110; Fri, 3 Feb 2023 16:50:33 GMT (envelope-from git) Date: Fri, 3 Feb 2023 16:50:33 GMT Message-Id: <202302031650.313GoXrl009110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a2286a1f4651 - main - man4: Add a manual page for kvmclock 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a2286a1f4651f9369cacb82bb1777920f5a86fdc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a2286a1f4651f9369cacb82bb1777920f5a86fdc commit a2286a1f4651f9369cacb82bb1777920f5a86fdc Author: Mark Johnston AuthorDate: 2023-02-03 15:54:50 +0000 Commit: Mark Johnston CommitDate: 2023-02-03 16:48:25 +0000 man4: Add a manual page for kvmclock Reviewed by: pauamma, imp, kib MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D38343 --- share/man/man4/Makefile | 2 + share/man/man4/kvmclock.4 | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index c54c3de1bf90..1c7703bdaeb2 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -271,6 +271,7 @@ MAN= aac.4 \ ktls.4 \ ktr.4 \ kue.4 \ + ${_kvmclock.4} \ lagg.4 \ le.4 \ led.4 \ @@ -824,6 +825,7 @@ _igc.4= igc.4 _imcsmb.4= imcsmb.4 _io.4= io.4 _itwd.4= itwd.4 +_kvmclock.4= kvmclock.4 _mgb.4= mgb.4 _nda.4= nda.4 _nfe.4= nfe.4 diff --git a/share/man/man4/kvmclock.4 b/share/man/man4/kvmclock.4 new file mode 100644 index 000000000000..55ee5fc1cb42 --- /dev/null +++ b/share/man/man4/kvmclock.4 @@ -0,0 +1,96 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2023 Klara, Inc. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd February 1, 2023 +.Dt KVMCLOCK 4 +.Os +.Sh NAME +.Nm kvmclock +.Nd Para-virtualized clock driver for x86 KVM guests +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device kvm_clock" +.Ed +.Sh DESCRIPTION +This driver reads time-keeping information from the para-virtualized clock +device provided by the KVM hypervisor on Linux hosts. +The +.Nm +driver is only implemented on i386 and amd64 platforms. +It acts as a +.Xr timecounters 4 +device and is preferred over the Time Stamp Counter (TSC) when available. +The driver exports timekeeping information via +.Pa /dev/pvclock , +enabling the implementation of +.Xr clock_gettime 2 +and related functions without entering the kernel. +.Pp +The +.Nm +driver works by accessing a per-vCPU timekeeping structure maintained by the +hypervisor. +It uses a combination of TSC readings and information from the shared structure +to produce a high-resolution timecounter which is invariant under hypervisor +events such as vCPU migration and live VM migration. +.Sh SYSCTL VARIABLES +The following variables are available as both +.Xr sysctl 8 +variables and +.Xr loader 8 +tunables: +.Bl -tag -width indent +.It Va dev.kvmclock.0.vdso_enable_without_rdtscp +By default, timekeeping information is exported to userspace only when the +(virtual) CPU announces support for the +.Dq rdtscp +instruction. +Setting this sysctl to 1 overrides this behavior, allowing timekeeping +information to be exported even in the absence of +.Dq rdtscp +support. +However, this breaks compatibility with copies of +.Pa /lib/libc.so.7 +released prior to +.Fx 14.0 , +and statically linked binaries which embed a copy of the system C library. +Thus, this sysctl value should not be changed if the system may execute +binaries older than +.Fx 14.0 . +.It Va dev.kvmclock.0.vdso_force_unstable +Mark the timecounter as unstable for userspace consumers. +This is mostly useful for debugging the driver and userspace timekeeping code, +and generally should not be touched. +.El +.Sh SEE ALSO +.Xr timecounters 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 13.1 .