diff mbox series

[RFC,kvmtool,26/31] virtio: Add a wrapper for get_host_features

Message ID 20230127113932.166089-27-suzuki.poulose@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: Support for Arm Confidential Compute Architecture | expand

Commit Message

Suzuki K Poulose Jan. 27, 2023, 11:39 a.m. UTC
Add a wrapper to the vdev->ops->get_host_features() to allow
setting platform specific flags outside the device

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/kvm/virtio.h | 2 ++
 virtio/core.c        | 5 +++++
 virtio/mmio-legacy.c | 2 +-
 virtio/mmio-modern.c | 2 +-
 virtio/pci-legacy.c  | 2 +-
 virtio/pci-modern.c  | 2 +-
 6 files changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h
index 94bddefe..e95cfad5 100644
--- a/include/kvm/virtio.h
+++ b/include/kvm/virtio.h
@@ -248,4 +248,6 @@  void virtio_set_guest_features(struct kvm *kvm, struct virtio_device *vdev,
 void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev,
 			  void *dev, u8 status);
 
+u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev);
+
 #endif /* KVM__VIRTIO_H */
diff --git a/virtio/core.c b/virtio/core.c
index ea0e5b65..50e7f86d 100644
--- a/virtio/core.c
+++ b/virtio/core.c
@@ -283,6 +283,11 @@  void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev,
 		vdev->ops->notify_status(kvm, dev, ext_status);
 }
 
+u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev)
+{
+	return vdev->ops->get_host_features(kvm, dev);
+}
+
 bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev,
 			  void *dev, unsigned long offset, void *data,
 			  size_t size, bool is_write)
diff --git a/virtio/mmio-legacy.c b/virtio/mmio-legacy.c
index 7ca7e69f..42673236 100644
--- a/virtio/mmio-legacy.c
+++ b/virtio/mmio-legacy.c
@@ -26,7 +26,7 @@  static void virtio_mmio_config_in(struct kvm_cpu *vcpu,
 		break;
 	case VIRTIO_MMIO_DEVICE_FEATURES:
 		if (vmmio->hdr.host_features_sel == 0)
-			val = vdev->ops->get_host_features(vmmio->kvm,
+			val = virtio_dev_get_host_features(vdev, vmmio->kvm,
 							   vmmio->dev);
 		ioport__write32(data, val);
 		break;
diff --git a/virtio/mmio-modern.c b/virtio/mmio-modern.c
index 6c0bb382..a09fa8e9 100644
--- a/virtio/mmio-modern.c
+++ b/virtio/mmio-modern.c
@@ -26,7 +26,7 @@  static void virtio_mmio_config_in(struct kvm_cpu *vcpu,
 	case VIRTIO_MMIO_DEVICE_FEATURES:
 		if (vmmio->hdr.host_features_sel > 1)
 			break;
-		features |= vdev->ops->get_host_features(vmmio->kvm, vmmio->dev);
+		features |= virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev);
 		val = features >> (32 * vmmio->hdr.host_features_sel);
 		break;
 	case VIRTIO_MMIO_QUEUE_NUM_MAX:
diff --git a/virtio/pci-legacy.c b/virtio/pci-legacy.c
index 58047967..d5f5dee7 100644
--- a/virtio/pci-legacy.c
+++ b/virtio/pci-legacy.c
@@ -44,7 +44,7 @@  static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev
 
 	switch (offset) {
 	case VIRTIO_PCI_HOST_FEATURES:
-		val = vdev->ops->get_host_features(kvm, vpci->dev);
+		val = virtio_dev_get_host_features(vdev, kvm, vpci->dev);
 		ioport__write32(data, val);
 		break;
 	case VIRTIO_PCI_QUEUE_PFN:
diff --git a/virtio/pci-modern.c b/virtio/pci-modern.c
index c5b4bc50..2c5bf3f8 100644
--- a/virtio/pci-modern.c
+++ b/virtio/pci-modern.c
@@ -158,7 +158,7 @@  static bool virtio_pci__common_read(struct virtio_device *vdev,
 	case VIRTIO_PCI_COMMON_DF:
 		if (vpci->device_features_sel > 1)
 			break;
-		features |= vdev->ops->get_host_features(vpci->kvm, vpci->dev);
+		features |= virtio_dev_get_host_features(vdev, vpci->kvm, vpci->dev);
 		val = features >> (32 * vpci->device_features_sel);
 		ioport__write32(data, val);
 		break;