From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Subject: Re: [PART2 PATCH v3 06/11] iommu/amd: Adding GALOG interrupt handler Date: Wed, 13 Jul 2016 19:49:50 +0700 Message-ID: <578638EE.6030200@amd.com> References: <1468231899-6987-1-git-send-email-suravee.suthikulpanit@amd.com> <1468231899-6987-7-git-send-email-suravee.suthikulpanit@amd.com> <20160711184712.GA1334@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: Received: from mail-dm3nam03on0089.outbound.protection.outlook.com ([104.47.41.89]:16416 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751317AbcGMMud (ORCPT ); Wed, 13 Jul 2016 08:50:33 -0400 In-Reply-To: <20160711184712.GA1334@potion> Sender: kvm-owner@vger.kernel.org List-ID: Hi Radim, On 07/12/2016 01:47 AM, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > 2016-07-11 05:11-0500, Suravee Suthikulpanit: >> From: Suravee Suthikulpanit >> >> This patch adds AMD IOMMU guest virtual APIC log (GALOG) handler. >> When IOMMU hardware receives an interrupt targeting a blocking vcpu, >> it creates an entry in the GALOG, and generates an interrupt to noti= fy >> the AMD IOMMU driver. >> >> At this point, the driver processes the log entry, and notify the SV= M >> driver via the registered iommu_ga_log_notifier function. >> >> Signed-off-by: Suravee Suthikulpanit >> --- >> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c >> @@ -741,14 +741,101 @@ static void iommu_poll_ppr_log(struct amd_iom= mu *iommu) >> +static void iommu_handle_ga_guest_nr_entry(struct amd_iommu *iommu, >> + u16 devid, u32 ga_tag) >> +{ >> + struct amd_ir_data *ir_data; >> + unsigned long flags; >> + int vec =3D 0; >> + >> + if (!iommu_ga_log_notifier) >> + return; >> + >> + spin_lock_irqsave(&iommu->ga_hash_lock, flags); >> + hash_for_each_possible(iommu->ga_hash, ir_data, hnode, ga_tag) { >> + struct irte_ga *entry =3D (struct irte_ga *)ir_data->entry; > > if (ga_tag !=3D entry->fields_vapic.ga_tag) > continue; > > Multiple different ga_tags can map to the same bucket, so we need to > explicitly select the correct entry. > In the upcoming V4 changes, we should not need this look up anymore. >> + >> + vec =3D entry->hi.fields.vector; >> + break; >> + } >> + spin_unlock_irqrestore(&iommu->ga_hash_lock, flags); >> + >> + if (vec) { >> + pr_debug("AMD-Vi: %s: devid=3D%#x, ga_tag=3D%#x\n", >> + __func__, devid, ga_tag); >> + >> + if (iommu_ga_log_notifier(GATAG_TO_AVICTAG(ga_tag), >> + GATAG_TO_VCPUID(ga_tag), vec) !=3D 0) The necessary look up (i.e. to get vm and vcpu information should be=20 done in the calling notifier here. I'll update this in V4, which gettin= g=20 ready to send out soon. Thanks, Suravee