Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1788774rwd; Thu, 18 May 2023 18:01:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6I3GZ1soXzmwKvCWwLvYVSONy2I/hTZM+BMcDtvfMU7yfSURirwfXnQHt17KdXc8IvVyYC X-Received: by 2002:a17:90a:7f91:b0:253:772b:a8ae with SMTP id m17-20020a17090a7f9100b00253772ba8aemr303751pjl.48.1684458064625; Thu, 18 May 2023 18:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684458064; cv=none; d=google.com; s=arc-20160816; b=bxK1rU3qDRJ2qk6DL0C+vyStRsZrPhCT/J7IBKdeH6FsT+vl7bEl6ItEG6nXFe8POe 5n3ChUgx9f8Uy5JtVTGNQ+eN4oq7wpsGEWmE6FSXPyRUlT5aqBoB1Mp0W1yKFNYAg7S0 q/7MbhCNvW5xrm6y7crM5E2GQ38gPrF1AqIyB9owNF4OTvTxA9xXAvdu1AtmPGOgeh1B L7fM/tpPLwDTGo0UAXcEjSem2fHPDPjv50i97044QO5V7kxc2/xRrDrrbEcSIXdpt3Rh 92KqQpyfO2H/28vD0D92vqeFSxB/2kfydnK07W5AjcFejdpQhl2XGou3jQ6+9Q1gsTgh ux1A== 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=eI3+o1vQveSU3bkuomrpolxp+t8dV7nu1enlALoGo84=; b=jXUKAXPZe49genPFHxLVpw+Dc9K1X7KoVhn7suU22GKzUIuz0MXb3NwXW9Sysf3wW9 CvBDPB/8sY3jcyXmqQiu6jdWRPGTROTw/sg0l5H6PVZ7Wr6xdumPLVSomVD1ergAet3Z /eOah2IAAykXxVvW0eBaU3avLKLZXS00VajkJm6GAFxrgqoSGrNcux5PgrjbtoamZbsd CThQelKvvlteZq4ChAcB4JEVH4dAt1mL+q24NhCvArssPZ1kJRlA6q8Ivx8vxRa5UTta SQgBpSijEby0qi6k+SdkFZtIh2BMHn1iiJeIr+DE1tAH5Zd1W/mikLg6GYJ7Ns/bBbDD 5d/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a993HPTO; 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 mp12-20020a17090b190c00b0024df18639fasi628352pjb.154.2023.05.18.18.00.49; Thu, 18 May 2023 18:01:04 -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=a993HPTO; 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 S230251AbjESAwq (ORCPT + 99 others); Thu, 18 May 2023 20:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjESAwk (ORCPT ); Thu, 18 May 2023 20:52:40 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B932E4A for ; Thu, 18 May 2023 17:52:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba8337a5861so684238276.0 for ; Thu, 18 May 2023 17:52:39 -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=eI3+o1vQveSU3bkuomrpolxp+t8dV7nu1enlALoGo84=; b=a993HPTO+g13j6obSzomXT8KISL/8mFSfYyDK/WG+ODvYVrzRo67FTVKRPNz4OtgR8 wbVvJI1UMWLNfzwvZ6Pc+IJB58PSbJkfDiM7qjnlf7+dulbrrXb1G2a556mStetHAB6X JhHn1bNc4gU6kdv2mB7svIf9qBYfY7+waIVlwadN4raN8L/2tiFCRgVB+TPiKZLB7r/M 5U85nJno9Reys1JZsaXHeJhYDz/wgCGwk4E2MFHocZEBRMlHKx4oBrY4LsUH0GALzyEz 5Yv9sRc5Gbx9MggBYHqKoqG75yo3yYxMGrKKLnLWjFd6xpGajIigzjT6XfGU/JHAF/8O qoJA== 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=eI3+o1vQveSU3bkuomrpolxp+t8dV7nu1enlALoGo84=; b=VpcjdfudMR0Z6i+GqI3XiYlDUKp20X+Ff69OMP3wHLhWVui0QKc8T5QGvUtPXp1g/P tIaUNriKQ8IC83ya409MswykHE34JpTsav9Tc1Ju92VcVa5Inw+0Hn7dEkCz0VBNmeXM ER+tN4aLvSzAGMMUuum2uN6ztLbEqR2C0kVW9ofJg7uM6tryPDcc9/JEXloEWSXW2M/n bCifWWYVavYHo8xOe4cY4fK0tghWf5WTweRoE02ts9PfBiAagxVgTM9YG8VBpXrkARd7 mToka0Q4KG44oxlxwkMGsT4HO3GUR+DYX16QVLVe9q1+sFvKoSwFzLs96TWRvn4XKwPr pEnQ== X-Gm-Message-State: AC+VfDyjjcPVNZvwpOOSLlZIzPws1+jMOiI4CMw1uoo6JDDSJ7/r7O/q wHNNvyTyK8SdCbKJvXPmGbQSlrt6mKPh X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a05:6902:1343:b0:ba8:4d1c:dd04 with SMTP id g3-20020a056902134300b00ba84d1cdd04mr94689ybu.1.1684457558794; Thu, 18 May 2023 17:52:38 -0700 (PDT) Date: Fri, 19 May 2023 00:52:28 +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-4-rananta@google.com> Subject: [PATCH v4 3/6] KVM: arm64: Implement kvm_arch_flush_remote_tlbs_range() 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 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 Implement kvm_arch_flush_remote_tlbs_range() for arm64 to invalidate the given range in the TLB. Signed-off-by: Raghavendra Rao Ananta --- arch/arm64/include/asm/kvm_host.h | 3 +++ arch/arm64/kvm/hyp/nvhe/tlb.c | 4 +--- arch/arm64/kvm/mmu.c | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 81ab41b84f436..343fb530eea9c 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1081,6 +1081,9 @@ struct kvm *kvm_arch_alloc_vm(void); #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS int kvm_arch_flush_remote_tlbs(struct kvm *kvm); +#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS_RANGE +int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn, u64 pages); + static inline bool kvm_vm_is_protected(struct kvm *kvm) { return false; diff --git a/arch/arm64/kvm/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c index d4ea549c4b5c4..d2c7c1bc6d441 100644 --- a/arch/arm64/kvm/hyp/nvhe/tlb.c +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c @@ -150,10 +150,8 @@ void __kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu, return; } - dsb(ishst); - /* Switch to requested VMID */ - __tlb_switch_to_guest(mmu, &cxt); + __tlb_switch_to_guest(mmu, &cxt, false); __flush_tlb_range_op(ipas2e1is, start, pages, stride, 0, 0, false); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index d0a0d3dca9316..e3673b4c10292 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -92,6 +92,17 @@ int kvm_arch_flush_remote_tlbs(struct kvm *kvm) return 0; } +int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn, u64 pages) +{ + phys_addr_t start, end; + + start = start_gfn << PAGE_SHIFT; + end = (start_gfn + pages) << PAGE_SHIFT; + + kvm_call_hyp(__kvm_tlb_flush_vmid_range, &kvm->arch.mmu, start, end); + return 0; +} + static bool kvm_is_device_pfn(unsigned long pfn) { return !pfn_is_map_memory(pfn); -- 2.40.1.698.g37aff9b760-goog