Skip to contentSkip to conversation

PAE issue (32-on-64 work)

DISCUSSION Jan Beulich 4 participants 9 messages Oct 19, 2006

lore
Share & tools
lore
#0 lore raw

As I had expressed before, I'm thinking that the current way of handling the top level of PAE paging is inappropriate, even after the above-4G adjustments that cured part of the problem. This is specifically because
- the handling here isn't consistent with how hardware behaves in the same situation (though the Xen behavior is probably within range of the generic architecture specification), in that the processor reads the 4 top level entries when CR3 gets re-loaded (and hence doesn't try to access them later in any way), while Xen treats them (including potential updates to them) like just on any level in the hierarchy
- the guest still needs to allocate a full page, even though only the first 32 bytes of it are actually used
- the shadowing done in Xen could be avoided altogether by following hardware behavior.

Just now I found that there is a resulting issue for the 32on64 work I'm
doing: Since none of the entries 4...511 of the PMD get initialized in Linux, and since Xen nevertheless has to validate all 512 entries (in order to avoid making available translations that could be used during speculative execution), the validation has the potential to fail (and does in reality), resulting in the guest dying. The only option I presently see is to special case the compatibility guest in the l3 handling and (I really hate to do that) clear out the 518 supposedly unused entries (or at least clear their present bits), meaning that no guest may ever make clever assumptions and try to store some other data in the unused portion of the pgd page.

Thanks for sharing any other ideas on how to overcome this problem, Jan

#1 lore raw
Quoted 1 line

As I had expressed before, I'm thinking that the current way of

handling

Quoted 5 lines

the
top level of PAE paging is inappropriate, even after the above-4G adjustments
that cured part of the problem. This is specifically because
- the handling here isn't consistent with how hardware behaves in the

same

Quoted 1 line

situation (though the Xen behavior is probably within range of the

generic

Quoted 1 line

architecture specification), in that the processor reads the 4 top

level

Quoted 2 lines

entries
when CR3 gets re-loaded (and hence doesn't try to access them later in

any

Quoted 1 line

way), while Xen treats them (including potential updates to them) like

just

Quoted 2 lines

on any level in the hierarchy
- the guest still needs to allocate a full page, even though only the

first

Quoted 6 lines

32
bytes of it are actually used
- the shadowing done in Xen could be avoided altogether by following hardware behavior.

Just now I found that there is a resulting issue for the 32on64 work

I'm

Quoted 3 lines

doing: Since none of the entries 4...511 of the PMD get initialized in Linux,
and since Xen nevertheless has to validate all 512 entries (in order

to

Quoted 1 line

avoid making available translations that could be used during

speculative

Quoted 1 line

execution), the validation has the potential to fail (and does in

reality),

Quoted 1 line

resulting in the guest dying. The only option I presently see is to

special

Quoted 1 line

case the compatibility guest in the l3 handling and (I really hate to

do

Quoted 4 lines

that) clear out the 518 supposedly unused entries (or at least clear their present bits), meaning that no guest may ever make clever assumptions and try to store some other data in the unused portion of the pgd page.

Why not just have a fixed per-vcpu L4 and L3, into which the 4 PAE L3's get copied on every cr3 load?
It's most analogous to what happens today.

We've thought of removing the page-size restriction on PAE L3's in the past, but it's pretty low down the priority list as it typically doesn't cost a great deal of memory.

Ian

#2 lore raw
Quoted 3 lines

Why not just have a fixed per-vcpu L4 and L3, into which the 4 PAE L3's get copied on every cr3 load?
It's most analogous to what happens today.

