From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [PATCH 15/19] KVM: PPC: Book3S HV: add get/set accessors for the source configuration Date: Thu, 7 Feb 2019 13:48:55 +1100 Message-ID: <20190207024855.GZ22661@umbus.fritz.box> References: <20190107184331.8429-1-clg@kaod.org> <20190107184331.8429-16-clg@kaod.org> <20190204052148.GH1927@umbus.fritz.box> <02ee0470-3c6a-5c5c-a903-44e172ce1ed5@kaod.org> <20190205053233.GG22661@umbus.fritz.box> <20190206012329.GQ22661@umbus.fritz.box> <20190206012447.GR22661@umbus.fritz.box> <1d92005a-c12d-1a55-d01b-98eded13629c@kaod.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+vcRm3WFmV0Q/ShD" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Paul Mackerras , linuxppc-dev@lists.ozlabs.org To: =?iso-8859-1?Q?C=E9dric?= Le Goater Return-path: Content-Disposition: inline In-Reply-To: <1d92005a-c12d-1a55-d01b-98eded13629c@kaod.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane.org@lists.ozlabs.org Sender: "Linuxppc-dev" List-Id: kvm.vger.kernel.org --+vcRm3WFmV0Q/ShD Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 06, 2019 at 08:07:36AM +0100, C=E9dric Le Goater wrote: > On 2/6/19 2:24 AM, David Gibson wrote: > > On Wed, Feb 06, 2019 at 12:23:29PM +1100, David Gibson wrote: > >> On Tue, Feb 05, 2019 at 02:03:11PM +0100, C=E9dric Le Goater wrote: > >>> On 2/5/19 6:32 AM, David Gibson wrote: > >>>> On Mon, Feb 04, 2019 at 05:07:28PM +0100, C=E9dric Le Goater wrote: > >>>>> On 2/4/19 6:21 AM, David Gibson wrote: > >>>>>> On Mon, Jan 07, 2019 at 07:43:27PM +0100, C=E9dric Le Goater wrote: > >>>>>>> Theses are use to capure the XIVE EAS table of the KVM device, the > >>>>>>> configuration of the source targets. > >>>>>>> > >>>>>>> Signed-off-by: C=E9dric Le Goater > >>>>>>> --- > >>>>>>> arch/powerpc/include/uapi/asm/kvm.h | 11 ++++ > >>>>>>> arch/powerpc/kvm/book3s_xive_native.c | 87 +++++++++++++++++++++= ++++++ > >>>>>>> 2 files changed, 98 insertions(+) > >>>>>>> > >>>>>>> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/i= nclude/uapi/asm/kvm.h > >>>>>>> index 1a8740629acf..faf024f39858 100644 > >>>>>>> --- a/arch/powerpc/include/uapi/asm/kvm.h > >>>>>>> +++ b/arch/powerpc/include/uapi/asm/kvm.h > >>>>>>> @@ -683,9 +683,20 @@ struct kvm_ppc_cpu_char { > >>>>>>> #define KVM_DEV_XIVE_SAVE_EQ_PAGES 4 > >>>>>>> #define KVM_DEV_XIVE_GRP_SOURCES 2 /* 64-bit source attributes */ > >>>>>>> #define KVM_DEV_XIVE_GRP_SYNC 3 /* 64-bit source attributes */ > >>>>>>> +#define KVM_DEV_XIVE_GRP_EAS 4 /* 64-bit eas attributes */ > >>>>>>> =20 > >>>>>>> /* Layout of 64-bit XIVE source attribute values */ > >>>>>>> #define KVM_XIVE_LEVEL_SENSITIVE (1ULL << 0) > >>>>>>> #define KVM_XIVE_LEVEL_ASSERTED (1ULL << 1) > >>>>>>> =20 > >>>>>>> +/* Layout of 64-bit eas attribute values */ > >>>>>>> +#define KVM_XIVE_EAS_PRIORITY_SHIFT 0 > >>>>>>> +#define KVM_XIVE_EAS_PRIORITY_MASK 0x7 > >>>>>>> +#define KVM_XIVE_EAS_SERVER_SHIFT 3 > >>>>>>> +#define KVM_XIVE_EAS_SERVER_MASK 0xfffffff8ULL > >>>>>>> +#define KVM_XIVE_EAS_MASK_SHIFT 32 > >>>>>>> +#define KVM_XIVE_EAS_MASK_MASK 0x100000000ULL > >>>>>>> +#define KVM_XIVE_EAS_EISN_SHIFT 33 > >>>>>>> +#define KVM_XIVE_EAS_EISN_MASK 0xfffffffe00000000ULL > >>>>>>> + > >>>>>>> #endif /* __LINUX_KVM_POWERPC_H */ > >>>>>>> diff --git a/arch/powerpc/kvm/book3s_xive_native.c b/arch/powerpc= /kvm/book3s_xive_native.c > >>>>>>> index f2de1bcf3b35..0468b605baa7 100644 > >>>>>>> --- a/arch/powerpc/kvm/book3s_xive_native.c > >>>>>>> +++ b/arch/powerpc/kvm/book3s_xive_native.c > >>>>>>> @@ -525,6 +525,88 @@ static int kvmppc_xive_native_sync(struct kv= mppc_xive *xive, long irq, u64 addr) > >>>>>>> return 0; > >>>>>>> } > >>>>>>> =20 > >>>>>>> +static int kvmppc_xive_native_set_eas(struct kvmppc_xive *xive, = long irq, > >>>>>>> + u64 addr) > >>>>>> > >>>>>> I'd prefer to avoid the name "EAS" here. IIUC these aren't "raw" = EAS > >>>>>> values, but rather essentially the "source config" in the terminol= ogy > >>>>>> of the PAPR hcalls. Which, yes, is basically implemented by setti= ng > >>>>>> the EAS, but since it's the PAPR architected state that we need to > >>>>>> preserve across migration, I'd prefer to stick as close as we can = to > >>>>>> the PAPR terminology. > >>>>> > >>>>> But we don't have an equivalent name in the PAPR specs for the tupl= e=20 > >>>>> (prio, server). We could use the generic 'target' name may be ? eve= n=20 > >>>>> if this is usually referring to a CPU number. > >>>> > >>>> Um.. what? That's about terminology for one of the fields in this > >>>> thing, not about the name for the thing itself. > >>>> > >>>>> Or, IVE (Interrupt Vector Entry) ? which makes some sense.=20 > >>>>> This is was the former name in HW. I think we recycle it for KVM. > >>>> > >>>> That's a terrible idea, which will make a confusing situation even > >>>> more confusing. > >>> > >>> Let's use SOURCE_CONFIG and QUEUE_CONFIG. The KVM ioctls are very=20 > >>> similar to the hcalls anyhow. > >> > >> Yes, I think that's a good idea. > >=20 > > Actually... AIUI the SET_CONFIG hcalls shouldn't be a fast path. =20 >=20 > No indeed. I have move them to standard hcalls in the current version. >=20 > > Can > > we simplify things further by removing the hcall implementation from > > the kernel entirely, and have qemu implement them by basically just > > forwarding them to the appropriate SET_CONFIG ioctl()? >=20 > Yes. I think we could.=20 Great! > The hcalls H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG and=20 > the KVM ioctls to set the EQ and the SOURCE configuration have a=20 > lot in common. I need to look at how we can plug the KVM ioctl in=20 > the hcalls under QEMU. >=20 > We will have to convert the returned error to respect the PAPR=20 > specs or have the ioctls return H_* errors. I don't think returning H_* values from a kernel call is a good idea. Converting errors is kinda ugly, but I still think it's the better option. Note that we already have something like this for the HPT resizing hcalls. > Let's dig that idea. If we choose that path, QEMU will have an=20 > up-to-date EAT and so we won't need to synchronize its state anymore=20 > for migration. I guess so, though I don't see that as essential. > H_INT_GET_SOURCE_CONFIG can be implemented in QEMU without any KVM=20 > ioctl. >=20 > H_INT_GET_QUEUE_INFO could be implemented in QEMU. I need to check=20 > how we return the address of the END ESB in sPAPR. We haven't paid=20 > much attention to these pages because they are not used under Linux > and today the address is returned by OPAL.=20 >=20 > H_INT_GET_QUEUE_CONFIG is a little more problematic because we need > to query into the XIVE HW the EQ index and toggle bit. OPAL support > is required for that. But we could reduce the KVM support to the=20 > ioctl querying these EQ information. Right, and we'd need an ioctl() like that for migration anyway, yes? > H_INT_ESB could be entirely done under QEMU. This one can actually happen on fairly hot paths, so I think doing that in qemu probably isn't a good idea. > H_INT_SYNC and H_INT_RESET can not. >=20 > H_INT_GET_OS_REPORTING_LINE and H_INT_SET_OS_REPORTING_LINE are not > implemented. >=20 > C. >=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 --+vcRm3WFmV0Q/ShD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlxbnJUACgkQbDjKyiDZ s5LNcRAAmYxLH3rKOtX3wxOCfTU3dQFsM8cCI8C6tEz5rW9kqhGqqhuAf88oGnzG /XHG/bulzSF9aFQZQFV8NM93FB1239/1TrgTbpJWqZBacS5TV1dQ5SJaEMOImnuv O+Uw9PjyPGl1XnSu6/+yREkHwCInhVKHFxPWzGbnOiD1DJhd457bwzk6vuUlIIIL /PB6z6vNxVeainkkEFfgzHzCKMrOaTWIWlgWkGDTayNn2dUwonZZaiDmPA6uTZ51 iC5eVVxGIUcsZGebus0B7i4nUFLOWc4B+/yYRlhTQ7Dl5Ph3cltggtkXLReh7kSx n6DBMnCmhR6AhapemOIC2z9AE25Z8h71FOPXOjvDR5RHP3gHxGmPqI8broC0V7v2 Sb8eyCdPmemqLK49PKdQVr2pBBLbHhHrVRskVuUc4Sk5yacel8DdMzY3oim5An2B hURpW644EhAX/sHFj3TpPaQX7htvc7yayJoirv3XoQUmUzmOiw5slq/V1OyWyVZK nlAP3SW33VK/8yCeOScfcyKVXoIYihO35XMNdkIzIB8CzFTwnF6fG7f7JL74AHNJ CWzRE+N57i+rh0fMypnM8E6nOxxA0TS/k/9YU6ZeF5Oyxaw+k4w29E3pZHOKjSHu W4PdF6k+dJJzD5p4nh3wAHzPx2MXzzu82CGt4hN0V2KYuAUjtpE= =NRCP -----END PGP SIGNATURE----- --+vcRm3WFmV0Q/ShD--