* [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table @ 2015-08-21 10:32 Nan Xiao 0 siblings, 0 replies; 7+ messages in thread From: Nan Xiao @ 2015-08-21 10:32 UTC (permalink / raw) To: dwmw2, joro; +Cc: iommu, linux-kernel Hi David & Joerg, In iommu_context_addr() function, we always use lower extended-context-table even though upper-half of the extended root-entry is present. Signed-off-by: Nan Xiao <nan-IAhD+5PxXTI3bvoXafbxaA@public.gmane.org> --- 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 { -- 2.4.3 Best Regards Nan Xiao ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table
@ 2015-08-24 6:26 Xiao, Nan (Nan@HPS Performance, Beijing)
[not found] ` <F9D82F0D71C0024FA18FE771EDDAF149081FAC8F-qhK1pdpzgV8SZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Xiao, Nan (Nan@HPS Performance, Beijing) @ 2015-08-24 6:26 UTC (permalink / raw)
To: joro@8bytes.org, dwmw2@infradead.org,
iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Hi David & joerg,
In iommu_context_addr() function, we always use lower extended-context-table
even though upper-half of the extended root-entry is present.
Signed-off-by: Nan Xiao <nan.xiao@hp.com>
---
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 {
--
2.4.3
Best Regards
Nan Xiao
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <F9D82F0D71C0024FA18FE771EDDAF149081FAC8F-qhK1pdpzgV8SZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>]
* Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table [not found] ` <F9D82F0D71C0024FA18FE771EDDAF149081FAC8F-qhK1pdpzgV8SZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org> @ 2015-08-25 8:42 ` joro-zLv9SwRftAIdnm+yROfE0A [not found] ` <20150825084208.GB32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: joro-zLv9SwRftAIdnm+yROfE0A @ 2015-08-25 8:42 UTC (permalink / raw) To: Xiao, Nan (Nan@HPS Performance, Beijing) Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 { ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <20150825084208.GB32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* RE: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table [not found] ` <20150825084208.GB32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2015-08-25 8:46 ` Xiao, Nan (Nan@HPservers-Core-OE-PSC) [not found] ` <F9D82F0D71C0024FA18FE771EDDAF149082020ED-aJCdeS5/g6oSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Xiao, Nan (Nan@HPservers-Core-OE-PSC) @ 2015-08-25 8:46 UTC (permalink / raw) To: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Hi Joerg, Yes, your patch is simple and better! Best Regards Nan Xiao -----Original Message----- From: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org [mailto:joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org] Sent: Tuesday, August 25, 2015 4:42 PM To: Xiao, Nan (Nan@HPservers-Core-OE-PSC) Cc: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table 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 { ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <F9D82F0D71C0024FA18FE771EDDAF149082020ED-aJCdeS5/g6oSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>]
* Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table [not found] ` <F9D82F0D71C0024FA18FE771EDDAF149082020ED-aJCdeS5/g6oSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org> @ 2015-08-25 8:59 ` joro-zLv9SwRftAIdnm+yROfE0A [not found] ` <20150825085937.GD32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: joro-zLv9SwRftAIdnm+yROfE0A @ 2015-08-25 8:59 UTC (permalink / raw) To: Xiao, Nan (Nan@HPservers-Core-OE-PSC) Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Tue, Aug 25, 2015 at 08:46:27AM +0000, Xiao, Nan (Nan@HPservers-Core-OE-PSC) wrote: > Yes, your patch is simple and better! Okay, I queued this patch to my x86/vt-d branch: >From 03932776424a799c3f065a69e98076a78530288b Mon Sep 17 00:00:00 2001 From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> Date: Tue, 25 Aug 2015 10:54:28 +0200 Subject: [PATCH] iommu/vt-d: Really use upper context table when necessary There is a bug in iommu_context_addr() which will always use the lower context table, event when the upper context table needs to be used. Fix this issue. Fixes: 03ecc32c5274 ("iommu/vt-d: support extended root and context entries") Reported-by: Xiao, Nan <nan.xiao-VXdhtT5mjnY@public.gmane.org> Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a85077d..63daf1b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -803,6 +803,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; @@ -810,7 +811,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 { -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <20150825085937.GD32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* RE: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table [not found] ` <20150825085937.GD32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2015-08-25 9:15 ` Xiao, Nan (Nan@HPservers-Core-OE-PSC) 2015-08-25 9:42 ` joro 0 siblings, 1 reply; 7+ messages in thread From: Xiao, Nan (Nan@HPservers-Core-OE-PSC) @ 2015-08-25 9:15 UTC (permalink / raw) To: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Hi Joerg, In commit message: > There is a bug in iommu_context_addr() which will always use the lower context table, event when the upper context table needs to be used. Fix this issue. I think it should be " even when the upper context table ", not "event". Thanks! Best Regards Nan Xiao -----Original Message----- From: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org [mailto:joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org] Sent: Tuesday, August 25, 2015 5:00 PM To: Xiao, Nan (Nan@HPservers-Core-OE-PSC) Cc: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table On Tue, Aug 25, 2015 at 08:46:27AM +0000, Xiao, Nan (Nan@HPservers-Core-OE-PSC) wrote: > Yes, your patch is simple and better! Okay, I queued this patch to my x86/vt-d branch: >From 03932776424a799c3f065a69e98076a78530288b Mon Sep 17 00:00:00 2001 From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> Date: Tue, 25 Aug 2015 10:54:28 +0200 Subject: [PATCH] iommu/vt-d: Really use upper context table when necessary There is a bug in iommu_context_addr() which will always use the lower context table, event when the upper context table needs to be used. Fix this issue. Fixes: 03ecc32c5274 ("iommu/vt-d: support extended root and context entries") Reported-by: Xiao, Nan <nan.xiao-VXdhtT5mjnY@public.gmane.org> Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a85077d..63daf1b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -803,6 +803,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; @@ -810,7 +811,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 { -- 1.8.4.5 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table 2015-08-25 9:15 ` Xiao, Nan (Nan@HPservers-Core-OE-PSC) @ 2015-08-25 9:42 ` joro 0 siblings, 0 replies; 7+ messages in thread From: joro @ 2015-08-25 9:42 UTC (permalink / raw) To: Xiao, Nan (Nan@HPservers-Core-OE-PSC) Cc: dwmw2@infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org On Tue, Aug 25, 2015 at 09:15:39AM +0000, Xiao, Nan (Nan@HPservers-Core-OE-PSC) wrote: > In commit message: > > > There is a bug in iommu_context_addr() which will always use the lower context table, event when the upper context table needs to be used. Fix this issue. > > I think it should be " even when the upper context table ", not "event". Right, fixed that. Thanks for noticing. Joerg ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-25 9:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-21 10:32 [PATCH] Fix bug in iommu_context_addr: Always get pointer to lower extended-context-table Nan Xiao
-- strict thread matches above, loose matches on Subject: below --
2015-08-24 6:26 Xiao, Nan (Nan@HPS Performance, Beijing)
[not found] ` <F9D82F0D71C0024FA18FE771EDDAF149081FAC8F-qhK1pdpzgV8SZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2015-08-25 8:42 ` joro-zLv9SwRftAIdnm+yROfE0A
[not found] ` <20150825084208.GB32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-08-25 8:46 ` Xiao, Nan (Nan@HPservers-Core-OE-PSC)
[not found] ` <F9D82F0D71C0024FA18FE771EDDAF149082020ED-aJCdeS5/g6oSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2015-08-25 8:59 ` joro-zLv9SwRftAIdnm+yROfE0A
[not found] ` <20150825085937.GD32055-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-08-25 9:15 ` Xiao, Nan (Nan@HPservers-Core-OE-PSC)
2015-08-25 9:42 ` joro
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox