From patchwork Mon Dec 13 17:42:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 523480 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp6383119imb; Mon, 13 Dec 2021 09:43:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3++vLAbOSANnIEsqiRCvyCso/hsjqopsfIdQizYsytMwHQHqNXl2I1drY7taUau1MnWnL X-Received: by 2002:a05:6214:174d:: with SMTP id dc13mr214789qvb.7.1639417412024; Mon, 13 Dec 2021 09:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639417412; cv=none; d=google.com; s=arc-20160816; b=mJIlhj/2Bk5QBr4X9dgRT2ILKja9XJ7U8rXtBtH/fklrnmsf7R/mhfcXHXmW2zoMh1 kw2FnMRQjFMhXBh3qk8K1HG9T0hrloMGY50+FcKH/L4bnGjGHgbm0ySUFby8a4K0MTNL TcsIKwM6o3HktXvIbtBOPbgw5FMgkCzwyhMXysxfDI4vlvbz56mx9t2eCcWN+02GESnX xUrgfoe+9T/bBRP1QMVA59uyDdkafErACZq+CpHrvJzw4npUXobESKBiK+F3sRomiZ1A NtwOt2BAynZUFHySx8UbxSPXbiS+S10asBP3gdkphhlouL+duAEu8T+OHlXrSkIWAv4x CyXQ== 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:message-id:date:subject:to:from:dkim-signature; bh=ciPxtNnzy5RQSIuGinEff8/WK2cqYqdP2QUk/Jr3dy0=; b=R7y3/ihQt4gGLDfN7NZjpHYupE9oHEJQgL8GKdEFm8yiN9v9Yv14BzUWiMZf9MO8tA q8mDwr6l38zJ4rOiZ81uHdQN407gVrRVlQ0Fza+nnYVd6SVqt5orF7eoOgLvhieI+ljP I1MjmxdpYr5E0fLATL9W3DRsAuyV8FJE8HyBLVl7Ldqd6yr63ENs54+MglFl3SHNTFd9 cmszHXf11K3+Dnl6mRm2nMNaGWWqpVlKRZdZaTK6rX0SC+gCpdh9SMUwbwShpXQZLXDo J3t13ficotI9AIkcPucxzBbWKqXQSeEqv7MEvbQTX469Yw3/crxv8lzCj5Qiu3TrziMv U0cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gRyTguK3; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hr10si11466151qvb.495.2021.12.13.09.43.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Dec 2021 09:43:32 -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=@linaro.org header.s=google header.b=gRyTguK3; 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=linaro.org Received: from localhost ([::1]:42900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwpMJ-0001FH-HH for patch@linaro.org; Mon, 13 Dec 2021 12:43:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwpLp-0001Ee-Sq for qemu-devel@nongnu.org; Mon, 13 Dec 2021 12:43:01 -0500 Received: from [2607:f8b0:4864:20::62d] (port=42762 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwpLh-000680-IV for qemu-devel@nongnu.org; Mon, 13 Dec 2021 12:42:59 -0500 Received: by mail-pl1-x62d.google.com with SMTP id u17so11677048plg.9 for ; Mon, 13 Dec 2021 09:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ciPxtNnzy5RQSIuGinEff8/WK2cqYqdP2QUk/Jr3dy0=; b=gRyTguK3cbVqcUcPGMqhNK9owb15M+fPnv0/aYQX/xTu5ILijw7VSnzV8//bWLX76m VSS8ZbxIDaTmruo5v7WSHIxZuQSDJ67Ts1gRmQkeis+73wDe1AGBImFOhgx+0cPQCmtP QXhdRy1amUxWrRtgjGeQhCDbw6SqsOc/iay6B/xw5t7Ub++IFzHBaVMYsND3O0ZDAkbQ 3ho8WDedGAzYrJfL3wwj5iqZmYg7lFrAnRBnRe3fF4GEARDhXSpgze6EwPinUNziUFid 2GhRh02kEvuGCUxQx0Nb3FvEgbM/EIFCC/M38RIOoqqUhRxkta4vEiffIhjjChJLBKA1 8S+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ciPxtNnzy5RQSIuGinEff8/WK2cqYqdP2QUk/Jr3dy0=; b=YRMF/hbBC5AariDV85vi/V4i/UUc1t8559i7uWFHJdWzFgIYSnb80hhGcVyOXBh19y gfekpQiTa5uU3i59CMc8twk7AE+1LxE9TMegKgz4n40SOMgikuc8GwDyxSVFvV6Nta8g 5/0bqhHgeGlN/lXjCRLHbjGigWAQltAeqZ/jFiIuUhKRWms5S7sEAafMsfMrDpJByIdA xtgsCeylXVRMjmlRucGpNjTX+6hxZd/CWeCWuDopekYx22Z/Oqg9+cgZMIC2FKhY6rPy DH13lgmPgL2wejgjQ2LYbGdIgjSGSKtA8Du5JU+LirGV1FNbTqDb/WUVeE496hmTC5AS LgCw== X-Gm-Message-State: AOAM5334udwEuQtVeubCig9mDM0dwq56EVTcuifOkTwO86f3Xa5e2O+W ukZ5P5UvEQ7UuBhjqD8SCQ5PFiVOheQT/Q== X-Received: by 2002:a17:902:a40f:b0:143:d470:d66d with SMTP id p15-20020a170902a40f00b00143d470d66dmr97179924plq.52.1639417369629; Mon, 13 Dec 2021 09:42:49 -0800 (PST) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id e7sm13819583pfv.156.2021.12.13.09.42.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 09:42:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH] target/hppa: Fix deposit assert from trans_shrpw_imm Date: Mon, 13 Dec 2021 09:42:48 -0800 Message-Id: <20211213174248.29222-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" Because sa may be 0, tcg_gen_deposit_reg(dest, t0, cpu_gr[a->r1], 32 - sa, sa); may attempt a zero-width deposit at bit 32, which will assert for TARGET_REGISTER_BITS == 32. Use the newer extract2 when possible, which itself includes the rotri special case; otherwise mirror the code from trans_shrpw_sar, using concat and shri. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/635 Signed-off-by: Richard Henderson --- target/hppa/translate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 3b9744deb4..952027a28e 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -140,6 +140,7 @@ #define tcg_gen_deposit_z_reg tcg_gen_deposit_z_i64 #define tcg_gen_extract_reg tcg_gen_extract_i64 #define tcg_gen_sextract_reg tcg_gen_sextract_i64 +#define tcg_gen_extract2_reg tcg_gen_extract2_i64 #define tcg_const_reg tcg_const_i64 #define tcg_const_local_reg tcg_const_local_i64 #define tcg_constant_reg tcg_constant_i64 @@ -234,6 +235,7 @@ #define tcg_gen_deposit_z_reg tcg_gen_deposit_z_i32 #define tcg_gen_extract_reg tcg_gen_extract_i32 #define tcg_gen_sextract_reg tcg_gen_sextract_i32 +#define tcg_gen_extract2_reg tcg_gen_extract2_i32 #define tcg_const_reg tcg_const_i32 #define tcg_const_local_reg tcg_const_local_i32 #define tcg_constant_reg tcg_constant_i32 @@ -3204,19 +3206,22 @@ static bool trans_shrpw_imm(DisasContext *ctx, arg_shrpw_imm *a) dest = dest_gpr(ctx, a->t); t2 = load_gpr(ctx, a->r2); - if (a->r1 == a->r2) { + if (a->r1 == 0) { + tcg_gen_extract_reg(dest, t2, sa, 32 - sa); + } else if (TARGET_REGISTER_BITS == 32) { + tcg_gen_extract2_reg(dest, t2, cpu_gr[a->r1], sa); + } else if (a->r1 == a->r2) { TCGv_i32 t32 = tcg_temp_new_i32(); tcg_gen_trunc_reg_i32(t32, t2); tcg_gen_rotri_i32(t32, t32, sa); tcg_gen_extu_i32_reg(dest, t32); tcg_temp_free_i32(t32); - } else if (a->r1 == 0) { - tcg_gen_extract_reg(dest, t2, sa, 32 - sa); } else { - TCGv_reg t0 = tcg_temp_new(); - tcg_gen_extract_reg(t0, t2, sa, 32 - sa); - tcg_gen_deposit_reg(dest, t0, cpu_gr[a->r1], 32 - sa, sa); - tcg_temp_free(t0); + TCGv_i64 t64 = tcg_temp_new_i64(); + tcg_gen_concat_reg_i64(t64, t2, cpu_gr[a->r1]); + tcg_gen_shri_i64(t64, t64, sa); + tcg_gen_trunc_i64_reg(dest, t64); + tcg_temp_free_i64(t64); } save_gpr(ctx, a->t, dest);