From: Vipin Sharma <vipinsh@google.com>
To: kernel test robot <lkp@intel.com>
Cc: seanjc@google.com, pbonzini@redhat.com,
oe-kbuild-all@lists.linux.dev, dmatlack@google.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86/mmu: Recover NX Huge pages belonging to TDP MMU under MMU read lock
Date: Thu, 15 Aug 2024 09:42:44 -0700 [thread overview]
Message-ID: <20240815164244.GA132028.vipinsh@google.com> (raw)
In-Reply-To: <202408150646.VV4z8Znl-lkp@intel.com>
On 2024-08-15 06:50:04, kernel test robot wrote:
> sparse warnings: (new ones prefixed by >>)
> >> arch/x86/kvm/mmu/tdp_mmu.c:847:21: sparse: sparse: incompatible types in comparison expression (different address spaces):
> arch/x86/kvm/mmu/tdp_mmu.c:847:21: sparse: unsigned long long [usertype] *
> arch/x86/kvm/mmu/tdp_mmu.c:847:21: sparse: unsigned long long [noderef] [usertype] __rcu *
> arch/x86/kvm/mmu/tdp_mmu.c: note: in included file (through include/linux/rbtree.h, include/linux/mm_types.h, include/linux/mmzone.h, ...):
> include/linux/rcupdate.h:812:25: sparse: sparse: context imbalance in '__tdp_mmu_zap_root' - unexpected unlock
> arch/x86/kvm/mmu/tdp_mmu.c:1447:33: sparse: sparse: context imbalance in 'tdp_mmu_split_huge_pages_root' - unexpected unlock
>
> vim +847 arch/x86/kvm/mmu/tdp_mmu.c
>
> 819
> 820 static bool tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
> 821 {
> 822 struct tdp_iter iter = {};
> 823
> 824 lockdep_assert_held_read(&kvm->mmu_lock);
> 825
> 826 /*
> 827 * This helper intentionally doesn't allow zapping a root shadow page,
> 828 * which doesn't have a parent page table and thus no associated entry.
> 829 */
> 830 if (WARN_ON_ONCE(!sp->ptep))
> 831 return false;
> 832
> 833 iter.old_spte = kvm_tdp_mmu_read_spte(sp->ptep);
> 834 iter.sptep = sp->ptep;
> 835 iter.level = sp->role.level + 1;
> 836 iter.gfn = sp->gfn;
> 837 iter.as_id = kvm_mmu_page_as_id(sp);
> 838
> 839 retry:
> 840 /*
> 841 * Since mmu_lock is held in read mode, it's possible to race with
> 842 * another CPU which can remove sp from the page table hierarchy.
> 843 *
> 844 * No need to re-read iter.old_spte as tdp_mmu_set_spte_atomic() will
> 845 * update it in the case of failure.
> 846 */
> > 847 if (sp->spt != spte_to_child_pt(iter.old_spte, iter.level))
Hmm, I need to wrap spte_to_child_pt() with rcu_access_pointer() before
comparing it to sp->spt. Following patch makes this Sparse error go
away.
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 7c7d207ee590..7d5dbfe48c4b 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -820,6 +820,7 @@ static void tdp_mmu_zap_root(struct kvm *kvm, struct kvm_mmu_page *root,
static bool tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
{
struct tdp_iter iter = {};
+ tdp_ptep_t pt;
lockdep_assert_held_read(&kvm->mmu_lock);
@@ -844,7 +845,8 @@ static bool tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
* No need to re-read iter.old_spte as tdp_mmu_set_spte_atomic() will
* update it in the case of failure.
*/
- if (sp->spt != spte_to_child_pt(iter.old_spte, iter.level))
+ pt = spte_to_child_pt(iter.old_spte, iter.level);
+ if (sp->spt != rcu_access_pointer(pt))
return false;
if (tdp_mmu_set_spte_atomic(kvm, &iter, SHADOW_NONPRESENT_VALUE))
next prev parent reply other threads:[~2024-08-15 16:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 17:13 [PATCH 0/2] KVM: x86/mmu: Run NX huge page recovery " Vipin Sharma
2024-08-12 17:13 ` [PATCH 1/2] KVM: x86/mmu: Split NX hugepage recovery flow into TDP and non-TDP flow Vipin Sharma
2024-08-16 23:29 ` Sean Christopherson
2024-08-19 17:20 ` Vipin Sharma
2024-08-19 17:28 ` David Matlack
2024-08-19 18:31 ` Sean Christopherson
2024-08-19 21:57 ` Vipin Sharma
2024-08-12 17:13 ` [PATCH 2/2] KVM: x86/mmu: Recover NX Huge pages belonging to TDP MMU under MMU read lock Vipin Sharma
2024-08-14 9:33 ` kernel test robot
2024-08-14 18:23 ` Vipin Sharma
2024-08-14 22:50 ` kernel test robot
2024-08-15 16:42 ` Vipin Sharma [this message]
2024-08-16 23:38 ` Sean Christopherson
2024-08-19 17:34 ` Vipin Sharma
2024-08-19 22:12 ` Sean Christopherson
2024-08-23 22:38 ` Vipin Sharma
2024-08-26 14:34 ` Sean Christopherson
2024-08-26 19:24 ` Vipin Sharma
2024-08-26 19:51 ` Sean Christopherson
2024-08-19 22:19 ` Sean Christopherson
2024-08-23 19:27 ` Vipin Sharma
2024-08-23 20:45 ` Sean Christopherson
2024-08-23 21:41 ` Vipin Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240815164244.GA132028.vipinsh@google.com \
--to=vipinsh@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome