Skip to contentSkip to conversation

dom0_ops explicitly sized types

PATCH In review Hollis Blanchard 7 participants 17 messages May 24, 2006 – May 27, 2006 3 messages not in the archive Arm/actions semi architecture

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 3/3 dom0_ops explicitly sized types

Replace 'long' in the dom0_ops and privcmd structures with uint64_t. As discussed previously, the these operations are not performance-sensitive, so the additional cache footprint shouldn't be an issue.

linux-2.6-xen-sparse/include/xen/public/privcmd.h +6 -6
diff -r c1434b779f36 linux-2.6-xen-sparse/include/xen/public/privcmd.h
@@ -39,14 +39,14 @@
 
 typedef struct privcmd_hypercall
 {
-	unsigned long op;
-	unsigned long arg[5];
+	uint64_t op;
+	uint64_t arg[5];
 } privcmd_hypercall_t;
 
 typedef struct privcmd_mmap_entry {
-	unsigned long va;
-	unsigned long mfn;
-	unsigned long npages;
+	uint64_t va;
+	uint64_t mfn;
+	uint64_t npages;
 } privcmd_mmap_entry_t; 
 
 typedef struct privcmd_mmap {
@@ -58,7 +58,7 @@ typedef struct privcmd_mmapbatch {
 typedef struct privcmd_mmapbatch {
 	int num;     /* number of pages to populate */
 	domid_t dom; /* target domain */
-	unsigned long addr;  /* virtual address */
+	uint64_t addr;  /* virtual address */
 	xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
 } privcmd_mmapbatch_t; 
 
xen/include/public/dom0_ops.h +27 -27

134 lines not on this page · raw message

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

#4 lore raw
Quoted 1 line · Hollis Blanchard

Replace 'long' in the dom0_ops and privcmd structures with uint64_t.

I am all in favor of identifying interfaces using explicitly sized types. The standard kernel style is to use u64 not uint64_t though.

Cheers,
Muli

#5 lore raw
Quoted 6 lines · Muli Ben-Yehuda
Quoted 1 line · Hollis Blanchard

Replace 'long' in the dom0_ops and privcmd structures with uint64_t.

I am all in favor of identifying interfaces using explicitly sized types. The standard kernel style is to use u64 not uint64_t though.

(There is plenty of uint.._t in Linux.)

I assume you're referring specifically to the privcmd structure change, which is the only Linux-specific part of the patch. The privcmd structure is shared between userspace and the kernel. Since "u64" is a kernel type, we need to use "uint64_t", which has meaning in userspace.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#6 lore raw
Quoted 9 lines · Hollis Blanchard
Quoted 6 lines · Muli Ben-Yehuda
Quoted 1 line · Hollis Blanchard

Replace 'long' in the dom0_ops and privcmd structures with uint64_t.

I am all in favor of identifying interfaces using explicitly sized types. The standard kernel style is to use u64 not uint64_t though.

(There is plenty of uint.._t in Linux.)

Yeah... but. That's not the Officially Sanctioned Way, except in headers that are shared with userspace, and in a perfect world no headers would be shared with userspace.

Quoted 5 lines

I assume you're referring specifically to the privcmd structure change, which is the only Linux-specific part of the patch. The privcmd structure is shared between userspace and the kernel. Since "u64" is a kernel type, we need to use "uint64_t", which has meaning in userspace.

Oh well, I didn't realize it was shared with userspace... sorry for the false alarm.

Cheers,
Muli

#7 lore raw
Quoted 8 lines · Muli Ben-Yehuda
Quoted 5 lines

I assume you're referring specifically to the privcmd structure change, which is the only Linux-specific part of the patch. The privcmd structure is shared between userspace and the kernel. Since "u64" is a kernel type, we need to use "uint64_t", which has meaning in userspace.

Oh well, I didn't realize it was shared with userspace... sorry for the false alarm.

I think Linus' opinion[0] is that kernel headers which are shared with userspace cannot assume that stdint.h has been included so you need to use __u64 and friends.

Ian.

[0] http://www.ussg.iu.edu/hypermail/linux/kernel/0412.1/1456.html.
There's been plenty of other traffic in lkml about it too.

#8 lore raw
Quoted 10 lines · Ian Campbell
Quoted 8 lines · Muli Ben-Yehuda
Quoted 5 lines

I assume you're referring specifically to the privcmd structure change, which is the only Linux-specific part of the patch. The privcmd structure is shared between userspace and the kernel. Since "u64" is a kernel type, we need to use "uint64_t", which has meaning in userspace.

Oh well, I didn't realize it was shared with userspace... sorry for the false alarm.

Quoted 8 lines

I think Linus' opinion[0] is that kernel headers which are shared with userspace cannot assume that stdint.h has been included so you need to use __u64 and friends.

Ian.

[0] http://www.ussg.iu.edu/hypermail/linux/kernel/0412.1/1456.html.
There's been plenty of other traffic in lkml about it too.

There certainly has been plenty of traffic, but I have seen no clear statements (other than "THIS IS BAD" with little explanation). In fact there was just a thread about it this month
(http://www.ussg.iu.edu/hypermail/linux/kernel/0605.0/0146.html), and I still don't understand the objections.

If you use __u64, you'd need to include some header defining what __u64 is, so you're requiring another header anyways. You might as well use the standard stdint.h rather than inventing your own.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#9 lore raw
Quoted 26 lines · Hollis Blanchard
Quoted 10 lines · Ian Campbell
Quoted 8 lines · Muli Ben-Yehuda
Quoted 5 lines

I assume you're referring specifically to the privcmd structure change, which is the only Linux-specific part of the patch. The privcmd structure is shared between userspace and the kernel. Since "u64" is a kernel type, we need to use "uint64_t", which has meaning in userspace.

Oh well, I didn't realize it was shared with userspace... sorry for the false alarm.

Quoted 8 lines

I think Linus' opinion[0] is that kernel headers which are shared with userspace cannot assume that stdint.h has been included so you need to use __u64 and friends.

Ian.

[0] http://www.ussg.iu.edu/hypermail/linux/kernel/0412.1/1456.html.
There's been plenty of other traffic in lkml about it too.

There certainly has been plenty of traffic, but I have seen no clear statements (other than "THIS IS BAD" with little explanation). In fact there was just a thread about it this month
(http://www.ussg.iu.edu/hypermail/linux/kernel/0605.0/0146.html), and I still don't understand the objections.

Quoted 3 lines

If you use __u64, you'd need to include some header defining what __u64 is, so you're requiring another header anyways. You might as well use the standard stdint.h rather than inventing your own.

As I understand it the issue is that the C spec makes the __* namespace available for the kernel to pollute and reserves the non-prefixed namespace for application usage. (Single underscore is for compiler or libc internals or something).

An application which has not included stdint.h itself can expect to use uint64_t however it wishes, including making it a struct, a function or even something as gross as a 32 bit signed int etc. Exporting some other idea of what uint64_t should be via the kernel headers breaks this. I guess this is more of a problem when a kernel header gets indirectly included -- presumably an app which includes a kernel header directly knows what it is doing.

Anyway, regardless of any opinion expressed here the Linux gatekeepers will no doubt insist on __uN. We might as well do it now as change it later.

Ian.

#10 lore raw
Quoted 10 lines · Ian Campbell
Quoted 4 lines

If you use __u64, you'd need to include some header defining what __u64 is, so you're requiring another header anyways. You might as well use the standard stdint.h rather than inventing your own.

As I understand it the issue is that the C spec makes the __* namespace available for the kernel to pollute and reserves the non-prefixed namespace for application usage. (Single underscore is for compiler or libc internals or something).

The relevant portions of the spec are:

7.1.3 Reserved identifiers

[#1] Each header declares or defines all identifiers listed in its associated subclause, and optionally declares or defines identifiers listed in its associated future library
directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.

- All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.

- All identifiers that begin with an underscore are always reserved for use as macros and as identifiers with file scope in both the ordinary and tag name spaces.

- Each macro name in any of the following subclauses (including the future library directions) is reserved for use as specified if any of its associated headers is included; unless explicitly stated otherwise (see 7.1.8 <http://www.vmunix.com/%7Egabor/c/draft.html#7.1.8>).

- All identifiers with external linkage in any of the following subclauses (including the future library directions) are always reserved for use as identifiers with external linkage.133

- Each identifier with file scope listed in any of the following subclauses (including the future library directions) is reserved for use as macro and as an identifier with file scope in the same name space if any of its associated headers is included.

[#2] No other identifiers are reserved. If the program
declares or defines an identifier that is reserved in that
context (other than as allowed by 7.1.8 <http://www.vmunix.com/%7Egabor/c/draft.html#7.1.8>), the behavior is undefined.134

It's pretty clear that __* names are reserved. The kernel is wrong here. The best explanation I've gotten is "egocentrism" :-)

Regards,

Anthony Liguori

Quoted 21 lines

An application which has not included stdint.h itself can expect to use uint64_t however it wishes, including making it a struct, a function or even something as gross as a 32 bit signed int etc. Exporting some other idea of what uint64_t should be via the kernel headers breaks this. I guess this is more of a problem when a kernel header gets indirectly included -- presumably an app which includes a kernel header directly knows what it is doing.

Anyway, regardless of any opinion expressed here the Linux gatekeepers will no doubt insist on __uN. We might as well do it now as change it later.

Ian.

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

#11 lore raw
Quoted 13 lines · Anthony Liguori
Quoted 10 lines · Ian Campbell
Quoted 4 lines

If you use __u64, you'd need to include some header defining what __u64 is, so you're requiring another header anyways. You might as well use the standard stdint.h rather than inventing your own.

As I understand it the issue is that the C spec makes the __* namespace available for the kernel to pollute and reserves the non-prefixed namespace for application usage. (Single underscore is for compiler or libc internals or something).

The relevant portions of the spec are:

[...]

Quoted 2 lines

It's pretty clear that __* names are reserved. The kernel is wrong here. The best explanation I've gotten is "egocentrism" :-)

Reserved for what? The `implementation'. Which is the combination of compiler, libc and whatever kernel headers libc lets through. How these guys divvy up their reserved name space is up to them, and we better play by their rules.

#12 lore raw
In reply to Ian Campbell
Quoted 4 lines · Ian Campbell

Anyway, regardless of any opinion expressed here the Linux gatekeepers will no doubt insist on __uN. We might as well do it now as change it later.

And where will userspace, e.g. tools/libxc/xc_linux.c, find the definition of __u64?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#13 lore raw
Quoted 8 lines · * Hollis Blanchard ([email protected]) wrote:
Quoted 4 lines · Ian Campbell

Anyway, regardless of any opinion expressed here the Linux gatekeepers will no doubt insist on __uN. We might as well do it now as change it later.

And where will userspace, e.g. tools/libxc/xc_linux.c, find the definition of __u64?

Same place they do for the rest of shared headers (glib-kernheaders, for example). Please use the proper form (u64 internal to kernel, and __u64 for header visisble to userspace). I'm going to have to clean it up anyway.

thanks,
-chris

#14 lore raw
Quoted 11 lines · Chris Wright
Quoted 6 lines
Quoted 3 lines

Anyway, regardless of any opinion expressed here the Linux gatekeepers will no doubt insist on __uN. We might as well do it now as change it later.

And where will userspace, e.g. tools/libxc/xc_linux.c, find the definition of __u64?

Same place they do for the rest of shared headers (glib-kernheaders, for example). Please use the proper form (u64 internal to kernel, and __u64 for header visisble to userspace). I'm going to have to clean it up anyway.

This won't work on platforms that don't provide __u64. Xen needs to define them somewhere for the userspace.

regards
john

#15 lore raw
Quoted 2 lines · * John Levon ([email protected]) wrote:

This won't work on platforms that don't provide __u64. Xen needs to define them somewhere for the userspace.

+++ b/linux-2.6-xen-sparse/include/xen/public/privcmd.h

That's specifically the part I'm talking about.

WRT Xen's public headers, that's a different issue, however there's still some of the same namespace concerns. Of course, I'd be thrilled to make it all __u64 in public headers w/ appropriate types.h involved. And realisitically, platforms will all need some santized version of the headers anyway.

thanks,
-chris

#16 lore raw
Quoted 5 lines · Chris Wright
Quoted 2 lines

This won't work on platforms that don't provide __u64. Xen needs to define them somewhere for the userspace.

+++ b/linux-2.6-xen-sparse/include/xen/public/privcmd.h

Quoted 7 lines

That's specifically the part I'm talking about.

WRT Xen's public headers, that's a different issue, however there's still some of the same namespace concerns. Of course, I'd be thrilled to make it all __u64 in public headers w/ appropriate types.h involved. And realisitically, platforms will all need some santized version of the headers anyway.

Yes, but hopefully it will be possible to provide the structure definitions in some generic form, possibly by including another header that has the platform-specific parts (such as ioctl numbers, __u64 definitions on Solaris, etc.)

It would be a shame if we had to duplicate the structure definitions 3 or more times.

regards
john

#17 lore raw

PATCH 2/3 use new 'xen_pfn_t' type to represent PFNs in the Xen ABI

In reply to a message not in the archive

Represent PFNs with their own type, rather than 'unsigned long', since 'long' changes size and alignment between 32- and 64-bit ABIs.

linux-2.6-xen-sparse/include/xen/public/privcmd.h +1 -1
diff -r 2212e54a95b5 linux-2.6-xen-sparse/include/xen/public/privcmd.h
@@ -59,7 +59,7 @@ typedef struct privcmd_mmapbatch {
 	int num;     /* number of pages to populate */
 	domid_t dom; /* target domain */
 	unsigned long addr;  /* virtual address */
-	unsigned long __user *arr; /* array of mfns - top nibble set on err */
+	xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
 } privcmd_mmapbatch_t; 
 
 /*
tools/debugger/libxendebug/xendebug.c +1 -1
diff -r 2212e54a95b5 tools/debugger/libxendebug/xendebug.c
@@ -57,7 +57,7 @@ typedef struct domain_context           
     vcpu_guest_context_t context[MAX_VIRT_CPUS];
 
     long            total_pages;
-    unsigned long  *page_array;
+    xen_pfn_t      *page_array;
 
     unsigned long   cr3_phys[MAX_VIRT_CPUS];
     unsigned long  *cr3_virt[MAX_VIRT_CPUS];
tools/ioemu/hw/cirrus_vga.c +6 -6
diff -r 2212e54a95b5 tools/ioemu/hw/cirrus_vga.c
@@ -2463,7 +2463,7 @@ extern FILE *logfile;
 #if defined(__i386__) || defined (__x86_64__)
 static void * set_vram_mapping(unsigned long begin, unsigned long end)
 {
-    unsigned long * extent_start = NULL;
+    xen_pfn_t *extent_start = NULL;
     unsigned long nr_extents;
     void *vram_pointer = NULL;
     int i;
@@ -2474,14 +2474,14 @@ static void * set_vram_mapping(unsigned 
     end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
     nr_extents = (end - begin) >> TARGET_PAGE_BITS;
 
-    extent_start = malloc(sizeof(unsigned long) * nr_extents );
+    extent_start = malloc(sizeof(xen_pfn_t) * nr_extents );
     if (extent_start == NULL)
     {
         fprintf(stderr, "Failed malloc on set_vram_mapping\n");
         return NULL;
     }
 
-    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+    memset(extent_start, 0, sizeof(xen_pfn_t) * nr_extents);
 
     for (i = 0; i < nr_extents; i++)
     {
@@ -2509,7 +2509,7 @@ static void * set_vram_mapping(unsigned 
 
 static int unset_vram_mapping(unsigned long begin, unsigned long end)
 {
-    unsigned long * extent_start = NULL;
+    xen_pfn_t *extent_start = NULL;
     unsigned long nr_extents;
     int i;
 
@@ -2520,7 +2520,7 @@ static int unset_vram_mapping(unsigned l
     end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
     nr_extents = (end - begin) >> TARGET_PAGE_BITS;
 
-    extent_start = malloc(sizeof(unsigned long) * nr_extents );
+    extent_start = malloc(sizeof(xen_pfn_t) * nr_extents );
 
     if (extent_start == NULL)
     {
@@ -2528,7 +2528,7 @@ static int unset_vram_mapping(unsigned l
         return -1;
     }
 
-    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+    memset(extent_start, 0, sizeof(xen_pfn_t) * nr_extents);
 
     for (i = 0; i < nr_extents; i++)
         extent_start[i] = (begin + (i * TARGET_PAGE_SIZE)) >> TARGET_PAGE_BITS;
tools/ioemu/vl.c +8 -7
diff -r 2212e54a95b5 tools/ioemu/vl.c
@@ -2457,7 +2457,7 @@ int unset_mm_mapping(int xc_handle,
                      uint32_t domid,
                      unsigned long nr_pages,
                      unsigned int address_bits,
-                     unsigned long *extent_start)
+                     xen_pfn_t *extent_start)
 {
     int err = 0;
     xc_dominfo_t info;
@@ -2490,7 +2490,7 @@ int set_mm_mapping(int xc_handle,
                     uint32_t domid,
                     unsigned long nr_pages,
                     unsigned int address_bits,
-                    unsigned long *extent_start)
+                    xen_pfn_t *extent_start)
 {
     xc_dominfo_t info;
     int err = 0;
@@ -2556,7 +2556,8 @@ int main(int argc, char **argv)
     int serial_device_index;
     char qemu_dm_logfilename[64];
     const char *loadvm = NULL;
-    unsigned long nr_pages, *page_array;
+    unsigned long nr_pages;
+    xen_pfn_t *page_array;
     extern void *shared_page;
 
 #if !defined(CONFIG_SOFTMMU)
@@ -3022,8 +3023,8 @@ int main(int argc, char **argv)
 
     xc_handle = xc_interface_open();
 
-    if ( (page_array = (unsigned long *)
-                        malloc(nr_pages * sizeof(unsigned long))) == NULL)
+    if ( (page_array = (xen_pfn_t *)
+                        malloc(nr_pages * sizeof(xen_pfn_t))) == NULL)
     {
         fprintf(logfile, "malloc returned error %d\n", errno);
         exit(-1);
@@ -3078,8 +3079,8 @@ int main(int argc, char **argv)
                                        page_array[0]);
 #endif
 
-    fprintf(logfile, "shared page at pfn:%lx, mfn: %lx\n", (nr_pages-1),
-           (page_array[nr_pages - 1]));
+    fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n", (nr_pages-1),
+           (uint64_t)(page_array[nr_pages - 1]));
 
     /* we always create the cdrom drive, even if no disk is there */
     bdrv_init();
tools/libxc/xc_core.c +4 -4
diff -r 2212e54a95b5 tools/libxc/xc_core.c
@@ -28,7 +28,7 @@ xc_domain_dumpcore_via_callback(int xc_h
                                 dumpcore_rtn_t dump_rtn)
 {
     unsigned long nr_pages;
-    unsigned long *page_array = NULL;
+    xen_pfn_t *page_array = NULL;
     xc_dominfo_t info;
     int i, nr_vcpus = 0;
     char *dump_mem, *dump_mem_start = NULL;
@@ -70,7 +70,7 @@ xc_domain_dumpcore_via_callback(int xc_h
         sizeof(vcpu_guest_context_t)*nr_vcpus;
     dummy_len = (sizeof(struct xc_core_header) +
                  (sizeof(vcpu_guest_context_t) * nr_vcpus) +
-                 (nr_pages * sizeof(unsigned long)));
+                 (nr_pages * sizeof(xen_pfn_t)));
     header.xch_pages_offset = round_pgup(dummy_len);
 
     sts = dump_rtn(args, (char *)&header, sizeof(struct xc_core_header));
@@ -81,7 +81,7 @@ xc_domain_dumpcore_via_callback(int xc_h
     if ( sts != 0 )
         goto error_out;
 
-    if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
+    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
     {
         printf("Could not allocate memory\n");
         goto error_out;
@@ -91,7 +91,7 @@ xc_domain_dumpcore_via_callback(int xc_h
         printf("Could not get the page frame list\n");
         goto error_out;
     }
-    sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(unsigned long));
+    sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(xen_pfn_t));
     if ( sts != 0 )
         goto error_out;
 
tools/libxc/xc_domain.c +5 -5
diff -r 2212e54a95b5 tools/libxc/xc_domain.c
@@ -291,7 +291,7 @@ int xc_domain_memory_increase_reservatio
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
                                           unsigned int address_bits,
-                                          unsigned long *extent_start)
+                                          xen_pfn_t *extent_start)
 {
     int err;
     struct xen_memory_reservation reservation = {
@@ -324,7 +324,7 @@ int xc_domain_memory_decrease_reservatio
                                           uint32_t domid,
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned long *extent_start)
+                                          xen_pfn_t *extent_start)
 {
     int err;
     struct xen_memory_reservation reservation = {
@@ -363,7 +363,7 @@ int xc_domain_memory_populate_physmap(in
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
                                           unsigned int address_bits,
-                                          unsigned long *extent_start)
+                                          xen_pfn_t *extent_start)
 {
     int err;
     struct xen_memory_reservation reservation = {
@@ -392,8 +392,8 @@ int xc_domain_translate_gpfn_list(int xc
 int xc_domain_translate_gpfn_list(int xc_handle,
                                   uint32_t domid,
                                   unsigned long nr_gpfns,
-                                  unsigned long *gpfn_list,
-                                  unsigned long *mfn_list)
+                                  xen_pfn_t *gpfn_list,
+                                  xen_pfn_t *mfn_list)
 {
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
tools/libxc/xc_hvm_build.c +3 -3
diff -r 2212e54a95b5 tools/libxc/xc_hvm_build.c
@@ -135,7 +135,7 @@ static void set_hvm_info_checksum(struct
  * hvmloader will use this info to set BIOS accordingly
  */
 static int set_hvm_info(int xc_handle, uint32_t dom,
-                        unsigned long *pfn_list, unsigned int vcpus,
+                        xen_pfn_t *pfn_list, unsigned int vcpus,
                         unsigned int pae, unsigned int acpi, unsigned int apic)
 {
     char *va_map;
@@ -178,7 +178,7 @@ static int setup_guest(int xc_handle,
                        unsigned int store_evtchn,
                        unsigned long *store_mfn)
 {
-    unsigned long *page_array = NULL;
+    xen_pfn_t *page_array = NULL;
     unsigned long count, i;
     unsigned long long ptr;
     xc_mmu_t *mmu = NULL;
@@ -223,7 +223,7 @@ static int setup_guest(int xc_handle,
         goto error_out;
     }
 
-    if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
+    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
     {
         PERROR("Could not allocate memory.\n");
         goto error_out;
tools/libxc/xc_ia64_stubs.c +6 -6
diff -r 2212e54a95b5 tools/libxc/xc_ia64_stubs.c
@@ -57,7 +57,7 @@ xc_plan9_build(int xc_handle,
 
 int xc_ia64_get_pfn_list(int xc_handle,
                          uint32_t domid,
-                         unsigned long *pfn_buf,
+                         xen_pfn_t *pfn_buf,
                          unsigned int start_page,
                          unsigned int nr_pages)
 {
@@ -65,7 +65,7 @@ int xc_ia64_get_pfn_list(int xc_handle,
     int num_pfns,ret;
     unsigned int __start_page, __nr_pages;
     unsigned long max_pfns;
-    unsigned long *__pfn_buf;
+    xen_pfn_t *__pfn_buf;
 
     __start_page = start_page;
     __nr_pages = nr_pages;
@@ -80,7 +80,7 @@ int xc_ia64_get_pfn_list(int xc_handle,
         set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf);
 
         if ( (max_pfns != -1UL)
-            && mlock(__pfn_buf, __nr_pages * sizeof(unsigned long)) != 0 )
+            && mlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t)) != 0 )
         {
             PERROR("Could not lock pfn list buffer");
             return -1;
@@ -89,7 +89,7 @@ int xc_ia64_get_pfn_list(int xc_handle,
         ret = do_dom0_op(xc_handle, &op);
 
         if (max_pfns != -1UL)
-            (void)munlock(__pfn_buf, __nr_pages * sizeof(unsigned long));
+            (void)munlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t));
 
         if (max_pfns == -1UL)
             return 0;
@@ -122,10 +122,10 @@ int xc_ia64_copy_to_domain_pages(int xc_
 {
     // N.B. gva should be page aligned
 
-    unsigned long *page_array = NULL;
+    xen_pfn_t *page_array = NULL;
     int i;
 
-    if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL ){
+    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL ){
         PERROR("Could not allocate memory");
         goto error_out;
     }
tools/libxc/xc_linux.c +1 -1
diff -r 2212e54a95b5 tools/libxc/xc_linux.c
@@ -28,7 +28,7 @@ int xc_interface_close(int xc_handle)
 }
 
 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
-                           unsigned long *arr, int num)
+                           xen_pfn_t *arr, int num)
 {
     privcmd_mmapbatch_t ioctlx;
     void *addr;
tools/libxc/xc_linux_build.c +11 -10
diff -r 2212e54a95b5 tools/libxc/xc_linux_build.c
@@ -10,6 +10,7 @@
 #include "xc_aout9.h"
 #include <stdlib.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include <zlib.h>
 
 #if defined(__i386__)
@@ -136,7 +137,7 @@ int load_initrd(int xc_handle, domid_t d
 int load_initrd(int xc_handle, domid_t dom,
                 struct initrd_info *initrd,
                 unsigned long physbase,
-                unsigned long *phys_to_mach)
+                xen_pfn_t *phys_to_mach)
 {
     char page[PAGE_SIZE];
     unsigned long pfn_start, pfn, nr_pages;
@@ -189,7 +190,7 @@ static int setup_pg_tables(int xc_handle
                            vcpu_guest_context_t *ctxt,
                            unsigned long dsi_v_start,
                            unsigned long v_end,
-                           unsigned long *page_array,
+                           xen_pfn_t *page_array,
                            unsigned long vpt_start,
                            unsigned long vpt_end,
                            unsigned shadow_mode_enabled)
@@ -251,7 +252,7 @@ static int setup_pg_tables_pae(int xc_ha
                                vcpu_guest_context_t *ctxt,
                                unsigned long dsi_v_start,
                                unsigned long v_end,
-                               unsigned long *page_array,
+                               xen_pfn_t *page_array,
                                unsigned long vpt_start,
                                unsigned long vpt_end,
                                unsigned shadow_mode_enabled)
@@ -351,7 +352,7 @@ static int setup_pg_tables_64(int xc_han
                               vcpu_guest_context_t *ctxt,
                               unsigned long dsi_v_start,
                               unsigned long v_end,
-                              unsigned long *page_array,
+                              xen_pfn_t *page_array,
                               unsigned long vpt_start,
                               unsigned long vpt_end,
                               int shadow_mode_enabled)
@@ -462,7 +463,7 @@ static int setup_guest(int xc_handle,
                        unsigned int console_evtchn, unsigned long *console_mfn,
                        uint32_t required_features[XENFEAT_NR_SUBMAPS])
 {
-    unsigned long *page_array = NULL;
+    xen_pfn_t *page_array = NULL;
     struct load_funcs load_funcs;
     struct domain_setup_info dsi;
     unsigned long vinitrd_start;
@@ -489,7 +490,7 @@ static int setup_guest(int xc_handle,
 
     start_page = dsi.v_start >> PAGE_SHIFT;
     pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
-    if ( (page_array = malloc(pgnr * sizeof(unsigned long))) == NULL )
+    if ( (page_array = malloc(pgnr * sizeof(xen_pfn_t))) == NULL )
     {
         PERROR("Could not allocate memory");
         goto error_out;
@@ -617,7 +618,7 @@ static int setup_guest(int xc_handle,
                        unsigned int console_evtchn, unsigned long *console_mfn,
                        uint32_t required_features[XENFEAT_NR_SUBMAPS])
 {
-    unsigned long *page_array = NULL;
+    xen_pfn_t *page_array = NULL;
     unsigned long count, i, hypercall_pfn;
     start_info_t *start_info;
     shared_info_t *shared_info;
@@ -628,7 +629,7 @@ static int setup_guest(int xc_handle,
 
     unsigned long nr_pt_pages;
     unsigned long physmap_pfn;
-    unsigned long *physmap, *physmap_e;
+    xen_pfn_t *physmap, *physmap_e;
 
     struct load_funcs load_funcs;
     struct domain_setup_info dsi;
@@ -876,8 +877,8 @@ static int setup_guest(int xc_handle,
             ((uint64_t)page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
             count) )
         {
-            fprintf(stderr,"m2p update failure p=%lx m=%lx\n",
-                    count, page_array[count]);
+            fprintf(stderr,"m2p update failure p=%lx m=%"PRIx64"\n",
+                    count, (uint64_t)page_array[count]);
             munmap(physmap, PAGE_SIZE);
             goto error_out;
         }
tools/libxc/xc_linux_restore.c +7 -7
diff -r 2212e54a95b5 tools/libxc/xc_linux_restore.c
@@ -25,10 +25,10 @@ static unsigned long max_pfn;
 static unsigned long max_pfn;
 
 /* Live mapping of the table mapping each PFN to its current MFN. */
-static unsigned long *live_p2m = NULL;
+static xen_pfn_t *live_p2m = NULL;
 
 /* A table mapping each PFN to its new MFN. */
-static unsigned long *p2m = NULL;
+static xen_pfn_t *p2m = NULL;
 
 
 static ssize_t
@@ -126,7 +126,7 @@ int xc_linux_restore(int xc_handle, int 
     unsigned long *pfn_type = NULL;
 
     /* A table of MFNs to map in the current region */
-    unsigned long *region_mfn = NULL;
+    xen_pfn_t *region_mfn = NULL;
 
     /* Types of the pfns in the current region */
     unsigned long region_pfn_type[MAX_BATCH_SIZE];
@@ -135,7 +135,7 @@ int xc_linux_restore(int xc_handle, int 
     unsigned long *page = NULL;
 
     /* A copy of the pfn-to-mfn table frame list. */
-    unsigned long *p2m_frame_list = NULL;
+    xen_pfn_t *p2m_frame_list = NULL;
 
     /* A temporary mapping of the guest's start_info page. */
     start_info_t *start_info;
@@ -183,9 +183,9 @@ int xc_linux_restore(int xc_handle, int 
 
 
     /* We want zeroed memory so use calloc rather than malloc. */
-    p2m        = calloc(max_pfn, sizeof(unsigned long));
+    p2m        = calloc(max_pfn, sizeof(xen_pfn_t));
     pfn_type   = calloc(max_pfn, sizeof(unsigned long));
-    region_mfn = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
+    region_mfn = calloc(MAX_BATCH_SIZE, sizeof(xen_pfn_t));
 
     if ((p2m == NULL) || (pfn_type == NULL) || (region_mfn == NULL)) {
         ERR("memory alloc failed");
@@ -193,7 +193,7 @@ int xc_linux_restore(int xc_handle, int 
         goto out;
     }
 
-    if (mlock(region_mfn, sizeof(unsigned long) * MAX_BATCH_SIZE)) {
+    if (mlock(region_mfn, sizeof(xen_pfn_t) * MAX_BATCH_SIZE)) {
         ERR("Could not mlock region_mfn");
         goto out;
     }
tools/libxc/xc_linux_save.c +14 -14
diff -r 2212e54a95b5 tools/libxc/xc_linux_save.c
@@ -40,10 +40,10 @@ static unsigned long max_pfn;
 static unsigned long max_pfn;
 
 /* Live mapping of the table mapping each PFN to its current MFN. */
-static unsigned long *live_p2m = NULL;
+static xen_pfn_t *live_p2m = NULL;
 
 /* Live mapping of system MFN to PFN table. */
-static unsigned long *live_m2p = NULL;
+static xen_pfn_t *live_m2p = NULL;
 
 /* grep fodder: machine_to_phys */
 
@@ -501,22 +501,22 @@ void canonicalize_pagetable(unsigned lon
 
 
 
-static unsigned long *xc_map_m2p(int xc_handle,
+static xen_pfn_t *xc_map_m2p(int xc_handle,
                                  unsigned long max_mfn,
                                  int prot)
 {
     struct xen_machphys_mfn_list xmml;
     privcmd_mmap_entry_t *entries;
     unsigned long m2p_chunks, m2p_size;
-    unsigned long *m2p;
-    unsigned long *extent_start;
+    xen_pfn_t *m2p;
+    xen_pfn_t *extent_start;
     int i, rc;
 
     m2p_size   = M2P_SIZE(max_mfn);
     m2p_chunks = M2P_CHUNKS(max_mfn);
 
     xmml.max_extents = m2p_chunks;
-    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
+    if (!(extent_start = malloc(m2p_chunks * sizeof(xen_pfn_t)))) {
         ERR("failed to allocate space for m2p mfns");
         return NULL;
     }
@@ -583,11 +583,11 @@ int xc_linux_save(int xc_handle, int io_
     char page[PAGE_SIZE];
 
     /* Double and single indirect references to the live P2M table */
-    unsigned long *live_p2m_frame_list_list = NULL;
-    unsigned long *live_p2m_frame_list = NULL;
+    xen_pfn_t *live_p2m_frame_list_list = NULL;
+    xen_pfn_t *live_p2m_frame_list = NULL;
 
     /* A copy of the pfn-to-mfn table frame list. */
-    unsigned long *p2m_frame_list = NULL;
+    xen_pfn_t *p2m_frame_list = NULL;
 
     /* Live mapping of shared info structure */
     shared_info_t *live_shinfo = NULL;
@@ -712,11 +712,11 @@ int xc_linux_save(int xc_handle, int io_
     memcpy(p2m_frame_list, live_p2m_frame_list, P2M_FL_SIZE);
 
     /* Canonicalise the pfn-to-mfn table frame-number list. */
-    for (i = 0; i < max_pfn; i += ulpp) {
-        if (!translate_mfn_to_pfn(&p2m_frame_list[i/ulpp])) {
+    for (i = 0; i < max_pfn; i += fpp) {
+        if (!translate_mfn_to_pfn(&p2m_frame_list[i/fpp])) {
             ERR("Frame# in pfn-to-mfn frame list is not in pseudophys");
-            ERR("entry %d: p2m_frame_list[%ld] is 0x%lx", i, i/ulpp,
-                p2m_frame_list[i/ulpp]);
+            ERR("entry %d: p2m_frame_list[%ld] is 0x%"PRIx64, i, i/fpp,
+                (uint64_t)p2m_frame_list[i/fpp]);
             goto out;
         }
     }
@@ -818,7 +818,7 @@ int xc_linux_save(int xc_handle, int io_
 
     /* Start writing out the saved-domain record. */
 
-    if(!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) {
+    if(!write_exact(io_fd, &max_pfn, sizeof(xen_pfn_t))) {
         ERR("write: max_pfn");
         goto out;
     }
tools/libxc/xc_load_aout9.c +2 -2
diff -r 2212e54a95b5 tools/libxc/xc_load_aout9.c
@@ -17,7 +17,7 @@
 #define KOFFSET(_p)       ((_p)&~KZERO)
 
 static int parseaout9image(const char *, unsigned long, struct domain_setup_info *);
-static int loadaout9image(const char *, unsigned long, int, uint32_t, unsigned long *, struct domain_setup_info *);
+static int loadaout9image(const char *, unsigned long, int, uint32_t, xen_pfn_t *, struct domain_setup_info *);
 static void copyout(int, uint32_t, unsigned long *, unsigned long, const char *, int);
 struct Exec *get_header(const char *, unsigned long, struct Exec *);
 
@@ -79,7 +79,7 @@ loadaout9image(
     const char *image,
     unsigned long image_size,
     int xch, uint32_t dom,
-    unsigned long *parray,
+    xen_pfn_t *parray,
     struct domain_setup_info *dsi)
 {
     struct Exec ehdr;
tools/libxc/xc_load_bin.c +2 -2
diff -r 2212e54a95b5 tools/libxc/xc_load_bin.c
@@ -107,7 +107,7 @@ static int
 static int
 loadbinimage(
     const char *image, unsigned long image_size, int xch, uint32_t dom,
-    unsigned long *parray, struct domain_setup_info *dsi);
+    xen_pfn_t *parray, struct domain_setup_info *dsi);
 
 int probe_bin(const char *image,
               unsigned long image_size,
@@ -235,7 +235,7 @@ static int
 static int
 loadbinimage(
     const char *image, unsigned long image_size, int xch, uint32_t dom,
-    unsigned long *parray, struct domain_setup_info *dsi)
+    xen_pfn_t *parray, struct domain_setup_info *dsi)
 {
     unsigned long size;
     char         *va;
tools/libxc/xc_load_elf.c +4 -4
diff -r 2212e54a95b5 tools/libxc/xc_load_elf.c
@@ -16,10 +16,10 @@ static int
 static int
 loadelfimage(
     const char *image, unsigned long image_size, int xch, uint32_t dom,
-    unsigned long *parray, struct domain_setup_info *dsi);
+    xen_pfn_t *parray, struct domain_setup_info *dsi);
 static int
 loadelfsymtab(
-    const char *image, int xch, uint32_t dom, unsigned long *parray,
+    const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
     struct domain_setup_info *dsi);
 
 int probe_elf(const char *image,
@@ -204,7 +204,7 @@ static int
 static int
 loadelfimage(
     const char *image, unsigned long elfsize, int xch, uint32_t dom,
-    unsigned long *parray, struct domain_setup_info *dsi)
+    xen_pfn_t *parray, struct domain_setup_info *dsi)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
     Elf_Phdr *phdr;
@@ -258,7 +258,7 @@ loadelfimage(
 
 static int
 loadelfsymtab(
-    const char *image, int xch, uint32_t dom, unsigned long *parray,
+    const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
     struct domain_setup_info *dsi)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr;
tools/libxc/xc_private.c +28 -24

146 lines not on this page · raw message

tools/libxc/xenctrl.h +8 -8
diff -r 2212e54a95b5 tools/libxc/xenctrl.h
@@ -407,26 +407,26 @@ int xc_domain_memory_increase_reservatio
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
                                           unsigned int address_bits,
-                                          unsigned long *extent_start);
+                                          xen_pfn_t *extent_start);
 
 int xc_domain_memory_decrease_reservation(int xc_handle,
                                           uint32_t domid,
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned long *extent_start);
+                                          xen_pfn_t *extent_start);
 
 int xc_domain_memory_populate_physmap(int xc_handle,
                                       uint32_t domid,
                                       unsigned long nr_extents,
                                       unsigned int extent_order,
                                       unsigned int address_bits,
-                                      unsigned long *extent_start);
+                                      xen_pfn_t *extent_start);
 
 int xc_domain_translate_gpfn_list(int xc_handle,
                                   uint32_t domid,
                                   unsigned long nr_gpfns,
-                                  unsigned long *gpfn_list,
-                                  unsigned long *mfn_list);
+                                  xen_pfn_t *gpfn_list,
+                                  xen_pfn_t *mfn_list);
 
 int xc_domain_ioport_permission(int xc_handle,
                                 uint32_t domid,
@@ -479,7 +479,7 @@ void *xc_map_foreign_range(int xc_handle
                             unsigned long mfn );
 
 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
-                           unsigned long *arr, int num );
+                           xen_pfn_t *arr, int num );
 
 /**
  * Translates a virtual address in the context of a given domain and
@@ -494,11 +494,11 @@ unsigned long xc_translate_foreign_addre
 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
                                            int vcpu, unsigned long long virt);
 
-int xc_get_pfn_list(int xc_handle, uint32_t domid, unsigned long *pfn_buf,
+int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
                     unsigned long max_pfns);
 
 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
-                         unsigned long *pfn_buf,
+                         xen_pfn_t *pfn_buf,
                          unsigned int start_page, unsigned int nr_pages);
 
 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
tools/libxc/xg_private.h +2 -2
diff -r 2212e54a95b5 tools/libxc/xg_private.h
@@ -162,7 +162,7 @@ typedef int (*parseimagefunc)(const char
                               struct domain_setup_info *dsi);
 typedef int (*loadimagefunc)(const char *image, unsigned long image_size,
                              int xch,
-                             uint32_t dom, unsigned long *parray,
+                             uint32_t dom, xen_pfn_t *parray,
                              struct domain_setup_info *dsi);
 
 struct load_funcs
@@ -190,7 +190,7 @@ unsigned long xc_get_filesz(int fd);
 unsigned long xc_get_filesz(int fd);
 
 void xc_map_memcpy(unsigned long dst, const char *src, unsigned long size,
-                   int xch, uint32_t dom, unsigned long *parray,
+                   int xch, uint32_t dom, xen_pfn_t *parray,
                    unsigned long vstart);
 
 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
tools/libxc/xg_save_restore.h +6 -6
diff -r 2212e54a95b5 tools/libxc/xg_save_restore.h
@@ -105,23 +105,23 @@ static int get_platform_info(int xc_hand
 */
 #define M2P_SHIFT       L2_PAGETABLE_SHIFT_PAE
 #define M2P_CHUNK_SIZE  (1 << M2P_SHIFT)
-#define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(unsigned long)), M2P_SHIFT)
+#define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(xen_pfn_t)), M2P_SHIFT)
 #define M2P_CHUNKS(_m)  (M2P_SIZE((_m)) >> M2P_SHIFT)
 
 /* Size in bytes of the P2M (rounded up to the nearest PAGE_SIZE bytes) */
-#define P2M_SIZE        ROUNDUP((max_pfn * sizeof(unsigned long)), PAGE_SHIFT)
+#define P2M_SIZE        ROUNDUP((max_pfn * sizeof(xen_pfn_t)), PAGE_SHIFT)
 
-/* Number of unsigned longs in a page */
-#define ulpp            (PAGE_SIZE/sizeof(unsigned long))
+/* Number of xen_pfn_t in a page */
+#define fpp             (PAGE_SIZE/sizeof(xen_pfn_t))
 
 /* Number of entries in the pfn_to_mfn_frame_list */
-#define P2M_FL_ENTRIES  (((max_pfn)+ulpp-1)/ulpp)
+#define P2M_FL_ENTRIES  (((max_pfn)+fpp-1)/fpp)
 
 /* Size in bytes of the pfn_to_mfn_frame_list     */
 #define P2M_FL_SIZE     ((P2M_FL_ENTRIES)*sizeof(unsigned long))
 
 /* Number of entries in the pfn_to_mfn_frame_list_list */
-#define P2M_FLL_ENTRIES (((max_pfn)+(ulpp*ulpp)-1)/(ulpp*ulpp))
+#define P2M_FLL_ENTRIES (((max_pfn)+(fpp*fpp)-1)/(fpp*fpp))
 
 /* Current guests allow 8MB 'slack' in their P2M */
 #define NR_SLACK_ENTRIES   ((8 * 1024 * 1024) / PAGE_SIZE)
xen/common/memory.c +13 -7
diff -r 2212e54a95b5 xen/common/memory.c
@@ -31,14 +31,15 @@ static long
 static long
 increase_reservation(
     struct domain *d, 
-    XEN_GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(xen_pfn_t) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
     int           *preempted)
 {
     struct page_info *page;
-    unsigned long     i, mfn;
+    unsigned long i;
+    xen_pfn_t mfn;
 
     if ( !guest_handle_is_null(extent_list) &&
          !guest_handle_okay(extent_list, nr_extents) )
@@ -80,14 +81,16 @@ static long
 static long
 populate_physmap(
     struct domain *d, 
-    XEN_GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(xen_pfn_t) extent_list,
     unsigned int  nr_extents,
     unsigned int  extent_order,
     unsigned int  flags,
     int          *preempted)
 {
     struct page_info *page;
-    unsigned long    i, j, gpfn, mfn;
+    unsigned long i, j;
+    xen_pfn_t gpfn;
+    xen_pfn_t mfn;
 
     if ( !guest_handle_okay(extent_list, nr_extents) )
         return 0;
@@ -177,13 +180,14 @@ static long
 static long
 decrease_reservation(
     struct domain *d,
-    XEN_GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(xen_pfn_t) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
     int           *preempted)
 {
-    unsigned long    i, j, gmfn;
+    unsigned long i, j;
+    xen_pfn_t gmfn;
 
     if ( !guest_handle_okay(extent_list, nr_extents) )
         return 0;
@@ -214,7 +218,9 @@ translate_gpfn_list(
     XEN_GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
 {
     struct xen_translate_gpfn_list op;
-    unsigned long i, gpfn, mfn;
+    unsigned long i;
+    xen_pfn_t gpfn;
+    xen_pfn_t mfn;
     struct domain *d;
 
     if ( copy_from_guest(&op, uop, 1) )
xen/include/public/arch-ia64.h +3 -0
diff -r 2212e54a95b5 xen/include/public/arch-ia64.h
@@ -26,6 +26,9 @@ DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(long);
 DEFINE_XEN_GUEST_HANDLE(void);
+
+typedef unsigned long xen_pfn_t;
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #endif
 
 /* Arch specific VIRQs definition */
xen/include/public/arch-x86_32.h +3 -0
diff -r 2212e54a95b5 xen/include/public/arch-x86_32.h
@@ -28,6 +28,9 @@ DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(long);
 DEFINE_XEN_GUEST_HANDLE(void);
+
+typedef unsigned long xen_pfn_t;
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #endif
 
 /*
xen/include/public/arch-x86_64.h +3 -0
diff -r 2212e54a95b5 xen/include/public/arch-x86_64.h
@@ -28,6 +28,9 @@ DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(int);
 DEFINE_XEN_GUEST_HANDLE(long);
 DEFINE_XEN_GUEST_HANDLE(void);
+
+typedef unsigned long xen_pfn_t;
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #endif
 
 /*
xen/include/public/dom0_ops.h +1 -1
diff -r 2212e54a95b5 xen/include/public/dom0_ops.h
@@ -28,7 +28,7 @@ struct dom0_getmemlist {
     /* IN variables. */
     domid_t       domain;
     unsigned long max_pfns;
-    XEN_GUEST_HANDLE(ulong) buffer;
+    XEN_GUEST_HANDLE(xen_pfn_t) buffer;
     /* OUT variables. */
     unsigned long num_pfns;
 };
xen/include/public/memory.h +4 -4
diff -r 2212e54a95b5 xen/include/public/memory.h
@@ -29,7 +29,7 @@ struct xen_memory_reservation {
      *   OUT: GMFN bases of extents that were allocated
      *   (NB. This command also updates the mach_to_phys translation table)
      */
-    XEN_GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
 
     /* Number of extents, and size/alignment of each (2^extent_order pages). */
     unsigned long  nr_extents;
@@ -87,7 +87,7 @@ struct xen_machphys_mfn_list {
      * any large discontiguities in the machine address space, 2MB gaps in
      * the machphys table will be represented by an MFN base of zero.
      */
-    XEN_GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
 
     /*
      * Number of extents written to the above array. This will be smaller
@@ -135,13 +135,13 @@ struct xen_translate_gpfn_list {
     unsigned long nr_gpfns;
 
     /* List of GPFNs to translate. */
-    XEN_GUEST_HANDLE(ulong) gpfn_list;
+    XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
 
     /*
      * Output list to contain MFN translations. May be the same as the input
      * list (in which case each input GPFN is overwritten with the output MFN).
      */
-    XEN_GUEST_HANDLE(ulong) mfn_list;
+    XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
 };
 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);

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

#18 lore raw

PATCH 1/3 global build configuration file

In reply to a message not in the archive

Use a global build configuration file, and rework libxc Makefile to work on PowerPC.

Config.mk +1 -13
diff -r ad33b3882867 Config.mk
@@ -39,19 +39,7 @@ CFLAGS    += -g
 CFLAGS    += -g
 endif
 
-ifeq ($(XEN_TARGET_ARCH),x86_32)
-CFLAGS  += -m32 -march=i686
-endif
-
-ifeq ($(XEN_TARGET_ARCH),x86_64)
-CFLAGS  += -m64
-endif
-
-ifeq ($(XEN_TARGET_ARCH),x86_64)
-LIBDIR = lib64
-else
-LIBDIR = lib
-endif
+include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
extras/mini-os/Makefile +2 -1
diff -r ad33b3882867 extras/mini-os/Makefile
@@ -1,7 +1,8 @@ debug ?= y
 debug ?= y
 pae ?= n
 
-include $(CURDIR)/../../Config.mk
+XEN_ROOT = ../..
+include $(XEN_ROOT)/Config.mk
 
 # Set TARGET_ARCH
 override TARGET_ARCH     := $(XEN_TARGET_ARCH)
tools/Makefile +22 -23

75 lines not on this page · raw message

tools/Rules.mk +2 -0
diff -r ad33b3882867 tools/Rules.mk
@@ -4,6 +4,8 @@ all:
 all:
 
 include $(XEN_ROOT)/Config.mk
+
+CONFIG_$(shell uname -s) := y
 
 XEN_XC             = $(XEN_ROOT)/tools/python/xen/lowlevel/xc
 XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
tools/libxc/Makefile +30 -43

109 lines not on this page · raw message

tools/libxc/xc_core.c +0 -2
diff -r ad33b3882867 tools/libxc/xc_core.c
@@ -1,6 +1,4 @@
 #include "xg_private.h"
-#define ELFSIZE 32
-#include "xc_elf.h"
 #include <stdlib.h>
 #include <unistd.h>
 
tools/libxc/xc_linux_build.c +0 -8
diff -r ad33b3882867 tools/libxc/xc_linux_build.c
@@ -5,14 +5,6 @@
 #include "xg_private.h"
 #include "xc_private.h"
 #include <xenctrl.h>
-
-#if defined(__i386__)
-#define ELFSIZE 32
-#endif
-
-#if defined(__x86_64__) || defined(__ia64__)
-#define ELFSIZE 64
-#endif
 
 #include "xc_elf.h"
 #include "xc_aout9.h"
tools/libxc/xc_load_elf.c +0 -8
diff -r ad33b3882867 tools/libxc/xc_load_elf.c
@@ -3,14 +3,6 @@
  */
 
 #include "xg_private.h"
-
-#if defined(__i386__)
-#define ELFSIZE 32
-#endif
-#if defined(__x86_64__) || defined(__ia64__)
-#define ELFSIZE 64
-#endif
-
 #include "xc_elf.h"
 #include <stdlib.h>
 
tools/misc/Makefile +1 -1
diff -r ad33b3882867 tools/misc/Makefile
@@ -25,7 +25,7 @@ build: $(TARGETS)
 build: $(TARGETS)
 	$(MAKE) -C miniterm
 	$(MAKE) -C cpuperf
-ifneq ($(XEN_TARGET_ARCH),ia64)
+ifeq ($(CONFIG_MBOOTPACK),y)
 	$(MAKE) -C mbootpack
 endif
 	$(MAKE) -C lomount
tools/python/xen/lowlevel/xc/xc.c +4 -0
diff -r ad33b3882867 tools/python/xen/lowlevel/xc/xc.c
@@ -359,6 +359,7 @@ static PyObject *pyxc_linux_build(XcObje
 			 "console_mfn", console_mfn);
 }
 
+#ifdef CONFIG_HVM
 static PyObject *pyxc_hvm_build(XcObject *self,
                                 PyObject *args,
                                 PyObject *kwds)
@@ -387,6 +388,7 @@ static PyObject *pyxc_hvm_build(XcObject
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
 }
+#endif
 
 static PyObject *pyxc_bvtsched_global_set(XcObject *self, PyObject *args)
 {
@@ -969,6 +971,7 @@ static PyMethodDef pyxc_methods[] = {
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+#ifdef CONFIG_HVM
     { "hvm_build", 
       (PyCFunction)pyxc_hvm_build, 
       METH_VARARGS | METH_KEYWORDS, "\n"
@@ -977,6 +980,7 @@ static PyMethodDef pyxc_methods[] = {
       " image   [str]:      Name of HVM loader image file.\n"
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
+#endif
 
     { "bvtsched_global_set",
       (PyCFunction)pyxc_bvtsched_global_set,
xen/tools/Makefile +2 -1
diff -r ad33b3882867 xen/tools/Makefile
@@ -1,5 +1,6 @@
 
-include $(BASEDIR)/../Config.mk
+XEN_ROOT = $(BASEDIR)/..
+include $(XEN_ROOT)/Config.mk
 
 .PHONY: default
 default:
xen/tools/figlet/Makefile +2 -1
diff -r ad33b3882867 xen/tools/figlet/Makefile
@@ -1,5 +1,6 @@
 
-include $(BASEDIR)/../Config.mk
+XEN_ROOT = $(BASEDIR)/..
+include $(XEN_ROOT)/Config.mk
 
 figlet: figlet.c
 	$(HOSTCC) -o $@ $<

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

#19 lore raw

Re: [XenPPC] [patch] [1/3] global build configuration file

(John pointed out I had missed an "hg add". This patch includes the missing config/*.mk files.)

Use a global build configuration file, and rework libxc Makefile to work on PowerPC.

Config.mk +1 -13
diff -r ad33b3882867 Config.mk
@@ -39,19 +39,7 @@ CFLAGS    += -g
 CFLAGS    += -g
 endif
 
-ifeq ($(XEN_TARGET_ARCH),x86_32)
-CFLAGS  += -m32 -march=i686
-endif
-
-ifeq ($(XEN_TARGET_ARCH),x86_64)
-CFLAGS  += -m64
-endif
-
-ifeq ($(XEN_TARGET_ARCH),x86_64)
-LIBDIR = lib64
-else
-LIBDIR = lib
-endif
+include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
extras/mini-os/Makefile +2 -1
diff -r ad33b3882867 extras/mini-os/Makefile
@@ -1,7 +1,8 @@ debug ?= y
 debug ?= y
 pae ?= n
 
-include $(CURDIR)/../../Config.mk
+XEN_ROOT = ../..
+include $(XEN_ROOT)/Config.mk
 
 # Set TARGET_ARCH
 override TARGET_ARCH     := $(XEN_TARGET_ARCH)
tools/Makefile +22 -23

75 lines not on this page · raw message

tools/Rules.mk +2 -0
diff -r ad33b3882867 tools/Rules.mk
@@ -4,6 +4,8 @@ all:
 all:
 
 include $(XEN_ROOT)/Config.mk
+
+CONFIG_$(shell uname -s) := y
 
 XEN_XC             = $(XEN_ROOT)/tools/python/xen/lowlevel/xc
 XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
tools/libxc/Makefile +30 -43

109 lines not on this page · raw message

tools/libxc/xc_core.c +0 -2
diff -r ad33b3882867 tools/libxc/xc_core.c
@@ -1,6 +1,4 @@
 #include "xg_private.h"
-#define ELFSIZE 32
-#include "xc_elf.h"
 #include <stdlib.h>
 #include <unistd.h>
 
tools/libxc/xc_linux_build.c +0 -8
diff -r ad33b3882867 tools/libxc/xc_linux_build.c
@@ -5,14 +5,6 @@
 #include "xg_private.h"
 #include "xc_private.h"
 #include <xenctrl.h>
-
-#if defined(__i386__)
-#define ELFSIZE 32
-#endif
-
-#if defined(__x86_64__) || defined(__ia64__)
-#define ELFSIZE 64
-#endif
 
 #include "xc_elf.h"
 #include "xc_aout9.h"
tools/libxc/xc_load_elf.c +0 -8
diff -r ad33b3882867 tools/libxc/xc_load_elf.c
@@ -3,14 +3,6 @@
  */
 
 #include "xg_private.h"
-
-#if defined(__i386__)
-#define ELFSIZE 32
-#endif
-#if defined(__x86_64__) || defined(__ia64__)
-#define ELFSIZE 64
-#endif
-
 #include "xc_elf.h"
 #include <stdlib.h>
 
tools/misc/Makefile +1 -1
diff -r ad33b3882867 tools/misc/Makefile
@@ -25,7 +25,7 @@ build: $(TARGETS)
 build: $(TARGETS)
 	$(MAKE) -C miniterm
 	$(MAKE) -C cpuperf
-ifneq ($(XEN_TARGET_ARCH),ia64)
+ifeq ($(CONFIG_MBOOTPACK),y)
 	$(MAKE) -C mbootpack
 endif
 	$(MAKE) -C lomount
tools/python/xen/lowlevel/xc/xc.c +4 -0
diff -r ad33b3882867 tools/python/xen/lowlevel/xc/xc.c
@@ -359,6 +359,7 @@ static PyObject *pyxc_linux_build(XcObje
 			 "console_mfn", console_mfn);
 }
 
+#ifdef CONFIG_HVM
 static PyObject *pyxc_hvm_build(XcObject *self,
                                 PyObject *args,
                                 PyObject *kwds)
@@ -387,6 +388,7 @@ static PyObject *pyxc_hvm_build(XcObject
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
 }
+#endif
 
 static PyObject *pyxc_bvtsched_global_set(XcObject *self, PyObject *args)
 {
@@ -969,6 +971,7 @@ static PyMethodDef pyxc_methods[] = {
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+#ifdef CONFIG_HVM
     { "hvm_build", 
       (PyCFunction)pyxc_hvm_build, 
       METH_VARARGS | METH_KEYWORDS, "\n"
@@ -977,6 +980,7 @@ static PyMethodDef pyxc_methods[] = {
       " image   [str]:      Name of HVM loader image file.\n"
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
+#endif
 
     { "bvtsched_global_set",
       (PyCFunction)pyxc_bvtsched_global_set,
xen/tools/Makefile +2 -1
diff -r ad33b3882867 xen/tools/Makefile
@@ -1,5 +1,6 @@
 
-include $(BASEDIR)/../Config.mk
+XEN_ROOT = $(BASEDIR)/..
+include $(XEN_ROOT)/Config.mk
 
 .PHONY: default
 default:
xen/tools/figlet/Makefile +2 -1
diff -r ad33b3882867 xen/tools/figlet/Makefile
@@ -1,5 +1,6 @@
 
-include $(BASEDIR)/../Config.mk
+XEN_ROOT = $(BASEDIR)/..
+include $(XEN_ROOT)/Config.mk
 
 figlet: figlet.c
 	$(HOSTCC) -o $@ $<
config/ia64.mk new file +5 -0
diff -r ad33b3882867 config/ia64.mk
@@ -0,0 +1,5 @@
+CONFIG_IA64 := y
+CONFIG_IOEMU := y
+
+CFLAGS += -DELFSIZE=64 -DCONFIG_HVM
+LIBDIR := lib
config/x86_32.mk new file +9 -0
diff -r ad33b3882867 config/x86_32.mk
@@ -0,0 +1,9 @@
+CONFIG_X86 := y
+CONFIG_PLAN9 := y
+CONFIG_HVM := y
+CONFIG_MIGRATE := y
+CONFIG_IOEMU := y
+CONFIG_MBOOTPACK := y
+
+CFLAGS += -m32 -march=i686 -DELFSIZE=32 -DCONFIG_HVM
+LIBDIR := lib
config/x86_64.mk new file +9 -0
diff -r ad33b3882867 config/x86_64.mk
@@ -0,0 +1,9 @@
+CONFIG_X86 := y
+CONFIG_PLAN9 := y
+CONFIG_HVM := y
+CONFIG_MIGRATE := y
+CONFIG_IOEMU := y
+CONFIG_MBOOTPACK := y
+
+CFLAGS += -m64 -DELFSIZE=64 -DCONFIG_HVM
+LIBDIR = lib64