Skip to content

Commit 0f05dad

Browse files
committed
Merge branch 'for-next/sme' into for-next/core
* for-next/sme: arm64/fpsimd: Remove duplicate SYS_SVCR read arm64/signal: Clean up SVE/SME feature checking inconsistency arm64/sme: Expose SMIDR through sysfs
2 parents 288e21b + 4139320 commit 0f05dad

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,13 @@ What: /sys/devices/system/cpu/cpuX/regs/
493493
/sys/devices/system/cpu/cpuX/regs/identification/
494494
/sys/devices/system/cpu/cpuX/regs/identification/midr_el1
495495
/sys/devices/system/cpu/cpuX/regs/identification/revidr_el1
496+
/sys/devices/system/cpu/cpuX/regs/identification/smidr_el1
496497
Date: June 2016
497498
Contact: Linux ARM Kernel Mailing list <[email protected]>
498499
Description: AArch64 CPU registers
499500

500501
'identification' directory exposes the CPU ID registers for
501-
identifying model and revision of the CPU.
502+
identifying model and revision of the CPU and SMCU.
502503

503504
What: /sys/devices/system/cpu/aarch32_el0
504505
Date: May 2021

arch/arm64/include/asm/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct cpuinfo_arm64 {
4646
u64 reg_midr;
4747
u64 reg_revidr;
4848
u64 reg_gmid;
49+
u64 reg_smidr;
4950

5051
u64 reg_id_aa64dfr0;
5152
u64 reg_id_aa64dfr1;

arch/arm64/kernel/cpuinfo.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ static struct kobj_type cpuregs_kobj_type = {
267267

268268
CPUREGS_ATTR_RO(midr_el1, midr);
269269
CPUREGS_ATTR_RO(revidr_el1, revidr);
270+
CPUREGS_ATTR_RO(smidr_el1, smidr);
270271

271272
static struct attribute *cpuregs_id_attrs[] = {
272273
&cpuregs_attr_midr_el1.attr,
@@ -279,6 +280,16 @@ static const struct attribute_group cpuregs_attr_group = {
279280
.name = "identification"
280281
};
281282

283+
static struct attribute *sme_cpuregs_id_attrs[] = {
284+
&cpuregs_attr_smidr_el1.attr,
285+
NULL
286+
};
287+
288+
static const struct attribute_group sme_cpuregs_attr_group = {
289+
.attrs = sme_cpuregs_id_attrs,
290+
.name = "identification"
291+
};
292+
282293
static int cpuid_cpu_online(unsigned int cpu)
283294
{
284295
int rc;
@@ -296,6 +307,8 @@ static int cpuid_cpu_online(unsigned int cpu)
296307
rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group);
297308
if (rc)
298309
kobject_del(&info->kobj);
310+
if (system_supports_sme())
311+
rc = sysfs_merge_group(&info->kobj, &sme_cpuregs_attr_group);
299312
out:
300313
return rc;
301314
}
@@ -423,9 +436,17 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
423436
info->reg_zcr = read_zcr_features();
424437

425438
if (IS_ENABLED(CONFIG_ARM64_SME) &&
426-
id_aa64pfr1_sme(info->reg_id_aa64pfr1))
439+
id_aa64pfr1_sme(info->reg_id_aa64pfr1)) {
427440
info->reg_smcr = read_smcr_features();
428441

442+
/*
443+
* We mask out SMPS since even if the hardware
444+
* supports priorities the kernel does not at present
445+
* and we block access to them.
446+
*/
447+
info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS;
448+
}
449+
429450
cpuinfo_detect_icache_policy(info);
430451
}
431452

arch/arm64/kernel/fpsimd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ static void fpsimd_save(void)
445445

446446
if (system_supports_sme()) {
447447
u64 *svcr = last->svcr;
448-
*svcr = read_sysreg_s(SYS_SVCR);
449448

450449
*svcr = read_sysreg_s(SYS_SVCR);
451450

arch/arm64/kernel/signal.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
280280

281281
vl = task_get_sme_vl(current);
282282
} else {
283+
if (!system_supports_sve())
284+
return -EINVAL;
285+
283286
vl = task_get_sve_vl(current);
284287
}
285288

@@ -342,9 +345,14 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
342345

343346
#else /* ! CONFIG_ARM64_SVE */
344347

345-
/* Turn any non-optimised out attempts to use these into a link error: */
348+
static int restore_sve_fpsimd_context(struct user_ctxs *user)
349+
{
350+
WARN_ON_ONCE(1);
351+
return -EINVAL;
352+
}
353+
354+
/* Turn any non-optimised out attempts to use this into a link error: */
346355
extern int preserve_sve_context(void __user *ctx);
347-
extern int restore_sve_fpsimd_context(struct user_ctxs *user);
348356

349357
#endif /* ! CONFIG_ARM64_SVE */
350358

@@ -649,14 +657,10 @@ static int restore_sigframe(struct pt_regs *regs,
649657
if (!user.fpsimd)
650658
return -EINVAL;
651659

652-
if (user.sve) {
653-
if (!system_supports_sve())
654-
return -EINVAL;
655-
660+
if (user.sve)
656661
err = restore_sve_fpsimd_context(&user);
657-
} else {
662+
else
658663
err = restore_fpsimd_context(user.fpsimd);
659-
}
660664
}
661665

662666
if (err == 0 && system_supports_sme() && user.za)

0 commit comments

Comments
 (0)