mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Robert_Hentosh@dell.com
Cc: linux-kernel@vger.kernel.org, johnsonm@redhat.com,
	alan@redhat.com, arjanv@redhat.com
Subject: Re: [PATCH] reboot=bios is invalidating cache incorrectly
Date: Wed, 24 Apr 2002 19:10:07 +0100	[thread overview]
Message-ID: <20020424191007.A22278@kushida.apsleyroad.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0204191651160.32269-100000@humbolt.us.dell.com>

Robert Hentosh wrote:
> The hand assembled routine contained in the array "real_mode_switch" 
> contains INVD which invalidates the CPU caches, unfortunately the routine 
> was just previously copied via memcpy and is contained in the cache.  This 
> leads to unexpected results.  The following patch replaces INVD with 
> WBINVD which will insure that the routine is written to RAM before 
> invalidating the cache, providing more reliable reboots.

Hi Robert,

I wrote that code originally.

I wasn't sure that `wbinvd' was safe with the cache disabled, but I've
looked more closely at some Intel docs, and it seems that CD and NW
simply change the behaviour of the cache -- the cache is still used, but
it has slightly different behaviour.

There is another bug with both `wbinvd' and `invd': it is possible (on
some 486s at least) that a cache line fill is in progress when the
`wbinvd' executes, and that line won't be flushed.  In particular, the
i-cache line containing the `wbinvd' instruction itself is quite likely
to be being filled at the time.

The process will access filled cache lines even with CD ("cache
disable") and NW set in CR0, yet it won't fill write back changes to
RAM.  (It's a rarely used capability to allow execution from cache
without external bus traffic).  This is quite a nasty state for the BIOS
to inherit.

I think that this will occur in practice, if the bug is still present on
real CPUs: we have just copied the real mode code, so the copy is dirty
in the d-cache which means that it is definitely not valid in the
i-cache.  And so the cache line containing the `wbinvd' instruction may
still be filling when the instruction executes.

http://ivs.cs.uni-magdeburg.de/~zbrog/asm/86bugs.html shows how to fix
this.  It's a bit fiddly, and involves a PC-relative address so the code
isn't a two-liner.  So I'm not going to write that fix.

Summary to all Cc'd: please do apply Robert's patch.  It would make
sense on the 2.2 stable branch too, after some user testing on 2.4/2.5
has verified that its ok for everyone.

cheers,
-- Jamie

  reply	other threads:[~2002-04-24 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-19 22:00 Robert Hentosh
2002-04-24 18:10 ` Jamie Lokier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-04-23 20:02 Robert_Hentosh
2002-04-23 13:51 Martin Knoblauch
2002-04-19 20:21 Robert_Hentosh

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=20020424191007.A22278@kushida.apsleyroad.org \
    --to=lk@tantalophile.demon.co.uk \
    --cc=Robert_Hentosh@dell.com \
    --cc=alan@redhat.com \
    --cc=arjanv@redhat.com \
    --cc=johnsonm@redhat.com \
    --cc=linux-kernel@vger.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®