public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella via Libc-help <libc-help@sourceware.org>,
	"Dr. Todor Dimitrov" <dimitrov@technology.de>
Subject: Re: Glibc 2.31 - time64 with 64-bit kernel and 32-bit userland
Date: Tue, 19 Jan 2021 08:23:27 -0300	[thread overview]
Message-ID: <f6a8cba8-7b09-4883-ac41-e206241e951b@linaro.org> (raw)
In-Reply-To: <27f150dc-d721-ac60-bbdf-bd964a99b983@linaro.org>



On 18/01/2021 18:22, Adhemerval Zanella wrote:
> 
> 
> On 18/01/2021 17:35, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>>> Should we just undefined __NR_clock_gettime64 for 64-bit AArch64?
>>>
>>> No, this is armhf default binaries.  This situation is similar to
>>> i686 running on x86_64 kernels.
>>
>> It sure looks like it.  I wasn't aware that it's possible to run armhfp
>> userspace on an AArch64 kernel.
>>
>> What kind of hardware is needed for that?
>>
>> (For some reason, Fedora builds its armhfp distribution in a virtualized
>> environment.)
> 
> You need a hardware that supports ARMv8 on EL0, was described by 
> Armv8-A architecture profile (page D13-3255):
> 
> EL3, bits [15:12]
>           EL3 Exception level handling. Defined values are:
> 
>           0b0000      EL3 is not implemented.
>           0b0001      EL3 can be executed in AArch64 state only.
>           0b0010      EL3 can be executed in either AArch64 or AArch32 state.
> 
>           All other values are reserved.
> 
> EL2, bits [11:8]
>           EL2 Exception level handling. Defined values are:
> 
>           0b0000      EL2 is not implemented.
>           0b0001      EL2 can be executed in AArch64 state only.
>           0b0010      EL2 can be executed in either AArch64 or AArch32 state.
> 
>           All other values are reserved.
> 
> EL1, bits [7:4]
>           EL1 Exception level handling. Defined values are:
> 
>           0b0001      EL1 can be executed in AArch64 state only.
>           0b0010      EL1 can be executed in either AArch64 or AArch32 state.
> 
>           All other values are reserved.
> 
> EL0, bits [3:0]
>           EL0 Exception level handling. Defined values are:
> 
>           0b0001      EL0 can be executed in AArch64 state only.
>           0b0010      EL0 can be executed in either AArch64 or AArch32 state.
> 
>           All other values are reserved.
> 
> And unfortunately there is no way to access this special register without
> kernel support [2] even with 'cpuid' support (HWCAP_CPUID from hwcap) [3]
> this information is masked away due security issues.
> 
> I don't know a easy way to find out without actually issuing a arm32 binary 
> to find out if the chip does support A32 and T32 state.
> 
> The kernel also limits the compat syscall mechanism (A32 state running on
> arm64 chip):
> 
> arch/arm64/Kconfig
> 
> 1213 menuconfig COMPAT
> 1214         bool "Kernel support for 32-bit EL0"
> 1215         depends on ARM64_4K_PAGES || EXPERT
> 1216         select COMPAT_BINFMT_ELF if BINFMT_ELF
> 1217         select HAVE_UID16
> 1218         select OLD_SIGSUSPEND3
> 1219         select COMPAT_OLD_SIGACTION
> 1220         help
> 1221           This option enables support for a 32-bit EL0 running under a 64-bit
> 1222           kernel at EL1. AArch32-specific components such as system calls,
> 1223           the user helper functions, VFP support and the ptrace interface are
> 1224           handled appropriately by the kernel.
> 1225 
> 1226           If you use a page size other than 4KB (i.e, 16KB or 64KB), please be aware
> 1227           that you will only be able to execute AArch32 binaries that were compiled
> 1228           with page size aligned segments.
> 
> [1] https://developer.arm.com/documentation/ddi0487/latest/ 
> [2] https://stackoverflow.com/questions/60071590/reading-armv8-a-registers-with-devmem-from-gnu-linux-shell
> [3] https://www.kernel.org/doc/html/latest/arm64/cpu-feature-registers.html
> 

In fact checking with ARM guys there is a way to find it out on Linux:

 * if the personality(PER_LINUX32) syscall succeeds from an AArch64
   process, then 32-bit process support is present

From the commandline:
 * run 'lscpu': if its output includes the line
      CPU op-mode(s): 32-bit, 64-bit
   then both modes are supported; if it says
      CPU op-mode(s): 64-bit
   then only 64-bit is supported.
   If it says neither then the 'lscpu' binary is too old 
   (lscpu is running "personality(PER_LINUX32)" to find this info.)

      reply	other threads:[~2021-01-19 11:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 17:43 Dr. Todor Dimitrov
2021-01-18 17:51 ` Florian Weimer
2021-01-18 17:57   ` Dr. Todor Dimitrov
2021-01-18 19:31 ` Adhemerval Zanella
2021-01-18 20:10   ` Dr. Todor Dimitrov
2021-01-18 20:14   ` Florian Weimer
2021-01-18 20:31     ` Adhemerval Zanella
2021-01-18 20:35       ` Florian Weimer
2021-01-18 21:22         ` Adhemerval Zanella
2021-01-19 11:23           ` Adhemerval Zanella [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f6a8cba8-7b09-4883-ac41-e206241e951b@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=dimitrov@technology.de \
    --cc=fweimer@redhat.com \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).