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=1796375023; b=ONygnS+48AHhGKgV5mIUDrml1WI8HiZhOAlsyZrhtCmh6SSlxJhU2zo0p91+GrVsPAbq ItdGHW3yP8+TF1KKCffG1jWaDdPtkwffJel5VhbFLMpwybPETLmN5mc5zjXNRqVN8+Cjb Z6IN/wYscdIjhWu9Z2TbRyqbVD5TNWwf0+kif2LEIoVnpO4MnRlDOWm/e97PlqwXfq7Q7 9etwdsRRKNIKOPuZifSCwC7ldhl2FDsMfzEbwijg5WlbwRHLyaEGpnsEpT+6DBsR+7BE2 qJ95cFSz6vFWFZ4sV9cZ4ABWDUpmLjaF6WNPw5c6fGfHx3km+6mlMbY6P+1g2PAiKmA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375023; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ZUiJ7Znjg1G8KUouwy5V4scTF34R0KMNsRUPwNwooqY=; b=F9ijtMHt68n4w4yb3vILiViyxYtNbvk3L3EhNO6POjwcP3Px0Uiztb6Pflz4bkvcQ7CN 9dlvnhyEZErw8QaGdE7hKoppkuW4PkVQRqLsuQ5B03GocvvM08QUDYbSOD4tId7Vy45hS CNkITzaVbYGaOCWmTexbGaIaNfVbl7rxDckQi08FE8vyRvoIB08AVFnQR8oi3KTdwxZtb hYQVsla8VPMDdg2IAL27fX4gl/qgiCkHfDp5tDggQZHhR/Z4hC9/SE3/ES9xzst1C6qmZ RM/HNbliFnjSg928an95iZFNeFsSAzYpYhJROmtJRt7GG+nldAhj9P/K7QZAOgKV3SA== 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=EnskRL2p; 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 E4355606A322; Fri, 4 Dec 2026 09:03:42 +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=EnskRL2p Received: by smtp.kernel.org (Postfix) with ESMTPSA id 505E91F000C2; Fri, 4 Dec 2026 09:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796375022; bh=ZUiJ7Znjg1G8KUouwy5V4scTF34R0KMNsRUPwNwooqY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=EnskRL2pG883kPYUCL0LEhIcyKeiBEAs00EIuyVbTCOsToN8Sfw9it7tjBxtYFO3T 0TT7ef5vFt/HYMSwioT9OcmXq/7KTwClvbi1yADHcSRtNLPFAAVVOQ3tFC5DC15PmI RfDXNCbfgnSawLK35iac0/wzfiOzt3u88dlKVJYBFGf0HvbP0/NI+SzESI5cZogjRk oCZVuBNg/j5uIqeJpKoXOdqoZ2ayGryTGYER5Gf3toKWJ68kjY4K3srhcSj1YZKIDl WuiciBybIe/y7TJzxB4vfeh2cMOPxmI7N2x3ubwsNdC8QiLg8cW8OL/P2NbxLfjnLl tTZ2ViOEoEIOQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 4/9] KVM: arm64: Discard a pending SError when resetting a vcpu Reply-To: sashiko-reviews@lists.linux.dev To: "Dan Carpenter" Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261204-double_exception_v4-v4-4-523921511673@pereq.eu> References: <20261204-double_exception_v4-v4-0-523921511673@pereq.eu> <20261204-double_exception_v4-v4-4-523921511673@pereq.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:03:41 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] KVM: arm64: non-atomic hcr_el2 RMW in kvm_reset_vcpu() races with KVM_IRQ_LINE -- commit 410049e49c865f69ca46cd29eb464dfffe46ce36 Author: Dan Carpenter KVM: arm64: Discard a pending SError when resetting a vcpu This commit clears HCR_EL2_VSE in kvm_reset_vcpu() so a pending SError is discarded when resetting a vCPU. > diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c > index 26081d2734087..4b1917b48edcb 100644 > --- a/arch/arm64/kvm/reset.c > +++ b/arch/arm64/kvm/reset.c > @@ -204,6 +204,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu) > /* Reset system registers */ > kvm_reset_sys_regs(vcpu); > =20 > + /* Discard a pending SError */ > + vcpu->arch.hcr_el2 &=3D ~HCR_EL2_VSE; [Severity: Medium] Can this non-atomic read-modify-write on vcpu->arch.hcr_el2 race with KVM_IRQ_LINE? For a VM with a userspace irqchip, kvm_vm_ioctl_irq_line() calls vcpu_interrupt_line() without holding vcpu->mutex and updates HCR_EL2_VI or HCR_EL2_VF in vcpu->arch.hcr_el2 via test_and_set_bit() or test_and_clear_bit(). CPU0 CPU1 kvm_reset_vcpu() kvm_vm_ioctl_irq_line() val =3D vcpu->arch.hcr_el2 vcpu_interrupt_line() test_and_set_bit(VI, hcr) vcpu->arch.hcr_el2 =3D val & ~VSE <-- overwrites HCR_EL2_VI If KVM_IRQ_LINE runs between the load and store in kvm_reset_vcpu(), the store writes back stale HCR_EL2_VI or HCR_EL2_VF bits and the guest can miss a virtual IRQ or FIQ transition. Using clear_bit(__ffs(HCR_EL2_VSE), vcpu_hcr(vcpu)) would match vcpu_interrupt_line() and avoid this data race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-double_exc= eption_v4-v4-0-523921511673@pereq.eu?part=3D4