Re: [PATCH v5 42/43] arm64: kvm: Expose support for private memory

From: kernel test robot
Date: Wed Oct 09 2024 - 03:03:55 EST


Hi Steven,

kernel test robot noticed the following build warnings:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on linus/master v6.12-rc2 next-20241008]
[cannot apply to kvmarm/next kvm/queue 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/Steven-Price/KVM-Prepare-for-handling-only-shared-mappings-in-mmu_notifier-events/20241005-000420
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20241004152804.72508-43-steven.price%40arm.com
patch subject: [PATCH v5 42/43] arm64: kvm: Expose support for private memory
config: arm64-randconfig-r121-20241008 (https://download.01.org/0day-ci/archive/20241009/202410091403.EUd787Qt-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20241009/202410091403.EUd787Qt-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/202410091403.EUd787Qt-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:563:18: sparse: sparse: incompatible types in comparison expression (different address spaces):
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:563:18: sparse: struct file *
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:563:18: sparse: struct file [noderef] __rcu *
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:130:17: sparse: sparse: context imbalance in 'kvm_gmem_invalidate_begin' - different lock contexts for basic block
>> arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct file **f @@ got struct file [noderef] __rcu ** @@
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: expected struct file **f
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: got struct file [noderef] __rcu **
>> arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct file **f @@ got struct file [noderef] __rcu ** @@
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: expected struct file **f
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: got struct file [noderef] __rcu **
>> arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct file **f @@ got struct file [noderef] __rcu ** @@
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: expected struct file **f
arch/arm64/kvm/../../../virt/kvm/guest_memfd.c:302:33: sparse: got struct file [noderef] __rcu **

vim +563 arch/arm64/kvm/../../../virt/kvm/guest_memfd.c

a7800aa80ea4d5 Sean Christopherson 2023-11-13 552
78c4293372fe1f Paolo Bonzini 2024-07-11 553 /* Returns a locked folio on success. */
d0d87226f53596 Paolo Bonzini 2024-07-11 554 static struct folio *
d0d87226f53596 Paolo Bonzini 2024-07-11 555 __kvm_gmem_get_pfn(struct file *file, struct kvm_memory_slot *slot,
66a644c09fbed0 Paolo Bonzini 2024-07-26 556 gfn_t gfn, kvm_pfn_t *pfn, bool *is_prepared,
66a644c09fbed0 Paolo Bonzini 2024-07-26 557 int *max_order)
a7800aa80ea4d5 Sean Christopherson 2023-11-13 558 {
a7800aa80ea4d5 Sean Christopherson 2023-11-13 559 pgoff_t index = gfn - slot->base_gfn + slot->gmem.pgoff;
17573fd971f9e3 Paolo Bonzini 2024-04-04 560 struct kvm_gmem *gmem = file->private_data;
a7800aa80ea4d5 Sean Christopherson 2023-11-13 561 struct folio *folio;
a7800aa80ea4d5 Sean Christopherson 2023-11-13 562
17573fd971f9e3 Paolo Bonzini 2024-04-04 @563 if (file != slot->gmem.file) {
17573fd971f9e3 Paolo Bonzini 2024-04-04 564 WARN_ON_ONCE(slot->gmem.file);
d0d87226f53596 Paolo Bonzini 2024-07-11 565 return ERR_PTR(-EFAULT);
17573fd971f9e3 Paolo Bonzini 2024-04-04 566 }
a7800aa80ea4d5 Sean Christopherson 2023-11-13 567
a7800aa80ea4d5 Sean Christopherson 2023-11-13 568 gmem = file->private_data;
fa30b0dc91c815 Paolo Bonzini 2024-04-04 569 if (xa_load(&gmem->bindings, index) != slot) {
fa30b0dc91c815 Paolo Bonzini 2024-04-04 570 WARN_ON_ONCE(xa_load(&gmem->bindings, index));
d0d87226f53596 Paolo Bonzini 2024-07-11 571 return ERR_PTR(-EIO);
a7800aa80ea4d5 Sean Christopherson 2023-11-13 572 }
a7800aa80ea4d5 Sean Christopherson 2023-11-13 573
b85524314a3db6 Paolo Bonzini 2024-07-11 574 folio = kvm_gmem_get_folio(file_inode(file), index);
17573fd971f9e3 Paolo Bonzini 2024-04-04 575 if (IS_ERR(folio))
d0d87226f53596 Paolo Bonzini 2024-07-11 576 return folio;
a7800aa80ea4d5 Sean Christopherson 2023-11-13 577
a7800aa80ea4d5 Sean Christopherson 2023-11-13 578 if (folio_test_hwpoison(folio)) {
c31745d2c50879 Paolo Bonzini 2024-06-11 579 folio_unlock(folio);
c31745d2c50879 Paolo Bonzini 2024-06-11 580 folio_put(folio);
d0d87226f53596 Paolo Bonzini 2024-07-11 581 return ERR_PTR(-EHWPOISON);
a7800aa80ea4d5 Sean Christopherson 2023-11-13 582 }
a7800aa80ea4d5 Sean Christopherson 2023-11-13 583
7fbdda31b0a14f Paolo Bonzini 2024-07-11 584 *pfn = folio_file_pfn(folio, index);
a7800aa80ea4d5 Sean Christopherson 2023-11-13 585 if (max_order)
a7800aa80ea4d5 Sean Christopherson 2023-11-13 586 *max_order = 0;
a7800aa80ea4d5 Sean Christopherson 2023-11-13 587
66a644c09fbed0 Paolo Bonzini 2024-07-26 588 *is_prepared = folio_test_uptodate(folio);
d0d87226f53596 Paolo Bonzini 2024-07-11 589 return folio;
a7800aa80ea4d5 Sean Christopherson 2023-11-13 590 }
17573fd971f9e3 Paolo Bonzini 2024-04-04 591

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