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=1796119257; b=3oWsFlbTkVVr7hvesLkPbrZAdW5N4gizynyYCiT2uBSa95vdXPz5JSuNCsc3MWqoOO7d /Sa0+euJxZLIuZNzBmgwbaLjI/h7l+vUDiJ3TtQGltTvATRJAbI7ySs3gkF2an+V8mSiA 4jMGg5RD6w0l4qMUs7vaDvJEpnAG87V5Al4xeEBrViX61kHYvP/4KEb0BXS8RNXHODz6X s6I+ex6T8FvOv1Bbhwz/JJb1WxcliyXR1CeB4zmLOYvYyPWmUfaVclv7PeiX5owy8LPJe 75ESWO3BINGUrdes/Irh+wcm+r7yrVWpHJm3gBwKnU7LJEcgzB2eeGukKh3vYPLwGvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796119257; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oY7n8e4OjlO+jux6a+1aMulSd4WVRtWPxXiSVM3m0oM=; b=ubsqvbcE377OA08Rcq7Vb7e3XQulV1ZUaPQHk3EfMTUaxJkLuSgBNVR6JfbziYR++4Wx 7GfZynF81bxeDa7dC8AbtH5vWti5DMRUUjW6dB18YyGNb75aq4zgE0xJybHYpuCQ7M8zZ 1Sso6U29H249nIWfh5ODPO2n4OzIqYMiUoAK9oZoqeuXyBKwr8Cep4q906AegmziaOqG9 Nt+Gmm717zeuRz2Qty6C3HOg8rNzIWV/kPEqayzwzvznqonPq67qYqDKI9gf7aaqHqCAD hzWD+RE0LRrlBR/zPljfZr8Odw0wzgVODibsQiWKLbikhnvwngj+uw8/+iNrkzyGSgw== 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=UQVSCWCB; 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 C6157606A31A for ; Tue, 1 Dec 2026 10:00:57 +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=UQVSCWCB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ACE71F00897; Tue, 1 Dec 2026 10:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796119257; bh=oY7n8e4OjlO+jux6a+1aMulSd4WVRtWPxXiSVM3m0oM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=UQVSCWCBbU6OUabmXOskSpCXhFcpft+z/1YzuR/D8IBk0fuVI6QBgLe7dHH/LWNz+ Kz9BuPfadYvRuXyUgO9Je7vjriWeUijScohPzFz1n0ybmja5uabup4O2SPBFmOYr/L +Rc26svTAw0HpgwUazDR3ZaDpM86mJc1E+k1BY68dBJwrC5Qzvbug3cI/hWm11ZGzR g8syDZ9hI4+BdYM1LkeEvCptHcyhnwmTjT7RFqtJcRF95wDLmxO2dZwOT5M7ijkief Xl/bx9DPeQgv/aKD366qDV5B0kvLbuBZcc4q/vcQkjRWF35QPDhOrYYoK7oThR2HiU RW3VyAvldselg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 3/7] KVM: SVM: Implement GET_AP_APIC_IDS NAE event Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?SsO2cmcgUsO2ZGVs?= Cc: kvm@vger.kernel.org In-Reply-To: <20261201094525.1240736-4-joro@8bytes.org> References: <20261201094525.1240736-1-joro@8bytes.org> <20261201094525.1240736-4-joro@8bytes.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 10:00:56 +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: - [High] KVM: SVM: incomplete GET_APIC_IDS VMGEXIT on -EINTR in sev_snp_get_apic_ids() -- commit bf4fda927f82a937a9bfab8fabf43d37858e2284 Author: Joerg Roedel KVM: SVM: Implement GET_AP_APIC_IDS NAE event This commit implements the GHCB APIC ID List VMGEXIT event for SEV-SNP guests when direct VMSA support is enabled. > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 18ccab1139895..f22490f86a4ab 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c [ ... ] > @@ -4261,6 +4262,93 @@ static int sev_snp_ap_creation(struct vcpu_svm *sv= m) > return 0; > } > =20 [ ... ] > +static int sev_snp_get_apic_ids(struct vcpu_svm *svm) > +{ > + struct kvm_vcpu *vcpu =3D &svm->vcpu; > + struct kvm *kvm =3D vcpu->kvm; > + struct sev_apic_id_desc *desc; > + unsigned int nr_vcpus, size; > + unsigned int i; > + gpa_t gpa, end_gpa; > + gfn_t gfn; > + u64 pages, len; > + > + nr_vcpus =3D atomic_read(&kvm->online_vcpus); > + size =3D sizeof(*desc) + (nr_vcpus * sizeof(desc->apic_ids[0])); > + > + pages =3D vcpu->arch.regs[VCPU_REGS_RAX]; > + if (pages < PFN_UP(size)) { > + vcpu->arch.regs[VCPU_REGS_RAX] =3D PFN_UP(size); > + return 1; > + } > + > + gpa =3D svm->vmcb->control.exit_info_1; > + if (!PAGE_ALIGNED(gpa) || > + check_mul_overflow(pages, (u64)PAGE_SIZE, &len) || > + check_add_overflow(gpa, len - 1, &end_gpa) || > + !page_address_valid(vcpu, gpa) || > + !page_address_valid(vcpu, end_gpa & PAGE_MASK)) > + goto invalid_buffer; > + > + for (gfn =3D gpa_to_gfn(gpa); gfn <=3D gpa_to_gfn(end_gpa); gfn++) { > + struct kvm_memory_slot *slot =3D gfn_to_memslot(kvm, gfn); > + > + if (kvm_is_error_hva(gfn_to_hva_memslot(slot, gfn)) || > + kvm_is_private_gfn(kvm, gfn)) > + goto invalid_buffer; > + > + if (signal_pending(current)) > + return -EINTR; > + cond_resched(); > + } [Severity: High] Does returning -EINTR here leave the SVM_VMGEXIT_GET_APIC_IDS event uncompleted while telling the guest it succeeded? Before dispatching to sev_snp_get_apic_ids(), sev_handle_vmgexit() clears ghcb->save.valid_bitmap in sev_es_sync_from_ghcb() and presets the GHCB return code to success via svm_vmgexit_success(svm, 0). Hardware has already advanced the guest RIP past VMGEXIT, and no vcpu->arch.complete_userspace_io callback is installed when returning -EINTR. On the next KVM_RUN, svm_prepare_switch_to_guest() syncs the preset success status back to the GHCB and resumes the guest past VMGEXIT without ever writing the APIC ID descriptor to guest memory. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201094525.1240= 736-1-joro@8bytes.org?part=3D3