[Devel] [VZ10 05/21] x86/cpuid_fault: Make it compile with !CONFIG_VE

Vasileios Almpanis vasileios.almpanis at virtuozzo.com
Fri May 15 14:15:28 MSK 2026


On 5/7/26 9:10 PM, Vladimir Riabchun wrote:
> arch/x86/kernel/cpuid_fault.c:275:52: error: 'proc_vz_dir' undeclared
>    275 |         proc = proc_create("cpuid_override", 0644, proc_vz_dir,
>        |                                                    ^~~~~~~~~~~
>
> We have no proc_vz_dir without CONFIG_VE. For minimal logic change
> covel all the code in cpuid_fault.c except do_cpuid_fault
cover
> with #ifdef CONFIG_VE.
>
> When CONFIG_VE is disabled, the behavior will be as if
> cpuid_override list is empty.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-130116
>
> Feature: !CONFIG_VE build
> Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
> ---
>   arch/x86/kernel/cpuid_fault.c | 63 ++++++++++++++++++++++-------------
>   1 file changed, 39 insertions(+), 24 deletions(-)
>
> diff --git a/arch/x86/kernel/cpuid_fault.c b/arch/x86/kernel/cpuid_fault.c
> index 117c971f531a..b8c65363625f 100644
> --- a/arch/x86/kernel/cpuid_fault.c
> +++ b/arch/x86/kernel/cpuid_fault.c
> @@ -20,6 +20,44 @@
>   #include <asm/uaccess.h>
>   #include <asm/traps.h>
>   
> +#ifndef CONFIG_VE
> +static bool cpuid_override_match(unsigned int op, unsigned int count,
> +				 unsigned int *eax, unsigned int *ebx,
> +				 unsigned int *ecx, unsigned int *edx)
> +{
> +	return false;
> +}
> +#else
> +static bool cpuid_override_match(unsigned int op, unsigned int count,
> +				 unsigned int *eax, unsigned int *ebx,
> +				 unsigned int *ecx, unsigned int *edx);
> +#endif
> +
> +void __do_cpuid_fault(unsigned int op, unsigned int count,
> +		      unsigned int *eax, unsigned int *ebx,
> +		      unsigned int *ecx, unsigned int *edx)
> +{
> +	/* check if op is overridden */
> +	if (cpuid_override_match(op, count, eax, ebx, ecx, edx))
> +		return;
> +
> +	/* fallback to real cpuid */
> +	cpuid_count(op, count, eax, ebx, ecx, edx);
> +}
> +
> +void do_cpuid_fault(struct pt_regs *regs)
> +{
> +	unsigned int eax, ebx, ecx, edx;
> +
> +	__do_cpuid_fault(regs->ax, regs->cx, &eax, &ebx, &ecx, &edx);
> +
> +	regs->ax = eax;
> +	regs->bx = ebx;
> +	regs->cx = ecx;
> +	regs->dx = edx;
> +}
> +
> +#ifdef CONFIG_VE
>   struct cpuid_override_table __rcu *cpuid_override __read_mostly;
>   static DEFINE_SPINLOCK(cpuid_override_lock);
>   
> @@ -99,30 +137,6 @@ static bool cpuid_override_match(unsigned int op, unsigned int count,
>   	return ret;
>   }
>   
> -void __do_cpuid_fault(unsigned int op, unsigned int count,
> -		      unsigned int *eax, unsigned int *ebx,
> -		      unsigned int *ecx, unsigned int *edx)
> -{
> -	/* check if op is overridden */
> -	if (cpuid_override_match(op, count, eax, ebx, ecx, edx))
> -		return;
> -
> -	/* fallback to real cpuid */
> -	cpuid_count(op, count, eax, ebx, ecx, edx);
> -}
> -
> -void do_cpuid_fault(struct pt_regs *regs)
> -{
> -	unsigned int eax, ebx, ecx, edx;
> -
> -	__do_cpuid_fault(regs->ax, regs->cx, &eax, &ebx, &ecx, &edx);
> -
> -	regs->ax = eax;
> -	regs->bx = ebx;
> -	regs->cx = ecx;
> -	regs->dx = edx;
> -}
> -
>   /*
>    * CPUID override entry format:
>    *
> @@ -281,3 +295,4 @@ static int __init cpuid_fault_init(void)
>   	return 0;
>   }
>   module_init(cpuid_fault_init);
> +#endif /* CONFIG_VE */

-- 
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.



More information about the Devel mailing list