From patchwork Tue Aug 8 23:13:28 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: 13347223 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 363DCC04A94 for ; Tue, 8 Aug 2023 23:15:08 +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=GZLeJwI8ftuzohIYgj3/FG6H94++zEDQmON4j2dTYoM=; b=zmDAIfYmVtr9LhxajFVmC7Hqw0 qedWXN1x+6GwC53OAVOCnvgZIc47azsjDemq4xvrzagLmy/d8qyQqDhocV5c+H3OIKpp50e/I1jm6 A2e6ryaM8a/5cbx2CVz7TLhdh6NPe6r0D2pFMkMM9ijIZKlZ9sM5xmW2nN+9jn2xxNj+ey03des4W TA8Yy+PBzCemDvmC3n7jKdFk/MbiBmtsmunxFvIrdr81aFsAW7rKMdXVbBsT5aa35bcBICthHS5uf tzxDdniSiTS8IvUBxnjK1dRvYynifEFRanLNnKQ66CDkE+ojZOE98+G4J/VuN8I6MFSOakaKP02Fd Sj9e4j9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTVuW-003eC2-1C; Tue, 08 Aug 2023 23:14:44 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTVtm-003dOn-23 for linux-arm-kernel@bombadil.infradead.org; Tue, 08 Aug 2023 23:13:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DdFQXc9QjMOj4pMVD7mddwddfJwM0E/FVNI1wIxPkhk=; b=PB04PD6BNu5kWIrfUJqeFRGsl+ qAf4RcQGZvcJOaYQ77ZA9d2fF4HH5qo+SnKye3ThbStSdBisnFFJzR5jE2fPr7QyAffpdtJA0in12 7g/bTlS+c/mM90rPk7rn99oCtsPdvgYK8yerN5Cux5K63oUZDt7QtxZ82T79AhVbsI6x2T1lN+3AA RRvRbTpjmXbQiRmbmXdVjEsae3lSGuP1rhW67nzBOjK65FAlq+l7078N1cxIwhnEjp61jKmuOsuZ4 Mvo9iu9RQf8O43hCRuKoOJ9L5+TG1gATfZbz6itNBLGofJjn7GyeyhwCucpUcXxavTZGX/43gllNr aUrDOZxA==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTVte-0057mc-27 for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2023 23:13:55 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5868992ddd4so74146527b3.0 for ; Tue, 08 Aug 2023 16:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691536427; x=1692141227; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DdFQXc9QjMOj4pMVD7mddwddfJwM0E/FVNI1wIxPkhk=; b=GGya4r79Fypy7MpijHUr6lRrKbN2KwgnqmepmFHyoEm6JOw0RI4BnR26D52ypMST14 qMrhS6uMP+X/P+04iY+CFJYP/yfNgW/oQiRxmX4L8KUMTb9SHE2leuL53nL+lEy8UfWN H6Gme/iQnweVgHOIz203N5vFFXqVCtC2ViqgYkIHf1XrsCct05bcsmV1KcRfn0mKeymj ESMAAwstxX9ujJZpbixig2EzSNSrlwlq3HWLXEyApK1JC0D3VIjPeG/oYEmpo68kYHS8 /95jhR/N+ADW8Wt9ABI0Q1X51ZWQY4WgE96INI5uDk8QgBXuW/N36eA7E8a9TtSBew8R 8+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691536427; x=1692141227; 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=DdFQXc9QjMOj4pMVD7mddwddfJwM0E/FVNI1wIxPkhk=; b=aRldcXpTjkwIhFFw/n75wgb+9bwWfThp8l5EThsaG7/3M1tY4hSumC8zR3heEZLx6g oS/m/m7obE0ASest0ZOWGNho5QusBTVMGdYDDxSk4BrZN+PX799IOjXxDa+XXzxju7n4 4JuVzYgrlUDS5e98mWJ8KDBiy/kg2L8j4pYK0BUt8RnOcqDjRyUnGtBGccW1CN3hJKiv cAm+xSwsGqlBt+Hjyq6+ZvMDL4Dr36tVOV5Gvh6Jl2sVUJmhvgMI8Uco9YiOQNYr0fRC 3gnXgs9jG0rNhztkITZcvzgn8y2bTsBIVYdwr9Ampjh5P7j44N9+DSfzzTPuhKJL6oAS R2Pg== X-Gm-Message-State: AOJu0Yyk402nYHLXV24Wp5bf1UwFDEGck1QJp58kSINBex/BcTjbN3MK tUG2+UgBO8hU0dQaH0jNRh999k36KO4M X-Google-Smtp-Source: AGHT+IHtVpA0B67cdmlCLqrTRdBRqOLFjvFy7tyIxoiuO5XwsAt9fDPTNialdcxuGgrd+oEKUp81U6/MqqgQ X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a25:ac09:0:b0:d0c:1f08:5fef with SMTP id w9-20020a25ac09000000b00d0c1f085fefmr19514ybi.12.1691536427532; Tue, 08 Aug 2023 16:13:47 -0700 (PDT) Date: Tue, 8 Aug 2023 23:13:28 +0000 In-Reply-To: <20230808231330.3855936-1-rananta@google.com> Mime-Version: 1.0 References: <20230808231330.3855936-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230808231330.3855936-13-rananta@google.com> Subject: [PATCH v8 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-20230809_001352_812179_1DAC7EA4 X-CRM114-Status: GOOD ( 11.73 ) 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 294078ce16349..95ca2b86aa2cd 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); } /**