On Sat, 2024-10-12 at 16:09 +0800, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-coco-queue > head: d2c7662a6ea1c325a9ae878b3f1a265264bcd18b > commit: b6bcd88ad43aebc2385c7ff418b0532e80e60e19 [62/109] KVM: x86/tdp_mmu: Propagate building mirror page tables > config: x86_64-randconfig-121-20241011 (https://download.01.org/0day-ci/archive/20241012/202410121644.Eq7zRGPO-lkp@xxxxxxxxx/config) > compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241012/202410121644.Eq7zRGPO-lkp@xxxxxxxxx/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > > Reported-by: kernel test robot <lkp@xxxxxxxxx> > > Closes: https://lore.kernel.org/oe-kbuild-all/202410121644.Eq7zRGPO-lkp@xxxxxxxxx/ > > sparse warnings: (new ones prefixed by >>) > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile *v @@ got unsigned long long [noderef] [usertype] __rcu *__ai_ptr @@ > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: expected void const volatile *v > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: got unsigned long long [noderef] [usertype] __rcu *__ai_ptr > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: cast removes address space '__rcu' of expression > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: cast removes address space '__rcu' of expression > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: cast removes address space '__rcu' of expression > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: cast removes address space '__rcu' of expression > > > arch/x86/kvm/mmu/tdp_mmu.c:754:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:754:29: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:754:29: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > arch/x86/kvm/mmu/tdp_mmu.c:1246:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[addressable] [usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:1246:25: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:1246:25: sparse: got unsigned long long [noderef] [usertype] __rcu *[addressable] [usertype] sptep > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: dereference of noderef expression > > > arch/x86/kvm/mmu/tdp_mmu.c:474:14: sparse: sparse: dereference of noderef expression > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > 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:869:25: sparse: sparse: context imbalance in '__tdp_mmu_zap_root' - unexpected unlock > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > arch/x86/kvm/mmu/tdp_mmu.c:1536:33: sparse: sparse: context imbalance in 'tdp_mmu_split_huge_pages_root' - unexpected unlock > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected unsigned long long [usertype] *sptep @@ got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep @@ > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: expected unsigned long long [usertype] *sptep > arch/x86/kvm/mmu/tdp_mmu.c:618:33: sparse: got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep I think we need something like the below. The first hunk needs to target: 70caac283fb30 KVM: x86/mmu: Add an is_mirror member for union kvm_mmu_page_role and the second: 161d4f7c6d80e KVM: x86/tdp_mmu: Propagate building mirror page tables Should we send some proper fixup patches? diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h index a72f0e3bde173..5d30d59bedfc0 100644 --- a/arch/x86/kvm/mmu/spte.h +++ b/arch/x86/kvm/mmu/spte.h @@ -267,9 +267,9 @@ static inline struct kvm_mmu_page *root_to_sp(hpa_t root) return spte_to_child_sp(root); } -static inline bool is_mirror_sptep(u64 *sptep) +static inline bool is_mirror_sptep(tdp_ptep_t sptep) { - return is_mirror_sp(sptep_to_sp(sptep)); + return is_mirror_sp(sptep_to_sp(rcu_dereference((sptep)))); } static inline bool is_mmio_spte(struct kvm *kvm, u64 spte) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 019b43723d901..76512e05e31f2 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -511,7 +511,7 @@ static int __must_check set_external_spte_present(struct kvm *kvm, tdp_ptep_t sp * page table has been modified. Use FROZEN_SPTE similar to * the zapping case. */ - if (!try_cmpxchg64(sptep, &old_spte, FROZEN_SPTE)) + if (!try_cmpxchg64(rcu_dereference(sptep), &old_spte, FROZEN_SPTE)) return -EBUSY; /*