On 12 March 2017 at 20:12, Michael S. Tsirkin <m...@redhat.com> 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 <mark.cave-ayl...@ilande.co.uk> > Cc: Paolo Bonzini <pbonz...@redhat.com> > Signed-off-by: Michael S. Tsirkin <m...@redhat.com> > --- > 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