ia64/xen-unstable

changeset 5432:9e1e2d648dce

bitkeeper revision 1.1710 (42a9cf67UYP4Ao1KcX2E9wd6g877MA)

Merge firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
into firebug.cl.cam.ac.uk:/local/scratch/kaf24/xeno-unstable-ia64.bk
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 10 17:35:35 2005 +0000 (2005-06-10)
parents da92dcde82ea ed8174531c13
children d9263038f0e8
files xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/seg_fixup.c xen/arch/x86/x86_64/entry.S
line diff
     1.1 --- a/xen/arch/x86/x86_32/entry.S	Fri Jun 10 15:45:23 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_32/entry.S	Fri Jun 10 17:35:35 2005 +0000
     1.3 @@ -176,10 +176,10 @@ vmx_process_softirqs:
     1.4  restore_all_guest:
     1.5          testl $X86_EFLAGS_VM,UREGS_eflags(%esp)
     1.6          jnz  restore_all_vm86
     1.7 -FLT1:   mov UREGS_ds(%esp),%ds
     1.8 -FLT2:   mov UREGS_es(%esp),%es
     1.9 -FLT3:   mov UREGS_fs(%esp),%fs
    1.10 -FLT4:   mov UREGS_gs(%esp),%gs
    1.11 +FLT1:   mov  UREGS_ds(%esp),%ds
    1.12 +FLT2:   mov  UREGS_es(%esp),%es
    1.13 +FLT3:   mov  UREGS_fs(%esp),%fs
    1.14 +FLT4:   mov  UREGS_gs(%esp),%gs
    1.15  restore_all_vm86:
    1.16          popl %ebx
    1.17          popl %ecx
    1.18 @@ -306,7 +306,7 @@ create_bounce_frame:
    1.19          testl $(2|X86_EFLAGS_VM),%ecx
    1.20          jz   ring1 /* jump if returning to an existing ring-1 activation */
    1.21          movl VCPU_kernel_sp(%ebx),%esi
    1.22 -FLT6:   mov VCPU_kernel_ss(%ebx),%gs
    1.23 +FLT6:   mov  VCPU_kernel_ss(%ebx),%gs
    1.24          testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp)
    1.25          jz   nvm86_1
    1.26          subl $16,%esi       /* push ES/DS/FS/GS (VM86 stack frame) */
    1.27 @@ -326,13 +326,11 @@ FLT12:  movl %eax,%gs:4(%esi)
    1.28          jmp 1f
    1.29  ring1:  /* obtain ss/esp from oldss/oldesp -- a ring-1 activation exists */
    1.30          movl UREGS_esp+4(%esp),%esi
    1.31 -FLT13:  mov UREGS_ss+4(%esp),%gs 
    1.32 +FLT13:  mov  UREGS_ss+4(%esp),%gs 
    1.33  1:      /* Construct a stack frame: EFLAGS, CS/EIP */
    1.34          movb TRAPBOUNCE_flags(%edx),%cl
    1.35          subl $12,%esi
    1.36          movl UREGS_eip+4(%esp),%eax
    1.37 -        test %eax,%eax
    1.38 -        jz   domain_crash_synchronous
    1.39  FLT14:  movl %eax,%gs:(%esi) 
    1.40          movl VCPU_vcpu_info(%ebx),%eax
    1.41          pushl VCPUINFO_upcall_mask(%eax)
    1.42 @@ -383,11 +381,13 @@ 2:      testl $X86_EFLAGS_VM,UREGS_eflag
    1.43  nvm86_3:/* Rewrite our stack frame and return to ring 1. */
    1.44          /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */
    1.45          andl $0xfffcbeff,UREGS_eflags+4(%esp)
    1.46 -        mov %gs,UREGS_ss+4(%esp)
    1.47 +        mov  %gs,UREGS_ss+4(%esp)
    1.48          movl %esi,UREGS_esp+4(%esp)
    1.49          movzwl TRAPBOUNCE_cs(%edx),%eax
    1.50          movl %eax,UREGS_cs+4(%esp)
    1.51          movl TRAPBOUNCE_eip(%edx),%eax
    1.52 +        test %eax,%eax
    1.53 +        jz   domain_crash_synchronous
    1.54          movl %eax,UREGS_eip+4(%esp)
    1.55          movb $0,TRAPBOUNCE_flags(%edx)
    1.56          ret
    1.57 @@ -670,7 +670,7 @@ do_switch_vm86:
    1.58  
    1.59          # GS:ESI == Ring-1 stack activation
    1.60          movl UREGS_esp(%esp),%esi
    1.61 -VFLT1:  mov UREGS_ss(%esp),%gs
    1.62 +VFLT1:  mov  UREGS_ss(%esp),%gs
    1.63  
    1.64          # ES:EDI == Ring-0 stack activation
    1.65          leal UREGS_eip(%esp),%edi
     2.1 --- a/xen/arch/x86/x86_32/seg_fixup.c	Fri Jun 10 15:45:23 2005 +0000
     2.2 +++ b/xen/arch/x86/x86_32/seg_fixup.c	Fri Jun 10 17:35:35 2005 +0000
     2.3 @@ -277,7 +277,7 @@ int gpf_emulate_4gb(struct cpu_user_regs
     2.4      u32           disp32 = 0;
     2.5      u8            *eip;         /* ptr to instruction start */
     2.6      u8            *pb, b;       /* ptr into instr. / current instr. byte */
     2.7 -    u16           *pseg = NULL; /* segment for memory operand (NULL=default) */
     2.8 +    int            gs_override = 0;
     2.9  
    2.10      /* WARNING: We only work for ring-3 segments. */
    2.11      if ( unlikely(VM86_MODE(regs)) || unlikely(!RING_3(regs)) )
    2.12 @@ -310,30 +310,20 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.13          switch ( b )
    2.14          {
    2.15          case 0x67: /* Address-size override */
    2.16 -            DPRINTK("Unhandleable prefix byte %02x\n", b);
    2.17 -            goto fixme;
    2.18 +        case 0x2e: /* CS override */
    2.19 +        case 0x3e: /* DS override */
    2.20 +        case 0x26: /* ES override */
    2.21 +        case 0x64: /* FS override */
    2.22 +        case 0x36: /* SS override */
    2.23 +            DPRINTK("Unhandled prefix %02x\n", b);
    2.24 +            goto fail;
    2.25          case 0x66: /* Operand-size override */
    2.26          case 0xf0: /* LOCK */
    2.27          case 0xf2: /* REPNE/REPNZ */
    2.28          case 0xf3: /* REP/REPE/REPZ */
    2.29              break;
    2.30 -        case 0x2e: /* CS override */
    2.31 -            pseg = &regs->cs;
    2.32 -            break;
    2.33 -        case 0x3e: /* DS override */
    2.34 -            pseg = &regs->ds;
    2.35 -            break;
    2.36 -        case 0x26: /* ES override */
    2.37 -            pseg = &regs->es;
    2.38 -            break;
    2.39 -        case 0x64: /* FS override */
    2.40 -            pseg = &regs->fs;
    2.41 -            break;
    2.42          case 0x65: /* GS override */
    2.43 -            pseg = &regs->gs;
    2.44 -            break;
    2.45 -        case 0x36: /* SS override */
    2.46 -            pseg = &regs->ss;
    2.47 +            gs_override = 1;
    2.48              break;
    2.49          default: /* Not a prefix byte */
    2.50              goto done_prefix;
    2.51 @@ -341,6 +331,12 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.52      }
    2.53   done_prefix:
    2.54  
    2.55 +    if ( !gs_override )
    2.56 +    {
    2.57 +        DPRINTK("Only instructions with GS override\n");
    2.58 +        goto fail;
    2.59 +    }
    2.60 +
    2.61      decode = insn_decode[b]; /* opcode byte */
    2.62      pb++;
    2.63      if ( decode == 0 )
    2.64 @@ -351,12 +347,13 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.65      
    2.66      if ( !(decode & HAS_MODRM) )
    2.67      {
    2.68 +        /* Must be a <disp32>, or bail. */
    2.69          if ( (decode & 7) != 4 )
    2.70              goto fail;
    2.71  
    2.72          if ( get_user(offset, (u32 *)pb) )
    2.73          {
    2.74 -            DPRINTK("Fault while extracting <disp8>.\n");
    2.75 +            DPRINTK("Fault while extracting <disp32>.\n");
    2.76              goto page_fault;
    2.77          }
    2.78          pb += 4;
    2.79 @@ -394,8 +391,6 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.80      switch ( modrm >> 6 )
    2.81      {
    2.82      case 0:
    2.83 -        if ( pseg == NULL )
    2.84 -            pseg = &regs->ds;
    2.85          disp32 = 0;
    2.86          if ( rm == 5 ) /* disp32 rather than (EBP) */
    2.87          {
    2.88 @@ -410,8 +405,6 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.89          break;
    2.90  
    2.91      case 1:
    2.92 -        if ( pseg == NULL ) /* NB. EBP defaults to SS */
    2.93 -            pseg = (rm == 5) ? &regs->ss : &regs->ds;
    2.94          if ( get_user(disp8, pb) )
    2.95          {
    2.96              DPRINTK("Fault while extracting <disp8>.\n");
    2.97 @@ -422,8 +415,6 @@ int gpf_emulate_4gb(struct cpu_user_regs
    2.98          break;
    2.99  
   2.100      case 2:
   2.101 -        if ( pseg == NULL ) /* NB. EBP defaults to SS */
   2.102 -            pseg = (rm == 5) ? &regs->ss : &regs->ds;
   2.103          if ( get_user(disp32, (u32 *)pb) )
   2.104          {
   2.105              DPRINTK("Fault while extracting <disp8>.\n");
   2.106 @@ -442,7 +433,7 @@ int gpf_emulate_4gb(struct cpu_user_regs
   2.107          offset += *(u32 *)memreg;
   2.108  
   2.109   skip_modrm:
   2.110 -    if ( !fixup_seg((u16)(*pseg), offset) )
   2.111 +    if ( !fixup_seg((u16)regs->gs, offset) )
   2.112          goto fail;
   2.113  
   2.114      /* Success! */
     3.1 --- a/xen/arch/x86/x86_64/entry.S	Fri Jun 10 15:45:23 2005 +0000
     3.2 +++ b/xen/arch/x86/x86_64/entry.S	Fri Jun 10 17:35:35 2005 +0000
     3.3 @@ -320,8 +320,6 @@ FLT4:   movq  %rax,16(%rsi)             
     3.4          movw  UREGS_cs+8(%rsp),%ax      # Bits  0-15: CS
     3.5  FLT5:   movq  %rax,8(%rsi)              # CS/saved_upcall_mask
     3.6          movq  UREGS_rip+8(%rsp),%rax
     3.7 -        testq %rax,%rax
     3.8 -        jz    domain_crash_synchronous
     3.9  FLT6:   movq  %rax,(%rsi)               # RIP
    3.10          testb $TBF_EXCEPTION_ERRCODE,%cl
    3.11          jz    1f
    3.12 @@ -357,6 +355,8 @@ FLT14:  movq  %rax,(%rsi)               
    3.13          movq  %rsi,UREGS_rsp+8(%rsp)
    3.14          movq  $__GUEST_CS,UREGS_cs+8(%rsp)
    3.15          movq  TRAPBOUNCE_eip(%rdx),%rax
    3.16 +        testq %rax,%rax
    3.17 +        jz    domain_crash_synchronous
    3.18          movq  %rax,UREGS_rip+8(%rsp)
    3.19          movb  $0,TRAPBOUNCE_flags(%rdx)
    3.20          ret