In the shadowing (PAE, 32bit) case (a code path that, as I said, I'd rather see ripped out). In the general 64-bit case, this would add another (needless) distinct code path. I think I still like better the idea of clearing out the final 518 entries.

Quoted 3 lines

We've thought of removing the page-size restriction on PAE L3's in the past, but it's pretty low down the priority list as it typically doesn't cost a great deal of memory.

Ah. I would have felt different.

Jan

#3 lore raw
Quoted 1 line
Quoted 1 line

Why not just have a fixed per-vcpu L4 and L3, into which the 4 PAE

L3's

Quoted 4 lines
Quoted 2 lines

get copied on every cr3 load?
It's most analogous to what happens today.

In the shadowing (PAE, 32bit) case (a code path that, as I said, I'd

rather

Quoted 1 line

see ripped out).

Why? It's essential to allow PAE PGDs to live above 4GB, which is a PITA otherwise.

Quoted 5 lines

In the general 64-bit case, this would add another (needless) distinct code path. I think I still like better the idea of clearing out the final 518 entries.

Quoted 1 line

We've thought of removing the page-size restriction on PAE L3's in

the

Quoted 1 line
Quoted 1 line

past, but it's pretty low down the priority list as it typically

doesn't

Quoted 3 lines
Quoted 1 line

cost a great deal of memory.

Ah. I would have felt different.

Most machines probably only have a hundred processes (we can exclude kernel threads and threads in general), hence maybe a few hundred KB wasted, tops.

If we did remove the size restriction, we'd still want to put them in their own slab cache rather than the general 32b cache, as you don't want them being shared with other non-PGD data. This is a PITA that mandates how we handle shadowing of PAE PGDs in the HVM case where we can't control what they're allocated alongside.

Ian

#7 lore raw
In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

Just now I found that there is a resulting issue for the 32on64 work I'm
doing: Since none of the entries 4...511 of the PMD get initialized in Linux, and since Xen nevertheless has to validate all 512 entries (in order to avoid making available translations that could be used during speculative execution), the validation has the potential to fail (and does in reality), resulting in the guest dying. The only option I presently see is to special case the compatibility guest in the l3 handling and (I really hate to do that) clear out the 518 supposedly unused entries (or at least clear their present bits), meaning that no guest may ever make clever assumptions and try to store some other data in the unused portion of the pgd page.

Either copy the PGDs out into a shadow L3, as we do for PAE Xen today. Or, as you say, zap the 508 unused entries. No guest uses them -- I'm pretty sure Linux is the only PAE-capable guest (others are non-pae or 64-bit). Storing other stuff in the page would be inconvenient anyway since it has to be read-only.

-- Keir

#4 lore raw
In reply to Jan Beulich
Quoted 9 lines · Jan Beulich
Quoted 3 lines

Why not just have a fixed per-vcpu L4 and L3, into which the 4 PAE L3's get copied on every cr3 load?
It's most analogous to what happens today.

In the shadowing (PAE, 32bit) case (a code path that, as I said, I'd rather see ripped out). In the general 64-bit case, this would add another (needless) distinct code path. I think I still like better the idea of clearing
out the final 518 entries.

If we allowed non-pae-aligned L3s then you'd have no choice but to shadow anyway, as that would be the only way to make the guest mappings appear at the correct place in the 64-bit address space.

-- Keir

Quoted 5 lines
Quoted 3 lines

We've thought of removing the page-size restriction on PAE L3's in the past, but it's pretty low down the priority list as it typically doesn't cost a great deal of memory.

Ah. I would have felt different.

#8 lore raw
In reply to Keir Fraser

NetWare is also a PAE guest, but doesn't put anything in the rest of the page, so zapping would be fine for NetWare.

- Bruce

Quoted 1 line
Quoted 1 line
Quoted 1 line

On 10/19/2006 at 6:56 AM, in message <C15D34A3.2CB1%[email protected]>,

Quoted 29 lines · Keir Fraser
Quoted 2 lines · Jan Beulich

Just now I found that there is a resulting issue for the 32on64 work I'm
doing: Since none of the entries 4...511 of the PMD get initialized in

Linux,

Quoted 9 lines

and since Xen nevertheless has to validate all 512 entries (in order to avoid making available translations that could be used during speculative execution), the validation has the potential to fail (and does in reality), resulting in the guest dying. The only option I presently see is to special case the compatibility guest in the l3 handling and (I really hate to do that) clear out the 518 supposedly unused entries (or at least clear their present bits), meaning that no guest may ever make clever assumptions and try to store some other data in the unused portion of the pgd page.

Either copy the PGDs out into a shadow L3, as we do for PAE Xen today. Or, as you say, zap the 508 unused entries. No guest uses them -- I'm pretty sure Linux is the only PAE-capable guest (others are non-pae or 64-bit). Storing other stuff in the page would be inconvenient anyway since it has to be read-only.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
In reply to Keir Fraser
Quoted 3 lines

If we allowed non-pae-aligned L3s then you'd have no choice but to shadow anyway, as that would be the only way to make the guest mappings appear at the correct place in the 64-bit address space.

It's not really shadowing, since there is no need to monitor changes. I'd therefore rather call it snapshotting.

Jan

#6 lore raw
Quoted 6 lines · Jan Beulich
Quoted 3 lines

If we allowed non-pae-aligned L3s then you'd have no choice but to shadow anyway, as that would be the only way to make the guest mappings appear at the correct place in the 64-bit address space.

It's not really shadowing, since there is no need to monitor changes. I'd therefore rather call it snapshotting.

But you do need to track updates, right? What if the guest zaps an L3 entry in an in-use PGD table and than flushes TLBs?

-- Keir