qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command


From: Cornelia Huck
Subject: Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command
Date: Mon, 31 Aug 2015 17:20:08 +0200

On Mon, 31 Aug 2015 08:48:03 -0600
Eric Blake <address@hidden> wrote:

> On 08/31/2015 05:00 AM, Cornelia Huck wrote:
> > From: "Jason J. Herne" <address@hidden>
> > 
> > Provide a dump-skeys qmp command to allow the end user to dump storage
> > keys. This is useful for debugging problems with guest storage key support
> > within Qemu and for guest operating system developers.
> > 
> > Reviewed-by: Thomas Huth <address@hidden>
> > Reviewed-by: David Hildenbrand <address@hidden>
> > Signed-off-by: Jason J. Herne <address@hidden>
> > Signed-off-by: Cornelia Huck <address@hidden>
> > ---
> >  hw/s390x/s390-skeys.c | 90 
> > +++++++++++++++++++++++++++++++++++++++++++++++++--
> >  monitor.c             |  7 ++++
> >  qapi-schema.json      | 14 ++++++++
> >  qmp-commands.hx       | 25 ++++++++++++++
> >  4 files changed, 134 insertions(+), 2 deletions(-)
> > 
> 
> > +static void write_keys(QEMUFile *f, uint8_t *keys, uint64_t startgfn,
> > +                       uint64_t count, Error **errp)
> > +{
> > +    uint64_t curpage = startgfn;
> > +    uint64_t maxpage = curpage + count - 1;
> > +    const char *fmt = "page=%03" PRIx64 ": key(%d) => ACC=%X, FP=%d, 
> > REF=%d,"
> > +                      " ch=%d, reserved=%d\n";
> > +    char buf[128];
> > +    int len;
> > +
> > +    for (; curpage <= maxpage; curpage++) {
> > +        uint8_t acc = (*keys & 0xF0) >> 4;
> > +        int fp =  (*keys & 0x08);
> > +        int ref = (*keys & 0x04);
> > +        int ch = (*keys & 0x02);
> > +        int res = (*keys & 0x01);
> > +
> > +        len = snprintf(buf, sizeof(buf), fmt, curpage,
> > +                       *keys, acc, fp, ref, ch, res);
> > +        qemu_put_buffer(f, (uint8_t *)buf, len);
> 
> While I can overlook the use of snprintf(), I still think you ought to
> at least have assert(len < sizeof(buf)) here before the
> qemu_put_buffer(), to ensure that future changes to fmt don't attempt to
> print beyond the end of the fixed-width buffer.

I'll just merge that in when sending the pull request.

> 
> With an assert added,
> Reviewed-by: Eric Blake <address@hidden>
> 
Thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]