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

[Xen-changelog] XEN/VTI utilizes a PMT table to describe physical->machine



ChangeSet 1.1709.1.7, 2005/06/14 11:57:25-06:00, djm@xxxxxxxxxxxxxxx

        XEN/VTI utilizes a PMT table to describe physical->machine
        mapping info, instead of 3 level page tables from Linux.
        Attached patch adds some necessary macro/interface/definitions
        about that structure.  Some stuff is added to public directory,
        because control panel needs to use those info to construct domain.
        
        Signed-off-by Kevin Tian <Kevin.tian@xxxxxxxxx>



 arch/ia64/xenmem.c         |    2 +-
 include/asm-ia64/domain.h  |   11 ++++++++++-
 include/asm-ia64/mm.h      |   27 +++++++++++++++++++++++++--
 include/asm-ia64/vmx_vpd.h |    1 +
 include/public/arch-ia64.h |   26 ++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 4 deletions(-)


diff -Nru a/xen/arch/ia64/xenmem.c b/xen/arch/ia64/xenmem.c
--- a/xen/arch/ia64/xenmem.c    2005-06-19 14:04:11 -04:00
+++ b/xen/arch/ia64/xenmem.c    2005-06-19 14:04:11 -04:00
@@ -52,7 +52,7 @@
                panic("Not enough memory to bootstrap Xen.\n");
 
        printk("machine to physical table: 0x%lx\n", (u64)mpt_table);
-       memset(mpt_table, 0x55, mpt_table_size);
+       memset(mpt_table, INVALID_M2P_ENTRY, mpt_table_size);
 
        /* Any more setup here? On VMX enabled platform,
         * there's no need to keep guest linear pg table,
diff -Nru a/xen/include/asm-ia64/domain.h b/xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     2005-06-19 14:04:12 -04:00
+++ b/xen/include/asm-ia64/domain.h     2005-06-19 14:04:12 -04:00
@@ -6,6 +6,7 @@
 #include <asm/vmx_vpd.h>
 #include <asm/vmmu.h>
 #include <asm/regionreg.h>
+#include <public/arch-ia64.h>
 #endif // CONFIG_VTI
 #include <xen/list.h>
 
@@ -33,7 +34,15 @@
     int imp_va_msb;
     ia64_rr emul_phy_rr0;
     ia64_rr emul_phy_rr4;
-    u64 *pmt;  /* physical to machine table */
+    unsigned long *pmt;        /* physical to machine table */
+    /*
+     * max_pfn is the maximum page frame in guest physical space, including
+     * inter-middle I/O ranges and memory holes. This is different with
+     * max_pages in domain struct, which indicates maximum memory size
+     */
+    unsigned long max_pfn;
+    unsigned int section_nr;
+    mm_section_t *sections;    /* Describe memory hole except for Dom0 */
 #endif  //CONFIG_VTI
     u64 xen_vastart;
     u64 xen_vaend;
diff -Nru a/xen/include/asm-ia64/mm.h b/xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h 2005-06-19 14:04:11 -04:00
+++ b/xen/include/asm-ia64/mm.h 2005-06-19 14:04:12 -04:00
@@ -375,17 +375,40 @@
 #undef machine_to_phys_mapping
 #define machine_to_phys_mapping        mpt_table
 
+#define INVALID_M2P_ENTRY        (~0U)
+#define VALID_M2P(_e)            (!((_e) & (1U<<63)))
+#define IS_INVALID_M2P_ENTRY(_e) (!VALID_M2P(_e))
 /* If pmt table is provided by control pannel later, we need __get_user
 * here. However if it's allocated by HV, we should access it directly
 */
-#define phys_to_machine_mapping(d, gpfn)       \
-    ((d) == dom0 ? gpfn : (d)->arch.pmt[(gpfn)])
+#define phys_to_machine_mapping(d, gpfn)                       \
+    ((d) == dom0 ? gpfn :                                      \
+       (gpfn <= d->arch.max_pfn ? (d)->arch.pmt[(gpfn)] :      \
+               INVALID_MFN))
 
 #define __mfn_to_gpfn(_d, mfn)                 \
     machine_to_phys_mapping[(mfn)]
 
 #define __gpfn_to_mfn(_d, gpfn)                        \
     phys_to_machine_mapping((_d), (gpfn))
