]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xen: rework xen_pv_domain()
authorJuergen Gross <jgross@suse.com>
Tue, 26 Aug 2025 14:56:06 +0000 (16:56 +0200)
committerJuergen Gross <jgross@suse.com>
Mon, 8 Sep 2025 15:01:36 +0000 (17:01 +0200)
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>

arch/x86/xen/enlighten_pv.c
include/xen/xen.h

index 26bbaf4b7330b4981e59467e9b05192b56b04d70..4806cc28d7ca77558f1bc79bf4f3661400806d24 100644 (file)
@@ -382,7 +382,6 @@ static bool __init xen_check_xsave(void)
 
 static void __init xen_init_capabilities(void)
 {
-       setup_force_cpu_cap(X86_FEATURE_XENPV);
        setup_clear_cpu_cap(X86_FEATURE_DCA);
        setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
        setup_clear_cpu_cap(X86_FEATURE_MTRR);
@@ -1402,6 +1401,7 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
                        JMP32_INSN_SIZE);
 
        xen_domain_type = XEN_PV_DOMAIN;
+       setup_force_cpu_cap(X86_FEATURE_XENPV);
        xen_start_flags = xen_start_info->flags;
        /* Interrupts are guaranteed to be off initially. */
        early_boot_irqs_disabled = true;
index a1e5b3f18d69f9d75ca5cc44bbbe462b54200907..61854e3f283776b9e323b64b3d8d298330ae32cd 100644 (file)
@@ -22,8 +22,15 @@ extern bool xen_pvh;
 #define xen_pvh                        0
 #endif
 
+#ifdef CONFIG_X86
+#include <asm/cpufeature.h>
+
+#define xen_pv_domain()                (cpu_feature_enabled(X86_FEATURE_XENPV))
+#else
+#define xen_pv_domain()                0
+#endif
+
 #define xen_domain()           (xen_domain_type != XEN_NATIVE)
-#define xen_pv_domain()                (xen_domain_type == XEN_PV_DOMAIN)
 #define xen_hvm_domain()       (xen_domain_type == XEN_HVM_DOMAIN)
 #define xen_pvh_domain()       (xen_pvh)