[PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

Subsystems: kernel virtual machine (kvm), the rest

STALE2901d

4 messages, 4 authors, 2018-11-15 · open the first message on its own page

[PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

From: Peng Hao <hidden>
Date: 2018-11-15 06:52:02

When virtual machine starts, hang up. The kernel version of guest
is 4.16. Host support vgic_v3.
It was mainly due to the incorrect vgic_irq's(intid=27) group value
during injection interruption. when kvm_vgic_vcpu_init is called,
dist is not initialized at this time. Unable to get vgic V3 or V2
correctly, so group is not set.
group is setted to 1 when vgic_mmio_write_group is invoked at some
time.
when irq->group=0 (intid=27), No ICH_LR_GROUP flag was set and
interrupt injection failed.

Signed-off-by: Peng Hao <redacted>
---
 virt/kvm/arm/vgic/vgic-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 9c0dd23..d101000 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -198,7 +198,7 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
 	if (vgic_irq_is_mapped_level(irq) && (val & ICH_LR_PENDING_BIT))
 		irq->line_level = false;
 
-	if (irq->group)
+	if (model == KVM_DEV_TYPE_ARM_VGIC_V3)
 		val |= ICH_LR_GROUP;
 
 	val |= (u64)irq->priority << ICH_LR_PRIORITY_SHIFT;
-- 
1.8.3.1

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

From: Julien Thierry <hidden>
Date: 2018-11-15 09:43:00

Hi Peng,

On 15/11/18 15:14, Peng Hao wrote:
When virtual machine starts, hang up. The kernel version of guest
is 4.16. Host support vgic_v3.
I don't understand the issue here. the vgic_irq->group field does not 
exist in 4.16 (neither in the first nor the last version). Nor does the 
line you are modifying.

Both exist in mainline, but what you are mentioning shouldn't be an 
issue in mainline since vgic_irq->group gets initialized in 
kvm_vgic_vcpu_init for SGIs and PPIs (i.e. intid < 32) which includes 
your interrupt.

Cheers,
quoted hunk
It was mainly due to the incorrect vgic_irq's(intid=27) group value
during injection interruption. when kvm_vgic_vcpu_init is called,
dist is not initialized at this time. Unable to get vgic V3 or V2
correctly, so group is not set.
group is setted to 1 when vgic_mmio_write_group is invoked at some
time.
when irq->group=0 (intid=27), No ICH_LR_GROUP flag was set and
interrupt injection failed.

Signed-off-by: Peng Hao <redacted>
---
  virt/kvm/arm/vgic/vgic-v3.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 9c0dd23..d101000 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -198,7 +198,7 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
  	if (vgic_irq_is_mapped_level(irq) && (val & ICH_LR_PENDING_BIT))
  		irq->line_level = false;
  
-	if (irq->group)
+	if (model == KVM_DEV_TYPE_ARM_VGIC_V3)
  		val |= ICH_LR_GROUP;
  
  	val |= (u64)irq->priority << ICH_LR_PRIORITY_SHIFT;
-- 
Julien Thierry

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

From: Andre Przywara <andre.przywara@arm.com>
Date: 2018-11-15 14:39:14

On Thu, 15 Nov 2018 23:14:08 +0800
Peng Hao [off-list ref] wrote:

Hi,
When virtual machine starts, hang up.
I take it you mean the *guest* hangs? Because it doesn't get a timer
interrupt?
The kernel version of guest
is 4.16. Host support vgic_v3.
Your host kernel is something recent, I guess?
It was mainly due to the incorrect vgic_irq's(intid=27) group value
during injection interruption. when kvm_vgic_vcpu_init is called,
dist is not initialized at this time. Unable to get vgic V3 or V2
correctly, so group is not set.
Mmh, that shouldn't happen with (v)GICv3. Do you use QEMU (which
version?) or some other userland tool?
quoted hunk
group is setted to 1 when vgic_mmio_write_group is invoked at some
time.
when irq->group=0 (intid=27), No ICH_LR_GROUP flag was set and
interrupt injection failed.

Signed-off-by: Peng Hao <redacted>
---
 virt/kvm/arm/vgic/vgic-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 9c0dd23..d101000 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -198,7 +198,7 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu,
struct vgic_irq *irq, int lr) if (vgic_irq_is_mapped_level(irq) &&
(val & ICH_LR_PENDING_BIT)) irq->line_level = false;
 
-	if (irq->group)
+	if (model == KVM_DEV_TYPE_ARM_VGIC_V3)
This is not the right fix, not only because it basically reverts the
GICv3 part of 87322099052 (KVM: arm/arm64: vgic: Signal IRQs using
their configured group).

Can you try to work out why kvm_vgic_vcpu_init() is apparently called
before dist->vgic_model is set, also what value it has?
If I understand the code correctly, that shouldn't happen for a GICv3.

Cheers,
Andre.
 		val |= ICH_LR_GROUP;
 
 	val |= (u64)irq->priority << ICH_LR_PRIORITY_SHIFT;

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

From: Marc Zyngier <hidden>
Date: 2018-11-15 15:06:23

On Thu, 15 Nov 2018 15:14:08 +0000,
Peng Hao [off-list ref] wrote:
quoted hunk
When virtual machine starts, hang up. The kernel version of guest
is 4.16. Host support vgic_v3.
It was mainly due to the incorrect vgic_irq's(intid=27) group value
during injection interruption. when kvm_vgic_vcpu_init is called,
dist is not initialized at this time. Unable to get vgic V3 or V2
correctly, so group is not set.
group is setted to 1 when vgic_mmio_write_group is invoked at some
time.
when irq->group=0 (intid=27), No ICH_LR_GROUP flag was set and
interrupt injection failed.

Signed-off-by: Peng Hao <redacted>
---
 virt/kvm/arm/vgic/vgic-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 9c0dd23..d101000 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -198,7 +198,7 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
 	if (vgic_irq_is_mapped_level(irq) && (val & ICH_LR_PENDING_BIT))
 		irq->line_level = false;
 
-	if (irq->group)
+	if (model == KVM_DEV_TYPE_ARM_VGIC_V3)
 		val |= ICH_LR_GROUP;
 
 	val |= (u64)irq->priority << ICH_LR_PRIORITY_SHIFT;
This patch makes exactly zero sense. The group is a property of the
interrupt, and has nothing to do with the model used for the emulation

Which version of the kernel is this against? What userspace are you
using? How can I reproduce this issue?

Thanks,

	M.

-- 
Jazz is not dead, it just smell funny.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help