Re: [PATCH] x86: use the right protections for split-up pagetables

From: Linus Torvalds
Date: Fri Feb 20 2009 - 10:41:38 EST




On Fri, 20 Feb 2009, Ingo Molnar wrote:
>
> Agreed, split_large_page() was just plain confused here - there
> was no hidden reason for this logic. It makes no sense to bring
> any pte level protection information to the PMD level because a
> pmd entry covers a set of 512 ptes so there's no singular
> protection attribute that can be carried to it.

Btw, I think split_large_page() is confused in another way too, although
I'm not entirely sure that it matters. I suspect that it doesn't, if I
read things correctly.

The confusion? When it moves the 'ref_prot' bits from the upper level, it
doesn't do the right thing for the PAT bit. That bit is special, and moves
around depending on level. In the upper levels, it's bit#12, and in the
final 4k pte level it's bit#7.

So _if_ the PAT bit ever matters, it looks like split_large_page() does
the wrong thing.

Now, it looks like we avoid the PAT bit on purpose, and we only ever
encode four PAT values (ie we use only the PCD/PWT bits, and leave the PAT
bit clear - we don't need any more cases), _but_ we actually do end up
looking at the PAT bit anyway in cache_attr(). So it looks like at least
some of the code is _trying_ to handle the PAT bit, but I can pretty much
guarantee that at least split_large_page() is broken if it is ever set.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/