From: Marc Zyngier <marc.zyngier@arm.com> To: "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com> Cc: kvm@vger.kernel.org, Richard Henderson <richard.henderson@linaro.org>, Masami Hiramatsu <mhiramat@kernel.org>, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/11] KVM: arm/arm64: vgic: Always initialize the group of private IRQs Date: Thu, 7 Feb 2019 13:18:40 +0000 [thread overview] Message-ID: <20190207131843.157210-9-marc.zyngier@arm.com> (raw) In-Reply-To: <20190207131843.157210-1-marc.zyngier@arm.com> From: Christoffer Dall <christoffer.dall@arm.com> We currently initialize the group of private IRQs during kvm_vgic_vcpu_init, and the value of the group depends on the GIC model we are emulating. However, CPUs created before creating (and initializing) the VGIC might end up with the wrong group if the VGIC is created as GICv3 later. Since we have no enforced ordering of creating the VGIC and creating VCPUs, we can end up with part the VCPUs being properly intialized and the remaining incorrectly initialized. That also means that we have no single place to do the per-cpu data structure initialization which depends on knowing the emulated GIC model (which is only the group field). This patch removes the incorrect comment from kvm_vgic_vcpu_init and initializes the group of all previously created VCPUs's private interrupts in vgic_init in addition to the existing initialization in kvm_vgic_vcpu_init. Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- virt/kvm/arm/vgic/vgic-init.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index dfbfcb1fe933..3bdb31eaed64 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -231,13 +231,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) irq->config = VGIC_CONFIG_LEVEL; } - /* - * GICv3 can only be created via the KVM_DEVICE_CREATE API and - * so we always know the emulation type at this point as it's - * either explicitly configured as GICv3, or explicitly - * configured as GICv2, or not configured yet which also - * implies GICv2. - */ if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) irq->group = 1; else @@ -281,7 +274,7 @@ int vgic_init(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; struct kvm_vcpu *vcpu; - int ret = 0, i; + int ret = 0, i, idx; if (vgic_initialized(kvm)) return 0; @@ -298,6 +291,19 @@ int vgic_init(struct kvm *kvm) if (ret) goto out; + /* Initialize groups on CPUs created before the VGIC type was known */ + kvm_for_each_vcpu(idx, vcpu, kvm) { + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + + for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { + struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; + if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) + irq->group = 1; + else + irq->group = 0; + } + } + if (vgic_has_its(kvm)) { ret = vgic_v4_init(kvm); if (ret) -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com> To: "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com>, Andrew Jones <drjones@redhat.com>, kvm@vger.kernel.org, Julien Thierry <julien.thierry@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Richard Henderson <richard.henderson@linaro.org>, Christoffer Dall <christoffer.dall@arm.com>, James Morse <james.morse@arm.com>, Masami Hiramatsu <mhiramat@kernel.org>, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/11] KVM: arm/arm64: vgic: Always initialize the group of private IRQs Date: Thu, 7 Feb 2019 13:18:40 +0000 [thread overview] Message-ID: <20190207131843.157210-9-marc.zyngier@arm.com> (raw) In-Reply-To: <20190207131843.157210-1-marc.zyngier@arm.com> From: Christoffer Dall <christoffer.dall@arm.com> We currently initialize the group of private IRQs during kvm_vgic_vcpu_init, and the value of the group depends on the GIC model we are emulating. However, CPUs created before creating (and initializing) the VGIC might end up with the wrong group if the VGIC is created as GICv3 later. Since we have no enforced ordering of creating the VGIC and creating VCPUs, we can end up with part the VCPUs being properly intialized and the remaining incorrectly initialized. That also means that we have no single place to do the per-cpu data structure initialization which depends on knowing the emulated GIC model (which is only the group field). This patch removes the incorrect comment from kvm_vgic_vcpu_init and initializes the group of all previously created VCPUs's private interrupts in vgic_init in addition to the existing initialization in kvm_vgic_vcpu_init. Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- virt/kvm/arm/vgic/vgic-init.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index dfbfcb1fe933..3bdb31eaed64 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -231,13 +231,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) irq->config = VGIC_CONFIG_LEVEL; } - /* - * GICv3 can only be created via the KVM_DEVICE_CREATE API and - * so we always know the emulation type at this point as it's - * either explicitly configured as GICv3, or explicitly - * configured as GICv2, or not configured yet which also - * implies GICv2. - */ if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) irq->group = 1; else @@ -281,7 +274,7 @@ int vgic_init(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; struct kvm_vcpu *vcpu; - int ret = 0, i; + int ret = 0, i, idx; if (vgic_initialized(kvm)) return 0; @@ -298,6 +291,19 @@ int vgic_init(struct kvm *kvm) if (ret) goto out; + /* Initialize groups on CPUs created before the VGIC type was known */ + kvm_for_each_vcpu(idx, vcpu, kvm) { + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + + for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { + struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; + if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) + irq->group = 1; + else + irq->group = 0; + } + } + if (vgic_has_its(kvm)) { ret = vgic_v4_init(kvm); if (ret) -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-02-07 13:18 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-07 13:18 [GIT PULL] KVM/ARM updates for 5.0-rc6 Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 01/11] KVM: arm/arm64: vgic: Make vgic_irq->irq_lock a raw_spinlock Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 02/11] KVM: arm/arm64: vgic: Make vgic_dist->lpi_list_lock " Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 03/11] KVM: arm/arm64: vgic: Make vgic_cpu->ap_list_lock " Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 04/11] arm64: KVM: Don't generate UNDEF when LORegion feature is present Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 05/11] KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-03-04 16:30 ` Julien Grall 2019-03-04 16:30 ` Julien Grall 2019-03-04 17:06 ` Marc Zyngier 2019-03-04 17:06 ` Marc Zyngier 2019-03-04 17:31 ` Julien Grall 2019-03-04 17:31 ` Julien Grall 2019-03-04 17:37 ` Marc Zyngier 2019-03-04 17:37 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 06/11] arm/arm64: KVM: Allow a VCPU to fully reset itself Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 07/11] arm/arm64: KVM: Don't panic on failure to properly reset system registers Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier [this message] 2019-02-07 13:18 ` [PATCH 08/11] KVM: arm/arm64: vgic: Always initialize the group of private IRQs Marc Zyngier 2019-02-07 13:18 ` [PATCH 09/11] arm: KVM: Add missing kvm_stage2_has_pmd() helper Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 10/11] KVM: arm64: Relax the restriction on using stage2 PUD huge mapping Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-07 13:18 ` [PATCH 11/11] KVM: arm64: Forbid kprobing of the VHE world-switch code Marc Zyngier 2019-02-07 13:18 ` Marc Zyngier 2019-02-13 18:39 ` [GIT PULL] KVM/ARM updates for 5.0-rc6 Paolo Bonzini 2019-02-13 18:39 ` Paolo Bonzini
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190207131843.157210-9-marc.zyngier@arm.com \ --to=marc.zyngier@arm.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=mhiramat@kernel.org \ --cc=pbonzini@redhat.com \ --cc=richard.henderson@linaro.org \ --cc=rkrcmar@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.