KVM: arm/arm64: vgic-its: Fix vgicv4 init
PATCH v2 1/1 KVM: arm/arm64: vgic-its: Fix vgicv4 init
Commit 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues") moved the vgic_supports_direct_msis() check in vgic_v4_init(). However when vgic_v4_init is called from vgic_its_create(), the has_its field is not yet set. Hence vgic_supports_direct_msis returns false and vgic_v4_init does nothing.
Let's move the check back to vgic_v4_init caller.
---
v1 -> v2:
- move the check to the caller
- identify the right commit this patch fixes
--- virt/kvm/arm/vgic/vgic-init.c | 8 +++++--- virt/kvm/arm/vgic/vgic-its.c | 2 +- virt/kvm/arm/vgic/vgic-v4.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)
virt/kvm/arm/vgic/vgic-init.c +5 -3
@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_supports_direct_msis (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);
virt/kvm/arm/vgic/vgic-its.c +1 -1
@@ -1687,7 +1687,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)if (!its)return -ENOMEM ; -if (vgic_initialized (dev->kvm)) { +if (kvm_vgic_global_state.has_gicv4 &&vgic_initialized (dev->kvm)) {int ret =vgic_v4_init (dev->kvm);if (ret <0 ) {kfree (its);
virt/kvm/arm/vgic/vgic-v4.c +0 -3
@@ -118,9 +118,6 @@ int vgic_v4_init(struct kvm *kvm)struct kvm_vcpu *vcpu;int i, nr_vcpus, ret; -if (!vgic_supports_direct_msis (kvm)) -return 0 ;/* Nothing to see here... move along. */ -if (dist->its_vm.vpes)return 0 ;
Signature · 1 line
2.5.5
Quoted 8 lines · Eric Auger
Commit
3d1ad640f8c94("KVM: arm/arm64: Fix GICv4 ITS initialization issues") moved thevgic_supports_direct_msis()check invgic_v4_init(). However whenvgic_v4_initis called fromvgic_its_create(), thehas_itsfield is not yet set. Hencevgic_supports_direct_msisreturns false andvgic_v4_initdoes nothing.Let's move the check back to
vgic_v4_initcaller.
Quoted 7 lines
Fixes 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues")Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- move the check to the caller
Why this change, I slightly preferred the first version of this patch, but I will admit that the "has_its = true; no_wait(); has_its = false;" things is pretty ugly...
Quoted 31 lines
- identify the right commit this patch fixes
--- virt/kvm/arm/vgic/vgic-init.c | 8 +++++--- virt/kvm/arm/vgic/vgic-its.c | 2 +- virt/kvm/arm/vgic/vgic-v4.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)virt/kvm/arm/vgic/vgic-init.c +5
-3@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_supports_direct_msis (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);virt/kvm/arm/vgic/vgic-its.c +0
-0
virt/kvm/arm/vgic/vgic-its.c static int vgic_its_create(struct kvm_device *dev, u32 type) · line 1690
Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1
-1@@ -1687,7 +1687,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)if (!its)return -ENOMEM ; -if (vgic_initialized (dev->kvm)) { +if (kvm_vgic_global_state.has_gicv4 &&vgic_initialized (dev->kvm)) {
... but now we're using vgic_supports_direct_msis() in one part of the init path and a half-open coded version of that in another path, which is not very pretty.
So I actually would suggest doing the init stuff more open-coded, because init of the gic/its/gicv4 is a mess anyway.
Something like this:
virt/kvm/arm/vgic/vgic-init.c +5 -3
@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_has_its (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);
virt/kvm/arm/vgic/vgic-v4.c +1 -1
@@ -118,7 +118,7 @@ int vgic_v4_init(struct kvm *kvm)struct kvm_vcpu *vcpu;int i, nr_vcpus, ret; -if (!vgic_supports_direct_msis (kvm)) +if (!kvm_vgic_global_state.has_gicv4)return 0 ;/* Nothing to see here... move along. */ if (dist->its_vm.vpes)
Does that work?
Thanks,
-Christoffer
Hi Christoffer
Quoted 12 lines · Christoffer Dall
Quoted 11 lines · Eric Auger
Commit
3d1ad640f8c94("KVM: arm/arm64: Fix GICv4 ITS initialization issues") moved thevgic_supports_direct_msis()check invgic_v4_init(). However whenvgic_v4_initis called fromvgic_its_create(), thehas_itsfield is not yet set. Hencevgic_supports_direct_msisreturns false andvgic_v4_initdoes nothing.Let's move the check back to
vgic_v4_initcaller.Fixes 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues")Signed-off-by Eric Auger <[email protected]>
Quoted 8 lines
Quoted 4 lines
---
v1 -> v2:
- move the check to the callerWhy this change, I slightly preferred the first version of this patch, but I will admit that the "
has_its= true;no_wait();has_its= false;" things is pretty ugly...
I didn't find the 1st solution elegant either and reverted to how the code looked like before your patch.
Quoted 80 lines
Quoted 32 lines
- identify the right commit this patch fixes
--- virt/kvm/arm/vgic/vgic-init.c | 8 +++++--- virt/kvm/arm/vgic/vgic-its.c | 2 +- virt/kvm/arm/vgic/vgic-v4.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)virt/kvm/arm/vgic/vgic-init.c +5
-3@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_supports_direct_msis (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);virt/kvm/arm/vgic/vgic-its.c +0
-0virt/kvm/arm/vgic/vgic-its.c static int vgic_its_create(struct kvm_device *dev, u32 type) · line 1690
Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1
-1@@ -1687,7 +1687,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)if (!its)return -ENOMEM ; -if (vgic_initialized (dev->kvm)) { +if (kvm_vgic_global_state.has_gicv4 &&vgic_initialized (dev->kvm)) {... but now we're using
vgic_supports_direct_msis()in one part of the init path and a half-open coded version of that in another path, which is not very pretty.So I actually would suggest doing the init stuff more open-coded, because init of the gic/its/gicv4 is a mess anyway.
Something like this:
virt/kvm/arm/vgic/vgic-init.c +5
-3@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_has_its (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);virt/kvm/arm/vgic/vgic-v4.c +1
-1@@ -118,7 +118,7 @@ int vgic_v4_init(struct kvm *kvm)struct kvm_vcpu *vcpu;int i, nr_vcpus, ret; -if (!vgic_supports_direct_msis (kvm)) +if (!kvm_vgic_global_state.has_gicv4)return 0 ;/* Nothing to see here... move along. */ if (dist->its_vm.vpes)
Quoted 1 line
Does that work?
Looks OK to me. Unfortunately I don't have access to this specific machine anymore at the moment so I can't test it right now.
Thanks
Eric
Quoted 4 lines
Thanks,
-Christoffer
Quoted 104 lines · Auger Eric
Hi Christoffer
Quoted 12 lines · Christoffer Dall
Quoted 11 lines · Eric Auger
Commit
3d1ad640f8c94("KVM: arm/arm64: Fix GICv4 ITS initialization issues") moved thevgic_supports_direct_msis()check invgic_v4_init(). However whenvgic_v4_initis called fromvgic_its_create(), thehas_itsfield is not yet set. Hencevgic_supports_direct_msisreturns false andvgic_v4_initdoes nothing.Let's move the check back to
vgic_v4_initcaller.Fixes 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues")Signed-off-by Eric Auger <[email protected]>Quoted 8 lines
Quoted 4 lines
---
v1 -> v2:
- move the check to the callerWhy this change, I slightly preferred the first version of this patch, but I will admit that the "
has_its= true;no_wait();has_its= false;" things is pretty ugly...I didn't find the 1st solution elegant either and reverted to how the code looked like before your patch.
Quoted 78 lines
Quoted 32 lines
- identify the right commit this patch fixes
--- virt/kvm/arm/vgic/vgic-init.c | 8 +++++--- virt/kvm/arm/vgic/vgic-its.c | 2 +- virt/kvm/arm/vgic/vgic-v4.c | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-)virt/kvm/arm/vgic/vgic-init.c +5
-3@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_supports_direct_msis (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);virt/kvm/arm/vgic/vgic-its.c +0
-0virt/kvm/arm/vgic/vgic-its.c static int vgic_its_create(struct kvm_device *dev, u32 type) · line 1690
Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1
-1@@ -1687,7 +1687,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)if (!its)return -ENOMEM ; -if (vgic_initialized (dev->kvm)) { +if (kvm_vgic_global_state.has_gicv4 &&vgic_initialized (dev->kvm)) {... but now we're using
vgic_supports_direct_msis()in one part of the init path and a half-open coded version of that in another path, which is not very pretty.So I actually would suggest doing the init stuff more open-coded, because init of the gic/its/gicv4 is a mess anyway.
Something like this:
virt/kvm/arm/vgic/vgic-init.c +5
-3@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)if (ret) goto out; - ret =vgic_v4_init (kvm); -if (ret) - goto out; +if (vgic_has_its (kvm)) { + ret =vgic_v4_init (kvm); +if (ret) + goto out; + }kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_enable (vcpu);virt/kvm/arm/vgic/vgic-v4.c +1
-1@@ -118,7 +118,7 @@ int vgic_v4_init(struct kvm *kvm)struct kvm_vcpu *vcpu;int i, nr_vcpus, ret; -if (!vgic_supports_direct_msis (kvm)) +if (!kvm_vgic_global_state.has_gicv4)return 0 ;/* Nothing to see here... move along. */
Quoted 6 lines
Quoted 3 lines
virt/kvm/arm/vgic/vgic-v4.c +0
-0if (dist->its_vm.vpes)Does that work?
Looks OK to me. Unfortunately I don't have access to this specific machine anymore at the moment so I can't test it right now.
ok, I've queued my version with your reported-by.
Thanks,
-Christoffer