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: 9503961 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 309BD60757 for ; Mon, 9 Jan 2017 06:33:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F16C2808F for ; Mon, 9 Jan 2017 06:33:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11C8F2811C; Mon, 9 Jan 2017 06:33:48 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55AEC2808F for ; Mon, 9 Jan 2017 06:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033918AbdAIGdV (ORCPT ); Mon, 9 Jan 2017 01:33:21 -0500 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]:52269 "EHLO outprodmail02.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939753AbdAIG0X (ORCPT ); Mon, 9 Jan 2017 01:26:23 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q9nm006312 for ; Mon, 9 Jan 2017 01:26:18 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id B545280 for ; Mon, 9 Jan 2017 01:26:18 -0500 (EST) Received: from sendprodmail04.cc.columbia.edu (sendprodmail04.cc.columbia.edu [128.59.72.16]) by hazelnut (Postfix) with ESMTP id 9440E80 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 sendprodmail04.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QIPs005459 (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 f4so58598876qte.1 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=aAfrM0xtMlGjxUo6N4riypuPOTykkhlDSHY4obO7xfkKKR21vkqCVLAf01HsNcMWeN r26zSfrJ5MFkCNpgLi3ISk+ctgbucCHwp3tQhJKIsW8bAyyXbIoVjjUPaWK3/Hp0OveN JIoNjOYaQ4u5JA8TW0+bdrvvXquAg3KEq2glBE1ON3Ua8oB+KpjEJ0gjP3S85DUkS7Pt LgAuBB9VVrQUq+YUuCYZeahxEST+mN/a++8PVOsBZ/iiFxwRXiGsatrvZGbvbqRNC/ZS ovV+LLAiw1S8mDjVDzyLnijv1YXK4VKOTOXt11SEYeZ7K9ootpIij1L5/bjcX1ePCCOi Ltdg== X-Gm-Message-State: AIkVDXKz2V6/aRHKxCuKoDK3PGrnEDml8UbGYDDToLoIX6f2ctrfGdZfQSAwda9C2dKJYSc/0Q5Fkz5mZ2oLBdBFUOoldNXqz+FE1hiwAB7QKERSh8DLO8Tmw3DVxTXRgH6jg18l6G4qU4g= X-Received: by 10.55.169.216 with SMTP id s207mr22511358qke.211.1483943177842; 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 Cc: jintack@cs.columbia.edu 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.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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 } /*