x86/CPU: optional build of Intel/AMD CPUs support
cover x86/CPU: optional build of Intel/AMD CPUs support
This series is one more step towards separation of Intel/AMD support in Xen. With all preparation work is mostly done now, it becomes possible to make build of arch/x86/cpu/{amd.c,intel.c} files optional, depending on whether CONFIG_{AMD,INTEL} are enabled or not.
This can be useful for builds tuned for specific platform -- by reducing dead code that won't ever be executed on that platform anyway.
Note: this series (namely its Intel part) depends on optional PSR support patch:
https://lore.kernel.org/xen-devel/[email protected]/
-Sergiy
Sergiy Kibrik (2):
x86/intel: optional build of intel.c
x86/amd: optional build of amd.c
xen/arch/x86/cpu/Makefile | 10 +++++----- xen/arch/x86/cpu/common.c | 8 ++++++-- xen/arch/x86/include/asm/amd.h | 22 ++++++++++++++++++++++ xen/arch/x86/include/asm/processor.h | 7 ++++--- xen/arch/x86/spec_ctrl.c | 2 ++ 5 files changed, 39 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 x86/intel: optional build of intel.c
With specific config option INTEL in place and most of the code that depends on intel.c now can be optionally enabled/disabled it's now possible to put the whole intel.c under INTEL option as well. This will allow for a Xen build without Intel CPU support.
--- xen/arch/x86/cpu/Makefile | 6 +++--- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/include/asm/processor.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-)
xen/arch/x86/cpu/Makefile +3 -3
@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o -obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.o obj-y += vpmu.o obj-$(CONFIG_AMD) += vpmu_amd.o obj-$(CONFIG_INTEL) += vpmu_intel.o
xen/arch/x86/cpu/common.c +3 -1
@@ -336,11 +336,13 @@ void __init early_cpu_init(bool verbose) c->x86_vendor =x86_cpuid_lookup_vendor (ebx, ecx, edx);switch (c->x86_vendor) { +#ifdef CONFIG_INTEL case X86_VENDOR_INTEL :intel_unlock_cpuid_leaves (c); actual_cpu = intel_cpu_dev;break ; +case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ; +#endif case X86_VENDOR_AMD : actual_cpu = amd_cpu_dev;break ;case X86_VENDOR_CENTAUR : actual_cpu = centaur_cpu_dev;break ; -case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ;case X86_VENDOR_HYGON : actual_cpu = hygon_cpu_dev;break ;default : actual_cpu = default_cpu;
xen/arch/x86/include/asm/processor.h +4 -3
@@ -507,15 +507,16 @@ static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,extern int8_t opt_tsx;extern bool rtm_disabled;void tsx_init (void ); +void update_mcu_opt_ctrl (void ); +void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val);#else #define opt_tsx 0/* explicitly indicate TSX is off */ #define rtm_disabled false/* RTM was not force-disabled */ static inline void tsx_init (void ) {} +static inline void update_mcu_opt_ctrl (void ) {} +static inline void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val) {}#endif -void update_mcu_opt_ctrl (void ); -void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val); -enum ap_boot_method {AP_BOOT_NORMAL ,AP_BOOT_SKINIT ,
Signature · 1 line
2.25.1
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
Quoted 17 lines · Sergiy Kibrik
With specific config option INTEL in place and most of the code that depends on
intel.cnow can be optionally enabled/disabled it's now possible to put the wholeintel.cunder INTEL option as well. This will allow for a Xen build without Intel CPU support.Signed-off-by Sergiy Kibrik <[email protected]>--- xen/arch/x86/cpu/Makefile | 6 +++--- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/include/asm/processor.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-)xen/arch/x86/cpu/Makefile +0
-0
xen/arch/x86/cpu/Makefile obj-y += amd.o · line 12
Quoted 10 lines
xen/arch/x86/cpu/Makefile +3
-3@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o -obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.o
Why pick this one too? It's based on VIA IP, aiui.
Quoted 36 lines
xen/arch/x86/cpu/Makefile +0
-0obj-y += vpmu.o obj-$(CONFIG_AMD) += vpmu_amd.o obj-$(CONFIG_INTEL) += vpmu_intel.oxen/arch/x86/cpu/common.c +3
-1@@ -336,11 +336,13 @@ void __init early_cpu_init(bool verbose) c->x86_vendor =x86_cpuid_lookup_vendor (ebx, ecx, edx);switch (c->x86_vendor) { +#ifdef CONFIG_INTEL case X86_VENDOR_INTEL :intel_unlock_cpuid_leaves (c); actual_cpu = intel_cpu_dev;break ; +case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ; +#endif case X86_VENDOR_AMD : actual_cpu = amd_cpu_dev;break ;case X86_VENDOR_CENTAUR : actual_cpu = centaur_cpu_dev;break ; -case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ;case X86_VENDOR_HYGON : actual_cpu = hygon_cpu_dev;break ;default : actual_cpu = default_cpu;xen/arch/x86/include/asm/processor.h +2
-0@@ -507,15 +507,16 @@ static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,extern int8_t opt_tsx;extern bool rtm_disabled;void tsx_init (void ); +void update_mcu_opt_ctrl (void ); +void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val);#else #define opt_tsx 0/* explicitly indicate TSX is off */ #define rtm_disabled false/* RTM was not force-disabled */ static inline void tsx_init (void ) {}
xen/arch/x86/include/asm/processor.h static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model, · line 522
Quoted 10 lines
xen/arch/x86/include/asm/processor.h +2
-3+static inline void update_mcu_opt_ctrl (void ) {} +static inline void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val) {}#endif -void update_mcu_opt_ctrl (void ); -void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val); -enum ap_boot_method {AP_BOOT_NORMAL ,AP_BOOT_SKINIT ,
Cheers,
Alejandro
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
09.08.24 13:36, Alejandro Vallejo:
Quoted 22 lines · Sergiy Kibrik
Quoted 21 lines
With specific config option INTEL in place and most of the code that depends on
intel.cnow can be optionally enabled/disabled it's now possible to put the wholeintel.cunder INTEL option as well. This will allow for a Xen build without Intel CPU support.Signed-off-by Sergiy Kibrik <[email protected]>--- xen/arch/x86/cpu/Makefile | 6 +++--- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/include/asm/processor.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-)xen/arch/x86/cpu/Makefile +0
-1@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o
Quoted 8 lines
xen/arch/x86/cpu/Makefile obj-y += amd.o · line 12
Quoted 6 lines
xen/arch/x86/cpu/Makefile +3
-2-obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.oWhy pick this one too? It's based on VIA IP, aiui.
shanghai.c and intel.c both use init_intel_cacheinfo() routine, so there's build dependency on Intel code.
-Sergiy
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
Quoted 18 lines · Sergiy Kibrik
09.08.24 13:36, Alejandro Vallejo:
Quoted 8 lines · Sergiy Kibrik
Quoted 7 lines
xen/arch/x86/cpu/Makefile +0
-1@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.oQuoted 8 lines
xen/arch/x86/cpu/Makefile obj-y += amd.o · line 12
Quoted 6 lines
xen/arch/x86/cpu/Makefile +3
-2-obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.oWhy pick this one too? It's based on VIA IP, aiui.
Quoted 2 lines
shanghai.candintel.cboth useinit_intel_cacheinfo()routine, so there's build dependency on Intel code.
Yet Shanghai isn't as directly a clone of Intel CPUs as Hygon ones are for AMD. So at the very least you want to justify your choice in the description. After all there's also the alternative of having a separate SHANGHAI Kconfig setting, which would merely have "select INTEL" or "depends on INTEL".
Jan
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
Quoted 19 lines · Jan Beulich
Quoted 18 lines · Sergiy Kibrik
09.08.24 13:36, Alejandro Vallejo:
Quoted 16 lines · Sergiy Kibrik
xen/arch/x86/cpu/Makefile obj-y += amd.o · line 12
Quoted 13 lines
xen/arch/x86/cpu/Makefile +3
-3@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o -obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.oWhy pick this one too? It's based on VIA IP, aiui.
Quoted 2 lines
Quoted 2 lines
shanghai.candintel.cboth useinit_intel_cacheinfo()routine, so there's build dependency on Intel code.
My point is that the use of Intel functions on Shanghai and not Centaur is accidental. If shanghai goes under Intel so should Centaur (imo).
Quoted 8 lines
Yet Shanghai isn't as directly a clone of Intel CPUs as Hygon ones are for AMD. So at the very least you want to justify your choice in the description. After all there's also the alternative of having a separate SHANGHAI
Kconfigsetting, which would merely have "select INTEL" or "depends on INTEL".Jan
That's one option, another is for the Kconfig options to explicitly state which vendors they apply to. I'd be fine with either. It's less fine for CONFIG_INTEL to cover a VIA derivative and not the other.
Cheers,
Alejandro
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
12.08.24 15:24, Alejandro Vallejo:
Quoted 33 lines · Jan Beulich
Quoted 19 lines · Sergiy Kibrik
Quoted 18 lines
09.08.24 13:36, Alejandro Vallejo:
Quoted 16 lines · Sergiy Kibrik
xen/arch/x86/cpu/Makefile obj-y += amd.o · line 12
Quoted 13 lines
xen/arch/x86/cpu/Makefile +3
-3@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o -obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.oWhy pick this one too? It's based on VIA IP, aiui.
Quoted 2 lines
Quoted 2 lines
shanghai.candintel.cboth useinit_intel_cacheinfo()routine, so there's build dependency on Intel code.My point is that the use of Intel functions on Shanghai and not Centaur is accidental. If shanghai goes under Intel so should Centaur (imo).
Quoted 7 lines
Yet Shanghai isn't as directly a clone of Intel CPUs as Hygon ones are for AMD. So at the very least you want to justify your choice in the description. After all there's also the alternative of having a separate SHANGHAI
Kconfigsetting, which would merely have "select INTEL" or "depends on INTEL".
Quoted 6 lines
Quoted 1 line
Jan
That's one option, another is for the
Kconfigoptions to explicitly state which vendors they apply to. I'd be fine with either. It's less fine forCONFIG_INTELto cover a VIA derivative and not the other.
I think I'll go with separate kconfig options -- for Centaur, Shanghai & Hygon, as we already got a separate submenu for CPUs & everything. Also this way it's more up to the task of config tuning.
Thanks for clarification!
-Sergiy
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
In reply to Sergiy KibrikQuoted 59 lines · Sergiy Kibrik
With specific config option INTEL in place and most of the code that depends on
intel.cnow can be optionally enabled/disabled it's now possible to put the wholeintel.cunder INTEL option as well. This will allow for a Xen build without Intel CPU support.Signed-off-by Sergiy Kibrik <[email protected]>--- xen/arch/x86/cpu/Makefile | 6 +++--- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/include/asm/processor.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-)xen/arch/x86/cpu/Makefile +3
-3@@ -6,10 +6,10 @@ obj-y += amd.o obj-y += centaur.o obj-y += common.o obj-y += hygon.o -obj-y += intel.o -obj-y += intel_cacheinfo.o +obj-$(CONFIG_INTEL) += intel.o +obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o -obj-y += shanghai.o +obj-$(CONFIG_INTEL) += shanghai.o obj-y += vpmu.o obj-$(CONFIG_AMD) += vpmu_amd.o obj-$(CONFIG_INTEL) += vpmu_intel.oxen/arch/x86/cpu/common.c +3
-1@@ -336,11 +336,13 @@ void __init early_cpu_init(bool verbose) c->x86_vendor =x86_cpuid_lookup_vendor (ebx, ecx, edx);switch (c->x86_vendor) { +#ifdef CONFIG_INTEL case X86_VENDOR_INTEL :intel_unlock_cpuid_leaves (c); actual_cpu = intel_cpu_dev;break ; +case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ; +#endif case X86_VENDOR_AMD : actual_cpu = amd_cpu_dev;break ;case X86_VENDOR_CENTAUR : actual_cpu = centaur_cpu_dev;break ; -case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ;case X86_VENDOR_HYGON : actual_cpu = hygon_cpu_dev;break ;default : actual_cpu = default_cpu;xen/arch/x86/include/asm/processor.h +2
-0@@ -507,15 +507,16 @@ static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,extern int8_t opt_tsx;extern bool rtm_disabled;void tsx_init (void ); +void update_mcu_opt_ctrl (void ); +void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val);
xen/arch/x86/include/asm/processor.h static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model, · line 517
Quoted 10 lines
xen/arch/x86/include/asm/processor.h +2
-2#else #define opt_tsx 0/* explicitly indicate TSX is off */ #define rtm_disabled false/* RTM was not force-disabled */ static inline void tsx_init (void ) {} +static inline void update_mcu_opt_ctrl (void ) {} +static inline void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val) {}#endif -void update_mcu_opt_ctrl (void ); -void set_in_mcu_opt_ctrl (uint32_t mask,uint32_t val);
I'm okay-ish with the simple stubbing out for update_mcu_opt_ctrl(), but set_in_mcu_opt_ctrl() imo requires more work. The call sites in spec_ctrl.c shouldn't give the wrong impression of having some effect. Imo in init_speculation_mitigations() an #endif wants to move down, while all of gds_calculations() wants to be compiled out. And that likely extends to further Intel-only functions there (with an early bail-out keyed to boot_cpu_data.x86_vendor != X86_VENDOR_INTEL). Which overall likely means there wants to be another separate patch dealing with that. (And then maybe a counterpart one for AMD.)
Jan
Re: [XEN PATCH v1 1/2] x86/intel: optional build of intel.c
13.08.24 10:40, Jan Beulich:
Quoted 9 lines
I'm okay-ish with the simple stubbing out for
update_mcu_opt_ctrl(), butset_in_mcu_opt_ctrl()imo requires more work. The call sites inspec_ctrl.cshouldn't give the wrong impression of having some effect. Imo ininit_speculation_mitigations()an #endif wants to move down, while all ofgds_calculations()wants to be compiled out. And that likely extends to further Intel-only functions there (with an early bail-out keyed to boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL). Which overall likely means there wants to be another separate patch dealing with that. (And then maybe a counterpart one for AMD.)
Thanks for a suggestion, indeed there are many routines there that can be put under CONFIG_{AMD,INTEL}.
-Sergiy
PATCH 2/2 x86/amd: optional build of amd.c
In reply to Sergiy KibrikSimilar to making Intel CPU support optional -- as we've got CONFIG_AMD option now, we can put arch/x86/cpu/amd.c under it and make it possible to build Xen without AMD CPU support. One possible use case is to dispose of dead code in Intel-only systems.
--- xen/arch/x86/cpu/Makefile | 4 ++-- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/include/asm/amd.h | 22 ++++++++++++++++++++++ xen/arch/x86/spec_ctrl.c | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-)
xen/arch/x86/cpu/Makefile +2 -2
@@ -2,10 +2,10 @@ obj-y += mcheck/ obj-y += microcode/ obj-y += mtrr/ -obj-y += amd.o +obj-$(CONFIG_AMD) += amd.o obj-y += centaur.o obj-y += common.o -obj-y += hygon.o +obj-$(CONFIG_AMD) += hygon.o obj-$(CONFIG_INTEL) += intel.o obj-$(CONFIG_INTEL) += intel_cacheinfo.o obj-y += mwait-idle.o
xen/arch/x86/cpu/common.c +3 -1
@@ -341,9 +341,11 @@ void __init early_cpu_init(bool verbose) actual_cpu = intel_cpu_dev;break ;case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ;#endif +#ifdef CONFIG_AMD case X86_VENDOR_AMD : actual_cpu = amd_cpu_dev;break ; -case X86_VENDOR_CENTAUR : actual_cpu = centaur_cpu_dev;break ;case X86_VENDOR_HYGON : actual_cpu = hygon_cpu_dev;break ; +#endif +case X86_VENDOR_CENTAUR : actual_cpu = centaur_cpu_dev;break ;default : actual_cpu = default_cpu;if (!verbose)
xen/arch/x86/include/asm/amd.h +22 -0
@@ -158,13 +158,21 @@#define is_zen4_uarch () boot_cpu_has(X86_FEATURE_AUTO_IBRS)struct cpuinfo_x86 ; +#ifdef CONFIG_AMD int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...); +#else +static inline int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...) +{ +return false; +} +#endif extern s8 opt_allow_unsafe;void fam10h_check_enable_mmcfg (void );void check_enable_amd_mmconf_dmi (void ); +#ifdef CONFIG_AMD extern bool amd_acpi_c1e_quirk;void amd_check_disable_c1e (unsigned int port,u8 value);
@@ -173,5 +181,19 @@ extern bool amd_virt_spec_ctrl;bool amd_setup_legacy_ssbd (void );void amd_set_legacy_ssbd (bool enable);void amd_set_cpuid_user_dis (bool enable); +#else +static inline void amd_set_cpuid_user_dis (bool enable) {} +static inline void amd_set_legacy_ssbd (bool enable) {} +static inline bool amd_setup_legacy_ssbd (void ) +{ +return false; +} + +#define amd_acpi_c1e_quirk (false) +#define amd_virt_spec_ctrl (false) +#define amd_legacy_ssbd (false) + +static inline void amd_check_disable_c1e (unsigned int port,u8 value) {} +#endif #endif /* __AMD_H__ */
xen/arch/x86/spec_ctrl.c +2 -0
@@ -1884,10 +1884,12 @@ void __init init_speculation_mitigations(void)setup_force_cpu_cap (X86_FEATURE_SC_MSR_HVM ); } +#ifdef CONFIG_AMD /* Support VIRT_SPEC_CTRL.SSBD if AMD_SSBD is not available. */ if ( opt_msr_sc_hvm && !cpu_has_amd_ssbd && (cpu_has_virt_ssbd || (amd_legacy_ssbd &&amd_setup_legacy_ssbd ())) ) amd_virt_spec_ctrl = true; +#endif /* Figure out default_xen_spec_ctrl. */ if ( has_spec_ctrl && ibrs )
Signature · 1 line
2.25.1
Re: [XEN PATCH v1 2/2] x86/amd: optional build of amd.c
xen/arch/x86/include/asm/amd.h line 164
Quoted 10 lines · Sergiy Kibrik
xen/arch/x86/include/asm/amd.h +3
-0@@ -158,13 +158,21 @@#define is_zen4_uarch () boot_cpu_has(X86_FEATURE_AUTO_IBRS)struct cpuinfo_x86 ; +#ifdef CONFIG_AMD int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...); +#else +static inline int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...)
Nit: Too long line.
xen/arch/x86/include/asm/amd.h line 166
Quoted 2 lines
xen/arch/x86/include/asm/amd.h +2
-0+{ +return false;
I wouldn't mind if you consistently changed the function to return bool, but as long as it returns int I don't think it should be returning false.
xen/arch/x86/include/asm/amd.h extern bool amd_virt_spec_ctrl; · line 190
Quoted 11 lines
xen/arch/x86/include/asm/amd.h +7
-0@@ -173,5 +181,19 @@ extern bool amd_virt_spec_ctrl;bool amd_setup_legacy_ssbd (void );void amd_set_legacy_ssbd (bool enable);void amd_set_cpuid_user_dis (bool enable); +#else +static inline void amd_set_cpuid_user_dis (bool enable) {} +static inline void amd_set_legacy_ssbd (bool enable) {} +static inline bool amd_setup_legacy_ssbd (void ) +{ +return false; +}
Nit: Would be a little nicer if these were in the same order as their corresponding declarations. However, along the lines of one of my comments on the Intel counterpart patch ...
xen/arch/x86/include/asm/amd.h extern bool amd_virt_spec_ctrl; · line 197
Quoted 6 lines
xen/arch/x86/include/asm/amd.h +6
-0+#define amd_acpi_c1e_quirk (false) +#define amd_virt_spec_ctrl (false) +#define amd_legacy_ssbd (false) + +static inline void amd_check_disable_c1e (unsigned int port,u8 value) {} +#endif
... question overall is how many of these stubs are really required, once clearly AMD-only code is properly taken care of (perhaps not just in spec_ctrl.c).
Jan
Re: [XEN PATCH v1 2/2] x86/amd: optional build of amd.c
13.08.24 10:50, Jan Beulich:
Quoted 14 lines · Sergiy Kibrik
xen/arch/x86/include/asm/amd.h line 164
Quoted 10 lines
xen/arch/x86/include/asm/amd.h +3
-0@@ -158,13 +158,21 @@#define is_zen4_uarch () boot_cpu_has(X86_FEATURE_AUTO_IBRS)struct cpuinfo_x86 ; +#ifdef CONFIG_AMD int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...); +#else +static inline int cpu_has_amd_erratum (const struct cpuinfo_x86 *cpu,int osvw_id, ...)Nit: Too long line.
Quoted 7 lines
xen/arch/x86/include/asm/amd.h line 166
Quoted 2 lines
xen/arch/x86/include/asm/amd.h +2
-0+{ +return false;I wouldn't mind if you consistently changed the function to return bool, but as long as it returns int I don't think it should be returning false.
indeed, it should return 0
Quoted 16 lines
xen/arch/x86/include/asm/amd.h extern bool amd_virt_spec_ctrl; · line 190
Quoted 11 lines
xen/arch/x86/include/asm/amd.h +7
-0@@ -173,5 +181,19 @@ extern bool amd_virt_spec_ctrl;bool amd_setup_legacy_ssbd (void );void amd_set_legacy_ssbd (bool enable);void amd_set_cpuid_user_dis (bool enable); +#else +static inline void amd_set_cpuid_user_dis (bool enable) {} +static inline void amd_set_legacy_ssbd (bool enable) {} +static inline bool amd_setup_legacy_ssbd (void ) +{ +return false; +}Nit: Would be a little nicer if these were in the same order as their corresponding declarations. However, along the lines of one of my comments on the Intel counterpart patch ...
Quoted 11 lines
xen/arch/x86/include/asm/amd.h extern bool amd_virt_spec_ctrl; · line 197
Quoted 6 lines
xen/arch/x86/include/asm/amd.h +6
-0+#define amd_acpi_c1e_quirk (false) +#define amd_virt_spec_ctrl (false) +#define amd_legacy_ssbd (false) + +static inline void amd_check_disable_c1e (unsigned int port,u8 value) {} +#endif ... question overall is how many of these stubs are really required, once clearly AMD-only code is properly taken care of (perhaps not just in
spec_ctrl.c).
most of these functions-stubs can go away, though it'll require more CONFIG_AMD checks at call sites, and more patches probably.
-Sergiy