[PATCH 3/3] KVM: arm64: Drop open-coded GIC idreg sanitisation

Fuad Tabba fuad.tabba at linux.dev
Tue Nov 24 01:38:00 PST 2026


Hi Marc,

On Mon, 23 Nov 2026 19:24:57 +0000, Marc Zyngier <maz at 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?

[...]
> 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?

Cheers,
/fuad



More information about the linux-arm-kernel mailing list