From patchwork Tue Feb 11 21:02:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xabier Ugarte-Pedrero X-Patchwork-Id: 319422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1E4CE2C009C for ; Wed, 12 Feb 2014 08:37:36 +1100 (EST) Received: from localhost ([::1]:36097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDKxQ-0005u4-Vb for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 16:33:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDKvA-0002LZ-5s for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:31:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDKv4-000889-Kj for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:31:11 -0500 Received: from ppp-seco21th2-46-193-160-128.wb.wifirst.net ([46.193.160.128]:41884 helo=xabi-desktop) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDKv3-00085R-Ea for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:31:06 -0500 Received: from xabi-desktop (xabi-desktop.local [192.168.0.1]) by xabi-desktop (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id s1BL6PW2026756; Tue, 11 Feb 2014 22:06:26 +0100 Received: (from xabi@localhost) by xabi-desktop (8.14.4/8.14.4/Submit) id s1BL6PTC026752; Tue, 11 Feb 2014 22:06:25 +0100 From: Xabier Ugarte-Pedrero To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 22:02:59 +0100 Message-Id: <1392152582-26703-3-git-send-email-xabier.ugarte@deusto.es> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392152582-26703-1-git-send-email-xabier.ugarte@deusto.es> References: <1392152582-26703-1-git-send-email-xabier.ugarte@deusto.es> MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by xabi-desktop id s1BL6PW2026756 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 46.193.160.128 Cc: Xabier Ugarte-Pedrero Subject: [Qemu-devel] [PATCH 1/3] X86: Invalid lock prefix (F0) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If the lock prefix (F0) is prepended more than once to any instruction, then it should generate an invalid instruction exception (illegal_op). See Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2A: Instruction Set Reference, A-M. Order Number: 253666-049US February 2014. See “LOCK—Assert LOCK# Signal Prefix” in Chapter 3. Signed-off-by: Xabier Ugarte-Pedrero --- target-i386/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target-i386/translate.c b/target-i386/translate.c index b0f2279..733e5b2 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -4415,6 +4415,12 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, prefixes |= PREFIX_REPNZ; goto next_byte; case 0xf0: + /*Invalid lock sequence*/ + if (prefixes & PREFIX_LOCK){ + /*Clear the PREFIX_LOCK FLAG*/ + prefixes &= !PREFIX_LOCK; + goto illegal_op; + } prefixes |= PREFIX_LOCK; goto next_byte; case 0x2e: