From patchwork Fri Jul 25 00:56:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Smarduch X-Patchwork-Id: 4620721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D47EE9F39B for ; Fri, 25 Jul 2014 00:58:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9DF7201E4 for ; Fri, 25 Jul 2014 00:58:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C9B6201DD for ; Fri, 25 Jul 2014 00:58:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XAToP-0001kh-5B; Fri, 25 Jul 2014 00:56:41 +0000 Received: from mailout1.w2.samsung.com ([211.189.100.11] helo=usmailout1.samsung.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XAToL-0001gi-Cq for linux-arm-kernel@lists.infradead.org; Fri, 25 Jul 2014 00:56:38 +0000 Received: from uscpsbgex1.samsung.com (u122.gpu85.samsung.co.kr [203.254.195.122]) by mailout1.w2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9800525T9QUY40@mailout1.w2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 24 Jul 2014 20:56:14 -0400 (EDT) X-AuditID: cbfec37a-b7f206d000005572-52-53d1ab2ecfab Received: from usmmp2.samsung.com ( [203.254.195.78]) by uscpsbgex1.samsung.com (USCPEXMTA) with SMTP id 54.CE.21874.E2BA1D35; Thu, 24 Jul 2014 20:56:14 -0400 (EDT) Received: from sisasmtp.sisa.samsung.com ([105.144.21.116]) by usmmp2.samsung.com (Oracle Communications Messaging Server 7u4-27.01(7.0.4.27.0) 64bit (built Aug 30 2012)) with ESMTP id <0N9800HM9T9PZJ80@usmmp2.samsung.com>; Thu, 24 Jul 2014 20:56:14 -0400 (EDT) Received: from mjsmard-530U3C-530U4C-532U3C.sisa.samsung.com (105.144.129.72) by SISAEX02SJ.sisa.samsung.com (105.144.21.116) with Microsoft SMTP Server (TLS) id 14.1.421.2; Thu, 24 Jul 2014 17:56:12 -0700 From: Mario Smarduch To: kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, christoffer.dall@linaro.org, pbonzini@redhat.com, gleb@kernel.org, agraf@suse.de, xiantao.zhang@intel.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com Subject: [PATCH v9 1/4] arm: add ARMv7 HYP API to flush VM TLBs, change generic TLB flush to support arch flush Date: Thu, 24 Jul 2014 17:56:05 -0700 Message-id: <1406249768-25315-2-git-send-email-m.smarduch@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1406249768-25315-1-git-send-email-m.smarduch@samsung.com> References: <1406249768-25315-1-git-send-email-m.smarduch@samsung.com> MIME-version: 1.0 X-Originating-IP: [105.144.129.72] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9hP1291ReDDVbf4rE4ceUfo8X0FdtZ LF68BrLmNzcyWnz5eZ3R4v7V74wWc6YWWnw8dZzdYtPja6wWf+/8Y7PYv+0fq8WkN9uYLD7M WMlo0fV9B7PFwv83GR34PdbMW8PocfDRITaPxXteMnlsWtXJ5nHn2h42jweHNrN4nN+0htlj 85J6j/f7rrJ59G1Zxeix+XS1x+dNcgE8UVw2Kak5mWWpRfp2CVwZU84vZyvoUarY17udvYFx qUwXIyeHhICJxOymoywQtpjEhXvr2boYuTiEBJYxSvTs/ADl9DJJ7Lm0gh3Cucgo8XvOMTaQ FjYBXYn99zaCJUQEbjJKXOh6B+YwC1xjlJi65C8jSJWwQKHE2q4XrF2MHBwsAqoSkw8xg4R5 Bdwk5k6+AhaWEFCQmDPJBiTMKeAuseL/QzaQsBBQSevcTIhqQYkfk++xgISZBSQknn9WAgkL Ac3bdvM5I8QDShJX585kmcAoNAtJxyyEjgWMTKsYxUqLkwuKk9JTKwz1ihNzi0vz0vWS83M3 MUKisWoH452vNocYBTgYlXh4O+ovBguxJpYVV+YeYpTgYFYS4XWbCxTiTUmsrEotyo8vKs1J LT7EyMTBKdXAKOfzrcXLvFvqWL5d0dfvfCWVD6O52T6fuOX4XL5MY9KGx2Yz32z7n7jPxa9B qvSKturljzHuP75tvtgpvSruwrnmNAb5WxzWGlsW7/3KdEVFJFChwecyf7efglC9RuflbWt5 Fgi06R/hzXmxQMWwszDmivCJjY9NDE4VrZ89n//Aoazrl548UmIpzkg01GIuKk4EAEQAKJuk AgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140724_175637_531632_E07887BA X-CRM114-Status: GOOD ( 10.85 ) X-Spam-Score: -5.0 (-----) Cc: kvm@vger.kernel.org, steve.capper@arm.com, xiaoguangrong@linux.vnet.ibm.com, jays.lee@samsung.com, sungjinn.chung@samsung.com, linux-arm-kernel@lists.infradead.org, Mario Smarduch X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch adds HYP interface for global VM TLB invalidation without address parameter. Generic VM TLB flush calls ARMv7 arch defined TLB flush function. Signed-off-by: Mario Smarduch --- arch/arm/include/asm/kvm_asm.h | 1 + arch/arm/include/asm/kvm_host.h | 1 + arch/arm/kvm/Kconfig | 1 + arch/arm/kvm/interrupts.S | 12 ++++++++++++ arch/arm/kvm/mmu.c | 17 +++++++++++++++++ virt/kvm/Kconfig | 3 +++ virt/kvm/kvm_main.c | 4 ++++ 7 files changed, 39 insertions(+) diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h index 53b3c4a..21bc519 100644 --- a/arch/arm/include/asm/kvm_asm.h +++ b/arch/arm/include/asm/kvm_asm.h @@ -78,6 +78,7 @@ extern char __kvm_hyp_code_end[]; extern void __kvm_flush_vm_context(void); extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); +extern void __kvm_tlb_flush_vmid(struct kvm *kvm); extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); #endif diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 193ceaf..042206f 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -230,5 +230,6 @@ int kvm_perf_teardown(void); u64 kvm_arm_timer_get_reg(struct kvm_vcpu *, u64 regid); int kvm_arm_timer_set_reg(struct kvm_vcpu *, u64 regid, u64 value); +void kvm_arch_flush_remote_tlbs(struct kvm *); #endif /* __ARM_KVM_HOST_H__ */ diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index 466bd29..44d3b6f 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select ANON_INODES select HAVE_KVM_CPU_RELAX_INTERCEPT select KVM_MMIO + select HAVE_KVM_ARCH_TLB_FLUSH_ALL select KVM_ARM_HOST depends on ARM_VIRT_EXT && ARM_LPAE ---help--- diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S index 0d68d40..1258d46 100644 --- a/arch/arm/kvm/interrupts.S +++ b/arch/arm/kvm/interrupts.S @@ -66,6 +66,18 @@ ENTRY(__kvm_tlb_flush_vmid_ipa) bx lr ENDPROC(__kvm_tlb_flush_vmid_ipa) +/** + * void __kvm_tlb_flush_vmid(struct kvm *kvm) - Flush per-VMID TLBs + * + * Reuses __kvm_tlb_flush_vmid_ipa() for ARMv7, without passing address + * parameter + */ + +ENTRY(__kvm_tlb_flush_vmid) + b __kvm_tlb_flush_vmid_ipa +ENDPROC(__kvm_tlb_flush_vmid) + + /******************************************************************** * Flush TLBs and instruction caches of all CPUs inside the inner-shareable * domain, for all VMIDs diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 2ac9588..35254c6 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -56,6 +56,23 @@ static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa); } +#ifdef CONFIG_ARM +/** + * kvm_arch_flush_remote_tlbs() - flush all VM TLB entries + * @kvm: pointer to kvm structure. + * + * Interface to HYP function to flush all VM TLB entries without address + * parameter. In HYP mode reuses __kvm_tlb_flush_vmid_ipa() function used by + * kvm_tlb_flush_vmid_ipa(). + */ +void kvm_arch_flush_remote_tlbs(struct kvm *kvm) +{ + if (kvm) + kvm_call_hyp(__kvm_tlb_flush_vmid, kvm); +} + +#endif + static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, int min, int max) { diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index 13f2d19..f1efaa5 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -34,3 +34,6 @@ config HAVE_KVM_CPU_RELAX_INTERCEPT config KVM_VFIO bool + +config HAVE_KVM_ARCH_TLB_FLUSH_ALL + bool diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fa70c6e..258f3d9 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -186,12 +186,16 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) void kvm_flush_remote_tlbs(struct kvm *kvm) { +#ifdef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL + kvm_arch_flush_remote_tlbs(kvm); +#else long dirty_count = kvm->tlbs_dirty; smp_mb(); if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) ++kvm->stat.remote_tlb_flush; cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); +#endif } EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs);