direct-io.hg

changeset 5914:8c1944538086

Here is our latest patch to enable the Xen tools to
build and work with IA64 Xen.
Signed-off-by: Matt Chapman <matthewc@hp.com>
Acked-by: Dan Magenheimer <dan.magenheimer@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jul 29 10:34:45 2005 +0000 (2005-07-29)
parents 51094fae410e
children 52260d8c2775
files tools/libxc/Makefile tools/libxc/xc.h tools/libxc/xc_domain.c tools/libxc/xc_linux_build.c tools/libxc/xc_load_elf.c tools/libxc/xc_private.c tools/libxc/xc_private.h tools/misc/Makefile tools/python/xen/lowlevel/xc/xc.c tools/python/xen/lowlevel/xu/xu.c tools/python/xen/xend/XendCheckpoint.py tools/xcs/xcs.h
line diff
     1.1 --- a/tools/libxc/Makefile	Fri Jul 29 10:31:22 2005 +0000
     1.2 +++ b/tools/libxc/Makefile	Fri Jul 29 10:34:45 2005 +0000
     1.3 @@ -19,18 +19,22 @@ SRCS     += xc_core.c
     1.4  SRCS     += xc_domain.c
     1.5  SRCS     += xc_evtchn.c
     1.6  SRCS     += xc_gnttab.c
     1.7 -SRCS     += xc_load_aout9.c
     1.8  SRCS     += xc_load_bin.c
     1.9  SRCS     += xc_load_elf.c
    1.10  SRCS     += xc_linux_build.c
    1.11 -SRCS     += xc_linux_restore.c
    1.12 -SRCS     += xc_linux_save.c
    1.13  SRCS     += xc_misc.c
    1.14  SRCS     += xc_physdev.c
    1.15  SRCS     += xc_private.c
    1.16 +ifeq ($(XEN_TARGET_ARCH),ia64)
    1.17 +SRCS     += xc_ia64_stubs.c
    1.18 +else
    1.19 +SRCS     += xc_load_aout9.c
    1.20 +SRCS     += xc_linux_restore.c
    1.21 +SRCS     += xc_linux_save.c
    1.22 +SRCS     += xc_vmx_build.c
    1.23  SRCS     += xc_ptrace.c
    1.24  SRCS     += xc_ptrace_core.c
    1.25 -SRCS     += xc_vmx_build.c
    1.26 +endif
    1.27  
    1.28  CFLAGS   += -Wall
    1.29  CFLAGS   += -Werror
     2.1 --- a/tools/libxc/xc.h	Fri Jul 29 10:31:22 2005 +0000
     2.2 +++ b/tools/libxc/xc.h	Fri Jul 29 10:34:45 2005 +0000
     2.3 @@ -27,6 +27,14 @@ typedef int64_t            s64;
     2.4  #include <xen/sched_ctl.h>
     2.5  #include <xen/acm.h>
     2.6  
     2.7 +#ifdef __ia64__
     2.8 +#define XC_PAGE_SHIFT           14
     2.9 +#else
    2.10 +#define XC_PAGE_SHIFT           12
    2.11 +#endif
    2.12 +#define XC_PAGE_SIZE            (1UL << XC_PAGE_SHIFT)
    2.13 +#define XC_PAGE_MASK            (~(XC_PAGE_SIZE-1))
    2.14 +
    2.15  /*
    2.16   *  DEFINITIONS FOR CPU BARRIERS
    2.17   */ 
    2.18 @@ -39,6 +47,11 @@ typedef int64_t            s64;
    2.19  #define mb()  __asm__ __volatile__ ( "mfence" : : : "memory")
    2.20  #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
    2.21  #define wmb() __asm__ __volatile__ ( "" : : : "memory")
    2.22 +#elif defined(__ia64__)
    2.23 +/* FIXME */
    2.24 +#define mb()
    2.25 +#define rmb()
    2.26 +#define wmb()
    2.27  #else
    2.28  #error "Define barriers"
    2.29  #endif
    2.30 @@ -462,6 +475,9 @@ void *xc_map_foreign_batch(int xc_handle
    2.31  int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf, 
    2.32                      unsigned long max_pfns);
    2.33  
    2.34 +int xc_ia64_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf, 
    2.35 +                    unsigned int start_page, unsigned int nr_pages);
    2.36 +
    2.37  /*\
    2.38   *  GRANT TABLE FUNCTIONS
    2.39  \*/ 
     3.1 --- a/tools/libxc/xc_domain.c	Fri Jul 29 10:31:22 2005 +0000
     3.2 +++ b/tools/libxc/xc_domain.c	Fri Jul 29 10:34:45 2005 +0000
     3.3 @@ -264,10 +264,11 @@ int xc_domain_memory_increase_reservatio
     3.4                                            unsigned int mem_kb)
     3.5  {
     3.6      int err;
     3.7 +    unsigned int npages = mem_kb / (PAGE_SIZE/1024);
     3.8  
     3.9      err = do_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL,
    3.10 -                        mem_kb / 4, 0, domid);
    3.11 -    if (err == mem_kb / 4)
    3.12 +                        npages, 0, domid);
    3.13 +    if (err == npages)
    3.14          return 0;
    3.15  
    3.16      if (err > 0) {
     4.1 --- a/tools/libxc/xc_linux_build.c	Fri Jul 29 10:31:22 2005 +0000
     4.2 +++ b/tools/libxc/xc_linux_build.c	Fri Jul 29 10:34:45 2005 +0000
     4.3 @@ -8,7 +8,7 @@
     4.4  #define ELFSIZE 32
     4.5  #endif
     4.6  
     4.7 -#if defined(__x86_64__)
     4.8 +#if defined(__x86_64__) || defined(__ia64__)
     4.9  #define ELFSIZE 64
    4.10  #endif
    4.11  
    4.12 @@ -35,6 +35,10 @@
    4.13  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    4.14  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    4.15  
    4.16 +#ifdef __ia64__
    4.17 +#define probe_aout9(image,image_size,load_funcs) 1
    4.18 +#endif
    4.19 +
    4.20  static int probeimageformat(char *image,
    4.21                              unsigned long image_size,
    4.22                              struct load_funcs *load_funcs)
    4.23 @@ -258,6 +262,67 @@ static int setup_pg_tables_64(int xc_han
    4.24  }
    4.25  #endif
    4.26  
    4.27 +#ifdef __ia64__
    4.28 +#include <asm/fpu.h> /* for FPSR_DEFAULT */
    4.29 +static int setup_guest(int xc_handle,
    4.30 +                         u32 dom,
    4.31 +                         char *image, unsigned long image_size,
    4.32 +                         gzFile initrd_gfd, unsigned long initrd_len,
    4.33 +                         unsigned long nr_pages,
    4.34 +                         unsigned long *pvsi, unsigned long *pvke,
    4.35 +                         unsigned long *pvss, vcpu_guest_context_t *ctxt,
    4.36 +                         const char *cmdline,
    4.37 +                         unsigned long shared_info_frame,
    4.38 +                         unsigned int control_evtchn,
    4.39 +                         unsigned long flags,
    4.40 +                         unsigned int vcpus,
    4.41 +                         unsigned int store_evtchn, unsigned long *store_mfn)
    4.42 +{
    4.43 +    unsigned long *page_array = NULL;
    4.44 +    struct load_funcs load_funcs;
    4.45 +    struct domain_setup_info dsi;
    4.46 +    unsigned long start_page;
    4.47 +    int rc;
    4.48 +
    4.49 +    rc = probeimageformat(image, image_size, &load_funcs);
    4.50 +    if ( rc != 0 )
    4.51 +        goto error_out;
    4.52 +
    4.53 +    memset(&dsi, 0, sizeof(struct domain_setup_info));
    4.54 +
    4.55 +    rc = (load_funcs.parseimage)(image, image_size, &dsi);
    4.56 +    if ( rc != 0 )
    4.57 +        goto error_out;
    4.58 +
    4.59 +    dsi.v_start = round_pgdown(dsi.v_start);
    4.60 +    dsi.v_end   = round_pgup(dsi.v_end);
    4.61 +
    4.62 +    start_page = dsi.v_start >> PAGE_SHIFT;
    4.63 +    nr_pages = (dsi.v_end - dsi.v_start) >> PAGE_SHIFT;
    4.64 +    if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
    4.65 +    {
    4.66 +        PERROR("Could not allocate memory");
    4.67 +        goto error_out;
    4.68 +    }
    4.69 +
    4.70 +    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array, start_page, nr_pages) != nr_pages )
    4.71 +    {
    4.72 +        PERROR("Could not get the page frame list");
    4.73 +        goto error_out;
    4.74 +    }
    4.75 +
    4.76 +    (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
    4.77 +                           &dsi);
    4.78 +
    4.79 +    *pvke = dsi.v_kernentry;
    4.80 +    return 0;
    4.81 +
    4.82 + error_out:
    4.83 +    if ( page_array != NULL )
    4.84 +        free(page_array);
    4.85 +    return -1;
    4.86 +}
    4.87 +#else /* x86 */
    4.88  static int setup_guest(int xc_handle,
    4.89                         u32 dom,
    4.90                         char *image, unsigned long image_size,
    4.91 @@ -557,6 +622,7 @@ static int setup_guest(int xc_handle,
    4.92          free(page_array);
    4.93      return -1;
    4.94  }
    4.95 +#endif
    4.96  
    4.97  int xc_linux_build(int xc_handle,
    4.98                     u32 domid,
    4.99 @@ -627,7 +693,11 @@ int xc_linux_build(int xc_handle,
   4.100      }
   4.101  
   4.102      if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
   4.103 +#ifdef __ia64__
   4.104 +	0 )
   4.105 +#else
   4.106           (ctxt->ctrlreg[3] != 0) )
   4.107 +#endif
   4.108      {
   4.109          ERROR("Domain is already constructed");
   4.110          goto error_out;
   4.111 @@ -652,6 +722,18 @@ int xc_linux_build(int xc_handle,
   4.112      if ( image != NULL )
   4.113          free(image);
   4.114  
   4.115 +#ifdef __ia64__
   4.116 +    /* based on new_thread in xen/arch/ia64/domain.c */
   4.117 +    ctxt->regs.cr_ipsr = 0; /* all necessary bits filled by hypervisor */
   4.118 +    ctxt->regs.cr_iip = vkern_entry;
   4.119 +    ctxt->regs.cr_ifs = 1UL << 63;
   4.120 +    ctxt->regs.ar_fpsr = FPSR_DEFAULT;
   4.121 +    /* ctxt->regs.r28 = dom_fw_setup(); currently done by hypervisor, should move here */
   4.122 +    ctxt->vcpu.privregs = 0;
   4.123 +    ctxt->shared.domain_controller_evtchn = control_evtchn;
   4.124 +    ctxt->shared.flags = flags;
   4.125 +    i = 0; /* silence unused variable warning */
   4.126 +#else /* x86 */
   4.127      /*
   4.128       * Initial register values:
   4.129       *  DS,ES,FS,GS = FLAT_KERNEL_DS
   4.130 @@ -706,6 +788,7 @@ int xc_linux_build(int xc_handle,
   4.131      ctxt->failsafe_callback_eip = 0;
   4.132      ctxt->syscall_callback_eip  = 0;
   4.133  #endif
   4.134 +#endif /* x86 */
   4.135  
   4.136      memset( &launch_op, 0, sizeof(launch_op) );
   4.137  
     5.1 --- a/tools/libxc/xc_load_elf.c	Fri Jul 29 10:31:22 2005 +0000
     5.2 +++ b/tools/libxc/xc_load_elf.c	Fri Jul 29 10:34:45 2005 +0000
     5.3 @@ -7,7 +7,7 @@
     5.4  #if defined(__i386__)
     5.5  #define ELFSIZE 32
     5.6  #endif
     5.7 -#if defined(__x86_64__)
     5.8 +#if defined(__x86_64__) || defined(__ia64__)
     5.9  #define ELFSIZE 64
    5.10  #endif
    5.11  
    5.12 @@ -122,8 +122,12 @@ static int parseelfimage(char *image,
    5.13      }
    5.14      if ( guestinfo == NULL )
    5.15      {
    5.16 +#ifdef __ia64__
    5.17 +        guestinfo = "";
    5.18 +#else
    5.19          ERROR("Not a Xen-ELF image: '__xen_guest' section not found.");
    5.20          return -EINVAL;
    5.21 +#endif
    5.22      }
    5.23  
    5.24      for ( h = 0; h < ehdr->e_phnum; h++ ) 
     6.1 --- a/tools/libxc/xc_private.c	Fri Jul 29 10:31:22 2005 +0000
     6.2 +++ b/tools/libxc/xc_private.c	Fri Jul 29 10:34:45 2005 +0000
     6.3 @@ -256,6 +256,37 @@ int xc_get_pfn_list(int xc_handle,
     6.4      return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
     6.5  }
     6.6  
     6.7 +#ifdef __ia64__
     6.8 +int xc_ia64_get_pfn_list(int xc_handle,
     6.9 +		 u32 domid, 
    6.10 +		 unsigned long *pfn_buf, 
    6.11 +		 unsigned int start_page,
    6.12 +		 unsigned int nr_pages)
    6.13 +{
    6.14 +    dom0_op_t op;
    6.15 +    int ret;
    6.16 +
    6.17 +    op.cmd = DOM0_GETMEMLIST;
    6.18 +    op.u.getmemlist.domain   = (domid_t)domid;
    6.19 +    op.u.getmemlist.max_pfns = ((unsigned long)start_page << 32) | nr_pages;
    6.20 +    op.u.getmemlist.buffer   = pfn_buf;
    6.21 +
    6.22 +    if ( mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
    6.23 +    {
    6.24 +        PERROR("Could not lock pfn list buffer");
    6.25 +        return -1;
    6.26 +    }    
    6.27 +
    6.28 +    /* XXX Hack to put pages in TLB, hypervisor should be able to handle this */
    6.29 +    memset(pfn_buf, 0, nr_pages * sizeof(unsigned long));
    6.30 +    ret = do_dom0_op(xc_handle, &op);
    6.31 +
    6.32 +    (void)munlock(pfn_buf, nr_pages * sizeof(unsigned long));
    6.33 +
    6.34 +    return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
    6.35 +}
    6.36 +#endif
    6.37 +
    6.38  long xc_get_tot_pages(int xc_handle, u32 domid)
    6.39  {
    6.40      dom0_op_t op;
     7.1 --- a/tools/libxc/xc_private.h	Fri Jul 29 10:31:22 2005 +0000
     7.2 +++ b/tools/libxc/xc_private.h	Fri Jul 29 10:34:45 2005 +0000
     7.3 @@ -55,7 +55,7 @@
     7.4  #define L4_PAGETABLE_ENTRIES    512
     7.5  #endif
     7.6   
     7.7 -#define PAGE_SHIFT              L1_PAGETABLE_SHIFT
     7.8 +#define PAGE_SHIFT              XC_PAGE_SHIFT
     7.9  #define PAGE_SIZE               (1UL << PAGE_SHIFT)
    7.10  #define PAGE_MASK               (~(PAGE_SIZE-1))
    7.11  
     8.1 --- a/tools/misc/Makefile	Fri Jul 29 10:31:22 2005 +0000
     8.2 +++ b/tools/misc/Makefile	Fri Jul 29 10:34:45 2005 +0000
     8.3 @@ -22,7 +22,9 @@ all: build
     8.4  build: $(TARGETS)
     8.5  	$(MAKE) -C miniterm
     8.6  	$(MAKE) -C cpuperf
     8.7 +ifneq ($(XEN_TARGET_ARCH),ia64)
     8.8  	$(MAKE) -C mbootpack
     8.9 +endif
    8.10  	$(MAKE) -C lomount
    8.11  
    8.12  install: build
     9.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 29 10:31:22 2005 +0000
     9.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 29 10:34:45 2005 +0000
     9.3 @@ -242,7 +242,7 @@ static PyObject *pyxc_domain_getinfo(PyO
     9.4                                    "paused",    info[i].paused,
     9.5                                    "blocked",   info[i].blocked,
     9.6                                    "running",   info[i].running,
     9.7 -                                  "mem_kb",    info[i].nr_pages*4,
     9.8 +                                  "mem_kb",    info[i].nr_pages*(XC_PAGE_SIZE/1024),
     9.9                                    "cpu_time",  info[i].cpu_time,
    9.10                                    "maxmem_kb", info[i].max_memkb,
    9.11                                    "ssidref",   info[i].ssidref,
    10.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Fri Jul 29 10:31:22 2005 +0000
    10.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Fri Jul 29 10:34:45 2005 +0000
    10.3 @@ -46,9 +46,6 @@
    10.4  /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
    10.5  #define EVTCHN_UNBIND _IO('E', 3)
    10.6  
    10.7 -/* Size of a machine page frame. */
    10.8 -#define PAGE_SIZE 4096
    10.9 -
   10.10  /* Set the close-on-exec flag on a file descriptor.  Doesn't currently bother
   10.11   * to check for errors. */
   10.12  /*
    11.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Fri Jul 29 10:31:22 2005 +0000
    11.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Fri Jul 29 10:34:45 2005 +0000
    11.3 @@ -17,7 +17,6 @@ from XendError import XendError
    11.4  from XendLogging import log
    11.5  
    11.6  SIGNATURE = "LinuxGuestRecord"
    11.7 -PAGE_SIZE = 4096
    11.8  PATH_XC_SAVE = "/usr/libexec/xen/xc_save"
    11.9  PATH_XC_RESTORE = "/usr/libexec/xen/xc_restore"
   11.10  
    12.1 --- a/tools/xcs/xcs.h	Fri Jul 29 10:31:22 2005 +0000
    12.2 +++ b/tools/xcs/xcs.h	Fri Jul 29 10:34:45 2005 +0000
    12.3 @@ -37,7 +37,7 @@
    12.4  /* ------[ Other required defines ]----------------------------------------*/
    12.5  
    12.6  /* Size of a machine page frame. */
    12.7 -#define PAGE_SIZE 4096
    12.8 +#define PAGE_SIZE XC_PAGE_SIZE
    12.9  
   12.10  #ifndef timersub /* XOPEN and __BSD don't cooperate well... */
   12.11  #define timersub(a, b, result)                                                \