From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796405571; b=esd066Th1nxzYWjnZjf/Sbi7/wrn1Cevt2Y4BWiMWNRagE2b2heoCReNr1ZrHumL/n4H IXY1PFulqOs8sEusJ3bZchHKWYy8E0pNftE2uR6CyE/fTUVzEuCKhUTBHTayqntpf/DmR OOFi84sKyhDoI0VHphncRFItbsbcKnCcTBsqYR5JMrLxlz6DO+gnRdSfV4p7m+nqubJLm OcawIp2yHr0E8xp1zptmAVLGIqFApzfwlktjktailXIvX6UaEAyuM0Sd8D7ABo9slJjWF SBAxYWSCkmcoTRLoBbcjZWdNLcLZBUmwvjJ2ArnSw586KTzO1459c9wNFREzdwsqaEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796405571; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ZCY6gPgAwiW5OS3hVWvZ/odpadJTGhTVAx50SV5jCp8=; b=COSra8nnKmx++wG8VSAePI4UaNgvLPKocjEnSfWhT20qoX3VS6HOPNccxvNNwLhxA5lV /EJmiduN2oC0rJOWCREVmkpNeJJdx4gz7k5Oka4EUG59vf25hjSNNEbfpjC5mp4FtES72 h4Mg7xXqbeRohCKl501AKUN8CKcJ9hQaDPgAQAzDT/iyVr6b2cEBb8qgsemN9Ds1j4sLS WS9+4kCo8EGJKUcjLUQnHnDutM2Mb25SdXSCgEb4bWSgWHz2LhNpXt+rV1gCV8V5boi41 r3PLz+8vB692qWgjj8tNfq+yjZ6mRQG055F9WZy1Y+HUiZUTbFvja1eWKlxePwTjbdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZ951exK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE792606A322 for ; Fri, 4 Dec 2026 17:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZ951exK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10C9B1F00936; Fri, 4 Dec 2026 17:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796405571; bh=ZCY6gPgAwiW5OS3hVWvZ/odpadJTGhTVAx50SV5jCp8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FZ951exKEA6bEM8JbYcuOUjpG+W7StaIP9b/YKelGqoiX1/mzWnIjyYlhW1FWjeRV pyD+zaHppqMzRi2RMNGlzMMudngi9qa0Fzdf1hLQ6ciFoOhofkDxcJMnoNMqn59N5g fX0K8P94z6LTwdDIrQM5uLSBelNH1ZutbKEb2KFXATLH7CxNbLZSD+H2YMpqTySS0Q YZMGvpq3WMN38JDNXQWpJNRcHWCJ9CsbTkaIpKZty7o/PHtgWShDl/cSq77PnCvPFZ Vk4/6yUdBsj7aqXhKHK2PwEFPt21ILIbp8Q60CqP6F+hOaOFjlCANKlTupxi4j6bkI DGUow9fYvu6Mw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] KVM: arm64: vgic-v3: Use the minimal BPR for the emulated active priority Reply-To: sashiko-reviews@lists.linux.dev To: "Xuheng Li" Cc: kvmarm@lists.linux.dev, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261204-vgic-v3-active-priority-v1-1-9ce5187224ce@cs.columbia.edu> References: <20261204-vgic-v3-active-priority-v1-1-9ce5187224ce@cs.columbia.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 17:32:50 +0000 X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] KVM: arm64: asymmetric BPR masking in __vgic_v3_read_iar() preemption check - [High] KVM: arm64: BPR mask mismatch in __vgic_v3_write_eoir() skips LR deactivation -- commit 4db6cbe64dc25717be9406f747d530f50d9a2d05 Author: Xuheng Li KVM: arm64: vgic-v3: Use the minimal BPR for the emulated active priority This commit stops masking the interrupt priority with the guest's current BPR in __vgic_v3_set_active_priority(), normalizing the priority directly with __vgic_v3_bpr_min() before recording it in ICH_AP{0,1}R_EL2. > diff --git a/arch/arm64/kvm/hyp/vgic-v3-sr.c b/arch/arm64/kvm/hyp/vgic-v3= -sr.c > index 2dfb5ff9db575..ef8f003cd52f9 100644 > --- a/arch/arm64/kvm/hyp/vgic-v3-sr.c > +++ b/arch/arm64/kvm/hyp/vgic-v3-sr.c > @@ -669,14 +669,13 @@ static u8 __vgic_v3_pri_to_pre(u8 pri, u32 vmcr, in= t grp) > * matter what the guest does with its BPR, we can always set/get the > * same value of a priority. > */ > -static void __vgic_v3_set_active_priority(u8 pri, u32 vmcr, int grp) > +static void __vgic_v3_set_active_priority(u8 pri, int grp) > { > - u8 pre, ap; > + u8 ap; > u32 val; > int apr; > =20 > - pre =3D __vgic_v3_pri_to_pre(pri, vmcr, grp); > - ap =3D pre >> __vgic_v3_bpr_min(); > + ap =3D pri >> __vgic_v3_bpr_min(); > apr =3D ap / 32; [Severity: High] Does removing __vgic_v3_pri_to_pre() here break interrupt deactivation in __vgic_v3_write_eoir()? arch/arm64/kvm/hyp/vgic-v3-sr.c:__vgic_v3_write_eoir() { ... act_prio =3D __vgic_v3_clear_highest_active_priority(); ... if (grp !=3D !!(lr_val & ICH_LR_GROUP) || __vgic_v3_pri_to_pre(lr_prio, vmcr, grp) !=3D act_prio) return; /* Let's now perform the deactivation */ __vgic_v3_clear_active_lr(lr, lr_val); } __vgic_v3_clear_highest_active_priority() now returns act_prio normalized only to __vgic_v3_bpr_min(). With ICC_BPR1_EL1 =3D=3D 7 and priority 0x78, act_prio is 0x78 while __vgic_v3_pri_to_pre() yields 0x00, so __vgic_v3_write_eoir() returns early before clearing the LR. For EOImode =3D=3D 0 interrupts and LPIs in List Registers, this leaves ICH_LR_ACTIVE_BIT set (and skips gic_write_dir() for ICH_LR_HW interrupts), wedging the interrupt active even though the APR bit was already cleared. [ ... ] > @@ -752,7 +751,7 @@ static void __vgic_v3_read_iar(struct kvm_vcpu *vcpu,= u32 vmcr, int rt) > lr_val &=3D ~ICH_LR_STATE; > lr_val |=3D ICH_LR_ACTIVE_BIT; > __gic_v3_set_lr(lr_val, lr); > - __vgic_v3_set_active_priority(lr_prio, vmcr, grp); > + __vgic_v3_set_active_priority(lr_prio, grp); > vcpu_set_reg(vcpu, rt, lr_val & ICH_LR_VIRTUAL_ID_MASK); > return; [Severity: High] Can this asymmetric BPR masking in __vgic_v3_read_iar() let lower- or equal-priority interrupts preempt an active interrupt? arch/arm64/kvm/hyp/vgic-v3-sr.c:__vgic_v3_read_iar() { ... if (__vgic_v3_get_highest_active_priority() <=3D __vgic_v3_pri_to_pre(lr_p= rio, vmcr, grp)) goto spurious; ... } __vgic_v3_get_highest_active_priority() now keeps bits below the current BPR while the right-hand side masks them off. With 5 preemption bits and ICC_BPR1_EL1 =3D=3D 7, an active interrupt at 0x40 is preempted by a lower-priority one at 0x78 (masked to 0x00). That sets a second APR bit so the preempting interrupt's EOI clears the higher-priority interrupt's bit instead (and equal-priority preemption aliases the same APR bit). Masking the active priority with the current BPR as well needs to preserve GICv3_IDLE_PRIORITY (0xff). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-vgic-v3-ac= tive-priority-v1-1-9ce5187224ce@cs.columbia.edu?part=3D1