From: David Gibson Date: Sun, 27 Aug 2017 03:19:29 +0000 Subject: Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace Message-Id: <20170827031929.GR2772@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="b0op/nKJ9CeIhp9z" List-Id: References: <20170825095339.GC14035@fergus.ozlabs.ibm.com> In-Reply-To: <20170825095339.GC14035@fergus.ozlabs.ibm.com> To: Paul Mackerras Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org --b0op/nKJ9CeIhp9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote: > This adds information about storage keys to the struct returned by > the KVM_PPC_GET_SMMU_INFO ioctl. The new fields replace a pad field, > which was zeroed by previous kernel versions. Thus userspace that > knows about the new fields will see zeroes when running on an older > kernel, indicating that storage keys are not supported. The size of > the structure has not changed. >=20 > The number of keys is hard-coded for the CPUs supported by HV KVM, > which is just POWER7, POWER8 and POWER9. >=20 > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson > --- > This is intended to go in after Ram Pai's patch fixing the H_ENTER > code to not drop the top two bits of the key field. >=20 > arch/powerpc/kvm/book3s_hv.c | 8 ++++++++ > include/uapi/linux/kvm.h | 3 ++- > 2 files changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 359c79c..3d9b661 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kv= m *kvm, > if (radix_enabled()) > return -EINVAL; > =20 > + /* > + * POWER7, POWER8 and POWER9 all support 32 storage keys for data. > + * POWER7 doesn't support keys for instruction accesses, > + * POWER8 and POWER9 do. > + */ > + info->data_keys =3D 32; > + info->instr_keys =3D cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0; > + > info->flags =3D KVM_PPC_PAGE_SIZES_REAL; > if (mmu_has_feature(MMU_FTR_1T_SEGMENT)) > info->flags |=3D KVM_PPC_1T_SEGMENTS; > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > index 6cd63c1..8388875 100644 > --- a/include/uapi/linux/kvm.h > +++ b/include/uapi/linux/kvm.h > @@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size { > struct kvm_ppc_smmu_info { > __u64 flags; > __u32 slb_size; > - __u32 pad; > + __u16 data_keys; /* # storage keys supported for data */ > + __u16 instr_keys; /* # storage keys supported for instructions */ > struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; > }; > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --b0op/nKJ9CeIhp9z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlmiOj8ACgkQbDjKyiDZ s5IS4RAA4KSZcUOS+z2W7+GMBgObZzBo/cCsbLpFvKVX92H4enQAqwBtYTvptcGr IIGUlHsqgSITBm9WbOtfgIDX9sgWMwFVM58SrwL2DGkdeu/kb5Rgjl+tVdvH/OsF Y8cu8s7CBg7F9tXYamFLWk4i3O8m1PtVyFVXUbj+8IABBCfyX5NvxALnPF0Uxwzi CSac8VOQWDAQvYiYCtupwml9qkxK9gljuq5iKtZcKjNZicLdWdJWpt49qDfIEzA4 1aQ2gOmwq/aAQNcz2/KBeK/bTsWJ2JVv5vJecy7NPayjz+BjH8PU70zn5kYiKHeM /GwfSTZj2sEoKb1g4Au/uhQO8SORr8g9EHHgUOUV/NRW7Q7V8yXFVf4k1679Rmis qOMp9Gw7wtM5IM6e23ej1A9VzsOcj7DJjF/PXBkYO0KUGCqnwiH/IXxav4SkHEF6 21/5xC/zyzo+KIeGmX0vysvYuXcqRPF+obeGjHk11KwJXKG2XOiGUIj37SdoVXmU VB0mZocVgHRDHzLkoI9YPyBKy1+mmK7ltBtjUlJMnLKBxlBxFOuo2rBmhByzjyCR FS2qS0ZnyTgey7Vnakg5rEKUjdH31xUWACArVv8ihvjPqk4eICFUmHvQvbcEvjw3 qqshmjD5dAJ9/nwqOwZ/P613LDlMQs9HgINYoPJzwjiI7WGFO8g= =/IYw -----END PGP SIGNATURE----- --b0op/nKJ9CeIhp9z--