From: Jeremy Linton Date: Tue, 11 Dec 2018 18:27:29 +0000 (-0600) Subject: lscpu: Add aarch32 detection on aarch64 X-Git-Tag: v2.34-rc1~182^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32865bd5df59f14fd3fe6651acebde99b0691b5d;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 1ff9069f34..245be6e5ce 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -33,6 +33,7 @@ #include #include #include +#include #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; }