From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932345AbbHYImP (ORCPT ); Tue, 25 Aug 2015 04:42:15 -0400 Received: from 8bytes.org ([81.169.241.247]:50036 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755290AbbHYImK (ORCPT ); Tue, 25 Aug 2015 04:42:10 -0400 Date: Tue, 25 Aug 2015 10:42:08 +0200 From: "joro@8bytes.org" To: "Xiao, Nan (Nan@HPS Performance, Beijing)" Cc: "dwmw2@infradead.org" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table Message-ID: <20150825084208.GB32055@8bytes.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nan, On Mon, Aug 24, 2015 at 06:26:33AM +0000, Xiao, Nan (Nan@HPS Performance, Beijing) wrote: > drivers/iommu/intel-iommu.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 0649b94..4213598 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -759,10 +759,11 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu > if (devfn >= 0x80) { > devfn -= 0x80; > entry = &root->hi; > - } > + } else > + entry = &root->lo; > devfn *= 2; > - } > - entry = &root->lo; > + } else > + entry = &root->lo; > if (*entry & 1) > context = phys_to_virt(*entry & VTD_PAGE_MASK); > else { Shouldn't this diff have the same effect? diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 0649b94..7553cb9 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -755,6 +755,7 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu struct context_entry *context; u64 *entry; + entry = &root->lo; if (ecs_enabled(iommu)) { if (devfn >= 0x80) { devfn -= 0x80; @@ -762,7 +763,6 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu } devfn *= 2; } - entry = &root->lo; if (*entry & 1) context = phys_to_virt(*entry & VTD_PAGE_MASK); else {