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=1796050537; b=BfBocC3XD6lwM/rqUz9z6Fp1FrIyN/HKpRHzrbaAoG9JTT3n7VT5dP7WMTXrZyz6q+fh IVJ6By3k3TRnUyx2bY5cq/siNFT3u8cdjyTuu/woAlySZ13akz0paqY9c7B3UdBekuNZw uOingQblz/krhryxs5haH9tQnJ3gZIWm24mpocfRwbhEA4Prvc1Jw8fxWpUihvb/cW8kn 8P0bVFvq8qKyRmseuFfZBw0Bd9wzjLdSYzHEYMkxQVfYoJF4bb5M/x/gpV/tdH+mOh2D+ Eo2mQHF1S+9N64rcTMuG3eDjyNhoZglRbHAbY3g2TcBtPHpuwzqesihUcSCR4/Rb4og== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796050537; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ebNwH5VpXhZ4+3vj6v52VJHpQm6C2TcokOZDICK30GM=; b=akkGNuekOP/B0Sj0wEa1fEVu+wEQDhHDzsB9GuGJaGHOGrPxV2FeU5NZ5MHd2mNOuvJw vpOntIuJEn00iGb/UXlbVLwXWVLmqBcAFFA0hB/4ncutXJKqCpnVhNvwt7ybFEEITb37F VLiGPfVL63AzO4UnDLGA/eXcc22fa8JvS+OuxGNmsCm4NOyRqTOy4xhMrF+esb3EC+MsE H/OFrbCFu/rCPAy7JcY97L/DJM5pXheQRVV2pT/TZbyv8tReO++7Uigr3ySKm/jjaN4Bf fjSLjXHwUnWLAo3mdEDX4T4OR9V3BZRv52a9dQv3KXcZ2g1Dk8TvY7kxtSLZh9ZbG2A== 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=bCbcvdeB; 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 E72B8606A327 for ; Mon, 30 Nov 2026 14:55:36 +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=bCbcvdeB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 937A51F00A1B; Mon, 30 Nov 2026 14:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796050536; bh=ebNwH5VpXhZ4+3vj6v52VJHpQm6C2TcokOZDICK30GM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bCbcvdeBO4eCUNRJqQuO0sNFGaKYBZJPKeCxv4U4BgbMmNYqc60nArsmfQntS0TU2 oLdn+zCVF5K6SRowxweKtZ9Jdgjyuk/TQTP9k1ajUtQ4++R6KmqDbilo+VWm+bEPCj xGkdLSNwukCshWMD4L60wqUBgUIa3fnLPNvivHXzPI5ehsGvvah1E1PjYsonhf5ehM vRiEfZn2b1VqljKpajketrWn1qxsSMdbnee2QomRbD1zoS1qzp3/l/cTXyl+klOYYF M8CDktg/lp1ZSLXaHXQTuMpC9TW7HWDF88kPt5dXAqmpWKhhcUvrI90JWdFLVFUKYg 3wy3FvODjCKDQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/3] KVM: arm64: Reject KVM_RUN on a vCPU that's no longer initialized Reply-To: sashiko-reviews@lists.linux.dev To: "Fuad Tabba" Cc: kvmarm@lists.linux.dev, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261130144438.3176276-3-fuad.tabba@linux.dev> References: <20261130144438.3176276-1-fuad.tabba@linux.dev> <20261130144438.3176276-3-fuad.tabba@linux.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 14:55:36 +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 no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] KVM: arm64: stolen time underflow in kvm_update_stolen_time() [1] -- commit bfa878fdb69c60cb82e53267508c4265191ade79 Author: Fuad Tabba KVM: arm64: Reject KVM_RUN on a vCPU that's no longer initialized This commit restores the kvm_vcpu_initialized() check in kvm_arch_vcpu_ioctl_run() so that KVM_RUN returns -ENOEXEC if a vCPU has been marked uninitialized after its first run. > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index cfaaadd97233f..6c2d3811f2814 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1417,6 +1417,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) > struct kvm_run *run =3D vcpu->run; > int ret; > =20 > + if (unlikely(!kvm_vcpu_initialized(vcpu))) > + return -ENOEXEC; > + > if (run->exit_reason =3D=3D KVM_EXIT_MMIO) { > ret =3D kvm_handle_mmio_return(vcpu); > if (ret <=3D 0) [Severity: High] This problem wasn't introduced by this patch, but can vcpu->arch.steal.last_steal underflow in kvm_update_stolen_time() [1] when a vCPU migrates to a new host thread? When a new thread runs a vCPU that has already run once, kvm_arch_vcpu_run_pid_change() returns early without resetting vcpu->arch.steal.last_steal to the new task's run_delay: arch/arm64/kvm/arm.c:kvm_arch_vcpu_run_pid_change() { ... if (likely(vcpu_has_run_once(vcpu))) return 0; ... } On the next guest entry, kvm_update_stolen_time() subtracts the previous thread's cached run_delay from the new thread's current->sched_info.run_delay: arch/arm64/kvm/pvtime.c:kvm_update_stolen_time() { ... if (!kvm_get_guest(kvm, base + offset, steal)) { steal =3D le64_to_cpu(steal); vcpu->arch.steal.last_steal =3D READ_ONCE(current->sched_info.run_delay); steal +=3D vcpu->arch.steal.last_steal - last_steal; kvm_put_guest(kvm, base + offset, cpu_to_le64(steal)); } ... } If the new thread has accumulated less runqueue delay than the old thread, the unsigned subtraction wraps around and writes a bogus stolen_time value to guest memory, corrupting guest CPU time accounting. [1] https://sashiko.dev/#/bug/linux-9029bf19-3622-4a26-a158-ad236ad8cc5f --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130144438.3176= 276-1-fuad.tabba@linux.dev?part=3D2