mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: mikelley@microsoft.com, kvm <kvm@vger.kernel.org>
Cc: bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com,
	 haiyangz@microsoft.com, kys@microsoft.com,
	linux-hyperv@vger.kernel.org,  linux-kernel@vger.kernel.org,
	lirongqing@baidu.com, mingo@redhat.com,  seanjc@google.com,
	tglx@linutronix.de, wei.liu@kernel.org, x86@kernel.org
Subject: RE: [PATCH] clockevents/drivers/i8253: Do not zero timer counter in shutdown
Date: Thu, 01 Aug 2024 10:00:38 +0100	[thread overview]
Message-ID: <8eb7ba99a746110597bbac6f1e027aa63384dfce.camel@infradead.org> (raw)
In-Reply-To: <BYAPR21MB168840B3814336ED510845C0D7D89@BYAPR21MB1688.namprd21.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]




On 2023-02-08 at 01:04:19 +0000, "Michael Kelley (LINUX)" <mikelley@microsoft.com> said:
> From: lirongqing@baidu.com <lirongqing@baidu.com> Sent: Monday, February 6, 2023 5:15 PM
> > 
> > Zeroing the counter register in pit_shutdown() isn't actually supposed to
> > stop it from counting,  will causes the PIT to start running again,
> > From the spec:
> > 
> >   The largest possible initial count is 0; this is equivalent to 216 for
> >   binary counting and 104 for BCD counting.
> > 
> >   The Counter does not stop when it reaches zero. In Modes 0, 1, 4, and 5 the
> >   Counter "wraps around" to the highest count, either FFFF hex for binary
> >   count- ing or 9999 for BCD counting, and continues counting.
> > 
> >   Mode 0 is typically used for event counting. After the Control Word is
> >   written, OUT is initially low, and will remain low until the Counter
> >   reaches zero. OUT then goes high and remains high until a new count or a
> >   new Mode 0 Control Word is written into the Counter.
> > 
> > Hyper-V and KVM follow the spec, the issue that 35b69a42 "(clockevents/drivers/
> > i8253: Add support for PIT shutdown quirk") fixed is in i8253 drivers, not Hyper-v,
> > so delete the zero timer counter register in shutdown, and delete PIT shutdown
> > quirk for Hyper-v
> 
> From the standpoint of Hyper-V, I'm good with this change.  But there's a
> risk that old hardware might not be compliant with the spec, and needs the
> zero'ing for some reason. The experts in the x86 space will be in the best
> position to assess the risk.  At the time, the quirk approach was taken so
> the change applied only to Hyper-V, and any such risk was avoided.
> 
> For Hyper-V,
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>

It's not entirely clear why we zero it at all. What was it supposed to
achieve?

I suppose if we want to be ultra-careful, perhaps we could do the
zeroing only on real hardware, if hypervisor_is_type(X86_HYPER_NATIVE)?

This does seem to be making VMMs spend a bunch of time stealing cycles
from the guest to emulate an unwanted timer, so it would be good to fix
it.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

  parent reply	other threads:[~2024-08-01  9:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07  1:14 lirongqing
2023-02-08  1:04 ` Michael Kelley (LINUX)
2023-02-08 15:04   ` Sean Christopherson
2023-02-24  9:45     ` Li,Rongqing
     [not found]     ` <3b8496c071214bda9e5ecfa048f18ab9@baidu.com>
2023-04-13  1:28       ` Wei Liu
     [not found]       ` <1311175816673.202304.ZDdawTGHoa/UH20U@liuwe-devbox-debian-v2>
2023-04-14  5:17         ` Li,Rongqing
2024-08-01  9:00   ` David Woodhouse [this message]
2024-08-01 15:22     ` David Woodhouse
2024-08-01 21:07       ` Thomas Gleixner
2024-08-01 21:10         ` David Woodhouse
2024-08-01 14:21 ` Thomas Gleixner
2024-08-01 16:14   ` Michael Kelley
2024-08-01 18:54     ` Thomas Gleixner
2024-08-02  8:21       ` David Woodhouse
2024-08-02 14:55         ` Sean Christopherson
2024-08-02 15:04           ` David Woodhouse
2024-08-12 23:59             ` Sean Christopherson
2024-08-13  6:39               ` David Woodhouse
2024-08-01 17:49   ` David Woodhouse
2024-08-01 18:25     ` David Woodhouse
2024-08-01 18:57       ` Thomas Gleixner
2024-08-02  8:07         ` David Woodhouse
2024-08-02 10:49           ` Thomas Gleixner
2024-08-02 11:04             ` David Woodhouse
2024-08-02 13:27               ` Thomas Gleixner
2024-08-02 13:46                 ` David Woodhouse
2024-08-01 19:06     ` Thomas Gleixner
2024-08-01 19:21       ` David Woodhouse
2024-08-01 20:00         ` Thomas Gleixner
2024-08-01 20:49           ` David Woodhouse
2024-08-01 21:22             ` Thomas Gleixner
2024-08-01 21:31               ` David Woodhouse
2024-08-02  9:55                 ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8eb7ba99a746110597bbac6f1e027aa63384dfce.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=mikelley@microsoft.com \
    --cc=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®