linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()
@ 2020-12-23  6:24 Zhenzhong Duan
  2020-12-30  7:02 ` Borislav Petkov
  2021-01-04 19:02 ` Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 5+ messages in thread
From: Zhenzhong Duan @ 2020-12-23  6:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: zhongjiang, joe, konrad.wilk, tglx, mingo, bp, iommu, dwmw2,
	baolu.lu, joro, will, Zhenzhong Duan

check_iommu_entries() checks for cyclic dependency in iommu entries
and fixes the cyclic dependency by setting x->depend to NULL. But
this repairing isn't correct if q is in front of p, there will be
"EXECUTION ORDER INVALID!" report following. Fix it by NULLing
whichever in the front.

The second issue is about the report of exectuion order reverse,
the order is reversed incorrectly in the report, fix it.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
---
 arch/x86/kernel/pci-iommu_table.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
index 2e9006c..40c8249 100644
--- a/arch/x86/kernel/pci-iommu_table.c
+++ b/arch/x86/kernel/pci-iommu_table.c
@@ -60,7 +60,10 @@ void __init check_iommu_entries(struct iommu_table_entry *start,
 			printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n",
 			       p->detect, q->detect);
 			/* Heavy handed way..*/
-			x->depend = NULL;
+			if (p > q)
+				q->depend = NULL;
+			else
+				p->depend = NULL;
 		}
 	}
 
@@ -68,7 +71,7 @@ void __init check_iommu_entries(struct iommu_table_entry *start,
 		q = find_dependents_of(p, finish, p);
 		if (q && q > p) {
 			printk(KERN_ERR "EXECUTION ORDER INVALID! %pS should be called before %pS!\n",
-			       p->detect, q->detect);
+			       q->detect, p->detect);
 		}
 	}
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()
  2020-12-23  6:24 [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries() Zhenzhong Duan
@ 2020-12-30  7:02 ` Borislav Petkov
  2021-01-04  5:43   ` Zhenzhong Duan
  2021-01-04 19:02 ` Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2020-12-30  7:02 UTC (permalink / raw)
  To: Zhenzhong Duan
  Cc: linux-kernel, zhongjiang, joe, konrad.wilk, tglx, mingo, iommu,
	dwmw2, baolu.lu, joro, will

On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote:
> check_iommu_entries() checks for cyclic dependency in iommu entries
> and fixes the cyclic dependency by setting x->depend to NULL. But
> this repairing isn't correct if q is in front of p, there will be
> "EXECUTION ORDER INVALID!" report following. Fix it by NULLing
> whichever in the front.

When does "q is in front of p" happen? How does it happen?

> The second issue is about the report of exectuion order reverse,
> the order is reversed incorrectly in the report, fix it.

I have no clue what that means.

Plese structure your commit message something like this:

Problem is A.

It happens because of B.

Fix it by doing C.

(Potentially do D).

For more detailed info, see
Documentation/process/submitting-patches.rst, Section "2) Describe your
changes".

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()
  2020-12-30  7:02 ` Borislav Petkov
@ 2021-01-04  5:43   ` Zhenzhong Duan
  0 siblings, 0 replies; 5+ messages in thread
From: Zhenzhong Duan @ 2021-01-04  5:43 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: linux-kernel, zhongjiang, joe, konrad.wilk, Thomas Gleixner,
	Ingo Molnar, iommu, David Woodhouse, Lu Baolu, Joerg Roedel,
	will

On Wed, Dec 30, 2020 at 3:02 PM Borislav Petkov <bp@alien8.de> wrote:
>
> On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote:
> > check_iommu_entries() checks for cyclic dependency in iommu entries
> > and fixes the cyclic dependency by setting x->depend to NULL. But
> > this repairing isn't correct if q is in front of p, there will be
> > "EXECUTION ORDER INVALID!" report following. Fix it by NULLing
> > whichever in the front.
>
> When does "q is in front of p" happen? How does it happen?

Sorry, just realized it never happen.
>
> > The second issue is about the report of exectuion order reverse,
> > the order is reversed incorrectly in the report, fix it.
>
> I have no clue what that means.

I mean if p depends on q, then q->detect should be called before p->detect.
The message generated by printk() is wrong.

Regards
Zhenzhong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()
  2020-12-23  6:24 [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries() Zhenzhong Duan
  2020-12-30  7:02 ` Borislav Petkov
@ 2021-01-04 19:02 ` Konrad Rzeszutek Wilk
  2021-01-07  2:51   ` Zhenzhong Duan
  1 sibling, 1 reply; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2021-01-04 19:02 UTC (permalink / raw)
  To: Zhenzhong Duan
  Cc: linux-kernel, zhongjiang, joe, tglx, mingo, bp, iommu, dwmw2,
	baolu.lu, joro, will

On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote:
> check_iommu_entries() checks for cyclic dependency in iommu entries
> and fixes the cyclic dependency by setting x->depend to NULL. But
> this repairing isn't correct if q is in front of p, there will be
> "EXECUTION ORDER INVALID!" report following. Fix it by NULLing
> whichever in the front.
> 
> The second issue is about the report of exectuion order reverse,
> the order is reversed incorrectly in the report, fix it.

Heya!

When you debugged this, did you by any chance save the
serial logs and the debug logs to double-check it?

Thanks!
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
> ---
>  arch/x86/kernel/pci-iommu_table.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
> index 2e9006c..40c8249 100644
> --- a/arch/x86/kernel/pci-iommu_table.c
> +++ b/arch/x86/kernel/pci-iommu_table.c
> @@ -60,7 +60,10 @@ void __init check_iommu_entries(struct iommu_table_entry *start,
>  			printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n",
>  			       p->detect, q->detect);
>  			/* Heavy handed way..*/
> -			x->depend = NULL;
> +			if (p > q)
> +				q->depend = NULL;
> +			else
> +				p->depend = NULL;
>  		}
>  	}
>  
> @@ -68,7 +71,7 @@ void __init check_iommu_entries(struct iommu_table_entry *start,
>  		q = find_dependents_of(p, finish, p);
>  		if (q && q > p) {
>  			printk(KERN_ERR "EXECUTION ORDER INVALID! %pS should be called before %pS!\n",
> -			       p->detect, q->detect);
> +			       q->detect, p->detect);
>  		}
>  	}
>  }
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()
  2021-01-04 19:02 ` Konrad Rzeszutek Wilk
@ 2021-01-07  2:51   ` Zhenzhong Duan
  0 siblings, 0 replies; 5+ messages in thread
