From: Pierre Morel <pmorel@linux.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: pasic@linux.ibm.com, borntraeger@de.ibm.com,
frankja@linux.ibm.com, mst@redhat.com, jasowang@redhat.com,
cohuck@redhat.com, kvm@vger.kernel.org,
linux-s390@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: [PATCH v1 1/1] s390: virtio-ccw: PV needs VIRTIO I/O device protection
Date: Thu, 6 Aug 2020 16:23:02 +0200 [thread overview]
Message-ID: <1596723782-12798-2-git-send-email-pmorel@linux.ibm.com> (raw)
In-Reply-To: <1596723782-12798-1-git-send-email-pmorel@linux.ibm.com>
If protected virtualization is active on s390, the virtio queues are
not accessible to the host, unless VIRTIO_F_IOMMU_PLATFORM has been
negotiated. Use ccw_transport_features() to fail feature negociation
and consequently probe if that's not the case, preventing a host
error on access attempt.
Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
drivers/s390/virtio/virtio_ccw.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 5730572b52cd..cc8d8064c6c4 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -803,11 +803,23 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
return rc;
}
-static void ccw_transport_features(struct virtio_device *vdev)
+static int ccw_transport_features(struct virtio_device *vdev)
{
- /*
- * Currently nothing to do here.
- */
+ if (!is_prot_virt_guest())
+ return 0;
+
+ if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+ dev_warn(&vdev->dev,
+ "device must provide VIRTIO_F_VERSION_1\n");
+ return -ENODEV;
+ }
+
+ if (!virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
+ dev_warn(&vdev->dev,
+ "device must provide VIRTIO_F_IOMMU_PLATFORM\n");
+ return -ENODEV;
+ }
+ return 0;
}
static int virtio_ccw_finalize_features(struct virtio_device *vdev)
@@ -837,7 +849,9 @@ static int virtio_ccw_finalize_features(struct virtio_device *vdev)
vring_transport_features(vdev);
/* Give virtio_ccw a chance to accept features. */
- ccw_transport_features(vdev);
+ ret = ccw_transport_features(vdev);
+ if (ret)
+ goto out_free;
features->index = 0;
features->features = cpu_to_le32((u32)vdev->features);
--
2.25.1
next prev parent reply other threads:[~2020-08-06 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-06 14:23 [PATCH v1 0/1] s390: virtio-ccw: PV needs VIRTIO I/O device protection Pierre Morel
2020-08-06 14:23 ` Pierre Morel [this message]
2020-08-06 15:47 ` Cornelia Huck
2020-08-07 14:25 ` Pierre Morel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1596723782-12798-2-git-send-email-pmorel@linux.ibm.com \
--to=pmorel@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox