Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5201962rwl; Tue, 21 Mar 2023 15:14:12 -0700 (PDT) X-Google-Smtp-Source: AK7set/2dXAnQ1x8HdrGt0a8XuZCwoGRzaMMNBlSAiwovubWbzkonM4y7ySnVAGl81/zFOMyI7KW X-Received: by 2002:a17:906:51d5:b0:929:b101:937d with SMTP id v21-20020a17090651d500b00929b101937dmr3804063ejk.1.1679436852391; Tue, 21 Mar 2023 15:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679436852; cv=none; d=google.com; s=arc-20160816; b=if1FN5+3+x8wOXawI7eCZAgL7PA28w7h8lN/Kmo8irfomIxeXUF5ug9vILddmTqsMu H7aJj0YwEq0zfxdjf8qegMNa9/HtALqHUpbshqNnMdvyAkwFX37HCsITobTVQ2sjX5Rf 7V+J6nOJ+gJri9LdZ7+9x9UGD841C/A2sUT5wXGLNGQ8/d9v3utXOULXP5nfsoMq5i5b rByxTWkPn4eeLQS4o3Uxd/L4mC4re3Lh5JkeecjpsRKzIX17OkK5T7c+P25qs8UhdJQa cH9S8AsknuNOu+CWiROglDEdatqCdDEp4QdyDjOGBCwEgu+RqvPGAORXjiw6PX01pRtH YkcA== 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:reply-to:dkim-signature; bh=TXYP/la1qhNyvVoZkTScqrgtgxD2yAawazbtnCeBxio=; b=vRj1/WTQXmvqKY+uA+azyG1zHrp3o0nr1lawet3AfVK9T7uLX3uioAYwfa6sQ5x9EV ZDijF9IrEwSqfgspFIwmV3kDP9rkK0Pp7KGXt84F//ti8T9IT/VO+g6ZcM9LKsixCZH0 A+i7ymCmnDqc+cO42/HiLg4ExGMHwWlVRKGzLOjYmHkb2JcAPu5gsPNysYgnX/eGJ2aX WD6LGhhDES8Cild44UwR5IMCw04mHSF4ABfoxuRXKwOi7opQOzHcwpdR931gz5qB2AXI s/i1Ln9eRxsFnTelJuQQb58Gn9ERP95yt/+HskBMXoc50ecezsXzNP8Vxp32IIszsMax PBzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=g+1xhV9H; 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 y9-20020a170906070900b0093117deb464si14817480ejb.88.2023.03.21.15.13.47; Tue, 21 Mar 2023 15:14:12 -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=20210112 header.b=g+1xhV9H; 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 S230293AbjCUWBl (ORCPT + 99 others); Tue, 21 Mar 2023 18:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbjCUWBJ (ORCPT ); Tue, 21 Mar 2023 18:01:09 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB75748E0F for ; Tue, 21 Mar 2023 15:00:44 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id p9-20020a170902e74900b001a1c7b2e7afso4864001plf.0 for ; Tue, 21 Mar 2023 15:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679436042; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=TXYP/la1qhNyvVoZkTScqrgtgxD2yAawazbtnCeBxio=; b=g+1xhV9HsMHnKFM49waIK6sqkS2EKBFRc3TBIumBs9n9HLYewdRG78hEvTPZimgJuF jOZCE9/uPtqTkdpOX96ixTH0A1jj/qpMTudZtnOg2HBqXrPlFJ2vNamX2wNk3YxqMR1K 8S+VRHbSrN3k7nQTqBoSEpcMETj0nkdITGJbmcqzjVBQlsawg5hTdDH/z6D/YbrAPIr5 1lZh+OfD/2Poua0cWt0WCnu9A8paciTZqfS5DRH34XWsE5P8heG6DZxwSIF7wZbK+Zhx aa3y/2ZarGX0G4zmlREasDuUbDqvZSlQwchIVBxZCUsvAskwrf7ne9EhA3R0W8p1vX7A yQQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679436042; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TXYP/la1qhNyvVoZkTScqrgtgxD2yAawazbtnCeBxio=; b=DqZAkdxwNQZ2v9C3Y39IeWp/PpHpt96UNfQBsNvhD+l+mc5jRa6K6P85km7ZjRTnZL BdMd2of/tRcFpbrraF9MiHA37J501fXABDL6XB3nD5cbGqUztQEFPAAovPp1/WOIbY/N gBR5bx+dtSBv58ut+zbIpn79OQocwn4Yn3v/754uN/GoBVePQkOJpdu9Olr1VhL33DaP VANiWujI/I80w1GhOB/vAaDl1Ia3j59KpD36hw5dpDSo621i2eKtLMH0oeUNMXlRxuXk Vf9iwbC2lyUfIed5o0omj7UwSlrjXdOO004miOTwoOnP+JsZDGdlZNx5/qM+jNK953Z+ PIUA== X-Gm-Message-State: AO0yUKVVALoN+Cj99AvPqYR1znpY0MTvjAOlYsvPV/5exk065W2hMuf1 1elJAuIekXRixjdx5pYduQsfL2HAZZs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:f3d5:b0:23d:2000:ccd6 with SMTP id ha21-20020a17090af3d500b0023d2000ccd6mr460733pjb.2.1679436042594; Tue, 21 Mar 2023 15:00:42 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 21 Mar 2023 15:00:19 -0700 In-Reply-To: <20230321220021.2119033-1-seanjc@google.com> Mime-Version: 1.0 References: <20230321220021.2119033-1-seanjc@google.com> X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: <20230321220021.2119033-12-seanjc@google.com> Subject: [PATCH v4 11/13] KVM: x86/mmu: Remove "record_acc_track" in __tdp_mmu_set_spte() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma , David Matlack , Ben Gardon Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 From: Vipin Sharma Remove bool parameter "record_acc_track" from __tdp_mmu_set_spte() and refactor the code. This variable is always set to true by its caller. Remove single and double underscore prefix from tdp_mmu_set_spte() related APIs: 1. Change __tdp_mmu_set_spte() to tdp_mmu_set_spte() 2. Change _tdp_mmu_set_spte() to tdp_mmu_iter_set_spte() Signed-off-by: Vipin Sharma Reviewed-by: David Matlack Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/tdp_mmu.c | 51 +++++++++++++------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index cdfb67ef5800..9649e0fe4302 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -695,7 +695,7 @@ static inline int tdp_mmu_zap_spte_atomic(struct kvm *kvm, /* - * __tdp_mmu_set_spte - Set a TDP MMU SPTE and handle the associated bookkeeping + * tdp_mmu_set_spte - Set a TDP MMU SPTE and handle the associated bookkeeping * @kvm: KVM instance * @as_id: Address space ID, i.e. regular vs. SMM * @sptep: Pointer to the SPTE @@ -703,18 +703,12 @@ static inline int tdp_mmu_zap_spte_atomic(struct kvm *kvm, * @new_spte: The new value that will be set for the SPTE * @gfn: The base GFN that was (or will be) mapped by the SPTE * @level: The level _containing_ the SPTE (its parent PT's level) - * @record_acc_track: Notify the MM subsystem of changes to the accessed state - * of the page. Should be set unless handling an MMU - * notifier for access tracking. Leaving record_acc_track - * unset in that case prevents page accesses from being - * double counted. * * Returns the old SPTE value, which _may_ be different than @old_spte if the * SPTE had voldatile bits. */ -static u64 __tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep, - u64 old_spte, u64 new_spte, gfn_t gfn, int level, - bool record_acc_track) +static u64 tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep, + u64 old_spte, u64 new_spte, gfn_t gfn, int level) { lockdep_assert_held_write(&kvm->mmu_lock); @@ -730,30 +724,19 @@ static u64 __tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep, old_spte = kvm_tdp_mmu_write_spte(sptep, old_spte, new_spte, level); __handle_changed_spte(kvm, as_id, gfn, old_spte, new_spte, level, false); - - if (record_acc_track) - handle_changed_spte_acc_track(old_spte, new_spte, level); - + handle_changed_spte_acc_track(old_spte, new_spte, level); handle_changed_spte_dirty_log(kvm, as_id, gfn, old_spte, new_spte, level); return old_spte; } -static inline void _tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter, - u64 new_spte, bool record_acc_track) +static inline void tdp_mmu_iter_set_spte(struct kvm *kvm, struct tdp_iter *iter, + u64 new_spte) { WARN_ON_ONCE(iter->yielded); - - iter->old_spte = __tdp_mmu_set_spte(kvm, iter->as_id, iter->sptep, - iter->old_spte, new_spte, - iter->gfn, iter->level, - record_acc_track); -} - -static inline void tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter, - u64 new_spte) -{ - _tdp_mmu_set_spte(kvm, iter, new_spte, true); + iter->old_spte = tdp_mmu_set_spte(kvm, iter->as_id, iter->sptep, + iter->old_spte, new_spte, + iter->gfn, iter->level); } #define tdp_root_for_each_pte(_iter, _root, _start, _end) \ @@ -845,7 +828,7 @@ static void __tdp_mmu_zap_root(struct kvm *kvm, struct kvm_mmu_page *root, continue; if (!shared) - tdp_mmu_set_spte(kvm, &iter, 0); + tdp_mmu_iter_set_spte(kvm, &iter, 0); else if (tdp_mmu_set_spte_atomic(kvm, &iter, 0)) goto retry; } @@ -902,8 +885,8 @@ bool kvm_tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp) if (WARN_ON_ONCE(!is_shadow_present_pte(old_spte))) return false; - __tdp_mmu_set_spte(kvm, kvm_mmu_page_as_id(sp), sp->ptep, old_spte, 0, - sp->gfn, sp->role.level + 1, true); + tdp_mmu_set_spte(kvm, kvm_mmu_page_as_id(sp), sp->ptep, old_spte, 0, + sp->gfn, sp->role.level + 1); return true; } @@ -937,7 +920,7 @@ static bool tdp_mmu_zap_leafs(struct kvm *kvm, struct kvm_mmu_page *root, !is_last_spte(iter.old_spte, iter.level)) continue; - tdp_mmu_set_spte(kvm, &iter, 0); + tdp_mmu_iter_set_spte(kvm, &iter, 0); flush = true; } @@ -1107,7 +1090,7 @@ static int tdp_mmu_link_sp(struct kvm *kvm, struct tdp_iter *iter, if (ret) return ret; } else { - tdp_mmu_set_spte(kvm, iter, spte); + tdp_mmu_iter_set_spte(kvm, iter, spte); } tdp_account_mmu_page(kvm, sp); @@ -1314,13 +1297,13 @@ static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter, * invariant that the PFN of a present * leaf SPTE can never change. * See __handle_changed_spte(). */ - tdp_mmu_set_spte(kvm, iter, 0); + tdp_mmu_iter_set_spte(kvm, iter, 0); if (!pte_write(range->pte)) { new_spte = kvm_mmu_changed_pte_notifier_make_spte(iter->old_spte, pte_pfn(range->pte)); - tdp_mmu_set_spte(kvm, iter, new_spte); + tdp_mmu_iter_set_spte(kvm, iter, new_spte); } return true; @@ -1805,7 +1788,7 @@ static bool write_protect_gfn(struct kvm *kvm, struct kvm_mmu_page *root, if (new_spte == iter.old_spte) break; - tdp_mmu_set_spte(kvm, &iter, new_spte); + tdp_mmu_iter_set_spte(kvm, &iter, new_spte); spte_set = true; } -- 2.40.0.rc2.332.ga46443480c-goog