From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAEA8C433EF for ; Thu, 2 Sep 2021 20:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A66DD60FC0 for ; Thu, 2 Sep 2021 20:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344670AbhIBUoa (ORCPT ); Thu, 2 Sep 2021 16:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344623AbhIBUo3 (ORCPT ); Thu, 2 Sep 2021 16:44:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B919FC061575 for ; Thu, 2 Sep 2021 13:43:30 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id j1so2206955pjv.3 for ; Thu, 02 Sep 2021 13:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=p+yuVJmEDLdMa0DmcBrLMHfy6agkaRopOhr58pW7MG0=; b=vYyJOnxuYUr+rVmUomYhYa1NvySadhA8ChpY8vSebSK40lSdX9B/LuLB6HfL/5gEtj Qrc9n1vHQbAmDlnOIp9PVI8Hrx4p3oycy7PtPn8FqDi1pV3ZKNMwyYWRxQHUfrgdNGYY AJpo3zkXoEOFiAtmQ8CwE3cY1gFoHTNWue/cGX6FBzrZwowE/2p/8uwky/JSCqg00ymP 8TclXFuyTFK3eU0XVj33sSkTByhoPDGKmOHD7AhpNJlFayfRcfkKDEs4JjdMkFPPlaZj Rfx6WghZTOqPO3pVMFuL/kIeeHCzD6YTAbcV/Hivk2OPDV8/+oHHEvyyUD3t13k7AAim Xqzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=p+yuVJmEDLdMa0DmcBrLMHfy6agkaRopOhr58pW7MG0=; b=NOi87X8pInu1zeO9e6tuCxKDDDHOF9zXM4xpt7/D1xXpMuNe/0om46kZt+4017TSJ4 busSN3suCW+A3GyjGS8dNmGBZWQ+kp5F1/uunWR1iSBYt8zWvZ7jwEVnXFKaXJWzSyK3 nfz4FsjYAxVAhvZCeNXTGrVeMjaNA7GDDg4dX2GTF3B5SSrKSdQjr3LwZJn0jEte0fvi HGp0CYQ1WTxDjhptbICENzGg2FX93T+IiX5xsvX8pnum8A0MaE9TGPoCQRfSAxZBtcno P4iUS7pmWtdmvl2lNjP+IDNVlrSKsm5aLkLTmfUbczqvGv5qfKCW3QbnypbRgX9XQB7L sv6w== X-Gm-Message-State: AOAM5323RqJhiRZXrllObHmmjFbRfPwevF9huW36xNYDWFYQBZ8jUCuY 4J8i1dREDYAGVYhhQ3+q9BaSCQ== X-Google-Smtp-Source: ABdhPJxfHCj0VhB1q85OqR3pcVQs6lqkmK+oRcNLc/XsqRlCQywRkuJy4gbI1paKAUY6+nl0NdCxnQ== X-Received: by 2002:a17:902:650b:b0:137:3940:ec24 with SMTP id b11-20020a170902650b00b001373940ec24mr4569727plk.36.1630615410089; Thu, 02 Sep 2021 13:43:30 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id i14sm3024750pfd.112.2021.09.02.13.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 13:43:29 -0700 (PDT) Date: Thu, 2 Sep 2021 20:43:25 +0000 From: Sean Christopherson To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org Subject: Re: [PATCH V2] KVM: X86: Move PTE present check from loop body to __shadow_walk_next() Message-ID: References: <20210813031629.78670-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210813031629.78670-1-jiangshanlai@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 13, 2021, Lai Jiangshan wrote: > From: Lai Jiangshan > > So far, the loop bodies already ensure the PTE is present before calling > __shadow_walk_next(): Some loop bodies simply exit with a !PRESENT > directly and some other loop bodies, i.e. FNAME(fetch) and __direct_map() > do not currently terminate their walks with a !PRESENT, but they get away > with it because they install present non-leaf SPTEs in the loop itself. > > But checking pte present in __shadow_walk_next() is a more prudent way of > programing and loop bodies will not need to always check it. It allows us > removing unneded is_shadow_present_pte() in the loop bodies. ^^^^^^^ unneeded > > Terminating on !is_shadow_present_pte() is 100% the correct behavior, as > walking past a !PRESENT SPTE would lead to attempting to read a the next > level SPTE from a garbage iter->shadow_addr. Even some paths that do _not_ > currently have a !is_shadow_present_pte() in the loop body is Ok since > they will install present non-leaf SPTEs and the additinal present check ^^^^^^^^^ additional > is just an NOP. > > The checking result in __shadow_walk_next() will be propagated to > shadow_walk_okay() for being used in any for(;;) loop. > > Signed-off-by: Lai Jiangshan > --- Nits aside, Reviewed-by: Sean Christopherson