lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202510211010.XRaEeuBa-lkp@intel.com>
Date: Tue, 21 Oct 2025 10:38:33 +0800
From: kernel test robot <lkp@...el.com>
To: fangyu.yu@...ux.alibaba.com, anup@...infault.org, atish.patra@...ux.dev,
	pjw@...nel.org, palmer@...belt.com, aou@...s.berkeley.edu,
	alex@...ti.fr, pbonzini@...hat.com, jiangyifei@...wei.com
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev, guoren@...nel.org,
	kvm@...r.kernel.org, kvm-riscv@...ts.infradead.org,
	linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Fangyu Yu <fangyu.yu@...ux.alibaba.com>
Subject: Re: [PATCH] RISC-V: KVM: Remove automatic I/O mapping for VM_PFNMAP

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kvm/queue]
[also build test WARNING on kvm/next linus/master v6.18-rc2 next-20251020]
[cannot apply to kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/fangyu-yu-linux-alibaba-com/RISC-V-KVM-Remove-automatic-I-O-mapping-for-VM_PFNMAP/20251020-210957
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/20251020130801.68356-1-fangyu.yu%40linux.alibaba.com
patch subject: [PATCH] RISC-V: KVM: Remove automatic I/O mapping for VM_PFNMAP
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20251021/202510211010.XRaEeuBa-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 754ebc6ebb9fb9fbee7aef33478c74ea74949853)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251021/202510211010.XRaEeuBa-lkp@intel.com/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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510211010.XRaEeuBa-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/riscv/kvm/mmu.c:211:9: warning: variable 'vm_start' set but not used [-Wunused-but-set-variable]
     211 |                 hva_t vm_start, vm_end;
         |                       ^
>> arch/riscv/kvm/mmu.c:174:8: warning: variable 'base_gpa' set but not used [-Wunused-but-set-variable]
     174 |         gpa_t base_gpa;
         |               ^
   2 warnings generated.


vim +/vm_start +211 arch/riscv/kvm/mmu.c

