From patchwork Fri Dec 13 18:24:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBCE714DB for ; Fri, 13 Dec 2019 22:32:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD7E120706 for ; Fri, 13 Dec 2019 22:32:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Cg2EH91x"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="f0XkbJuT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD7E120706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V/QWI5sc1pHkP4iko4Bj9/GK35uadpKKBo5ceIDC+I0=; b=Cg2EH91x5eieTj 61SfBNDQkyuMJ6ybdVMYWZZOmZyiQznQ6WDw3bTVib5+xAuAqcOO4t88hgq/ofyHAj7g4gyB7wsjo pU7/E11au/NkFJsR3Kt5ySWQbQM3EYH2BQoCBOw0ooy3/de8XXMdfXU+cQb1b9YeOttAHoZDKOZdR K+ZcIZSLAF1sEx9XaFhWJnEw2gxVaKxJZPmturrH2/Z9QNgzn8hQ0njriNhuZHtZaY42wRgpbzxEk r1uJLSuPRuFjDlv6QekWvrcfOSm80CvcO/JWPm6ltswhHfcldnAygfQW6G7YtzvvlMQpKRmNeRpFw uyWlWG30umGu+zcU6dlA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpfv-0000i7-DE; Fri, 13 Dec 2019 18:28:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpfi-0000Xp-7w for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:28:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6/SlbrtIh8SblQiBH4SRyyo4fw2iDM1TKN8PjYusjXE=; b=f0XkbJuTNW5uY6LUNEE87NNOKK ENevbviXdp4709TE3xP/3Xvju0bhmvuKHKM6Z/SwkPaaeFytuxzTRWZ5o+A09neiSf+ydzN9lOFe8 1gy1rLwm4pFDYKBRBofz1ZNUzRU9cpaHCFOVGCMiZRoqoeTpIP7Iayg4YS/mVvTp9gT3vl0r4pfOR X9y8MoorTtyY2ndjf+La/GtMjBZXvGe9AuOrs479AC80eV5KpR+nslkwzcY6Nd6uW0ibZdFCG2ps/ IqtNLWbyVbWwMG8Arhjzgphlr0LdAaKWqH8RV4Dqt1/KfY7I4raDVNnV7slHXMUHRKyPwkT9ZlXaU mxA5ABFw==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpg8-0006IF-DW for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:28:42 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdE-0001O7-PY; Fri, 13 Dec 2019 19:25:41 +0100 From: Marc Zyngier To: Subject: [PATCH 1/7] KVM: Pass mmu_notifier_range down to kvm_unmap_hva_range() Date: Fri, 13 Dec 2019 18:24:57 +0000 Message-Id: <20191213182503.14460-2-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_182840_508989_E7BDA49C X-CRM114-Status: GOOD ( 16.17 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org kvm_unmap_hva_range() is currently passed both start and end fields from the mmu_notifier_range structure. As this struct now contains important information about the reason of the unmap (the event field), replace the start/end parameters with the range struct, and update all architectures. No functionnal change. Signed-off-by: Marc Zyngier Acked-by: Paolo Bonzini --- arch/arm/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- arch/mips/include/asm/kvm_host.h | 2 +- arch/mips/kvm/mmu.c | 6 ++++-- arch/powerpc/include/asm/kvm_host.h | 2 +- arch/powerpc/kvm/book3s.c | 5 +++-- arch/powerpc/kvm/e500_mmu_host.c | 4 ++-- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu/mmu.c | 5 +++-- arch/x86/kvm/x86.c | 4 ++-- include/linux/kvm_host.h | 2 +- virt/kvm/arm/mmu.c | 8 ++++---- virt/kvm/kvm_main.c | 7 +++---- 13 files changed, 28 insertions(+), 24 deletions(-) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 556cd818eccf..621c71594499 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -276,7 +276,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, #define KVM_ARCH_WANT_MMU_NOTIFIER int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end); + const struct mmu_notifier_range *range); int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index c61260cf63c5..dd850f5e81e3 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -441,7 +441,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, #define KVM_ARCH_WANT_MMU_NOTIFIER int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end); + const struct mmu_notifier_range *range); int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 41204a49cf95..0ed065870f1b 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -935,7 +935,7 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu, #define KVM_ARCH_WANT_MMU_NOTIFIER int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end); + const struct mmu_notifier_range *range); int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 7dad7a293eae..32ef868258b9 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c @@ -518,9 +518,11 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end, return 1; } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) +int kvm_unmap_hva_range(struct kvm *kvm, + const struct mmu_notifier_range *range) { - handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL); + handle_hva_to_gpa(kvm, range->start, range->end, + &kvm_unmap_hva_handler, NULL); kvm_mips_callbacks->flush_shadow_all(kvm); return 0; diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 0a398f2321c2..8cef585e0abe 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -58,7 +58,7 @@ #define KVM_ARCH_WANT_MMU_NOTIFIER extern int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end); + const struct mmu_notifier_range *range); extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); extern int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 58a59ee998e2..a1529a0dd656 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -842,9 +842,10 @@ void kvmppc_core_commit_memory_region(struct kvm *kvm, kvm->arch.kvm_ops->commit_memory_region(kvm, mem, old, new, change); } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) +int kvm_unmap_hva_range(struct kvm *kvm, + const struct mmu_notifier_range *range) { - return kvm->arch.kvm_ops->unmap_hva_range(kvm, start, end); + return kvm->arch.kvm_ops->unmap_hva_range(kvm, range->start, range->end); } int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end) diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index 425d13806645..5a7211901063 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -734,10 +734,10 @@ static int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) return 0; } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) +int kvm_unmap_hva_range(struct kvm *kvm, const struct mmu_notifier_range *range) { /* kvm_unmap_hva flushes everything anyways */ - kvm_unmap_hva(kvm, start); + kvm_unmap_hva(kvm, range->start); return 0; } diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index b79cd6aa4075..c479fa845d72 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1569,7 +1569,8 @@ asmlinkage void kvm_spurious_fault(void); _ASM_EXTABLE(666b, 667b) #define KVM_ARCH_WANT_MMU_NOTIFIER -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end); +int kvm_unmap_hva_range(struct kvm *kvm, + const struct mmu_notifier_range *range); int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6f92b40d798c..86831be07c17 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2040,9 +2040,10 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler); } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) +int kvm_unmap_hva_range(struct kvm *kvm, + const struct mmu_notifier_range *range); { - return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp); + return kvm_handle_hva_range(kvm, range->start, range->end, 0, kvm_unmap_rmapp); } int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cf917139de6b..c1a238f4ee35 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7942,7 +7942,7 @@ static void vcpu_load_eoi_exitmap(struct kvm_vcpu *vcpu) } int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, - unsigned long start, unsigned long end, + const struct mmu_notifier_range *range, bool blockable) { unsigned long apic_address; @@ -7952,7 +7952,7 @@ int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, * Update it when it becomes invalid. */ apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); - if (start <= apic_address && apic_address < end) + if (range->start <= apic_address && apic_address < range->end) kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); return 0; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7ed1e2f8641e..d6e2ae2accc4 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1391,7 +1391,7 @@ static inline long kvm_arch_vcpu_async_ioctl(struct file *filp, #endif /* CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL */ int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, - unsigned long start, unsigned long end, bool blockable); + const struct mmu_notifier_range *range, bool blockable); #ifdef CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu); diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 38b4c910b6c3..078e10c5650e 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -2035,14 +2035,14 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *dat return 0; } -int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end) +int kvm_unmap_hva_range(struct kvm *kvm, const struct mmu_notifier_range *range) { if (!kvm->arch.pgd) return 0; - trace_kvm_unmap_hva_range(start, end); - handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL); + trace_kvm_unmap_hva_range(range->start, range->end); + handle_hva_to_gpa(kvm, range->start, range->end, + &kvm_unmap_hva_handler, NULL); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 00268290dcbd..7c3665ad1035 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -158,7 +158,7 @@ static unsigned long long kvm_createvm_count; static unsigned long long kvm_active_vms; __weak int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, - unsigned long start, unsigned long end, bool blockable) + const struct mmu_notifier_range *range, bool blockable) { return 0; } @@ -415,7 +415,7 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, * count is also read inside the mmu_lock critical section. */ kvm->mmu_notifier_count++; - need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end); + need_tlb_flush = kvm_unmap_hva_range(kvm, range); need_tlb_flush |= kvm->tlbs_dirty; /* we've to flush the tlb before the pages can be freed */ if (need_tlb_flush) @@ -423,8 +423,7 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, spin_unlock(&kvm->mmu_lock); - ret = kvm_arch_mmu_notifier_invalidate_range(kvm, range->start, - range->end, + ret = kvm_arch_mmu_notifier_invalidate_range(kvm, range, mmu_notifier_range_blockable(range)); srcu_read_unlock(&kvm->srcu, idx); From patchwork Fri Dec 13 18:24:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ACBC14B7 for ; Fri, 13 Dec 2019 22:30:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0500A20706 for ; Fri, 13 Dec 2019 22:30:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O3TvsIKD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SyA2Knbc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0500A20706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KGIPIvD9hiR234eVBETFFVFLD4me9KAT2XP9cJhgyms=; b=O3TvsIKD87AOUc 7bCmUqA4KFp8U85WsE0WJDF+/qaCNMAG2rJzFBpWV4Wz7ADsR4GtVrd2UlPATcGi7Rwxm5030zk+0 YXt4nll4u4r/XoKyWcBQmf2JPRUF4JwmoVqb+4QYzSP98fxc7r2XQ8vNaiS+cPVbBj8bD3z0TMCdf jHkQs+iPbFwhvpsMVLB/rPmBGxi6a2lWygcLXRITB06Ei0IR/Ei24BibrUpWzNtrdEVzQW0BajZI8 MpHcrNFBbR3c99kyc85cmS8rDTSLoQoQH7urowRkChcsGd4rQB6DK3PJq/1O7npfMmxKg+gYOTIk4 nXXbhyhdM0FLzg8z9xBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpiE-00042Q-Fy; Fri, 13 Dec 2019 18:30:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifphi-0003TL-IW for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:30:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SERy6jLYtPQtnCZQig3rTtkjMBE/u+4PdMy05T5rTdY=; b=SyA2Knbc5LCZnjsDfF0XKRpBUR qm3FnV2px2gok4jFcbIYCK2Pug7LzJ1re9XXUjLH7hn+QWqeetJ68A8KC/XIMcJZTOt2WhBUV1wHi 4OqijZdolYREvdRrtTHpRLpy9mGrI/yx/fc3+YxB7V8IAtfrIskJFEuAR1LIF3dPcGsQuBVUgEnsL 6N5xAMMRjKNnaXghioH55uKiwLz08gTeZLhY/Z0OeEk8evthYU3L7m1lwIDTwH2QZe07Afl63e7Ci cyZVd6euYDenfDlzjS2klCQqoe+SIYt9agfv1xYeMkm96IH2SnbJticzMHZZ4K+kYXmhoM8ayu2/F nHj6/1hw==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpi8-0006OL-O2 for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:30:47 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdF-0001O7-KH; Fri, 13 Dec 2019 19:25:41 +0100 From: Marc Zyngier To: Subject: [PATCH 2/7] KVM: arm/arm64: Pass flags along Stage-2 unmapping functions Date: Fri, 13 Dec 2019 18:24:58 +0000 Message-Id: <20191213182503.14460-3-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_183044_829084_88F3C0F9 X-CRM114-Status: GOOD ( 12.78 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Pass a set of flags to all Stage-2 unmapping functions. The only value passed for now is zero, and it is not evaluated yet. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 47 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 078e10c5650e..0fed7c19c6d5 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -152,7 +152,8 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc) return p; } -static void clear_stage2_pgd_entry(struct kvm *kvm, pgd_t *pgd, phys_addr_t addr) +static void clear_stage2_pgd_entry(struct kvm *kvm, pgd_t *pgd, phys_addr_t addr, + unsigned long flags) { pud_t *pud_table __maybe_unused = stage2_pud_offset(kvm, pgd, 0UL); stage2_pgd_clear(kvm, pgd); @@ -161,7 +162,8 @@ static void clear_stage2_pgd_entry(struct kvm *kvm, pgd_t *pgd, phys_addr_t addr put_page(virt_to_page(pgd)); } -static void clear_stage2_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr) +static void clear_stage2_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr, + unsigned long flags) { pmd_t *pmd_table __maybe_unused = stage2_pmd_offset(kvm, pud, 0); VM_BUG_ON(stage2_pud_huge(kvm, *pud)); @@ -171,7 +173,8 @@ static void clear_stage2_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr put_page(virt_to_page(pud)); } -static void clear_stage2_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr) +static void clear_stage2_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr, + unsigned long flags) { pte_t *pte_table = pte_offset_kernel(pmd, 0); VM_BUG_ON(pmd_thp_or_huge(*pmd)); @@ -235,7 +238,8 @@ static inline void kvm_pgd_populate(pgd_t *pgdp, pud_t *pudp) * does. */ static void unmap_stage2_ptes(struct kvm *kvm, pmd_t *pmd, - phys_addr_t addr, phys_addr_t end) + phys_addr_t addr, phys_addr_t end, + unsigned long flags) { phys_addr_t start_addr = addr; pte_t *pte, *start_pte; @@ -257,11 +261,12 @@ static void unmap_stage2_ptes(struct kvm *kvm, pmd_t *pmd, } while (pte++, addr += PAGE_SIZE, addr != end); if (stage2_pte_table_empty(kvm, start_pte)) - clear_stage2_pmd_entry(kvm, pmd, start_addr); + clear_stage2_pmd_entry(kvm, pmd, start_addr, flags); } static void unmap_stage2_pmds(struct kvm *kvm, pud_t *pud, - phys_addr_t addr, phys_addr_t end) + phys_addr_t addr, phys_addr_t end, + unsigned long flags) { phys_addr_t next, start_addr = addr; pmd_t *pmd, *start_pmd; @@ -280,17 +285,18 @@ static void unmap_stage2_pmds(struct kvm *kvm, pud_t *pud, put_page(virt_to_page(pmd)); } else { - unmap_stage2_ptes(kvm, pmd, addr, next); + unmap_stage2_ptes(kvm, pmd, addr, next, flags); } } } while (pmd++, addr = next, addr != end); if (stage2_pmd_table_empty(kvm, start_pmd)) - clear_stage2_pud_entry(kvm, pud, start_addr); + clear_stage2_pud_entry(kvm, pud, start_addr, flags); } static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd, - phys_addr_t addr, phys_addr_t end) + phys_addr_t addr, phys_addr_t end, + unsigned long flags) { phys_addr_t next, start_addr = addr; pud_t *pud, *start_pud; @@ -307,13 +313,13 @@ static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd, kvm_flush_dcache_pud(old_pud); put_page(virt_to_page(pud)); } else { - unmap_stage2_pmds(kvm, pud, addr, next); + unmap_stage2_pmds(kvm, pud, addr, next, flags); } } } while (pud++, addr = next, addr != end); if (stage2_pud_table_empty(kvm, start_pud)) - clear_stage2_pgd_entry(kvm, pgd, start_addr); + clear_stage2_pgd_entry(kvm, pgd, start_addr, flags); } /** @@ -327,7 +333,8 @@ static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd, * destroying the VM), otherwise another faulting VCPU may come in and mess * with things behind our backs. */ -static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size) +static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size, + unsigned long flags) { pgd_t *pgd; phys_addr_t addr = start, end = start + size; @@ -347,7 +354,7 @@ static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size) break; next = stage2_pgd_addr_end(kvm, addr, end); if (!stage2_pgd_none(kvm, *pgd)) - unmap_stage2_puds(kvm, pgd, addr, next); + unmap_stage2_puds(kvm, pgd, addr, next, flags); /* * If the range is too large, release the kvm->mmu_lock * to prevent starvation and lockup detector warnings. @@ -950,7 +957,7 @@ static void stage2_unmap_memslot(struct kvm *kvm, if (!(vma->vm_flags & VM_PFNMAP)) { gpa_t gpa = addr + (vm_start - memslot->userspace_addr); - unmap_stage2_range(kvm, gpa, vm_end - vm_start); + unmap_stage2_range(kvm, gpa, vm_end - vm_start, 0); } hva = vm_end; } while (hva < reg_end); @@ -996,7 +1003,7 @@ void kvm_free_stage2_pgd(struct kvm *kvm) spin_lock(&kvm->mmu_lock); if (kvm->arch.pgd) { - unmap_stage2_range(kvm, 0, kvm_phys_size(kvm)); + unmap_stage2_range(kvm, 0, kvm_phys_size(kvm), 0); pgd = READ_ONCE(kvm->arch.pgd); kvm->arch.pgd = NULL; kvm->arch.pgd_phys = 0; @@ -1086,7 +1093,7 @@ static int stage2_set_pmd_huge(struct kvm *kvm, struct kvm_mmu_memory_cache * get handled accordingly. */ if (!pmd_thp_or_huge(old_pmd)) { - unmap_stage2_range(kvm, addr & S2_PMD_MASK, S2_PMD_SIZE); + unmap_stage2_range(kvm, addr & S2_PMD_MASK, S2_PMD_SIZE, 0); goto retry; } /* @@ -1136,7 +1143,7 @@ static int stage2_set_pud_huge(struct kvm *kvm, struct kvm_mmu_memory_cache *cac * the range for this block and retry. */ if (!stage2_pud_huge(kvm, old_pud)) { - unmap_stage2_range(kvm, addr & S2_PUD_MASK, S2_PUD_SIZE); + unmap_stage2_range(kvm, addr & S2_PUD_MASK, S2_PUD_SIZE, 0); goto retry; } @@ -2031,7 +2038,7 @@ static int handle_hva_to_gpa(struct kvm *kvm, static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data) { - unmap_stage2_range(kvm, gpa, size); + unmap_stage2_range(kvm, gpa, size, 0); return 0; } @@ -2344,7 +2351,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, spin_lock(&kvm->mmu_lock); if (ret) - unmap_stage2_range(kvm, mem->guest_phys_addr, mem->memory_size); + unmap_stage2_range(kvm, mem->guest_phys_addr, mem->memory_size, 0); else stage2_flush_memslot(kvm, memslot); spin_unlock(&kvm->mmu_lock); @@ -2380,7 +2387,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, phys_addr_t size = slot->npages << PAGE_SHIFT; spin_lock(&kvm->mmu_lock); - unmap_stage2_range(kvm, gpa, size); + unmap_stage2_range(kvm, gpa, size, 0); spin_unlock(&kvm->mmu_lock); } From patchwork Fri Dec 13 18:24:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5289F14B7 for ; Fri, 13 Dec 2019 22:31:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36AF720706 for ; Fri, 13 Dec 2019 22:31:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="umyAWlWT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="l4QP2crC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36AF720706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aoLpGohiClY2vUTHi3Ufok+UKjaep0KRhYYJ5S0skpU=; b=umyAWlWT+7Pvpt WbMqr4Gy3eBtmie2YpMD+g0V69a+2HjUk8qwQ3rmCoQo4zp1Rbjrzzm2yyRXkWZOLtWiCVoiQjf9x ifiqK6FXqn7ng1zoA92+QMJiPQYvOQHbGHZ11eBKW5xcZAR75Sp7S2TZwfhS8hbUrjlghbrYABhSg aFMugr8KKs96ANoGbs7KsvcK8nsMIIIWnwGKd5ktgdKltGOerXEJb732ntFB1PsolByKANySWQZGF /y3bzLn2M+F1VKaUefEfNzifgqoIJDIcY6HbxoRv5Y3Ywwx6C3JACF8woxao8nrLD/e9J3lGhrGRB IHRKLfzynifOaDpuzSog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpgh-0001SZ-Tv; Fri, 13 Dec 2019 18:29:15 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpfl-0000Zr-0m for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:28:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=b9+9cTCzO5ftesHUHdPxVL5ofeKDIArOvIRxuM9BuSQ=; b=l4QP2crCLrcLoT8EteMRG2pgwX yl2ytP9AcjCJQZsX0mAdvnpBu6eDV8Zz7B6+l28ioafKdlRZ4HG6KcsN2JYn+rgJMN1i0bBXgbEVW r+PVLCxQdUGSI4fAUepGUllRPXIANvBwXylIjM9OpKr08P0vz4xAfDQidWWTypSjH02IFE5uKPg+u vq0epAsCgTGOH3mMwd+LRsd+ZSez2zIcsbF9olB+f7PWAP0fRs6BvRwqQ0zwUApT68orzhVeM4hMT Hvr4avgSyIcLLoxJhjfXqXQ318nJskO3/Pc1haKfLYc9MiK6LOkCDDAkKU0OvNF7yshZxve12XC2P lFpI0bWg==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpgA-0006JP-0T for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:28:45 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdG-0001O7-Df; Fri, 13 Dec 2019 19:25:42 +0100 From: Marc Zyngier To: Subject: [PATCH 3/7] KVM: arm/arm64: Condition cache maintenance on unmap with a flag Date: Fri, 13 Dec 2019 18:24:59 +0000 Message-Id: <20191213182503.14460-4-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_182842_091449_CF54C8C9 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In order to allow the elision of cache maintenance operations on unmap, add a new flag (KVM_UNMAP_ELIDE_CMO) that a caller can use to indicate that CMOs are not required. Nobody is passing this flag yet, hence no functional change. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 0fed7c19c6d5..ebf8c87cc007 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -35,6 +35,9 @@ static unsigned long io_map_base; #define hyp_pgd_order get_order(PTRS_PER_PGD * sizeof(pgd_t)) +/* Flags controlling S2 unmapping */ +#define KVM_UNMAP_ELIDE_CMO (1UL << 0) + #define KVM_S2PTE_FLAG_IS_IOMAP (1UL << 0) #define KVM_S2_FLAG_LOGGING_ACTIVE (1UL << 1) @@ -253,7 +256,8 @@ static void unmap_stage2_ptes(struct kvm *kvm, pmd_t *pmd, kvm_tlb_flush_vmid_ipa(kvm, addr); /* No need to invalidate the cache for device mappings */ - if (!kvm_is_device_pfn(pte_pfn(old_pte))) + if (!kvm_is_device_pfn(pte_pfn(old_pte)) && + !(flags & KVM_UNMAP_ELIDE_CMO)) kvm_flush_dcache_pte(old_pte); put_page(virt_to_page(pte)); @@ -281,7 +285,8 @@ static void unmap_stage2_pmds(struct kvm *kvm, pud_t *pud, pmd_clear(pmd); kvm_tlb_flush_vmid_ipa(kvm, addr); - kvm_flush_dcache_pmd(old_pmd); + if (!(flags & KVM_UNMAP_ELIDE_CMO)) + kvm_flush_dcache_pmd(old_pmd); put_page(virt_to_page(pmd)); } else { @@ -310,7 +315,8 @@ static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd, stage2_pud_clear(kvm, pud); kvm_tlb_flush_vmid_ipa(kvm, addr); - kvm_flush_dcache_pud(old_pud); + if (!(flags & KVM_UNMAP_ELIDE_CMO)) + kvm_flush_dcache_pud(old_pud); put_page(virt_to_page(pud)); } else { unmap_stage2_pmds(kvm, pud, addr, next, flags); From patchwork Fri Dec 13 18:25:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9CC014B7 for ; Fri, 13 Dec 2019 22:30:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A05772077B for ; Fri, 13 Dec 2019 22:30:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HqDRVUgK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QvRh8+gG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A05772077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JQ6JHwk9k+Z2/k2aa/3+TFHHPuCW52VDUSax24JOKH8=; b=HqDRVUgKrLiZ2c zmxzX8siDaHXBo3n6exp0HezDRjMGsWL0vmhh4pSO98uA4LzGb31mnw2Tq14YG3tMgFjDZKFMIchh bP3U0cbwGV6mS60C5uIA979YhPZ9tmIb/hnwyjFegqVO4o9HN+YMT5X9ZrKKys9wdyCfGHa01E9BK Yt9OaBy3d1czIv300euJLU1R8udo7fdlWRjnN+DtqNdnVMxlRvjWnjlRb2iKyznp+LTXHBZvpx1+M C4qhWGOK8GB52Z2Jgt5UAZLTqwhdB1MhHW2tg2+52CsvmFaS+sQu6IvCozhyQLOxG6KKMgdJWl+E8 uR/4g63Djo9fC9aBvMgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifphw-0003d2-LP; Fri, 13 Dec 2019 18:30:32 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifphi-0003TI-6h for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:30:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WAuT2wlA5NSeznqmnfgHqGVJ1sG0Nwiv/gcz3aYIWp0=; b=QvRh8+gGm2G5cqCeU79CSvjIUO UHTyZL1bCYntLJFqhgXx+fnhuTznA92ag7IA/aP6VHOpU3oGHStd2wOZzcKMIRmciCvoQQu4xSgaP Ix5zQRtCnFVTaD9lAm42V3Dj8GZmPKzdN8oyEqLcUtw1HdYztmOxeDN3LMCLjE55m/uDz7MNcENNd SxekflnFzGCtzY63/BWbPh+X0YBFuRDTZhAFHqXtXps511HjMcItsWXcGmdgC3Uf5PD+7JRytxHly INmNbHflh32ZtYB2+zIhLLNweBwXJhSZ+c8/M5gHsX+v8v5GAxUq8p0A3jJvvrTG7HKiI6hKQFyBE JIlF1ZUw==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpi8-0006OK-OD for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:30:46 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdH-0001O7-7w; Fri, 13 Dec 2019 19:25:43 +0100 From: Marc Zyngier To: Subject: [PATCH 4/7] KVM: arm/arm64: Condition TLB maintenance on unmap with a flag Date: Fri, 13 Dec 2019 18:25:00 +0000 Message-Id: <20191213182503.14460-5-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_183044_829884_BA98B888 X-CRM114-Status: GOOD ( 10.99 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In order to allow the elision of TLB maintenance operations on unmap, add a new flag (KVM_UNMAP_ELIDE_TBLI) that a caller can use to indicate that TLB invalidation is not required. Nobody is passing this flag yet, hence no functional change. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index ebf8c87cc007..4399866842dc 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -37,6 +37,7 @@ static unsigned long io_map_base; /* Flags controlling S2 unmapping */ #define KVM_UNMAP_ELIDE_CMO (1UL << 0) +#define KVM_UNMAP_ELIDE_TBLI (1UL << 1) #define KVM_S2PTE_FLAG_IS_IOMAP (1UL << 0) #define KVM_S2_FLAG_LOGGING_ACTIVE (1UL << 1) @@ -160,7 +161,8 @@ static void clear_stage2_pgd_entry(struct kvm *kvm, pgd_t *pgd, phys_addr_t addr { pud_t *pud_table __maybe_unused = stage2_pud_offset(kvm, pgd, 0UL); stage2_pgd_clear(kvm, pgd); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); stage2_pud_free(kvm, pud_table); put_page(virt_to_page(pgd)); } @@ -171,7 +173,8 @@ static void clear_stage2_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr pmd_t *pmd_table __maybe_unused = stage2_pmd_offset(kvm, pud, 0); VM_BUG_ON(stage2_pud_huge(kvm, *pud)); stage2_pud_clear(kvm, pud); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); stage2_pmd_free(kvm, pmd_table); put_page(virt_to_page(pud)); } @@ -182,7 +185,8 @@ static void clear_stage2_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr pte_t *pte_table = pte_offset_kernel(pmd, 0); VM_BUG_ON(pmd_thp_or_huge(*pmd)); pmd_clear(pmd); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); free_page((unsigned long)pte_table); put_page(virt_to_page(pmd)); } @@ -253,7 +257,8 @@ static void unmap_stage2_ptes(struct kvm *kvm, pmd_t *pmd, pte_t old_pte = *pte; kvm_set_pte(pte, __pte(0)); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); /* No need to invalidate the cache for device mappings */ if (!kvm_is_device_pfn(pte_pfn(old_pte)) && @@ -283,7 +288,8 @@ static void unmap_stage2_pmds(struct kvm *kvm, pud_t *pud, pmd_t old_pmd = *pmd; pmd_clear(pmd); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); if (!(flags & KVM_UNMAP_ELIDE_CMO)) kvm_flush_dcache_pmd(old_pmd); @@ -314,7 +320,8 @@ static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd, pud_t old_pud = *pud; stage2_pud_clear(kvm, pud); - kvm_tlb_flush_vmid_ipa(kvm, addr); + if (!(flags & KVM_UNMAP_ELIDE_TBLI)) + kvm_tlb_flush_vmid_ipa(kvm, addr); if (!(flags & KVM_UNMAP_ELIDE_CMO)) kvm_flush_dcache_pud(old_pud); put_page(virt_to_page(pud)); From patchwork Fri Dec 13 18:25:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E7B614DB for ; Fri, 13 Dec 2019 22:30:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 826D520706 for ; Fri, 13 Dec 2019 22:30:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Q4JLm9Ts"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="uwFbY0f5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 826D520706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+hJrBiwse03R/WPb3LqFDa58IQaRsOiv0R5r69fRFlk=; b=Q4JLm9TsJbgILB 4v2lJ0a7ZAUEDTNMlcuQUO8U03gHsTc2BrGSCyCYZ20RNT/Fk2aP1u8ZAbxX3I4R7r6bnwnv2ZAkA CEdqlRBWTJysevKfgnM8KuMLPXPeX2Z+dH1+C6YI1WkBQHHypHLbfVRLj/UjNsljhhZqTK0y+czOE MMrGr20RjSirxQ/FoMMJb4CNkpeBGtDrBFFVOv8fjz0j/rl9DgZ/KFlc1fcMsVamSqh7CrDTKyGrA sBnTFJtgae+ByzWsjG9Jd3+RWVsmCMP3yirwtLMJZgq2x8ldGhQB13VP78xmltuQ/3vs7rvjWBj2f RBENyegz/GR+V3b1P7rg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpgD-0000yJ-46; Fri, 13 Dec 2019 18:28:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpfj-0000Yu-J5 for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:28:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iY4r/Cpja2MTp9nLPxqT5+JkzLwYwSxRg9yYMap58ig=; b=uwFbY0f5MPFL4Jl4U1+MWJ3yEv ROvu/7t6VcUhoZDBYzB8wHhEPzik6lDzDLSfJoshcmRJ3cXDhEX6Q/uY3ljQaChPfvxyW6CMjTvAn 7NCrHfNlw8jHgV+qlbAdUDzkUlambZpDcCTGB1M0EGnPaqDzhsYfww6LSH1zk1bzHBEB1Ox4nuOs4 GBqD3n1Qgvunx57NUlzIUFiQkT0YATThNxQFQ00HXwAazNSbxQjJyyadm3cV4Po8TnPfQtwO/Ia42 43rsoZhtwB1XZttwmyComb2dhQKSGo3634M/n0nolCDM2PRuLf2Jsj6Jc888XAIMdwZiXJQf9fl9N LeIXxozg==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpg8-0006IE-DY for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:28:44 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdI-0001O7-2m; Fri, 13 Dec 2019 19:25:44 +0100 From: Marc Zyngier To: Subject: [PATCH 5/7] KVM: arm/arm64: Elide both CMOs and TBLIs on freeing the whole Stage-2 Date: Fri, 13 Dec 2019 18:25:01 +0000 Message-Id: <20191213182503.14460-6-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_182840_534021_AB46F185 X-CRM114-Status: GOOD ( 12.03 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When freeing the whole of a VM's Stage-2 page tables, there is little point in doing cache maintenance on each and every page (the guest won't be running anymore, let alone having its MMU off). As for TLBs, there is no point in invalidating individual pages, as we can replace the whole thing with a VMALL operation, which invalidates all the TLBs for this VM in one go. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 4399866842dc..d7c710491d26 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1016,10 +1016,13 @@ void kvm_free_stage2_pgd(struct kvm *kvm) spin_lock(&kvm->mmu_lock); if (kvm->arch.pgd) { - unmap_stage2_range(kvm, 0, kvm_phys_size(kvm), 0); + unmap_stage2_range(kvm, 0, kvm_phys_size(kvm), + KVM_UNMAP_ELIDE_CMO | KVM_UNMAP_ELIDE_TBLI); pgd = READ_ONCE(kvm->arch.pgd); kvm->arch.pgd = NULL; kvm->arch.pgd_phys = 0; + + kvm_flush_remote_tlbs(kvm); } spin_unlock(&kvm->mmu_lock); From patchwork Fri Dec 13 18:25:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C5F8109A for ; Fri, 13 Dec 2019 22:24:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 018CF214D8 for ; Fri, 13 Dec 2019 22:24:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hwuLbtEr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ks9rttKM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 018CF214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1Wb/Jtv7mFB9+B/2mBRoMs9uY1dxiS0gmQticNh2ILU=; b=hwuLbtErIxVHkN 4cz8iKE2V0aKfRJh5fAVeYS/ofV4iZm8kM+Ei5hI9WsfqJcdpQy8ywL+2pi+kAiCyhqUV/TRvH7kT DpXlW1Oe/FQzNVGBQvY/0v+Q0kZnW9T3IzkoeOoIvJzpN07TY3RjLX6ay/Iuk6C3J/4b5DJw7GYQH Ag9ZufZsoyVHbiMeqNuVBfidHCL0FTf2mQ/JKcqQroX+7rW5D6p6rymfpgK+13lECbgHnGx98TLkW HIPekpvOizD/DlwAosmMYcrUQpwzslWbmd31gbf8e6PEkCpjTBjKGstyHu5e+zqGaj3M5wOykPx98 Yh6qtYhuwhNtG9x39HnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifphj-0003Th-Vy; Fri, 13 Dec 2019 18:30:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifphh-0003TA-UD for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:30:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Jeqj7CRDsTOztbpEvu8sFavkXPJenfkY3QRGn8nl6y4=; b=ks9rttKM7d0I/hEJn8+5bh0BIu rLbUHQBaDu2HjnK/u8tsZLQA+qWDUreGPI6CbX6fkXv/02xvh+wa3otVAwSOxP/swgRQDkPB9VKCJ 0JLHRzsz/LWzCKA5tLSojvZv9fHrQMBghffNTMSkz2z04/F/asNDoaiLEfwzKOiliLSaGyBCXQC0S aLaGKxXvw2q3LiDdP1apOHWYhEsdYOkNmDLJ2hNTi5DJpjZksueYjpYzv5llzhn/uE4M78iF9E3pj nTVekUrBlrnCtIaSlQ9syKEJTOq0p72adIPyVcWsxfy3WOAM+3mspjszky/vxjVfkvZqvI0xbVGgE HHKI2l7w==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpi8-0006OJ-O2 for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:30:46 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdI-0001O7-Qa; Fri, 13 Dec 2019 19:25:44 +0100 From: Marc Zyngier To: Subject: [PATCH 6/7] KVM: arm/arm64: Elide CMOs when retrying a block mapping Date: Fri, 13 Dec 2019 18:25:02 +0000 Message-Id: <20191213182503.14460-7-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_183044_802594_7421E3B8 X-CRM114-Status: GOOD ( 11.30 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In the rare cases where we're converting a table mapping in a block mapping, there is no point in cleaning memory to the PoC, as we're about to remap the exact same pages again, only as a block mapping. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index d7c710491d26..c55022dbac89 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1109,7 +1109,8 @@ static int stage2_set_pmd_huge(struct kvm *kvm, struct kvm_mmu_memory_cache * get handled accordingly. */ if (!pmd_thp_or_huge(old_pmd)) { - unmap_stage2_range(kvm, addr & S2_PMD_MASK, S2_PMD_SIZE, 0); + unmap_stage2_range(kvm, addr & S2_PMD_MASK, S2_PMD_SIZE, + KVM_UNMAP_ELIDE_CMO); goto retry; } /* @@ -1159,7 +1160,8 @@ static int stage2_set_pud_huge(struct kvm *kvm, struct kvm_mmu_memory_cache *cac * the range for this block and retry. */ if (!stage2_pud_huge(kvm, old_pud)) { - unmap_stage2_range(kvm, addr & S2_PUD_MASK, S2_PUD_SIZE, 0); + unmap_stage2_range(kvm, addr & S2_PUD_MASK, S2_PUD_SIZE, + KVM_UNMAP_ELIDE_CMO); goto retry; } From patchwork Fri Dec 13 18:25:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11291689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A6E1109A for ; Fri, 13 Dec 2019 22:25:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2FBC2077B for ; Fri, 13 Dec 2019 22:25:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kn1zdRyr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="tALDUqsO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2FBC2077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8Yq+UBtIAbONQC7ttUGBhuipJJB9vPUKzME1yhgeNLE=; b=kn1zdRyrC+E0v5 6cCXsBO/6mvC1Z2CQE18EDNaXqWPCMwGRria8hmNZENhh28dWX5e1SFidP0wiKPw7ywmsqfee/KXg X6jZHdCrFSNftViYUYtG2Unwl5JAnZDZqD+GXg/4zVc1TkQEG5ByldapFJW/nKUwIv9vcfMgXE6cn WsYT2xeHOZbj+6BbiTnbqMfO5rBunN98Ps6/IzorKHCTe/7bvqj5JxdGnu9f80osz6i0rcJPCNLO5 Z+dTX3SkDgiuYkbKxzQbehRjhjQwOP8vzIlis/Gu+V2zBcYTris8naELmUEwPAQ+QCZs4bqMtFnOB tUSrYpE5YUlcBzo08OqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpgW-0001Fv-9U; Fri, 13 Dec 2019 18:29:04 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpfl-0000Zs-0H for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Dec 2019 18:28:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=m7GXogmvRuTwfuJicGQ2Zyj36+IZresYnE8Bz7r3uTA=; b=tALDUqsOH7Rrz+g5LRlluJ+GvQ YySD44ivVu0UuBebOswwo3J5UYyQKmUMdHY9DoSlv4+lGsz/iSeFpbThOuMF+get36tP9FnaXUCP7 f868eXmWg26ebvQbnFTED/aJpl7je1IygjgrUmS1VjknGx2J9uHdCJVQ18THK4ssSrRgvDis9ajty jESGPLJu6TLZolddYGT/9Jq2CniP7p6NS+MDlmCOuRyJ57ayFVCNch39LmJJZArFN5v1M6VnKSU9B 4uRjsckw4hmbWM+t08IxCh3ybkDkeVDoautmuq6HZ8w0kZMIRvSos85kLRmwhZ6Zyh+Oox1SyGC0N OvHdw8EA==; Received: from inca-roads.misterjones.org ([213.251.177.50]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifpg8-0006IG-DX for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2019 18:28:45 +0000 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdJ-0001O7-JV; Fri, 13 Dec 2019 19:25:45 +0100 From: Marc Zyngier To: Subject: [PATCH 7/7] KVM: arm/arm64: Elide CMOs when unmapping a range Date: Fri, 13 Dec 2019 18:25:03 +0000 Message-Id: <20191213182503.14460-8-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191213_182840_542536_D0EC4360 X-CRM114-Status: GOOD ( 11.83 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-ppc@vger.kernel.org, Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , James Hogan , Joerg Roedel , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , linux-mips@vger.kernel.org, Sean Christopherson , Paul Mackerras , James Morse , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Julien Thierry , Jim Mattson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If userspace issues a munmap() on a set of pages, there is no expectation that the pages are cleaned to the PoC. So let's not do more work than strictly necessary, and set the magic flag that avoids CMOs in this case. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index c55022dbac89..6749be33d822 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -2056,7 +2056,13 @@ static int handle_hva_to_gpa(struct kvm *kvm, static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data) { - unmap_stage2_range(kvm, gpa, size, 0); + struct mmu_notifier_range *range = data; + unsigned long flags = 0; + + if (range->event == MMU_NOTIFY_UNMAP) + flags = KVM_UNMAP_ELIDE_CMO; + + unmap_stage2_range(kvm, gpa, size, flags); return 0; } @@ -2067,7 +2073,7 @@ int kvm_unmap_hva_range(struct kvm *kvm, const struct mmu_notifier_range *range) trace_kvm_unmap_hva_range(range->start, range->end); handle_hva_to_gpa(kvm, range->start, range->end, - &kvm_unmap_hva_handler, NULL); + &kvm_unmap_hva_handler, (void *)range); return 0; }