linux-stable/arch/x86
Jeremy Fitzhardinge d6182fbf04 xen64: allocate and manage user pagetables
Because the x86_64 architecture does not enforce segment limits, Xen
cannot protect itself with them as it does in 32-bit mode.  Therefore,
to protect itself, it runs the guest kernel in ring 3.  Since it also
runs the guest userspace in ring3, the guest kernel must maintain a
second pagetable for its userspace, which does not map kernel space.
Naturally, the guest kernel pagetables map both kernel and userspace.

The userspace pagetable is attached to the corresponding kernel
pagetable via the pgd's page->private field.  It is allocated and
freed at the same time as the kernel pgd via the
paravirt_pgd_alloc/free hooks.

Fortunately, the user pagetable is almost entirely shared with the
kernel pagetable; the only difference is the pgd page itself.  set_pgd
will populate all entries in the kernel pagetable, and also set the
corresponding user pgd entry if the address is less than
STACK_TOP_MAX.

The user pagetable must be pinned and unpinned with the kernel one,
but because the pagetables are aliased, pgd_walk() only needs to be
called on the kernel pagetable.  The user pgd page is then
pinned/unpinned along with the kernel pgd page.

xen_write_cr3 must write both the kernel and user cr3s.

The init_mm.pgd pagetable never has a user pagetable allocated for it,
because it can never be used while running usermode.

One awkward area is that early in boot the page structures are not
available.  No user pagetable can exist at that point, but it
complicates the logic to avoid looking at the page structure.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-16 11:05:38 +02:00
..
boot Merge branch 'x86/mpparse' into x86/devel 2008-07-08 11:14:58 +02:00
configs x86: defconfig updates 2008-05-12 21:28:12 +02:00
crypto [CRYPTO] aes-x86-32: Remove unused return code 2008-04-21 10:19:21 +08:00
ia32 x86_64: adjust exception frame in ia32entry 2008-07-16 10:54:53 +02:00
kernel xen64: implement failsafe callback 2008-07-16 11:04:41 +02:00
kvm on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
lguest x86, VisWS: turn into generic arch, eliminate Kconfig specials 2008-07-10 18:55:47 +02:00
lib Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
mach-default x86, VisWS: turn into generic arch, eliminate Kconfig specials 2008-07-10 18:55:47 +02:00
mach-es7000 x86: make generic arch support NUMAQ 2008-06-10 11:34:42 +02:00
mach-generic x86: make generic arch support NUMAQ, fix 2008-07-08 10:35:45 +02:00
mach-rdc321x x86, rdc321x: remove watchdog file 2008-04-17 17:40:50 +02:00
mach-voyager Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
math-emu x86: coding style fixes to arch/x86/math-emu/reg_constant 2008-06-18 15:00:13 +02:00
mm pvops-64: call paravirt_post_allocator_init() on setup_arch() 2008-07-16 10:53:57 +02:00
oprofile Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
pci generic-ipi: merge fix 2008-07-15 22:03:56 +02:00
power x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
vdso Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
video x86: video/fbdev.c: add MODULE_LICENSE 2008-05-04 20:04:46 +02:00
xen xen64: allocate and manage user pagetables 2008-07-16 11:05:38 +02:00
Kconfig Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
Kconfig.cpu x86: mark x86_64 as having a working WP. 2008-07-09 09:14:21 +02:00
Kconfig.debug x86: MMIOTRACE should not default to on 2008-07-14 15:03:25 -07:00
Makefile x86, VisWS: turn into generic arch, remove leftover files 2008-07-10 18:55:45 +02:00
Makefile_32.cpu