From patchwork Fri Aug 11 04:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra Rao Ananta X-Patchwork-Id: 13350116 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 55D71C0015E for ; Fri, 11 Aug 2023 04:53:19 +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: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vXKLwSCMaKSiIhEUmtFZDzVPWd6JW81UKCBVEt23gBI=; b=DEe3hnt6jE4NCejTvNk4OVT9l+ NVloQt43a6YDR/39ROgQPOPM/gPTUi3ijdsQnnj9eCSoJ0pOjirWMNoRd009TYHbq3CrAwLyLKqZy RFCGWgKkX4gUsmVl7l5M41dP07Ro0B2dNHZwg3tB8CcQGw2unOpWuPQYmmG9OJKXVYc9+6L75e7+X lmuexeSrIhA9nTsWRruo7Us+rw8a5LCIFyPPwECWMwyvH0CO6RYwC0rsdC8hcGoisWgBdWyAqhuRl 4WaKICeUdxSkEINZv7OygODeHrJfW4e8K9np1Rp71DE9ALWeXdoXTkvq356HSLbVhoR54LSDYSKuw hPMxsfDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qUK8n-009QT9-11; Fri, 11 Aug 2023 04:52:49 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qUK7p-009PcS-1y for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2023 04:51:54 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5734d919156so19831007b3.3 for ; Thu, 10 Aug 2023 21:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691729508; x=1692334308; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=P6qPiqYiGdEy+ALMWmUClgOJtf7MJwHf5G0engyYFuk=; b=qrcaMEcSpq+ULmZt9JgV/iXS5+x9ZwEslbJLOWWZHpe9tEaJ28kJ0dsZTFh+wHaZVY z/+PWbhe4kPyyucCymXKpbVkBUvDdebb4moSiMcKue6hrkGuTyTFlQ2SS1ZDAmF+7o2K JIqhRUzm+nxJK7sCky9lN7UwOaQ9GwOZduGzIbm/TwSEScjePA4FFoYCus4bBKN6ke8D wf+zv3/75Th+zNlJ44hzGeBSVubCWPJjE5lDfkpmjoMYIWdYXie5RHK61lA9sT3xtR4j o2HtqwDGpSxcDAOl6CF9D9EeEbTPBni26ZJIeebSWG7wMNG4nNsXFqjiD04Lfm8rlpNh SVOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691729508; x=1692334308; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P6qPiqYiGdEy+ALMWmUClgOJtf7MJwHf5G0engyYFuk=; b=DYvB4flRkWnlwZk29o46G1+AEVnQBap40qav2ofMc7YL/65wPMl1JI6a85rHq3cfCo Uzj6geMFWr+mBDTWf3FOBeGxIOElfi0JS4eOO8jGZ2qA+mVVrYwrPtTadY9qIVHGF9i3 5QwP6+Ubjg6yuJJd8kw3aku0LEMzWFRfcx0NXANHs5G5iF9iYOW47Ay4n6EGmUGCQ/dA cpP0aAzKzjU8GMlpRHJTLK/WJ1381GNbLFhVuToEPLbPnvvsGSlNq6XZHINcRZC8vuQT TI7PVdDPiqYiZiJNFyt9MmfFdT8Wl1PmG7jA8rF+Na36uS5ufuDHiENG5E5tBcCA4yT2 2t/g== X-Gm-Message-State: AOJu0YyS4mSb+bgQwZVtC4ebLuf9rNWG0faxAPumMId+9ZQlNjDd1y4D xETQjG6Spl63JfxaJtpRDXPmW1ZEr0sB X-Google-Smtp-Source: AGHT+IGXV3TrUe7VdEmoyRMybbrBwXMmeig9Hy139aV3xPrm/bppO8Uhrj80L5wM2TEVNSyoFL3mzf/IgjNd X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a81:b71b:0:b0:589:bfc5:d80b with SMTP id v27-20020a81b71b000000b00589bfc5d80bmr14055ywh.2.1691729508012; Thu, 10 Aug 2023 21:51:48 -0700 (PDT) Date: Fri, 11 Aug 2023 04:51:25 +0000 In-Reply-To: <20230811045127.3308641-1-rananta@google.com> Mime-Version: 1.0 References: <20230811045127.3308641-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230811045127.3308641-13-rananta@google.com> Subject: [PATCH v9 12/14] KVM: arm64: Flush only the memslot after write-protect From: Raghavendra Rao Ananta To: Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Reiji Watanabe , Colton Lewis , Raghavendra Rao Anata , David Matlack , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Gavin Shan , Shaoqin Huang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230810_215149_755897_F1C5A5FF X-CRM114-Status: GOOD ( 11.03 ) 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 After write-protecting the region, currently KVM invalidates the entire TLB entries using kvm_flush_remote_tlbs(). Instead, scope the invalidation only to the targeted memslot. If supported, the architecture would use the range-based TLBI instructions to flush the memslot or else fallback to flushing all of the TLBs. Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Gavin Shan Reviewed-by: Shaoqin Huang --- arch/arm64/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 702f8715f9fe7..6f44896936b47 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1083,7 +1083,7 @@ static void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot) write_lock(&kvm->mmu_lock); stage2_wp_range(&kvm->arch.mmu, start, end); write_unlock(&kvm->mmu_lock); - kvm_flush_remote_tlbs(kvm); + kvm_flush_remote_tlbs_memslot(kvm, memslot); } /**