Message ID | 20240820100349.3544850-5-maz@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: arm64: Handle the lack of GICv3 exposed to a guest | expand |
s/activa/active/ On Tue, Aug 20, 2024 at 11:03:41AM +0100, Marc Zyngier wrote: > On a VHE system, no GICv3 traps get configured when no irqchip is > present. This is not quite matching the "no GICv3" semantics that > we want to present. > > Force such traps to be configured in this case. > > Signed-off-by: Marc Zyngier <maz@kernel.org> > --- > arch/arm64/kvm/vgic/vgic.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > index 974849ea7101..2caa64415ff3 100644 > --- a/arch/arm64/kvm/vgic/vgic.c > +++ b/arch/arm64/kvm/vgic/vgic.c > @@ -917,10 +917,13 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) > > void kvm_vgic_load(struct kvm_vcpu *vcpu) > { > - if (unlikely(!vgic_initialized(vcpu->kvm))) > + if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) { Doesn't !vgic_initialized(vcpu->kvm) also cover the case of no irqchip in kernel?
On Wed, 21 Aug 2024 00:33:40 +0100, Oliver Upton <oliver.upton@linux.dev> wrote: > > s/activa/active/ > > On Tue, Aug 20, 2024 at 11:03:41AM +0100, Marc Zyngier wrote: > > On a VHE system, no GICv3 traps get configured when no irqchip is > > present. This is not quite matching the "no GICv3" semantics that > > we want to present. > > > > Force such traps to be configured in this case. > > > > Signed-off-by: Marc Zyngier <maz@kernel.org> > > --- > > arch/arm64/kvm/vgic/vgic.c | 14 ++++++++++---- > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > > index 974849ea7101..2caa64415ff3 100644 > > --- a/arch/arm64/kvm/vgic/vgic.c > > +++ b/arch/arm64/kvm/vgic/vgic.c > > @@ -917,10 +917,13 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) > > > > void kvm_vgic_load(struct kvm_vcpu *vcpu) > > { > > - if (unlikely(!vgic_initialized(vcpu->kvm))) > > + if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) { > > Doesn't !vgic_initialized(vcpu->kvm) also cover the case of no irqchip > in kernel? It does, but that's purely accidental. I can drop that, but it is really fragile. Thanks, M.
On Wed, Aug 21, 2024 at 12:13:57PM +0100, Marc Zyngier wrote: > On Wed, 21 Aug 2024 00:33:40 +0100, > Oliver Upton <oliver.upton@linux.dev> wrote: > > > > s/activa/active/ > > > > On Tue, Aug 20, 2024 at 11:03:41AM +0100, Marc Zyngier wrote: > > > On a VHE system, no GICv3 traps get configured when no irqchip is > > > present. This is not quite matching the "no GICv3" semantics that > > > we want to present. > > > > > > Force such traps to be configured in this case. > > > > > > Signed-off-by: Marc Zyngier <maz@kernel.org> > > > --- > > > arch/arm64/kvm/vgic/vgic.c | 14 ++++++++++---- > > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > > > index 974849ea7101..2caa64415ff3 100644 > > > --- a/arch/arm64/kvm/vgic/vgic.c > > > +++ b/arch/arm64/kvm/vgic/vgic.c > > > @@ -917,10 +917,13 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) > > > > > > void kvm_vgic_load(struct kvm_vcpu *vcpu) > > > { > > > - if (unlikely(!vgic_initialized(vcpu->kvm))) > > > + if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) { > > > > Doesn't !vgic_initialized(vcpu->kvm) also cover the case of no irqchip > > in kernel? > > It does, but that's purely accidental. I can drop that, but it is > really fragile. Oh, definitely not, I was just wondering if this was meant as a functional change or a readability change to make the relation explicit.
diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c index 974849ea7101..2caa64415ff3 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -917,10 +917,13 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) void kvm_vgic_load(struct kvm_vcpu *vcpu) { - if (unlikely(!vgic_initialized(vcpu->kvm))) + if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) { + if (has_vhe() && static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) + __vgic_v3_activate_traps(&vcpu->arch.vgic_cpu.vgic_v3); return; + } - if (kvm_vgic_global_state.type == VGIC_V2) + if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) vgic_v2_load(vcpu); else vgic_v3_load(vcpu); @@ -928,10 +931,13 @@ void kvm_vgic_load(struct kvm_vcpu *vcpu) void kvm_vgic_put(struct kvm_vcpu *vcpu) { - if (unlikely(!vgic_initialized(vcpu->kvm))) + if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) { + if (has_vhe() && static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) + __vgic_v3_deactivate_traps(&vcpu->arch.vgic_cpu.vgic_v3); return; + } - if (kvm_vgic_global_state.type == VGIC_V2) + if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) vgic_v2_put(vcpu); else vgic_v3_put(vcpu);
On a VHE system, no GICv3 traps get configured when no irqchip is present. This is not quite matching the "no GICv3" semantics that we want to present. Force such traps to be configured in this case. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kvm/vgic/vgic.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)