mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dave Airlie <airlied@linux.ie>
Cc: Andy Lutomirski <luto@mit.edu>,
	dri-devel@lists.sf.net, linux-kernel@vger.kernel.org
Subject: Re: [git pull] drm: previous pull req + 1.
Date: Sun, 21 Jun 2009 10:13:31 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0906210948340.3119@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.01.0906210945170.3119@localhost.localdomain>



On Sun, 21 Jun 2009, Linus Torvalds wrote:
> 
> Dave - no amount of userspace differences make a corrupted page table 
> acceptable. 
> 
> This needs to be fixed. No excuses. Kernel crashes are never an issue of 
> "you used the wrong user space".

So "corrupted page table" means that one of the reserved bits was set, and 
we get a page fault with the PF_RSVD bit on in the error code.

Looking at the debug output, it says

	PGD        12148a067
	PUD        12148b067
	PMD        121496067
	PTE ffffc90011780237

where the top-level entries look fine, but the PTE is total crap. It looks 
like it has filled in the page frame number with a virtual address rather 
than with an actual page

The PTE _should_ look like this:

 - bit 63: NX
 - bits 62-52: zero (available to sw, but I don't think we use them)
 - bits 51-47: zero (reserved)
 - bits 46-12: page frame
 - bits 11-0: protection and PAT bits etc (bits 8-7 are also reserved)

and that PTE clearly does not match.

Strictly speaking, that "47-bit" physical address is purely theoretical. I 
think existing CPU's are limited to 40 bits or so, so there are even more 
reserved bits. 

Anyway, here's a totally UNTESTED patch that hopefully gives a warning on 
where exactly we set the invalid bits. Andy, mind trying it out? You 
should get the warnign much earlier, and it should have a much more useful 
back-trace.

(But this is _untested_, so maybe I screwed up and it doesn't compile or 
work. The BAD_PTE_BITS mask could also be improved upon, but that mask 
should be "good enough" - it doesn't include _all_ the bits it could, 
but it certainly has enough bits set to trigger that obviously bad case).

			Linus

---
 arch/x86/include/asm/pgtable_64.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index c57a301..b95828e 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -49,8 +49,11 @@ static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
 	*ptep = native_make_pte(0);
 }
 
+#define BAD_PTE_BITS (_PAGE_NX - (1ul << __PHYSICAL_MASK_SHIFT))
+
 static inline void native_set_pte(pte_t *ptep, pte_t pte)
 {
+	WARN_ON_ONCE(pte.pte & BAD_PTE_BITS);
 	*ptep = pte;
 }
 

  reply	other threads:[~2009-06-21 17:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-20  5:23 Dave Airlie
2009-06-21  0:04 ` Maxim Levitsky
2009-06-21  0:42   ` Linus Torvalds
2009-06-21 14:47     ` Maxim Levitsky
2009-06-21 21:24       ` Chris Wilson
2009-06-22 18:09         ` Maxim Levitsky
2009-06-29  7:57           ` Chris Wilson
2009-06-30  9:49             ` Chris Wilson
2009-07-09 23:11             ` Eric Anholt
2009-06-21  1:33   ` Dave Airlie
2009-06-21  3:41 ` Andy Lutomirski
2009-06-21  5:16   ` Dave Airlie
2009-06-21 12:06     ` Andrew Lutomirski
2009-06-21 16:46     ` Linus Torvalds
2009-06-21 17:13       ` Linus Torvalds [this message]
2009-06-21 18:50         ` Andrew Lutomirski
2009-06-21 19:47           ` Linus Torvalds
2009-06-21 21:14             ` Andrew Lutomirski
2009-06-22  0:05               ` Andrew Lutomirski
2009-06-22 19:20                 ` Arnaldo Carvalho de Melo
2009-06-21 22:40             ` Dave Airlie
2009-06-22  8:18               ` Thomas Hellström
2009-06-22  8:30                 ` Dave Airlie
2009-06-22 18:22                 ` Linus Torvalds
2009-06-22 18:59                   ` Andrew Lutomirski
2009-06-22 19:43                     ` Linus Torvalds
2009-06-23  0:01                   ` Benjamin Herrenschmidt
2009-06-23  0:00                 ` Benjamin Herrenschmidt
2009-06-23  0:24                   ` Linus Torvalds
2009-06-23  1:04                     ` Benjamin Herrenschmidt
2009-06-23  1:18                       ` Jesse Barnes
2009-06-23  1:58                         ` Benjamin Herrenschmidt
2009-06-23  2:07                           ` Jesse Barnes
2009-06-23  2:26                             ` Benjamin Herrenschmidt
2009-06-23 15:40                               ` Jesse Barnes
2009-06-23  7:48                         ` Michel Dänzer
2009-06-23 15:39                           ` Jesse Barnes
2009-06-23 16:28                             ` Jesse Barnes
2009-06-22 23:57             ` Benjamin Herrenschmidt
2009-06-21 22:41       ` Dave Airlie

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=alpine.LFD.2.01.0906210948340.3119@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.sf.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@mit.edu \
    /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

Powered by JetHome