From: sashiko-bot@kernel.org
To: "Sairaj Kodilkar" <sarunkod@amd.com>, kvm@vger.kernel.org
Subject: Re: [PATCH v5 5/7] KVM: VMX: Factor out wakeup list handling code to KVM
Date: Thu, 15 Oct 2026 07:00:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-172375@kernel.org> (raw)
In-Reply-To: <20261015064515.10700-6-sarunkod@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] kvm: uninitialized return value from vcpu_irq_pending due to KVM_X86_OP_OPTIONAL
--
commit 56cc0b2c3b271017f40149e674efc58c033886d7
Author: Sairaj Kodilkar <sarunkod@amd.com>
KVM: VMX: Factor out wakeup list handling code to KVM
This commit moves the per-pCPU list of blocked vCPUs and the wakeup
handler from VMX to common KVM x86 code to support AMD. It introduces
a new optional vcpu_irq_pending callback so Intel and AMD can
determine if a queued vCPU has a notification pending.
> diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
> index e213c9ae3e301..5d337f9336c5d 100644
> --- a/arch/x86/include/asm/kvm-x86-ops.h
> +++ b/arch/x86/include/asm/kvm-x86-ops.h
> @@ -30,6 +30,7 @@ KVM_X86_OP(vcpu_reset)
> KVM_X86_OP(prepare_switch_to_guest)
> KVM_X86_OP(vcpu_load)
> KVM_X86_OP(vcpu_put)
> +KVM_X86_OP_OPTIONAL(vcpu_irq_pending)
[Severity: Medium]
Since vcpu_irq_pending() returns a boolean, should this be declared with
KVM_X86_OP_OPTIONAL_RET0 instead?
For optional KVM operations, if the active vendor module does not implement
the callback, KVM patches the static call site to a dummy trampoline. Because
KVM_X86_OP_OPTIONAL is used here, the trampoline does not clear the return
register.
[ ... ]
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index aad065d035fbb..0c637a18bcfa4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
[ ... ]
> @@ -2688,6 +2709,79 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
[ ... ]
> +/*
> + * Handler for POSTED_INTERRUPT_WAKEUP_VECTOR.
> + */
> +static void kvm_pi_wakeup_handler(void)
> +{
> + int cpu = smp_processor_id();
> + struct list_head *wakeup_list = &per_cpu(wakeup_vcpus_on_cpu, cpu);
> + raw_spinlock_t *spinlock = &per_cpu(wakeup_vcpus_on_cpu_lock, cpu);
> + struct kvm_vcpu *vcpu;
> +
> + raw_spin_lock(spinlock);
> + list_for_each_entry(vcpu, wakeup_list, pi_wakeup_list) {
> + if (kvm_x86_call(vcpu_irq_pending)(vcpu))
[Severity: Medium]
Could this evaluate uninitialized garbage if the vendor omits the callback?
Because KVM_X86_OP_OPTIONAL does not clear the return register, this check
will read whatever was left in the register. This could lead to unpredictable
behavior, such as spurious vCPU wakeups or missed wakeups on platforms
lacking the implementation.
> + kvm_vcpu_wake_up(vcpu);
> + }
> + raw_spin_unlock(spinlock);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015064515.10700-1-sarunkod@amd.com?part=5
next prev parent reply other threads:[~2026-10-15 7:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 6:45 [PATCH v5 0/7] Add support for AMD IOMMU GAPPI Sairaj Kodilkar
2026-10-15 6:45 ` [PATCH v5 1/7] iommu/amd: KVM: SVM: Rename cpu to apicid in IOMMU interface Sairaj Kodilkar
2026-10-15 6:45 ` [PATCH v5 2/7] iommu/amd: KVM: SVM: Rename ga_log_intr to wakeup_intr " Sairaj Kodilkar
2026-10-15 6:45 ` [PATCH v5 3/7] iommu/amd: KVM: SVM: Add explicit vCPU running state to " Sairaj Kodilkar
2026-10-15 6:45 ` [PATCH v5 4/7] iommu/amd: Program guest-mode IRTEs for GAPPI wakeup when IRTE[IsRun] = 0 Sairaj Kodilkar
2026-10-15 7:03 ` sashiko-bot
2026-10-15 6:45 ` [PATCH v5 5/7] KVM: VMX: Factor out wakeup list handling code to KVM Sairaj Kodilkar
2026-10-15 7:00 ` sashiko-bot [this message]
2026-10-15 6:45 ` [PATCH v5 6/7] KVM: SVM: Add support for AMD IOMMU Guest APIC Physical Processor Interrupt (GAPPI) Sairaj Kodilkar
2026-10-15 7:05 ` sashiko-bot
2026-10-15 6:45 ` [PATCH v5 7/7] iommu/amd: Provide kernel command line option to enable GAPPI Sairaj Kodilkar
2026-10-15 7:08 ` sashiko-bot
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-172375@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sarunkod@amd.com \
--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