Skip to content

Commit 34c605f

Browse files
committed
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>
1 parent 76eeb9b commit 34c605f

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

arch/x86/xen/enlighten_pv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ static bool __init xen_check_xsave(void)
382382

383383
static void __init xen_init_capabilities(void)
384384
{
385-
setup_force_cpu_cap(X86_FEATURE_XENPV);
386385
setup_clear_cpu_cap(X86_FEATURE_DCA);
387386
setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
388387
setup_clear_cpu_cap(X86_FEATURE_MTRR);
@@ -1402,6 +1401,7 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
14021401
JMP32_INSN_SIZE);
14031402

14041403
xen_domain_type = XEN_PV_DOMAIN;
1404+
setup_force_cpu_cap(X86_FEATURE_XENPV);
14051405
xen_start_flags = xen_start_info->flags;
14061406
/* Interrupts are guaranteed to be off initially. */
14071407
early_boot_irqs_disabled = true;

include/xen/xen.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ extern bool xen_pvh;
2222
#define xen_pvh 0
2323
#endif
2424

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+
2533
#define xen_domain() (xen_domain_type != XEN_NATIVE)
26-
#define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN)
2734
#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)
2835
#define xen_pvh_domain() (xen_pvh)
2936

0 commit comments

Comments
 (0)