From patchwork Wed Mar 8 16:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660452 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp435060wrb; Wed, 8 Mar 2023 09:06:07 -0800 (PST) X-Google-Smtp-Source: AK7set9B+xc5xwwIKWxe/BOmjEap5MLWN6aRiWiad737WAbU/0xSvsGumqTZ/SLSL2I97DlhX5Ls X-Received: by 2002:a05:6214:2524:b0:56e:a658:84e4 with SMTP id gg4-20020a056214252400b0056ea65884e4mr31544220qvb.36.1678295167675; Wed, 08 Mar 2023 09:06:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295167; cv=none; d=google.com; s=arc-20160816; b=UA7HwAl1VhYy5W65lyPBk9KZD5c3gOGF3pq82sYnCJSc4pE/vnfoBvxbfl/NJQWouM 51IPGyIgor2AT53tBdXQGzdUFi4goUvgcn8DVDr21xnoKyGRcP/qBMFCczBJN/e8K7Zg jKEdNRybPgniuckkVPs7oPwKjgD+/hlPFQtIee2KXyk8NGQD3uAW9Gv2k+2zxCdpyyiF YANIvCAjErPEkD0I44rfGh9vMDMo9ODUUsN8NJh+UWLW2EUdAAJ67tXjbXiT14CTA0uj 8uQ5wXRf1t+2kz/x7G2eHmU5eupGDSe3a95vMTzdtU2Sw7VipNz6FqDSXKuOPq5FF9T4 4gcQ== 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; bh=7IKAOvrBI0gTRVGvAc5fCcX5/mDJ2sdZdOUYRZUZgaU=; b=YgfESLeKiUB0qStjs60GeAGAYfbPLWOWcnjWiCIHwwr8WkHyb6uzk52kgJYmcRAybo mEH3X3Y437qYiEKKr8J68q3c41wg8kQDmWL/DgPQQANR1HZZuWagFPAQ3Fxw4LWzYhXr YPmHnI9BWL80AiAeMz/CQIXwxs/ZNsIG7j7X0ln7q4zj5jf0npI4gyywcQZaZNbVbwtl G823uHZI6UEi1RMJfOIv/4VEEO9tb9GlOSqObmGZWq9ffdqJsZb5dbMwV0bvjNueUxwQ 80o/X1OAshplBW/UMBRxbDZxy6o3m2ojA7dktm2u/m49iYCPlE+pytI2qAY+cUyDQxMV aXmg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d2-20020a0ce442000000b0056e9c022011si12427449qvm.562.2023.03.08.09.06.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:06:07 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx7t-0004AZ-4v; Wed, 08 Mar 2023 11:58:53 -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 1pZx7q-00049U-2V; Wed, 08 Mar 2023 11:58:50 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx7l-0003wp-Ur; Wed, 08 Mar 2023 11:58:48 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C4811400B9; Wed, 8 Mar 2023 19:58:17 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 8186292; Wed, 8 Mar 2023 19:58:16 +0300 (MSK) Received: (nullmailer pid 2098262 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , Michael Tokarev Subject: [PATCH 05/47] target/arm: fix handling of HLT semihosting in system mode Date: Wed, 8 Mar 2023 19:57:08 +0300 Message-Id: <20230308165815.2098148-5-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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: Alex Bennée The check semihosting_enabled() wants to know if the guest is currently in user mode. Unlike the other cases the test was inverted causing us to block semihosting calls in non-EL0 modes. Cc: qemu-stable@nongnu.org Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on) Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 9788d4c007cbde7cda1b7a577b8b836335eb2b73) Signed-off-by: Michael Tokarev --- target/arm/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 74a903072f..1dcaefb8e7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1184,7 +1184,7 @@ static inline void gen_hlt(DisasContext *s, int imm) * semihosting, to provide some semblance of security * (and for consistency with our 32-bit semihosting). */ - if (semihosting_enabled(s->current_el != 0) && + if (semihosting_enabled(s->current_el == 0) && (imm == (s->thumb ? 0x3c : 0xf000))) { gen_exception_internal_insn(s, EXCP_SEMIHOST); return; From patchwork Wed Mar 8 16:57:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660455 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp436685wrb; Wed, 8 Mar 2023 09:08:42 -0800 (PST) X-Google-Smtp-Source: AK7set8yYiMPqI+ComIAbP/MX7BsRjDwrnq5MMVjZmh+13ZhbWsXvOFSlvttc66H4vu3fNJ2Cd1K X-Received: by 2002:ad4:5ba7:0:b0:56b:ee46:5c3c with SMTP id 7-20020ad45ba7000000b0056bee465c3cmr29543436qvq.49.1678295322744; Wed, 08 Mar 2023 09:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295322; cv=none; d=google.com; s=arc-20160816; b=MbGiD02ueS03Yy9Ah9gijsX11IbzIMx2rpGfQ0rOKYInbENO6h9igfdSVgP2aiALyH bQ7U8GQa75fO07Z/IP1mIxgP0i9TcIAdAuGSpOnthnM+W9wRD9NHwFKwGwynMrf/9JjO W0K8OpFZK5ck1i5SkfSb9lMDZ+8qJ/X1G6AokolVl7YcxWnq6hfElk3rsNwDmCSfqt1a KOaz8w5bgb4pL1UQKhPocf7FbSZ2auTFVBDsjcOiDVMVT9WD636KDILizStdmSRwZmE5 CW5NSfAxb13Gde/WyK8ZcUFe/AUw5OdNwI//JoLwUhvutQG9zxacZ+/2JY08UDdG9k5k 9Nqw== 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; bh=tKHO5AuKwDOop1QcAaWAChTYUgBfSZpfi5EQmzMZMOs=; b=QHLeK4/XyLBjX4bKKYnhrwgTRFhExhOktHiwNdGB/gaPcitfz+MCjCdfVRCmRHZ2qW Zwd7jZuWJueuBpjpnOqk+At7iEkBRtKlvkf8AhxGOJlKiwkoV9zg8W209ZQKC+qIZCxh GmE0dvNAnF3u6HJbgv6C6n4Tdd9gObuqF/ZoQ0w6HjSbhtmCtO+0gabFzG45qFeAyj6J zq5NLWQhnnYtpmqr+APZGxvB3gy6MLUmm9wOEzJuuX52fnSgR4BAMd4NKFDPhiG5cl6k MHq+F+5uOsrwvF/VcY3j57bNEA8rjxWdPwC8dKVH/q/KgonJq5obUXfTjiQ0vkzKTASW y7Vg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m11-20020a0cac4b000000b005994d62c136si1494653qvb.447.2023.03.08.09.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:08:42 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZxDZ-00034Y-LT; Wed, 08 Mar 2023 12:04:45 -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 1pZxDX-0002uL-Bg for qemu-devel@nongnu.org; Wed, 08 Mar 2023 12:04:43 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZxDU-0005XP-0q for qemu-devel@nongnu.org; Wed, 08 Mar 2023 12:04:41 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 7CAEA400BC; Wed, 8 Mar 2023 19:58:18 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 0944A1FD; Wed, 8 Mar 2023 19:58:17 +0300 (MSK) Received: (nullmailer pid 2098266 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Michael Tokarev Subject: [PATCH 07/47] target/riscv: Set pc_succ_insn for !rvc illegal insn Date: Wed, 8 Mar 2023 19:57:10 +0300 Message-Id: <20230308165815.2098148-7-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 Failure to set pc_succ_insn may result in a TB covering zero bytes, which triggers an assert within the code generator. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1224 Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20221203175744.151365-1-richard.henderson@linaro.org> [ Changes by AF: - Add missing run-plugin-test-noc-% line ] Signed-off-by: Alistair Francis (cherry picked from commit ec2918b467228e7634f1dd5f35033ad3021b6ef7) Signed-off-by: Michael Tokarev --- target/riscv/translate.c | 12 ++++-------- tests/tcg/Makefile.target | 2 ++ tests/tcg/riscv64/Makefile.target | 6 ++++++ tests/tcg/riscv64/test-noc.S | 32 +++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tests/tcg/riscv64/test-noc.S diff --git a/target/riscv/translate.c b/target/riscv/translate.c index db123da5ec..1ed4bb5ec3 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1064,14 +1064,10 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) /* Check for compressed insn */ if (insn_len(opcode) == 2) { - if (!has_ext(ctx, RVC)) { - gen_exception_illegal(ctx); - } else { - ctx->opcode = opcode; - ctx->pc_succ_insn = ctx->base.pc_next + 2; - if (decode_insn16(ctx, opcode)) { - return; - } + ctx->opcode = opcode; + ctx->pc_succ_insn = ctx->base.pc_next + 2; + if (has_ext(ctx, RVC) && decode_insn16(ctx, opcode)) { + return; } } else { uint32_t opcode32 = opcode; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 75257f2b29..14bc013181 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -117,6 +117,8 @@ endif %: %.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) +%: %.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) else # For softmmu targets we include a different Makefile fragement as the # build options for bare programs are usually pretty different. They diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target index b5b89dfb0e..cc3ed65ffd 100644 --- a/tests/tcg/riscv64/Makefile.target +++ b/tests/tcg/riscv64/Makefile.target @@ -4,3 +4,9 @@ VPATH += $(SRC_PATH)/tests/tcg/riscv64 TESTS += test-div TESTS += noexec + +# Disable compressed instructions for test-noc +TESTS += test-noc +test-noc: LDFLAGS = -nostdlib -static +run-test-noc: QEMU_OPTS += -cpu rv64,c=false +run-plugin-test-noc-%: QEMU_OPTS += -cpu rv64,c=false diff --git a/tests/tcg/riscv64/test-noc.S b/tests/tcg/riscv64/test-noc.S new file mode 100644 index 0000000000..e29d60c8b3 --- /dev/null +++ b/tests/tcg/riscv64/test-noc.S @@ -0,0 +1,32 @@ +#include + + .text + .globl _start +_start: + .option norvc + li a0, 4 /* SIGILL */ + la a1, sa + li a2, 0 + li a3, 8 + li a7, __NR_rt_sigaction + scall + + .option rvc + li a0, 1 + j exit + .option norvc + +pass: + li a0, 0 +exit: + li a7, __NR_exit + scall + + .data + /* struct kernel_sigaction sa = { .sa_handler = pass }; */ + .type sa, @object + .size sa, 32 +sa: + .dword pass + .zero 24 + From patchwork Wed Mar 8 16:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660454 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp435092wrb; Wed, 8 Mar 2023 09:06:11 -0800 (PST) X-Google-Smtp-Source: AK7set8T0EnXZcFqyz6jygJj0F8i3KSXADi7zQWJqT07Dm13DZzJzRil/uSr03hl2K53pKIyNO32 X-Received: by 2002:a05:622a:4b:b0:3bf:d6ad:5236 with SMTP id y11-20020a05622a004b00b003bfd6ad5236mr30813164qtw.32.1678295170956; Wed, 08 Mar 2023 09:06:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295170; cv=none; d=google.com; s=arc-20160816; b=OdrPAbK7Vl6f5msNK70cNc9LLU4F1euCtk7N2yD6vIStUr6zrIBq724EnoTewmSRWB UTDAQPqnJ35/E5anvQqnELCahsH4QACGmXVyWBjENTfTfGxP52eRpcQvr3LjfowyqMEb KKhULWLaBE1MI6eMR7JjhimfMcx8NoM+x0nfjc/vbIyK7rPFeoN1e7dn1Ni3yJnKlsSP 2Ix+lGzXiPihqdye5r9Pcf9C0I+2eBPDLztf6i59nVRwYjOH7SfGluWxs7Pvoy6OXDr7 jAt/E7f3lWK31moJdkKQ3VGjMTW36y82I5BaJn5IKofSSt7VWtsTCf7cQJMz01gdeKTG v4Zg== 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; bh=28Fq/A1YofbQw7VLKsf6ELkrqDfhOKwEh41ZzDBzaXc=; b=MRcM+t/+tCQtqF0HY/0CqWonNZiyPd68zOcYpa3pxLw5tnp/v+CLdWwiZ9Nqb4G1m1 /ascC7GcTCxFgVJC3m/iiTkrIElXIUWLS6BWtCqQTztCBorgpNR14JiFZR2CvXC3oNty hCCv/+wxcDlk8h/Bk1oclR9hSzVd0txM33/ydqPZNx0NRki8LnuOxr6zzQSbYb6ExQr2 3DwmPuRPNnpUZwme6iweUjq87mbj2hp9En2q6gLV1T2k8EVMKSlMMpTlJL+c0Og2S1YC Wkj1izKs9VMfgESYqpUrTApz2Lz3rbOjzMy4z+wTtwD9Uiw59lxATf5MgHTJ56DRUElQ napA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 10-20020ac8594a000000b003bfb833eb0csi12916258qtz.750.2023.03.08.09.06.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:06:10 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx7t-0004Az-BK; Wed, 08 Mar 2023 11:58:53 -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 1pZx7r-00049j-Ay; Wed, 08 Mar 2023 11:58:51 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx7p-0003y5-P3; Wed, 08 Mar 2023 11:58:51 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0F946400E9; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id BBBB313A; Wed, 8 Mar 2023 19:58:18 +0300 (MSK) Received: (nullmailer pid 2098276 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [PATCH 12/47] target/arm: Fix sve_probe_page Date: Wed, 8 Mar 2023 19:57:15 +0300 Message-Id: <20230308165815.2098148-12-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 Don't dereference CPUTLBEntryFull until we verify that the page is valid. Move the other user-only info field updates after the valid check to match. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20230104190056.305143-1-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit ce848378b999214777fa984a8a0a3e3deb1cf687) Signed-off-by: Michael Tokarev --- target/arm/sve_helper.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 1afeadf9c8..521fc9b969 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -5354,15 +5354,10 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, #ifdef CONFIG_USER_ONLY flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault, &info->host, retaddr); - memset(&info->attrs, 0, sizeof(info->attrs)); - /* Require both ANON and MTE; see allocation_tag_mem(). */ - info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); #else CPUTLBEntryFull *full; flags = probe_access_full(env, addr, access_type, mmu_idx, nofault, &info->host, &full, retaddr); - info->attrs = full->attrs; - info->tagged = full->pte_attrs == 0xf0; #endif info->flags = flags; @@ -5371,6 +5366,15 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, return false; } +#ifdef CONFIG_USER_ONLY + memset(&info->attrs, 0, sizeof(info->attrs)); + /* Require both ANON and MTE; see allocation_tag_mem(). */ + info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); +#else + info->attrs = full->attrs; + info->tagged = full->pte_attrs == 0xf0; +#endif + /* Ensure that info->host[] is relative to addr, not addr + mem_off. */ info->host -= mem_off; return true; From patchwork Wed Mar 8 16:57:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660451 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp433352wrb; Wed, 8 Mar 2023 09:03:24 -0800 (PST) X-Google-Smtp-Source: AK7set+CCEnagSRzleaPMDnhHjK/1aFFaB1sAKvNfE+xbOz5ROyEt/i6FqsfJQ64wV0F0YpeYKSy X-Received: by 2002:a05:6214:250d:b0:56e:ab08:670d with SMTP id gf13-20020a056214250d00b0056eab08670dmr33310775qvb.42.1678295003940; Wed, 08 Mar 2023 09:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295003; cv=none; d=google.com; s=arc-20160816; b=HujQpc8w6+2D70pgMGTkINlFJuCQRfTL4kZm1zGcReFLydqKWxRjsI5iZhxwth88Zz PpRSEAOtZ+ki6vJqTuNDzBMvbctzN74D+TEf/7A4kIp4f3W04wuMLNSQtbVsLxx5Zqc+ eu4smWLNm2sCeoyEWIMcTifPChfypYwo0jaxim3VLh8M4MaXt6/L7pW9d2aUyK3+0BMW L1xIqm7iodGv99krdKEJ/ZUwbGqHixVfBiW1xSP6MyH/8IvIJgn/OWOXGuz/bMAMYjJB 9Ol0GqKpkWzgSOEf1KGER/VzmLw39M8OHRmwcy4OIO/eS2aQF0I42YpqM4rey+Va59do aSlg== 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; bh=lbzES6mGCRThb4h6Y0Cch8tyH+03d9cif9zcxoTryEs=; b=gIyHthdDdRtyEeSAYcCaIhcwan2+ANzq1R292xMz5YZ/kf/Jo0M81AAXeRwzDvAKfU bPXywguqlMOG8EiQLToram9O5PAAm+Y660ZfS8TdQPsA7vsY1Rmhbqt4aHbRKQ/+AftI 8r2k/TQDHEcEYG7H4OxB2yVsP8IbGQak8vZEGh5FG4SD1nsDbY5hHofTvUJYyp5E6hVP Q7UEeR57AE+D4A4ohjoycFdUQmAtt+NiTaCdnKr9uerk6xr+ywOzj7lzPi2U9/wibDph qC/OcQWsYuHOaJNa9aikXV1Gcuf0ffXH1d812F7sGrRJG2HhCeSaXRIYCJcLk59CuZKP 3FMA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w24-20020a05620a0e9800b006fa1585a6absi12077995qkm.186.2023.03.08.09.03.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:03:23 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx7v-0004CU-5w; Wed, 08 Mar 2023 11:58:55 -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 1pZx7s-0004AC-LS; Wed, 08 Mar 2023 11:58:52 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx7p-0003yC-Rq; Wed, 08 Mar 2023 11:58:52 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 7AAA4400EB; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 3048E1FD; Wed, 8 Mar 2023 19:58:19 +0300 (MSK) Received: (nullmailer pid 2098280 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Michael Tokarev Subject: [PATCH 14/47] target/arm: Fix in_debug path in S1_ptw_translate Date: Wed, 8 Mar 2023 19:57:17 +0300 Message-Id: <20230308165815.2098148-14-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 During the conversion, the test against get_phys_addr_lpae got inverted, meaning that successful translations went to the 'failed' label. Cc: qemu-stable@nongnu.org Fixes: f3639a64f60 ("target/arm: Use softmmu tlbs for page table walking") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1417 Signed-off-by: Richard Henderson Message-id: 20230114054605.2977022-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 4a1103afb16efa64600ef0c2b03afe60f689fdc9) Signed-off-by: Michael Tokarev --- target/arm/ptw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index f812734bfb..bb22271a1d 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -238,8 +238,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, }; GetPhysAddrResult s2 = { }; - if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, - false, &s2, fi)) { + if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, + false, &s2, fi)) { goto fail; } ptw->out_phys = s2.f.phys_addr; From patchwork Wed Mar 8 16:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660456 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp437330wrb; Wed, 8 Mar 2023 09:09:48 -0800 (PST) X-Google-Smtp-Source: AK7set/SH/+XgetAW0tUCBENtEGzyfd2jhHXiWKngI99FY7lE8wcma0NnLhbqoRZn/SAqapJP+jl X-Received: by 2002:a05:7500:c99:b0:fb:277b:183 with SMTP id fu25-20020a0575000c9900b000fb277b0183mr578739gab.68.1678295388012; Wed, 08 Mar 2023 09:09:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295387; cv=none; d=google.com; s=arc-20160816; b=zvCEdb5VSgZq8EF5qjeoXEuNTabtzKZib+44+uD/9tSGykZe1Bj/sMcs2Q423hC7qf YaaEcumoZfUPadp5UsH2r7RFuzN8a6ZjN7CIopu8+AVzFFHn+i1qzvZMFWd1ZcNhH/F5 JNyEEcJtOI5GAyOVXKPYTazeRkltLPBDcnf9N7Lxxkhgm+bUtYHU4iebsAYYU0GT722s BM7VbeT184PiOurS+JmUWKSx3QDymcdeqvDpd8rSkTUxeiFGtwJPRrz7PX1Z3cTk2R6i 5fiWz8xaHeAOGFnNjw4IaeSOCljAbCFxUSHDSrWob/jSSgIFWlTFjnR9tSY50MjM+VDw 3ClQ== 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; bh=1osm2aifSZIXoAbwLppt4xGIY91THCHQ9WgFg3MrQkU=; b=qKfn31rqUo2ktjyzBSFWK5TMnjCXPUd1QCN32ybGdOHcESLClYq4YeqBuPvDcaVcTY +u9WMQem3eZWq+qiSYLtwBoNuYXIbps+7tFfbEkreYFUBHzGJ5hHprdG5tEIKLlSS8bP asJxRyac5aMkl2caltcXJbYlLbKlSn2eeQV/74c1B1p4JcqcI57W2YhdyDy4AptG2m/i pTwLShJfBN+R4bpp5ijhwzWDMGTzl+JlDqRmlTioQzwfupvd3L41Sw18y2HXjCXDBQOJ 84ITatChUg5HE9kSS7I/AOO6JQgF4Eb876F+DMTaIyggpAmsAdiGe0OUiTeKk+GWZZoR 0RQA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w10-20020a67ffca000000b0041204f01d6dsi5255044vsq.693.2023.03.08.09.09.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:09:47 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx82-0004Fu-Fb; Wed, 08 Mar 2023 11:59:02 -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 1pZx80-0004En-Mw; Wed, 08 Mar 2023 11:59:00 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx7y-00040X-PG; Wed, 08 Mar 2023 11:59:00 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C647E400EC; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 6DA531FE; Wed, 8 Mar 2023 19:58:19 +0300 (MSK) Received: (nullmailer pid 2098282 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Sid Manning , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [PATCH 15/47] target/arm: Fix physical address resolution for Stage2 Date: Wed, 8 Mar 2023 19:57:18 +0300 Message-Id: <20230308165815.2098148-15-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 Conversion to probe_access_full missed applying the page offset. Cc: qemu-stable@nongnu.org Reported-by: Sid Manning Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20230126233134.103193-1-richard.henderson@linaro.org Fixes: f3639a64f602 ("target/arm: Use softmmu tlbs for page table walking") Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell (cherry picked from commit 9d2617ac7d3139d870ba14204aedd74395990192) Signed-off-by: Michael Tokarev --- target/arm/ptw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index bb22271a1d..0b16068557 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -266,7 +266,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, if (unlikely(flags & TLB_INVALID_MASK)) { goto fail; } - ptw->out_phys = full->phys_addr; + ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK); ptw->out_rw = full->prot & PAGE_WRITE; pte_attrs = full->pte_attrs; pte_secure = full->attrs.secure; From patchwork Wed Mar 8 16:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660453 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp435068wrb; Wed, 8 Mar 2023 09:06:08 -0800 (PST) X-Google-Smtp-Source: AK7set86WjqeTgqcmYeiP9f6ssBbqO0qAXenilDWJI8d1hFGjKp9QtQfXmnwyaA3vEQeiK1A+mTH X-Received: by 2002:a05:6214:5089:b0:56f:8ef:693 with SMTP id kk9-20020a056214508900b0056f08ef0693mr30998606qvb.0.1678295168514; Wed, 08 Mar 2023 09:06:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295168; cv=none; d=google.com; s=arc-20160816; b=FVVm9+05YQZp0onOEHm0jbrMG63RJOlrz0y3p7F5GGX6/0MGlXI2v2ok0K1xlebttw z6EyhkKcHnMl8X+nXEeSItg01FLtHCKEfXxTX+MWC9iycQ/SK2aARJ+gWf6O6o+9b1FR BQ7uYmgMLO1stLj4yz9qhmeCb1rJjSguJhICk1zgdZuG1KrZDnt+ozg4tfYUlIvAexx+ wzUProPIjHta7ecednYdqQ3BWph89pi2KG6CW8ga2w7LHsVUOlFEx4X/2Cz1HZ2dAvHX vb83FFaNDTytLZ+hUZoSY6BxypUS6LJnE+QWgEQ/NpVdtoDswpPIneynhRq30vmqLd9v gmVA== 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; bh=eYSqtHFhze/gDz+CW7Zxlnd6nrlq9YUiS02HL4CWrKw=; b=zpNAlKdri8xQaIUnwGZ+4MYFadq3DwZikIRNWx7yGK+r7j+xCsWSTmNY3Rv7i94ebH Zqf/mZ+qpg7ZxXw/Ky1hb25VhEf/Mr03cUnH10+unbSGfv0kWi12EwKfIfng7wc2+0mB h+xuc7doH7sILyfqklICBwAjZ7vThXag+1BAw/SsQkditjKa4YzpFIhxI0eJJyzwIsJ/ 7z8VN65z1vmoXDa6vCGTQVCR5cK8HIIV+9B3XgMbkv2x5QJ7ZPMBd2kDJpCyOYRtpG8B bn+D6RWXS/5GlRp7G0eytq/W1NaTCqZezGPQgoyT9KLAH/XFvx/Y+hdlqBfEeS0X1NIB Ibvw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18-20020a0ca9d2000000b0056eb136aa91si12409894qvb.63.2023.03.08.09.06.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:06:08 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx84-0004IT-5b; Wed, 08 Mar 2023 11:59:04 -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 1pZx82-0004Fr-82; Wed, 08 Mar 2023 11:59:02 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx80-00041r-6l; Wed, 08 Mar 2023 11:59:02 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id B814A400F2; Wed, 8 Mar 2023 19:58:21 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 71ACC1FE; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: (nullmailer pid 2098292 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Michael Tokarev Subject: [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently Date: Wed, 8 Mar 2023 19:57:23 +0300 Message-Id: <20230308165815.2098148-20-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 Define reg_t based on the actual register width. Define the inlines using that type. This will allow input registers to 32-bit insns to be set to 64-bit values on x86-64, which allows testing various edge cases. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230114230542.3116013-2-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini (cherry picked from commit 5d62d6649cd367b5b4a3676e7514d2f9ca86cb03) Signed-off-by: Michael Tokarev --- tests/tcg/i386/test-i386-bmi2.c | 182 ++++++++++++++++---------------- 1 file changed, 93 insertions(+), 89 deletions(-) diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c index 5fadf47510..3c3ef85513 100644 --- a/tests/tcg/i386/test-i386-bmi2.c +++ b/tests/tcg/i386/test-i386-bmi2.c @@ -3,34 +3,40 @@ #include #include +#ifdef __x86_64 +typedef uint64_t reg_t; +#else +typedef uint32_t reg_t; +#endif + #define insn1q(name, arg0) \ -static inline uint64_t name##q(uint64_t arg0) \ +static inline reg_t name##q(reg_t arg0) \ { \ - uint64_t result64; \ + reg_t result64; \ asm volatile (#name "q %1, %0" : "=r"(result64) : "rm"(arg0)); \ return result64; \ } #define insn1l(name, arg0) \ -static inline uint32_t name##l(uint32_t arg0) \ +static inline reg_t name##l(reg_t arg0) \ { \ - uint32_t result32; \ + reg_t result32; \ asm volatile (#name "l %k1, %k0" : "=r"(result32) : "rm"(arg0)); \ return result32; \ } #define insn2q(name, arg0, c0, arg1, c1) \ -static inline uint64_t name##q(uint64_t arg0, uint64_t arg1) \ +static inline reg_t name##q(reg_t arg0, reg_t arg1) \ { \ - uint64_t result64; \ + reg_t result64; \ asm volatile (#name "q %2, %1, %0" : "=r"(result64) : c0(arg0), c1(arg1)); \ return result64; \ } #define insn2l(name, arg0, c0, arg1, c1) \ -static inline uint32_t name##l(uint32_t arg0, uint32_t arg1) \ +static inline reg_t name##l(reg_t arg0, reg_t arg1) \ { \ - uint32_t result32; \ + reg_t result32; \ asm volatile (#name "l %k2, %k1, %k0" : "=r"(result32) : c0(arg0), c1(arg1)); \ return result32; \ } @@ -65,130 +71,128 @@ insn1l(blsr, src) int main(int argc, char *argv[]) { uint64_t ehlo = 0x202020204f4c4845ull; uint64_t mask = 0xa080800302020001ull; - uint32_t result32; + reg_t result; #ifdef __x86_64 - uint64_t result64; - /* 64 bits */ - result64 = andnq(mask, ehlo); - assert(result64 == 0x002020204d4c4844); + result = andnq(mask, ehlo); + assert(result == 0x002020204d4c4844); - result64 = pextq(ehlo, mask); - assert(result64 == 133); + result = pextq(ehlo, mask); + assert(result == 133); - result64 = pdepq(result64, mask); - assert(result64 == (ehlo & mask)); + result = pdepq(result, mask); + assert(result == (ehlo & mask)); - result64 = pextq(-1ull, mask); - assert(result64 == 511); /* mask has 9 bits set */ + result = pextq(-1ull, mask); + assert(result == 511); /* mask has 9 bits set */ - result64 = pdepq(-1ull, mask); - assert(result64 == mask); + result = pdepq(-1ull, mask); + assert(result == mask); - result64 = bextrq(mask, 0x3f00); - assert(result64 == (mask & ~INT64_MIN)); + result = bextrq(mask, 0x3f00); + assert(result == (mask & ~INT64_MIN)); - result64 = bextrq(mask, 0x1038); - assert(result64 == 0xa0); + result = bextrq(mask, 0x1038); + assert(result == 0xa0); - result64 = bextrq(mask, 0x10f8); - assert(result64 == 0); + result = bextrq(mask, 0x10f8); + assert(result == 0); - result64 = blsiq(0x30); - assert(result64 == 0x10); + result = blsiq(0x30); + assert(result == 0x10); - result64 = blsiq(0x30ull << 32); - assert(result64 == 0x10ull << 32); + result = blsiq(0x30ull << 32); + assert(result == 0x10ull << 32); - result64 = blsmskq(0x30); - assert(result64 == 0x1f); + result = blsmskq(0x30); + assert(result == 0x1f); - result64 = blsrq(0x30); - assert(result64 == 0x20); + result = blsrq(0x30); + assert(result == 0x20); - result64 = blsrq(0x30ull << 32); - assert(result64 == 0x20ull << 32); + result = blsrq(0x30ull << 32); + assert(result == 0x20ull << 32); - result64 = bzhiq(mask, 0x3f); - assert(result64 == (mask & ~INT64_MIN)); + result = bzhiq(mask, 0x3f); + assert(result == (mask & ~INT64_MIN)); - result64 = bzhiq(mask, 0x1f); - assert(result64 == (mask & ~(-1 << 30))); + result = bzhiq(mask, 0x1f); + assert(result == (mask & ~(-1 << 30))); - result64 = rorxq(0x2132435465768798, 8); - assert(result64 == 0x9821324354657687); + result = rorxq(0x2132435465768798, 8); + assert(result == 0x9821324354657687); - result64 = sarxq(0xffeeddccbbaa9988, 8); - assert(result64 == 0xffffeeddccbbaa99); + result = sarxq(0xffeeddccbbaa9988, 8); + assert(result == 0xffffeeddccbbaa99); - result64 = sarxq(0x77eeddccbbaa9988, 8 | 64); - assert(result64 == 0x0077eeddccbbaa99); + result = sarxq(0x77eeddccbbaa9988, 8 | 64); + assert(result == 0x0077eeddccbbaa99); - result64 = shrxq(0xffeeddccbbaa9988, 8); - assert(result64 == 0x00ffeeddccbbaa99); + result = shrxq(0xffeeddccbbaa9988, 8); + assert(result == 0x00ffeeddccbbaa99); - result64 = shrxq(0x77eeddccbbaa9988, 8 | 192); - assert(result64 == 0x0077eeddccbbaa99); + result = shrxq(0x77eeddccbbaa9988, 8 | 192); + assert(result == 0x0077eeddccbbaa99); - result64 = shlxq(0xffeeddccbbaa9988, 8); - assert(result64 == 0xeeddccbbaa998800); + result = shlxq(0xffeeddccbbaa9988, 8); + assert(result == 0xeeddccbbaa998800); #endif /* 32 bits */ - result32 = andnl(mask, ehlo); - assert(result32 == 0x04d4c4844); + result = andnl(mask, ehlo); + assert(result == 0x04d4c4844); - result32 = pextl((uint32_t) ehlo, mask); - assert(result32 == 5); + result = pextl((uint32_t) ehlo, mask); + assert(result == 5); - result32 = pdepl(result32, mask); - assert(result32 == (uint32_t)(ehlo & mask)); + result = pdepl(result, mask); + assert(result == (uint32_t)(ehlo & mask)); - result32 = pextl(-1u, mask); - assert(result32 == 7); /* mask has 3 bits set */ + result = pextl(-1u, mask); + assert(result == 7); /* mask has 3 bits set */ - result32 = pdepl(-1u, mask); - assert(result32 == (uint32_t)mask); + result = pdepl(-1u, mask); + assert(result == (uint32_t)mask); - result32 = bextrl(mask, 0x1f00); - assert(result32 == (mask & ~INT32_MIN)); + result = bextrl(mask, 0x1f00); + assert(result == (mask & ~INT32_MIN)); - result32 = bextrl(ehlo, 0x1018); - assert(result32 == 0x4f); + result = bextrl(ehlo, 0x1018); + assert(result == 0x4f); - result32 = bextrl(mask, 0x1038); - assert(result32 == 0); + result = bextrl(mask, 0x1038); + assert(result == 0); - result32 = blsil(0xffff); - assert(result32 == 1); + result = blsil(0xffff); + assert(result == 1); - result32 = blsmskl(0x300); - assert(result32 == 0x1ff); + result = blsmskl(0x300); + assert(result == 0x1ff); - result32 = blsrl(0xffc); - assert(result32 == 0xff8); + result = blsrl(0xffc); + assert(result == 0xff8); - result32 = bzhil(mask, 0xf); - assert(result32 == 1); + result = bzhil(mask, 0xf); + assert(result == 1); - result32 = rorxl(0x65768798, 8); - assert(result32 == 0x98657687); + result = rorxl(0x65768798, 8); + assert(result == 0x98657687); - result32 = sarxl(0xffeeddcc, 8); - assert(result32 == 0xffffeedd); + result = sarxl(0xffeeddcc, 8); + assert(result == 0xffffeedd); - result32 = sarxl(0x77eeddcc, 8 | 32); - assert(result32 == 0x0077eedd); + result = sarxl(0x77eeddcc, 8 | 32); + assert(result == 0x0077eedd); - result32 = shrxl(0xffeeddcc, 8); - assert(result32 == 0x00ffeedd); + result = shrxl(0xffeeddcc, 8); + assert(result == 0x00ffeedd); - result32 = shrxl(0x77eeddcc, 8 | 128); - assert(result32 == 0x0077eedd); + result = shrxl(0x77eeddcc, 8 | 128); + assert(result == 0x0077eedd); - result32 = shlxl(0xffeeddcc, 8); - assert(result32 == 0xeeddcc00); + result = shlxl(0xffeeddcc, 8); + assert(result == 0xeeddcc00); return 0; } From patchwork Wed Mar 8 16:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660450 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp433336wrb; Wed, 8 Mar 2023 09:03:23 -0800 (PST) X-Google-Smtp-Source: AK7set+U4kDIi8jiCZLJctnhXxOZU0npeL7R5LwooXNnYLwKjvrvu6fj+bIYawnrU7G3O90IdO0y X-Received: by 2002:ac8:5c4a:0:b0:3bf:c6be:cbbe with SMTP id j10-20020ac85c4a000000b003bfc6becbbemr33146283qtj.1.1678295003118; Wed, 08 Mar 2023 09:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295003; cv=none; d=google.com; s=arc-20160816; b=caZMAfQbD0Qg/nqgCb9sddHylS6QncBizFZ66sZ+3Cg4xypiVxHsr7ZIfqLKZqjFjM 7Up9th2gOwv/5+OKDGdC74KA4TaRlSNLUU5sLBK2Nq+fz32R/DcEE4+9cMpzvvjyWKm3 BjK/qFRq/lGMVsYJZ1NaojykJuZWfaw9RMDuQQZOd+jQkp6vOJQ5AEMSfmldfqFFhxQN z7loxYc9ycLCsF3lTeo/Sg25+s/N0R3PTleKQ96i4H5+rIL7oMwEErZwjzoHVkYNmo0u S6FeKxmyN60l39UurT6k81B7LTeXE+qbGLnb5tk9KNc+5eTOaxAGUv3HOvqxLQbzcFcU hizg== 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; bh=GRovcK2knzDDJlgrcJql4M4t0aZ3W4+fK9/TfNNql7Q=; b=vELx7Cx1rijXcUAlbPTHfAwsbOgmTuTHB4pXMcUXIGFs+K5Lsu00Md7QFJe7N2gBCv St2Z527MbF/FD8UHcIOT0tJBgBVI1ngXIp/JbRvrX47xPkskLHcKTwwOeJdxWRpII8jy aLQ5q+xXwOu+u7fgaRbukV1uhUtm6UPGnf092aaDJ4ACwqCTRQ9vYtWRZOCF5d67PzRa D76wIqFbYlSmgN5u/3dATFMcQXiV+/XpJd9U98QjhiPfGIHYnPSvCQZokNxyfTVg8S25 6VRotQV5M/C04lNPNG0T/ITwxgatQ3U4or428ZHdHh9DpV/Ck4kcFNKO2Yg2zXisEBQq lafQ== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p17-20020a05622a13d100b003b634a2268esi12486516qtk.643.2023.03.08.09.03.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:03:23 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx88-0004RR-Sx; Wed, 08 Mar 2023 11:59:09 -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 1pZx83-0004HD-2r; Wed, 08 Mar 2023 11:59:03 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx80-00041u-OK; Wed, 08 Mar 2023 11:59:02 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id EFF56400F3; Wed, 8 Mar 2023 19:58:21 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B0EC892; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: (nullmailer pid 2098294 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Paolo Bonzini , Michael Tokarev Subject: [PATCH 21/47] target/i386: Fix BEXTR instruction Date: Wed, 8 Mar 2023 19:57:24 +0300 Message-Id: <20230308165815.2098148-21-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 There were two problems here: not limiting the input to operand bits, and not correctly handling large extraction length. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1372 Signed-off-by: Richard Henderson Message-Id: <20230114230542.3116013-3-richard.henderson@linaro.org> Cc: qemu-stable@nongnu.org Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18) Signed-off-by: Paolo Bonzini (cherry picked from commit b14c0098975264ed03144f145bca0179a6763a07) Signed-off-by: Michael Tokarev --- target/i386/tcg/emit.c.inc | 22 +++++++++++----------- tests/tcg/i386/test-i386-bmi2.c | 12 ++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 7037ff91c6..99f6ba6e19 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1078,30 +1078,30 @@ static void gen_ANDN(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) { MemOp ot = decode->op[0].ot; - TCGv bound, zero; + TCGv bound = tcg_constant_tl(ot == MO_64 ? 63 : 31); + TCGv zero = tcg_constant_tl(0); + TCGv mone = tcg_constant_tl(-1); /* * Extract START, and shift the operand. * Shifts larger than operand size get zeros. */ tcg_gen_ext8u_tl(s->A0, s->T1); + if (TARGET_LONG_BITS == 64 && ot == MO_32) { + tcg_gen_ext32u_tl(s->T0, s->T0); + } tcg_gen_shr_tl(s->T0, s->T0, s->A0); - bound = tcg_constant_tl(ot == MO_64 ? 63 : 31); - zero = tcg_constant_tl(0); tcg_gen_movcond_tl(TCG_COND_LEU, s->T0, s->A0, bound, s->T0, zero); /* - * Extract the LEN into a mask. Lengths larger than - * operand size get all ones. + * Extract the LEN into an inverse mask. Lengths larger than + * operand size get all zeros, length 0 gets all ones. */ tcg_gen_extract_tl(s->A0, s->T1, 8, 8); - tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->A0, bound, s->A0, bound); - - tcg_gen_movi_tl(s->T1, 1); - tcg_gen_shl_tl(s->T1, s->T1, s->A0); - tcg_gen_subi_tl(s->T1, s->T1, 1); - tcg_gen_and_tl(s->T0, s->T0, s->T1); + tcg_gen_shl_tl(s->T1, mone, s->A0); + tcg_gen_movcond_tl(TCG_COND_LEU, s->T1, s->A0, bound, s->T1, zero); + tcg_gen_andc_tl(s->T0, s->T0, s->T1); gen_op_update1_cc(s); set_cc_op(s, CC_OP_LOGICB + ot); diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c index 3c3ef85513..982d4abda4 100644 --- a/tests/tcg/i386/test-i386-bmi2.c +++ b/tests/tcg/i386/test-i386-bmi2.c @@ -99,6 +99,9 @@ int main(int argc, char *argv[]) { result = bextrq(mask, 0x10f8); assert(result == 0); + result = bextrq(0xfedcba9876543210ull, 0x7f00); + assert(result == 0xfedcba9876543210ull); + result = blsiq(0x30); assert(result == 0x10); @@ -164,6 +167,15 @@ int main(int argc, char *argv[]) { result = bextrl(mask, 0x1038); assert(result == 0); + result = bextrl((reg_t)0x8f635a775ad3b9b4ull, 0x3018); + assert(result == 0x5a); + + result = bextrl((reg_t)0xfedcba9876543210ull, 0x7f00); + assert(result == 0x76543210u); + + result = bextrl(-1, 0); + assert(result == 0); + result = blsil(0xffff); assert(result == 1); From patchwork Wed Mar 8 16:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660458 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp437484wrb; Wed, 8 Mar 2023 09:10:04 -0800 (PST) X-Google-Smtp-Source: AK7set/BEHCuvqpYh6fiEQs63vwJSBjzGBKGMqDxqXvVIC13vwYRkKA8WrLikjxi2S2DL5miNez4 X-Received: by 2002:ac8:5e10:0:b0:3bf:d254:bb9b with SMTP id h16-20020ac85e10000000b003bfd254bb9bmr34524424qtx.44.1678295404264; Wed, 08 Mar 2023 09:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295404; cv=none; d=google.com; s=arc-20160816; b=UaO56B9CIzSjzNfYo9D5CLshD3MudiyziWD0HmJeAW6tgDhaCKKP71oF+ptuLXfDlo Io5fidrXGxd8bouc9zEEnq1wv3MoZXrHVHvXGXb74fYEwa4pn8/dS0E6Gl67HowgKbk5 dzHDjgezOMpXO3ULHxHO2CobRBbBT/V5hll9rT1ToKCO0lv4A76/NaCVGuemQn7fRiUP LqLEn3VLPq1K3QnCFHGeZ48ahqzO+ez6I3bsO8EReUBwbz+qOKTyTDDfauq+vvwob55s dNs1zW8TB+Lp0fE+u6S6CT6ZLqdZgTCrxyFwPrhlXCyOlU9OJoma8K7Muqsm4TnrAQbF RO2A== 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; bh=sY0PHhB7txcFinQr9jqv+K6VM2+QBoZXXTllrrkXLJM=; b=fgm8aMPbbEU+pcNqJN/yjmNQCVNW/L308Xi7ugogTkiJn7ojNn329H2276q5hOFsVe Reqd6xlUAoVqIn2MsXc46fzHrm/7/LiVpfMTXxoG/iFI0iCryaq4ptAqLKZ9TcEq6jaX 54SxAwxxqUNxChfN3JYJvyLG+WfhPpi57fKfKNMDRvhfnFVrb1e1ZswccK+nXgAFwr/A 3xEEXAbs6/3Ojjhqcc23852iI+LoG4ErMRJT0Bxaiq7+dOJV1iWTGWRz5pN7YmFdAK5+ jvqYhpt8j6SwT5rg4JxawkyvisE8miTlXp2shc0v/99UZh5jllEAZfNnQuFiBv5R7D0K 5Gqg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m7-20020ac85b07000000b003bfe796bfb9si13470330qtw.319.2023.03.08.09.10.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:10:04 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx86-0004M9-52; Wed, 08 Mar 2023 11:59:06 -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 1pZx82-0004GA-Du; Wed, 08 Mar 2023 11:59:02 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx80-00041t-Nm; Wed, 08 Mar 2023 11:59:02 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 2CB25400F4; Wed, 8 Mar 2023 19:58:22 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E2FC413A; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: (nullmailer pid 2098296 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Paolo Bonzini , Michael Tokarev Subject: [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR Date: Wed, 8 Mar 2023 19:57:25 +0300 Message-Id: <20230308165815.2098148-22-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 forgot to set cc_src, which is used for computing C. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1370 Signed-off-by: Richard Henderson Message-Id: <20230114180601.2993644-1-richard.henderson@linaro.org> Cc: qemu-stable@nongnu.org Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18) Signed-off-by: Paolo Bonzini (cherry picked from commit 99282098dc74c2055bde5652bde6cf0067d0c370) Signed-off-by: Michael Tokarev --- target/i386/tcg/emit.c.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 99f6ba6e19..4d7702c106 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1111,6 +1111,7 @@ static void gen_BLSI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) { MemOp ot = decode->op[0].ot; + tcg_gen_mov_tl(cpu_cc_src, s->T0); tcg_gen_neg_tl(s->T1, s->T0); tcg_gen_and_tl(s->T0, s->T0, s->T1); tcg_gen_mov_tl(cpu_cc_dst, s->T0); @@ -1121,6 +1122,7 @@ static void gen_BLSMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode { MemOp ot = decode->op[0].ot; + tcg_gen_mov_tl(cpu_cc_src, s->T0); tcg_gen_subi_tl(s->T1, s->T0, 1); tcg_gen_xor_tl(s->T0, s->T0, s->T1); tcg_gen_mov_tl(cpu_cc_dst, s->T0); @@ -1131,6 +1133,7 @@ static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode) { MemOp ot = decode->op[0].ot; + tcg_gen_mov_tl(cpu_cc_src, s->T0); tcg_gen_subi_tl(s->T1, s->T0, 1); tcg_gen_and_tl(s->T0, s->T0, s->T1); tcg_gen_mov_tl(cpu_cc_dst, s->T0); From patchwork Wed Mar 8 16:57:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660457 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp437386wrb; Wed, 8 Mar 2023 09:09:54 -0800 (PST) X-Google-Smtp-Source: AK7set/8zYrsAj9OxHblIvm3p/lXYKmOvvJMThXEJ8JnuphMvyP3uNxVSLkbgaUEqxSTaUmks56Z X-Received: by 2002:a05:7500:6787:b0:fb:1350:ad76 with SMTP id je7-20020a057500678700b000fb1350ad76mr618134gab.0.1678295394263; Wed, 08 Mar 2023 09:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295394; cv=none; d=google.com; s=arc-20160816; b=DhCOgUAW/di/FmPsCf7qsQ3gCYEjFAyeCh/RJCwP75GPtpb4/wQj7wTdbuabYy8NHo P0pDG1BJxsErPaMEgZ7AXctWinjzsnctoCS3jTut9yWzfuL+S5e5ScAdjzttd/F76mR4 KBSyvDEeKgKIPlfTrTwzBBQP+yr9dMZHRJlGdJvbsiVy6sFrEFaPox1Kqluq2Wc33qth 3BFs27cYHQ2+j698dDEGwC48iYVK3QuxpEfpYXwRABeHvdAykgBWt1VbVClmSlSE3KAz Yp/7TC78E9ZhcIsqMGVVq9qshYrl+44YvZny38JSV6keNaW9G1EvW/CTRWHHu3vy2h6z g05Q== 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; bh=MANDDFEM3qq+VO4SNvb5gE2IiVSjN8LnA1pHlzfI32I=; b=RFdfvqrjNKI9OSDKI9cGeSAjUxYgkscLxHEdwqi1FFRZud39iCrIw9gKFvtemedKjn mjLwTyY3jNBZaB6spfo/mrzNovgpmB/TMrrdEbs9MhPbyOYQj4jqnMiWmCBbKl5Fc7TF 2+rOXHTs2sOWJxlbQfXwoJr4laLKCf/Aw9PP3nJt22vtfJZIt/2NyZOmmBsj2OAuKwgc EiXIQhtO4kMrYdCOMl0j8rjt4TcAykk7AxlNH0vudW40XLS9sSdiQD3F7cLFWeT93vU0 GYYh8dYFesSpp7iRDX2X+xs47Z7KNg8UoF3iV//VTv37nde14S3GQCPlRIL6LykulGMT Lnyw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i25-20020a67dd99000000b00412dea8d470si5112722vsk.543.2023.03.08.09.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:09:54 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx86-0004NZ-G5; Wed, 08 Mar 2023 11:59:06 -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 1pZx83-0004HE-36; Wed, 08 Mar 2023 11:59:03 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx80-000426-Ox; Wed, 08 Mar 2023 11:59:02 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 4622B40102; Wed, 8 Mar 2023 19:58:33 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 0987613A; Wed, 8 Mar 2023 19:58:32 +0300 (MSK) Received: (nullmailer pid 2098324 invoked by uid 1000); Wed, 08 Mar 2023 16:58:31 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Paolo Bonzini , Michael Tokarev Subject: [PATCH 24/47] target/i386: Fix BZHI instruction Date: Wed, 8 Mar 2023 19:57:27 +0300 Message-Id: <20230308165815.2098148-24-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 (cherry picked from commit 9ad2ba6e8e7fc195d0dd0b76ab38bd2fceb1bdd4) Signed-off-by: Michael Tokarev --- 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 0d7c6e80ae..7296f3952c 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1145,20 +1145,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 982d4abda4..0244df7987 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); From patchwork Wed Mar 8 16:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660449 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp432365wrb; Wed, 8 Mar 2023 09:02:06 -0800 (PST) X-Google-Smtp-Source: AK7set+KQnq/EW5btRZtb7kFanD9KaYLvPvqAs2OovAABQMgcHo0xIX2GgjFQNWHINsu7G2jlHf1 X-Received: by 2002:a05:7500:5c0e:b0:fb:307a:8238 with SMTP id fd14-20020a0575005c0e00b000fb307a8238mr139846gab.7.1678294925909; Wed, 08 Mar 2023 09:02:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678294925; cv=none; d=google.com; s=arc-20160816; b=iUnKJ4dyKFFpXw9wUJWz5bTUJuGTwKuCXKqOgUvqTWREX1EhTsAI9Q5mhkQsFhXYJr SCGAHDRv/MtFfxWkOgI+4XigTNm55WswsYtuJbpxssigoBBTJN2iQyIVtDjO2B1tDSS3 1ZTT++QvbkMgEHMsusneEfQeQ/kSguf/tuS3Yt5PpGkSFL7pE7olRtUya45ne5J2AblK Its7XYKZfmH9sJ3WExxXzBNxS6r00DGfNUykgsDzt2g50wMUFpp26wkAlwQG6AmdCvWP yvUksD1JWeBGvXYrEdo+H8biii+SANfAuT7ciwNvWiZ6T+ZSAb1tPjsV9VscCBZfW8EB U6Gg== 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; bh=C9oh772rQEZ5srk0NgDy7YaWCrMOspIZCWnIddr07Yc=; b=H7qn4rMEfWmuygv8zPJEvhurdJfnY2ZRYxtZee5h1NmCcKjyeI5TsnkEpuMzPRW3rP OvlaXAPjnD2d7Wd5jUJKv2H5zlK9QjVc1TPMzhN02qTqstsgjc88mf9oIYrHv8jHJpUz CPy3JvU+A/pRdiijb4gnEs2pE17Q8si1FZaB7xIHo+z/NW1KsGc6e3ZlCLRCk79rhiXH 3zPa9E1ucUFdvg2fQRHu53zrKnPl1/ItkMN6Z8ovRdUx+o25YkgE620l4SzpqRFb+Tbc qFG0exEqXfIsCTIiFJG2tBKvkHL/gyXejhk2sSGQ0DfhUgrai/9c8vSqYzxC5xxaiCIO lcWw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v195-20020a1f2fcc000000b0042d799dc970si856819vkv.160.2023.03.08.09.02.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:02:05 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx8l-0004zV-US; Wed, 08 Mar 2023 11:59:48 -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 1pZx8a-0004s7-4b; Wed, 08 Mar 2023 11:59:36 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx8Y-0004BO-GW; Wed, 08 Mar 2023 11:59:35 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id BE75E40112; Wed, 8 Mar 2023 19:58:58 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 8D0C913A; Wed, 8 Mar 2023 19:58:57 +0300 (MSK) Received: (nullmailer pid 2098387 invoked by uid 1000); Wed, 08 Mar 2023 16:58:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Michael Tokarev Subject: [PATCH 46/47] tests/tcg: fix unused variable in linux-test Date: Wed, 8 Mar 2023 19:57:49 +0300 Message-Id: <20230308165815.2098148-46-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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: Alex Bennée The latest hexagon compiler picks up that we never consume wcount. Given the name of the #define that rcount checks against is WCOUNT_MAX I figured the check just got missed. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20221221090411.1995037-5-alex.bennee@linaro.org> (cherry picked from commit 2bc6c79417b89c3306b724577e775f03fe61fb2e) Signed-off-by: Michael Tokarev --- tests/tcg/multiarch/linux/linux-test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/tcg/multiarch/linux/linux-test.c b/tests/tcg/multiarch/linux/linux-test.c index 5a2a4f2258..64f57cb287 100644 --- a/tests/tcg/multiarch/linux/linux-test.c +++ b/tests/tcg/multiarch/linux/linux-test.c @@ -354,13 +354,17 @@ static void test_pipe(void) if (FD_ISSET(fds[0], &rfds)) { chk_error(read(fds[0], &ch, 1)); rcount++; - if (rcount >= WCOUNT_MAX) + if (rcount >= WCOUNT_MAX) { break; + } } if (FD_ISSET(fds[1], &wfds)) { ch = 'a'; chk_error(write(fds[1], &ch, 1)); wcount++; + if (wcount >= WCOUNT_MAX) { + break; + } } } }