diff mbox

KVM: x86: Fix cmpxchg with two 32-bit registers

Message ID 1430061048-14958-1-git-send-email-namit@cs.technion.ac.il (mailing list archive)
State New, archived
Headers show

Commit Message

Nadav Amit April 26, 2015, 3:10 p.m. UTC
The emulation of CMPXCHG with two register operands in 64-bit mistakenly masks
the high 32-bits as it performs assignment. Fix it.

Fixes: 2fcf5c8ae244b4c298d2111a288d410a719ac626

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
 arch/x86/kvm/emulate.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paolo Bonzini April 27, 2015, 1:37 p.m. UTC | #1
On 26/04/2015 17:10, Nadav Amit wrote:
> The emulation of CMPXCHG with two register operands in 64-bit mistakenly masks
> the high 32-bits as it performs assignment. Fix it.
> 
> Fixes: 2fcf5c8ae244b4c298d2111a288d410a719ac626
> 
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
> ---
>  arch/x86/kvm/emulate.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 630bcb0..84c132b 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2242,6 +2242,8 @@ static int em_cmpxchg(struct x86_emulate_ctxt *ctxt)
>  		ctxt->src.val = ctxt->dst.orig_val;
>  		/* Create write-cycle to dest by writing the same value */
>  		ctxt->dst.val = ctxt->dst.orig_val;
> +		if (ctxt->dst.type != OP_MEM)
> +			ctxt->dst.type = OP_NONE;
>  	}
>  	return X86EMUL_CONTINUE;
>  }
> 

Applied, thanks.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 630bcb0..84c132b 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2242,6 +2242,8 @@  static int em_cmpxchg(struct x86_emulate_ctxt *ctxt)
 		ctxt->src.val = ctxt->dst.orig_val;
 		/* Create write-cycle to dest by writing the same value */
 		ctxt->dst.val = ctxt->dst.orig_val;
+		if (ctxt->dst.type != OP_MEM)
+			ctxt->dst.type = OP_NONE;
 	}
 	return X86EMUL_CONTINUE;
 }