From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Subject: Re: [PART2 PATCH v3 10/11] svm: Introduce AMD IOMMU avic_ga_log_notifier Date: Wed, 13 Jul 2016 15:53:05 +0700 Message-ID: <57860171.3080400@amd.com> References: <1468231899-6987-1-git-send-email-suravee.suthikulpanit@amd.com> <1468231899-6987-11-git-send-email-suravee.suthikulpanit@amd.com> <20160711190932.GB1375@potion> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: , , , , , To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: In-Reply-To: <20160711190932.GB1375@potion> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Hi Radim, Again, sorry for possible confusion from the mis-use of the word ga_tag= =20 for parameter naming in different places. Please see my reply for the=20 patch 07/11 for more detail. On 07/12/2016 02:09 AM, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > 2016-07-11 05:11-0500, Suravee Suthikulpanit: >> From: Suravee Suthikulpanit >> >> This patch introduces avic_ga_log_notifier, which will be called >> by IOMMU driver whenever it handles the Guest vAPIC (GA) log entry. >> >> Signed-off-by: Suravee Suthikulpanit >> --- >> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >> @@ -928,6 +930,45 @@ static void svm_disable_lbrv(struct vcpu_svm *s= vm) >> +static int avic_ga_log_notifier(int avic_tag, int vcpu_id, int vec) >> +{ >> + unsigned long flags; >> + struct kvm_arch *ka =3D NULL; >> + struct kvm_vcpu *vcpu =3D NULL; >> + struct vcpu_svm *svm =3D NULL; >> + >> + pr_debug("SVM: %s: avic_tag=3D%#x, vcpu_id=3D%#x, vec=3D%#x\n", >> + __func__, avic_tag, vcpu_id, vec); >> + >> + spin_lock_irqsave(&svm_vm_data_hash_lock, flags); >> + hash_for_each_possible(svm_vm_data_hash, ka, hnode, avic_tag) { >> + struct kvm *kvm =3D container_of(ka, struct kvm, arch); > > iommu_handle_ga_guest_nr_entry(), the caller, already performed a has= h > lookup to get ir_data. Cannot we store the vcpu pointer in ir_data, = to > avoid a second hash lookup and a vcpu lookup? > > Thanks. > The iommu_handle_ga_guest_nr_entry() has the look up logic to map ga_ta= g=20 back to an ir_data in order to see if there are any pending interrupts=20 targeting a particular VCPU of a particular VM. The look up in the avic_ga_log_notifier() is for SVM to map VM_ID to th= e=20 struct kvm_arch. Thanks, Suravee