From patchwork Wed May 9 15:48:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 910958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="erm0gS/z"; dkim-atps=neutral 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 40h1880CPyz9s37 for ; Thu, 10 May 2018 01:52:23 +1000 (AEST) Received: from localhost ([::1]:57206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRO9-0004DF-J3 for incoming@patchwork.ozlabs.org; Wed, 09 May 2018 11:52:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRKq-0000uD-MK for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRKo-0006wB-Er for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:56 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:44949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGRKo-0006um-9Z for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:54 -0400 Received: by mail-pg0-x244.google.com with SMTP id x145-v6so2592092pgx.11 for ; Wed, 09 May 2018 08:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r/7uV1Bl2SYuznx6rfMiwpEENtRjBk3YUGzerdwBCV4=; b=erm0gS/zGrPL25OVuBDvrUhFfw+KExMpZGdkRztNjOU+EJlmnHSzKL61l8v0pSgjPN WhLJU1akG6GASvKjnPE3/XWp9UOP4VJX3Q/bAexqj3nc1fQD0FdBD0UUNW0QoMbzGXVg 7PeQAQ1X+mOLpzr4Kym9OTGqwWNmw6tgEnrPE= 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:in-reply-to :references; bh=r/7uV1Bl2SYuznx6rfMiwpEENtRjBk3YUGzerdwBCV4=; b=J20T5GuQPZSkST1An49GSOSRUgjXbS5I4XSwPeLpgHXgTSPFyh5zfHXrkHJO3ov+hM 3UkBUhZJkb5mtTlV3dWg+58YN9yYYoybdbTSKvAx6+9pm9v+lUp0kQmG+6A11YKVNc+T 10unVi36ftIyNbsy5cpslKSwTgRL32sEM0/T7FnFF0xE1zot3b2zGcydbPmE1aYrQfeP QcnTsR5DaDBhTUpet39471SsC/qFiigm21jVaxZFJGKzRHkPxUik0czKwrT7I/5aujkE /eaCgfVt1jGFxWZuGq/fIOZfJW67zcUU24NU15d8p6Q/6+HuKEBXwnUIVgQz3INv54O8 w0oA== X-Gm-Message-State: ALQs6tAYDoSmnIkKS2iyqYFHxtF/AV/Ix7tAkIT/pZhxTLOjpAwar5G6 n457T+6GT2cHLSIi1RHC+Mai4X7H3LM= X-Google-Smtp-Source: AB8JxZp3HXiFuOXDwDACvP8af7TxojcC5to6W4hLiFMchwgKHZhj3K2UQFjjZn0gs7efPWDnA3uPbw== X-Received: by 10.98.75.139 with SMTP id d11mr44531383pfj.244.1525880932892; Wed, 09 May 2018 08:48:52 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id d3-v6sm44058794pgc.12.2018.05.09.08.48.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 08:48:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 08:48:48 -0700 Message-Id: <20180509154849.27979-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509154849.27979-1-richard.henderson@linaro.org> References: <20180509154849.27979-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PULL 1/2] tcg/i386: Fix dup_vec in non-AVX2 codepath 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: peter.maydell@linaro.org, qemu-stable@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The VPUNPCKLD* instructions are all "non-destructive source", indicated by "NDS" in the encoding string in the x86 ISA manual. This means that they take two source operands, one of which is encoded in the VEX.vvvv field. We were incorrectly treating them as if they were destructive-source and passing 0 as the 'v' argument of tcg_out_vex_modrm(). This meant we were always using %xmm0 as one of the source operands, causing incorrect results if the register allocator happened to want to use something else. For instance the input AArch64 insn: DUP v26.16b, w21 which becomes TCG IR ops: dup_vec v128,e8,tmp2,x21 st_vec v128,e8,tmp2,env,$0xa40 was assembled to: 0x607c568c: c4 c1 7a 7e 86 e8 00 00 vmovq 0xe8(%r14), %xmm0 0x607c5694: 00 0x607c5695: c5 f9 60 c8 vpunpcklbw %xmm0, %xmm0, %xmm1 0x607c5699: c5 f9 61 c9 vpunpcklwd %xmm1, %xmm0, %xmm1 0x607c569d: c5 f9 70 c9 00 vpshufd $0, %xmm1, %xmm1 0x607c56a2: c4 c1 7a 7f 8e 40 0a 00 vmovdqu %xmm1, 0xa40(%r14) 0x607c56aa: 00 when the vpunpcklwd insn should be "%xmm1, %xmm1, %xmm1". This resulted in our incorrectly setting the output vector to q26=0000320000003200:0000320000003200 when given an input of x21 == 0000000002803200 rather than the expected all-zeroes. Pass the correct source register number to tcg_out_vex_modrm() for these insns. Fixes: 770c2fc7bb70804a Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Message-Id: <20180504153431.5169-1-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index d7e59e79c5..5357909fff 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -854,11 +854,11 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, switch (vece) { case MO_8: /* ??? With zero in a register, use PSHUFB. */ - tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, a, a); a = r; /* FALLTHRU */ case MO_16: - tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, a, a); a = r; /* FALLTHRU */ case MO_32: @@ -867,7 +867,7 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out8(s, 0); break; case MO_64: - tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, a, a); break; default: g_assert_not_reached();