Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp364235ioo; Thu, 26 May 2022 05:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD0boyvkCoftIR+j3kwDqAHqzsulsgGzKagDjyAmx5thpA4+5dO5m3+XUPVZDkE6Pz4TC8 X-Received: by 2002:a63:904b:0:b0:3f8:4814:ecb4 with SMTP id a72-20020a63904b000000b003f84814ecb4mr26806286pge.257.1653568375651; Thu, 26 May 2022 05:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653568375; cv=none; d=google.com; s=arc-20160816; b=sDJA+D1C2ZQ8E8AcgBqKVB5aFb3Bq9zgGivEZn52IN2WDjD6lbKKDA/tc5GqMRb7Rf PaUzuPmcN9wf/XkmN1G9uMRzpWBrg8sgBDvPUOZA7WYDviKui4brRLidcGPzVLxz7How p67O+OIUaXgWJSoEUQQ1TrG63bzXjk2fTTX9w+F/yEGbschdxCSMGXuDdiGfnBu8KpDX ONpwixU/ctg40vsDL/VuGuMAKb3GL6cBm3QK93zrXkESdR5SrHn8wVx5PgGsmNmch2Kt dlivN7lT9ygt4QkWrWAkA4FM6rZQyPkRr2k096YY4Avz0ot0oRkWcfq53Ss8JOlxWFk4 nTHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5fW3OfjEhzE5YNooV46nflF0oAOwiUDDOMvNtmNpi/w=; b=DVQsOm/Gv9xAfZRqZInr8li01ZQ9YHXBH8XcBI4g9t65jO+8Idp2AqY+yLf+HGjE5Y RFWVnI+tl1goziwwM8yC169gJ9Guj1zrYKnT6cmHTAkKTV4d9/CTRMi8KHOZ0pituO9p QOvY6/dfdQCpXEGLepNPoKpBvNVSzEdGmiFjlBeE6d3UCwxEyZ1cfwKOf3z5sW1kOW1z JiAkVuiVdz3ofET6WlZeVZx767FetBLR8vcJNNn6TYBQ7SgIED8qqpGIq9Rkan/DIruC DVXnALkZAs8KPEV8OIN2GI6ZU2EhMDAG2eL2vpHBqW+XHnf7BpvkkRZmY4ngipjMgP86 37fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K2iyAo7B; 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 y2-20020a17090322c200b00158eb28cb9dsi1913296plg.254.2022.05.26.05.32.41; Thu, 26 May 2022 05:32:55 -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=K2iyAo7B; 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 S240964AbiEZJwR (ORCPT + 99 others); Thu, 26 May 2022 05:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231512AbiEZJwP (ORCPT ); Thu, 26 May 2022 05:52:15 -0400 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15088C9657; Thu, 26 May 2022 02:52:15 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-2ec42eae76bso9627707b3.10; Thu, 26 May 2022 02:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5fW3OfjEhzE5YNooV46nflF0oAOwiUDDOMvNtmNpi/w=; b=K2iyAo7Bms6m+fqUFJtfe6CXeLZsYcr916aM41w+5VuE9O0UzmacBX+KtsC+fZJ9+t Lb0f0LJmnN78I1YHKHvn6DTizcHGYIRAfpEm2HVO5pKAz4ohKRZleWWNr0GeZ4CldsgO q2wVwTIpDBQGrfhwRuEjyPC+yM1MYaBU/C3q4gY1no3iZZi/Tij0J20DW25KIxOpDzPX PG4DDlQGYfHnZgWQlS1dnpNLurObhdtbFEEWqa+uiH1mwc2hBGAYJhRxH6UOVS4mkLn7 iT8pux43RThpY9Kr6oTYuRb4pXz+8iALq0f8QlwrI3nO60QVKMUyzIsjdttGUUdwE0mW /NLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5fW3OfjEhzE5YNooV46nflF0oAOwiUDDOMvNtmNpi/w=; b=22ZmZ+FcPQm4ZB9Qo3/f6eRMlzqJ+SOyJWN5sFTGExIGT4uyI/ziKxyH999z924TcP PFobCWb8ajvTu2PDZ/jtWTFhmeSTkyNHL76mHDtImN1r42HaA7IJkaVbOys13Y/vTxS9 8mWz7ezfUJXOGzgTZc8NPsK7s920Tg4Nm9EnSqswbGPTe8/5NheZ6xurWfWzfQ6J/5pE 2vAkaTx2TAdPvcxYCp+hMo/J0MQel/k2rsjqC6hPDR7+MVwrX/e32z1vTMlyULdQ7uY4 fA6mYRyotaLpDhOv1rqEA1tPfLyaKjOBfq3Y6IdwSByvJGkMwvx9oSLHBEmcm1vSjB2v hTZg== X-Gm-Message-State: AOAM533UVTzRqWm5/nXOX8/S7muGcO3Xn28TwUXrj2j/AWToJRzyyvTT UPUM+YdCOKICwwBpNTvVNmFX1D4NWNTi59aPATU= X-Received: by 2002:a0d:e60a:0:b0:301:b342:5316 with SMTP id p10-20020a0de60a000000b00301b3425316mr3759640ywe.256.1653558734405; Thu, 26 May 2022 02:52:14 -0700 (PDT) MIME-Version: 1.0 References: <20220415103414.86555-1-jiangshanlai@gmail.com> <70cec00b-428f-9310-96b6-c6257fe36dec@redhat.com> In-Reply-To: <70cec00b-428f-9310-96b6-c6257fe36dec@redhat.com> From: Lai Jiangshan Date: Thu, 26 May 2022 17:52:03 +0800 Message-ID: Subject: Re: [PATCH] kvm: x86/svm/nested: Cache PDPTEs for nested NPT in PAE paging mode To: Paolo Bonzini Cc: David Matlack , Sean Christopherson , LKML , Lai Jiangshan , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , Marcelo Tosatti , Avi Kivity , kvm list Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE 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 Thu, May 26, 2022 at 5:33 PM Paolo Bonzini wrote: > > On 5/26/22 10:38, Lai Jiangshan wrote: > >> (Although the APM does say that "modern processors" do not pre-load > >> PDPTEs.) > > This changed between the Oct 2020 and Nov 2021, so I suppose the change > was done in Zen 3. > > > Oh, I also missed the fact that L1 is the host when emulating it. > > > > The code is for host-mode (L1)'s nested_cr3 which is using the > > traditional PAE PDPTEs loading and checking. > > > > So using caches is the only correct way, right? > > The caching behavior for NPT PDPTEs does not matter too much. What > matters is that a PDPTE with reserved bits should cause a #NPF at usage > time rather than a VMentry failure or a #NPF immediately after VMentry. > Since there is mmu->get_pdptrs() in mmu_alloc_shadow_roots(), you can't conform this now. It will be easier to only cause a #NPF at usage time after the one-off local patchset.