* [PATCH kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables
@ 2017-04-13 7:05 Alexey Kardashevskiy
2017-04-28 6:19 ` Alexey Kardashevskiy
2017-05-01 2:58 ` [kernel] " Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2017-04-13 7:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, David Gibson, Paul Mackerras
When the userspace requests a small TCE table (which takes less than
the system page size) and more than 1 TCE level, the existing code
returns a single page size which is a bug as each additional TCE level
requires at least one page and this is what
pnv_pci_ioda2_table_alloc_pages() does. And we end up seeing
WARN_ON(!ret && ((*ptbl)->it_allocated_size != table_size))
in drivers/vfio/vfio_iommu_spapr_tce.c.
This replaces incorrect _ALIGN_UP() (which aligns zero up to zero) with
max_t() to fix the bug.
Besides removing WARN_ON(), there should be no other changes in
behaviour.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 6d0da5dfc955..a0d046adcf45 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2538,7 +2538,8 @@ static unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
tce_table_size /= direct_table_size;
tce_table_size <<= 3;
- tce_table_size = _ALIGN_UP(tce_table_size, direct_table_size);
+ tce_table_size = max_t(unsigned long,
+ tce_table_size, direct_table_size);
}
return bytes;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables
2017-04-13 7:05 [PATCH kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables Alexey Kardashevskiy
@ 2017-04-28 6:19 ` Alexey Kardashevskiy
2017-05-01 2:58 ` [kernel] " Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2017-04-28 6:19 UTC (permalink / raw)
To: linuxppc-dev; +Cc: David Gibson, Paul Mackerras
On Thu, 13 Apr 2017 17:05:27 +1000
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> When the userspace requests a small TCE table (which takes less than
> the system page size) and more than 1 TCE level, the existing code
> returns a single page size which is a bug as each additional TCE level
> requires at least one page and this is what
> pnv_pci_ioda2_table_alloc_pages() does. And we end up seeing
> WARN_ON(!ret && ((*ptbl)->it_allocated_size != table_size))
> in drivers/vfio/vfio_iommu_spapr_tce.c.
>
> This replaces incorrect _ALIGN_UP() (which aligns zero up to zero) with
> max_t() to fix the bug.
>
> Besides removing WARN_ON(), there should be no other changes in
> behaviour.
Ping?
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 6d0da5dfc955..a0d046adcf45 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -2538,7 +2538,8 @@ static unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
>
> tce_table_size /= direct_table_size;
> tce_table_size <<= 3;
> - tce_table_size = _ALIGN_UP(tce_table_size, direct_table_size);
> + tce_table_size = max_t(unsigned long,
> + tce_table_size, direct_table_size);
> }
>
> return bytes;
--
Alexey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables
2017-04-13 7:05 [PATCH kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables Alexey Kardashevskiy
2017-04-28 6:19 ` Alexey Kardashevskiy
@ 2017-05-01 2:58 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-05-01 2:58 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev
Cc: Alexey Kardashevskiy, Paul Mackerras, David Gibson
On Thu, 2017-04-13 at 07:05:27 UTC, Alexey Kardashevskiy wrote:
> When the userspace requests a small TCE table (which takes less than
> the system page size) and more than 1 TCE level, the existing code
> returns a single page size which is a bug as each additional TCE level
> requires at least one page and this is what
> pnv_pci_ioda2_table_alloc_pages() does. And we end up seeing
> WARN_ON(!ret && ((*ptbl)->it_allocated_size != table_size))
> in drivers/vfio/vfio_iommu_spapr_tce.c.
>
> This replaces incorrect _ALIGN_UP() (which aligns zero up to zero) with
> max_t() to fix the bug.
>
> Besides removing WARN_ON(), there should be no other changes in
> behaviour.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/e49a6a2173346d316c0e65d054a3cd
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-01 2:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13 7:05 [PATCH kernel] powerpc/powernv: Fix iommu table size calculation hook for small tables Alexey Kardashevskiy
2017-04-28 6:19 ` Alexey Kardashevskiy
2017-05-01 2:58 ` [kernel] " Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.