From: sashiko-bot@kernel.org
To: "Jörg Rödel" <joro@8bytes.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 3/7] KVM: SVM: Implement GET_AP_APIC_IDS NAE event
Date: Tue, 01 Dec 2026 10:00:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-243025@kernel.org> (raw)
In-Reply-To: <20261201094525.1240736-4-joro@8bytes.org>
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 <joerg.roedel@amd.com>
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 *svm)
> return 0;
> }
>
[ ... ]
> +static int sev_snp_get_apic_ids(struct vcpu_svm *svm)
> +{
> + struct kvm_vcpu *vcpu = &svm->vcpu;
> + struct kvm *kvm = 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 = atomic_read(&kvm->online_vcpus);
> + size = sizeof(*desc) + (nr_vcpus * sizeof(desc->apic_ids[0]));
> +
> + pages = vcpu->arch.regs[VCPU_REGS_RAX];
> + if (pages < PFN_UP(size)) {
> + vcpu->arch.regs[VCPU_REGS_RAX] = PFN_UP(size);
> + return 1;
> + }
> +
> + gpa = 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 = gpa_to_gfn(gpa); gfn <= gpa_to_gfn(end_gpa); gfn++) {
> + struct kvm_memory_slot *slot = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201094525.1240736-1-joro@8bytes.org?part=3
next prev parent reply other threads:[~2026-12-01 10:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:45 [PATCH v4 0/7] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 1/7] KVM: SEV: Document SNP direct VMSA userspace ABI Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 2/7] KVM: SEV: Add direct VMSA capability Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 3/7] KVM: SVM: Implement GET_AP_APIC_IDS NAE event Jörg Rödel
2026-12-01 10:00 ` sashiko-bot [this message]
2026-12-01 9:45 ` [PATCH v4 4/7] KVM: SEV: Allow VMSA pages in SNP launch updates Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 5/7] KVM: SEV: Add SNP vCPU state get and set commands Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 6/7] KVM: selftests: Test SNP vCPU state and direct VMSA launch Jörg Rödel
2026-12-01 9:45 ` [PATCH v4 7/7] KVM: selftests: Test the SNP APIC-ID-list GHCB request Jörg Rödel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-243025@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox