Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: rework xen_pv_domain()

Rework xen_pv_domain() to no longer use the xen_domain_type variable,
but the artificial X86_FEATURE_XENPV cpu feature.

On non-x86 architectures xen_pv_domain() can be defined as "0".

This has the advantage that a kernel not built with CONFIG_XEN_PV
will be smaller due to dead code elimination.

Set the X86_FEATURE_XENPV feature very early, as xen_pv_domain() is
used rather early, too.

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20250826145608.10352-2-jgross@suse.com>

+9 -2
+1 -1
arch/x86/xen/enlighten_pv.c
··· 382 382 383 383 static void __init xen_init_capabilities(void) 384 384 { 385 - setup_force_cpu_cap(X86_FEATURE_XENPV); 386 385 setup_clear_cpu_cap(X86_FEATURE_DCA); 387 386 setup_clear_cpu_cap(X86_FEATURE_APERFMPERF); 388 387 setup_clear_cpu_cap(X86_FEATURE_MTRR); ··· 1401 1402 JMP32_INSN_SIZE); 1402 1403 1403 1404 xen_domain_type = XEN_PV_DOMAIN; 1405 + setup_force_cpu_cap(X86_FEATURE_XENPV); 1404 1406 xen_start_flags = xen_start_info->flags; 1405 1407 /* Interrupts are guaranteed to be off initially. */ 1406 1408 early_boot_irqs_disabled = true;
+8 -1
include/xen/xen.h
··· 22 22 #define xen_pvh 0 23 23 #endif 24 24 25 + #ifdef CONFIG_X86 26 + #include <asm/cpufeature.h> 27 + 28 + #define xen_pv_domain() (cpu_feature_enabled(X86_FEATURE_XENPV)) 29 + #else 30 + #define xen_pv_domain() 0 31 + #endif 32 + 25 33 #define xen_domain() (xen_domain_type != XEN_NATIVE) 26 - #define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN) 27 34 #define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN) 28 35 #define xen_pvh_domain() (xen_pvh) 29 36