lkml.org 
[lkml]   [2022]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v3 11/28] KVM: x86/mmu: WARN if old _or_ new SPTE is REMOVED in non-atomic path
    From
    WARN if the new_spte being set by __tdp_mmu_set_spte() is a REMOVED_SPTE,
    which is called out by the comment as being disallowed but not actually
    checked. Keep the WARN on the old_spte as well, because overwriting a
    REMOVED_SPTE in the non-atomic path is also disallowed (as evidence by
    lack of splats with the existing WARN).

    Fixes: 08f07c800e9d ("KVM: x86/mmu: Flush TLBs after zap in TDP MMU PF handler")
    Cc: Ben Gardon <bgardon@google.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Reviewed-by: Ben Gardon <bgardon@google.com>
    ---
    arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
    index 8fbf3364f116..1dcdf1a4fcc1 100644
    --- a/arch/x86/kvm/mmu/tdp_mmu.c
    +++ b/arch/x86/kvm/mmu/tdp_mmu.c
    @@ -640,13 +640,13 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter,
    lockdep_assert_held_write(&kvm->mmu_lock);

    /*
    - * No thread should be using this function to set SPTEs to the
    + * No thread should be using this function to set SPTEs to or from the
    * temporary removed SPTE value.
    * If operating under the MMU lock in read mode, tdp_mmu_set_spte_atomic
    * should be used. If operating under the MMU lock in write mode, the
    * use of the removed SPTE should not be necessary.
    */
    - WARN_ON(is_removed_spte(iter->old_spte));
    + WARN_ON(is_removed_spte(iter->old_spte) || is_removed_spte(new_spte));

    kvm_tdp_mmu_write_spte(iter->sptep, new_spte);

    --
    2.35.1.574.g5d30c73bfb-goog
    \
     
     \ /
      Last update: 2022-02-26 01:18    [W:4.088 / U:0.620 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site