Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4747609rwb; Tue, 6 Sep 2022 12:02:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5SQfwQ6Ehj9iUtnpLLEfg7ZZl5jsEkbFaOQ8f/C8rzC3SITrs9r2HzmXvQ97n5U7pSH/3O X-Received: by 2002:a17:90b:3b8d:b0:1fe:1fbe:b043 with SMTP id pc13-20020a17090b3b8d00b001fe1fbeb043mr27277331pjb.63.1662490972904; Tue, 06 Sep 2022 12:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662490972; cv=none; d=google.com; s=arc-20160816; b=D1jskRdfJbEusAYplTsVTxQDX6NHjvrWRO/Ag9Ugn4otEH4ttJyGF4EE+UBQm+9kp9 shM1JGIs8Tx36coEvoKEZtji7/U7Zu/CNdSFuLVJN7EaPjpJkstzh3Bt/PdBxgiGjjle /a6jxxsV88jH+8RuuDEDce52AlYffNTkkFArrNL/FMYZDZ9YJVF+fub/0d44jJIZU+cx ka12MfwzYL/yLlK2sKDmCB0GFcFIFvM4TaP86EVEaA5G7yOdNiXugISbJx8H7K1wENIq Bv6FAjaKAEWK0cmpaNb5PM2Y5yZ2zdFrvXAmM+DtOAuYe2e5IpYR3GM2QKtzEf6euV66 kg8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E9k+DekvPqCyEfJ57hGn14U8clOdojaXZR0lBsYnNU0=; b=O2h3SUw1hxiFSA+/oNhuR+4UtaL0n7UoHWkKLF7t2wDrRs28mqyGj3irqpZpTHyUHK 0MTEYwc28YLG5pSSnwAiSzoKjktmco4Td9vNiN4iUsqVfZC8Dxi3LVT8BJz9/SdYpXFj kf/I3ChvFK8wo7sF6gg4TlKdazmgCiResj4Oyr0NwR9YUbmAzZcqCF5qa2K6nxVvar85 tzENOwzU9siWMdIfkvuXJrhu9dT9H+QEGiPC0f0v1AdT21jraqcTREIsjmLrJJD7/OJu ti7Iohgz4SCcKpyi5CcSKNqD5ItwpsRzJ62uMZwl00qM3vdGsbvCNar+PetiP8sdlFI/ 3oJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Lpv2gTp5; 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 l11-20020a170903244b00b00176dd41a640si1290086pls.593.2022.09.06.12.02.37; Tue, 06 Sep 2022 12:02:52 -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=Lpv2gTp5; 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 S229740AbiIFSip (ORCPT + 99 others); Tue, 6 Sep 2022 14:38:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiIFSik (ORCPT ); Tue, 6 Sep 2022 14:38:40 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A53C9C2E8 for ; Tue, 6 Sep 2022 11:38:36 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id f124so3113287pgc.0 for ; Tue, 06 Sep 2022 11:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=E9k+DekvPqCyEfJ57hGn14U8clOdojaXZR0lBsYnNU0=; b=Lpv2gTp5kKu4vwEqcCL+7Nqun/lu8ZiOgR9j9vkfzdFHbyVXEusirVzrEO2CUbKPT/ HiuYO//edu2A/HUYCamKWzhiP26F1BvTYcEblbQEu63etjTQU31UR9k6dBg11GomS//t LzH6iscCegYGvSC3zEOd8NheodkxIiswcQ+0Vc/BYoY/rdVMN5/00xwo3flRccpNkpXw mYduULHGs/ezoAzKpbnif9msdH8wh/uEfxCm7lzIPNe0sz0RT9RG/42RG8u3b6Cv1nYr ppnl5WPZYS0Vmi3XleHNdAPVu5W099SjYsqFtPeC84pISwSd3NbKYgX4P+D5bH8Dk07q /QCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=E9k+DekvPqCyEfJ57hGn14U8clOdojaXZR0lBsYnNU0=; b=yNRWhqTlUCzXbSkmm0nxzXZwSEMSVWSizrhSj2YMap0WAyT89DQHme6CBFbH9OfBXp 94L8luBaOEp/xaqfOmkg+KvI8VyCx7dhtVBiffHzQvDChbY3e0ef1wn8p6Uo+AmsgM11 pEC/61LkMJiA9eCLYQfitR/Fd6rU+iNEFFc9dmgrur23ygQQDJA2/OO1KfwBHJRcozyN uwVF7TBxi/rfqIaefFcXlTFMhwZBSdGvFVkOFR+2ecU8QyAujZ9PISj/+L77Zpf9Jy1d X15NQpTTwu8P6pJUmAygof5DmJRr9dEXCSHaMsT7RhojQS5k0z5x7nAiWpwrFTJJIvmN wwlg== X-Gm-Message-State: ACgBeo2sfifPbSRCJ1+aOqR5M+mFqsKHOn2m0M5evvvlvuiVE0zHuCx5 foHL8+nC97BMUZdezWwMmQFS6Q== X-Received: by 2002:a62:e91a:0:b0:537:e307:fab0 with SMTP id j26-20020a62e91a000000b00537e307fab0mr52273151pfh.37.1662489515927; Tue, 06 Sep 2022 11:38:35 -0700 (PDT) Received: from google.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id a6-20020a1709027e4600b00176da1aae5asm1539847pln.70.2022.09.06.11.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 11:38:35 -0700 (PDT) Date: Tue, 6 Sep 2022 18:38:32 +0000 From: Mingwei Zhang To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Yan Zhao , Ben Gardon Subject: Re: [PATCH v4 0/9] KVM: x86: Apply NX mitigation more precisely Message-ID: References: <20220830235537.4004585-1-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220830235537.4004585-1-seanjc@google.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Tue, Aug 30, 2022, Sean Christopherson wrote: > Note, this applies on Yosry's stats series (there's a trivial-but-subtle > conflict in the TDP MMU shadow page accounting). > https://lore.kernel.org/all/20220823004639.2387269-1-yosryahmed@google.com > > Precisely track (via kvm_mmu_page) if a non-huge page is being forced > and use that info to avoid unnecessarily forcing smaller page sizes in > disallowed_hugepage_adjust(). > > KVM incorrectly assumes that the NX huge page mitigation is the only > scenario where KVM will create a non-leaf page instead of a huge page. > As a result, if the original source of huge page incompatibility goes > away, the NX mitigation is enabled, and KVM encounters an present shadow > page when attempting to install a huge page, KVM will force a smaller page > regardless of whether or not a smaller page is actually necessary to > satisfy the NX huge page mitigation. > > Unnecessarily forcing small pages can result in degraded guest performance, > especially on larger VMs. The bug was originally discovered when testing > dirty log performance, as KVM would leave small pages lying around when > zapping collapsible SPTEs. That case was indadvertantly fixed by commit > 5ba7c4c6d1c7 ("KVM: x86/MMU: Zap non-leaf SPTEs when disabling dirty > logging"), but other scenarios are still affected, e.g. KVM will not > rebuild a huge page if the mmu_notifier zaps a range of PTEs because the > primary MMU is creating a huge page. > > v4: > - Collect reviews. [Mingwei] > - Add comment to document possible_nx_huge_pages. [Mingwei] > - Drop extra memory barriers. [Paolo] > - Document ordering providing by TDP SPTE helpers. [Paolo] Hi Paolo and folks, Just a gentle ping. Are we good on this version? It seems the ordering concern in TDP MMU has been addressed. Thanks. -Mingwei