From: Marc Zyngier <maz@kernel•org>
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, Eric Auger <eric.auger@redhat•com>,
Heinrich Schuchardt <xypron.glpk@gmx•de>,
Sebastian Andrzej Siewior <bigeasy@linutronix•de>,
Suzuki K Poulose <suzuki.poulose@arm•com>,
Christoffer Dall <christoffer.dall@arm•com>,
stable@vger•kernel.org, Steven Price <steven.price@arm•com>,
Christian Borntraeger <borntraeger@de•ibm.com>,
Julien Grall <julien.grall@arm•com>,
Alexander Graf <graf@amazon•com>,
linux-arm-kernel@lists•infradead.org,
Zenghui Yu <yuzenghui@huawei•com>,
James Morse <james.morse@arm•com>,
Thomas Gleixner <tglx@linutronix•de>,
Will Deacon <will@kernel•org>,
kvmarm@lists•cs.columbia.edu,
Julien Thierry <julien.thierry.kdev@gmail•com>
Subject: [PATCH 19/22] KVM: arm/arm64: vgic: Don't rely on the wrong pending table
Date: Wed, 20 Nov 2019 16:42:33 +0000 [thread overview]
Message-ID: <20191120164236.29359-20-maz@kernel.org> (raw)
In-Reply-To: <20191120164236.29359-1-maz@kernel.org>
From: Zenghui Yu <yuzenghui@huawei•com>
It's possible that two LPIs locate in the same "byte_offset" but target
two different vcpus, where their pending status are indicated by two
different pending tables. In such a scenario, using last_byte_offset
optimization will lead KVM relying on the wrong pending table entry.
Let us use last_ptr instead, which can be treated as a byte index into
a pending table and also, can be vcpu specific.
Fixes: 280771252c1b ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES")
Cc: stable@vger•kernel.org
Signed-off-by: Zenghui Yu <yuzenghui@huawei•com>
Signed-off-by: Marc Zyngier <maz@kernel•org>
Acked-by: Eric Auger <eric.auger@redhat•com>
Link: https://lore.kernel.org/r/20191029071919.177-4-yuzenghui@huawei.com
---
virt/kvm/arm/vgic/vgic-v3.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index e69c538a24ca..f45635a6f0ec 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -363,8 +363,8 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq)
int vgic_v3_save_pending_tables(struct kvm *kvm)
{
struct vgic_dist *dist = &kvm->arch.vgic;
- int last_byte_offset = -1;
struct vgic_irq *irq;
+ gpa_t last_ptr = ~(gpa_t)0;
int ret;
u8 val;
@@ -384,11 +384,11 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
bit_nr = irq->intid % BITS_PER_BYTE;
ptr = pendbase + byte_offset;
- if (byte_offset != last_byte_offset) {
+ if (ptr != last_ptr) {
ret = kvm_read_guest_lock(kvm, ptr, &val, 1);
if (ret)
return ret;
- last_byte_offset = byte_offset;
+ last_ptr = ptr;
}
stored = val & (1U << bit_nr);
--
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-11-20 16:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 16:42 [GIT PULL] KVM/arm updates for 5.5 Marc Zyngier
2019-11-20 16:42 ` [PATCH 01/22] KVM: arm/arm64: Allow reporting non-ISV data aborts to userspace Marc Zyngier
2019-11-20 16:42 ` [PATCH 02/22] KVM: arm/arm64: Allow user injection of external data aborts Marc Zyngier
2019-11-20 16:42 ` [PATCH 03/22] KVM: arm64: Document PV-time interface Marc Zyngier
2019-11-20 16:42 ` [PATCH 04/22] KVM: arm/arm64: Factor out hypercall handling from PSCI code Marc Zyngier
2019-11-20 16:42 ` [PATCH 05/22] KVM: arm64: Implement PV_TIME_FEATURES call Marc Zyngier
2019-11-20 16:42 ` [PATCH 06/22] KVM: Implement kvm_put_guest() Marc Zyngier
2019-11-20 16:42 ` [PATCH 07/22] KVM: arm64: Support stolen time reporting via shared structure Marc Zyngier
2019-11-20 16:42 ` [PATCH 08/22] KVM: Allow kvm_device_ops to be const Marc Zyngier
2019-11-20 16:42 ` [PATCH 09/22] KVM: arm64: Provide VCPU attributes for stolen time Marc Zyngier
2019-11-20 16:42 ` [PATCH 10/22] arm/arm64: Provide a wrapper for SMCCC 1.1 calls Marc Zyngier
2019-11-20 16:42 ` [PATCH 11/22] arm/arm64: Make use of the SMCCC 1.1 wrapper Marc Zyngier
2019-11-20 16:42 ` [PATCH 12/22] arm64: Retrieve stolen time as paravirtualized guest Marc Zyngier
2019-11-20 16:42 ` [PATCH 13/22] KVM: arm64: Select TASK_DELAY_ACCT+TASKSTATS rather than SCHEDSTATS Marc Zyngier
2019-11-20 16:42 ` [PATCH 14/22] KVM: arm/arm64: Show halt poll counters in debugfs Marc Zyngier
2019-11-20 16:42 ` [PATCH 15/22] KVM: arm64: Don't set HCR_EL2.TVM when S2FWB is supported Marc Zyngier
2019-11-20 16:42 ` [PATCH 16/22] KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put Marc Zyngier
2019-11-20 16:42 ` [PATCH 17/22] KVM: arm/arm64: vgic: Remove the declaration of kvm_send_userspace_msi() Marc Zyngier
2019-11-20 16:42 ` [PATCH 18/22] KVM: arm/arm64: vgic: Fix some comments typo Marc Zyngier
2019-11-20 16:42 ` Marc Zyngier [this message]
2019-11-20 16:42 ` [PATCH 20/22] KVM: arm/arm64: Let the timer expire in hardirq context on RT Marc Zyngier
2019-11-20 16:42 ` [PATCH 21/22] KVM: vgic-v4: Track the number of VLPIs per vcpu Marc Zyngier
2019-11-20 16:42 ` [PATCH 22/22] KVM: arm64: Opportunistically turn off WFI trapping when using direct LPI injection Marc Zyngier
2019-11-21 8:58 ` [GIT PULL] KVM/arm updates for 5.5 Paolo Bonzini
2019-11-21 9:06 ` Marc Zyngier
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=20191120164236.29359-20-maz@kernel.org \
--to=maz@kernel$(echo .)org \
--cc=bigeasy@linutronix$(echo .)de \
--cc=borntraeger@de$(echo .)ibm.com \
--cc=christoffer.dall@arm$(echo .)com \
--cc=drjones@redhat$(echo .)com \
--cc=eric.auger@redhat$(echo .)com \
--cc=graf@amazon$(echo .)com \
--cc=james.morse@arm$(echo .)com \
--cc=julien.grall@arm$(echo .)com \
--cc=julien.thierry.kdev@gmail$(echo .)com \
--cc=kvm@vger$(echo .)kernel.org \
--cc=kvmarm@lists$(echo .)cs.columbia.edu \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=mark.rutland@arm$(echo .)com \
--cc=pbonzini@redhat$(echo .)com \
--cc=rkrcmar@redhat$(echo .)com \
--cc=stable@vger$(echo .)kernel.org \
--cc=steven.price@arm$(echo .)com \
--cc=suzuki.poulose@arm$(echo .)com \
--cc=tglx@linutronix$(echo .)de \
--cc=will@kernel$(echo .)org \
--cc=xypron.glpk@gmx$(echo .)de \
--cc=yuzenghui@huawei$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox