From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6A8735FF43; Fri, 30 Jan 2026 17:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794002; cv=none; b=Ro6Wb7V5rj9lmnyvj/si608kqAuijEz6Vga8u8GRbJ5UDnx2w+dPp7kIQSvRHY2Val+M0DRDU692mUri40DxfcqaKUfCTeQ2G4HX3y5elYfjz4vEVcoAvROhsA1w1BUgR5ydZ+0aXTokI3oNGuh3xd2P4cB406KIBbPqD3Kvd9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794002; c=relaxed/simple; bh=M/J2fDQm2LgYTOtygveeKcKFKa3ZI9LGFPJPx+f2kn0=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=jXrNi0qaXxUXg2ima/pyyBU4DE8b3lkK5bp8j6NXLbvDM+TvS6/3Q54cW52xHV3B4WHxWtPILDQeEwOwW5PepZ+utw74GMsKGzsio/GoaqY2fqHJ9hkcvi47eA4vOgTd1PRA+GQ6bDhjNqWO22bv57Xl4zZZ7cDZ1//fGxEmGOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jNG9iBZd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jNG9iBZd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DD9DC116C6; Fri, 30 Jan 2026 17:26:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769794002; bh=M/J2fDQm2LgYTOtygveeKcKFKa3ZI9LGFPJPx+f2kn0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jNG9iBZdzYRLsPfcV3qNhestvrsV2JaXANbl6G0erDL29XxcuEuD32xOPeBR823Cu DjMDgBtTXeziu09ExIUwKXSciGbe9zSbLLJX3Mf4XGO04ZKuyQqmPzNqxqpVRI0WKZ Be/fSFhid/omnw0+b0NIk9PwxMxeV5Wyp+f746+IWkpUzOR0VllgV9Wk3KNet1x95J Z1mv2Hl60f6nA3LDuh88q8wThgfTYF5xOXb2/8f415oX+b+/R+J58J/FEUDkZU74WL fpzqhG8uI+AV4yMbsF4Z0D78ry7urDu8IIjGO4l1oCPkGR4q6IA5trR2U5A2iGAIBV u3CetnGjoJ4wg== 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.98.2) (envelope-from ) id 1vlsGV-000000077vO-3lzt; Fri, 30 Jan 2026 17:26:39 +0000 Date: Fri, 30 Jan 2026 17:26:39 +0000 Message-ID: <86zf5v9flc.wl-maz@kernel.org> From: Marc Zyngier To: Sascha Bischoff Cc: "yuzenghui@huawei.com" , Timothy Hayes , Suzuki Poulose , nd , "peter.maydell@linaro.org" , "kvmarm@lists.linux.dev" , "jonathan.cameron@huawei.com" , "linux-arm-kernel@lists.infradead.org" , "kvm@vger.kernel.org" , Joey Gouly , "lpieralisi@kernel.org" , "oliver.upton@linux.dev" Subject: Re: [PATCH v4 11/36] KVM: arm64: gic-v5: Sanitize ID_AA64PFR2_EL1.GCIE In-Reply-To: <6a45dd02fdd2e70e0722dc5b3087ecfb18f01e98.camel@arm.com> References: <20260128175919.3828384-1-sascha.bischoff@arm.com> <20260128175919.3828384-12-sascha.bischoff@arm.com> <861pj7baav.wl-maz@kernel.org> <6a45dd02fdd2e70e0722dc5b3087ecfb18f01e98.camel@arm.com> 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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: Sascha.Bischoff@arm.com, yuzenghui@huawei.com, Timothy.Hayes@arm.com, Suzuki.Poulose@arm.com, nd@arm.com, peter.maydell@linaro.org, kvmarm@lists.linux.dev, jonathan.cameron@huawei.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Joey.Gouly@arm.com, lpieralisi@kernel.org, oliver.upton@linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 30 Jan 2026 17:13:18 +0000, Sascha Bischoff wrote: >=20 > On Fri, 2026-01-30 at 11:38 +0000, Marc Zyngier wrote: > > On Wed, 28 Jan 2026 18:02:09 +0000, > > Sascha Bischoff wrote: > > >=20 > > > Set the guest's view of the GCIE field to IMP when running a GICv5 > > > VM, > > > NI otherwise. Reject any writes to the register that try to do > > > anything but set GCIE to IMP when running a GICv5 VM. > > >=20 > > > As part of this change, we're also required to extend > > > vgic_is_v3_compat() to check for the actual vgic_model. This has > > > one > > > potential issue - if any of the vgic_is_v*() checks are used prior > > > to > > > setting the vgic_model (that is, before kvm_vgic_create) then > > > vgic_model will be set to 0, which can result in a false-positive. > > >=20 > > > Co-authored-by: Timothy Hayes > > > Signed-off-by: Timothy Hayes > > > Signed-off-by: Sascha Bischoff > > > Reviewed-by: Jonathan Cameron > > > --- > > > =C2=A0arch/arm64/kvm/sys_regs.c=C2=A0 | 42 ++++++++++++++++++++++++++= ++++---- > > > ---- > > > =C2=A0arch/arm64/kvm/vgic/vgic.h | 10 ++++++++- > > > =C2=A02 files changed, 43 insertions(+), 9 deletions(-) > > >=20 > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > > index 88a57ca36d96..73dd2bd85c4f 100644 > > > --- a/arch/arm64/kvm/sys_regs.c > > > +++ b/arch/arm64/kvm/sys_regs.c > > > @@ -1758,6 +1758,7 @@ static u8 pmuver_to_perfmon(u8 pmuver) > > > =C2=A0 > > > =C2=A0static u64 sanitise_id_aa64pfr0_el1(const struct kvm_vcpu *vcpu, > > > u64 val); > > > =C2=A0static u64 sanitise_id_aa64pfr1_el1(const struct kvm_vcpu *vcpu, > > > u64 val); > > > +static u64 sanitise_id_aa64pfr2_el1(const struct kvm_vcpu *vcpu, > > > u64 val); > > > =C2=A0static u64 sanitise_id_aa64dfr0_el1(const struct kvm_vcpu *vcpu, > > > u64 val); > > > =C2=A0 > > > =C2=A0/* Read a sanitised cpufeature ID register by sys_reg_desc */ > > > @@ -1783,10 +1784,7 @@ static u64 __kvm_read_sanitised_id_reg(const > > > struct kvm_vcpu *vcpu, > > > =C2=A0 val =3D sanitise_id_aa64pfr1_el1(vcpu, val); > > > =C2=A0 break; > > > =C2=A0 case SYS_ID_AA64PFR2_EL1: > > > - val &=3D ID_AA64PFR2_EL1_FPMR | > > > - (kvm_has_mte(vcpu->kvm) ? > > > - ID_AA64PFR2_EL1_MTEFAR | > > > ID_AA64PFR2_EL1_MTESTOREONLY : > > > - 0); > > > + val =3D sanitise_id_aa64pfr2_el1(vcpu, val); > > > =C2=A0 break; > > > =C2=A0 case SYS_ID_AA64ISAR1_EL1: > > > =C2=A0 if (!vcpu_has_ptrauth(vcpu)) > > > @@ -2024,6 +2022,23 @@ static u64 sanitise_id_aa64pfr1_el1(const > > > struct kvm_vcpu *vcpu, u64 val) > > > =C2=A0 return val; > > > =C2=A0} > > > =C2=A0 > > > +static u64 sanitise_id_aa64pfr2_el1(const struct kvm_vcpu *vcpu, > > > u64 val) > > > +{ > > > + val &=3D ID_AA64PFR2_EL1_FPMR | > > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ID_AA64PFR2_EL1_MTEFAR | > > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ID_AA64PFR2_EL1_MTESTOREONLY; > > > + > > > + if (!kvm_has_mte(vcpu->kvm)) { > > > + val &=3D ~ID_AA64PFR2_EL1_MTEFAR; > > > + val &=3D ~ID_AA64PFR2_EL1_MTESTOREONLY; > > > + } > > > + > > > + if (vgic_is_v5(vcpu->kvm)) > > > + val |=3D SYS_FIELD_PREP_ENUM(ID_AA64PFR2_EL1, GCIE, > > > IMP); > >=20 > > You probably want to clear the field before or'ing something in, or > > you may be promising more than we'd expect. >=20 > The GCIE field should already be zeroed at this point as it is filtered > out to begin with. If we have GICv5 (so FEAT_GCIE) we're explicitly > setting this field to IMP, else NI. As you can tell by now, I can't read. Apologies for the noise. Thanks, M. --=20 Without deviation from the norm, progress is not possible.