]> xenbits.xensource.com Git - people/gdunlap/xen.git/commitdiff
x86/hvm: move MAX_INST_LEN into x86_emulate.h
authorDon Slutz <dslutz@verizon.com>
Wed, 18 Feb 2015 16:00:47 +0000 (17:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 18 Feb 2015 16:00:47 +0000 (17:00 +0100)
Change some hard coded 15 into MAX_INST_LEN.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/svm/emulate.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/x86_emulate/x86_emulate.c
xen/arch/x86/x86_emulate/x86_emulate.h

index 37a1ecea9a8465b103b76b03240715c78eda476f..6f5c8d3a0f6086cb5246890b74f088399ef819b5 100644 (file)
@@ -27,8 +27,6 @@
 #include <asm/hvm/svm/vmcb.h>
 #include <asm/hvm/svm/emulate.h>
 
-#define MAX_INST_LEN 15
-
 static unsigned int is_prefix(u8 opc)
 {
     switch ( opc )
index 018dd708c2b5d3ed108b1b55f3bbc2d738c85ce4..d82b434e0f95f3f693c4756e2350b161b03c4237 100644 (file)
@@ -106,7 +106,7 @@ void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len)
     if ( unlikely(inst_len == 0) )
         return;
 
-    if ( unlikely(inst_len > 15) )
+    if ( unlikely(inst_len > MAX_INST_LEN) )
     {
         gdprintk(XENLOG_ERR, "Bad instruction length %u\n", inst_len);
         svm_crash_or_fault(curr);
@@ -859,7 +859,7 @@ static unsigned int svm_get_insn_bytes(struct vcpu *v, uint8_t *buf)
     if ( len != 0 )
     {
         /* Latch and clear the cached instruction. */
-        memcpy(buf, vmcb->guest_ins, 15);
+        memcpy(buf, vmcb->guest_ins, MAX_INST_LEN);
         v->arch.hvm_svm.cached_insn_len = 0;
     }
 
index 357ef6c58a9353715c2678e454aa345c815bdb8f..e1c55ce815121b8cf0b62e74bef6f773a490f813 100644 (file)
@@ -1854,7 +1854,7 @@ static int get_instruction_length(void)
     unsigned long len;
 
     __vmread(VM_EXIT_INSTRUCTION_LEN, &len); /* Safe: callers audited */
-    BUG_ON((len < 1) || (len > 15));
+    BUG_ON((len < 1) || (len > MAX_INST_LEN));
     return len;
 }
 
index f13f07d21413ff1a28f99b383ab86631001c999b..5e9e0403c793cb58a3f537fdf92cfb58ca5b91cb 100644 (file)
@@ -579,7 +579,8 @@ do{ asm volatile (                                                      \
 ({ unsigned long _x = 0, _eip = _regs.eip;                              \
    if ( !mode_64bit() ) _eip = (uint32_t)_eip; /* ignore upper dword */ \
    _regs.eip += (_size); /* real hardware doesn't truncate */           \
-   generate_exception_if((uint8_t)(_regs.eip - ctxt->regs->eip) > 15,   \
+   generate_exception_if((uint8_t)(_regs.eip -                          \
+                                   ctxt->regs->eip) > MAX_INST_LEN,     \
                          EXC_GP, 0);                                    \
    rc = ops->insn_fetch(x86_seg_cs, _eip, &_x, (_size), ctxt);          \
    if ( rc ) goto done;                                                 \
index bdce8619f6c45c1d262f9a7b235b0081e06a6d88..593b31e84603f6aea0a785578b7a91d399fb61fc 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __X86_EMULATE_H__
 #define __X86_EMULATE_H__
 
+#define MAX_INST_LEN 15
+
 struct x86_emulate_ctxt;
 
 /* Comprehensive enumeration of x86 segment registers. */