[Devel] [PATCH rh7 04/11] Port diff-arch-x86-take-into-account-cpuid-override-while-reporting-cpuinfo

Vladimir Davydov vdavydov at virtuozzo.com
Fri Oct 16 09:22:48 PDT 2015


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: arch: x86: take into account cpuid override while reporting cpuinfo
Date: Tue, 2 Dec 2014 15:53:32 +0300

For /proc/cpuinfo to take into account CPUID masking, we made readers
get the feature mask with the aid of the cpuid instruction instead of
using the cached value. Now, with CPUID faulting introduced, it isn't
enough, because calls to cpuid from inside the kernel are not
intercepted. So we should issue do_cpuid_fault explicitly there for
/proc/cpuinfo to be consistent with cpuid.

https://jira.sw.ru/browse/PSBM-28682

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov at parallels.com>
=============================================================================

https://jira.sw.ru/browse/PSBM-33638

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 arch/x86/kernel/cpu/proc.c    | 10 ++++++++--
 arch/x86/kernel/cpuid_fault.c |  6 +++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 9f4658888ec9..e98290be927d 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -52,6 +52,10 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
 }
 #endif
 
+extern void __do_cpuid_fault(unsigned int op, unsigned int count,
+			     unsigned int *eax, unsigned int *ebx,
+			     unsigned int *ecx, unsigned int *edx);
+
 struct cpu_flags {
 	u32 val[NCAPINTS];
 };
@@ -71,8 +75,10 @@ static void init_cpu_flags(void *dummy)
 		if (cpu_has(c, i))
 			set_bit(i, (unsigned long *)flags);
 
-	cpuid(0x00000001, &tmp1, &tmp2, &flags->val[4], &flags->val[0]);
-	cpuid(0x80000001, &tmp1, &tmp2, &flags->val[6], &flags->val[1]);
+	__do_cpuid_fault(0x00000001, 0, &tmp1, &tmp2,
+			 &flags->val[4], &flags->val[0]);
+	__do_cpuid_fault(0x80000001, 0, &tmp1, &tmp2,
+			 &flags->val[6], &flags->val[1]);
 }
 
 static int show_cpuinfo(struct seq_file *m, void *v)
diff --git a/arch/x86/kernel/cpuid_fault.c b/arch/x86/kernel/cpuid_fault.c
index 24d16c21614f..34dda4045753 100644
--- a/arch/x86/kernel/cpuid_fault.c
+++ b/arch/x86/kernel/cpuid_fault.c
@@ -74,9 +74,9 @@ out:
 	return ret;
 }
 
-static void __do_cpuid_fault(unsigned int op, unsigned int count,
-			     unsigned int *eax, unsigned int *ebx,
-			     unsigned int *ecx, unsigned int *edx)
+void __do_cpuid_fault(unsigned int op, unsigned int count,
+		      unsigned int *eax, unsigned int *ebx,
+		      unsigned int *ecx, unsigned int *edx)
 {
 	/* check if op is overridden */
 	if (cpuid_override_match(op, count, eax, ebx, ecx, edx))
-- 
2.1.4




More information about the Devel mailing list