From: Hugh Dickins <hugh@veritas.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: "Ingo Molnar" <mingo@elte.hu>, "Rafał Miłecki" <zajec5@gmail.com>,
"Alan Jenkins" <alan-jenkins@tuffmail.co.uk>,
"H. Peter Anvin" <hpa@zytor.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC] x86: check for and defend against BIOS memory corruption
Date: Mon, 8 Sep 2008 12:35:47 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0809081157020.14401@blonde.site> (raw)
In-Reply-To: <48B80C26.2080002@goop.org>
On Fri, 29 Aug 2008, Jeremy Fitzhardinge wrote:
> Hugh Dickins wrote:
>
> > Is this the right moment for me to mention again that I'm not sure
> > your reuse of existing pagetables was quite right anyway: NX being
> > excluded from level2_ident_pgt, but wanted in the direct map?
>
> We could add NX. What's the behaviour of setting NX in a
> non-NX-supporting CPU? I don't think it would trigger a "reserved bit"
> exception (the other high pte flags don't). Or failing that, we could
> mask out NX once we've worked out the CPU doesn't support it (at the
> same time it relocates the pagetables to the kernel's load-time address).
I've no experience of what happens if NX is set to a non-NX-supporting
CPU, so can't advise on that at all. But I think you're looking at
it the wrong way round - or else I am.
Here's the declaration and comment on level2_ident_pgt in head_64.S:
NEXT_PAGE(level2_ident_pgt)
/* Since I easily can, map the first 1G.
* Don't set NX because code runs from these pages.
*/
PMDS(0, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD)
(The "Since I easily can" comment is there because it used to map
only a subset needed for early kernel startup, not the whole 1G.)
So it's very intentionally leaving NX out there. I believe the
level2_ident_pgt page appears twice or more in the pagetable layout,
used to map two or more areas of virtual address space - once to
provide the direct map at ffff880000000000 and once to provide
the kernel image virtual mapping at ffffffff80200000.
I think we don't want NX on Linux kernel text ;-?
Before your 2.6.27-rc changes, init_memory_mapping subsequently
replaced the direct map usage by a separately constructed pagetable,
similar to it but with NX set throughout. After your 2.6.27-rc
changes, level2_ident_pgt is found there already so left untouched -
leaving NX out of that first 1G of the direct map forever (when CPA
splits it up, the smaller pages inherit the lack of NX too).
I noticed when changing /proc/meminfo to show DirectMap in kB,
and tried to fix it, but only gave myself a non-booting system
(I probably shrank my direct map to 0 while implicitly using it).
And at that stage I didn't realize at all that it was a recent
regression arising from your mods.
I'm reluctant to delve in there again at present, and unsure
what the right fix should be: perhaps the code which checks if
an entry is already there, should check if it has the desired
flags?
Hugh
next prev parent reply other threads:[~2008-09-08 11:36 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 19:52 Jeremy Fitzhardinge
2008-08-29 1:49 ` Yinghai Lu
2008-08-29 3:28 ` Jeremy Fitzhardinge
2008-08-29 9:25 ` Alan Cox
2008-08-29 10:13 ` Rafał Miłecki
2008-08-29 10:06 ` Alan Cox
2008-08-29 10:24 ` Hugh Dickins
2008-08-29 11:54 ` Rafał Miłecki
2008-08-29 12:09 ` Alan Jenkins
2008-08-29 13:21 ` Hugh Dickins
2008-08-29 16:30 ` Rafał Miłecki
2008-08-29 17:39 ` Rafał Miłecki
2008-09-04 19:42 ` Rafał Miłecki
2008-09-04 20:23 ` Hugh Dickins
2008-09-04 23:04 ` Jeremy Fitzhardinge
2008-09-06 18:09 ` Ingo Molnar
2008-08-29 14:08 ` Jeremy Fitzhardinge
2008-08-29 14:18 ` Jeremy Fitzhardinge
2008-08-29 20:31 ` Kasper Sandberg
2008-08-30 1:15 ` Jeremy Fitzhardinge
2008-08-29 6:20 ` Rafał Miłecki
2008-08-29 6:45 ` Ingo Molnar
2008-08-29 7:21 ` Jeremy Fitzhardinge
2008-08-29 7:30 ` Ingo Molnar
2008-08-29 8:02 ` Jeremy Fitzhardinge
2008-08-29 7:22 ` Jeremy Fitzhardinge
2008-08-29 8:14 ` Hugh Dickins
2008-08-29 14:48 ` Jeremy Fitzhardinge
2008-08-29 17:20 ` H. Peter Anvin
2008-09-08 11:35 ` Hugh Dickins [this message]
2008-09-08 17:16 ` Jeremy Fitzhardinge
2008-09-08 19:14 ` Hugh Dickins
2008-09-08 19:45 ` Jeremy Fitzhardinge
2008-08-29 17:02 ` H. Peter Anvin
2008-08-29 17:03 ` H. Peter Anvin
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=Pine.LNX.4.64.0809081157020.14401@blonde.site \
--to=hugh@veritas.com \
--cc=alan-jenkins@tuffmail.co.uk \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=zajec5@gmail.com \
/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®