[Devel] [PATCH RHEL7 COMMIT] arch/x86: check if cpuid level exists while reporting cpuinfo

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 20 09:00:19 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.9
------>
commit 41e0b6471b4ef32fd2888a79a1b2eb18bd091e7f
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Tue Oct 20 20:00:19 2015 +0400

    arch/x86: check if cpuid level exists while reporting cpuinfo
    
    Port diff-arch-x86-check-if-cpuid-level-exists-while-reporting-cpuinfo
    
    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 e98290b..77c7c82 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)



More information about the Devel mailing list