lkml.org 
[lkml]   [2021]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH V2] KVM: X86: Move PTE present check from loop body to __shadow_walk_next()
    On Fri, Aug 13, 2021, Lai Jiangshan wrote:
    > From: Lai Jiangshan <laijs@linux.alibaba.com>
    >
    > 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 <laijs@linux.alibaba.com>
    > ---

    Nits aside,

    Reviewed-by: Sean Christopherson <seanjc@google.com>

    \
     
     \ /
      Last update: 2021-09-02 22:43    [W:2.571 / U:0.368 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site