From 32865bd5df59f14fd3fe6651acebde99b0691b5d Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Tue, 11 Dec 2018 12:27:29 -0600 Subject: [PATCH] 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 --- sys-utils/lscpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; } -- 2.47.2