Re: [RFC PATCH v3 3/6] iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface
From: Sairaj Kodilkar
Date: Wed Aug 12 2026 - 01:20:37 EST
On 8/11/2026 6:04 AM, Sean Christopherson wrote:
> On Mon, Jul 13, 2026, Sairaj Kodilkar wrote:
>> @@ -1008,6 +1010,7 @@ static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int apicid,
>> enum avic_vcpu_action action)
>> {
>> bool wakeup_intr = (action & AVIC_START_BLOCKING);
>> + bool is_running = apicid >= 0;
>> struct vcpu_svm *svm = to_svm(vcpu);
>> struct kvm_kernel_irqfd *irqfd;
>>
>> @@ -1024,9 +1027,10 @@ static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int apicid,
>> void *data = irqfd->irq_bypass_data;
>>
>> if (!(action & AVIC_TOGGLE_ON_OFF))
>> - WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr));
>> - else if (apicid >= 0)
>> - WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr));
>> + WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr, is_running));
>> + else if (is_running)
>> + WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr,
>> + is_running));
>
> Pass is_running here is rather weird. Given that this is the only call site
> that originates outside of the IOMMU driver, what if the exported
> amd_iommu_activate_guest_mode() is a wrapper to an internal API and hardcodes
> is_running=true? Then the internal path via irq_set_vcpu_affinity() can pass
> an actual variable.
Yep, this makes sense, I'll create an internal function
__amd_iommu_activate_guest_mode() and keep exported
amd_iommu_activate_guest_mode() as a wrapper around it.
Thanks
Sairaj