From patchwork Mon Jun 22 20:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11619015 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 4019B138C for ; Mon, 22 Jun 2020 20:12:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 19D472075A for ; Mon, 22 Jun 2020 20:12:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0psiWyT6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19D472075A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=LDbJV8hhK9uVCcivZAsvqVaAGCy+L9oTzmAnma8KERg=; b=0psiWyT6J9xLaGHZhQgHIKQL3a cWQ53rMV63DM6z0PBgrAoMK3zFcrQ5uVzpt1hqwRfVvqr5s7w05LrVignKEkfA7f7828Uda6mLw1P /BVj7LxEfjEe3xaMkNC43wE6sFMKRZ0QHuBDk8c/zpukgN6Xj8T3+akGwaCSaVyRkXmIkvpHy8Wpt rx6VIzvmK0tEL+DIks9W+p/NXcU9z1wFyqiP4Ulp2L7mEywtl2Ryn/898/hFNv2ejDCBqoUFxJELX +KUoJTB7WOQ2hiyz8BZzWIvyvNivLig6+MB9C771mi/ov8yMz52yAWQqqlKnnuld17vloqr+f/Kb6 itRHAEgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnSlf-0006He-Nr; Mon, 22 Jun 2020 20:10:11 +0000 Received: from mga12.intel.com ([192.55.52.136]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnSlc-0006Gp-TE for linux-arm-kernel@lists.infradead.org; Mon, 22 Jun 2020 20:10:10 +0000 IronPort-SDR: aNOKciTc24pyHv4qMJ4FrFzg2v9S55hZr70XpL6jvZeJELBd5I07Sh/RFxDDYD99S9p2Xqombd g8mqAnphQ2pA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="123527695" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="123527695" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 13:09:05 -0700 IronPort-SDR: ACiGxnvdRH5yHzKRcBqEkHkrUW0Xmd5fP+wZakk5PUawdwmWwHSjFB8CI8ofv1H3JKPtVSPmv8 o5YF/XigfYJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="318877033" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2020 13:09:05 -0700 From: Sean Christopherson To: Marc Zyngier , Paolo Bonzini , Arnd Bergmann Subject: [PATCH v2 00/21] KVM: Cleanup and unify kvm_mmu_memory_cache usage Date: Mon, 22 Jun 2020 13:08:01 -0700 Message-Id: <20200622200822.4426-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.136 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 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: linux-arch@vger.kernel.org, Junaid Shahid , Christoffer Dall , Wanpeng Li , kvm@vger.kernel.org, Suzuki K Poulose , Joerg Roedel , Peter Shier , linux-mips@vger.kernel.org, Sean Christopherson , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Ben Gardon , Vitaly Kuznetsov , Peter Feiner , 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 Note, patch 18 will conflict with the p4d rework in 5.8. I originally stated I would send v2 only after that got pulled into Paolo's tree, but I got my timing wrong, i.e. I was thinking that would have already happened. I'll send v3 if necessary. I wanted to get v2 out there now that I actually compile tested other architectures. Marc, I interpreted your "nothing caught fire" as Tested-by for the arm64 patches, let me know if that's not what you intended. This series resurrects Christoffer Dall's series[1] to provide a common MMU memory cache implementation that can be shared by x86, arm64 and MIPS. It also picks up a suggested change from Ben Gardon[2] to clear shadow page tables during initial allocation so as to avoid clearing entire pages while holding mmu_lock. The front half of the patches do house cleaning on x86's memory cache implementation in preparation for moving it to common code, along with a fair bit of cleanup on the usage. The middle chunk moves the patches to common KVM, and the last two chunks convert arm64 and MIPS to the common implementation. Fully tested on x86 only. Compile tested patches 14-21 on arm64, MIPS, s390 and PowerPC. v2: - Rebase to kvm-5.8-2, commit 49b3deaad345 ("Merge tag ..."). - Use an asm-generic kvm_types.h for s390 and PowerPC instead of an empty arch-specific file. [Marc] - Explicit document "GFP_PGTABLE_USER == GFP_KERNEL_ACCOUNT | GFP_ZERO" in the arm64 conversion patch. [Marc] - Collect review tags. [Ben] [1] https://lkml.kernel.org/r/20191105110357.8607-1-christoffer.dall@arm [2] https://lkml.kernel.org/r/20190926231824.149014-4-bgardon@google.com Sean Christopherson (21): KVM: x86/mmu: Track the associated kmem_cache in the MMU caches KVM: x86/mmu: Consolidate "page" variant of memory cache helpers KVM: x86/mmu: Use consistent "mc" name for kvm_mmu_memory_cache locals KVM: x86/mmu: Remove superfluous gotos from mmu_topup_memory_caches() KVM: x86/mmu: Try to avoid crashing KVM if a MMU memory cache is empty KVM: x86/mmu: Move fast_page_fault() call above mmu_topup_memory_caches() KVM: x86/mmu: Topup memory caches after walking GVA->GPA KVM: x86/mmu: Clean up the gorilla math in mmu_topup_memory_caches() KVM: x86/mmu: Separate the memory caches for shadow pages and gfn arrays KVM: x86/mmu: Make __GFP_ZERO a property of the memory cache KVM: x86/mmu: Zero allocate shadow pages (outside of mmu_lock) KVM: x86/mmu: Skip filling the gfn cache for guaranteed direct MMU topups KVM: x86/mmu: Prepend "kvm_" to memory cache helpers that will be global KVM: Move x86's version of struct kvm_mmu_memory_cache to common code KVM: Move x86's MMU memory cache helpers to common KVM code KVM: arm64: Drop @max param from mmu_topup_memory_cache() KVM: arm64: Use common code's approach for __GFP_ZERO with memory caches KVM: arm64: Use common KVM implementation of MMU memory caches KVM: MIPS: Drop @max param from mmu_topup_memory_cache() KVM: MIPS: Account pages used for GPA page tables KVM: MIPS: Use common KVM implementation of MMU memory caches arch/arm64/include/asm/kvm_host.h | 11 --- arch/arm64/include/asm/kvm_types.h | 8 ++ arch/arm64/kvm/arm.c | 2 + arch/arm64/kvm/mmu.c | 54 +++--------- arch/mips/include/asm/kvm_host.h | 11 --- arch/mips/include/asm/kvm_types.h | 7 ++ arch/mips/kvm/mmu.c | 44 ++-------- arch/powerpc/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/x86/include/asm/kvm_host.h | 14 +--- arch/x86/include/asm/kvm_types.h | 7 ++ arch/x86/kvm/mmu/mmu.c | 129 +++++++++-------------------- arch/x86/kvm/mmu/paging_tmpl.h | 10 +-- include/asm-generic/kvm_types.h | 5 ++ include/linux/kvm_host.h | 7 ++ include/linux/kvm_types.h | 19 +++++ virt/kvm/kvm_main.c | 55 ++++++++++++ 17 files changed, 175 insertions(+), 210 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_types.h create mode 100644 arch/mips/include/asm/kvm_types.h create mode 100644 arch/x86/include/asm/kvm_types.h create mode 100644 include/asm-generic/kvm_types.h