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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86_urgent_for_v6.0_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:
"As usually the case, right after a major release, the tip urgent
branches accumulate a couple more fixes than normal. And here is the
x86, a bit bigger, urgent pile.

- Use the correct CPU capability clearing function on the error path
in Intel perf LBR

- A CFI fix to ftrace along with a simplification

- Adjust handling of zero capacity bit mask for resctrl cache
allocation on AMD

- A fix to the AMD microcode loader to attempt patch application on
every logical thread

- A couple of topology fixes to handle CPUID leaf 0x1f enumeration
info properly

- Drop a -mabi=ms compiler option check as both compilers support it
now anyway

- A couple of fixes to how the initial, statically allocated FPU
buffer state is setup and its interaction with dynamic states at
runtime"

* tag 'x86_urgent_for_v6.0_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/fpu: Fix copy_xstate_to_uabi() to copy init states correctly
perf/x86/intel/lbr: Use setup_clear_cpu_cap() instead of clear_cpu_cap()
ftrace,kcfi: Separate ftrace_stub() and ftrace_stub_graph()
x86/ftrace: Remove ftrace_epilogue()
x86/resctrl: Fix min_cbm_bits for AMD
x86/microcode/AMD: Apply the patch early on every logical thread
x86/topology: Fix duplicated core ID within a package
x86/topology: Fix multiple packages shown on a single-package system
hwmon/coretemp: Handle large core ID value
x86/Kconfig: Drop check for -mabi=ms for CONFIG_EFI_STUB
x86/fpu: Exclude dynamic states from init_fpstate
x86/fpu: Fix the init_fpstate size check with the actual size
x86/fpu: Configure init_fpstate attributes orderly

