[intel-tdx:kvm-upstream-workaround 149/296] arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'

From: kernel test robot
Date: Tue Mar 15 2022 - 18:38:57 EST


tree: https://github.com/intel/tdx.git kvm-upstream-workaround
head: 97612c5f3be3447870b5d6fd476931a4c5ff280f
commit: 540e161d6f1b1e4ca7535ef11258660947ae7b00 [149/296] KVM: TDX: Add placeholders for TDX VM/vcpu structure
config: x86_64-randconfig-a015 (https://download.01.org/0day-ci/archive/20220316/202203160607.2mVzGlMC-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
reproduce (this is a W=1 build):
# https://github.com/intel/tdx/commit/540e161d6f1b1e4ca7535ef11258660947ae7b00
git remote add intel-tdx https://github.com/intel/tdx.git
git fetch --no-tags intel-tdx kvm-upstream-workaround
git checkout 540e161d6f1b1e4ca7535ef11258660947ae7b00
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

In file included from include/linux/kernel.h:26,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
arch/x86/kvm/vmx/main.c: In function 'vt_init':
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/minmax.h:20:39: note: in definition of macro '__typecheck'
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
In file included from include/linux/align.h:5,
from include/linux/kernel.h:15,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/const.h:12:48: note: in definition of macro '__is_constexpr'
12 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
| ^
include/linux/minmax.h:26:25: note: in expansion of macro '__no_side_effects'
26 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
In file included from include/linux/kernel.h:26,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/minmax.h:28:34: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/minmax.h:28:46: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/minmax.h:32:10: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:175:58: error: invalid application of 'sizeof' to incomplete type 'struct kvm_tdx'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~~~~
include/linux/minmax.h:32:25: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
>> include/linux/minmax.h:36:2: error: first argument to '__builtin_choose_expr' not a constant
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:175:23: note: in expansion of macro 'max'
175 | vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:20:39: note: in definition of macro '__typecheck'
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
In file included from include/linux/align.h:5,
from include/linux/kernel.h:15,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/const.h:12:48: note: in definition of macro '__is_constexpr'
12 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
| ^
include/linux/minmax.h:26:25: note: in expansion of macro '__no_side_effects'
26 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
In file included from include/linux/kernel.h:26,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:28:34: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:28:46: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:32:10: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:176:50: error: invalid application of 'sizeof' to incomplete type 'struct vcpu_tdx'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:32:25: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
>> include/linux/minmax.h:36:2: error: first argument to '__builtin_choose_expr' not a constant
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:176:14: note: in expansion of macro 'max'
176 | vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
| ^~~
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:20:39: note: in definition of macro '__typecheck'
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
In file included from include/linux/align.h:5,
from include/linux/kernel.h:15,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/const.h:12:48: note: in definition of macro '__is_constexpr'
12 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
| ^
include/linux/minmax.h:26:25: note: in expansion of macro '__no_side_effects'
26 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: in expansion of macro '__safe_cmp'
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
In file included from include/linux/kernel.h:26,
from include/linux/moduleparam.h:7,
from arch/x86/kvm/vmx/main.c:2:
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:28:34: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:28:46: note: in definition of macro '__cmp'
28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:32:10: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
>> arch/x86/kvm/vmx/main.c:178:16: error: invalid application of '__alignof__' to incomplete type 'struct vcpu_tdx'
178 | __alignof__(struct vcpu_tdx));
| ^~~~~~
include/linux/minmax.h:32:25: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~
include/linux/minmax.h:36:2: error: first argument to '__builtin_choose_expr' not a constant
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:52:19: note: in expansion of macro '__careful_cmp'
52 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
arch/x86/kvm/vmx/main.c:177:15: note: in expansion of macro 'max'
177 | vcpu_align = max(__alignof__(struct vcpu_vmx),
| ^~~


vim +175 arch/x86/kvm/vmx/main.c

169
170 static int __init vt_init(void)
171 {
172 unsigned int vcpu_size, vcpu_align;
173 int r;
174
> 175 vt_x86_ops.vm_size = max(sizeof(struct kvm_vmx), sizeof(struct kvm_tdx));
> 176 vcpu_size = max(sizeof(struct vcpu_vmx), sizeof(struct vcpu_tdx));
177 vcpu_align = max(__alignof__(struct vcpu_vmx),
> 178 __alignof__(struct vcpu_tdx));
179
180 hv_vp_assist_page_init();
181
182 r = kvm_init(&vt_init_ops, vcpu_size, vcpu_align, THIS_MODULE);
183 if (r)
184 goto err_vmx_post_exit;
185
186 r = vmx_init();
187 if (r)
188 goto err_kvm_exit;
189
190 return 0;
191
192 err_kvm_exit:
193 kvm_exit();
194 err_vmx_post_exit:
195 hv_vp_assist_page_exit();
196 return r;
197 }
198 module_init(vt_init);
199

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx