Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/cpufeatures: Carve out CQM features retrieval

... into a separate function for better readability. Split out from a
patch from Fenghua Yu <fenghua.yu@intel.com> to keep the mechanical,
sole code movement separate for easy review.

No functional changes.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: x86@kernel.org

+33 -27
+33 -27
arch/x86/kernel/cpu/common.c
··· 801 801 } 802 802 } 803 803 804 + static void init_cqm(struct cpuinfo_x86 *c) 805 + { 806 + u32 eax, ebx, ecx, edx; 807 + 808 + /* Additional Intel-defined flags: level 0x0000000F */ 809 + if (c->cpuid_level >= 0x0000000F) { 810 + 811 + /* QoS sub-leaf, EAX=0Fh, ECX=0 */ 812 + cpuid_count(0x0000000F, 0, &eax, &ebx, &ecx, &edx); 813 + c->x86_capability[CPUID_F_0_EDX] = edx; 814 + 815 + if (cpu_has(c, X86_FEATURE_CQM_LLC)) { 816 + /* will be overridden if occupancy monitoring exists */ 817 + c->x86_cache_max_rmid = ebx; 818 + 819 + /* QoS sub-leaf, EAX=0Fh, ECX=1 */ 820 + cpuid_count(0x0000000F, 1, &eax, &ebx, &ecx, &edx); 821 + c->x86_capability[CPUID_F_1_EDX] = edx; 822 + 823 + if ((cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC)) || 824 + ((cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL)) || 825 + (cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)))) { 826 + c->x86_cache_max_rmid = ecx; 827 + c->x86_cache_occ_scale = ebx; 828 + } 829 + } else { 830 + c->x86_cache_max_rmid = -1; 831 + c->x86_cache_occ_scale = -1; 832 + } 833 + } 834 + } 835 + 804 836 void get_cpu_cap(struct cpuinfo_x86 *c) 805 837 { 806 838 u32 eax, ebx, ecx, edx; ··· 862 830 cpuid_count(0x0000000d, 1, &eax, &ebx, &ecx, &edx); 863 831 864 832 c->x86_capability[CPUID_D_1_EAX] = eax; 865 - } 866 - 867 - /* Additional Intel-defined flags: level 0x0000000F */ 868 - if (c->cpuid_level >= 0x0000000F) { 869 - 870 - /* QoS sub-leaf, EAX=0Fh, ECX=0 */ 871 - cpuid_count(0x0000000F, 0, &eax, &ebx, &ecx, &edx); 872 - c->x86_capability[CPUID_F_0_EDX] = edx; 873 - 874 - if (cpu_has(c, X86_FEATURE_CQM_LLC)) { 875 - /* will be overridden if occupancy monitoring exists */ 876 - c->x86_cache_max_rmid = ebx; 877 - 878 - /* QoS sub-leaf, EAX=0Fh, ECX=1 */ 879 - cpuid_count(0x0000000F, 1, &eax, &ebx, &ecx, &edx); 880 - c->x86_capability[CPUID_F_1_EDX] = edx; 881 - 882 - if ((cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC)) || 883 - ((cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL)) || 884 - (cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)))) { 885 - c->x86_cache_max_rmid = ecx; 886 - c->x86_cache_occ_scale = ebx; 887 - } 888 - } else { 889 - c->x86_cache_max_rmid = -1; 890 - c->x86_cache_occ_scale = -1; 891 - } 892 833 } 893 834 894 835 /* AMD-defined flags: level 0x80000001 */ ··· 894 889 895 890 init_scattered_cpuid_features(c); 896 891 init_speculation_control(c); 892 + init_cqm(c); 897 893 898 894 /* 899 895 * Clear/Set all flags overridden by options, after probe.