andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0013-Ticket-48925-slapd-crash-with-SIGILL-Dsktune-should-.patch

7c7f29
From 9f8d3fc5bd7cb1e00b6bd48669b8074849f4c5da Mon Sep 17 00:00:00 2001
7c7f29
From: William Brown <firstyear@redhat.com>
7c7f29
Date: Thu, 14 Jul 2016 13:47:11 +1000
7c7f29
Subject: [PATCH 13/15] Ticket 48925 - slapd crash with SIGILL: Dsktune should
7c7f29
 detect lack of CMPXCHG16B
7c7f29
7c7f29
Bug Description:  On older AMD the CMPXCHG16B is not present. This is critical
7c7f29
to the correct operation of lfds. Without out it we are unable to use nunc-stans
7c7f29
7c7f29
Fix Description:  dsktune should warn if CMPXCHG16B (flag cx16) is not present.
7c7f29
In a future release we will NOT allow installation upon a platform that lacks
7c7f29
this instruction.
7c7f29
7c7f29
https://fedorahosted.org/389/ticket/48925
7c7f29
7c7f29
Author: wibrown
7c7f29
7c7f29
Review by: nhosoi (Thank you!)
7c7f29
7c7f29
(cherry picked from commit 5eb19778f7939967e8ca714c4d4cb03ffa11064d)
7c7f29
---
7c7f29
 ldap/systools/idsktune.c | 40 +++++++++++++++++++++++++++++++++++++++-
7c7f29
 1 file changed, 39 insertions(+), 1 deletion(-)
7c7f29
7c7f29
diff --git a/ldap/systools/idsktune.c b/ldap/systools/idsktune.c
7c7f29
index c7e76e7..b6c352a 100644
7c7f29
--- a/ldap/systools/idsktune.c
7c7f29
+++ b/ldap/systools/idsktune.c
7c7f29
@@ -11,11 +11,12 @@
7c7f29
 #  include <config.h>
7c7f29
 #endif
7c7f29
 
7c7f29
+#define _GNU_SOURCE
7c7f29
 
7c7f29
 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7c7f29
  *    Don't forget to update build_date when the patch sets are updated. 
7c7f29
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
7c7f29
-static char *build_date = "23-FEBRUARY-2012";
7c7f29
+static char *build_date = "14-JULY-2016";
7c7f29
 
7c7f29
 #if defined(linux) || defined(__linux) || defined(__linux__)
7c7f29
 #define IDDS_LINUX_INCLUDE 1
7c7f29
@@ -32,10 +33,12 @@ static char *build_date = "23-FEBRUARY-2012";
7c7f29
 #include <sys/resource.h>
7c7f29
 #include <unistd.h>
7c7f29
 #endif
7c7f29
+
7c7f29
 #include <stdlib.h>
7c7f29
 #include <string.h>
7c7f29
 #include <errno.h>
7c7f29
 #include <ctype.h>
7c7f29
+
7c7f29
 #if !defined(__VMS) && !defined(IDDS_LINUX_INCLUDE)
7c7f29
 #if defined(__hpux) && defined(f_type)
7c7f29
 #undef f_type
7c7f29
@@ -864,6 +867,39 @@ done:
7c7f29
         free(cmd);
7c7f29
     }
7c7f29
 }
7c7f29
+
7c7f29
+
7c7f29
+static void
7c7f29
+linux_check_cpu_features(void)
7c7f29
+{
7c7f29
+    FILE *cpuinfo = fopen("/proc/cpuinfo", "rb");
7c7f29
+    char *arg = 0;
7c7f29
+    char *token = NULL;
7c7f29
+    size_t size = 0;
7c7f29
+    int found = 0;
7c7f29
+    while(getline(&arg, &size, cpuinfo) != -1)
7c7f29
+    {
7c7f29
+        if (strncmp("flags", arg, 5) == 0) {
7c7f29
+            token = strtok(arg, " ");
7c7f29
+            while (token != NULL) {
7c7f29
+                if (strncmp(token, "cx16", 4) == 0) {
7c7f29
+                    found += 1;
7c7f29
+                }
7c7f29
+                token = strtok(NULL, " ");
7c7f29
+            }
7c7f29
+        }
7c7f29
+    }
7c7f29
+    free(arg);
7c7f29
+    fclose(cpuinfo);
7c7f29
+
7c7f29
+    if (found == 0) {
7c7f29
+        flag_os_bad = 1;
7c7f29
+        printf("ERROR: This system does not support CMPXCHG16B instruction (cpuflag cx16).\n");
7c7f29
+        printf("       nsslapd-enable-nunc-stans must be set to "off" on this system. \n");
7c7f29
+        printf("       In a future release of Directory Server this platform will NOT be supported.\n\n");
7c7f29
+    }
7c7f29
+
7c7f29
+}
7c7f29
 #endif /* IDDS_LINUX_INCLUDE */
7c7f29
 
7c7f29
 
7c7f29
@@ -976,6 +1012,8 @@ static void gen_tests (void)
7c7f29
 
7c7f29
 #if defined(IDDS_LINUX_INCLUDE)
7c7f29
     linux_check_release();
7c7f29
+
7c7f29
+    linux_check_cpu_features();
7c7f29
 #endif
7c7f29
 
7c7f29
 
7c7f29
-- 
7c7f29
2.4.11
7c7f29