From patchwork Fri May 19 00:52:29 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: 13247566 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 E675EC77B7D for ; Fri, 19 May 2023 00:53:17 +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=F0OuMlRDlXPxy6/2h6QRpVWrvSZl2BnQPWvM0/zZWy8=; b=sZssT+rSksKcXLk9NYjXqJ84Qb e0V3H8ya0bK4JMsS65wkK4hmIt3aubS4WF01VCAkNJRchSiqROKpGwa31nwlzGbYP0MLI2GXWCRqE /bo3h5Tf/f5aPwG4dt3cFJhAIMOZb9N2hmDBcuKqbg3BTfPypmGS8WSlHOvbyQnSGAe1q+ioGYPn/ jvN2ETtk+PjzuBNZ0zmYW08g28S0X/8Jw732OHOIYFvXcyiMQq8ijk6Szlvi50rNxWfd6GKC1lmnR k3FbdWJP3bOYFCzdQVufrAda6FJoR3uwJaC4d857W/Ha8NcOwqL7PhQuSxb2ITd8y6yCXRv1tnPq/ SUslIdgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzoMS-00EbRP-0e; Fri, 19 May 2023 00:52:48 +0000 Received: from mail-il1-x14a.google.com ([2607:f8b0:4864:20::14a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzoML-00EbMI-1t for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 00:52:42 +0000 Received: by mail-il1-x14a.google.com with SMTP id e9e14a558f8ab-3383a678225so38179565ab.3 for ; Thu, 18 May 2023 17:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684457559; x=1687049559; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ux8TuKlucx7+2ANrW96xfpSzC0srXjlkGkFfov8Qh8A=; b=nfSM+9p6k+4DETvto+y0GWvj0T9Pn8cMCjrch3oOD/Wt9bRMqYA9UGLB5sbBIFm3bE ErGeQr5UdDquGK62ZHTcCSsHQAXPCCLZVOkbzbU6VHi8oy1BBkXlDTx1rUSKGHyXEkcw CRrFCWWvlBNXVCva7myDBYAhGGf/U7gd9GAipG1KEYCz1LLOkJLWaSE8T5nm1cEdVlR8 5tP2tqRGprEouckvewWTYmoYRDgGUs1jXpJueLe9UdjlIwEd5LWNV3rcOeywTjR8qcTr 7fzQ54BFSSQK1VZGjDitJwXDp65Cwumn+1ym/giNrZSEg0XMB2EwauEgdfRfOpuh9nka y5xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684457559; x=1687049559; 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=Ux8TuKlucx7+2ANrW96xfpSzC0srXjlkGkFfov8Qh8A=; b=Hs2fo8iAVzIuhvykW19mJCg8drJqpnhKobHNDk18UNVvQk2/mAPT3jF2GUqQBv/IqZ 475N3nIVHUAijK/bNTO/LAMNB+azuc8r8Qx423LhgixdKiWFbFXZDouYJ9yS0L39pWMe fYFrMLz49GhBzzXgoDdpuZChSlE6brDbhCvISzDcfNFdxzF9+l4wpZdN44JGSUT8alGv 2oJRNOF6w7Anl8POqaWtxDqGpkdhmidag/E6SKdqhGXlFdRD4q2qFwixqoYr+2jFZrG1 l76hKbJdNsF24JV9k+tHx4Zuq+fPcsnO+6w1nLT0xPj4Uz8eWC+K2n/HcJMt7Y+Cf1oY qtyA== X-Gm-Message-State: AC+VfDw+t3gpgjOVFr8u93MmhmtIDPKkxoLucqQJHfqvHGCSlSXx6NWd lHgO2lZ2WPJtTYn1I5gDC9bNKw5tKTxl X-Google-Smtp-Source: ACHHUZ4mrHRBUPTPC63HrBmyYMpoPQXoQJAtvWnxdjoUIHpL+YcJ3GzassZ0JGPJascAshL3vG7BYy3W5E7i X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a05:6e02:786:b0:335:fee3:37c1 with SMTP id q6-20020a056e02078600b00335fee337c1mr28210ils.3.1684457559778; Thu, 18 May 2023 17:52:39 -0700 (PDT) Date: Fri, 19 May 2023 00:52:29 +0000 In-Reply-To: <20230519005231.3027912-1-rananta@google.com> Mime-Version: 1.0 References: <20230519005231.3027912-1-rananta@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Message-ID: <20230519005231.3027912-5-rananta@google.com> Subject: [PATCH v4 4/6] KVM: arm64: Flush only the memslot after write-protect From: Raghavendra Rao Ananta To: Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Ricardo Koller , Paolo Bonzini , Jing Zhang , Colton Lewis , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230518_175241_624716_A3871E4C X-CRM114-Status: GOOD ( 11.27 ) 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 --- 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 e3673b4c10292..2ea6eb4ea763e 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -996,7 +996,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); } /**