From nobody Mon Feb 20 16:24:24 2023 X-Original-To: dev-commits-src-branches@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 4PL76K1Tyrz3t2Xy; Mon, 20 Feb 2023 16:24:25 +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 4PL76J2r2Zz4Cvj; Mon, 20 Feb 2023 16:24:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676910264; 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=u0uFX+rhsYcD6kDVRW/thGrA42dtMKx0RwmBLnKl76I=; b=n/Pg8wKxSkj+gz500X4qJk8jwBlu6ni6uEBUPiDhXaw+o4fPuIm9KD6VRwpWt1TckEgwQx +/y22s0TKh7FdWFBxhDM4UruBXldC4PK9MPnMZoMmAt2CNauQc+A57tZujFlMEJcJNxQEL sfMRWbvhUVSLshirxU+cN7oyVh5r4mERgonITHUOzT1ci5as/pfiPXKH402xXZeDpdVvcF VRb09pYwfTk1Y2YzwJclx2UiDALdfUIaC1vNQWI1hrqOfZwWMkb+PoXT3ujwxH2ApM7rXX VxzdBizfE/x4M8POZvehS35tTabOnFebRWBMl22MrmgxuSgGLFz5P2jC2aX7AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676910264; 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=u0uFX+rhsYcD6kDVRW/thGrA42dtMKx0RwmBLnKl76I=; b=j1ANHg6ZjzPbJu+FUWASHIs+6aaZNu1un+9kDCOlb2SCA3FVwIpvVnOZ86zlonmshUHOYC pB6w3q2qcqzyU7m2j4RTrye5s+qXMQbOGnCvYOkJsKpdSDIBBXcYKYc38tX7J4WhpN83ND AGCaBrPSk8+FoUAluo7C9IKZ2KRj3TIOsa+TVcPXu9FInXOhH5ddIQcFGm5GcXfFo4VE1J 9c2v9qcPbxpDoE2baKKpxZPNn9olT3xhBu4SLsDx3IRoepJgiTNRtuP2e7/Q/oupSueCEJ 6xkwttcaJIGu6kcsd8SaJBJldYH0URn6CkpsbpaG7ElEICaivt8HBI8Io0WzRQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676910264; a=rsa-sha256; cv=none; b=wc/m2ytXdja1lfmrURAnHmaMB1W45LDtavDkFi4S/uF2ZXzXt8XIYhx1xpEXl2WDqaP+Up 9UwieTtw0vplFtJ7k7Fv5r2+Bl9RSSN/KS+TXCr7sJriB/vnRLzUUNM1+cojiU2DKf+8+z Y0fSKcwFmXoRhhaav5qjrjbZ4LrtAM3ZH5shYPt0tE/8DzhGo/X4AQSiwJhdMsxTrQ3/1C BQY9vopP01r6ll8ZidQKu7NTVX6bqk9U0Znq1ZyTA+j0NCkoFAGhybSdAXxO2lcsj43WKP T/d/2ini5bHpQCyJlIepTT59UFqUXwXUg+4m4V/+cRe7VWK1WJVUqY1f77h6gQ== 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 4PL76J1T5GznJ0; Mon, 20 Feb 2023 16:24:24 +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 31KGOOaC064692; Mon, 20 Feb 2023 16:24:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31KGOO6V064691; Mon, 20 Feb 2023 16:24:24 GMT (envelope-from git) Date: Mon, 20 Feb 2023 16:24:24 GMT Message-Id: <202302201624.31KGOO6V064691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 460e41a24baf - stable/13 - man4: Add a manual page for kvmclock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 460e41a24baf03b910364e77bfce02baf3047891 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=460e41a24baf03b910364e77bfce02baf3047891 commit 460e41a24baf03b910364e77bfce02baf3047891 Author: Mark Johnston AuthorDate: 2023-02-03 15:54:50 +0000 Commit: Mark Johnston CommitDate: 2023-02-20 16:24:08 +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 (cherry picked from commit a2286a1f4651f9369cacb82bb1777920f5a86fdc) --- 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 0af0246f9328..a8064d12fc0d 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -273,6 +273,7 @@ MAN= aac.4 \ ktls.4 \ ktr.4 \ kue.4 \ + ${_kvmclock.4} \ lagg.4 \ le.4 \ led.4 \ @@ -846,6 +847,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 _ndis.4= ndis.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 .