+
+#define __gpfn_invalid(_d, gpfn)                       \
+       (__gpfn_to_mfn((_d), (gpfn)) & GPFN_INV_MASK)
+
+#define __gpfn_valid(_d, gpfn) !__gpfn_invalid(_d, gpfn)
+
+/* Return I/O type if trye */
+#define __gpfn_is_io(_d, gpfn)                         \
+       (__gpfn_valid(_d, gpfn) ?                       \
+       (__gpfn_to_mfn((_d), (gpfn)) & GPFN_IO_MASK) : 0)
+
+#define __gpfn_is_mem(_d, gpfn)                                \
+       (__gpfn_valid(_d, gpfn) ?                       \
+       ((__gpfn_to_mfn((_d), (gpfn)) & GPFN_IO_MASK) == GPFN_MEM) : 0)
+
+
+#define __gpa_to_mpa(_d, gpa)   \
+    ((__gpfn_to_mfn((_d),(gpa)>>PAGE_SHIFT)<<PAGE_SHIFT)|((gpa)&~PAGE_MASK))
 #endif // CONFIG_VTI
 
 #endif /* __ASM_IA64_MM_H__ */
diff -Nru a/xen/include/asm-ia64/vmx_vpd.h b/xen/include/asm-ia64/vmx_vpd.h
--- a/xen/include/asm-ia64/vmx_vpd.h    2005-06-19 14:04:12 -04:00
+++ b/xen/include/asm-ia64/vmx_vpd.h    2005-06-19 14:04:12 -04:00
@@ -26,6 +26,7 @@
 
 #include <asm/vtm.h>
 #include <asm/vmx_platform.h>
+#include <public/arch-ia64.h>
 
 #define VPD_SHIFT      17      /* 128K requirement */
 #define VPD_SIZE       (1 << VPD_SHIFT)
diff -Nru a/xen/include/public/arch-ia64.h b/xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    2005-06-19 14:04:11 -04:00
+++ b/xen/include/public/arch-ia64.h    2005-06-19 14:04:11 -04:00
@@ -19,6 +19,32 @@
 /* NB. Both the following are 64 bits each. */
 typedef unsigned long memory_t;   /* Full-sized pointer/address/memory-size. */
 
+#define MAX_NR_SECTION  32  // at most 32 memory holes
+typedef struct {
+    unsigned long      start;  /* start of memory hole */
+    unsigned long      end;    /* end of memory hole */
+} mm_section_t;
+
+typedef struct {
+    unsigned long      mfn : 56;
+    unsigned long      type: 8;
+} pmt_entry_t;
+
+#define GPFN_MEM               (0UL << 56)     /* Guest pfn is normal mem */
+#define GPFN_FRAME_BUFFER      (1UL << 56)     /* VGA framebuffer */
+#define GPFN_LOW_MMIO          (2UL << 56)     /* Low MMIO range */
+#define GPFN_PIB               (3UL << 56)     /* PIB base */
+#define GPFN_IOSAPIC           (4UL << 56)     /* IOSAPIC base */
+#define GPFN_LEGACY_IO         (5UL << 56)     /* Legacy I/O base */
+#define GPFN_GFW               (6UL << 56)     /* Guest Firmware */
+#define GPFN_HIGH_MMIO         (7UL << 56)     /* High MMIO range */
+
+#define GPFN_IO_MASK           (7UL << 56)     /* Guest pfn is I/O type */
+#define GPFN_INV_MASK          (31UL << 59)    /* Guest pfn is invalid */
+
+#define INVALID_MFN              (~0UL)
+
+
 typedef struct
 {
 } PACKED cpu_user_regs;

_______________________________________________
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®.