Skip to content

Commit

Permalink
x86/intel: optional build of TSX support
Browse files Browse the repository at this point in the history
Transactional Synchronization Extensions are supported on certain Intel's
CPUs only, hence can be put under CONFIG_INTEL build option.

The whole TSX support, even if supported by CPU, may need to be disabled via
options, by microcode or through spec-ctrl, depending on a set of specific
conditions. To make sure nothing gets accidentally runtime-broken all
modifications of global TSX configuration variables is secured by #ifdef's,
while variables themselves redefined to 0, so that ones can't mistakenly be
written to.

Signed-off-by: Sergiy Kibrik <[email protected]>
Acked-by: Jan Beulich <[email protected]>
  • Loading branch information
sa-kib authored and jbeulich committed Aug 1, 2024
1 parent fb45a35 commit b1b017f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/misc/xen-command-line.pandoc
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ pages) must also be specified via the tbuf_size parameter.
### tsx
= <bool>

Applicability: x86
Applicability: x86 with CONFIG_INTEL active
Default: false on parts vulnerable to TAA, true otherwise

Controls for the use of Transactional Synchronization eXtensions.
Expand Down
2 changes: 1 addition & 1 deletion xen/arch/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ obj-y += srat.o
obj-y += string.o
obj-y += time.o
obj-y += traps.o
obj-y += tsx.o
obj-$(CONFIG_INTEL) += tsx.o
obj-y += usercopy.o
obj-y += x86_emulate.o
obj-$(CONFIG_TBOOT) += tboot.o
Expand Down
6 changes: 6 additions & 0 deletions xen/arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,15 @@ static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,
return fam;
}

#ifdef CONFIG_INTEL
extern int8_t opt_tsx;
extern bool rtm_disabled;
void tsx_init(void);
#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) {}
#endif

void update_mcu_opt_ctrl(void);
void set_in_mcu_opt_ctrl(uint32_t mask, uint32_t val);
Expand Down
4 changes: 4 additions & 0 deletions xen/arch/x86/spec_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ static int __init cf_check parse_spec_ctrl(const char *s)
if ( opt_pv_l1tf_domu < 0 )
opt_pv_l1tf_domu = 0;

#ifdef CONFIG_INTEL
if ( opt_tsx == -1 )
opt_tsx = -3;
#endif

disable_common:
opt_rsb_pv = false;
Expand Down Expand Up @@ -2264,13 +2266,15 @@ void __init init_speculation_mitigations(void)
* plausibly value TSX higher than Hyperthreading...), disable TSX to
* mitigate TAA.
*/
#ifdef CONFIG_INTEL
if ( opt_tsx == -1 && cpu_has_bug_taa && cpu_has_tsx_ctrl &&
((hw_smt_enabled && opt_smt) ||
!boot_cpu_has(X86_FEATURE_SC_VERW_IDLE)) )
{
opt_tsx = 0;
tsx_init();
}
#endif

/*
* On some SRBDS-affected hardware, it may be safe to relax srb-lock by
Expand Down

0 comments on commit b1b017f

Please sign in to comment.