Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp435386imn; Mon, 25 Jul 2022 22:40:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srfmoCVW4zszRbp73RBszCuzXMH2l6fO8utidIAFZqyxyGNMyNHqfcRms0F3K5U+64tK1K X-Received: by 2002:a17:90b:4b10:b0:1f2:d4a9:6b6d with SMTP id lx16-20020a17090b4b1000b001f2d4a96b6dmr4966429pjb.12.1658814017568; Mon, 25 Jul 2022 22:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658814017; cv=none; d=google.com; s=arc-20160816; b=KY+tvoRNGavwL7A2zBgO5R/aE+5fHBkwSyRAnF+5iAL9ONIEpSYWYQ3bPSQPChzD+f CL8xLrgR+sspkmpvGEOKbUsP+m6VvdOeRJngQe3CVd7JjyobzIgd1MFgCdPhURxOG/r1 TLzZwDhLsSHiYnQtFXP73d9C8sfdPRJz7Jcm5x7EUov6JLKeVnm+LC0jJ/w75C2AD2l1 N4ykgyBK/63xSlGD6bGy567ZAcMF3odIX6sfy1b3vip28DkVIzwT9X2UN6RKt0p6gVHW Wr2lQcVfycINHu22zf+2qTzSgBaQNJAqEJcdE5vExb2jCfw9j73zrjhpSg2nHbWcSb4D AP+w== 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=cSJ2gSZEB95hQy+fBPJ2b6XGNWJqJmog2/ljhs0mKjk=; b=HAfYOozFzZlGpL4qmFkWiAqTaWWM0qKsVA1O5DKkjEY5idRFPx1Pe5P+QwbGlWYrSQ NbifXQeZDwt7DPegXWLhnLso3Lw5UNyaQmbXkGQA++V62JcHSQ8W0zglwNtHJD4jfmT1 FgzQJ3kt4hmp32EucD38ySD9LFSuMZJDg5/g1XvVrDkGGp2Py6ehwHb1Y3ZkQakJ8Chn Vz57pewhE9fgc7Swldh/jrZQ/lUpuzt6W579TJb1d8AUxuVyMvJLoQD0JJHL9XuiKCBa KzkWZCrY3XIdVpxZQ5ktbYVTzMi8aAxQA+sHm8XUDUJj4A8ELQPXz9tRGkioqVck93EV RgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Tni2yj0/"; 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 c2-20020a170902d48200b001616b8f1c0fsi10820759plg.449.2022.07.25.22.39.54; Mon, 25 Jul 2022 22:40:17 -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="Tni2yj0/"; 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 S237611AbiGZFh0 (ORCPT + 99 others); Tue, 26 Jul 2022 01:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237603AbiGZFhY (ORCPT ); Tue, 26 Jul 2022 01:37:24 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CAB27CE8 for ; Mon, 25 Jul 2022 22:37:23 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id t3-20020a17090a3b4300b001f21eb7e8b0so15724765pjf.1 for ; Mon, 25 Jul 2022 22:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cSJ2gSZEB95hQy+fBPJ2b6XGNWJqJmog2/ljhs0mKjk=; b=Tni2yj0/pL2Jpa8ecAowM1kwFjFqP1gjp4Pwvvksw8y6+kamiIiCbiK8LMkZy7tv3l eCz53si26zG3SIFgWxMoLX1OWgY3g92VLYPoz06MadIQFIM6U+QGv2n925Diti5NOn7K 2gDDCp419O+bMCh6SplghILz6okQcoBGnApd5QXxL62BmRimZ6mhqUcCfvzH4JT1aIVA IwmvKKLyIWfgqMJ3J3AeWRyYKJhqTuC8Y2/5XY+EdgTeDMUsxO0cQudUwkWSzQvmtNBW j2SBzu5/z4zrjac5sUzfrrQQYuFyyjYJrQeB4k0ZcZIGAH3NRoPQRyCh/VBwTHrX4fv+ U3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cSJ2gSZEB95hQy+fBPJ2b6XGNWJqJmog2/ljhs0mKjk=; b=c3Fog3HNqzEriXrk6zR4SGjRtrjZIFjE4PGnPSyzvicnN/zC6uksEa8UeOUqrPA7vg OY3EYXylLnzez0krSOc7emF/8rwdGp8Pd0m6/DyCn/0eS8J8jNTlJmM3DfZCtXXJn+nc rKGbSd3NzJ1w3PhelofiR3QNzEgir+ol/Nkf2Vfe3GqqRu/QGAx9B2L1BA1nkawYy5Pl vGqvhSz1E2rF2NkuVC15AaOsMD/HFPOUocaIWrbo7RFyGUvj2fSakw8IMc2w7Qrtq1sh tZ1dkDmVB5LuXU58xXTjTbMuFJQUlexw07C6wrX0/S2x/gxD5V+xtMzQlQgqZWSAuMeT +urw== X-Gm-Message-State: AJIora8YTsjiAUL4mNRjP8hfDoI55FlXjChXXwOjsSMKdl3pJmUSC79C y7uVCxeneoHlqHWApEw30BoK9A== X-Received: by 2002:a17:902:d64a:b0:16c:2755:428d with SMTP id y10-20020a170902d64a00b0016c2755428dmr15805492plh.79.1658813843096; Mon, 25 Jul 2022 22:37:23 -0700 (PDT) Received: from google.com (59.39.145.34.bc.googleusercontent.com. [34.145.39.59]) by smtp.gmail.com with ESMTPSA id h13-20020a170902680d00b00168c52319c3sm10429459plk.149.2022.07.25.22.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 22:37:22 -0700 (PDT) Date: Tue, 26 Jul 2022 05:37:18 +0000 From: Mingwei Zhang To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed , Ben Gardon Subject: Re: [PATCH v2 0/6] KVM: x86: Apply NX mitigation more precisely Message-ID: References: <20220723012325.1715714-1-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220723012325.1715714-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, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Sat, Jul 23, 2022, 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. hmm, I applied this patch set (v2) on top of kvm/queue (HEAD: 1a4d88a361af) and it seems kvm-unit-tests/vmx failed on both ept=1 and ept=0. And it did not work on our internel kernel either (kernel crashed). Maybe there is still minor issues? > > 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 > > arch/x86/include/asm/kvm_host.h | 17 ++--- > arch/x86/kvm/mmu/mmu.c | 107 ++++++++++++++++++++++---------- > arch/x86/kvm/mmu/mmu_internal.h | 41 +++++++----- > arch/x86/kvm/mmu/paging_tmpl.h | 6 +- > arch/x86/kvm/mmu/spte.c | 11 ++++ > arch/x86/kvm/mmu/spte.h | 17 +++++ > arch/x86/kvm/mmu/tdp_mmu.c | 49 +++++++++------ > arch/x86/kvm/mmu/tdp_mmu.h | 2 + > 8 files changed, 167 insertions(+), 83 deletions(-) > > > base-commit: 1a4d88a361af4f2e91861d632c6a1fe87a9665c2 > -- > 2.37.1.359.gd136c6c3e2-goog >