From patchwork Mon Feb 27 17:55:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 657116 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2490274wrb; Mon, 27 Feb 2023 09:57:28 -0800 (PST) X-Google-Smtp-Source: AK7set/PV7rl3yGMPF0gkt9WLcIUmfNjkdUCp0VpJcAkiRy9B0zHWB0MrBbYHgMOS1W6mK0y3AUl X-Received: by 2002:a05:6214:252f:b0:567:fe96:85a5 with SMTP id gg15-20020a056214252f00b00567fe9685a5mr595366qvb.22.1677520648709; Mon, 27 Feb 2023 09:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677520648; cv=none; d=google.com; s=arc-20160816; b=GXNsgUXhjyLWkujTGivk3cVO+Qrj3FIhX08+f4dCGuDlsgl3LL3fy0IROs29QR52om bYQMcIaG8xxmUZlpEU6ApY/6CcI9Qb5re0OPuERmn8cQSt5YFo29/vNOTIxd1fDSSjZL ncq8utwd/zd09HEdq5KDGa/m/2t2Q3P5NTF5PlHTjSjQ8k7ayDm7LF6aDvp2MzPUQ45j q2P0Shcuv3J+uST1ttigyHvh/TANlOAohqhuhnQk4guLxBVEGNnQGZnP5a5bd6PQzdRn faWPxF3aXekrkoo7Q6G0FUAU/f0VhGHuu+yA9EBypSprJt8xTD6sVOWzE8+AdHCxLMtS H+BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/cKztsXVeRHpYgALmCO8ArSZEBJfh5ujk1+B8eD0HHw=; b=ZJ5thQ9lotQn3EB+8Kb8YWPCcDg2p18p/q5uR/OBZOhH2qrGgwAFfHBwBmu2N818kh cF89c6zb51CrW4v/NRtTot8/j72Tkez7owxJaMKVCqs0+BQnhK/ZWklFh/ICFYkG+ty4 dfPyQ3g0wfMvQ8pWrSzZs+YpnEVzffosgD/5ql8xXA1NJ8Da5hJQg8eFq58JqLiJrjaI GM/Kh3nq6TfVvvRyAB3hHqLgfAYep2fQzCkI1PAjiXE/IokJfjG+Ty9JRIhKCDVOOMFw yTd7aQheX4RGWWv7zJWNe7LisV/cIj5tjq77aHJgTWi/8N5do8Cv0gywT0E05lX3B4Wx XCFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e4xQ7KLC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i21-20020a05620a405500b007423597d35csi7143300qko.521.2023.02.27.09.57.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 09:57:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e4xQ7KLC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWhiv-0003Lw-SD; Mon, 27 Feb 2023 12:55:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWhiq-0003IG-3l for qemu-devel@nongnu.org; Mon, 27 Feb 2023 12:55:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWhio-0004Lj-64 for qemu-devel@nongnu.org; Mon, 27 Feb 2023 12:55:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677520533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/cKztsXVeRHpYgALmCO8ArSZEBJfh5ujk1+B8eD0HHw=; b=e4xQ7KLCM3cik5xiF4k1ADooVX6XKJ0abU6MMukV06jn7hdCC8tEIiV3Fp68J+KebfjwVM POwIquA3AxD4ONMYFoskg3OREk0t+KoUzz+smqD2Xnmw3vzCpiSEJzqvqHY5LbHpqpXdmv ibZmR7llNL0gU8ql3K0sLG1qPPhPyw0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-45-fQiaM-1pPk61RgXI02mgzg-1; Mon, 27 Feb 2023 12:55:31 -0500 X-MC-Unique: fQiaM-1pPk61RgXI02mgzg-1 Received: by mail-ed1-f72.google.com with SMTP id cf11-20020a0564020b8b00b0049ec3a108beso9672216edb.7 for ; Mon, 27 Feb 2023 09:55:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/cKztsXVeRHpYgALmCO8ArSZEBJfh5ujk1+B8eD0HHw=; b=2w/BaXTzuNGDBoNqJhqo5eSVNbZGn8XzHkRWoIy+U+bVP3RxIaHxz+dTXezRDj5Wo0 NdtCgEeNpdKmIs7Eqca24hlImvGk1AcuRL7lAqXrf4LxyMh8nPMlcm7TRLQXeafQ9Hbp IaEA9B9Lzk07g/jw/hprePfqdVUplxa72vO/SaKS6nS3lKsRrjuMOvSWapy1AWTKCjUW 1BpAVbPe3kQwOvSOEd1+FjLhk5uzQ3orW8K3wX9RANZj6fONvGmSVvqbJVDwXNQHHLEC daSCyqaDjjTMEbLf610dDsxRPnVuajnhCvPIM39PKGl2FqmbYY8KF+LoHQIjdTM48ok4 PO+w== X-Gm-Message-State: AO0yUKUXyYydYbhjjAnCJKHyqaqBK/1h5oXxJtPHz2/yiqPgHu6n67fj PNm0yYyKD43N6m3N2cYiuRzwb7LZFpGMDwgupM3VSh40iyjuzVGpHri0QTEexBxDQepc/KlkZwz ny8mYEI2Z+CG4BKrBL4NticZTvQxpXHiYBjKxpxZiAmukn9TtXaF/wBQQZqd/S/ogp18ECZVh X-Received: by 2002:a17:906:bfcc:b0:87b:7c1d:e02b with SMTP id us12-20020a170906bfcc00b0087b7c1de02bmr35438433ejb.36.1677520530395; Mon, 27 Feb 2023 09:55:30 -0800 (PST) X-Received: by 2002:a17:906:bfcc:b0:87b:7c1d:e02b with SMTP id us12-20020a170906bfcc00b0087b7c1de02bmr35438411ejb.36.1677520529992; Mon, 27 Feb 2023 09:55:29 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id g15-20020a1709064e4f00b008ee64893786sm3522865ejw.99.2023.02.27.09.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 09:55:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 01/13] target/i386: Fix BZHI instruction Date: Mon, 27 Feb 2023 18:55:12 +0100 Message-Id: <20230227175524.710880-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230227175524.710880-1-pbonzini@redhat.com> References: <20230227175524.710880-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson We did not correctly handle N >= operand size. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1374 Signed-off-by: Richard Henderson Message-Id: <20230114233206.3118472-1-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/emit.c.inc | 14 +++++++------- tests/tcg/i386/test-i386-bmi2.c | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index e61ae9a2e92d..0d01e13002a6 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1147,20 +1147,20 @@ static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) static void gen_BZHI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) { MemOp ot = decode->op[0].ot; - TCGv bound; + TCGv bound = tcg_constant_tl(ot == MO_64 ? 63 : 31); + TCGv zero = tcg_constant_tl(0); + TCGv mone = tcg_constant_tl(-1); - tcg_gen_ext8u_tl(s->T1, cpu_regs[s->vex_v]); - bound = tcg_constant_tl(ot == MO_64 ? 63 : 31); + tcg_gen_ext8u_tl(s->T1, s->T1); /* * Note that since we're using BMILG (in order to get O * cleared) we need to store the inverse into C. */ - tcg_gen_setcond_tl(TCG_COND_LT, cpu_cc_src, s->T1, bound); - tcg_gen_movcond_tl(TCG_COND_GT, s->T1, s->T1, bound, bound, s->T1); + tcg_gen_setcond_tl(TCG_COND_LEU, cpu_cc_src, s->T1, bound); - tcg_gen_movi_tl(s->A0, -1); - tcg_gen_shl_tl(s->A0, s->A0, s->T1); + tcg_gen_shl_tl(s->A0, mone, s->T1); + tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->T1, bound, s->A0, zero); tcg_gen_andc_tl(s->T0, s->T0, s->A0); gen_op_update1_cc(s); diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c index 982d4abda455..0244df798778 100644 --- a/tests/tcg/i386/test-i386-bmi2.c +++ b/tests/tcg/i386/test-i386-bmi2.c @@ -123,6 +123,9 @@ int main(int argc, char *argv[]) { result = bzhiq(mask, 0x1f); assert(result == (mask & ~(-1 << 30))); + result = bzhiq(mask, 0x40); + assert(result == mask); + result = rorxq(0x2132435465768798, 8); assert(result == 0x9821324354657687);