ia64/xen-unstable

changeset 14665:4a240d458db9

hvm: Fix the assert on size in HVM MMIO flag-setting functions
Signed-off-by: Xin Li <xin.b.li@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Mar 29 19:23:41 2007 +0100 (2007-03-29)
parents 9a839ead4870
children 4434d1039a65
files xen/arch/x86/hvm/io.c
line diff
     1.1 --- a/xen/arch/x86/hvm/io.c	Thu Mar 29 19:18:43 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/io.c	Thu Mar 29 19:23:41 2007 +0100
     1.3 @@ -287,13 +287,15 @@ static void set_reg_value (int size, int
     1.4  }
     1.5  #endif
     1.6  
     1.7 -extern long get_reg_value(int size, int index, int seg, struct cpu_user_regs *regs);
     1.8 +long get_reg_value(int size, int index, int seg, struct cpu_user_regs *regs);
     1.9  
    1.10  static inline void set_eflags_CF(int size, unsigned long v1,
    1.11                                   unsigned long v2, struct cpu_user_regs *regs)
    1.12  {
    1.13      unsigned long mask;
    1.14 -    
    1.15 +
    1.16 +    if ( size == BYTE_64 )
    1.17 +        size = BYTE;
    1.18      ASSERT((size <= sizeof(mask)) && (size > 0));
    1.19  
    1.20      mask = ~0UL >> (8 * (sizeof(mask) - size));
    1.21 @@ -305,20 +307,24 @@ static inline void set_eflags_CF(int siz
    1.22  }
    1.23  
    1.24  static inline void set_eflags_OF(int size, unsigned long v1,
    1.25 -                                 unsigned long v2, unsigned long v3, struct cpu_user_regs *regs)
    1.26 +                                 unsigned long v2, unsigned long v3,
    1.27 +                                 struct cpu_user_regs *regs)
    1.28  {
    1.29      unsigned long mask;
    1.30  
    1.31 +    if ( size == BYTE_64 )
    1.32 +        size = BYTE;
    1.33      ASSERT((size <= sizeof(mask)) && (size > 0));
    1.34  
    1.35      mask = ~0UL >> (8 * (sizeof(mask) - size));
    1.36 -    
    1.37 +
    1.38      if ((v3 ^ v2) & (v3 ^ v1) & mask)
    1.39          regs->eflags |= X86_EFLAGS_OF;
    1.40  }
    1.41  
    1.42  static inline void set_eflags_AF(int size, unsigned long v1,
    1.43 -                                 unsigned long v2, unsigned long v3, struct cpu_user_regs *regs)
    1.44 +                                 unsigned long v2, unsigned long v3,
    1.45 +                                 struct cpu_user_regs *regs)
    1.46  {
    1.47      if ((v1 ^ v2 ^ v3) & 0x10)
    1.48          regs->eflags |= X86_EFLAGS_AF;
    1.49 @@ -328,7 +334,9 @@ static inline void set_eflags_ZF(int siz
    1.50                                   struct cpu_user_regs *regs)
    1.51  {
    1.52      unsigned long mask;
    1.53 -    
    1.54 +
    1.55 +    if ( size == BYTE_64 )
    1.56 +        size = BYTE;
    1.57      ASSERT((size <= sizeof(mask)) && (size > 0));
    1.58  
    1.59      mask = ~0UL >> (8 * (sizeof(mask) - size));
    1.60 @@ -341,7 +349,9 @@ static inline void set_eflags_SF(int siz
    1.61                                   struct cpu_user_regs *regs)
    1.62  {
    1.63      unsigned long mask;
    1.64 -    
    1.65 +
    1.66 +    if ( size == BYTE_64 )
    1.67 +        size = BYTE;
    1.68      ASSERT((size <= sizeof(mask)) && (size > 0));
    1.69  
    1.70      mask = ~0UL >> (8 * (sizeof(mask) - size));
    1.71 @@ -395,14 +405,14 @@ static void hvm_pio_assist(struct cpu_us
    1.72                  if ( hvm_paging_enabled(current) )
    1.73                  {
    1.74                      int rv = hvm_copy_to_guest_virt(addr, &p->data, p->size);
    1.75 -                    if ( rv != 0 ) 
    1.76 +                    if ( rv != 0 )
    1.77                      {
    1.78                          /* Failed on the page-spanning copy.  Inject PF into
    1.79                           * the guest for the address where we failed. */
    1.80                          addr += p->size - rv;
    1.81                          gdprintk(XENLOG_DEBUG, "Pagefault writing non-io side "
    1.82                                   "of a page-spanning PIO: va=%#lx\n", addr);
    1.83 -                        hvm_inject_exception(TRAP_page_fault, 
    1.84 +                        hvm_inject_exception(TRAP_page_fault,
    1.85                                               PFEC_write_access, addr);
    1.86                          return;
    1.87                      }
    1.88 @@ -525,14 +535,14 @@ static void hvm_mmio_assist(struct cpu_u
    1.89              if (hvm_paging_enabled(current))
    1.90              {
    1.91                  int rv = hvm_copy_to_guest_virt(addr, &p->data, p->size);
    1.92 -                if ( rv != 0 ) 
    1.93 +                if ( rv != 0 )
    1.94                  {
    1.95                      /* Failed on the page-spanning copy.  Inject PF into
    1.96                       * the guest for the address where we failed. */
    1.97                      addr += p->size - rv;
    1.98                      gdprintk(XENLOG_DEBUG, "Pagefault writing non-io side of "
    1.99                               "a page-spanning MMIO: va=%#lx\n", addr);
   1.100 -                    hvm_inject_exception(TRAP_page_fault, 
   1.101 +                    hvm_inject_exception(TRAP_page_fault,
   1.102                                           PFEC_write_access, addr);
   1.103                      return;
   1.104                  }
   1.105 @@ -738,14 +748,14 @@ static void hvm_mmio_assist(struct cpu_u
   1.106  
   1.107      case INSTR_PUSH:
   1.108          mmio_opp->addr += hvm_get_segment_base(current, x86_seg_ss);
   1.109 -        { 
   1.110 +        {
   1.111              unsigned long addr = mmio_opp->addr;
   1.112              int rv = hvm_copy_to_guest_virt(addr, &p->data, size);
   1.113 -            if ( rv != 0 ) 
   1.114 +            if ( rv != 0 )
   1.115              {
   1.116                  addr += p->size - rv;
   1.117 -                gdprintk(XENLOG_DEBUG, "Pagefault emulating PUSH from MMIO: "
   1.118 -                         "va=%#lx\n", addr);
   1.119 +                gdprintk(XENLOG_DEBUG, "Pagefault emulating PUSH from MMIO:"
   1.120 +                         " va=%#lx\n", addr);
   1.121                  hvm_inject_exception(TRAP_page_fault, PFEC_write_access, addr);
   1.122                  return;
   1.123              }
   1.124 @@ -787,7 +797,7 @@ void hvm_io_assist(struct vcpu *v)
   1.125      memcpy(guest_cpu_user_regs(), regs, HVM_CONTEXT_STACK_BYTES);
   1.126  
   1.127      /* Has memory been dirtied? */
   1.128 -    if ( p->dir == IOREQ_READ && p->data_is_ptr ) 
   1.129 +    if ( p->dir == IOREQ_READ && p->data_is_ptr )
   1.130      {
   1.131          gmfn = get_mfn_from_gpfn(paging_gva_to_gfn(v, p->data));
   1.132          mark_dirty(v->domain, gmfn);