diff mbox series

[kvm-unit-tests,2/2] s390x: fixing I/O memory allocation

Message ID 1629908421-8543-3-git-send-email-pmorel@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Two fixes for KVM unit tests | expand

Commit Message

Pierre Morel Aug. 25, 2021, 4:20 p.m. UTC
The allocator allocate pages it follows the size must be rounded
to pages before the allocation.

Fixes: b0fe3988 "s390x: define UV compatible I/O allocation"

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/malloc_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Claudio Imbrenda Aug. 25, 2021, 4:31 p.m. UTC | #1
On Wed, 25 Aug 2021 18:20:21 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> The allocator allocate pages it follows the size must be rounded
> to pages before the allocation.
> 
> Fixes: b0fe3988 "s390x: define UV compatible I/O allocation"
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  lib/s390x/malloc_io.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/s390x/malloc_io.c b/lib/s390x/malloc_io.c
> index 78582eac..080fc694 100644
> --- a/lib/s390x/malloc_io.c
> +++ b/lib/s390x/malloc_io.c
> @@ -41,7 +41,7 @@ static void unshare_pages(void *p, int count)
>  
>  void *alloc_io_mem(int size, int flags)
>  {
> -	int order = get_order(size >> PAGE_SHIFT);
> +	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
>  	void *p;
>  	int n;
>  
> @@ -62,7 +62,7 @@ void *alloc_io_mem(int size, int flags)
>  
>  void free_io_mem(void *p, int size)
>  {
> -	int order = get_order(size >> PAGE_SHIFT);
> +	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
>  
>  	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));
>
Pierre Morel Aug. 27, 2021, 9:39 a.m. UTC | #2
On 8/25/21 6:31 PM, Claudio Imbrenda wrote:
> On Wed, 25 Aug 2021 18:20:21 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> The allocator allocate pages it follows the size must be rounded
>> to pages before the allocation.
>>
>> Fixes: b0fe3988 "s390x: define UV compatible I/O allocation"
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> 
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> 


Thanks,
Pierre
diff mbox series

Patch

diff --git a/lib/s390x/malloc_io.c b/lib/s390x/malloc_io.c
index 78582eac..080fc694 100644
--- a/lib/s390x/malloc_io.c
+++ b/lib/s390x/malloc_io.c
@@ -41,7 +41,7 @@  static void unshare_pages(void *p, int count)
 
 void *alloc_io_mem(int size, int flags)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 	void *p;
 	int n;
 
@@ -62,7 +62,7 @@  void *alloc_io_mem(int size, int flags)
 
 void free_io_mem(void *p, int size)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 
 	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));