Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp807437rdg; Thu, 10 Aug 2023 23:28:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG985ey9wSRJBg9k1YXYfl6IsnoNFi/Df7W//NKby67neTDibJ9n36ca8LE4M+gO/8K7uCr X-Received: by 2002:a05:6808:140f:b0:3a7:5b1d:9470 with SMTP id w15-20020a056808140f00b003a75b1d9470mr1608298oiv.53.1691735298731; Thu, 10 Aug 2023 23:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691735298; cv=none; d=google.com; s=arc-20160816; b=VSzAL3h4LKbHKX9YgygsTxw2oQ2qpLf/ySeWjTS++M1WhPU6sMhYYnK07f/UXD3Y5P lfQJNgG8OM7LhyYVRJaiVGwRStA8atxFZ5htb/6zewGH6i7ceQlGuoLtobshZ6wO5SQZ T4mTcroJPR25LDDQRFKXmi4SJYhXXzU73LyE3sOc1q8UP3MzykB31vBD7SDDYlZNDRob spoyrMcdcF4BOCqeWLKuG8F39v4uPkotRAZSqV/HUXToPkPuFSKH9Q1D1YaAiCfM2NQm RD0AIxyR/sAhmMCaXTqannr241zKTFs9vptLtDLdamGigTrInbmeG2Ndbco/QQQGz4+E szbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=P6qPiqYiGdEy+ALMWmUClgOJtf7MJwHf5G0engyYFuk=; fh=yw5tXiXa6fgZNcqMuRzw9eeT6vziy3WnhZBwRz1vFio=; b=nm4Waq+OUrHXsPDn1VIoJE6+cXPZcZrDtRlJcnvwTbfw2DTS+vK2icbEjyvsrKTGZh GqWvHwi/FHYfpPNLIp3uf1/s4UYUtZNSLOPFaN/odmDQWLZIUQToYe1jp7vYVXmzkPiQ VMShbiikadJax4SukNxkPBi3zwed3nxqAosTvyzKerzrRuGjlzhD/HJzUznkYjnn5AwL Myw3KgKHmF7MHIj7ys0O3V4AeZABSVTcRhw/NEKjTmtt0Ph6lPWY9gBTtg6NohQRmDET rDQ83eEWfA8gz/b0NSkR9jW69VyM1MKtcUcQkxtYE1lDS5YP7FCoQr35vp/SlqdfOcjf iKFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qrcaMEcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 81-20020a630154000000b005639fa704c3si2867639pgb.764.2023.08.10.23.28.06; Thu, 10 Aug 2023 23:28:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qrcaMEcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233496AbjHKEwk (ORCPT + 99 others); Fri, 11 Aug 2023 00:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbjHKEwF (ORCPT ); Fri, 11 Aug 2023 00:52:05 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CE630CF for ; Thu, 10 Aug 2023 21:51:48 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58667d06607so19956647b3.1 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=VftutOV/Ae9HCxlKxtbq8kMmZOlD3meMlBG+j09F1BEsBiX595Q9+uAnB8omod4dZd f9G0bS66E7R4yTtLgpAq4vVXBAsUWQGYob89UMd67/fw6VH3HNZ5pIfWqJPNW0aO5uuj hlO481brJ53DCy3ga0KutuFbi81USiW/m91uSsGo530GrDJRUf4aE4hikfiHuam5TRBc ihJmSQNpP01n3YiPb6tw5YOkmAOMJ5sF+LSF1DsKSsUqkWt5Pwioadd9L8Ymn2jQHdqO M/lhOFM+PgUXyzTzabHPUBs1P9NHI262MzayZuxU9dYvU2bL3DH/c8UcBbn36hrUYYxy ydUg== X-Gm-Message-State: AOJu0YyThNy3128jFtX0rZlQBc4K4B5jSIhQGMKdycn5JAANVmSIOyHP q7ai+xPkH1p6talInJ2VR9kiFfzW9H8+ 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); } /** -- 2.41.0.640.ga95def55d0-goog