From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWQNa-0002KJ-Tp for qemu-devel@nongnu.org; Mon, 31 Aug 2015 10:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWQNW-0005ZM-Oz for qemu-devel@nongnu.org; Mon, 31 Aug 2015 10:48:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWQNW-0005Yi-H5 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 10:48:10 -0400 References: <1441018834-8993-1-git-send-email-cornelia.huck@de.ibm.com> <1441018834-8993-5-git-send-email-cornelia.huck@de.ibm.com> From: Eric Blake Message-ID: <55E46923.4030304@redhat.com> Date: Mon, 31 Aug 2015 08:48:03 -0600 MIME-Version: 1.0 In-Reply-To: <1441018834-8993-5-git-send-email-cornelia.huck@de.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IJpLmxG9whE4vgfOPn5WcbfpxkDEomefq" Subject: Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck , qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, jjherne@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IJpLmxG9whE4vgfOPn5WcbfpxkDEomefq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/31/2015 05:00 AM, Cornelia Huck wrote: > From: "Jason J. Herne" >=20 > 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 supp= ort > within Qemu and for guest operating system developers. >=20 > Reviewed-by: Thomas Huth > Reviewed-by: David Hildenbrand > Signed-off-by: Jason J. Herne > Signed-off-by: Cornelia Huck > --- > hw/s390x/s390-skeys.c | 90 +++++++++++++++++++++++++++++++++++++++++++= ++++++-- > monitor.c | 7 ++++ > qapi-schema.json | 14 ++++++++ > qmp-commands.hx | 25 ++++++++++++++ > 4 files changed, 134 insertions(+), 2 deletions(-) >=20 > +static void write_keys(QEMUFile *f, uint8_t *keys, uint64_t startgfn, > + uint64_t count, Error **errp) > +{ > + uint64_t curpage =3D startgfn; > + uint64_t maxpage =3D curpage + count - 1; > + const char *fmt =3D "page=3D%03" PRIx64 ": key(%d) =3D> ACC=3D%X, = FP=3D%d, REF=3D%d," > + " ch=3D%d, reserved=3D%d\n"; > + char buf[128]; > + int len; > + > + for (; curpage <=3D maxpage; curpage++) { > + uint8_t acc =3D (*keys & 0xF0) >> 4; > + int fp =3D (*keys & 0x08); > + int ref =3D (*keys & 0x04); > + int ch =3D (*keys & 0x02); > + int res =3D (*keys & 0x01); > + > + len =3D 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. With an assert added, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --IJpLmxG9whE4vgfOPn5WcbfpxkDEomefq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5GkjAAoJEKeha0olJ0NqVN8H/RDJ3i7vbiOuZhAo/hMpnzUg wQuYmvx3JflFtdCNKEUrrEsB/KEzuj990AKWXT6+jlUzEnYeO9KdlXXhiLdU66FJ aUIB+VAxr6W8C6N7K82gkhDS93GEJgx0NYsHu3AdYJrLcP5JH+moeQsI78Zuo6sC pKJT4jlM93+GgaZjWpEbvZECj4YEv3ldn6in2r+23W0M6IViQWpAzZVYM7N3w6vZ byTdBGzelI3BELG6yG1OnpzqyTf4KshBjDIAT+uD0bCOKCHzL+/Z3ajN9i9vux+S B9YABocC9lSMfr/esSCKln8Bv8hBlK7oY2hNZyE7Y1tvT5e3OfJITnTysKbbgyM= =UUJQ -----END PGP SIGNATURE----- --IJpLmxG9whE4vgfOPn5WcbfpxkDEomefq--