Skip to content

Commit b756412

Browse files
kristina-martsenkoctmarinas
authored andcommitted
arm64: mops: detect and enable FEAT_MOPS
The Arm v8.8/9.3 FEAT_MOPS feature provides new instructions that perform a memory copy or set. Wire up the cpufeature code to detect the presence of FEAT_MOPS and enable it. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com> Link: https://lore.kernel.org/r/20230509142235.3284028-10-kristina.martsenko@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 8cd076a commit b756412

File tree

7 files changed

+24
-0
lines changed

7 files changed

+24
-0
lines changed

Documentation/arm64/cpu-feature-registers.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ infrastructure:
288288
+------------------------------+---------+---------+
289289
| Name | bits | visible |
290290
+------------------------------+---------+---------+
291+
| MOPS | [19-16] | y |
292+
+------------------------------+---------+---------+
291293
| RPRES | [7-4] | y |
292294
+------------------------------+---------+---------+
293295
| WFXT | [3-0] | y |

Documentation/arm64/elf_hwcaps.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ HWCAP2_SMEB16B16
302302
HWCAP2_SMEF16F16
303303
Functionality implied by ID_AA64SMFR0_EL1.F16F16 == 0b1
304304

305+
HWCAP2_MOPS
306+
Functionality implied by ID_AA64ISAR2_EL1.MOPS == 0b0001.
307+
305308
4. Unused AT_HWCAP bits
306309
-----------------------
307310

arch/arm64/include/asm/hwcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
#define KERNEL_HWCAP_SME_BI32I32 __khwcap2_feature(SME_BI32I32)
138138
#define KERNEL_HWCAP_SME_B16B16 __khwcap2_feature(SME_B16B16)
139139
#define KERNEL_HWCAP_SME_F16F16 __khwcap2_feature(SME_F16F16)
140+
#define KERNEL_HWCAP_MOPS __khwcap2_feature(MOPS)
140141

141142
/*
142143
* This yields a mask that user programs can use to figure out what

arch/arm64/include/uapi/asm/hwcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@
102102
#define HWCAP2_SME_BI32I32 (1UL << 40)
103103
#define HWCAP2_SME_B16B16 (1UL << 41)
104104
#define HWCAP2_SME_F16F16 (1UL << 42)
105+
#define HWCAP2_MOPS (1UL << 43)
105106

106107
#endif /* _UAPI__ASM_HWCAP_H */

arch/arm64/kernel/cpufeature.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar2[] = {
223223
ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64ISAR2_EL1_CSSC_SHIFT, 4, 0),
224224
ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64ISAR2_EL1_RPRFM_SHIFT, 4, 0),
225225
ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_HIGHER_SAFE, ID_AA64ISAR2_EL1_BC_SHIFT, 4, 0),
226+
ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR2_EL1_MOPS_SHIFT, 4, 0),
226227
ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
227228
FTR_STRICT, FTR_EXACT, ID_AA64ISAR2_EL1_APA3_SHIFT, 4, 0),
228229
ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
@@ -2187,6 +2188,11 @@ static void cpu_enable_dit(const struct arm64_cpu_capabilities *__unused)
21872188
set_pstate_dit(1);
21882189
}
21892190

2191+
static void cpu_enable_mops(const struct arm64_cpu_capabilities *__unused)
2192+
{
2193+
sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_MSCEn);
2194+
}
2195+
21902196
/* Internal helper functions to match cpu capability type */
21912197
static bool
21922198
cpucap_late_cpu_optional(const struct arm64_cpu_capabilities *cap)
@@ -2649,6 +2655,14 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
26492655
.cpu_enable = cpu_enable_dit,
26502656
ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, DIT, IMP)
26512657
},
2658+
{
2659+
.desc = "Memory Copy and Memory Set instructions",
2660+
.capability = ARM64_HAS_MOPS,
2661+
.type = ARM64_CPUCAP_SYSTEM_FEATURE,
2662+
.matches = has_cpuid_feature,
2663+
.cpu_enable = cpu_enable_mops,
2664+
ARM64_CPUID_FIELDS(ID_AA64ISAR2_EL1, MOPS, IMP)
2665+
},
26522666
{},
26532667
};
26542668

@@ -2777,6 +2791,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
27772791
HWCAP_CAP(ID_AA64ISAR2_EL1, RPRFM, IMP, CAP_HWCAP, KERNEL_HWCAP_RPRFM),
27782792
HWCAP_CAP(ID_AA64ISAR2_EL1, RPRES, IMP, CAP_HWCAP, KERNEL_HWCAP_RPRES),
27792793
HWCAP_CAP(ID_AA64ISAR2_EL1, WFxT, IMP, CAP_HWCAP, KERNEL_HWCAP_WFXT),
2794+
HWCAP_CAP(ID_AA64ISAR2_EL1, MOPS, IMP, CAP_HWCAP, KERNEL_HWCAP_MOPS),
27802795
#ifdef CONFIG_ARM64_SME
27812796
HWCAP_CAP(ID_AA64PFR1_EL1, SME, IMP, CAP_HWCAP, KERNEL_HWCAP_SME),
27822797
HWCAP_CAP(ID_AA64SMFR0_EL1, FA64, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_FA64),

arch/arm64/kernel/cpuinfo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static const char *const hwcap_str[] = {
125125
[KERNEL_HWCAP_SME_BI32I32] = "smebi32i32",
126126
[KERNEL_HWCAP_SME_B16B16] = "smeb16b16",
127127
[KERNEL_HWCAP_SME_F16F16] = "smef16f16",
128+
[KERNEL_HWCAP_MOPS] = "mops",
128129
};
129130

130131
#ifdef CONFIG_COMPAT

arch/arm64/tools/cpucaps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ HAS_GIC_PRIO_RELAXED_SYNC
3535
HAS_HCX
3636
HAS_LDAPR
3737
HAS_LSE_ATOMICS
38+
HAS_MOPS
3839
HAS_NESTED_VIRT
3940
HAS_NO_FPSIMD
4041
HAS_NO_HW_PREFETCH

0 commit comments

Comments
 (0)