From patchwork Wed Dec 21 22:24:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardon X-Patchwork-Id: 35542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:8188:b0:89:790f:f786 with SMTP id m8csp4946033dye; Wed, 21 Dec 2022 14:27:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsm54bSR0to47z6UQkl8W+W/uBE8BSRq1MObiD2ZmJ3rRO9PqC4wWsvqfOcsV/VvvvFBjM3 X-Received: by 2002:a17:906:265a:b0:7ad:9893:ff40 with SMTP id i26-20020a170906265a00b007ad9893ff40mr7039550ejc.27.1671661675222; Wed, 21 Dec 2022 14:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671661675; cv=none; d=google.com; s=arc-20160816; b=sHi+ZjyRwaLG+CBYTL4tLHG+r3yzLjVLxl5u7d0biSMEX+ZoJNMqaZZRs6naY5qIw9 rYTOxF5iiqaMtdgRlFS9QWKS+SV2bonObFKegQXzHUSv/kQVbz605pNZVBdtMZWfKm93 b2drweF8txWSYy875KSQ9+6xf1ODNGIIgDehY/K06UpgQI7E2eUOF9ExoB/yWNkC3rCA TtYIndHHDnV7XhkorI20aI8rj/NLdhLmiiVvNqu/9o3T6kSdLhoI9yh+2g6Hje/CjAKD qzpzSkpA++OQ/+sZjoXw0DIuHZjnAhaNYyOSU+1+0ZsRV7WbWw1nlOz1vzd6PIFpvVXT 7KNQ== 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=ZvHSZ7wyO6HpWC7GgWotvlWeVl4F+Q0dZdGlQyXVA6g=; b=QM2h3RU6XSM2Y9YtII39/QtvxAjacmHVvFJxQfxBeX4gyRkK+GROFcTc3jTi09tAKg d/i34A+J49dVF9fQgrBTGFTwma9gxwtRSiv7K2krqTFBXvO8BkwvXAWcOeduke+abuO6 prf1ume6kshD+ncqERp98Li1lrJPlz10MRrvSZA1BZintPaDWu28hoLn1GxBAtlrZ+mP CP2NA0MC4SWXpCeizERvS+/ov3/WtGfwkwvVR+zJd2Cl8oRrAaKkxhfjzmrYFdzs+m2n ss0vsD1Zff0+jK8VcqQj+fKwWSg2d2X1R6WpwV6Z09b9f3lzFakNG+VxnUJ0Jx3rIZew hQpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SZmxxj3D; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a170906848700b007c0d88f1614si12859959ejx.342.2022.12.21.14.27.31; Wed, 21 Dec 2022 14:27:55 -0800 (PST) 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=SZmxxj3D; 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 S235126AbiLUWZv (ORCPT + 99 others); Wed, 21 Dec 2022 17:25:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235051AbiLUWZP (ORCPT ); Wed, 21 Dec 2022 17:25:15 -0500 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 0FD3C27920 for ; Wed, 21 Dec 2022 14:24:43 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id m13-20020a170902f64d00b001899a70c8f1so128658plg.14 for ; Wed, 21 Dec 2022 14:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZvHSZ7wyO6HpWC7GgWotvlWeVl4F+Q0dZdGlQyXVA6g=; b=SZmxxj3D7ZU/s/vea1hbQX3dVt8uH8sCEHNP+G6nLRcEHVdJ8hshrQVvHHLhSFn40n gJwzzUv13Wwj4TPXk4zLMaNE7Il3+japKHq9hAOS3Uzam7+8ANCSXsQO5uZjmDyrib8v n7BsILS36PW4iMO4uWVAOs6+sx5t4+1pg/u9I3KpAsMyLw8mHxIVg/Wt2pfxeyHDqcxc HGT2NGqNDuzehTa0QijHcR97mXOs1J+H+2mJ46JHFhPk6XZfnisD+R37bMDh2M9WiZq3 MSr8s3Qhiy5xIfqLB/smHZVEetk3udAPOdilIivf5+njgF/jOhq3oLoDwhHLecPyYFNr afyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZvHSZ7wyO6HpWC7GgWotvlWeVl4F+Q0dZdGlQyXVA6g=; b=ZOKwDuuBXE7uOKeThj2elgSeJp+0hgfTgvpom/cMegW+MjNp308tBKS3gb79xGp/d4 1mB9g2ag7H0z5t2P82b0NZQ35nsFzkl8YofIG6K3gL3gIizZJSdkabr2kyiqiiNw93aA jFFhkp+4Sk1yeszPHGkWBiqONAqpLlFkXpFdzqf27zYkPSDFjgZ6VM1mhYjIjmEsM7aV XdshzSbktx/XfoHiRo0FibPj4RAxjLCALZMC7dAD3HPBfbbSe6mwHLE1gqPyRxw37eyW mqyeHuS7IHqY443hFYWMVLyH2lG1RVlsGGVpUEJmfsQxTwAeaW4zHzcvRdXHC8BurHSz MxPQ== X-Gm-Message-State: AFqh2kpvy0T+StbWHnWi22SGxBtE/GgSzGxkDHZVffKIGw7siLZKHORk cB5vQIJrkEmJhPceMB8GRXRLKmeX8Qkhw59592VxQztzEg8sKkIoMsnpmjPfu5Mj357rsEoybkD RS0wRDxG3Vd2slLdkWVYGcnuRpvmBA2DfHu5d6GIBELwa7EAy246eBwP4NEMa9CMnBAiUW3np X-Received: from sweer.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:e45]) (user=bgardon job=sendgmr) by 2002:a05:6a00:3404:b0:577:4103:8da with SMTP id cn4-20020a056a00340400b00577410308damr245364pfb.1.1671661482452; Wed, 21 Dec 2022 14:24:42 -0800 (PST) Date: Wed, 21 Dec 2022 22:24:16 +0000 In-Reply-To: <20221221222418.3307832-1-bgardon@google.com> Mime-Version: 1.0 References: <20221221222418.3307832-1-bgardon@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221221222418.3307832-13-bgardon@google.com> Subject: [RFC 12/14] KVM: x86/MMU: Remove unneeded exports from shadow_mmu.c From: Ben Gardon To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Peter Xu , Sean Christopherson , David Matlack , Vipin Sharma , Nagareddy Reddy , Ben Gardon 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,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752864312834131844?= X-GMAIL-MSGID: =?utf-8?q?1752864312834131844?= Now that the various dirty logging / wrprot function implementations are in shadow_mmu.c, do another round of cleanups to remove functions which no longer need to be exposed and can be marked static. No functional change intended. Signed-off-by: Ben Gardon --- arch/x86/kvm/mmu/shadow_mmu.c | 30 +++++++++++++++++------------- arch/x86/kvm/mmu/shadow_mmu.h | 18 ------------------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/arch/x86/kvm/mmu/shadow_mmu.c b/arch/x86/kvm/mmu/shadow_mmu.c index 80b8c78daaeb..77472eb9b06a 100644 --- a/arch/x86/kvm/mmu/shadow_mmu.c +++ b/arch/x86/kvm/mmu/shadow_mmu.c @@ -632,8 +632,8 @@ unsigned int pte_list_count(struct kvm_rmap_head *rmap_head) return count; } -struct kvm_rmap_head *gfn_to_rmap(gfn_t gfn, int level, - const struct kvm_memory_slot *slot) +static struct kvm_rmap_head *gfn_to_rmap(gfn_t gfn, int level, + const struct kvm_memory_slot *slot) { unsigned long idx; @@ -801,7 +801,7 @@ static bool spte_write_protect(u64 *sptep, bool pt_protect) return mmu_spte_update(sptep, spte); } -bool rmap_write_protect(struct kvm_rmap_head *rmap_head, bool pt_protect) +static bool rmap_write_protect(struct kvm_rmap_head *rmap_head, bool pt_protect) { u64 *sptep; struct rmap_iterator iter; @@ -840,8 +840,8 @@ static bool spte_wrprot_for_clear_dirty(u64 *sptep) * - W bit on ad-disabled SPTEs. * Returns true iff any D or W bits were cleared. */ -bool __rmap_clear_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head, - const struct kvm_memory_slot *slot) +static bool __rmap_clear_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head, + const struct kvm_memory_slot *slot) { u64 *sptep; struct rmap_iterator iter; @@ -3045,6 +3045,11 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, write_unlock(&vcpu->kvm->mmu_lock); } +/* The return value indicates if tlb flush on all vcpus is needed. */ +typedef bool (*slot_level_handler) (struct kvm *kvm, + struct kvm_rmap_head *rmap_head, + const struct kvm_memory_slot *slot); + /* The caller should hold mmu-lock before calling this function. */ static __always_inline bool slot_handle_level_range(struct kvm *kvm, const struct kvm_memory_slot *memslot, @@ -3073,10 +3078,10 @@ slot_handle_level_range(struct kvm *kvm, const struct kvm_memory_slot *memslot, return flush; } -__always_inline bool slot_handle_level(struct kvm *kvm, - const struct kvm_memory_slot *memslot, - slot_level_handler fn, int start_level, - int end_level, bool flush_on_yield) +static __always_inline bool +slot_handle_level(struct kvm *kvm, const struct kvm_memory_slot *memslot, + slot_level_handler fn, int start_level, int end_level, + bool flush_on_yield) { return slot_handle_level_range(kvm, memslot, fn, start_level, end_level, memslot->base_gfn, @@ -3084,10 +3089,9 @@ __always_inline bool slot_handle_level(struct kvm *kvm, flush_on_yield, false); } -__always_inline bool slot_handle_level_4k(struct kvm *kvm, - const struct kvm_memory_slot *memslot, - slot_level_handler fn, - bool flush_on_yield) +static __always_inline bool +slot_handle_level_4k(struct kvm *kvm, const struct kvm_memory_slot *memslot, + slot_level_handler fn, bool flush_on_yield) { return slot_handle_level(kvm, memslot, fn, PG_LEVEL_4K, PG_LEVEL_4K, flush_on_yield); diff --git a/arch/x86/kvm/mmu/shadow_mmu.h b/arch/x86/kvm/mmu/shadow_mmu.h index c322eeaa0688..397fb463ef54 100644 --- a/arch/x86/kvm/mmu/shadow_mmu.h +++ b/arch/x86/kvm/mmu/shadow_mmu.h @@ -26,11 +26,6 @@ struct pte_list_desc { /* Only exported for debugfs.c. */ unsigned int pte_list_count(struct kvm_rmap_head *rmap_head); -struct kvm_rmap_head *gfn_to_rmap(gfn_t gfn, int level, - const struct kvm_memory_slot *slot); -bool rmap_write_protect(struct kvm_rmap_head *rmap_head, bool pt_protect); -bool __rmap_clear_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head, - const struct kvm_memory_slot *slot); bool kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head, struct kvm_memory_slot *slot, gfn_t gfn, int level, pte_t unused); @@ -78,22 +73,9 @@ int kvm_shadow_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes, void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes, struct kvm_page_track_notifier_node *node); -/* The return value indicates if tlb flush on all vcpus is needed. */ -typedef bool (*slot_level_handler) (struct kvm *kvm, - struct kvm_rmap_head *rmap_head, - const struct kvm_memory_slot *slot); -bool slot_handle_level(struct kvm *kvm, const struct kvm_memory_slot *memslot, - slot_level_handler fn, int start_level, int end_level, - bool flush_on_yield); -bool slot_handle_level_4k(struct kvm *kvm, const struct kvm_memory_slot *memslot, - slot_level_handler fn, bool flush_on_yield); - void kvm_shadow_mmu_zap_obsolete_pages(struct kvm *kvm); bool kvm_shadow_mmu_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end); -bool slot_rmap_write_protect(struct kvm *kvm, struct kvm_rmap_head *rmap_head, - const struct kvm_memory_slot *slot); - void kvm_shadow_mmu_try_split_huge_pages(struct kvm *kvm, const struct kvm_memory_slot *slot, gfn_t start, gfn_t end,