[igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
Ville Syrjälä
ville.syrjala at linux.intel.com
Fri Sep 27 17:26:19 UTC 2019
On Tue, Sep 24, 2019 at 10:02:29PM +0800, brandon.hong at intel.com wrote:
> From: Brandon Hong <brandon.hong at intel.com>
>
> 270 out of 284 tests get failed with SIGSEGV on ClearLinux because the ifunc
> resolver resolve_half_to_float() tries to call unbound global function
> igt_x86_features(). This patch fixes the issue by adding a F16C checking
> local function.
The rules for this stuff seem to be poorly documented. But I did find
some docs that support this. So generally lgtm, just a few nitpicks
below...
>
> Signed-off-by: Brandon Hong <brandon.hong at intel.com>
> ---
> lib/igt_halffloat.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
> index 08ab05fc..fa7ad2e0 100644
> --- a/lib/igt_halffloat.c
> +++ b/lib/igt_halffloat.c
> @@ -24,6 +24,7 @@
>
> #include <assert.h>
> #include <math.h>
> +#include <stdbool.h>
>
> #include "igt_halffloat.h"
> #include "igt_x86.h"
> @@ -163,6 +164,8 @@ static inline float _half_to_float(uint16_t val)
> }
>
> #if defined(__x86_64__) && !defined(__clang__)
> +#include <cpuid.h>
igt_x86.c has HAVE_CPUID_H protection around this stuff.
I suppose we'd want the same here?
> +
> #pragma GCC push_options
> #pragma GCC target("f16c")
>
> @@ -182,6 +185,20 @@ static void half_to_float_f16c(const uint16_t *h, float *f, unsigned int num)
>
> #pragma GCC pop_options
>
> +static bool f16c_is_supported(void)
> +{
> + unsigned max = __get_cpuid_max(0, NULL);
> + unsigned eax, ebx, ecx, edx;
> +
> + if (max >= 1) {
> + __cpuid(1, eax, ebx, ecx, edx);
> +
> + if (ecx & bit_F16C)
> + return true;
> + }
> + return false;
> +}
> +
> static void float_to_half(const float *f, uint16_t *h, unsigned int num)
> {
> for (int i = 0; i < num; i++)
> @@ -194,9 +211,10 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
> f[i] = _half_to_float(h[i]);
> }
>
> +
Spurious newline.
> static void (*resolve_float_to_half(void))(const float *f, uint16_t *h, unsigned int num)
> {
> - if (igt_x86_features() & F16C)
> + if (f16c_is_supported())
> return float_to_half_f16c;
>
> return float_to_half;
> @@ -207,7 +225,7 @@ void igt_float_to_half(const float *f, uint16_t *h, unsigned int num)
>
> static void (*resolve_half_to_float(void))(const uint16_t *h, float *f, unsigned int num)
> {
> - if (igt_x86_features() & F16C)
> + if (f16c_is_supported())
> return half_to_float_f16c;
>
> return half_to_float;
> --
> 2.23.0
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Ville Syrjälä
Intel
More information about the igt-dev
mailing list