Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Steffen Eiden <seiden@linux.ibm.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oupton@kernel.org>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH 3/3] KVM: arm64: Drop open-coded GIC idreg sanitisation
Date: Tue, 24 Nov 2026 10:50:11 +0000	[thread overview]
Message-ID: <86a4myzeos.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTynhBzhjrFzd514Sycib=1rmh7JqYp0xSPVBvurk6Sm-A@mail.gmail.com>

On Tue, 24 Nov 2026 09:38:00 +0000,
Fuad Tabba <fuad.tabba@linux.dev> wrote:
> 
> Hi Marc,
> 
> On Mon, 23 Nov 2026 19:24:57 +0000, Marc Zyngier <maz@kernel.org> wrote:
> [...]
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> [...]
> > @@ -5874,51 +5874,6 @@ static int kvm_vm_finalize_sys_regs(struct kvm *kvm)
> [...]
> > -                 * On GICv5 hardware that supports FEAT_GCIE_LEGACY we can run
> > -                 * both GICv3- and GICv5-based guests. Therefore, we initially
> > -                 * present both ID_AA64PFR0.GIC and ID_AA64PFR2.GCIE as IMP to
> > -                 * reflect that userspace can create EITHER a vGICv3 or a
> > -                 * vGICv5. This is an architecturally invalid combination, of
> > -                 * course. Once an in-kernel GIC is created, the sysreg state is
> > -                 * updated to reflect the actual, valid configuration.
> 
> nit: This comment is the only place that explains why, on a
> FEAT_GCIE_LEGACY host, a VM's ID registers can show both GIC and GCIE
> as IMP before the VM first runs. sanitise_id_aa64pfr0_el1() and
> sanitise_id_aa64pfr2_el1() still set both at reset. Is it worth having
> a short version of it next to the tables patch 2 adds?

I don't think that's the correct place. If anything, such comment
should be in the reset code, not in the sanitisation code, which
actually generates the architecturally compliant view.

> 
> [...]
> > diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
> [...]
> > @@ -180,7 +180,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
> >           * We've now created the GIC. Update the system register state
> >           * to accurately reflect what we've created.
> >           */
> > -        kvm_vgic_finalize_idregs(kvm);
> > +        kvm_idregs_enforce_dependencies(kvm);
> 
> This now also applies the S1P[IO]E dependencies when the vGIC is
> created, at a point where userspace can still write the ID registers.
> Was that intended? If this clears S1PIE or S1POE, the first KVM_RUN
> doesn't restore it, so the final ID_AA64MMFR3_EL1 can change with the
> order in which userspace writes the ID registers and creates the vGIC.
> If that's the intent, should it say so in the commit message?

The commit message has no influence on the behaviour of the kernel.
However, I want to know whether this change is an acceptable behaviour
or not *from an ABI perspective*. We have several options:

(1) delay all idreg enforcement to the same (late) point

(2) keep things as currently done, meaning that the GIC fields are
    special and sanitised at a different time

(3) say that idregs can change at any point if you change the
    configuration of the system, such as creating a GIC

I'd be tempted to go with either (1) or (3). (2) feels like a total
bodge.

	M.

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


  reply	other threads:[~2026-11-24 12:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 19:24 [PATCH 0/3] KVM: arm64: Convert GIC idreg sanitisation to the confic framework Marc Zyngier
2026-11-23 19:24 ` [PATCH 1/3] KVM: arm64: Add enum support to idreg sanitisation Marc Zyngier
2026-11-24  8:35   ` Fuad Tabba
2026-11-23 19:24 ` [PATCH 2/3] KVM: arm64: Add GIC idregs sanitisation to common framework Marc Zyngier
2026-11-24  9:05   ` Fuad Tabba
2026-11-23 19:24 ` [PATCH 3/3] KVM: arm64: Drop open-coded GIC idreg sanitisation Marc Zyngier
2026-11-24  9:38   ` Fuad Tabba
2026-11-24 10:50     ` Marc Zyngier [this message]
2026-11-24 12:02       ` Fuad Tabba
2026-11-24  9:44 ` [PATCH 0/3] KVM: arm64: Convert GIC idreg sanitisation to the confic framework Fuad Tabba

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=86a4myzeos.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /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