[RFC kvmtool 27/31] virtio: Add arch specific hook for virtio host flags

From: Suzuki K Poulose
Date: Fri Jan 27 2023 - 06:43:03 EST


Add callbacks for archs to provide virtio host flags.

Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
arm/aarch32/kvm.c | 5 +++++
arm/aarch64/kvm.c | 5 +++++
include/kvm/kvm.h | 2 ++
mips/kvm.c | 5 +++++
powerpc/kvm.c | 5 +++++
riscv/kvm.c | 5 +++++
virtio/core.c | 5 ++++-
x86/kvm.c | 5 +++++
8 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/arm/aarch32/kvm.c b/arm/aarch32/kvm.c
index 768a56bb..849c55d3 100644
--- a/arm/aarch32/kvm.c
+++ b/arm/aarch32/kvm.c
@@ -12,3 +12,8 @@ u64 kvm__arch_default_ram_address(void)
{
return ARM_MEMORY_AREA;
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c
index 344c568b..a4664237 100644
--- a/arm/aarch64/kvm.c
+++ b/arm/aarch64/kvm.c
@@ -234,3 +234,8 @@ void kvm__arch_enable_mte(struct kvm *kvm)

pr_debug("MTE capability enabled");
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h
index 3872dc65..a3624de4 100644
--- a/include/kvm/kvm.h
+++ b/include/kvm/kvm.h
@@ -203,6 +203,8 @@ int kvm__arch_free_firmware(struct kvm *kvm);
bool kvm__arch_cpu_supports_vm(void);
void kvm__arch_read_term(struct kvm *kvm);

+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm);
+
#ifdef ARCH_HAS_CFG_RAM_ADDRESS
static inline bool kvm__arch_has_cfg_ram_address(void)
{
diff --git a/mips/kvm.c b/mips/kvm.c
index 0faa03a9..e23d5cf9 100644
--- a/mips/kvm.c
+++ b/mips/kvm.c
@@ -374,3 +374,8 @@ void ioport__map_irq(u8 *irq)
void serial8250__inject_sysrq(struct kvm *kvm, char sysrq)
{
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
diff --git a/powerpc/kvm.c b/powerpc/kvm.c
index 7b0d0669..6b3ab93f 100644
--- a/powerpc/kvm.c
+++ b/powerpc/kvm.c
@@ -529,3 +529,8 @@ int kvm__arch_free_firmware(struct kvm *kvm)
{
return 0;
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
diff --git a/riscv/kvm.c b/riscv/kvm.c
index 4d6f5cb5..884321ca 100644
--- a/riscv/kvm.c
+++ b/riscv/kvm.c
@@ -182,3 +182,8 @@ int kvm__arch_setup_firmware(struct kvm *kvm)
{
return 0;
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
diff --git a/virtio/core.c b/virtio/core.c
index 50e7f86d..674f6fae 100644
--- a/virtio/core.c
+++ b/virtio/core.c
@@ -285,7 +285,10 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev,

u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev)
{
- return vdev->ops->get_host_features(kvm, dev);
+ u64 features = kvm__arch_get_virtio_host_features(kvm);
+
+ features |= vdev->ops->get_host_features(kvm, dev);
+ return features;
}

bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev,
diff --git a/x86/kvm.c b/x86/kvm.c
index 328fa750..961b5d3f 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -387,3 +387,8 @@ void kvm__arch_read_term(struct kvm *kvm)
serial8250__update_consoles(kvm);
virtio_console__inject_interrupt(kvm);
}
+
+u64 kvm__arch_get_virtio_host_features(struct kvm *kvm)
+{
+ return 0;
+}
--
2.34.1