Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1554071

[RFC 36/55] KVM: arm64: Invalidate virtual EL2 TLB entries when needed

Path csiph.com!news.redatomik.org!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From Jintack Lim <jintack@cs.columbia.edu>
Newsgroups linux.kernel
Subject [RFC 36/55] KVM: arm64: Invalidate virtual EL2 TLB entries when needed
Date Mon, 09 Jan 2017 07:40:01 +0100
Message-ID <sXBMB-zF-3@gated-at.bofh.it> (permalink)
References <sXBCV-wl-3@gated-at.bofh.it>
X-Original-To christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UCx/kMtE+KrXA4UGZ4HPR0B7ZxlkCeqIcK7C4WJj+MA=; b=ZHcvdcvLfaOU65247A09bf7qfDUNZoZfjRvooKUrtQpoMvGvV2t4y2TQHXUQ8s0t6R EQPjn6h05n5hbXuoFL7TyFg050PHlxH855SPssm0gwlguuCqVrvb7s0kml1czEfIBBM9 IrDalRALE2Tj3sqebwXmnEMM64Yu6lCmgeXb6axrnNn1Ri/OIjAGnG5mjok17Qshu9as xfhCWgfOTc6SPccooxxtyooyvBtIjSrTLUj63BF627vlvP2CB6E+Bd3X/V/h6B1aiW5J 72qVRMniv3pYKWf3r2xk0GIt3dlC61xI+55nO9GDzwM0Ut3vWXIug6Tz7f26IS63ISJx sGpQ==
X-Gm-Message-State AIkVDXJAZIiZhAvmYKFJRd2X2CAASn2FywKhBkk+di6iKH66xz9AHtN20gLA5mC7U+YRvMXYJQcCWg3kLZ5u+VprE7iqqi10THvfcIQEGrxSyCthJOl704eiwrHiWA5NazT2tYz734ejlaqU/f2eu2wjsx4=
X-Received by 10.55.169.216 with SMTP id s207mr22511349qke.211.1483943177841; Sun, 08 Jan 2017 22:26:17 -0800 (PST)
X-Received by 10.55.169.216 with SMTP id s207mr22511329qke.211.1483943177701; Sun, 08 Jan 2017 22:26:17 -0800 (PST)
X-Mailer git-send-email 1.9.1
X-No-Spam-Score Local
X-Scanned-By MIMEDefang 2.78 on 128.59.72.16
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 70
Organization linux.* mail to news gateway
X-Original-Cc jintack@cs.columbia.edu
X-Original-Date Mon, 9 Jan 2017 01:24:32 -0500
X-Original-Message-ID <1483943091-1364-37-git-send-email-jintack@cs.columbia.edu>
X-Original-References <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1554071

Show key headers only | View raw


From: Christoffer Dall <christoffer.dall@linaro.org>

Sometimes when we are invalidating the TLB for a certain S2 MMU
context, this context can also have EL2 context associated with it and
we have to invalidate this too.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Jintack Lim <jintack@cs.columbia.edu>
---
 arch/arm/kvm/arm.c |  6 ++++++
 arch/arm/kvm/mmu.c | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index aa8771d..371b38e7 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -350,6 +350,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 		u64 vttbr = kvm_get_vttbr(&mmu->vmid, mmu);
 
 		kvm_call_hyp(__kvm_tlb_flush_local_vmid, vttbr);
+#ifndef CONFIG_KVM_ARM_NESTED_HYP
+		if (mmu->el2_vmid.vmid) {
+			vttbr = kvm_get_vttbr(&mmu->el2_vmid, mmu);
+			kvm_call_hyp(__kvm_tlb_flush_local_vmid, vttbr);
+		}
+#endif
 		*last_ran = vcpu->vcpu_id;
 	}
 
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 5ca3a04..56358fa 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -60,10 +60,20 @@ static bool memslot_is_logging(struct kvm_memory_slot *memslot)
  */
 void kvm_flush_remote_tlbs(struct kvm *kvm)
 {
+#ifndef CONFIG_KVM_ARM_NESTED_HYP
 	struct kvm_s2_mmu *mmu = &kvm->arch.mmu;
 	u64 vttbr = kvm_get_vttbr(&mmu->vmid, mmu);
 
 	kvm_call_hyp(__kvm_tlb_flush_vmid, vttbr);
+#else
+	/*
+	 * When supporting nested virtualization, we can have multiple VMIDs
+	 * in play for each VCPU in the VM, so it's really not worth it to try
+	 * to quiesce the system and flush all the VMIDs that may be in use,
+	 * instead just nuke the whole thing.
+	 */
+	kvm_call_hyp(__kvm_flush_vm_context);
+#endif
 }
 
 static void kvm_tlb_flush_vmid_ipa(struct kvm_s2_mmu *mmu, phys_addr_t ipa)
@@ -71,6 +81,12 @@ static void kvm_tlb_flush_vmid_ipa(struct kvm_s2_mmu *mmu, phys_addr_t ipa)
 	u64 vttbr = kvm_get_vttbr(&mmu->vmid, mmu);
 
 	kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, vttbr, ipa);
+#ifdef CONFIG_KVM_ARM_NESTED_HYP
+	if (!mmu->el2_vmid.vmid)
+		return; /* only if this mmu has el2 context */
+	vttbr = kvm_get_vttbr(&mmu->el2_vmid, mmu);
+	kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, vttbr, ipa);
+#endif
 }
 
 /*
-- 
1.9.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC 36/55] KVM: arm64: Invalidate virtual EL2 TLB entries when needed Jintack Lim <jintack@cs.columbia.edu> - 2017-01-09 07:40 +0100

csiph-web