From: Jan Kiszka <[email protected]>

This fixes one case around mov imm,<addr>: We read the immediate value
to be written, but we forgot to update inst_len. This fixes that issue
by moving the update from ctx.count to inst.inst_len to the very end
of the parser.

Fixes: 95202a038b9e ("x86,mmio: Add support for 1 more instructions on
                      the MMIO dispatcher")
Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/x86/mmio.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hypervisor/arch/x86/mmio.c b/hypervisor/arch/x86/mmio.c
index d7a6c0019..8139a462d 100644
--- a/hypervisor/arch/x86/mmio.c
+++ b/hypervisor/arch/x86/mmio.c
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2018
  * Copyright (c) Valentine Sinitsyn, 2014
  *
  * Authors:
@@ -130,12 +130,12 @@ restart:
                does_write = true;
                break;
        case X86_OP_MOV_MEM_TO_AX:
-               inst.inst_len = ctx.count + 4;
+               inst.inst_len += 4;
                inst.access_size = has_rex_w ? 8 : 4;
                inst.in_reg_num = 15;
                goto final;
        case X86_OP_MOV_AX_TO_MEM:
-               inst.inst_len = ctx.count + 4;
+               inst.inst_len += 4;
                inst.access_size = has_rex_w ? 8 : 4;
                inst.out_val = guest_regs->by_index[15];
                does_write = true;
@@ -179,7 +179,6 @@ restart:
                goto error_unsupported;
        }
 
-       inst.inst_len += ctx.count;
        if (has_rex_r)
                inst.in_reg_num = 7 - op[2].modrm.reg;
        else if (op[2].modrm.reg == 4)
@@ -200,6 +199,8 @@ final:
        if (does_write != is_write)
                goto error_inconsitent;
 
+       inst.inst_len += ctx.count;
+
        return inst;
 
 error_noinst:
-- 
2.13.6

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to