[Devel] [PATCH rh7 05/11] Port diff-arch-x86-check-if-cpuid-level-exists-while-reporting-cpuinfo

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


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: arch: x86: check if cpuid level exists while reporting cpuinfo
Date: Mon, 8 Dec 2014 12:40:42 +0300

For /proc/cpuinfo to reflect cpuid masking/faulting setup we use cpuid
instruction to get some features. However, the cpuid levels may not
exist, in which case cpuid'll return rubbish. Let's assure that the
cpuid levels exist, just like we do in get_cpu_cap.

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

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

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 arch/x86/kernel/cpu/proc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index e98290be927d..77c7c825f95d 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -75,10 +75,14 @@ static void init_cpu_flags(void *dummy)
 		if (cpu_has(c, i))
 			set_bit(i, (unsigned long *)flags);
 
-	__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]);
+	if (c->cpuid_level >= 0x00000001)
+		__do_cpuid_fault(0x00000001, 0, &tmp1, &tmp2,
+				 &flags->val[4], &flags->val[0]);
+
+	if ((c->extended_cpuid_level & 0xffff0000) == 0x80000000 &&
+	    c->extended_cpuid_level >= 0x80000001)
+		__do_cpuid_fault(0x80000001, 0, &tmp1, &tmp2,
+				 &flags->val[6], &flags->val[1]);
 }
 
 static int show_cpuinfo(struct seq_file *m, void *v)
-- 
2.1.4




More information about the Devel mailing list