linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Oliver Upton <oliver.upton@linux.dev>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Joey Gouly <joey.gouly@arm.com>,
	Christoffer Dall <cdall@cs.columbia.edu>,
	KVM <kvm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: Re: linux-next: build failure after merge of the kvm-arm tree
Date: Thu, 22 Feb 2024 14:31:38 +0000	[thread overview]
Message-ID: <87frxka7ud.wl-maz@kernel.org> (raw)
In-Reply-To: <b9d9a871-ba64-4c13-a186-0c60adc8d245@redhat.com>

On Thu, 22 Feb 2024 13:11:59 +0000,
Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 2/22/24 12:40, Stephen Rothwell wrote:
> >> This fails because https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?id=fdd867fe9b32
> >> added new fields to that register (ID_AA64DFR1_EL1)
> >> 
> >> and commit b80b701d5a6 ("KVM: arm64: Snapshot all non-zero RES0/RES1 sysreg fields for later checking")
> >> took a snapshot of the fields, so the RES0 (reserved 0) bits don't match anymore.
> >> 
> >> Not sure how to resolve it in the git branches though.
> > 
> > Thanks.  I will apply this patch to the merge of the kvm-arm tree from
> > tomorrow (and at the end of today's tree).
> 
> Marc, Oliver, can you get a topic branch from Catalin and friends for
> this sysreg patch, and apply the fixup directly to the kvm-arm branch
> in the merge commit?
> 
> Not _necessary_, as I can always ask Linus to do the fixup, but
> generally he prefers to have this sorted out by the maintainers if it
> is detected by linux-next.

I think that's not the correct thing to do at this time. I should have
timed the introduction of these checks a bit later, after the merge
window.

But more to the point, the proposed patch is also not the best thing
to merge, because it hides that there is a discrepancy between what
the architecture describes, and what KVM knows. I really want to know
about it, or it will be yet another bug that we wont detect easily.
Specially for ID_AA64DFR*_EL1 which are a bloody mine-field.

So I'd rather we make the check optional, and we'll play catch up for
a bit longer. Something like the patch below.

Oliver, do you mind queuing this ASAP (also pushed out to my dev
branch)?

Thanks,

	M.

From 85d861a6ca055c7681c826c580e7c90d74c26ac5 Mon Sep 17 00:00:00 2001
From: Marc Zyngier <maz@kernel.org>
Date: Thu, 22 Feb 2024 14:12:09 +0000
Subject: [PATCH] KVM: arm64: Make build-time check of RES0/RES1 bits optional

In order to ease the transition towards a state of absolute
paranoia where all RES0/RES1 bits gets checked against what
KVM know of them, make the checks optional and garded by a
config symbol (CONFIG_KVM_ARM64_RES_BITS_PARANOIA) default to n.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/Kconfig          | 11 +++++++++++
 arch/arm64/kvm/check-res-bits.h |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 5c2a672c06a8..fa9389270cfe 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -67,4 +67,15 @@ config PROTECTED_NVHE_STACKTRACE
 
 	  If unsure, or not using protected nVHE (pKVM), say N.
 
+config KVM_ARM64_RES_BITS_PARANOIA
+	bool "Build-time check of RES0/RES1 bits"
+	depends on KVM
+	default n
+	help
+	  Say Y here to validate that KVM's knowledge of most system
+	  registers' RES0/RES1 bits matches when the rest of the kernel
+	  defines. Expect the build to fail badly if you enable this.
+
+	  Just say N.
+
 endif # VIRTUALIZATION
diff --git a/arch/arm64/kvm/check-res-bits.h b/arch/arm64/kvm/check-res-bits.h
index 967b5d171d53..2d98e60efc3c 100644
--- a/arch/arm64/kvm/check-res-bits.h
+++ b/arch/arm64/kvm/check-res-bits.h
@@ -21,6 +21,8 @@
  */
 static inline void check_res_bits(void)
 {
+#ifdef CONFIG_KVM_ARM64_RES_BITS_PARANOIA
+
 	BUILD_BUG_ON(OSDTRRX_EL1_RES0		!= (GENMASK_ULL(63, 32)));
 	BUILD_BUG_ON(MDCCINT_EL1_RES0		!= (GENMASK_ULL(63, 31) | GENMASK_ULL(28, 0)));
 	BUILD_BUG_ON(MDSCR_EL1_RES0		!= (GENMASK_ULL(63, 36) | GENMASK_ULL(28, 28) | GENMASK_ULL(25, 24) | GENMASK_ULL(20, 20) | GENMASK_ULL(18, 16) | GENMASK_ULL(11, 7) | GENMASK_ULL(5, 1)));
@@ -118,4 +120,6 @@ static inline void check_res_bits(void)
 	BUILD_BUG_ON(TRBMAR_EL1_RES0		!= (GENMASK_ULL(63, 12)));
 	BUILD_BUG_ON(TRBTRG_EL1_RES0		!= (GENMASK_ULL(63, 32)));
 	BUILD_BUG_ON(TRBIDR_EL1_RES0		!= (GENMASK_ULL(63, 12) | GENMASK_ULL(7, 6)));
+
+#endif
 }
-- 
2.39.2


-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2024-02-22 14:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 11:03 linux-next: build failure after merge of the kvm-arm tree Stephen Rothwell
2024-02-22 11:11 ` Joey Gouly
2024-02-22 11:40   ` Stephen Rothwell
2024-02-22 13:11     ` Paolo Bonzini
2024-02-22 13:11     ` Paolo Bonzini
2024-02-22 14:31       ` Marc Zyngier [this message]
2024-02-22 18:58         ` Oliver Upton
  -- strict thread matches above, loose matches on Subject: below --
2025-09-23 15:28 Mark Brown
2025-09-23 16:02 ` Will Deacon
2025-09-23 16:44   ` Will Deacon
2025-09-24  2:37     ` Anshuman Khandual
2025-09-24  7:45       ` Will Deacon
2025-07-29  4:22 Stephen Rothwell
2025-07-29 18:05 ` Oliver Upton
2025-03-20  9:32 Stephen Rothwell
2025-03-20 13:35 ` Oliver Upton
2025-03-06  5:46 Stephen Rothwell
2025-03-06  9:56 ` Shameerali Kolothum Thodi
2025-03-07  0:00   ` Marc Zyngier
2025-03-07  0:51     ` Oliver Upton
2023-10-05  1:31 Stephen Rothwell
2023-10-05  1:53 ` Oliver Upton
2022-05-05 10:10 Stephen Rothwell
2022-05-05 10:11 ` Stephen Rothwell
2022-05-05 11:27   ` Marc Zyngier
2016-09-23  3:31 Stephen Rothwell
2016-09-23  8:43 ` Marc Zyngier
2014-09-22  4:06 Stephen Rothwell
2014-09-22  5:07 ` Eric Auger
2014-09-22  5:31   ` Eric Auger
     [not found] ` <CAEDV+g+qVgG+=1Q7gBCPs8oAjK8rpzpoQ2cPMF0hi5Q1M3Nckw@mail.gmail.com>
2014-09-22 21:26   ` Paolo Bonzini
2014-09-24  6:50 ` Stephen Rothwell
2014-09-24  7:06   ` Christoffer Dall
2014-09-24 10:05     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frxka7ud.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=cdall@cs.columbia.edu \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).