mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yasunori Goto <y-goto@jp.fujitsu.com>
To: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: clemens@ladisch.de,
	Linux Kernel ML <linux-kernel@vger.kernel.org>,
	robert.picco@hp.com, venkatesh.pallipadi@intel.com,
	vojtech@suse.cz, mingo@redhat.com
Subject: Re: [Patch] Fix the possibility of insane return value of  hpet_calibrate() against SMI.
Date: Mon, 16 Mar 2009 11:34:55 +0900	[thread overview]
Message-ID: <20090316111300.7CE5.E1E9C6FF@jp.fujitsu.com> (raw)
In-Reply-To: <7d1d9c250903151256l36586764wfbd5e2578a45663c@mail.gmail.com>

> On Fri, Mar 13, 2009 at 1:00 AM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
> > Hello.
> >
> > I think there is a possibility that HPET driver will return
> > insane value due to a SMI interruption (or switching guests by hypervisor).
> > I found it by reviewing, and I would like to fix it.
> >
> > Current HPET driver calibrates the adjustment value
> > by calculation the elapse time in CPU busy loop.
> > However this way is too dangerous against SMI interruption.
> >
> > Here is the calibration code in hpet_calibrate()
> >
> > ?701 static unsigned long hpet_calibrate(struct hpets *hpetp)
> > ? ? ? ? ? ? :
> > ? ? ? ? ? ? :
> > ?728 ? ? ? ? do {
> > ?729 ? ? ? ? ? ? ? ? m = read_counter(&hpet->hpet_mc);
> > ?730 ? ? ? ? ? ? ? ? write_counter(t + m + hpetp->hp_delta, &timer->hpet_compare);
> > ?731 ? ? ? ? } while (i++, (m - start) < count);
> > ?732
> > ?733 ? ? ? ? local_irq_restore(flags);
> > ?734
> > ?735 ? ? ? ? return (m - start) / i;
> >
> > If SMI interruption occurs between 728 to 731, then return value will be
> > bigger value than correct one. (SMI is not able to be controlled by OS.)
> >
> >
> > This patch is a simple solution to fix it.
> > hpet_calibrate() is called 5 times, and one of them is expected as
> > correct value.
> 
> I've no sense of feel for how long each calibration run would take.
> Would doing it 5 times show up as a significant increase in the boot
> time for those that care about boot time being as quick as possible?

Hmm. The loop times is trade off against reliable value....
Though SMI is rare interruption, I don't know how frequent
hypervisor's switch is.

Each calibration of this has 1 milli second.
Do you think 5 msec is too long?
If yes, how is 3 msec? Is it still too long?

Thanks.

-- 
Yasunori Goto 



  reply	other threads:[~2009-03-16  2:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-13  5:00 Yasunori Goto
2009-03-14  8:23 ` Rik van Riel
2009-03-15 19:56 ` Paul Gortmaker
2009-03-16  2:34   ` Yasunori Goto [this message]
2009-03-16  8:59     ` Vojtech Pavlik
2009-03-16  9:52     ` Clemens Ladisch
2009-03-17 10:12       ` Yasunori Goto
2009-03-17 13:12         ` Paul Gortmaker
2009-03-18  0:45           ` Yasunori Goto
2009-03-18  2:47             ` [Patch] Fix the possibility of insane return value of hpet_calibrate() against SMI. (take 2) Yasunori Goto
2009-03-18  7:44               ` Clemens Ladisch
2009-03-18  8:25                 ` Vojtech Pavlik
2009-03-18 13:55               ` Paul Gortmaker
2009-03-18 15:11                 ` Clemens Ladisch
2009-03-18 15:32                   ` Paul Gortmaker
2009-03-30 21:06               ` Andrew Morton
2009-03-30 21:23                 ` Paul Gortmaker
  -- strict thread matches above, loose matches on Subject: below --
2008-12-04 10:34 [Patch] Fix the possibility of insane return value of hpet_calibrate() against SMI Yasunori Goto

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=20090316111300.7CE5.E1E9C6FF@jp.fujitsu.com \
    --to=y-goto@jp.fujitsu.com \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=robert.picco@hp.com \
    --cc=venkatesh.pallipadi@intel.com \
    --cc=vojtech@suse.cz \
    /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®