s390/tx: Convert MACHINE_HAS_TE to machine_has_tx()

Use static branch(es) to implement and use machine_has_tx() instead of
a runtime check with MACHINE_HAS_TE.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
Heiko Carstens
2025-02-07 15:49:01 +01:00
committed by Vasily Gorbik
parent 17d3804808
commit e82462fbb2
6 changed files with 12 additions and 11 deletions

View File

@@ -84,6 +84,10 @@ static void detect_facilities(void)
clock_comparator_max = -1UL >> 1;
local_ctl_set_bit(0, CR0_CLOCK_COMPARATOR_SIGN_BIT);
}
if (test_facility(50) && test_facility(73)) {
set_machine_feature(MFEATURE_TX);
local_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
}
}
static int cmma_test_essa(void)

View File

@@ -12,6 +12,7 @@
#define MFEATURE_PCI_MIO 1
#define MFEATURE_SCC 2
#define MFEATURE_TLB_GUEST 3
#define MFEATURE_TX 4
#ifndef __ASSEMBLY__
@@ -82,6 +83,7 @@ static __always_inline bool machine_has_##name(void) \
DEFINE_MACHINE_HAS_FEATURE(relocated_lowcore, MFEATURE_LOWCORE)
DEFINE_MACHINE_HAS_FEATURE(scc, MFEATURE_SCC)
DEFINE_MACHINE_HAS_FEATURE(tlb_guest, MFEATURE_TLB_GUEST)
DEFINE_MACHINE_HAS_FEATURE(tx, MFEATURE_TX)
#endif /* __ASSEMBLY__ */
#endif /* __ASM_S390_MACHINE_H */

View File

@@ -22,7 +22,6 @@
#define MACHINE_FLAG_LPAR BIT(2)
#define MACHINE_FLAG_DIAG9C BIT(3)
#define MACHINE_FLAG_ESOP BIT(4)
#define MACHINE_FLAG_TE BIT(11)
#define LPP_MAGIC BIT(31)
#define LPP_PID_MASK _AC(0xffffffff, UL)
@@ -72,7 +71,6 @@ extern unsigned long mio_wb_bit_mask;
#define MACHINE_HAS_DIAG9C (get_lowcore()->machine_flags & MACHINE_FLAG_DIAG9C)
#define MACHINE_HAS_ESOP (get_lowcore()->machine_flags & MACHINE_FLAG_ESOP)
#define MACHINE_HAS_TE (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
/*
* Console mode. Override with conmode=

View File

@@ -222,10 +222,6 @@ static __init void detect_diag9c(void)
static __init void detect_machine_facilities(void)
{
if (test_facility(50) && test_facility(73)) {
get_lowcore()->machine_flags |= MACHINE_FLAG_TE;
system_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
}
if (test_facility(129))
system_ctl_set_bit(0, CR0_VECTOR_BIT);
}

View File

@@ -218,7 +218,7 @@ static int __init setup_hwcaps(void)
elf_hwcap |= HWCAP_HIGH_GPRS;
/* transactional execution */
if (MACHINE_HAS_TE)
if (machine_has_tx())
elf_hwcap |= HWCAP_TE;
/* vector */

View File

@@ -32,6 +32,7 @@
#include <asm/unistd.h>
#include <asm/runtime_instr.h>
#include <asm/facility.h>
#include <asm/machine.h>
#include <asm/fpu.h>
#include "entry.h"
@@ -61,7 +62,7 @@ void update_cr_regs(struct task_struct *task)
cr0_new = cr0_old;
cr2_new = cr2_old;
/* Take care of the enable/disable of transactional execution. */
if (MACHINE_HAS_TE) {
if (machine_has_tx()) {
/* Set or clear transaction execution TXC bit 8. */
cr0_new.tcx = 1;
if (task->thread.per_flags & PER_FLAG_NO_TE)
@@ -471,18 +472,18 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_GET_LAST_BREAK:
return put_user(child->thread.last_break, (unsigned long __user *)data);
case PTRACE_ENABLE_TE:
if (!MACHINE_HAS_TE)
if (!machine_has_tx())
return -EIO;
child->thread.per_flags &= ~PER_FLAG_NO_TE;
return 0;
case PTRACE_DISABLE_TE:
if (!MACHINE_HAS_TE)
if (!machine_has_tx())
return -EIO;
child->thread.per_flags |= PER_FLAG_NO_TE;
child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
return 0;
case PTRACE_TE_ABORT_RAND:
if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE))
if (!machine_has_tx() || (child->thread.per_flags & PER_FLAG_NO_TE))
return -EIO;
switch (data) {
case 0UL: