Skip to content

Commit 12fa272

Browse files
Nitin A Kambleavikivity
authored andcommitted
KVM: x86 emulator: fix src, dst value initialization
Some operand fetches are less than the machine word size and can result in stale bits if used together with operands of different sizes. Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
1 parent 26a3e98 commit 12fa272

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/kvm/x86_emulate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
827827
srcmem_common:
828828
src.type = OP_MEM;
829829
src.ptr = (unsigned long *)cr2;
830+
src.val = 0;
830831
if ((rc = ops->read_emulated((unsigned long)src.ptr,
831832
&src.val, src.bytes, ctxt->vcpu)) != 0)
832833
goto done;
@@ -891,6 +892,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
891892
dst.type = OP_MEM;
892893
dst.ptr = (unsigned long *)cr2;
893894
dst.bytes = (d & ByteOp) ? 1 : op_bytes;
895+
dst.val = 0;
894896
if (d & BitOp) {
895897
unsigned long mask = ~(dst.bytes * 8 - 1);
896898

0 commit comments

Comments
 (0)