ia64/xen-unstable

changeset 17062:0769835cf50f

x86 shadow: Reduce scope of shadow lock.

emulate_map_dest doesn't require holding lock, since
only shadow related operation possibly involved is to
remove shadow which is less frequent and can acquire
lock inside. Rest are either guest table walk or
per-vcpu monitor table manipulation

Signed-off-by Kevin Tian <kevin.tian@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 14 10:33:12 2008 +0000 (2008-02-14)
parents 80428fb872be
children c9d9bbf1204c
files xen/arch/x86/mm/shadow/multi.c
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/multi.c	Thu Feb 14 10:31:01 2008 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Thu Feb 14 10:33:12 2008 +0000
     1.3 @@ -4216,15 +4216,12 @@ sh_x86_emulate_write(struct vcpu *v, uns
     1.4      if ( (vaddr & (bytes - 1)) && !is_hvm_vcpu(v)  )
     1.5          return X86EMUL_UNHANDLEABLE;
     1.6  
     1.7 -    shadow_lock(v->domain);
     1.8      addr = emulate_map_dest(v, vaddr, bytes, sh_ctxt);
     1.9      if ( emulate_map_dest_failed(addr) )
    1.10 -    {
    1.11 -        shadow_unlock(v->domain);
    1.12          return ((addr == MAPPING_EXCEPTION) ?
    1.13                  X86EMUL_EXCEPTION : X86EMUL_UNHANDLEABLE);
    1.14 -    }
    1.15 -
    1.16 +
    1.17 +    shadow_lock(v->domain);
    1.18      memcpy(addr, src, bytes);
    1.19  
    1.20      emulate_unmap_dest(v, addr, bytes, sh_ctxt);
    1.21 @@ -4246,16 +4243,12 @@ sh_x86_emulate_cmpxchg(struct vcpu *v, u
    1.22      if ( (vaddr & (bytes - 1)) && !is_hvm_vcpu(v)  )
    1.23          return X86EMUL_UNHANDLEABLE;
    1.24  
    1.25 -    shadow_lock(v->domain);
    1.26 -
    1.27      addr = emulate_map_dest(v, vaddr, bytes, sh_ctxt);
    1.28      if ( emulate_map_dest_failed(addr) )
    1.29 -    {
    1.30 -        shadow_unlock(v->domain);
    1.31          return ((addr == MAPPING_EXCEPTION) ?
    1.32                  X86EMUL_EXCEPTION : X86EMUL_UNHANDLEABLE);
    1.33 -    }
    1.34 -
    1.35 +
    1.36 +    shadow_lock(v->domain);
    1.37      switch ( bytes )
    1.38      {
    1.39      case 1: prev = cmpxchg(((u8 *)addr), old, new);  break;
    1.40 @@ -4294,18 +4287,15 @@ sh_x86_emulate_cmpxchg8b(struct vcpu *v,
    1.41      if ( (vaddr & 7) && !is_hvm_vcpu(v) )
    1.42          return X86EMUL_UNHANDLEABLE;
    1.43  
    1.44 -    shadow_lock(v->domain);
    1.45 -
    1.46      addr = emulate_map_dest(v, vaddr, 8, sh_ctxt);
    1.47      if ( emulate_map_dest_failed(addr) )
    1.48 -    {
    1.49 -        shadow_unlock(v->domain);
    1.50          return ((addr == MAPPING_EXCEPTION) ?
    1.51                  X86EMUL_EXCEPTION : X86EMUL_UNHANDLEABLE);
    1.52 -    }
    1.53  
    1.54      old = (((u64) old_hi) << 32) | (u64) old_lo;
    1.55      new = (((u64) new_hi) << 32) | (u64) new_lo;
    1.56 +
    1.57 +    shadow_lock(v->domain);
    1.58      prev = cmpxchg(((u64 *)addr), old, new);
    1.59  
    1.60      if ( prev != old )