From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [PATCH v3 11/17] KVM: introduce a 'mmap' method for KVM devices Date: Mon, 18 Mar 2019 14:32:23 +1100 Message-ID: <20190318033223.GL6874@umbus.fritz.box> References: <20190315120609.25910-1-clg@kaod.org> <20190315120609.25910-12-clg@kaod.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4e5ZDkbgLEOfWmLx" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Paul Mackerras , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org To: =?iso-8859-1?Q?C=E9dric?= Le Goater Return-path: Content-Disposition: inline In-Reply-To: <20190315120609.25910-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 --4e5ZDkbgLEOfWmLx Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 15, 2019 at 01:06:03PM +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 > Cc: Paolo Bonzini > Signed-off-by: C=E9dric Le Goater Reviewed-by: David Gibson > --- > 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 076bc38963bf..e4881a8c2a6f 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 --4e5ZDkbgLEOfWmLx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlyPEUYACgkQbDjKyiDZ s5JkcQ/9El5dCERRJqATuvBEvvEkUfnB0NRPUbd+j/EnMNG+S/J9fF+Lt7MjpLKR UJ+kkidVuL69z41U3UM5yFsrGMtqgeP1aGZ+0ybw+daa6SXWVsPr7W3FWNfg1nI8 YDz0G6kcInq+3/wu0M8yQEFXL9W/MwxvtX3usY6IBNjFztyNavV/aQE/uzCDY0N+ H9q5sRZRNgE5JL+qlgcDhZNqzxm4ILKxQWiExghLazKrW3/+L1UctOc0/2lE8iB0 R4rdtANi5egwwg2mlXU025VpmSgNS3RBNZpZSZNb56sHvuktsnsPY7MTY7OHehVw TJqBSmUEB+oGdfmbB3p2p7/2cHdIAQPYRozybrq69Ewd3csIqtnbGbJH3fJ5ScOZ C5LJxUom7oQ4qcJUWf9X52n06UPst6aBhyNXv+40wl9TfHY18sk5d6K3kU4fYV1z Fca3Az5t23FnHEFiZ5NiQKg06vBPo2Ay9BvnDZD/QmKeqx6ARoRrmATXUNb6bOiQ /X6uTT016oqh6cPc1Uwr1qRjI0ZV9Pj7AFstHQO/LQ3MJ1Ff0CCozZgowgplB9Ps 3xCAvTwdultNfhmvxpsUih33MAzV855B0+VCPkDy4whlYjj1xz/LdVqF4252hBrj rQPpVkTmZQbkZk+XzMVav7lVPulB9nJUwip0ik/iv4nctYU6WPs= =OMfW -----END PGP SIGNATURE----- --4e5ZDkbgLEOfWmLx-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Date: Mon, 18 Mar 2019 03:32:23 +0000 Subject: Re: [PATCH v3 11/17] KVM: introduce a 'mmap' method for KVM devices Message-Id: <20190318033223.GL6874@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="4e5ZDkbgLEOfWmLx" List-Id: References: <20190315120609.25910-1-clg@kaod.org> <20190315120609.25910-12-clg@kaod.org> In-Reply-To: <20190315120609.25910-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 , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org --4e5ZDkbgLEOfWmLx Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 15, 2019 at 01:06:03PM +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 > Cc: Paolo Bonzini > Signed-off-by: C=E9dric Le Goater Reviewed-by: David Gibson > --- > 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 076bc38963bf..e4881a8c2a6f 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 --4e5ZDkbgLEOfWmLx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlyPEUYACgkQbDjKyiDZ s5JkcQ/9El5dCERRJqATuvBEvvEkUfnB0NRPUbd+j/EnMNG+S/J9fF+Lt7MjpLKR UJ+kkidVuL69z41U3UM5yFsrGMtqgeP1aGZ+0ybw+daa6SXWVsPr7W3FWNfg1nI8 YDz0G6kcInq+3/wu0M8yQEFXL9W/MwxvtX3usY6IBNjFztyNavV/aQE/uzCDY0N+ H9q5sRZRNgE5JL+qlgcDhZNqzxm4ILKxQWiExghLazKrW3/+L1UctOc0/2lE8iB0 R4rdtANi5egwwg2mlXU025VpmSgNS3RBNZpZSZNb56sHvuktsnsPY7MTY7OHehVw TJqBSmUEB+oGdfmbB3p2p7/2cHdIAQPYRozybrq69Ewd3csIqtnbGbJH3fJ5ScOZ C5LJxUom7oQ4qcJUWf9X52n06UPst6aBhyNXv+40wl9TfHY18sk5d6K3kU4fYV1z Fca3Az5t23FnHEFiZ5NiQKg06vBPo2Ay9BvnDZD/QmKeqx6ARoRrmATXUNb6bOiQ /X6uTT016oqh6cPc1Uwr1qRjI0ZV9Pj7AFstHQO/LQ3MJ1Ff0CCozZgowgplB9Ps 3xCAvTwdultNfhmvxpsUih33MAzV855B0+VCPkDy4whlYjj1xz/LdVqF4252hBrj rQPpVkTmZQbkZk+XzMVav7lVPulB9nJUwip0ik/iv4nctYU6WPs= =OMfW -----END PGP SIGNATURE----- --4e5ZDkbgLEOfWmLx--