[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] memory: use 128 bit in info mtree
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] memory: use 128 bit in info mtree |
Date: |
Sun, 12 Mar 2017 20:35:42 +0100 |
On 12 March 2017 at 20:12, Michael S. Tsirkin <address@hidden> wrote:
> info mtree is doing 64 bit math to figure out
> addresses from offsets, this does not work ncorrectly
> incase of overflow.
>
> Overflow usually indicates a guest bug, so this is unusual
> but reporting correct addresses makes it easier to discover
> what is going on.
>
> Reported-by: Mark Cave-Ayland <address@hidden>
> Cc: Paolo Bonzini <address@hidden>
> Signed-off-by: Michael S. Tsirkin <address@hidden>
> ---
> include/qemu/int128.h | 15 +++++++++++++++
> memory.c | 28 +++++++++++++++++-----------
> 2 files changed, 32 insertions(+), 11 deletions(-)
>
> diff --git a/include/qemu/int128.h b/include/qemu/int128.h
> index 5c9890d..8be5328 100644
> --- a/include/qemu/int128.h
> +++ b/include/qemu/int128.h
> @@ -302,4 +302,19 @@ static inline void int128_subfrom(Int128 *a, Int128 b)
> }
>
> #endif /* CONFIG_INT128 */
> +
> +#define INT128_FMT1_plx "0x%" PRIx64
> +#define INT128_FMT2_plx "%015" PRIx64
> +
> +static inline uint64_t int128_printf1(Int128 a)
> +{
> + /* We assume 4 highest bits are clear and safe to ignore */
> + return (int128_gethi(a) << 4) | (int128_getlo(a) >> 60);
> +}
> +
> +static inline uint64_t int128_printf2(Int128 a)
> +{
> + return (int128_getlo(a) << 4) >> 4;
> +}
I'm confused -- I was expecting these to just
be the two halves of the 128 bit integer to be
printed, but they seem to be doing something
more complicated...
thanks
-- PMM