Skip to contentSkip to conversation

riscv: pci: Add --force-pci option for riscv VMs.

PATCH In review Rajnesh Kanwal 5 participants 6 messages Jan 18, 2023 – Jan 21, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: pci: Add --force-pci option for riscv VMs.

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

---
 riscv/include/kvm/kvm-arch.h        | 6 ++++--
 riscv/include/kvm/kvm-config-arch.h | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
riscv/include/kvm/kvm-arch.h +4 -2
index 1e130f5..2cf41c5 100644
@@ -46,8 +46,10 @@
 
 #define KVM_VM_TYPE		0
 
-#define VIRTIO_DEFAULT_TRANS(kvm) \
-	((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO)
+#define VIRTIO_DEFAULT_TRANS(kvm)					\
+	((kvm)->cfg.arch.virtio_trans_pci ?				\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_PCI_LEGACY : VIRTIO_PCI) :	\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO))
 
 #define VIRTIO_RING_ENDIAN	VIRTIO_ENDIAN_LE
 
riscv/include/kvm/kvm-config-arch.h +6 -1
index 188125c..901a5e0 100644
@@ -6,6 +6,7 @@
 struct kvm_config_arch {
 	const char	*dump_dtb_filename;
 	bool		ext_disabled[KVM_RISCV_ISA_EXT_MAX];
+	bool		virtio_trans_pci;
 };
 
 #define OPT_ARCH_RUN(pfx, cfg)						\
@@ -26,6 +27,10 @@ struct kvm_config_arch {
 		    "Disable Zicbom Extension"),			\
 	OPT_BOOLEAN('\0', "disable-zihintpause",			\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
-		    "Disable Zihintpause Extension"),
+		    "Disable Zihintpause Extension"),			\
+	OPT_BOOLEAN('\0', "force-pci",					\
+			&(cfg)->virtio_trans_pci,			\
+		    "Force virtio devices to use PCI as their "		\
+		    "default transport"),
 
 #endif /* KVM__KVM_CONFIG_ARCH_H */
Signature · 1 line
2.25.1
#1 lore raw

Hi,

CC'ing the kvmtool maintainers and other people that might be interested in this thread. Sorry for hijacking your patch!

Quoted 2 lines · Rajnesh Kanwal

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

arm is in the same situation, MMIO is the default virtio transport. I was bitten by that in the past. It also cought other people unaware, and I remember maz complaining about it on the list.

So I was thinking about adding a new command line parameter, --virtio-transport, with the possible values mmio-legacy, mmio, pci-legacy and pci. Then each architecture can define the default value for the transport. For arm, that would be pci.

What do you guys think?

Thanks,
Alex

Quoted 51 lines
---
 riscv/include/kvm/kvm-arch.h        | 6 ++++--
 riscv/include/kvm/kvm-config-arch.h | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
riscv/include/kvm/kvm-arch.h +4 -2
index 1e130f5..2cf41c5 100644
@@ -46,8 +46,10 @@
 
 #define KVM_VM_TYPE		0
 
-#define VIRTIO_DEFAULT_TRANS(kvm) \
-	((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO)
+#define VIRTIO_DEFAULT_TRANS(kvm)					\
+	((kvm)->cfg.arch.virtio_trans_pci ?				\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_PCI_LEGACY : VIRTIO_PCI) :	\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO))
 
 #define VIRTIO_RING_ENDIAN	VIRTIO_ENDIAN_LE
 
riscv/include/kvm/kvm-config-arch.h +6 -1
index 188125c..901a5e0 100644
@@ -6,6 +6,7 @@
 struct kvm_config_arch {
 	const char	*dump_dtb_filename;
 	bool		ext_disabled[KVM_RISCV_ISA_EXT_MAX];
+	bool		virtio_trans_pci;
 };
 
 #define OPT_ARCH_RUN(pfx, cfg)						\
@@ -26,6 +27,10 @@ struct kvm_config_arch {
 		    "Disable Zicbom Extension"),			\
 	OPT_BOOLEAN('\0', "disable-zihintpause",			\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
-		    "Disable Zihintpause Extension"),
+		    "Disable Zihintpause Extension"),			\
+	OPT_BOOLEAN('\0', "force-pci",					\
+			&(cfg)->virtio_trans_pci,			\
+		    "Force virtio devices to use PCI as their "		\
+		    "default transport"),
 
 #endif /* KVM__KVM_CONFIG_ARCH_H */
Signature · 1 line
2.25.1
#2 lore raw

On Thu, 19 Jan 2023 13:39:32 +0000 Alexandru Elisei <[email protected]> wrote:

Hi Alex,

Quoted 11 lines

CC'ing the kvmtool maintainers and other people that might be interested in this thread. Sorry for hijacking your patch!

Quoted 2 lines · Rajnesh Kanwal

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

arm is in the same situation, MMIO is the default virtio transport. I was bitten by that in the past. It also cought other people unaware, and I remember maz complaining about it on the list.

Quoted 6 lines

So I was thinking about adding a new command line parameter, --virtio-transport, with the possible values mmio-legacy, mmio, pci-legacy and pci. Then each architecture can define the default value for the transport. For arm, that would be pci.

What do you guys think?

That sounds good to me, definitely much better than proliferating the force-pci parameter, which is a bit of a misnomer anyway.

I also heard people recently asking explicitly for MMIO transport, since it's leaner and you can remove PCI support from the guest kernel entirely. So giving the user explicit choice is probably the way to go.

