ia64/xen-unstable

changeset 16878:7a2824f99a28

x86, hvm: Only invalidate qemu mapcache on XENMEM_decrease_reservation.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 24 18:09:26 2008 +0000 (2008-01-24)
parents 31adb5c972d0
children 1a2f557448cf
files xen/arch/x86/hvm/hvm.c xen/include/asm-x86/hvm/domain.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Jan 24 14:41:26 2008 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Jan 24 18:09:26 2008 +0000
     1.3 @@ -1470,6 +1470,14 @@ static long hvm_grant_table_op(
     1.4      return do_grant_table_op(cmd, uop, count);
     1.5  }
     1.6  
     1.7 +static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE(void) arg)
     1.8 +{
     1.9 +    long rc = do_memory_op(cmd, arg);
    1.10 +    if ( (cmd & MEMOP_CMD_MASK) == XENMEM_decrease_reservation )
    1.11 +        current->domain->arch.hvm_domain.qemu_mapcache_invalidate = 1;
    1.12 +    return rc;
    1.13 +}
    1.14 +
    1.15  typedef unsigned long hvm_hypercall_t(
    1.16      unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
    1.17  
    1.18 @@ -1479,7 +1487,7 @@ typedef unsigned long hvm_hypercall_t(
    1.19  #if defined(__i386__)
    1.20  
    1.21  static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
    1.22 -    HYPERCALL(memory_op),
    1.23 +    [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op,
    1.24      [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op,
    1.25      HYPERCALL(xen_version),
    1.26      HYPERCALL(event_channel_op),
    1.27 @@ -1489,7 +1497,7 @@ static hvm_hypercall_t *hvm_hypercall32_
    1.28  
    1.29  #else /* defined(__x86_64__) */
    1.30  
    1.31 -static long do_memory_op_compat32(int cmd, XEN_GUEST_HANDLE(void) arg)
    1.32 +static long hvm_memory_op_compat32(int cmd, XEN_GUEST_HANDLE(void) arg)
    1.33  {
    1.34      extern long do_add_to_physmap(struct xen_add_to_physmap *xatp);
    1.35      long rc;
    1.36 @@ -1515,7 +1523,7 @@ static long do_memory_op_compat32(int cm
    1.37          h.gpfn = u.gpfn;
    1.38  
    1.39          this_cpu(guest_handles_in_xen_space) = 1;
    1.40 -        rc = do_memory_op(cmd, guest_handle_from_ptr(&h, void));
    1.41 +        rc = hvm_memory_op(cmd, guest_handle_from_ptr(&h, void));
    1.42          this_cpu(guest_handles_in_xen_space) = 0;
    1.43  
    1.44          break;
    1.45 @@ -1531,7 +1539,7 @@ static long do_memory_op_compat32(int cm
    1.46  }
    1.47  
    1.48  static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] = {
    1.49 -    HYPERCALL(memory_op),
    1.50 +    [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op,
    1.51      [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op,
    1.52      HYPERCALL(xen_version),
    1.53      HYPERCALL(event_channel_op),
    1.54 @@ -1540,7 +1548,7 @@ static hvm_hypercall_t *hvm_hypercall64_
    1.55  };
    1.56  
    1.57  static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
    1.58 -    [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)do_memory_op_compat32,
    1.59 +    [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op_compat32,
    1.60      [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op,
    1.61      HYPERCALL(xen_version),
    1.62      HYPERCALL(event_channel_op),
    1.63 @@ -1552,8 +1560,9 @@ static hvm_hypercall_t *hvm_hypercall32_
    1.64  
    1.65  int hvm_do_hypercall(struct cpu_user_regs *regs)
    1.66  {
    1.67 +    struct vcpu *curr = current;
    1.68      struct segment_register sreg;
    1.69 -    int flush, mode = hvm_guest_x86_mode(current);
    1.70 +    int mode = hvm_guest_x86_mode(curr);
    1.71      uint32_t eax = regs->eax;
    1.72  
    1.73      switch ( mode )
    1.74 @@ -1563,7 +1572,7 @@ int hvm_do_hypercall(struct cpu_user_reg
    1.75  #endif
    1.76      case 4:
    1.77      case 2:
    1.78 -        hvm_get_segment_register(current, x86_seg_ss, &sreg);
    1.79 +        hvm_get_segment_register(curr, x86_seg_ss, &sreg);
    1.80          if ( unlikely(sreg.attr.fields.dpl == 3) )
    1.81          {
    1.82      default:
    1.83 @@ -1580,13 +1589,6 @@ int hvm_do_hypercall(struct cpu_user_reg
    1.84          return HVM_HCALL_completed;
    1.85      }
    1.86  
    1.87 -    /*
    1.88 -     * NB. In future flush only on decrease_reservation.
    1.89 -     * For now we also need to flush when pages are added, as qemu-dm is not
    1.90 -     * yet capable of faulting pages into an existing valid mapcache bucket.
    1.91 -     */
    1.92 -    flush = ((eax == __HYPERVISOR_memory_op) ||
    1.93 -             (eax == __HYPERVISOR_grant_table_op)); /* needed ? */
    1.94      this_cpu(hc_preempted) = 0;
    1.95  
    1.96  #ifdef __x86_64__
    1.97 @@ -1619,8 +1621,15 @@ int hvm_do_hypercall(struct cpu_user_reg
    1.98      HVM_DBG_LOG(DBG_LEVEL_HCALL, "hcall%u -> %lx",
    1.99                  eax, (unsigned long)regs->eax);
   1.100  
   1.101 -    return (this_cpu(hc_preempted) ? HVM_HCALL_preempted :
   1.102 -            flush ? HVM_HCALL_invalidate : HVM_HCALL_completed);
   1.103 +    if ( this_cpu(hc_preempted) )
   1.104 +        return HVM_HCALL_preempted;
   1.105 +
   1.106 +    if ( unlikely(curr->domain->arch.hvm_domain.qemu_mapcache_invalidate) &&
   1.107 +         test_and_clear_bool(curr->domain->arch.hvm_domain.
   1.108 +                             qemu_mapcache_invalidate) )
   1.109 +        return HVM_HCALL_invalidate;
   1.110 +
   1.111 +    return HVM_HCALL_completed;
   1.112  }
   1.113  
   1.114  static void hvm_latch_shinfo_size(struct domain *d)
     2.1 --- a/xen/include/asm-x86/hvm/domain.h	Thu Jan 24 14:41:26 2008 +0000
     2.2 +++ b/xen/include/asm-x86/hvm/domain.h	Thu Jan 24 18:09:26 2008 +0000
     2.3 @@ -77,6 +77,8 @@ struct hvm_domain {
     2.4  #if CONFIG_PAGING_LEVELS == 3
     2.5      bool_t                 amd_npt_4gb_warning;
     2.6  #endif
     2.7 +
     2.8 +    bool_t                 qemu_mapcache_invalidate;
     2.9  };
    2.10  
    2.11  #endif /* __ASM_X86_HVM_DOMAIN_H__ */