lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu,  4 Jul 2013 13:27:00 +0200
From:	Denys Vlasenko <dvlasenk@...hat.com>
To:	Gleb Natapov <gleb@...hat.com>, linux-kernel@...r.kernel.org
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Paolo Bonzini <pbonzini@...hat.com>,
	Avi Kivity <avi.kivity@...il.com>
Subject: [PATCH v2] x86/kvm/emulate.c: simplify NOP (opcode 0x90) check

We do not need to check for reg == RAX for opcodes 0x91...0x97.

Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
CC: Paolo Bonzini <pbonzini@...hat.com>
CC: Avi Kivity <avi.kivity@...il.com>

Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
CC: Paolo Bonzini <pbonzini@...hat.com>
CC: Avi Kivity <avi.kivity@...il.com>
---
 arch/x86/kvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2bc1e81..2dc48a1 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4544,9 +4544,14 @@ special_insn:
 	case 0x8d: /* lea r16/r32, m */
 		ctxt->dst.val = ctxt->src.addr.mem.ea;
 		break;
-	case 0x90 ... 0x97: /* nop / xchg reg, rax */
+	case 0x90: /* nop / xchg reg, rax */
+		/* Not all opcodes 90 are NOPs, only ones which refer to RAX */
+		/* For example, 49 90 is xchg %rax,%r8 */
+		/* Bare 90 and 40 90 (redundant REX prefix) are nop */
 		if (ctxt->dst.addr.reg == reg_rmw(ctxt, VCPU_REGS_RAX))
 			break;
+		/* Fall through */
+	case 0x91 ... 0x97: /* xchg reg, rax */
 		rc = em_xchg(ctxt);
 		break;
 	case 0x98: /* cbw/cwde/cdqe */
-- 
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