Skip to contentSkip to conversation

libxc x86-64 enablement

PATCH New Jerone Young 1 participant 1 message Mar 21, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc x86-64 enablement

Here is some of the preliminary work for libxc to work and compile properly under x86-64 .

libxc_x64_makefile_patch[1].diff:
First, I've set files such as xc_ptrace,xc_plan9_build,xc_vmx_build, & xc_linux_build to build only for x86_32. As we enable these to work will add we should add them back. Now everyone may not agree with my changes, but this can be resolved through discussion. I do wonder what tools ia64 guys are using...because it can't be these...can it ?

libxc_x64_xc_private_patch[2].diff:
Adds need definitions for x86-64.

libxc_x64_xc_linux_build_x64_patch[3].diff:
I've added a new file xc_linux_build_x64.c. I did this with the future in mind of supporting both 32bit and 64bit domains. Currently we will only support 64bit domains. So this file will have the xc_linux_build function for x86-64. Once 32bit domain support is added then we will rename the function to xc_linux_build_x64 or something else that distinguishes it as our x86-64 build linux function, and xc_linux_build would be our 32bit build function (located in xc_linux_build.c).

Don't know if anything works yet, but once all the code is in place and working I'll be able to kick out any bugs. I also don't know if I am zeroing out the 4 level page table correctly. So as you can see from the comments..I'm not sure about that work.

Signature · 4 lines
Jerone Young
IBM Linux Technology Center
[email protected]
512-838-1157 (T/L: 678-1157)
tools/libxc/Makefile +9 -3
@@ -22,16 +22,22 @@ SRCS     += xc_domain.c
 SRCS     += xc_evtchn.c
 SRCS     += xc_gnttab.c
 SRCS     += xc_io.c
-SRCS     += xc_linux_build.c
-SRCS     += xc_plan9_build.c
 SRCS     += xc_linux_restore.c
 SRCS     += xc_linux_save.c
 SRCS     += xc_misc.c
 SRCS     += xc_physdev.c
 SRCS     += xc_private.c
-SRCS     += xc_ptrace.c
 SRCS     += xc_rrobin.c
+ifeq ($(XEN_TARGET_ARCH),x86_32)
+SRC 	  += xc_linux_build.c
+SRCS     += xc_plan9_build.c
 SRCS     += xc_vmx_build.c
+SRCS     += xc_ptrace.c
+endif
+ifeq ($(XEN_TARGET_ARCH),x86_64)
+SRCS	  += xc_linux_build_x64.c
+endif
+
 
 CFLAGS   += -Wall
 CFLAGS   += -Werror
tools/libxc/xc_linux_build_x64.c +795 -0

795 lines not on this page · raw message

tools/libxc/xc_private.h +30 -2
@@ -29,12 +29,25 @@
 #define _PAGE_PSE       0x080
 #define _PAGE_GLOBAL    0x100
 
-
+#if defined(__i386__)
 #define L1_PAGETABLE_SHIFT       12
 #define L2_PAGETABLE_SHIFT       22
- 
+#elif defined(__x86_64__)
+#define L1_PAGETABLE_SHIFT      12
+#define L2_PAGETABLE_SHIFT      21
+#define L3_PAGETABLE_SHIFT      30
+#define L4_PAGETABLE_SHIFT      39
+#endif
+
+#if defined(__i386__) 
 #define ENTRIES_PER_L1_PAGETABLE 1024
 #define ENTRIES_PER_L2_PAGETABLE 1024
+#elif defined(__x86_64__)
+#define L1_PAGETABLE_ENTRIES    512
+#define L2_PAGETABLE_ENTRIES    512
+#define L3_PAGETABLE_ENTRIES    512
+#define L4_PAGETABLE_ENTRIES    512
+#endif
  
 #define PAGE_SHIFT              L1_PAGETABLE_SHIFT
 #define PAGE_SIZE               (1UL << PAGE_SHIFT)
@@ -42,11 +55,26 @@
 
 typedef unsigned long l1_pgentry_t;
 typedef unsigned long l2_pgentry_t;
+#if defined(__x86_64__)
+typedef unsigned long l3_pgentry_t;
+typedef unsigned long l4_pgentry_t;
+#endif
 
+#if defined(__i386__)
 #define l1_table_offset(_a) \
           (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
 #define l2_table_offset(_a) \
           ((_a) >> L2_PAGETABLE_SHIFT)
+#elif defined(__x86_64__)
+#define l1_table_offset(_a) \
+  (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
+#define l2_table_offset(_a) \
+  (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
+#define l3_table_offset(_a) \
+	(((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
+#define l4_table_offset(_a) \
+	(((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
+#endif
 
 #define ERROR(_m, _a...)  \
     fprintf(stderr, "ERROR: " _m "\n" , ## _a )