Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp712280imn; Thu, 28 Jul 2022 13:31:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5dvZc0Z7gOTEOTw7U9y/IERAhJLgPy7jrfx8QX9YQ+GbdT8oDqy1iscyPl41svTrj9ULKC X-Received: by 2002:a17:902:7107:b0:16d:c92b:8ad2 with SMTP id a7-20020a170902710700b0016dc92b8ad2mr543350pll.126.1659040293930; Thu, 28 Jul 2022 13:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659040293; cv=none; d=google.com; s=arc-20160816; b=oYjGiAqc4OAHHD0PdBk/VGDN0xyJOwyFaXqEHEA2XtiO4pvqb0tKPlpvMHvucomZSH BZIQQPwb4c9GF3CYPXQxn1sk/talSjeQqe3h3EcYpq8AzeXP1MkVDVSxH7620TYiBFte Fn0ZSTMJsdvFnWbzlj3YKL7sMNYdmgshrt1M/li1ysa57siaFzaCF4PFEqvRD0KaFZWL 4ZVQWkOwwGsWHCqsD2tqNjgo8QZmL74sL0uqN2amz8jJbxZqBpRSNA+aY1xghk5lkApO SUDJ5et9dnzdBxxGgXwhlgCQ2dH1TKTEgc9DrgyMKVSrFGxfkFY1LRyzBD5WPFHp0DgQ bEWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=Ak/yZTzpgIpJQtD3WljhsD5fouvH+uomdrADi70BHVM=; b=j+YY219XEWMHWRTZGzKh5pwkj2VYCDd9myLP/1bAQyaW0umTt/ER6844wVXOQwzWsN 0l2XUseTB7K7HUq5DGu+j7Ea/BJo9JN7FzjuBmXdscdYr5t9hsSFYyex92IyDcLseTcw D9v1JQ8Gu30JTYYDcNNYyXoZE7xdtA9i9vnValP/itedfjOV+HPyvKT22ogvpDz0QP6g RbQ7LBAAi9gBPROlOxdGfdRntiedF055EcqGcnAx1JQ/tkh8aFyVDRckeGJ0d+IKE083 sJb47aQYbMfTCrChSLQ2hKerbpvbzYc8KBdIupnQrd/1QlQVrAohtOZ1J8MhdjwgdWjl X7Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ixZyFAdc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a631f13000000b00408a86aeba9si2046888pgf.74.2022.07.28.13.31.18; Thu, 28 Jul 2022 13:31:33 -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=@gmail.com header.s=20210112 header.b=ixZyFAdc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232197AbiG1URl (ORCPT + 99 others); Thu, 28 Jul 2022 16:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232292AbiG1URg (ORCPT ); Thu, 28 Jul 2022 16:17:36 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FBF577561; Thu, 28 Jul 2022 13:17:35 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id v17so3556751edc.1; Thu, 28 Jul 2022 13:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ak/yZTzpgIpJQtD3WljhsD5fouvH+uomdrADi70BHVM=; b=ixZyFAdcGtxnZpyaCmt9Oesw0zIva2L+SI9fpMV88n2PleVuncVjFahbO2RmDl2rqU vvwH9bl1seswMDFt9LREEvFykrv28/iYW3kXZHIOMRGwQ745SyQfeLVvvqmjIbNUt2lf JYVPKyifCOpaSqxGt3Mq9uLyDEc5NtI7kiMMFBp7s1t414ea26irotKawjyBC9o+udWg vugtMk1KbGMjLhmcQRtezpUvB/Mv1UGXW9DMNQu52hD20BK5pp3VJJIT+d6Zxcq1Rxsi 0qfVWuFHddxsmbH+jcgD77xo38pROEoug1MJwEEJi8ukv5cu7duHJwLnm9VbWcGBLdnK C12A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ak/yZTzpgIpJQtD3WljhsD5fouvH+uomdrADi70BHVM=; b=TIF1tsbOcuTIUVL6q/UnHQ5Kh5Iptkz6bCqhXYLL2vAReVXpyr8a439Mro71KdMmdB mheK9IW6Dbeo9iA1ODSBocrPwSWlIcwe/rWEh6E4I7At0MblPlmLirKwHWJ+vG84F2cQ x2XEW/x+Ep8lnkGQWhabTXONbd8F2glSGGLwVS/zwZK2cFmF2vgf230c6egH8olpGhrJ 7sa5PNgaWe9Kykj7HF71Vd3xVElVLEL6iOc8dWP+qAHpx+ieclI+Xv/4AarNV28x/LvH rOBXTjFxCkjscRXXZjY41CBo8AYkcNsv1roxk5TF31oYwYtFShVINTGYDrBRc9Nb2ju8 LyLQ== X-Gm-Message-State: AJIora8KK9kQgJWrXaEsY0viHMaY/28xvCVjim/xgBdWzaU50li50sSs NidD7NtXqdXi68KzwyN+JFPItbSlFRUGuw== X-Received: by 2002:aa7:ce94:0:b0:43b:bf79:e9c3 with SMTP id y20-20020aa7ce94000000b0043bbf79e9c3mr590238edv.57.1659039453783; Thu, 28 Jul 2022 13:17:33 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id v18-20020a170906293200b00726c0e63b94sm778289ejd.27.2022.07.28.13.17.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Jul 2022 13:17:33 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <08c9e2ed-29a2-14ea-c872-1a353a70d3e5@redhat.com> Date: Thu, 28 Jul 2022 22:17:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 0/6] KVM: x86: Apply NX mitigation more precisely Content-Language: en-US To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed , Mingwei Zhang , Ben Gardon References: <20220723012325.1715714-1-seanjc@google.com> From: Paolo Bonzini In-Reply-To: <20220723012325.1715714-1-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=no 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 7/23/22 03:23, Sean Christopherson wrote: > Patch 6 from Mingwei is the end goal of the series. 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. 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(). > > v2: Rebase, tweak a changelog accordingly. > > v1:https://lore.kernel.org/all/20220409003847.819686-1-seanjc@google.com > > Mingwei Zhang (1): > KVM: x86/mmu: explicitly check nx_hugepage in > disallowed_hugepage_adjust() > > Sean Christopherson (5): > KVM: x86/mmu: Tag disallowed NX huge pages even if they're not tracked > KVM: x86/mmu: Properly account NX huge page workaround for nonpaging > MMUs > KVM: x86/mmu: Set disallowed_nx_huge_page in TDP MMU before setting > SPTE > KVM: x86/mmu: Track the number of TDP MMU pages, but not the actual > pages > KVM: x86/mmu: Add helper to convert SPTE value to its shadow page Some of the benefits are cool, such as not having to track the pages for the TDP MMU, and patch 2 is a borderline bugfix, but there's quite a lot of new non-obvious complexity here. So the obligatory question is: is it worth a hundred lines of new code? Paolo