From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUGoi-00020k-HU for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUGog-0001vn-JD for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:20 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:45796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUGog-0001uz-AN for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:18 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Aug 2015 17:11:17 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 87EF717D805A for ; Tue, 25 Aug 2015 17:12:52 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7PGBD7G33816696 for ; Tue, 25 Aug 2015 16:11:13 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7PGB30j017689 for ; Tue, 25 Aug 2015 10:11:04 -0600 From: Cornelia Huck Date: Tue, 25 Aug 2015 18:10:48 +0200 Message-Id: <1440519050-17986-7-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1440519050-17986-1-git-send-email-cornelia.huck@de.ibm.com> References: <1440519050-17986-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH v2 6/8] s390x: Info skeys sub-command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, jjherne@linux.vnet.ibm.com From: "Jason J. Herne" Provide an info skeys hmp sub-command to allow the end user to dump a storage key for a given address. This is useful for guest operating system developers. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Jason J. Herne Signed-off-by: Cornelia Huck --- hmp-commands.hx | 2 ++ hw/s390x/s390-skeys.c | 23 +++++++++++++++++++++++ include/hw/s390x/storage-keys.h | 2 ++ monitor.c | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 803ff91..c61468e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1806,6 +1806,8 @@ show roms show the TPM device @item info memory-devices show the memory devices +@item info skeys +Display the value of a storage key (s390 only) @end table ETEXI diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index f6a29ab..0b13d77 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -72,6 +72,29 @@ static void write_keys(QEMUFile *f, uint8_t *keys, uint64_t startgfn, g_free(buf); } +void hmp_info_skeys(Monitor *mon, const QDict *qdict) +{ + S390SKeysState *ss = s390_get_skeys_device(); + S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss); + uint64_t addr = qdict_get_int(qdict, "addr"); + uint8_t key; + int r; + + /* Quick check to see if guest is using storage keys*/ + if (!skeyclass->skeys_enabled(ss)) { + monitor_printf(mon, "Error: This guest is not using storage keys.\n"); + return; + } + + r = skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key); + if (r < 0) { + monitor_printf(mon, "Error: %s\n", strerror(-r)); + return; + } + + monitor_printf(mon, " key: 0x%X\n", key); +} + void hmp_dump_skeys(Monitor *mon, const QDict *qdict) { const char *filename = qdict_get_str(qdict, "filename"); diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h index 0d04f19..18e08d2 100644 --- a/include/hw/s390x/storage-keys.h +++ b/include/hw/s390x/storage-keys.h @@ -54,4 +54,6 @@ void s390_skeys_init(void); S390SKeysState *s390_get_skeys_device(void); void hmp_dump_skeys(Monitor *mon, const QDict *qdict); +void hmp_info_skeys(Monitor *mon, const QDict *qdict); + #endif /* __S390_STORAGE_KEYS_H */ diff --git a/monitor.c b/monitor.c index 3deba38..451af6f 100644 --- a/monitor.c +++ b/monitor.c @@ -2881,6 +2881,15 @@ static mon_cmd_t info_cmds[] = { .help = "Show rocker OF-DPA groups", .mhandler.cmd = hmp_rocker_of_dpa_groups, }, +#if defined(TARGET_S390X) + { + .name = "skeys", + .args_type = "addr:l", + .params = "address", + .help = "Display the value of a storage key", + .mhandler.cmd = hmp_info_skeys, + }, +#endif { .name = NULL, }, -- 2.5.0