[{"id":1758198,"web_url":"http://patchwork.ozlabs.org/comment/1758198/","msgid":"<20170827031929.GR2772@umbus.fritz.box>","list_archive_url":null,"date":"2017-08-27T03:19:29","subject":"Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to\n\tuserspace","submitter":{"id":47,"url":"http://patchwork.ozlabs.org/api/people/47/","name":"David Gibson","email":"david@gibson.dropbear.id.au"},"content":"On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:\n> This adds information about storage keys to the struct returned by\n> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,\n> which was zeroed by previous kernel versions.  Thus userspace that\n> knows about the new fields will see zeroes when running on an older\n> kernel, indicating that storage keys are not supported.  The size of\n> the structure has not changed.\n> \n> The number of keys is hard-coded for the CPUs supported by HV KVM,\n> which is just POWER7, POWER8 and POWER9.\n> \n> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>\n\nReviewed-by: David Gibson <david@gibson.dropbear.id.au>\n\n> ---\n> This is intended to go in after Ram Pai's patch fixing the H_ENTER\n> code to not drop the top two bits of the key field.\n> \n>  arch/powerpc/kvm/book3s_hv.c | 8 ++++++++\n>  include/uapi/linux/kvm.h     | 3 ++-\n>  2 files changed, 10 insertions(+), 1 deletion(-)\n> \n> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c\n> index 359c79c..3d9b661 100644\n> --- a/arch/powerpc/kvm/book3s_hv.c\n> +++ b/arch/powerpc/kvm/book3s_hv.c\n> @@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,\n>  \tif (radix_enabled())\n>  \t\treturn -EINVAL;\n>  \n> +\t/*\n> +\t * POWER7, POWER8 and POWER9 all support 32 storage keys for data.\n> +\t * POWER7 doesn't support keys for instruction accesses,\n> +\t * POWER8 and POWER9 do.\n> +\t */\n> +\tinfo->data_keys = 32;\n> +\tinfo->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0;\n> +\n>  \tinfo->flags = KVM_PPC_PAGE_SIZES_REAL;\n>  \tif (mmu_has_feature(MMU_FTR_1T_SEGMENT))\n>  \t\tinfo->flags |= KVM_PPC_1T_SEGMENTS;\n> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h\n> index 6cd63c1..8388875 100644\n> --- a/include/uapi/linux/kvm.h\n> +++ b/include/uapi/linux/kvm.h\n> @@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {\n>  struct kvm_ppc_smmu_info {\n>  \t__u64 flags;\n>  \t__u32 slb_size;\n> -\t__u32 pad;\n> +\t__u16 data_keys;\t/* # storage keys supported for data */\n> +\t__u16 instr_keys;\t/* # storage keys supported for instructions */\n>  \tstruct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];\n>  };\n>","headers":{"Return-Path":"<kvm-ppc-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=kvm-ppc-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au header.b=\"nNSy8ibC\"; \n\tdkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xg0WJ3Tpwz9t3P\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 27 Aug 2017 13:19:40 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751152AbdH0DTi (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSat, 26 Aug 2017 23:19:38 -0400","from ozlabs.org ([103.22.144.67]:42837 \"EHLO ozlabs.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751112AbdH0DTh (ORCPT <rfc822;kvm-ppc@vger.kernel.org>);\n\tSat, 26 Aug 2017 23:19:37 -0400","by ozlabs.org (Postfix, from userid 1007)\n\tid 3xg0WB35hTz9t39; Sun, 27 Aug 2017 13:19:34 +1000 (AEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=gibson.dropbear.id.au; s=201602; t=1503803974;\n\tbh=MYJhDwc2786LMr6w6uaX9h1j9laygVeHXib6FHS75hA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nNSy8ibCNBLUOIvTnV0qhnaoH7TVmBj3C8IOI+8srASkTe8tlq1JVsx2Z8sqtIkur\n\tWRmHNpy7z/Pbyej2eIOE/9OQNITJTfDZtOrqJt1136LhFhbDtERT/a/lqUy+0OeB7d\n\t3pch3CzPNaJmcfStXFsFPONX/5QL4IzZkVQt0yk0=","Date":"Sun, 27 Aug 2017 13:19:29 +1000","From":"David Gibson <david@gibson.dropbear.id.au>","To":"Paul Mackerras <paulus@ozlabs.org>","Cc":"kvm@vger.kernel.org, kvm-ppc@vger.kernel.org","Subject":"Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to\n\tuserspace","Message-ID":"<20170827031929.GR2772@umbus.fritz.box>","References":"<20170825095339.GC14035@fergus.ozlabs.ibm.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"b0op/nKJ9CeIhp9z\"","Content-Disposition":"inline","In-Reply-To":"<20170825095339.GC14035@fergus.ozlabs.ibm.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","Sender":"kvm-ppc-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<kvm-ppc.vger.kernel.org>","X-Mailing-List":"kvm-ppc@vger.kernel.org"}},{"id":1760617,"web_url":"http://patchwork.ozlabs.org/comment/1760617/","msgid":"<20170831034330.GF22549@fergus.ozlabs.ibm.com>","list_archive_url":null,"date":"2017-08-31T03:43:30","subject":"Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to\n\tuserspace","submitter":{"id":67079,"url":"http://patchwork.ozlabs.org/api/people/67079/","name":"Paul Mackerras","email":"paulus@ozlabs.org"},"content":"On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:\n> This adds information about storage keys to the struct returned by\n> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,\n> which was zeroed by previous kernel versions.  Thus userspace that\n> knows about the new fields will see zeroes when running on an older\n> kernel, indicating that storage keys are not supported.  The size of\n> the structure has not changed.\n> \n> The number of keys is hard-coded for the CPUs supported by HV KVM,\n> which is just POWER7, POWER8 and POWER9.\n> \n> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>\n\nPatch applied to my kvm-ppc-next branch.\n\nPaul.\n--\nTo unsubscribe from this list: send the line \"unsubscribe kvm-ppc\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html","headers":{"Return-Path":"<kvm-ppc-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=kvm-ppc-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tsecure) header.d=ozlabs.org header.i=@ozlabs.org header.b=\"AmDAXiwW\";\n\tdkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjSsy2mkYz9sRq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 13:44:22 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751323AbdHaDoL (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 30 Aug 2017 23:44:11 -0400","from ozlabs.org ([103.22.144.67]:35293 \"EHLO ozlabs.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751016AbdHaDoK (ORCPT <rfc822;kvm-ppc@vger.kernel.org>);\n\tWed, 30 Aug 2017 23:44:10 -0400","by ozlabs.org (Postfix, from userid 1003)\n\tid 3xjSsj1Vhsz9sNr; Thu, 31 Aug 2017 13:44:09 +1000 (AEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; \n\tt=1504151049; bh=K7Ga50SzzNUYp07g6xPfwR9zFJxgPWb13WkdyMam4n8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AmDAXiwWNzVwpDBDaNngUNXrFilkX3R+VTP/Dif4O34lnDszFFb3WByxdOHiqiKEk\n\tKE4KJgevUzZhfxftyxbjjHTGSme9q5j1kspeO4QCcb/VDfK9jFxjbWQ5+cKWLeQvjb\n\tX+GC/mpXN9amXyT3HwEl0NQDj+VT+a/1da/qHamn53zk+rs3zmITu7NOV4JX+x8kvC\n\tzNE3Thlg+xv9Lbae/wUMPy5B6r1/IbSNMfukXqkmnQStHBSCcrVJ4eibpwyEXGFfvt\n\tKFTZH9Td4u8cexVmQL2mFlcyWbZhxaxKDlqfMoo494SMtG29HMPx27KKpAF33YAf2y\n\t/ogiD8/f4Msdw==","Date":"Thu, 31 Aug 2017 13:43:30 +1000","From":"Paul Mackerras <paulus@ozlabs.org>","To":"kvm@vger.kernel.org, kvm-ppc@vger.kernel.org","Cc":"David Gibson <david@gibson.dropbear.id.au>","Subject":"Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to\n\tuserspace","Message-ID":"<20170831034330.GF22549@fergus.ozlabs.ibm.com>","References":"<20170825095339.GC14035@fergus.ozlabs.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170825095339.GC14035@fergus.ozlabs.ibm.com>","User-Agent":"Mutt/1.5.24 (2015-08-30)","Sender":"kvm-ppc-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<kvm-ppc.vger.kernel.org>","X-Mailing-List":"kvm-ppc@vger.kernel.org"}}]