99cdc6c18c2d815 Anup Patel          2021-09-27  167  
99cdc6c18c2d815 Anup Patel          2021-09-27  168  int kvm_arch_prepare_memory_region(struct kvm *kvm,
537a17b31493009 Sean Christopherson 2021-12-06  169  				const struct kvm_memory_slot *old,
537a17b31493009 Sean Christopherson 2021-12-06  170  				struct kvm_memory_slot *new,
99cdc6c18c2d815 Anup Patel          2021-09-27  171  				enum kvm_mr_change change)
99cdc6c18c2d815 Anup Patel          2021-09-27  172  {
d01495d4cffb327 Sean Christopherson 2021-12-06  173  	hva_t hva, reg_end, size;
d01495d4cffb327 Sean Christopherson 2021-12-06 @174  	gpa_t base_gpa;
d01495d4cffb327 Sean Christopherson 2021-12-06  175  	bool writable;
9d05c1fee837572 Anup Patel          2021-09-27  176  	int ret = 0;
9d05c1fee837572 Anup Patel          2021-09-27  177  
9d05c1fee837572 Anup Patel          2021-09-27  178  	if (change != KVM_MR_CREATE && change != KVM_MR_MOVE &&
9d05c1fee837572 Anup Patel          2021-09-27  179  			change != KVM_MR_FLAGS_ONLY)
99cdc6c18c2d815 Anup Patel          2021-09-27  180  		return 0;
9d05c1fee837572 Anup Patel          2021-09-27  181  
9d05c1fee837572 Anup Patel          2021-09-27  182  	/*
9d05c1fee837572 Anup Patel          2021-09-27  183  	 * Prevent userspace from creating a memory region outside of the GPA
9d05c1fee837572 Anup Patel          2021-09-27  184  	 * space addressable by the KVM guest GPA space.
9d05c1fee837572 Anup Patel          2021-09-27  185  	 */
537a17b31493009 Sean Christopherson 2021-12-06  186  	if ((new->base_gfn + new->npages) >=
dd82e35638d67f4 Anup Patel          2025-06-18  187  	    (kvm_riscv_gstage_gpa_size >> PAGE_SHIFT))
9d05c1fee837572 Anup Patel          2021-09-27  188  		return -EFAULT;
9d05c1fee837572 Anup Patel          2021-09-27  189  
d01495d4cffb327 Sean Christopherson 2021-12-06  190  	hva = new->userspace_addr;
d01495d4cffb327 Sean Christopherson 2021-12-06  191  	size = new->npages << PAGE_SHIFT;
d01495d4cffb327 Sean Christopherson 2021-12-06  192  	reg_end = hva + size;
d01495d4cffb327 Sean Christopherson 2021-12-06  193  	base_gpa = new->base_gfn << PAGE_SHIFT;
d01495d4cffb327 Sean Christopherson 2021-12-06  194  	writable = !(new->flags & KVM_MEM_READONLY);
d01495d4cffb327 Sean Christopherson 2021-12-06  195  
9d05c1fee837572 Anup Patel          2021-09-27  196  	mmap_read_lock(current->mm);
9d05c1fee837572 Anup Patel          2021-09-27  197  
9d05c1fee837572 Anup Patel          2021-09-27  198  	/*
9d05c1fee837572 Anup Patel          2021-09-27  199  	 * A memory region could potentially cover multiple VMAs, and
b35152e0fb35983 Fangyu Yu           2025-10-20  200  	 * any holes between them, so iterate over all of them.
9d05c1fee837572 Anup Patel          2021-09-27  201  	 *
9d05c1fee837572 Anup Patel          2021-09-27  202  	 *     +--------------------------------------------+
9d05c1fee837572 Anup Patel          2021-09-27  203  	 * +---------------+----------------+   +----------------+
9d05c1fee837572 Anup Patel          2021-09-27  204  	 * |   : VMA 1     |      VMA 2     |   |    VMA 3  :    |
9d05c1fee837572 Anup Patel          2021-09-27  205  	 * +---------------+----------------+   +----------------+
9d05c1fee837572 Anup Patel          2021-09-27  206  	 *     |               memory region                |
9d05c1fee837572 Anup Patel          2021-09-27  207  	 *     +--------------------------------------------+
9d05c1fee837572 Anup Patel          2021-09-27  208  	 */
9d05c1fee837572 Anup Patel          2021-09-27  209  	do {
fce11b667022766 Quan Zhou           2025-06-17  210  		struct vm_area_struct *vma;
9d05c1fee837572 Anup Patel          2021-09-27 @211  		hva_t vm_start, vm_end;
9d05c1fee837572 Anup Patel          2021-09-27  212  
fce11b667022766 Quan Zhou           2025-06-17  213  		vma = find_vma_intersection(current->mm, hva, reg_end);
fce11b667022766 Quan Zhou           2025-06-17  214  		if (!vma)
9d05c1fee837572 Anup Patel          2021-09-27  215  			break;
9d05c1fee837572 Anup Patel          2021-09-27  216  
9d05c1fee837572 Anup Patel          2021-09-27  217  		/*
9d05c1fee837572 Anup Patel          2021-09-27  218  		 * Mapping a read-only VMA is only allowed if the
9d05c1fee837572 Anup Patel          2021-09-27  219  		 * memory region is configured as read-only.
9d05c1fee837572 Anup Patel          2021-09-27  220  		 */
9d05c1fee837572 Anup Patel          2021-09-27  221  		if (writable && !(vma->vm_flags & VM_WRITE)) {
9d05c1fee837572 Anup Patel          2021-09-27  222  			ret = -EPERM;
9d05c1fee837572 Anup Patel          2021-09-27  223  			break;
9d05c1fee837572 Anup Patel          2021-09-27  224  		}
9d05c1fee837572 Anup Patel          2021-09-27  225  
9d05c1fee837572 Anup Patel          2021-09-27  226  		/* Take the intersection of this VMA with the memory region */
9d05c1fee837572 Anup Patel          2021-09-27  227  		vm_start = max(hva, vma->vm_start);
9d05c1fee837572 Anup Patel          2021-09-27  228  		vm_end = min(reg_end, vma->vm_end);
9d05c1fee837572 Anup Patel          2021-09-27  229  
9d05c1fee837572 Anup Patel          2021-09-27  230  		if (vma->vm_flags & VM_PFNMAP) {
9d05c1fee837572 Anup Patel          2021-09-27  231  			/* IO region dirty page logging not allowed */
537a17b31493009 Sean Christopherson 2021-12-06  232  			if (new->flags & KVM_MEM_LOG_DIRTY_PAGES) {
9d05c1fee837572 Anup Patel          2021-09-27  233  				ret = -EINVAL;
9d05c1fee837572 Anup Patel          2021-09-27  234  				goto out;
9d05c1fee837572 Anup Patel          2021-09-27  235  			}
9d05c1fee837572 Anup Patel          2021-09-27  236  		}
9d05c1fee837572 Anup Patel          2021-09-27  237  		hva = vm_end;
9d05c1fee837572 Anup Patel          2021-09-27  238  	} while (hva < reg_end);
9d05c1fee837572 Anup Patel          2021-09-27  239  
9d05c1fee837572 Anup Patel          2021-09-27  240  out:
9d05c1fee837572 Anup Patel          2021-09-27  241  	mmap_read_unlock(current->mm);
9d05c1fee837572 Anup Patel          2021-09-27  242  	return ret;
99cdc6c18c2d815 Anup Patel          2021-09-27  243  }
99cdc6c18c2d815 Anup Patel          2021-09-27  244  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