SSBD AMD via LS CFG Enablement
cover SSBD AMD via LS CFG Enablement
This series of patches is for enabling SSBD via the LS_CFG MSR for family 15h-17h. The first patch make it so that the information is correctly displayed on boot. The last two patches are for further enablement for Xen switching SSBD on or off internally, or for further control of SSBD for guests via the VIRT_SPEC_CTRL.
Note: these should be applied after Jan's patch:
x86/AMD: distinguish compute units from hyper-threads
Brian Woods (3):
x86/spec-ctrl: add AMD SSBD LS_CFG in init print x86/spec-ctrl: Add defines and variables for AMD SSBD support x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
xen/arch/x86/cpu/amd.c | 7 +- xen/arch/x86/setup.c | 2 + xen/arch/x86/smpboot.c | 3 + xen/arch/x86/spec_ctrl.c | 218 +++++++++++++++++++++++++++++++++++++- xen/include/asm-x86/cpufeatures.h | 1 + xen/include/asm-x86/spec_ctrl.h | 5 + 6 files changed, 231 insertions(+), 5 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/3 x86/spec-ctrl: add AMD SSBD LS_CFG in init print
Edit the initialization code for AMD's SSBD via the LS_CFG MSR and enable it to pass the status to the initial spec-ctrl print_details at boot.
--- xen/arch/x86/cpu/amd.c | 13 ++++++++++--- xen/arch/x86/spec_ctrl.c | 9 +++++++-- xen/include/asm-x86/cpufeatures.h | 1 + xen/include/asm-x86/spec_ctrl.h | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-)
xen/arch/x86/cpu/amd.c +10 -3
@@ -598,7 +598,7 @@ static void init_amd(struct cpuinfo_x86 *c)* If the user has explicitly chosen to disable Memory Disambiguation * to mitigiate Speculative Store Bypass, poke the appropriate MSR. */ -if (opt_ssbd) { +if (!ssbd_amd_ls_cfg_mask) {int bit =-1 ;switch (c->x86) {
@@ -607,8 +607,15 @@ static void init_amd(struct cpuinfo_x86 *c)case 0x17 : bit =10 ;break ; } -if (bit >=0 && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { - value |=1ull << bit; +if (bit >=0 ) + ssbd_amd_ls_cfg_mask =1ull << bit; + } + +if (ssbd_amd_ls_cfg_mask && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { +if (!boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG )) +setup_force_cpu_cap (X86_FEATURE_SSBD_AMD_LS_CFG ); +if (opt_ssbd) { + value |= ssbd_amd_ls_cfg_mask;wrmsr_safe (MSR_AMD64_LS_CFG , value); } }
xen/arch/x86/spec_ctrl.c +7 -2
@@ -50,6 +50,8 @@ bool __initdata bsp_delay_spec_ctrl;uint8_t __read_mostly default_xen_spec_ctrl;uint8_t __read_mostly default_spec_ctrl_flags; +uint64_t __read_mostly ssbd_amd_ls_cfg_mask =0ull ; +static int __init parse_bti (const char *s) {const char *ss;
@@ -210,10 +212,11 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", + boot_cpu_has(X86_FEATURE_SSBD_AMD_LS_CFG)? " SSBD" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPABILITIES_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPABILITIES_RDCL_NO) ? " RDCL_NO" : "",
@@ -225,7 +228,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk (" Compiled-in support: INDIRECT_THUNK\n" );/* Settings for Xen's protection, irrespective of guests. */ -printk (" Xen settings: BTI-Thunk %s, SPEC_CTRL: %s%s, Other:%s\n" , +printk (" Xen settings: BTI-Thunk %s, SPEC_CTRL: %s%s%s, Other:%s\n" , thunk ==THUNK_NONE ?"N/A" : thunk ==THUNK_RETPOLINE ?"RETPOLINE" : thunk == THUNK_LFENCE ? "LFENCE" :
@@ -234,6 +237,8 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps) (default_xen_spec_ctrl &SPEC_CTRL_IBRS ) ?"IBRS+" :"IBRS-" , !boot_cpu_has (X86_FEATURE_SSBD ) ?"" : (default_xen_spec_ctrl &SPEC_CTRL_SSBD ) ?" SSBD+" :" SSBD-" , + !boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG )?"" : + (opt_ssbd && ssbd_amd_ls_cfg_mask) ?" SSBD+" :" SSBD-" , opt_ibpb ? " IBPB" : "");/*
xen/include/asm-x86/cpufeatures.h +1 -0
@@ -32,3 +32,4 @@ XEN_CPUFEATURE(SC_RSB_PV, (FSCAPINTS+0)*32+18) /* RSB overwrite needed for XEN_CPUFEATURE(SC_RSB_HVM, (FSCAPINTS+0)*32+19) /* RSB overwrite needed for HVM */ XEN_CPUFEATURE(NO_XPTI, (FSCAPINTS+0)*32+20) /* XPTI mitigation not in use */ XEN_CPUFEATURE(SC_MSR_IDLE, (FSCAPINTS+0)*32+21) /* (SC_MSR_PV || SC_MSR_HVM) && default_xen_spec_ctrl */ +XEN_CPUFEATURE (SSBD_AMD_LS_CFG , (FSCAPINTS +0 )*32 +22 )/* if SSBD support is enabled via LS_CGF MSR on AMD hardware */
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -38,6 +38,8 @@ extern uint8_t opt_xpti;#define OPT_XPTI_DOM0 0x01#define OPT_XPTI_DOMU 0x02 +extern uint64_t ssbd_amd_ls_cfg_mask; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/3] x86/spec-ctrl: add AMD SSBD LS_CFG in init print
Quoted 49 lines
Quoted 1 line
Quoted 1 line · On 20.07.18 at 16:57, <[email protected]> wrote:
Edit the initialization code for AMD's SSBD via the
LS_CFGMSR and enable it to pass the status to the initial spec-ctrlprint_detailsat boot.Signed-off-by Brian Woods <[email protected]>--- xen/arch/x86/cpu/amd.c | 13 ++++++++++--- xen/arch/x86/spec_ctrl.c | 9 +++++++-- xen/include/asm-x86/cpufeatures.h | 1 + xen/include/asm-x86/spec_ctrl.h | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-)xen/arch/x86/cpu/amd.c +10
-3@@ -598,7 +598,7 @@ static void init_amd(struct cpuinfo_x86 *c)* If the user has explicitly chosen to disable Memory Disambiguation * to mitigiate Speculative Store Bypass, poke the appropriate MSR. */ -if (opt_ssbd) { +if (!ssbd_amd_ls_cfg_mask) {int bit =-1 ;switch (c->x86) {@@ -607,8 +607,15 @@ static void init_amd(struct cpuinfo_x86 *c)case 0x17 : bit =10 ;break ; } -if (bit >=0 && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { - value |=1ull << bit; +if (bit >=0 ) + ssbd_amd_ls_cfg_mask =1ull << bit; + } + +if (ssbd_amd_ls_cfg_mask && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { +if (!boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG )) +setup_force_cpu_cap (X86_FEATURE_SSBD_AMD_LS_CFG ); +if (opt_ssbd) { + value |= ssbd_amd_ls_cfg_mask;wrmsr_safe (MSR_AMD64_LS_CFG , value); } }xen/arch/x86/spec_ctrl.c +0
-0
xen/arch/x86/spec_ctrl.c bool __initdata bsp_delay_spec_ctrl; · line 53
Quoted 4 lines
xen/arch/x86/spec_ctrl.c +1
-0@@ -50,6 +50,8 @@ bool __initdata bsp_delay_spec_ctrl;uint8_t __read_mostly default_xen_spec_ctrl;uint8_t __read_mostly default_spec_ctrl_flags; +uint64_t __read_mostly ssbd_amd_ls_cfg_mask =0ull ;
Pointless initializer.
xen/arch/x86/spec_ctrl.c static void __init print_details(enum ind_thunk thunk, uint64_t caps) · line 219
Quoted 10 lines
xen/arch/x86/spec_ctrl.c +2
-1@@ -210,10 +212,11 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", + boot_cpu_has(X86_FEATURE_SSBD_AMD_LS_CFG)? " SSBD" : "",
Why log the same string twice? Simply OR together both conditions. Also please don't omit the blank before the ? operator. Both remarks apply as well further down.
xen/include/asm-x86/cpufeatures.h XEN_CPUFEATURE(SC_RSB_PV, (FSCAPINTS+0)*32+18) /* RSB overwrite needed for · line 35
Quoted 7 lines
xen/include/asm-x86/cpufeatures.h +1
-0@@ -32,3 +32,4 @@ XEN_CPUFEATURE(SC_RSB_PV, (FSCAPINTS+0)*32+18) /* RSB overwrite needed for XEN_CPUFEATURE(SC_RSB_HVM, (FSCAPINTS+0)*32+19) /* RSB overwrite needed for HVM */ XEN_CPUFEATURE(NO_XPTI, (FSCAPINTS+0)*32+20) /* XPTI mitigation not in use */ XEN_CPUFEATURE(SC_MSR_IDLE, (FSCAPINTS+0)*32+21) /* (SC_MSR_PV || SC_MSR_HVM) && default_xen_spec_ctrl */ +XEN_CPUFEATURE (SSBD_AMD_LS_CFG , (FSCAPINTS +0 )*32 +22 )/* if SSBD support is
I've peeked ahead into the following patches, and I can't see why this needs to be a synthetic feature flag. We use such flags for the purpose of alternative instruction patching, but you don't do anything like that.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/3] x86/spec-ctrl: add AMD SSBD LS_CFG in init print
Quoted 1 line · Jan Beulich
Pointless initializer.
Noted
Quoted 3 lines
Why log the same string twice? Simply OR together both conditions. Also please don't omit the blank before the ? operator. Both remarks apply as well further down.
Because they're completely different implementation at this point. I thought about naming it something else but couldn't think of something. It also reads easier with having them split up where there isn't a ton of logic in a single ternary operator. There can be easily changed.
Quoted 6 lines
I've peeked ahead into the following patches, and I can't see why this needs to be a synthetic feature flag. We use such flags for the purpose of alternative instruction patching, but you don't do anything like that.
Jan
I was talking Andy earily about a SSBD (via VIRT_SPEC_CTRL) implementation and he mentioned something about ALTERNATIVE C funcs which would allow to allow HVM guests to be able control SSBD. In that case having a synthetic feature flag is useful for helping to differiate between SSBD via the LS_CFG MSR vs SPEC_CTRL in the future.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/3] x86/spec-ctrl: add AMD SSBD LS_CFG in init print
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.08.18 at 23:38, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Why log the same string twice? Simply OR together both conditions. Also please don't omit the blank before the ? operator. Both remarks apply as well further down.
Because they're completely different implementation at this point. I thought about naming it something else but couldn't think of something. It also reads easier with having them split up where there isn't a ton of logic in a single ternary operator. There can be easily changed.
Well, I'm not going to insist, but I'd prefer things to be as suggested, to be in line with other similar code. Let's see what Andrew thinks.
Quoted 10 lines
Quoted 4 lines
I've peeked ahead into the following patches, and I can't see why this needs to be a synthetic feature flag. We use such flags for the purpose of alternative instruction patching, but you don't do anything like that.
I was talking Andy earily about a SSBD (via
VIRT_SPEC_CTRL) implementation and he mentioned something about ALTERNATIVE C funcs which would allow to allow HVM guests to be able control SSBD. In that case having a synthetic feature flag is useful for helping to differiate between SSBD via theLS_CFGMSR vsSPEC_CTRLin the future.
I'd much appreciate if such would be introduced once actually needed, not early on just in case.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/3 x86/spec-ctrl: Add defines and variables for AMD SSBD support
In reply to Brian WoodsIn preparation for adding switchable SSBD, add some defines and variables.
--- xen/arch/x86/spec_ctrl.c | 10 ++++++++++ xen/include/asm-x86/spec_ctrl.h | 3 +++ 2 files changed, 13 insertions(+)
xen/arch/x86/spec_ctrl.c +10 -0
@@ -19,6 +19,7 @@#include <xen/errno.h> #include <xen/init.h> #include <xen/lib.h> +#include <xen/spinlock.h> #include <asm/microcode.h> #include <asm/msr.h>
@@ -50,7 +51,16 @@ bool __initdata bsp_delay_spec_ctrl;uint8_t __read_mostly default_xen_spec_ctrl;uint8_t __read_mostly default_spec_ctrl_flags; +/* for SSBD support for AMD via LS_CFG */ +#define SSBD_AMD_MAX_SOCKET 2 +struct ssbd_amd_ls_cfg_smt_status { +spinlock_t lock; +uint32_t mask; +} __attribute__ ((aligned (64 ))); +bool __read_mostly ssbd_amd_smt_en = false; +bool __read_mostly xen_ssbd_amd_ls_cfg_en = false;uint64_t __read_mostly ssbd_amd_ls_cfg_mask =0ull ; +struct ssbd_amd_ls_cfg_smt_status *ssbd_amd_smt_status[SSBD_AMD_MAX_SOCKET ] = {NULL };static int __init parse_bti (const char *s) {
xen/include/asm-x86/spec_ctrl.h +3 -0
@@ -39,6 +39,9 @@ extern uint8_t opt_xpti;#define OPT_XPTI_DOMU 0x02extern uint64_t ssbd_amd_ls_cfg_mask; +extern bool xen_ssbd_amd_ls_cfg_en; +extern void ssbd_amd_ls_cfg_init (void ); +extern void ssbd_amd_ls_cfg_set (bool enable_ssbd);static inline void init_shadow_spec_ctrl_state (void ) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/3] x86/spec-ctrl: Add defines and variables for AMD SSBD support
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 20.07.18 at 16:57, <[email protected]> wrote:
In preparation for adding switchable SSBD, add some defines and variables.
Signed-off-by Brian Woods <[email protected]>
Whether these additions fit the purpose can only be told when seeing their use. Please fold this into the patch using these.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/3] x86/spec-ctrl: Add defines and variables for AMD SSBD support
Quoted 4 lines · Jan Beulich
Whether these additions fit the purpose can only be told when seeing their use. Please fold this into the patch using these.
Jan
I was trying to split up patch 3 but I'll combine 2 and 3.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/3 x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
In reply to Brian WoodsAdds support for modifying the LS_CFG MSR to enable SSBD on supporting
AMD CPUs. There needs to be locking logic for family 17h with SMT
enabled since both threads share the same MSR. Otherwise, a core just needs to write to the LS_CFG MSR. For more information see:
https://developer.amd.com/wp-content/resources/124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
--- xen/arch/x86/cpu/amd.c | 10 +-- xen/arch/x86/setup.c | 2 + xen/arch/x86/smpboot.c | 3 + xen/arch/x86/spec_ctrl.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 207 insertions(+), 9 deletions(-)
xen/arch/x86/cpu/amd.c +2 -8
@@ -607,16 +607,10 @@ static void init_amd(struct cpuinfo_x86 *c)case 0x17 : bit =10 ;break ; } -if (bit >=0 ) - ssbd_amd_ls_cfg_mask =1ull << bit; - } -if (ssbd_amd_ls_cfg_mask && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { -if (!boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG )) +if (bit >=0 && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { + ssbd_amd_ls_cfg_mask =1ull << bit;setup_force_cpu_cap (X86_FEATURE_SSBD_AMD_LS_CFG ); -if (opt_ssbd) { - value |= ssbd_amd_ls_cfg_mask; -wrmsr_safe (MSR_AMD64_LS_CFG , value); } }
xen/arch/x86/setup.c +2 -0
@@ -1579,6 +1579,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)arch_init_memory (); +ssbd_amd_ls_cfg_init (); +alternative_instructions ();local_irq_enable ();
xen/arch/x86/smpboot.c +3 -0
@@ -366,6 +366,9 @@ void start_secondary(void *unused)if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if ( xen_ssbd_amd_ls_cfg_en ) +ssbd_amd_ls_cfg_set (true); +if ( xen_guest )hypervisor_ap_setup ();
xen/arch/x86/spec_ctrl.c +200 -1
219 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.07.18 at 16:57, <[email protected]> wrote:
xen/arch/x86/cpu/amd.c +0
-3@@ -607,16 +607,10 @@ static void init_amd(struct cpuinfo_x86 *c)case 0x17 : bit =10 ;break ; } -if (bit >=0 ) - ssbd_amd_ls_cfg_mask =1ull << bit; - }
xen/arch/x86/cpu/amd.c static void init_amd(struct cpuinfo_x86 *c) · line 615
Quoted 10 lines
xen/arch/x86/cpu/amd.c +2
-5-if (ssbd_amd_ls_cfg_mask && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { -if (!boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG )) +if (bit >=0 && !rdmsr_safe (MSR_AMD64_LS_CFG , value)) { + ssbd_amd_ls_cfg_mask =1ull << bit;setup_force_cpu_cap (X86_FEATURE_SSBD_AMD_LS_CFG ); -if (opt_ssbd) { - value |= ssbd_amd_ls_cfg_mask; -wrmsr_safe (MSR_AMD64_LS_CFG , value); } }
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1582
Quoted 7 lines
xen/arch/x86/setup.c +1
-0@@ -1579,6 +1579,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)arch_init_memory (); +ssbd_amd_ls_cfg_init ();
Why can't this be called from init_speculation_mitigations()?
Quoted 5 lines
xen/arch/x86/setup.c +1
-0@@ -497,6 +497,201 @@ static __init int parse_xpti(const char *s) }custom_param ("xpti" , parse_xpti); +/*
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 510
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+* For family 15h and 16h, there are no SMT enabled processors, so there +* is no need for locking, just need to set an MSR bit. For 17h, it +* depends if SMT is enabled. If SMT, are two threads share a single +* MSR so there needs to be a lock and a virtual bit for each thread. +*/ + +/* used for non SMT mitigations (no shared MSRs) */ +static void ssbd_amd_ls_cfg_set_nonsmt (bool enable_ssbd) +{ +unsigned long ls_cfg;
Please be consistent with types: ssbd_amd_ls_cfg_mask is uint64_t, in which case variables like the one here should be too.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 523
Quoted 13 lines
xen/arch/x86/setup.c +13
-0+if ( enable_ssbd ) + { +rdmsrl (MSR_AMD64_LS_CFG , ls_cfg); +if ( !(ls_cfg & ssbd_amd_ls_cfg_mask) ) + { + ls_cfg |= ssbd_amd_ls_cfg_mask; +wrmsrl (MSR_AMD64_LS_CFG , ls_cfg); + } + } +else + { +rdmsrl (MSR_AMD64_LS_CFG , ls_cfg); +if (ls_cfg & ssbd_amd_ls_cfg_mask)
Missing blanks.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 529
Quoted 6 lines
xen/arch/x86/setup.c +6
-0+ { + ls_cfg &= ~ssbd_amd_ls_cfg_mask; +wrmsrl (MSR_AMD64_LS_CFG , ls_cfg); + } + } +}
Please simplify this to have just a single rdmsrl() and wrmsrl() each in the function.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 534
Quoted 5 lines
xen/arch/x86/setup.c +5
-0+/* used for family 17h with SMT enabled (shared MSRs) */ +static void ssbd_amd_ls_cfg_set_smt (bool enable_ssbd) +{ +__u32 socket, core, thread; +uint64_t enable_mask;
You really should notice such anomalies / inconsistencies yourself:
You properly use uint64_t here, so why not also uint32_t on the preceding line? That said - why a fixed width type anyway for those variables - unsigned int looks to be just fine there.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 547
Quoted 13 lines
xen/arch/x86/setup.c +13
-0+void ssbd_amd_ls_cfg_set (bool enable_ssbd) +{ +if ( !ssbd_amd_ls_cfg_mask || + !boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG ) ) { +dprintk (XENLOG_ERR ,"SSBD AMD LS CFG: Invalid mask\n" ); +return ; + } + +if ( ssbd_amd_smt_en ) +ssbd_amd_ls_cfg_set_smt (enable_ssbd); +else +ssbd_amd_ls_cfg_set_nonsmt (enable_ssbd); +}
This function is called from exactly one place, with the parameter set to true. Makes me wonder what the actual purpose of this patch is.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 551
Quoted 4 lines
xen/arch/x86/setup.c +4
-0+/* +* used to init the boot cpu, we don't need to lock anything because +* it's just the boot CPU +*/
Still I wonder whether less code duplication wouldn't be better.
Quoted 5 lines
xen/arch/x86/setup.c +5
-0+static __init void ssbd_amd_ls_cfg_set_init (void ) +{ +__u32 socket, core, thread; +unsigned long long ls_cfg; +struct ssbd_amd_ls_cfg_smt_status *status;
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 566
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+struct cpuinfo_x86 *c = &boot_cpu_data; + +if ( ssbd_amd_smt_en ) + { + socket = c->phys_proc_id; + core = c->cpu_core_id; + thread = c->apicid && (c->x86_num_siblings -1 ); + + status = ssbd_amd_smt_status[socket] + core; + status->mask |= (1ull << thread);
This hides very well an assumption of there only ever being two threads. Please don't. I'm also having a hard time seeing why c->apicid being (non-)zero matters. Or wait - do you mean & instead of && above (then also in ssbd_amd_ls_cfg_set_smt())?
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 577
Quoted 11 lines
xen/arch/x86/setup.c +11
-0+ } + +rdmsrl (MSR_AMD64_LS_CFG , ls_cfg); +if ( !(ls_cfg & ssbd_amd_ls_cfg_mask) ) + { + ls_cfg |= ssbd_amd_ls_cfg_mask; +wrmsrl (MSR_AMD64_LS_CFG , ls_cfg); + } +} + +__init void ssbd_amd_ls_cfg_init (void )
Most noticeable here, but applicable elsewhere: The canonical placement is
void __init ssbd_amd_ls_cfg_init(void)
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 581
Quoted 4 lines
xen/arch/x86/setup.c +4
-0+{ +int cores_per_socket, threads_per_core; +struct cpuinfo_x86 *c = &boot_cpu_data; +int core,socket;
unsigned int please for anything that can't go negative. And a blank is missing after the comma here, while there's one too many on the line before.
You also don't look to be altering the data c points to - please make this a pointer to const (and check whether there are other places wanting such a transformation).
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 591
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+if ( !ssbd_amd_ls_cfg_mask || + !boot_cpu_has (X86_FEATURE_SSBD_AMD_LS_CFG ) ) + goto ssbd_amd_ls_cfg_init_fail; + +switch ( c->x86 ) + { +case 0x15 : +case 0x16 : +break ; +case 0x17 :
Blank lines between case blocks please.
Quoted 4 lines
xen/arch/x86/setup.c +4
-0+ cores_per_socket = c->x86_max_cores; + threads_per_core = c->x86_num_siblings; + +if ( (cores_per_socket <1 ) || (threads_per_core <1 ) )
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 605
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+ { +dprintk (XENLOG_ERR , +"SSBD AMD LS CFG: error in topology decoding\n" ); + goto ssbd_amd_ls_cfg_init_fail; + } + +if ( threads_per_core >1 ) + { + ssbd_amd_smt_en = true; +for ( socket =0 ; socket <SSBD_AMD_MAX_SOCKET ; socket++ )
I find such a hard-coded upper bound quite concerning. Is nr_sockets not correct in the AMD case? If so, that would want fixing, such that you can use the variable here.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 610
Quoted 5 lines
xen/arch/x86/setup.c +5
-0+ { + ssbd_amd_smt_status[socket] = + (struct ssbd_amd_ls_cfg_smt_status *) + xmalloc_array (struct ssbd_amd_ls_cfg_smt_status, + cores_per_socket);
Style: Blank before * and no blank before (.
Quoted 4 lines
xen/arch/x86/setup.c +4
-0+if ( ssbd_amd_smt_status[socket] ==NULL ) + { +dprintk (XENLOG_ERR , +"SSBD AMD LS CFG: error in status allocing\n" );
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 624
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+ goto ssbd_amd_ls_cfg_init_fail; + } + } + +for ( socket =0 ; socket <SSBD_AMD_MAX_SOCKET ; socket++ ) + { +for ( core =0 ; core < cores_per_socket; core++ ) + { +spin_lock_init (&(ssbd_amd_smt_status[socket] + core)->lock); + (ssbd_amd_smt_status[socket] + core)->mask =0 ;
Perhaps better
spin_lock_init(&ssbd_amd_smt_status[socket][core].lock);
ssbd_amd_smt_status[socket][core].mask = 0;?
Quoted 4 lines
xen/arch/x86/setup.c +4
-0+ } + } + } +break ;
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 638
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+default : + goto ssbd_amd_ls_cfg_init_fail; + } + +if ( xen_ssbd_amd_ls_cfg_en ) +ssbd_amd_ls_cfg_set_init (); + +return ; + +ssbd_amd_ls_cfg_init_fail:
Labels indented by at least one blank please.
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 644
Quoted 6 lines
xen/arch/x86/setup.c +6
-0+for ( socket =0 ; socket <SSBD_AMD_MAX_SOCKET ; socket++ ) +if ( ssbd_amd_smt_status[socket] !=NULL ) +xfree (ssbd_amd_smt_status[socket]); + +setup_clear_cpu_cap (X86_FEATURE_SSBD_AMD_LS_CFG ); + xen_ssbd_amd_ls_cfg_en = false;
Btw - why the xen_ prefix for the variable?
xen/arch/x86/setup.c static __init int parse_xpti(const char *s) · line 646
Quoted 2 lines
xen/arch/x86/setup.c +2
-0+return ; +}
Pointless "return" at end of function.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 2 lines · Jan Beulich
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
Patch 1 stand alone just to improve reporting the capabilities of the processor. Currently Xen doesn't mention anything if SSBD is actually enable on AMD processors. Patch 2-3 add it where Xen can it dynamically.
Quoted 1 line
Why can't this be called from
init_speculation_mitigations()?
IIRC I was having memory init problems with. It was moved to later in the boot so that xmalloc would work correctly. I haven't touched this code in over month. If you want a 100% tested answer I can retest putting it in init_speculation_mitigations().
Quoted 2 lines
Please be consistent with types:
ssbd_amd_ls_cfg_maskisuint64_t, in which case variables like the one here should be too.
I think that was left over from something in init_amd, but yes.
Quoted 1 line
Missing blanks.
Noted
Quoted 2 lines
Please simplify this to have just a single
rdmsrl()andwrmsrl()each in the function.
Will do.
Quoted 4 lines
You really should notice such anomalies / inconsistencies yourself:
You properly useuint64_there, so why not alsouint32_ton the preceding line? That said - why a fixed width type anyway for those variables - unsigned int looks to be just fine there.
IIRC they're __32 in struct I'm reading from so I decided to use that. I can change them though, that's easily.
Quoted 3 lines
This function is called from exactly one place, with the parameter set to true. Makes me wonder what the actual purpose of this patch is.
See earlier in this email.
Quoted 1 line
Still I wonder whether less code duplication wouldn't be better.
current_cpu_data isn't available when ssbd_amd_ls_cfg_init is called.
Quoted 4 lines
This hides very well an assumption of there only ever being two threads. Please don't. I'm also having a hard time seeing why
c->apicidbeing (non-)zero matters. Or wait - do you mean & instead of && above (then also inssbd_amd_ls_cfg_set_smt())?
Yes... That was meant to be a &. Thanks for catching that.
Quoted 9 lines
Most noticeable here, but applicable elsewhere: The canonical placement is
void
__initssbd_amd_ls_cfg_init(void)unsigned int please for anything that can't go negative. And a blank is missing after the comma here, while there's one too many on the line before.
Quoted 5 lines
You also don't look to be altering the data c points to - please make this a pointer to const (and check whether there are other places wanting such a transformation).
Blank lines between case blocks please.
Noted about the above.
Quoted 3 lines
I find such a hard-coded upper bound quite concerning. Is
nr_socketsnot correct in the AMD case? If so, that would want fixing, such that you can use the variable here.
It's been a while since I wrote this but IIRC, it has to do with nr_sockets either being off or not available when the code is run. For Family 17h which the patches are for, there's a max of two sockets.
Quoted 8 lines
Style: Blank before * and no blank before (.
Perhaps better
spin_lock_init(&ssbd_amd_smt_status[socket][core].lock); ssbd_amd_smt_status[socket][core].mask = 0;?
Labels indented by at least one blank please.
Noted about the above.
Quoted 1 line
Btw - why the
xen_prefix for the variable?
See the first reply, but basically it's for if Xen has SSBD turned on or not via using the LS_CFG MSR.
Quoted 3 lines
Pointless "return" at end of function.
Jan
Noted.
Thanks for all the feedback. I'll try and get v2 out in a couple of days or so.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 02.08.18 at 00:20, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
Patch 1 stand alone just to improve reporting the capabilities of the processor. Currently Xen doesn't mention anything if SSBD is actually enable on AMD processors. Patch 2-3 add it where Xen can it dynamically.
Which is all fine, but couldn't patch 1 be written in a way that the next one(s) don't have to turn code structure all over again.
Quoted 6 lines
Quoted 1 line
Why can't this be called from
init_speculation_mitigations()?IIRC I was having memory init problems with. It was moved to later in the boot so that xmalloc would work correctly. I haven't touched this code in over month. If you want a 100% tested answer I can retest putting it in
init_speculation_mitigations().
Would be nice if that could be arranged for, as the rather specialized call looks pretty odd in (iirc __start_xen(); iirc because you've dropped too much of the context in your reply, and I'm too lazy to dig out the original patch again).
Quoted 7 lines
Quoted 4 lines
You really should notice such anomalies / inconsistencies yourself:
You properly useuint64_there, so why not alsouint32_ton the preceding line? That said - why a fixed width type anyway for those variables - unsigned int looks to be just fine there.IIRC they're __32 in struct I'm reading from so I decided to use that. I can change them though, that's easily.
Thanks - we prefer to avoid u<N> and s<N> in favor of uint<N>_t and int<N>_t in new code, and __u<N> as well as __s<N> should go away rather sooner than later anyway, as representing name space violations (__s8, for example, already looks to be unused).
Quoted 5 lines
Quoted 3 lines
This function is called from exactly one place, with the parameter set to true. Makes me wonder what the actual purpose of this patch is.
See earlier in this email.
Where? I can't find anything as to the purpose. Your response to patch 1's comments on mine might have been a hint, but then again the function parameter here seems contrary to the alternatives patching plans, at least at the first glance. If you want to keep the parameter (rather than introducing it when needed), please at least outline the plans in the description.
Quoted 3 lines
Quoted 1 line
Still I wonder whether less code duplication wouldn't be better.
current_cpu_dataisn't available whenssbd_amd_ls_cfg_initis called.
By "isn't available" you mean "hasn't been populated yet"? Else I don't understand.
Quoted 7 lines
Quoted 3 lines
I find such a hard-coded upper bound quite concerning. Is
nr_socketsnot correct in the AMD case? If so, that would want fixing, such that you can use the variable here.It's been a while since I wrote this but IIRC, it has to do with
nr_socketseither being off or not available when the code is run. For Family 17h which the patches are for, there's a max of two sockets.
I've implied that from how you wrote the patches, but such hard coding will only make for more code churn later on. Try to be as generic as possible.
Quoted 4 lines
Quoted 1 line
Btw - why the
xen_prefix for the variable?See the first reply, but basically it's for if Xen has SSBD turned on or not via using the
LS_CFGMSR.
Personally I'd prefer if the xen_-prefixed sub-name-space was left to the public interface. Make it an infix if you want to express what you've explained?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.08.18 at 00:20, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
Quoted 7 lines
Quoted 4 lines
Patch 1 stand alone just to improve reporting the capabilities of the processor. Currently Xen doesn't mention anything if SSBD is actually enable on AMD processors. Patch 2-3 add it where Xen can it dynamically.
Which is all fine, but couldn't patch 1 be written in a way that the next one(s) don't have to turn code structure all over again.
Rather than change 1, I changed patch 3 (well now patch 2).
Quoted 11 lines
Quoted 6 lines
Quoted 1 line
Why can't this be called from
init_speculation_mitigations()?IIRC I was having memory init problems with. It was moved to later in the boot so that xmalloc would work correctly. I haven't touched this code in over month. If you want a 100% tested answer I can retest putting it in
init_speculation_mitigations().Would be nice if that could be arranged for, as the rather specialized call looks pretty odd in (iirc
__start_xen(); iirc because you've dropped too much of the context in your reply, and I'm too lazy to dig out the original patch again).
It was __start_xen(). Well, IIRC xalloc didn't work (well writing to the address given) until after arch_init_memory(). For it to work in init_speculation_mitigations(), I'd assume you'd need to call arch_init_memory() before init_speculation_mitigations().
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
You really should notice such anomalies / inconsistencies yourself:
You properly useuint64_there, so why not alsouint32_ton the preceding line? That said - why a fixed width type anyway for those variables - unsigned int looks to be just fine there.
Quoted 7 lines
Quoted 2 lines
IIRC they're __32 in struct I'm reading from so I decided to use that. I can change them though, that's easily.
Thanks - we prefer to avoid u<N> and s<N> in favor of uint<N>_t and int<N>_t in new code, and __u<N> as well as __s<N> should go away rather sooner than later anyway, as representing name space violations (
__s8, for example, already looks to be unused).
Noted, I've changed all of them.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
This function is called from exactly one place, with the parameter set to true. Makes me wonder what the actual purpose of this patch is.
Quoted 8 lines
Quoted 1 line
See earlier in this email.
Where? I can't find anything as to the purpose. Your response to patch 1's comments on mine might have been a hint, but then again the function parameter here seems contrary to the alternatives patching plans, at least at the first glance. If you want to keep the parameter (rather than introducing it when needed), please at least outline the plans in the description.
To be honest, I assumed that only patch 1 would get accepted and then once there was the infrastructure (alternative c funcs), I'd rework the rest into a patch set that would introduce allowing HVM guests to change SSBD via MSR interception (since there is some interest in that). I guess I should have been clearer up front about it.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Still I wonder whether less code duplication wouldn't be better.
current_cpu_dataisn't available whenssbd_amd_ls_cfg_initis called.By "isn't available" you mean "hasn't been populated yet"? Else I don't understand.
It hasn't been populated yet.
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
I find such a hard-coded upper bound quite concerning. Is
nr_socketsnot correct in the AMD case? If so, that would want fixing, such that you can use the variable here.It's been a while since I wrote this but IIRC, it has to do with
nr_socketseither being off or not available when the code is run. For Family 17h which the patches are for, there's a max of two sockets.I've implied that from how you wrote the patches, but such hard coding will only make for more code churn later on. Try to be as generic as possible.
Well, nr_sockets gets set in smp_prepare_cpus, which gets called after init_speculation_mitigations() and ssbd_amd_ls_cfg_init(). It could be put later on in the boot, but it needs to be run at least before other cpus are brought online. I'm welcome to any suggestions about how to restructure things though.
Also, settings SSBD via the LS_CFG MSR is not a permanent method. Once hardware supports using SPEC_CTRL for it, it won't be needed. For multisocket systems, there should only be 2 sockets. I agree with making things generic, but this early in the boot there's limited information.
Quoted 10 lines
Quoted 4 lines
Quoted 1 line
Btw - why the
xen_prefix for the variable?See the first reply, but basically it's for if Xen has SSBD turned on or not via using the
LS_CFGMSR.Personally I'd prefer if the xen_-prefixed sub-name-space was left to the public interface. Make it an infix if you want to express what you've explained?
Jan
Noted. I'll change that.
Thanks again for the feedback.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 06.08.18 at 21:07, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.08.18 at 00:20, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
Quoted 7 lines
Quoted 4 lines
Patch 1 stand alone just to improve reporting the capabilities of the processor. Currently Xen doesn't mention anything if SSBD is actually enable on AMD processors. Patch 2-3 add it where Xen can it dynamically.
Which is all fine, but couldn't patch 1 be written in a way that the next one(s) don't have to turn code structure all over again.
Rather than change 1, I changed patch 3 (well now patch 2).
Quoted 11 lines
Quoted 6 lines
Quoted 1 line
Why can't this be called from
init_speculation_mitigations()?IIRC I was having memory init problems with. It was moved to later in the boot so that xmalloc would work correctly. I haven't touched this code in over month. If you want a 100% tested answer I can retest putting it in
init_speculation_mitigations().Would be nice if that could be arranged for, as the rather specialized call looks pretty odd in (iirc
__start_xen(); iirc because you've dropped too much of the context in your reply, and I'm too lazy to dig out the original patch again).
Quoted 4 lines
It was
__start_xen(). Well, IIRC xalloc didn't work (well writing to the address given) until afterarch_init_memory(). For it to work ininit_speculation_mitigations(), I'd assume you'd need to callarch_init_memory()beforeinit_speculation_mitigations().
I don't think that's a viable option, but it could certainly be explored. I wonder though whether you can't get away without allocation at this early point.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Still I wonder whether less code duplication wouldn't be better.
current_cpu_dataisn't available whenssbd_amd_ls_cfg_initis called.By "isn't available" you mean "hasn't been populated yet"? Else I don't understand.
It hasn't been populated yet.
Not even boot_cpu_data?
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
I find such a hard-coded upper bound quite concerning. Is
nr_socketsnot correct in the AMD case? If so, that would want fixing, such that you can use the variable here.It's been a while since I wrote this but IIRC, it has to do with
nr_socketseither being off or not available when the code is run. For Family 17h which the patches are for, there's a max of two sockets.I've implied that from how you wrote the patches, but such hard coding will only make for more code churn later on. Try to be as generic as possible.
Quoted 5 lines
Well,
nr_socketsgets set insmp_prepare_cpus, which gets called afterinit_speculation_mitigations()andssbd_amd_ls_cfg_init(). It could be put later on in the boot, but it needs to be run at least before other cpus are brought online. I'm welcome to any suggestions about how to restructure things though.
Did you consider using a presmp-initcall?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 29 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 06.08.18 at 21:07, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.08.18 at 00:20, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Code structure wise this looks to undo a fair part of what patch 1 has done. It would be nice to limit code churn.
Quoted 7 lines
Quoted 4 lines
Patch 1 stand alone just to improve reporting the capabilities of the processor. Currently Xen doesn't mention anything if SSBD is actually enable on AMD processors. Patch 2-3 add it where Xen can it dynamically.
Which is all fine, but couldn't patch 1 be written in a way that the next one(s) don't have to turn code structure all over again.
Rather than change 1, I changed patch 3 (well now patch 2).
Quoted 11 lines
Quoted 6 lines
Quoted 1 line
Why can't this be called from
init_speculation_mitigations()?IIRC I was having memory init problems with. It was moved to later in the boot so that xmalloc would work correctly. I haven't touched this code in over month. If you want a 100% tested answer I can retest putting it in
init_speculation_mitigations().Would be nice if that could be arranged for, as the rather specialized call looks pretty odd in (iirc
__start_xen(); iirc because you've dropped too much of the context in your reply, and I'm too lazy to dig out the original patch again).
Quoted 8 lines
Quoted 4 lines
It was
__start_xen(). Well, IIRC xalloc didn't work (well writing to the address given) until afterarch_init_memory(). For it to work ininit_speculation_mitigations(), I'd assume you'd need to callarch_init_memory()beforeinit_speculation_mitigations().I don't think that's a viable option, but it could certainly be explored. I wonder though whether you can't get away without allocation at this early point.
Well, the thing is that you could use DECLARE_PER_CPU but then you have to initialize it during each cpu start up, but two logical cpus share a lock and only one needs to touch it etc. I found it better to just initialize everything on the boot cpu before others are brought up, but the whole thing is a little messy. (See the last comment.)
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Still I wonder whether less code duplication wouldn't be better.
current_cpu_dataisn't available whenssbd_amd_ls_cfg_initis called.By "isn't available" you mean "hasn't been populated yet"? Else I don't understand.
It hasn't been populated yet.
Not even
boot_cpu_data?
boot_cpu_data is, but current_cpu_data and nr_sockets is not.
Quoted 18 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
I find such a hard-coded upper bound quite concerning. Is
nr_socketsnot correct in the AMD case? If so, that would want fixing, such that you can use the variable here.It's been a while since I wrote this but IIRC, it has to do with
nr_socketseither being off or not available when the code is run. For Family 17h which the patches are for, there's a max of two sockets.I've implied that from how you wrote the patches, but such hard coding will only make for more code churn later on. Try to be as generic as possible.
Quoted 5 lines
Well,
nr_socketsgets set insmp_prepare_cpus, which gets called afterinit_speculation_mitigations()andssbd_amd_ls_cfg_init(). It could be put later on in the boot, but it needs to be run at least before other cpus are brought online. I'm welcome to any suggestions about how to restructure things though.
Quoted 3 lines
Did you consider using a presmp-initcall?
Jan
I've been looking at it, seems like that could work. You'd still need something in start_secondary but it would take the init call out of __start_xen(). I'll test that.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/3] x86/spec-ctrl: Add support for modifying SSBD AMD VIA LS_CFG MSR
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 08.08.18 at 18:43, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.08.18 at 21:07, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 02.08.18 at 00:20, <[email protected]> wrote:
current_cpu_dataisn't available whenssbd_amd_ls_cfg_initis called.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
By "isn't available" you mean "hasn't been populated yet"? Else I don't understand.
It hasn't been populated yet.
Not even
boot_cpu_data?
boot_cpu_datais, butcurrent_cpu_dataandnr_socketsis not.
Then any reason not to use it (on the BSP)? I agree nr_sockets is a problem, should it really be needed this early.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel