ia64/xen-unstable

changeset 16201:2ad8550033cb

merge with xen-unstable.hg (staging)
author Alex Williamson <alex.williamson@hp.com>
date Tue Oct 23 11:27:56 2007 -0600 (2007-10-23)
parents f9772037c2e7 6a9b1626c82a
children c05ec22a9106
files
line diff
     1.1 --- a/tools/ioemu/hw/cirrus_vga.c	Tue Oct 23 10:21:31 2007 -0600
     1.2 +++ b/tools/ioemu/hw/cirrus_vga.c	Tue Oct 23 11:27:56 2007 -0600
     1.3 @@ -2565,6 +2565,12 @@ static void *set_vram_mapping(unsigned l
     1.4          return NULL;
     1.5      }
     1.6  
     1.7 +    (void)xc_domain_pin_memory_cacheattr(
     1.8 +        xc_handle, domid,
     1.9 +        begin >> TARGET_PAGE_BITS,
    1.10 +        end >> TARGET_PAGE_BITS,
    1.11 +        XEN_DOMCTL_MEM_CACHEATTR_WB);
    1.12 +
    1.13      vram_pointer = xc_map_foreign_pages(xc_handle, domid,
    1.14                                          PROT_READ|PROT_WRITE,
    1.15                                          extent_start, nr_extents);
     2.1 --- a/tools/libxc/xc_dom_boot.c	Tue Oct 23 10:21:31 2007 -0600
     2.2 +++ b/tools/libxc/xc_dom_boot.c	Tue Oct 23 11:27:56 2007 -0600
     2.3 @@ -92,7 +92,9 @@ int xc_dom_compat_check(struct xc_dom_im
     2.4      char *item, *ptr;
     2.5      int match, found = 0;
     2.6  
     2.7 -    strcpy(xen_caps, dom->xen_caps);
     2.8 +    strncpy(xen_caps, dom->xen_caps, XEN_CAPABILITIES_INFO_LEN - 1);
     2.9 +    xen_caps[XEN_CAPABILITIES_INFO_LEN - 1] = '\0';
    2.10 +
    2.11      for ( item = strtok_r(xen_caps, " ", &ptr);
    2.12            item != NULL ; item = strtok_r(NULL, " ", &ptr) )
    2.13      {
     3.1 --- a/tools/libxc/xc_domain.c	Tue Oct 23 10:21:31 2007 -0600
     3.2 +++ b/tools/libxc/xc_domain.c	Tue Oct 23 11:27:56 2007 -0600
     3.3 @@ -376,6 +376,21 @@ int xc_domain_setmaxmem(int xc_handle,
     3.4      return do_domctl(xc_handle, &domctl);
     3.5  }
     3.6  
     3.7 +int xc_domain_pin_memory_cacheattr(int xc_handle,
     3.8 +                                   uint32_t domid,
     3.9 +                                   unsigned long start,
    3.10 +                                   unsigned long end,
    3.11 +                                   unsigned int type)
    3.12 +{
    3.13 +    DECLARE_DOMCTL;
    3.14 +    domctl.cmd = XEN_DOMCTL_pin_mem_cacheattr;
    3.15 +    domctl.domain = (domid_t)domid;
    3.16 +    domctl.u.pin_mem_cacheattr.start = start;
    3.17 +    domctl.u.pin_mem_cacheattr.end = end;
    3.18 +    domctl.u.pin_mem_cacheattr.type = type;
    3.19 +    return do_domctl(xc_handle, &domctl);
    3.20 +}
    3.21 +
    3.22  #if defined(__i386__) || defined(__x86_64__)
    3.23  #include "xc_e820.h"
    3.24  int xc_domain_set_memmap_limit(int xc_handle,
     4.1 --- a/tools/libxc/xenctrl.h	Tue Oct 23 10:21:31 2007 -0600
     4.2 +++ b/tools/libxc/xenctrl.h	Tue Oct 23 11:27:56 2007 -0600
     4.3 @@ -614,6 +614,12 @@ int xc_domain_iomem_permission(int xc_ha
     4.4                                 unsigned long nr_mfns,
     4.5                                 uint8_t allow_access);
     4.6  
     4.7 +int xc_domain_pin_memory_cacheattr(int xc_handle,
     4.8 +                                   uint32_t domid,
     4.9 +                                   unsigned long start,
    4.10 +                                   unsigned long end,
    4.11 +                                   unsigned int type);
    4.12 +
    4.13  unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
    4.14                                      unsigned long mfn);
    4.15  
     5.1 --- a/tools/xenmon/xenbaked.c	Tue Oct 23 10:21:31 2007 -0600
     5.2 +++ b/tools/xenmon/xenbaked.c	Tue Oct 23 11:27:56 2007 -0600
     5.3 @@ -589,7 +589,7 @@ error_t cmd_parser(int key, char *arg, s
     5.4      return 0;
     5.5  }
     5.6  
     5.7 -#define SHARED_MEM_FILE "/tmp/xenq-shm"
     5.8 +#define SHARED_MEM_FILE "/var/run/xenq-shm"
     5.9  void alloc_qos_data(int ncpu)
    5.10  {
    5.11      int i, n, pgsize, off=0;
     6.1 --- a/tools/xenmon/xenmon.py	Tue Oct 23 10:21:31 2007 -0600
     6.2 +++ b/tools/xenmon/xenmon.py	Tue Oct 23 11:27:56 2007 -0600
     6.3 @@ -46,7 +46,7 @@ ST_QDATA = "%dQ" % (6*NDOMAINS + 4)
     6.4  QOS_DATA_SIZE = struct.calcsize(ST_QDATA)*NSAMPLES + struct.calcsize(ST_DOM_INFO)*NDOMAINS + struct.calcsize("4i")
     6.5  
     6.6  # location of mmaped file, hard coded right now
     6.7 -SHM_FILE = "/tmp/xenq-shm"
     6.8 +SHM_FILE = "/var/run/xenq-shm"
     6.9  
    6.10  # format strings
    6.11  TOTALS = 15*' ' + "%6.2f%%" + 35*' ' + "%6.2f%%"
     7.1 --- a/tools/xenstat/xentop/xentop.c	Tue Oct 23 10:21:31 2007 -0600
     7.2 +++ b/tools/xenstat/xentop/xentop.c	Tue Oct 23 11:27:56 2007 -0600
     7.3 @@ -758,7 +758,7 @@ void do_summary(void)
     7.4  
     7.5  	/* Print program name, current time, and number of domains */
     7.6  	strftime(time_str, TIME_STR_LEN, TIME_STR_FORMAT,
     7.7 -	         localtime(&curtime.tv_sec));
     7.8 +	         localtime((const time_t *)&curtime.tv_sec));
     7.9  	num_domains = xenstat_node_num_domains(cur_node);
    7.10  	ver_str = xenstat_node_xen_version(cur_node);
    7.11  	print("xentop - %s   Xen %s\n", time_str, ver_str);
     8.1 --- a/xen/arch/x86/boot/head.S	Tue Oct 23 10:21:31 2007 -0600
     8.2 +++ b/xen/arch/x86/boot/head.S	Tue Oct 23 11:27:56 2007 -0600
     8.3 @@ -167,7 +167,7 @@ 1:      stosl   /* low mappings cover up
     8.4          mov     $trampoline_end - trampoline_start,%ecx
     8.5          rep     movsb
     8.6  
     8.7 -        mov     $0x98000,%esp
     8.8 +        mov     $0x90000,%esp
     8.9          call    cmdline_parse_early
    8.10  
    8.11          /* Jump into the relocated trampoline. */
     9.1 --- a/xen/arch/x86/boot/trampoline.S	Tue Oct 23 10:21:31 2007 -0600
     9.2 +++ b/xen/arch/x86/boot/trampoline.S	Tue Oct 23 11:27:56 2007 -0600
     9.3 @@ -22,7 +22,6 @@ trampoline_realmode_entry:
     9.4  idt_48: .word   0, 0, 0 # base = limit = 0
     9.5  gdt_48: .word   6*8-1
     9.6          .long   bootsym_phys(trampoline_gdt)
     9.7 -        .align  8
     9.8  trampoline_gdt:
     9.9          /* 0x0000: unused */
    9.10          .quad   0x0000000000000000
    10.1 --- a/xen/arch/x86/boot/video.S	Tue Oct 23 10:21:31 2007 -0600
    10.2 +++ b/xen/arch/x86/boot/video.S	Tue Oct 23 11:27:56 2007 -0600
    10.3 @@ -15,10 +15,10 @@
    10.4  
    10.5  #include "video.h"
    10.6  
    10.7 -/* Scratch space layout. */
    10.8 -#define modelist       (0x3000)
    10.9 -#define vesa_glob_info (modelist + 1024)
   10.10 -#define vesa_mode_info (vesa_glob_info + 1024)
   10.11 +/* Scratch space layout: +0x3000 to +0x4000. */
   10.12 +#define modelist       (0x3000)                  /* 2kB (256 entries) */
   10.13 +#define vesa_glob_info (modelist + 0x800)        /* 1kB */
   10.14 +#define vesa_mode_info (vesa_glob_info + 0x400)  /* 1kB */
   10.15  
   10.16  /* Retrieve Extended Display Identification Data. */
   10.17  #define CONFIG_FIRMWARE_EDID
    11.1 --- a/xen/arch/x86/domctl.c	Tue Oct 23 10:21:31 2007 -0600
    11.2 +++ b/xen/arch/x86/domctl.c	Tue Oct 23 11:27:56 2007 -0600
    11.3 @@ -23,6 +23,7 @@
    11.4  #include <asm/irq.h>
    11.5  #include <asm/hvm/hvm.h>
    11.6  #include <asm/hvm/support.h>
    11.7 +#include <asm/hvm/cacheattr.h>
    11.8  #include <asm/processor.h>
    11.9  #include <xsm/xsm.h>
   11.10  #include <xen/list.h>
   11.11 @@ -678,6 +679,24 @@ long arch_do_domctl(
   11.12      }
   11.13      break;    
   11.14  
   11.15 +    case XEN_DOMCTL_pin_mem_cacheattr:
   11.16 +    {
   11.17 +        struct domain *d;
   11.18 +
   11.19 +        ret = -ESRCH;
   11.20 +        d = rcu_lock_domain_by_id(domctl->domain);
   11.21 +        if ( d == NULL )
   11.22 +            break;
   11.23 +
   11.24 +        ret = hvm_set_mem_pinned_cacheattr(
   11.25 +            d, domctl->u.pin_mem_cacheattr.start,
   11.26 +            domctl->u.pin_mem_cacheattr.end,
   11.27 +            domctl->u.pin_mem_cacheattr.type);
   11.28 +
   11.29 +        rcu_unlock_domain(d);
   11.30 +    }
   11.31 +    break;
   11.32 +
   11.33      default:
   11.34          ret = -ENOSYS;
   11.35          break;
    12.1 --- a/xen/arch/x86/hvm/hvm.c	Tue Oct 23 10:21:31 2007 -0600
    12.2 +++ b/xen/arch/x86/hvm/hvm.c	Tue Oct 23 11:27:56 2007 -0600
    12.3 @@ -44,6 +44,7 @@
    12.4  #include <asm/hvm/hvm.h>
    12.5  #include <asm/hvm/vpt.h>
    12.6  #include <asm/hvm/support.h>
    12.7 +#include <asm/hvm/cacheattr.h>
    12.8  #include <public/sched.h>
    12.9  #include <public/hvm/ioreq.h>
   12.10  #include <public/version.h>
   12.11 @@ -228,20 +229,32 @@ int hvm_domain_initialise(struct domain 
   12.12      spin_lock_init(&d->arch.hvm_domain.irq_lock);
   12.13      spin_lock_init(&d->arch.hvm_domain.uc_lock);
   12.14  
   12.15 +    hvm_init_cacheattr_region_list(d);
   12.16 +
   12.17      rc = paging_enable(d, PG_refcounts|PG_translate|PG_external);
   12.18      if ( rc != 0 )
   12.19 -        return rc;
   12.20 +        goto fail1;
   12.21  
   12.22      vpic_init(d);
   12.23  
   12.24      rc = vioapic_init(d);
   12.25      if ( rc != 0 )
   12.26 -        return rc;
   12.27 +        goto fail1;
   12.28  
   12.29      hvm_init_ioreq_page(d, &d->arch.hvm_domain.ioreq);
   12.30      hvm_init_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq);
   12.31  
   12.32 -    return hvm_funcs.domain_initialise(d);
   12.33 +    rc = hvm_funcs.domain_initialise(d);
   12.34 +    if ( rc != 0 )
   12.35 +        goto fail2;
   12.36 +
   12.37 +    return 0;
   12.38 +
   12.39 + fail2:
   12.40 +    vioapic_deinit(d);
   12.41 + fail1:
   12.42 +    hvm_destroy_cacheattr_region_list(d);
   12.43 +    return rc;
   12.44  }
   12.45  
   12.46  void hvm_domain_relinquish_resources(struct domain *d)
   12.47 @@ -259,6 +272,7 @@ void hvm_domain_destroy(struct domain *d
   12.48  {
   12.49      hvm_funcs.domain_destroy(d);
   12.50      vioapic_deinit(d);
   12.51 +    hvm_destroy_cacheattr_region_list(d);
   12.52  }
   12.53  
   12.54  static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
    13.1 --- a/xen/arch/x86/hvm/mtrr.c	Tue Oct 23 10:21:31 2007 -0600
    13.2 +++ b/xen/arch/x86/hvm/mtrr.c	Tue Oct 23 11:27:56 2007 -0600
    13.3 @@ -26,6 +26,7 @@
    13.4  #include <stdbool.h>
    13.5  #include <asm/mtrr.h>
    13.6  #include <asm/hvm/support.h>
    13.7 +#include <asm/hvm/cacheattr.h>
    13.8  
    13.9  /* Xen holds the native MTRR MSRs */
   13.10  extern struct mtrr_state mtrr_state;
   13.11 @@ -685,3 +686,83 @@ bool_t mtrr_pat_not_equal(struct vcpu *v
   13.12  
   13.13      return 0;
   13.14  }
   13.15 +
   13.16 +void hvm_init_cacheattr_region_list(
   13.17 +    struct domain *d)
   13.18 +{
   13.19 +    INIT_LIST_HEAD(&d->arch.hvm_domain.pinned_cacheattr_ranges);
   13.20 +}
   13.21 +
   13.22 +void hvm_destroy_cacheattr_region_list(
   13.23 +    struct domain *d)
   13.24 +{
   13.25 +    struct list_head *head = &d->arch.hvm_domain.pinned_cacheattr_ranges;
   13.26 +    struct hvm_mem_pinned_cacheattr_range *range;
   13.27 +
   13.28 +    while ( !list_empty(head) )
   13.29 +    {
   13.30 +        range = list_entry(head->next,
   13.31 +                           struct hvm_mem_pinned_cacheattr_range,
   13.32 +                           list);
   13.33 +        list_del(&range->list);
   13.34 +        xfree(range);
   13.35 +    }
   13.36 +}
   13.37 +
   13.38 +int hvm_get_mem_pinned_cacheattr(
   13.39 +    struct domain *d,
   13.40 +    unsigned long guest_fn,
   13.41 +    unsigned int *type)
   13.42 +{
   13.43 +    struct hvm_mem_pinned_cacheattr_range *range;
   13.44 +
   13.45 +    *type = 0;
   13.46 +
   13.47 +    if ( !is_hvm_domain(d) )
   13.48 +        return 0;
   13.49 +
   13.50 +    list_for_each_entry_rcu ( range,
   13.51 +                              &d->arch.hvm_domain.pinned_cacheattr_ranges,
   13.52 +                              list )
   13.53 +    {
   13.54 +        if ( (guest_fn >= range->start) && (guest_fn <= range->end) )
   13.55 +        {
   13.56 +            *type = range->type;
   13.57 +            return 1;
   13.58 +        }
   13.59 +    }
   13.60 +
   13.61 +    return 0;
   13.62 +}
   13.63 +
   13.64 +int hvm_set_mem_pinned_cacheattr(
   13.65 +    struct domain *d,
   13.66 +    unsigned long gfn_start,
   13.67 +    unsigned long gfn_end,
   13.68 +    unsigned int  type)
   13.69 +{
   13.70 +    struct hvm_mem_pinned_cacheattr_range *range;
   13.71 +
   13.72 +    if ( !((type == PAT_TYPE_UNCACHABLE) ||
   13.73 +           (type == PAT_TYPE_WRCOMB) ||
   13.74 +           (type == PAT_TYPE_WRTHROUGH) ||
   13.75 +           (type == PAT_TYPE_WRPROT) ||
   13.76 +           (type == PAT_TYPE_WRBACK) ||
   13.77 +           (type == PAT_TYPE_UC_MINUS)) ||
   13.78 +         !is_hvm_domain(d) )
   13.79 +        return -EINVAL;
   13.80 +
   13.81 +    range = xmalloc(struct hvm_mem_pinned_cacheattr_range);
   13.82 +    if ( range == NULL )
   13.83 +        return -ENOMEM;
   13.84 +
   13.85 +    memset(range, 0, sizeof(*range));
   13.86 +
   13.87 +    range->start = gfn_start;
   13.88 +    range->end = gfn_end;
   13.89 +    range->type = type;
   13.90 +
   13.91 +    list_add_rcu(&range->list, &d->arch.hvm_domain.pinned_cacheattr_ranges);
   13.92 +
   13.93 +    return 0;
   13.94 +}
    14.1 --- a/xen/arch/x86/hvm/vmx/vtd/utils.c	Tue Oct 23 10:21:31 2007 -0600
    14.2 +++ b/xen/arch/x86/hvm/vmx/vtd/utils.c	Tue Oct 23 11:27:56 2007 -0600
    14.3 @@ -64,24 +64,28 @@ int vtd_hw_check(void)
    14.4      return 0;
    14.5  }
    14.6  
    14.7 -/* disable vt-d protected memory registers */
    14.8 +/* Disable vt-d protected memory registers. */
    14.9  void disable_pmr(struct iommu *iommu)
   14.10  {
   14.11      unsigned long start_time, status;
   14.12 +    unsigned int val;
   14.13  
   14.14 -    gdprintk(XENLOG_INFO VTDPREFIX,
   14.15 -        "disabling protected memory registers\n");
   14.16 +    val = dmar_readl(iommu->reg, DMAR_PMEN_REG);
   14.17 +    dmar_writel(iommu->reg, DMAR_PMEN_REG, val & ~DMA_PMEN_EPM);
   14.18 +    start_time = jiffies;
   14.19  
   14.20 -    dmar_writel(iommu->reg, DMAR_PMEN_REG, 0);
   14.21 -    start_time = jiffies;
   14.22 -    while (1) {
   14.23 +    for ( ; ; )
   14.24 +    {
   14.25          status = dmar_readl(iommu->reg, DMAR_PMEN_REG);
   14.26          if ( (status & DMA_PMEN_PRS) == 0 )
   14.27              break;
   14.28 -        if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))
   14.29 +        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
   14.30              panic("Cannot set QIE field for queue invalidation\n");
   14.31          cpu_relax();
   14.32      }
   14.33 +
   14.34 +    dprintk(XENLOG_INFO VTDPREFIX,
   14.35 +            "disabled protected memory registers\n");
   14.36  }
   14.37  
   14.38  #if defined(__x86_64__)
    15.1 --- a/xen/arch/x86/mm/shadow/multi.c	Tue Oct 23 10:21:31 2007 -0600
    15.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Tue Oct 23 11:27:56 2007 -0600
    15.3 @@ -33,6 +33,7 @@
    15.4  #include <asm/shadow.h>
    15.5  #include <asm/flushtlb.h>
    15.6  #include <asm/hvm/hvm.h>
    15.7 +#include <asm/hvm/cacheattr.h>
    15.8  #include <asm/mtrr.h>
    15.9  #include "private.h"
   15.10  #include "types.h"
   15.11 @@ -715,8 +716,14 @@ static always_inline void
   15.12      sflags = gflags & pass_thru_flags;
   15.13  
   15.14      /* Only change memory caching type for pass-through domain */
   15.15 -    if ( (level == 1) && !list_empty(&(domain_hvm_iommu(d)->pdev_list)) ) {
   15.16 -        if ( v->domain->arch.hvm_domain.is_in_uc_mode )
   15.17 +    if ( (level == 1) && is_hvm_domain(d) &&
   15.18 +         !list_empty(&(domain_hvm_iommu(d)->pdev_list)) )
   15.19 +    {
   15.20 +        unsigned int type;
   15.21 +        if ( hvm_get_mem_pinned_cacheattr(d, gfn_x(guest_l1e_get_gfn(*gp)),
   15.22 +                                          &type) )
   15.23 +            sflags |= pat_type_2_pte_flags(type);
   15.24 +        else if ( v->domain->arch.hvm_domain.is_in_uc_mode )
   15.25              sflags |= pat_type_2_pte_flags(PAT_TYPE_UNCACHABLE);
   15.26          else
   15.27              sflags |= get_pat_flags(v,
    16.1 --- a/xen/arch/x86/x86_32/entry.S	Tue Oct 23 10:21:31 2007 -0600
    16.2 +++ b/xen/arch/x86/x86_32/entry.S	Tue Oct 23 11:27:56 2007 -0600
    16.3 @@ -181,6 +181,7 @@ 1:      sti
    16.4          movl  $0xDEADBEEF,%eax
    16.5          rep   stosl
    16.6          movl  %esi,%eax
    16.7 +#define SHADOW_BYTES 32 /* 6 shadow parameters + EIP + hypercall # */
    16.8  #else
    16.9          /* 
   16.10           * We need shadow parameters even on non-debug builds. We depend on the
   16.11 @@ -193,12 +194,14 @@ 1:      sti
   16.12          pushl 20(%esp) # EDX
   16.13          pushl 20(%esp) # ECX
   16.14          pushl 20(%esp) # EBX
   16.15 +#define SHADOW_BYTES 24 /* 6 shadow parameters */
   16.16  #endif
   16.17          cmpb  $0,tb_init_done
   16.18          je    tracing_off
   16.19          call  trace_hypercall
   16.20          /* Now restore all the registers that trace_hypercall clobbered */
   16.21 -        movl  UREGS_eax+24(%esp),%eax /* Hypercall # */
   16.22 +        movl  UREGS_eax+SHADOW_BYTES(%esp),%eax /* Hypercall # */
   16.23 +#undef SHADOW_BYTES
   16.24  tracing_off:
   16.25          call *hypercall_table(,%eax,4)
   16.26          addl  $24,%esp     # Discard the shadow parameters
    17.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Tue Oct 23 10:21:31 2007 -0600
    17.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Tue Oct 23 11:27:56 2007 -0600
    17.3 @@ -47,6 +47,7 @@ ENTRY(compat_hypercall)
    17.4          movl  UREGS_rax(%rsp),%eax
    17.5          pushq %rax
    17.6          pushq UREGS_rip+8(%rsp)
    17.7 +#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
    17.8  #else
    17.9          /* Relocate argument registers and zero-extend to 64 bits. */
   17.10          movl  %eax,%eax              /* Hypercall #  */
   17.11 @@ -55,18 +56,20 @@ ENTRY(compat_hypercall)
   17.12          movl  %edi,%r8d              /* Arg 5        */
   17.13          movl  %ebp,%r9d              /* Arg 6        */
   17.14          movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
   17.15 +#define SHADOW_BYTES 0  /* No on-stack shadow state */
   17.16  #endif
   17.17          cmpb  $0,tb_init_done(%rip)
   17.18          je    compat_tracing_off
   17.19          call  trace_hypercall
   17.20          /* Now restore all the registers that trace_hypercall clobbered */
   17.21 -        movl  UREGS_rax(%rsp),%eax   /* Hypercall #  */
   17.22 -        movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
   17.23 -        movl  UREGS_rcx(%rsp),%esi   /* Arg 2        */
   17.24 -        movl  UREGS_rdx(%rsp),%edx   /* Arg 3        */
   17.25 -        movl  UREGS_rsi(%rsp),%ecx   /* Arg 4        */
   17.26 -        movl  UREGS_rdi(%rsp),%r8d   /* Arg 5        */
   17.27 -        movl  UREGS_rbp(%rsp),%r9d   /* Arg 6        */
   17.28 +        movl  UREGS_rax+SHADOW_BYTES(%rsp),%eax   /* Hypercall #  */
   17.29 +        movl  UREGS_rbx+SHADOW_BYTES(%rsp),%edi   /* Arg 1        */
   17.30 +        movl  UREGS_rcx+SHADOW_BYTES(%rsp),%esi   /* Arg 2        */
   17.31 +        movl  UREGS_rdx+SHADOW_BYTES(%rsp),%edx   /* Arg 3        */
   17.32 +        movl  UREGS_rsi+SHADOW_BYTES(%rsp),%ecx   /* Arg 4        */
   17.33 +        movl  UREGS_rdi+SHADOW_BYTES(%rsp),%r8d   /* Arg 5        */
   17.34 +        movl  UREGS_rbp+SHADOW_BYTES(%rsp),%r9d   /* Arg 6        */
   17.35 +#undef SHADOW_BYTES
   17.36  compat_tracing_off:
   17.37          leaq  compat_hypercall_table(%rip),%r10
   17.38          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
    18.1 --- a/xen/arch/x86/x86_64/entry.S	Tue Oct 23 10:21:31 2007 -0600
    18.2 +++ b/xen/arch/x86/x86_64/entry.S	Tue Oct 23 11:27:56 2007 -0600
    18.3 @@ -148,18 +148,22 @@ ENTRY(syscall_enter)
    18.4          movq  UREGS_rax(%rsp),%rax
    18.5          pushq %rax
    18.6          pushq UREGS_rip+8(%rsp)
    18.7 +#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
    18.8 +#else
    18.9 +#define SHADOW_BYTES 0  /* No on-stack shadow state */
   18.10  #endif
   18.11          cmpb  $0,tb_init_done(%rip)
   18.12          je    tracing_off
   18.13          call  trace_hypercall
   18.14          /* Now restore all the registers that trace_hypercall clobbered */
   18.15 -        movq  UREGS_rax(%rsp),%rax   /* Hypercall #  */
   18.16 -        movq  UREGS_rdi(%rsp),%rdi   /* Arg 1        */
   18.17 -        movq  UREGS_rsi(%rsp),%rsi   /* Arg 2        */
   18.18 -        movq  UREGS_rdx(%rsp),%rdx   /* Arg 3        */
   18.19 -        movq  UREGS_r10(%rsp),%rcx   /* Arg 4        */
   18.20 -        movq  UREGS_rdi(%rsp),%r8    /* Arg 5        */
   18.21 -        movq  UREGS_rbp(%rsp),%r9    /* Arg 6        */
   18.22 +        movq  UREGS_rax+SHADOW_BYTES(%rsp),%rax   /* Hypercall #  */
   18.23 +        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%rdi   /* Arg 1        */
   18.24 +        movq  UREGS_rsi+SHADOW_BYTES(%rsp),%rsi   /* Arg 2        */
   18.25 +        movq  UREGS_rdx+SHADOW_BYTES(%rsp),%rdx   /* Arg 3        */
   18.26 +        movq  UREGS_r10+SHADOW_BYTES(%rsp),%rcx   /* Arg 4        */
   18.27 +        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%r8    /* Arg 5        */
   18.28 +        movq  UREGS_rbp+SHADOW_BYTES(%rsp),%r9    /* Arg 6        */
   18.29 +#undef SHADOW_BYTES
   18.30  tracing_off:
   18.31          leaq  hypercall_table(%rip),%r10
   18.32          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
    19.1 --- a/xen/include/Makefile	Tue Oct 23 10:21:31 2007 -0600
    19.2 +++ b/xen/include/Makefile	Tue Oct 23 11:27:56 2007 -0600
    19.3 @@ -61,7 +61,7 @@ compat/%.c: public/%.h xlat.lst Makefile
    19.4  compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile
    19.5  	grep -v '^[	 ]*#' xlat.lst | \
    19.6  	while read what name hdr; do \
    19.7 -		/bin/sh $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$(echo compat/$$hdr | sed 's,@arch@,$(compat-arch-y),g') || exit $$?; \
    19.8 +		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$(echo compat/$$hdr | sed 's,@arch@,$(compat-arch-y),g') || exit $$?; \
    19.9  	done >$@.new
   19.10  	mv -f $@.new $@
   19.11  
    20.1 --- a/xen/include/asm-x86/config.h	Tue Oct 23 10:21:31 2007 -0600
    20.2 +++ b/xen/include/asm-x86/config.h	Tue Oct 23 11:27:56 2007 -0600
    20.3 @@ -93,7 +93,7 @@
    20.4  
    20.5  #define CONFIG_DMA_BITSIZE 32
    20.6  
    20.7 -#define BOOT_TRAMPOLINE 0x94000
    20.8 +#define BOOT_TRAMPOLINE 0x8c000
    20.9  #define bootsym_phys(sym)                                 \
   20.10      (((unsigned long)&(sym)-(unsigned long)&trampoline_start)+BOOT_TRAMPOLINE)
   20.11  #define bootsym(sym)                                      \
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/xen/include/asm-x86/hvm/cacheattr.h	Tue Oct 23 11:27:56 2007 -0600
    21.3 @@ -0,0 +1,33 @@
    21.4 +#ifndef __HVM_CACHEATTR_H__
    21.5 +#define __HVM_CACHEATTR_H__
    21.6 +
    21.7 +struct hvm_mem_pinned_cacheattr_range {
    21.8 +    struct list_head list;
    21.9 +    uint64_t start, end;
   21.10 +    unsigned int type;
   21.11 +};
   21.12 +
   21.13 +void hvm_init_cacheattr_region_list(
   21.14 +    struct domain *d);
   21.15 +void hvm_destroy_cacheattr_region_list(
   21.16 +    struct domain *d);
   21.17 +
   21.18 +/*
   21.19 + * To see guest_fn is in the pinned range or not,
   21.20 + * if yes, return 1, and set type to value in this range
   21.21 + * if no,  return 0, and set type to 0
   21.22 + */
   21.23 +int hvm_get_mem_pinned_cacheattr(
   21.24 +    struct domain *d,
   21.25 +    unsigned long guest_fn,
   21.26 +    unsigned int *type);
   21.27 +
   21.28 +
   21.29 +/* Set pinned caching type for a domain. */
   21.30 +int hvm_set_mem_pinned_cacheattr(
   21.31 +    struct domain *d,
   21.32 +    unsigned long gfn_start,
   21.33 +    unsigned long gfn_end,
   21.34 +    unsigned int  type);
   21.35 +
   21.36 +#endif /* __HVM_CACHEATTR_H__ */
    22.1 --- a/xen/include/asm-x86/hvm/domain.h	Tue Oct 23 10:21:31 2007 -0600
    22.2 +++ b/xen/include/asm-x86/hvm/domain.h	Tue Oct 23 11:27:56 2007 -0600
    22.3 @@ -61,11 +61,14 @@ struct hvm_domain {
    22.4  
    22.5      unsigned long          vmx_apic_access_mfn;
    22.6  
    22.7 +    /* Memory ranges with pinned cache attributes. */
    22.8 +    struct list_head       pinned_cacheattr_ranges;
    22.9 +
   22.10      /* If one of vcpus of this domain is in no_fill_mode or
   22.11       * mtrr/pat between vcpus is not the same, set is_in_uc_mode
   22.12       */
   22.13 -    spinlock_t       uc_lock;
   22.14 -    bool_t           is_in_uc_mode;
   22.15 +    spinlock_t             uc_lock;
   22.16 +    bool_t                 is_in_uc_mode;
   22.17  
   22.18      /* Pass-through */
   22.19      struct hvm_iommu       hvm_iommu;
    23.1 --- a/xen/include/asm-x86/hvm/vmx/intel-iommu.h	Tue Oct 23 10:21:31 2007 -0600
    23.2 +++ b/xen/include/asm-x86/hvm/vmx/intel-iommu.h	Tue Oct 23 11:27:56 2007 -0600
    23.3 @@ -147,7 +147,7 @@
    23.4  
    23.5  /* PMEN_REG */
    23.6  #define DMA_PMEN_EPM   (((u32)1) << 31)
    23.7 -#define DMA_PMEN_PRS   (((u32)1) << 1)
    23.8 +#define DMA_PMEN_PRS   (((u32)1) << 0)
    23.9  
   23.10  /* CCMD_REG */
   23.11  #define DMA_CCMD_INVL_GRANU_OFFSET  61
    24.1 --- a/xen/include/asm-x86/msr-index.h	Tue Oct 23 10:21:31 2007 -0600
    24.2 +++ b/xen/include/asm-x86/msr-index.h	Tue Oct 23 11:27:56 2007 -0600
    24.3 @@ -166,13 +166,18 @@
    24.4  #define MSR_K7_FID_VID_CTL		0xc0010041
    24.5  #define MSR_K7_FID_VID_STATUS		0xc0010042
    24.6  #define MSR_K8_ENABLE_C1E		0xc0010055
    24.7 -#define MSR_K8_VM_CR			0xC0010114
    24.8 -#define MSR_K8_VM_HSAVE_PA		0xC0010117
    24.9 +#define MSR_K8_VM_CR			0xc0010114
   24.10 +#define MSR_K8_VM_HSAVE_PA		0xc0010117
   24.11  
   24.12  /* MSR_K8_VM_CR bits: */
   24.13  #define _K8_VMCR_SVME_DISABLE		4
   24.14  #define K8_VMCR_SVME_DISABLE		(1 << _K8_VMCR_SVME_DISABLE)
   24.15  
   24.16 +/* AMD Family10h machine check MSRs */
   24.17 +#define MSR_F10_MC4_MISC1		0xc0000408
   24.18 +#define MSR_F10_MC4_MISC2		0xc0000409
   24.19 +#define MSR_F10_MC4_MISC3		0xc000040A
   24.20 +
   24.21  /* K6 MSRs */
   24.22  #define MSR_K6_EFER			0xc0000080
   24.23  #define MSR_K6_STAR			0xc0000081
    25.1 --- a/xen/include/public/domctl.h	Tue Oct 23 10:21:31 2007 -0600
    25.2 +++ b/xen/include/public/domctl.h	Tue Oct 23 11:27:56 2007 -0600
    25.3 @@ -495,6 +495,23 @@ struct xen_domctl_ioport_mapping {
    25.4  typedef struct xen_domctl_ioport_mapping xen_domctl_ioport_mapping_t;
    25.5  DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_mapping_t);
    25.6  
    25.7 +/*
    25.8 + * Pin caching type of RAM space for x86 HVM domU.
    25.9 + */
   25.10 +#define XEN_DOMCTL_pin_mem_cacheattr 41
   25.11 +/* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */
   25.12 +#define XEN_DOMCTL_MEM_CACHEATTR_UC  0
   25.13 +#define XEN_DOMCTL_MEM_CACHEATTR_WC  1
   25.14 +#define XEN_DOMCTL_MEM_CACHEATTR_WT  4
   25.15 +#define XEN_DOMCTL_MEM_CACHEATTR_WP  5
   25.16 +#define XEN_DOMCTL_MEM_CACHEATTR_WB  6
   25.17 +#define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
   25.18 +struct xen_domctl_pin_mem_cacheattr {
   25.19 +    uint64_t start, end;
   25.20 +    unsigned int type; /* XEN_DOMCTL_MEM_CACHEATTR_* */
   25.21 +};
   25.22 +typedef struct xen_domctl_pin_mem_cacheattr xen_domctl_pin_mem_cacheattr_t;
   25.23 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_pin_mem_cacheattr_t);
   25.24  
   25.25  struct xen_domctl {
   25.26      uint32_t cmd;
   25.27 @@ -529,6 +546,7 @@ struct xen_domctl {
   25.28          struct xen_domctl_bind_pt_irq       bind_pt_irq;
   25.29          struct xen_domctl_memory_mapping    memory_mapping;
   25.30          struct xen_domctl_ioport_mapping    ioport_mapping;
   25.31 +        struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
   25.32          uint8_t                             pad[128];
   25.33      } u;
   25.34  };
    26.1 --- a/xen/tools/get-fields.sh	Tue Oct 23 10:21:31 2007 -0600
    26.2 +++ b/xen/tools/get-fields.sh	Tue Oct 23 11:27:56 2007 -0600
    26.3 @@ -1,4 +1,3 @@
    26.4 -#!/bin/sh
    26.5  test -n "$1" -a -n "$2" -a -n "$3"
    26.6  set -ef
    26.7