* [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC
@ 2017-12-07 11:46 Marc Zyngier
2017-12-07 15:57 ` Andre Przywara
2017-12-11 9:17 ` Christoffer Dall
0 siblings, 2 replies; 3+ messages in thread
From: Marc Zyngier @ 2017-12-07 11:46 UTC (permalink / raw)
To: linux-arm-kernel
If we don't have a usable GIC, do not try to set the vcpu affinity
as this is guaranteed to fail.
Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
include/kvm/arm_arch_timer.h | 2 +-
virt/kvm/arm/arch_timer.c | 13 ++++++++-----
virt/kvm/arm/arm.c | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
index 01ee473517e2..5fa4fef257a4 100644
--- a/include/kvm/arm_arch_timer.h
+++ b/include/kvm/arm_arch_timer.h
@@ -62,7 +62,7 @@ struct arch_timer_cpu {
bool enabled;
};
-int kvm_timer_hyp_init(void);
+int kvm_timer_hyp_init(bool);
int kvm_timer_enable(struct kvm_vcpu *vcpu);
int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu);
void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 4151250ce8da..4804b5608013 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -726,7 +726,7 @@ static int kvm_timer_dying_cpu(unsigned int cpu)
return 0;
}
-int kvm_timer_hyp_init(void)
+int kvm_timer_hyp_init(bool has_gic)
{
struct arch_timer_kvm_info *info;
int err;
@@ -762,10 +762,13 @@ int kvm_timer_hyp_init(void)
return err;
}
- err = irq_set_vcpu_affinity(host_vtimer_irq, kvm_get_running_vcpus());
- if (err) {
- kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
- goto out_free_irq;
+ if (has_gic) {
+ err = irq_set_vcpu_affinity(host_vtimer_irq,
+ kvm_get_running_vcpus());
+ if (err) {
+ kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
+ goto out_free_irq;
+ }
}
kvm_info("virtual timer IRQ%d\n", host_vtimer_irq);
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a67c106d73f5..d9df6d0731e6 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -1323,7 +1323,7 @@ static int init_subsystems(void)
/*
* Init HYP architected timer support
*/
- err = kvm_timer_hyp_init();
+ err = kvm_timer_hyp_init(vgic_present);
if (err)
goto out;
--
2.14.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC
2017-12-07 11:46 [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC Marc Zyngier
@ 2017-12-07 15:57 ` Andre Przywara
2017-12-11 9:17 ` Christoffer Dall
1 sibling, 0 replies; 3+ messages in thread
From: Andre Przywara @ 2017-12-07 15:57 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On 07/12/17 11:46, Marc Zyngier wrote:
> If we don't have a usable GIC, do not try to set the vcpu affinity
> as this is guaranteed to fail.
Yes, I can confirm that this fixes the problem. With this patch and a DT
advertising only a 4K GICC region size KVM still initializes, but denies
the in-kernel VGIC. kvmtool does not work anymore (expected), but QEMU
helps out with its userland GIC emulation.
> Reported-by: Andre Przywara <andre.przywara@arm.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
> ---
> include/kvm/arm_arch_timer.h | 2 +-
> virt/kvm/arm/arch_timer.c | 13 ++++++++-----
> virt/kvm/arm/arm.c | 2 +-
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
> index 01ee473517e2..5fa4fef257a4 100644
> --- a/include/kvm/arm_arch_timer.h
> +++ b/include/kvm/arm_arch_timer.h
> @@ -62,7 +62,7 @@ struct arch_timer_cpu {
> bool enabled;
> };
>
> -int kvm_timer_hyp_init(void);
> +int kvm_timer_hyp_init(bool);
> int kvm_timer_enable(struct kvm_vcpu *vcpu);
> int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu);
> void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
> diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
> index 4151250ce8da..4804b5608013 100644
> --- a/virt/kvm/arm/arch_timer.c
> +++ b/virt/kvm/arm/arch_timer.c
> @@ -726,7 +726,7 @@ static int kvm_timer_dying_cpu(unsigned int cpu)
> return 0;
> }
>
> -int kvm_timer_hyp_init(void)
> +int kvm_timer_hyp_init(bool has_gic)
> {
> struct arch_timer_kvm_info *info;
> int err;
> @@ -762,10 +762,13 @@ int kvm_timer_hyp_init(void)
> return err;
> }
>
> - err = irq_set_vcpu_affinity(host_vtimer_irq, kvm_get_running_vcpus());
> - if (err) {
> - kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
> - goto out_free_irq;
> + if (has_gic) {
> + err = irq_set_vcpu_affinity(host_vtimer_irq,
> + kvm_get_running_vcpus());
> + if (err) {
> + kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
> + goto out_free_irq;
> + }
> }
>
> kvm_info("virtual timer IRQ%d\n", host_vtimer_irq);
> diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
> index a67c106d73f5..d9df6d0731e6 100644
> --- a/virt/kvm/arm/arm.c
> +++ b/virt/kvm/arm/arm.c
> @@ -1323,7 +1323,7 @@ static int init_subsystems(void)
> /*
> * Init HYP architected timer support
> */
> - err = kvm_timer_hyp_init();
> + err = kvm_timer_hyp_init(vgic_present);
> if (err)
> goto out;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC
2017-12-07 11:46 [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC Marc Zyngier
2017-12-07 15:57 ` Andre Przywara
@ 2017-12-11 9:17 ` Christoffer Dall
1 sibling, 0 replies; 3+ messages in thread
From: Christoffer Dall @ 2017-12-11 9:17 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 07, 2017 at 11:46:15AM +0000, Marc Zyngier wrote:
> If we don't have a usable GIC, do not try to set the vcpu affinity
> as this is guaranteed to fail.
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
... and applied.
Thanks for fixing my broken code,
-Christoffer
>
> Reported-by: Andre Przywara <andre.przywara@arm.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> include/kvm/arm_arch_timer.h | 2 +-
> virt/kvm/arm/arch_timer.c | 13 ++++++++-----
> virt/kvm/arm/arm.c | 2 +-
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
> index 01ee473517e2..5fa4fef257a4 100644
> --- a/include/kvm/arm_arch_timer.h
> +++ b/include/kvm/arm_arch_timer.h
> @@ -62,7 +62,7 @@ struct arch_timer_cpu {
> bool enabled;
> };
>
> -int kvm_timer_hyp_init(void);
> +int kvm_timer_hyp_init(bool);
> int kvm_timer_enable(struct kvm_vcpu *vcpu);
> int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu);
> void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
> diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
> index 4151250ce8da..4804b5608013 100644
> --- a/virt/kvm/arm/arch_timer.c
> +++ b/virt/kvm/arm/arch_timer.c
> @@ -726,7 +726,7 @@ static int kvm_timer_dying_cpu(unsigned int cpu)
> return 0;
> }
>
> -int kvm_timer_hyp_init(void)
> +int kvm_timer_hyp_init(bool has_gic)
> {
> struct arch_timer_kvm_info *info;
> int err;
> @@ -762,10 +762,13 @@ int kvm_timer_hyp_init(void)
> return err;
> }
>
> - err = irq_set_vcpu_affinity(host_vtimer_irq, kvm_get_running_vcpus());
> - if (err) {
> - kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
> - goto out_free_irq;
> + if (has_gic) {
> + err = irq_set_vcpu_affinity(host_vtimer_irq,
> + kvm_get_running_vcpus());
> + if (err) {
> + kvm_err("kvm_arch_timer: error setting vcpu affinity\n");
> + goto out_free_irq;
> + }
> }
>
> kvm_info("virtual timer IRQ%d\n", host_vtimer_irq);
> diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
> index a67c106d73f5..d9df6d0731e6 100644
> --- a/virt/kvm/arm/arm.c
> +++ b/virt/kvm/arm/arm.c
> @@ -1323,7 +1323,7 @@ static int init_subsystems(void)
> /*
> * Init HYP architected timer support
> */
> - err = kvm_timer_hyp_init();
> + err = kvm_timer_hyp_init(vgic_present);
> if (err)
> goto out;
>
> --
> 2.14.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-11 9:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 11:46 [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC Marc Zyngier
2017-12-07 15:57 ` Andre Przywara
2017-12-11 9:17 ` Christoffer Dall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).