From patchwork Tue Aug 22 07:19:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 715699 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp120582wrp; Tue, 22 Aug 2023 00:20:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkWJIwqvn6wHHr4TkSgjyNALBdh6j1Bl1Rc3OViutybcf1yj5SKVNQ8UhCyeIcX4ZWuqu+ X-Received: by 2002:ae9:e011:0:b0:765:a7c3:69ab with SMTP id m17-20020ae9e011000000b00765a7c369abmr8767897qkk.45.1692688831999; Tue, 22 Aug 2023 00:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692688831; cv=none; d=google.com; s=arc-20160816; b=W6r1NdKYpIBpYYpkQaKUjmx4YDRXIBehxc3LgwqlVmH6YNmWWZUE/v9eoYBE8vS1ru 2z+0M8jRYdj5W4LOdYCiRmXXwHswg3FhXJXfUCOXT7kH3lLwPnvWDiel/eJ63nf/S2L8 caZKCtbRCcBlps9VJVLA+PeFmNSxplZ/3ASYAQHW1o/yI9cl3VTheWOof2B1O2zhOjtw AOcwDup76Z0LAOMvDKho8xETWbfc7OsNBa0HI0QHG8PROBH4QFpyYbFTAOpAYcVjDsm2 44+eqGUnb56RIH8A9AhOrNnkJ4JXiLELSMv+2iMJ9JWLkd6NgDkD6msa06pXnFo7Fi+a tRKQ== 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=MhjR1Tf2TeBu860wg/l8a21u7QsD4djihIlF5A0hbsE=; fh=IauHLtGdVi5m9rCNCDXgkBuY8q6wkaEoqBTGXQDGRRo=; b=LhUaOh8bmj1cgcnAB+/tOME2mRt1Ny34R2OjCOAbQonu8IkjAVb4IQw/BHxTh4xu3H bOptgBAet30llbudlVsAeaKIBC5ZhtG5DdNPV1f0AQC/csy9VjWs3W9CO0lP0vpTtmwI kJkbZH26/SeYEq72STepmwCYIqDz9jGjUt+pitpHx3OT/rfXYgwdshQlPy71qSgu8B2Z DA8L87TZtcEGVL1WJ3dHg2jUgfwOO6+UL5NyOujNWujLmlFvqLLTjZrf5XAdAsngLPqS 406zvCdGf600FLPye2EoKhFzk0fUIpoJS+tF2TRncaq0ODS5EkBs4NTEFDQZWljvzv9Z XY9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TxFtfTqf; 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 j8-20020a05620a288800b0076cb2727c15si863754qkp.638.2023.08.22.00.20.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Aug 2023 00:20: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=@linaro.org header.s=google header.b=TxFtfTqf; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYLgY-0006xj-Oc; Tue, 22 Aug 2023 03:20:18 -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 1qYLgW-0006xY-04 for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:20:16 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYLgS-0004cY-74 for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:20:14 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31aeee69de0so2341457f8f.2 for ; Tue, 22 Aug 2023 00:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692688810; x=1693293610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MhjR1Tf2TeBu860wg/l8a21u7QsD4djihIlF5A0hbsE=; b=TxFtfTqfzuP86TULQjBP9Fc9LyCmXjZfx39IvEUzYF/HziXdHqK7ZTJAlKSF+W1YF9 6hi+MwW63lcpE4iwjOvfE9eCrEGOREHnAP7z8zboMW0TdwzZc4uto1doQ1Kr1KeDplfV LjZlQCRu3bMrSjLgghLC9hc9Vu4wLRD3wljyjrL/ynVILJbTe7AsERNOHpwpbDmqxbUU XGD9DjFYDdGEwIh2d7nmwmTAQFpREB5ZvCCm5yc0YmSeeh1g4FWtDYd6iKnsC/G2FABL Crdkb2vl8casZLfuWfofEEsEn0FxyizV1DwroDbtgTvZUGdXlC9z+ww9JqUyKPU9g0ox AzlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692688810; x=1693293610; 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=MhjR1Tf2TeBu860wg/l8a21u7QsD4djihIlF5A0hbsE=; b=MsXcaud7dl8lSLFCSJxm8d7OUZSR2gaOgEsZ4MtHz3duC9eWi+1Jkg450q8raP/lUM VvU0iNVqwUTA9a6W+d0ZFRC+Ezu4AiLrTf8SqB5ZAXkDy0Xvv8/Md/b3glkOZxV6vanp S8GYhYna9GPek6R+tO5c3K1k5MDhiKPV/KpKuBzMj8V0F+0HkK5wzIG/fI0iIvIXshMN fJff700r88bsL3V6YAXvonyQyF2aYcyUh5yZlXCbEZXfpjxBCInR5w2TIJWxokcdyY0t X93hspfiL9/0djQh4gNpAV5DwIO0ja9aUcFPxK/lUERz5sCbog63wsGoaUHm5z214qAu lTUw== X-Gm-Message-State: AOJu0YyDdy3q/mXuVB4DDpBJMFKkQ/Dnnr8wy2d5OFLbI6gMpFlR5ger MxiOgsONSdvJhZAAySTtuvP9fxJnV/xJ6xi9wkMLkg== X-Received: by 2002:adf:fed1:0:b0:317:5b5f:2328 with SMTP id q17-20020adffed1000000b003175b5f2328mr6828132wrs.24.1692688810034; Tue, 22 Aug 2023 00:20:10 -0700 (PDT) Received: from localhost.localdomain ([37.19.214.4]) by smtp.gmail.com with ESMTPSA id g18-20020a5d5552000000b003142ea7a661sm14807924wrw.21.2023.08.22.00.20.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Aug 2023 00:20:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Song Gao Cc: Jiajie Chen , Xiaojuan Yang , Huacai Chen , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH RESEND v5 10/19] target/loongarch: Sign extend results in VA32 mode Date: Tue, 22 Aug 2023 09:19:50 +0200 Message-ID: <20230822071959.35620-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822071405.35386-1-philmd@linaro.org> References: <20230822071405.35386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Jiajie Chen In VA32 mode, BL, JIRL and PC* instructions should sign-extend the low 32 bit result to 64 bits. Signed-off-by: Jiajie Chen Reviewed-by: Richard Henderson Signed-off-by: Song Gao Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20230822032724.1353391-7-gaosong@loongson.cn> --- target/loongarch/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/loongarch/translate.c b/target/loongarch/translate.c index 9a23ec786d..de7c1c5d1f 100644 --- a/target/loongarch/translate.c +++ b/target/loongarch/translate.c @@ -238,6 +238,9 @@ static TCGv make_address_i(DisasContext *ctx, TCGv base, target_long ofs) static uint64_t make_address_pc(DisasContext *ctx, uint64_t addr) { + if (ctx->va32) { + addr = (int32_t)addr; + } return addr; }