diff mbox

[1/2] KVM: x86 emulator: Disable writeback for CMP emulation

Message ID 20110329013229.20e6168f.takuya.yoshikawa@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Takuya Yoshikawa March 28, 2011, 4:32 p.m. UTC
None

Comments

Avi Kivity April 3, 2011, 2:42 p.m. UTC | #1
On 03/28/2011 06:32 PM, Takuya Yoshikawa wrote:
> From: Takuya Yoshikawa<yoshikawa.takuya@oss.ntt.co.jp>
>
> This stops "CMP r/m, reg" to write back the data into memory.
> Pointed out by Avi.
>
> Signed-off-by: Takuya Yoshikawa<yoshikawa.takuya@oss.ntt.co.jp>
> ---
>   arch/x86/kvm/emulate.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 14c5ad5..8a73805 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -3084,6 +3084,7 @@ special_insn:
>   		emulate_2op_SrcV("xor", c->src, c->dst, ctxt->eflags);
>   		break;
>   	case 0x38 ... 0x3d:
> +		c->dst.type = OP_NONE; /* Disable writeback. */
>   	      cmp:		/* cmp */

Why not disable writeback here?  As a prelude to having em_cmp() which 
does everything?

I see SCAS also does a 'goto cmp', but it also benefits from disabling 
writeback.

>   		emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags);
>   		break;
> @@ -3138,6 +3139,7 @@ special_insn:
>   		case 6:
>   			goto xor;
>   		case 7:
> +			c->dst.type = OP_NONE; /* Disable writeback. */
>   			goto cmp;
>   		}
>   		break;
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 14c5ad5..8a73805 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3084,6 +3084,7 @@  special_insn:
 		emulate_2op_SrcV("xor", c->src, c->dst, ctxt->eflags);
 		break;
 	case 0x38 ... 0x3d:
+		c->dst.type = OP_NONE; /* Disable writeback. */
 	      cmp:		/* cmp */
 		emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags);
 		break;
@@ -3138,6 +3139,7 @@  special_insn:
 		case 6:
 			goto xor;
 		case 7:
+			c->dst.type = OP_NONE; /* Disable writeback. */
 			goto cmp;
 		}
 		break;