View Issue Details

IDProjectCategoryView StatusLast Update
0000914channel: kernel/el7kernel-ltpublic2019-05-22 08:03
Reporterburakkucat Assigned Toburakkucat  
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Summary0000914: Unable to build the turbostat binary for the kernel-lt-4.4.180-1.el7.elrepo package set.
DescriptionAttempts to build the turbostat binary, part of the tools sub-package, fails with the following error --

[Build64R7 linux-stable-tmp]$ make -C tools/power/x86/turbostat/
make: Entering directory `/home/bcat/tmp/turbostat/linux-stable-tmp/tools/power/x86/turbostat'
gcc -Wall -I../../../include -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"' turbostat.c -o /home/bcat/tmp/turbostat/linux-stable-tmp/tools/power/x86/turbostat/turbostat
In file included from turbostat.c:23:0:
../../../../arch/x86/include/asm/msr-index.h:4:24: fatal error: linux/bits.h: No such file or directory
 #include <linux/bits.h>
                        ^
compilation terminated.
make: *** [turbostat] Error 1
make: Leaving directory `/home/bcat/tmp/turbostat/linux-stable-tmp/tools/power/x86/turbostat'
[Build64R7 linux-stable-tmp]$

A bisection of the source tree discloses the following bad commit --

683f9fba8c27817b6c2f7320a4095ca353022651 is the first bad commit
commit 683f9fba8c27817b6c2f7320a4095ca353022651
Author: Thomas Gleixner <tglx@linutronix.de>
Date: Thu Feb 21 12:36:50 2019 +0100

    x86/msr-index: Cleanup bit defines
    
    commit d8eabc37310a92df40d07c5a8afc53cebf996716 upstream.
    
    Greg pointed out that speculation related bit defines are using (1 << N)
    format instead of BIT(N). Aside of that (1 << N) is wrong as it should use
    1UL at least.
    
    Clean it up.
    
    [ Josh Poimboeuf: Fix tools build ]
    
    Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
    Reviewed-by: Jon Masters <jcm@redhat.com>
    Tested-by: Jon Masters <jcm@redhat.com>
    [bwh: Backported to 4.4:
     - Drop change to x86_energy_perf_policy, which doesn't use msr-index.h here
     - Drop changes to flush MSRs which we haven't defined]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

:040000 040000 0ce430a14e73eef1007bf1558693e75e95ffe39a 3ab5675ed0798fc61e7d67ade87ac58dbbf33756 M arch
:040000 040000 d45f1a90570a44d8924711e56280cde7041328de c603a03d7801225fb15869d1386224f793f1ba1d M tools

A copy of the above commit is attached.

Examination of the commit shows that the problem originates in the second of the two patches --

diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
index e367b1a8..3c04e2a 100644
--- a/tools/power/x86/turbostat/Makefile
+++ b/tools/power/x86/turbostat/Makefile
@@ -8,7 +8,7 @@ ifeq ("$(origin O)", "command line")
 endif
 
 turbostat : turbostat.c
-CFLAGS += -Wall
+CFLAGS += -Wall -I../../../include
 CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
 
 %: %.c

The problem is fixed by patching the tools/power/x86/turbostat/{Makefile,turbostat.c} files --

diff -Npru a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
--- a/tools/power/x86/turbostat/Makefile 2019-05-16 13:45:18.000000000 -0400
+++ b/tools/power/x86/turbostat/Makefile 2019-05-21 10:19:21.580477034 -0400
@@ -8,8 +8,7 @@ ifeq ("$(origin O)", "command line")
 endif
 
 turbostat : turbostat.c
-CFLAGS += -Wall -I../../../include
-CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
+CFLAGS += -Wall
 
 %: %.c
     @mkdir -p $(BUILD_OUTPUT)
diff -Npru a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
--- a/tools/power/x86/turbostat/turbostat.c 2019-05-16 13:45:18.000000000 -0400
+++ b/tools/power/x86/turbostat/turbostat.c 2019-05-21 10:29:58.007236178 -0400
@@ -20,7 +20,7 @@
  */
 
 #define _GNU_SOURCE
-#include MSRHEADER
+#include <asm/msr-index.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <err.h>

The build now succeeds. Please apply the patch locally to the kernel-lt package set, for RHEL7 until, such time as a fix is applied to the upstream linux-4.4.X source tree.
TagsNo tags attached.
Attached Files
commit-683f9fba8c27817b6c2f7320a4095ca353022651.txt (3,894 bytes)   
commit 683f9fba8c27817b6c2f7320a4095ca353022651
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Feb 21 12:36:50 2019 +0100

    x86/msr-index: Cleanup bit defines
    
    commit d8eabc37310a92df40d07c5a8afc53cebf996716 upstream.
    
    Greg pointed out that speculation related bit defines are using (1 << N)
    format instead of BIT(N). Aside of that (1 << N) is wrong as it should use
    1UL at least.
    
    Clean it up.
    
    [ Josh Poimboeuf: Fix tools build ]
    
    Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
    Reviewed-by: Jon Masters <jcm@redhat.com>
    Tested-by: Jon Masters <jcm@redhat.com>
    [bwh: Backported to 4.4:
     - Drop change to x86_energy_perf_policy, which doesn't use msr-index.h here
     - Drop changes to flush MSRs which we haven't defined]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 2eae9d8..45f9b8d 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_X86_MSR_INDEX_H
 #define _ASM_X86_MSR_INDEX_H
 
+#include <linux/bits.h>
+
 /* CPU model specific register (MSR) numbers */
 
 /* x86-64 specific MSRs */
@@ -33,14 +35,14 @@
 
 /* Intel MSRs. Some also available on other CPUs */
 #define MSR_IA32_SPEC_CTRL		0x00000048 /* Speculation Control */
-#define SPEC_CTRL_IBRS			(1 << 0)   /* Indirect Branch Restricted Speculation */
+#define SPEC_CTRL_IBRS			BIT(0)	   /* Indirect Branch Restricted Speculation */
 #define SPEC_CTRL_STIBP_SHIFT		1	   /* Single Thread Indirect Branch Predictor (STIBP) bit */
-#define SPEC_CTRL_STIBP			(1 << SPEC_CTRL_STIBP_SHIFT)	/* STIBP mask */
+#define SPEC_CTRL_STIBP			BIT(SPEC_CTRL_STIBP_SHIFT)	/* STIBP mask */
 #define SPEC_CTRL_SSBD_SHIFT		2	   /* Speculative Store Bypass Disable bit */
-#define SPEC_CTRL_SSBD			(1 << SPEC_CTRL_SSBD_SHIFT)	/* Speculative Store Bypass Disable */
+#define SPEC_CTRL_SSBD			BIT(SPEC_CTRL_SSBD_SHIFT)	/* Speculative Store Bypass Disable */
 
 #define MSR_IA32_PRED_CMD		0x00000049 /* Prediction Command */
-#define PRED_CMD_IBPB			(1 << 0)   /* Indirect Branch Prediction Barrier */
+#define PRED_CMD_IBPB			BIT(0)	   /* Indirect Branch Prediction Barrier */
 
 #define MSR_IA32_PERFCTR0		0x000000c1
 #define MSR_IA32_PERFCTR1		0x000000c2
@@ -57,13 +59,13 @@
 #define MSR_MTRRcap			0x000000fe
 
 #define MSR_IA32_ARCH_CAPABILITIES	0x0000010a
-#define ARCH_CAP_RDCL_NO		(1 << 0)   /* Not susceptible to Meltdown */
-#define ARCH_CAP_IBRS_ALL		(1 << 1)   /* Enhanced IBRS support */
-#define ARCH_CAP_SSB_NO			(1 << 4)   /*
-						    * Not susceptible to Speculative Store Bypass
-						    * attack, so no Speculative Store Bypass
-						    * control required.
-						    */
+#define ARCH_CAP_RDCL_NO		BIT(0)	/* Not susceptible to Meltdown */
+#define ARCH_CAP_IBRS_ALL		BIT(1)	/* Enhanced IBRS support */
+#define ARCH_CAP_SSB_NO			BIT(4)	/*
+						 * Not susceptible to Speculative Store Bypass
+						 * attack, so no Speculative Store Bypass
+						 * control required.
+						 */
 
 #define MSR_IA32_BBL_CR_CTL		0x00000119
 #define MSR_IA32_BBL_CR_CTL3		0x0000011e
diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
index e367b1a8..3c04e2a 100644
--- a/tools/power/x86/turbostat/Makefile
+++ b/tools/power/x86/turbostat/Makefile
@@ -8,7 +8,7 @@ ifeq ("$(origin O)", "command line")
 endif
 
 turbostat : turbostat.c
-CFLAGS +=	-Wall
+CFLAGS +=	-Wall -I../../../include
 CFLAGS +=	-DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
 
 %: %.c

Activities

burakkucat

2019-05-22 08:03

administrator   ~0006306

The kernel-lt-4.4.180-2.el7.elrepo package set has been completely built using the upstream source code with the ELRepo_turbostat_build.patch applied.

The patch will be carried and applied locally, as appropriate.

Now closing as "resolved/fixed".

Issue History

Date Modified Username Field Change
2019-05-22 05:50 burakkucat New Issue
2019-05-22 05:50 burakkucat Status new => assigned
2019-05-22 05:50 burakkucat Assigned To => burakkucat
2019-05-22 05:50 burakkucat File Added: commit-683f9fba8c27817b6c2f7320a4095ca353022651.txt
2019-05-22 08:03 burakkucat Note Added: 0006306
2019-05-22 08:03 burakkucat Status assigned => resolved
2019-05-22 08:03 burakkucat Resolution open => fixed