aboutsummaryrefslogtreecommitdiffstats
path: root/main/cpufrequtils/0001-Support-for-Position-Independet-Code-by-aboid-clobbe.patch
blob: b10d2e56350da4752eb12c0b986e6e51d54b0f76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 4c6552d2df2912a710cab6acf476347a7fbf15a0 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 1 Sep 2010 09:12:44 +0000
Subject: [PATCH] Support for Position Independet Code by aboid clobbering PIC register

Do not use the PIC register (ebx)
See http://www.gentoo.org/proj/en/hardened/pic-fix-guide.xml#doc_chap5
---
 utils/cpuid.h |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/utils/cpuid.h b/utils/cpuid.h
index 2bac69a..ebcec7c 100644
--- a/utils/cpuid.h
+++ b/utils/cpuid.h
@@ -5,9 +5,12 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
 				unsigned int *ecx, unsigned int *edx)
 {
 	/* ecx is often an input as well as an output. */
-	asm volatile("cpuid"
+	asm volatile(
+		"movl %%ebx, %%esi;"
+		"cpuid;"
+		"xchg %%ebx, %%esi;"
 	    : "=a" (*eax),
-	      "=b" (*ebx),
+	      "=S" (*ebx),
 	      "=c" (*ecx),
 	      "=d" (*edx)
 	    : "0" (*eax), "2" (*ecx));
-- 
1.7.2.2