From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79AD7C433EF for ; Tue, 26 Apr 2022 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SpV56G5Hi3N4dydU5xO8CADnAtXqm00r2dLx8h8X/QI=; b=MRLIvoYlnsFrWm PqBJbkGRv/lrGkvw8riKtuOWcgnpQ4AIhWWYlHrc8iQPZedZ7Wyl2CKfXBRGeF/FJNqNrI42qMjsi oHZngBPUl8ade7W1E4hpqshd3KrfMhtnHIq0auJBFiGL+yQW7qgXVBdPtPFxZy39RpmmuEPK4Vi6d AnZ405jS0KONmuXHg+J+638sFmxJzsiUu6y8PcL3Ua4PE7FrTvtKYtxzEHwR6WR4hTo9/QB+umNe5 Je8yBHHl5wdlbr4mqnOyGaO7JSG1ZsDODrnyNrpmGs6o1Kgei+jehq0L5kQuRor9B+lLpCG/c77BM uQYyvZq8KMQSFi3RcQQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njPmS-00Fee1-Lg; Tue, 26 Apr 2022 18:19:20 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njPls-00FePi-Tg for linux-arm-kernel@lists.infradead.org; Tue, 26 Apr 2022 18:18:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 824DAB821B2; Tue, 26 Apr 2022 18:18:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BB87C385A4; Tue, 26 Apr 2022 18:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650997121; bh=FlRwocIwaX6bmOOtGl8IhP/u9fmw41o8nWbkAfdgbuM=; h=From:To:Cc:Subject:Date:From; b=so15WDBm4EdJLOlTPsOrewpF7omLEU3/4wrmWDdIWA9dzlvuIAMNLcVkWijOYU+GT DerUsEc3bb/qB1rY9vpbXp/Q2i2clu7+iIS+OHqmvq+xbKXIMDqmswFg2ocXl3eb4/ 4Biy+Si7PMomvXrPFIpz3hAL1X69oWvVZGX9w5X+yav2UL2dLsJGPNYluRLRD6+D1W RjriD2IngAKlncXcarpWghu9po6LBkyPMZDAuEd9EEHFp3o6XnTwva/gHCjE1erio2 kUa2upWYin+K9uPR2un+SseWar1ez+DMTXr/PAI54O0U7X6ksLx4QAozeO/FFudBAS vS5/zNDztmp1Q== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Mark Rutland , Marc Zyngier , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v5 00/12] arm64: Automatic system register definition generation Date: Tue, 26 Apr 2022 19:16:52 +0100 Message-Id: <20220426181704.2583494-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6333; h=from:subject; bh=FlRwocIwaX6bmOOtGl8IhP/u9fmw41o8nWbkAfdgbuM=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiaDcVZkzb9HDVMtsAIcqUStMwBaNRgcTNQcpo5ys5 QGfWG2GJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYmg3FQAKCRAk1otyXVSH0HVzB/ 9AL/kM9i9stN8dv9rqeKNFo9xEotylsKSQ+u/4oRTza/W8kGy79t/v2tfSb8ZwnvkubsVc9RBdKhlS 6RQdROHibpB0qdnGNQDEpgda1J1vx8rqeuH7ner0ofCae8M6asaX+MBhyWgv3oLGgmhKPHgV4kTPtC b4SrWLSdxWYFDUudhxNwx9MkT/pzhWs1MnvkNOzOvtFoUMXZJcAEfXWkKenBSdUsNUP0AMqF+5/HDG jl79SbgR0MXUTuIhwawoe8oD0ND/CT1PwWyv6dHJOjtLbgffyp0dxzIsjcxoPPXARnRRsdttiXvxkw xhYybzlO49jEEIKB35H5U5EH/1Xp1H X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220426_111845_352986_939DFCC2 X-CRM114-Status: GOOD ( 24.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The arm64 kernel requires some metadata for each system register it may need to access. Currently we have: * A SYS_ definition which sorresponds to a sys_reg() macro. This is used both to look up a sysreg by encoding (e.g. in KVM), and also to generate code to access a sysreg where the assembler is unaware of the specific sysreg encoding. Where assemblers support the S3__C_C_ syntax for system registers, we could use this rather than manually assembling the instructions. However, we don't have consistent definitions for these and we currently still need to handle toolchains that lack this feature. * A set of __SHIFT and __MASK definitions, which can be used to extract fields from the register, or to construct a register from a set of fields. These do not follow the convention used by , and the masks are not shifted into place, preventing their use in FIELD_PREP() and FIELD_GET(). We require the SHIFT definitions for inline assembly (and WIDTH definitions would be helpful for UBFX/SBFX), so we cannot only define a shifted MASK. Defining a SHIFT, WIDTH, shifted MASK and unshifted MASK is tedious and error-prone and life is much easier when they can be relied up to exist when writing code. * A set of __ definitions for each enumerated value a field may hold. These are used when identifying the presence of features. Atop of this, other code has to build up metadata at runtime (e.g. the sets of RES0/RES1 bits in a register). This patch series introduces a script which describes registers and the fields within them in a format that is easy to cross reference with the architecture reference manual and uses them to generate the constants we use in a standard format: | #define REG_ID_AA64ISAR0_EL1 S3_0_C0_C6_0 | #define SYS_ID_AA64ISAR0_EL1 sys_reg(3, 0, 0, 6, 0) | #define SYS_ID_AA64ISAR0_EL1_Op0 3 | #define SYS_ID_AA64ISAR0_EL1_Op1 0 | #define SYS_ID_AA64ISAR0_EL1_CRn 0 | #define SYS_ID_AA64ISAR0_EL1_CRm 6 | #define SYS_ID_AA64ISAR0_EL1_Op2 0 | #define ID_AA64ISAR0_EL1_RNDR GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_MASK GENMASK(63, 60) | #define ID_AA64ISAR0_EL1_RNDR_SHIFT 60 | #define ID_AA64ISAR0_EL1_RNDR_WIDTH 4 | #define ID_AA64ISAR0_EL1_RNDR_NI UL(0b0000) | #define ID_AA64ISAR0_EL1_RNDR_IMP UL(0b0001) This should be particularly useful for the ID registers where we will be able to specify just the register and field for more of the bitfield information, simplifying ARM64_FTR_BITS() and providing helpers for use in struct arm64_cpu_capabilities or for hwcaps. For registers which have shared definitions (eg, registers that have versions with identical layouts at multiple ELs) we support defining a shared layout for those registers which is then referenced from the per register definition. At the moment this is only intended to express metadata from the architecture, and does not handle policy imposed by the kernel, such as values exposed to userspace or VMs. In future this could be extended to express such information. This could also be extended to cover more information such as the FTR_SIGNED/FTR_UNSIGNED distinction. There is also currently no support for registers which change layout at runtime, for example based on virtualisation settings - these could be manually handled for the time being, or the script extended. Rather than attempting to convert every register at once the current series converts a few sample registers to provide some concrete examples but allow for easier updating during review of the file format and the script. Handling a register at a time should also make review less taxing so it seems like a sensible approach in general. The generation script was originally written by Mark Rutland and subsequently improved and integrated into the kernel build by me. v5: - Introduce and use SYS_FIELD_PREP() and SYS_FIELD_PREP_ENUM(). - Use helper macros for SCTLR_ELx.TCF as well as TCF0. - Rename sysreg-gen.h to sysreg-defs.h. - Use UL rather than ULL. - Implement a SharedLayout statement, currently as a noop. - Fix checks to ensure regexps only match in the correct block in the script. - Minor stylistic tweaks. v4: - Rebase onto v5.18-rc3. v3: - Rebase onto v5.18-rc1. v2: - Fix issue with building bounds.s in an O= build by renaming the generated header. Mark Brown (11): arm64/sysreg: Introduce helpers for access to sysreg fields arm64/mte: Make TCF0 naming and field values more standard arm64/mte: Make TCF field values and naming more standard arm64/sysreg: Rename SCTLR_EL1_NTWE/TWI to SCTLR_EL1_nTWE/TWI arm64/sysreg: Define bits for previously RES1 fields in SCTLR_EL1 arm64: Update name of ID_AA64ISAR0_EL1_ATOMIC to reflect ARM arm64/sysreg: Standardise ID_AA64ISAR0_EL1 macro names arm64/sysreg: Enable automatic generation of system register definitions arm64/sysreg: Generate definitions for ID_AA64ISAR0_EL1 arm64/sysreg: Generate definitions for TTBRn_EL1 arm64/sysreg: Generate definitions for SCTLR_EL1 Mark Rutland (1): arm64: Add sysreg header generation scripting arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/archrandom.h | 2 +- arch/arm64/include/asm/sysreg.h | 117 +++----- arch/arm64/kernel/cpufeature.c | 70 ++--- arch/arm64/kernel/mte.c | 15 +- .../arm64/kvm/hyp/include/nvhe/fixed_config.h | 28 +- arch/arm64/mm/fault.c | 3 +- arch/arm64/tools/Makefile | 8 +- arch/arm64/tools/gen-sysreg.awk | 267 ++++++++++++++++++ arch/arm64/tools/sysreg | 200 +++++++++++++ 10 files changed, 576 insertions(+), 135 deletions(-) create mode 100755 arch/arm64/tools/gen-sysreg.awk create mode 100644 arch/arm64/tools/sysreg base-commit: b2d229d4ddb17db541098b83524d901257e93845 -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel