KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
Marc Zyngier
maintainerPATCH 1/1 KVM: arm64: vgic-v4: Initialize GICv4.1 even in the absence of a virtual ITS
KVM now expects to be able to use HW-accelerated delivery of vSGIs as soon as the guest has enabled thm. Unfortunately, we only initialize the GICv4 context if we have a virtual ITS exposed to the guest.
Fix it by always initializing the GICv4.1 context if it is available on the host.
--- virt/kvm/arm/vgic/vgic-init.c | 9 ++++++++- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)
virt/kvm/arm/vgic/vgic-init.c +8 -1
@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm) } } -if (vgic_has_its (kvm)) { +if (vgic_has_its (kvm))vgic_lpi_translation_cache_init (kvm); + +/* +* If we have GICv4.1 enabled, unconditionnaly request enable the +* v4 support so that we get HW-accelerated vSGIs. Otherwise, only +* enable it if we present a virtual ITS to the guest. +*/ +if (vgic_supports_direct_msis (kvm)) { ret =vgic_v4_init (kvm);if (ret) goto out;
virt/kvm/arm/vgic/vgic-mmio-v3.c +2 -1
@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)bool vgic_supports_direct_msis (struct kvm *kvm) { -return kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm); +return (kvm_vgic_global_state.has_gicv4_1 || + (kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm))); }/*
Signature · 1 line
2.26.2
Hi Marc,
Quoted 2 lines · Marc Zyngier
KVM now expects to be able to use HW-accelerated delivery of vSGIs as soon as the guest has enabled thm. Unfortunately, we only
them
Quoted 39 lines
initialize the GICv4 context if we have a virtual ITS exposed to the guest.
Fix it by always initializing the GICv4.1 context if it is available on the host.
Fixes 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")Signed-off-by Marc Zyngier <[email protected]>--- virt/kvm/arm/vgic/vgic-init.c | 9 ++++++++- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)virt/kvm/arm/vgic/vgic-init.c +8
-1@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm) } } -if (vgic_has_its (kvm)) { +if (vgic_has_its (kvm))vgic_lpi_translation_cache_init (kvm); + +/* +* If we have GICv4.1 enabled, unconditionnaly request enable the +* v4 support so that we get HW-accelerated vSGIs. Otherwise, only +* enable it if we present a virtual ITS to the guest. +*/ +if (vgic_supports_direct_msis (kvm)) { ret =vgic_v4_init (kvm);if (ret) goto out;virt/kvm/arm/vgic/vgic-mmio-v3.c +0
-0
virt/kvm/arm/vgic/vgic-mmio-v3.c bool vgic_has_its(struct kvm *kvm) · line 55
Quoted 7 lines
virt/kvm/arm/vgic/vgic-mmio-v3.c +2
-1@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)bool vgic_supports_direct_msis (struct kvm *kvm) { -return kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm); +return (kvm_vgic_global_state.has_gicv4_1 || + (kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm))); }
Not related to this patch, but I think that the function name can be improved a bit after this change. It now indicates whether the vGIC supports direct MSIs injection *or* direct SGIs injection, not just MSIs. And if vgic_has_its() is false, we don't even support MSIs.
The fix itself looks correct to me,
Thanks.
Marc Zyngier
maintainerHi Zenghui,
Quoted 47 lines · Zenghui Yu
Hi Marc,
Quoted 2 lines · Marc Zyngier
KVM now expects to be able to use HW-accelerated delivery of vSGIs as soon as the guest has enabled thm. Unfortunately, we only
them
Quoted 41 lines
initialize the GICv4 context if we have a virtual ITS exposed to the guest.
Fix it by always initializing the GICv4.1 context if it is available on the host.
Fixes 2291ff2f2a56 ("KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor")Signed-off-by Marc Zyngier <[email protected]>--- virt/kvm/arm/vgic/vgic-init.c | 9 ++++++++- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)virt/kvm/arm/vgic/vgic-init.c +8
-0@@ -294,8 +294,15 @@ int vgic_init(struct kvm *kvm) } } - if (vgic_has_its(kvm)) { +if (vgic_has_its (kvm))vgic_lpi_translation_cache_init (kvm); + +/* +* If we have GICv4.1 enabled, unconditionnaly request enable the +* v4 support so that we get HW-accelerated vSGIs. Otherwise, only +* enable it if we present a virtual ITS to the guest. +*/ +if (vgic_supports_direct_msis (kvm)) { ret =vgic_v4_init (kvm);if (ret) goto out;virt/kvm/arm/vgic/vgic-mmio-v3.c +0
-1@@ -50,7 +50,8 @@ bool vgic_has_its(struct kvm *kvm)bool vgic_supports_direct_msis (struct kvm *kvm) { -return kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm);
Quoted 8 lines
virt/kvm/arm/vgic/vgic-mmio-v3.c bool vgic_has_its(struct kvm *kvm) · line 55
Quoted 3 lines
virt/kvm/arm/vgic/vgic-mmio-v3.c +2
-0+return (kvm_vgic_global_state.has_gicv4_1 || + (kvm_vgic_global_state.has_gicv4 &&vgic_has_its (kvm))); }Not related to this patch, but I think that the function name can be improved a bit after this change. It now indicates whether the vGIC supports direct MSIs injection *or* direct SGIs injection, not just MSIs. And if
vgic_has_its()is false, we don't even support MSIs.
Yes, I noticed that too. But in the spirit of keeping the change minimal and avoid later conflicts with potential fixes, I decided against changing it right now.
Quoted 3 lines
The fix itself looks correct to me,
Reviewed-by Zenghui Yu <[email protected]>
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...