On 2014-06-23 21:10:14 +0300, Martin Storsjö wrote:
> When running on a 64 bit kernel, /proc/cpuinfo does not list
> the cpu features that aren't optional on such CPUs.
> 
> A 32 bit binary which runs on such a kernel, that tries to parse
> /proc/cpuinfo to find the relevant cpu features at runtime, won't
> thus detect those features, unless it is assumed that CPU architecture
> >= 8 implies a set of features.
> 
> The kernel does list these features properly if they are queried
> via /proc/self/auxv though - however this file is not always readable
> (e.g. on most android systems).
> 
> This is similar to what the android cpufeatures library will do
> starting from the next release. See [1] for details.
> 
> It has been suggested to include the non-optional features in
> /proc/cpuinfo as well, but that suggested patch never was merged.
> See [2] for the discussion around this suggestion.
> 
> [1] https://android-review.googlesource.com/91380
> [2] http://marc.info/?l=linux-arm-kernel&m=139087240101974
> 
> ---
> This is untested in practice due to the lack of a real ARMv8
> device.
> ---
>  libavutil/arm/cpu.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
> index 85ea662..5644ffe 100644
> --- a/libavutil/arm/cpu.c
> +++ b/libavutil/arm/cpu.c
> @@ -16,6 +16,8 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> +#include <stdlib.h>
> +
>  #include "libavutil/cpu.h"
>  #include "libavutil/cpu_internal.h"
>  #include "config.h"
> @@ -92,7 +94,19 @@ static int get_cpuinfo(uint32_t *hwcap)
>                  *hwcap |= HWCAP_VFPv3;
>              if (strstr(buf, " neon "))
>                  *hwcap |= HWCAP_NEON;
> -            break;
> +        } else if (av_strstart(buf, "CPU architecture", NULL)) {
> +            char *sep = strchr(buf, ':');
> +            if (sep) {
> +                char *val = sep + 1;
> +                int arch;
> +                val += strspn(val, " \t");
> +                arch = atoi(val);
> +                if (arch >= 8) {
> +                    /* These features are non-optional in ARMv8, and aren't
> +                     * listed in cpuinfo on 64 bit kernels. */
> +                    *hwcap |= HWCAP_VFP | HWCAP_VFPv3 | HWCAP_NEON;
> +                }
> +            }

Setting 'HWCAP_VFP | HWCAP_VFPv3' based on " fp" and HWCAP_NEON on asimd 
in Features seems to be an easier solution and would even work in the 
unlikely case that one of the features is not available.

I can test with ARM's simulator.

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to