From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [PATCH v2 11/16] KVM: introduce a 'mmap' method for KVM devices Date: Mon, 25 Feb 2019 14:33:09 +1100 Message-ID: <20190225033309.GO7668@umbus.fritz.box> References: <20190222112840.25000-1-clg@kaod.org> <20190222112840.25000-12-clg@kaod.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MdEjg5WkSuUg8x46" 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: <20190222112840.25000-12-clg@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 --MdEjg5WkSuUg8x46 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 22, 2019 at 12:28:35PM +0100, C=E9dric Le Goater wrote: > Some KVM devices will want to handle special mappings related to the > underlying HW. For instance, the XIVE interrupt controller of the > POWER9 processor has MMIO pages for thread interrupt management and > for interrupt source control that need to be exposed to the guest when > the OS has the required support. >=20 > Signed-off-by: C=E9dric Le Goater Ah, when I suggested mmap() on the base device fd, I hadn't realized there wasn't a facility for that yet. Have you discussed this with Paolo? We'll need some core KVM buy in to merge this. > --- > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 11 +++++++++++ > 2 files changed, 12 insertions(+) >=20 > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index c38cc5eb7e73..cbf81487b69f 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1223,6 +1223,7 @@ struct kvm_device_ops { > int (*has_attr)(struct kvm_device *dev, struct kvm_device_attr *attr); > long (*ioctl)(struct kvm_device *dev, unsigned int ioctl, > unsigned long arg); > + int (*mmap)(struct kvm_device *dev, struct vm_area_struct *vma); > }; > =20 > void kvm_device_get(struct kvm_device *dev); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 585845203db8..84717d8cb5e4 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2878,6 +2878,16 @@ static long kvm_vcpu_compat_ioctl(struct file *fil= p, > } > #endif > =20 > +static int kvm_device_mmap(struct file *filp, struct vm_area_struct *vma) > +{ > + struct kvm_device *dev =3D filp->private_data; > + > + if (dev->ops->mmap) > + return dev->ops->mmap(dev, vma); > + > + return -ENODEV; > +} > + > static int kvm_device_ioctl_attr(struct kvm_device *dev, > int (*accessor)(struct kvm_device *dev, > struct kvm_device_attr *attr), > @@ -2927,6 +2937,7 @@ static const struct file_operations kvm_device_fops= =3D { > .unlocked_ioctl =3D kvm_device_ioctl, > .release =3D kvm_device_release, > KVM_COMPAT(kvm_device_ioctl), > + .mmap =3D kvm_device_mmap, > }; > =20 > struct kvm_device *kvm_device_from_filp(struct file *filp) --=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 --MdEjg5WkSuUg8x46 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlxzYfUACgkQbDjKyiDZ s5JP/A/9E2eVjzW3hIpObywCYF59PrShr4U3oPk+MgINMc39o5VpZNPU8KbGV8AR duGV33Vtv5+mBrY4hzGH0n1KVxf5hnRAGn0fVDXZcYG/1HcDMbCbNJClafOjn3Qu xI7jFQ6zbLbVSL7B7IQR9nvSu3xFp0gss16SEgw+KccfMV4RJ+COHKfRd6V4vzg0 HZ+rHvr0136ipued9dl9zJ00KqP/GOgMTJR4nFe83DgaYhhR63tP9E5gdqe3zlfG D5BoP3LDQBTLKGZfYEXvVa1VoCZCUxhW2uFGzmdjA3Ext1HrgyQ/A5Y8Hq363vT8 FTAsbbbpTmAHrVdom2EZo2m0a2j9sRNaYcFPnEOhfuOkp65eqOTDDeAp40LBGa3l fFEovLumIJFBfMQ8WN5Sl+irc8v9e1BdAA6ZH7IYiAaEH6bnIt9Q2UEcU1500rXy j0FrO+iiOb+4XVQ9lO5MhYusxl/mzawRcGqjhi6O1HmgOJjUluCywWq31ANkwEcS ymPk/R5qcGgSfvplvvY+dnpRj8FLBiezbbEl4vdYDW3hQV7BchUDybm00HaJQ/PN rDgYT+2nqgjnBUUPwmBvS3CIrbfiQchNAhRMdR4op9fIM77RipzxffHbbX20MP2b KF/Yjc4okuWGMnOhdoiJh+B47W3IujZX9YTnMe25hO45EiVc1YU= =U2aO -----END PGP SIGNATURE----- --MdEjg5WkSuUg8x46-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Date: Mon, 25 Feb 2019 03:33:09 +0000 Subject: Re: [PATCH v2 11/16] KVM: introduce a 'mmap' method for KVM devices Message-Id: <20190225033309.GO7668@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="MdEjg5WkSuUg8x46" List-Id: References: <20190222112840.25000-1-clg@kaod.org> <20190222112840.25000-12-clg@kaod.org> In-Reply-To: <20190222112840.25000-12-clg@kaod.org> To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Paul Mackerras , linuxppc-dev@lists.ozlabs.org --MdEjg5WkSuUg8x46 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 22, 2019 at 12:28:35PM +0100, C=E9dric Le Goater wrote: > Some KVM devices will want to handle special mappings related to the > underlying HW. For instance, the XIVE interrupt controller of the > POWER9 processor has MMIO pages for thread interrupt management and > for interrupt source control that need to be exposed to the guest when > the OS has the required support. >=20 > Signed-off-by: C=E9dric Le Goater Ah, when I suggested mmap() on the base device fd, I hadn't realized there wasn't a facility for that yet. Have you discussed this with Paolo? We'll need some core KVM buy in to merge this. > --- > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 11 +++++++++++ > 2 files changed, 12 insertions(+) >=20 > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index c38cc5eb7e73..cbf81487b69f 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1223,6 +1223,7 @@ struct kvm_device_ops { > int (*has_attr)(struct kvm_device *dev, struct kvm_device_attr *attr); > long (*ioctl)(struct kvm_device *dev, unsigned int ioctl, > unsigned long arg); > + int (*mmap)(struct kvm_device *dev, struct vm_area_struct *vma); > }; > =20 > void kvm_device_get(struct kvm_device *dev); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 585845203db8..84717d8cb5e4 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2878,6 +2878,16 @@ static long kvm_vcpu_compat_ioctl(struct file *fil= p, > } > #endif > =20 > +static int kvm_device_mmap(struct file *filp, struct vm_area_struct *vma) > +{ > + struct kvm_device *dev =3D filp->private_data; > + > + if (dev->ops->mmap) > + return dev->ops->mmap(dev, vma); > + > + return -ENODEV; > +} > + > static int kvm_device_ioctl_attr(struct kvm_device *dev, > int (*accessor)(struct kvm_device *dev, > struct kvm_device_attr *attr), > @@ -2927,6 +2937,7 @@ static const struct file_operations kvm_device_fops= =3D { > .unlocked_ioctl =3D kvm_device_ioctl, > .release =3D kvm_device_release, > KVM_COMPAT(kvm_device_ioctl), > + .mmap =3D kvm_device_mmap, > }; > =20 > struct kvm_device *kvm_device_from_filp(struct file *filp) --=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 --MdEjg5WkSuUg8x46 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlxzYfUACgkQbDjKyiDZ s5JP/A/9E2eVjzW3hIpObywCYF59PrShr4U3oPk+MgINMc39o5VpZNPU8KbGV8AR duGV33Vtv5+mBrY4hzGH0n1KVxf5hnRAGn0fVDXZcYG/1HcDMbCbNJClafOjn3Qu xI7jFQ6zbLbVSL7B7IQR9nvSu3xFp0gss16SEgw+KccfMV4RJ+COHKfRd6V4vzg0 HZ+rHvr0136ipued9dl9zJ00KqP/GOgMTJR4nFe83DgaYhhR63tP9E5gdqe3zlfG D5BoP3LDQBTLKGZfYEXvVa1VoCZCUxhW2uFGzmdjA3Ext1HrgyQ/A5Y8Hq363vT8 FTAsbbbpTmAHrVdom2EZo2m0a2j9sRNaYcFPnEOhfuOkp65eqOTDDeAp40LBGa3l fFEovLumIJFBfMQ8WN5Sl+irc8v9e1BdAA6ZH7IYiAaEH6bnIt9Q2UEcU1500rXy j0FrO+iiOb+4XVQ9lO5MhYusxl/mzawRcGqjhi6O1HmgOJjUluCywWq31ANkwEcS ymPk/R5qcGgSfvplvvY+dnpRj8FLBiezbbEl4vdYDW3hQV7BchUDybm00HaJQ/PN rDgYT+2nqgjnBUUPwmBvS3CIrbfiQchNAhRMdR4op9fIM77RipzxffHbbX20MP2b KF/Yjc4okuWGMnOhdoiJh+B47W3IujZX9YTnMe25hO45EiVc1YU= =U2aO -----END PGP SIGNATURE----- --MdEjg5WkSuUg8x46--