From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] ARM: KVM: be more thorough when invalidating TLBs
Date: Tue, 30 Apr 2013 19:02:16 +0100 [thread overview]
Message-ID: <51800728.9050306@arm.com> (raw)
In-Reply-To: <CAEDV+g+LKEj_XdeLvMwxJhVQ9FG9=U6eqO7dPU340xX2oMkS0A@mail.gmail.com>
On 30/04/13 18:17, Christoffer Dall wrote:
> On Tue, Apr 30, 2013 at 7:17 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> The KVM/ARM MMU code doesn't take care of invalidating TLBs before
>> freeing a {pte,pmd} table. This could cause problems if the page
>> is reallocated and then speculated into by another CPU.
>>
>> Reported-by: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> arch/arm/kvm/interrupts.S | 2 ++
>> arch/arm/kvm/mmu.c | 36 +++++++++++++++++++++---------------
>> 2 files changed, 23 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S
>> index f7793df..9e2d906c 100644
>> --- a/arch/arm/kvm/interrupts.S
>> +++ b/arch/arm/kvm/interrupts.S
>> @@ -37,6 +37,8 @@ __kvm_hyp_code_start:
>> *
>> * void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
>> *
>> + * Invalidate TLB for the given IPA, or invalidate all if ipa is zero.
>> + *
>> * We rely on the hardware to broadcast the TLB invalidation to all CPUs
>> * inside the inner-shareable domain (which is the case for all v7
>> * implementations). If we come across a non-IS SMP implementation, we'll
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 9657065..71f2a57 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -43,7 +43,8 @@ static phys_addr_t hyp_idmap_vector;
>>
>> static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
>> {
>> - kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
>> + if (kvm)
>> + kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
>
> this feels slightly abusive? could we add a comment that hyp page
> table freeing don't need tlb flushing from these functions and don't
> have a struct kvm?
>
> alternatively it may be more clear to have something like:
>
> if (kvm) /* Check if Hyp or Stage-2 page table */
> kvm_tlb_flush_vmid_ipa(kvm, addr);
>
> in the callers, but, eh, maybe I'm over thinking this.
That code would be repeated three times, which feels a bit overkill.
I'll add a comment to the function so it is crystal clear.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <cdall@cs.columbia.edu>
Cc: linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
KVM General <kvm@vger.kernel.org>,
Catalin Marinas <Catalin.Marinas@arm.com>
Subject: Re: [PATCH 1/4] ARM: KVM: be more thorough when invalidating TLBs
Date: Tue, 30 Apr 2013 19:02:16 +0100 [thread overview]
Message-ID: <51800728.9050306@arm.com> (raw)
In-Reply-To: <CAEDV+g+LKEj_XdeLvMwxJhVQ9FG9=U6eqO7dPU340xX2oMkS0A@mail.gmail.com>
On 30/04/13 18:17, Christoffer Dall wrote:
> On Tue, Apr 30, 2013 at 7:17 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> The KVM/ARM MMU code doesn't take care of invalidating TLBs before
>> freeing a {pte,pmd} table. This could cause problems if the page
>> is reallocated and then speculated into by another CPU.
>>
>> Reported-by: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> arch/arm/kvm/interrupts.S | 2 ++
>> arch/arm/kvm/mmu.c | 36 +++++++++++++++++++++---------------
>> 2 files changed, 23 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S
>> index f7793df..9e2d906c 100644
>> --- a/arch/arm/kvm/interrupts.S
>> +++ b/arch/arm/kvm/interrupts.S
>> @@ -37,6 +37,8 @@ __kvm_hyp_code_start:
>> *
>> * void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
>> *
>> + * Invalidate TLB for the given IPA, or invalidate all if ipa is zero.
>> + *
>> * We rely on the hardware to broadcast the TLB invalidation to all CPUs
>> * inside the inner-shareable domain (which is the case for all v7
>> * implementations). If we come across a non-IS SMP implementation, we'll
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 9657065..71f2a57 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -43,7 +43,8 @@ static phys_addr_t hyp_idmap_vector;
>>
>> static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
>> {
>> - kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
>> + if (kvm)
>> + kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
>
> this feels slightly abusive? could we add a comment that hyp page
> table freeing don't need tlb flushing from these functions and don't
> have a struct kvm?
>
> alternatively it may be more clear to have something like:
>
> if (kvm) /* Check if Hyp or Stage-2 page table */
> kvm_tlb_flush_vmid_ipa(kvm, addr);
>
> in the callers, but, eh, maybe I'm over thinking this.
That code would be repeated three times, which feels a bit overkill.
I'll add a comment to the function so it is crystal clear.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2013-04-30 18:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 14:17 [PATCH 0/4] ARM: KVM: random mmu related fixes for 3.10 Marc Zyngier
2013-04-30 14:17 ` Marc Zyngier
2013-04-30 14:17 ` [PATCH 1/4] ARM: KVM: be more thorough when invalidating TLBs Marc Zyngier
2013-04-30 14:17 ` Marc Zyngier
2013-04-30 17:17 ` Christoffer Dall
2013-04-30 17:17 ` Christoffer Dall
2013-04-30 18:02 ` Marc Zyngier [this message]
2013-04-30 18:02 ` Marc Zyngier
2013-04-30 14:17 ` [PATCH 2/4] ARM: KVM: remove dead prototype for __kvm_tlb_flush_vmid Marc Zyngier
2013-04-30 14:17 ` Marc Zyngier
2013-04-30 14:17 ` [PATCH 3/4] ARM: KVM: relax cache maintainance when building page pables Marc Zyngier
2013-04-30 14:17 ` Marc Zyngier
2013-04-30 14:30 ` Will Deacon
2013-04-30 14:30 ` Will Deacon
2013-04-30 14:17 ` [PATCH 4/4] ARM: KVM: fix use of S2_PGD_SIZE Marc Zyngier
2013-04-30 14:17 ` Marc Zyngier
2013-04-30 17:40 ` Christoffer Dall
2013-04-30 17:40 ` Christoffer Dall
2013-04-30 17:52 ` Marc Zyngier
2013-04-30 17:52 ` Marc Zyngier
2013-04-30 17:56 ` Christoffer Dall
2013-04-30 17:56 ` Christoffer Dall
2013-04-30 17:59 ` Marc Zyngier
2013-04-30 17:59 ` 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=51800728.9050306@arm.com \
--to=marc.zyngier@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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: link
Be 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.