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

From: kernel test robot
Date: Tue Aug 09 2022 - 15:18:59 EST


tree: https://github.com/intel/tdx.git kvm-upstream-workaround
head: 6e62680f6e4094d3986229a4145ebd54390dc110
commit: 18114293527217d8d0ccbe394b003089166a35c5 [627/846] KVM: x86/tdp_mmu: implement MapGPA hypercall for TDX
config: i386-randconfig-a001-20220808 (https://download.01.org/0day-ci/archive/20220810/202208100315.2ORxWmgi-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/18114293527217d8d0ccbe394b003089166a35c5
git remote add intel-tdx https://github.com/intel/tdx.git
git fetch --no-tags intel-tdx kvm-upstream-workaround
git checkout 18114293527217d8d0ccbe394b003089166a35c5
# 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/kvm/ virt/

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

Note: the intel-tdx/kvm-upstream-workaround HEAD 6e62680f6e4094d3986229a4145ebd54390dc110 builds fine.
It only hurts bisectability.

All errors (new ones prefixed by >>):

arch/x86/kvm/mmu/mmu.c: In function 'kvm_mmu_zap_collapsible_spte':
arch/x86/kvm/mmu/mmu.c:6603:19: warning: variable 'pfn' set but not used [-Wunused-but-set-variable]
6603 | kvm_pfn_t pfn;
| ^~~
arch/x86/kvm/mmu/mmu.c: In function 'kvm_mmu_map_gpa':
>> arch/x86/kvm/mmu/mmu.c:6775:30: error: 'KVM_MEM_ATTR_PRIVATE' undeclared (first use in this function)
6775 | attr = map_private ? KVM_MEM_ATTR_PRIVATE : KVM_MEM_ATTR_SHARED;
| ^~~~~~~~~~~~~~~~~~~~
arch/x86/kvm/mmu/mmu.c:6775:30: note: each undeclared identifier is reported only once for each function it appears in
>> arch/x86/kvm/mmu/mmu.c:6775:53: error: 'KVM_MEM_ATTR_SHARED' undeclared (first use in this function)
6775 | attr = map_private ? KVM_MEM_ATTR_PRIVATE : KVM_MEM_ATTR_SHARED;
| ^~~~~~~~~~~~~~~~~~~


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

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

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