* [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
@ 2019-09-30 9:30 brandon.hong
2019-09-30 9:53 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix global symbol loading failure in resolve function (rev4) Patchwork
2019-09-30 11:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
0 siblings, 2 replies; 10+ messages in thread
From: brandon.hong @ 2019-09-30 9:30 UTC (permalink / raw)
To: igt-dev
From: Brandon Hong <brandon.hong@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.
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
---
lib/igt_halffloat.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
index 08ab05fc..e5e8a5bd 100644
--- a/lib/igt_halffloat.c
+++ b/lib/igt_halffloat.c
@@ -24,6 +24,19 @@
#include <assert.h>
#include <math.h>
+#include <stdbool.h>
+
+#ifdef HAVE_CPUID_H
+#include <cpuid.h>
+#else
+#define __get_cpuid_max(x, y) 0
+#define __cpuid(level, a, b, c, d) a = b = c = d = 0
+#define __cpuid_count(level, count, a, b, c, d) a = b = c = d = 0
+#endif
+
+#ifndef bit_F16C
+#define bit_F16C (1 << 29)
+#endif
#include "igt_halffloat.h"
#include "igt_x86.h"
@@ -182,6 +195,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++)
@@ -196,7 +223,7 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
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 +234,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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
@ 2019-09-30 9:06 brandon.hong
0 siblings, 0 replies; 10+ messages in thread
From: brandon.hong @ 2019-09-30 9:06 UTC (permalink / raw)
To: igt-dev
From: Brandon Hong <brandon.hong@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.
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
---
lib/igt_halffloat.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
index 08ab05fc..ec365829 100644
--- a/lib/igt_halffloat.c
+++ b/lib/igt_halffloat.c
@@ -24,6 +24,15 @@
#include <assert.h>
#include <math.h>
+#include <stdbool.h>
+
+#ifdef HAVE_CPUID_H
+#include <cpuid.h>
+#else
+#define __get_cpuid_max(x, y) 0
+#define __cpuid(level, a, b, c, d) a = b = c = d = 0
+#define __cpuid_count(level, count, a, b, c, d) a = b = c = d = 0
+#endif
#include "igt_halffloat.h"
#include "igt_x86.h"
@@ -182,6 +191,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++)
@@ -196,7 +219,7 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
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 +230,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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
@ 2019-09-24 14:02 brandon.hong
2019-09-27 17:26 ` Ville Syrjälä
0 siblings, 1 reply; 10+ messages in thread
From: brandon.hong @ 2019-09-24 14:02 UTC (permalink / raw)
To: igt-dev
From: Brandon Hong <brandon.hong@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.
Signed-off-by: Brandon Hong <brandon.hong@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>
+
#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]);
}
+
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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
2019-09-24 14:02 brandon.hong
@ 2019-09-27 17:26 ` Ville Syrjälä
2019-09-30 9:04 ` Hong, Brandon
0 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2019-09-27 17:26 UTC (permalink / raw)
To: brandon.hong; +Cc: igt-dev
On Tue, Sep 24, 2019 at 10:02:29PM +0800, brandon.hong@intel.com wrote:
> From: Brandon Hong <brandon.hong@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@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@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
2019-09-27 17:26 ` Ville Syrjälä
@ 2019-09-30 9:04 ` Hong, Brandon
0 siblings, 0 replies; 10+ messages in thread
From: Hong, Brandon @ 2019-09-30 9:04 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: igt-dev
> On 28 Sep 2019, at 2:26 AM, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
>
> On Tue, Sep 24, 2019 at 10:02:29PM +0800, brandon.hong@intel.com wrote:
>> From: Brandon Hong <brandon.hong@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@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?
Thanks for pointing it out. Will add HAVE_CPUID_H as same as igt_x86.c file.
>
>> +
>> #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.
Will remove it and re-submit.
>
>> 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@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/igt-dev
>
> --
> Ville Syrjälä
> Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 10+ messages in thread
* [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
@ 2019-09-24 8:02 brandon.hong
2019-09-24 8:26 ` Chris Wilson
0 siblings, 1 reply; 10+ messages in thread
From: brandon.hong @ 2019-09-24 8:02 UTC (permalink / raw)
To: igt-dev
From: Brandon Hong <brandon.hong@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.
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
---
lib/igt_halffloat.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
index 08ab05fc..17e9cf9d 100644
--- a/lib/igt_halffloat.c
+++ b/lib/igt_halffloat.c
@@ -24,6 +24,8 @@
#include <assert.h>
#include <math.h>
+#include <stdbool.h>
+#include <cpuid.h>
#include "igt_halffloat.h"
#include "igt_x86.h"
@@ -182,6 +184,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 +210,10 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
f[i] = _half_to_float(h[i]);
}
+
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 +224,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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
2019-09-24 8:02 brandon.hong
@ 2019-09-24 8:26 ` Chris Wilson
2019-09-24 14:22 ` Hong, Brandon
0 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2019-09-24 8:26 UTC (permalink / raw)
To: brandon.hong, igt-dev
Quoting brandon.hong@intel.com (2019-09-24 09:02:07)
> From: Brandon Hong <brandon.hong@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.
So, out of curiosity, why is the global function not bound?
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
2019-09-24 8:26 ` Chris Wilson
@ 2019-09-24 14:22 ` Hong, Brandon
0 siblings, 0 replies; 10+ messages in thread
From: Hong, Brandon @ 2019-09-24 14:22 UTC (permalink / raw)
To: Chris Wilson; +Cc: igt-dev
Unfortunately, I do not have a clear answer why it's not bound.
I guess it's related to IFUNC lazy binding because I observed crash call stack related to glibc elf_machine_rela() and the crash didn’t happen when I call the same global function igt_x86_features() in rewritten generic FUNC igt_half_to_float() for testing.
- Brandon
> On 24 Sep 2019, at 5:26 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Quoting brandon.hong@intel.com (2019-09-24 09:02:07)
>> From: Brandon Hong <brandon.hong@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.
>
> So, out of curiosity, why is the global function not bound?
> -Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-09-30 11:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 9:30 [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function brandon.hong
2019-09-30 9:53 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix global symbol loading failure in resolve function (rev4) Patchwork
2019-09-30 11:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2019-09-30 9:06 [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function brandon.hong
2019-09-24 14:02 brandon.hong
2019-09-27 17:26 ` Ville Syrjälä
2019-09-30 9:04 ` Hong, Brandon
2019-09-24 8:02 brandon.hong
2019-09-24 8:26 ` Chris Wilson
2019-09-24 14:22 ` Hong, Brandon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.