ia64/xen-unstable

changeset 9593:c1d53788a25e

Add support for XCHG instruction accessing LAPIC device model.

Signed-off-by: Boris Ostrovsky <bostrovsky@virtualiron.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 05 15:42:01 2006 +0100 (2006-04-05)
parents 08aede767c63
children 133ce326febd
files xen/Rules.mk xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/platform.c xen/include/asm-x86/hvm/io.h xen/include/public/hvm/ioreq.h
line diff
     1.1 --- a/xen/Rules.mk	Wed Apr 05 15:00:42 2006 +0100
     1.2 +++ b/xen/Rules.mk	Wed Apr 05 15:42:01 2006 +0100
     1.3 @@ -31,6 +31,9 @@ HDRS    := $(wildcard $(BASEDIR)/include
     1.4  HDRS    += $(wildcard $(BASEDIR)/include/public/*.h)
     1.5  HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h)
     1.6  HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h)
     1.7 +HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/hvm/*.h)
     1.8 +HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/hvm/svm/*.h)
     1.9 +HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/hvm/vmx/*.h)
    1.10  # Do not depend on auto-generated header files.
    1.11  HDRS    := $(subst $(BASEDIR)/include/asm-$(TARGET_ARCH)/asm-offsets.h,,$(HDRS))
    1.12  HDRS    := $(subst $(BASEDIR)/include/xen/banner.h,,$(HDRS))
     2.1 --- a/xen/arch/x86/hvm/intercept.c	Wed Apr 05 15:00:42 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/intercept.c	Wed Apr 05 15:42:01 2006 +0100
     2.3 @@ -123,6 +123,16 @@ static inline void hvm_mmio_access(struc
     2.4          req->u.data = tmp1;
     2.5          break;
     2.6  
     2.7 +    case IOREQ_TYPE_XCHG:
     2.8 +        /* 
     2.9 +         * Note that we don't need to be atomic here since VCPU is accessing
    2.10 +         * its own local APIC.
    2.11 +         */
    2.12 +        tmp1 = read_handler(v, req->addr, req->size);
    2.13 +        write_handler(v, req->addr, req->size, (unsigned long) req->u.data);
    2.14 +        req->u.data = tmp1;
    2.15 +        break;
    2.16 +
    2.17      default:
    2.18          printk("error ioreq type for local APIC %x\n", req->type);
    2.19          domain_crash_synchronous();
    2.20 @@ -143,7 +153,7 @@ int hvm_mmio_intercept(ioreq_t *p)
    2.21          if ( hvm_mmio_handlers[i]->check_handler(v, p->addr) ) {
    2.22              hvm_mmio_access(v, p,
    2.23                              hvm_mmio_handlers[i]->read_handler,
    2.24 -	                    hvm_mmio_handlers[i]->write_handler);
    2.25 +                            hvm_mmio_handlers[i]->write_handler);
    2.26              return 1;
    2.27          }
    2.28      }
     3.1 --- a/xen/arch/x86/hvm/platform.c	Wed Apr 05 15:00:42 2006 +0100
     3.2 +++ b/xen/arch/x86/hvm/platform.c	Wed Apr 05 15:42:01 2006 +0100
     3.3 @@ -439,6 +439,14 @@ static int hvm_decode(int realmode, unsi
     3.4          GET_OP_SIZE_FOR_BYTE(size_reg);
     3.5          return mem_reg(size_reg, opcode, instr, rex);
     3.6  
     3.7 +    case 0x87:  /* xchg {r/m16|r/m32}, {m/r16|m/r32} */
     3.8 +        instr->instr = INSTR_XCHG;
     3.9 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
    3.10 +        if (((*(opcode+1)) & 0xc7) == 5)
    3.11 +            return reg_mem(instr->op_size, opcode, instr, rex);
    3.12 +        else
    3.13 +            return mem_reg(instr->op_size, opcode, instr, rex);
    3.14 +
    3.15      case 0x88: /* mov r8, m8 */
    3.16          instr->instr = INSTR_MOV;
    3.17          instr->op_size = BYTE;
    3.18 @@ -936,6 +944,17 @@ void handle_mmio(unsigned long va, unsig
    3.19              break;
    3.20          }
    3.21  
    3.22 +    case INSTR_XCHG:
    3.23 +        mmio_opp->flags = mmio_inst.flags;
    3.24 +        mmio_opp->instr = mmio_inst.instr;
    3.25 +        mmio_opp->operand[0] = mmio_inst.operand[0]; /* source */
    3.26 +        mmio_opp->operand[1] = mmio_inst.operand[1]; /* destination */
    3.27 +
    3.28 +        /* send the request and wait for the value */
    3.29 +        send_mmio_req(IOREQ_TYPE_XCHG, gpa, 1,
    3.30 +                      mmio_inst.op_size, 0, IOREQ_WRITE, 0);
    3.31 +        break;
    3.32 +
    3.33      default:
    3.34          printf("Unhandled MMIO instruction\n");
    3.35          domain_crash_synchronous();
     4.1 --- a/xen/include/asm-x86/hvm/io.h	Wed Apr 05 15:00:42 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/io.h	Wed Apr 05 15:42:01 2006 +0100
     4.3 @@ -66,6 +66,7 @@
     4.4  #define INSTR_STOS  10
     4.5  #define INSTR_TEST  11
     4.6  #define INSTR_BT    12
     4.7 +#define INSTR_XCHG  13
     4.8  
     4.9  struct instruction {
    4.10      __s8    instr;        /* instruction type */
     5.1 --- a/xen/include/public/hvm/ioreq.h	Wed Apr 05 15:00:42 2006 +0100
     5.2 +++ b/xen/include/public/hvm/ioreq.h	Wed Apr 05 15:42:01 2006 +0100
     5.3 @@ -34,6 +34,7 @@
     5.4  #define IOREQ_TYPE_AND          2
     5.5  #define IOREQ_TYPE_OR           3
     5.6  #define IOREQ_TYPE_XOR          4
     5.7 +#define IOREQ_TYPE_XCHG         5
     5.8  
     5.9  /*
    5.10   * VMExit dispatcher should cooperate with instruction decoder to