From patchwork Sat May 13 15:58:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9725381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F906601E7 for ; Sat, 13 May 2017 15:59:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA00B288C2 for ; Sat, 13 May 2017 15:59:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C97C8288E4; Sat, 13 May 2017 15:59:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53617288C2 for ; Sat, 13 May 2017 15:59:29 +0000 (UTC) Received: from localhost ([::1]:58071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9ZS3-0000ZL-P9 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 13 May 2017 11:59:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9ZR3-0000ZD-5X for qemu-devel@nongnu.org; Sat, 13 May 2017 11:58:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9ZQy-0007c0-AL for qemu-devel@nongnu.org; Sat, 13 May 2017 11:58:25 -0400 Received: from mail-yw0-x241.google.com ([2607:f8b0:4002:c05::241]:34400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9ZQy-0007aD-4Q for qemu-devel@nongnu.org; Sat, 13 May 2017 11:58:20 -0400 Received: by mail-yw0-x241.google.com with SMTP id 17so3275179ywk.1 for ; Sat, 13 May 2017 08:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=GhBE0pHjixixPmaTymWBum2hvYODSgornQ76hk4XPDo=; b=GX8F934xxj7YUNUGuyog5tNiO45fwi2afrYJUVLHJDUD+pxkoOBkFibgXdnz18ipoG /GHnUP0UYMaJBM9ECerCkokaIpP+ugqEg+7F2IeaY4EwbB6+sLAkyVlIvo2WytuJozwb 7REryUTZqMn6hDjvFNmvaIqsyD1mps36KX5pEJFc7es1BfnzFwL8fCe4AzCKI1YOkLg/ MhVnwDVFApr3h9cM7oeZR0B157AcaIy+Ddj9k9VEw+Q3MdhvYp5kZ4sSS2zLbLNj71HX 8fe0ToxeJuqxtx8LethkAQugFtPT6HH/VlmKf2ol6fSFnthh638VKJ/kJiGs+jLhJroN yz2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=GhBE0pHjixixPmaTymWBum2hvYODSgornQ76hk4XPDo=; b=olzgdISOvgjeDrB5Fqo8wEpJ0ooAzN6B59D/dbkV2sNWnhh/Gzxe6pM2lUTuZCWAcE 0pdbarEu+rUPJexffB9nrbcNjwTj7Tx+cZJVNY/KcYSb6K9QTdOKl8vWaPQo3jAAXsei l+OAv3MeEBKrECzQ3GjKx/jCmPBdO6nBUauJ3spiunK4j6muYh7++VFfriq2TrfB7wzw Kz17CgTzBALoNhv2UpXwhBVbqi34qzcUutqN4VKYvG2FUVO9XyeNFwdeslpiVOsPy0MY VJAn/pJ6EWkNsaJ0RnowheNfMPgsN7IaqyldDo6oGexfRl5JpFKZ+wY8OsUHBVb6XIgW faLQ== X-Gm-Message-State: AODbwcBg3O8cN2UxyWsTPk8Z4OVQuEXXhw8V6RTVdOEnntA0eOZTKign mXp8ZHBmUzgdoQ== X-Received: by 10.129.95.84 with SMTP id t81mr7437357ywb.73.1494691097859; Sat, 13 May 2017 08:58:17 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id u187sm2976491ywg.65.2017.05.13.08.58.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 May 2017 08:58:17 -0700 (PDT) From: Pranith Kumar To: Paolo Bonzini , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org (open list:All patches CC here) Date: Sat, 13 May 2017 11:58:16 -0400 Message-Id: <20170513155816.17294-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.13.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::241 Subject: [Qemu-devel] [PATCH] tcg/i386: 'nop' instruction with 'lock' prefix is illegal X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The instruction "lock nopl (%rax)" should raise an exception. However, we don't do that since we do not check for lock prefix for nop instructions. The following patch adds this check and makes the behavior similar to hardware. Signed-off-by: Pranith Kumar --- target/i386/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index 1d1372fb43..76f4ccd3b4 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -7881,6 +7881,9 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_nop_modrm(env, s, modrm); break; case 0x119: case 0x11c ... 0x11f: /* nop (multi byte) */ + if (prefixes & PREFIX_LOCK) { + goto illegal_op; + } modrm = cpu_ldub_code(env, s->pc++); gen_nop_modrm(env, s, modrm); break;