Re: [PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-20 Thread Joerg Roedel
On Thu, Jun 20, 2013 at 01:46:48PM -0600, Alex Williamson wrote: > But that's true of a bug in any kernel code. I think the only danger > unique to recursion is using too much stack space, but I doubt that's > really an issue for a tiny function with a fixed depth like this. In > case you didn't

Re: [PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-20 Thread Alex Williamson
On Thu, 2013-06-20 at 21:26 +0200, Joerg Roedel wrote: > On Thu, Jun 20, 2013 at 01:08:00PM -0600, Alex Williamson wrote: > > On Thu, 2013-06-20 at 20:28 +0200, Joerg Roedel wrote: > > > Hmm, actually a recursive version would make more sense here. But since > > > recursion is a bad idea in the ker

Re: [PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-20 Thread Joerg Roedel
On Thu, Jun 20, 2013 at 01:08:00PM -0600, Alex Williamson wrote: > On Thu, 2013-06-20 at 20:28 +0200, Joerg Roedel wrote: > > Hmm, actually a recursive version would make more sense here. But since > > recursion is a bad idea in the kernel, how about this approach instead: > > It's a fixed maximum

Re: [PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-20 Thread Alex Williamson
On Thu, 2013-06-20 at 20:28 +0200, Joerg Roedel wrote: > On Mon, Jun 17, 2013 at 07:52:14PM -0600, Alex Williamson wrote: > > static void free_pagetable(struct protection_domain *domain) > > { > > - int i, j; > > - u64 *p1, *p2, *p3; > > + int i, j, k, l, m, depth = domain->mode; > > + u6

Re: [PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-20 Thread Joerg Roedel
On Mon, Jun 17, 2013 at 07:52:14PM -0600, Alex Williamson wrote: > static void free_pagetable(struct protection_domain *domain) > { > - int i, j; > - u64 *p1, *p2, *p3; > + int i, j, k, l, m, depth = domain->mode; > + u64 *p1, *p2, *p3, *p4, *p5, *p6; > > p1 = domain->pt_r

[PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-17 Thread Alex Williamson
AMD IOMMU initializes domains with a 3 level page table by default and will dynamically size it up to a 6 level page table. Sadly, free_pagetable() ignores this feature and statically frees as if it's a 3 level page table. Add support for the extra levels. Signed-off-by: Alex Williamson Cc: sta

[PATCH] amd_iommu: Fix leak in free_pagetable()

2013-06-17 Thread Alex Williamson
AMD IOMMU initializes domains with a 3 level page table by default and will dynamically size it up to a 6 level page table. Sadly, free_pagetable() ignores this feature and statically frees as if it's a 3 level page table. Recurse through all the levels to free everything. Signed-off-by: Alex Wi