]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: Add aarch32 detection on aarch64
authorJeremy Linton <lintonrjeremy@gmail.com>
Tue, 11 Dec 2018 18:27:29 +0000 (12:27 -0600)
committerJeremy Linton <lintonrjeremy@gmail.com>
Tue, 11 Dec 2018 18:27:29 +0000 (12:27 -0600)
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>
sys-utils/lscpu.c

index 1ff9069f34d670262106cb2594640d32d03f7a59..245be6e5ce4837956642ea07066bb549f5051f7f 100644 (file)
@@ -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;
 }