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 +
    1.58      regs = mmio_opp->inst_decoder_regs;
    1.59 +    store_cpu_user_regs(regs);
    1.60  
    1.61 -    __vmread(GUEST_RIP, &eip);
    1.62      __vmread(VM_EXIT_INSTRUCTION_LEN, &inst_len);
    1.63 -    __vmread(GUEST_RFLAGS, &eflags);
    1.64 -    vm86 = eflags & X86_EFLAGS_VM;
    1.65  
    1.66 -    if (vm86) {
    1.67 -        __vmread(GUEST_CS_SELECTOR, &cs);
    1.68 -        inst_addr = (cs << 4) + eip;
    1.69 -    } else
    1.70 -        inst_addr = eip;
    1.71 +    vm86 = regs->eflags & X86_EFLAGS_VM;
    1.72 +    if (vm86)
    1.73 +        inst_addr = (regs->cs << 4) + regs->eip;
    1.74 +    else
    1.75 +        inst_addr = regs->eip;
    1.76  
    1.77      memset(inst, 0, MAX_INST_LEN);
    1.78      ret = inst_copy_from_guest(inst, inst_addr, inst_len);
    1.79 @@ -756,7 +746,7 @@ void handle_mmio(unsigned long va, unsig
    1.80  
    1.81      init_instruction(&mmio_inst);
    1.82  
    1.83 -    if (vmx_decode(inst, &mmio_inst) == DECODE_failure) {
    1.84 +    if (vmx_decode(vm86, inst, &mmio_inst) == DECODE_failure) {
    1.85          printf("mmio opcode: va 0x%lx, gpa 0x%lx, len %ld:",
    1.86                 va, gpa, inst_len);
    1.87          for (i = 0; i < inst_len; i++)
    1.88 @@ -765,7 +755,6 @@ void handle_mmio(unsigned long va, unsig
    1.89          domain_crash_synchronous();
    1.90      }
    1.91  
    1.92 -    store_cpu_user_regs(regs);
    1.93      regs->eip += inst_len; /* advance %eip */
    1.94  
    1.95      switch (mmio_inst.instr) {
    1.96 @@ -783,16 +772,12 @@ void handle_mmio(unsigned long va, unsig
    1.97  
    1.98          /* determine non-MMIO address */
    1.99          if (vm86) {
   1.100 -            unsigned long seg;
   1.101 -
   1.102 -            __vmread(GUEST_ES_SELECTOR, &seg);
   1.103 -            if (((seg << 4) + (regs->edi & 0xFFFF)) == va) {
   1.104 +            if (((regs->es << 4) + (regs->edi & 0xFFFF)) == va) {
   1.105                  dir = IOREQ_WRITE;
   1.106 -                __vmread(GUEST_DS_SELECTOR, &seg);
   1.107 -                addr = (seg << 4) + (regs->esi & 0xFFFF);
   1.108 +                addr = (regs->ds << 4) + (regs->esi & 0xFFFF);
   1.109              } else {
   1.110                  dir = IOREQ_READ;
   1.111 -                addr = (seg << 4) + (regs->edi & 0xFFFF);
   1.112 +                addr = (regs->es << 4) + (regs->edi & 0xFFFF);
   1.113              }
   1.114          } else {
   1.115              if (va == regs->edi) {