I'm running Cog on aarch64, and because I have an old linux kernel (v3.18.140) which I cannot upgrade (it's a repurposed PostmarketOS Android device), Cog yields illegal instruction trying to execute `mrs x0, id_aa64isar0_el1`. This instruction is privileged, but later linux kernels trap and emulate it for userspace.
Given that it's currently only being used to detect presence of atomic instructions (`self setHasAtomicInstructions: (idISAR0 >> 20 bitAnd: 2r1111) = 2r10`), and there's a kernel API for retrieving that specific bit of information (https://www.kernel.org/doc/html/latest/arm64/elf_hwcaps.html suggests HWCAP_ATOMICS), perhaps instead of using the instruction directly Cog could call the relevant `getauxval` variant?
For now, I have the Stack VM running well on aarch64, so I can make progress, even if it is a little slower than it could be :-)
Hi Tony,
On Nov 29, 2021, at 7:51 AM, Tony Garnock-Jones ***@***.***> wrote:
I'm running Cog on aarch64, and because I have an old linux kernel (v3.18.140) which I cannot upgrade (it's a repurposed PostmarketOS Android device), Cog yields illegal instruction trying to execute mrs x0, id_aa64isar0_el1. This instruction is privileged, but later linux kernels trap and emulate it for userspace.
Given that it's currently only being used to detect presence of atomic instructions (self setHasAtomicInstructions: (idISAR0 >> 20 bitAnd: 2r1111) = 2r10), and there's a kernel API for retrieving that specific bit of information (https://www.kernel.org/doc/html/latest/arm64/elf_hwcaps.html suggests HWCAP_ATOMICS), perhaps instead of using the instruction directly Cog could call the relevant getauxval variant?
Good suggestion. I’ll try and get this folded in I the next couple of days.
For now, I have the Stack VM running well on aarch64, so I can make progress, even if it is a little slower than it could be :-)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Closed #608.
Should be fixed by 6f2914e4484fa2d6f0e0107391b674daea85b60c Author: Eliot Miranda eliot.miranda@gmail.com Date: Thu Dec 2 14:03:25 2021 -0800
CogVm source as per VMMaker.oscog-eem.3117
Cog ARMv8: Since id_aa64isar0_el1 is a priviledged instruction use getauxval on linux to derive the value(s) derived there-from, currenty whether atomic instructions are available or not. This addresses opensmalltalk-vm Issue #608.
Amazing, thank you very much Eliot!
Just reporting back: running the latest Cog VM on aarch64 on PostmarketOS (i.e. Alpine) on Pinephone 1.2 works very well. No problems with illegal instructions. (I did have to `mount -o remount,exec /dev/shm` to allow the `mprotect` with `PROT_EXEC` to work, but other than that, no hitches.)
vm-dev@lists.squeakfoundation.org