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 EAABDC52D6D for ; Sat, 3 Aug 2024 09:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=daLFqYQuPQLS+KKuAmOUzM5qUJFwi9XM5RBYTtW6jxM=; b=H/1I2THQV8vsWg15ziVs2lTqXV VYrbi9l47DbMytp26IU2hewMcrNK+oCsFHuIb8n74xoDM1FiL24rFp1OyvfZ1A3eDdnvHZE92i31/ 5mRR9bMPZLscybBKaoBULNU3+az3pkAM0M7Jujwxjx+enfndLZ8lU/w6MUgD699qIti+sqnGZWZi5 Kaa29X4PhKa3oq/hiA10NUnAiEf5eaigijuIrfHkTtO37dlPzDOj22YvIH8MWZ5nuJ1ZPcZg/CucS Jw4ONBj03WCIx35o8viguiPeimS3rATiahKk6jOZtzYM/EkAvY+Xu2iUPCQauEWVUVd1C/kdyVHsM tn/Jd40w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1saBBe-0000000B7w9-1I1F; Sat, 03 Aug 2024 09:36:30 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1saBB9-0000000B7qb-1Cti for linux-arm-kernel@lists.infradead.org; Sat, 03 Aug 2024 09:36:00 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4E1D06202C; Sat, 3 Aug 2024 09:35:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFEB8C116B1; Sat, 3 Aug 2024 09:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722677757; bh=JEbsnrTzSmhOmnx/e5esxkcGV3rSX/GncsC3HN+bUFQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QM+nyj2rOf9eNpv7HTwm4Yvl582CUak/+I/ywihkAhigADTLUmGK3qsrg3uF8Us4q T9yLXq2uDCIwL7Pv0MCAOhngtRrfD9MkmfEWacBXfwJW9UrymMbMp4zQGJnXS2Vqzu ZFAJYky7XnrZ7rBfaYXLSf+E2LvM6d2JWJVc92KWaHOxqu3QOwIToL5Ce/1HFSCq4t cgbQ/quWJmy1EQGKjMI4WT7a+9mVA2bKKVXtkynyv197wWgqq0k+ModGmORY0nMJb6 BrRnR2rYJXBCHjIUePO74SA0IZQt6ZswKVvxHOmNHEW2cOVm/BAumIgH7ohiaG6gbI FSG+KbS1j28zw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1saBB4-000Ymy-Mz; Sat, 03 Aug 2024 10:35:54 +0100 Date: Sat, 03 Aug 2024 10:35:54 +0100 Message-ID: <868qxe0wzp.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: Oliver Upton , James Morse , Suzuki K Poulose , Paolo Bonzini , Shuah Khan , Catalin Marinas , Joey Gouly , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: selftests: arm64: Use generated defines for named system registers In-Reply-To: <20240802-kvm-arm64-get-reg-list-v1-2-3a5bf8f80765@kernel.org> References: <20240802-kvm-arm64-get-reg-list-v1-0-3a5bf8f80765@kernel.org> <20240802-kvm-arm64-get-reg-list-v1-2-3a5bf8f80765@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.3 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: broonie@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, pbonzini@redhat.com, shuah@kernel.org, catalin.marinas@arm.com, joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240803_023559_439000_901A7706 X-CRM114-Status: GOOD ( 28.83 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 02 Aug 2024 22:57:54 +0100, Mark Brown wrote: > > Currently the get-reg-list test uses directly specified numeric values to > define system registers to validate. Since we already have a macro which > allows us to use the generated system register definitions from the main > kernel easily let's update all the registers where we have specified the > name in a comment to just use that macro. This reduces the number of > places where we need to validate the name to number mapping. > > This conversion was done with the sed command: > > sed -i -E 's-ARM64_SYS_REG.*/\* (.*) \*/-KVM_ARM64_SYS_REG(SYS_\1),-' tools/testing/selftests/kvm/aarch64/get-reg-list.c > [Eyes rolling] What I asked about scripting the whole thing, it never occurred to me that you would use the *comments* as a reliable source of information. Do we have anything less reliable than comments in the kernel? The matching must be done from the arch/arm64/tools/sysreg file, because that's the (admittedly dubious) source of truth. We actually trust the encodings because they are reported by the kernel itself. The comment is hand-written, and likely wrong. Also, this hides the horrible truth about existing ABI bugs, see below. > We still have a number of numerically specified registers, some of these > are reserved registers without defined names (eg, unallocated ID registers) > and others don't have kernel macro definitions yet. > > No change in the generated output. > > Suggested-by: Marc Zyngier > Signed-off-by: Mark Brown > --- > tools/testing/selftests/kvm/aarch64/get-reg-list.c | 208 ++++++++++----------- > 1 file changed, 104 insertions(+), 104 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > index a00322970578..4d786c4ab28a 100644 > --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c > +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > @@ -313,14 +313,14 @@ static __u64 base_regs[] = { > KVM_REG_ARM_FW_FEAT_BMAP_REG(0), /* KVM_REG_ARM_STD_BMAP */ > KVM_REG_ARM_FW_FEAT_BMAP_REG(1), /* KVM_REG_ARM_STD_HYP_BMAP */ > KVM_REG_ARM_FW_FEAT_BMAP_REG(2), /* KVM_REG_ARM_VENDOR_HYP_BMAP */ > - ARM64_SYS_REG(3, 3, 14, 3, 1), /* CNTV_CTL_EL0 */ > - ARM64_SYS_REG(3, 3, 14, 3, 2), /* CNTV_CVAL_EL0 */ > + KVM_ARM64_SYS_REG(SYS_CNTV_CTL_EL0), > + KVM_ARM64_SYS_REG(SYS_CNTV_CVAL_EL0), > ARM64_SYS_REG(3, 3, 14, 0, 2), Great. So not only you fail convert a register, but you also ignore the nugget described in arch/arm64/invlude/uapi/asm/kvm.h:267. Sure, having both described hides the crap, as we don't attach any significance to the registers themselves. But that shows how untrustworthy the comments are. > - ARM64_SYS_REG(3, 0, 0, 0, 0), /* MIDR_EL1 */ > - ARM64_SYS_REG(3, 0, 0, 0, 6), /* REVIDR_EL1 */ > - ARM64_SYS_REG(3, 1, 0, 0, 1), /* CLIDR_EL1 */ > - ARM64_SYS_REG(3, 1, 0, 0, 7), /* AIDR_EL1 */ > - ARM64_SYS_REG(3, 3, 0, 0, 1), /* CTR_EL0 */ > + KVM_ARM64_SYS_REG(SYS_MIDR_EL1), > + KVM_ARM64_SYS_REG(SYS_REVIDR_EL1), > + KVM_ARM64_SYS_REG(SYS_CLIDR_EL1), > + KVM_ARM64_SYS_REG(SYS_AIDR_EL1), > + KVM_ARM64_SYS_REG(SYS_CTR_EL0), > ARM64_SYS_REG(2, 0, 0, 0, 4), > ARM64_SYS_REG(2, 0, 0, 0, 5), > ARM64_SYS_REG(2, 0, 0, 0, 6), As far as I can tell, these registers are not unallocated, and they should be named. Thanks, M. -- Without deviation from the norm, progress is not possible.