From patchwork Mon Aug 5 12:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 816734 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp1311233wrh; Mon, 5 Aug 2024 05:17:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2nQvL9oPYs5XJ3csiLmo/znYuFt9EqgYrxYtOBSnBrmSxyLRWugC4yP1ml/saSBMPQWzxayZzc4Zju3f7kEBX X-Google-Smtp-Source: AGHT+IFbY36dTetIddegxZYjVppITzDK3XxvGXstM1e5v+CL+MPmEKu14n3VUIqx0LPqYlvOKTtT X-Received: by 2002:a05:6214:5d84:b0:6b7:a3da:1cdb with SMTP id 6a1803df08f44-6bb9837871amr119857686d6.21.1722860251365; Mon, 05 Aug 2024 05:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722860251; cv=none; d=google.com; s=arc-20160816; b=H7LUKxTTFmVmZfiJkqX6z4CjYISAifDc3QmU4l3/v9kxdJx/XGN7pUabmLVq2Wgj3R MU7BP63mmc1UWvNdvK9fM8sKmY6sp7OfRr0v10XdHLEDj/TTk006llJDwN9mR+AxIUnX wFQc/FFoXlm8gLgMO2kM6Oso1hSU523LbI2L1bfQuaiSEEoJpm7C4m+khLoYk/0iA7tN 1tdSr636/iqmAm3Vf9lZr9F9neFUg2dOdOe9uNMoBjMiMUD1EaqFW2LkIZap6KRMpbBJ Bb9E0XUZAcRhEp8IxkNUBdakMwiwM3AAZ7q8Up06aiQrQExaUpwDw7uNkIzz1bzoU0H/ ytzg== 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=jeuQ0ics8c/eTrxVuF4ictoz8iprxKsLXbs2qAfHIOw=; fh=VjvH2dnEqcO4/q63J5z14goRKEsM9S8mfNHbNHV7E9o=; b=D3uBP2pp9BRyHN2ogcJbUc7jDNwycGtW7aM47aGiQL6wgxKEHbW1LcSlAVH1wCFdxy B3LqVD26Y/zaOcCdwZ02VBx8HmnPU47p6HMt8ULP03IAnjbEmKKtrYp3O0pmmm2TUwKh In1MuBim5lBI4baEkZf62h8tGIiAgFDvOkWjMuvzHH9kh+cO7d8ejAKUOcpBTYo/ryiB /40AyxHSIhZY0IucABm0LNJQpY9PdFp6AdVL2tUj0zICaxg35dyKpZ9tUxmjmYswKnbi txl90LJCgdbI4sR24l1QvD8n5jRltL4xVgH9AZbawOVTOrKHS7mr/TUgR8OL4bNWL8AS lVGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G0i4RUz/"; 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 6a1803df08f44-6bb9c76f9eesi90091506d6.68.2024.08.05.05.17.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Aug 2024 05:17:31 -0700 (PDT) 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="G0i4RUz/"; 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 1sawe0-0000FJ-7S; Mon, 05 Aug 2024 08:16:56 -0400 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 1sawdq-000079-S0 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 08:16:52 -0400 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 1sawdn-0001QY-Ly for qemu-devel@nongnu.org; Mon, 05 Aug 2024 08:16:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722860202; 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=jeuQ0ics8c/eTrxVuF4ictoz8iprxKsLXbs2qAfHIOw=; b=G0i4RUz/lXFtibW9U7p9Yu/pdKghvTJQAY78EpMTatuCUiW79uiswjdbgqcwkBQ4aeaLwi nGI8GHjIwb7nRd6g+jAcKQbIqVzj4sT80iI8R5utZSIDUMoWZK1Sr9lnSxnx2TFmOk2Paq d6CSJXEzGxoI+5cqRauHR9WIfKZczD4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-gnkDMmM2MvC1sfGEzz2odw-1; Mon, 05 Aug 2024 08:16:41 -0400 X-MC-Unique: gnkDMmM2MvC1sfGEzz2odw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7d63fbf4afso836545066b.2 for ; Mon, 05 Aug 2024 05:16:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722860199; x=1723464999; 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=jeuQ0ics8c/eTrxVuF4ictoz8iprxKsLXbs2qAfHIOw=; b=XNCv0Rg5Qs6HY0jAuyzL4EqUNsJC68kUmArVINqlLbaK0ZpTg5XCDIJNagXgDFnB0g myE0qku2lCB7W6iaM37goNsexzcxrfRQX9LTxYlxQjgylWnQx1a96NIm1+Djas+2VBch Ux44q6WES5lE4+VC4UcQo4huDmSrtUTY5X1iLiCVQuuywOiESG4zO+ZH8r9+7gI/+VNw Ajf+GRxdxd0cyCgMOgJJa96FMDgpT9Cn9njxusNSU93yr4xoyFZ8DG3WZp6wwPHFgGK+ dDr3BUUUjXix+qZThzikIUUIXV1L6Jxl6cltbLnCsNjiPqn99uI21Lmqjjq9xmgHP1IE T5Xw== X-Gm-Message-State: AOJu0YyuOjT9qCkRkv48dZq+6nq5AOR5dIXkWD5+j+u3VSKhCnTPnDuI 3iwsPcF2RlqT6vSuh1D1bMxzJBa8cTVa1euRtNF6tlam4d8rqCEIHtjRY10DI5ZbLoiS6RvNICg YEyHKZ75xf6IFsc51ybMJL5dKIjcRkjun1nTf5HHi2xeL4AuRwg+ki5JTq84GVaahVV02QJjD3i vEgc5oBXxJ/JhhLTzR3+k4AbFvhWuq74c6+qqY X-Received: by 2002:a17:906:fe0b:b0:a72:41e7:fef4 with SMTP id a640c23a62f3a-a7dc510ccfamr739339466b.68.1722860199243; Mon, 05 Aug 2024 05:16:39 -0700 (PDT) X-Received: by 2002:a17:906:fe0b:b0:a72:41e7:fef4 with SMTP id a640c23a62f3a-a7dc510ccfamr739337266b.68.1722860198804; Mon, 05 Aug 2024 05:16:38 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d4378fsm444723666b.117.2024.08.05.05.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 05:16:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-stable@nongnu.org Subject: [PULL 2/2] target/i386: Fix VSIB decode Date: Mon, 5 Aug 2024 14:16:32 +0200 Message-ID: <20240805121632.482610-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805121632.482610-1-pbonzini@redhat.com> References: <20240805121632.482610-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 With normal SIB, index == 4 indicates no index. With VSIB, there is no exception for VR4/VR12. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2474 Signed-off-by: Richard Henderson Link: https://lore.kernel.org/r/20240805003130.1421051-3-richard.henderson@linaro.org Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 20 ++++++++++---------- target/i386/tcg/decode-new.c.inc | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 95bad55bf46..b72864bf014 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1523,7 +1523,7 @@ typedef struct AddressParts { } AddressParts; static AddressParts gen_lea_modrm_0(CPUX86State *env, DisasContext *s, - int modrm) + int modrm, bool is_vsib) { int def_seg, base, index, scale, mod, rm; target_long disp; @@ -1552,7 +1552,7 @@ static AddressParts gen_lea_modrm_0(CPUX86State *env, DisasContext *s, int code = x86_ldub_code(env, s); scale = (code >> 6) & 3; index = ((code >> 3) & 7) | REX_X(s); - if (index == 4) { + if (index == 4 && !is_vsib) { index = -1; /* no index */ } base = (code & 7) | REX_B(s); @@ -1682,21 +1682,21 @@ static TCGv gen_lea_modrm_1(DisasContext *s, AddressParts a, bool is_vsib) static void gen_lea_modrm(CPUX86State *env, DisasContext *s, int modrm) { - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); TCGv ea = gen_lea_modrm_1(s, a, false); gen_lea_v_seg(s, ea, a.def_seg, s->override); } static void gen_nop_modrm(CPUX86State *env, DisasContext *s, int modrm) { - (void)gen_lea_modrm_0(env, s, modrm); + (void)gen_lea_modrm_0(env, s, modrm, false); } /* Used for BNDCL, BNDCU, BNDCN. */ static void gen_bndck(CPUX86State *env, DisasContext *s, int modrm, TCGCond cond, TCGv_i64 bndv) { - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); TCGv ea = gen_lea_modrm_1(s, a, false); tcg_gen_extu_tl_i64(s->tmp1_i64, ea); @@ -2417,7 +2417,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState *cpu, int b) op = ((b & 7) << 3) | ((modrm >> 3) & 7); if (mod != 3) { /* memory op */ - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); TCGv ea = gen_lea_modrm_1(s, a, false); TCGv last_addr = tcg_temp_new(); bool update_fdp = true; @@ -3078,7 +3078,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) rm = (modrm & 7) | REX_B(s); gen_op_mov_v_reg(s, MO_32, s->T1, reg); if (mod != 3) { - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); /* specific case: we need to add a displacement */ gen_exts(ot, s->T1); tcg_gen_sari_tl(s->tmp0, s->T1, 3 + ot); @@ -3635,7 +3635,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) } } else if (mod != 3) { /* bndldx */ - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); if (reg >= 4 || (prefixes & PREFIX_LOCK) || s->aflag == MO_16 @@ -3679,7 +3679,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) || s->aflag == MO_16) { goto illegal_op; } - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); if (a.base >= 0) { tcg_gen_extu_tl_i64(cpu_bndl[reg], cpu_regs[a.base]); if (!CODE64(s)) { @@ -3740,7 +3740,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) } } else if (mod != 3) { /* bndstx */ - AddressParts a = gen_lea_modrm_0(env, s, modrm); + AddressParts a = gen_lea_modrm_0(env, s, modrm, false); if (reg >= 4 || (prefixes & PREFIX_LOCK) || s->aflag == MO_16 diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc index d2da1d396d5..b22210f45d9 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1811,7 +1811,8 @@ static int decode_modrm(DisasContext *s, CPUX86State *env, X86DecodedInsn *decod } else { op->has_ea = true; op->n = -1; - decode->mem = gen_lea_modrm_0(env, s, get_modrm(s, env)); + decode->mem = gen_lea_modrm_0(env, s, modrm, + decode->e.vex_class == 12); } return modrm; }