linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Detecting AArch32 support from a AArch64 process in user space
@ 2019-08-08  7:36 Stefan Agner
  2019-08-08  9:04 ` Marc Zyngier
  2019-08-08  9:35 ` Dave Martin
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Agner @ 2019-08-08  7:36 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, ynorov, will.deacon, suzuki.poulose

[resend this time with the correct mailing list address]

Hello,

I am trying to detect whether an ARMv8 system running in AArch64 state
supports AArch32 state from a user space process. The arm64_features[]
in
arch/arm64/kernel/cpufeature.c lists a CPU feature "32-bit EL0 Support".
However, afaik this CPU feature is not directly exposed to user-space.
The features do get printed in the kernel log, but that requires
privileges and only works directly after boot. There is
system_supports_32bit_el0() which is used in various places in the arm64
architecture code. One of the instances where I can make sense of from
user space is through the personality system call. One idea is to call
personality(PER_LINUX32). It would then return error code 22 in case
32-bit is not supported in user space. However, if successful this
changes the personality of the current process which might have side
effects which I do not want...?

I started to ask myself what PER_LINUX32 actually changes. From what I
can tell it only changes the behavior of /proc/cpuinfo? The personality
seems not to be applied automatically to 32-bit processes, so this is a
opt-in backward compatibility feature?

To be on the safe side, I was thinking about executing the system call
in a separate process. However, at that point I could also just execute
a statically linked AArch32 binary and see whether I get a "exec format
error". I guess this could then be either due to missing AArch32 CPU
support or the kernel not being compiled with 32-bit compatibility.

At last I was considering reading directly from the CPU. But from what I
understand the register used in the kernel to determine 32-bit
compatibility (ID_AA64PFR0_EL1) is not accessible by user space (due to
the suffix _EL1).

Any advice/thoughts on this topic?

--
Stefan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-08-08 11:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-08  7:36 Detecting AArch32 support from a AArch64 process in user space Stefan Agner
2019-08-08  9:04 ` Marc Zyngier
2019-08-08  9:15   ` Will Deacon
2019-08-08 10:22     ` Stefan Agner
2019-08-08 10:41       ` Stefan Agner
2019-08-08 10:17   ` Stefan Agner
2019-08-08 11:31     ` Dave Martin
2019-08-08  9:35 ` Dave Martin
2019-08-08 10:30   ` Stefan Agner
2019-08-08 11:28     ` Dave Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).