From patchwork Mon Jan 9 06:24:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9504079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA57060710 for ; Mon, 9 Jan 2017 06:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C612C280DE for ; Mon, 9 Jan 2017 06:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA7492815E; Mon, 9 Jan 2017 06:42:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F667280DE for ; Mon, 9 Jan 2017 06:42:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQTfD-0005T6-80; Mon, 09 Jan 2017 06:42:39 +0000 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTPj-0002SM-3U for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 06:26:43 +0000 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096PXvw017320 for ; Mon, 9 Jan 2017 01:26:18 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 83A097E for ; Mon, 9 Jan 2017 01:26:18 -0500 (EST) Received: from sendprodmail01.cc.columbia.edu (sendprodmail01.cc.columbia.edu [128.59.72.13]) by hazelnut (Postfix) with ESMTP id 4866483 for ; Mon, 9 Jan 2017 01:26:18 -0500 (EST) Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by sendprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QI2t041416 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:18 -0500 Received: by mail-qt0-f199.google.com with SMTP id k15so94308608qtg.5 for ; Sun, 08 Jan 2017 22:26:18 -0800 (PST) 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=bVGKZgoShQESyp/nHovNtaZipJvCZ9qb9XHytopJBJzWj91/e7UPL9/B2YUynVCnzN xu5dC33Pe5s6oXw+M25b5xDI0jGkHX9/4gKvk2wZOGt7++PJOZ5C7xSARazzTtauL3jS 22nsDUI9UhE7gl84auB6VXX7aH9Ml+CMe39HkpTWSlD1dlorq/eUb4wcGFwOGJQXCA9D cyu//ZLmu9Van59z4wRBgkQ7sNcoYL52+eTc4VUpubkzmlSRsOfRJOuW5h7NQVkVagMH RxSGGjOI08iNim8+m1F/E1TVOxYBNWlysaHNgOrjIAdpr5LUs6uKjm4QFWh/5n2fg2no OBVQ== X-Gm-Message-State: AIkVDXLD0SauYUUd+JuuANG6l0qLEW/ZRzdOwEramjmmwKd/rVRanAX1CReCdXvfyW9WZokz/10Z+kZwmRCARSLVdyDdkRLijmTgl31HSs72q7Yi7tKl1Lg+TXsnnr1o/pM3TXtJ9BkWiI29TciVZnKQC+wObIbq1hyZ4A== X-Received: by 10.55.169.216 with SMTP id s207mr22511347qke.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) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id h3sm8623257qtc.6.2017.01.08.22.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:17 -0800 (PST) From: Jintack Lim 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 Subject: [RFC 36/55] KVM: arm64: Invalidate virtual EL2 TLB entries when needed Date: Mon, 9 Jan 2017 01:24:32 -0500 Message-Id: <1483943091-1364-37-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170108_222639_450301_AF6A4A62 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jintack@cs.columbia.edu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall 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 Signed-off-by: Jintack Lim --- 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 } /*