All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] Question about recursive mappings
@ 2006-05-22  9:15 Mathieu Ropert
  2006-05-22 15:18 ` Mathieu Ropert
  0 siblings, 1 reply; 11+ messages in thread
From: Mathieu Ropert @ 2006-05-22  9:15 UTC (permalink / raw)
  To: xen-devel

[Previous one didn't hit list after 3 days, trying a resend, sorry if 
both finally show up]

Hi,

are recursive mappings (ie: a page table entry pointing back to itself)
supported by Xen (on x86_64 at least)?
I'm asking cause i'm seeing many error logs from get_page_type() telling
something like "saw L3_page_table expected L2_page_table" or "saw
L4_page_table expected L3_page_table" (finally leading to a failing 
mmu_update, i guess others happens on user pagetables switches).
Or maybe is there any workaround needed? (I think i saw something like
setting entry to 0 first then to the recursive entry somewhere, but
can't remember where).
By the way, i'm using recursive mappings in kernel page directory (which
seems ok) and i temporay make user page directory recursive when i map
a user PGD in kernel space (mapping user PGD to a L4 entry of kernel 
tables, then using kernel L4 slot and user PGD recursive entry to access 
user page tables).

[edit]
Done some little research about the problem. Seems like NetBSD use the 
same thing and works, but there is no x86_64 ports for now. I'm starting 
to think that may be a x86_64 issue, maybe because recursive mappings 
don't lead to conflicting types with only 2 levels.
Xen interface states that a page can only be of one type (PGD, PT, LDT, 
GDT  and R/W). I don't know why there is a need to distinguish page 
table levels, but i'm afraid this restriction will conflit with some MMU 
implementation on x86_64 like NetBSD and OpenBSD, and maybe others 
(FreeBSD on top of my mind, don't know how much the pmap implementation 
diverged).
[/edit]

Regards,

Mathieu

^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: [RESEND] Question about recursive mappings
@ 2006-05-23  9:41 Ian Pratt
  2006-05-23  9:52 ` Keir Fraser
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Pratt @ 2006-05-23  9:41 UTC (permalink / raw)
  To: Mathieu Ropert, xen-devel

> Done some investingations in the mm code of Xen, i think the 
> problem is that linear page tables entries are checked only 
> on level 4 entries.
> In my case, my recursive entry is in a L3 table, already 
> validated as another type, hence not "valid" for Xen.

Can you explain the pagtable structure a little better please. Does the
L3 contain an entry point at itself (recursive), or at another L3
(foreign)?

I've never come across non-root pagetable linear mappings other than in
the crock that is PAE (3 level) where you have to use 4 entries in an L2
to point to all the L2s due to the limited address space.

What OS are you porting? Was it written for 3-level pagetables, with the
x86 4th level being added on as an afterthought, perhaps with only a
single L4 for the system and just one entry being used?

> Will authorizing L3 or L2 recursive mappings induce a 
> security hole or vulnerability?
> If not, I'll try to make a patch to address this issue (any 
> hint welcome :)).

I'm sure it can be done safely, but you'd best wrap a damp towel around
your head while thinking about how. I wouldn't want to slow down the
common case...

Ian 
 
> Regards,
> Mathieu
> 
> Mathieu Ropert wrote:
> 
> > [Previous one didn't hit list after 3 days, trying a 
> resend, sorry if 
> > both finally show up]
> >
> > Hi,
> >
> > are recursive mappings (ie: a page table entry pointing back to 
> > itself) supported by Xen (on x86_64 at least)?
> > I'm asking cause i'm seeing many error logs from get_page_type() 
> > telling something like "saw L3_page_table expected 
> L2_page_table" or 
> > "saw L4_page_table expected L3_page_table" (finally leading to a 
> > failing mmu_update, i guess others happens on user 
> pagetables switches).
> > Or maybe is there any workaround needed? (I think i saw 
> something like 
> > setting entry to 0 first then to the recursive entry somewhere, but 
> > can't remember where).
> > By the way, i'm using recursive mappings in kernel page directory 
> > (which seems ok) and i temporay make user page directory recursive 
> > when i map a user PGD in kernel space (mapping user PGD to 
> a L4 entry 
> > of kernel tables, then using kernel L4 slot and user PGD recursive 
> > entry to access user page tables).
> >
> > [edit]
> > Done some little research about the problem. Seems like 
> NetBSD use the 
> > same thing and works, but there is no x86_64 ports for now. I'm 
> > starting to think that may be a x86_64 issue, maybe because 
> recursive 
> > mappings don't lead to conflicting types with only 2 levels.
> > Xen interface states that a page can only be of one type (PGD, PT, 
> > LDT, GDT  and R/W). I don't know why there is a need to distinguish 
> > page table levels, but i'm afraid this restriction will 
> conflit with 
> > some MMU implementation on x86_64 like NetBSD and OpenBSD, 
> and maybe 
> > others (FreeBSD on top of my mind, don't know how much the pmap 
> > implementation diverged).
> > [/edit]
> >
> > Regards,
> >
> > Mathieu
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: [RESEND] Question about recursive mappings
@ 2006-05-24  9:34 Ian Pratt
  2006-05-24 20:12 ` Mathieu Ropert
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Pratt @ 2006-05-24  9:34 UTC (permalink / raw)
  To: Mathieu Ropert, Keir Fraser; +Cc: xen-devel

> About the possible fix, won't something like trying a
> get_linear_pagetable() at all level works? Will it cause too 
> much overhead?
> Generally speaking, is allowing a R/O mapping of another 
> table the domain own (whichever level it is) safe? At first 
> thought, i don't see any way of exploiting it.

Yes, it's safe, you just need to get the 'general' ref count right,
which as I recall, depends on whether the page you're mapping is in the
same page table, or a foreign page table. The va back pointer means that
there is a unique 'normal' place in each pagetable where a given page
can be mapped, so you can easily inspect (via xen's linear mapping) to
see whether the page belongs to the current pagetable or not.

One thing we do have to watch out for is when we introduce super page
mappings, as you have to be careful about using linear page tables in
this context -- the x86 pagetable format doesn't allow you to generate a
trap if a linear mapping attempts to misuse a superpage. That's not your
worry right now :-) 

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-07-27 22:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-22  9:15 [RESEND] Question about recursive mappings Mathieu Ropert
2006-05-22 15:18 ` Mathieu Ropert
  -- strict thread matches above, loose matches on Subject: below --
2006-05-23  9:41 Ian Pratt
2006-05-23  9:52 ` Keir Fraser
2006-05-23 12:22   ` Mathieu Ropert
2006-07-27 22:14   ` Bruce Rogers
2006-05-24  9:34 Ian Pratt
2006-05-24 20:12 ` Mathieu Ropert
2006-05-24 20:16   ` Keir Fraser
2006-05-26  9:27     ` Mathieu Ropert
2006-05-29 11:43     ` Mathieu Ropert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.