From nobody Thu Nov 28 16:53:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1691468518; cv=none; d=zohomail.com; s=zohoarc; b=bk0cKM3pLNWuK+dRkIlzqQH1yWYCOwWhWufuIJ5f+L7oxQtzHXpjCUXHbIaqyapzZN6n+TECGmTBpdoY89OkvUbSX0TLtuLvz66SYt94jsL9m9hJOLZ55M6vd0Y9SSrPxvravd9NolZBTS2wIvgmA5Wa72sS4CAcSl9sQQZ7Pdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691468518; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q7dhfUcwpc4jAqyrup5K9pjejMt9A7JsRyG2tDSr+mc=; b=ZTy3j85/YIgoIz6H2ZtfsNG162JmvsNyA4z5DAhQQVKv+SFRKM9wgP7m78q0yN1AG48xgAmWoOfuc+phLUmIMJGlr3/1SFH6A89SjmDZi3uliGP8PZG3qrqtMX+cQ+xKFXm3o2LsyPr2s1KcmCcDf1f7dlzO6E6/HJOej3izvT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691468518340227.44851819259543; Mon, 7 Aug 2023 21:21:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTEDF-0006w3-29; Tue, 08 Aug 2023 00:20:53 -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 1qTEDD-0006uW-D6; Tue, 08 Aug 2023 00:20:51 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTEDB-0007jJ-Tt; Tue, 08 Aug 2023 00:20:51 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-686be28e1a8so3638101b3a.0; Mon, 07 Aug 2023 21:20:49 -0700 (PDT) Received: from wheely.local0.net (61-68-137-140.tpgi.com.au. [61.68.137.140]) by smtp.gmail.com with ESMTPSA id fk10-20020a056a003a8a00b0068718f6a035sm6979207pfb.33.2023.08.07.21.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 21:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691468448; x=1692073248; 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=q7dhfUcwpc4jAqyrup5K9pjejMt9A7JsRyG2tDSr+mc=; b=dXTJ942WVDwt2ktLti46QlUaN+plR7QbZjmi+9zkANKkG06vHE7jyrh7+WwDkcpYRu pmynt/e52XQQ1pY4f8I6JphxOOC+mGxrzAQwc9n6V4qt5oNoDWKjz65F4h0yxmIfTUjG xc4x9xBnYLeov1VOf4SLt0P9jKNDo/Mch9jHSRi454Kw+TdnUoWE91Z9OzbtI73GosU8 2RW/njN4zkCgkVidf7pHZKkSoHBwD5YiGsty5/TGUM5XGP5Broi+Dj0ZqtYMcPxhFIGm KG3Go++JwNGRpTRRD5SG+4quCSqPw72k/sIQmZvB9xV5nknVvDSZZDuY9V026oDPo3Ke tWMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691468448; x=1692073248; 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=q7dhfUcwpc4jAqyrup5K9pjejMt9A7JsRyG2tDSr+mc=; b=enOzt0HLwrA2TSCA3a2Lp8xkZkCp/gvXYhA2seQKz3P1teHso0yE517fPgRhhjHfEG I1TMTAy57tO01i/VgzGN3hhKTkoS8JAHYgsmFLpox7V3Q5Ig7ZAECj8tBkQ7CXNQ2wDn N0EC50GQS0Csi6HnqeOo8eIZLmmdDkA0ZMjsppjATsG2qhhw2FWOzpZwC2arjcswuIaz j0wUN5ywU+0lzuVAtFvdxOXC3gK5xon0B/6h4gaW3/aE1fRRvUQ3QJfhU4GFtpJR/Sbl 6TYsDC0PGqjnRyKJz+peiSPIzj4esks7NTDmDdraJp69BKGmLM5V4w06Py6btl+BXRJZ cIqg== X-Gm-Message-State: AOJu0YwudKpuDFO2sy+YFMLyHuIhj4GCbmQSIKn6ICEQlvSs4NJxyPST 3Xfydh+B7S3oCe19BMnm6bUr2mpPLVY= X-Google-Smtp-Source: AGHT+IErzqNXPEStJAUDHZy5a3q0GtY3cdNTEQDOwxLeP/+EW4ODFLh76ciTEMiqMWc8JA8QfuUdxg== X-Received: by 2002:a05:6a00:1306:b0:668:73f5:dce0 with SMTP id j6-20020a056a00130600b0066873f5dce0mr10076311pfu.29.1691468447971; Mon, 07 Aug 2023 21:20:47 -0700 (PDT) From: Nicholas Piggin To: Daniel Henrique Barboza Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Harsh Prateek Bora , Pavel Dovgalyuk , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 08/19] target/ppc: Sign-extend large decrementer to 64-bits Date: Tue, 8 Aug 2023 14:19:50 +1000 Message-Id: <20230808042001.411094-9-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230808042001.411094-1-npiggin@gmail.com> References: <20230808042001.411094-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42b.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, FREEMAIL_FROM=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691468520474100003 Content-Type: text/plain; charset="utf-8" When storing a large decrementer value with the most significant implemented bit set, it is to be treated as a negative and sign extended. This isn't hit for book3s DEC because of another bug, fixing it in the next patch exposes this one and can cause additional problems, so fix this first. It can be hit with HDECR and other edge triggered types. Fixes: a8dafa52518 ("target/ppc: Implement large decrementer support for TC= G") Signed-off-by: Nicholas Piggin --- hw/ppc/ppc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index a397820d9c..fb4784793c 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -743,7 +743,9 @@ target_ulong cpu_ppc_load_decr(CPUPPCState *env) * to 64 bits, otherwise it is a 32 bit value. */ if (env->spr[SPR_LPCR] & LPCR_LD) { - return decr; + PowerPCCPU *cpu =3D env_archcpu(env); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + return sextract64(decr, 0, pcc->lrg_decr_bits); } return (uint32_t) decr; } @@ -762,7 +764,9 @@ target_ulong cpu_ppc_load_hdecr(CPUPPCState *env) * extended to 64 bits, otherwise it is 32 bits. */ if (pcc->lrg_decr_bits > 32) { - return hdecr; + PowerPCCPU *cpu =3D env_archcpu(env); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + return sextract64(hdecr, 0, pcc->lrg_decr_bits); } return (uint32_t) hdecr; } --=20 2.40.1