From owner-svn-src-all@freebsd.org Thu May 14 22:32:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E54AC2E26D8; Thu, 14 May 2020 22:32:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49NRBF3rtnz42l1; Thu, 14 May 2020 22:32:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id 04EMWTZj007272 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 15 May 2020 01:32:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 04EMWTZj007272 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 04EMWTMP007271; Fri, 15 May 2020 01:32:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 15 May 2020 01:32:29 +0300 From: Konstantin Belousov To: Peter Grehan Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r361064 - head/sys/amd64/vmm Message-ID: <20200514223229.GA46537@kib.kiev.ua> References: <202005142218.04EMICgT045505@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202005142218.04EMICgT045505@repo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 49NRBF3rtnz42l1 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-5.93 / 15.00]; NEURAL_HAM_MEDIUM(-0.93)[-0.931,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2020 22:32:38 -0000 On Thu, May 14, 2020 at 10:18:12PM +0000, Peter Grehan wrote: > Author: grehan > Date: Thu May 14 22:18:12 2020 > New Revision: 361064 > URL: https://svnweb.freebsd.org/changeset/base/361064 > > Log: > Hide host CPUID 0x15 TSC/Crystal ratio/freq info from guest > > In recent Linux (5.3+) and OpenBSD (6.6+) kernels, and with hosts that > support CPUID 0x15, the local APIC frequency is determined directly > from the reported crystal clock to avoid calibration against the 8254 > timer. > > However, the local APIC frequency implemented by bhyve is 128MHz, where > most h/w systems report frequencies around 25MHz. This shows up on > OpenBSD guests as repeated keystrokes on the emulated PS2 keyboard > when using VNC, since the kernel's timers are now much shorter. > > Fix by reporting all-zeroes for CPUID 0x15. This allows guests to fall > back to using the 8254 to calibrate the local APIC frequency. > > Future work could be to compute values returned for 0x15 that would > match the host TSC and bhyve local APIC frequency, though all dependencies > on this would need to be examined (for example, Linux will start using > 0x16 for some hosts). FreeBSD uses 0x15 (and 0x16 if there is no 0x15) as well. We recheck against 8254 and decide that there is no ISA timer if calibration differs too much from CPUID numbers.