* [PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation
@ 2015-03-13 8:36 Alexey Kardashevskiy
2015-03-13 8:55 ` Nikunj A Dadhania
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kardashevskiy @ 2015-03-13 8:36 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, Thomas Huth, Nikunj A Dadhania
Every caller of SLOF_alloc_mem_aligned() assumes the size is the first
argument while it is not.
This switches align and size and fixes random memory corruptions.
This is grep for SLOF_alloc_mem_aligned with this patch applied:
include/helpers.h|27| extern void *SLOF_alloc_mem_aligned(long size, long align);
lib/libveth/veth.c|103| buffer_list = SLOF_alloc_mem_aligned(8192, 4096);
lib/libveth/veth.c|105| rx_queue = SLOF_alloc_mem_aligned(rx_queue_len, 16);
lib/libvirtio/virtio-net.c|101| vq[i].desc = SLOF_alloc_mem_aligned(virtio_vring_size(vq[i].size), 4096);
slof/helpers.c|70| void *SLOF_alloc_mem_aligned(long size, long align)
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
include/helpers.h | 2 +-
slof/helpers.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/helpers.h b/include/helpers.h
index f6d4375..fb10534 100644
--- a/include/helpers.h
+++ b/include/helpers.h
@@ -24,7 +24,7 @@ extern void SLOF_usleep(uint32_t time);
extern void *SLOF_dma_alloc(long size);
extern void SLOF_dma_free(void *virt, long size);
extern void *SLOF_alloc_mem(long size);
-extern void *SLOF_alloc_mem_aligned(long align, long size);
+extern void *SLOF_alloc_mem_aligned(long size, long align);
extern void SLOF_free_mem(void *addr, long size);
extern long SLOF_dma_map_in(void *virt, long size, int cacheable);
extern void SLOF_dma_map_out(long phys, void *virt, long size);
diff --git a/slof/helpers.c b/slof/helpers.c
index c582996..d7c1888 100644
--- a/slof/helpers.c
+++ b/slof/helpers.c
@@ -67,7 +67,7 @@ void *SLOF_alloc_mem(long size)
return (void *)forth_pop();
}
-void *SLOF_alloc_mem_aligned(long align, long size)
+void *SLOF_alloc_mem_aligned(long size, long align)
{
unsigned long addr = (unsigned long)SLOF_alloc_mem(size + align - 1);
addr = addr + align - 1;
--
2.0.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation
2015-03-13 8:36 [PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation Alexey Kardashevskiy
@ 2015-03-13 8:55 ` Nikunj A Dadhania
0 siblings, 0 replies; 2+ messages in thread
From: Nikunj A Dadhania @ 2015-03-13 8:55 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev; +Cc: Alexey Kardashevskiy, Thomas Huth
Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> Every caller of SLOF_alloc_mem_aligned() assumes the size is the first
> argument while it is not.
>
> This switches align and size and fixes random memory corruptions.
>
> This is grep for SLOF_alloc_mem_aligned with this patch applied:
>
> include/helpers.h|27| extern void *SLOF_alloc_mem_aligned(long size, long align);
> lib/libveth/veth.c|103| buffer_list = SLOF_alloc_mem_aligned(8192, 4096);
> lib/libveth/veth.c|105| rx_queue = SLOF_alloc_mem_aligned(rx_queue_len, 16);
> lib/libvirtio/virtio-net.c|101| vq[i].desc = SLOF_alloc_mem_aligned(virtio_vring_size(vq[i].size), 4096);
> slof/helpers.c|70| void *SLOF_alloc_mem_aligned(long size, long align)
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
> ---
> include/helpers.h | 2 +-
> slof/helpers.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/helpers.h b/include/helpers.h
> index f6d4375..fb10534 100644
> --- a/include/helpers.h
> +++ b/include/helpers.h
> @@ -24,7 +24,7 @@ extern void SLOF_usleep(uint32_t time);
> extern void *SLOF_dma_alloc(long size);
> extern void SLOF_dma_free(void *virt, long size);
> extern void *SLOF_alloc_mem(long size);
> -extern void *SLOF_alloc_mem_aligned(long align, long size);
> +extern void *SLOF_alloc_mem_aligned(long size, long align);
> extern void SLOF_free_mem(void *addr, long size);
> extern long SLOF_dma_map_in(void *virt, long size, int cacheable);
> extern void SLOF_dma_map_out(long phys, void *virt, long size);
> diff --git a/slof/helpers.c b/slof/helpers.c
> index c582996..d7c1888 100644
> --- a/slof/helpers.c
> +++ b/slof/helpers.c
> @@ -67,7 +67,7 @@ void *SLOF_alloc_mem(long size)
> return (void *)forth_pop();
> }
>
> -void *SLOF_alloc_mem_aligned(long align, long size)
> +void *SLOF_alloc_mem_aligned(long size, long align)
> {
> unsigned long addr = (unsigned long)SLOF_alloc_mem(size + align - 1);
> addr = addr + align - 1;
> --
> 2.0.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-13 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 8:36 [PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation Alexey Kardashevskiy
2015-03-13 8:55 ` Nikunj A Dadhania
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.