[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Are G3/ no altivec cpu still usable on Debian?



On Sun, Jun 4, 2023 at 6:15 AM Lorenzo <plorenzo@disroot.org> wrote:
>
> On Sat, 03 Jun 2023 12:14:47 +0200
> John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:
>
> > Hello!
> >
> > On Sat, 2023-06-03 at 11:29 +0200, Lorenzo wrote:
> > > There is a bug in mplayer [1] that could be fixed by building a
> > > variant of mplayer without altivec, however I can't tell if such
> > > bug can still be triggered nowadays. The ppc port is gone right?
> > > Are cpus without altivec still usable on one of Debian's powerpc
> > > ports?
> >
> > No, Debian for 32-bit PowerPC is still maintained as an unofficial
> > port:
> >
> > > https://cdimage.debian.org/cdimage/ports/snapshots/2023-05-28/debian-12.0.0-powerpc-NETINST-1.iso
> >
> > As for Altivec support in mplayer: Have you tried the latest version?
> > It might be possible there is proper runtime detection these days.
>
> According to mplayer upstream [1] "AltiVec runtime detection never
> worked reliably" and "the way it was detected in libavcodec was an
> unacceptable hack".. that was in back in 2007, I'll check if upstream
> still consider runtime detection unfeasible.
>
> [...]
>
> [1]https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=448105

Altivec detection on Linux is relatively easy nowadays using
getauxval(). From
https://github.com/weidai11/cryptopp/blob/master/cpu.cpp#L1210 :

inline bool CPU_QueryAltivec()
{
#if defined(__linux__) && defined(PPC_FEATURE_HAS_ALTIVEC)
    if ((getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC) != 0)
        return true;
#elif defined(_AIX)
    if (__power_6_andup() != 0)
        return true;
#elif ...
#endif
    return false;
}

Botan uses similar runtime detection via getauxval() at
https://github.com/randombit/botan/blob/master/src/lib/utils/cpuid/cpuid_ppc.cpp.

OpenSSL performs runtime probes in
https://github.com/openssl/openssl/blob/master/crypto/ppccap.c. But
instead of using a query via getauxval(), OpenSSL does a runtime probe
by executing an Altivec instruction. If a SIGILL is encountered, then
Altivec is false.

The tricky machines are Apple running MacOS 9 and OS X. You have to be
careful of runtime probes and SIGILLs. On Apple machines, memory
corruption happens with runtime CPU probes.

Jeff


Reply to: