From patchwork Thu Jan 26 18:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13117684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EC482C61DA3 for ; Thu, 26 Jan 2023 19:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date: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=a4cBFfyRfrcERN3cxlb9oTT1wH9KozEpL90vu6UdHW8=; b=EFv 6uQMusTnrU5INVNUcPCZ0TW3dR28SzcgTh7RwaZw67CO/2CZbDSAKbCrxqG38XzBzl3Qez7SoRqBU MuZ5Q9RYevMysW2LahgoqsLhNDTCjOyp+8EKApigthfqXQngqMWAvXt57FQZr8mHRCD/3Z9xo25pG mCavZQSDuwxghwgbfKi5hPR8gc4jfh21d/WdfZ9bmfUeQarjb7a4BEI+hUEXJprsxnva337/TH39j vaMjSW9D00JpT+ucWyf4uUxOhOYA1e5KwrzRfUSzopoGSgSZde+ikC1mMVafznC15McbTEbRyt14+ ngrU4BcVbqdQHGSusQn3ZsuKG/v5vDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pL8E7-00CNXY-6s; Thu, 26 Jan 2023 19:48:04 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pL7B1-00CAVp-0x for linux-arm-kernel@lists.infradead.org; Thu, 26 Jan 2023 18:40:51 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-4c11ae6ab25so29505897b3.8 for ; Thu, 26 Jan 2023 10:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Ie07OawPNI+tJK8/hFSWiI7XFoX01SxG+4YwTEZViLQ=; b=D1zilxz/MrFwcNOLMT1LAITkqOyJHoIg1OvmdTgNrSXt2+8bKehEyhZdJ83wWYuURL Y0TlzIojPMrAY/CU2EgKBxKy8Nx8rmheh1GkuQRsxJHJN2NAKEqwzghdwiLNFihCDWAp xAqgswB2O5bVSkkHVOV/HJM6lOVfZSqt9ReqdJP9r1WG6enSrRiCbP2umw7Iz+8nswUx YO7YdtyP+HTlvOTCLKBJfy3cdltcIpQzviK1n84DUaBgb2qM5tqpM8I9zoSX/91t7Yqw jiFcfGub83bVeaJzvdpdizULguQj8McM0NB0eAlP96DiLVznXsRzwRYQJ3xMSNQhmSRM +wUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Ie07OawPNI+tJK8/hFSWiI7XFoX01SxG+4YwTEZViLQ=; b=youfOj5tTfujwiwBG/iRhxDK5gdN2rcI+QUdOkMwB0rMXoU/5slNl2PJVxAmI7dI73 MZz5aFLgE10tpClz/q+zjNJaK8bALFpRbMt7ZcLl8Jw2o1zGaN0/j/zncr4VKFd1Wrv+ wy+wntjfaEY2omEOnp5q/roAPT+YRM0NZGpgTVcAp4uumxbwwnU9uQatwY0PBML/XRsr V/KK0AoCts8UhmGTxY/Su42rvymXFFQfh7enQYVI+Yh6jxpmMu4mSs9sAEMwKowiuMBN S3Kw2SPJu54mUhxgZbZviC4AAKxW18LV1kvciDq3UAL1+9yu/q1171AmHHWeSOpPd7we VIqQ== X-Gm-Message-State: AFqh2kpI+wLEOBdyB3jnnTVFVS+Nh4y/zNJEG8aZ8+MzNTNuRGll+USH zmH8Ot7Ks67Y5tXXhaxzDY9uOIPzvXr2RQ== X-Google-Smtp-Source: AMrXdXvYhsT+DA2KA1c/9P+wVBnv1OdnS37rNGakXvNF40eWFc5OqICy7ZZvOWGpLhibmaIEJb5soSQRpzz3bA== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:4f81:0:b0:502:92ae:5123 with SMTP id d123-20020a814f81000000b0050292ae5123mr2486176ywb.99.1674758440211; Thu, 26 Jan 2023 10:40:40 -0800 (PST) Date: Thu, 26 Jan 2023 10:40:18 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230126184025.2294823-1-dmatlack@google.com> Subject: [PATCH v2 0/7] KVM: Add a common API for range-based TLB invalidation From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, David Matlack , Raghavendra Rao Ananta X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230126_104047_094503_0F445527 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series introduces a common API for performing range-based TLB invalidation. This is then used to supplant kvm_arch_flush_remote_tlbs_memslot() and pave the way for two other patch series: 1. https://lore.kernel.org/kvm/20230109215347.3119271-1-rananta@google.com/ Adds ARM support for range-based TLB invalidation and needs a mechanism to invoke it from common code. This series provides such a mechanism via kvm_arch_flush_remote_tlbs_range(). 2. https://lore.kernel.org/kvm/20221208193857.4090582-1-dmatlack@google.com/ Refactors the TDP MMU into common code, which requires an API for range-based TLB invaliation. This series is based on patches 29-33 from (2.), but I made some further cleanups after looking at it a second time. Tested on x86_64 and ARM64 using KVM selftests. Cc: Raghavendra Rao Ananta v2: - Rebased on top of kvm-x86/next to resolve conflicts in changes slated for 6.3 [Sean] - Drop CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL from virt/kvm/Kconfig [Oliver] v1: https://lore.kernel.org/kvm/20230119173559.2517103-1-dmatlack@google.com/ David Matlack (7): KVM: Rename kvm_arch_flush_remote_tlb() to kvm_arch_flush_remote_tlbs() KVM: arm64: Use kvm_arch_flush_remote_tlbs() KVM: x86/mmu: Collapse kvm_flush_remote_tlbs_with_{range,address}() together KVM: x86/mmu: Rename kvm_flush_remote_tlbs_with_address() KVM: x86/MMU: Use gfn_t in kvm_flush_remote_tlbs_range() KVM: Allow range-based TLB invalidation from common code KVM: Move kvm_arch_flush_remote_tlbs_memslot() to common code arch/arm64/include/asm/kvm_host.h | 3 ++ arch/arm64/kvm/Kconfig | 1 - arch/arm64/kvm/arm.c | 6 ---- arch/arm64/kvm/mmu.c | 6 ++-- arch/mips/include/asm/kvm_host.h | 4 +-- arch/mips/kvm/mips.c | 12 ++------ arch/riscv/kvm/mmu.c | 6 ---- arch/x86/include/asm/kvm_host.h | 7 +++-- arch/x86/kvm/mmu/mmu.c | 46 +++++++------------------------ arch/x86/kvm/mmu/mmu_internal.h | 7 ++--- arch/x86/kvm/x86.c | 2 +- include/linux/kvm_host.h | 20 ++++++++++---- virt/kvm/Kconfig | 3 -- virt/kvm/kvm_main.c | 35 +++++++++++++++++++---- 14 files changed, 73 insertions(+), 85 deletions(-) base-commit: 503f0315c97739d3f8e645c500d81757dfbf76be prerequisite-patch-id: 42a76ce7cec240776c21f674e99e893a3a6bee58 prerequisite-patch-id: c5ef6bbef252706b7e65b76dc9bd92cf320828f5 prerequisite-patch-id: c6e662cb6c369a47a027c25d3ccc7138a19b17f5 prerequisite-patch-id: 15a58bec64bf1537e6c9e2f52179fac652d441f7 prerequisite-patch-id: d5b6fea4724f4f2c3408b95d7ce5acdd4b528b10