From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH v2 08/28] ARM: KVM: Add TLB invalidation code
Date: Wed, 10 Feb 2016 15:32:52 +0000 [thread overview]
Message-ID: <56BB5824.2010502@arm.com> (raw)
In-Reply-To: <20160209184228.GL5171@cbox>
On 09/02/16 18:42, Christoffer Dall wrote:
> On Thu, Feb 04, 2016 at 11:00:25AM +0000, Marc Zyngier wrote:
>> Convert the TLB invalidation code to C, hooking it into the
>> build system whilst we're at it.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> arch/arm/kvm/Makefile | 1 +
>> arch/arm/kvm/hyp/Makefile | 5 ++++
>> arch/arm/kvm/hyp/hyp.h | 5 ++++
>> arch/arm/kvm/hyp/tlb.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 82 insertions(+)
>> create mode 100644 arch/arm/kvm/hyp/Makefile
>> create mode 100644 arch/arm/kvm/hyp/tlb.c
>>
>> diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
>> index c5eef02c..eb1bf43 100644
>> --- a/arch/arm/kvm/Makefile
>> +++ b/arch/arm/kvm/Makefile
>> @@ -17,6 +17,7 @@ AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
>> KVM := ../../../virt/kvm
>> kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o $(KVM)/vfio.o
>>
>> +obj-$(CONFIG_KVM_ARM_HOST) += hyp/
>> obj-y += kvm-arm.o init.o interrupts.o
>> obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
>> obj-y += coproc.o coproc_a15.o coproc_a7.o mmio.o psci.o perf.o
>> diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
>> new file mode 100644
>> index 0000000..36c760d
>> --- /dev/null
>> +++ b/arch/arm/kvm/hyp/Makefile
>> @@ -0,0 +1,5 @@
>> +#
>> +# Makefile for Kernel-based Virtual Machine module, HYP part
>> +#
>> +
>> +obj-$(CONFIG_KVM_ARM_HOST) += tlb.o
>> diff --git a/arch/arm/kvm/hyp/hyp.h b/arch/arm/kvm/hyp/hyp.h
>> index 727089f..5808bbd 100644
>> --- a/arch/arm/kvm/hyp/hyp.h
>> +++ b/arch/arm/kvm/hyp/hyp.h
>> @@ -42,4 +42,9 @@
>> })
>> #define read_sysreg(...) __read_sysreg(__VA_ARGS__)
>>
>> +#define VTTBR __ACCESS_CP15_64(6, c2)
>> +#define ICIALLUIS __ACCESS_CP15(c7, 0, c1, 0)
>> +#define TLBIALLIS __ACCESS_CP15(c8, 0, c3, 0)
>> +#define TLBIALLNSNHIS __ACCESS_CP15(c8, 4, c3, 4)
>> +
>> #endif /* __ARM_KVM_HYP_H__ */
>> diff --git a/arch/arm/kvm/hyp/tlb.c b/arch/arm/kvm/hyp/tlb.c
>> new file mode 100644
>> index 0000000..993fe89
>> --- /dev/null
>> +++ b/arch/arm/kvm/hyp/tlb.c
>> @@ -0,0 +1,71 @@
>> +/*
>> + * Original code:
>> + * Copyright (C) 2012 - Virtual Open Systems and Columbia University
>> + * Author: Christoffer Dall <c.dall@virtualopensystems.com>
>> + *
>> + * Mostly rewritten in C by Marc Zyngier <marc.zyngier@arm.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include "hyp.h"
>> +
>> +/**
>> + * Flush per-VMID TLBs
>> + *
>> + * __kvm_tlb_flush_vmid(struct kvm *kvm);
>> + *
>> + * 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
>> + * have to use an IPI based mechanism. Until then, we stick to the simple
>> + * hardware assisted version.
>> + *
>> + * As v7 does not support flushing per IPA, just nuke the whole TLB
>> + * instead, ignoring the ipa value.
>> + */
>> +static void __hyp_text __tlb_flush_vmid(struct kvm *kvm)
>> +{
>> + dsb(ishst);
>> +
>> + /* Switch to requested VMID */
>> + kvm = kern_hyp_va(kvm);
>> + write_sysreg(kvm->arch.vttbr, VTTBR);
>> + isb();
>> +
>> + write_sysreg(0, TLBIALLIS);
>> + dsb(ish);
>> + isb();
>> +
>> + write_sysreg(0, VTTBR);
>> +}
>> +
>> +__alias(__tlb_flush_vmid) void __weak __kvm_tlb_flush_vmid(struct kvm *kvm);
>> +
>> +static void __hyp_text __tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
>> +{
>> + __tlb_flush_vmid(kvm);
>> +}
>> +
>> +__alias(__tlb_flush_vmid_ipa) void __weak __kvm_tlb_flush_vmid_ipa(struct kvm *kvm,
>> + phys_addr_t ipa);
>> +
>> +static void __hyp_text __tlb_flush_vm_context(void)
>> +{
>> + dsb(ishst);
>
> do we need this initial dsb?
I'm a copy-paste muppet. I'll drop that.
>> + write_sysreg(0, TLBIALLNSNHIS);
>> + write_sysreg(0, ICIALLUIS);
>> + dsb(ish);
>
> we used to have an isb here, but we got rid of this because it's always
> followed by eret?
Indeed. We were super extra cautious in the old code, and eret does the
right thing.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2016-02-10 15:32 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 11:00 [PATCH v2 00/28] ARM: KVM: Rewrite the world switch in C (mostly) Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 01/28] ARM: KVM: Move the HYP code to its own section Marc Zyngier
2016-02-09 18:39 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 02/28] ARM: KVM: Remove __kvm_hyp_code_start/__kvm_hyp_code_end Marc Zyngier
2016-02-09 18:39 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 03/28] ARM: KVM: Move VFP registers to a CPU context structure Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 04/28] ARM: KVM: Move CP15 array into the " Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 05/28] ARM: KVM: Move GP registers " Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 06/28] ARM: KVM: Add a HYP-specific header file Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 07/28] ARM: KVM: Add system register accessor macros Marc Zyngier
2016-02-10 17:25 ` Christoffer Dall
2016-02-10 17:32 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 08/28] ARM: KVM: Add TLB invalidation code Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-10 15:32 ` Marc Zyngier [this message]
2016-02-04 11:00 ` [PATCH v2 09/28] ARM: KVM: Add CP15 save/restore code Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 10/28] ARM: KVM: Add timer save/restore Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-10 15:36 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 11/28] ARM: KVM: Add vgic v2 save/restore Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 12/28] ARM: KVM: Add VFP save/restore Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 13/28] ARM: KVM: Add banked registers save/restore Marc Zyngier
2016-02-09 18:42 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 14/28] ARM: KVM: Add guest entry code Marc Zyngier
2016-02-09 18:44 ` Christoffer Dall
2016-02-10 15:48 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 15/28] ARM: KVM: Add VFP lazy save/restore handler Marc Zyngier
2016-02-09 18:44 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 16/28] ARM: KVM: Add the new world switch implementation Marc Zyngier
2016-02-09 18:44 ` Christoffer Dall
2016-02-10 16:00 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 17/28] ARM: KVM: Add populating of fault data structure Marc Zyngier
2016-02-09 18:44 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 18/28] ARM: KVM: Add HYP mode entry code Marc Zyngier
2016-02-09 17:00 ` Christoffer Dall
2016-02-10 16:02 ` Marc Zyngier
2016-02-10 17:23 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 19/28] ARM: KVM: Add panic handling code Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-10 16:03 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 20/28] ARM: KVM: Change kvm_call_hyp return type to unsigned long Marc Zyngier
2016-02-09 18:28 ` Christoffer Dall
2016-02-10 16:07 ` Marc Zyngier
2016-02-04 11:00 ` [PATCH v2 21/28] ARM: KVM: Remove the old world switch Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 22/28] ARM: KVM: Switch to C-based stage2 init Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-10 7:42 ` Marc Zyngier
2016-02-10 8:04 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 23/28] ARM: KVM: Remove __weak attributes Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 24/28] ARM: KVM: Turn CP15 defines to an enum Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 25/28] ARM: KVM: Cleanup asm-offsets.c Marc Zyngier
2016-02-09 18:45 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 26/28] ARM: KVM: Remove unused hyp_pc field Marc Zyngier
2016-02-09 18:39 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 27/28] ARM: KVM: Remove handling of ARM_EXCEPTION_DATA/PREF_ABORT Marc Zyngier
2016-02-09 18:39 ` Christoffer Dall
2016-02-04 11:00 ` [PATCH v2 28/28] ARM: KVM: Remove __kvm_hyp_exit/__kvm_hyp_exit_end Marc Zyngier
2016-02-09 18:39 ` Christoffer Dall
2016-02-09 18:49 ` [PATCH v2 00/28] ARM: KVM: Rewrite the world switch in C (mostly) Christoffer Dall
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=56BB5824.2010502@arm.com \
--to=marc.zyngier@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--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 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).