[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-3.0-testing] [PAE] Chaneg interface for accessing %cr3 so that extra bits (>4GB) for PAE pgdirs



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 33263455b079d7a1a5c68a9b519029925d427c2a
# Parent  6255f38623b3270ab5a8e57003e485737328e1a4
[PAE] Chaneg interface for accessing %cr3 so that extra bits (>4GB) for PAE 
pgdirs
are placed in low-order bits of %cr3. Guests who understand this interface 
change
publish the fact by setting the option 'PAE=yes[extended-cr3]' in their 
__xen_guest
section.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
xen-unstable changeset:   10257:b198bbfeec10579b539455eeb41b4daaed53c546
xen-unstable date:        Fri Jun  2 11:46:24 2006 +0100
---
 linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S            |    2 +-
 linux-2.6-xen-sparse/drivers/xen/core/smpboot.c             |    4 ++--
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h |    6 ++++--
 xen/common/kernel.c                                         |    3 +--
 xen/include/public/arch-x86_32.h                            |    8 ++++++++
 xen/include/public/arch-x86_64.h                            |    3 +++
 6 files changed, 19 insertions(+), 7 deletions(-)

diff -r 6255f38623b3 -r 33263455b079 
linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S  Fri Jun 02 09:38:34 
2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S  Fri Jun 02 12:00:25 
2006 +0100
@@ -163,7 +163,7 @@ ENTRY(cpu_gdt_table)
        .ascii           "|pae_pgdir_above_4gb"
        .ascii           "|supervisor_mode_kernel"
 #ifdef CONFIG_X86_PAE
-       .ascii  ",PAE=yes"
+       .ascii  ",PAE=yes[extended-cr3]"
 #else
        .ascii  ",PAE=no"
 #endif
diff -r 6255f38623b3 -r 33263455b079 
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c   Fri Jun 02 09:38:34 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c   Fri Jun 02 12:00:25 
2006 +0100
@@ -211,7 +211,7 @@ static void vcpu_prepare(int vcpu)
        ctxt.failsafe_callback_cs  = __KERNEL_CS;
        ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
 
-       ctxt.ctrlreg[3] = virt_to_mfn(swapper_pg_dir) << PAGE_SHIFT;
+       ctxt.ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir));
 #else /* __x86_64__ */
        ctxt.user_regs.cs = __KERNEL_CS;
        ctxt.user_regs.esp = idle->thread.rsp0 - sizeof(struct pt_regs);
@@ -223,7 +223,7 @@ static void vcpu_prepare(int vcpu)
        ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
        ctxt.syscall_callback_eip  = (unsigned long)system_call;
 
-       ctxt.ctrlreg[3] = virt_to_mfn(init_level4_pgt) << PAGE_SHIFT;
+       ctxt.ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(init_level4_pgt));
 
        ctxt.gs_base_kernel = (unsigned long)(cpu_pda(vcpu));
 #endif
diff -r 6255f38623b3 -r 33263455b079 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h       Fri Jun 
02 09:38:34 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h       Fri Jun 
02 12:00:25 2006 +0100
@@ -116,10 +116,12 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t"
        __asm__ ( \
                "movl %%cr3,%0\n\t" \
                :"=r" (__dummy)); \
-       machine_to_phys(__dummy); \
+       __dummy = xen_cr3_to_pfn(__dummy); \
+       mfn_to_pfn(__dummy) << PAGE_SHIFT; \
 })
 #define write_cr3(x) ({                                                \
-       maddr_t __dummy = phys_to_machine(x);                   \
+       unsigned int __dummy = pfn_to_mfn((x) >> PAGE_SHIFT);   \
+       __dummy = xen_pfn_to_cr3(__dummy);                      \
        __asm__ __volatile__("movl %0,%%cr3": :"r" (__dummy));  \
 })
 
diff -r 6255f38623b3 -r 33263455b079 xen/common/kernel.c
--- a/xen/common/kernel.c       Fri Jun 02 09:38:34 2006 +0100
+++ b/xen/common/kernel.c       Fri Jun 02 12:00:25 2006 +0100
@@ -195,8 +195,7 @@ long do_xen_version(int cmd, GUEST_HANDL
             if ( shadow_mode_translate(current->domain) )
                 fi.submap |= 
                     (1U << XENFEAT_writable_page_tables) |
-                    (1U << XENFEAT_auto_translated_physmap) |
-                    (1U << XENFEAT_pae_pgdir_above_4gb);
+                    (1U << XENFEAT_auto_translated_physmap);
             if ( supervisor_mode_kernel )
                 fi.submap |= 1U << XENFEAT_supervisor_mode_kernel;
             break;
diff -r 6255f38623b3 -r 33263455b079 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h  Fri Jun 02 09:38:34 2006 +0100
+++ b/xen/include/public/arch-x86_32.h  Fri Jun 02 12:00:25 2006 +0100
@@ -156,6 +156,14 @@ typedef struct vcpu_guest_context {
 } vcpu_guest_context_t;
 DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
 
+/*
+ * Page-directory addresses above 4GB do not fit into architectural %cr3.
+ * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
+ * must use the following accessor macros to pack/unpack valid MFNs.
+ */
+#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
+#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
+
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
     /* Frame containing list of mfns containing list of mfns containing p2m. */
diff -r 6255f38623b3 -r 33263455b079 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h  Fri Jun 02 09:38:34 2006 +0100
+++ b/xen/include/public/arch-x86_64.h  Fri Jun 02 12:00:25 2006 +0100
@@ -232,6 +232,9 @@ typedef struct vcpu_guest_context {
 } vcpu_guest_context_t;
 DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
 
+#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
+#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
+
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
     /* Frame containing list of mfns containing list of mfns containing p2m. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.