[intel-tdx:kvm-upstream-workaround 627/846] arch/x86/kvm/mmu/mmu.c:6776:30: error: 'KVM_MEM_ATTR_PRIVATE' undeclared

From: kernel test robot
Date: Mon Aug 08 2022 - 04:24:24 EST


tree: https://github.com/intel/tdx.git kvm-upstream-workaround
head: d2f4a2362378fcfa26297befc778815836aecd3b
commit: 1293aaf4ce16f80dc4bf9cd943d399183f0d4d7d [627/846] KVM: x86/tdp_mmu: implement MapGPA hypercall for TDX
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220808/202208081628.vWneWyoS-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel/tdx/commit/1293aaf4ce16f80dc4bf9cd943d399183f0d4d7d
git remote add intel-tdx https://github.com/intel/tdx.git
git fetch --no-tags intel-tdx kvm-upstream-workaround
git checkout 1293aaf4ce16f80dc4bf9cd943d399183f0d4d7d
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

arch/x86/kvm/mmu/mmu.c: In function 'mmu_topup_shadow_page_cache':
arch/x86/kvm/mmu/mmu.c:696:53: error: incompatible type for argument 1 of 'kvm_mmu_topup_memory_cache'
696 | return kvm_mmu_topup_memory_cache(vcpu->arch.mmu_shadow_page_cache,
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
| |
| struct kvm_mmu_memory_cache
In file included from arch/x86/kvm/irq.h:15,
from arch/x86/kvm/mmu/mmu.c:18:
include/linux/kvm_host.h:1369:61: note: expected 'struct kvm_mmu_memory_cache *' but argument is of type 'struct kvm_mmu_memory_cache'
1369 | int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
arch/x86/kvm/mmu/mmu.c: In function 'kvm_faultin_pfn':
arch/x86/kvm/mmu/mmu.c:4234:14: error: implicit declaration of function 'kvm_mem_is_private'; did you mean 'kvm_gpa_private'? [-Werror=implicit-function-declaration]
4234 | (kvm_mem_is_private(vcpu->kvm, fault->gfn) != fault->is_private))
| ^~~~~~~~~~~~~~~~~~
| kvm_gpa_private
arch/x86/kvm/mmu/mmu.c: In function 'kvm_mmu_zap_collapsible_spte':
arch/x86/kvm/mmu/mmu.c:6604:19: warning: variable 'pfn' set but not used [-Wunused-but-set-variable]
6604 | kvm_pfn_t pfn;
| ^~~
arch/x86/kvm/mmu/mmu.c: In function 'kvm_mmu_map_gpa':
>> arch/x86/kvm/mmu/mmu.c:6776:30: error: 'KVM_MEM_ATTR_PRIVATE' undeclared (first use in this function)
6776 | attr = map_private ? KVM_MEM_ATTR_PRIVATE : KVM_MEM_ATTR_SHARED;
| ^~~~~~~~~~~~~~~~~~~~
arch/x86/kvm/mmu/mmu.c:6776:30: note: each undeclared identifier is reported only once for each function it appears in
>> arch/x86/kvm/mmu/mmu.c:6776:53: error: 'KVM_MEM_ATTR_SHARED' undeclared (first use in this function)
6776 | attr = map_private ? KVM_MEM_ATTR_PRIVATE : KVM_MEM_ATTR_SHARED;
| ^~~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/mmu/mmu.c:6784:15: error: implicit declaration of function 'kvm_vm_reserve_mem_attr' [-Werror=implicit-function-declaration]
6784 | ret = kvm_vm_reserve_mem_attr(kvm, start, end);
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/include/asm/bug.h:87,
from include/linux/bug.h:5,
from include/linux/cpumask.h:14,
from include/linux/mm_types_task.h:14,
from include/linux/mm_types.h:5,
from arch/x86/kvm/irq.h:13,
from arch/x86/kvm/mmu/mmu.c:18:
>> arch/x86/kvm/mmu/mmu.c:6794:33: error: implicit declaration of function 'kvm_vm_set_mem_attr' [-Werror=implicit-function-declaration]
6794 | WARN_ON(kvm_vm_set_mem_attr(kvm, attr, start, end));
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/bug.h:122:32: note: in definition of macro 'WARN_ON'
122 | int __ret_warn_on = !!(condition); \
| ^~~~~~~~~
arch/x86/kvm/mmu/mmu.c: In function 'mmu_topup_shadow_page_cache':
arch/x86/kvm/mmu/mmu.c:698:1: error: control reaches end of non-void function [-Werror=return-type]
698 | }
| ^
cc1: some warnings being treated as errors


vim +/KVM_MEM_ATTR_PRIVATE +6776 arch/x86/kvm/mmu/mmu.c

6763
6764 int kvm_mmu_map_gpa(struct kvm_vcpu *vcpu, gfn_t *startp, gfn_t end,
6765 bool map_private)
6766 {
6767 struct kvm *kvm = vcpu->kvm;
6768 gfn_t start = *startp;
6769 int attr;
6770 int ret;
6771
6772
6773 if (!kvm_gfn_shared_mask(kvm))
6774 return -EOPNOTSUPP;
6775
> 6776 attr = map_private ? KVM_MEM_ATTR_PRIVATE : KVM_MEM_ATTR_SHARED;
6777 start = start & ~kvm_gfn_shared_mask(kvm);
6778 end = end & ~kvm_gfn_shared_mask(kvm);
6779
6780 /*
6781 * To make the following kvm_vm_set_mem_attr() success within spinlock
6782 * without memory allocation.
6783 */
> 6784 ret = kvm_vm_reserve_mem_attr(kvm, start, end);
6785 if (ret)
6786 return ret;
6787
6788 write_lock(&kvm->mmu_lock);
6789 if (is_tdp_mmu_enabled(kvm)) {
6790 gfn_t s = start;
6791
6792 ret = kvm_tdp_mmu_map_gpa(vcpu, &s, end, map_private);
6793 if (!ret) {
> 6794 WARN_ON(kvm_vm_set_mem_attr(kvm, attr, start, end));
6795 } else if (ret == -EAGAIN) {
6796 WARN_ON(kvm_vm_set_mem_attr(kvm, attr, start, s));
6797 start = s;
6798 }
6799 } else {
6800 ret = -EOPNOTSUPP;
6801 }
6802 write_unlock(&kvm->mmu_lock);
6803
6804 if (ret == -EAGAIN) {
6805 if (map_private)
6806 *startp = kvm_gfn_private(kvm, start);
6807 else
6808 *startp = kvm_gfn_shared(kvm, start);
6809 }
6810 return ret;
6811 }
6812 EXPORT_SYMBOL_GPL(kvm_mmu_map_gpa);
6813

--
0-DAY CI Kernel Test Service
https://01.org/lkp