From: Zhenzhong Duan @ 2021-01-07  2:51 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: linux-kernel, zhongjiang, joe, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, iommu, David Woodhouse, Lu Baolu, Joerg Roedel,
	will

On Tue, Jan 5, 2021 at 3:04 AM Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
>
> On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote:
> > check_iommu_entries() checks for cyclic dependency in iommu entries
> > and fixes the cyclic dependency by setting x->depend to NULL. But
> > this repairing isn't correct if q is in front of p, there will be
> > "EXECUTION ORDER INVALID!" report following. Fix it by NULLing
> > whichever in the front.
> >
> > The second issue is about the report of exectuion order reverse,
> > the order is reversed incorrectly in the report, fix it.
>
> Heya!
>
> When you debugged this, did you by any chance save the
> serial logs and the debug logs to double-check it?

Hi Konrad,

The iommu_table_entry is sorted by sort_iommu_table() and
check_iommu_entries() finds nothing abnormal,
so there is no related logs to check.

Sorry for my poor english, I'm not saying there is order reverse, even
if there is, it will be repaired by sort_iommu_table(). Then
check_iommu_entries() report nothing.
What I mean is about check_iommu_entries() itself, below printk isn't correct.

printk(KERN_ERR "EXECUTION ORDER INVALID! %pS should be called before %pS!\n",
                               p->detect, q->detect);

Should be:

printk(KERN_ERR "EXECUTION ORDER INVALID! %pS should be called before %pS!\n",
                               q->detect, p->detect);

Regards
Zhenzhong

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-07  2:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23  6:24 [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries() Zhenzhong Duan
2020-12-30  7:02 ` Borislav Petkov
2021-01-04  5:43   ` Zhenzhong Duan
2021-01-04 19:02 ` Konrad Rzeszutek Wilk
2021-01-07  2:51   ` Zhenzhong Duan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).