All of lore.kernel.org
 help / color / mirror / Atom feed
From: brandon.hong@intel.com
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] Fix global symbol loading failure in resolve function
Date: Mon, 30 Sep 2019 17:30:18 +0800	[thread overview]
Message-ID: <20190930093018.32402-1-brandon.hong@intel.com> (raw)

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

             reply	other threads:[~2019-09-30  9:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30  9:30 brandon.hong [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190930093018.32402-1-brandon.hong@intel.com \
    --to=brandon.hong@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.