summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorJeremy Linton2018-12-11 19:27:29 +0100
committerJeremy Linton2018-12-11 19:27:29 +0100
commit32865bd5df59f14fd3fe6651acebde99b0691b5d (patch)
tree29e495f1370d8a0aa53c12d19516ed8379dca690 /sys-utils/lscpu.c
parentlslogins: make valid_pwd() more robust (diff)
downloadkernel-qcow2-util-linux-32865bd5df59f14fd3fe6651acebde99b0691b5d.tar.gz
kernel-qcow2-util-linux-32865bd5df59f14fd3fe6651acebde99b0691b5d.tar.xz
kernel-qcow2-util-linux-32865bd5df59f14fd3fe6651acebde99b0691b5d.zip
lscpu: Add aarch32 detection on aarch64
aarch32 support is an optional feature of ARMv8, as CPUs which don't support aarch32 become more common, lets make sure that lscpu can tell a user quickly if they are on a machine that only supports 64-bit. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1ff9069f3..245be6e5c 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -33,6 +33,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/personality.h>
#if (defined(__x86_64__) || defined(__i386__))
# if !defined( __SANITIZE_ADDRESS__)
@@ -332,6 +333,19 @@ init_mode(struct lscpu_modifier *mod)
defined(__s390x__) || defined(__s390__) || defined(__sparc_v9__)
m |= MODE_32BIT;
#endif
+
+#if defined(__aarch64__)
+ {
+ /* personality() is the most reliable way (since 4.7)
+ * to determine aarch32 support */
+ int pers = personality(PER_LINUX32);
+ if (pers != -1) {
+ personality(pers);
+ m |= MODE_32BIT;
+ }
+ m |= MODE_64BIT;
+ }
+#endif
return m;
}