Skip to content

Commit 1f5a062

Browse files
committed
Merge branch 'for-next/cpufeature' into for-next/core
* for-next/cpufeature: arm64/fpsimd: Only provide the length to cpufeature for xCR registers selftests/arm64: add HWCAP2_HBC test arm64: add HWCAP for FEAT_HBC (hinted conditional branches) arm64/cpufeature: Use ARM64_CPUID_FIELD() to match EVT
2 parents 6eaae19 + 01948b0 commit 1f5a062

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

arch/arm64/include/asm/hwcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
#define KERNEL_HWCAP_SME_B16B16 __khwcap2_feature(SME_B16B16)
139139
#define KERNEL_HWCAP_SME_F16F16 __khwcap2_feature(SME_F16F16)
140140
#define KERNEL_HWCAP_MOPS __khwcap2_feature(MOPS)
141+
#define KERNEL_HWCAP_HBC __khwcap2_feature(HBC)
141142

142143
/*
143144
* 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
@@ -103,5 +103,6 @@
103103
#define HWCAP2_SME_B16B16 (1UL << 41)
104104
#define HWCAP2_SME_F16F16 (1UL << 42)
105105
#define HWCAP2_MOPS (1UL << 43)
106+
#define HWCAP2_HBC (1UL << 44)
106107

107108
#endif /* _UAPI__ASM_HWCAP_H */

arch/arm64/kernel/cpufeature.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar1[] = {
222222
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),
225-
ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_HIGHER_SAFE, ID_AA64ISAR2_EL1_BC_SHIFT, 4, 0),
225+
ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, ID_AA64ISAR2_EL1_BC_SHIFT, 4, 0),
226226
ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR2_EL1_MOPS_SHIFT, 4, 0),
227227
ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
228228
FTR_STRICT, FTR_EXACT, ID_AA64ISAR2_EL1_APA3_SHIFT, 4, 0),
@@ -2708,12 +2708,8 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
27082708
.desc = "Enhanced Virtualization Traps",
27092709
.capability = ARM64_HAS_EVT,
27102710
.type = ARM64_CPUCAP_SYSTEM_FEATURE,
2711-
.sys_reg = SYS_ID_AA64MMFR2_EL1,
2712-
.sign = FTR_UNSIGNED,
2713-
.field_pos = ID_AA64MMFR2_EL1_EVT_SHIFT,
2714-
.field_width = 4,
2715-
.min_field_value = ID_AA64MMFR2_EL1_EVT_IMP,
27162711
.matches = has_cpuid_feature,
2712+
ARM64_CPUID_FIELDS(ID_AA64MMFR2_EL1, EVT, IMP)
27172713
},
27182714
{},
27192715
};
@@ -2844,6 +2840,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
28442840
HWCAP_CAP(ID_AA64ISAR2_EL1, RPRES, IMP, CAP_HWCAP, KERNEL_HWCAP_RPRES),
28452841
HWCAP_CAP(ID_AA64ISAR2_EL1, WFxT, IMP, CAP_HWCAP, KERNEL_HWCAP_WFXT),
28462842
HWCAP_CAP(ID_AA64ISAR2_EL1, MOPS, IMP, CAP_HWCAP, KERNEL_HWCAP_MOPS),
2843+
HWCAP_CAP(ID_AA64ISAR2_EL1, BC, IMP, CAP_HWCAP, KERNEL_HWCAP_HBC),
28472844
#ifdef CONFIG_ARM64_SME
28482845
HWCAP_CAP(ID_AA64PFR1_EL1, SME, IMP, CAP_HWCAP, KERNEL_HWCAP_SME),
28492846
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
@@ -126,6 +126,7 @@ static const char *const hwcap_str[] = {
126126
[KERNEL_HWCAP_SME_B16B16] = "smeb16b16",
127127
[KERNEL_HWCAP_SME_F16F16] = "smef16f16",
128128
[KERNEL_HWCAP_MOPS] = "mops",
129+
[KERNEL_HWCAP_HBC] = "hbc",
129130
};
130131

131132
#ifdef CONFIG_COMPAT

arch/arm64/kernel/fpsimd.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,22 +1178,15 @@ void sve_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
11781178
*/
11791179
u64 read_zcr_features(void)
11801180
{
1181-
u64 zcr;
1182-
unsigned int vq_max;
1183-
11841181
/*
11851182
* Set the maximum possible VL, and write zeroes to all other
11861183
* bits to see if they stick.
11871184
*/
11881185
sve_kernel_enable(NULL);
11891186
write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
11901187

1191-
zcr = read_sysreg_s(SYS_ZCR_EL1);
1192-
zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
1193-
vq_max = sve_vq_from_vl(sve_get_vl());
1194-
zcr |= vq_max - 1; /* set LEN field to maximum effective value */
1195-
1196-
return zcr;
1188+
/* Return LEN value that would be written to get the maximum VL */
1189+
return sve_vq_from_vl(sve_get_vl()) - 1;
11971190
}
11981191

11991192
void __init sve_setup(void)
@@ -1348,9 +1341,6 @@ void fa64_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
13481341
*/
13491342
u64 read_smcr_features(void)
13501343
{
1351-
u64 smcr;
1352-
unsigned int vq_max;
1353-
13541344
sme_kernel_enable(NULL);
13551345

13561346
/*
@@ -1359,12 +1349,8 @@ u64 read_smcr_features(void)
13591349
write_sysreg_s(read_sysreg_s(SYS_SMCR_EL1) | SMCR_ELx_LEN_MASK,
13601350
SYS_SMCR_EL1);
13611351

1362-
smcr = read_sysreg_s(SYS_SMCR_EL1);
1363-
smcr &= ~(u64)SMCR_ELx_LEN_MASK; /* Only the LEN field */
1364-
vq_max = sve_vq_from_vl(sme_get_vl());
1365-
smcr |= vq_max - 1; /* set LEN field to maximum effective value */
1366-
1367-
return smcr;
1352+
/* Return LEN value that would be written to get the maximum VL */
1353+
return sve_vq_from_vl(sme_get_vl()) - 1;
13681354
}
13691355

13701356
void __init sme_setup(void)

tools/testing/selftests/arm64/abi/hwcap.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ static void svebf16_sigill(void)
208208
asm volatile(".inst 0x658aa000" : : : "z0");
209209
}
210210

211+
static void hbc_sigill(void)
212+
{
213+
/* BC.EQ +4 */
214+
asm volatile("cmp xzr, xzr\n"
215+
".inst 0x54000030" : : : "cc");
216+
}
217+
211218
static const struct hwcap_data {
212219
const char *name;
213220
unsigned long at_hwcap;
@@ -386,6 +393,14 @@ static const struct hwcap_data {
386393
.hwcap_bit = HWCAP2_SVE_EBF16,
387394
.cpuinfo = "sveebf16",
388395
},
396+
{
397+
.name = "HBC",
398+
.at_hwcap = AT_HWCAP2,
399+
.hwcap_bit = HWCAP2_HBC,
400+
.cpuinfo = "hbc",
401+
.sigill_fn = hbc_sigill,
402+
.sigill_reliable = true,
403+
},
389404
};
390405

391406
static bool seen_sigill;

0 commit comments

Comments
 (0)