[avpatel:riscv_trace_support_v5 17/108] arch/riscv/kvm/mmu.c:147:3-9: preceding lock on line 143

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
TO: Wang Yechao <[email protected]>
CC: Anup Patel <[email protected]>

tree:   https://github.com/avpatel/linux.git riscv_trace_support_v5
head:   d5f1be8d8fd44129a93976f98cc0153408015030
commit: da870fdafa8adf6f6287dbbdd2c3b3181655965e [17/108] RISC-V: KVM: Split huge pages when dirty logging is enabled
:::::: branch date: 76 minutes ago
:::::: commit date: 12 days ago
config: riscv-randconfig-r063-20260813 (https://download.01.org/0day-ci/archive/20260813/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 6ea395e4fe4db26920d57779ddae98eac6ba945d)

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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)
>> arch/riscv/kvm/mmu.c:147:3-9: preceding lock on line 143

vim +147 arch/riscv/kvm/mmu.c

da870fdafa8adf Wang Yechao 2026-07-31  111  
da870fdafa8adf Wang Yechao 2026-07-31  112  static bool mmu_split_huge_pages(struct kvm_gstage *gstage,
da870fdafa8adf Wang Yechao 2026-07-31  113  				 phys_addr_t start, phys_addr_t end)
da870fdafa8adf Wang Yechao 2026-07-31  114  {
da870fdafa8adf Wang Yechao 2026-07-31  115  	struct kvm *kvm = gstage->kvm;
da870fdafa8adf Wang Yechao 2026-07-31  116  	struct kvm_mmu_memory_cache *pcache = &kvm->arch.pgd_split_page_cache;
da870fdafa8adf Wang Yechao 2026-07-31  117  	phys_addr_t addr = ALIGN_DOWN(start, PMD_SIZE);
da870fdafa8adf Wang Yechao 2026-07-31  118  	phys_addr_t last_flush_gfn = addr >> PAGE_SHIFT;
da870fdafa8adf Wang Yechao 2026-07-31  119  	int count = gstage->pgd_levels;
da870fdafa8adf Wang Yechao 2026-07-31  120  	bool flush = false;
da870fdafa8adf Wang Yechao 2026-07-31  121  	int ret;
da870fdafa8adf Wang Yechao 2026-07-31  122  
da870fdafa8adf Wang Yechao 2026-07-31  123  	lockdep_assert_held_write(&kvm->mmu_lock);
da870fdafa8adf Wang Yechao 2026-07-31  124  
da870fdafa8adf Wang Yechao 2026-07-31  125  	while (addr < end) {
da870fdafa8adf Wang Yechao 2026-07-31  126  		if (need_topup_split_caches_or_resched(kvm, count)) {
da870fdafa8adf Wang Yechao 2026-07-31  127  			if (flush) {
da870fdafa8adf Wang Yechao 2026-07-31  128  				kvm_flush_remote_tlbs_range(kvm, last_flush_gfn,
da870fdafa8adf Wang Yechao 2026-07-31  129  					  (addr >> PAGE_SHIFT) - last_flush_gfn);
da870fdafa8adf Wang Yechao 2026-07-31  130  				last_flush_gfn = addr >> PAGE_SHIFT;
da870fdafa8adf Wang Yechao 2026-07-31  131  				flush = false;
da870fdafa8adf Wang Yechao 2026-07-31  132  			}
da870fdafa8adf Wang Yechao 2026-07-31  133  
da870fdafa8adf Wang Yechao 2026-07-31  134  			write_unlock(&kvm->mmu_lock);
da870fdafa8adf Wang Yechao 2026-07-31  135  			cond_resched();
da870fdafa8adf Wang Yechao 2026-07-31  136  
da870fdafa8adf Wang Yechao 2026-07-31  137  			ret = kvm_mmu_topup_memory_cache(pcache, count);
da870fdafa8adf Wang Yechao 2026-07-31  138  			if (ret) {
da870fdafa8adf Wang Yechao 2026-07-31  139  				kvm_err("Failed to toup split page cache\n");
da870fdafa8adf Wang Yechao 2026-07-31  140  				write_lock(&kvm->mmu_lock);
da870fdafa8adf Wang Yechao 2026-07-31  141  				return flush;
da870fdafa8adf Wang Yechao 2026-07-31  142  			}
da870fdafa8adf Wang Yechao 2026-07-31 @143  			write_lock(&kvm->mmu_lock);
da870fdafa8adf Wang Yechao 2026-07-31  144  		}
da870fdafa8adf Wang Yechao 2026-07-31  145  
da870fdafa8adf Wang Yechao 2026-07-31  146  		if (!kvm->arch.pgd)
da870fdafa8adf Wang Yechao 2026-07-31 @147  			return flush;
da870fdafa8adf Wang Yechao 2026-07-31  148  
da870fdafa8adf Wang Yechao 2026-07-31  149  		flush |= kvm_riscv_gstage_split_huge(gstage, pcache, addr, 0, false);
da870fdafa8adf Wang Yechao 2026-07-31  150  
da870fdafa8adf Wang Yechao 2026-07-31  151  		addr += PMD_SIZE;
da870fdafa8adf Wang Yechao 2026-07-31  152  	}
da870fdafa8adf Wang Yechao 2026-07-31  153  
da870fdafa8adf Wang Yechao 2026-07-31  154  	return flush;
da870fdafa8adf Wang Yechao 2026-07-31  155  }
da870fdafa8adf Wang Yechao 2026-07-31  156  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.