All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc: switch to XC_PAGE_*
@ 2011-12-06  9:34 Christoph Egger
  2011-12-12 14:52 ` Ian Jackson
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Egger @ 2011-12-06  9:34 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com, Ian Campbell

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]


Switch to a consistent set of XC_PAGE_* constants.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_libxc_page.diff --]
[-- Type: text/plain, Size: 12163 bytes --]

diff -r 7244cea070fc tools/libxc/xc_dom_ia64.c
--- a/tools/libxc/xc_dom_ia64.c	Tue Nov 15 11:18:34 2011 +0100
+++ b/tools/libxc/xc_dom_ia64.c	Tue Dec 06 10:28:03 2011 +0100
@@ -83,7 +83,7 @@ int start_info_ia64(struct xc_dom_image 
         bp->initrd_start = start_info->mod_start;
         bp->initrd_size = start_info->mod_len;
     }
-    bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64)
+    bp->command_line = (dom->start_info_pfn << XC_PAGE_SHIFT)
         + offsetof(start_info_t, cmd_line);
     if ( dom->cmdline )
     {
@@ -128,7 +128,7 @@ static int vcpu_ia64(struct xc_dom_image
 #ifdef __ia64__			/* FIXME */
     ctxt->regs.ar.fpsr = xc_ia64_fpsr_default();
 #endif
-    ctxt->regs.r[28] = (dom->start_info_pfn << PAGE_SHIFT_IA64)
+    ctxt->regs.r[28] = (dom->start_info_pfn << XC_PAGE_SHIFT)
         + sizeof(start_info_ia64_t);
     return 0;
 }
@@ -138,7 +138,7 @@ static int vcpu_ia64(struct xc_dom_image
 static struct xc_dom_arch xc_dom_arch = {
     .guest_type = "xen-3.0-ia64",
     .native_protocol = XEN_IO_PROTO_ABI_IA64,
-    .page_shift = PAGE_SHIFT_IA64,
+    .page_shift = XC_PAGE_SHIFT,
     .alloc_magic_pages = alloc_magic_pages,
     .start_info = start_info_ia64,
     .shared_info = shared_info_ia64,
@@ -148,7 +148,7 @@ static struct xc_dom_arch xc_dom_arch = 
 static struct xc_dom_arch xc_dom_arch_ia64be = {
     .guest_type = "xen-3.0-ia64be",
     .native_protocol = XEN_IO_PROTO_ABI_IA64,
-    .page_shift = PAGE_SHIFT_IA64,
+    .page_shift = XC_PAGE_SHIFT,
     .alloc_magic_pages = alloc_magic_pages,
     .start_info = start_info_ia64,
     .shared_info = shared_info_ia64,
@@ -173,8 +173,8 @@ int arch_setup_meminit(struct xc_dom_ima
     /* setup initial p2m */
     if (dom->guest_type && strcmp(dom->guest_type,
                                   "hvm-3.0-ia64-sioemu") == 0) {
-        start = FW_MEM_BASE >> PAGE_SHIFT_IA64;
-        nbr = FW_MEM_SIZE >> PAGE_SHIFT_IA64;
+        start = FW_MEM_BASE >> XC_PAGE_SHIFT;
+        nbr = FW_MEM_SIZE >> XC_PAGE_SHIFT;
     } else {
         start = 0;
         nbr = dom->total_pages;
diff -r 7244cea070fc tools/libxc/xc_dom_x86.c
--- a/tools/libxc/xc_dom_x86.c	Tue Nov 15 11:18:34 2011 +0100
+++ b/tools/libxc/xc_dom_x86.c	Tue Dec 06 10:28:03 2011 +0100
@@ -89,7 +89,7 @@ static int count_pgtables(struct xc_dom_
     pages = extra_pages;
     for ( ; ; )
     {
-        try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86,
+        try_virt_end = round_up(dom->virt_alloc_end + pages * XC_PAGE_SIZE,
                                 bits_to_mask(22)); /* 4MB alignment */
         dom->pg_l4 =
             nr_page_tables(dom, dom->parms.virt_base, try_virt_end, l4_bits);
@@ -107,7 +107,7 @@ static int count_pgtables(struct xc_dom_
         }
         dom->pgtables = dom->pg_l4 + dom->pg_l3 + dom->pg_l2 + dom->pg_l1;
         pages = dom->pgtables + extra_pages;
-        if ( dom->virt_alloc_end + pages * PAGE_SIZE_X86 <= try_virt_end + 1 )
+        if ( dom->virt_alloc_end + pages * XC_PAGE_SIZE <= try_virt_end + 1 )
             break;
     }
     dom->virt_pgtab_end = try_virt_end + 1;
@@ -132,7 +132,7 @@ static int count_pgtables_x86_32_pae(str
                           L3_PAGETABLE_SHIFT_PAE, L2_PAGETABLE_SHIFT_PAE);
 }
 
-#define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86)
+#define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << XC_PAGE_SHIFT)
 
 static int setup_pgtables_x86_32(struct xc_dom_image *dom)
 {
@@ -145,7 +145,7 @@ static int setup_pgtables_x86_32(struct 
     xen_pfn_t pgpfn;
 
     for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
-          addr += PAGE_SIZE_X86 )
+          addr += XC_PAGE_SIZE )
     {
         if ( l1tab == NULL )
         {
@@ -159,7 +159,7 @@ static int setup_pgtables_x86_32(struct 
 
         /* make L1 entry */
         l1off = l1_table_offset_i386(addr);
-        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
+        pgpfn = (addr - dom->parms.virt_base) >> XC_PAGE_SHIFT;
         l1tab[l1off] =
             pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
         if ( (addr >= dom->pgtables_seg.vstart) && 
@@ -264,7 +264,7 @@ static int setup_pgtables_x86_32_pae(str
     l3tab = xc_dom_pfn_to_ptr(dom, l3pfn, 1);
 
     for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
-          addr += PAGE_SIZE_X86 )
+          addr += XC_PAGE_SIZE )
     {
         if ( l2tab == NULL )
         {
@@ -290,7 +290,7 @@ static int setup_pgtables_x86_32_pae(str
 
         /* make L1 entry */
         l1off = l1_table_offset_pae(addr);
-        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
+        pgpfn = (addr - dom->parms.virt_base) >> XC_PAGE_SHIFT;
         l1tab[l1off] =
             pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
         if ( (addr >= dom->pgtables_seg.vstart) &&
@@ -345,7 +345,7 @@ static int setup_pgtables_x86_64(struct 
     xen_pfn_t pgpfn;
 
     for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
-          addr += PAGE_SIZE_X86 )
+          addr += XC_PAGE_SIZE )
     {
         if ( l3tab == NULL )
         {
@@ -383,7 +383,7 @@ static int setup_pgtables_x86_64(struct 
 
         /* make L1 entry */
         l1off = l1_table_offset_x86_64(addr);
-        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
+        pgpfn = (addr - dom->parms.virt_base) >> XC_PAGE_SHIFT;
         l1tab[l1off] =
             pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
         if ( (addr >= dom->pgtables_seg.vstart) && 
@@ -438,7 +438,7 @@ static int start_info_x86_32(struct xc_d
     strncpy(start_info->magic, dom->guest_type, sizeof(start_info->magic));
     start_info->magic[sizeof(start_info->magic) - 1] = '\0';
     start_info->nr_pages = dom->total_pages;
-    start_info->shared_info = shinfo << PAGE_SHIFT_X86;
+    start_info->shared_info = shinfo << XC_PAGE_SHIFT;
     start_info->pt_base = dom->pgtables_seg.vstart;
     start_info->nr_pt_frames = dom->pgtables;
     start_info->mfn_list = dom->p2m_seg.vstart;
@@ -478,7 +478,7 @@ static int start_info_x86_64(struct xc_d
     strncpy(start_info->magic, dom->guest_type, sizeof(start_info->magic));
     start_info->magic[sizeof(start_info->magic) - 1] = '\0';
     start_info->nr_pages = dom->total_pages;
-    start_info->shared_info = shinfo << PAGE_SHIFT_X86;
+    start_info->shared_info = shinfo << XC_PAGE_SHIFT;
     start_info->pt_base = dom->pgtables_seg.vstart;
     start_info->nr_pt_frames = dom->pgtables;
     start_info->mfn_list = dom->p2m_seg.vstart;
@@ -550,9 +550,9 @@ static int vcpu_x86_32(struct xc_dom_ima
     ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_32;
     ctxt->user_regs.eip = dom->parms.virt_entry;
     ctxt->user_regs.esp =
-        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
+        dom->parms.virt_base + (dom->bootstack_pfn + 1) * XC_PAGE_SIZE;
     ctxt->user_regs.esi =
-        dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
+        dom->parms.virt_base + (dom->start_info_pfn) * XC_PAGE_SIZE;
     ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
 
     ctxt->kernel_ss = ctxt->user_regs.ss;
@@ -589,9 +589,9 @@ static int vcpu_x86_64(struct xc_dom_ima
     ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_64;
     ctxt->user_regs.rip = dom->parms.virt_entry;
     ctxt->user_regs.rsp =
-        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
+        dom->parms.virt_base + (dom->bootstack_pfn + 1) * XC_PAGE_SIZE;
     ctxt->user_regs.rsi =
-        dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
+        dom->parms.virt_base + (dom->start_info_pfn) * XC_PAGE_SIZE;
     ctxt->user_regs.rflags = 1 << 9; /* Interrupt Enable */
 
     ctxt->kernel_ss = ctxt->user_regs.ss;
@@ -611,7 +611,7 @@ static int vcpu_x86_64(struct xc_dom_ima
 static struct xc_dom_arch xc_dom_32 = {
     .guest_type = "xen-3.0-x86_32",
     .native_protocol = XEN_IO_PROTO_ABI_X86_32,
-    .page_shift = PAGE_SHIFT_X86,
+    .page_shift = XC_PAGE_SHIFT,
     .sizeof_pfn = 4,
     .alloc_magic_pages = alloc_magic_pages,
     .count_pgtables = count_pgtables_x86_32,
@@ -623,7 +623,7 @@ static struct xc_dom_arch xc_dom_32 = {
 static struct xc_dom_arch xc_dom_32_pae = {
     .guest_type = "xen-3.0-x86_32p",
     .native_protocol = XEN_IO_PROTO_ABI_X86_32,
-    .page_shift = PAGE_SHIFT_X86,
+    .page_shift = XC_PAGE_SHIFT,
     .sizeof_pfn = 4,
     .alloc_magic_pages = alloc_magic_pages,
     .count_pgtables = count_pgtables_x86_32_pae,
@@ -636,7 +636,7 @@ static struct xc_dom_arch xc_dom_32_pae 
 static struct xc_dom_arch xc_dom_64 = {
     .guest_type = "xen-3.0-x86_64",
     .native_protocol = XEN_IO_PROTO_ABI_X86_64,
-    .page_shift = PAGE_SHIFT_X86,
+    .page_shift = XC_PAGE_SHIFT,
     .sizeof_pfn = 8,
     .alloc_magic_pages = alloc_magic_pages,
     .count_pgtables = count_pgtables_x86_64,
@@ -855,13 +855,13 @@ int arch_setup_bootlate(struct xc_dom_im
     DOMPRINTF("%s: shared_info: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "",
               __FUNCTION__, dom->shared_info_pfn, dom->shared_info_mfn);
     shared_info = xc_map_foreign_range(dom->xch, dom->guest_domid,
-                                       PAGE_SIZE_X86,
+                                       XC_PAGE_SIZE,
                                        PROT_READ | PROT_WRITE,
                                        shinfo);
     if ( shared_info == NULL )
         return -1;
     dom->arch_hooks->shared_info(dom, shared_info);
-    munmap(shared_info, PAGE_SIZE_X86);
+    munmap(shared_info, XC_PAGE_SIZE);
 
     return 0;
 }
diff -r 7244cea070fc tools/libxc/xc_offline_page.c
--- a/tools/libxc/xc_offline_page.c	Tue Nov 15 11:18:34 2011 +0100
+++ b/tools/libxc/xc_offline_page.c	Tue Dec 06 10:28:03 2011 +0100
@@ -369,7 +369,7 @@ static int __clear_pte(xc_interface *xch
 
     /* XXX Check for PSE bit here */
     /* Hit one entry */
-    if ( ((pte >> PAGE_SHIFT_X86) & MFN_MASK_X86) == mfn)
+    if ( ((pte >> XC_PAGE_SHIFT) & MFN_MASK_X86) == mfn)
     {
         *new_pte = pte & ~_PAGE_PRESENT;
         if (!backup_ptes(table_mfn, table_offset, backup))
@@ -400,7 +400,7 @@ static int __update_pte(xc_interface *xc
         if (pte & _PAGE_PRESENT)
             ERROR("Page present while in backup ptes\n");
         pte &= ~MFN_MASK_X86;
-        pte |= (new_mfn << PAGE_SHIFT_X86) | _PAGE_PRESENT;
+        pte |= (new_mfn << XC_PAGE_SHIFT) | _PAGE_PRESENT;
         *new_pte = pte;
         return 1;
     }
diff -r 7244cea070fc tools/libxc/xg_private.h
--- a/tools/libxc/xg_private.h	Tue Nov 15 11:18:34 2011 +0100
+++ b/tools/libxc/xg_private.h	Tue Dec 06 10:28:03 2011 +0100
@@ -148,16 +148,8 @@ typedef l4_pgentry_64_t l4_pgentry_t;
 #define l4_table_offset(_a) l4_table_offset_x86_64(_a)
 #endif
 
-#define PAGE_SHIFT_X86          12
-#define PAGE_SIZE_X86           (1UL << PAGE_SHIFT_X86)
-#define PAGE_MASK_X86           (~(PAGE_SIZE_X86-1))
-
-#define PAGE_SHIFT_IA64         14
-#define PAGE_SIZE_IA64          (1UL << PAGE_SHIFT_IA64)
-#define PAGE_MASK_IA64          (~(PAGE_SIZE_IA64-1))
-
 #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-#define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
+#define NRPAGES(x) (ROUNDUP(x, XC_PAGE_SHIFT) >> XC_PAGE_SHIFT)
 
 
 /* XXX SMH: following skanky macros rely on variable p2m_size being set */
@@ -169,7 +161,7 @@ struct domain_info_context {
 };
 
 /* Number of xen_pfn_t in a page */
-#define FPP             (PAGE_SIZE/(dinfo->guest_width))
+#define FPP             (XC_PAGE_SIZE/(dinfo->guest_width))
 
 /* Number of entries in the pfn_to_mfn_frame_list_list */
 #define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP))
@@ -184,8 +176,8 @@ struct domain_info_context {
 
 /* Masks for PTE<->PFN conversions */
 #define MADDR_BITS_X86  ((dinfo->guest_width == 8) ? 52 : 44)
-#define MFN_MASK_X86    ((1ULL << (MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1)
-#define MADDR_MASK_X86  (MFN_MASK_X86 << PAGE_SHIFT_X86)
+#define MFN_MASK_X86    ((1ULL << (MADDR_BITS_X86 - XC_PAGE_SHIFT)) - 1)
+#define MADDR_MASK_X86  (MFN_MASK_X86 << XC_PAGE_SHIFT)
 
 
 #define PAEKERN_no           0

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

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

end of thread, other threads:[~2011-12-13 14:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06  9:34 [PATCH] libxc: switch to XC_PAGE_* Christoph Egger
2011-12-12 14:52 ` Ian Jackson
2011-12-13 14:19   ` Christoph Egger
2011-12-13 14:21     ` Ian Jackson

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.