[Devel] [PATCH RHEL7 COMMIT] arch/x86: take into account cpuid override 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 f23957bd5303c0b4be9331f0694efaf4d7da454b
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Tue Oct 20 20:00:19 2015 +0400

    arch/x86: take into account cpuid override while reporting cpuinfo
    
    Port diff-arch-x86-take-into-account-cpuid-override-while-reporting-cpuinfo
    
    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 9f46588..e98290b 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 24d16c2..34dda40 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))



More information about the Devel mailing list