Re: [PATCH] vmx/nested: Set the SGX feature flag only when hardware supported.

From: kernel test robot

Date: Sun Mar 29 2026 - 04:31:29 EST


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.16-rc1 next-20260327]
[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/18341265598-163-com/vmx-nested-Set-the-SGX-feature-flag-only-when-hardware-supported/20260329-093645
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/1774322860-25106-1-git-send-email-18341265598%40163.com
patch subject: [PATCH] vmx/nested: Set the SGX feature flag only when hardware supported.
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260329/202603291021.Yc83e9lC-lkp@xxxxxxxxx/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260329/202603291021.Yc83e9lC-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/202603291021.Yc83e9lC-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from arch/x86/kvm/kvm-asm-offsets.c:10:
>> arch/x86/kvm/vmx/vmx.h:347:13: warning: 'cpu_has_sgx' defined but not used [-Wunused-function]
347 | static bool cpu_has_sgx(void)
| ^~~~~~~~~~~


vim +/cpu_has_sgx +347 arch/x86/kvm/vmx/vmx.h

340
341 /*
342 * There is no X86_FEATURE for SGX yet, but anyway we need to query CPUID
343 * directly instead of going through cpu_has(), to ensure KVM is trapping
344 * ENCLS whenever it's supported in hardware. It does not matter whether
345 * the host OS supports or has enabled SGX.
346 */
> 347 static bool cpu_has_sgx(void)
348 {
349 return cpuid_eax(0) >= 0x12 && (cpuid_eax(0x12) & BIT(0));
350 }
351

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