From patchwork Mon Aug 31 11:00:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 512431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6DFA71401DA for ; Mon, 31 Aug 2015 21:01:48 +1000 (AEST) Received: from localhost ([::1]:35866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWMqQ-0004TD-HU for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2015 07:01:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWMpq-0003b8-Dy for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:01:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWMpl-0007y1-U0 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:01:10 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:45671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWMpl-0007xw-L7 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:01:05 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Aug 2015 12:01:03 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 31 Aug 2015 12:01:02 +0100 X-Helo: d06dlp01.portsmouth.uk.ibm.com X-MailFrom: cornelia.huck@de.ibm.com X-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id B468817D8056 for ; Mon, 31 Aug 2015 12:02:43 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7VB0x9D19595314 for ; Mon, 31 Aug 2015 11:01:02 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7VB0n0X015408 for ; Mon, 31 Aug 2015 05:00:50 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-121.boeblingen.de.ibm.com [9.152.224.121]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t7VB0kXb014910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 31 Aug 2015 05:00:49 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Mon, 31 Aug 2015 13:00:32 +0200 Message-Id: <1441018834-8993-7-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1441018834-8993-1-git-send-email-cornelia.huck@de.ibm.com> References: <1441018834-8993-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15083111-0009-0000-0000-00000562A56E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.108 Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, jjherne@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 6/8] s390x: Info skeys sub-command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 0ef3aea..b8aacc8 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -65,6 +65,29 @@ static void write_keys(QEMUFile *f, uint8_t *keys, uint64_t startgfn, } } +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, },