diff mbox

memory: fix 128 arithmetic in info mtree

Message ID 1377850238-10270-1-git-send-email-aik@ozlabs.ru
State New
Headers show

Commit Message

Alexey Kardashevskiy Aug. 30, 2013, 8:10 a.m. UTC
mtree_print_mr() calls int128_get64() in 3 places but only 2 places
handle 2^64 correctly.

This fixes the third call of int128_get64().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 memory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alexey Kardashevskiy Sept. 10, 2013, 4:19 a.m. UTC | #1
On 08/30/2013 06:10 PM, Alexey Kardashevskiy wrote:
> mtree_print_mr() calls int128_get64() in 3 places but only 2 places
> handle 2^64 correctly.
> 
> This fixes the third call of int128_get64().
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  memory.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/memory.c b/memory.c
> index ffedde7..93f2995 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1816,7 +1816,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>                     mr->alias->name,
>                     mr->alias_offset,
>                     mr->alias_offset
> -                   + (hwaddr)int128_get64(mr->size) - 1);
> +                   + (int128_nz(mr->size) ?
> +                      (hwaddr)int128_get64(int128_sub(mr->size,
> +                                                      int128_one())) : 0));
>      } else {
>          mon_printf(f,
>                     TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
> 


Ping?
Alexey Kardashevskiy Sept. 25, 2013, 10:46 a.m. UTC | #2
On 09/10/2013 02:19 PM, Alexey Kardashevskiy wrote:
> On 08/30/2013 06:10 PM, Alexey Kardashevskiy wrote:
>> mtree_print_mr() calls int128_get64() in 3 places but only 2 places
>> handle 2^64 correctly.
>>
>> This fixes the third call of int128_get64().
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>  memory.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/memory.c b/memory.c
>> index ffedde7..93f2995 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -1816,7 +1816,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>>                     mr->alias->name,
>>                     mr->alias_offset,
>>                     mr->alias_offset
>> -                   + (hwaddr)int128_get64(mr->size) - 1);
>> +                   + (int128_nz(mr->size) ?
>> +                      (hwaddr)int128_get64(int128_sub(mr->size,
>> +                                                      int128_one())) : 0));
>>      } else {
>>          mon_printf(f,
>>                     TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
>>
> 
> 
> Ping?


Ping?
Paolo Bonzini Sept. 25, 2013, 11:27 a.m. UTC | #3
Il 30/08/2013 10:10, Alexey Kardashevskiy ha scritto:
> mtree_print_mr() calls int128_get64() in 3 places but only 2 places
> handle 2^64 correctly.
> 
> This fixes the third call of int128_get64().
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  memory.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/memory.c b/memory.c
> index ffedde7..93f2995 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1816,7 +1816,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>                     mr->alias->name,
>                     mr->alias_offset,
>                     mr->alias_offset
> -                   + (hwaddr)int128_get64(mr->size) - 1);
> +                   + (int128_nz(mr->size) ?
> +                      (hwaddr)int128_get64(int128_sub(mr->size,
> +                                                      int128_one())) : 0));
>      } else {
>          mon_printf(f,
>                     TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
> 

Applied to my iommu branch, which I should eventually rename. :)

Thanks,

Paolo
diff mbox

Patch

diff --git a/memory.c b/memory.c
index ffedde7..93f2995 100644
--- a/memory.c
+++ b/memory.c
@@ -1816,7 +1816,9 @@  static void mtree_print_mr(fprintf_function mon_printf, void *f,
                    mr->alias->name,
                    mr->alias_offset,
                    mr->alias_offset
-                   + (hwaddr)int128_get64(mr->size) - 1);
+                   + (int128_nz(mr->size) ?
+                      (hwaddr)int128_get64(int128_sub(mr->size,
+                                                      int128_one())) : 0));
     } else {
         mon_printf(f,
                    TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",