From patchwork Fri Jan 27 17:54:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 647520 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp960076pvb; Fri, 27 Jan 2023 09:58:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxn8CA0GJLoHIxmwo15EZ1NFfBeQTWDQ0MXiYjASFKtgh12JPIEkDZjU9ATfLW7dAv9hPR X-Received: by 2002:ac8:7c87:0:b0:3ae:bd53:dfd2 with SMTP id y7-20020ac87c87000000b003aebd53dfd2mr51784446qtv.41.1674842280237; Fri, 27 Jan 2023 09:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674842280; cv=none; d=google.com; s=arc-20160816; b=X1p2Y1rnoGhBLp+MZcb6ZtV/CeWeBt4gcDDFifqv67SxN59qIntL1TmEolga2mNydV vLt5Zmy2t4ZiPSOjICsszggHIB8cWYR/QYig2sPs6zQrrPxzlyAm71llhPC7gqYOuKHz /1rhwsogt/recw3iDyRWCZavsNkPXKkeZFwJlX28o1uwyf3fsL9MLjARZokvCCM2AYzD rCVnxGT3e32wpzz6py/U0KIZFuGGqyjuhtTfU/hmz0xay9jFpNuW5oy8iM9nwoScCurS kLRcfRH8bV8U5p8HRw9dHg3GUB3Aqu4XtSeYs2aKfyxSNKCiXmL6NoeohLoD4EVdlddB 85rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=uvuf0K3RKNAPJETXJV9XevZKYErx9RVt5zxuzgDSynQ=; b=toNIFIk1RLYiNxPXwnqTb5nEdkSGlD/GCJzb5Tb+xvfx9PTvDPgzi/crPj++xWPYL6 rdT8cBofruYiHGZYd/omuW+OkCVjqrNvJmrfq+ZV9lmdLOmbD58uJe3yBCL95BmcBhQw pcX3D67xkvCVcLThgw4qwPh0eTJGp7qN/0dnjs1ZGX6fz0NJRvffhbdhe1UGQ3WrLbUz AnbH4IEnifNSWwTGxuZaLtEetib7iIaQgcVyPyGtHhB916usl/KQTAg1ALHj1mw2EJ0M 9L3Ymjg7UK5m6M2j1qCQyO+DEBfILkaXE2eokcfIGY8uiOzmiipz2pUgYOAN8ldeXyth U6aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVWb9Mgn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n22-20020ae9c316000000b0070695f77965si2839230qkg.340.2023.01.27.09.58.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jan 2023 09:58:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVWb9Mgn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLSwo-0000oP-87; Fri, 27 Jan 2023 12:55:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLSwl-0000mr-S6 for qemu-devel@nongnu.org; Fri, 27 Jan 2023 12:55:31 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLSwT-0005yR-9m for qemu-devel@nongnu.org; Fri, 27 Jan 2023 12:55:15 -0500 Received: by mail-wr1-x434.google.com with SMTP id h16so5640615wrz.12 for ; Fri, 27 Jan 2023 09:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=uvuf0K3RKNAPJETXJV9XevZKYErx9RVt5zxuzgDSynQ=; b=rVWb9Mgnv9uPZXJYiAAK+Uy3P8sm4aTdS2P//YzaHxe3p9K0A9vv3KpRnc4Aspfq7z m/m1OXfJNSqAVW3FKHuy6E+YIvY9qD8wtT94tjUfogTORWDhkpTFTIU56oxTJMCCIeoR WpZ/FsjyIVNZWWz8IbJoOCZWIrZE2iLcxgZMa1ds0FWIYosJtRh/BrKjFZn5mVydlq9S 3gMnPEgxAQZi67k20hCzX+dyIFvAmxZVNDwYiis4q9KMS5omlcwn2Xph2XhgtzHM8XW2 IDpGhZNxA1I98qzAtCGytu4KB8vvQiSmibRSwjkwIt9qkvHv2Fl+2IDD6UkdmjVJhv9h qSXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uvuf0K3RKNAPJETXJV9XevZKYErx9RVt5zxuzgDSynQ=; b=oqU86xCJ1L2zMvhTIUFxDs7US71CiTeSBp7rBs7OIie0+/OcobNUdBE1bhJLwICA75 JFyN3suhwT6fqvNRNWGr2UoBracqqPLDDI32gRmwk9j1mt+Qp1fJlBPo/bbwjodZzclO Cvw1n34BfnThlxht/DVo6ektBI1NDTC2n3sERnrTodvKYwBfssnCvtdRycUVsw3D/AGO WtGJcUiteVC2HKjhMwdIYAKzvtB85j9VHnpnH8glZ7dIzGmoSoS2+H4Er3hdl7BPQ5jS ilZbDBMqjcT5MXud4w1gsURFElT8OU5IJUdAy7jqEmoDX/ZBmnuhedaZC50wheI/RYd4 drdg== X-Gm-Message-State: AO0yUKV2zqRIR81DUOvBiCOMHuLZV8kM21BffG/zar3GIcBy6V1mxftd 58UGE2ZA1qGobkzJ2kG1i1W2yzJ7XcQi8eb1 X-Received: by 2002:a5d:4951:0:b0:2bf:d425:11ba with SMTP id r17-20020a5d4951000000b002bfd42511bamr2806451wrs.22.1674842110542; Fri, 27 Jan 2023 09:55:10 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l13-20020adff48d000000b002366e3f1497sm4545089wro.6.2023.01.27.09.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 09:55:09 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 00/23] target/arm: Implement FEAT_FGT fine-grained traps Date: Fri, 27 Jan 2023 17:54:44 +0000 Message-Id: <20230127175507.2895013-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This series implements the FEAT_FGT fine-grained traps architectural feature. The bulk of this is new system registers HFGRTR_EL2, HFGWTR_EL2, HFGITR_EL2, HDFGRTR_EL2, HDFGWTR_EL2, which have bits that enable trapping of system register and system instruction accesses on a fine-grained basis (typically one or a few sysregs at a time). In theory we could implement this with our existing ARMCPRegInfo::accessfn machinery, but we would end up with many many very nearly identical access functions. Instead this series adds a new ARMCPRegInfo::fgt field, which specifies which bit in which FGT register should be checked; this is then tested by code in the access_check_cp_reg helper function. A few bits in HFGITR_EL2 allow trapping of instructions which aren't handled by the ARMCPRegInfo mechanism: ERET and SVC. These we just implement "by hand". FEAT_FGT also adds new MDCR_EL3.TDCC and MDCR_EL2.TDCC bits for trapping the Debug Comms Channel registers; these we implement with a standard accessfn. The first seven patches are various cleanups and bugfixes that I noticed while I was doing the FEAT_FGT work. In particular, we weren't getting the priority of HSTR_EL2 traps right -- these should take priority over UNDEF-at-EL traps but not over UNDEF-at-EL0 traps. The rest of the series is FEAT_FGT itself. thanks -- PMM Peter Maydell (23): target/arm: Name AT_S1E1RP and AT_S1E1WP cpregs correctly target/arm: Correct syndrome for ATS12NSO* at Secure EL1 target/arm: Remove CP_ACCESS_TRAP_UNCATEGORIZED_{EL2,EL3} target/arm: Move do_coproc_insn() syndrome calculation earlier target/arm: All UNDEF-at-EL0 traps take priority over HSTR_EL2 traps target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1 target/arm: Disable HSTR_EL2 traps if EL2 is not enabled target/arm: Define the FEAT_FGT registers target/arm: Implement FGT trapping infrastructure target/arm: Mark up sysregs for HFGRTR bits 0..11 target/arm: Mark up sysregs for HFGRTR bits 12..23 target/arm: Mark up sysregs for HFGRTR bits 24..35 target/arm: Mark up sysregs for HFGRTR bits 36..63 target/arm: Mark up sysregs for HDFGRTR bits 0..11 target/arm: Mark up sysregs for HDFGRTR bits 12..63 target/arm: Mark up sysregs for HFGITR bits 0..11 target/arm: Mark up sysregs for HFGITR bits 12..17 target/arm: Mark up sysregs for HFGITR bits 18..47 target/arm: Mark up sysregs for HFGITR bits 48..63 target/arm: Implement the HFGITR_EL2.ERET trap target/arm: Implement the HFGITR_EL2.SVC_EL0 and SVC_EL1 traps target/arm: Implement MDCR_EL2.TDCC and MDCR_EL3.TDCC traps target/arm: Enable FEAT_FGT on '-cpu max' docs/system/arm/emulation.rst | 1 + target/arm/cpregs.h | 484 +++++++++++++++++++++++++++++++++- target/arm/cpu.h | 18 ++ target/arm/helper.h | 1 + target/arm/internals.h | 20 ++ target/arm/syndrome.h | 10 + target/arm/translate.h | 6 + hw/intc/arm_gicv3_cpuif.c | 2 + target/arm/cpu64.c | 1 + target/arm/debug_helper.c | 46 +++- target/arm/helper.c | 245 ++++++++++++++++- target/arm/op_helper.c | 65 ++++- target/arm/translate-a64.c | 22 +- target/arm/translate.c | 132 ++++++---- 14 files changed, 986 insertions(+), 67 deletions(-)