+123 -87
+6 -1
arch/arm64/kernel/entry-ftrace.S
··· 7 7 */ 8 8 9 9 #include <linux/linkage.h> 10 + #include <linux/cfi_types.h> 10 11 #include <asm/asm-offsets.h> 11 12 #include <asm/assembler.h> 12 13 #include <asm/ftrace.h> ··· 295 294 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 296 295 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */ 297 296 298 - SYM_FUNC_START(ftrace_stub) 297 + SYM_TYPED_FUNC_START(ftrace_stub) 299 298 ret 300 299 SYM_FUNC_END(ftrace_stub) 300 + 301 + SYM_TYPED_FUNC_START(ftrace_stub_graph) 302 + ret 303 + SYM_FUNC_END(ftrace_stub_graph) 301 304 302 305 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 303 306 /*
-1
arch/x86/Kconfig
··· 1973 1973 config EFI_STUB 1974 1974 bool "EFI stub support" 1975 1975 depends on EFI 1976 - depends on $(cc-option,-mabi=ms) || X86_32 1977 1976 select RELOCATABLE 1978 1977 help 1979 1978 This kernel feature allows a bzImage to be loaded directly
+1 -1
arch/x86/events/intel/lbr.c
··· 1596 1596 return; 1597 1597 1598 1598 clear_arch_lbr: 1599 - clear_cpu_cap(&boot_cpu_data, X86_FEATURE_ARCH_LBR); 1599 + setup_clear_cpu_cap(X86_FEATURE_ARCH_LBR); 1600 1600 } 1601 1601 1602 1602 /**
+13 -3
arch/x86/kernel/cpu/microcode/amd.c
··· 440 440 return ret; 441 441 442 442 native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy); 443 - if (rev >= mc->hdr.patch_id) 443 + 444 + /* 445 + * Allow application of the same revision to pick up SMT-specific 446 + * changes even if the revision of the other SMT thread is already 447 + * up-to-date. 448 + */ 449 + if (rev > mc->hdr.patch_id) 444 450 return ret; 445 451 446 452 if (!__apply_microcode_amd(mc)) { ··· 534 528 535 529 native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy); 536 530 537 - /* Check whether we have saved a new patch already: */ 538 - if (*new_rev && rev < mc->hdr.patch_id) { 531 + /* 532 + * Check whether a new patch has been saved already. Also, allow application of 533 + * the same revision in order to pick up SMT-thread-specific configuration even 534 + * if the sibling SMT thread already has an up-to-date revision. 535 + */ 536 + if (*new_rev && rev <= mc->hdr.patch_id) { 539 537 if (!__apply_microcode_amd(mc)) { 540 538 *new_rev = mc->hdr.patch_id; 541 539 return;
+2 -6
arch/x86/kernel/cpu/resctrl/core.c
··· 66 66 .rid = RDT_RESOURCE_L3, 67 67 .name = "L3", 68 68 .cache_level = 3, 69 - .cache = { 70 - .min_cbm_bits = 1, 71 - }, 72 69 .domains = domain_init(RDT_RESOURCE_L3), 73 70 .parse_ctrlval = parse_cbm, 74 71 .format_str = "%d=%0*x", ··· 80 83 .rid = RDT_RESOURCE_L2, 81 84 .name = "L2", 82 85 .cache_level = 2, 83 - .cache = { 84 - .min_cbm_bits = 1, 85 - }, 86 86 .domains = domain_init(RDT_RESOURCE_L2), 87 87 .parse_ctrlval = parse_cbm, 88 88 .format_str = "%d=%0*x", ··· 830 836 r->cache.arch_has_sparse_bitmaps = false; 831 837 r->cache.arch_has_empty_bitmaps = false; 832 838 r->cache.arch_has_per_cpu_cfg = false; 839 + r->cache.min_cbm_bits = 1; 833 840 } else if (r->rid == RDT_RESOURCE_MBA) { 834 841 hw_res->msr_base = MSR_IA32_MBA_THRTL_BASE; 835 842 hw_res->msr_update = mba_wrmsr_intel; ··· 851 856 r->cache.arch_has_sparse_bitmaps = true; 852 857 r->cache.arch_has_empty_bitmaps = true; 853 858 r->cache.arch_has_per_cpu_cfg = true; 859 + r->cache.min_cbm_bits = 0; 854 860 } else if (r->rid == RDT_RESOURCE_MBA) { 855 861 hw_res->msr_base = MSR_IA32_MBA_BW_BASE; 856 862 hw_res->msr_update = mba_wrmsr_amd;
+12 -6
arch/x86/kernel/cpu/topology.c
··· 96 96 unsigned int ht_mask_width, core_plus_mask_width, die_plus_mask_width; 97 97 unsigned int core_select_mask, core_level_siblings; 98 98 unsigned int die_select_mask, die_level_siblings; 99 + unsigned int pkg_mask_width; 99 100 bool die_level_present = false; 100 101 int leaf; 101 102 ··· 112 111 core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx); 113 112 core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); 114 113 die_level_siblings = LEVEL_MAX_SIBLINGS(ebx); 115 - die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); 114 + pkg_mask_width = die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); 116 115 117 116 sub_index = 1; 118 - do { 117 + while (true) { 119 118 cpuid_count(leaf, sub_index, &eax, &ebx, &ecx, &edx); 120 119 121 120 /* ··· 133 132 die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); 134 133 } 135 134 136 - sub_index++; 137 - } while (LEAFB_SUBTYPE(ecx) != INVALID_TYPE); 135 + if (LEAFB_SUBTYPE(ecx) != INVALID_TYPE) 136 + pkg_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); 137 + else 138 + break; 138 139 139 - core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width; 140 + sub_index++; 141 + } 142 + 143 + core_select_mask = (~(-1 << pkg_mask_width)) >> ht_mask_width; 140 144 die_select_mask = (~(-1 << die_plus_mask_width)) >> 141 145 core_plus_mask_width; 142 146 ··· 154 148 } 155 149 156 150 c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, 157 - die_plus_mask_width); 151 + pkg_mask_width); 158 152 /* 159 153 * Reinit the apicid, now that we have extended initial_apicid. 160 154 */
-8
arch/x86/kernel/fpu/init.c
··· 210 210 fpstate_reset(&current->thread.fpu); 211 211 } 212 212 213 - static void __init fpu__init_init_fpstate(void) 214 - { 215 - /* Bring init_fpstate size and features up to date */ 216 - init_fpstate.size = fpu_kernel_cfg.max_size; 217 - init_fpstate.xfeatures = fpu_kernel_cfg.max_features; 218 - } 219 - 220 213 /* 221 214 * Called on the boot CPU once per system bootup, to set up the initial 222 215 * FPU state that is later cloned into all processes: ··· 229 236 fpu__init_system_xstate_size_legacy(); 230 237 fpu__init_system_xstate(fpu_kernel_cfg.max_size); 231 238 fpu__init_task_struct_size(); 232 - fpu__init_init_fpstate(); 233 239 }
+23 -19
arch/x86/kernel/fpu/xstate.c
··· 360 360 361 361 print_xstate_features(); 362 362 363 - xstate_init_xcomp_bv(&init_fpstate.regs.xsave, fpu_kernel_cfg.max_features); 363 + xstate_init_xcomp_bv(&init_fpstate.regs.xsave, init_fpstate.xfeatures); 364 364 365 365 /* 366 366 * Init all the features state with header.xfeatures being 0x0 ··· 678 678 return ebx; 679 679 } 680 680 681 - /* 682 - * Will the runtime-enumerated 'xstate_size' fit in the init 683 - * task's statically-allocated buffer? 684 - */ 685 - static bool __init is_supported_xstate_size(unsigned int test_xstate_size) 686 - { 687 - if (test_xstate_size <= sizeof(init_fpstate.regs)) 688 - return true; 689 - 690 - pr_warn("x86/fpu: xstate buffer too small (%zu < %d), disabling xsave\n", 691 - sizeof(init_fpstate.regs), test_xstate_size); 692 - return false; 693 - } 694 - 695 681 static int __init init_xstate_size(void) 696 682 { 697 683 /* Recompute the context size for enabled features: */ ··· 702 716 703 717 kernel_default_size = 704 718 xstate_calculate_size(fpu_kernel_cfg.default_features, compacted); 705 - 706 - /* Ensure we have the space to store all default enabled features. */ 707 - if (!is_supported_xstate_size(kernel_default_size)) 708 - return -EINVAL; 709 719 710 720 if (!paranoid_xstate_size_valid(kernel_size)) 711 721 return -EINVAL; ··· 856 874 */ 857 875 update_regset_xstate_info(fpu_user_cfg.max_size, 858 876 fpu_user_cfg.max_features); 877 + 878 + /* 879 + * init_fpstate excludes dynamic states as they are large but init 880 + * state is zero. 881 + */ 882 + init_fpstate.size = fpu_kernel_cfg.default_size; 883 + init_fpstate.xfeatures = fpu_kernel_cfg.default_features; 884 + 885 + if (init_fpstate.size > sizeof(init_fpstate.regs)) { 886 + pr_warn("x86/fpu: init_fpstate buffer too small (%zu < %d), disabling XSAVE\n", 887 + sizeof(init_fpstate.regs), init_fpstate.size); 888 + goto out_disable; 889 + } 859 890 860 891 setup_init_fpu_buf(); 861 892 ··· 1124 1129 * init_fpstate. The gap tracking will zero these states. 1125 1130 */ 1126 1131 mask = fpstate->user_xfeatures; 1132 + 1133 + /* 1134 + * Dynamic features are not present in init_fpstate. When they are 1135 + * in an all zeros init state, remove those from 'mask' to zero 1136 + * those features in the user buffer instead of retrieving them 1137 + * from init_fpstate. 1138 + */ 1139 + if (fpu_state_size_dynamic()) 1140 + mask &= (header.xfeatures | xinit->header.xcomp_bv); 1127 1141 1128 1142 for_each_extended_xfeature(i, mask) { 1129 1143 /*
+13 -21
arch/x86/kernel/ftrace_64.S
··· 4 4 */ 5 5 6 6 #include <linux/linkage.h> 7 + #include <linux/cfi_types.h> 7 8 #include <asm/ptrace.h> 8 9 #include <asm/ftrace.h> 9 10 #include <asm/export.h> ··· 130 129 131 130 .endm 132 131 132 + SYM_TYPED_FUNC_START(ftrace_stub) 133 + RET 134 + SYM_FUNC_END(ftrace_stub) 135 + 136 + SYM_TYPED_FUNC_START(ftrace_stub_graph) 137 + RET 138 + SYM_FUNC_END(ftrace_stub_graph) 139 + 133 140 #ifdef CONFIG_DYNAMIC_FTRACE 134 141 135 142 SYM_FUNC_START(__fentry__) ··· 181 172 */ 182 173 SYM_INNER_LABEL(ftrace_caller_end, SYM_L_GLOBAL) 183 174 ANNOTATE_NOENDBR 184 - 185 - jmp ftrace_epilogue 175 + RET 186 176 SYM_FUNC_END(ftrace_caller); 187 177 STACK_FRAME_NON_STANDARD_FP(ftrace_caller) 188 - 189 - SYM_FUNC_START(ftrace_epilogue) 190 - /* 191 - * This is weak to keep gas from relaxing the jumps. 192 - */ 193 - SYM_INNER_LABEL_ALIGN(ftrace_stub, SYM_L_WEAK) 194 - UNWIND_HINT_FUNC 195 - ENDBR 196 - RET 197 - SYM_FUNC_END(ftrace_epilogue) 198 178 199 179 SYM_FUNC_START(ftrace_regs_caller) 200 180 /* Save the current flags before any operations that can change them */ ··· 260 262 popfq 261 263 262 264 /* 263 - * As this jmp to ftrace_epilogue can be a short jump 264 - * it must not be copied into the trampoline. 265 - * The trampoline will add the code to jump 266 - * to the return. 265 + * The trampoline will add the return. 267 266 */ 268 267 SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL) 269 268 ANNOTATE_NOENDBR 270 - jmp ftrace_epilogue 269 + RET 271 270 272 271 /* Swap the flags with orig_rax */ 273 272 1: movq MCOUNT_REG_SIZE(%rsp), %rdi ··· 275 280 /* Restore flags */ 276 281 popfq 277 282 UNWIND_HINT_FUNC 278 - jmp ftrace_epilogue 283 + RET 279 284 280 285 SYM_FUNC_END(ftrace_regs_caller) 281 286 STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller) ··· 286 291 SYM_FUNC_START(__fentry__) 287 292 cmpq $ftrace_stub, ftrace_trace_function 288 293 jnz trace 289 - 290 - SYM_INNER_LABEL(ftrace_stub, SYM_L_GLOBAL) 291 - ENDBR 292 294 RET 293 295 294 296 trace:
+41 -15
drivers/hwmon/coretemp.c
··· 46 46 #define TOTAL_ATTRS (MAX_CORE_ATTRS + 1) 47 47 #define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO) 48 48 49 - #define TO_CORE_ID(cpu) (cpu_data(cpu).cpu_core_id) 50 - #define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO) 51 - 52 49 #ifdef CONFIG_SMP 53 50 #define for_each_sibling(i, cpu) \ 54 51 for_each_cpu(i, topology_sibling_cpumask(cpu)) ··· 88 91 struct platform_data { 89 92 struct device *hwmon_dev; 90 93 u16 pkg_id; 94 + u16 cpu_map[NUM_REAL_CORES]; 95 + struct ida ida; 91 96 struct cpumask cpumask; 92 97 struct temp_data *core_data[MAX_CORE_DATA]; 93 98 struct device_attribute name_attr; ··· 440 441 MSR_IA32_THERM_STATUS; 441 442 tdata->is_pkg_data = pkg_flag; 442 443 tdata->cpu = cpu; 443 - tdata->cpu_core_id = TO_CORE_ID(cpu); 444 + tdata->cpu_core_id = topology_core_id(cpu); 444 445 tdata->attr_size = MAX_CORE_ATTRS; 445 446 mutex_init(&tdata->update_lock); 446 447 return tdata; ··· 453 454 struct platform_data *pdata = platform_get_drvdata(pdev); 454 455 struct cpuinfo_x86 *c = &cpu_data(cpu); 455 456 u32 eax, edx; 456 - int err, attr_no; 457 + int err, index, attr_no; 457 458 458 459 /* 459 460 * Find attr number for sysfs: ··· 461 462 * The attr number is always core id + 2 462 463 * The Pkgtemp will always show up as temp1_*, if available 463 464 */ 464 - attr_no = pkg_flag ? PKG_SYSFS_ATTR_NO : TO_ATTR_NO(cpu); 465 + if (pkg_flag) { 466 + attr_no = PKG_SYSFS_ATTR_NO; 467 + } else { 468 + index = ida_alloc(&pdata->ida, GFP_KERNEL); 469 + if (index < 0) 470 + return index; 471 + pdata->cpu_map[index] = topology_core_id(cpu); 472 + attr_no = index + BASE_SYSFS_ATTR_NO; 473 + } 465 474 466 - if (attr_no > MAX_CORE_DATA - 1) 467 - return -ERANGE; 475 + if (attr_no > MAX_CORE_DATA - 1) { 476 + err = -ERANGE; 477 + goto ida_free; 478 + } 468 479 469 480 tdata = init_temp_data(cpu, pkg_flag); 470 - if (!tdata) 471 - return -ENOMEM; 481 + if (!tdata) { 482 + err = -ENOMEM; 483 + goto ida_free; 484 + } 472 485 473 486 /* Test if we can access the status register */ 474 487 err = rdmsr_safe_on_cpu(cpu, tdata->status_reg, &eax, &edx); ··· 516 505 exit_free: 517 506 pdata->core_data[attr_no] = NULL; 518 507 kfree(tdata); 508 + ida_free: 509 + if (!pkg_flag) 510 + ida_free(&pdata->ida, index); 519 511 return err; 520 512 } 521 513 ··· 538 524 539 525 kfree(pdata->core_data[indx]); 540 526 pdata->core_data[indx] = NULL; 527 + 528 + if (indx >= BASE_SYSFS_ATTR_NO) 529 + ida_free(&pdata->ida, indx - BASE_SYSFS_ATTR_NO); 541 530 } 542 531 543 532 static int coretemp_probe(struct platform_device *pdev) ··· 554 537 return -ENOMEM; 555 538 556 539 pdata->pkg_id = pdev->id; 540 + ida_init(&pdata->ida); 557 541 platform_set_drvdata(pdev, pdata); 558 542 559 543 pdata->hwmon_dev = devm_hwmon_device_register_with_groups(dev, DRVNAME, ··· 571 553 if (pdata->core_data[i]) 572 554 coretemp_remove_core(pdata, i); 573 555 556 + ida_destroy(&pdata->ida); 574 557 return 0; 575 558 } 576 559 ··· 666 647 struct platform_device *pdev = coretemp_get_pdev(cpu); 667 648 struct platform_data *pd; 668 649 struct temp_data *tdata; 669 - int indx, target; 650 + int i, indx = -1, target; 670 651 671 652 /* 672 653 * Don't execute this on suspend as the device remove locks ··· 679 660 if (!pdev) 680 661 return 0; 681 662 682 - /* The core id is too big, just return */ 683 - indx = TO_ATTR_NO(cpu); 684 - if (indx > MAX_CORE_DATA - 1) 663 + pd = platform_get_drvdata(pdev); 664 + 665 + for (i = 0; i < NUM_REAL_CORES; i++) { 666 + if (pd->cpu_map[i] == topology_core_id(cpu)) { 667 + indx = i + BASE_SYSFS_ATTR_NO; 668 + break; 669 + } 670 + } 671 + 672 + /* Too many cores and this core is not populated, just return */ 673 + if (indx < 0) 685 674 return 0; 686 675 687 - pd = platform_get_drvdata(pdev); 688 676 tdata = pd->core_data[indx]; 689 677 690 678 cpumask_clear_cpu(cpu, &pd->cpumask);
+12 -6
include/asm-generic/vmlinux.lds.h
··· 162 162 #define PATCHABLE_DISCARDS *(__patchable_function_entries) 163 163 #endif 164 164 165 + #ifndef CONFIG_ARCH_SUPPORTS_CFI_CLANG 166 + /* 167 + * Simply points to ftrace_stub, but with the proper protocol. 168 + * Defined by the linker script in linux/vmlinux.lds.h 169 + */ 170 + #define FTRACE_STUB_HACK ftrace_stub_graph = ftrace_stub; 171 + #else 172 + #define FTRACE_STUB_HACK 173 + #endif 174 + 165 175 #ifdef CONFIG_FTRACE_MCOUNT_RECORD 166 176 /* 167 177 * The ftrace call sites are logged to a section whose name depends on the 168 178 * compiler option used. A given kernel image will only use one, AKA 169 179 * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header 170 180 * dependencies for FTRACE_CALLSITE_SECTION's definition. 171 - * 172 - * Need to also make ftrace_stub_graph point to ftrace_stub 173 - * so that the same stub location may have different protocols 174 - * and not mess up with C verifiers. 175 181 * 176 182 * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func 177 183 * as some archs will have a different prototype for that function ··· 188 182 KEEP(*(__mcount_loc)) \ 189 183 KEEP_PATCHABLE \ 190 184 __stop_mcount_loc = .; \ 191 - ftrace_stub_graph = ftrace_stub; \ 185 + FTRACE_STUB_HACK \ 192 186 ftrace_ops_list_func = arch_ftrace_ops_list_func; 193 187 #else 194 188 # ifdef CONFIG_FUNCTION_TRACER 195 - # define MCOUNT_REC() ftrace_stub_graph = ftrace_stub; \ 189 + # define MCOUNT_REC() FTRACE_STUB_HACK \ 196 190 ftrace_ops_list_func = arch_ftrace_ops_list_func; 197 191 # else 198 192 # define MCOUNT_REC()