Skip to content

Commit 7af3350

Browse files
willdeaconPeter Zijlstra
authored andcommitted
arm64: Advertise CPUs capable of running 32-bit applications in sysfs
Since 32-bit applications will be killed if they are caught trying to execute on a 64-bit-only CPU in a mismatched system, advertise the set of 32-bit capable CPUs to userspace in sysfs. Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent df95081 commit 7af3350

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,15 @@ Description: AArch64 CPU registers
494494
'identification' directory exposes the CPU ID registers for
495495
identifying model and revision of the CPU.
496496

497+
What: /sys/devices/system/cpu/aarch32_el0
498+
Date: May 2021
499+
Contact: Linux ARM Kernel Mailing list <[email protected]>
500+
Description: Identifies the subset of CPUs in the system that can execute
501+
AArch32 (32-bit ARM) applications. If present, the same format as
502+
/sys/devices/system/cpu/{offline,online,possible,present} is used.
503+
If absent, then all or none of the CPUs can execute AArch32
504+
applications and execve() will behave accordingly.
505+
497506
What: /sys/devices/system/cpu/cpu#/cpu_capacity
498507
Date: December 2016
499508
Contact: Linux kernel mailing list <[email protected]>

arch/arm64/kernel/cpufeature.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include <linux/crash_dump.h>
6868
#include <linux/sort.h>
6969
#include <linux/stop_machine.h>
70+
#include <linux/sysfs.h>
7071
#include <linux/types.h>
7172
#include <linux/minmax.h>
7273
#include <linux/mm.h>
@@ -1321,6 +1322,24 @@ const struct cpumask *system_32bit_el0_cpumask(void)
13211322
return cpu_possible_mask;
13221323
}
13231324

1325+
static ssize_t aarch32_el0_show(struct device *dev,
1326+
struct device_attribute *attr, char *buf)
1327+
{
1328+
const struct cpumask *mask = system_32bit_el0_cpumask();
1329+
1330+
return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(mask));
1331+
}
1332+
static const DEVICE_ATTR_RO(aarch32_el0);
1333+
1334+
static int __init aarch32_el0_sysfs_init(void)
1335+
{
1336+
if (!allow_mismatched_32bit_el0)
1337+
return 0;
1338+
1339+
return device_create_file(cpu_subsys.dev_root, &dev_attr_aarch32_el0);
1340+
}
1341+
device_initcall(aarch32_el0_sysfs_init);
1342+
13241343
static bool has_32bit_el0(const struct arm64_cpu_capabilities *entry, int scope)
13251344
{
13261345
if (!has_cpuid_feature(entry, scope))

0 commit comments

Comments
 (0)