ia64/xen-unstable

changeset 7624:289b73a5ace7

Simplified vmx_platform.c by removing obsolete code and redundant vmread's.

Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 03 09:58:45 2005 +0100 (2005-11-03)
parents ca2e91ab4311
children 98515ca23ca3
files xen/arch/x86/vmx_platform.c
line diff
     1.1 --- a/xen/arch/x86/vmx_platform.c	Thu Nov 03 02:45:07 2005 +0100
     1.2 +++ b/xen/arch/x86/vmx_platform.c	Thu Nov 03 09:58:45 2005 +0100
     1.3 @@ -366,21 +366,16 @@ static int reg_mem(unsigned char size, u
     1.4      return DECODE_success;
     1.5  }
     1.6  
     1.7 -static int vmx_decode(unsigned char *opcode, struct instruction *instr)
     1.8 +static int vmx_decode(int vm86, unsigned char *opcode, struct instruction *instr)
     1.9  {
    1.10 -    unsigned long eflags;
    1.11 -    int index, vm86 = 0;
    1.12 +    unsigned char size_reg = 0;
    1.13      unsigned char rex = 0;
    1.14 -    unsigned char size_reg = 0;
    1.15 +    int index;
    1.16  
    1.17      init_instruction(instr);
    1.18  
    1.19      opcode = check_prefix(opcode, instr, &rex);
    1.20  
    1.21 -    __vmread(GUEST_RFLAGS, &eflags);
    1.22 -    if (eflags & X86_EFLAGS_VM)
    1.23 -        vm86 = 1;
    1.24 -
    1.25      if (vm86) { /* meaning is reversed */
    1.26          if (instr->op_size == WORD)
    1.27              instr->op_size = LONG;
    1.28 @@ -636,7 +631,6 @@ void send_mmio_req(unsigned char type, u
    1.29      struct vcpu *v = current;
    1.30      vcpu_iodata_t *vio;
    1.31      ioreq_t *p;
    1.32 -    int vm86;
    1.33      struct cpu_user_regs *regs;
    1.34      extern long evtchn_send(int lport);
    1.35  
    1.36 @@ -650,8 +644,6 @@ void send_mmio_req(unsigned char type, u
    1.37  
    1.38      p = &vio->vp_ioreq;
    1.39  
    1.40 -    vm86 = regs->eflags & X86_EFLAGS_VM;
    1.41 -
    1.42      if (test_bit(ARCH_VMX_IO_WAIT, &v->arch.arch_vmx.flags)) {
    1.43          printf("VMX I/O has not yet completed\n");
    1.44          domain_crash_synchronous();
    1.45 @@ -725,7 +717,6 @@ static void mmio_operands(int type, unsi
    1.46  
    1.47  void handle_mmio(unsigned long va, unsigned long gpa)
    1.48  {
    1.49 -    unsigned long eip, eflags, cs;
    1.50      unsigned long inst_len, inst_addr;
    1.51      struct mmio_op *mmio_opp;
    1.52      struct cpu_user_regs *regs;
    1.53 @@ -734,18 +725,17 @@ void handle_mmio(unsigned long va, unsig
    1.54      int i, vm86, ret;
    1.55  
    1.56      mmio_opp = &current->arch.arch_vmx.mmio_op;
    1.57 -    regs = mmio_opp->inst_decoder_regs;
    1.58  
    1.59 -    __vmread(GUEST_RIP, &eip);
    1.60 +    regs = mmio_opp->inst_decoder_regs;
    1.61 +    store_cpu_user_regs(regs);
    1.62 +
    1.63      __vmread(VM_EXIT_INSTRUCTION_LEN, &inst_len);
    1.64 -    __vmread(GUEST_RFLAGS, &eflags);
    1.65 -    vm86 = eflags & X86_EFLAGS_VM;
    1.66  
    1.67 -    if (vm86) {
    1.68 -        __vmread(GUEST_CS_SELECTOR, &cs);
    1.69 -        inst_addr = (cs << 4) + eip;
    1.70 -    } else
    1.71 -        inst_addr = eip;
    1.72 +    vm86 = regs->eflags & X86_EFLAGS_VM;
    1.73 +    if (vm86)
    1.74 +        inst_addr = (regs->cs << 4) + regs->eip;
    1.75 +    else
    1.76 +        inst_addr = regs->eip;
    1.77  
    1.78      memset(inst, 0, MAX_INST_LEN);
    1.79      ret = inst_copy_from_guest(inst, inst_addr, inst_len);
    1.80 @@ -756,7 +746,7 @@ void handle_mmio(unsigned long va, unsig
    1.81  
    1.82      init_instruction(&mmio_inst);
    1.83  
    1.84 -    if (vmx_decode(inst, &mmio_inst) == DECODE_failure) {
    1.85 +    if (vmx_decode(vm86, inst, &mmio_inst) == DECODE_failure) {
    1.86          printf("mmio opcode: va 0x%lx, gpa 0x%lx, len %ld:",
    1.87                 va, gpa, inst_len);
    1.88          for (i = 0; i < inst_len; i++)
    1.89 @@ -765,7 +755,6 @@ void handle_mmio(unsigned long va, unsig
    1.90          domain_crash_synchronous();
    1.91      }
    1.92  
    1.93 -    store_cpu_user_regs(regs);
    1.94      regs->eip += inst_len; /* advance %eip */
    1.95  
    1.96      switch (mmio_inst.instr) {
    1.97 @@ -783,16 +772,12 @@ void handle_mmio(unsigned long va, unsig
    1.98  
    1.99          /* determine non-MMIO address */
   1.100          if (vm86) {
   1.101 -            unsigned long seg;
   1.102 -
   1.103 -            __vmread(GUEST_ES_SELECTOR, &seg);
   1.104 -            if (((seg << 4) + (regs->edi & 0xFFFF)) == va) {
   1.105 +            if (((regs->es << 4) + (regs->edi & 0xFFFF)) == va) {
   1.106                  dir = IOREQ_WRITE;
   1.107 -                __vmread(GUEST_DS_SELECTOR, &seg);
   1.108 -                addr = (seg << 4) + (regs->esi & 0xFFFF);
   1.109 +                addr = (regs->ds << 4) + (regs->esi & 0xFFFF);
   1.110              } else {
   1.111                  dir = IOREQ_READ;
   1.112 -                addr = (seg << 4) + (regs->edi & 0xFFFF);
   1.113 +                addr = (regs->es << 4) + (regs->edi & 0xFFFF);
   1.114              }
   1.115          } else {
   1.116              if (va == regs->edi) {