Cheers,
Andre

Quoted 50 lines
Quoted 50 lines
---
 riscv/include/kvm/kvm-arch.h        | 6 ++++--
 riscv/include/kvm/kvm-config-arch.h | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
riscv/include/kvm/kvm-arch.h +4 -2
index 1e130f5..2cf41c5 100644
@@ -46,8 +46,10 @@
 
 #define KVM_VM_TYPE		0
 
-#define VIRTIO_DEFAULT_TRANS(kvm) \
-	((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO)
+#define VIRTIO_DEFAULT_TRANS(kvm)					\
+	((kvm)->cfg.arch.virtio_trans_pci ?				\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_PCI_LEGACY : VIRTIO_PCI) :	\
+	 ((kvm)->cfg.virtio_legacy ? VIRTIO_MMIO_LEGACY : VIRTIO_MMIO))
 
 #define VIRTIO_RING_ENDIAN	VIRTIO_ENDIAN_LE
 
riscv/include/kvm/kvm-config-arch.h +6 -1
index 188125c..901a5e0 100644
@@ -6,6 +6,7 @@
 struct kvm_config_arch {
 	const char	*dump_dtb_filename;
 	bool		ext_disabled[KVM_RISCV_ISA_EXT_MAX];
+	bool		virtio_trans_pci;
 };
 
 #define OPT_ARCH_RUN(pfx, cfg)						\
@@ -26,6 +27,10 @@ struct kvm_config_arch {
 		    "Disable Zicbom Extension"),			\
 	OPT_BOOLEAN('\0', "disable-zihintpause",			\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
-		    "Disable Zihintpause Extension"),
+		    "Disable Zihintpause Extension"),			\
+	OPT_BOOLEAN('\0', "force-pci",					\
+			&(cfg)->virtio_trans_pci,			\
+		    "Force virtio devices to use PCI as their "		\
+		    "default transport"),
 
 #endif /* KVM__KVM_CONFIG_ARCH_H */
Signature · 1 line
2.25.1
#3 lore raw
In reply to Alexandru Elisei
Quoted 13 lines · Alexandru Elisei

Hi,

CC'ing the kvmtool maintainers and other people that might be interested in this thread. Sorry for hijacking your patch!

Quoted 2 lines · Rajnesh Kanwal

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

arm is in the same situation, MMIO is the default virtio transport. I was bitten by that in the past. It also cought other people unaware, and I remember maz complaining about it on the list.

Quoted 6 lines

So I was thinking about adding a new command line parameter, --virtio-transport, with the possible values mmio-legacy, mmio, pci-legacy and pci. Then each architecture can define the default value for the transport. For arm, that would be pci.

What do you guys think?

That sounds good to me. Then we can remove --force-pci altogether and maybe have PCI as the default for everybody? Should make the tool a little easier to use across architectures.

Will

#4 lore raw
Quoted 20 lines · Will Deacon
Quoted 18 lines · Alexandru Elisei

Hi,

CC'ing the kvmtool maintainers and other people that might be interested in this thread. Sorry for hijacking your patch!

Quoted 2 lines · Rajnesh Kanwal

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

arm is in the same situation, MMIO is the default virtio transport. I was bitten by that in the past. It also cought other people unaware, and I remember maz complaining about it on the list.

So I was thinking about adding a new command line parameter, --virtio-transport, with the possible values mmio-legacy, mmio, pci-legacy and pci. Then each architecture can define the default value for the transport. For arm, that would be pci.

Quoted 5 lines
Quoted 1 line

What do you guys think?

That sounds good to me. Then we can remove --force-pci altogether and maybe have PCI as the default for everybody? Should make the tool a little easier to use across architectures.

I'd rather keep --force-pci in order no to break existing scripting. It just won't do anything once we make PCI the default (which we definitely should).

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#5 lore raw

Hi,

Quoted 24 lines · Marc Zyngier
Quoted 22 lines · Will Deacon
Quoted 19 lines · Alexandru Elisei

Hi,

CC'ing the kvmtool maintainers and other people that might be interested in this thread. Sorry for hijacking your patch!

Quoted 2 lines · Rajnesh Kanwal

Adding force-pci option to allow forcing virtio
devices to use pci as the default transport.

arm is in the same situation, MMIO is the default virtio transport. I was bitten by that in the past. It also cought other people unaware, and I remember maz complaining about it on the list.

So I was thinking about adding a new command line parameter, --virtio-transport, with the possible values mmio-legacy, mmio, pci-legacy and pci. Then each architecture can define the default value for the transport. For arm, that would be pci.

What do you guys think?

Quoted 7 lines
Quoted 3 lines

That sounds good to me. Then we can remove --force-pci altogether and maybe have PCI as the default for everybody? Should make the tool a little easier to use across architectures.

I'd rather keep --force-pci in order no to break existing scripting. It just won't do anything once we make PCI the default (which we definitely should).

My plan was to mark --force-pci and --virtio-legacy as deprecated in the help message and to parse them to set the correct value for --virtio-transport (so if --force-pci and --virtio-legacy is specified, the value for --virtio-transport pci-legacy). So as not to break CIs and existing scripts.

Since I would be already parsing them, I was wondering if it would be useful to also print a warning on the command line for users to switch to --virtio-transport. Any opinions about this?

Thanks,
Alex

Quoted 7 lines

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.