From patchwork Fri Jul 3 02:35:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11640687 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 8CDCF14E3 for ; Fri, 3 Jul 2020 02:38:42 +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 46055207CD for ; Fri, 3 Jul 2020 02:38:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hvajyhTZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46055207CD 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=BCZ242Jd9RipAnhd7/cVrXnJ9NUQY62fysOj2eAT9Gg=; b=hvajyhTZzwHMnndpsUInsX1U9v 8QAtxWthzcC2lHzw/yGyNupsmYnAGhQ6HfPRyuCVruDt0jN8tN+cO+v0PjkI2SVSajyqOC4ntM5Gj 2HYSznKC0EXGttN1ek4OmdcuGBx4tSWivmw0a1LOv4xfjZ9KKF/A1Sua/+FKq8lih9CBGa5l872Dt rZDo6GsjjKQxs7OhdXivmmC6yA1rH9M8Zfo+E6fspsB/EXtSqq1HITnKzPOtr3xDydsfKGxbednt6 zqADcC8ylOpYgxwkWpl7o/PDrdFuXCV2C42V8mHUV/TvwFWWfAbWewEB5554p0GCEcwQOD/My8BIS HTM4x6dw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrBYm-0000Sh-4J; Fri, 03 Jul 2020 02:36:16 +0000 Received: from mga18.intel.com ([134.134.136.126]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrBYe-0000PL-9t for linux-arm-kernel@lists.infradead.org; Fri, 03 Jul 2020 02:36:09 +0000 IronPort-SDR: LO5HjDNiiLEhE9SEINBCE8oFrsfk6v0o8Ak+GUjwf4wzNHzKNworJGrf5HXQhq5DBkXalH4UVC CBPnqadCXDTw== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="134534679" X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="134534679" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 19:36:04 -0700 IronPort-SDR: T2DxoJ+6pDgQH7e5SIxXyTgQ9QkegMOBSCNjFHu7YUc0H8gIQqRN5KQHpGrfYlDlqtc8ESDZ15 OICltGe0pc2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="278295716" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by orsmga003.jf.intel.com with ESMTP; 02 Jul 2020 19:36:04 -0700 From: Sean Christopherson To: Marc Zyngier , Paolo Bonzini , Arnd Bergmann Subject: [PATCH v3 00/21] KVM: Cleanup and unify kvm_mmu_memory_cache usage Date: Thu, 2 Jul 2020 19:35:24 -0700 Message-Id: <20200703023545.8771-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200702_223608_505909_1FD4B21B X-CRM114-Status: GOOD ( 14.01 ) 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 [134.134.136.126 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 The only interesting delta from v2 is that patch 18 is updated to handle a conflict with arm64's p4d rework. Resolution was straightforward (famous last words). 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. v3: - Rebased to kvm/queue, commit a037ff353ba6 ("Merge ... into HEAD") - Collect more review tags. [Ben] 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] 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 | 56 +++---------- 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, 176 insertions(+), 211 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