From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414303; cv=none; d=zohomail.com; s=zohoarc; b=oKMEbs/bHzXxfutlYM404xRBTqLoxHGqJ4QPJwufqhWWHUN+JZsc2BH79sHYgEsI6LMPJcqQE+MxnQf4tPBEC1I/mkG0kn5ka4n4WhwiEceeIZ6jUvJgKA9cPZl4iYk2SpiAX4/OyUNy2/0Pjlrf2LrMZ4kHyeqLYSAALtwBYEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414303; h=Content-Transfer-Encoding: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=94FCi7vRK7PCs/VHyO/ULgXCs/4n8etjGNdHUXsYuv0=; b=fX/zRcv3JWVonpA+1YJwnEQ1i+9DLPBuDIVXAk4od0k3ObHFKlllVqmjmKxu4gLDI/Gb/aMHb0rJsVExJAHR4WPOsqY62RgT3hEqS9SzMIRkrupPJ45SjqLp/hkH8p/h8BfZg3TUGJjFG2pg4V7JUiistwynszGoqeyiohNzSmw= 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 1684414303661944.8335205971481; Thu, 18 May 2023 05:51:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6G-00048X-03; Thu, 18 May 2023 08:51:22 -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 1pzd68-00048D-0N for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:12 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd66-0007vV-Ih for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:11 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f42769a0c1so20056105e9.2 for ; Thu, 18 May 2023 05:51:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414269; x=1687006269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=94FCi7vRK7PCs/VHyO/ULgXCs/4n8etjGNdHUXsYuv0=; b=FH3XHwwpO8AVRez9im6KL3DnjOzEy5bgBxrJimKFYw3QrKXEU//zANcAAEG2orkWFr zWwED5i5Um7RUUFb9mp0oTDuHbYG2zTeoDLPWTH2q1Y5WRYzdLzzk9gwT6NG+6C+4m/k CRB3Bmw70pIN+MVgetw4RVhW2yjDxnVP75FvENh/63c2hKwJATjqwc8wcBBqvjICHbz1 7FGV2C/AHolw+xKqxJTnR8DbzBiPItKDuyMhsaGLkCOG4gim5V5jFclB11fO/WhY16Rd VU1R0o20rD5ffktvae2adeJFOzp/97utq+KlIkW/oc5zdc8heVnIgLkoqGNpzdac/tPQ UlIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414269; x=1687006269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=94FCi7vRK7PCs/VHyO/ULgXCs/4n8etjGNdHUXsYuv0=; b=R4yj2UB8UG4xe5kBsojiEBjfjmcXsVUkswJy670Bh7qzkVzJsyVWGxfGblB+S3sqFU 1MTYKfIWU3KHj/8oXaXpDuHCAKUnAb6NMjBtJVwNfQaPvwoeOCF6v3BMG0V3DANTNVqo 1GQuLDrr2+8VOPMaT+LkVim1hdvaOJ8sKawSyu6D20OhvprIp4ZArfYBlvtj5xQ7M1op Iyn7acGh4zScabrY4XLm/XnEjjnj31Gn3Ia3qsG97dGXyIhoS10zm8cvtpD8TMFsFWtX p32uJyqpgAAUwcoa1yLGzjqfH0mkL0NEYlJJrhE32qFL2z8wC233s5J9ul2LJtt1WsT0 fAPQ== X-Gm-Message-State: AC+VfDwPilSKJr7h2KRrRWYKwLkkQjEQ3Uoih5tMELW/q6Pezu05NDXp yZ9YMfaLYVqxlS06av9GAuCw+ihJxhAqQxIhdQY= X-Google-Smtp-Source: ACHHUZ47PDwBmtssD+SPDatP1AMFzZEfDqHTdtRKtzphe8l31CIzhfEaCUM77xMLfNM+DBheLKF4+g== X-Received: by 2002:a1c:7910:0:b0:3f4:27ff:7d54 with SMTP id l16-20020a1c7910000000b003f427ff7d54mr1523362wme.3.1684414269118; Thu, 18 May 2023 05:51:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/29] sbsa-ref: switch default cpu core to Neoverse-N1 Date: Thu, 18 May 2023 13:50:39 +0100 Message-Id: <20230518125107.146421-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414304748100002 Content-Type: text/plain; charset="utf-8" From: Marcin Juszkiewicz The world outside moves to newer and newer cpu cores. Let move SBSA Reference Platform to something newer as well. Signed-off-by: Marcin Juszkiewicz Reviewed-by: Leif Lindholm Message-id: 20230506183417.1360427-1-marcin.juszkiewicz@linaro.org Signed-off-by: Peter Maydell --- hw/arm/sbsa-ref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 0b93558dde1..a1562f944a6 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -852,7 +852,7 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *= data) =20 mc->init =3D sbsa_ref_init; mc->desc =3D "QEMU 'SBSA Reference' ARM Virtual Machine"; - mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a57"); + mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("neoverse-n1"); mc->max_cpus =3D 512; mc->pci_allow_0_address =3D true; mc->minimum_page_bits =3D 12; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414412; cv=none; d=zohomail.com; s=zohoarc; b=STO+MkLU5QY+EjXHOcTmCHjVCCgzN7zg9ASHCVo121alsEgtmJTGgIBQTJ/yFhEQGGKmgKEPihXbG/vL6O12JNy8a4nPPr/yNT5Px0YHwW6p4Lpy458vMoHin8WXZOKx0Rlx4yPjfCQhv4toyKfld1Lt1ITPDrdoSgKbgGhJaE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414412; h=Content-Transfer-Encoding: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=3qgQgU0oovp++OASw0Q9fkW/XuF2+8h0xHqcmjtio2o=; b=c1r3SpvIGQbc8NOygzwE5rfsKAip1aSrHfeRYOcNqOM55pVzJgPxoLHm9SxzOb3wLPO26AS6ZWCclB3xCPhU1pnJCaZIHhvixx33t8MyM4QsLIT5fibsaQs3pZRwjgdOW1xSVykuRNPkf4SGvsMalgLhrpKR8vXgxIdSP7Gtzw4= 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 1684414412153857.8280527697641; Thu, 18 May 2023 05:53:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6M-0004AU-5P; Thu, 18 May 2023 08:51:27 -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 1pzd6C-00048l-Tv for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:19 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd67-0007vn-Hs for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:13 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f4249b7badso20004865e9.3 for ; Thu, 18 May 2023 05:51:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414269; x=1687006269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3qgQgU0oovp++OASw0Q9fkW/XuF2+8h0xHqcmjtio2o=; b=PIY78DRzhDloelyVFdnDXBNoH066+cQQD70srzPuacfQ/BpVgoygWKSHW4xo3uF2r1 GwRsDlz4ugmcWrjE6KjAfgykQXbyidmmxwJ+Gjst+IFG1fDZEvAzzssIMNn8jRD4iT4o Y/uWStgtb4nccBdpXD5FTqafWF54MNfG+O5oaWWAgk230iwNKol9WqJrXJMNLA2OxX0W wAZQbMAZM9MhBampIWsbpl04HZ8h4Ii+fId3zvX/JCBxmkWB7WeLNdQTkwo7zCLQpIzG S78CciOyW3VK2R+B4iwyX5m+uHGzmfZm3QNkcijkgSribOgUapeSokiZ47Erux7Gsjiw Umrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414269; x=1687006269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3qgQgU0oovp++OASw0Q9fkW/XuF2+8h0xHqcmjtio2o=; b=Ypy867hss6S8m2jz6xs7PLKWmkDNXCrOmoU0GzMx3LV6NG9Vau4+FfDe/Sa10xhwEC SDbA38zsAuG29rgsSSBQUkcGIR1UrBGHKkhusTc6+D4GzEFHDvvpnie8vtKhXIn2Eyk5 S43EJGg/Pkhc7iO7kgI/Om+vXzr/6KjQiEJ1JHj2RZ+myLKJurxkUjzG0R0edZflSAdN zY2BJe9F78W08TfXITh49y9jVdlm+1X0rSu34tT8p0577JLWCFa+FSmjcy+DcAf1IbHt 2JdMx801WBqDMXELCakSO3GKtv+sRbJNJqizlP7rWpciOcXTu2OhYPUgi58Jo+Am6E32 LgJA== X-Gm-Message-State: AC+VfDzHkWvy32PsOgVOasQEab+ayNQTXWnJYnfTJIhW7sYA0/gwaIel zruzyegB/a+1KjxYSgDeg62+26MtU3k8APMThr8= X-Google-Smtp-Source: ACHHUZ5wfLoreon7OriuyIdjTvadvW/fpNDugCBGEDTE2ay0YP8nZZyiR0BYVhag5PeAgUEDH+pDVA== X-Received: by 2002:a05:600c:ad9:b0:3f4:21ff:b91f with SMTP id c25-20020a05600c0ad900b003f421ffb91fmr1416245wmr.28.1684414269574; Thu, 18 May 2023 05:51:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/29] target/arm: Fix vd == vm overlap in sve_ldff1_z Date: Thu, 18 May 2023 13:50:40 +0100 Message-Id: <20230518125107.146421-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414413423100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson If vd =3D=3D vm, copy vm to scratch, so that we can pre-zero the output and still access the gather indicies. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612 Signed-off-by: Richard Henderson Message-id: 20230504104232.1877774-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/sve_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c index ccf5e5beca2..0097522470e 100644 --- a/target/arm/tcg/sve_helper.c +++ b/target/arm/tcg/sve_helper.c @@ -6727,6 +6727,7 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t= *vg, void *vm, intptr_t reg_off; SVEHostPage info; target_ulong addr, in_page; + ARMVectorReg scratch; =20 /* Skip to the first true predicate. */ reg_off =3D find_next_active(vg, 0, reg_max, esz); @@ -6736,6 +6737,11 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_= t *vg, void *vm, return; } =20 + /* Protect against overlap between vd and vm. */ + if (unlikely(vd =3D=3D vm)) { + vm =3D memcpy(&scratch, vm, reg_max); + } + /* * Probe the first element, allowing faults. */ --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414415; cv=none; d=zohomail.com; s=zohoarc; b=btZlToPzubQsE6es0s4KzcBnnmhsVT4sj25LWbb2oplXzxah9J2mSIGv94CO6g7Z+mq1onj++cBxHn4PhQ4TeuX9SleQecCcpidp1pHV1PxnSa8O36tUvkagc5ROB1HcLQObbN7te6LeviIH4VPbJEF93/1AV7m/66zx7AaS1xs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414415; h=Content-Type:Content-Transfer-Encoding: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=71bqprvJHFwaprTBPUqH8YYr/a1cVIn1wiv2+BaYT4w=; b=MyUXVlCqd+kvq/S7iWkTjzu1MPdmEsTdXCXgwJDkXQqvMH0ANQITUUcnqtntKYQnufyPSNtnQa21i/Q7s/mBYCIgsMvjPIHN0nQfxEnjgZPS3/QjS73YOKTYtFzGvUXBjvDeV06ypB6vHhWPddu7R6gulmErAZ6tif34/MV3dII= 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 1684414415097466.99456992406; Thu, 18 May 2023 05:53:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6S-0004Cn-GJ; Thu, 18 May 2023 08:51:32 -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 1pzd6B-00048k-Sh for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:19 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd67-0007w6-IE for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:12 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f41dceb9d1so19555945e9.1 for ; Thu, 18 May 2023 05:51:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414270; x=1687006270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=71bqprvJHFwaprTBPUqH8YYr/a1cVIn1wiv2+BaYT4w=; b=XxhhaI73zrKQLFUp0bAKtZlL+vGjWTJ87alMItSmwVZ4xEkcELr7i88BQSVYhnoF/5 mw8ISmByqZlfjYGamX7TJnnsHUDKxntwBkRfhz8UI0PmXXfBueJ1mTXsPREhP7WcyRLx ubahybu+3KACBoMj8JjtmkNQmWxwDvhrAhyH/jwPcPPS8qOY/clr4zhOIwYGrfaGTxn7 kzA9pC8KTbBIkHcmK3R1eV9MqWkHnXSNMp30H4mXE6LX4bLeuFXa2hoMzMQDj68FlTdb CJOlejLDeLnUsBp60Q08+tkQtelsxcKtIOrb+qCQRK+b2CYFf75xklT2dKYhyfEz1qDr 3psA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414270; x=1687006270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=71bqprvJHFwaprTBPUqH8YYr/a1cVIn1wiv2+BaYT4w=; b=hgMg8tsn/j4qurNPl3EbxEJWPJ+IVIk6hZ1XkNu2FjKtPnO+VmdlhQsbgJp2NGVoJ+ pB/WrAUbXsAJUmQLTSGjw0r7yMLXo+mTmLsgIR2BOWYHsnx1FstxLCni7j3iNu2QyZNy qksx73WqfGIdiSbGeOCE2MruAz/Szjq1nXOvBiDdTY2Y0pPuEOa+nWq7asifyzdz215b a1YJCbeMe9xVyxI9D8DHrgyFNPEhL0UxRBRoWb5qZ/2drpaxmYlrww4TD9QRjVTSAOQA DfV0kL762k6Wir8Lp/1RbSBPbfIoPE6SttrQeIcg1+6sTO8JHuFOiIPXcTXYZ3ZyUmES +HVg== X-Gm-Message-State: AC+VfDwSGbJGJgB0NV5I8e7dR6M1lTnNWZMu+dZrI0PENOziaPwcoaA8 be5dwPjoG22BH1A7cb9FjXmKEHGFcZp0bznWMls= X-Google-Smtp-Source: ACHHUZ6Dkm55MfVU8Y0gWVYIqoRcqiCa89NT3pjxNLn5FdqSWGBzXX0LuPVYOx7P7RbGWFAmckYeZw== X-Received: by 2002:a1c:7910:0:b0:3f4:f0c2:127 with SMTP id l16-20020a1c7910000000b003f4f0c20127mr1577334wme.22.1684414269989; Thu, 18 May 2023 05:51:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/29] Maintainers: add myself as reviewer for sbsa-ref Date: Thu, 18 May 2023 13:50:41 +0100 Message-Id: <20230518125107.146421-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414415540100006 From: Marcin Juszkiewicz At Linaro I work on sbsa-ref, know direction it goes. May not get code details each time. Signed-off-by: Marcin Juszkiewicz Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20230515143753.365591-1-marcin.juszkiewicz@linaro.org Signed-off-by: Peter Maydell --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 50585117a0b..d0e604c725d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -940,6 +940,7 @@ SBSA-REF M: Radoslaw Biernacki M: Peter Maydell R: Leif Lindholm +R: Marcin Juszkiewicz L: qemu-arm@nongnu.org S: Maintained F: hw/arm/sbsa-ref.c --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414496; cv=none; d=zohomail.com; s=zohoarc; b=eqlImcIfz1ni7WbA5SlNBbeQCPuCD8D0AohkowgNfEX5PciB8EyovI5UpFKxfx4NOslhS38wOcop1Yn975H1XWegAloE6+XpLsIAfV0Y+YvwsCwUiW7iCWhJLw50gMK/T/6dfOWqt/4uXoaqm2ABRQefbAXxeArlOY+MSEIrCC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414496; h=Content-Transfer-Encoding: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=Dvb2oduGiED8gUe4k3v43syGsJCxTmuhvJjtOtVniqQ=; b=HMToOTjOV6QbtDii5pCyqR5Y7l+0yWNc6odQLbN0uB8JxP6S10A0mn0ZBT/BRkbSWB4+qk1qn4K+LZZpp3aEE9eWyhvvz7PvgwB1cs8hYyWuv/U19hKOxS0xAO2boztESyTVx7NYffGrJVew39n6o+4roZnkFfMhU583p1oliyc= 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 1684414496628784.0343169463453; Thu, 18 May 2023 05:54:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6P-0004Bf-J7; Thu, 18 May 2023 08:51:29 -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 1pzd6C-00048m-Tm for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:19 -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 1pzd68-0007x6-Bg for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:14 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-30636edb493so826487f8f.1 for ; Thu, 18 May 2023 05:51:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Dvb2oduGiED8gUe4k3v43syGsJCxTmuhvJjtOtVniqQ=; b=qHAX684DAkLm9UkP5iMjLsWMrJyhH4x7Ot0R68kYSaDCpeHl6Cfl5CbJ94Rd/QHxo7 EJUDkRM9lr4VZgFoZH3vemczu07jP7rKKe/K5pC36cCfjkpP3khksPIlb/or3RfsYvlL uva5EBpYlAwQPg+57x/njYHpOETXxHWMlvHfIMo3ARXGSx4vaf8CKGmqXSTZS1jL3uQX jgRv6/YEP/E8Wrc9QBVgaQKcl8BBJ4ayhXOrcz+1Gx0QWVYKpyd/T0SJWQIGuuKA3wIj 1zRyAZVhEYceezrhavOAWEP6NFjpCAW8y7yvrlqzweydjMbW9nFqB/qhvQH/6y2rpYbA gOqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dvb2oduGiED8gUe4k3v43syGsJCxTmuhvJjtOtVniqQ=; b=BI0zy/tW3iBtarTQRIarrTzWg1w1vo2Uz4dGUrV1QFQu+oImxeHRhbe6+pRTLGQZWW cTvu1Kc/34K4lZhEgSRLbj/mmd/f3vft5BXa71NctOdrYl8cv+HXj4yZpFaft0nMJlja 6MAsPiRp75IK176tcaCkLA66IlIsNTMlDLUTPnhaTxHy9QGYgsyHMpAMhel+OvaymlsM L4yJKDgGDRBVo/7xpKEObnYfJ9CmJVUwtnS7MSKYPNsa3MEKPsIHXjK0xvS38O/TqJHO zCkSfgWZ/54yfj6TxsXmkWi3mlHwTjCSZPTEVg/iT5myi9b3XK4Es1t436hUTU6k2X5g SSJg== X-Gm-Message-State: AC+VfDxheuzf481K27cCtRXlvrN5nfW20ztY6OMvyk8nJq2CzlB478qr LhdRbrzoIQQ6HxZHtfDYlpAkVmDemaB/jqc5yT0= X-Google-Smtp-Source: ACHHUZ7C1KL/Eme44iEShD6KN0VpK1bIHJ2YWNfVZoPlGsYzoRNFZ3bGqMX7c5uQ3eesGcoNxSA+iQ== X-Received: by 2002:adf:ebc6:0:b0:309:4ece:a412 with SMTP id v6-20020adfebc6000000b003094ecea412mr647906wrn.14.1684414270657; Thu, 18 May 2023 05:51:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/29] arm/kvm: add support for MTE Date: Thu, 18 May 2023 13:50:42 +0100 Message-Id: <20230518125107.146421-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::435; envelope-from=peter.maydell@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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414498856100009 Content-Type: text/plain; charset="utf-8" From: Cornelia Huck Extend the 'mte' property for the virt machine to cover KVM as well. For KVM, we don't allocate tag memory, but instead enable the capability. If MTE has been enabled, we need to disable migration, as we do not yet have a way to migrate the tags as well. Therefore, MTE will stay off with KVM unless requested explicitly. Signed-off-by: Cornelia Huck Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230428095533.21747-2-cohuck@redhat.com Signed-off-by: Peter Maydell --- target/arm/cpu.h | 4 +++ target/arm/kvm_arm.h | 19 ++++++++++++ hw/arm/virt.c | 73 +++++++++++++++++++++++++------------------- target/arm/cpu.c | 9 +++--- target/arm/kvm.c | 35 +++++++++++++++++++++ target/arm/kvm64.c | 5 +++ 6 files changed, 109 insertions(+), 36 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d469a2637b3..c3463e39bcd 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -935,6 +935,9 @@ struct ArchCPU { */ uint32_t psci_conduit; =20 + /* CPU has Memory Tag Extension */ + bool has_mte; + /* For v8M, initial value of the Secure VTOR */ uint32_t init_svtor; /* For v8M, initial value of the Non-secure VTOR */ @@ -1053,6 +1056,7 @@ struct ArchCPU { bool prop_pauth; bool prop_pauth_impdef; bool prop_lpa2; + OnOffAuto prop_mte; =20 /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ uint32_t dcz_blocksize; diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 330fbe5c722..2083547bf60 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -313,6 +313,13 @@ bool kvm_arm_pmu_supported(void); */ bool kvm_arm_sve_supported(void); =20 +/** + * kvm_arm_mte_supported: + * + * Returns: true if KVM can enable MTE, and false otherwise. + */ +bool kvm_arm_mte_supported(void); + /** * kvm_arm_get_max_vm_ipa_size: * @ms: Machine state handle @@ -377,6 +384,8 @@ void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa); =20 int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); =20 +void kvm_arm_enable_mte(Object *cpuobj, Error **errp); + #else =20 /* @@ -403,6 +412,11 @@ static inline bool kvm_arm_steal_time_supported(void) return false; } =20 +static inline bool kvm_arm_mte_supported(void) +{ + return false; +} + /* * These functions should never actually be called without KVM support. */ @@ -451,6 +465,11 @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *c= s) g_assert_not_reached(); } =20 +static inline void kvm_arm_enable_mte(Object *cpuobj, Error **errp) +{ + g_assert_not_reached(); +} + #endif =20 static inline const char *gic_class_name(void) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b99ae185016..06b514b25c3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2146,7 +2146,7 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - if (vms->mte && (kvm_enabled() || hvf_enabled())) { + if (vms->mte && hvf_enabled()) { error_report("mach-virt: %s does not support providing " "MTE to the guest CPU", current_accel_name()); @@ -2216,39 +2216,48 @@ static void machvirt_init(MachineState *machine) } =20 if (vms->mte) { - /* Create the memory region only once, but link to all cpus. */ - if (!tag_sysmem) { - /* - * The property exists only if MemTag is supported. - * If it is, we must allocate the ram to back that up. - */ - if (!object_property_find(cpuobj, "tag-memory")) { - error_report("MTE requested, but not supported " - "by the guest CPU"); + if (tcg_enabled()) { + /* Create the memory region only once, but link to all cpu= s. */ + if (!tag_sysmem) { + /* + * The property exists only if MemTag is supported. + * If it is, we must allocate the ram to back that up. + */ + if (!object_property_find(cpuobj, "tag-memory")) { + error_report("MTE requested, but not supported " + "by the guest CPU"); + exit(1); + } + + tag_sysmem =3D g_new(MemoryRegion, 1); + memory_region_init(tag_sysmem, OBJECT(machine), + "tag-memory", UINT64_MAX / 32); + + if (vms->secure) { + secure_tag_sysmem =3D g_new(MemoryRegion, 1); + memory_region_init(secure_tag_sysmem, OBJECT(machi= ne), + "secure-tag-memory", + UINT64_MAX / 32); + + /* As with ram, secure-tag takes precedence over t= ag. */ + memory_region_add_subregion_overlap(secure_tag_sys= mem, + 0, tag_sysmem,= -1); + } + } + + object_property_set_link(cpuobj, "tag-memory", + OBJECT(tag_sysmem), &error_abort); + if (vms->secure) { + object_property_set_link(cpuobj, "secure-tag-memory", + OBJECT(secure_tag_sysmem), + &error_abort); + } + } else if (kvm_enabled()) { + if (!kvm_arm_mte_supported()) { + error_report("MTE requested, but not supported by KVM"= ); exit(1); } - - tag_sysmem =3D g_new(MemoryRegion, 1); - memory_region_init(tag_sysmem, OBJECT(machine), - "tag-memory", UINT64_MAX / 32); - - if (vms->secure) { - secure_tag_sysmem =3D g_new(MemoryRegion, 1); - memory_region_init(secure_tag_sysmem, OBJECT(machine), - "secure-tag-memory", UINT64_MAX / 3= 2); - - /* As with ram, secure-tag takes precedence over tag. = */ - memory_region_add_subregion_overlap(secure_tag_sysmem,= 0, - tag_sysmem, -1); - } - } - - object_property_set_link(cpuobj, "tag-memory", OBJECT(tag_sysm= em), - &error_abort); - if (vms->secure) { - object_property_set_link(cpuobj, "secure-tag-memory", - OBJECT(secure_tag_sysmem), - &error_abort); + kvm_arm_enable_mte(cpuobj, &error_abort); } } =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 5182ed0c911..f6a88e52ac2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1480,6 +1480,7 @@ void arm_cpu_post_init(Object *obj) qdev_prop_allow_set_link_before_reali= ze, OBJ_PROP_LINK_STRONG); } + cpu->has_mte =3D true; } #endif } @@ -1616,7 +1617,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) } if (cpu->tag_memory) { error_setg(errp, - "Cannot enable %s when guest CPUs has MTE enabled", + "Cannot enable %s when guest CPUs has tag memory en= abled", current_accel_name()); return; } @@ -1996,10 +1997,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) } =20 #ifndef CONFIG_USER_ONLY - if (cpu->tag_memory =3D=3D NULL && cpu_isar_feature(aa64_mte, cpu)) { + if (!cpu->has_mte && cpu_isar_feature(aa64_mte, cpu)) { /* - * Disable the MTE feature bits if we do not have tag-memory - * provided by the machine. + * Disable the MTE feature bits if we do not have the feature + * setup by the machine. */ cpu->isar.id_aa64pfr1 =3D FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 84da49332c4..9553488ecd1 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -31,6 +31,7 @@ #include "hw/boards.h" #include "hw/irq.h" #include "qemu/log.h" +#include "migration/blocker.h" =20 const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { KVM_CAP_LAST_INFO @@ -1064,3 +1065,37 @@ bool kvm_arch_cpu_check_are_resettable(void) void kvm_arch_accel_class_init(ObjectClass *oc) { } + +void kvm_arm_enable_mte(Object *cpuobj, Error **errp) +{ + static bool tried_to_enable; + static bool succeeded_to_enable; + Error *mte_migration_blocker =3D NULL; + int ret; + + if (!tried_to_enable) { + /* + * MTE on KVM is enabled on a per-VM basis (and retrying doesn't m= ake + * sense), and we only want a single migration blocker as well. + */ + tried_to_enable =3D true; + + ret =3D kvm_vm_enable_cap(kvm_state, KVM_CAP_ARM_MTE, 0); + if (ret) { + error_setg_errno(errp, -ret, "Failed to enable KVM_CAP_ARM_MTE= "); + return; + } + + /* TODO: add proper migration support with MTE enabled */ + error_setg(&mte_migration_blocker, + "Live migration disabled due to MTE enabled"); + if (migrate_add_blocker(mte_migration_blocker, errp)) { + error_free(mte_migration_blocker); + return; + } + succeeded_to_enable =3D true; + } + if (succeeded_to_enable) { + object_property_set_bool(cpuobj, "has_mte", true, NULL); + } +} diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 810db33ccbd..1893f387936 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -756,6 +756,11 @@ bool kvm_arm_steal_time_supported(void) return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); } =20 +bool kvm_arm_mte_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_MTE); +} + QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN !=3D 1); =20 uint32_t kvm_arm_sve_get_vls(CPUState *cs) --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414431; cv=none; d=zohomail.com; s=zohoarc; b=Z/OeKrjOMPWRyk+29m7PAQV1qlMaJjXdsDqjeFutghO8B0y/6wiJagucdgItgV80aqs9+uyzLbOHGaPyl04P/2yxaXfiWNyh9fMJ1NreTq8HELJYEUromAbtwqVPTWh6XYq0N8nHfQVTvl3F++UGi7bq52Q6ubrmAsDMk0+uz9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414431; h=Content-Type:Content-Transfer-Encoding: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=wxd+FoSXQR+gX/AlQoxBlHelx6+D0GgmomOiDV1+MQM=; b=G5jGKXMetF2c4Il7SdY99MGNcEWzj66n/4hmBpl5ZPYYwlhPLr/b/AFzBEVtfHXIZzNmSDbTQ5wepoLbrd+3a4ljT8sBMvBw0QH+HZonsoCxdubCeOXafOBKGcuD68SsANh3Zkl+W3mFI5+r97c6ep0T3Z+5AuRjF+xw61P/ehY= 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 1684414431326674.172396008707; Thu, 18 May 2023 05:53:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6S-0004Cg-D8; Thu, 18 May 2023 08:51:32 -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 1pzd6I-00049d-Fc for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:22 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6B-0007xa-FV for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:19 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3063891d61aso1896310f8f.0 for ; Thu, 18 May 2023 05:51:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wxd+FoSXQR+gX/AlQoxBlHelx6+D0GgmomOiDV1+MQM=; b=dnXuYJP8GK77Bnlf4puDdjYjqiAbABXc/3oAcuQG5fWlsI0CCLiZd8uGAw4pDfSoXf UMOtASyPwH8TzwriFJjyBf0ZE5BU8rI+BJD6xtroiEWKe1PyljWBBlaXwLcrHNRfqyaX VXSBelWwyUmo76wBwxGw2i/MnYl06/F+hIIQtfSijlMcFzv9bUCty2Fguw6lWfBkCMVo Zfa2uWkNUBITpvXyYYk+lCaEUEECX1eEDCebmLfJV3O0IubV6QOsN7JH6RM2c5hr7qYd /w2eXjV7WiMM43HAirl1rBFDaE0E39jXAMQBfnzmML2y5BXS5LAPJObLuepNNbnI9KX/ 8fLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wxd+FoSXQR+gX/AlQoxBlHelx6+D0GgmomOiDV1+MQM=; b=QvbPvM+1jytXSeySadrMZZlmaTspcMfsEiBqZ/16Spi/Kw2X9lXcPI59+xkC06UpeD icgnSwZeK0l2FcKg6e5qJTjqi3gZWPuDfrTcZU6StMa+MwyUD39JQzKGWyjCUtiSnCp2 QBaLKPGMsWo7tNrVP4Wg3QUVQn4Got4bQXClswqq50mqgYrGDZNh/P+X6z/PHW5nN3Sv Gy/uzmOoHusM2jUAyBKmJXKHQ497Eh/DeRXxUqUqn2/2Gm1p9A3wLWFPTjvk+g3b0ZZY nk5/J+TMKw2dgj1BD9OOiAV/SvPXHMEbzSqSqNeQZj5sn3CoOnAM9DpY5hxY+Cl1KkuR PX3w== X-Gm-Message-State: AC+VfDzZV1E4mNZ+8EVqJ1UehLaKP3rnyiUcSHT5FbsXbZQAckEDWXn3 0uFel3D7609ziD3CoNCoOk0OFok5NQS8I3JpsTQ= X-Google-Smtp-Source: ACHHUZ5ETFOsSyyzaqlqitISg9gKM4HsUxs3feDLTwSHOVLrZoAlsqWtdFbHKoKzpvA3pozvvxnAtw== X-Received: by 2002:adf:e90b:0:b0:306:3911:dff0 with SMTP id f11-20020adfe90b000000b003063911dff0mr1532970wrm.4.1684414271163; Thu, 18 May 2023 05:51:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/29] target/arm: add RAZ/WI handling for DBGDTR[TX|RX] Date: Thu, 18 May 2023 13:50:43 +0100 Message-Id: <20230518125107.146421-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414432353100001 From: Alex Benn=C3=A9e The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console". Extend the registers we RAZ/WI set to avoid this. Cc: Anders Roxell Cc: Evgeny Iakovlev Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-id: 20230516104420.407912-1-alex.bennee@linaro.org Signed-off-by: Peter Maydell --- target/arm/debug_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index dfc8b2a1a5d..d41cc643b1b 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -949,8 +949,10 @@ static const ARMCPRegInfo debug_cp_reginfo[] =3D { .access =3D PL0_R, .accessfn =3D access_tdcc, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, /* - * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_E= L0. - * It is a component of the Debug Communications Channel, which is not= implemented. + * These registers belong to the Debug Communications Channel, + * which is not implemented. However we implement RAZ/WI behaviour + * with trapping to prevent spurious SIGILLs if the guest OS does + * access them as the support cannot be probed for. */ { .name =3D "OSDTRRX_EL1", .state =3D ARM_CP_STATE_BOTH, .cp =3D 14, .opc0 =3D 2, .opc1 =3D 0, .crn =3D 0, .crm =3D 0, .opc2 =3D 2, @@ -960,6 +962,11 @@ static const ARMCPRegInfo debug_cp_reginfo[] =3D { .opc0 =3D 2, .opc1 =3D 0, .crn =3D 0, .crm =3D 3, .opc2 =3D 2, .access =3D PL1_RW, .accessfn =3D access_tdcc, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + /* DBGDTRTX_EL0/DBGDTRRX_EL0 depend on direction */ + { .name =3D "DBGDTR_EL0", .state =3D ARM_CP_STATE_BOTH, .cp =3D 14, + .opc0 =3D 2, .opc1 =3D 3, .crn =3D 0, .crm =3D 5, .opc2 =3D 0, + .access =3D PL0_RW, .accessfn =3D access_tdcc, + .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, /* * OSECCR_EL1 provides a mechanism for an operating system * to access the contents of EDECCR. EDECCR is not implemented though, --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414353; cv=none; d=zohomail.com; s=zohoarc; b=GHIZVtI6t8gJSsqTGRtQUF2HtrPXTKUuAZSbpF/Co8vKdPPtaRHps6A/QCzQCH3EfNVd09kMCG1TnhSyhAOGsm93/qqk7GO27TTddIcmcXOj8gxqh03GltEwQAHGe8Z3jttlJn5FI77QujNcVGfYz7WkWojoihbU9/GyrYxz5Uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414353; h=Content-Transfer-Encoding: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=xwItqdXeRUcy3ZRER30kEfBrQGOJx2J+XMMo/JwvEA8=; b=jsocziSK3z0mb8UwRCNluk+uJuefKMZRNPXk0WRGd19yWCqNePLc6+I+3cnIL9ImJsr02+0uldj7QeJlv8TfH8ba6vnLpmeXDWolUYtYjmpk4B+UFDS/u0bQwt/5TD6V+QM940uVJxJUXsAeRBJCHtdvpmkdVh3nnEX3VfSkVRA= 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 1684414353104580.919440209873; Thu, 18 May 2023 05:52:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6T-0004Da-Qs; Thu, 18 May 2023 08:51:33 -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 1pzd6Q-0004Bk-3O for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6I-0007xy-8k for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:28 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f417ea5252so14056625e9.0 for ; Thu, 18 May 2023 05:51:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xwItqdXeRUcy3ZRER30kEfBrQGOJx2J+XMMo/JwvEA8=; b=MDIUlxsajpkshcjXLCzeEie6FcUN2QJjL8Be6R/BvD3/Txa5HXzMj+Clgo56KlXeLH 7XHo6J1VR9hsouEU4s3oZWe+4oDlyREEtmTKAkFa3eEcRaex8wosKAqs3ZsNLE2XaSBo 9mL0iYHYQRU1X9nLVJZzXMKHDdZ49PghNLU4MPOKx/+WI/JS2cqZE/Zf6bhLAB4H500B 4rldvWkhklrxAqWzuXpjJ+AJUf6VCNN2+UzsMlNfPD7jVNuzCkbNN1HwpwUXcBPOOWH6 A9mPs7j7z3GmiND8hV8xVLPH57vMThfdyK57v/qf2jKzdqm1fS0R+13/M2rWNP0tpxKG Xj6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414271; x=1687006271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xwItqdXeRUcy3ZRER30kEfBrQGOJx2J+XMMo/JwvEA8=; b=GkQEDM226srL4vGEcDSHj/pSOURyhRmAlXVynqsPHX60B4VcbvzLi83kYSrAsckLM1 9iqrU3RZHypujSmGutSkaH3PvCK1Ld1yzVF6REyyeXySl/dAxmEWp3gXJLfAv1ooQvQU qnjTS2bKpuc4l2/XvY9+mBRmkZZGOaO1gTsWNj/f0DYBCeRhvTaxMkP4f9RllbWyx1vo m14J/aSXV0/IcF7FS+ZSvUXZZIhjG/kUmbYJrB4/kaSq0bItspgTEG7RTR/+lCcyJ5lM vOgt6Pz6z7dtJpVio9nIMbHYlgD9QEQkacE5kmF4CnU2+7crnKDnA9JIeHBNpwc5ljYU rK9A== X-Gm-Message-State: AC+VfDzI++GBoqYpm9ZMONVUgAkidEeYworsLPlaynK3ZSuZY4i5MpKg iXQcDL3RT4ykGCbyZXb0GhF93lfc1KYcDj5qdWU= X-Google-Smtp-Source: ACHHUZ6GfudeytutYTVdOC3I6e139UdTkxBn1KZP+gJlj19I5ayKRmomU0Uq3wLN0FgV852P4Vl77w== X-Received: by 2002:a7b:c3c4:0:b0:3f1:75ae:1cfe with SMTP id t4-20020a7bc3c4000000b003f175ae1cfemr1436594wmj.7.1684414271598; Thu, 18 May 2023 05:51:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/29] sbsa-ref: use Bochs graphics card instead of VGA Date: Thu, 18 May 2023 13:50:44 +0100 Message-Id: <20230518125107.146421-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684414353939100001 Content-Type: text/plain; charset="utf-8" From: Marcin Juszkiewicz Bochs card is normal PCI Express card so it fits better in system with PCI Express bus. VGA is simple legacy PCI card. Signed-off-by: Marcin Juszkiewicz Reviewed-by: Leif Lindholm Message-id: 20230505120936.1097060-1-marcin.juszkiewicz@linaro.org Signed-off-by: Peter Maydell --- hw/arm/sbsa-ref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index a1562f944a6..792371fdce5 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -648,7 +648,7 @@ static void create_pcie(SBSAMachineState *sms) } } =20 - pci_create_simple(pci->bus, -1, "VGA"); + pci_create_simple(pci->bus, -1, "bochs-display"); =20 create_smmu(sms, pci->bus); } --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414373; cv=none; d=zohomail.com; s=zohoarc; b=hl1KCTHhm2Ir5wkRsx/TmzdRilssKNbwnNUIZ52tDNoR7cjiDF2+xvBM4sz9m7DDkFN8xtsX195ipu+Jj8Zoign8K3DVty0CRY1NBTDgN6OoBTG9s/Ci+R5VmeHaT/YNSdhjDDh7HrHoXQtTIjTFO2C7XynBV6EV/UyTz7bTeWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414373; h=Content-Transfer-Encoding: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=TwDbjF8l3pQWDAsmh6VMzkv7CThxBT0If/DBybZ28xA=; b=lhScULWkuqkDDPowgVaEOE7tyu0rnHztAC1elxNClcxrq5YhH7VjVeGu6ckDKzBaOp8X8WAjM/2t6dWGhEIcf4fiMgVKuKUFLOLeaeuCsuJwmM6hofE/Z1iJp7T+YhJIXvMGHd5Cy7JpgZ1O54D8YRf9WAoeUXpxlseOqCjDyKM= 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 1684414373051531.2164448873451; Thu, 18 May 2023 05:52:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6T-0004D9-8q; Thu, 18 May 2023 08:51:33 -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 1pzd6I-00049e-GE for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:24 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6C-0007yE-Jw for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:20 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f41dceb9d1so19556225e9.1 for ; Thu, 18 May 2023 05:51:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414272; x=1687006272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TwDbjF8l3pQWDAsmh6VMzkv7CThxBT0If/DBybZ28xA=; b=P+zaZsrV0hBVPSdqmINaoqaH69lmLnOMmqFTU3CftCQzQQQPwcIXGhWdT/OCRsSFCV nZXEnVPL5yur+vjv+sm/OZ2toTNaDQQ7hO591YdnlWd2AY77Kxzr0EyPF+h37F14duEB xTbuch7Rc09nVQDfD81s5vyIoF9/prJ2+QmbURCe1WBjdgKco0emyw2ky6A2ZSEhXOyF S0ht6cOkIEcC574iIPViuPnWumMXPc/K9UKSZoyPlXCC/3UtE3da/Meancdv/tn7hcoc XwzYXoX31p73W4dkR/+q8tc91L2GgjyV3zJtSKX5eXla1iGax+4HZmDjGKOiGga16/M8 C6CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414272; x=1687006272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TwDbjF8l3pQWDAsmh6VMzkv7CThxBT0If/DBybZ28xA=; b=OyXaUoDAmKLqc+x/ANNjb+oQ6s9uJH0uspREsBVyU2XRCkVw08F+9G3vIVnN7xdb5r jxoXuR43SURTlnl9wd4fISWdGJDXuzQR/3d60TCj3JKCkeCXv1k1C/FyhdUiNYdoRRFT Kyg51Ok1HR26XQo8UepvgOudLpbrl37zQanRPYf/+fz1ySqBNVWX6y5Yl/EdhTHFzDX6 qcKezUFE2nnH/kah+LTEqSoEL34kuRejwIn5ZOHOw0sj+NgPLfXk7rxOYXv4h4wmt+oR hMD2VtOnQ/8jg4yQhbGBToU4w+G7u43Fy2MJysSo3C18mcsKucqQKkoAdxOrRq4p+XZa Qb1w== X-Gm-Message-State: AC+VfDwEfOoP15Boc5pZxjkdkO/Q4VQz82iWCfXWH2eTCBV22Wju3JR/ RIwJYV/VmtTnzS7jTICoGd33PSUzlusCt8ezEWE= X-Google-Smtp-Source: ACHHUZ699c3pZEY/z3pGTwzFPQN/w7/Lwd+sTTFzK50J2hdXnTabnHrkJnNAXm9kwBeUoTYaZwCDVw== X-Received: by 2002:a05:600c:216:b0:3f4:253b:92a9 with SMTP id 22-20020a05600c021600b003f4253b92a9mr1649515wmi.30.1684414271991; Thu, 18 May 2023 05:51:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/29] target/arm: Split out disas_a64_legacy Date: Thu, 18 May 2023 13:50:45 +0100 Message-Id: <20230518125107.146421-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414373997100009 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Split out all of the decode stuff from aarch64_tr_translate_insn. Call it disas_a64_legacy to indicate it will be replaced. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-2-peter.maydell@linaro.org [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 82 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dff391bfe24..8a0ede96440 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -14200,6 +14200,49 @@ static bool btype_destination_ok(uint32_t insn, bo= ol bt, int btype) return false; } =20 +/* C3.1 A64 instruction index by encoding */ +static void disas_a64_legacy(DisasContext *s, uint32_t insn) +{ + switch (extract32(insn, 25, 4)) { + case 0x0: + if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { + unallocated_encoding(s); + } + break; + case 0x1: case 0x3: /* UNALLOCATED */ + unallocated_encoding(s); + break; + case 0x2: + if (!disas_sve(s, insn)) { + unallocated_encoding(s); + } + break; + case 0x8: case 0x9: /* Data processing - immediate */ + disas_data_proc_imm(s, insn); + break; + case 0xa: case 0xb: /* Branch, exception generation and system insns */ + disas_b_exc_sys(s, insn); + break; + case 0x4: + case 0x6: + case 0xc: + case 0xe: /* Loads and stores */ + disas_ldst(s, insn); + break; + case 0x5: + case 0xd: /* Data processing - register */ + disas_data_proc_reg(s, insn); + break; + case 0x7: + case 0xf: /* Data processing - SIMD and floating point */ + disas_data_proc_simd_fp(s, insn); + break; + default: + assert(FALSE); /* all 15 cases should be handled above */ + break; + } +} + static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) { @@ -14401,44 +14444,7 @@ static void aarch64_tr_translate_insn(DisasContext= Base *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - switch (extract32(insn, 25, 4)) { - case 0x0: - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x1: case 0x3: /* UNALLOCATED */ - unallocated_encoding(s); - break; - case 0x2: - if (!disas_sve(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x8: case 0x9: /* Data processing - immediate */ - disas_data_proc_imm(s, insn); - break; - case 0xa: case 0xb: /* Branch, exception generation and system insns */ - disas_b_exc_sys(s, insn); - break; - case 0x4: - case 0x6: - case 0xc: - case 0xe: /* Loads and stores */ - disas_ldst(s, insn); - break; - case 0x5: - case 0xd: /* Data processing - register */ - disas_data_proc_reg(s, insn); - break; - case 0x7: - case 0xf: /* Data processing - SIMD and floating point */ - disas_data_proc_simd_fp(s, insn); - break; - default: - assert(FALSE); /* all 15 cases should be handled above */ - break; - } + disas_a64_legacy(s, insn); =20 /* * After execution of most insns, btype is reset to 0. --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414502; cv=none; d=zohomail.com; s=zohoarc; b=cswMykwYW4cNto1g4MGjBd0WAeNhZfZsVOrEmuHfthMeKPSnZ/l0RMYt3zcB4FLaNh2QPnki1vzsv/xZDSczO8k+U4nSAAaw4m015EvTPi1lYXIzNR3t4cz8CkM+6xTpPb8isqZqEjbWYLAo41G1Fgvl4ZMp5yjGHA3htLTyYRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414502; h=Content-Transfer-Encoding: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=qoIHKXt1x5lMmWEQJjZOAjpzW3XSYUTiAtfwQsNE2iI=; b=UGSCqzHyndtj1S9ROgp+zBlkHNUW0uKId8YPMLaHNPAN5Sv5bDgzYgdSXozDcb+P3qGKZmnGKnenQUGZid2nx/k4BtDPVep8gjhd5MXXqFXJHU9jdBwr6xzznFBpgWoi67P9+oSWUBJydHMKf4cGgP/Y8B5ORVls5T5XyoAzL0Q= 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 1684414502665643.921533534795; Thu, 18 May 2023 05:55:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6P-0004Bb-0I; Thu, 18 May 2023 08:51:29 -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 1pzd6I-00049c-FX for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:22 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6B-0007yb-Is for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:17 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f41dceb93bso13239975e9.1 for ; Thu, 18 May 2023 05:51:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414272; x=1687006272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qoIHKXt1x5lMmWEQJjZOAjpzW3XSYUTiAtfwQsNE2iI=; b=M5r2xELMxVf+Ygpf6zmu3Pity+m02MeRG3Ku84TFdL+FEXxZ+6zxiDo1FPEpExSRuH qM3wvJrBGbdDfd4Bfz4IEZuNUDr8Efg/zX4s+qDTEMKT+vsTOyV8du00eq4k82UOMlzw IW67Y5nDkIggVuOkyS2e8k30dEfzTghaPyc+F2kU4kJhQEjU9owVlu1fwOY5b3FDwlkD YXH3nA1L0uyBvwJEPPOzckV1zOjlWMnyb7kcHSVoj5GlVz/crI5GfiRyWksQp8JAI/zD XWRooo+Yephyou0cOWIC2I4m6RfE/0GvT4Z7ncGuY2km1j7iJbT7AExgkSOBohn/6v/8 zBBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414272; x=1687006272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qoIHKXt1x5lMmWEQJjZOAjpzW3XSYUTiAtfwQsNE2iI=; b=FVjtPaRWEYSEkRC0c9IuVoxo6YA415K0D100Il0Bb26kayG5fFGBiQfZPERGIHjrqz 1i+7YEZsfg8vx3k9UuyGIr+z1cEK9eJPaY9MPtShsNsXxpb1aqEANwOZZaqXD0osvKTV IGspX1A/pIqCD8Svg79w7JQmC4AnrWHA91yUzAkJhX++RK6ZcuEZ9xa9qdg5xIR39BHx FF3fyQlCUPle33W1Vet50cBg1o69EjhWPEHFikzPBBPWjSnGSdXVRnJCV02JGrfvT1DR s2ozwpI8K8CFY0eQF6rFyz8Y5V9uIv7UNWr1Cm/eOB0ofD5fk6fD3kXa5Lciy8OCbb52 VEwQ== X-Gm-Message-State: AC+VfDzMeJ6EcJdAji1dDeP5MWmXJ5qYbP1UPMpLncqAixM9znJA/Ddo aI8SHAUDJe71OYjDCs12/3kDeAiUfKu9wh0Sxm0= X-Google-Smtp-Source: ACHHUZ7xip0SVJlr4+02pYPddgGZhnnUplhvbhh417Us7+Ru5x60UDZqNrfwAVer3ddLuq9s/3WPHw== X-Received: by 2002:a7b:cc82:0:b0:3f4:253f:c3d6 with SMTP id p2-20020a7bcc82000000b003f4253fc3d6mr1473250wma.33.1684414272444; Thu, 18 May 2023 05:51:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/29] target/arm: Create decodetree skeleton for A64 Date: Thu, 18 May 2023 13:50:46 +0100 Message-Id: <20230518125107.146421-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414503830100001 Content-Type: text/plain; charset="utf-8" The A64 translator uses a hand-written decoder for everything except SVE or SME. It's fairly well structured, but it's becoming obvious that it's still more painful to add instructions to than the A32 translator, because putting a new instruction into the right place in a hand-written decoder is much harder than adding new instruction patterns to a decodetree file. As the first step in conversion to decodetree, create the skeleton of the decodetree decoder; where it does not handle instructions we will fall back to the legacy decoder (which will be for everything at the moment, since there are no patterns in a64.decode). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-3-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 20 ++++++++++++++++++++ target/arm/tcg/translate-a64.c | 18 +++++++++++------- target/arm/tcg/meson.build | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 target/arm/tcg/a64.decode diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode new file mode 100644 index 00000000000..43321bbbb05 --- /dev/null +++ b/target/arm/tcg/a64.decode @@ -0,0 +1,20 @@ +# AArch64 A64 allowed instruction decoding +# +# Copyright (c) 2023 Linaro, Ltd +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . + +# +# This file is processed by scripts/decodetree.py +# diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 8a0ede96440..7862e9dd4e3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -56,6 +56,13 @@ enum a64_shift_type { A64_SHIFT_TYPE_ROR =3D 3 }; =20 +/* + * Include the generated decoders. + */ + +#include "decode-sme-fa64.c.inc" +#include "decode-a64.c.inc" + /* Table based decoder typedefs - used when the relevant bits for decode * are too awkwardly scattered across the instruction (eg SIMD). */ @@ -14100,12 +14107,6 @@ static void disas_data_proc_simd_fp(DisasContext *= s, uint32_t insn) } } =20 -/* - * Include the generated SME FA64 decoder. - */ - -#include "decode-sme-fa64.c.inc" - static bool trans_OK(DisasContext *s, arg_OK *a) { return true; @@ -14444,7 +14445,10 @@ static void aarch64_tr_translate_insn(DisasContext= Base *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - disas_a64_legacy(s, insn); + + if (!disas_a64(s, insn)) { + disas_a64_legacy(s, insn); + } =20 /* * After execution of most insns, btype is reset to 0. diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build index 4d99f6dacb3..130ed62fcd7 100644 --- a/target/arm/tcg/meson.build +++ b/target/arm/tcg/meson.build @@ -13,6 +13,7 @@ gen =3D [ decodetree.process('a32-uncond.decode', extra_args: '--static-decode=3Dd= isas_a32_uncond'), decodetree.process('t32.decode', extra_args: '--static-decode=3Ddisas_t3= 2'), decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-deco= de=3Ddisas_t16']), + decodetree.process('a64.decode', extra_args: ['--static-decode=3Ddisas_a= 64']), ] =20 arm_ss.add(gen) --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414496; cv=none; d=zohomail.com; s=zohoarc; b=hgwKEvUNhSWHFzY03vfc/RtkgRvxCMVJRgeUd5GM/jJWy+ld465rnOgnsbGw4Q8S201GuEJ9SuvBUHT7czptmhtjkBzkuRNWvA+vrQbK2SQM1xIKXKiIl8kwdoXpjAbtLTR1nOj+GSHGnq8TxSrgwvNyLeXvwmtas3cSCcisVMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414496; h=Content-Transfer-Encoding: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=589iqNrMeAs79wjrBAvFfcZRoxcqL9gt48lPQfaMb+0=; b=QOPnH8vNHD+zB3Vbj+O0IX7H2F0kRXKx8dz5TTGO3xOp/rd+U7ajDdWuN4VOutxlnZhb7aP5o/CIDY0F2NBxnafOmDcxVIP7Z5+ZWhA8/mkqii0n1W6s0X3ChQqDPz1lxUv1I5spkPC/5+OtaiFTbS3c0EMTV+i2LwXCV4Cf0KM= 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 1684414496919359.453716967501; Thu, 18 May 2023 05:54:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6P-0004Bi-Tx; Thu, 18 May 2023 08:51:30 -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 1pzd6I-00049f-G0 for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:22 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6B-0007zD-LL for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f4ec041fc3so12595465e9.1 for ; Thu, 18 May 2023 05:51:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414273; x=1687006273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=589iqNrMeAs79wjrBAvFfcZRoxcqL9gt48lPQfaMb+0=; b=hIkirGWRp9ZFmKuVp11x6DGiDPd71dglwQa8B6zlhl/lG6jGXEdZpmDqnjguzv63kQ hwu42aWA+cnuCkbmb2SzVq3R9PT+NirNDeuqkUIIgj3U0HqGkdGWeWO04hQ5Xyhnkwyu cSDDg3H86SJkx7TUHDMwg28W+r9Cpvk+WjWnuj6kpdx1OCEjied7rd9bUicSerCLuptC /ODXW7Em6zcx5tdPEG77laZTEEwkCuDN5NuhPKV8C0cOoc8/XxSfbn4rSknHF0bCdzvs QmPtajYU766vovzGf88G4x+ejT+ks+Vu8whXpOwgxivIiNoKP23GDUuBek3w9F4VGD7D VFAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414273; x=1687006273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=589iqNrMeAs79wjrBAvFfcZRoxcqL9gt48lPQfaMb+0=; b=PH+HdK5RtbCcxQuyUo7QxoEQBYQFrdcO1GhwYZP337m9+rkAtHyPLV0VqH6joU4LjE roCZ8cMJUJyxgUOg4+2F/rpeWQBy7wnIMPK9nRtImojpkTB5Qg5E+yXVmBp0Q0648WNO NplGMH+u8N/VMoz+UpiV+bnZ+PpNxD6ackXY/Zkmo31SlJGkwsGNW+qWDLLdskv8/PMG 06apPTa6bREeXoS84m5cnJ1cOhTOMH6e9v3yhNNiaq/JRyuBk2PQIxEwr71Nsi6zKU7A ny6BvTS49ceFNAclj/2Jf9QaacB8E1RtTqdHnLYGlyRgwFvWiYqPsWtoMaaUEn0OQw8o iyaw== X-Gm-Message-State: AC+VfDynd7ZrIos2HdjIN6LLnLUv+1U5BDSfwFrXrH732x9wPi1Gy8UJ SgeDt7CXqNCnBEiTshkTf2/b2z8Td+o4D9i4Jbo= X-Google-Smtp-Source: ACHHUZ72mTT7TAXZEsv99ce/o2VrQPWXVmA0oqRgImz/+m6flChrN8al8882YzaEWRDVKCp8rW5RVg== X-Received: by 2002:a7b:c8c4:0:b0:3f4:266d:5901 with SMTP id f4-20020a7bc8c4000000b003f4266d5901mr1230877wml.35.1684414272942; Thu, 18 May 2023 05:51:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/29] target/arm: Pull calls to disas_sve() and disas_sme() out of legacy decoder Date: Thu, 18 May 2023 13:50:47 +0100 Message-Id: <20230518125107.146421-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414499066100011 Content-Type: text/plain; charset="utf-8" The SVE and SME decode is already done by decodetree. Pull the calls to these decoders out of the legacy decoder. This doesn't change behaviour because all the patterns in sve.decode and sme.decode already require the bits that the legacy decoder is decoding to have the correct values. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-4-peter.maydell@linaro.org --- target/arm/tcg/translate-a64.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 7862e9dd4e3..1fd6f97b641 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -14205,19 +14205,6 @@ static bool btype_destination_ok(uint32_t insn, bo= ol bt, int btype) static void disas_a64_legacy(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 4)) { - case 0x0: - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x1: case 0x3: /* UNALLOCATED */ - unallocated_encoding(s); - break; - case 0x2: - if (!disas_sve(s, insn)) { - unallocated_encoding(s); - } - break; case 0x8: case 0x9: /* Data processing - immediate */ disas_data_proc_imm(s, insn); break; @@ -14239,7 +14226,7 @@ static void disas_a64_legacy(DisasContext *s, uint3= 2_t insn) disas_data_proc_simd_fp(s, insn); break; default: - assert(FALSE); /* all 15 cases should be handled above */ + unallocated_encoding(s); break; } } @@ -14445,8 +14432,9 @@ static void aarch64_tr_translate_insn(DisasContextB= ase *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - - if (!disas_a64(s, insn)) { + if (!disas_a64(s, insn) && + !disas_sme(s, insn) && + !disas_sve(s, insn)) { disas_a64_legacy(s, insn); } =20 --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414380; cv=none; d=zohomail.com; s=zohoarc; b=mJ6IaPbTuEwH3K8zwQojL0sflhvpVg53C6qQ+tFtbHXH72OLNeXsbTrboojs03qbkopjky2q5ea/ZPY66+qHrRWx8ntHvWQWbjqhMhfkp94bBb+sgmIGOksqp58yGNx6TEMu8xl+E19cnc0jFwhTXN1fZTvJZE8tQATcvR6Zuo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414380; h=Content-Transfer-Encoding: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=EYMNPZn0ycDWSAniczGdOCIYstv04S4syoY1G6oBBM0=; b=BPZpl6aA+nGkRMlrK56kTm/P5Xo8WBsG16pYEqHv2IkrC13sLE401OON6wjRigkW0/Piv7gsDyS29yObie3P0RH7WG9+FO37A64jE+DsXptgOVZ+KhHssKkfZcfCtJaTt8M9qQwo6aEHjCQvnQ+j0hUI5hIgGCD3BoohxnrUc2A= 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 1684414380204358.38272720418774; Thu, 18 May 2023 05:53:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6U-0004FF-Cz; Thu, 18 May 2023 08:51:34 -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 1pzd6L-0004Al-PP for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:26 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6E-0007zM-FV for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:23 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f427118644so19430045e9.0 for ; Thu, 18 May 2023 05:51:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414273; x=1687006273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=EYMNPZn0ycDWSAniczGdOCIYstv04S4syoY1G6oBBM0=; b=g0tRyEUOpxcX2s8O0UJsmp7DUiygSKJEwcUyIQ0sHdq+aJpi3gJCXMoafcYtKHR0BR DXjYXj6Lx5vRKriirkc20HzT4HpThbCMMKHic+y0+ah8Emf4M4caVAdYCBF5lrZsHgK6 6cwwP0nUTEZ3DS0kyJwq0pDOK8zxYCPUwWACSsJVPtcGbrvEnm7Wcgj8WJpQ+UFNC+dy r6Rj9Yu4BAlSfoW67tIXU7kSlHmHv3SKcyrg3d1/Wijr+p/MAJpHcqKYUXUBFEjRYigl mSrGe90w16zVo1OAIW+RLPWmen/5HnzRTvt2z7lmMPCDBxIeNjGz/McvBUrJStTl1W0S /eaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414273; x=1687006273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EYMNPZn0ycDWSAniczGdOCIYstv04S4syoY1G6oBBM0=; b=IQ/uwhCJKf2iRMelN06xT7N2Oz36JmrHNLmrwS7bRbsytWKAVnh4L+zq52LrMPyfrX aSkZ5iUQYA0FZsb191RXZVCH/DDU4i3kwQInWOpKEjfikZ/+YMnUUTKQQRfVk5QvOEf8 k0WC+b8wIrb4xVy4JPrKZIyo/1BSXQ1PvX96iWzPDRPISBDa2o6Uib/bTe3UCktvv3B5 ZZqcs2SotdACRT6CByppSbmg1gqIEYHl1avm5IfBz4PyhN6TC4AypGVI3oGVCpt9pPWL u/mt1GL7tGH/1hcCN8SdU16gI8gwWuaBLISjzb728qDiq4V9fiOl2tEeu9r6B32H83RC Q2SA== X-Gm-Message-State: AC+VfDwoi6e8X6Oa5sR2Oy5NBKdiIF7g+rCKTDbKTKDlES4Z4o0gYAWV aXWc6PlmyKeA9hvitqRSHZwlu0RS2rkJUtJhH0o= X-Google-Smtp-Source: ACHHUZ6Cabe/vERvinp1Y4/ZBDcUDCYAAXO3Kkn3D8b44uVBPHk84fTFZYLogoApNnj+llifZlVhOA== X-Received: by 2002:a05:600c:2152:b0:3f2:5be3:cd6a with SMTP id v18-20020a05600c215200b003f25be3cd6amr1378369wml.4.1684414273372; Thu, 18 May 2023 05:51:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/29] target/arm: Convert PC-rel addressing to decodetree Date: Thu, 18 May 2023 13:50:48 +0100 Message-Id: <20230518125107.146421-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414382167100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADR and ADRP instructions. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-5-peter.maydell@linaro.org [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 ++++++++++++ target/arm/tcg/translate-a64.c | 38 +++++++++++++--------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 43321bbbb05..bcf46fc37d7 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -18,3 +18,16 @@ # # This file is processed by scripts/decodetree.py # + +&ri rd imm + + +### Data Processing - Immediate + +# PC-rel addressing + +%imm_pcrel 5:s19 29:2 +@pcrel . .. ..... ................... rd:5 &ri imm=3D%imm_pcr= el + +ADR 0 .. 10000 ................... ..... @pcrel +ADRP 1 .. 10000 ................... ..... @pcrel diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 1fd6f97b641..ffcd05eb38a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4179,31 +4179,24 @@ static void disas_ldst(DisasContext *s, uint32_t in= sn) } } =20 -/* PC-rel. addressing - * 31 30 29 28 24 23 5 4 0 - * +----+-------+-----------+-------------------+------+ - * | op | immlo | 1 0 0 0 0 | immhi | Rd | - * +----+-------+-----------+-------------------+------+ +/* + * PC-rel. addressing */ -static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) + +static bool trans_ADR(DisasContext *s, arg_ri *a) { - unsigned int page, rd; - int64_t offset; + gen_pc_plus_diff(s, cpu_reg(s, a->rd), a->imm); + return true; +} =20 - page =3D extract32(insn, 31, 1); - /* SignExtend(immhi:immlo) -> offset */ - offset =3D sextract64(insn, 5, 19); - offset =3D offset << 2 | extract32(insn, 29, 2); - rd =3D extract32(insn, 0, 5); +static bool trans_ADRP(DisasContext *s, arg_ri *a) +{ + int64_t offset =3D (int64_t)a->imm << 12; =20 - if (page) { - /* ADRP (page based) */ - offset <<=3D 12; - /* The page offset is ok for CF_PCREL. */ - offset -=3D s->pc_curr & 0xfff; - } - - gen_pc_plus_diff(s, cpu_reg(s, rd), offset); + /* The page offset is ok for CF_PCREL. */ + offset -=3D s->pc_curr & 0xfff; + gen_pc_plus_diff(s, cpu_reg(s, a->rd), offset); + return true; } =20 /* @@ -4656,9 +4649,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x20: case 0x21: /* PC-rel. addressing */ - disas_pc_rel_adr(s, insn); - break; case 0x22: /* Add/subtract (immediate) */ disas_add_sub_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414371; cv=none; d=zohomail.com; s=zohoarc; b=mVkc7+ShUkrRzYwXu2/CWPFIKSoGes6x4isTQQB4UAZenHBFySPPqEzotLEgGtCkF9BsuSw9Aj66O7YxVoWjaVHCu8020ic0wQ19FQtXyF3Awd6GhsBqFGTL4aVbmyXi+nrgRS6zsVV/oiM7I71oo2X/2kirzEIQsFz9Mv+exOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414371; h=Content-Transfer-Encoding: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=MitncF/4GqTSNnwixClM4RdAFm5G7KDGOzVgQYsIGKo=; b=J0FkhgkExBBQLAoO/qdRc8n9/UVECpvKgt+9uIhTl+SL3SJj5OP4r5/e0YMkt+z8n6hWWsIqr5uJVpEO1xCypnI4frjxTFcbacbJmS+62qeJLWvRTb2Yg/I14Geb1UGA8R1tkDC2cihnSfYl8HOgPpiAopzQ23zpxARBQ4LFhCQ= 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 1684414371038361.79821195422005; Thu, 18 May 2023 05:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6T-0004Cy-6Z; Thu, 18 May 2023 08:51:33 -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 1pzd6L-0004Ah-CB for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:26 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6D-00080Q-5T for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:21 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f42c86543bso13198875e9.3 for ; Thu, 18 May 2023 05:51:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414274; x=1687006274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MitncF/4GqTSNnwixClM4RdAFm5G7KDGOzVgQYsIGKo=; b=rx+PmxiW9qIU5xNMBKaIdRg64ufGexmhvR1n5qKoTEvaGBeEw4u97Twf7j2veOOk6A BGvbBWtqxUNqkweSrKRl9swyj218YoZ6vuHDJXQiQS2ap67Xsi7WTuNGUINR0BO2nM9S FacJ3bN+1XfcfmjNF29/s5vhcnVSuhc3B5MX1ZcQnBOTQ+/mMJ56coifKIvYdrMVTjY4 KS4IK6PJNWw+9L2lq9w+3HXkkVFxb6G4DWmxjiHfJFrjWxc67JUZloHtupl8pZYNb1GJ 4NKQ9vXb0L0UrrmVMBj6OgaNOwLwx5fS0pw6KQxibEWLmnvn4bv6JK++Sizj474nAnX3 Ts6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414274; x=1687006274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MitncF/4GqTSNnwixClM4RdAFm5G7KDGOzVgQYsIGKo=; b=X5tLKFjNQBo6YcMuUBOghJRKirTyBojcYcJgaem2vLDGzsGmgdPlhNBj02frbIr2RB mQ4XXTyjnVCzBFDGfe+tWbDjGoNmlzHXC20bWTnXv1s/aDQjnGLTTGuridj8D2SPyIDt yitT3RW64rWvQMMKBQbynL6Fmbz63LWJsuRJeE6jegoBeleWbqdARIn/12SCTx/mDwnk YEpxI0q67Z9zYY7kuR8mMCgVbKE2d2RstdbNIqK5Mr2uuIS9/FRr+Sh5ysaCd2WwbVEl PjR1ZEUt5l2DCmkXZh4clcGv4hQZjidZW2+q48ckYom9C2KcraXNCg4cPVJD/MW98aL6 RxvQ== X-Gm-Message-State: AC+VfDx/5c/KnnsjEA723S9k3nd1c2zkiPMD8UStFbJrAYNLxLRKOzXi 2HXdUOU2pGud0NAVkz7KH8glPT034ARu/adamio= X-Google-Smtp-Source: ACHHUZ7tw37++rz2SMU5g/0wUcr3v+jPeik2PWy7CtdAbviBbhH3ajx2x7wwh5opkPeDSxG9vpXAqg== X-Received: by 2002:a05:600c:ad9:b0:3f4:21cf:b4a4 with SMTP id c25-20020a05600c0ad900b003f421cfb4a4mr1534086wmr.20.1684414273768; Thu, 18 May 2023 05:51:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/29] target/arm: Split gen_add_CC and gen_sub_CC Date: Thu, 18 May 2023 13:50:49 +0100 Message-Id: <20230518125107.146421-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414371958100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Split out specific 32-bit and 64-bit functions. These carry the same signature as tcg_gen_add_i64, and so will be easier to pass as callbacks. Retain gen_add_CC and gen_sub_CC during conversion. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-6-peter.maydell@linaro.org [PMM: rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 149 +++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index ffcd05eb38a..7a633abf830 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -682,83 +682,102 @@ static inline void gen_logic_CC(int sf, TCGv_i64 res= ult) } =20 /* dest =3D T0 + T1; compute C, N, V and Z flags */ +static void gen_add64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + TCGv_i64 result, flag, tmp; + result =3D tcg_temp_new_i64(); + flag =3D tcg_temp_new_i64(); + tmp =3D tcg_temp_new_i64(); + + tcg_gen_movi_i64(tmp, 0); + tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); + + tcg_gen_extrl_i64_i32(cpu_CF, flag); + + gen_set_NZ64(result); + + tcg_gen_xor_i64(flag, result, t0); + tcg_gen_xor_i64(tmp, t0, t1); + tcg_gen_andc_i64(flag, flag, tmp); + tcg_gen_extrh_i64_i32(cpu_VF, flag); + + tcg_gen_mov_i64(dest, result); +} + +static void gen_add32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + TCGv_i32 t0_32 =3D tcg_temp_new_i32(); + TCGv_i32 t1_32 =3D tcg_temp_new_i32(); + TCGv_i32 tmp =3D tcg_temp_new_i32(); + + tcg_gen_movi_i32(tmp, 0); + tcg_gen_extrl_i64_i32(t0_32, t0); + tcg_gen_extrl_i64_i32(t1_32, t1); + tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); + tcg_gen_mov_i32(cpu_ZF, cpu_NF); + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); + tcg_gen_xor_i32(tmp, t0_32, t1_32); + tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); + tcg_gen_extu_i32_i64(dest, cpu_NF); +} + static void gen_add_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) { if (sf) { - TCGv_i64 result, flag, tmp; - result =3D tcg_temp_new_i64(); - flag =3D tcg_temp_new_i64(); - tmp =3D tcg_temp_new_i64(); - - tcg_gen_movi_i64(tmp, 0); - tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); - - tcg_gen_extrl_i64_i32(cpu_CF, flag); - - gen_set_NZ64(result); - - tcg_gen_xor_i64(flag, result, t0); - tcg_gen_xor_i64(tmp, t0, t1); - tcg_gen_andc_i64(flag, flag, tmp); - tcg_gen_extrh_i64_i32(cpu_VF, flag); - - tcg_gen_mov_i64(dest, result); + gen_add64_CC(dest, t0, t1); } else { - /* 32 bit arithmetic */ - TCGv_i32 t0_32 =3D tcg_temp_new_i32(); - TCGv_i32 t1_32 =3D tcg_temp_new_i32(); - TCGv_i32 tmp =3D tcg_temp_new_i32(); - - tcg_gen_movi_i32(tmp, 0); - tcg_gen_extrl_i64_i32(t0_32, t0); - tcg_gen_extrl_i64_i32(t1_32, t1); - tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); - tcg_gen_mov_i32(cpu_ZF, cpu_NF); - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); - tcg_gen_xor_i32(tmp, t0_32, t1_32); - tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); - tcg_gen_extu_i32_i64(dest, cpu_NF); + gen_add32_CC(dest, t0, t1); } } =20 /* dest =3D T0 - T1; compute C, N, V and Z flags */ +static void gen_sub64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + /* 64 bit arithmetic */ + TCGv_i64 result, flag, tmp; + + result =3D tcg_temp_new_i64(); + flag =3D tcg_temp_new_i64(); + tcg_gen_sub_i64(result, t0, t1); + + gen_set_NZ64(result); + + tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); + tcg_gen_extrl_i64_i32(cpu_CF, flag); + + tcg_gen_xor_i64(flag, result, t0); + tmp =3D tcg_temp_new_i64(); + tcg_gen_xor_i64(tmp, t0, t1); + tcg_gen_and_i64(flag, flag, tmp); + tcg_gen_extrh_i64_i32(cpu_VF, flag); + tcg_gen_mov_i64(dest, result); +} + +static void gen_sub32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + /* 32 bit arithmetic */ + TCGv_i32 t0_32 =3D tcg_temp_new_i32(); + TCGv_i32 t1_32 =3D tcg_temp_new_i32(); + TCGv_i32 tmp; + + tcg_gen_extrl_i64_i32(t0_32, t0); + tcg_gen_extrl_i64_i32(t1_32, t1); + tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); + tcg_gen_mov_i32(cpu_ZF, cpu_NF); + tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); + tmp =3D tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, t0_32, t1_32); + tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); + tcg_gen_extu_i32_i64(dest, cpu_NF); +} + static void gen_sub_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) { if (sf) { - /* 64 bit arithmetic */ - TCGv_i64 result, flag, tmp; - - result =3D tcg_temp_new_i64(); - flag =3D tcg_temp_new_i64(); - tcg_gen_sub_i64(result, t0, t1); - - gen_set_NZ64(result); - - tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); - tcg_gen_extrl_i64_i32(cpu_CF, flag); - - tcg_gen_xor_i64(flag, result, t0); - tmp =3D tcg_temp_new_i64(); - tcg_gen_xor_i64(tmp, t0, t1); - tcg_gen_and_i64(flag, flag, tmp); - tcg_gen_extrh_i64_i32(cpu_VF, flag); - tcg_gen_mov_i64(dest, result); + gen_sub64_CC(dest, t0, t1); } else { - /* 32 bit arithmetic */ - TCGv_i32 t0_32 =3D tcg_temp_new_i32(); - TCGv_i32 t1_32 =3D tcg_temp_new_i32(); - TCGv_i32 tmp; - - tcg_gen_extrl_i64_i32(t0_32, t0); - tcg_gen_extrl_i64_i32(t1_32, t1); - tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); - tcg_gen_mov_i32(cpu_ZF, cpu_NF); - tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); - tmp =3D tcg_temp_new_i32(); - tcg_gen_xor_i32(tmp, t0_32, t1_32); - tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); - tcg_gen_extu_i32_i64(dest, cpu_NF); + gen_sub32_CC(dest, t0, t1); } } =20 --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414303; cv=none; d=zohomail.com; s=zohoarc; b=fqNN4ZbS2pnAPvKAvDeh333MNcZ2WlNHHnxbvCPVg9avmOx7mYwyFuaUdxYVPh0vA2QkI61haqaE8Z/u0fJGpjtSi1rgteEUW+YZmiiNqY0oTWK6VS3D9YwcDV/vpAKZCi7W/Ly5Z6Uq0gQrVQiQ2lTKMB9a+K8WeXEVBi+ONHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414303; h=Content-Transfer-Encoding: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=KPbocWaggxSVkxKTVO05DNcZGruO9AVgr5QQFu9P3DA=; b=B0O5bvQYCvH0IUYSL6ZQAnUVwqrXRw7rXVPCk9SrlGXCechkNh1zqVRTmuaBrQDhCQgLZwY5xe12e9SnIuujaVRVwDM191fCPMYwnutO3pJMm218MGlny+hR/J8+fZWVu307vR1mD4p3e9/wuigooCiEfE9k5UZX+awJE/gYZfE= 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 1684414303660328.6539368809175; Thu, 18 May 2023 05:51:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Y-0004IC-46; Thu, 18 May 2023 08:51:38 -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 1pzd6Q-0004Bl-4A for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6L-00080i-Jd for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:29 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f49bf0223cso19415455e9.1 for ; Thu, 18 May 2023 05:51:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414274; x=1687006274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KPbocWaggxSVkxKTVO05DNcZGruO9AVgr5QQFu9P3DA=; b=SeXJgGfH73wzZ0ZXIzLJu+VasEZ1jl/tTx/Iynh9W2/VWp/H0eI4MN75PMMu03yKm7 cfkm5UwePxZx8xKQSLKnBJdKg1l2mYPQ9284YKPLc46GRvA1tiBwbXHwIpyWNAd6vxAU s6WctZobj+i8GMmBqaGwsRdl+GYP+tvPvX3Lpod3Vacb6clHMBQrMAwYpfqwlbX2WJU7 mT4P/zdgKLMFOwl/6Ef5TbHeIgImUdS2IAs4rYyouUA9H3KfkSAwjN5bMzyrih7Si5t1 vvXnnDbthebYdwFq0WBXzJXsMxaVPu8er3hF/z8M2zquTG6PrMDv/HEVbZSNIY6J+EYr Ss5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414274; x=1687006274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KPbocWaggxSVkxKTVO05DNcZGruO9AVgr5QQFu9P3DA=; b=CdS075or/WxLKNmJvptlChRHKBmElBgvIg6vgo+dBNEvctbyM1uW7CkPE+LARdvyXh alPvclGEZeVZhYjNSZ6iPsXdLhOvP36vdH9yx8UUYMfLXedJCNv4kGpjfHZJ7SUAehVL ZF29xGgMflk8VY0OaO/v/9S9t36Rb29MZbD4345wxDxoA+cuQrlUHh65QKrqYSCSpwu5 p4r6qrinE1PqQd77TkUSxEop39IzQvHQRkz5KWXP2sO7TUs5ovINypKgFGG9vfVrcYiJ c5/kZIoAtawlZ8lMgsXtu6/ICa2tWuIhXaLkISjko1KcwPnqJnMOkkclvIIb5udJD+Gg mXpQ== X-Gm-Message-State: AC+VfDz5EEh9C6MZlQ2bDJLrUCkLiLYl4tI8u4U29FcBn13QYrWwI0nM Yqg/BUlnnx2E5pFiMqH5FK4tekgB1dWtCuh824w= X-Google-Smtp-Source: ACHHUZ5XfVjcUFqAogB7GNoumuXjFqR84L2nCalIPrSLJ8TGWjLTEMUgaCjqDiuAZJ28CnrbnqGwnA== X-Received: by 2002:a1c:4c11:0:b0:3f5:4e1:2a89 with SMTP id z17-20020a1c4c11000000b003f504e12a89mr1419147wmf.34.1684414274239; Thu, 18 May 2023 05:51:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/29] target/arm: Convert Add/subtract (immediate) to decodetree Date: Thu, 18 May 2023 13:50:50 +0100 Message-Id: <20230518125107.146421-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414304715100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADD and SUB (immediate) instructions. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-7-peter.maydell@linaro.org [PMM: Rebased; adjusted to use translate.h's TRANS macro] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate.h | 5 +++ target/arm/tcg/a64.decode | 17 ++++++++ target/arm/tcg/translate-a64.c | 73 ++++++++++------------------------ 3 files changed, 42 insertions(+), 53 deletions(-) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index f02d4685b4c..a9d1f4adc28 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -220,6 +220,11 @@ static inline int rsub_8(DisasContext *s, int x) return 8 - x; } =20 +static inline int shl_12(DisasContext *s, int x) +{ + return x << 12; +} + static inline int neon_3same_fp_size(DisasContext *s, int x) { /* Convert 0=3D=3Dfp32, 1=3D=3Dfp16 into a MO_* value */ diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index bcf46fc37d7..30c2ac7e271 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -20,6 +20,7 @@ # =20 &ri rd imm +&rri_sf rd rn imm sf =20 =20 ### Data Processing - Immediate @@ -31,3 +32,19 @@ =20 ADR 0 .. 10000 ................... ..... @pcrel ADRP 1 .. 10000 ................... ..... @pcrel + +# Add/subtract (immediate) + +%imm12_sh12 10:12 !function=3Dshl_12 +@addsub_imm sf:1 .. ...... . imm:12 rn:5 rd:5 +@addsub_imm12 sf:1 .. ...... . ............ rn:5 rd:5 imm=3D%imm12_sh12 + +ADD_i . 00 100010 0 ............ ..... ..... @addsub_imm +ADD_i . 00 100010 1 ............ ..... ..... @addsub_imm12 +ADDS_i . 01 100010 0 ............ ..... ..... @addsub_imm +ADDS_i . 01 100010 1 ............ ..... ..... @addsub_imm12 + +SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm +SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 +SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm +SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 7a633abf830..2dd0df7286e 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4198,6 +4198,22 @@ static void disas_ldst(DisasContext *s, uint32_t ins= n) } } =20 +typedef void ArithTwoOp(TCGv_i64, TCGv_i64, TCGv_i64); + +static bool gen_rri(DisasContext *s, arg_rri_sf *a, + bool rd_sp, bool rn_sp, ArithTwoOp *fn) +{ + TCGv_i64 tcg_rn =3D rn_sp ? cpu_reg_sp(s, a->rn) : cpu_reg(s, a->rn); + TCGv_i64 tcg_rd =3D rd_sp ? cpu_reg_sp(s, a->rd) : cpu_reg(s, a->rd); + TCGv_i64 tcg_imm =3D tcg_constant_i64(a->imm); + + fn(tcg_rd, tcg_rn, tcg_imm); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + return true; +} + /* * PC-rel. addressing */ @@ -4220,57 +4236,11 @@ static bool trans_ADRP(DisasContext *s, arg_ri *a) =20 /* * Add/subtract (immediate) - * - * 31 30 29 28 23 22 21 10 9 5 4 0 - * +--+--+--+-------------+--+-------------+-----+-----+ - * |sf|op| S| 1 0 0 0 1 0 |sh| imm12 | Rn | Rd | - * +--+--+--+-------------+--+-------------+-----+-----+ - * - * sf: 0 -> 32bit, 1 -> 64bit - * op: 0 -> add , 1 -> sub - * S: 1 -> set flags - * sh: 1 -> LSL imm by 12 */ -static void disas_add_sub_imm(DisasContext *s, uint32_t insn) -{ - int rd =3D extract32(insn, 0, 5); - int rn =3D extract32(insn, 5, 5); - uint64_t imm =3D extract32(insn, 10, 12); - bool shift =3D extract32(insn, 22, 1); - bool setflags =3D extract32(insn, 29, 1); - bool sub_op =3D extract32(insn, 30, 1); - bool is_64bit =3D extract32(insn, 31, 1); - - TCGv_i64 tcg_rn =3D cpu_reg_sp(s, rn); - TCGv_i64 tcg_rd =3D setflags ? cpu_reg(s, rd) : cpu_reg_sp(s, rd); - TCGv_i64 tcg_result; - - if (shift) { - imm <<=3D 12; - } - - tcg_result =3D tcg_temp_new_i64(); - if (!setflags) { - if (sub_op) { - tcg_gen_subi_i64(tcg_result, tcg_rn, imm); - } else { - tcg_gen_addi_i64(tcg_result, tcg_rn, imm); - } - } else { - TCGv_i64 tcg_imm =3D tcg_constant_i64(imm); - if (sub_op) { - gen_sub_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); - } else { - gen_add_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); - } - } - - if (is_64bit) { - tcg_gen_mov_i64(tcg_rd, tcg_result); - } else { - tcg_gen_ext32u_i64(tcg_rd, tcg_result); - } -} +TRANS(ADD_i, gen_rri, a, 1, 1, tcg_gen_add_i64) +TRANS(SUB_i, gen_rri, a, 1, 1, tcg_gen_sub_i64) +TRANS(ADDS_i, gen_rri, a, 0, 1, a->sf ? gen_add64_CC : gen_add32_CC) +TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) =20 /* * Add/subtract (immediate, with tags) @@ -4668,9 +4638,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x22: /* Add/subtract (immediate) */ - disas_add_sub_imm(s, insn); - break; case 0x23: /* Add/subtract (immediate, with tags) */ disas_add_sub_imm_with_tags(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414453; cv=none; d=zohomail.com; s=zohoarc; b=OZ6AOJwQ1xwuv55JEHtX9w01MRc8AbHdbtYLkcsYXppB2YGgtzja7XSNcfWc7K/umI8IDCRKWPGDYY4T/bITUY0ZFkn0Xr2hKSKmCPk9Ws7Coje6hKgQAkADmW9gZODLCmsLZWWVvDF5nZV5iTR75K32+0JPtvVSaPZ9fEJWx4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414453; h=Content-Transfer-Encoding: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=ZIOTPLHXOaLKVT0TIdYuivhuqIAVXvjRLcJHDsFR/PM=; b=Ug2whKtAnlUidd5dUdk/0YXXX8BAImDjZ+1t039mP+UnMxSWIzOK0Stn0ITx4DM6FvwUbbbMHMy0I1pXkqTOqb5x8m5lezYa3kcpn58otKo8UxhzaGmak8bMipUSgilbIdDZFkHRiS4xQjaph6PgGk47/+dxIl6nmbL604GYHPM= 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 1684414453323526.9573803436756; Thu, 18 May 2023 05:54:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Z-0004IM-CJ; Thu, 18 May 2023 08:51:39 -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 1pzd6T-0004Du-TC for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00080o-UG for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:31 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f41d087b24so13983865e9.1 for ; Thu, 18 May 2023 05:51:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZIOTPLHXOaLKVT0TIdYuivhuqIAVXvjRLcJHDsFR/PM=; b=Cshk82ZYZhdftmEVbi8fz/AFvisIZkRb1liUzdUxQcSS49G/MB1OTfEBXkf1HeuAlK Gyk2eto04GRDBZAgon7Ah9NBOC9J16QLpxSLJrX/e+3iooqGo+tlzc6fdqxkLt5D3HkW UlLH11lgDEoxIZpA0yEwyoVDVoOS/brJCK1igA7VNJ161Q+P6aC6bJTelhb2AEynRAoh FHWOer6VDQKGEri4LlPc4UeF0J4mEfIiiV7zHSoMPDq2IqhkNUkxpnDT35HbrhkA/v2O PB1c3jJY9v9eBsdH//qvsjr0PcyXw7hGoQDO3Gdu/rGtqlsGoDadqQ/mNbq8uUQ2Fu7L 8mxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZIOTPLHXOaLKVT0TIdYuivhuqIAVXvjRLcJHDsFR/PM=; b=HtdZOWS4MZVar5sOClNMMD9Fcmo0pPy0lpKRaExsilF0J7ZK7YEkN7eXIVqamm+JGK jwT656SNNLCrcCM0cuLrzuKtgSBoN6Hzreui+deEddmxYfErhucrJGf0p/DyhzIh5g1g UyaHzXoQy9T4z3sMRM/ijThiq6W7UEoYyPe6R+xIMdiNfbp3YamoUcsUWVz9Op1NLDj3 F64TWh3UGxiVT+O0V5rK5eCg75Xg4WZtMKkyo0HAOfbSXo0i85q5bGqE24zTn/DZaLX9 Z4WGs4fiOm+WRyOmn6DvJGXOdkziBfrK+VXPv7ywssIdXrJkRJ8asTqMeIG+fhZVE9pD 3c7w== X-Gm-Message-State: AC+VfDzJ562ekhqGZ7xsJ13RPKTcx1W0RmYFPYOBqMXVzudBrtH2VnjQ jI3OjpsPXYOU85ydLK8a+4stae5+t1e5822FtjM= X-Google-Smtp-Source: ACHHUZ6f9g1xfqNwDommeHyVJ/3YFja6j4tqcobhxit9uvRpOoUkxGTm6GHz7zgB5rU9AG+bCO21pw== X-Received: by 2002:a5d:654a:0:b0:306:77da:13a with SMTP id z10-20020a5d654a000000b0030677da013amr1596151wrv.25.1684414274858; Thu, 18 May 2023 05:51:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/29] target/arm: Convert Add/subtract (immediate with tags) to decodetree Date: Thu, 18 May 2023 13:50:51 +0100 Message-Id: <20230518125107.146421-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414454452100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADDG and SUBG (immediate) instructions. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-8-peter.maydell@linaro.org [PMM: Rebased; use TRANS_FEAT()] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 8 +++++++ target/arm/tcg/translate-a64.c | 38 ++++++++++------------------------ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 30c2ac7e271..ed03d9e1349 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -48,3 +48,11 @@ SUB_i . 10 100010 0 ............ ..... ..... = @addsub_imm SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 + +# Add/subtract (immediate with tags) + +&rri_tag rd rn uimm6 uimm4 +@addsub_imm_tag . .. ...... . uimm6:6 .. uimm4:4 rn:5 rd:5 &rri_tag + +ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag +SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 2dd0df7286e..8fa08cc2518 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4244,49 +4244,36 @@ TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_C= C : gen_sub32_CC) =20 /* * Add/subtract (immediate, with tags) - * - * 31 30 29 28 23 22 21 16 14 10 9 5 4 0 - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ - * |sf|op| S| 1 0 0 0 1 1 |o2| uimm6 |o3| uimm4 | Rn | Rd | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ - * - * op: 0 -> add, 1 -> sub */ -static void disas_add_sub_imm_with_tags(DisasContext *s, uint32_t insn) + +static bool gen_add_sub_imm_with_tags(DisasContext *s, arg_rri_tag *a, + bool sub_op) { - int rd =3D extract32(insn, 0, 5); - int rn =3D extract32(insn, 5, 5); - int uimm4 =3D extract32(insn, 10, 4); - int uimm6 =3D extract32(insn, 16, 6); - bool sub_op =3D extract32(insn, 30, 1); TCGv_i64 tcg_rn, tcg_rd; int imm; =20 - /* Test all of sf=3D1, S=3D0, o2=3D0, o3=3D0. */ - if ((insn & 0xa040c000u) !=3D 0x80000000u || - !dc_isar_feature(aa64_mte_insn_reg, s)) { - unallocated_encoding(s); - return; - } - - imm =3D uimm6 << LOG2_TAG_GRANULE; + imm =3D a->uimm6 << LOG2_TAG_GRANULE; if (sub_op) { imm =3D -imm; } =20 - tcg_rn =3D cpu_reg_sp(s, rn); - tcg_rd =3D cpu_reg_sp(s, rd); + tcg_rn =3D cpu_reg_sp(s, a->rn); + tcg_rd =3D cpu_reg_sp(s, a->rd); =20 if (s->ata) { gen_helper_addsubg(tcg_rd, cpu_env, tcg_rn, tcg_constant_i32(imm), - tcg_constant_i32(uimm4)); + tcg_constant_i32(a->uimm4)); } else { tcg_gen_addi_i64(tcg_rd, tcg_rn, imm); gen_address_with_allocation_tag0(tcg_rd, tcg_rd); } + return true; } =20 +TRANS_FEAT(ADDG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, false) +TRANS_FEAT(SUBG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, true) + /* The input should be a value in the bottom e bits (with higher * bits zero); returns that value replicated into every element * of size e in a 64 bit integer. @@ -4638,9 +4625,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x23: /* Add/subtract (immediate, with tags) */ - disas_add_sub_imm_with_tags(s, insn); - break; case 0x24: /* Logical (immediate) */ disas_logic_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414491; cv=none; d=zohomail.com; s=zohoarc; b=blGnHApfaK9KLr+832uw+YV6bHcrKLUTRkTYxNc0dfrkV+w32PJmdn609GlUyKAK36Xipi+rvSmJ5UG071QbM9KivpH0X01jye7we6+Z+k1ncS5YVoFrj2y15xZBbEtKtjpHO/ymdGt2h0ZstOCO+ZHQlDsMREU+6wdHwrmSBXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414491; h=Content-Transfer-Encoding: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=ushDbgyrUsE+lBS91PL1NoncrPh1O6I8HngN7CgBijs=; b=gj8Y5PIoHlfz7UYpeEyPDki1dOZCHSvvGtKZQFgMzXclnY1JBZg7pt5Vf7SzS6eh88nG1rL95Yy1S8E9lFVzuMdg+PWydtaxw0iGAMNVBSzopWk1VAZoGIFwWiijd/vyzsK819JSh5mhd6CaFaICxrv5eZkIdgyDM/JWOt22C7c= 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 1684414491398868.7445135390998; Thu, 18 May 2023 05:54:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6a-0004JE-OT; Thu, 18 May 2023 08:51:40 -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 1pzd6T-0004Dw-TW for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-000817-UF for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:31 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f41dceb9d4so19278015e9.1 for ; Thu, 18 May 2023 05:51:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ushDbgyrUsE+lBS91PL1NoncrPh1O6I8HngN7CgBijs=; b=QmSNgZRtFbirDBInrUNSxg+okdze9CPE26DVB7MrWxy9vjZA5OTZzi5RxbqltDXKNe CFnd+lYm6ypi694mKMKf8Zicx87aNaMXIcJx9j+rB9iZttfqkw/8gyrQNZB1DU6n55ZQ ImVPaV2rv32gmYCSE6e8GHL3zFPh06FWFhsZQaA02d72KVqrmOblNh+FL4Ts7E6Qqn/p oacW/UrysPBXKuR/obOCIcmU6ky06Sydd99a5QTGptuIsSnlNHRbjDOQdW0waFMJ05B1 kMDWuSkdagtp/WCl3hzsvP/FmeZ6qi78CxfCHhfRDtQMN0KNbzArQcVpt1sogU1NNx92 XkSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ushDbgyrUsE+lBS91PL1NoncrPh1O6I8HngN7CgBijs=; b=erk2+i+WAj2WMglAAjO/cvycworALm28pQ9LCmhVg178mDAoyHEt6s4wSfuxpzSH3w HOAjlTaF5Rrn8ayRGB/5X4AEfjnsLMIy9t1zprfH98KHAxFj/0s/M2xAjDkLsEeNpIqI NZaEj9tiBozEzI281XWJUQIjUSjNzCJecO0nYsnG9jaSYXRrWOINzKJA30XdztLTDp+n o928j8cSCuL3hTi+IqLOc40GwwTa5mNPrpsTPNivUq2AQWHZTMjgBT+Sh5523peMrt/H beg2S75zmm+gwvnVJ7qiPZmRpMWx6m9W3nvuKxm6WjOVmGdjSgAKNGchkGwwIw2dYVGx vC7g== X-Gm-Message-State: AC+VfDxLJvCyJST/D6EwOj0i6IYblhHq7U9dk1oPg1aJggyMyuNyoEdH OHi7PJt8nB9b0wynK/3rdVsSOlHPYLEYODv6jM0= X-Google-Smtp-Source: ACHHUZ5iUlwLNfmhjX7MPoVIpAw084CBNfIVK++KGKHmN8iI3EnkAWpE3FDbJjJODIc9VsdtOdS9zA== X-Received: by 2002:a7b:c393:0:b0:3f0:7e56:82a4 with SMTP id s19-20020a7bc393000000b003f07e5682a4mr1496537wmj.18.1684414275276; Thu, 18 May 2023 05:51:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/29] target/arm: Replace bitmask64 with MAKE_64BIT_MASK Date: Thu, 18 May 2023 13:50:52 +0100 Message-Id: <20230518125107.146421-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414491810100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Use the bitops.h macro rather than rolling our own here. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Message-id: 20230512144106.3608981-9-peter.maydell@linaro.org --- target/arm/tcg/translate-a64.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 8fa08cc2518..c744477d71a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4288,13 +4288,6 @@ static uint64_t bitfield_replicate(uint64_t mask, un= signed int e) return mask; } =20 -/* Return a value with the bottom len bits set (where 0 < len <=3D 64) */ -static inline uint64_t bitmask64(unsigned int length) -{ - assert(length > 0 && length <=3D 64); - return ~0ULL >> (64 - length); -} - /* Simplified variant of pseudocode DecodeBitMasks() for the case where we * only require the wmask. Returns false if the imms/immr/immn are a reser= ved * value (ie should cause a guest UNDEF exception), and true if they are @@ -4350,10 +4343,10 @@ bool logic_imm_decode_wmask(uint64_t *result, unsig= ned int immn, /* Create the value of one element: s+1 set bits rotated * by r within the element (which is e bits wide)... */ - mask =3D bitmask64(s + 1); + mask =3D MAKE_64BIT_MASK(0, s + 1); if (r) { mask =3D (mask >> r) | (mask << (e - r)); - mask &=3D bitmask64(e); + mask &=3D MAKE_64BIT_MASK(0, e); } /* ...then replicate the element over the whole 64 bit value */ mask =3D bitfield_replicate(mask, e); --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414495; cv=none; d=zohomail.com; s=zohoarc; b=IICrncucf8E6pdaeA/wPQyMLRaF6K7tFi9SD6cWuVQo24H0ePWs1gG5CcceMWtJbteG/KDqLjnyC6rT9YmJKFSKZtIAIiyOq/0Vb5cUZV4BiAnqo2+CRzZV8qRxzjgQC7OYbTM9H9uj4Wr03e1XUyByI8SPVXpsruEoAADOR6KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414495; h=Content-Transfer-Encoding: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=tOuL57rBampNeBJU0Jmsoiux96q2cJaOnFFC2DVYQQI=; b=b/eV9wXFppMloYbbAhgvdtI4RLKKbnxG2PTsi2CJEBnYhxqDRGUS+3+JE90UucAFMO4ShQ7s0sWsFexGubLjdQhVXpR+H2rkxev67SOzi75Viym1VeVsHxzzRnURQmlIjXOpRgjwaOsiT5Zzs0crcjWqTZ+VEeUBF1Cudy3aLoc= 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 1684414495873477.0067381949717; Thu, 18 May 2023 05:54:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6V-0004GT-6I; Thu, 18 May 2023 08:51:35 -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 1pzd6L-0004Ak-PM for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:26 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6F-00081D-Di for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:23 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f41d087a84so8345155e9.1 for ; Thu, 18 May 2023 05:51:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tOuL57rBampNeBJU0Jmsoiux96q2cJaOnFFC2DVYQQI=; b=N+5Xd4msNiabIWJ/z8lOfdGyKbCRvkMwYhxmnNCIXJLPFh92Tgss9/RC6qQslcFSxx JuCsqKDBtvY14BI8/BpbUn4c3yO+geFud1G0MQ/zULIiCZDjmn0G5oiBPxAJaSRd1eIx KewWq12HHQxww+zAV7MhAg9XMAM8DhIxaoyGMf4E6iXDOEBb0PKr1i68ZgYP6hAvFrB8 NHlahzOkrYxOdEsg4FgodM5p4WGMwZcBg34UvT/K+2WP3Qnh9X7YFkueogf9XK56jJNR H7tpD/ZAPM38NelSEX7WQp0IuZXTwVeB8uwMi+ajwIZc40xArUErBVf9iZ/6cuhciXBy FzNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414275; x=1687006275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tOuL57rBampNeBJU0Jmsoiux96q2cJaOnFFC2DVYQQI=; b=DF8TLo9qc72QvQMBytSU8m1lvLxJ3eIU1+650S6RDEuL+w5sbfSGZVVAVUoWaI4Oxl RoPB90DcYTQo9a/X967X7ej6LP38nQoTcgRSkuUnKVd0LT9+q12F6WDFrScqe069Lum0 jPE7bSpHoMC8C4Jjrf3rwYJ30krBsmvo2ZKlcWpaG1XTEhOcfCyucm3rv8/6/2mw3ti9 SfwsyIT2rGG/rFCewF0vdhaTcEz9j+WxBBq0MzHMXQLk6HMswfCKKjMvN/8JX3kF9SgY zFZK97tisUuvF1VJS2gWZcOPvKd/gSKhNdUnKQHRrdotpo1OSvnWdJjPABBJur3WMhJG JupA== X-Gm-Message-State: AC+VfDwdAHEpy7B49XB8QbumeTdbke9N/GpN/v1fJsjMtWpHp3KT9o2N XfFX/zMxF7ux1pc0v+B0ukPg40rr+QbvpImIp00= X-Google-Smtp-Source: ACHHUZ7II6I74sytrDZyW5c4ApztqUxQStsyW0GFGyWhuqXTqzO5PZuTECy3HT6Ha2onTHl9po/AWA== X-Received: by 2002:a7b:cbc1:0:b0:3f1:731e:cdb1 with SMTP id n1-20020a7bcbc1000000b003f1731ecdb1mr1322645wmi.6.1684414275725; Thu, 18 May 2023 05:51:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/29] target/arm: Convert Logical (immediate) to decodetree Date: Thu, 18 May 2023 13:50:53 +0100 Message-Id: <20230518125107.146421-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414497928100004 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADD, ORR, EOR, ANDS (immediate) instructions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Message-id: 20230512144106.3608981-10-peter.maydell@linaro.org [PMM: rebased] Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 15 ++++++ target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- 2 files changed, 44 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index ed03d9e1349..1933afa457b 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -56,3 +56,18 @@ SUBS_i . 11 100010 1 ............ ..... ..... = @addsub_imm12 =20 ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag + +# Logical (immediate) + +&rri_log rd rn sf dbm +@logic_imm_64 1 .. ...... dbm:13 rn:5 rd:5 &rri_log sf=3D1 +@logic_imm_32 0 .. ...... 0 dbm:12 rn:5 rd:5 &rri_log sf=3D0 + +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_64 +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_32 +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_64 +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_32 +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index c744477d71a..4192f951d48 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4288,7 +4288,12 @@ static uint64_t bitfield_replicate(uint64_t mask, un= signed int e) return mask; } =20 -/* Simplified variant of pseudocode DecodeBitMasks() for the case where we +/* + * Logical (immediate) + */ + +/* + * Simplified variant of pseudocode DecodeBitMasks() for the case where we * only require the wmask. Returns false if the imms/immr/immn are a reser= ved * value (ie should cause a guest UNDEF exception), and true if they are * valid, in which case the decoded bit pattern is written to result. @@ -4354,78 +4359,40 @@ bool logic_imm_decode_wmask(uint64_t *result, unsig= ned int immn, return true; } =20 -/* Logical (immediate) - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 - * +----+-----+-------------+---+------+------+------+------+ - * | sf | opc | 1 0 0 1 0 0 | N | immr | imms | Rn | Rd | - * +----+-----+-------------+---+------+------+------+------+ - */ -static void disas_logic_imm(DisasContext *s, uint32_t insn) +static bool gen_rri_log(DisasContext *s, arg_rri_log *a, bool set_cc, + void (*fn)(TCGv_i64, TCGv_i64, int64_t)) { - unsigned int sf, opc, is_n, immr, imms, rn, rd; TCGv_i64 tcg_rd, tcg_rn; - uint64_t wmask; - bool is_and =3D false; + uint64_t imm; =20 - sf =3D extract32(insn, 31, 1); - opc =3D extract32(insn, 29, 2); - is_n =3D extract32(insn, 22, 1); - immr =3D extract32(insn, 16, 6); - imms =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - - if (!sf && is_n) { - unallocated_encoding(s); - return; + /* Some immediate field values are reserved. */ + if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), + extract32(a->dbm, 0, 6), + extract32(a->dbm, 6, 6))) { + return false; + } + if (!a->sf) { + imm &=3D 0xffffffffull; } =20 - if (opc =3D=3D 0x3) { /* ANDS */ - tcg_rd =3D cpu_reg(s, rd); - } else { - tcg_rd =3D cpu_reg_sp(s, rd); - } - tcg_rn =3D cpu_reg(s, rn); + tcg_rd =3D set_cc ? cpu_reg(s, a->rd) : cpu_reg_sp(s, a->rd); + tcg_rn =3D cpu_reg(s, a->rn); =20 - if (!logic_imm_decode_wmask(&wmask, is_n, imms, immr)) { - /* some immediate field values are reserved */ - unallocated_encoding(s); - return; + fn(tcg_rd, tcg_rn, imm); + if (set_cc) { + gen_logic_CC(a->sf, tcg_rd); } - - if (!sf) { - wmask &=3D 0xffffffff; - } - - switch (opc) { - case 0x3: /* ANDS */ - case 0x0: /* AND */ - tcg_gen_andi_i64(tcg_rd, tcg_rn, wmask); - is_and =3D true; - break; - case 0x1: /* ORR */ - tcg_gen_ori_i64(tcg_rd, tcg_rn, wmask); - break; - case 0x2: /* EOR */ - tcg_gen_xori_i64(tcg_rd, tcg_rn, wmask); - break; - default: - assert(FALSE); /* must handle all above */ - break; - } - - if (!sf && !is_and) { - /* zero extend final result; we know we can skip this for AND - * since the immediate had the high 32 bits clear. - */ + if (!a->sf) { tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } - - if (opc =3D=3D 3) { /* ANDS */ - gen_logic_CC(sf, tcg_rd); - } + return true; } =20 +TRANS(AND_i, gen_rri_log, a, false, tcg_gen_andi_i64) +TRANS(ORR_i, gen_rri_log, a, false, tcg_gen_ori_i64) +TRANS(EOR_i, gen_rri_log, a, false, tcg_gen_xori_i64) +TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) + /* * Move wide (immediate) * @@ -4618,9 +4585,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x24: /* Logical (immediate) */ - disas_logic_imm(s, insn); - break; case 0x25: /* Move wide (immediate) */ disas_movw_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414353; cv=none; d=zohomail.com; s=zohoarc; b=nnkoVenHGrBWnBZkviLs/1RjHXSGZslWKpAdfQ/OuyxqxR5bm6NI2wu9Quqjkd2bKkgrSz5U+bUr50Yd+mZ+y3SS2qsV7igy77NlSSZkFckfrrZHIzk//HKIBiTnznY+Jz/rnbC77XboDjrS9fKbOgfazMCisYkJvUpy7bIn1Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414353; h=Content-Transfer-Encoding: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=uNT0sE0KvR5tqYTGENxbEwXvtcUr3Gd67Gy0nr4Q/MM=; b=KoAK5flFF9VInCNlrcDeUqMAVGvCuBRGwiAyMHE4+v8Ec43wOgvIPUXPQAYXzMKH/LDOoDt91X6c+KfOTF4CcbUd6veUiCwJnlZKENiUI7wpKbf3TDkUZZjulDVozCWb9eUFX7h7T7X67NgxdntuN+niF0uLLXei9XgWggcIL6U= 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 1684414353909548.6208970805818; Thu, 18 May 2023 05:52:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6b-0004K2-DL; Thu, 18 May 2023 08:51:41 -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 1pzd6T-0004E0-Vu for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081F-V4 for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:32 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f42ba32e24so12946055e9.3 for ; Thu, 18 May 2023 05:51:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414276; x=1687006276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uNT0sE0KvR5tqYTGENxbEwXvtcUr3Gd67Gy0nr4Q/MM=; b=mugcpl5PqGFMf2VB1qUHBS7NuGTWAL/ahRFY5nr646zqJixTksMiWpIomJLc/78O65 0MzP2OFBF6A6YLJHrELnCj7T4/tTABvQUEBFnnSOQ+g/1oPCxg0jEfYj6NpMlwRBd5Lf JjR40gE2jF5djEfNVH5OFQNZ/jaB4hjVvU9JKRtlmv2hB7FQy/wEgzf9Tmw8/mli0T/0 XArJH9097cy/266J+DE3h2w8JLYV2hBM4YJUvpVNEr0OcF+wSJptmsh4C07M4xO31Go5 YM4klr9eDNJ0NQaA++eZSqz5E3x+bEWu42Xj6dmEb7RoUD9G1Gs0WRorlXIkOHdP6tM4 /AWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414276; x=1687006276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uNT0sE0KvR5tqYTGENxbEwXvtcUr3Gd67Gy0nr4Q/MM=; b=hoZncEFYv0uQveeaLuNau/zNsi8MBL7x59nbaf3KWehkBYuVe0zaZFm8LWqNpepRXN RC6zrkw3A88E8Kx7qjEdYossJaQp9GMyGtlyss3rnmJmfG0aLfKUvIBeWd5vt2Qh7zU5 BRluoV6Sosgzov2B2071cJe3fpBXLWgLyBCXlTB4cfO56OZ+ECdR1ZDWCToe3op6/Hp8 uQUQ/lHYNpqijuvZXBJ0umv1MUjeI4cuq7WeFvlrakCsGoc64+FDbQOqzCotfJnJFoJo CHgZPS7sALrqxW3eyOEcM5TxMVB4+HPRn4pPT702o+cN7Ze5yw1pAEl15LVt0bsKlV74 R65Q== X-Gm-Message-State: AC+VfDwFaNOjkNorU5DIiWqaJ2QmkXI2IcWhpdqPk4rGPbRuh+WUa9Dc yFGvIGAFJvadJnb4qt3dqM+V65biIrOpxzTet5U= X-Google-Smtp-Source: ACHHUZ7VAuow0zvKMbclAf8KDyz8vn+61iWKL2ZxFnwMjJCM5p1IxKsdY3EC/zg5Q2cQ8s9MHKj1TQ== X-Received: by 2002:a05:600c:cb:b0:3f4:23b9:eed2 with SMTP id u11-20020a05600c00cb00b003f423b9eed2mr1418501wmm.38.1684414276121; Thu, 18 May 2023 05:51:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/29] target/arm: Convert Move wide (immediate) to decodetree Date: Thu, 18 May 2023 13:50:54 +0100 Message-Id: <20230518125107.146421-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414355917100005 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the MON, MOVZ, MOVK instructions. Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Message-id: 20230512144106.3608981-11-peter.maydell@linaro.org [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 ++++++ target/arm/tcg/translate-a64.c | 73 ++++++++++++++-------------------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 1933afa457b..350b37c8f37 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -71,3 +71,16 @@ EOR_i . 10 100100 . ...... ...... ..... ..... = @logic_imm_64 EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 + +# Move wide (immediate) + +&movw rd sf imm hw +@movw_64 1 .. ...... hw:2 imm:16 rd:5 &movw sf=3D1 +@movw_32 0 .. ...... 0 hw:1 imm:16 rd:5 &movw sf=3D0 + +MOVN . 00 100101 .. ................ ..... @movw_64 +MOVN . 00 100101 .. ................ ..... @movw_32 +MOVZ . 10 100101 .. ................ ..... @movw_64 +MOVZ . 10 100101 .. ................ ..... @movw_32 +MOVK . 11 100101 .. ................ ..... @movw_64 +MOVK . 11 100101 .. ................ ..... @movw_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 4192f951d48..c9117f0a405 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4395,52 +4395,40 @@ TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i6= 4) =20 /* * Move wide (immediate) - * - * 31 30 29 28 23 22 21 20 5 4 0 - * +--+-----+-------------+-----+----------------+------+ - * |sf| opc | 1 0 0 1 0 1 | hw | imm16 | Rd | - * +--+-----+-------------+-----+----------------+------+ - * - * sf: 0 -> 32 bit, 1 -> 64 bit - * opc: 00 -> N, 10 -> Z, 11 -> K - * hw: shift/16 (0,16, and sf only 32, 48) */ -static void disas_movw_imm(DisasContext *s, uint32_t insn) + +static bool trans_MOVZ(DisasContext *s, arg_movw *a) { - int rd =3D extract32(insn, 0, 5); - uint64_t imm =3D extract32(insn, 5, 16); - int sf =3D extract32(insn, 31, 1); - int opc =3D extract32(insn, 29, 2); - int pos =3D extract32(insn, 21, 2) << 4; - TCGv_i64 tcg_rd =3D cpu_reg(s, rd); + int pos =3D a->hw << 4; + tcg_gen_movi_i64(cpu_reg(s, a->rd), (uint64_t)a->imm << pos); + return true; +} =20 - if (!sf && (pos >=3D 32)) { - unallocated_encoding(s); - return; - } +static bool trans_MOVN(DisasContext *s, arg_movw *a) +{ + int pos =3D a->hw << 4; + uint64_t imm =3D a->imm; =20 - switch (opc) { - case 0: /* MOVN */ - case 2: /* MOVZ */ - imm <<=3D pos; - if (opc =3D=3D 0) { - imm =3D ~imm; - } - if (!sf) { - imm &=3D 0xffffffffu; - } - tcg_gen_movi_i64(tcg_rd, imm); - break; - case 3: /* MOVK */ - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_constant_i64(imm), pos, 16= ); - if (!sf) { - tcg_gen_ext32u_i64(tcg_rd, tcg_rd); - } - break; - default: - unallocated_encoding(s); - break; + imm =3D ~(imm << pos); + if (!a->sf) { + imm =3D (uint32_t)imm; } + tcg_gen_movi_i64(cpu_reg(s, a->rd), imm); + return true; +} + +static bool trans_MOVK(DisasContext *s, arg_movw *a) +{ + int pos =3D a->hw << 4; + TCGv_i64 tcg_rd, tcg_im; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_im =3D tcg_constant_i64(a->imm); + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_im, pos, 16); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + return true; } =20 /* Bitfield @@ -4585,9 +4573,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x25: /* Move wide (immediate) */ - disas_movw_imm(s, insn); - break; case 0x26: /* Bitfield */ disas_bitfield(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414371; cv=none; d=zohomail.com; s=zohoarc; b=S6je/xAJCYmK39kUrkfCCLQm4nXwpmobpmD0li8OIGZNCv66VzkqE3gS2Yuhl30x7zpXnoysikOvfOYUjGaUQpn5ZW1nsOyYXYYhdlVeRmLAosQUJWg9gtA/rL24u0HWlgM9XFlrZyF8m/WGxws7i99svh70m8QRr4u6EsEupvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414371; h=Content-Transfer-Encoding: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=316WPcTaX/dkZyaOwPkqhzyQ3qnA+Bqof7S5NJnRzk4=; b=TkEgfEtVpmrUAx0QlkD5a4o+FCQUp6TBWqwa1/Woysm1x4/3TQttP2Deorav7/QTBr6Q0wLM5hIG3BBa11F83vQr8dT1iXzgD62g0TIXY5Mo6eIcK/EpKRsNim84yFVh7/ZETViIDnXUxKBDrv6dQeqwePd0TDliRTI5gPPPT4o= 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 1684414371348809.972507609357; Thu, 18 May 2023 05:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6X-0004HW-BI; Thu, 18 May 2023 08:51:37 -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 1pzd6O-0004BP-5m for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:28 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6K-00081L-5l for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:27 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3078cc99232so1900597f8f.3 for ; Thu, 18 May 2023 05:51:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414276; x=1687006276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=316WPcTaX/dkZyaOwPkqhzyQ3qnA+Bqof7S5NJnRzk4=; b=S+3I4xXRHgJ42h3DloY6yhHVKW1NOpiYXjmo1lmdEOhkvGfh67PmqweQ9LpmWNaEi5 EjlrbaNcDGjYn8ydkOXD+WO0GASawhjJsdA9xO1RlZVw9RtuNrSu7m2CD6RAJpefR2VC 5pZHcZw5NWjSkhw3OCBxsf6uuxvvRuwQ6DduWlsrQhlQ50XnNmqKg68l1/C3jvbUPAok vZ44IumqECB6EaoYIXTCZU2G40EQ+3Iz2P32RUdv2LJTGFZq6DZL6iDh+i03fPRz9qBt IHMdEtuJ5aOfYwmBvmwD2U7EryT2BbtDSxAQl1booacO8Z6g6MxaRHz6MZ57uuK2QsTa XdPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414276; x=1687006276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=316WPcTaX/dkZyaOwPkqhzyQ3qnA+Bqof7S5NJnRzk4=; b=ekonLL/Wp0TV3bgqVTVpxkYA5VVJZATZZT6QM+X+hKPSkTBeC+1pLhsJwR7gdFPAOl 0wOWqWHPMytKIVAz7OuqnTkCNu1H/sPW5yH36XCxv/bdyleOefhiMeC85U3atLCI6nhc QcKZ1+ua0w8dr96prfRrb03w/k9Z0HkY+vmwQ21kGmnsmnAOKpeqTOzc8W2KfPOGZbHU WuF39BHzWIdvlD4vNf4i+2d8ZiCw0GSeoJkTy5Tng5DRn1QharWFHZLcBP7B+NQkGNTr 6CFdmNQpnPByncgeDv5xm/hjTmk+7ebFByl2AHg3RIUfPcqPYjQ3729xSR01goskVcEv YYmQ== X-Gm-Message-State: AC+VfDyXWHbg7LWKUu2mTATyMll0VRhTRJItYRZhC5RBIhXQutXgyr9Q mysa3MqfluC1nARbMAo2i6yuDIdJZQjPf24xUUQ= X-Google-Smtp-Source: ACHHUZ5CDISbTg8X/ZqdwXnfULItg/EIfe3ftiRnhJkz0XWH7PjU8Wufok3hwMz9+qDYYZzKtEpcng== X-Received: by 2002:adf:fe50:0:b0:307:a36b:e7b1 with SMTP id m16-20020adffe50000000b00307a36be7b1mr1771112wrs.5.1684414276546; Thu, 18 May 2023 05:51:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/29] target/arm: Convert Bitfield to decodetree Date: Thu, 18 May 2023 13:50:55 +0100 Message-Id: <20230518125107.146421-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414372008100002 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the BFM, SBFM, UBFM instructions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Message-id: 20230512144106.3608981-12-peter.maydell@linaro.org [PMM: Rebased] Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 +++ target/arm/tcg/translate-a64.c | 144 ++++++++++++++++++--------------- 2 files changed, 94 insertions(+), 63 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 350b37c8f37..4d5709f9857 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -84,3 +84,16 @@ MOVZ . 10 100101 .. ................ ..... = @movw_64 MOVZ . 10 100101 .. ................ ..... @movw_32 MOVK . 11 100101 .. ................ ..... @movw_64 MOVK . 11 100101 .. ................ ..... @movw_32 + +# Bitfield + +&bitfield rd rn sf immr imms +@bitfield_64 1 .. ...... 1 immr:6 imms:6 rn:5 rd:5 &bitfield sf=3D1 +@bitfield_32 0 .. ...... 0 0 immr:5 0 imms:5 rn:5 rd:5 &bitfield sf=3D0 + +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_64 +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_32 +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index c9117f0a405..3e7344e79c3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4431,82 +4431,103 @@ static bool trans_MOVK(DisasContext *s, arg_movw *= a) return true; } =20 -/* Bitfield - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 - * +----+-----+-------------+---+------+------+------+------+ - * | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd | - * +----+-----+-------------+---+------+------+------+------+ +/* + * Bitfield */ -static void disas_bitfield(DisasContext *s, uint32_t insn) + +static bool trans_SBFM(DisasContext *s, arg_SBFM *a) { - unsigned int sf, n, opc, ri, si, rn, rd, bitsize, pos, len; - TCGv_i64 tcg_rd, tcg_tmp; + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; =20 - sf =3D extract32(insn, 31, 1); - opc =3D extract32(insn, 29, 2); - n =3D extract32(insn, 22, 1); - ri =3D extract32(insn, 16, 6); - si =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - bitsize =3D sf ? 64 : 32; - - if (sf !=3D n || ri >=3D bitsize || si >=3D bitsize || opc > 2) { - unallocated_encoding(s); - return; - } - - tcg_rd =3D cpu_reg(s, rd); - - /* Suppress the zero-extend for !sf. Since RI and SI are constrained - to be smaller than bitsize, we'll never reference data outside the - low 32-bits anyway. */ - tcg_tmp =3D read_cpu_reg(s, rn, 1); - - /* Recognize simple(r) extractions. */ if (si >=3D ri) { /* Wd =3D Wn */ len =3D (si - ri) + 1; - if (opc =3D=3D 0) { /* SBFM: ASR, SBFX, SXTB, SXTH, SXTW */ - tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); - goto done; - } else if (opc =3D=3D 2) { /* UBFM: UBFX, LSR, UXTB, UXTH */ - tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); - return; + tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } - /* opc =3D=3D 1, BFXIL fall through to deposit */ + } else { + /* Wd<32+s-r,32-r> =3D Wn */ + len =3D si + 1; + pos =3D (bitsize - ri) & (bitsize - 1); + + if (len < ri) { + /* + * Sign extend the destination field from len to fill the + * balance of the word. Let the deposit below insert all + * of those sign bits. + */ + tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); + len =3D ri; + } + + /* + * We start with zero, and we haven't modified any bits outside + * bitsize, therefore no final zero-extension is unneeded for !sf. + */ + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); + } + return true; +} + +static bool trans_UBFM(DisasContext *s, arg_UBFM *a) +{ + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + + if (si >=3D ri) { + /* Wd =3D Wn */ + len =3D (si - ri) + 1; + tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); + } else { + /* Wd<32+s-r,32-r> =3D Wn */ + len =3D si + 1; + pos =3D (bitsize - ri) & (bitsize - 1); + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); + } + return true; +} + +static bool trans_BFM(DisasContext *s, arg_BFM *a) +{ + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + + if (si >=3D ri) { + /* Wd =3D Wn */ tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); + len =3D (si - ri) + 1; pos =3D 0; } else { - /* Handle the ri > si case with a deposit - * Wd<32+s-r,32-r> =3D Wn - */ + /* Wd<32+s-r,32-r> =3D Wn */ len =3D si + 1; pos =3D (bitsize - ri) & (bitsize - 1); } =20 - if (opc =3D=3D 0 && len < ri) { - /* SBFM: sign extend the destination field from len to fill - the balance of the word. Let the deposit below insert all - of those sign bits. */ - tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); - len =3D ri; - } - - if (opc =3D=3D 1) { /* BFM, BFXIL */ - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); - } else { - /* SBFM or UBFM: We start with zero, and we haven't modified - any bits outside bitsize, therefore the zero-extension - below is unneeded. */ - tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); - return; - } - - done: - if (!sf) { /* zero extend final result */ + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); + if (!a->sf) { tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } + return true; } =20 /* Extract @@ -4573,9 +4594,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x26: /* Bitfield */ - disas_bitfield(s, insn); - break; case 0x27: /* Extract */ disas_extract(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414516; cv=none; d=zohomail.com; s=zohoarc; b=cLvUXwhz7xGzXThCYqzcqi52bdHPbH4eqbsOrldeVvWujrlESUCQSQ03a2DqMV0J2cQuu1dQ6fiYc7rvkRyJhXgnQghL4LeOsi+O9bBIJTx/PlBxqKO4v0Z9DLAa1GIbuPN0/sB5Zxa988tQRfuyuJisS+ULNopHUW5eocJFlZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414516; h=Content-Transfer-Encoding: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=bXAj0yybqjVJG30UNIaT2K/bVJBeJjQHqvMdRVkkaL4=; b=f7ybG3Q5jmygIYTfmASSPDNwoE7m15y2qtP4GMc+Bf9mBI1g9YVqYhpgw/jBuLpBFNZzKHvLcv96uV5jmUIowEkqa4BQ1krDClpBFznVb/mvYxaHTkeywJzJy+HezSFnUBpthuHw/lWBK2543W3YnkE/hEFNoI+qTLN2mNBPSoI= 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 1684414516648371.3319702085397; Thu, 18 May 2023 05:55:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6a-0004Ii-Bh; Thu, 18 May 2023 08:51:40 -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 1pzd6T-0004Dx-Tj for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081T-Vg for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:31 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f42c865534so19288305e9.2 for ; Thu, 18 May 2023 05:51:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bXAj0yybqjVJG30UNIaT2K/bVJBeJjQHqvMdRVkkaL4=; b=qNMT7C+ryPpz+uaEOAEbSPPni4mj0eGlrV1ET9FWNSzh8MjPNXCOrBoudIR1eh5PlK 6Vtt1//5Tg9+YZ9ROcPmSqONddYNQfYg3f3C6Y0w9d7v2gnN/Oji26p2iyHIwkSNJ/t4 TSrknIuWVizaiX6cvfgfXY9NTtnnY5w4dMXCAB46e/K4VaXJEMbu0XII9vYmk+YLvWb7 TVl87C1hyld0x86rN0ecMWiTizcwyolLDYMwVtYSnmZb1j2oxrlixF3F9lxGMA4ovvF5 Ih6diicb9UR6+zUvjVbwsbwydMBa0nq/9EOrqHVdE4jtvJP4GDL1i1Ckw3xT8COvuBx8 9nAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bXAj0yybqjVJG30UNIaT2K/bVJBeJjQHqvMdRVkkaL4=; b=YHEa5G5JPmJs31anoE5/jbb7d5UKmDwiOarICmXx78Yyie7r3lPUv9vyiO9qCB6l5J GO8vb8/WaF23/zs50dKwPVxhEkAGsfHifUoIWPhhwa+pt8Y6BIaoH1TJ26I62RjhMhQ1 IgSCQDe1USUaAsVTnLttw65ZgTzmtQz4WIkSFYUwVgZTba2FQ8N1sLAUXYMXs2FS3O7Y XRRWABaonUfAug+cDpyvCtyGLWGIQJbZT9m5BRGa5UvCh2HpAV3vce81apXJopT2C3S4 UKReb0XueN/qxoI52DD98qhF0iDjspxoOX5utlf/7DKuApNIi57CKPrxHNnfFCiX0Sch C2pw== X-Gm-Message-State: AC+VfDxspCQB9+C28siJeFycH7b3vv+QxnIKpqSvz0DFtHjClCf+qlvx SkNjcflVFNr+1P5/8KxRADfvBAuHaZyz8E0dJzs= X-Google-Smtp-Source: ACHHUZ4QorrMUE4Rt30LPyKzljXnc2RE7zFqIY3sodg3dZqzWbkPfUfdRSFT1hh6epJ8RG/cIspUQQ== X-Received: by 2002:a05:600c:22d7:b0:3f4:2e13:ccdc with SMTP id 23-20020a05600c22d700b003f42e13ccdcmr1420286wmg.0.1684414276937; Thu, 18 May 2023 05:51:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/29] target/arm: Convert Extract instructions to decodetree Date: Thu, 18 May 2023 13:50:56 +0100 Message-Id: <20230518125107.146421-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414517860100003 Content-Type: text/plain; charset="utf-8" Convert the EXTR instruction to decodetree (this is the only one in the 'Extract" class). This is the last of the dp-immediate insns in the legacy decoder, so we can now remove disas_data_proc_imm(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-13-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 7 +++ target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- 2 files changed, 36 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 4d5709f9857..e6e1a5f2bcb 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -97,3 +97,10 @@ BFM . 01 100110 . ...... ...... ..... ..... = @bitfield_64 BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 + +# Extract + +&extract rd rn rm imm sf + +EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=3D1 +EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=3D0 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3e7344e79c3..f939f6c9443 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4530,77 +4530,44 @@ static bool trans_BFM(DisasContext *s, arg_BFM *a) return true; } =20 -/* Extract - * 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0 - * +----+------+-------------+---+----+------+--------+------+------+ - * | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd | - * +----+------+-------------+---+----+------+--------+------+------+ - */ -static void disas_extract(DisasContext *s, uint32_t insn) +static bool trans_EXTR(DisasContext *s, arg_extract *a) { - unsigned int sf, n, rm, imm, rn, rd, bitsize, op21, op0; + TCGv_i64 tcg_rd, tcg_rm, tcg_rn; =20 - sf =3D extract32(insn, 31, 1); - n =3D extract32(insn, 22, 1); - rm =3D extract32(insn, 16, 5); - imm =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - op21 =3D extract32(insn, 29, 2); - op0 =3D extract32(insn, 21, 1); - bitsize =3D sf ? 64 : 32; + tcg_rd =3D cpu_reg(s, a->rd); =20 - if (sf !=3D n || op21 || op0 || imm >=3D bitsize) { - unallocated_encoding(s); - } else { - TCGv_i64 tcg_rd, tcg_rm, tcg_rn; - - tcg_rd =3D cpu_reg(s, rd); - - if (unlikely(imm =3D=3D 0)) { - /* tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, - * so an extract from bit 0 is a special case. - */ - if (sf) { - tcg_gen_mov_i64(tcg_rd, cpu_reg(s, rm)); - } else { - tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); - } + if (unlikely(a->imm =3D=3D 0)) { + /* + * tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, + * so an extract from bit 0 is a special case. + */ + if (a->sf) { + tcg_gen_mov_i64(tcg_rd, cpu_reg(s, a->rm)); } else { - tcg_rm =3D cpu_reg(s, rm); - tcg_rn =3D cpu_reg(s, rn); + tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, a->rm)); + } + } else { + tcg_rm =3D cpu_reg(s, a->rm); + tcg_rn =3D cpu_reg(s, a->rn); =20 - if (sf) { - /* Specialization to ROR happens in EXTRACT2. */ - tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, imm); + if (a->sf) { + /* Specialization to ROR happens in EXTRACT2. */ + tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, a->imm); + } else { + TCGv_i32 t0 =3D tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t0, tcg_rm); + if (a->rm =3D=3D a->rn) { + tcg_gen_rotri_i32(t0, t0, a->imm); } else { - TCGv_i32 t0 =3D tcg_temp_new_i32(); - - tcg_gen_extrl_i64_i32(t0, tcg_rm); - if (rm =3D=3D rn) { - tcg_gen_rotri_i32(t0, t0, imm); - } else { - TCGv_i32 t1 =3D tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(t1, tcg_rn); - tcg_gen_extract2_i32(t0, t0, t1, imm); - } - tcg_gen_extu_i32_i64(tcg_rd, t0); + TCGv_i32 t1 =3D tcg_temp_new_i32(); + tcg_gen_extrl_i64_i32(t1, tcg_rn); + tcg_gen_extract2_i32(t0, t0, t1, a->imm); } + tcg_gen_extu_i32_i64(tcg_rd, t0); } } -} - -/* Data processing - immediate */ -static void disas_data_proc_imm(DisasContext *s, uint32_t insn) -{ - switch (extract32(insn, 23, 6)) { - case 0x27: /* Extract */ - disas_extract(s, insn); - break; - default: - unallocated_encoding(s); - break; - } + return true; } =20 /* Shift a TCGv src by TCGv shift_amount, put result in dst. @@ -14125,9 +14092,6 @@ static bool btype_destination_ok(uint32_t insn, boo= l bt, int btype) static void disas_a64_legacy(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 4)) { - case 0x8: case 0x9: /* Data processing - immediate */ - disas_data_proc_imm(s, insn); - break; case 0xa: case 0xb: /* Branch, exception generation and system insns */ disas_b_exc_sys(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414521; cv=none; d=zohomail.com; s=zohoarc; b=UD2go9CEJPj7tpIb1IWAfsSZwmY9skgf8OjnTwUUNq9j/wI5ZsPwi7fQ+ipLXE40LwLv0ut12YPWEzQ7aw8I3TwUXtDSkR204Ml5WoP/KkgfhtGUVwiblvNYdCsZJoLCl701PGOv3sveqFP4Im4UVI1JnTQ92owIgzy4ffXjG9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414521; h=Content-Transfer-Encoding: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=7EB1RtFUAd4cT6NrXiFuDC7ITXwAXhWcCBcvwhZmQlQ=; b=d392J8PW/Q8Na4ljulz69HmmFYqnpJTi0LKfn4e/h1ypMmKaagzkihmcnGwVdwDE3czoS7ZYf3Sc9i4QkDIkcyucov2dPX1B5pCukwInlmbBihywvFwiGUa/h7RjJz+w2d8qfWh6OcfBI6hRatSEGQWT+ViG0Elmn/3v4fQeylY= 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 1684414521436547.4636929798545; Thu, 18 May 2023 05:55:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Z-0004IO-Sz; Thu, 18 May 2023 08:51:39 -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 1pzd6T-0004Dv-TD for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081W-UC for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:31 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f4c6c4b51eso19541175e9.2 for ; Thu, 18 May 2023 05:51:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7EB1RtFUAd4cT6NrXiFuDC7ITXwAXhWcCBcvwhZmQlQ=; b=vsqWPO0rmdbE0zSbdL59vSZU85G3dEcL+PTa7E3yLSQ+ZHgr6R8cYocVSovRs+qJ2C w0SFkZ5BlvErc+DueEGcNMC2Ficx9qkYDkRp3a8S+CgjfXYXoCchQiokuimNmKNlhEYs ENNiU7mJzVvuCugM9cDmGGQsmsSYRnoUNqB1i87UUG/qVbeeEpm+5OYyf/1iy7TE+HX3 K7JZRTT+p8Y9LVj/EXPt81ghT4IZCr4jaMlVYGesotPnJEMdc+V4PQjzsYuDAitR8Z1d QEQCdWdHuw9CAuoVwTZHYkTSa1LCC168KWDG79KK3huiew1tPMXW1cT2h1zXlbFgXvM3 WD6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7EB1RtFUAd4cT6NrXiFuDC7ITXwAXhWcCBcvwhZmQlQ=; b=ZPPM3rLrXyF/uRg6k8cmuldE+6zhZJTTRtG1gfFzGBhPS44n4cqf9aKeyiSPBCjlZf QWesfpg7/kRN768hQk7vNhAkl5J5t0Imq5+6vaket/tWv71nGru0pjXigOdhp3y++shq HitGZR9xCTecdtkjJtjbkfrdg02w3rYVTNjfwWjy1LIUEIBQBhRgjQwnlwCoUmOs/tbk +6WRBfc5DFK/lyoedPnWTTt1KT08tw1HL5ey6h19lvjFQgbOkzlepmZeMvutW4DJQ1og zIXMt3K/YpHyria+hVvf7EeFWbbqDeMDED+5OGsUSdpeTE9//1IhgnLEDcOJLi5Z6vKD KUdw== X-Gm-Message-State: AC+VfDxLjOVnVESeaZMQQCRQXjLAJAK2EvAGfrzaXduPfIV+ApSnNMLe hXTu7eploA2zw8bOZCx+MPrchLIVFoJQIa0E3zg= X-Google-Smtp-Source: ACHHUZ47zmiL3jBica4j9nDr/s9O/m0TqYIwKdnOyx+3YVpXFRtsyRVeNpuMc+IOb9ySux2iwMiUGQ== X-Received: by 2002:a05:600c:3787:b0:3f4:2b98:428f with SMTP id o7-20020a05600c378700b003f42b98428fmr1536220wmr.39.1684414277347; Thu, 18 May 2023 05:51:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/29] target/arm: Convert unconditional branch immediate to decodetree Date: Thu, 18 May 2023 13:50:57 +0100 Message-Id: <20230518125107.146421-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414521886100009 Content-Type: text/plain; charset="utf-8" Convert the unconditional branch immediate insns B and BL to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-14-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 9 +++++++++ target/arm/tcg/translate-a64.c | 31 +++++++++++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index e6e1a5f2bcb..483e3649929 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -21,6 +21,7 @@ =20 &ri rd imm &rri_sf rd rn imm sf +&i imm =20 =20 ### Data Processing - Immediate @@ -104,3 +105,11 @@ UBFM . 10 100110 . ...... ...... ..... ....= . @bitfield_32 =20 EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=3D1 EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=3D0 + +# Branches + +%imm26 0:s26 !function=3Dtimes_4 +@branch . ..... .......................... &i imm=3D%imm26 + +B 0 00101 .......................... @branch +BL 1 00101 .......................... @branch diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index f939f6c9443..f702e9b0678 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1319,24 +1319,19 @@ static inline AArch64DecodeFn *lookup_disas_fn(cons= t AArch64DecodeTable *table, * match up with those in the manual. */ =20 -/* Unconditional branch (immediate) - * 31 30 26 25 0 - * +----+-----------+-------------------------------------+ - * | op | 0 0 1 0 1 | imm26 | - * +----+-----------+-------------------------------------+ - */ -static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) +static bool trans_B(DisasContext *s, arg_i *a) { - int64_t diff =3D sextract32(insn, 0, 26) * 4; - - if (insn & (1U << 31)) { - /* BL Branch with link */ - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); - } - - /* B Branch / BL Branch with link */ reset_btype(s); - gen_goto_tb(s, 0, diff); + gen_goto_tb(s, 0, a->imm); + return true; +} + +static bool trans_BL(DisasContext *s, arg_i *a) +{ + gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); + reset_btype(s); + gen_goto_tb(s, 0, a->imm); + return true; } =20 /* Compare and branch (immediate) @@ -2413,10 +2408,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x0a: case 0x0b: - case 0x4a: case 0x4b: /* Unconditional branch (immediate) */ - disas_uncond_b_imm(s, insn); - break; case 0x1a: case 0x5a: /* Compare & branch (immediate) */ disas_comp_b_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414385; cv=none; d=zohomail.com; s=zohoarc; b=VKGEEY3LiB0+CanAi0BaTJLL4E0VDuFnBrkU4e9mV7HEYXqo2moNIC/QkU4NjtLaTZ/wj36nWJxsgMD0Yq3t5vHmzyM+8H9wXf7qE1TCzssVy2Bo1Fz7ve6SYWOF/IRe4F394J5f2+jmg2KofFzzg2H6gWghVVJpwgo+CmQdgCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414385; h=Content-Transfer-Encoding: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=u3wPL3NK+XZ35Ptpin56VFyKyMzmgfDqXeAb/6jTxe8=; b=Cs9/SXsCgA4WXA0dvn21R1J9ctiGN4pLSs4Wu2VA86UzpL8gdRPwkXfN4pvMMsCKy/kOzZhJuQIJCDQUUX0Cfm3wPy6k5rro1ShLcg6yW65pcBvLIjk3SzCFVmsxwdAw526N0JiEuehtLP0LCsrp0DJ074ARCmr1VK3444w4tr0= 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 1684414385845277.56763275006017; Thu, 18 May 2023 05:53:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6X-0004Hu-Ok; Thu, 18 May 2023 08:51:37 -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 1pzd6U-0004Ey-8s for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081f-W0 for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3093a7b71fbso1882018f8f.2 for ; Thu, 18 May 2023 05:51:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=u3wPL3NK+XZ35Ptpin56VFyKyMzmgfDqXeAb/6jTxe8=; b=EcLG9Us9FbFSgL8jjBKcAwEkL2m3aSb01tKJphR2tg0kfAGGhtFBkcPY3X+iGgu/dT wDCcPXHGRktx4YI1c6p8kWs49cz69PQrNua4dHt6Z1d6fO7v6G+ApYu1J2M0IqY4Mlux 4TgH3TJ/1hfY1h1KlTnw5pf9iCoV0nvtX6VkRp69pmurNiDxEbgWff4KKN6X/Ne8xAqa U/SSXav5UwG1Vp+3C6tSTESzi+dyK9HUSTI+0W13uISuW0cJubM4fjSfKO69nRWN/Xz8 2nqAhY1SvKuRem9E5sDyDTf7HiLm0BDjOatddOalMkpTQY/Z20D+cgpazzku5fN6wMRS EDZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414277; x=1687006277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u3wPL3NK+XZ35Ptpin56VFyKyMzmgfDqXeAb/6jTxe8=; b=O4wu6jYOIgpK3rIqR2/lnvde0HNuGvembmvi+dO80kU8BvSuyWuzJpUyFT0kKJASfx a95TuwHKfLXQxahCe+WmmQ9zbXTm2DQ54zE8lgagceS+v5C7trSmR3N4/E31+N++eSIo bG6pi6PUhwW7Fh0Wm1msW/EMqXZHfU2LBvV+5nmAlA5l7ikrz9IzeMjM/0xAZH0aw18I I6GnB5bskJD40drP1Pzmyxx+TDaoK1TgUxXz+ri+Vv6wuheGase44mlDSZ0JbuUKiwkZ nHWNCicyzu6QUB50pRNRC81NbsZ/t7i5D+v4rhWZ6c7sDWYE035LYYj59dwo6m3e1MJz Pcfg== X-Gm-Message-State: AC+VfDy34jfeeXOIxPcUBWeMPBn3KNVHU+IVe3geo9w6edRJLT/vYyL7 JDo3bJfoLZZ9hqy4zmT8GIHmfhOBBu9XNMuyvh4= X-Google-Smtp-Source: ACHHUZ5MbocghGDrgJXt5Mhcrtxvg6yYcNblKH7nur7ctJihyS2BLx83Yoeo0N5thp21Y+S71P8Bkg== X-Received: by 2002:a5d:6545:0:b0:309:4368:a8a0 with SMTP id z5-20020a5d6545000000b003094368a8a0mr1462388wrv.68.1684414277737; Thu, 18 May 2023 05:51:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/29] target/arm: Convert CBZ, CBNZ to decodetree Date: Thu, 18 May 2023 13:50:58 +0100 Message-Id: <20230518125107.146421-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414386158100002 Content-Type: text/plain; charset="utf-8" Convert the compare-and-branch-immediate insns CBZ and CBNZ to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-15-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 5 +++++ target/arm/tcg/translate-a64.c | 26 ++++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 483e3649929..f5759a66e7f 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -113,3 +113,8 @@ EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 = &extract sf=3D0 =20 B 0 00101 .......................... @branch BL 1 00101 .......................... @branch + +%imm19 5:s19 !function=3Dtimes_4 +&cbz rt imm sf nz + +CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=3D%imm19 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index f702e9b0678..06619f8a05d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1334,33 +1334,22 @@ static bool trans_BL(DisasContext *s, arg_i *a) return true; } =20 -/* Compare and branch (immediate) - * 31 30 25 24 23 5 4 0 - * +----+-------------+----+---------------------+--------+ - * | sf | 0 1 1 0 1 0 | op | imm19 | Rt | - * +----+-------------+----+---------------------+--------+ - */ -static void disas_comp_b_imm(DisasContext *s, uint32_t insn) + +static bool trans_CBZ(DisasContext *s, arg_cbz *a) { - unsigned int sf, op, rt; - int64_t diff; DisasLabel match; TCGv_i64 tcg_cmp; =20 - sf =3D extract32(insn, 31, 1); - op =3D extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ - rt =3D extract32(insn, 0, 5); - diff =3D sextract32(insn, 5, 19) * 4; - - tcg_cmp =3D read_cpu_reg(s, rt, sf); + tcg_cmp =3D read_cpu_reg(s, a->rt, a->sf); reset_btype(s); =20 match =3D gen_disas_label(s); - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, tcg_cmp, 0, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); + return true; } =20 /* Test and branch (immediate) @@ -2408,9 +2397,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x1a: case 0x5a: /* Compare & branch (immediate) */ - disas_comp_b_imm(s, insn); - break; case 0x1b: case 0x5b: /* Test & branch (immediate) */ disas_test_b_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414518; cv=none; d=zohomail.com; s=zohoarc; b=JMOoUVt5qRYvYZU/5fVnabkQEkP4W/akyGzo7S1jYxOFgclC8asWmdczKjfrt1nNxWMVByN+UcAJjIadDr6fB+iXTApdn30yHlGfkYjIikaVmiqANd6ynGZ+NIimCfxr+j9+DYgPo5O+LyBoLqA9HXTXPcSnbGx8B7dFe11U9Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414518; h=Content-Transfer-Encoding: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=W6KDzoUlerslTQhMby3OQ4q1nBSstouBuvraHtUO/aU=; b=TtZJScVr5AFP3r2oUioUEPWlCA3x7qaarOmkdKxoCVt18uGI55QVYPB3cD/3Xh6jmrWmcYh6g3DYbZUWQIqilvsuwzhkTCSGs86qwqMQVxzuyAg+oYIvYoB/tP5l7Dy1+rNo02XQWMIZB+3hp/PgtqJTl2q4SGQUWMwFrDfCIsE= 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 1684414518006100.13924139947278; Thu, 18 May 2023 05:55:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6a-0004JG-Q3; Thu, 18 May 2023 08:51:40 -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 1pzd6T-0004E2-W5 for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081j-UT for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:31 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f41d087b3bso20206885e9.0 for ; Thu, 18 May 2023 05:51:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414278; x=1687006278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=W6KDzoUlerslTQhMby3OQ4q1nBSstouBuvraHtUO/aU=; b=srWVxZYd2kCDDPVc1wVLUC0M2xfIDKLs7iFrbG/Ye7thv0Rwc1Idq/NzA4l00UdLFx 8eK3hJQSLX6y7b7xYY5k8PRFDNdYo/I7/O0tPNx2bc+l80MYCMmhqUHwyF/6QbpOcYl5 bOCU8wOLdqtmMruPQE5lnoLjZxQ+fpl7Dv4Nf7hlMOtHuBVkLwMAcZ9MNIzEOJO+eHoQ 1cgUwYgNAlqAuqHPDki4WbAf45l/66wSBjhA7Gr3FWOVt9fJwQQTsmzN/1/ezxYY4VJO ZzeThtVQmbKyc5kt1CCmTXXIYQIO31BLRRjHY4iJIPJtsLG7DcUAbQU4ysitk4ySTFqX lOUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414278; x=1687006278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W6KDzoUlerslTQhMby3OQ4q1nBSstouBuvraHtUO/aU=; b=KUb7h3fJmGR+j6ZcUHv1t1B33f9GritTKSuTvSxFqBzpe5dieL8p2rqe4SWkjq6Hun xFYmeIL0gGbEvA0fs/kn0Ur3EtokTz/QlZUw48mSlyNK/FKb91qSKKRHz0YN0lLDkY7L TgZEpPfuROfLVa3ZnXwm6apSuMcAk3G2AxmnvKSQVUat2264aR5N2zHXqohyXQC8yspy pbgQcWPvJD1Or8AaOsqmtjm/UusBjknLNhoOMwfNtT2/yeYTu7FKWelJrc9rnYmR/w+h GsgTzJv0JXea+E+Ci0Gq5emhexzM0v3ZJV2/AZdBfalgbFYxJamq7Emj4tyZxJb3iQBs WgtQ== X-Gm-Message-State: AC+VfDzSyWDvO3RE5mgJUfbFh6V2ILngPEQCx3gwTt1lR6niCNXdahXn JkdaEEGbcOkVBtrmxHtFirB3vjAlmOTFDjAirro= X-Google-Smtp-Source: ACHHUZ4xHy+JkugiM4xXnHlfktVfSEuIlf4s0iaRRYTtDiMRDXl4lmXnRVat3FZgtexQAbWVpgzJWA== X-Received: by 2002:a1c:7409:0:b0:3f1:75b0:dc47 with SMTP id p9-20020a1c7409000000b003f175b0dc47mr1394474wmc.15.1684414278168; Thu, 18 May 2023 05:51:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/29] target/arm: Convert TBZ, TBNZ to decodetree Date: Thu, 18 May 2023 13:50:59 +0100 Message-Id: <20230518125107.146421-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414519856100007 Content-Type: text/plain; charset="utf-8" Convert the test-and-branch-immediate insns TBZ and TBNZ to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-16-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 6 ++++++ target/arm/tcg/translate-a64.c | 25 +++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index f5759a66e7f..09def15863f 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -118,3 +118,9 @@ BL 1 00101 .......................... @bra= nch &cbz rt imm sf nz =20 CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=3D%imm19 + +%imm14 5:s14 !function=3Dtimes_4 +%imm31_19 31:1 19:5 +&tbz rt imm nz bitpos + +TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=3D%imm14= bitpos=3D%imm31_19 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 06619f8a05d..1e5977423a6 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1352,35 +1352,23 @@ static bool trans_CBZ(DisasContext *s, arg_cbz *a) return true; } =20 -/* Test and branch (immediate) - * 31 30 25 24 23 19 18 5 4 0 - * +----+-------------+----+-------+-------------+------+ - * | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt | - * +----+-------------+----+-------+-------------+------+ - */ -static void disas_test_b_imm(DisasContext *s, uint32_t insn) +static bool trans_TBZ(DisasContext *s, arg_tbz *a) { - unsigned int bit_pos, op, rt; - int64_t diff; DisasLabel match; TCGv_i64 tcg_cmp; =20 - bit_pos =3D (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); - op =3D extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ - diff =3D sextract32(insn, 5, 14) * 4; - rt =3D extract32(insn, 0, 5); - tcg_cmp =3D tcg_temp_new_i64(); - tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); + tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, a->rt), 1ULL << a->bitpos); =20 reset_btype(s); =20 match =3D gen_disas_label(s); - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, tcg_cmp, 0, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); + return true; } =20 /* Conditional branch (immediate) @@ -2397,9 +2385,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x1b: case 0x5b: /* Test & branch (immediate) */ - disas_test_b_imm(s, insn); - break; case 0x2a: /* Conditional branch (immediate) */ disas_cond_b_imm(s, insn); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414347; cv=none; d=zohomail.com; s=zohoarc; b=DWgLxsuH3r+rbAE7oL2z2xif8E13FBp4oPPCkX4q70a1+2j0J9zMEnj1LYDNPkMtcVzEXc0W2UimcWzV8dpgEuUlOwrTg3wSL1p3HIcVFh8l4XNIUYjBrrLBQ9hz7p7D3K4K+e2dqmGEqYrNYZu1UWPS60eZeP7Lh8ur40DP+uA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414347; h=Content-Transfer-Encoding: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=/9DPUpf5bQDvtdp/1Tfm8Da/KNhELKY6TnW1+dKMD2w=; b=TG/2cLQ2b5GNLLHeF1zF0qQOrU1peOAlWN/ADbMO0kDoGq2/GU59Y3T85f019es2KVL0ItOI35NXf++1GqP8JXPnMR9eN4TZhzD9qTfOZD6EGTN7mz+ZH1vJd9JXXaO/ZQ5usxrkqXFdpF8QzIHkxiRm0xEmuH2RsR/damu0Klg= 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 1684414347591318.9114151813392; Thu, 18 May 2023 05:52:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Y-0004IK-PB; Thu, 18 May 2023 08:51:38 -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 1pzd6Q-0004Bj-2O for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6I-00081o-8z for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:28 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f450815d02so13086745e9.0 for ; Thu, 18 May 2023 05:51:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414278; x=1687006278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/9DPUpf5bQDvtdp/1Tfm8Da/KNhELKY6TnW1+dKMD2w=; b=qi9VRKdi2iMljdx5cSizkbj94TEb9BCL0kKL3Yywa78u/7EL2I60axaZxQ/91x3bFM HRPuZ8+bx69lJMzn6BH4d74OnT74Yoj21F/fYIn5l0rRalxavoB13IJC6828D4CuCls+ p3uRcP1ttZI1hD3/GGr2qidVC+irTMzVUAyoUDfbXRb8A6+EfW7WMCWmGals+UktIfIC YXkFYENUaYzcjqIs9j4y9Zdbd91eSIOwlylp5mO6JGrxLvcarrCzt8TszT9rDqO/S4A4 kWVRFcWKxM6z2MQo00vRzSSlPIM7wKhunq6/38iR1bYUwwvJkGy4vtKD1ss25ATAzPzp 3Oiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414278; x=1687006278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/9DPUpf5bQDvtdp/1Tfm8Da/KNhELKY6TnW1+dKMD2w=; b=XAdIgmHbvU+GPPmAjsKJck3RX+aCxU/HW/TxiQh0JezVGo5Y5dL8eg82nDS3bGVynX 7dKHFtL+DIg7x55OrOvELi1HfPtdRmBUSyaF3XVP8vKttAcYYYYR6dAKz4NOg36dVcmj S0fRWdXnNohhxJDAaFKgyNfGhKsv/GasXdybrz8XRYdegr22l87c6ufQ4OJYr/TDD4J9 G25PQFSTPKU0TIUPdfm16dkqDsOHAWuqk3wdnzU8Vh+HyZG4DdOL/ZA0PrfruU4yTv1n HvsaP/t0EeLIZGk7hSAtTkX4f4rAxt9+a4oJ23IRPdCGjwkXYJJkhQC7SUNtAuIA8HYY R3Gw== X-Gm-Message-State: AC+VfDxWp+Cs9vG6zBoWQ11WAlik8FF0Ljmq/g0R+N8oScSy84oQ0MAe MGgbpomTuCIrdmmQP/eiCoK3cxqZRvI57zwbfsI= X-Google-Smtp-Source: ACHHUZ6UPBcwAQh31kpEeBXtu4fL2YYBEvG82x1IFAQWZDDlUPeKpiNO18DG+W3HiYUbkx3OBuRBxQ== X-Received: by 2002:a05:600c:2243:b0:3f4:2610:5cd4 with SMTP id a3-20020a05600c224300b003f426105cd4mr1514435wmm.29.1684414278643; Thu, 18 May 2023 05:51:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/29] target/arm: Convert conditional branch insns to decodetree Date: Thu, 18 May 2023 13:51:00 +0100 Message-Id: <20230518125107.146421-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414349861100007 Content-Type: text/plain; charset="utf-8" Convert the immediate conditional branch insn B.cond to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-17-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 2 ++ target/arm/tcg/translate-a64.c | 30 ++++++------------------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 09def15863f..5b9e275b5f8 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -124,3 +124,5 @@ CBZ sf:1 011010 nz:1 ................... rt= :5 &cbz imm=3D%imm19 &tbz rt imm nz bitpos =20 TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=3D%imm14= bitpos=3D%imm31_19 + +B_cond 0101010 0 ................... 0 cond:4 imm=3D%imm19 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 1e5977423a6..a7ab89fdc8c 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1371,36 +1371,21 @@ static bool trans_TBZ(DisasContext *s, arg_tbz *a) return true; } =20 -/* Conditional branch (immediate) - * 31 25 24 23 5 4 3 0 - * +---------------+----+---------------------+----+------+ - * | 0 1 0 1 0 1 0 | o1 | imm19 | o0 | cond | - * +---------------+----+---------------------+----+------+ - */ -static void disas_cond_b_imm(DisasContext *s, uint32_t insn) +static bool trans_B_cond(DisasContext *s, arg_B_cond *a) { - unsigned int cond; - int64_t diff; - - if ((insn & (1 << 4)) || (insn & (1 << 24))) { - unallocated_encoding(s); - return; - } - diff =3D sextract32(insn, 5, 19) * 4; - cond =3D extract32(insn, 0, 4); - reset_btype(s); - if (cond < 0x0e) { + if (a->cond < 0x0e) { /* genuinely conditional branches */ DisasLabel match =3D gen_disas_label(s); - arm_gen_test_cc(cond, match.label); + arm_gen_test_cc(a->cond, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); } else { /* 0xe and 0xf are both "always" conditions */ - gen_goto_tb(s, 0, diff); + gen_goto_tb(s, 0, a->imm); } + return true; } =20 /* HINT instruction group, including various allocated HINTs */ @@ -2385,9 +2370,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x2a: /* Conditional branch (immediate) */ - disas_cond_b_imm(s, insn); - break; case 0x6a: /* Exception generation / System */ if (insn & (1 << 24)) { if (extract32(insn, 22, 2) =3D=3D 0) { --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414394; cv=none; d=zohomail.com; s=zohoarc; b=jrdjwbkiCVusO8vHE8yirWp4+w3CY+pqY9L898G8GOhlwBTU/4du5rEcMLXeCZfrBFTnj60rVmBmxIHBdr2n/FWJp/RRULQtIwCiVQs3ipbbE2QAmXxVzoulHm4Qbp1pThBwvdgL1J1mqKWfuR4+Cx4iELVl+EKNEDud9WDdNvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414394; h=Content-Transfer-Encoding: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=qKdYxX6AGGIMH+Ujyu/x5WcZet6ovGbUI7+N7ydiBEM=; b=bsU+Rfm6FQnAYWbgUp64drfoNooMQ97OaKYn75k7fjKYLLOyJdll6t/HXeFeawYUylFKCyI5S3Z1y33QTAaCQeRebSmWQHmS87HmHSpGa+dwRLBv8CYPcPbfuF0JrOxQRFOoV5md3g7OtqAkHHVTsqn/sZMDYyy3NzZsIy4iLfU= 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 1684414394657400.67019901452863; Thu, 18 May 2023 05:53:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Y-0004I8-19; Thu, 18 May 2023 08:51:38 -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 1pzd6U-0004Dz-0b for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081t-Tr for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:32 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f4ad71b00eso12795475e9.2 for ; Thu, 18 May 2023 05:51:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414279; x=1687006279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qKdYxX6AGGIMH+Ujyu/x5WcZet6ovGbUI7+N7ydiBEM=; b=JgzWMLQdofTeXfc6H0zjC9o6PWM4osQ2fAMqZCXSe51+y8c7htKugE+hQ69qCi0qSL S3s3vQkLg7GeeBRQPdiy3XH037cWWVt0F13rT7/ZhMHx2bFAYwQlJDoAKo8wHC0pxFXt 0Zn2ufQd4GFOsNdd/oZbBXZVrtIv0RGSfuX1cXOpKJGNs1AT+X0eMluNs3eiLvyDVQIW wjGQi6qY3240/HDvh5uv763r1LX6q8HRxFkT59nUUigrd55NCww6GTfi+OyLf1GFX9KV NNVo1NL4GsvOkryODwKPHqKIzo/NBRWBO1hV3gkV47KelRblE5qNTfYz9snFRtAY2wd5 eb0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414279; x=1687006279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qKdYxX6AGGIMH+Ujyu/x5WcZet6ovGbUI7+N7ydiBEM=; b=jh6m98/x8Zm5CVtscxvZUfbKGPdZ4dqjo5FxqTbhiX07nh39jn6R0EwABZpzDKXX7c tRt06ggECds0W/EYsEIDC5iFkG3mykP8GWzlEuKIV9jr9D45/Ti+nryWl7BZuq5J32Hy Ns4Dnltj+5wL3IfPzDza/35Y7v45dHJDOeloFc5LDKHNt3WeKP97TKxmw0ZQku6p3jQP LQh5b78CYkO6+yrScViggGL4xbFUxXbQqy39q2nMwoOYhWKyX5Aj1F/fECLUbxVqYUip XvneB5igBerEpjCMzcxXLgGp4IFhxff7GZWUsgt7dEJXszRWpEXAsgfghPxGwd7YUQtA AawA== X-Gm-Message-State: AC+VfDz7KhbGZcjuLon3590rjNN9Qf5GuG/BM7rfpZMDqt+nXM8LVfZI NP1ed7elgAWJEWO4JwVrIzMDWXtNOvXPrymL4wI= X-Google-Smtp-Source: ACHHUZ4rJLc0v/FxkgdVrV2iJoUE0iTdKUXLv5RwPGWami8P606tF/SUosCZmkL7YywFSttv8KTmrA== X-Received: by 2002:a5d:428d:0:b0:306:37bf:ca5a with SMTP id k13-20020a5d428d000000b0030637bfca5amr1392742wrq.47.1684414279027; Thu, 18 May 2023 05:51:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/29] target/arm: Convert BR, BLR, RET to decodetree Date: Thu, 18 May 2023 13:51:01 +0100 Message-Id: <20230518125107.146421-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414395352100001 Content-Type: text/plain; charset="utf-8" Convert the simple (non-pointer-auth) BR, BLR and RET insns to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-18-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 5 ++++ target/arm/tcg/translate-a64.c | 55 ++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 5b9e275b5f8..690dc107d41 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -19,6 +19,7 @@ # This file is processed by scripts/decodetree.py # =20 +&r rn &ri rd imm &rri_sf rd rn imm sf &i imm @@ -126,3 +127,7 @@ CBZ sf:1 011010 nz:1 ................... rt= :5 &cbz imm=3D%imm19 TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=3D%imm14= bitpos=3D%imm31_19 =20 B_cond 0101010 0 ................... 0 cond:4 imm=3D%imm19 + +BR 1101011 0000 11111 000000 rn:5 00000 &r +BLR 1101011 0001 11111 000000 rn:5 00000 &r +RET 1101011 0010 11111 000000 rn:5 00000 &r diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a7ab89fdc8c..3af16e60b50 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1388,6 +1388,53 @@ static bool trans_B_cond(DisasContext *s, arg_B_cond= *a) return true; } =20 +static void set_btype_for_br(DisasContext *s, int rn) +{ + if (dc_isar_feature(aa64_bti, s)) { + /* BR to {x16,x17} or !guard -> 1, else 3. */ + set_btype(s, rn =3D=3D 16 || rn =3D=3D 17 || !s->guarded_page ? 1 = : 3); + } +} + +static void set_btype_for_blr(DisasContext *s) +{ + if (dc_isar_feature(aa64_bti, s)) { + /* BLR sets BTYPE to 2, regardless of source guarded page. */ + set_btype(s, 2); + } +} + +static bool trans_BR(DisasContext *s, arg_r *a) +{ + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLR(DisasContext *s, arg_r *a) +{ + TCGv_i64 dst =3D cpu_reg(s, a->rn); + TCGv_i64 lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_RET(DisasContext *s, arg_r *a) +{ + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2186,12 +2233,8 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) btype_mod =3D opc; switch (op3) { case 0: - /* BR, BLR, RET */ - if (op4 !=3D 0) { - goto do_unallocated; - } - dst =3D cpu_reg(s, rn); - break; + /* BR, BLR, RET : handled in decodetree */ + goto do_unallocated; =20 case 2: case 3: --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414447; cv=none; d=zohomail.com; s=zohoarc; b=kqwj9tBQZPEZYrrcwGi/Ipf3iI0WGekpLulGCJWEJhQ0to3NkBec1ByTukeyNfAZYKkceevAiGlMeDSgVEuAtVAQyNiOgSvthY4s1yTNhsNr6gShzKnHIPaiMOs0Z1hhWLcmHZzps5YcJqPrkI66V7rurQUCe+DLJwUPxqV7bEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414447; h=Content-Transfer-Encoding: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=YMhCV7wm3l7VDS8emWqKL20+1SbJLBnRldB9YK48kv0=; b=ERQhLR1i+N9WGt1hiQTZJteNk9ysjI2q7W/HnpGN3Bgul6wt3UbRo6bQ+lwGDJC+15/qDJ3SFuVPk/pxENc2JnbGiS+uOOhV5ER2jCSyM7ZSLlO3YLHQi8OSW/qs5Y03VggYMdx3BRm5YG3A0ZROWC9u2gZU8cAchkbqzUtyssY= 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 168441444729269.22328643731635; Thu, 18 May 2023 05:54:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6X-0004HX-Ad; Thu, 18 May 2023 08:51:37 -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 1pzd6T-0004E1-Vg for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00081z-Ud for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f41dceb9c9so13913295e9.3 for ; Thu, 18 May 2023 05:51:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414279; x=1687006279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YMhCV7wm3l7VDS8emWqKL20+1SbJLBnRldB9YK48kv0=; b=Iik4TIZs2V+9re5YOKYxpFO2YzJWANwG6oNlRw/g/vvcdMMLPipm+lg3kVuzZrenW+ Sr+EfEsNuV0cDb55p6JblpHUkLvkLJQv+QBVXDbHWavS75tCLFHflGRs+T7S1PN17r++ R71GegtZjsdoaRwfpuWqfRSvzITgd2CSMI3mZJuwKvlfG0xlimVcd0REGrLw8S9o6EqV ckxkPL/HfsjHhzmrBr/OFEiVJiVHSyacYy3OgmVMmMIYRo0BW35Pv0bm/A6DpR2Nc9/V YAxm62Efisv0uLzhb5mzsOUcsxKKmpg2F4GGFUhXmI1r6VjTQetMQ/3kNqq6qaRdXO41 4l+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414279; x=1687006279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YMhCV7wm3l7VDS8emWqKL20+1SbJLBnRldB9YK48kv0=; b=X/SkQ4GPc6cXypHeMfm11gRhUl90vTRfz3mzEGGsP0xj22HljGrlDedQtGhOJepim7 E4EygAsCkOZkNiEuFtQyeeulzqkHwHDkpW6befOn0E7CPAh98c5NlUTx2wEq2dUDlsYH A/ut83n/NqfRhE4Zfk9GwaNg+vM35jxh9s23G/OSGelFsk5rYUU/WX+KOfUIcncpma1S fUCUjB3t4iWWaeVVw8uxr3/1YGbNldVIjYY6vdzo23ds2IOvMCO3voT8tPOHiFId4hJ5 S1q3JCQpRI/ntHF5GrUc+w6QrimCrxoV3eCWokXy8sAnN5aat+P03Lz7PLXflWlGTi7+ 4iYA== X-Gm-Message-State: AC+VfDzgwo0DUm3PndO9Sj44Mlc+wc4pGHdRA4vIy04vp4BwOpoQpBU2 h45inVLSeV22ZF7WtadkYi3WCXme1ohFpUSJb10= X-Google-Smtp-Source: ACHHUZ4ebnC/YXnN8YbAlemqYBsvMR8L3XWx46bjhNMeMnWBMvRnRPSPIRdi5kx6eOI1OsnGvgediQ== X-Received: by 2002:a1c:7412:0:b0:3f4:fffc:add with SMTP id p18-20020a1c7412000000b003f4fffc0addmr1246757wmc.27.1684414279448; Thu, 18 May 2023 05:51:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/29] target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] to decodetree Date: Thu, 18 May 2023 13:51:02 +0100 Message-Id: <20230518125107.146421-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414447556100001 Content-Type: text/plain; charset="utf-8" Convert the single-register pointer-authentication variants of BR, BLR, RET to decodetree. (BRAA/BLRAA are in a different branch of the legacy decoder and will be dealt with in the next commit.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-19-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 7 ++ target/arm/tcg/translate-a64.c | 132 +++++++++++++++++++-------------- 2 files changed, 84 insertions(+), 55 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 690dc107d41..f66202081ae 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -131,3 +131,10 @@ B_cond 0101010 0 ................... 0 cond:4= imm=3D%imm19 BR 1101011 0000 11111 000000 rn:5 00000 &r BLR 1101011 0001 11111 000000 rn:5 00000 &r RET 1101011 0010 11111 000000 rn:5 00000 &r + +&braz rn m +BRAZ 1101011 0000 11111 00001 m:1 rn:5 11111 &braz # BRAAZ, B= RABZ +BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, = BLRABZ + +&reta m +RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, R= ETAB diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3af16e60b50..a278136cd10 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1435,6 +1435,75 @@ static bool trans_RET(DisasContext *s, arg_r *a) return true; } =20 +static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst, + TCGv_i64 modifier, bool use_key_a) +{ + TCGv_i64 truedst; + /* + * Return the branch target for a BRAA/RETA/etc, which is either + * just the destination dst, or that value with the pauth check + * done and the code removed from the high bits. + */ + if (!s->pauth_active) { + return dst; + } + + truedst =3D tcg_temp_new_i64(); + if (use_key_a) { + gen_helper_autia(truedst, cpu_env, dst, modifier); + } else { + gen_helper_autib(truedst, cpu_env, dst, modifier); + } + return truedst; +} + +static bool trans_BRAZ(DisasContext *s, arg_braz *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); + gen_a64_set_pc(s, dst); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLRAZ(DisasContext *s, arg_braz *a) +{ + TCGv_i64 dst, lr; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); + lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_RETA(DisasContext *s, arg_reta *a) +{ + TCGv_i64 dst; + + dst =3D auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); + gen_a64_set_pc(s, dst); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2227,61 +2296,14 @@ static void disas_uncond_b_reg(DisasContext *s, uin= t32_t insn) } =20 switch (opc) { - case 0: /* BR */ - case 1: /* BLR */ - case 2: /* RET */ - btype_mod =3D opc; - switch (op3) { - case 0: - /* BR, BLR, RET : handled in decodetree */ - goto do_unallocated; - - case 2: - case 3: - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if (opc =3D=3D 2) { - /* RETAA, RETAB */ - if (rn !=3D 0x1f || op4 !=3D 0x1f) { - goto do_unallocated; - } - rn =3D 30; - modifier =3D cpu_X[31]; - } else { - /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ - if (op4 !=3D 0x1f) { - goto do_unallocated; - } - modifier =3D tcg_constant_i64(0); - } - if (s->pauth_active) { - dst =3D tcg_temp_new_i64(); - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifie= r); - } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifie= r); - } - } else { - dst =3D cpu_reg(s, rn); - } - break; - - default: - goto do_unallocated; - } - /* BLR also needs to load return address */ - if (opc =3D=3D 1) { - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; - } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - } - gen_a64_set_pc(s, dst); - break; + case 0: + case 1: + case 2: + /* + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: + * handled in decodetree + */ + goto do_unallocated; =20 case 8: /* BRAA */ case 9: /* BLRAA */ --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414468; cv=none; d=zohomail.com; s=zohoarc; b=EfoAmPfYYrFPd0hpxP+ZFt/ATk6J2ed3iU8UtDy/ujwiSRTy9/Xz76LTpb1ueXsjoe7dQvxAHtoJg6zbAFFChAoP7EnzxeBskHiOYwA7CrF2uzT4mZ7A2omc7oIKhw9Dz2PYnX7SCyfqUDPlQskyRQ+8pTTmoV2xln9dg3lpyw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414468; h=Content-Transfer-Encoding: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=+uKAV67tegBPCi4W/Vkq6NRUE8/9elykbxDxhdc51ns=; b=bsU96bUyi7eSgRiy7NT6trH/XQrNw5t4CUP2Jcks60awoQQhClwW5dq/BeFvXHCUHfmywh+SePIUFcynX6bENm1BKoLXDdlOEFngdNLF3E3mBHjEYjya92hozkLTS2lhU22+u87erUTaa83IPbUAAuh9+NxA1E+d6onHROKLgSg= 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 1684414468948579.3525855017841; Thu, 18 May 2023 05:54:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Z-0004IL-2j; Thu, 18 May 2023 08:51:39 -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 1pzd6T-0004DD-9t for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-000828-Gi for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f41d087bd3so12562805e9.3 for ; Thu, 18 May 2023 05:51:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414280; x=1687006280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+uKAV67tegBPCi4W/Vkq6NRUE8/9elykbxDxhdc51ns=; b=S6JYOhoLsyl4omWnSfY3eLPWGfy/+LEgdLfKhlHud+yuFJLbJ24OwLirW07cWpyoDW +ANDdOpd3uOc0ZRx9wHdcoj4rAPiDLkpMZ0ugv/FWjaGWtZHszmqdfNgb2k7LBIMBPtZ 63ksYEwbVtfHT50hG9/0ehJri0LrJSUADFEcA4D44xo+xgajDQ/Yv26eJjKYCwFkD6K7 bFkNi8f3FviVD30CaFzi33gBU/elfQi7uCFu7JG6Y0A4ZUMgF1GBz6QG8k0j5bvT7xfg wmcgZ6aAFXtma0EvH9EqXESOwWxxRNg6hGk4RPi+oXtLv/FLRL32pfg1J7UCyeSweF8L 0Nig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414280; x=1687006280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+uKAV67tegBPCi4W/Vkq6NRUE8/9elykbxDxhdc51ns=; b=KIqXsTNzhMb8vu5OwCvkRP9+mlRybujRiAZxMJkG5Np0Xrc+7kBDp8NtmMtnpCwoD+ 1FjrYMRiSFGJBjcol2ntQ7ZVpV9CHup7VmczDK6V+WMKCkSmcDUQ9LezAs8ppuDmiNVs c5hkeUHk53p8AgOe9HA82EsvRcBclbhYdRaRzgxUO387DZeU1XUkhjZeF8fbkwBylSZm mdb/RVp/2a8lzQNjpKWkW4znzr0RkV7AnpbxPNk4cyjdW9GDRqtJm7E/RhZ6xE85lEN0 ckjF5JUOIiCIt38OZic7sqZEmq8ZVUOje2X7OMvJz6DOmcukZvtphArtVKUPxnPUZTYc hc5Q== X-Gm-Message-State: AC+VfDxDRIPXoUoaR0z2xGUhx12QY0k1zMucaB6hpfp3eyGg2y+o/I64 6zQnbBhrpShb8A8zJRbenK6ecVFZvgPb2mGEVYU= X-Google-Smtp-Source: ACHHUZ7qJIgSrDgFft7DkESP7//sjLqTkDsTNH++i2HrFznoXcLmP7acap4FAOMGzDKMxHmmA8Z9DA== X-Received: by 2002:a1c:7311:0:b0:3f4:237f:a171 with SMTP id d17-20020a1c7311000000b003f4237fa171mr1495346wmb.3.1684414280277; Thu, 18 May 2023 05:51:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/29] target/arm: Convert BRAA, BRAB, BLRAA, BLRAB to decodetree Date: Thu, 18 May 2023 13:51:03 +0100 Message-Id: <20230518125107.146421-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414469672100001 Content-Type: text/plain; charset="utf-8" Convert the last four BR-with-pointer-auth insns to decodetree. The remaining cases in the outer switch in disas_uncond_b_reg() all return early rather than leaving the case statement, so we can delete the now-unused code at the end of that function. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-20-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 4 ++ target/arm/tcg/translate-a64.c | 97 ++++++++++++++-------------------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index f66202081ae..2fd435b6317 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -138,3 +138,7 @@ BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111= &braz # BLRAAZ, BLRABZ =20 &reta m RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, R= ETAB + +&bra rn rm m +BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB +BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a278136cd10..40a6e59a609 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1504,6 +1504,41 @@ static bool trans_RETA(DisasContext *s, arg_reta *a) return true; } =20 +static bool trans_BRA(DisasContext *s, arg_bra *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + dst =3D auth_branch_target(s, cpu_reg(s,a->rn), cpu_reg_sp(s, a->rm), = !a->m); + gen_a64_set_pc(s, dst); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLRA(DisasContext *s, arg_bra *a) +{ + TCGv_i64 dst, lr; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm),= !a->m); + lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2281,7 +2316,6 @@ static void disas_exc(DisasContext *s, uint32_t insn) static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) { unsigned int opc, op2, op3, rn, op4; - unsigned btype_mod =3D 2; /* 0: BR, 1: BLR, 2: other */ TCGv_i64 dst; TCGv_i64 modifier; =20 @@ -2299,45 +2333,14 @@ static void disas_uncond_b_reg(DisasContext *s, uin= t32_t insn) case 0: case 1: case 2: + case 8: + case 9: /* - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: - * handled in decodetree + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, + * BRAA, BLRAA: handled in decodetree */ goto do_unallocated; =20 - case 8: /* BRAA */ - case 9: /* BLRAA */ - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if ((op3 & ~1) !=3D 2) { - goto do_unallocated; - } - btype_mod =3D opc & 1; - if (s->pauth_active) { - dst =3D tcg_temp_new_i64(); - modifier =3D cpu_reg_sp(s, op4); - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); - } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); - } - } else { - dst =3D cpu_reg(s, rn); - } - /* BLRAA also needs to load return address */ - if (opc =3D=3D 9) { - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; - } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - } - gen_a64_set_pc(s, dst); - break; - case 4: /* ERET */ if (s->current_el =3D=3D 0) { goto do_unallocated; @@ -2407,28 +2410,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) unallocated_encoding(s); return; } - - switch (btype_mod) { - case 0: /* BR */ - if (dc_isar_feature(aa64_bti, s)) { - /* BR to {x16,x17} or !guard -> 1, else 3. */ - set_btype(s, rn =3D=3D 16 || rn =3D=3D 17 || !s->guarded_page = ? 1 : 3); - } - break; - - case 1: /* BLR */ - if (dc_isar_feature(aa64_bti, s)) { - /* BLR sets BTYPE to 2, regardless of source guarded page. */ - set_btype(s, 2); - } - break; - - default: /* RET or none of the above. */ - /* BTYPE will be set to 0 by normal end-of-insn processing. */ - break; - } - - s->base.is_jmp =3D DISAS_JUMP; } =20 /* Branches, exception generating and system instructions */ --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414408; cv=none; d=zohomail.com; s=zohoarc; b=VHrZLYcyogP8P7lrpSWkSPApampfjg/5B9AiFkyaXLScclULlGDnydze4ddzmlyQ7kqeodqbdb5IXiJwoyCD3rLZnC8WGQPj9kqoziArToo7vtE4CzA+0OUONDOge6fahAOy9Gj/R0MNgKpXJ3kTazVwLrnOOaTTjqyqWcvqb0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414408; h=Content-Transfer-Encoding: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=KJ0AuTZIeHtuKSRHgOzvysEJomvJ3ZVkSEuGxl++Sq4=; b=QXAvjqwiogtVPGBOSpAgHnyzQgkpDiQ3fqpuan1PUonGVE9i+wW2XosYetim9w/xSlpSpYVIHW9BQJO2aY4zyJ2klXULWiyK/jH/3XMh5RA7RmC0V9Dvy+VFdQcemsAMSieUZMUU9m1tkch/9x8XrE4fAGKdH7f52P7HjhHCCsU= 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 1684414408299137.75283339328837; Thu, 18 May 2023 05:53:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6S-0004Co-K9; Thu, 18 May 2023 08:51:32 -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 1pzd6Q-0004Bm-4a for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6K-00082B-5Z for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:29 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f450815d0bso19663975e9.0 for ; Thu, 18 May 2023 05:51:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414280; x=1687006280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KJ0AuTZIeHtuKSRHgOzvysEJomvJ3ZVkSEuGxl++Sq4=; b=HshaxGK1tq+rZh64u+TC8e4zMT1kwD+MOLJb4VzWrnqQsOP/BcV3gJhT1BOajUIhHT WNGzeNDjVdgRNNRu/kU03mHi7BfG8gmnAJvV92Kz7ppERRjEOzegkyllxSLG0t7IDpp/ gKdZT8kbsHxG4V13EIBOTZLNdeXC3PZHMFQDEk6eo6zC0LIs745kOsayd+HHSLV07ZVe lYI3OdNoD7Zot7eNdbGgXKYhwLb0N8BDgfnxtC0zffTnysbBEH3XPqo1FOA7+90vxi3+ a8ueeSJFdDLpOF810ReGXrc97CQhBrJA7GcMNm180JcgItAtETO0tkM7kGtL0L7YzfwJ mwfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414280; x=1687006280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KJ0AuTZIeHtuKSRHgOzvysEJomvJ3ZVkSEuGxl++Sq4=; b=ArRYGfsToGtI5zRkxJGR61sKCXdhJcawnO9+Y9orhDwp1gKj2cPSEVIHowxBmsg8lU xY/uXbjpxMNMJPKNwIK4QN0YC+4moOmOSdlKOzWdCX9aJoxe3+RTcUIQmNqy+4sb4P/Q +NVWCAMYX7Qcg4aQNDm5h0gdgTRQv5joc0Vy0hRpTovV7gSvASZDZ3j9eL1u5BWnzjns G0vqodmGGfUdLkfVQyE/agiY1YnEBU7rS+JH9kGhtJNOJWdV3pQ3JIj5qHBj20wDvKxV C73iA2gttDI3/vKpmsaa7jxi/DmjtSspF50NgKc+IXpVkJs8xgEDCZnFyQ2pI1MZKNG1 Zd8Q== X-Gm-Message-State: AC+VfDw8RnKBaqLRheBJwxAHerjJhqVgzBIZl5UY2MJzWPt54s6/ynDg 6cT15Z4OCD9Te16LV5W6QgGH4TSN4+fd9TKwksw= X-Google-Smtp-Source: ACHHUZ4+XVvknHRR/U1tFbof+/yo+JyQXDAVOC5ou1uLRWbohuAu1o6Mhg994IOJGCf+5C/3gT1tzg== X-Received: by 2002:a7b:c393:0:b0:3f4:2267:10c0 with SMTP id s19-20020a7bc393000000b003f4226710c0mr1577703wmj.28.1684414280776; Thu, 18 May 2023 05:51:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/29] target/arm: Convert ERET, ERETAA, ERETAB to decodetree Date: Thu, 18 May 2023 13:51:04 +0100 Message-Id: <20230518125107.146421-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414409414100001 Content-Type: text/plain; charset="utf-8" Convert the exception-return insns ERET, ERETA and ERETB to decodetree. These were the last insns left in the legacy decoder function disas_uncond_reg_b(), which allows us to remove it. The old decoder explicitly decoded the DRPS instruction, only in order to call unallocated_encoding() on it, exactly as would have happened if it hadn't decoded it. This is because this insn always UNDEFs unless the CPU is in halting-debug state, which we don't emulate. So we list the pattern in a comment in a64.decode, but don't actively decode it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512144106.3608981-21-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 8 ++ target/arm/tcg/translate-a64.c | 163 +++++++++++---------------------- 2 files changed, 63 insertions(+), 108 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 2fd435b6317..12a310d0a31 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -142,3 +142,11 @@ RETA 1101011 0010 11111 00001 m:1 11111 111= 11 &reta # RETAA, RETAB &bra rn rm m BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB + +ERET 1101011 0100 11111 000000 11111 00000 +ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, = ERETAB + +# We don't need to decode DRPS because it always UNDEFs except when +# the processor is in halting debug state (which we don't implement). +# The pattern is listed here as documentation. +# DRPS 1101011 0101 11111 000000 11111 00000 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 40a6e59a609..741a6087399 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1539,6 +1539,61 @@ static bool trans_BLRA(DisasContext *s, arg_bra *a) return true; } =20 +static bool trans_ERET(DisasContext *s, arg_ERET *a) +{ + TCGv_i64 dst; + + if (s->current_el =3D=3D 0) { + return false; + } + if (s->fgt_eret) { + gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2); + return true; + } + dst =3D tcg_temp_new_i64(); + tcg_gen_ld_i64(dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); + + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } + + gen_helper_exception_return(cpu_env, dst); + /* Must exit loop to check un-masked IRQs */ + s->base.is_jmp =3D DISAS_EXIT; + return true; +} + +static bool trans_ERETA(DisasContext *s, arg_reta *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + if (s->current_el =3D=3D 0) { + return false; + } + /* The FGT trap takes precedence over an auth trap. */ + if (s->fgt_eret) { + gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2); + return true; + } + dst =3D tcg_temp_new_i64(); + tcg_gen_ld_i64(dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); + + dst =3D auth_branch_target(s, dst, cpu_X[31], !a->m); + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } + + gen_helper_exception_return(cpu_env, dst); + /* Must exit loop to check un-masked IRQs */ + s->base.is_jmp =3D DISAS_EXIT; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2307,111 +2362,6 @@ static void disas_exc(DisasContext *s, uint32_t ins= n) } } =20 -/* Unconditional branch (register) - * 31 25 24 21 20 16 15 10 9 5 4 0 - * +---------------+-------+-------+-------+------+-------+ - * | 1 1 0 1 0 1 1 | opc | op2 | op3 | Rn | op4 | - * +---------------+-------+-------+-------+------+-------+ - */ -static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) -{ - unsigned int opc, op2, op3, rn, op4; - TCGv_i64 dst; - TCGv_i64 modifier; - - opc =3D extract32(insn, 21, 4); - op2 =3D extract32(insn, 16, 5); - op3 =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - op4 =3D extract32(insn, 0, 5); - - if (op2 !=3D 0x1f) { - goto do_unallocated; - } - - switch (opc) { - case 0: - case 1: - case 2: - case 8: - case 9: - /* - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, - * BRAA, BLRAA: handled in decodetree - */ - goto do_unallocated; - - case 4: /* ERET */ - if (s->current_el =3D=3D 0) { - goto do_unallocated; - } - switch (op3) { - case 0: /* ERET */ - if (op4 !=3D 0) { - goto do_unallocated; - } - if (s->fgt_eret) { - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), = 2); - return; - } - dst =3D tcg_temp_new_i64(); - tcg_gen_ld_i64(dst, cpu_env, - offsetof(CPUARMState, elr_el[s->current_el])); - break; - - case 2: /* ERETAA */ - case 3: /* ERETAB */ - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if (rn !=3D 0x1f || op4 !=3D 0x1f) { - goto do_unallocated; - } - /* The FGT trap takes precedence over an auth trap. */ - if (s->fgt_eret) { - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), = 2); - return; - } - dst =3D tcg_temp_new_i64(); - tcg_gen_ld_i64(dst, cpu_env, - offsetof(CPUARMState, elr_el[s->current_el])); - if (s->pauth_active) { - modifier =3D cpu_X[31]; - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, dst, modifier); - } else { - gen_helper_autib(dst, cpu_env, dst, modifier); - } - } - break; - - default: - goto do_unallocated; - } - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_start(); - } - - gen_helper_exception_return(cpu_env, dst); - /* Must exit loop to check un-masked IRQs */ - s->base.is_jmp =3D DISAS_EXIT; - return; - - case 5: /* DRPS */ - if (op3 !=3D 0 || op4 !=3D 0 || rn !=3D 0x1f) { - goto do_unallocated; - } else { - unallocated_encoding(s); - } - return; - - default: - do_unallocated: - unallocated_encoding(s); - return; - } -} - /* Branches, exception generating and system instructions */ static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { @@ -2427,9 +2377,6 @@ static void disas_b_exc_sys(DisasContext *s, uint32_t= insn) disas_exc(s, insn); } break; - case 0x6b: /* Unconditional branch (register) */ - disas_uncond_b_reg(s, insn); - break; default: unallocated_encoding(s); break; --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414346; cv=none; d=zohomail.com; s=zohoarc; b=UQzvQVeSQNnX++bJ0mjE9L7RSXn3yYOb9SfqObBNuahsBaIg2L6/Km2kKuJssVfVS7NjpuavaHhHyIXFLQ8qfmV+pdrMv2uLHt4f55NONV0uglWCkfNR7WuQuOM8K6Vwl1jO/eb1/s7hoSOSXEsACKVTKmVzwWLjBQxx/QdqO0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414346; h=Content-Transfer-Encoding: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=DfLkJ/KKotr8qkh9BlAVe/zewDqYjcmGwxDXPduCDv0=; b=m5zScAyjDR7P2+yiEW29ZvkNvz4LMB/dsdAFRO1MiaMZGOfTkmYI/rhby4Th4qVLWXcEY409AM4SIeVC+u5V4k1PZWmI01kTv0iU6/TLMFN47pRT2Zrs0wyEsxz/DLffL/ZtO0/UxZPmWugWls9UsVuoUTUTuHaon/2GFGGevEU= 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 1684414346032938.193112642679; Thu, 18 May 2023 05:52:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6d-0004PP-HP; Thu, 18 May 2023 08:51:43 -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 1pzd6Q-0004Bn-4M for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:30 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6K-00082G-RI for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:28 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f42c865534so19289425e9.2 for ; Thu, 18 May 2023 05:51:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414281; x=1687006281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DfLkJ/KKotr8qkh9BlAVe/zewDqYjcmGwxDXPduCDv0=; b=Jtwul7lNYZy+w/SdrVmtkS6d6o4TkzMxiMOu83VckjPo/s80Mv6tRxCJw0vRZPew/h 1+a4CJ2RnMwJYozxmu52V4VcYEEAxTD+xbbfnhyFEIhLoDy9qlQNDehSRbgkkUVjrZ9+ kxUU8MAPzKcWTbhs0MCjsXDojUMOMFAYTfTMgRfF9Ds0D6vSwsd4xPFl9+H2FspSodkl 8mE0IhqphfNu21d9nCzPTuR6M6ok7q+1jZZNDmw6CFJ431VUV8zvceiWddF0VOpcTQj3 82PWktqbG2CMnq6YTTqUxrhozKXvm8ibd7UCtYobbMi+kp57u8KUq/Vt0G+m631hlOli nzww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414281; x=1687006281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DfLkJ/KKotr8qkh9BlAVe/zewDqYjcmGwxDXPduCDv0=; b=AUnNTTTzW+LqjfpBei4oZmqHoLqXeThoODKEmuaITisVm5aVtX0ERYJNv+Ud/+OGF/ m7znugUZwA65Cavjb62jmd8e1P0x9xWzi5QqKqprnDhXD9j30wjrrokCYU1TxSfe2+iO skxF33tN0sCRg78aJhuseWltTDtUkepq/Ldarst2sCdmuCUWp+5gFpdfK/H3ZjGNRFi0 Y2GuVbMZAFMtK09TTSdUopsVvx0UJts/zXEqo095Xo8sK2wrQiWHsPEB7FlLRvFQwPda r3hw70pH7npLHjIp9YTtB2d24LNjDT3l4we9BBzYGFh3Eq7ZISoNU59plDsixO7UFTYX /qLw== X-Gm-Message-State: AC+VfDz8D2HMsU8+FYj1Zs5r5FoGtlPqzeb8lsVkZMIiAa7KUtliRJAP CwQUmlWA4N+zeBTDmMH6pa/5p1a5Qj4UFGGUSd4= X-Google-Smtp-Source: ACHHUZ6gZCcGXx3d7NG0xuOh+t62ZmlrRXXdv6Zqstf93x6EUcuz/GR/T45W5CvumR1JcojXeaCqCQ== X-Received: by 2002:a05:600c:215:b0:3f4:27db:d with SMTP id 21-20020a05600c021500b003f427db000dmr1313529wmi.17.1684414281149; Thu, 18 May 2023 05:51:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/29] target/arm: Saturate L2CTLR_EL1 core count field rather than overflowing Date: Thu, 18 May 2023 13:51:05 +0100 Message-Id: <20230518125107.146421-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414347915100001 Content-Type: text/plain; charset="utf-8" The IMPDEF sysreg L2CTLR_EL1 found on the Cortex-A35, A53, A57, A72 and which we (arguably dubiously) also provide in '-cpu max' has a 2 bit field for the number of processors in the cluster. On real hardware this must be sufficient because it can only be configured with up to 4 CPUs in the cluster. However on QEMU if the board code does not explicitly configure the code into clusters with the right CPU count we default to "give the value assuming that all CPUs in the system are in a single cluster", which might be too big to fit in the field. Instead of just overflowing this 2-bit field, saturate to 3 (meaning "4 CPUs", so at least we don't overwrite other fields in the register. It's unlikely that any guest code really cares about the value in this field; at least, if it does it probably also wants the system to be more closely matching real hardware, i.e. not to have more than 4 CPUs. This issue has been present since the L2CTLR was first added in commit 377a44ec8f2fac5b back in 2014. It was only noticed because Coverity complains (CID 1509227) that the shift might overflow 32 bits and inadvertently sign extend into the top half of the 64 bit value. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230512170223.3801643-2-peter.maydell@linaro.org --- target/arm/cortex-regs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/arm/cortex-regs.c b/target/arm/cortex-regs.c index 17708480e75..ae817b08ddf 100644 --- a/target/arm/cortex-regs.c +++ b/target/arm/cortex-regs.c @@ -15,8 +15,15 @@ static uint64_t l2ctlr_read(CPUARMState *env, const ARMC= PRegInfo *ri) { ARMCPU *cpu =3D env_archcpu(env); =20 - /* Number of cores is in [25:24]; otherwise we RAZ */ - return (cpu->core_count - 1) << 24; + /* + * Number of cores is in [25:24]; otherwise we RAZ. + * If the board didn't configure the CPUs into clusters, + * we default to "all CPUs in one cluster", which might be + * more than the 4 that the hardware permits and which is + * all you can report in this two-bit field. Saturate to + * 0b11 (=3D=3D 4 CPUs) rather than overflowing the field. + */ + return MIN(cpu->core_count - 1, 3) << 24; } =20 static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] =3D { --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414484; cv=none; d=zohomail.com; s=zohoarc; b=HibCuLi9gcsFkLNkXXMvnmcPOzAyhGHVtZCOGpVAC9M3EYrUaZi9CUFU2uMrg2G+iM9Ih/uxAFc4ZdkfXvo/+asHLPwvTju9DAmcyRU5aJ1N4JSBk7JQIpS60bCf4QDsf1hJXYp9m1fs28f6XYyI/mvmUE6YnOZlPXAHqIvqllg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414484; h=Content-Type:Content-Transfer-Encoding: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=jCWIoWT3Hd3TR8fGxUvKYcgsnVLN9JfO4nlSuLHIiD0=; b=dRJqvhP9HRgP3RyvYc5ctLVFuqtVC1xYHJXwNblgzfIhxZTcBssFMkdR+H6WWaO2NKIO1ohgl9sb7ce/MHDL5rTuX+rbbR+AabGNS2ZfcEy8PO7FktPReirgQUrR4GoBHnEdoRk3TZGwuLkD3Heh5nWH/bjRW04rf2vp9h46Itw= 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 1684414484309176.42311171127471; Thu, 18 May 2023 05:54:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6Z-0004IP-VJ; Thu, 18 May 2023 08:51:40 -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 1pzd6U-0004E4-11 for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:34 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00082J-Uw for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:33 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f42d937d61so19244045e9.3 for ; Thu, 18 May 2023 05:51:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414281; x=1687006281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jCWIoWT3Hd3TR8fGxUvKYcgsnVLN9JfO4nlSuLHIiD0=; b=IRUibtPNX3glYBL073WskxCsUs4AM63lHDSxn/eAvv+ei4AmEfNOMhPjzt87aMs6MG 0yya7cMwPFt19Wfbl7kCNKzEKrJVJhMJwMIg0rwbeecBbud+9mPuvpnmIbWtrQs6NxDQ JG1ERU0DYeUft6iH+gbcT1uCzTEhHu0G7lDCF1pQjA7iAGdR6r2SIUJMR1A1MNNjtLXq dV2BHL2IyBCuzMcBK3IyU/YmWyaWVBqRD4hbd3+YdEtXnBt2O8FhrV14tOr335a5Ex3t f8qyx1JLaaAh4E0cGT0DeZyf16owjYewdcMKwk/FwiCJx1sDat/9mnXp4nb0xgfmN5L3 pZUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414281; x=1687006281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jCWIoWT3Hd3TR8fGxUvKYcgsnVLN9JfO4nlSuLHIiD0=; b=XyhSLP/YTtCO5U+Flri/rNtjOyYAyFV1vW0JGXo2aA/RNIRVxIV3kNc+RPz7wATKLr Tu+qZE7qq5k8pvAR0XFfzRj3jk4hl7fAe1B92dfF7Byu004V4VkStYuhReOqLTAQNK/L 8pP/lRG+jH2Ov7YdMCe4CWxIvWhe22ixYT436pYLhEbI8iDmuLEwxDLgIFVs8CH2gnql 0xUd9CyByfQjl0qiS57pGnQb1v0cEhy1qmEoK3DMnOONPsznKeTGIr1x00roROgZrtCh UA6vZHWS23y4gvvP6b6wZV1oT55b6RyWFEZuQKMUe2ixKvoZWimM+gEZFlTjYlRMGBDs Xeww== X-Gm-Message-State: AC+VfDzYASOUi3Tmpl1VCywcyTThPs11FceM7uGp/bd//nkMdYSIQjho rYgAD7udH0JUYEGkG+H3sLLQ6sq7z3WcGOq20PU= X-Google-Smtp-Source: ACHHUZ4/RTsisPl1zGxGaPWmv2C8EPktsJ98b6UUYR5L5+S50Rh+zAJpwacc3csZXdTwIv5MZcJZ8Q== X-Received: by 2002:a7b:cc84:0:b0:3f5:54f:b1b2 with SMTP id p4-20020a7bcc84000000b003f5054fb1b2mr1517166wma.37.1684414281534; Thu, 18 May 2023 05:51:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/29] hw/arm/vexpress: Avoid trivial memory leak of 'flashalias' Date: Thu, 18 May 2023 13:51:06 +0100 Message-Id: <20230518125107.146421-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414485786100001 In the vexpress board code, we allocate a new MemoryRegion at the top of vexpress_common_init() but only set it up and use it inside the "if (map[VE_NORFLASHALIAS] !=3D -1)" conditional, so we leak it if not. This isn't a very interesting leak as it's a tiny amount of memory once at startup, but it's easy to fix. We could silence Coverity simply by moving the g_new() into the if() block, but this use of g_new(MemoryRegion, 1) is a legacy from when this board model was originally written; we wouldn't do that if we wrote it today. The MemoryRegions are conceptually a part of the board and must not go away until the whole board is done with (at the end of the simulation), so they belong in its state struct. This machine already has a VexpressMachineState struct that extends MachineState, so statically put the MemoryRegions in there instead of dynamically allocating them separately at runtime. Spotted by Coverity (CID 1509083). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20230512170223.3801643-3-peter.maydell@linaro.org --- hw/arm/vexpress.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 34b012b528b..56abadd9b8b 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -173,6 +173,11 @@ struct VexpressMachineClass { =20 struct VexpressMachineState { MachineState parent; + MemoryRegion vram; + MemoryRegion sram; + MemoryRegion flashalias; + MemoryRegion lowram; + MemoryRegion a15sram; bool secure; bool virt; }; @@ -182,7 +187,7 @@ struct VexpressMachineState { #define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15") OBJECT_DECLARE_TYPE(VexpressMachineState, VexpressMachineClass, VEXPRESS_M= ACHINE) =20 -typedef void DBoardInitFn(const VexpressMachineState *machine, +typedef void DBoardInitFn(VexpressMachineState *machine, ram_addr_t ram_size, const char *cpu_type, qemu_irq *pic); @@ -263,14 +268,13 @@ static void init_cpus(MachineState *ms, const char *c= pu_type, } } =20 -static void a9_daughterboard_init(const VexpressMachineState *vms, +static void a9_daughterboard_init(VexpressMachineState *vms, ram_addr_t ram_size, const char *cpu_type, qemu_irq *pic) { MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *lowram =3D g_new(MemoryRegion, 1); ram_addr_t low_ram_size; =20 if (ram_size > 0x40000000) { @@ -287,9 +291,9 @@ static void a9_daughterboard_init(const VexpressMachine= State *vms, * address space should in theory be remappable to various * things including ROM or RAM; we always map the RAM there. */ - memory_region_init_alias(lowram, NULL, "vexpress.lowmem", machine->ram, - 0, low_ram_size); - memory_region_add_subregion(sysmem, 0x0, lowram); + memory_region_init_alias(&vms->lowram, NULL, "vexpress.lowmem", + machine->ram, 0, low_ram_size); + memory_region_add_subregion(sysmem, 0x0, &vms->lowram); memory_region_add_subregion(sysmem, 0x60000000, machine->ram); =20 /* 0x1e000000 A9MPCore (SCU) private memory region */ @@ -348,14 +352,13 @@ static VEDBoardInfo a9_daughterboard =3D { .init =3D a9_daughterboard_init, }; =20 -static void a15_daughterboard_init(const VexpressMachineState *vms, +static void a15_daughterboard_init(VexpressMachineState *vms, ram_addr_t ram_size, const char *cpu_type, qemu_irq *pic) { MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 { /* We have to use a separate 64 bit variable here to avoid the gcc @@ -386,9 +389,9 @@ static void a15_daughterboard_init(const VexpressMachin= eState *vms, /* 0x2b060000: SP805 watchdog: not modelled */ /* 0x2b0a0000: PL341 dynamic memory controller: not modelled */ /* 0x2e000000: system SRAM */ - memory_region_init_ram(sram, NULL, "vexpress.a15sram", 0x10000, + memory_region_init_ram(&vms->a15sram, NULL, "vexpress.a15sram", 0x1000= 0, &error_fatal); - memory_region_add_subregion(sysmem, 0x2e000000, sram); + memory_region_add_subregion(sysmem, 0x2e000000, &vms->a15sram); =20 /* 0x7ffb0000: DMA330 DMA controller: not modelled */ /* 0x7ffd0000: PL354 static memory controller: not modelled */ @@ -547,10 +550,6 @@ static void vexpress_common_init(MachineState *machine) I2CBus *i2c; ram_addr_t vram_size, sram_size; MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *vram =3D g_new(MemoryRegion, 1); - MemoryRegion *sram =3D g_new(MemoryRegion, 1); - MemoryRegion *flashalias =3D g_new(MemoryRegion, 1); - MemoryRegion *flash0mem; const hwaddr *map =3D daughterboard->motherboard_map; int i; =20 @@ -662,24 +661,25 @@ static void vexpress_common_init(MachineState *machin= e) =20 if (map[VE_NORFLASHALIAS] !=3D -1) { /* Map flash 0 as an alias into low memory */ + MemoryRegion *flash0mem; flash0mem =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pflash0), 0); - memory_region_init_alias(flashalias, NULL, "vexpress.flashalias", + memory_region_init_alias(&vms->flashalias, NULL, "vexpress.flashal= ias", flash0mem, 0, VEXPRESS_FLASH_SIZE); - memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], flashal= ias); + memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], &vms->f= lashalias); } =20 dinfo =3D drive_get(IF_PFLASH, 0, 1); ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo); =20 sram_size =3D 0x2000000; - memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size, + memory_region_init_ram(&vms->sram, NULL, "vexpress.sram", sram_size, &error_fatal); - memory_region_add_subregion(sysmem, map[VE_SRAM], sram); + memory_region_add_subregion(sysmem, map[VE_SRAM], &vms->sram); =20 vram_size =3D 0x800000; - memory_region_init_ram(vram, NULL, "vexpress.vram", vram_size, + memory_region_init_ram(&vms->vram, NULL, "vexpress.vram", vram_size, &error_fatal); - memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram); + memory_region_add_subregion(sysmem, map[VE_VIDEORAM], &vms->vram); =20 /* 0x4e000000 LAN9118 Ethernet */ if (nd_table[0].used) { --=20 2.34.1 From nobody Sat May 18 14:25:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684414335; cv=none; d=zohomail.com; s=zohoarc; b=nKtWH2sSHSp3AEW0WfvovU3CuaQR1+n/cQSUGeXRkIjoBV92kU+8y6RUjfNHETMG/dpP8fYhN8gLwtKzBUunHfa4Y+6PDZav0vJvf99ZQ5Yvg1TpLO6zsQ8OI/BX9wxR21Skoi7YahH0vUibhizxNawA722ZDH+CXmGx/c16FeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684414335; h=Content-Transfer-Encoding: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=pHx/qDMr99009RmTPyKS5C1hjjUNzbGI5QhnCleSJHE=; b=QJi+yladXGQvGJhWJ2QDRKKJeifVU3iRDv8o2hK6praB7fg1KudPZ+LEZn1gCcfbH9ekDiWRTIldk/IHGXA0YqopftSG3YzmNEoW0liukvz8IpVLW2avAV9oHk2b3yeoNzCXvTNtxcMyB6Ry2v/sagG6izbWa6DDM+BcZjPiN2s= 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 1684414335618662.2414142453285; Thu, 18 May 2023 05:52:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzd6b-0004K1-D9; Thu, 18 May 2023 08:51:41 -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 1pzd6X-0004I3-Op for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:37 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzd6N-00082j-Vj for qemu-devel@nongnu.org; Thu, 18 May 2023 08:51:37 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f42ba32e24so12946835e9.3 for ; Thu, 18 May 2023 05:51:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z21-20020a1c4c15000000b003f42d2f4531sm5201321wmf.48.2023.05.18.05.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 05:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684414282; x=1687006282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pHx/qDMr99009RmTPyKS5C1hjjUNzbGI5QhnCleSJHE=; b=BGBWoasgAU0gIcH/a5lo811QZntbcd6zpMkG2kJS8cininddc4nA5yikXyvEAXc1AD awMn31bVmNcFj6YcoIIe11S/e5aFfTbQMQKBRCIHV1y/s3zVSIBXrwGWDlMDD9VKSbIR yHZI7bD2HanfjPPlJCxF/SwEhgODDV1IWW5i/9PFAEKs3/JyhON5X/s0gSftdr9bbH5e KI/Lh26b91ZJttqy1HSIaFC95Vmi8NdYDiE8n3YOKqref4rT4SScSXgmuofKIIJ0w9l7 UTP61vD3JEh7L1/sFvW8ijT+Jk3/lOy+M/89590th/VnWGcMMZFOdHxdpj85vCy90kFv lQzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684414282; x=1687006282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pHx/qDMr99009RmTPyKS5C1hjjUNzbGI5QhnCleSJHE=; b=DcCFYP+oU8q+2jQaU9xuw61PO8yGBTSwU8iamNfUydFnY/lh7QIBYJFEo0qE/9fKiK ZjZ2paHCSgtjDgjXy41N052F+IynM7dfBqCb0lFUoSp/uGVK3FRnUdpku6/IEpxWcatH gdraQ48uQHqsohaAtSbxEW2Hqg8uR+Ho65135ZxuTsyenibW6ythDTmbcIZKSyZcVNO/ nzT5eR/SK0++BXTwl4vx6lnEZmugIsbZkhPEFIxNOPZ6EoiTf1LhMv8F+Zr1xkT4pAv3 pl1C99mQt7ZntDqmNdUERglVkAnSLnJe8dIBc69hP0bTkk4fNn2960uR/dLzqUPZrsmW eg3w== X-Gm-Message-State: AC+VfDz8RTDimMbbXzbGvwjDtMd6XnauOqtnLI7JxROvKBaXC4QX5Hv/ ioMGGVJXhi6sR6Q7rNCkpFGhbOoReU0s9OTujUA= X-Google-Smtp-Source: ACHHUZ7VXOul+nMYdizgeG/dGx33k8KQ7BBkmUhsvDaI14wD1k5d2tf45V96iM6YnxC9sa1ffncJHw== X-Received: by 2002:a05:600c:2288:b0:3f4:3562:f799 with SMTP id 8-20020a05600c228800b003f43562f799mr1385553wmf.28.1684414282087; Thu, 18 May 2023 05:51:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/29] docs: Convert u2f.txt to rST Date: Thu, 18 May 2023 13:51:07 +0100 Message-Id: <20230518125107.146421-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230518125107.146421-1-peter.maydell@linaro.org> References: <20230518125107.146421-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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 @linaro.org) X-ZM-MESSAGEID: 1684414337767100001 Content-Type: text/plain; charset="utf-8" Convert the u2f.txt file to rST, and place it in the right place in our manual layout. The old text didn't fit very well into our manual style, so the new version ends up looking like a rewrite, although some of the original text is preserved: * the 'building' section of the old file is removed, since we generally assume that users have already built QEMU * some rather verbose text has been cut back * document the passthrough device first, on the assumption that's most likely to be of interest to users * cut back on the duplication of text between sections * format example command lines etc with rST As it's a short document it seemed simplest to do this all in one go rather than try to do a minimal syntactic conversion and then clean up the wording and layout. Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Message-id: 20230421163734.1152076-1-peter.maydell@linaro.org --- docs/system/device-emulation.rst | 1 + docs/system/devices/usb-u2f.rst | 93 ++++++++++++++++++++++++++ docs/system/devices/usb.rst | 2 +- docs/u2f.txt | 110 ------------------------------- 4 files changed, 95 insertions(+), 111 deletions(-) create mode 100644 docs/system/devices/usb-u2f.rst delete mode 100644 docs/u2f.txt diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulatio= n.rst index c1b1934e3d3..8d4a1821fa7 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -93,4 +93,5 @@ Emulated Devices devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst + devices/usb-u2f.rst devices/igb.rst diff --git a/docs/system/devices/usb-u2f.rst b/docs/system/devices/usb-u2f.= rst new file mode 100644 index 00000000000..4f57d5c8c34 --- /dev/null +++ b/docs/system/devices/usb-u2f.rst @@ -0,0 +1,93 @@ +Universal Second Factor (U2F) USB Key Device +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +U2F is an open authentication standard that enables relying parties +exposed to the internet to offer a strong second factor option for end +user authentication. + +The second factor is provided by a device implementing the U2F +protocol. In case of a USB U2F security key, it is a USB HID device +that implements the U2F protocol. + +QEMU supports both pass-through of a host U2F key device to a VM, +and software emulation of a U2F key. + +``u2f-passthru`` +---------------- + +The ``u2f-passthru`` device allows you to connect a real hardware +U2F key on your host to a guest VM. All requests made from the guest +are passed through to the physical security key connected to the +host machine and vice versa. + +In addition, the dedicated pass-through allows you to share a single +U2F security key with several guest VMs, which is not possible with a +simple host device assignment pass-through. + +You can specify the host U2F key to use with the ``hidraw`` +option, which takes the host path to a Linux ``/dev/hidrawN`` device: + +.. parsed-literal:: + |qemu_system| -usb -device u2f-passthru,hidraw=3D/dev/hidraw0 + +If you don't specify the device, the ``u2f-passthru`` device will +autoscan to take the first U2F device it finds on the host (this +requires a working libudev): + +.. parsed-literal:: + |qemu_system| -usb -device u2f-passthru + +``u2f-emulated`` +---------------- + +``u2f-emulated`` is a completely software emulated U2F device. +It uses `libu2f-emu `__ +for the U2F key emulation. libu2f-emu +provides a complete implementation of the U2F protocol device part for +all specified transports given by the FIDO Alliance. + +To work, an emulated U2F device must have four elements: + + * ec x509 certificate + * ec private key + * counter (four bytes value) + * 48 bytes of entropy (random bits) + +To use this type of device, these have to be configured, and these +four elements must be passed one way or another. + +Assuming that you have a working libu2f-emu installed on the host, +there are three possible ways to configure the ``u2f-emulated`` device: + + * ephemeral + * setup directory + * manual + +Ephemeral is the simplest way to configure; it lets the device generate +all the elements it needs for a single use of the lifetime of the device. +It is the default if you do not pass any other options to the device. + +.. parsed-literal:: + |qemu_system| -usb -device u2f-emulated + +You can pass the device the path of a setup directory on the host +using the ``dir`` option; the directory must contain these four files: + + * ``certificate.pem``: ec x509 certificate + * ``private-key.pem``: ec private key + * ``counter``: counter value + * ``entropy``: 48 bytes of entropy + +.. parsed-literal:: + |qemu_system| -usb -device u2f-emulated,dir=3D$dir + +You can also manually pass the device the paths to each of these files, +if you don't want them all to be in the same directory, using the options + + * ``cert`` + * ``priv`` + * ``counter`` + * ``entropy`` + +.. parsed-literal:: + |qemu_system| -usb -device u2f-emulated,cert=3D$DIR1/$FILE1,priv=3D$DIR= 2/$FILE2,counter=3D$DIR3/$FILE3,entropy=3D$DIR4/$FILE4 diff --git a/docs/system/devices/usb.rst b/docs/system/devices/usb.rst index 74166810731..a6ca7b0c375 100644 --- a/docs/system/devices/usb.rst +++ b/docs/system/devices/usb.rst @@ -207,7 +207,7 @@ option or the ``device_add`` monitor command. Available= devices are: USB audio device =20 ``u2f-{emulated,passthru}`` - Universal Second Factor device + :doc:`usb-u2f` =20 ``canokey`` An Open-source Secure Key implementing FIDO2, OpenPGP, PIV and more. diff --git a/docs/u2f.txt b/docs/u2f.txt deleted file mode 100644 index 7f5813a0b72..00000000000 --- a/docs/u2f.txt +++ /dev/null @@ -1,110 +0,0 @@ -QEMU U2F Key Device Documentation. - -Contents -1. USB U2F key device -2. Building -3. Using u2f-emulated -4. Using u2f-passthru -5. Libu2f-emu - -1. USB U2F key device - -U2F is an open authentication standard that enables relying parties -exposed to the internet to offer a strong second factor option for end -user authentication. - -The standard brings many advantages to both parties, client and server, -allowing to reduce over-reliance on passwords, it increases authentication -security and simplifies passwords. - -The second factor is materialized by a device implementing the U2F -protocol. In case of a USB U2F security key, it is a USB HID device -that implements the U2F protocol. - -In QEMU, the USB U2F key device offers a dedicated support of U2F, allowing -guest USB FIDO/U2F security keys operating in two possible modes: -pass-through and emulated. - -The pass-through mode consists of passing all requests made from the guest -to the physical security key connected to the host machine and vice versa. -In addition, the dedicated pass-through allows to have a U2F security key -shared on several guests which is not possible with a simple host device -assignment pass-through. - -The emulated mode consists of completely emulating the behavior of an -U2F device through software part. Libu2f-emu is used for that. - - -2. Building - -To ensure the build of the u2f-emulated device variant which depends -on libu2f-emu: configuring and building: - - ./configure --enable-u2f && make - -The pass-through mode is built by default on Linux. To take advantage -of the autoscan option it provides, make sure you have a working libudev -installed on the host. - - -3. Using u2f-emulated - -To work, an emulated U2F device must have four elements: - * ec x509 certificate - * ec private key - * counter (four bytes value) - * 48 bytes of entropy (random bits) - -To use this type of device, this one has to be configured, and these -four elements must be passed one way or another. - -Assuming that you have a working libu2f-emu installed on the host. -There are three possible ways of configurations: - * ephemeral - * setup directory - * manual - -Ephemeral is the simplest way to configure, it lets the device generate -all the elements it needs for a single use of the lifetime of the device. - - qemu -usb -device u2f-emulated - -Setup directory allows to configure the device from a directory containing -four files: - * certificate.pem: ec x509 certificate - * private-key.pem: ec private key - * counter: counter value - * entropy: 48 bytes of entropy - - qemu -usb -device u2f-emulated,dir=3D$dir - -Manual allows to configure the device more finely by specifying each -of the elements necessary for the device: - * cert - * priv - * counter - * entropy - - qemu -usb -device u2f-emulated,cert=3D$DIR1/$FILE1,priv=3D$DIR2/$FILE2= ,counter=3D$DIR3/$FILE3,entropy=3D$DIR4/$FILE4 - - -4. Using u2f-passthru - -On the host specify the u2f-passthru device with a suitable hidraw: - - qemu -usb -device u2f-passthru,hidraw=3D/dev/hidraw0 - -Alternately, the u2f-passthru device can autoscan to take the first -U2F device it finds on the host (this requires a working libudev): - - qemu -usb -device u2f-passthru - - -5. Libu2f-emu - -The u2f-emulated device uses libu2f-emu for the U2F key emulation. Libu2f-= emu -implements completely the U2F protocol device part for all specified -transport given by the FIDO Alliance. - -For more information about libu2f-emu see this page: -https://github.com/MattGorko/libu2f-emu. --=20 2.34.1