Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp693242rwl; Thu, 5 Jan 2023 03:17:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuVMiNn29yX0UjTgSe07P+fjxFzapUBLMuKMxkPy5D4iDvx8BIihr7X+SU/TOgmFhriOO47 X-Received: by 2002:a17:90b:4cc2:b0:225:f095:a3dc with SMTP id nd2-20020a17090b4cc200b00225f095a3dcmr37054485pjb.14.1672917441346; Thu, 05 Jan 2023 03:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672917441; cv=none; d=google.com; s=arc-20160816; b=n5FLYpzypF6CTcklF4juNjc3yVeozPSyw0dk5QzzQ8O2YU0dnbd+2tJdUGns/6jLEC htJ0VRFlDuoXYV3flXbNr6chZXKurPnKg3rAGFd9S3+cw8fOeZtTIJF3aSveqkGXCSmj CIm4Hw90sp3Y+G48pL1BwUVJZcT5CVlhSpC7wcnPb5QT5bTVD1buUjUopdEr18S0AUwU lLifOGelrtl8/uW6Gx+eskS8kqzf4eIFu99CC8CnLshqRw6YIBiGjCm0ew5v4jn4O0u8 pSdA1gnC4hJZwAe0X1z+ppE4b4lAXVn17HACkvTsLU3NqXoiLrkjEPeFCOUiAF0LtS2v 3MHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dIL5BQ5kiCN7aWb7s9J+mPjf4X7P7/oQ9fGAS1Y2L0E=; b=qZZXilmMYP31MIuD6jJvtsA5M/1vuadyfq6YBttHUsKAmjYsNwWZJZcV3asKljCEEh akUkdQhaFQO2WeI9nA19ThPqpL/T3JpbkTiTcwMDWsCf3PGTTz1+2FMWU7lM8dvk+cxu u6lKfuGEfh+XwbcXyFPCqI6Ttqes34kTo9eFbaut8dQL2seUEfW6oH8QZMLLNtKcAoM8 tdh7wNLm+6wMSyTIzGZ0xzQSO0EXXkBzEIpubmULWPOtbvlc/I9aZyclV5c5M2iqL1bz TuMufuUPQehdpqrf7EPGqpGmJ7Zai6zU1dmR4wTll0CY+XMRNPNTPyUk+fcq8S6ez8hf 1joA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f5KnFQOr; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a17090ac90500b002131bb4043asi1599534pjt.177.2023.01.05.03.17.14; Thu, 05 Jan 2023 03:17:21 -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=@gmail.com header.s=20210112 header.b=f5KnFQOr; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232482AbjAEKD0 (ORCPT + 55 others); Thu, 5 Jan 2023 05:03:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbjAEKC5 (ORCPT ); Thu, 5 Jan 2023 05:02:57 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A3013D16; Thu, 5 Jan 2023 02:02:00 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id j8-20020a17090a3e0800b00225fdd5007fso1541163pjc.2; Thu, 05 Jan 2023 02:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dIL5BQ5kiCN7aWb7s9J+mPjf4X7P7/oQ9fGAS1Y2L0E=; b=f5KnFQOrQ2JEr8F86AehTNd+ZROpDhAlBdTHW+sQYV6yM5KDjBEMCyvZ12qrjFD9CK hWZ7SJN5l4EG1gwNCGgMxUE3jBJwNHyb7wBjuiPJ9OWEi5v7qW9S/vqRI08wD7kB71IL adHmoDoeTFpkJUSpteSRZ/ctlaKAqqb5fnN5O81WvxGj/UBSH1c2OsyJnmegGrAnJ2It sNixLzo9UMmY7SvTZLaNPVvhflJ8zmTX0ZGIpX+8gNZ9kkQZ+zjxxBN9WbgvMFw6upf7 CLs7RzP4YPEBeU1POophBkGzSWq5RB70+1BTpU05eCNxV4xHCXEPCauCt72Rjga+PYUH UiAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dIL5BQ5kiCN7aWb7s9J+mPjf4X7P7/oQ9fGAS1Y2L0E=; b=AcchJOY78jjYuaDAlK2VvMn9YQAR6E+qISskHq6U1gClrtj1EW0NZME9TmalQ7GW3b Gqg+yDMvy50z1fLdJmJUGI1OMJr+M621xiayhJmtxWEczIvxHwAeIseEKFTnqE/awdgb dHYEkgThjeePyUVvf3dstwJM0QRopFzAFK5d4OOygCjs799wieyd7IIEDFxXvsDynFbR A6qqOaf7htHl3Woq0cSA0sy/RB31QNIdr7CAc1rTSNhx+vK6YK98VIUVmDjh54+XMzZn gMEruRNdHdOw0WBpTUcfnoCULmqJjz8op+HuB68NFYF+Fq+z7d08YSFTStT/F7FpSKtD Z5pw== X-Gm-Message-State: AFqh2kp8G+dZBCitjdnEUycHB0pqXf1+/bynF2FAINXeGkOEssREOw4z xHfQd9XcOZEMX7GR7Hui8w2wNvFTK1A= X-Received: by 2002:a05:6a20:94c4:b0:aa:806:7b91 with SMTP id ht4-20020a056a2094c400b000aa08067b91mr65167272pzb.39.1672912919124; Thu, 05 Jan 2023 02:01:59 -0800 (PST) Received: from localhost ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id mp10-20020a17090b190a00b00213202d77d9sm1006086pjb.43.2023.01.05.02.01.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2023 02:01:58 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Lai Jiangshan , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org Subject: [PATCH] kvm: x86/mmu: Don't clear write flooding for direct SP Date: Thu, 5 Jan 2023 18:03:10 +0800 Message-Id: <20230105100310.6700-1-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 From: Lai Jiangshan Although there is no harm, but there is no point to clear write flooding for direct SP. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/paging_tmpl.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 79da423ee4cb..11f17efbec97 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -649,12 +649,12 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, if (WARN_ON(!VALID_PAGE(vcpu->arch.mmu->root.hpa))) goto out_gpte_changed; - for (shadow_walk_init(&it, vcpu, fault->addr); - shadow_walk_okay(&it) && it.level > gw->level; - shadow_walk_next(&it)) { + for_each_shadow_entry(vcpu, fault->addr, it) { gfn_t table_gfn; clear_sp_write_flooding_count(it.sptep); + if (it.level == gw->level) + break; table_gfn = gw->table_gfn[it.level - 2]; access = gw->pt_access[it.level - 2]; @@ -706,8 +706,6 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, trace_kvm_mmu_spte_requested(fault); for (; shadow_walk_okay(&it); shadow_walk_next(&it)) { - clear_sp_write_flooding_count(it.sptep); - /* * We cannot overwrite existing page tables with an NX * large page, as the leaf could be executable. -- 2.19.1.6.gb485710b