From nobody Thu May 2 01:44:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544202914331609.3061407068499; Fri, 7 Dec 2018 09:15:14 -0800 (PST) Received: from localhost ([::1]:47371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVJiX-0000n8-5Q for importer@patchew.org; Fri, 07 Dec 2018 12:15:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVJdc-00047k-MA for qemu-devel@nongnu.org; Fri, 07 Dec 2018 12:10:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVJdY-0003Cq-3T for qemu-devel@nongnu.org; Fri, 07 Dec 2018 12:10:04 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:41314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gVJdX-0003Bc-LE for qemu-devel@nongnu.org; Fri, 07 Dec 2018 12:10:00 -0500 Received: by mail-ot1-x341.google.com with SMTP id u16so4423902otk.8 for ; Fri, 07 Dec 2018 09:09:59 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id j1sm1634664otl.43.2018.12.07.09.09.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 09:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=NBsR8ELIfLoS3PfzpHyKjCKY8P0UXYmmrwyCh7RrMV8=; b=L7EhLD2H+/YrAB7dzTPzdzOoqrGcSEYbHSE6YhtcX3rd3TkJ38toAnu8Aur1MGwXQg 7N1OkaJ6VftD2DzPglwM+ocaVcvteyakJiVlP0pIgWAJGdeEY7xmaCGuBWKXst20xQlP d4DBhtqlRaF6y+Pq0W5D3KYwvotmTIMTjqioQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NBsR8ELIfLoS3PfzpHyKjCKY8P0UXYmmrwyCh7RrMV8=; b=kkTtRi873AfsLMNV5Izwc8j0+65P329b08NNSEB3LphIvERTch2IrlxRlDMp3oxFZo I6WnLPuEKYwV6O1IGIJO3nmrafab01IGtV2nVG1yag+Yn6BaPABkG4dg7XVTZB4Kj6oR K0foH8OA50W2UqfmMA1PtTwK0Pv7y+K03vbwE7vCALTyjewoiAb1xKM2Jg48Y/ym5jVi PRkysM68kF9RYim7t81IJMxuqV5wuSJ6YWEmIWz6cJbUomOhMsVX6snfLKbwLYqUYYGW PDEEEVqDdmQfq6alHOvJsv74eGn78NJe75LKzBEI9UV24CYCom5cLiuV5vTnanKNG0Ok fuaQ== X-Gm-Message-State: AA+aEWbfVBA71f3dqlBQOYxFGtIkA8kQmZ+8ZfeRhRi70iWVlN7Dg4jC /H0uK5NpQbmI9WbFEZd+IylriD7+ndw= X-Google-Smtp-Source: AFSGD/XZT23UkttwxTmARISEo8RdWKjwEdWuDpW2RegFS0NQWRMnyJ9eW6Y53gRIh7jp5bS1MgFXSQ== X-Received: by 2002:a9d:18f:: with SMTP id e15mr2117814ote.84.1544202598547; Fri, 07 Dec 2018 09:09:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 11:09:51 -0600 Message-Id: <20181207170951.7307-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::341 Subject: [Qemu-devel] [PATCH] target/i386: Generate #UD when applying LOCK to a register 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: , Cc: pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This covers inc, dec, and the bit test instructions. I believe we've finally covered all of the cases for which we have an atomic path that would use the cpu_A0 temp, which is only initialized for address sources. Fixes: https://bugs.launchpad.net/qemu/+bug/1803160/comments/4 Signed-off-by: Richard Henderson Reported-by: Alberto Ortega Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index 0dd5fbe45c..eb52322a47 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemO= p ot, int d) static void gen_inc(DisasContext *s1, TCGMemOp ot, int d, int c) { if (s1->prefix & PREFIX_LOCK) { + if (d !=3D OR_TMP0) { + /* Lock prefix when destination is not memory. */ + gen_illegal_opcode(s1); + return; + } tcg_gen_movi_tl(s1->T0, c > 0 ? 1 : -1); tcg_gen_atomic_add_fetch_tl(s1->T0, s1->A0, s1->T0, s1->mem_index, ot | MO_LE); @@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_ld_v(s, ot, s->T0, s->A0); } } else { + if (s->prefix & PREFIX_LOCK) { + goto illegal_op; + } gen_op_mov_v_reg(s, ot, s->T0, rm); } /* load shift */ @@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_ld_v(s, ot, s->T0, s->A0); } } else { + if (s->prefix & PREFIX_LOCK) { + goto illegal_op; + } gen_op_mov_v_reg(s, ot, s->T0, rm); } bt_op: --=20 2.17.2