From patchwork Thu May 11 23:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 92892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4749014vqo; Thu, 11 May 2023 17:08:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6TeQkhCQmmvZtcON84mPGe4QRBfgGDDTlnBxYL2grZbWDPQN+W5FcFayxjScu+cyFEHdOW X-Received: by 2002:a17:902:d2cb:b0:1ac:7ea7:6ccd with SMTP id n11-20020a170902d2cb00b001ac7ea76ccdmr18551144plc.34.1683850093758; Thu, 11 May 2023 17:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683850093; cv=none; d=google.com; s=arc-20160816; b=ivRjy0ClYUOdfGlSNqWz53tngnY6ZiBax7dd8v5y0vL/6GwPqVgAh6Q8LoLOHQVfBJ PUmCwuvkHLeMKMcYWmH1bgWpUmR/ZcbDF53sqX3AeBQ2Q0JsjAhISJIPmqh/ypKbzy1k fjoa9kEUmjajp5VneY7r48DaApq3QdZIQNTgvEOootiyEPiH30Z/HTi2p5tcZcCdvA96 vBz4hMbZ02HpvLi4nyjKaui033MVqNoYBvWmcbiXXAYlVuge1/uSjl0TFi1N2bhdSE8G gVScGowOhkwwAqzafB3F5eIZzpDW5cmtHQGWcV6RKZoUxs00Rklr1qr12WcqfKs3xKBV bR2A== 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=CNraDidmFDw9dJQ9QnV0Y0C81tvqP9mqw0EiCSRz+Vs=; b=dSjXGeqdkUIc8Do39joV90z81xt+iOKHYC9xoUp0o6GsXSPCrmzdrlOymGOV04cWog hz9x4bBLbJcVROGrXujX7pqeICD6z6t1kk9Z+MLHoe2aaP0w1Kl62omLq6jmxl0rmLmJ MDD60F+S42KSlAvUacY7v4nZXSUJuQCcnaRZOgfy9JfPLlvVWR+t2kSENyFDiKkuvkzl zEtecXuRToMRuSnMRVkhinEsi4SVHZRT/lZdtIWpalsa/J6P/jKE8fdnW6bQmgXqZEmg FZ4GT0djl4aCWoOmbq+tsVgwlDBweI9BS4l1yTQMO25MYIFGPZZLVuznscuIJS7pOD+T 0CMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=sOIKLxFG; 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 i2-20020a17090332c200b001ac62935789si8817561plr.468.2023.05.11.17.07.56; Thu, 11 May 2023 17:08:13 -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=sOIKLxFG; 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 S239618AbjEKX70 (ORCPT + 99 others); Thu, 11 May 2023 19:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239160AbjEKX7X (ORCPT ); Thu, 11 May 2023 19:59:23 -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 57EB52689 for ; Thu, 11 May 2023 16:59:21 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-55d9a9d19c9so133438267b3.1 for ; Thu, 11 May 2023 16:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683849560; x=1686441560; 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=CNraDidmFDw9dJQ9QnV0Y0C81tvqP9mqw0EiCSRz+Vs=; b=sOIKLxFGuZR3i+K8MJnpj7JJVwmgGhXNdfe9XNnpN8OBIHbAYWKHKMnwLAXfeq0eS2 ML6wMOtYOj99/tupq5/BOSt0fd19YAO+5/xjWDl0mbazf82YyyhL0m2wtHFjZwoa87x/ iFiAl66sn+AQjsVPkU5S2e0s7QnsrMicU9ivDez7l6MkMd0z0N8wR0rZTx6+swKs+YEL 3cxQEQwHQTqOs7qC0XOyaKQJ+AwoNL/dPQTVXgZeYaToXfHCQKLMJ6sY3p/OudNICFtd oFAFNrp3Nu13/EUHIEvlNfCOBJwPTpZeUgGaw0luySkG+EAYCs99WAR7cgEIWIScPC9E 4rmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683849560; x=1686441560; 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=CNraDidmFDw9dJQ9QnV0Y0C81tvqP9mqw0EiCSRz+Vs=; b=JKPk3a5iOxXWZWoqpSF8YKc9TyapV4A7ow8fnxeq3jzNQP/nQUWfyu5YbwuOMu+AY2 xhCqrE0PbgjNdAVBLbJLeL3+eqHtT2QkQQ0oX1FKXEdbe9OGl4wOQxT+lbolAov7Bwkd veTy0QCZn9wBsFTAjCAFryuBhJTdr0lw04t5BUuZ0nYhr6QqmjUfuOG6jsRKWHwNN8TJ /2NT1O4zf8GypQ/egnYium5Ns1hJcy0SEWdVcs/EFLGyq0HnsqBSnZY5H1XwzOtE5UC9 uppSy32m1WrLR52a+y9he6lmfbBrFjAy8n0dJktpS5xYnzyNkaQr2ZlibsSzgEg4qXqQ RMRw== X-Gm-Message-State: AC+VfDyTthAaANvOK/10Jk/V3TDdKe/nmDZ9O7BRGTYJMx+0qbDKEzhh s95sleowyIqOXZ8UqS67zezw+IfuVhY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:ae65:0:b0:55d:f921:6bfa with SMTP id g37-20020a81ae65000000b0055df9216bfamr9874068ywk.5.1683849560649; Thu, 11 May 2023 16:59:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 11 May 2023 16:59:09 -0700 In-Reply-To: <20230511235917.639770-1-seanjc@google.com> Mime-Version: 1.0 References: <20230511235917.639770-1-seanjc@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230511235917.639770-2-seanjc@google.com> Subject: [PATCH 1/9] KVM: x86/mmu: Delete pgprintk() and all its usage From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mingwei Zhang , David Matlack , Jim Mattson 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765644795962290324?= X-GMAIL-MSGID: =?utf-8?q?1765644795962290324?= Delete KVM's pgprintk() and all its usage, as the code is very prone to bitrot due to being buried behind MMU_DEBUG, and the functionality has been rendered almost entirely obsolete by the tracepoints KVM has gained over the years. And for the situations where the information provided by KVM's tracepoints is insufficient, pgprintk() rarely fills in the gaps, and is almost always far too noisy, i.e. developers end up implementing custom prints anyways. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 17 ----------------- arch/x86/kvm/mmu/mmu_internal.h | 2 -- arch/x86/kvm/mmu/paging_tmpl.h | 7 ------- arch/x86/kvm/mmu/spte.c | 2 -- 4 files changed, 28 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index c8961f45e3b1..cb70958eeaf9 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2768,12 +2768,9 @@ int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn) LIST_HEAD(invalid_list); int r; - pgprintk("%s: looking for gfn %llx\n", __func__, gfn); r = 0; write_lock(&kvm->mmu_lock); for_each_gfn_valid_sp_with_gptes(kvm, sp, gfn) { - pgprintk("%s: gfn %llx role %x\n", __func__, gfn, - sp->role.word); r = 1; kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); } @@ -2931,9 +2928,6 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, bool prefetch = !fault || fault->prefetch; bool write_fault = fault && fault->write; - pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__, - *sptep, write_fault, gfn); - if (unlikely(is_noslot_pfn(pfn))) { vcpu->stat.pf_mmio_spte_created++; mark_mmio_spte(vcpu, sptep, gfn, pte_access); @@ -2953,8 +2947,6 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, drop_parent_pte(child, sptep); flush = true; } else if (pfn != spte_to_pfn(*sptep)) { - pgprintk("hfn old %llx new %llx\n", - spte_to_pfn(*sptep), pfn); drop_spte(vcpu->kvm, sptep); flush = true; } else @@ -2979,8 +2971,6 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, if (flush) kvm_flush_remote_tlbs_gfn(vcpu->kvm, gfn, level); - pgprintk("%s: setting spte %llx\n", __func__, *sptep); - if (!was_rmapped) { WARN_ON_ONCE(ret == RET_PF_SPURIOUS); rmap_add(vcpu, slot, sptep, gfn, pte_access); @@ -4436,8 +4426,6 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault static int nonpaging_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) { - pgprintk("%s: gva %lx error %x\n", __func__, fault->addr, fault->error_code); - /* This path builds a PAE pagetable, we can map 2mb pages at maximum. */ fault->max_level = PG_LEVEL_2M; return direct_page_fault(vcpu, fault); @@ -5627,9 +5615,6 @@ static bool detect_write_misaligned(struct kvm_mmu_page *sp, gpa_t gpa, { unsigned offset, pte_size, misaligned; - pgprintk("misaligned: gpa %llx bytes %d role %x\n", - gpa, bytes, sp->role.word); - offset = offset_in_page(gpa); pte_size = sp->role.has_4_byte_gpte ? 4 : 8; @@ -5695,8 +5680,6 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, if (!READ_ONCE(vcpu->kvm->arch.indirect_shadow_pages)) return; - pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes); - write_lock(&vcpu->kvm->mmu_lock); gentry = mmu_pte_write_fetch_gpte(vcpu, &gpa, &bytes); diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index d39af5639ce9..4f1e4b327f40 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -11,11 +11,9 @@ #ifdef MMU_DEBUG extern bool dbg; -#define pgprintk(x...) do { if (dbg) printk(x); } while (0) #define rmap_printk(fmt, args...) do { if (dbg) printk("%s: " fmt, __func__, ## args); } while (0) #define MMU_WARN_ON(x) WARN_ON(x) #else -#define pgprintk(x...) do { } while (0) #define rmap_printk(x...) do { } while (0) #define MMU_WARN_ON(x) do { } while (0) #endif diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 0662e0278e70..7a97f769a7cb 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -456,9 +456,6 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, goto retry_walk; } - pgprintk("%s: pte %llx pte_access %x pt_access %x\n", - __func__, (u64)pte, walker->pte_access, - walker->pt_access[walker->level - 1]); return 1; error: @@ -529,8 +526,6 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, if (FNAME(prefetch_invalid_gpte)(vcpu, sp, spte, gpte)) return false; - pgprintk("%s: gpte %llx spte %p\n", __func__, (u64)gpte, spte); - gfn = gpte_to_gfn(gpte); pte_access = sp->role.access & FNAME(gpte_access)(gpte); FNAME(protect_clean_gpte)(vcpu->arch.mmu, &pte_access, gpte); @@ -758,7 +753,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault struct guest_walker walker; int r; - pgprintk("%s: addr %lx err %x\n", __func__, fault->addr, fault->error_code); WARN_ON_ONCE(fault->is_tdp); /* @@ -773,7 +767,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault * The page is not mapped by the guest. Let the guest handle it. */ if (!r) { - pgprintk("%s: guest page fault\n", __func__); if (!fault->prefetch) kvm_inject_emulated_page_fault(vcpu, &walker.fault); diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c index cf2c6426a6fc..438a86bda9f3 100644 --- a/arch/x86/kvm/mmu/spte.c +++ b/arch/x86/kvm/mmu/spte.c @@ -221,8 +221,6 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, * shadow pages and unsync'ing pages is not allowed. */ if (mmu_try_to_unsync_pages(vcpu->kvm, slot, gfn, can_unsync, prefetch)) { - pgprintk("%s: found shadow page for %llx, marking ro\n", - __func__, gfn); wrprot = true; pte_access &= ~ACC_WRITE_MASK; spte &= ~(PT_WRITABLE_MASK | shadow_mmu_writable_mask);