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

Merge branch 'x86/asm' into x86/core, to pick up dependent commits

Signed-off-by: Ingo Molnar <mingo@kernel.org>

+1004 -1909
-4
Documentation/admin-guide/kdump/kdump.rst
··· 180 180 1) On i386, enable high memory support under "Processor type and 181 181 features":: 182 182 183 - CONFIG_HIGHMEM64G=y 184 - 185 - or:: 186 - 187 183 CONFIG_HIGHMEM4G 188 184 189 185 2) With CONFIG_SMP=y, usually nr_cpus=1 need specified on the kernel
-11
Documentation/admin-guide/kernel-parameters.txt
··· 416 416 Format: { quiet (default) | verbose | debug } 417 417 Change the amount of debugging information output 418 418 when initialising the APIC and IO-APIC components. 419 - For X86-32, this can also be used to specify an APIC 420 - driver name. 421 - Format: apic=driver_name 422 - Examples: apic=bigsmp 423 419 424 420 apic_extnmi= [APIC,X86,EARLY] External NMI delivery setting 425 421 Format: { bsp (default) | all | none } ··· 7667 7671 8 - SIGSEGV faults 7668 7672 16 - SIGBUS faults 7669 7673 Example: user_debug=31 7670 - 7671 - userpte= 7672 - [X86,EARLY] Flags controlling user PTE allocations. 7673 - 7674 - nohigh = do not allocate PTE pages in 7675 - HIGHMEM regardless of setting 7676 - of CONFIG_HIGHPTE. 7677 7674 7678 7675 vdso= [X86,SH,SPARC] 7679 7676 On X86_32, this is an alias for vdso32=. Otherwise:
+1 -10
Documentation/arch/x86/usb-legacy-support.rst
··· 20 20 features (wheel, extra buttons, touchpad mode) of the real PS/2 mouse may 21 21 not be available. 22 22 23 - 2) If CONFIG_HIGHMEM64G is enabled, the PS/2 mouse emulation can cause 24 - system crashes, because the SMM BIOS is not expecting to be in PAE mode. 25 - The Intel E7505 is a typical machine where this happens. 26 - 27 - 3) If AMD64 64-bit mode is enabled, again system crashes often happen, 23 + 2) If AMD64 64-bit mode is enabled, again system crashes often happen, 28 24 because the SMM BIOS isn't expecting the CPU to be in 64-bit mode. The 29 25 BIOS manufacturers only test with Windows, and Windows doesn't do 64-bit 30 26 yet. ··· 34 38 compiled-in, too. 35 39 36 40 Problem 2) 37 - can currently only be solved by either disabling HIGHMEM64G 38 - in the kernel config or USB Legacy support in the BIOS. A BIOS update 39 - could help, but so far no such update exists. 40 - 41 - Problem 3) 42 41 is usually fixed by a BIOS update. Check the board 43 42 manufacturers web site. If an update is not available, disable USB 44 43 Legacy support in the BIOS. If this alone doesn't help, try also adding
+1 -1
arch/arm/include/asm/io.h
··· 381 381 void iounmap(volatile void __iomem *io_addr); 382 382 #define iounmap iounmap 383 383 384 - void *arch_memremap_wb(phys_addr_t phys_addr, size_t size); 384 + void *arch_memremap_wb(phys_addr_t phys_addr, size_t size, unsigned long flags); 385 385 #define arch_memremap_wb arch_memremap_wb 386 386 387 387 /*
+1 -1
arch/arm/mm/ioremap.c
··· 436 436 set_memory_ro((unsigned long)ptr, PAGE_ALIGN(size) / PAGE_SIZE); 437 437 } 438 438 439 - void *arch_memremap_wb(phys_addr_t phys_addr, size_t size) 439 + void *arch_memremap_wb(phys_addr_t phys_addr, size_t size, unsigned long flags) 440 440 { 441 441 return (__force void *)arch_ioremap_caller(phys_addr, size, 442 442 MT_MEMORY_RW,
+1 -1
arch/arm/mm/nommu.c
··· 248 248 EXPORT_SYMBOL_GPL(pci_remap_cfgspace); 249 249 #endif 250 250 251 - void *arch_memremap_wb(phys_addr_t phys_addr, size_t size) 251 + void *arch_memremap_wb(phys_addr_t phys_addr, size_t size, unsigned long flags) 252 252 { 253 253 return (void *)phys_addr; 254 254 }
+1 -1
arch/riscv/include/asm/io.h
··· 136 136 #include <asm-generic/io.h> 137 137 138 138 #ifdef CONFIG_MMU 139 - #define arch_memremap_wb(addr, size) \ 139 + #define arch_memremap_wb(addr, size, flags) \ 140 140 ((__force void *)ioremap_prot((addr), (size), _PAGE_KERNEL)) 141 141 #endif 142 142
+55 -136
arch/x86/Kconfig
··· 133 133 select ARCH_SUPPORTS_AUTOFDO_CLANG 134 134 select ARCH_SUPPORTS_PROPELLER_CLANG if X86_64 135 135 select ARCH_USE_BUILTIN_BSWAP 136 - select ARCH_USE_CMPXCHG_LOCKREF if X86_CMPXCHG64 136 + select ARCH_USE_CMPXCHG_LOCKREF if X86_CX8 137 137 select ARCH_USE_MEMTEST 138 138 select ARCH_USE_QUEUED_RWLOCKS 139 139 select ARCH_USE_QUEUED_SPINLOCKS ··· 233 233 select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if X86_64 234 234 select HAVE_EBPF_JIT 235 235 select HAVE_EFFICIENT_UNALIGNED_ACCESS 236 - select HAVE_EISA 236 + select HAVE_EISA if X86_32 237 237 select HAVE_EXIT_THREAD 238 238 select HAVE_GUP_FAST 239 239 select HAVE_FENTRY if X86_64 || DYNAMIC_FTRACE ··· 278 278 select HAVE_PCI 279 279 select HAVE_PERF_REGS 280 280 select HAVE_PERF_USER_STACK_DUMP 281 - select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT 281 + select MMU_GATHER_RCU_TABLE_FREE 282 282 select MMU_GATHER_MERGE_VMAS 283 283 select HAVE_POSIX_CPU_TIMERS_TASK_WORK 284 284 select HAVE_REGS_AND_STACK_ACCESS_API ··· 286 286 select HAVE_FUNCTION_ARG_ACCESS_API 287 287 select HAVE_SETUP_PER_CPU_AREA 288 288 select HAVE_SOFTIRQ_ON_OWN_STACK 289 - select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR 289 + select HAVE_STACKPROTECTOR 290 290 select HAVE_STACK_VALIDATION if HAVE_OBJTOOL 291 291 select HAVE_STATIC_CALL 292 292 select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL ··· 427 427 default 3 if X86_PAE 428 428 default 2 429 429 430 - config CC_HAS_SANE_STACKPROTECTOR 431 - bool 432 - default $(success,$(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC) $(CLANG_FLAGS)) if 64BIT 433 - default $(success,$(srctree)/scripts/gcc-x86_32-has-stack-protector.sh $(CC) $(CLANG_FLAGS)) 434 - help 435 - We have to make sure stack protector is unconditionally disabled if 436 - the compiler produces broken code or if it does not let us control 437 - the segment on 32-bit kernels. 438 - 439 430 menu "Processor type and features" 440 431 441 432 config SMP ··· 522 531 ring transitions and exception/interrupt handling if the 523 532 system supports it. 524 533 525 - config X86_BIGSMP 526 - bool "Support for big SMP systems with more than 8 CPUs" 527 - depends on SMP && X86_32 528 - help 529 - This option is needed for the systems that have more than 8 CPUs. 530 - 531 534 config X86_EXTENDED_PLATFORM 532 535 bool "Support for extended (non-PC) x86 platforms" 533 536 default y ··· 539 554 AMD Elan 540 555 RDC R-321x SoC 541 556 SGI 320/540 (Visual Workstation) 542 - STA2X11-based (e.g. Northville) 543 - Moorestown MID devices 544 557 545 558 64-bit platforms (CONFIG_64BIT=y): 546 559 Numascale NumaChip 547 560 ScaleMP vSMP 548 561 SGI Ultraviolet 562 + Merrifield/Moorefield MID devices 549 563 550 564 If you have one of these systems, or if you want to build a 551 565 generic distribution kernel, say Y here - otherwise say N. ··· 589 605 This option is needed in order to support SGI Ultraviolet systems. 590 606 If you don't have one of these, you should say N here. 591 607 592 - # Following is an alphabetically sorted list of 32 bit extended platforms 593 - # Please maintain the alphabetic order if and when there are additions 608 + config X86_INTEL_MID 609 + bool "Intel Z34xx/Z35xx MID platform support" 610 + depends on X86_EXTENDED_PLATFORM 611 + depends on X86_PLATFORM_DEVICES 612 + depends on PCI 613 + depends on X86_64 || (EXPERT && PCI_GOANY) 614 + depends on X86_IO_APIC 615 + select I2C 616 + select DW_APB_TIMER 617 + select INTEL_SCU_PCI 618 + help 619 + Select to build a kernel capable of supporting 64-bit Intel MID 620 + (Mobile Internet Device) platform systems which do not have 621 + the PCI legacy interfaces. 622 + 623 + The only supported devices are the 22nm Merrified (Z34xx) 624 + and Moorefield (Z35xx) SoC used in the Intel Edison board and 625 + a small number of Android devices such as the Asus Zenfone 2, 626 + Asus FonePad 8 and Dell Venue 7. 627 + 628 + If you are building for a PC class system or non-MID tablet 629 + SoCs like Bay Trail (Z36xx/Z37xx), say N here. 630 + 631 + Intel MID platforms are based on an Intel processor and chipset which 632 + consume less power than most of the x86 derivatives. 594 633 595 634 config X86_GOLDFISH 596 635 bool "Goldfish (Virtual Platform)" ··· 622 615 Enable support for the Goldfish virtual platform used primarily 623 616 for Android development. Unless you are building for the Android 624 617 Goldfish emulator say N here. 618 + 619 + # Following is an alphabetically sorted list of 32 bit extended platforms 620 + # Please maintain the alphabetic order if and when there are additions 625 621 626 622 config X86_INTEL_CE 627 623 bool "CE4100 TV platform" ··· 640 630 Select for the Intel CE media processor (CE4100) SOC. 641 631 This option compiles in support for the CE4100 SOC for settop 642 632 boxes and media devices. 643 - 644 - config X86_INTEL_MID 645 - bool "Intel MID platform support" 646 - depends on X86_EXTENDED_PLATFORM 647 - depends on X86_PLATFORM_DEVICES 648 - depends on PCI 649 - depends on X86_64 || (PCI_GOANY && X86_32) 650 - depends on X86_IO_APIC 651 - select I2C 652 - select DW_APB_TIMER 653 - select INTEL_SCU_PCI 654 - help 655 - Select to build a kernel capable of supporting Intel MID (Mobile 656 - Internet Device) platform systems which do not have the PCI legacy 657 - interfaces. If you are building for a PC class system say N here. 658 - 659 - Intel MID platforms are based on an Intel processor and chipset which 660 - consume less power than most of the x86 derivatives. 661 633 662 634 config X86_INTEL_QUARK 663 635 bool "Intel Quark platform support" ··· 722 730 as R-8610-(G). 723 731 If you don't have one of these chips, you should say N here. 724 732 725 - config X86_32_NON_STANDARD 726 - bool "Support non-standard 32-bit SMP architectures" 727 - depends on X86_32 && SMP 728 - depends on X86_EXTENDED_PLATFORM 729 - help 730 - This option compiles in the bigsmp and STA2X11 default 731 - subarchitectures. It is intended for a generic binary 732 - kernel. If you select them all, kernel will probe it one by 733 - one and will fallback to default. 734 - 735 - # Alphabetically sorted list of Non standard 32 bit platforms 736 - 737 733 config X86_SUPPORTS_MEMORY_FAILURE 738 734 def_bool y 739 735 # MCE code calls memory_failure(): ··· 730 750 # On 32-bit SPARSEMEM adds too big of SECTIONS_WIDTH: 731 751 depends on X86_64 || !SPARSEMEM 732 752 select ARCH_SUPPORTS_MEMORY_FAILURE 733 - 734 - config STA2X11 735 - bool "STA2X11 Companion Chip Support" 736 - depends on X86_32_NON_STANDARD && PCI 737 - select SWIOTLB 738 - select MFD_STA2X11 739 - select GPIOLIB 740 - help 741 - This adds support for boards based on the STA2X11 IO-Hub, 742 - a.k.a. "ConneXt". The chip is used in place of the standard 743 - PC chipset, so all "standard" peripherals are missing. If this 744 - option is selected the kernel will still be able to boot on 745 - standard PC machines. 746 753 747 754 config X86_32_IRIS 748 755 tristate "Eurobraille/Iris poweroff module" ··· 980 1013 config NR_CPUS_RANGE_END 981 1014 int 982 1015 depends on X86_32 983 - default 64 if SMP && X86_BIGSMP 984 - default 8 if SMP && !X86_BIGSMP 1016 + default 8 if SMP 985 1017 default 1 if !SMP 986 1018 987 1019 config NR_CPUS_RANGE_END ··· 993 1027 config NR_CPUS_DEFAULT 994 1028 int 995 1029 depends on X86_32 996 - default 32 if X86_BIGSMP 997 1030 default 8 if SMP 998 1031 default 1 if !SMP 999 1032 ··· 1068 1103 config X86_UP_APIC 1069 1104 bool "Local APIC support on uniprocessors" if !PCI_MSI 1070 1105 default PCI_MSI 1071 - depends on X86_32 && !SMP && !X86_32_NON_STANDARD 1106 + depends on X86_32 && !SMP 1072 1107 help 1073 1108 A local APIC (Advanced Programmable Interrupt Controller) is an 1074 1109 integrated interrupt controller in the CPU. If you have a single-CPU ··· 1093 1128 1094 1129 config X86_LOCAL_APIC 1095 1130 def_bool y 1096 - depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI 1131 + depends on X86_64 || SMP || X86_UP_APIC || PCI_MSI 1097 1132 select IRQ_DOMAIN_HIERARCHY 1098 1133 1099 1134 config ACPI_MADT_WAKEUP ··· 1361 1396 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to 1362 1397 /dev/cpu/31/cpuid. 1363 1398 1364 - choice 1365 - prompt "High Memory Support" 1366 - default HIGHMEM4G 1399 + config HIGHMEM4G 1400 + bool "High Memory Support" 1367 1401 depends on X86_32 1368 - 1369 - config NOHIGHMEM 1370 - bool "off" 1371 1402 help 1372 - Linux can use up to 64 Gigabytes of physical memory on x86 systems. 1403 + Linux can use up to 4 Gigabytes of physical memory on x86 systems. 1373 1404 However, the address space of 32-bit x86 processors is only 4 1374 1405 Gigabytes large. That means that, if you have a large amount of 1375 1406 physical memory, not all of it can be "permanently mapped" by the ··· 1381 1420 possible. 1382 1421 1383 1422 If the machine has between 1 and 4 Gigabytes physical RAM, then 1384 - answer "4GB" here. 1423 + answer "Y" here. 1385 1424 1386 - If more than 4 Gigabytes is used then answer "64GB" here. This 1387 - selection turns Intel PAE (Physical Address Extension) mode on. 1388 - PAE implements 3-level paging on IA32 processors. PAE is fully 1389 - supported by Linux, PAE mode is implemented on all recent Intel 1390 - processors (Pentium Pro and better). NOTE: If you say "64GB" here, 1391 - then the kernel will not boot on CPUs that don't support PAE! 1392 - 1393 - The actual amount of total physical memory will either be 1394 - auto detected or can be forced by using a kernel command line option 1395 - such as "mem=256M". (Try "man bootparam" or see the documentation of 1396 - your boot loader (lilo or loadlin) about how to pass options to the 1397 - kernel at boot time.) 1398 - 1399 - If unsure, say "off". 1400 - 1401 - config HIGHMEM4G 1402 - bool "4GB" 1403 - help 1404 - Select this if you have a 32-bit processor and between 1 and 4 1405 - gigabytes of physical RAM. 1406 - 1407 - config HIGHMEM64G 1408 - bool "64GB" 1409 - depends on X86_HAVE_PAE 1410 - select X86_PAE 1411 - help 1412 - Select this if you have a 32-bit processor and more than 4 1413 - gigabytes of physical RAM. 1414 - 1415 - endchoice 1425 + If unsure, say N. 1416 1426 1417 1427 choice 1418 1428 prompt "Memory split" if EXPERT ··· 1429 1497 depends on X86_32 1430 1498 1431 1499 config HIGHMEM 1432 - def_bool y 1433 - depends on X86_32 && (HIGHMEM64G || HIGHMEM4G) 1500 + def_bool HIGHMEM4G 1434 1501 1435 1502 config X86_PAE 1436 1503 bool "PAE (Physical Address Extension) Support" 1437 1504 depends on X86_32 && X86_HAVE_PAE 1438 1505 select PHYS_ADDR_T_64BIT 1439 - select SWIOTLB 1440 1506 help 1441 1507 PAE is required for NX support, and furthermore enables 1442 1508 larger swapspace support for non-overcommit purposes. It ··· 1504 1574 config NUMA 1505 1575 bool "NUMA Memory Allocation and Scheduler Support" 1506 1576 depends on SMP 1507 - depends on X86_64 || (X86_32 && HIGHMEM64G && X86_BIGSMP) 1508 - default y if X86_BIGSMP 1577 + depends on X86_64 1509 1578 select USE_PERCPU_NUMA_NODE_ID 1510 1579 select OF_NUMA if OF 1511 1580 help ··· 1516 1587 1517 1588 For 64-bit this is recommended if the system is Intel Core i7 1518 1589 (or later), AMD Opteron, or EM64T NUMA. 1519 - 1520 - For 32-bit this is only needed if you boot a 32-bit 1521 - kernel on a 64-bit NUMA platform. 1522 1590 1523 1591 Otherwise, you should say N. 1524 1592 ··· 1555 1629 1556 1630 config ARCH_SPARSEMEM_ENABLE 1557 1631 def_bool y 1558 - depends on X86_64 || NUMA || X86_32 || X86_32_NON_STANDARD 1632 + depends on X86_64 || NUMA || X86_32 1559 1633 select SPARSEMEM_STATIC if X86_32 1560 1634 select SPARSEMEM_VMEMMAP_ENABLE if X86_64 1561 1635 ··· 1600 1674 they can be used for persistent storage. 1601 1675 1602 1676 Say Y if unsure. 1603 - 1604 - config HIGHPTE 1605 - bool "Allocate 3rd-level pagetables from highmem" 1606 - depends on HIGHMEM 1607 - help 1608 - The VM uses one page table entry for each page of physical memory. 1609 - For systems with a lot of RAM, this can be wasteful of precious 1610 - low memory. Setting this option will put user-space page table 1611 - entries in high memory. 1612 1677 1613 1678 config X86_CHECK_BIOS_CORRUPTION 1614 1679 bool "Check for low memory corruption" ··· 2368 2451 def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null) 2369 2452 depends on CC_IS_GCC 2370 2453 2454 + # 2455 + # -fsanitize=kernel-address (KASAN) and -fsanitize=thread (KCSAN) 2456 + # are incompatible with named address spaces with GCC < 13.3 2457 + # (see GCC PR sanitizer/111736 and also PR sanitizer/115172). 2458 + # 2459 + 2371 2460 config CC_HAS_NAMED_AS_FIXED_SANITIZERS 2372 - def_bool CC_IS_GCC && GCC_VERSION >= 130300 2461 + def_bool y 2462 + depends on !(KASAN || KCSAN) || GCC_VERSION >= 130300 2463 + depends on !(UBSAN_BOOL && KASAN) || GCC_VERSION >= 140200 2373 2464 2374 2465 config USE_X86_SEG_SUPPORT 2375 - def_bool y 2376 - depends on CC_HAS_NAMED_AS 2377 - # 2378 - # -fsanitize=kernel-address (KASAN) and -fsanitize=thread 2379 - # (KCSAN) are incompatible with named address spaces with 2380 - # GCC < 13.3 - see GCC PR sanitizer/111736. 2381 - # 2382 - depends on !(KASAN || KCSAN) || CC_HAS_NAMED_AS_FIXED_SANITIZERS 2466 + def_bool CC_HAS_NAMED_AS 2467 + depends on CC_HAS_NAMED_AS_FIXED_SANITIZERS 2383 2468 2384 2469 config CC_HAS_SLS 2385 2470 def_bool $(cc-option,-mharden-sls=all)
+17 -84
arch/x86/Kconfig.cpu
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Put here option for CPU selection and depending optimization 3 3 choice 4 - prompt "Processor family" 5 - default M686 if X86_32 6 - default GENERIC_CPU if X86_64 4 + prompt "x86-32 Processor family" 5 + depends on X86_32 6 + default M686 7 7 help 8 8 This is the processor type of your CPU. This information is 9 9 used for optimizing purposes. In order to compile a kernel ··· 31 31 - "Pentium-4" for the Intel Pentium 4 or P4-based Celeron. 32 32 - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D). 33 33 - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird). 34 - - "Opteron/Athlon64/Hammer/K8" for all K8 and newer AMD CPUs. 35 34 - "Crusoe" for the Transmeta Crusoe series. 36 35 - "Efficeon" for the Transmeta Efficeon series. 37 36 - "Winchip-C6" for original IDT Winchip. ··· 41 42 - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3. 42 43 - "VIA C3-2" for VIA C3-2 "Nehemiah" (model 9 and above). 43 44 - "VIA C7" for VIA C7. 44 - - "Intel P4" for the Pentium 4/Netburst microarchitecture. 45 - - "Core 2/newer Xeon" for all core2 and newer Intel CPUs. 46 45 - "Intel Atom" for the Atom-microarchitecture CPUs. 47 - - "Generic-x86-64" for a kernel which runs on any x86-64 CPU. 48 46 49 47 See each option's help text for additional details. If you don't know 50 - what to do, choose "486". 48 + what to do, choose "Pentium-Pro". 51 49 52 50 config M486SX 53 51 bool "486SX" ··· 110 114 extensions. 111 115 112 116 config MPENTIUMM 113 - bool "Pentium M" 117 + bool "Pentium M/Pentium Dual Core/Core Solo/Core Duo" 114 118 depends on X86_32 115 119 help 116 120 Select this for Intel Pentium M (not Pentium-4 M) 117 - notebook chips. 121 + "Merom" Core Solo/Duo notebook chips 118 122 119 123 config MPENTIUM4 120 124 bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon" ··· 135 139 -Mobile Pentium 4 136 140 -Mobile Pentium 4 M 137 141 -Extreme Edition (Gallatin) 138 - -Prescott 139 - -Prescott 2M 140 - -Cedar Mill 141 - -Presler 142 - -Smithfiled 143 142 Xeons (Intel Xeon, Xeon MP, Xeon LV, Xeon MV) corename: 144 143 -Foster 145 144 -Prestonia 146 145 -Gallatin 147 - -Nocona 148 - -Irwindale 149 - -Cranford 150 - -Potomac 151 - -Paxville 152 - -Dempsey 153 - 154 146 155 147 config MK6 156 148 bool "K6/K6-II/K6-III" ··· 155 171 Select this for an AMD Athlon K7-family processor. Enables use of 156 172 some extended instructions, and passes appropriate optimization 157 173 flags to GCC. 158 - 159 - config MK8 160 - bool "Opteron/Athlon64/Hammer/K8" 161 - help 162 - Select this for an AMD Opteron or Athlon64 Hammer-family processor. 163 - Enables use of some extended instructions, and passes appropriate 164 - optimization flags to GCC. 165 174 166 175 config MCRUSOE 167 176 bool "Crusoe" ··· 235 258 Select this for a VIA C7. Selecting this uses the correct cache 236 259 shift and tells gcc to treat the CPU as a 686. 237 260 238 - config MPSC 239 - bool "Intel P4 / older Netburst based Xeon" 240 - depends on X86_64 241 - help 242 - Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey 243 - Xeon CPUs with Intel 64bit which is compatible with x86-64. 244 - Note that the latest Xeons (Xeon 51xx and 53xx) are not based on the 245 - Netburst core and shouldn't use this option. You can distinguish them 246 - using the cpu family field 247 - in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one. 248 - 249 - config MCORE2 250 - bool "Core 2/newer Xeon" 251 - help 252 - 253 - Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 254 - 53xx) CPUs. You can distinguish newer from older Xeons by the CPU 255 - family in /proc/cpuinfo. Newer ones have 6 and older ones 15 256 - (not a typo) 257 - 258 261 config MATOM 259 262 bool "Intel Atom" 260 263 help 261 - 262 264 Select this for the Intel Atom platform. Intel Atom CPUs have an 263 265 in-order pipelining architecture and thus can benefit from 264 266 accordingly optimized code. Use a recent GCC with specific Atom 265 267 support in order to fully benefit from selecting this option. 266 - 267 - config GENERIC_CPU 268 - bool "Generic-x86-64" 269 - depends on X86_64 270 - help 271 - Generic x86-64 CPU. 272 - Run equally well on all x86-64 CPUs. 273 268 274 269 endchoice 275 270 ··· 266 317 267 318 config X86_L1_CACHE_SHIFT 268 319 int 269 - default "7" if MPENTIUM4 || MPSC 270 - default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU 320 + default "7" if MPENTIUM4 321 + default "6" if MK7 || MPENTIUMM || MATOM || MVIAC7 || X86_GENERIC || X86_64 271 322 default "4" if MELAN || M486SX || M486 || MGEODEGX1 272 323 default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX 273 324 ··· 285 336 286 337 config X86_INTEL_USERCOPY 287 338 def_bool y 288 - depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2 339 + depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK7 || MEFFICEON 289 340 290 341 config X86_USE_PPRO_CHECKSUM 291 342 def_bool y 292 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM 293 - 294 - # 295 - # P6_NOPs are a relatively minor optimization that require a family >= 296 - # 6 processor, except that it is broken on certain VIA chips. 297 - # Furthermore, AMD chips prefer a totally different sequence of NOPs 298 - # (which work on all CPUs). In addition, it looks like Virtual PC 299 - # does not understand them. 300 - # 301 - # As a result, disallow these if we're not compiling for X86_64 (these 302 - # NOPs do work on all x86-64 capable chips); the list of processors in 303 - # the right-hand clause are the cores that benefit from this optimization. 304 - # 305 - config X86_P6_NOP 306 - def_bool y 307 - depends on X86_64 308 - depends on (MCORE2 || MPENTIUM4 || MPSC) 343 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MATOM 309 344 310 345 config X86_TSC 311 346 def_bool y 312 - depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64 347 + depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MATOM) || X86_64 313 348 314 349 config X86_HAVE_PAE 315 350 def_bool y 316 - depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC7 || MCORE2 || MATOM || X86_64 351 + depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC7 || MATOM || X86_64 317 352 318 - config X86_CMPXCHG64 353 + config X86_CX8 319 354 def_bool y 320 - depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7 355 + depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7 || MGEODEGX1 || MGEODE_LX 321 356 322 357 # this should be set for all -march=.. options where the compiler 323 358 # generates cmov. 324 359 config X86_CMOV 325 360 def_bool y 326 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX) 361 + depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || MATOM || MGEODE_LX || X86_64) 327 362 328 363 config X86_MINIMUM_CPU_FAMILY 329 364 int 330 365 default "64" if X86_64 331 - default "6" if X86_32 && (MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MATOM || MCORE2 || MK7 || MK8) 332 - default "5" if X86_32 && X86_CMPXCHG64 366 + default "6" if X86_32 && (MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MATOM || MK7) 367 + default "5" if X86_32 && X86_CX8 333 368 default "4" 334 369 335 370 config X86_DEBUGCTLMSR
+14 -22
arch/x86/Makefile
··· 140 140 # temporary until string.h is fixed 141 141 KBUILD_CFLAGS += -ffreestanding 142 142 143 - ifeq ($(CONFIG_STACKPROTECTOR),y) 144 - ifeq ($(CONFIG_SMP),y) 145 - KBUILD_CFLAGS += -mstack-protector-guard-reg=fs \ 146 - -mstack-protector-guard-symbol=__ref_stack_chk_guard 147 - else 148 - KBUILD_CFLAGS += -mstack-protector-guard=global 149 - endif 150 - endif 143 + percpu_seg := fs 151 144 else 152 145 BITS := 64 153 146 UTS_MACHINE := x86_64 ··· 171 178 # Use -mskip-rax-setup if supported. 172 179 KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup) 173 180 174 - # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) 175 - cflags-$(CONFIG_MK8) += -march=k8 176 - cflags-$(CONFIG_MPSC) += -march=nocona 177 - cflags-$(CONFIG_MCORE2) += -march=core2 178 - cflags-$(CONFIG_MATOM) += -march=atom 179 - cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic 180 - KBUILD_CFLAGS += $(cflags-y) 181 - 182 - rustflags-$(CONFIG_MK8) += -Ctarget-cpu=k8 183 - rustflags-$(CONFIG_MPSC) += -Ctarget-cpu=nocona 184 - rustflags-$(CONFIG_MCORE2) += -Ctarget-cpu=core2 185 - rustflags-$(CONFIG_MATOM) += -Ctarget-cpu=atom 186 - rustflags-$(CONFIG_GENERIC_CPU) += -Ztune-cpu=generic 187 - KBUILD_RUSTFLAGS += $(rustflags-y) 181 + KBUILD_CFLAGS += -march=x86-64 -mtune=generic 182 + KBUILD_RUSTFLAGS += -Ctarget-cpu=x86-64 -Ztune-cpu=generic 188 183 189 184 KBUILD_CFLAGS += -mno-red-zone 190 185 KBUILD_CFLAGS += -mcmodel=kernel 191 186 KBUILD_RUSTFLAGS += -Cno-redzone=y 192 187 KBUILD_RUSTFLAGS += -Ccode-model=kernel 188 + 189 + percpu_seg := gs 190 + endif 191 + 192 + ifeq ($(CONFIG_STACKPROTECTOR),y) 193 + ifeq ($(CONFIG_SMP),y) 194 + KBUILD_CFLAGS += -mstack-protector-guard-reg=$(percpu_seg) 195 + KBUILD_CFLAGS += -mstack-protector-guard-symbol=__ref_stack_chk_guard 196 + else 197 + KBUILD_CFLAGS += -mstack-protector-guard=global 198 + endif 193 199 endif 194 200 195 201 #
+1 -4
arch/x86/Makefile_32.cpu
··· 24 24 # Please note, that patches that add -march=athlon-xp and friends are pointless. 25 25 # They make zero difference whatsosever to performance at this time. 26 26 cflags-$(CONFIG_MK7) += -march=athlon 27 - cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon) 28 27 cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align) 29 28 cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align) 30 29 cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586) ··· 31 32 cflags-$(CONFIG_MCYRIXIII) += $(call cc-option,-march=c3,-march=i486) $(align) 32 33 cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686) 33 34 cflags-$(CONFIG_MVIAC7) += -march=i686 34 - cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2) 35 - cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \ 36 - $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic)) 35 + cflags-$(CONFIG_MATOM) += -march=atom 37 36 38 37 # AMD Elan support 39 38 cflags-$(CONFIG_MELAN) += -march=i486
+1 -13
arch/x86/boot/compressed/misc.c
··· 235 235 236 236 /* 237 237 * Process relocations: 32 bit relocations first then 64 bit after. 238 - * Three sets of binary relocations are added to the end of the kernel 238 + * Two sets of binary relocations are added to the end of the kernel 239 239 * before compression. Each relocation table entry is the kernel 240 240 * address of the location which needs to be updated stored as a 241 241 * 32-bit value which is sign extended to 64 bits. ··· 245 245 * kernel bits... 246 246 * 0 - zero terminator for 64 bit relocations 247 247 * 64 bit relocation repeated 248 - * 0 - zero terminator for inverse 32 bit relocations 249 - * 32 bit inverse relocation repeated 250 248 * 0 - zero terminator for 32 bit relocations 251 249 * 32 bit relocation repeated 252 250 * ··· 261 263 *(uint32_t *)ptr += delta; 262 264 } 263 265 #ifdef CONFIG_X86_64 264 - while (*--reloc) { 265 - long extended = *reloc; 266 - extended += map; 267 - 268 - ptr = (unsigned long)extended; 269 - if (ptr < min_addr || ptr > max_addr) 270 - error("inverse 32-bit relocation outside of kernel!\n"); 271 - 272 - *(int32_t *)ptr -= delta; 273 - } 274 266 for (reloc--; *reloc; reloc--) { 275 267 long extended = *reloc; 276 268 extended += map;
-2
arch/x86/configs/xen.config
··· 1 1 # global x86 required specific stuff 2 - # On 32-bit HIGHMEM4G is not allowed 3 - CONFIG_HIGHMEM64G=y 4 2 CONFIG_64BIT=y 5 3 6 4 # These enable us to allow some of the
-2
arch/x86/entry/entry.S
··· 54 54 55 55 THUNK warn_thunk_thunk, __warn_thunk 56 56 57 - #ifndef CONFIG_X86_64 58 57 /* 59 58 * Clang's implementation of TLS stack cookies requires the variable in 60 59 * question to be a TLS variable. If the variable happens to be defined as an ··· 66 67 */ 67 68 #ifdef CONFIG_STACKPROTECTOR 68 69 EXPORT_SYMBOL(__ref_stack_chk_guard); 69 - #endif 70 70 #endif
+1 -1
arch/x86/entry/entry_64.S
··· 193 193 194 194 #ifdef CONFIG_STACKPROTECTOR 195 195 movq TASK_stack_canary(%rsi), %rbx 196 - movq %rbx, PER_CPU_VAR(fixed_percpu_data + FIXED_stack_canary) 196 + movq %rbx, PER_CPU_VAR(__stack_chk_guard) 197 197 #endif 198 198 199 199 /*
+11 -10
arch/x86/events/intel/core.c
··· 4685 4685 return -EOPNOTSUPP; 4686 4686 } 4687 4687 4688 - static enum hybrid_cpu_type adl_get_hybrid_cpu_type(void) 4688 + static enum intel_cpu_type adl_get_hybrid_cpu_type(void) 4689 4689 { 4690 - return HYBRID_INTEL_CORE; 4690 + return INTEL_CPU_TYPE_CORE; 4691 4691 } 4692 4692 4693 4693 static inline bool erratum_hsw11(struct perf_event *event) ··· 5032 5032 5033 5033 static struct x86_hybrid_pmu *find_hybrid_pmu_for_cpu(void) 5034 5034 { 5035 - u8 cpu_type = get_this_hybrid_cpu_type(); 5035 + struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); 5036 + enum intel_cpu_type cpu_type = c->topo.intel_type; 5036 5037 int i; 5037 5038 5038 5039 /* ··· 5042 5041 * on it. There should be a fixup function provided for these 5043 5042 * troublesome CPUs (->get_hybrid_cpu_type). 5044 5043 */ 5045 - if (cpu_type == HYBRID_INTEL_NONE) { 5044 + if (cpu_type == INTEL_CPU_TYPE_UNKNOWN) { 5046 5045 if (x86_pmu.get_hybrid_cpu_type) 5047 5046 cpu_type = x86_pmu.get_hybrid_cpu_type(); 5048 5047 else ··· 5059 5058 enum hybrid_pmu_type pmu_type = x86_pmu.hybrid_pmu[i].pmu_type; 5060 5059 u32 native_id; 5061 5060 5062 - if (cpu_type == HYBRID_INTEL_CORE && pmu_type == hybrid_big) 5061 + if (cpu_type == INTEL_CPU_TYPE_CORE && pmu_type == hybrid_big) 5063 5062 return &x86_pmu.hybrid_pmu[i]; 5064 - if (cpu_type == HYBRID_INTEL_ATOM) { 5063 + if (cpu_type == INTEL_CPU_TYPE_ATOM) { 5065 5064 if (x86_pmu.num_hybrid_pmus == 2 && pmu_type == hybrid_small) 5066 5065 return &x86_pmu.hybrid_pmu[i]; 5067 5066 5068 - native_id = get_this_hybrid_cpu_native_id(); 5069 - if (native_id == skt_native_id && pmu_type == hybrid_small) 5067 + native_id = c->topo.intel_native_model_id; 5068 + if (native_id == INTEL_ATOM_SKT_NATIVE_ID && pmu_type == hybrid_small) 5070 5069 return &x86_pmu.hybrid_pmu[i]; 5071 - if (native_id == cmt_native_id && pmu_type == hybrid_tiny) 5070 + if (native_id == INTEL_ATOM_CMT_NATIVE_ID && pmu_type == hybrid_tiny) 5072 5071 return &x86_pmu.hybrid_pmu[i]; 5073 5072 } 5074 5073 } ··· 6697 6696 case INTEL_ATOM_SILVERMONT_D: 6698 6697 case INTEL_ATOM_SILVERMONT_MID: 6699 6698 case INTEL_ATOM_AIRMONT: 6700 - case INTEL_ATOM_AIRMONT_MID: 6699 + case INTEL_ATOM_SILVERMONT_MID2: 6701 6700 memcpy(hw_cache_event_ids, slm_hw_cache_event_ids, 6702 6701 sizeof(hw_cache_event_ids)); 6703 6702 memcpy(hw_cache_extra_regs, slm_hw_cache_extra_regs,
+1 -18
arch/x86/events/perf_event.h
··· 669 669 #define PERF_PEBS_DATA_SOURCE_GRT_MAX 0x10 670 670 #define PERF_PEBS_DATA_SOURCE_GRT_MASK (PERF_PEBS_DATA_SOURCE_GRT_MAX - 1) 671 671 672 - /* 673 - * CPUID.1AH.EAX[31:0] uniquely identifies the microarchitecture 674 - * of the core. Bits 31-24 indicates its core type (Core or Atom) 675 - * and Bits [23:0] indicates the native model ID of the core. 676 - * Core type and native model ID are defined in below enumerations. 677 - */ 678 - enum hybrid_cpu_type { 679 - HYBRID_INTEL_NONE, 680 - HYBRID_INTEL_ATOM = 0x20, 681 - HYBRID_INTEL_CORE = 0x40, 682 - }; 683 - 684 672 #define X86_HYBRID_PMU_ATOM_IDX 0 685 673 #define X86_HYBRID_PMU_CORE_IDX 1 686 674 #define X86_HYBRID_PMU_TINY_IDX 2 ··· 683 695 hybrid_big_small = hybrid_big | hybrid_small, 684 696 hybrid_small_tiny = hybrid_small | hybrid_tiny, 685 697 hybrid_big_small_tiny = hybrid_big | hybrid_small_tiny, 686 - }; 687 - 688 - enum atom_native_id { 689 - cmt_native_id = 0x2, /* Crestmont */ 690 - skt_native_id = 0x3, /* Skymont */ 691 698 }; 692 699 693 700 struct x86_hybrid_pmu { ··· 977 994 */ 978 995 int num_hybrid_pmus; 979 996 struct x86_hybrid_pmu *hybrid_pmu; 980 - enum hybrid_cpu_type (*get_hybrid_cpu_type) (void); 997 + enum intel_cpu_type (*get_hybrid_cpu_type) (void); 981 998 }; 982 999 983 1000 struct x86_perf_task_context_opt {
-1
arch/x86/hyperv/mmu.c
··· 239 239 240 240 pr_info("Using hypercall for remote TLB flush\n"); 241 241 pv_ops.mmu.flush_tlb_multi = hyperv_flush_tlb_multi; 242 - pv_ops.mmu.tlb_remove_table = tlb_remove_table; 243 242 }
+8 -16
arch/x86/include/asm/alternative.h
··· 236 236 * references: i.e., if used for a function, it would add the PLT 237 237 * suffix. 238 238 */ 239 - #define alternative_call(oldfunc, newfunc, ft_flags, output, input...) \ 239 + #define alternative_call(oldfunc, newfunc, ft_flags, output, input, clobbers...) \ 240 240 asm_inline volatile(ALTERNATIVE("call %c[old]", "call %c[new]", ft_flags) \ 241 241 : ALT_OUTPUT_SP(output) \ 242 - : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) 242 + : [old] "i" (oldfunc), [new] "i" (newfunc) \ 243 + COMMA(input) \ 244 + : clobbers) 243 245 244 246 /* 245 247 * Like alternative_call, but there are two features and respective functions. ··· 250 248 * Otherwise, old function is used. 251 249 */ 252 250 #define alternative_call_2(oldfunc, newfunc1, ft_flags1, newfunc2, ft_flags2, \ 253 - output, input...) \ 251 + output, input, clobbers...) \ 254 252 asm_inline volatile(ALTERNATIVE_2("call %c[old]", "call %c[new1]", ft_flags1, \ 255 253 "call %c[new2]", ft_flags2) \ 256 254 : ALT_OUTPUT_SP(output) \ 257 255 : [old] "i" (oldfunc), [new1] "i" (newfunc1), \ 258 - [new2] "i" (newfunc2), ## input) 259 - 260 - /* 261 - * use this macro(s) if you need more than one output parameter 262 - * in alternative_io 263 - */ 264 - #define ASM_OUTPUT2(a...) a 265 - 266 - /* 267 - * use this macro if you need clobbers but no inputs in 268 - * alternative_{input,io,call}() 269 - */ 270 - #define ASM_NO_INPUT_CLOBBER(clbr...) "i" (0) : clbr 256 + [new2] "i" (newfunc2) \ 257 + COMMA(input) \ 258 + : clobbers) 271 259 272 260 #define ALT_OUTPUT_SP(...) ASM_CALL_CONSTRAINT, ## __VA_ARGS__ 273 261
+2 -2
arch/x86/include/asm/apic.h
··· 99 99 volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg); 100 100 101 101 alternative_io("movl %0, %1", "xchgl %0, %1", X86_BUG_11AP, 102 - ASM_OUTPUT2("=r" (v), "=m" (*addr)), 103 - ASM_OUTPUT2("0" (v), "m" (*addr))); 102 + ASM_OUTPUT("=r" (v), "=m" (*addr)), 103 + ASM_INPUT("0" (v), "m" (*addr))); 104 104 } 105 105 106 106 static inline u32 native_apic_mem_read(u32 reg)
+1 -1
arch/x86/include/asm/asm-prototypes.h
··· 16 16 #include <asm/gsseg.h> 17 17 #include <asm/nospec-branch.h> 18 18 19 - #ifndef CONFIG_X86_CMPXCHG64 19 + #ifndef CONFIG_X86_CX8 20 20 extern void cmpxchg8b_emu(void); 21 21 #endif 22 22
+11
arch/x86/include/asm/asm.h
··· 213 213 214 214 /* For C file, we already have NOKPROBE_SYMBOL macro */ 215 215 216 + /* Insert a comma if args are non-empty */ 217 + #define COMMA(x...) __COMMA(x) 218 + #define __COMMA(...) , ##__VA_ARGS__ 219 + 220 + /* 221 + * Combine multiple asm inline constraint args into a single arg for passing to 222 + * another macro. 223 + */ 224 + #define ASM_OUTPUT(x...) x 225 + #define ASM_INPUT(x...) x 226 + 216 227 /* 217 228 * This output constraint should be used for any inline asm which has a "call" 218 229 * instruction. Otherwise the asm may be inserted before the frame pointer
+60 -38
arch/x86/include/asm/atomic64_32.h
··· 48 48 ATOMIC64_EXPORT(atomic64_##sym) 49 49 #endif 50 50 51 - #ifdef CONFIG_X86_CMPXCHG64 52 - #define __alternative_atomic64(f, g, out, in...) \ 53 - asm volatile("call %c[func]" \ 51 + #ifdef CONFIG_X86_CX8 52 + #define __alternative_atomic64(f, g, out, in, clobbers...) \ 53 + asm volatile("call %c[func]" \ 54 54 : ALT_OUTPUT_SP(out) \ 55 - : [func] "i" (atomic64_##g##_cx8), ## in) 55 + : [func] "i" (atomic64_##g##_cx8) \ 56 + COMMA(in) \ 57 + : clobbers) 56 58 57 59 #define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8) 58 60 #else 59 - #define __alternative_atomic64(f, g, out, in...) \ 60 - alternative_call(atomic64_##f##_386, atomic64_##g##_cx8, \ 61 - X86_FEATURE_CX8, ASM_OUTPUT2(out), ## in) 61 + #define __alternative_atomic64(f, g, out, in, clobbers...) \ 62 + alternative_call(atomic64_##f##_386, atomic64_##g##_cx8, \ 63 + X86_FEATURE_CX8, ASM_OUTPUT(out), \ 64 + ASM_INPUT(in), clobbers) 62 65 63 66 #define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8); \ 64 67 ATOMIC64_DECL_ONE(sym##_386) ··· 72 69 ATOMIC64_DECL_ONE(dec_386); 73 70 #endif 74 71 75 - #define alternative_atomic64(f, out, in...) \ 76 - __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in) 72 + #define alternative_atomic64(f, out, in, clobbers...) \ 73 + __alternative_atomic64(f, f, ASM_OUTPUT(out), ASM_INPUT(in), clobbers) 77 74 78 75 ATOMIC64_DECL(read); 79 76 ATOMIC64_DECL(set); ··· 108 105 s64 o; 109 106 unsigned high = (unsigned)(n >> 32); 110 107 unsigned low = (unsigned)n; 111 - alternative_atomic64(xchg, "=&A" (o), 112 - "S" (v), "b" (low), "c" (high) 113 - : "memory"); 108 + alternative_atomic64(xchg, 109 + "=&A" (o), 110 + ASM_INPUT("S" (v), "b" (low), "c" (high)), 111 + "memory"); 114 112 return o; 115 113 } 116 114 #define arch_atomic64_xchg arch_atomic64_xchg ··· 120 116 { 121 117 unsigned high = (unsigned)(i >> 32); 122 118 unsigned low = (unsigned)i; 123 - alternative_atomic64(set, /* no output */, 124 - "S" (v), "b" (low), "c" (high) 125 - : "eax", "edx", "memory"); 119 + alternative_atomic64(set, 120 + /* no output */, 121 + ASM_INPUT("S" (v), "b" (low), "c" (high)), 122 + "eax", "edx", "memory"); 126 123 } 127 124 128 125 static __always_inline s64 arch_atomic64_read(const atomic64_t *v) 129 126 { 130 127 s64 r; 131 - alternative_atomic64(read, "=&A" (r), "c" (v) : "memory"); 128 + alternative_atomic64(read, "=&A" (r), "c" (v), "memory"); 132 129 return r; 133 130 } 134 131 135 132 static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v) 136 133 { 137 134 alternative_atomic64(add_return, 138 - ASM_OUTPUT2("+A" (i), "+c" (v)), 139 - ASM_NO_INPUT_CLOBBER("memory")); 135 + ASM_OUTPUT("+A" (i), "+c" (v)), 136 + /* no input */, 137 + "memory"); 140 138 return i; 141 139 } 142 140 #define arch_atomic64_add_return arch_atomic64_add_return ··· 146 140 static __always_inline s64 arch_atomic64_sub_return(s64 i, atomic64_t *v) 147 141 { 148 142 alternative_atomic64(sub_return, 149 - ASM_OUTPUT2("+A" (i), "+c" (v)), 150 - ASM_NO_INPUT_CLOBBER("memory")); 143 + ASM_OUTPUT("+A" (i), "+c" (v)), 144 + /* no input */, 145 + "memory"); 151 146 return i; 152 147 } 153 148 #define arch_atomic64_sub_return arch_atomic64_sub_return ··· 156 149 static __always_inline s64 arch_atomic64_inc_return(atomic64_t *v) 157 150 { 158 151 s64 a; 159 - alternative_atomic64(inc_return, "=&A" (a), 160 - "S" (v) : "memory", "ecx"); 152 + alternative_atomic64(inc_return, 153 + "=&A" (a), 154 + "S" (v), 155 + "memory", "ecx"); 161 156 return a; 162 157 } 163 158 #define arch_atomic64_inc_return arch_atomic64_inc_return ··· 167 158 static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v) 168 159 { 169 160 s64 a; 170 - alternative_atomic64(dec_return, "=&A" (a), 171 - "S" (v) : "memory", "ecx"); 161 + alternative_atomic64(dec_return, 162 + "=&A" (a), 163 + "S" (v), 164 + "memory", "ecx"); 172 165 return a; 173 166 } 174 167 #define arch_atomic64_dec_return arch_atomic64_dec_return ··· 178 167 static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v) 179 168 { 180 169 __alternative_atomic64(add, add_return, 181 - ASM_OUTPUT2("+A" (i), "+c" (v)), 182 - ASM_NO_INPUT_CLOBBER("memory")); 170 + ASM_OUTPUT("+A" (i), "+c" (v)), 171 + /* no input */, 172 + "memory"); 183 173 } 184 174 185 175 static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v) 186 176 { 187 177 __alternative_atomic64(sub, sub_return, 188 - ASM_OUTPUT2("+A" (i), "+c" (v)), 189 - ASM_NO_INPUT_CLOBBER("memory")); 178 + ASM_OUTPUT("+A" (i), "+c" (v)), 179 + /* no input */, 180 + "memory"); 190 181 } 191 182 192 183 static __always_inline void arch_atomic64_inc(atomic64_t *v) 193 184 { 194 - __alternative_atomic64(inc, inc_return, /* no output */, 195 - "S" (v) : "memory", "eax", "ecx", "edx"); 185 + __alternative_atomic64(inc, inc_return, 186 + /* no output */, 187 + "S" (v), 188 + "memory", "eax", "ecx", "edx"); 196 189 } 197 190 #define arch_atomic64_inc arch_atomic64_inc 198 191 199 192 static __always_inline void arch_atomic64_dec(atomic64_t *v) 200 193 { 201 - __alternative_atomic64(dec, dec_return, /* no output */, 202 - "S" (v) : "memory", "eax", "ecx", "edx"); 194 + __alternative_atomic64(dec, dec_return, 195 + /* no output */, 196 + "S" (v), 197 + "memory", "eax", "ecx", "edx"); 203 198 } 204 199 #define arch_atomic64_dec arch_atomic64_dec 205 200 ··· 214 197 unsigned low = (unsigned)u; 215 198 unsigned high = (unsigned)(u >> 32); 216 199 alternative_atomic64(add_unless, 217 - ASM_OUTPUT2("+A" (a), "+c" (low), "+D" (high)), 218 - "S" (v) : "memory"); 200 + ASM_OUTPUT("+A" (a), "+c" (low), "+D" (high)), 201 + "S" (v), 202 + "memory"); 219 203 return (int)a; 220 204 } 221 205 #define arch_atomic64_add_unless arch_atomic64_add_unless ··· 224 206 static __always_inline int arch_atomic64_inc_not_zero(atomic64_t *v) 225 207 { 226 208 int r; 227 - alternative_atomic64(inc_not_zero, "=&a" (r), 228 - "S" (v) : "ecx", "edx", "memory"); 209 + alternative_atomic64(inc_not_zero, 210 + "=&a" (r), 211 + "S" (v), 212 + "ecx", "edx", "memory"); 229 213 return r; 230 214 } 231 215 #define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero ··· 235 215 static __always_inline s64 arch_atomic64_dec_if_positive(atomic64_t *v) 236 216 { 237 217 s64 r; 238 - alternative_atomic64(dec_if_positive, "=&A" (r), 239 - "S" (v) : "ecx", "memory"); 218 + alternative_atomic64(dec_if_positive, 219 + "=&A" (r), 220 + "S" (v), 221 + "ecx", "memory"); 240 222 return r; 241 223 } 242 224 #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
+19 -15
arch/x86/include/asm/cmpxchg_32.h
··· 69 69 return __arch_try_cmpxchg64(ptr, oldp, new,); 70 70 } 71 71 72 - #ifdef CONFIG_X86_CMPXCHG64 72 + #ifdef CONFIG_X86_CX8 73 73 74 74 #define arch_cmpxchg64 __cmpxchg64 75 75 ··· 91 91 union __u64_halves o = { .full = (_old), }, \ 92 92 n = { .full = (_new), }; \ 93 93 \ 94 - asm volatile(ALTERNATIVE(_lock_loc \ 95 - "call cmpxchg8b_emu", \ 96 - _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 97 - : ALT_OUTPUT_SP("+a" (o.low), "+d" (o.high)) \ 98 - : "b" (n.low), "c" (n.high), [ptr] "S" (_ptr) \ 99 - : "memory"); \ 94 + asm_inline volatile( \ 95 + ALTERNATIVE(_lock_loc \ 96 + "call cmpxchg8b_emu", \ 97 + _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 98 + : ALT_OUTPUT_SP("+a" (o.low), "+d" (o.high)) \ 99 + : "b" (n.low), "c" (n.high), \ 100 + [ptr] "S" (_ptr) \ 101 + : "memory"); \ 100 102 \ 101 103 o.full; \ 102 104 }) ··· 121 119 n = { .full = (_new), }; \ 122 120 bool ret; \ 123 121 \ 124 - asm volatile(ALTERNATIVE(_lock_loc \ 125 - "call cmpxchg8b_emu", \ 126 - _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 127 - CC_SET(e) \ 128 - : ALT_OUTPUT_SP(CC_OUT(e) (ret), \ 129 - "+a" (o.low), "+d" (o.high)) \ 130 - : "b" (n.low), "c" (n.high), [ptr] "S" (_ptr) \ 131 - : "memory"); \ 122 + asm_inline volatile( \ 123 + ALTERNATIVE(_lock_loc \ 124 + "call cmpxchg8b_emu", \ 125 + _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 126 + CC_SET(e) \ 127 + : ALT_OUTPUT_SP(CC_OUT(e) (ret), \ 128 + "+a" (o.low), "+d" (o.high)) \ 129 + : "b" (n.low), "c" (n.high), \ 130 + [ptr] "S" (_ptr) \ 131 + : "memory"); \ 132 132 \ 133 133 if (unlikely(!ret)) \ 134 134 *(_oldp) = o.full; \
-14
arch/x86/include/asm/cpu.h
··· 49 49 static inline void bus_lock_init(void) {} 50 50 #endif 51 51 52 - #ifdef CONFIG_CPU_SUP_INTEL 53 - u8 get_this_hybrid_cpu_type(void); 54 - u32 get_this_hybrid_cpu_native_id(void); 55 - #else 56 - static inline u8 get_this_hybrid_cpu_type(void) 57 - { 58 - return 0; 59 - } 60 - 61 - static inline u32 get_this_hybrid_cpu_native_id(void) 62 - { 63 - return 0; 64 - } 65 - #endif 66 52 #ifdef CONFIG_IA32_FEAT_CTL 67 53 void init_ia32_feat_ctl(struct cpuinfo_x86 *c); 68 54 #else
+1 -5
arch/x86/include/asm/cpufeature.h
··· 37 37 NR_CPUID_WORDS, 38 38 }; 39 39 40 - #define X86_CAP_FMT_NUM "%d:%d" 41 - #define x86_cap_flag_num(flag) ((flag) >> 5), ((flag) & 31) 42 - 43 40 extern const char * const x86_cap_flags[NCAPINTS*32]; 44 41 extern const char * const x86_power_flags[32]; 45 - #define X86_CAP_FMT "%s" 46 - #define x86_cap_flag(flag) x86_cap_flags[flag] 47 42 48 43 /* 49 44 * In order to save room, we index into this array by doing 50 45 * X86_BUG_<name> - NCAPINTS*32. 51 46 */ 52 47 extern const char * const x86_bug_flags[NBUGINTS*32]; 48 + #define x86_bug_flag(flag) x86_bug_flags[flag] 53 49 54 50 #define test_cpu_cap(c, bit) \ 55 51 arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
+1
arch/x86/include/asm/cpuid.h
··· 6 6 #ifndef _ASM_X86_CPUID_H 7 7 #define _ASM_X86_CPUID_H 8 8 9 + #include <linux/build_bug.h> 9 10 #include <linux/types.h> 10 11 11 12 #include <asm/string.h>
-1
arch/x86/include/asm/desc.h
··· 46 46 } __attribute__((aligned(PAGE_SIZE))); 47 47 48 48 DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page); 49 - DECLARE_INIT_PER_CPU(gdt_page); 50 49 51 50 /* Provide the original GDT */ 52 51 static inline struct desc_struct *get_cpu_gdt_rw(unsigned int cpu)
+3 -2
arch/x86/include/asm/elf.h
··· 54 54 #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ 55 55 #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ 56 56 #define R_X86_64_RELATIVE 8 /* Adjust by program base */ 57 - #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative 58 - offset to GOT */ 57 + #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative offset to GOT */ 58 + #define R_X86_64_GOTPCRELX 41 59 + #define R_X86_64_REX_GOTPCRELX 42 59 60 #define R_X86_64_32 10 /* Direct 32 bit zero extended */ 60 61 #define R_X86_64_32S 11 /* Direct 32 bit sign extended */ 61 62 #define R_X86_64_16 12 /* Direct 16 bit zero extended */
+21 -8
arch/x86/include/asm/intel-family.h
··· 110 110 111 111 #define INTEL_SAPPHIRERAPIDS_X IFM(6, 0x8F) /* Golden Cove */ 112 112 113 - #define INTEL_EMERALDRAPIDS_X IFM(6, 0xCF) 113 + #define INTEL_EMERALDRAPIDS_X IFM(6, 0xCF) /* Raptor Cove */ 114 114 115 - #define INTEL_GRANITERAPIDS_X IFM(6, 0xAD) 115 + #define INTEL_GRANITERAPIDS_X IFM(6, 0xAD) /* Redwood Cove */ 116 116 #define INTEL_GRANITERAPIDS_D IFM(6, 0xAE) 117 117 118 118 /* "Hybrid" Processors (P-Core/E-Core) */ ··· 126 126 #define INTEL_RAPTORLAKE_P IFM(6, 0xBA) 127 127 #define INTEL_RAPTORLAKE_S IFM(6, 0xBF) 128 128 129 - #define INTEL_METEORLAKE IFM(6, 0xAC) 129 + #define INTEL_METEORLAKE IFM(6, 0xAC) /* Redwood Cove / Crestmont */ 130 130 #define INTEL_METEORLAKE_L IFM(6, 0xAA) 131 131 132 - #define INTEL_ARROWLAKE_H IFM(6, 0xC5) 132 + #define INTEL_ARROWLAKE_H IFM(6, 0xC5) /* Lion Cove / Skymont */ 133 133 #define INTEL_ARROWLAKE IFM(6, 0xC6) 134 134 #define INTEL_ARROWLAKE_U IFM(6, 0xB5) 135 135 136 - #define INTEL_LUNARLAKE_M IFM(6, 0xBD) 136 + #define INTEL_LUNARLAKE_M IFM(6, 0xBD) /* Lion Cove / Skymont */ 137 137 138 - #define INTEL_PANTHERLAKE_L IFM(6, 0xCC) 138 + #define INTEL_PANTHERLAKE_L IFM(6, 0xCC) /* Cougar Cove / Crestmont */ 139 139 140 140 /* "Small Core" Processors (Atom/E-Core) */ 141 141 ··· 149 149 #define INTEL_ATOM_SILVERMONT IFM(6, 0x37) /* Bay Trail, Valleyview */ 150 150 #define INTEL_ATOM_SILVERMONT_D IFM(6, 0x4D) /* Avaton, Rangely */ 151 151 #define INTEL_ATOM_SILVERMONT_MID IFM(6, 0x4A) /* Merriefield */ 152 + #define INTEL_ATOM_SILVERMONT_MID2 IFM(6, 0x5A) /* Anniedale */ 152 153 153 154 #define INTEL_ATOM_AIRMONT IFM(6, 0x4C) /* Cherry Trail, Braswell */ 154 - #define INTEL_ATOM_AIRMONT_MID IFM(6, 0x5A) /* Moorefield */ 155 155 #define INTEL_ATOM_AIRMONT_NP IFM(6, 0x75) /* Lightning Mountain */ 156 156 157 157 #define INTEL_ATOM_GOLDMONT IFM(6, 0x5C) /* Apollo Lake */ ··· 182 182 /* Family 19 */ 183 183 #define INTEL_PANTHERCOVE_X IFM(19, 0x01) /* Diamond Rapids */ 184 184 185 - /* CPU core types */ 185 + /* 186 + * Intel CPU core types 187 + * 188 + * CPUID.1AH.EAX[31:0] uniquely identifies the microarchitecture 189 + * of the core. Bits 31-24 indicates its core type (Core or Atom) 190 + * and Bits [23:0] indicates the native model ID of the core. 191 + * Core type and native model ID are defined in below enumerations. 192 + */ 186 193 enum intel_cpu_type { 194 + INTEL_CPU_TYPE_UNKNOWN, 187 195 INTEL_CPU_TYPE_ATOM = 0x20, 188 196 INTEL_CPU_TYPE_CORE = 0x40, 197 + }; 198 + 199 + enum intel_native_id { 200 + INTEL_ATOM_CMT_NATIVE_ID = 0x2, /* Crestmont */ 201 + INTEL_ATOM_SKT_NATIVE_ID = 0x3, /* Skymont */ 189 202 }; 190 203 191 204 #endif /* _ASM_X86_INTEL_FAMILY_H */
+3
arch/x86/include/asm/io.h
··· 175 175 extern void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long size); 176 176 #define ioremap_encrypted ioremap_encrypted 177 177 178 + void *arch_memremap_wb(phys_addr_t phys_addr, size_t size, unsigned long flags); 179 + #define arch_memremap_wb arch_memremap_wb 180 + 178 181 /** 179 182 * ioremap - map bus memory into CPU space 180 183 * @offset: bus address of the memory
+9 -9
arch/x86/include/asm/mshyperv.h
··· 77 77 return hv_tdx_hypercall(control, input_address, output_address); 78 78 79 79 if (hv_isolation_type_snp() && !hyperv_paravisor_present) { 80 - __asm__ __volatile__("mov %4, %%r8\n" 80 + __asm__ __volatile__("mov %[output_address], %%r8\n" 81 81 "vmmcall" 82 82 : "=a" (hv_status), ASM_CALL_CONSTRAINT, 83 83 "+c" (control), "+d" (input_address) 84 - : "r" (output_address) 84 + : [output_address] "r" (output_address) 85 85 : "cc", "memory", "r8", "r9", "r10", "r11"); 86 86 return hv_status; 87 87 } ··· 89 89 if (!hv_hypercall_pg) 90 90 return U64_MAX; 91 91 92 - __asm__ __volatile__("mov %4, %%r8\n" 92 + __asm__ __volatile__("mov %[output_address], %%r8\n" 93 93 CALL_NOSPEC 94 94 : "=a" (hv_status), ASM_CALL_CONSTRAINT, 95 95 "+c" (control), "+d" (input_address) 96 - : "r" (output_address), 97 - THUNK_TARGET(hv_hypercall_pg) 96 + : [output_address] "r" (output_address), 97 + THUNK_TARGET(hv_hypercall_pg) 98 98 : "cc", "memory", "r8", "r9", "r10", "r11"); 99 99 #else 100 100 u32 input_address_hi = upper_32_bits(input_address); ··· 187 187 return hv_tdx_hypercall(control, input1, input2); 188 188 189 189 if (hv_isolation_type_snp() && !hyperv_paravisor_present) { 190 - __asm__ __volatile__("mov %4, %%r8\n" 190 + __asm__ __volatile__("mov %[input2], %%r8\n" 191 191 "vmmcall" 192 192 : "=a" (hv_status), ASM_CALL_CONSTRAINT, 193 193 "+c" (control), "+d" (input1) 194 - : "r" (input2) 194 + : [input2] "r" (input2) 195 195 : "cc", "r8", "r9", "r10", "r11"); 196 196 } else { 197 - __asm__ __volatile__("mov %4, %%r8\n" 197 + __asm__ __volatile__("mov %[input2], %%r8\n" 198 198 CALL_NOSPEC 199 199 : "=a" (hv_status), ASM_CALL_CONSTRAINT, 200 200 "+c" (control), "+d" (input1) 201 - : "r" (input2), 201 + : [input2] "r" (input2), 202 202 THUNK_TARGET(hv_hypercall_pg) 203 203 : "cc", "r8", "r9", "r10", "r11"); 204 204 }
+19 -13
arch/x86/include/asm/nospec-branch.h
··· 198 198 .endm 199 199 200 200 /* 201 - * Equivalent to -mindirect-branch-cs-prefix; emit the 5 byte jmp/call 202 - * to the retpoline thunk with a CS prefix when the register requires 203 - * a RAX prefix byte to encode. Also see apply_retpolines(). 201 + * Emits a conditional CS prefix that is compatible with 202 + * -mindirect-branch-cs-prefix. 204 203 */ 205 204 .macro __CS_PREFIX reg:req 206 205 .irp rs,r8,r9,r10,r11,r12,r13,r14,r15 ··· 420 421 #ifdef CONFIG_X86_64 421 422 422 423 /* 424 + * Emits a conditional CS prefix that is compatible with 425 + * -mindirect-branch-cs-prefix. 426 + */ 427 + #define __CS_PREFIX(reg) \ 428 + ".irp rs,r8,r9,r10,r11,r12,r13,r14,r15\n" \ 429 + ".ifc \\rs," reg "\n" \ 430 + ".byte 0x2e\n" \ 431 + ".endif\n" \ 432 + ".endr\n" 433 + 434 + /* 423 435 * Inline asm uses the %V modifier which is only in newer GCC 424 436 * which is ensured when CONFIG_MITIGATION_RETPOLINE is defined. 425 437 */ 426 - # define CALL_NOSPEC \ 427 - ALTERNATIVE_2( \ 428 - ANNOTATE_RETPOLINE_SAFE \ 429 - "call *%[thunk_target]\n", \ 430 - "call __x86_indirect_thunk_%V[thunk_target]\n", \ 431 - X86_FEATURE_RETPOLINE, \ 432 - "lfence;\n" \ 433 - ANNOTATE_RETPOLINE_SAFE \ 434 - "call *%[thunk_target]\n", \ 435 - X86_FEATURE_RETPOLINE_LFENCE) 438 + #ifdef CONFIG_MITIGATION_RETPOLINE 439 + #define CALL_NOSPEC __CS_PREFIX("%V[thunk_target]") \ 440 + "call __x86_indirect_thunk_%V[thunk_target]\n" 441 + #else 442 + #define CALL_NOSPEC "call *%[thunk_target]\n" 443 + #endif 436 444 437 445 # define THUNK_TARGET(addr) [thunk_target] "r" (addr) 438 446
+2 -2
arch/x86/include/asm/page_32_types.h
··· 11 11 * a virtual address space of one gigabyte, which limits the 12 12 * amount of physical memory you can use to about 950MB. 13 13 * 14 - * If you want more physical memory than this then see the CONFIG_HIGHMEM4G 15 - * and CONFIG_HIGHMEM64G options in the kernel configuration. 14 + * If you want more physical memory than this then see the CONFIG_VMSPLIT_2G 15 + * and CONFIG_HIGHMEM4G options in the kernel configuration. 16 16 */ 17 17 #define __PAGE_OFFSET_BASE _AC(CONFIG_PAGE_OFFSET, UL) 18 18 #define __PAGE_OFFSET __PAGE_OFFSET_BASE
+2 -2
arch/x86/include/asm/page_64.h
··· 55 55 clear_page_rep, X86_FEATURE_REP_GOOD, 56 56 clear_page_erms, X86_FEATURE_ERMS, 57 57 "=D" (page), 58 - "D" (page) 59 - : "cc", "memory", "rax", "rcx"); 58 + "D" (page), 59 + "cc", "memory", "rax", "rcx"); 60 60 } 61 61 62 62 void copy_page(void *to, void *from);
-5
arch/x86/include/asm/paravirt.h
··· 91 91 PVOP_VCALL2(mmu.flush_tlb_multi, cpumask, info); 92 92 } 93 93 94 - static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) 95 - { 96 - PVOP_VCALL2(mmu.tlb_remove_table, tlb, table); 97 - } 98 - 99 94 static inline void paravirt_arch_exit_mmap(struct mm_struct *mm) 100 95 { 101 96 PVOP_VCALL1(mmu.exit_mmap, mm);
-2
arch/x86/include/asm/paravirt_types.h
··· 134 134 void (*flush_tlb_multi)(const struct cpumask *cpus, 135 135 const struct flush_tlb_info *info); 136 136 137 - void (*tlb_remove_table)(struct mmu_gather *tlb, void *table); 138 - 139 137 /* Hook for intercepting the destruction of an mm_struct. */ 140 138 void (*exit_mmap)(struct mm_struct *mm); 141 139 void (*notify_page_enc_status_changed)(unsigned long pfn, int npages, bool enc);
+57 -88
arch/x86/include/asm/percpu.h
··· 20 20 21 21 #define PER_CPU_VAR(var) __percpu(var)__percpu_rel 22 22 23 - #ifdef CONFIG_X86_64_SMP 24 - # define INIT_PER_CPU_VAR(var) init_per_cpu__##var 25 - #else 26 - # define INIT_PER_CPU_VAR(var) var 27 - #endif 28 - 29 23 #else /* !__ASSEMBLY__: */ 30 24 25 + #include <linux/args.h> 31 26 #include <linux/build_bug.h> 32 27 #include <linux/stringify.h> 33 28 #include <asm/asm.h> ··· 36 41 # define __seg_fs __attribute__((address_space(__seg_fs))) 37 42 #endif 38 43 39 - #ifdef CONFIG_X86_64 40 - # define __percpu_seg_override __seg_gs 41 - #else 42 - # define __percpu_seg_override __seg_fs 43 - #endif 44 - 44 + #define __percpu_seg_override CONCATENATE(__seg_, __percpu_seg) 45 45 #define __percpu_prefix "" 46 46 47 47 #else /* !CONFIG_CC_HAS_NAMED_AS: */ ··· 88 98 #define __force_percpu_arg(x) __force_percpu_prefix "%" #x 89 99 90 100 /* 91 - * Initialized pointers to per-CPU variables needed for the boot 92 - * processor need to use these macros to get the proper address 93 - * offset from __per_cpu_load on SMP. 94 - * 95 - * There also must be an entry in vmlinux_64.lds.S 96 - */ 97 - #define DECLARE_INIT_PER_CPU(var) \ 98 - extern typeof(var) init_per_cpu_var(var) 99 - 100 - #ifdef CONFIG_X86_64_SMP 101 - # define init_per_cpu_var(var) init_per_cpu__##var 102 - #else 103 - # define init_per_cpu_var(var) var 104 - #endif 105 - 106 - /* 107 101 * For arch-specific code, we can use direct single-insn ops (they 108 102 * don't give an lvalue though). 109 103 */ ··· 102 128 #define __pcpu_cast_4(val) ((u32)(((unsigned long) val) & 0xffffffff)) 103 129 #define __pcpu_cast_8(val) ((u64)(val)) 104 130 105 - #define __pcpu_op1_1(op, dst) op "b " dst 106 - #define __pcpu_op1_2(op, dst) op "w " dst 107 - #define __pcpu_op1_4(op, dst) op "l " dst 108 - #define __pcpu_op1_8(op, dst) op "q " dst 109 - 110 - #define __pcpu_op2_1(op, src, dst) op "b " src ", " dst 111 - #define __pcpu_op2_2(op, src, dst) op "w " src ", " dst 112 - #define __pcpu_op2_4(op, src, dst) op "l " src ", " dst 113 - #define __pcpu_op2_8(op, src, dst) op "q " src ", " dst 131 + #define __pcpu_op_1(op) op "b " 132 + #define __pcpu_op_2(op) op "w " 133 + #define __pcpu_op_4(op) op "l " 134 + #define __pcpu_op_8(op) op "q " 114 135 115 136 #define __pcpu_reg_1(mod, x) mod "q" (x) 116 137 #define __pcpu_reg_2(mod, x) mod "r" (x) ··· 137 168 ({ \ 138 169 __pcpu_type_##size pfo_val__; \ 139 170 \ 140 - asm qual (__pcpu_op2_##size("mov", __percpu_arg([var]), "%[val]") \ 171 + asm qual (__pcpu_op_##size("mov") \ 172 + __percpu_arg([var]) ", %[val]" \ 141 173 : [val] __pcpu_reg_##size("=", pfo_val__) \ 142 174 : [var] "m" (__my_cpu_var(_var))); \ 143 175 \ ··· 154 184 pto_tmp__ = (_val); \ 155 185 (void)pto_tmp__; \ 156 186 } \ 157 - asm qual(__pcpu_op2_##size("mov", "%[val]", __percpu_arg([var])) \ 187 + asm qual (__pcpu_op_##size("mov") "%[val], " \ 188 + __percpu_arg([var]) \ 158 189 : [var] "=m" (__my_cpu_var(_var)) \ 159 190 : [val] __pcpu_reg_imm_##size(pto_val__)); \ 160 191 } while (0) ··· 172 201 ({ \ 173 202 __pcpu_type_##size pfo_val__; \ 174 203 \ 175 - asm(__pcpu_op2_##size("mov", __force_percpu_arg(a[var]), "%[val]") \ 204 + asm(__pcpu_op_##size("mov") \ 205 + __force_percpu_arg(a[var]) ", %[val]" \ 176 206 : [val] __pcpu_reg_##size("=", pfo_val__) \ 177 207 : [var] "i" (&(_var))); \ 178 208 \ ··· 182 210 183 211 #define percpu_unary_op(size, qual, op, _var) \ 184 212 ({ \ 185 - asm qual (__pcpu_op1_##size(op, __percpu_arg([var])) \ 213 + asm qual (__pcpu_op_##size(op) __percpu_arg([var]) \ 186 214 : [var] "+m" (__my_cpu_var(_var))); \ 187 215 }) 188 216 ··· 195 223 pto_tmp__ = (_val); \ 196 224 (void)pto_tmp__; \ 197 225 } \ 198 - asm qual(__pcpu_op2_##size(op, "%[val]", __percpu_arg([var])) \ 226 + asm qual (__pcpu_op_##size(op) "%[val], " __percpu_arg([var]) \ 199 227 : [var] "+m" (__my_cpu_var(_var)) \ 200 228 : [val] __pcpu_reg_imm_##size(pto_val__)); \ 201 229 } while (0) ··· 231 259 ({ \ 232 260 __pcpu_type_##size paro_tmp__ = __pcpu_cast_##size(_val); \ 233 261 \ 234 - asm qual (__pcpu_op2_##size("xadd", "%[tmp]", \ 235 - __percpu_arg([var])) \ 262 + asm qual (__pcpu_op_##size("xadd") "%[tmp], " \ 263 + __percpu_arg([var]) \ 236 264 : [tmp] __pcpu_reg_##size("+", paro_tmp__), \ 237 265 [var] "+m" (__my_cpu_var(_var)) \ 238 266 : : "memory"); \ ··· 275 303 __pcpu_type_##size pco_old__ = __pcpu_cast_##size(_oval); \ 276 304 __pcpu_type_##size pco_new__ = __pcpu_cast_##size(_nval); \ 277 305 \ 278 - asm qual (__pcpu_op2_##size("cmpxchg", "%[nval]", \ 279 - __percpu_arg([var])) \ 306 + asm qual (__pcpu_op_##size("cmpxchg") "%[nval], " \ 307 + __percpu_arg([var]) \ 280 308 : [oval] "+a" (pco_old__), \ 281 309 [var] "+m" (__my_cpu_var(_var)) \ 282 310 : [nval] __pcpu_reg_##size(, pco_new__) \ ··· 292 320 __pcpu_type_##size pco_old__ = *pco_oval__; \ 293 321 __pcpu_type_##size pco_new__ = __pcpu_cast_##size(_nval); \ 294 322 \ 295 - asm qual (__pcpu_op2_##size("cmpxchg", "%[nval]", \ 296 - __percpu_arg([var])) \ 323 + asm qual (__pcpu_op_##size("cmpxchg") "%[nval], " \ 324 + __percpu_arg([var]) \ 297 325 CC_SET(z) \ 298 326 : CC_OUT(z) (success), \ 299 327 [oval] "+a" (pco_old__), \ ··· 320 348 old__.var = _oval; \ 321 349 new__.var = _nval; \ 322 350 \ 323 - asm qual (ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \ 324 - "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \ 325 - : [var] "+m" (__my_cpu_var(_var)), \ 326 - "+a" (old__.low), \ 327 - "+d" (old__.high) \ 328 - : "b" (new__.low), \ 329 - "c" (new__.high), \ 330 - "S" (&(_var)) \ 331 - : "memory"); \ 351 + asm_inline qual ( \ 352 + ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \ 353 + "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \ 354 + : ALT_OUTPUT_SP([var] "+m" (__my_cpu_var(_var)), \ 355 + "+a" (old__.low), "+d" (old__.high)) \ 356 + : "b" (new__.low), "c" (new__.high), \ 357 + "S" (&(_var)) \ 358 + : "memory"); \ 332 359 \ 333 360 old__.var; \ 334 361 }) ··· 349 378 old__.var = *_oval; \ 350 379 new__.var = _nval; \ 351 380 \ 352 - asm qual (ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \ 353 - "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \ 354 - CC_SET(z) \ 355 - : CC_OUT(z) (success), \ 356 - [var] "+m" (__my_cpu_var(_var)), \ 357 - "+a" (old__.low), \ 358 - "+d" (old__.high) \ 359 - : "b" (new__.low), \ 360 - "c" (new__.high), \ 361 - "S" (&(_var)) \ 362 - : "memory"); \ 381 + asm_inline qual ( \ 382 + ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \ 383 + "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \ 384 + CC_SET(z) \ 385 + : ALT_OUTPUT_SP(CC_OUT(z) (success), \ 386 + [var] "+m" (__my_cpu_var(_var)), \ 387 + "+a" (old__.low), "+d" (old__.high)) \ 388 + : "b" (new__.low), "c" (new__.high), \ 389 + "S" (&(_var)) \ 390 + : "memory"); \ 363 391 if (unlikely(!success)) \ 364 392 *_oval = old__.var; \ 365 393 \ ··· 389 419 old__.var = _oval; \ 390 420 new__.var = _nval; \ 391 421 \ 392 - asm qual (ALTERNATIVE("call this_cpu_cmpxchg16b_emu", \ 393 - "cmpxchg16b " __percpu_arg([var]), X86_FEATURE_CX16) \ 394 - : [var] "+m" (__my_cpu_var(_var)), \ 395 - "+a" (old__.low), \ 396 - "+d" (old__.high) \ 397 - : "b" (new__.low), \ 398 - "c" (new__.high), \ 399 - "S" (&(_var)) \ 400 - : "memory"); \ 422 + asm_inline qual ( \ 423 + ALTERNATIVE("call this_cpu_cmpxchg16b_emu", \ 424 + "cmpxchg16b " __percpu_arg([var]), X86_FEATURE_CX16) \ 425 + : ALT_OUTPUT_SP([var] "+m" (__my_cpu_var(_var)), \ 426 + "+a" (old__.low), "+d" (old__.high)) \ 427 + : "b" (new__.low), "c" (new__.high), \ 428 + "S" (&(_var)) \ 429 + : "memory"); \ 401 430 \ 402 431 old__.var; \ 403 432 }) ··· 418 449 old__.var = *_oval; \ 419 450 new__.var = _nval; \ 420 451 \ 421 - asm qual (ALTERNATIVE("call this_cpu_cmpxchg16b_emu", \ 422 - "cmpxchg16b " __percpu_arg([var]), X86_FEATURE_CX16) \ 423 - CC_SET(z) \ 424 - : CC_OUT(z) (success), \ 425 - [var] "+m" (__my_cpu_var(_var)), \ 426 - "+a" (old__.low), \ 427 - "+d" (old__.high) \ 428 - : "b" (new__.low), \ 429 - "c" (new__.high), \ 430 - "S" (&(_var)) \ 431 - : "memory"); \ 452 + asm_inline qual ( \ 453 + ALTERNATIVE("call this_cpu_cmpxchg16b_emu", \ 454 + "cmpxchg16b " __percpu_arg([var]), X86_FEATURE_CX16) \ 455 + CC_SET(z) \ 456 + : ALT_OUTPUT_SP(CC_OUT(z) (success), \ 457 + [var] "+m" (__my_cpu_var(_var)), \ 458 + "+a" (old__.low), "+d" (old__.high)) \ 459 + : "b" (new__.low), "c" (new__.high), \ 460 + "S" (&(_var)) \ 461 + : "memory"); \ 432 462 if (unlikely(!success)) \ 433 463 *_oval = old__.var; \ 464 + \ 434 465 likely(success); \ 435 466 }) 436 467
-5
arch/x86/include/asm/pgalloc.h
··· 29 29 static inline void paravirt_release_p4d(unsigned long pfn) {} 30 30 #endif 31 31 32 - /* 33 - * Flags to use when allocating a user page table page. 34 - */ 35 - extern gfp_t __userpte_alloc_gfp; 36 - 37 32 #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION 38 33 /* 39 34 * Instead of one PGD, we acquire two PGDs. Being order-1, it is
+14 -35
arch/x86/include/asm/processor.h
··· 60 60 # define ARCH_MIN_MMSTRUCT_ALIGN 0 61 61 #endif 62 62 63 - enum tlb_infos { 64 - ENTRIES, 65 - NR_INFO 66 - }; 67 - 68 - extern u16 __read_mostly tlb_lli_4k[NR_INFO]; 69 - extern u16 __read_mostly tlb_lli_2m[NR_INFO]; 70 - extern u16 __read_mostly tlb_lli_4m[NR_INFO]; 71 - extern u16 __read_mostly tlb_lld_4k[NR_INFO]; 72 - extern u16 __read_mostly tlb_lld_2m[NR_INFO]; 73 - extern u16 __read_mostly tlb_lld_4m[NR_INFO]; 74 - extern u16 __read_mostly tlb_lld_1g[NR_INFO]; 63 + extern u16 __read_mostly tlb_lli_4k; 64 + extern u16 __read_mostly tlb_lli_2m; 65 + extern u16 __read_mostly tlb_lli_4m; 66 + extern u16 __read_mostly tlb_lld_4k; 67 + extern u16 __read_mostly tlb_lld_2m; 68 + extern u16 __read_mostly tlb_lld_4m; 69 + extern u16 __read_mostly tlb_lld_1g; 75 70 76 71 /* 77 72 * CPU type and hardware bug flags. Kept separately for each CPU. ··· 229 234 void init_cpu_devs(void); 230 235 void get_cpu_vendor(struct cpuinfo_x86 *c); 231 236 extern void early_cpu_init(void); 232 - extern void identify_secondary_cpu(struct cpuinfo_x86 *); 237 + extern void identify_secondary_cpu(unsigned int cpu); 233 238 extern void print_cpu_info(struct cpuinfo_x86 *); 234 239 void print_cpu_msr(struct cpuinfo_x86 *); 235 240 ··· 416 421 } __aligned(IRQ_STACK_SIZE); 417 422 418 423 #ifdef CONFIG_X86_64 419 - struct fixed_percpu_data { 420 - /* 421 - * GCC hardcodes the stack canary as %gs:40. Since the 422 - * irq_stack is the object at %gs:0, we reserve the bottom 423 - * 48 bytes of the irq stack for the canary. 424 - * 425 - * Once we are willing to require -mstack-protector-guard-symbol= 426 - * support for x86_64 stackprotector, we can get rid of this. 427 - */ 428 - char gs_base[40]; 429 - unsigned long stack_canary; 430 - }; 431 - 432 - DECLARE_PER_CPU_FIRST(struct fixed_percpu_data, fixed_percpu_data) __visible; 433 - DECLARE_INIT_PER_CPU(fixed_percpu_data); 434 - 435 424 static inline unsigned long cpu_kernelmode_gs_base(int cpu) 436 425 { 437 - return (unsigned long)per_cpu(fixed_percpu_data.gs_base, cpu); 426 + #ifdef CONFIG_SMP 427 + return per_cpu_offset(cpu); 428 + #else 429 + return 0; 430 + #endif 438 431 } 439 432 440 433 extern asmlinkage void entry_SYSCALL32_ignore(void); 441 434 442 435 /* Save actual FS/GS selectors and bases to current->thread */ 443 436 void current_save_fsgs(void); 444 - #else /* X86_64 */ 445 - #ifdef CONFIG_STACKPROTECTOR 446 - DECLARE_PER_CPU(unsigned long, __stack_chk_guard); 447 - #endif 448 - #endif /* !X86_64 */ 437 + #endif /* X86_64 */ 449 438 450 439 struct perf_event; 451 440
+1 -1
arch/x86/include/asm/required-features.h
··· 23 23 # define NEED_PAE 0 24 24 #endif 25 25 26 - #ifdef CONFIG_X86_CMPXCHG64 26 + #ifdef CONFIG_X86_CX8 27 27 # define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) 28 28 #else 29 29 # define NEED_CX8 0
+3 -2
arch/x86/include/asm/smp.h
··· 114 114 int wbinvd_on_all_cpus(void); 115 115 116 116 void smp_kick_mwait_play_dead(void); 117 + void __noreturn mwait_play_dead(unsigned int eax_hint); 117 118 118 119 void native_smp_send_reschedule(int cpu); 119 120 void native_send_call_func_ipi(const struct cpumask *mask); 120 121 void native_send_call_func_single_ipi(int cpu); 121 - 122 - void smp_store_cpu_info(int id); 123 122 124 123 asmlinkage __visible void smp_reboot_interrupt(void); 125 124 __visible void smp_reschedule_interrupt(struct pt_regs *regs); ··· 157 158 { 158 159 return (struct cpumask *)cpumask_of(0); 159 160 } 161 + 162 + static inline void __noreturn mwait_play_dead(unsigned int eax_hint) { BUG(); } 160 163 #endif /* CONFIG_SMP */ 161 164 162 165 #ifdef CONFIG_DEBUG_NMI_SELFTEST
-13
arch/x86/include/asm/sta2x11.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Header file for STMicroelectronics ConneXt (STA2X11) IOHub 4 - */ 5 - #ifndef __ASM_STA2X11_H 6 - #define __ASM_STA2X11_H 7 - 8 - #include <linux/pci.h> 9 - 10 - /* This needs to be called from the MFD to configure its sub-devices */ 11 - struct sta2x11_instance *sta2x11_get_instance(struct pci_dev *pdev); 12 - 13 - #endif /* __ASM_STA2X11_H */
+5 -31
arch/x86/include/asm/stackprotector.h
··· 2 2 /* 3 3 * GCC stack protector support. 4 4 * 5 - * Stack protector works by putting predefined pattern at the start of 5 + * Stack protector works by putting a predefined pattern at the start of 6 6 * the stack frame and verifying that it hasn't been overwritten when 7 - * returning from the function. The pattern is called stack canary 8 - * and unfortunately gcc historically required it to be at a fixed offset 9 - * from the percpu segment base. On x86_64, the offset is 40 bytes. 10 - * 11 - * The same segment is shared by percpu area and stack canary. On 12 - * x86_64, percpu symbols are zero based and %gs (64-bit) points to the 13 - * base of percpu area. The first occupant of the percpu area is always 14 - * fixed_percpu_data which contains stack_canary at the appropriate 15 - * offset. On x86_32, the stack canary is just a regular percpu 16 - * variable. 17 - * 18 - * Putting percpu data in %fs on 32-bit is a minor optimization compared to 19 - * using %gs. Since 32-bit userspace normally has %fs == 0, we are likely 20 - * to load 0 into %fs on exit to usermode, whereas with percpu data in 21 - * %gs, we are likely to load a non-null %gs on return to user mode. 22 - * 23 - * Once we are willing to require GCC 8.1 or better for 64-bit stackprotector 24 - * support, we can remove some of this complexity. 7 + * returning from the function. The pattern is called the stack canary 8 + * and is a unique value for each task. 25 9 */ 26 10 27 11 #ifndef _ASM_STACKPROTECTOR_H ··· 19 35 #include <asm/desc.h> 20 36 21 37 #include <linux/sched.h> 38 + 39 + DECLARE_PER_CPU(unsigned long, __stack_chk_guard); 22 40 23 41 /* 24 42 * Initialize the stackprotector canary value. ··· 37 51 { 38 52 unsigned long canary = get_random_canary(); 39 53 40 - #ifdef CONFIG_X86_64 41 - BUILD_BUG_ON(offsetof(struct fixed_percpu_data, stack_canary) != 40); 42 - #endif 43 - 44 54 current->stack_canary = canary; 45 - #ifdef CONFIG_X86_64 46 - this_cpu_write(fixed_percpu_data.stack_canary, canary); 47 - #else 48 55 this_cpu_write(__stack_chk_guard, canary); 49 - #endif 50 56 } 51 57 52 58 static inline void cpu_init_stack_canary(int cpu, struct task_struct *idle) 53 59 { 54 - #ifdef CONFIG_X86_64 55 - per_cpu(fixed_percpu_data.stack_canary, cpu) = idle->stack_canary; 56 - #else 57 60 per_cpu(__stack_chk_guard, cpu) = idle->stack_canary; 58 - #endif 59 61 } 60 62 61 63 #else /* STACKPROTECTOR */
-4
arch/x86/include/asm/vermagic.h
··· 15 15 #define MODULE_PROC_FAMILY "586TSC " 16 16 #elif defined CONFIG_M586MMX 17 17 #define MODULE_PROC_FAMILY "586MMX " 18 - #elif defined CONFIG_MCORE2 19 - #define MODULE_PROC_FAMILY "CORE2 " 20 18 #elif defined CONFIG_MATOM 21 19 #define MODULE_PROC_FAMILY "ATOM " 22 20 #elif defined CONFIG_M686 ··· 31 33 #define MODULE_PROC_FAMILY "K6 " 32 34 #elif defined CONFIG_MK7 33 35 #define MODULE_PROC_FAMILY "K7 " 34 - #elif defined CONFIG_MK8 35 - #define MODULE_PROC_FAMILY "K8 " 36 36 #elif defined CONFIG_MELAN 37 37 #define MODULE_PROC_FAMILY "ELAN " 38 38 #elif defined CONFIG_MCRUSOE
+2
arch/x86/kernel/Makefile
··· 44 44 KCOV_INSTRUMENT_unwind_frame.o := n 45 45 KCOV_INSTRUMENT_unwind_guess.o := n 46 46 47 + CFLAGS_head32.o := -fno-stack-protector 48 + CFLAGS_head64.o := -fno-stack-protector 47 49 CFLAGS_irq.o := -I $(src)/../include/asm/trace 48 50 49 51 obj-y += head_$(BITS).o
+11
arch/x86/kernel/acpi/cstate.c
··· 16 16 #include <asm/cpuid.h> 17 17 #include <asm/mwait.h> 18 18 #include <asm/special_insns.h> 19 + #include <asm/smp.h> 19 20 20 21 /* 21 22 * Initialize bm_flags based on the CPU cache properties ··· 205 204 return retval; 206 205 } 207 206 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); 207 + 208 + void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 209 + { 210 + unsigned int cpu = smp_processor_id(); 211 + struct cstate_entry *percpu_entry; 212 + 213 + percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); 214 + mwait_play_dead(percpu_entry->states[cx->index].eax); 215 + } 216 + EXPORT_SYMBOL_GPL(acpi_processor_ffh_play_dead); 208 217 209 218 void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx) 210 219 {
-3
arch/x86/kernel/apic/Makefile
··· 23 23 obj-y += apic_flat_64.o 24 24 endif 25 25 26 - # APIC probe will depend on the listing order here 27 - obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o 28 - 29 26 # For 32bit, probe_32 need to be listed last 30 27 obj-$(CONFIG_X86_LOCAL_APIC) += probe_$(BITS).o
-3
arch/x86/kernel/apic/apic.c
··· 1371 1371 1372 1372 x86_64_probe_apic(); 1373 1373 1374 - x86_32_install_bigsmp(); 1375 - 1376 1374 if (x86_platform.apic_post_init) 1377 1375 x86_platform.apic_post_init(); 1378 1376 ··· 1672 1674 boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR)); 1673 1675 } 1674 1676 topology_register_boot_apic(boot_cpu_physical_apicid); 1675 - x86_32_probe_bigsmp_early(); 1676 1677 } 1677 1678 1678 1679 #ifdef CONFIG_X86_X2APIC
-105
arch/x86/kernel/apic/bigsmp_32.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * APIC driver for "bigsmp" xAPIC machines with more than 8 virtual CPUs. 4 - * 5 - * Drives the local APIC in "clustered mode". 6 - */ 7 - #include <linux/cpumask.h> 8 - #include <linux/dmi.h> 9 - #include <linux/smp.h> 10 - 11 - #include <asm/apic.h> 12 - #include <asm/io_apic.h> 13 - 14 - #include "local.h" 15 - 16 - static u32 bigsmp_get_apic_id(u32 x) 17 - { 18 - return (x >> 24) & 0xFF; 19 - } 20 - 21 - static void bigsmp_send_IPI_allbutself(int vector) 22 - { 23 - default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector); 24 - } 25 - 26 - static void bigsmp_send_IPI_all(int vector) 27 - { 28 - default_send_IPI_mask_sequence_phys(cpu_online_mask, vector); 29 - } 30 - 31 - static int dmi_bigsmp; /* can be set by dmi scanners */ 32 - 33 - static int hp_ht_bigsmp(const struct dmi_system_id *d) 34 - { 35 - printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident); 36 - dmi_bigsmp = 1; 37 - 38 - return 0; 39 - } 40 - 41 - 42 - static const struct dmi_system_id bigsmp_dmi_table[] = { 43 - { hp_ht_bigsmp, "HP ProLiant DL760 G2", 44 - { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), 45 - DMI_MATCH(DMI_BIOS_VERSION, "P44-"), 46 - } 47 - }, 48 - 49 - { hp_ht_bigsmp, "HP ProLiant DL740", 50 - { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), 51 - DMI_MATCH(DMI_BIOS_VERSION, "P47-"), 52 - } 53 - }, 54 - { } /* NULL entry stops DMI scanning */ 55 - }; 56 - 57 - static int probe_bigsmp(void) 58 - { 59 - return dmi_check_system(bigsmp_dmi_table); 60 - } 61 - 62 - static struct apic apic_bigsmp __ro_after_init = { 63 - 64 - .name = "bigsmp", 65 - .probe = probe_bigsmp, 66 - 67 - .dest_mode_logical = false, 68 - 69 - .disable_esr = 1, 70 - 71 - .cpu_present_to_apicid = default_cpu_present_to_apicid, 72 - 73 - .max_apic_id = 0xFE, 74 - .get_apic_id = bigsmp_get_apic_id, 75 - 76 - .calc_dest_apicid = apic_default_calc_apicid, 77 - 78 - .send_IPI = default_send_IPI_single_phys, 79 - .send_IPI_mask = default_send_IPI_mask_sequence_phys, 80 - .send_IPI_mask_allbutself = NULL, 81 - .send_IPI_allbutself = bigsmp_send_IPI_allbutself, 82 - .send_IPI_all = bigsmp_send_IPI_all, 83 - .send_IPI_self = default_send_IPI_self, 84 - 85 - .read = native_apic_mem_read, 86 - .write = native_apic_mem_write, 87 - .eoi = native_apic_mem_eoi, 88 - .icr_read = native_apic_icr_read, 89 - .icr_write = native_apic_icr_write, 90 - .wait_icr_idle = apic_mem_wait_icr_idle, 91 - .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, 92 - }; 93 - 94 - bool __init apic_bigsmp_possible(bool cmdline_override) 95 - { 96 - return apic == &apic_bigsmp || !cmdline_override; 97 - } 98 - 99 - void __init apic_bigsmp_force(void) 100 - { 101 - if (apic != &apic_bigsmp) 102 - apic_install_driver(&apic_bigsmp); 103 - } 104 - 105 - apic_driver(apic_bigsmp);
-13
arch/x86/kernel/apic/local.h
··· 65 65 void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector); 66 66 void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector); 67 67 void default_send_IPI_mask_logical(const struct cpumask *mask, int vector); 68 - void x86_32_probe_bigsmp_early(void); 69 - void x86_32_install_bigsmp(void); 70 - #else 71 - static inline void x86_32_probe_bigsmp_early(void) { } 72 - static inline void x86_32_install_bigsmp(void) { } 73 - #endif 74 - 75 - #ifdef CONFIG_X86_BIGSMP 76 - bool apic_bigsmp_possible(bool cmdline_selected); 77 - void apic_bigsmp_force(void); 78 - #else 79 - static inline bool apic_bigsmp_possible(bool cmdline_selected) { return false; }; 80 - static inline void apic_bigsmp_force(void) { } 81 68 #endif
-29
arch/x86/kernel/apic/probe_32.c
··· 93 93 } 94 94 early_param("apic", parse_apic); 95 95 96 - void __init x86_32_probe_bigsmp_early(void) 97 - { 98 - if (nr_cpu_ids <= 8 || xen_pv_domain()) 99 - return; 100 - 101 - if (IS_ENABLED(CONFIG_X86_BIGSMP)) { 102 - switch (boot_cpu_data.x86_vendor) { 103 - case X86_VENDOR_INTEL: 104 - if (!APIC_XAPIC(boot_cpu_apic_version)) 105 - break; 106 - /* P4 and above */ 107 - fallthrough; 108 - case X86_VENDOR_HYGON: 109 - case X86_VENDOR_AMD: 110 - if (apic_bigsmp_possible(cmdline_apic)) 111 - return; 112 - break; 113 - } 114 - } 115 - pr_info("Limiting to 8 possible CPUs\n"); 116 - set_nr_cpu_ids(8); 117 - } 118 - 119 - void __init x86_32_install_bigsmp(void) 120 - { 121 - if (nr_cpu_ids > 8 && !xen_pv_domain()) 122 - apic_bigsmp_force(); 123 - } 124 - 125 96 void __init x86_32_probe_apic(void) 126 97 { 127 98 if (!cmdline_apic) {
-6
arch/x86/kernel/asm-offsets_64.c
··· 54 54 BLANK(); 55 55 #undef ENTRY 56 56 57 - BLANK(); 58 - 59 - #ifdef CONFIG_STACKPROTECTOR 60 - OFFSET(FIXED_stack_canary, fixed_percpu_data, stack_canary); 61 - BLANK(); 62 - #endif 63 57 return 0; 64 58 }
+10 -10
arch/x86/kernel/cpu/amd.c
··· 632 632 * (model = 0x14) and later actually support it. 633 633 * (AMD Erratum #110, docId: 25759). 634 634 */ 635 - if (c->x86_model < 0x14 && cpu_has(c, X86_FEATURE_LAHF_LM)) { 635 + if (c->x86_model < 0x14 && cpu_has(c, X86_FEATURE_LAHF_LM) && !cpu_has(c, X86_FEATURE_HYPERVISOR)) { 636 636 clear_cpu_cap(c, X86_FEATURE_LAHF_LM); 637 637 if (!rdmsrl_amd_safe(0xc001100d, &value)) { 638 638 value &= ~BIT_64(32); ··· 1105 1105 1106 1106 cpuid(0x80000006, &eax, &ebx, &ecx, &edx); 1107 1107 1108 - tlb_lld_4k[ENTRIES] = (ebx >> 16) & mask; 1109 - tlb_lli_4k[ENTRIES] = ebx & mask; 1108 + tlb_lld_4k = (ebx >> 16) & mask; 1109 + tlb_lli_4k = ebx & mask; 1110 1110 1111 1111 /* 1112 1112 * K8 doesn't have 2M/4M entries in the L2 TLB so read out the L1 TLB ··· 1119 1119 1120 1120 /* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ 1121 1121 if (!((eax >> 16) & mask)) 1122 - tlb_lld_2m[ENTRIES] = (cpuid_eax(0x80000005) >> 16) & 0xff; 1122 + tlb_lld_2m = (cpuid_eax(0x80000005) >> 16) & 0xff; 1123 1123 else 1124 - tlb_lld_2m[ENTRIES] = (eax >> 16) & mask; 1124 + tlb_lld_2m = (eax >> 16) & mask; 1125 1125 1126 1126 /* a 4M entry uses two 2M entries */ 1127 - tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1; 1127 + tlb_lld_4m = tlb_lld_2m >> 1; 1128 1128 1129 1129 /* Handle ITLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ 1130 1130 if (!(eax & mask)) { 1131 1131 /* Erratum 658 */ 1132 1132 if (c->x86 == 0x15 && c->x86_model <= 0x1f) { 1133 - tlb_lli_2m[ENTRIES] = 1024; 1133 + tlb_lli_2m = 1024; 1134 1134 } else { 1135 1135 cpuid(0x80000005, &eax, &ebx, &ecx, &edx); 1136 - tlb_lli_2m[ENTRIES] = eax & 0xff; 1136 + tlb_lli_2m = eax & 0xff; 1137 1137 } 1138 1138 } else 1139 - tlb_lli_2m[ENTRIES] = eax & mask; 1139 + tlb_lli_2m = eax & mask; 1140 1140 1141 - tlb_lli_4m[ENTRIES] = tlb_lli_2m[ENTRIES] >> 1; 1141 + tlb_lli_4m = tlb_lli_2m >> 1; 1142 1142 } 1143 1143 1144 1144 static const struct cpu_dev amd_cpu_dev = {
+9 -24
arch/x86/kernel/cpu/cacheinfo.c
··· 8 8 * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD. 9 9 */ 10 10 11 - #include <linux/slab.h> 12 11 #include <linux/cacheinfo.h> 12 + #include <linux/capability.h> 13 13 #include <linux/cpu.h> 14 14 #include <linux/cpuhotplug.h> 15 - #include <linux/sched.h> 16 - #include <linux/capability.h> 17 - #include <linux/sysfs.h> 18 15 #include <linux/pci.h> 19 16 #include <linux/stop_machine.h> 17 + #include <linux/sysfs.h> 20 18 21 - #include <asm/cpufeature.h> 22 - #include <asm/cacheinfo.h> 23 19 #include <asm/amd_nb.h> 24 - #include <asm/smp.h> 20 + #include <asm/cacheinfo.h> 21 + #include <asm/cpufeature.h> 25 22 #include <asm/mtrr.h> 23 + #include <asm/smp.h> 26 24 #include <asm/tlbflush.h> 27 25 28 26 #include "cpu.h" ··· 29 31 #define LVL_1_DATA 2 30 32 #define LVL_2 3 31 33 #define LVL_3 4 32 - #define LVL_TRACE 5 33 34 34 35 /* Shared last level cache maps */ 35 36 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map); ··· 93 96 { 0x66, LVL_1_DATA, 8 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 94 97 { 0x67, LVL_1_DATA, 16 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 95 98 { 0x68, LVL_1_DATA, 32 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 96 - { 0x70, LVL_TRACE, 12 }, /* 8-way set assoc */ 97 - { 0x71, LVL_TRACE, 16 }, /* 8-way set assoc */ 98 - { 0x72, LVL_TRACE, 32 }, /* 8-way set assoc */ 99 - { 0x73, LVL_TRACE, 64 }, /* 8-way set assoc */ 100 99 { 0x78, LVL_2, MB(1) }, /* 4-way set assoc, 64 byte line size */ 101 100 { 0x79, LVL_2, 128 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 102 101 { 0x7a, LVL_2, 256 }, /* 8-way set assoc, sectored cache, 64 byte line size */ ··· 780 787 } 781 788 } 782 789 } 783 - /* 784 - * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for 785 - * trace cache 786 - */ 787 - if ((!ci->num_leaves || c->x86 == 15) && c->cpuid_level > 1) { 790 + 791 + /* Don't use CPUID(2) if CPUID(4) is supported. */ 792 + if (!ci->num_leaves && c->cpuid_level > 1) { 788 793 /* supports eax=2 call */ 789 794 int j, n; 790 795 unsigned int regs[4]; 791 796 unsigned char *dp = (unsigned char *)regs; 792 - int only_trace = 0; 793 - 794 - if (ci->num_leaves && c->x86 == 15) 795 - only_trace = 1; 796 797 797 798 /* Number of times to iterate */ 798 799 n = cpuid_eax(2) & 0xFF; ··· 795 808 cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]); 796 809 797 810 /* If bit 31 is set, this is an unknown format */ 798 - for (j = 0 ; j < 3 ; j++) 811 + for (j = 0 ; j < 4 ; j++) 799 812 if (regs[j] & (1 << 31)) 800 813 regs[j] = 0; 801 814 ··· 807 820 /* look up this descriptor in the table */ 808 821 while (cache_table[k].descriptor != 0) { 809 822 if (cache_table[k].descriptor == des) { 810 - if (only_trace && cache_table[k].cache_type != LVL_TRACE) 811 - break; 812 823 switch (cache_table[k].cache_type) { 813 824 case LVL_1_INST: 814 825 l1i += cache_table[k].size;
+123 -80
arch/x86/kernel/cpu/common.c
··· 667 667 if (!warn) 668 668 continue; 669 669 670 - pr_warn("CPU: CPU feature " X86_CAP_FMT " disabled, no CPUID level 0x%x\n", 671 - x86_cap_flag(df->feature), df->level); 670 + pr_warn("CPU: CPU feature %s disabled, no CPUID level 0x%x\n", 671 + x86_cap_flags[df->feature], df->level); 672 672 } 673 673 } 674 674 ··· 846 846 c->x86_cache_size = l2size; 847 847 } 848 848 849 - u16 __read_mostly tlb_lli_4k[NR_INFO]; 850 - u16 __read_mostly tlb_lli_2m[NR_INFO]; 851 - u16 __read_mostly tlb_lli_4m[NR_INFO]; 852 - u16 __read_mostly tlb_lld_4k[NR_INFO]; 853 - u16 __read_mostly tlb_lld_2m[NR_INFO]; 854 - u16 __read_mostly tlb_lld_4m[NR_INFO]; 855 - u16 __read_mostly tlb_lld_1g[NR_INFO]; 849 + u16 __read_mostly tlb_lli_4k; 850 + u16 __read_mostly tlb_lli_2m; 851 + u16 __read_mostly tlb_lli_4m; 852 + u16 __read_mostly tlb_lld_4k; 853 + u16 __read_mostly tlb_lld_2m; 854 + u16 __read_mostly tlb_lld_4m; 855 + u16 __read_mostly tlb_lld_1g; 856 856 857 857 static void cpu_detect_tlb(struct cpuinfo_x86 *c) 858 858 { ··· 860 860 this_cpu->c_detect_tlb(c); 861 861 862 862 pr_info("Last level iTLB entries: 4KB %d, 2MB %d, 4MB %d\n", 863 - tlb_lli_4k[ENTRIES], tlb_lli_2m[ENTRIES], 864 - tlb_lli_4m[ENTRIES]); 863 + tlb_lli_4k, tlb_lli_2m, tlb_lli_4m); 865 864 866 865 pr_info("Last level dTLB entries: 4KB %d, 2MB %d, 4MB %d, 1GB %d\n", 867 - tlb_lld_4k[ENTRIES], tlb_lld_2m[ENTRIES], 868 - tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]); 866 + tlb_lld_4k, tlb_lld_2m, tlb_lld_4m, tlb_lld_1g); 869 867 } 870 868 871 869 void get_cpu_vendor(struct cpuinfo_x86 *c) ··· 1162 1164 1163 1165 VULNWL_INTEL(INTEL_CORE_YONAH, NO_SSB), 1164 1166 1165 - VULNWL_INTEL(INTEL_ATOM_AIRMONT_MID, NO_SSB | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | MSBDS_ONLY), 1167 + VULNWL_INTEL(INTEL_ATOM_SILVERMONT_MID2,NO_SSB | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | MSBDS_ONLY), 1166 1168 VULNWL_INTEL(INTEL_ATOM_AIRMONT_NP, NO_SSB | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT), 1167 1169 1168 1170 VULNWL_INTEL(INTEL_ATOM_GOLDMONT, NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO), ··· 1477 1479 #endif 1478 1480 } 1479 1481 1482 + static inline bool parse_set_clear_cpuid(char *arg, bool set) 1483 + { 1484 + char *opt; 1485 + int taint = 0; 1486 + 1487 + while (arg) { 1488 + bool found __maybe_unused = false; 1489 + unsigned int bit; 1490 + 1491 + opt = strsep(&arg, ","); 1492 + 1493 + /* 1494 + * Handle naked numbers first for feature flags which don't 1495 + * have names. It doesn't make sense for a bug not to have a 1496 + * name so don't handle bug flags here. 1497 + */ 1498 + if (!kstrtouint(opt, 10, &bit)) { 1499 + if (bit < NCAPINTS * 32) { 1500 + 1501 + if (set) { 1502 + pr_warn("setcpuid: force-enabling CPU feature flag:"); 1503 + setup_force_cpu_cap(bit); 1504 + } else { 1505 + pr_warn("clearcpuid: force-disabling CPU feature flag:"); 1506 + setup_clear_cpu_cap(bit); 1507 + } 1508 + /* empty-string, i.e., ""-defined feature flags */ 1509 + if (!x86_cap_flags[bit]) 1510 + pr_cont(" %d:%d\n", bit >> 5, bit & 31); 1511 + else 1512 + pr_cont(" %s\n", x86_cap_flags[bit]); 1513 + 1514 + taint++; 1515 + } 1516 + /* 1517 + * The assumption is that there are no feature names with only 1518 + * numbers in the name thus go to the next argument. 1519 + */ 1520 + continue; 1521 + } 1522 + 1523 + for (bit = 0; bit < 32 * (NCAPINTS + NBUGINTS); bit++) { 1524 + const char *flag; 1525 + const char *kind; 1526 + 1527 + if (bit < 32 * NCAPINTS) { 1528 + flag = x86_cap_flags[bit]; 1529 + kind = "feature"; 1530 + } else { 1531 + kind = "bug"; 1532 + flag = x86_bug_flags[bit - (32 * NCAPINTS)]; 1533 + } 1534 + 1535 + if (!flag) 1536 + continue; 1537 + 1538 + if (strcmp(flag, opt)) 1539 + continue; 1540 + 1541 + if (set) { 1542 + pr_warn("setcpuid: force-enabling CPU %s flag: %s\n", 1543 + kind, flag); 1544 + setup_force_cpu_cap(bit); 1545 + } else { 1546 + pr_warn("clearcpuid: force-disabling CPU %s flag: %s\n", 1547 + kind, flag); 1548 + setup_clear_cpu_cap(bit); 1549 + } 1550 + taint++; 1551 + found = true; 1552 + break; 1553 + } 1554 + 1555 + if (!found) 1556 + pr_warn("%s: unknown CPU flag: %s", set ? "setcpuid" : "clearcpuid", opt); 1557 + } 1558 + 1559 + return taint; 1560 + } 1561 + 1562 + 1480 1563 /* 1481 1564 * We parse cpu parameters early because fpu__init_system() is executed 1482 1565 * before parse_early_param(). 1483 1566 */ 1484 1567 static void __init cpu_parse_early_param(void) 1485 1568 { 1569 + bool cpuid_taint = false; 1486 1570 char arg[128]; 1487 - char *argptr = arg, *opt; 1488 - int arglen, taint = 0; 1571 + int arglen; 1489 1572 1490 1573 #ifdef CONFIG_X86_32 1491 1574 if (cmdline_find_option_bool(boot_command_line, "no387")) ··· 1598 1519 setup_clear_cpu_cap(X86_FEATURE_FRED); 1599 1520 1600 1521 arglen = cmdline_find_option(boot_command_line, "clearcpuid", arg, sizeof(arg)); 1601 - if (arglen <= 0) 1602 - return; 1522 + if (arglen > 0) 1523 + cpuid_taint |= parse_set_clear_cpuid(arg, false); 1603 1524 1604 - pr_info("Clearing CPUID bits:"); 1525 + arglen = cmdline_find_option(boot_command_line, "setcpuid", arg, sizeof(arg)); 1526 + if (arglen > 0) 1527 + cpuid_taint |= parse_set_clear_cpuid(arg, true); 1605 1528 1606 - while (argptr) { 1607 - bool found __maybe_unused = false; 1608 - unsigned int bit; 1609 - 1610 - opt = strsep(&argptr, ","); 1611 - 1612 - /* 1613 - * Handle naked numbers first for feature flags which don't 1614 - * have names. 1615 - */ 1616 - if (!kstrtouint(opt, 10, &bit)) { 1617 - if (bit < NCAPINTS * 32) { 1618 - 1619 - /* empty-string, i.e., ""-defined feature flags */ 1620 - if (!x86_cap_flags[bit]) 1621 - pr_cont(" " X86_CAP_FMT_NUM, x86_cap_flag_num(bit)); 1622 - else 1623 - pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit)); 1624 - 1625 - setup_clear_cpu_cap(bit); 1626 - taint++; 1627 - } 1628 - /* 1629 - * The assumption is that there are no feature names with only 1630 - * numbers in the name thus go to the next argument. 1631 - */ 1632 - continue; 1633 - } 1634 - 1635 - for (bit = 0; bit < 32 * NCAPINTS; bit++) { 1636 - if (!x86_cap_flag(bit)) 1637 - continue; 1638 - 1639 - if (strcmp(x86_cap_flag(bit), opt)) 1640 - continue; 1641 - 1642 - pr_cont(" %s", opt); 1643 - setup_clear_cpu_cap(bit); 1644 - taint++; 1645 - found = true; 1646 - break; 1647 - } 1648 - 1649 - if (!found) 1650 - pr_cont(" (unknown: %s)", opt); 1651 - } 1652 - pr_cont("\n"); 1653 - 1654 - if (taint) 1529 + if (cpuid_taint) { 1530 + pr_warn("!!! setcpuid=/clearcpuid= in use, this is for TESTING ONLY, may break things horribly. Tainting kernel.\n"); 1655 1531 add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); 1532 + } 1656 1533 } 1657 1534 1658 1535 /* ··· 1997 1962 lkgs_init(); 1998 1963 } 1999 1964 2000 - void identify_secondary_cpu(struct cpuinfo_x86 *c) 1965 + void identify_secondary_cpu(unsigned int cpu) 2001 1966 { 2002 - BUG_ON(c == &boot_cpu_data); 1967 + struct cpuinfo_x86 *c = &cpu_data(cpu); 1968 + 1969 + /* Copy boot_cpu_data only on the first bringup */ 1970 + if (!c->initialized) 1971 + *c = boot_cpu_data; 1972 + c->cpu_index = cpu; 1973 + 2003 1974 identify_cpu(c); 2004 1975 #ifdef CONFIG_X86_32 2005 1976 enable_sep_cpu(); ··· 2016 1975 update_gds_msr(); 2017 1976 2018 1977 tsx_ap_init(); 1978 + c->initialized = true; 2019 1979 } 2020 1980 2021 1981 void print_cpu_info(struct cpuinfo_x86 *c) ··· 2047 2005 } 2048 2006 2049 2007 /* 2050 - * clearcpuid= was already parsed in cpu_parse_early_param(). This dummy 2051 - * function prevents it from becoming an environment variable for init. 2008 + * clearcpuid= and setcpuid= were already parsed in cpu_parse_early_param(). 2009 + * These dummy functions prevent them from becoming an environment variable for 2010 + * init. 2052 2011 */ 2012 + 2053 2013 static __init int setup_clearcpuid(char *arg) 2054 2014 { 2055 2015 return 1; 2056 2016 } 2057 2017 __setup("clearcpuid=", setup_clearcpuid); 2018 + 2019 + static __init int setup_setcpuid(char *arg) 2020 + { 2021 + return 1; 2022 + } 2023 + __setup("setcpuid=", setup_setcpuid); 2058 2024 2059 2025 DEFINE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot) = { 2060 2026 .current_task = &init_task, ··· 2073 2023 EXPORT_PER_CPU_SYMBOL(const_pcpu_hot); 2074 2024 2075 2025 #ifdef CONFIG_X86_64 2076 - DEFINE_PER_CPU_FIRST(struct fixed_percpu_data, 2077 - fixed_percpu_data) __aligned(PAGE_SIZE) __visible; 2078 - EXPORT_PER_CPU_SYMBOL_GPL(fixed_percpu_data); 2079 - 2080 2026 static void wrmsrl_cstar(unsigned long val) 2081 2027 { 2082 2028 /* ··· 2135 2089 if (!cpu_feature_enabled(X86_FEATURE_FRED)) 2136 2090 idt_syscall_init(); 2137 2091 } 2138 - 2139 - #else /* CONFIG_X86_64 */ 2092 + #endif /* CONFIG_X86_64 */ 2140 2093 2141 2094 #ifdef CONFIG_STACKPROTECTOR 2142 2095 DEFINE_PER_CPU(unsigned long, __stack_chk_guard); ··· 2143 2098 EXPORT_PER_CPU_SYMBOL(__stack_chk_guard); 2144 2099 #endif 2145 2100 #endif 2146 - 2147 - #endif /* CONFIG_X86_64 */ 2148 2101 2149 2102 /* 2150 2103 * Clear all 6 debug registers:
-8
arch/x86/kernel/cpu/cpu.h
··· 33 33 #endif 34 34 }; 35 35 36 - struct _tlb_table { 37 - unsigned char descriptor; 38 - char tlb_type; 39 - unsigned int entries; 40 - /* unsigned int ways; */ 41 - char info[128]; 42 - }; 43 - 44 36 #define cpu_dev_register(cpu_devX) \ 45 37 static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \ 46 38 __section(".x86_cpu_dev.init") = \
+2 -2
arch/x86/kernel/cpu/debugfs.c
··· 16 16 if (!c->initialized) 17 17 return 0; 18 18 19 - seq_printf(m, "initial_apicid: %x\n", c->topo.initial_apicid); 20 - seq_printf(m, "apicid: %x\n", c->topo.apicid); 19 + seq_printf(m, "initial_apicid: 0x%x\n", c->topo.initial_apicid); 20 + seq_printf(m, "apicid: 0x%x\n", c->topo.apicid); 21 21 seq_printf(m, "pkg_id: %u\n", c->topo.pkg_id); 22 22 seq_printf(m, "die_id: %u\n", c->topo.die_id); 23 23 seq_printf(m, "cu_id: %u\n", c->topo.cu_id);
+8 -8
arch/x86/kernel/cpu/hygon.c
··· 240 240 241 241 cpuid(0x80000006, &eax, &ebx, &ecx, &edx); 242 242 243 - tlb_lld_4k[ENTRIES] = (ebx >> 16) & mask; 244 - tlb_lli_4k[ENTRIES] = ebx & mask; 243 + tlb_lld_4k = (ebx >> 16) & mask; 244 + tlb_lli_4k = ebx & mask; 245 245 246 246 /* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ 247 247 if (!((eax >> 16) & mask)) 248 - tlb_lld_2m[ENTRIES] = (cpuid_eax(0x80000005) >> 16) & 0xff; 248 + tlb_lld_2m = (cpuid_eax(0x80000005) >> 16) & 0xff; 249 249 else 250 - tlb_lld_2m[ENTRIES] = (eax >> 16) & mask; 250 + tlb_lld_2m = (eax >> 16) & mask; 251 251 252 252 /* a 4M entry uses two 2M entries */ 253 - tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1; 253 + tlb_lld_4m = tlb_lld_2m >> 1; 254 254 255 255 /* Handle ITLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ 256 256 if (!(eax & mask)) { 257 257 cpuid(0x80000005, &eax, &ebx, &ecx, &edx); 258 - tlb_lli_2m[ENTRIES] = eax & 0xff; 258 + tlb_lli_2m = eax & 0xff; 259 259 } else 260 - tlb_lli_2m[ENTRIES] = eax & mask; 260 + tlb_lli_2m = eax & mask; 261 261 262 - tlb_lli_4m[ENTRIES] = tlb_lli_2m[ENTRIES] >> 1; 262 + tlb_lli_4m = tlb_lli_2m >> 1; 263 263 } 264 264 265 265 static const struct cpu_dev hygon_cpu_dev = {
+116 -153
arch/x86/kernel/cpu/intel.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/kernel.h> 3 - #include <linux/pgtable.h> 4 2 5 - #include <linux/string.h> 6 3 #include <linux/bitops.h> 7 - #include <linux/smp.h> 8 - #include <linux/sched.h> 9 - #include <linux/sched/clock.h> 10 - #include <linux/thread_info.h> 11 4 #include <linux/init.h> 12 - #include <linux/uaccess.h> 13 - 14 - #include <asm/cpufeature.h> 15 - #include <asm/msr.h> 16 - #include <asm/bugs.h> 17 - #include <asm/cpu.h> 18 - #include <asm/intel-family.h> 19 - #include <asm/microcode.h> 20 - #include <asm/hwcap2.h> 21 - #include <asm/elf.h> 22 - #include <asm/cpu_device_id.h> 23 - #include <asm/resctrl.h> 24 - #include <asm/numa.h> 25 - #include <asm/thermal.h> 5 + #include <linux/kernel.h> 6 + #include <linux/minmax.h> 7 + #include <linux/smp.h> 8 + #include <linux/string.h> 26 9 27 10 #ifdef CONFIG_X86_64 28 11 #include <linux/topology.h> 29 12 #endif 30 13 31 - #include "cpu.h" 14 + #include <asm/bugs.h> 15 + #include <asm/cpu_device_id.h> 16 + #include <asm/cpufeature.h> 17 + #include <asm/cpu.h> 18 + #include <asm/hwcap2.h> 19 + #include <asm/intel-family.h> 20 + #include <asm/microcode.h> 21 + #include <asm/msr.h> 22 + #include <asm/numa.h> 23 + #include <asm/resctrl.h> 24 + #include <asm/thermal.h> 25 + #include <asm/uaccess.h> 32 26 33 - #ifdef CONFIG_X86_LOCAL_APIC 34 - #include <asm/mpspec.h> 35 - #include <asm/apic.h> 36 - #endif 27 + #include "cpu.h" 37 28 38 29 /* 39 30 * Processors which have self-snooping capability can handle conflicting ··· 626 635 } 627 636 #endif 628 637 629 - #define TLB_INST_4K 0x01 630 - #define TLB_INST_4M 0x02 631 - #define TLB_INST_2M_4M 0x03 638 + #define TLB_INST_4K 0x01 639 + #define TLB_INST_4M 0x02 640 + #define TLB_INST_2M_4M 0x03 632 641 633 - #define TLB_INST_ALL 0x05 634 - #define TLB_INST_1G 0x06 642 + #define TLB_INST_ALL 0x05 643 + #define TLB_INST_1G 0x06 635 644 636 - #define TLB_DATA_4K 0x11 637 - #define TLB_DATA_4M 0x12 638 - #define TLB_DATA_2M_4M 0x13 639 - #define TLB_DATA_4K_4M 0x14 645 + #define TLB_DATA_4K 0x11 646 + #define TLB_DATA_4M 0x12 647 + #define TLB_DATA_2M_4M 0x13 648 + #define TLB_DATA_4K_4M 0x14 640 649 641 - #define TLB_DATA_1G 0x16 650 + #define TLB_DATA_1G 0x16 651 + #define TLB_DATA_1G_2M_4M 0x17 642 652 643 - #define TLB_DATA0_4K 0x21 644 - #define TLB_DATA0_4M 0x22 645 - #define TLB_DATA0_2M_4M 0x23 653 + #define TLB_DATA0_4K 0x21 654 + #define TLB_DATA0_4M 0x22 655 + #define TLB_DATA0_2M_4M 0x23 646 656 647 - #define STLB_4K 0x41 648 - #define STLB_4K_2M 0x42 657 + #define STLB_4K 0x41 658 + #define STLB_4K_2M 0x42 659 + 660 + /* 661 + * All of leaf 0x2's one-byte TLB descriptors implies the same number of 662 + * entries for their respective TLB types. The 0x63 descriptor is an 663 + * exception: it implies 4 dTLB entries for 1GB pages 32 dTLB entries 664 + * for 2MB or 4MB pages. Encode descriptor 0x63 dTLB entry count for 665 + * 2MB/4MB pages here, as its count for dTLB 1GB pages is already at the 666 + * intel_tlb_table[] mapping. 667 + */ 668 + #define TLB_0x63_2M_4M_ENTRIES 32 669 + 670 + struct _tlb_table { 671 + unsigned char descriptor; 672 + char tlb_type; 673 + unsigned int entries; 674 + }; 649 675 650 676 static const struct _tlb_table intel_tlb_table[] = { 651 - { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" }, 652 - { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" }, 653 - { 0x03, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way set associative" }, 654 - { 0x04, TLB_DATA_4M, 8, " TLB_DATA 4 MByte pages, 4-way set associative" }, 655 - { 0x05, TLB_DATA_4M, 32, " TLB_DATA 4 MByte pages, 4-way set associative" }, 656 - { 0x0b, TLB_INST_4M, 4, " TLB_INST 4 MByte pages, 4-way set associative" }, 657 - { 0x4f, TLB_INST_4K, 32, " TLB_INST 4 KByte pages" }, 658 - { 0x50, TLB_INST_ALL, 64, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, 659 - { 0x51, TLB_INST_ALL, 128, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, 660 - { 0x52, TLB_INST_ALL, 256, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, 661 - { 0x55, TLB_INST_2M_4M, 7, " TLB_INST 2-MByte or 4-MByte pages, fully associative" }, 662 - { 0x56, TLB_DATA0_4M, 16, " TLB_DATA0 4 MByte pages, 4-way set associative" }, 663 - { 0x57, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, 4-way associative" }, 664 - { 0x59, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, fully associative" }, 665 - { 0x5a, TLB_DATA0_2M_4M, 32, " TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative" }, 666 - { 0x5b, TLB_DATA_4K_4M, 64, " TLB_DATA 4 KByte and 4 MByte pages" }, 667 - { 0x5c, TLB_DATA_4K_4M, 128, " TLB_DATA 4 KByte and 4 MByte pages" }, 668 - { 0x5d, TLB_DATA_4K_4M, 256, " TLB_DATA 4 KByte and 4 MByte pages" }, 669 - { 0x61, TLB_INST_4K, 48, " TLB_INST 4 KByte pages, full associative" }, 670 - { 0x63, TLB_DATA_1G, 4, " TLB_DATA 1 GByte pages, 4-way set associative" }, 671 - { 0x6b, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 8-way associative" }, 672 - { 0x6c, TLB_DATA_2M_4M, 128, " TLB_DATA 2 MByte or 4 MByte pages, 8-way associative" }, 673 - { 0x6d, TLB_DATA_1G, 16, " TLB_DATA 1 GByte pages, fully associative" }, 674 - { 0x76, TLB_INST_2M_4M, 8, " TLB_INST 2-MByte or 4-MByte pages, fully associative" }, 675 - { 0xb0, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 4-way set associative" }, 676 - { 0xb1, TLB_INST_2M_4M, 4, " TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries" }, 677 - { 0xb2, TLB_INST_4K, 64, " TLB_INST 4KByte pages, 4-way set associative" }, 678 - { 0xb3, TLB_DATA_4K, 128, " TLB_DATA 4 KByte pages, 4-way set associative" }, 679 - { 0xb4, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 4-way associative" }, 680 - { 0xb5, TLB_INST_4K, 64, " TLB_INST 4 KByte pages, 8-way set associative" }, 681 - { 0xb6, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 8-way set associative" }, 682 - { 0xba, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way associative" }, 683 - { 0xc0, TLB_DATA_4K_4M, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" }, 684 - { 0xc1, STLB_4K_2M, 1024, " STLB 4 KByte and 2 MByte pages, 8-way associative" }, 685 - { 0xc2, TLB_DATA_2M_4M, 16, " TLB_DATA 2 MByte/4MByte pages, 4-way associative" }, 686 - { 0xca, STLB_4K, 512, " STLB 4 KByte pages, 4-way associative" }, 677 + { 0x01, TLB_INST_4K, 32}, /* TLB_INST 4 KByte pages, 4-way set associative */ 678 + { 0x02, TLB_INST_4M, 2}, /* TLB_INST 4 MByte pages, full associative */ 679 + { 0x03, TLB_DATA_4K, 64}, /* TLB_DATA 4 KByte pages, 4-way set associative */ 680 + { 0x04, TLB_DATA_4M, 8}, /* TLB_DATA 4 MByte pages, 4-way set associative */ 681 + { 0x05, TLB_DATA_4M, 32}, /* TLB_DATA 4 MByte pages, 4-way set associative */ 682 + { 0x0b, TLB_INST_4M, 4}, /* TLB_INST 4 MByte pages, 4-way set associative */ 683 + { 0x4f, TLB_INST_4K, 32}, /* TLB_INST 4 KByte pages */ 684 + { 0x50, TLB_INST_ALL, 64}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 685 + { 0x51, TLB_INST_ALL, 128}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 686 + { 0x52, TLB_INST_ALL, 256}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 687 + { 0x55, TLB_INST_2M_4M, 7}, /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 688 + { 0x56, TLB_DATA0_4M, 16}, /* TLB_DATA0 4 MByte pages, 4-way set associative */ 689 + { 0x57, TLB_DATA0_4K, 16}, /* TLB_DATA0 4 KByte pages, 4-way associative */ 690 + { 0x59, TLB_DATA0_4K, 16}, /* TLB_DATA0 4 KByte pages, fully associative */ 691 + { 0x5a, TLB_DATA0_2M_4M, 32}, /* TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative */ 692 + { 0x5b, TLB_DATA_4K_4M, 64}, /* TLB_DATA 4 KByte and 4 MByte pages */ 693 + { 0x5c, TLB_DATA_4K_4M, 128}, /* TLB_DATA 4 KByte and 4 MByte pages */ 694 + { 0x5d, TLB_DATA_4K_4M, 256}, /* TLB_DATA 4 KByte and 4 MByte pages */ 695 + { 0x61, TLB_INST_4K, 48}, /* TLB_INST 4 KByte pages, full associative */ 696 + { 0x63, TLB_DATA_1G_2M_4M, 4}, /* TLB_DATA 1 GByte pages, 4-way set associative 697 + * (plus 32 entries TLB_DATA 2 MByte or 4 MByte pages, not encoded here) */ 698 + { 0x6b, TLB_DATA_4K, 256}, /* TLB_DATA 4 KByte pages, 8-way associative */ 699 + { 0x6c, TLB_DATA_2M_4M, 128}, /* TLB_DATA 2 MByte or 4 MByte pages, 8-way associative */ 700 + { 0x6d, TLB_DATA_1G, 16}, /* TLB_DATA 1 GByte pages, fully associative */ 701 + { 0x76, TLB_INST_2M_4M, 8}, /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 702 + { 0xb0, TLB_INST_4K, 128}, /* TLB_INST 4 KByte pages, 4-way set associative */ 703 + { 0xb1, TLB_INST_2M_4M, 4}, /* TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries */ 704 + { 0xb2, TLB_INST_4K, 64}, /* TLB_INST 4KByte pages, 4-way set associative */ 705 + { 0xb3, TLB_DATA_4K, 128}, /* TLB_DATA 4 KByte pages, 4-way set associative */ 706 + { 0xb4, TLB_DATA_4K, 256}, /* TLB_DATA 4 KByte pages, 4-way associative */ 707 + { 0xb5, TLB_INST_4K, 64}, /* TLB_INST 4 KByte pages, 8-way set associative */ 708 + { 0xb6, TLB_INST_4K, 128}, /* TLB_INST 4 KByte pages, 8-way set associative */ 709 + { 0xba, TLB_DATA_4K, 64}, /* TLB_DATA 4 KByte pages, 4-way associative */ 710 + { 0xc0, TLB_DATA_4K_4M, 8}, /* TLB_DATA 4 KByte and 4 MByte pages, 4-way associative */ 711 + { 0xc1, STLB_4K_2M, 1024}, /* STLB 4 KByte and 2 MByte pages, 8-way associative */ 712 + { 0xc2, TLB_DATA_2M_4M, 16}, /* TLB_DATA 2 MByte/4MByte pages, 4-way associative */ 713 + { 0xca, STLB_4K, 512}, /* STLB 4 KByte pages, 4-way associative */ 687 714 { 0x00, 0, 0 } 688 715 }; 689 716 690 717 static void intel_tlb_lookup(const unsigned char desc) 691 718 { 719 + unsigned int entries; 692 720 unsigned char k; 721 + 693 722 if (desc == 0) 694 723 return; 695 724 ··· 721 710 if (intel_tlb_table[k].tlb_type == 0) 722 711 return; 723 712 713 + entries = intel_tlb_table[k].entries; 724 714 switch (intel_tlb_table[k].tlb_type) { 725 715 case STLB_4K: 726 - if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) 727 - tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; 728 - if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) 729 - tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; 716 + tlb_lli_4k = max(tlb_lli_4k, entries); 717 + tlb_lld_4k = max(tlb_lld_4k, entries); 730 718 break; 731 719 case STLB_4K_2M: 732 - if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) 733 - tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; 734 - if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) 735 - tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; 736 - if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) 737 - tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; 738 - if (tlb_lld_2m[ENTRIES] < intel_tlb_table[k].entries) 739 - tlb_lld_2m[ENTRIES] = intel_tlb_table[k].entries; 740 - if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) 741 - tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; 742 - if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) 743 - tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; 720 + tlb_lli_4k = max(tlb_lli_4k, entries); 721 + tlb_lld_4k = max(tlb_lld_4k, entries); 722 + tlb_lli_2m = max(tlb_lli_2m, entries); 723 + tlb_lld_2m = max(tlb_lld_2m, entries); 724 + tlb_lli_4m = max(tlb_lli_4m, entries); 725 + tlb_lld_4m = max(tlb_lld_4m, entries); 744 726 break; 745 727 case TLB_INST_ALL: 746 - if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) 747 - tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; 748 - if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) 749 - tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; 750 - if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) 751 - tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; 728 + tlb_lli_4k = max(tlb_lli_4k, entries); 729 + tlb_lli_2m = max(tlb_lli_2m, entries); 730 + tlb_lli_4m = max(tlb_lli_4m, entries); 752 731 break; 753 732 case TLB_INST_4K: 754 - if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) 755 - tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; 733 + tlb_lli_4k = max(tlb_lli_4k, entries); 756 734 break; 757 735 case TLB_INST_4M: 758 - if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) 759 - tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; 736 + tlb_lli_4m = max(tlb_lli_4m, entries); 760 737 break; 761 738 case TLB_INST_2M_4M: 762 - if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) 763 - tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; 764 - if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) 765 - tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; 739 + tlb_lli_2m = max(tlb_lli_2m, entries); 740 + tlb_lli_4m = max(tlb_lli_4m, entries); 766 741 break; 767 742 case TLB_DATA_4K: 768 743 case TLB_DATA0_4K: 769 - if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) 770 - tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; 744 + tlb_lld_4k = max(tlb_lld_4k, entries); 771 745 break; 772 746 case TLB_DATA_4M: 773 747 case TLB_DATA0_4M: 774 - if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) 775 - tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; 748 + tlb_lld_4m = max(tlb_lld_4m, entries); 776 749 break; 777 750 case TLB_DATA_2M_4M: 778 751 case TLB_DATA0_2M_4M: 779 - if (tlb_lld_2m[ENTRIES] < intel_tlb_table[k].entries) 780 - tlb_lld_2m[ENTRIES] = intel_tlb_table[k].entries; 781 - if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) 782 - tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; 752 + tlb_lld_2m = max(tlb_lld_2m, entries); 753 + tlb_lld_4m = max(tlb_lld_4m, entries); 783 754 break; 784 755 case TLB_DATA_4K_4M: 785 - if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) 786 - tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; 787 - if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) 788 - tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; 756 + tlb_lld_4k = max(tlb_lld_4k, entries); 757 + tlb_lld_4m = max(tlb_lld_4m, entries); 789 758 break; 759 + case TLB_DATA_1G_2M_4M: 760 + tlb_lld_2m = max(tlb_lld_2m, TLB_0x63_2M_4M_ENTRIES); 761 + tlb_lld_4m = max(tlb_lld_4m, TLB_0x63_2M_4M_ENTRIES); 762 + fallthrough; 790 763 case TLB_DATA_1G: 791 - if (tlb_lld_1g[ENTRIES] < intel_tlb_table[k].entries) 792 - tlb_lld_1g[ENTRIES] = intel_tlb_table[k].entries; 764 + tlb_lld_1g = max(tlb_lld_1g, entries); 793 765 break; 794 766 } 795 767 } ··· 793 799 cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]); 794 800 795 801 /* If bit 31 is set, this is an unknown format */ 796 - for (j = 0 ; j < 3 ; j++) 802 + for (j = 0 ; j < 4 ; j++) 797 803 if (regs[j] & (1 << 31)) 798 804 regs[j] = 0; 799 805 ··· 867 873 }; 868 874 869 875 cpu_dev_register(intel_cpu_dev); 870 - 871 - #define X86_HYBRID_CPU_TYPE_ID_SHIFT 24 872 - 873 - /** 874 - * get_this_hybrid_cpu_type() - Get the type of this hybrid CPU 875 - * 876 - * Returns the CPU type [31:24] (i.e., Atom or Core) of a CPU in 877 - * a hybrid processor. If the processor is not hybrid, returns 0. 878 - */ 879 - u8 get_this_hybrid_cpu_type(void) 880 - { 881 - if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) 882 - return 0; 883 - 884 - return cpuid_eax(0x0000001a) >> X86_HYBRID_CPU_TYPE_ID_SHIFT; 885 - } 886 - 887 - /** 888 - * get_this_hybrid_cpu_native_id() - Get the native id of this hybrid CPU 889 - * 890 - * Returns the uarch native ID [23:0] of a CPU in a hybrid processor. 891 - * If the processor is not hybrid, returns 0. 892 - */ 893 - u32 get_this_hybrid_cpu_native_id(void) 894 - { 895 - if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) 896 - return 0; 897 - 898 - return cpuid_eax(0x0000001a) & 899 - (BIT_ULL(X86_HYBRID_CPU_TYPE_ID_SHIFT) - 1); 900 - }
+2 -4
arch/x86/kernel/cpu/mtrr/if.c
··· 99 99 char *ptr; 100 100 char line[LINE_SIZE]; 101 101 int length; 102 - size_t linelen; 103 102 104 103 memset(line, 0, LINE_SIZE); 105 104 ··· 107 108 if (length < 0) 108 109 return length; 109 110 110 - linelen = strlen(line); 111 - ptr = line + linelen - 1; 112 - if (linelen && *ptr == '\n') 111 + ptr = line + length - 1; 112 + if (length && *ptr == '\n') 113 113 *ptr = '\0'; 114 114 115 115 if (!strncmp(line, "disable=", 8)) {
+1 -1
arch/x86/kernel/head64.c
··· 567 567 */ 568 568 void __head startup_64_setup_gdt_idt(void) 569 569 { 570 - struct desc_struct *gdt = (void *)(__force unsigned long)init_per_cpu_var(gdt_page.gdt); 570 + struct desc_struct *gdt = (void *)(__force unsigned long)gdt_page.gdt; 571 571 void *handler = NULL; 572 572 573 573 struct desc_ptr startup_gdt_descr = {
+9 -11
arch/x86/kernel/head_64.S
··· 61 61 /* Set up the stack for verify_cpu() */ 62 62 leaq __top_init_kernel_stack(%rip), %rsp 63 63 64 - /* Setup GSBASE to allow stack canary access for C code */ 64 + /* 65 + * Set up GSBASE. 66 + * Note that on SMP the boot CPU uses the init data section until 67 + * the per-CPU areas are set up. 68 + */ 65 69 movl $MSR_GS_BASE, %ecx 66 - leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx 67 - movl %edx, %eax 68 - shrq $32, %rdx 70 + xorl %eax, %eax 71 + xorl %edx, %edx 69 72 wrmsr 70 73 71 74 call startup_64_setup_gdt_idt ··· 362 359 movl %eax,%fs 363 360 movl %eax,%gs 364 361 365 - /* Set up %gs. 366 - * 367 - * The base of %gs always points to fixed_percpu_data. If the 368 - * stack protector canary is enabled, it is located at %gs:40. 362 + /* 363 + * Set up GSBASE. 369 364 * Note that, on SMP, the boot cpu uses init data section until 370 365 * the per cpu areas are set up. 371 366 */ 372 367 movl $MSR_GS_BASE,%ecx 373 - #ifndef CONFIG_SMP 374 - leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx 375 - #endif 376 368 movl %edx, %eax 377 369 shrq $32, %rdx 378 370 wrmsr
+1 -1
arch/x86/kernel/ioport.c
··· 144 144 * Update the sequence number to force a TSS update on return to 145 145 * user mode. 146 146 */ 147 - iobm->sequence = atomic64_add_return(1, &io_bitmap_sequence); 147 + iobm->sequence = atomic64_inc_return(&io_bitmap_sequence); 148 148 149 149 return 0; 150 150 }
+17 -22
arch/x86/kernel/irq_32.c
··· 29 29 int sysctl_panic_on_stackoverflow __read_mostly; 30 30 31 31 /* Debugging check for stack overflow: is there less than 1KB free? */ 32 - static int check_stack_overflow(void) 32 + static bool check_stack_overflow(void) 33 33 { 34 - long sp; 35 - 36 - __asm__ __volatile__("andl %%esp,%0" : 37 - "=r" (sp) : "0" (THREAD_SIZE - 1)); 34 + unsigned long sp = current_stack_pointer & (THREAD_SIZE - 1); 38 35 39 36 return sp < (sizeof(struct thread_info) + STACK_WARN); 40 37 } ··· 45 48 } 46 49 47 50 #else 48 - static inline int check_stack_overflow(void) { return 0; } 51 + static inline bool check_stack_overflow(void) { return false; } 49 52 static inline void print_stack_overflow(void) { } 50 53 #endif 51 54 52 55 static void call_on_stack(void *func, void *stack) 53 56 { 54 - asm volatile("xchgl %%ebx,%%esp \n" 57 + asm volatile("xchgl %[sp], %%esp\n" 55 58 CALL_NOSPEC 56 - "movl %%ebx,%%esp \n" 57 - : "=b" (stack) 58 - : "0" (stack), 59 - [thunk_target] "D"(func) 59 + "movl %[sp], %%esp" 60 + : [sp] "+b" (stack) 61 + : [thunk_target] "D" (func) 60 62 : "memory", "cc", "edx", "ecx", "eax"); 61 63 } 62 64 ··· 64 68 return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1)); 65 69 } 66 70 67 - static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) 71 + static inline bool execute_on_irq_stack(bool overflow, struct irq_desc *desc) 68 72 { 69 73 struct irq_stack *curstk, *irqstk; 70 - u32 *isp, *prev_esp, arg1; 74 + u32 *isp, *prev_esp; 71 75 72 76 curstk = (struct irq_stack *) current_stack(); 73 77 irqstk = __this_cpu_read(pcpu_hot.hardirq_stack_ptr); ··· 79 83 * current stack (which is the irq stack already after all) 80 84 */ 81 85 if (unlikely(curstk == irqstk)) 82 - return 0; 86 + return false; 83 87 84 88 isp = (u32 *) ((char *)irqstk + sizeof(*irqstk)); 85 89 ··· 90 94 if (unlikely(overflow)) 91 95 call_on_stack(print_stack_overflow, isp); 92 96 93 - asm volatile("xchgl %%ebx,%%esp \n" 97 + asm volatile("xchgl %[sp], %%esp\n" 94 98 CALL_NOSPEC 95 - "movl %%ebx,%%esp \n" 96 - : "=a" (arg1), "=b" (isp) 97 - : "0" (desc), "1" (isp), 98 - [thunk_target] "D" (desc->handle_irq) 99 - : "memory", "cc", "ecx"); 100 - return 1; 99 + "movl %[sp], %%esp" 100 + : "+a" (desc), [sp] "+b" (isp) 101 + : [thunk_target] "D" (desc->handle_irq) 102 + : "memory", "cc", "edx", "ecx"); 103 + return true; 101 104 } 102 105 103 106 /* ··· 145 150 146 151 void __handle_irq(struct irq_desc *desc, struct pt_regs *regs) 147 152 { 148 - int overflow = check_stack_overflow(); 153 + bool overflow = check_stack_overflow(); 149 154 150 155 if (user_mode(regs) || !execute_on_irq_stack(overflow, desc)) { 151 156 if (unlikely(overflow))
-1
arch/x86/kernel/irq_64.c
··· 27 27 #include <asm/apic.h> 28 28 29 29 DEFINE_PER_CPU_PAGE_ALIGNED(struct irq_stack, irq_stack_backing_store) __visible; 30 - DECLARE_INIT_PER_CPU(irq_stack_backing_store); 31 30 32 31 #ifdef CONFIG_VMAP_STACK 33 32 /*
-1
arch/x86/kernel/kvm.c
··· 838 838 #ifdef CONFIG_SMP 839 839 if (pv_tlb_flush_supported()) { 840 840 pv_ops.mmu.flush_tlb_multi = kvm_flush_tlb_multi; 841 - pv_ops.mmu.tlb_remove_table = tlb_remove_table; 842 841 pr_info("KVM setup pv remote TLB flush\n"); 843 842 } 844 843
+15
arch/x86/kernel/module.c
··· 19 19 #include <linux/jump_label.h> 20 20 #include <linux/random.h> 21 21 #include <linux/memory.h> 22 + #include <linux/stackprotector.h> 22 23 23 24 #include <asm/text-patching.h> 24 25 #include <asm/page.h> ··· 131 130 goto overflow; 132 131 size = 4; 133 132 break; 133 + #if defined(CONFIG_STACKPROTECTOR) && \ 134 + defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 170000 135 + case R_X86_64_REX_GOTPCRELX: { 136 + static unsigned long __percpu *const addr = &__stack_chk_guard; 137 + 138 + if (sym->st_value != (u64)addr) { 139 + pr_err("%s: Unsupported GOTPCREL relocation\n", me->name); 140 + return -ENOEXEC; 141 + } 142 + 143 + val = (u64)&addr + rel[i].r_addend; 144 + fallthrough; 145 + } 146 + #endif 134 147 case R_X86_64_PC32: 135 148 case R_X86_64_PLT32: 136 149 val -= (u64)loc;
-16
arch/x86/kernel/paravirt.c
··· 59 59 static_branch_enable(&virt_spin_lock_key); 60 60 } 61 61 62 - #ifndef CONFIG_PT_RECLAIM 63 - static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) 64 - { 65 - struct ptdesc *ptdesc = (struct ptdesc *)table; 66 - 67 - pagetable_dtor(ptdesc); 68 - tlb_remove_page(tlb, ptdesc_page(ptdesc)); 69 - } 70 - #else 71 - static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) 72 - { 73 - tlb_remove_table(tlb, table); 74 - } 75 - #endif 76 - 77 62 struct static_key paravirt_steal_enabled; 78 63 struct static_key paravirt_steal_rq_enabled; 79 64 ··· 170 185 .mmu.flush_tlb_kernel = native_flush_tlb_global, 171 186 .mmu.flush_tlb_one_user = native_flush_tlb_one_user, 172 187 .mmu.flush_tlb_multi = native_flush_tlb_multi, 173 - .mmu.tlb_remove_table = native_tlb_remove_table, 174 188 175 189 .mmu.exit_mmap = paravirt_nop, 176 190 .mmu.notify_page_enc_status_changed = paravirt_nop,
+2 -10
arch/x86/kernel/setup_percpu.c
··· 23 23 #include <asm/cpumask.h> 24 24 #include <asm/cpu.h> 25 25 26 - #ifdef CONFIG_X86_64 27 - #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load) 28 - #else 29 - #define BOOT_PERCPU_OFFSET 0 30 - #endif 31 - 32 - DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET; 26 + DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off); 33 27 EXPORT_PER_CPU_SYMBOL(this_cpu_off); 34 28 35 - unsigned long __per_cpu_offset[NR_CPUS] __ro_after_init = { 36 - [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET, 37 - }; 29 + unsigned long __per_cpu_offset[NR_CPUS] __ro_after_init; 38 30 EXPORT_SYMBOL(__per_cpu_offset); 39 31 40 32 /*
+43 -19
arch/x86/kernel/signal_32.c
··· 33 33 #include <asm/smap.h> 34 34 #include <asm/gsseg.h> 35 35 36 + /* 37 + * The first GDT descriptor is reserved as 'NULL descriptor'. As bits 0 38 + * and 1 of a segment selector, i.e., the RPL bits, are NOT used to index 39 + * GDT, selector values 0~3 all point to the NULL descriptor, thus values 40 + * 0, 1, 2 and 3 are all valid NULL selector values. 41 + * 42 + * However IRET zeros ES, FS, GS, and DS segment registers if any of them 43 + * is found to have any nonzero NULL selector value, which can be used by 44 + * userspace in pre-FRED systems to spot any interrupt/exception by loading 45 + * a nonzero NULL selector and waiting for it to become zero. Before FRED 46 + * there was nothing software could do to prevent such an information leak. 47 + * 48 + * ERETU, the only legit instruction to return to userspace from kernel 49 + * under FRED, by design does NOT zero any segment register to avoid this 50 + * problem behavior. 51 + * 52 + * As such, leave NULL selector values 0~3 unchanged. 53 + */ 54 + static inline u16 fixup_rpl(u16 sel) 55 + { 56 + return sel <= 3 ? sel : sel | 3; 57 + } 58 + 36 59 #ifdef CONFIG_IA32_EMULATION 37 60 #include <asm/unistd_32_ia32.h> 38 61 39 62 static inline void reload_segments(struct sigcontext_32 *sc) 40 63 { 41 - unsigned int cur; 64 + u16 cur; 42 65 66 + /* 67 + * Reload fs and gs if they have changed in the signal 68 + * handler. This does not handle long fs/gs base changes in 69 + * the handler, but does not clobber them at least in the 70 + * normal case. 71 + */ 43 72 savesegment(gs, cur); 44 - if ((sc->gs | 0x03) != cur) 45 - load_gs_index(sc->gs | 0x03); 73 + if (fixup_rpl(sc->gs) != cur) 74 + load_gs_index(fixup_rpl(sc->gs)); 46 75 savesegment(fs, cur); 47 - if ((sc->fs | 0x03) != cur) 48 - loadsegment(fs, sc->fs | 0x03); 76 + if (fixup_rpl(sc->fs) != cur) 77 + loadsegment(fs, fixup_rpl(sc->fs)); 78 + 49 79 savesegment(ds, cur); 50 - if ((sc->ds | 0x03) != cur) 51 - loadsegment(ds, sc->ds | 0x03); 80 + if (fixup_rpl(sc->ds) != cur) 81 + loadsegment(ds, fixup_rpl(sc->ds)); 52 82 savesegment(es, cur); 53 - if ((sc->es | 0x03) != cur) 54 - loadsegment(es, sc->es | 0x03); 83 + if (fixup_rpl(sc->es) != cur) 84 + loadsegment(es, fixup_rpl(sc->es)); 55 85 } 56 86 57 87 #define sigset32_t compat_sigset_t ··· 135 105 regs->orig_ax = -1; 136 106 137 107 #ifdef CONFIG_IA32_EMULATION 138 - /* 139 - * Reload fs and gs if they have changed in the signal 140 - * handler. This does not handle long fs/gs base changes in 141 - * the handler, but does not clobber them at least in the 142 - * normal case. 143 - */ 144 108 reload_segments(&sc); 145 109 #else 146 - loadsegment(gs, sc.gs); 147 - regs->fs = sc.fs; 148 - regs->es = sc.es; 149 - regs->ds = sc.ds; 110 + loadsegment(gs, fixup_rpl(sc.gs)); 111 + regs->fs = fixup_rpl(sc.fs); 112 + regs->es = fixup_rpl(sc.es); 113 + regs->ds = fixup_rpl(sc.ds); 150 114 #endif 151 115 152 116 return fpu__restore_sig(compat_ptr(sc.fpstate), 1);
+7 -61
arch/x86/kernel/smpboot.c
··· 190 190 apic_ap_setup(); 191 191 192 192 /* Save the processor parameters. */ 193 - smp_store_cpu_info(cpuid); 193 + identify_secondary_cpu(cpuid); 194 194 195 195 /* 196 196 * The topology information must be up to date before ··· 215 215 { 216 216 /* 217 217 * Calibrate the delay loop and update loops_per_jiffy in cpu_data. 218 - * smp_store_cpu_info() stored a value that is close but not as 218 + * identify_secondary_cpu() stored a value that is close but not as 219 219 * accurate as the value just calculated. 220 220 * 221 221 * As this is invoked after the TSC synchronization check, ··· 315 315 cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); 316 316 } 317 317 ANNOTATE_NOENDBR_SYM(start_secondary); 318 - 319 - /* 320 - * The bootstrap kernel entry code has set these up. Save them for 321 - * a given CPU 322 - */ 323 - void smp_store_cpu_info(int id) 324 - { 325 - struct cpuinfo_x86 *c = &cpu_data(id); 326 - 327 - /* Copy boot_cpu_data only on the first bringup */ 328 - if (!c->initialized) 329 - *c = boot_cpu_data; 330 - c->cpu_index = id; 331 - /* 332 - * During boot time, CPU0 has this setup already. Save the info when 333 - * bringing up an AP. 334 - */ 335 - identify_secondary_cpu(c); 336 - c->initialized = true; 337 - } 338 318 339 319 static bool 340 320 topology_same_node(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) ··· 1243 1263 * We need to flush the caches before going to sleep, lest we have 1244 1264 * dirty data in our caches when we come back up. 1245 1265 */ 1246 - static inline void mwait_play_dead(void) 1266 + void __noreturn mwait_play_dead(unsigned int eax_hint) 1247 1267 { 1248 1268 struct mwait_cpu_dead *md = this_cpu_ptr(&mwait_cpu_dead); 1249 - unsigned int eax, ebx, ecx, edx; 1250 - unsigned int highest_cstate = 0; 1251 - unsigned int highest_subcstate = 0; 1252 - int i; 1253 - 1254 - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || 1255 - boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) 1256 - return; 1257 - if (!this_cpu_has(X86_FEATURE_MWAIT)) 1258 - return; 1259 - if (!this_cpu_has(X86_FEATURE_CLFLUSH)) 1260 - return; 1261 - 1262 - eax = CPUID_LEAF_MWAIT; 1263 - ecx = 0; 1264 - native_cpuid(&eax, &ebx, &ecx, &edx); 1265 - 1266 - /* 1267 - * eax will be 0 if EDX enumeration is not valid. 1268 - * Initialized below to cstate, sub_cstate value when EDX is valid. 1269 - */ 1270 - if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED)) { 1271 - eax = 0; 1272 - } else { 1273 - edx >>= MWAIT_SUBSTATE_SIZE; 1274 - for (i = 0; i < 7 && edx; i++, edx >>= MWAIT_SUBSTATE_SIZE) { 1275 - if (edx & MWAIT_SUBSTATE_MASK) { 1276 - highest_cstate = i; 1277 - highest_subcstate = edx & MWAIT_SUBSTATE_MASK; 1278 - } 1279 - } 1280 - eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) | 1281 - (highest_subcstate - 1); 1282 - } 1283 1269 1284 1270 /* Set up state for the kexec() hack below */ 1285 1271 md->status = CPUDEAD_MWAIT_WAIT; ··· 1266 1320 mb(); 1267 1321 __monitor(md, 0, 0); 1268 1322 mb(); 1269 - __mwait(eax, 0); 1323 + __mwait(eax_hint, 0); 1270 1324 1271 1325 if (READ_ONCE(md->control) == CPUDEAD_MWAIT_KEXEC_HLT) { 1272 1326 /* ··· 1338 1392 play_dead_common(); 1339 1393 tboot_shutdown(TB_SHUTDOWN_WFS); 1340 1394 1341 - mwait_play_dead(); 1342 - if (cpuidle_play_dead()) 1343 - hlt_play_dead(); 1395 + /* Below returns only on error. */ 1396 + cpuidle_play_dead(); 1397 + hlt_play_dead(); 1344 1398 } 1345 1399 1346 1400 #else /* ... !CONFIG_HOTPLUG_CPU */
+1 -1
arch/x86/kernel/tsc_msr.c
··· 152 152 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT, &freq_desc_byt), 153 153 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID, &freq_desc_tng), 154 154 X86_MATCH_VFM(INTEL_ATOM_AIRMONT, &freq_desc_cht), 155 - X86_MATCH_VFM(INTEL_ATOM_AIRMONT_MID, &freq_desc_ann), 155 + X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID2, &freq_desc_ann), 156 156 X86_MATCH_VFM(INTEL_ATOM_AIRMONT_NP, &freq_desc_lgm), 157 157 {} 158 158 };
-35
arch/x86/kernel/vmlinux.lds.S
··· 112 112 PHDRS { 113 113 text PT_LOAD FLAGS(5); /* R_E */ 114 114 data PT_LOAD FLAGS(6); /* RW_ */ 115 - #ifdef CONFIG_X86_64 116 - #ifdef CONFIG_SMP 117 - percpu PT_LOAD FLAGS(6); /* RW_ */ 118 - #endif 119 - init PT_LOAD FLAGS(7); /* RWE */ 120 - #endif 121 115 note PT_NOTE FLAGS(0); /* ___ */ 122 116 } 123 117 ··· 210 216 __init_begin = .; /* paired with __init_end */ 211 217 } 212 218 213 - #if defined(CONFIG_X86_64) && defined(CONFIG_SMP) 214 - /* 215 - * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the 216 - * output PHDR, so the next output section - .init.text - should 217 - * start another segment - init. 218 - */ 219 - PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu) 220 - ASSERT(SIZEOF(.data..percpu) < CONFIG_PHYSICAL_START, 221 - "per-CPU data too large - increase CONFIG_PHYSICAL_START") 222 - #endif 223 - 224 219 INIT_TEXT_SECTION(PAGE_SIZE) 225 - #ifdef CONFIG_X86_64 226 - :init 227 - #endif 228 220 229 221 /* 230 222 * Section for code used exclusively before alternatives are run. All ··· 327 347 EXIT_DATA 328 348 } 329 349 330 - #if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP) 331 350 PERCPU_SECTION(INTERNODE_CACHE_BYTES) 332 - #endif 333 351 334 352 RUNTIME_CONST_VARIABLES 335 353 RUNTIME_CONST(ptr, USER_PTR_MAX) ··· 471 493 PROVIDE(__ref_stack_chk_guard = __stack_chk_guard); 472 494 473 495 #ifdef CONFIG_X86_64 474 - /* 475 - * Per-cpu symbols which need to be offset from __per_cpu_load 476 - * for the boot processor. 477 - */ 478 - #define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load 479 - INIT_PER_CPU(gdt_page); 480 - INIT_PER_CPU(fixed_percpu_data); 481 - INIT_PER_CPU(irq_stack_backing_store); 482 - 483 - #ifdef CONFIG_SMP 484 - . = ASSERT((fixed_percpu_data == 0), 485 - "fixed_percpu_data is not at start of per-cpu area"); 486 - #endif 487 496 488 497 #ifdef CONFIG_MITIGATION_UNRET_ENTRY 489 498 . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned");
+10 -8
arch/x86/kvm/vmx/vmx_ops.h
··· 118 118 119 119 #else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ 120 120 121 - asm volatile("1: vmread %2, %1\n\t" 121 + asm volatile("1: vmread %[field], %[output]\n\t" 122 122 ".byte 0x3e\n\t" /* branch taken hint */ 123 123 "ja 3f\n\t" 124 124 ··· 127 127 * @field, and bounce through the trampoline to preserve 128 128 * volatile registers. 129 129 */ 130 - "xorl %k1, %k1\n\t" 130 + "xorl %k[output], %k[output]\n\t" 131 131 "2:\n\t" 132 - "push %1\n\t" 133 - "push %2\n\t" 132 + "push %[output]\n\t" 133 + "push %[field]\n\t" 134 134 "call vmread_error_trampoline\n\t" 135 135 136 136 /* 137 137 * Unwind the stack. Note, the trampoline zeros out the 138 138 * memory for @fault so that the result is '0' on error. 139 139 */ 140 - "pop %2\n\t" 141 - "pop %1\n\t" 140 + "pop %[field]\n\t" 141 + "pop %[output]\n\t" 142 142 "3:\n\t" 143 143 144 144 /* VMREAD faulted. As above, except push '1' for @fault. */ 145 - _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %1) 145 + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %[output]) 146 146 147 - : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc"); 147 + : ASM_CALL_CONSTRAINT, [output] "=&r" (value) 148 + : [field] "r" (field) 149 + : "cc"); 148 150 return value; 149 151 150 152 #endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */
+1 -1
arch/x86/lib/Makefile
··· 56 56 lib-y += string_32.o 57 57 lib-y += memmove_32.o 58 58 lib-y += cmpxchg8b_emu.o 59 - ifneq ($(CONFIG_X86_CMPXCHG64),y) 59 + ifneq ($(CONFIG_X86_CX8),y) 60 60 lib-y += atomic64_386_32.o 61 61 endif 62 62 else
+1 -1
arch/x86/lib/cmpxchg8b_emu.S
··· 7 7 8 8 .text 9 9 10 - #ifndef CONFIG_X86_CMPXCHG64 10 + #ifndef CONFIG_X86_CX8 11 11 12 12 /* 13 13 * Emulate 'cmpxchg8b (%esi)' on UP
+2 -7
arch/x86/mm/init_32.c
··· 582 582 "only %luMB highmem pages available, ignoring highmem size of %luMB!\n" 583 583 584 584 #define MSG_HIGHMEM_TRIMMED \ 585 - "Warning: only 4GB will be used. Use a HIGHMEM64G enabled kernel!\n" 585 + "Warning: only 4GB will be used. Support for for CONFIG_HIGHMEM64G was removed!\n" 586 586 /* 587 587 * We have more RAM than fits into lowmem - we try to put it into 588 588 * highmem, also taking the highmem=x boot parameter into account: ··· 606 606 #ifndef CONFIG_HIGHMEM 607 607 /* Maximum memory usable is what is directly addressable */ 608 608 printk(KERN_WARNING "Warning only %ldMB will be used.\n", MAXMEM>>20); 609 - if (max_pfn > MAX_NONPAE_PFN) 610 - printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n"); 611 - else 612 - printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n"); 609 + printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n"); 613 610 max_pfn = MAXMEM_PFN; 614 611 #else /* !CONFIG_HIGHMEM */ 615 - #ifndef CONFIG_HIGHMEM64G 616 612 if (max_pfn > MAX_NONPAE_PFN) { 617 613 max_pfn = MAX_NONPAE_PFN; 618 614 printk(KERN_WARNING MSG_HIGHMEM_TRIMMED); 619 615 } 620 - #endif /* !CONFIG_HIGHMEM64G */ 621 616 #endif /* !CONFIG_HIGHMEM */ 622 617 } 623 618
+8
arch/x86/mm/ioremap.c
··· 503 503 } 504 504 EXPORT_SYMBOL(iounmap); 505 505 506 + void *arch_memremap_wb(phys_addr_t phys_addr, size_t size, unsigned long flags) 507 + { 508 + if ((flags & MEMREMAP_DEC) || cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) 509 + return (void __force *)ioremap_cache(phys_addr, size); 510 + 511 + return (void __force *)ioremap_encrypted(phys_addr, size); 512 + } 513 + 506 514 /* 507 515 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 508 516 * access
+8 -2
arch/x86/mm/kaslr.c
··· 113 113 memory_tb = DIV_ROUND_UP(max_pfn << PAGE_SHIFT, 1UL << TB_SHIFT) + 114 114 CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING; 115 115 116 - /* Adapt physical memory region size based on available memory */ 117 - if (memory_tb < kaslr_regions[0].size_tb) 116 + /* 117 + * Adapt physical memory region size based on available memory, 118 + * except when CONFIG_PCI_P2PDMA is enabled. P2PDMA exposes the 119 + * device BAR space assuming the direct map space is large enough 120 + * for creating a ZONE_DEVICE mapping in the direct map corresponding 121 + * to the physical BAR address. 122 + */ 123 + if (!IS_ENABLED(CONFIG_PCI_P2PDMA) && (memory_tb < kaslr_regions[0].size_tb)) 118 124 kaslr_regions[0].size_tb = memory_tb; 119 125 120 126 /*
+1 -8
arch/x86/mm/mmap.c
··· 84 84 { 85 85 unsigned long gap = rlim_stack->rlim_cur; 86 86 unsigned long pad = stack_maxrandom_size(task_size) + stack_guard_gap; 87 - unsigned long gap_min, gap_max; 88 87 89 88 /* Values close to RLIM_INFINITY can overflow. */ 90 89 if (gap + pad > gap) ··· 93 94 * Top of mmap area (just below the process stack). 94 95 * Leave an at least ~128 MB hole with possible stack randomization. 95 96 */ 96 - gap_min = SIZE_128M; 97 - gap_max = (task_size / 6) * 5; 98 - 99 - if (gap < gap_min) 100 - gap = gap_min; 101 - else if (gap > gap_max) 102 - gap = gap_max; 97 + gap = clamp(gap, SIZE_128M, (task_size / 6) * 5); 103 98 104 99 return PAGE_ALIGN(task_size - gap - rnd); 105 100 }
+5 -5
arch/x86/mm/pat/set_memory.c
··· 225 225 return addr >= start && addr < end; 226 226 } 227 227 228 + #ifdef CONFIG_X86_64 229 + 228 230 static inline int 229 231 within_inclusive(unsigned long addr, unsigned long start, unsigned long end) 230 232 { 231 233 return addr >= start && addr <= end; 232 234 } 233 - 234 - #ifdef CONFIG_X86_64 235 235 236 236 /* 237 237 * The kernel image is mapped into two places in the virtual address space ··· 2628 2628 .pgd = NULL, 2629 2629 .numpages = numpages, 2630 2630 .mask_set = __pgprot(0), 2631 - .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW), 2631 + .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY), 2632 2632 .flags = CPA_NO_CHECK_ALIAS }; 2633 2633 2634 2634 /* ··· 2715 2715 .pgd = pgd, 2716 2716 .numpages = numpages, 2717 2717 .mask_set = __pgprot(0), 2718 - .mask_clr = __pgprot(~page_flags & (_PAGE_NX|_PAGE_RW)), 2718 + .mask_clr = __pgprot(~page_flags & (_PAGE_NX|_PAGE_RW|_PAGE_DIRTY)), 2719 2719 .flags = CPA_NO_CHECK_ALIAS, 2720 2720 }; 2721 2721 ··· 2758 2758 .pgd = pgd, 2759 2759 .numpages = numpages, 2760 2760 .mask_set = __pgprot(0), 2761 - .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW), 2761 + .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY), 2762 2762 .flags = CPA_NO_CHECK_ALIAS, 2763 2763 }; 2764 2764
+5 -49
arch/x86/mm/pgtable.c
··· 12 12 EXPORT_SYMBOL(physical_mask); 13 13 #endif 14 14 15 - #ifdef CONFIG_HIGHPTE 16 - #define PGTABLE_HIGHMEM __GFP_HIGHMEM 17 - #else 18 - #define PGTABLE_HIGHMEM 0 19 - #endif 20 - 21 - #ifndef CONFIG_PARAVIRT 22 - #ifndef CONFIG_PT_RECLAIM 23 - static inline 24 - void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) 25 - { 26 - struct ptdesc *ptdesc = (struct ptdesc *)table; 27 - 28 - pagetable_dtor(ptdesc); 29 - tlb_remove_page(tlb, ptdesc_page(ptdesc)); 30 - } 31 - #else 32 - static inline 33 - void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) 34 - { 35 - tlb_remove_table(tlb, table); 36 - } 37 - #endif /* !CONFIG_PT_RECLAIM */ 38 - #endif /* !CONFIG_PARAVIRT */ 39 - 40 - gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM; 41 - 42 15 pgtable_t pte_alloc_one(struct mm_struct *mm) 43 16 { 44 - return __pte_alloc_one(mm, __userpte_alloc_gfp); 17 + return __pte_alloc_one(mm, GFP_PGTABLE_USER); 45 18 } 46 - 47 - static int __init setup_userpte(char *arg) 48 - { 49 - if (!arg) 50 - return -EINVAL; 51 - 52 - /* 53 - * "userpte=nohigh" disables allocation of user pagetables in 54 - * high memory. 55 - */ 56 - if (strcmp(arg, "nohigh") == 0) 57 - __userpte_alloc_gfp &= ~__GFP_HIGHMEM; 58 - else 59 - return -EINVAL; 60 - return 0; 61 - } 62 - early_param("userpte", setup_userpte); 63 19 64 20 void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) 65 21 { 66 22 paravirt_release_pte(page_to_pfn(pte)); 67 - paravirt_tlb_remove_table(tlb, page_ptdesc(pte)); 23 + tlb_remove_table(tlb, page_ptdesc(pte)); 68 24 } 69 25 70 26 #if CONFIG_PGTABLE_LEVELS > 2 ··· 34 78 #ifdef CONFIG_X86_PAE 35 79 tlb->need_flush_all = 1; 36 80 #endif 37 - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pmd)); 81 + tlb_remove_table(tlb, virt_to_ptdesc(pmd)); 38 82 } 39 83 40 84 #if CONFIG_PGTABLE_LEVELS > 3 41 85 void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) 42 86 { 43 87 paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); 44 - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(pud)); 88 + tlb_remove_table(tlb, virt_to_ptdesc(pud)); 45 89 } 46 90 47 91 #if CONFIG_PGTABLE_LEVELS > 4 48 92 void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) 49 93 { 50 94 paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); 51 - paravirt_tlb_remove_table(tlb, virt_to_ptdesc(p4d)); 95 + tlb_remove_table(tlb, virt_to_ptdesc(p4d)); 52 96 } 53 97 #endif /* CONFIG_PGTABLE_LEVELS > 4 */ 54 98 #endif /* CONFIG_PGTABLE_LEVELS > 3 */
-2
arch/x86/pci/Makefile
··· 12 12 obj-$(CONFIG_ACPI) += acpi.o 13 13 obj-y += legacy.o irq.o 14 14 15 - obj-$(CONFIG_STA2X11) += sta2x11-fixup.o 16 - 17 15 obj-$(CONFIG_X86_NUMACHIP) += numachip.o 18 16 19 17 obj-$(CONFIG_X86_INTEL_MID) += intel_mid_pci.o
-233
arch/x86/pci/sta2x11-fixup.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * DMA translation between STA2x11 AMBA memory mapping and the x86 memory mapping 4 - * 5 - * ST Microelectronics ConneXt (STA2X11/STA2X10) 6 - * 7 - * Copyright (c) 2010-2011 Wind River Systems, Inc. 8 - */ 9 - 10 - #include <linux/pci.h> 11 - #include <linux/pci_ids.h> 12 - #include <linux/export.h> 13 - #include <linux/list.h> 14 - #include <linux/dma-map-ops.h> 15 - #include <linux/swiotlb.h> 16 - #include <asm/iommu.h> 17 - #include <asm/sta2x11.h> 18 - 19 - #define STA2X11_SWIOTLB_SIZE (4*1024*1024) 20 - 21 - /* 22 - * We build a list of bus numbers that are under the ConneXt. The 23 - * main bridge hosts 4 busses, which are the 4 endpoints, in order. 24 - */ 25 - #define STA2X11_NR_EP 4 /* 0..3 included */ 26 - #define STA2X11_NR_FUNCS 8 /* 0..7 included */ 27 - #define STA2X11_AMBA_SIZE (512 << 20) 28 - 29 - struct sta2x11_ahb_regs { /* saved during suspend */ 30 - u32 base, pexlbase, pexhbase, crw; 31 - }; 32 - 33 - struct sta2x11_mapping { 34 - int is_suspended; 35 - struct sta2x11_ahb_regs regs[STA2X11_NR_FUNCS]; 36 - }; 37 - 38 - struct sta2x11_instance { 39 - struct list_head list; 40 - int bus0; 41 - struct sta2x11_mapping map[STA2X11_NR_EP]; 42 - }; 43 - 44 - static LIST_HEAD(sta2x11_instance_list); 45 - 46 - /* At probe time, record new instances of this bridge (likely one only) */ 47 - static void sta2x11_new_instance(struct pci_dev *pdev) 48 - { 49 - struct sta2x11_instance *instance; 50 - 51 - instance = kzalloc(sizeof(*instance), GFP_ATOMIC); 52 - if (!instance) 53 - return; 54 - /* This has a subordinate bridge, with 4 more-subordinate ones */ 55 - instance->bus0 = pdev->subordinate->number + 1; 56 - 57 - if (list_empty(&sta2x11_instance_list)) { 58 - int size = STA2X11_SWIOTLB_SIZE; 59 - /* First instance: register your own swiotlb area */ 60 - dev_info(&pdev->dev, "Using SWIOTLB (size %i)\n", size); 61 - if (swiotlb_init_late(size, GFP_DMA, NULL)) 62 - dev_emerg(&pdev->dev, "init swiotlb failed\n"); 63 - } 64 - list_add(&instance->list, &sta2x11_instance_list); 65 - } 66 - DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_STMICRO, 0xcc17, sta2x11_new_instance); 67 - 68 - /* 69 - * Utility functions used in this file from below 70 - */ 71 - static struct sta2x11_instance *sta2x11_pdev_to_instance(struct pci_dev *pdev) 72 - { 73 - struct sta2x11_instance *instance; 74 - int ep; 75 - 76 - list_for_each_entry(instance, &sta2x11_instance_list, list) { 77 - ep = pdev->bus->number - instance->bus0; 78 - if (ep >= 0 && ep < STA2X11_NR_EP) 79 - return instance; 80 - } 81 - return NULL; 82 - } 83 - 84 - static int sta2x11_pdev_to_ep(struct pci_dev *pdev) 85 - { 86 - struct sta2x11_instance *instance; 87 - 88 - instance = sta2x11_pdev_to_instance(pdev); 89 - if (!instance) 90 - return -1; 91 - 92 - return pdev->bus->number - instance->bus0; 93 - } 94 - 95 - /* This is exported, as some devices need to access the MFD registers */ 96 - struct sta2x11_instance *sta2x11_get_instance(struct pci_dev *pdev) 97 - { 98 - return sta2x11_pdev_to_instance(pdev); 99 - } 100 - EXPORT_SYMBOL(sta2x11_get_instance); 101 - 102 - /* At setup time, we use our own ops if the device is a ConneXt one */ 103 - static void sta2x11_setup_pdev(struct pci_dev *pdev) 104 - { 105 - struct sta2x11_instance *instance = sta2x11_pdev_to_instance(pdev); 106 - 107 - if (!instance) /* either a sta2x11 bridge or another ST device */ 108 - return; 109 - 110 - /* We must enable all devices as master, for audio DMA to work */ 111 - pci_set_master(pdev); 112 - } 113 - DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_STMICRO, PCI_ANY_ID, sta2x11_setup_pdev); 114 - 115 - /* 116 - * At boot we must set up the mappings for the pcie-to-amba bridge. 117 - * It involves device access, and the same happens at suspend/resume time 118 - */ 119 - 120 - #define AHB_MAPB 0xCA4 121 - #define AHB_CRW(i) (AHB_MAPB + 0 + (i) * 0x10) 122 - #define AHB_CRW_SZMASK 0xfffffc00UL 123 - #define AHB_CRW_ENABLE (1 << 0) 124 - #define AHB_CRW_WTYPE_MEM (2 << 1) 125 - #define AHB_CRW_ROE (1UL << 3) /* Relax Order Ena */ 126 - #define AHB_CRW_NSE (1UL << 4) /* No Snoop Enable */ 127 - #define AHB_BASE(i) (AHB_MAPB + 4 + (i) * 0x10) 128 - #define AHB_PEXLBASE(i) (AHB_MAPB + 8 + (i) * 0x10) 129 - #define AHB_PEXHBASE(i) (AHB_MAPB + 12 + (i) * 0x10) 130 - 131 - /* At probe time, enable mapping for each endpoint, using the pdev */ 132 - static void sta2x11_map_ep(struct pci_dev *pdev) 133 - { 134 - struct sta2x11_instance *instance = sta2x11_pdev_to_instance(pdev); 135 - struct device *dev = &pdev->dev; 136 - u32 amba_base, max_amba_addr; 137 - int i, ret; 138 - 139 - if (!instance) 140 - return; 141 - 142 - pci_read_config_dword(pdev, AHB_BASE(0), &amba_base); 143 - max_amba_addr = amba_base + STA2X11_AMBA_SIZE - 1; 144 - 145 - ret = dma_direct_set_offset(dev, 0, amba_base, STA2X11_AMBA_SIZE); 146 - if (ret) 147 - dev_err(dev, "sta2x11: could not set DMA offset\n"); 148 - 149 - dev->bus_dma_limit = max_amba_addr; 150 - dma_set_mask_and_coherent(&pdev->dev, max_amba_addr); 151 - 152 - /* Configure AHB mapping */ 153 - pci_write_config_dword(pdev, AHB_PEXLBASE(0), 0); 154 - pci_write_config_dword(pdev, AHB_PEXHBASE(0), 0); 155 - pci_write_config_dword(pdev, AHB_CRW(0), STA2X11_AMBA_SIZE | 156 - AHB_CRW_WTYPE_MEM | AHB_CRW_ENABLE); 157 - 158 - /* Disable all the other windows */ 159 - for (i = 1; i < STA2X11_NR_FUNCS; i++) 160 - pci_write_config_dword(pdev, AHB_CRW(i), 0); 161 - 162 - dev_info(&pdev->dev, 163 - "sta2x11: Map EP %i: AMBA address %#8x-%#8x\n", 164 - sta2x11_pdev_to_ep(pdev), amba_base, max_amba_addr); 165 - } 166 - DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_STMICRO, PCI_ANY_ID, sta2x11_map_ep); 167 - 168 - #ifdef CONFIG_PM /* Some register values must be saved and restored */ 169 - 170 - static struct sta2x11_mapping *sta2x11_pdev_to_mapping(struct pci_dev *pdev) 171 - { 172 - struct sta2x11_instance *instance; 173 - int ep; 174 - 175 - instance = sta2x11_pdev_to_instance(pdev); 176 - if (!instance) 177 - return NULL; 178 - ep = sta2x11_pdev_to_ep(pdev); 179 - return instance->map + ep; 180 - } 181 - 182 - static void suspend_mapping(struct pci_dev *pdev) 183 - { 184 - struct sta2x11_mapping *map = sta2x11_pdev_to_mapping(pdev); 185 - int i; 186 - 187 - if (!map) 188 - return; 189 - 190 - if (map->is_suspended) 191 - return; 192 - map->is_suspended = 1; 193 - 194 - /* Save all window configs */ 195 - for (i = 0; i < STA2X11_NR_FUNCS; i++) { 196 - struct sta2x11_ahb_regs *regs = map->regs + i; 197 - 198 - pci_read_config_dword(pdev, AHB_BASE(i), &regs->base); 199 - pci_read_config_dword(pdev, AHB_PEXLBASE(i), &regs->pexlbase); 200 - pci_read_config_dword(pdev, AHB_PEXHBASE(i), &regs->pexhbase); 201 - pci_read_config_dword(pdev, AHB_CRW(i), &regs->crw); 202 - } 203 - } 204 - DECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_STMICRO, PCI_ANY_ID, suspend_mapping); 205 - 206 - static void resume_mapping(struct pci_dev *pdev) 207 - { 208 - struct sta2x11_mapping *map = sta2x11_pdev_to_mapping(pdev); 209 - int i; 210 - 211 - if (!map) 212 - return; 213 - 214 - 215 - if (!map->is_suspended) 216 - goto out; 217 - map->is_suspended = 0; 218 - 219 - /* Restore all window configs */ 220 - for (i = 0; i < STA2X11_NR_FUNCS; i++) { 221 - struct sta2x11_ahb_regs *regs = map->regs + i; 222 - 223 - pci_write_config_dword(pdev, AHB_BASE(i), regs->base); 224 - pci_write_config_dword(pdev, AHB_PEXLBASE(i), regs->pexlbase); 225 - pci_write_config_dword(pdev, AHB_PEXHBASE(i), regs->pexhbase); 226 - pci_write_config_dword(pdev, AHB_CRW(i), regs->crw); 227 - } 228 - out: 229 - pci_set_master(pdev); /* Like at boot, enable master on all devices */ 230 - } 231 - DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_STMICRO, PCI_ANY_ID, resume_mapping); 232 - 233 - #endif /* CONFIG_PM */
+8 -6
arch/x86/platform/pvh/head.S
··· 173 173 1: 174 174 UNWIND_HINT_END_OF_STACK 175 175 176 - /* Set base address in stack canary descriptor. */ 177 - mov $MSR_GS_BASE,%ecx 178 - leal canary(%rip), %eax 179 - xor %edx, %edx 176 + /* 177 + * Set up GSBASE. 178 + * Note that on SMP the boot CPU uses the init data section until 179 + * the per-CPU areas are set up. 180 + */ 181 + movl $MSR_GS_BASE,%ecx 182 + xorl %eax, %eax 183 + xorl %edx, %edx 180 184 wrmsr 181 185 182 186 /* Call xen_prepare_pvh() via the kernel virtual mapping */ ··· 242 238 SYM_DATA_END_LABEL(gdt_start, SYM_L_LOCAL, gdt_end) 243 239 244 240 .balign 16 245 - SYM_DATA_LOCAL(canary, .fill 48, 1, 0) 246 - 247 241 SYM_DATA_START_LOCAL(early_stack) 248 242 .fill BOOT_STACK_SIZE, 1, 0 249 243 SYM_DATA_END_LABEL(early_stack, SYM_L_LOCAL, early_stack_end)
+10 -137
arch/x86/tools/relocs.c
··· 29 29 static struct relocs relocs32; 30 30 31 31 #if ELF_BITS == 64 32 - static struct relocs relocs32neg; 33 32 static struct relocs relocs64; 34 33 # define FMT PRIu64 34 + 35 + #ifndef R_X86_64_REX_GOTPCRELX 36 + # define R_X86_64_REX_GOTPCRELX 42 37 + #endif 38 + 35 39 #else 36 40 # define FMT PRIu32 37 41 #endif ··· 90 86 "__initramfs_start|" 91 87 "(jiffies|jiffies_64)|" 92 88 #if ELF_BITS == 64 93 - "__per_cpu_load|" 94 - "init_per_cpu__.*|" 95 89 "__end_rodata_hpage_align|" 96 90 #endif 97 91 "_end)$" ··· 229 227 REL_TYPE(R_X86_64_PC16), 230 228 REL_TYPE(R_X86_64_8), 231 229 REL_TYPE(R_X86_64_PC8), 230 + REL_TYPE(R_X86_64_REX_GOTPCRELX), 232 231 #else 233 232 REL_TYPE(R_386_NONE), 234 233 REL_TYPE(R_386_32), ··· 285 282 name = sec_name(sym_index(sym)); 286 283 287 284 return name; 288 - } 289 - 290 - static Elf_Sym *sym_lookup(const char *symname) 291 - { 292 - int i; 293 - 294 - for (i = 0; i < shnum; i++) { 295 - struct section *sec = &secs[i]; 296 - long nsyms; 297 - char *strtab; 298 - Elf_Sym *symtab; 299 - Elf_Sym *sym; 300 - 301 - if (sec->shdr.sh_type != SHT_SYMTAB) 302 - continue; 303 - 304 - nsyms = sec->shdr.sh_size/sizeof(Elf_Sym); 305 - symtab = sec->symtab; 306 - strtab = sec->link->strtab; 307 - 308 - for (sym = symtab; --nsyms >= 0; sym++) { 309 - if (!sym->st_name) 310 - continue; 311 - if (strcmp(symname, strtab + sym->st_name) == 0) 312 - return sym; 313 - } 314 - } 315 - return 0; 316 285 } 317 286 318 287 #if BYTE_ORDER == LITTLE_ENDIAN ··· 735 760 } 736 761 } 737 762 738 - /* 739 - * The .data..percpu section is a special case for x86_64 SMP kernels. 740 - * It is used to initialize the actual per_cpu areas and to provide 741 - * definitions for the per_cpu variables that correspond to their offsets 742 - * within the percpu area. Since the values of all of the symbols need 743 - * to be offsets from the start of the per_cpu area the virtual address 744 - * (sh_addr) of .data..percpu is 0 in SMP kernels. 745 - * 746 - * This means that: 747 - * 748 - * Relocations that reference symbols in the per_cpu area do not 749 - * need further relocation (since the value is an offset relative 750 - * to the start of the per_cpu area that does not change). 751 - * 752 - * Relocations that apply to the per_cpu area need to have their 753 - * offset adjusted by by the value of __per_cpu_load to make them 754 - * point to the correct place in the loaded image (because the 755 - * virtual address of .data..percpu is 0). 756 - * 757 - * For non SMP kernels .data..percpu is linked as part of the normal 758 - * kernel data and does not require special treatment. 759 - * 760 - */ 761 - static int per_cpu_shndx = -1; 762 - static Elf_Addr per_cpu_load_addr; 763 - 764 - static void percpu_init(void) 765 - { 766 - int i; 767 - 768 - for (i = 0; i < shnum; i++) { 769 - ElfW(Sym) *sym; 770 - 771 - if (strcmp(sec_name(i), ".data..percpu")) 772 - continue; 773 - 774 - if (secs[i].shdr.sh_addr != 0) /* non SMP kernel */ 775 - return; 776 - 777 - sym = sym_lookup("__per_cpu_load"); 778 - if (!sym) 779 - die("can't find __per_cpu_load\n"); 780 - 781 - per_cpu_shndx = i; 782 - per_cpu_load_addr = sym->st_value; 783 - 784 - return; 785 - } 786 - } 787 - 788 763 #if ELF_BITS == 64 789 - 790 - /* 791 - * Check to see if a symbol lies in the .data..percpu section. 792 - * 793 - * The linker incorrectly associates some symbols with the 794 - * .data..percpu section so we also need to check the symbol 795 - * name to make sure that we classify the symbol correctly. 796 - * 797 - * The GNU linker incorrectly associates: 798 - * __init_begin 799 - * __per_cpu_load 800 - * 801 - * The "gold" linker incorrectly associates: 802 - * init_per_cpu__fixed_percpu_data 803 - * init_per_cpu__gdt_page 804 - */ 805 - static int is_percpu_sym(ElfW(Sym) *sym, const char *symname) 806 - { 807 - int shndx = sym_index(sym); 808 - 809 - return (shndx == per_cpu_shndx) && 810 - strcmp(symname, "__init_begin") && 811 - strcmp(symname, "__per_cpu_load") && 812 - strncmp(symname, "init_per_cpu_", 13); 813 - } 814 - 815 764 816 765 static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym, 817 766 const char *symname) ··· 747 848 if (sym->st_shndx == SHN_UNDEF) 748 849 return 0; 749 850 750 - /* 751 - * Adjust the offset if this reloc applies to the percpu section. 752 - */ 753 - if (sec->shdr.sh_info == per_cpu_shndx) 754 - offset += per_cpu_load_addr; 755 - 756 851 switch (r_type) { 757 852 case R_X86_64_NONE: 758 853 /* NONE can be ignored. */ ··· 754 861 755 862 case R_X86_64_PC32: 756 863 case R_X86_64_PLT32: 864 + case R_X86_64_REX_GOTPCRELX: 757 865 /* 758 - * PC relative relocations don't need to be adjusted unless 759 - * referencing a percpu symbol. 866 + * PC relative relocations don't need to be adjusted. 760 867 * 761 868 * NB: R_X86_64_PLT32 can be treated as R_X86_64_PC32. 762 869 */ 763 - if (is_percpu_sym(sym, symname)) 764 - add_reloc(&relocs32neg, offset); 765 870 break; 766 871 767 872 case R_X86_64_PC64: 768 873 /* 769 874 * Only used by jump labels 770 875 */ 771 - if (is_percpu_sym(sym, symname)) 772 - die("Invalid R_X86_64_PC64 relocation against per-CPU symbol %s\n", symname); 773 876 break; 774 877 775 878 case R_X86_64_32: 776 879 case R_X86_64_32S: 777 880 case R_X86_64_64: 778 - /* 779 - * References to the percpu area don't need to be adjusted. 780 - */ 781 - if (is_percpu_sym(sym, symname)) 782 - break; 783 - 784 881 if (shn_abs) { 785 882 /* 786 883 * Whitelisted absolute symbols do not require ··· 938 1055 939 1056 static void sort_relocs(struct relocs *r) 940 1057 { 941 - qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs); 1058 + if (r->count) 1059 + qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs); 942 1060 } 943 1061 944 1062 static int write32(uint32_t v, FILE *f) ··· 983 1099 /* Order the relocations for more efficient processing */ 984 1100 sort_relocs(&relocs32); 985 1101 #if ELF_BITS == 64 986 - sort_relocs(&relocs32neg); 987 1102 sort_relocs(&relocs64); 988 1103 #else 989 1104 sort_relocs(&relocs16); ··· 1014 1131 /* Now print each relocation */ 1015 1132 for (i = 0; i < relocs64.count; i++) 1016 1133 write_reloc(relocs64.offset[i], stdout); 1017 - 1018 - /* Print a stop */ 1019 - write_reloc(0, stdout); 1020 - 1021 - /* Now print each inverse 32-bit relocation */ 1022 - for (i = 0; i < relocs32neg.count; i++) 1023 - write_reloc(relocs32neg.offset[i], stdout); 1024 1134 #endif 1025 1135 1026 1136 /* Print a stop */ ··· 1065 1189 read_strtabs(fp); 1066 1190 read_symtabs(fp); 1067 1191 read_relocs(fp); 1068 - 1069 - if (ELF_BITS == 64) 1070 - percpu_init(); 1071 1192 1072 1193 if (show_absolute_syms) { 1073 1194 print_absolute_symbols();
+1 -1
arch/x86/xen/Kconfig
··· 9 9 select PARAVIRT_CLOCK 10 10 select X86_HV_CALLBACK_VECTOR 11 11 depends on X86_64 || (X86_32 && X86_PAE) 12 - depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MCORE2 || MATOM || MK8) 12 + depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MATOM) 13 13 depends on X86_LOCAL_APIC && X86_TSC 14 14 help 15 15 This is the Linux Xen port. Enabling this will allow the
-1
arch/x86/xen/mmu_pv.c
··· 2189 2189 .flush_tlb_kernel = xen_flush_tlb, 2190 2190 .flush_tlb_one_user = xen_flush_tlb_one_user, 2191 2191 .flush_tlb_multi = xen_flush_tlb_multi, 2192 - .tlb_remove_table = tlb_remove_table, 2193 2192 2194 2193 .pgd_alloc = xen_pgd_alloc, 2195 2194 .pgd_free = xen_pgd_free,
+1 -1
arch/x86/xen/smp_pv.c
··· 70 70 xen_enable_syscall(); 71 71 } 72 72 cpu = smp_processor_id(); 73 - smp_store_cpu_info(cpu); 73 + identify_secondary_cpu(cpu); 74 74 set_cpu_sibling_map(cpu); 75 75 76 76 speculative_store_bypass_ht_init();
+4 -6
arch/x86/xen/xen-head.S
··· 31 31 32 32 leaq __top_init_kernel_stack(%rip), %rsp 33 33 34 - /* Set up %gs. 35 - * 36 - * The base of %gs always points to fixed_percpu_data. If the 37 - * stack protector canary is enabled, it is located at %gs:40. 34 + /* 35 + * Set up GSBASE. 38 36 * Note that, on SMP, the boot cpu uses init data section until 39 37 * the per cpu areas are set up. 40 38 */ 41 39 movl $MSR_GS_BASE,%ecx 42 - movq $INIT_PER_CPU_VAR(fixed_percpu_data),%rax 43 - cdq 40 + xorl %eax, %eax 41 + xorl %edx, %edx 44 42 wrmsr 45 43 46 44 mov %rsi, %rdi
+2
drivers/acpi/processor_idle.c
··· 590 590 raw_safe_halt(); 591 591 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { 592 592 io_idle(cx->address); 593 + } else if (cx->entry_method == ACPI_CSTATE_FFH) { 594 + acpi_processor_ffh_play_dead(cx); 593 595 } else 594 596 return; 595 597 }
+4 -12
drivers/cpufreq/intel_pstate.c
··· 2200 2200 return ret; 2201 2201 } 2202 2202 2203 - static void hybrid_get_type(void *data) 2204 - { 2205 - u8 *cpu_type = data; 2206 - 2207 - *cpu_type = get_this_hybrid_cpu_type(); 2208 - } 2209 - 2210 2203 static int hwp_get_cpu_scaling(int cpu) 2211 2204 { 2212 2205 if (hybrid_scaling_factor) { 2213 - u8 cpu_type = 0; 2214 - 2215 - smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); 2206 + struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); 2207 + u8 cpu_type = c->topo.intel_type; 2216 2208 2217 2209 /* 2218 2210 * Return the hybrid scaling factor for P-cores and use the 2219 2211 * default core scaling for E-cores. 2220 2212 */ 2221 - if (cpu_type == 0x40) 2213 + if (cpu_type == INTEL_CPU_TYPE_CORE) 2222 2214 return hybrid_scaling_factor; 2223 2215 2224 - if (cpu_type == 0x20) 2216 + if (cpu_type == INTEL_CPU_TYPE_ATOM) 2225 2217 return core_get_scaling(); 2226 2218 } 2227 2219
+14
drivers/idle/intel_idle.c
··· 58 58 #include <asm/spec-ctrl.h> 59 59 #include <asm/tsc.h> 60 60 #include <asm/fpu/api.h> 61 + #include <asm/smp.h> 61 62 62 63 #define INTEL_IDLE_VERSION "0.5.1" 63 64 ··· 228 227 mwait_idle_with_hints(eax, ecx); 229 228 230 229 return 0; 230 + } 231 + 232 + static void intel_idle_enter_dead(struct cpuidle_device *dev, int index) 233 + { 234 + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 235 + struct cpuidle_state *state = &drv->states[index]; 236 + unsigned long eax = flg2MWAIT(state->flags); 237 + 238 + mwait_play_dead(eax); 231 239 } 232 240 233 241 /* ··· 1814 1804 mark_tsc_unstable("TSC halts in idle"); 1815 1805 1816 1806 state->enter = intel_idle; 1807 + state->enter_dead = intel_idle_enter_dead; 1817 1808 state->enter_s2idle = intel_idle_s2idle; 1818 1809 } 1819 1810 } ··· 2163 2152 if (!cpuidle_state_table[cstate].enter && 2164 2153 !cpuidle_state_table[cstate].enter_s2idle) 2165 2154 break; 2155 + 2156 + if (!cpuidle_state_table[cstate].enter_dead) 2157 + cpuidle_state_table[cstate].enter_dead = intel_idle_enter_dead; 2166 2158 2167 2159 /* If marked as unusable, skip this state. */ 2168 2160 if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
+1 -1
drivers/misc/mei/Kconfig
··· 3 3 config INTEL_MEI 4 4 tristate "Intel Management Engine Interface" 5 5 depends on X86 && PCI 6 - default GENERIC_CPU || MCORE2 || MATOM || X86_GENERIC 6 + default X86_64 || MATOM 7 7 help 8 8 The Intel Management Engine (Intel ME) provides Manageability, 9 9 Security and Media services for system containing Intel chipsets.
+6
drivers/pci/Kconfig
··· 203 203 P2P DMA transactions must be between devices behind the same root 204 204 port. 205 205 206 + Enabling this option will reduce the entropy of x86 KASLR memory 207 + regions. For example - on a 46 bit system, the entropy goes down 208 + from 16 bits to 15 bits. The actual reduction in entropy depends 209 + on the physical address bits, on processor features, kernel config 210 + (5 level page table) and physical memory present on the system. 211 + 206 212 If unsure, say N. 207 213 208 214 config PCI_LABEL
+1 -1
drivers/powercap/intel_rapl_common.c
··· 1274 1274 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT, &rapl_defaults_byt), 1275 1275 X86_MATCH_VFM(INTEL_ATOM_AIRMONT, &rapl_defaults_cht), 1276 1276 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID, &rapl_defaults_tng), 1277 - X86_MATCH_VFM(INTEL_ATOM_AIRMONT_MID, &rapl_defaults_ann), 1277 + X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID2,&rapl_defaults_ann), 1278 1278 X86_MATCH_VFM(INTEL_ATOM_GOLDMONT, &rapl_defaults_core), 1279 1279 X86_MATCH_VFM(INTEL_ATOM_GOLDMONT_PLUS, &rapl_defaults_core), 1280 1280 X86_MATCH_VFM(INTEL_ATOM_GOLDMONT_D, &rapl_defaults_core),
+2 -2
drivers/staging/media/atomisp/include/linux/atomisp_platform.h
··· 172 172 #define IS_BYT __IS_SOC(INTEL_ATOM_SILVERMONT) 173 173 #define IS_CHT __IS_SOC(INTEL_ATOM_AIRMONT) 174 174 #define IS_MRFD __IS_SOC(INTEL_ATOM_SILVERMONT_MID) 175 - #define IS_MOFD __IS_SOC(INTEL_ATOM_AIRMONT_MID) 175 + #define IS_MOFD __IS_SOC(INTEL_ATOM_SILVERMONT_MID2) 176 176 177 177 /* Both CHT and MOFD come with ISP2401 */ 178 178 #define IS_ISP2401 __IS_SOCS(INTEL_ATOM_AIRMONT, \ 179 - INTEL_ATOM_AIRMONT_MID) 179 + INTEL_ATOM_SILVERMONT_MID2) 180 180 181 181 #endif /* ATOMISP_PLATFORM_H_ */
+1 -1
drivers/thermal/intel/intel_tcc.c
··· 106 106 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_D, &temp_broadwell), 107 107 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID, &temp_broadwell), 108 108 X86_MATCH_VFM(INTEL_ATOM_AIRMONT, &temp_broadwell), 109 - X86_MATCH_VFM(INTEL_ATOM_AIRMONT_MID, &temp_broadwell), 109 + X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID2, &temp_broadwell), 110 110 X86_MATCH_VFM(INTEL_ATOM_AIRMONT_NP, &temp_broadwell), 111 111 X86_MATCH_VFM(INTEL_ATOM_GOLDMONT, &temp_goldmont), 112 112 X86_MATCH_VFM(INTEL_ATOM_GOLDMONT_D, &temp_goldmont),
+5
include/acpi/processor.h
··· 280 280 struct acpi_processor_cx *cx, 281 281 struct acpi_power_register *reg); 282 282 void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate); 283 + void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx); 283 284 #else 284 285 static inline void acpi_processor_power_init_bm_check(struct 285 286 acpi_processor_flags ··· 300 299 *cstate) 301 300 { 302 301 return; 302 + } 303 + static inline void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 304 + { 305 + BUG(); 303 306 } 304 307 #endif 305 308
+1 -1
include/asm-generic/sections.h
··· 39 39 extern char _sinittext[], _einittext[]; 40 40 extern char __start_ro_after_init[], __end_ro_after_init[]; 41 41 extern char _end[]; 42 - extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; 42 + extern char __per_cpu_start[], __per_cpu_end[]; 43 43 extern char __kprobes_text_start[], __kprobes_text_end[]; 44 44 extern char __entry_text_start[], __entry_text_end[]; 45 45 extern char __start_rodata[], __end_rodata[];
+1 -37
include/asm-generic/vmlinux.lds.h
··· 1062 1062 */ 1063 1063 #define PERCPU_INPUT(cacheline) \ 1064 1064 __per_cpu_start = .; \ 1065 - *(.data..percpu..first) \ 1066 1065 . = ALIGN(PAGE_SIZE); \ 1067 1066 *(.data..percpu..page_aligned) \ 1068 1067 . = ALIGN(cacheline); \ ··· 1073 1074 __per_cpu_end = .; 1074 1075 1075 1076 /** 1076 - * PERCPU_VADDR - define output section for percpu area 1077 + * PERCPU_SECTION - define output section for percpu area 1077 1078 * @cacheline: cacheline size 1078 - * @vaddr: explicit base address (optional) 1079 - * @phdr: destination PHDR (optional) 1080 1079 * 1081 1080 * Macro which expands to output section for percpu area. 1082 1081 * 1083 1082 * @cacheline is used to align subsections to avoid false cacheline 1084 1083 * sharing between subsections for different purposes. 1085 - * 1086 - * If @vaddr is not blank, it specifies explicit base address and all 1087 - * percpu symbols will be offset from the given address. If blank, 1088 - * @vaddr always equals @laddr + LOAD_OFFSET. 1089 - * 1090 - * @phdr defines the output PHDR to use if not blank. Be warned that 1091 - * output PHDR is sticky. If @phdr is specified, the next output 1092 - * section in the linker script will go there too. @phdr should have 1093 - * a leading colon. 1094 - * 1095 - * Note that this macros defines __per_cpu_load as an absolute symbol. 1096 - * If there is no need to put the percpu section at a predetermined 1097 - * address, use PERCPU_SECTION. 1098 - */ 1099 - #define PERCPU_VADDR(cacheline, vaddr, phdr) \ 1100 - __per_cpu_load = .; \ 1101 - .data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) { \ 1102 - PERCPU_INPUT(cacheline) \ 1103 - } phdr \ 1104 - . = __per_cpu_load + SIZEOF(.data..percpu); 1105 - 1106 - /** 1107 - * PERCPU_SECTION - define output section for percpu area, simple version 1108 - * @cacheline: cacheline size 1109 - * 1110 - * Align to PAGE_SIZE and outputs output section for percpu area. This 1111 - * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and 1112 - * __per_cpu_start will be identical. 1113 - * 1114 - * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,) 1115 - * except that __per_cpu_load is defined as a relative symbol against 1116 - * .data..percpu which is required for relocatable x86_32 configuration. 1117 1084 */ 1118 1085 #define PERCPU_SECTION(cacheline) \ 1119 1086 . = ALIGN(PAGE_SIZE); \ 1120 1087 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \ 1121 - __per_cpu_load = .; \ 1122 1088 PERCPU_INPUT(cacheline) \ 1123 1089 } 1124 1090
-12
include/linux/percpu-defs.h
··· 26 26 #define PER_CPU_SHARED_ALIGNED_SECTION "..shared_aligned" 27 27 #define PER_CPU_ALIGNED_SECTION "..shared_aligned" 28 28 #endif 29 - #define PER_CPU_FIRST_SECTION "..first" 30 29 31 30 #else 32 31 33 32 #define PER_CPU_SHARED_ALIGNED_SECTION "" 34 33 #define PER_CPU_ALIGNED_SECTION "..shared_aligned" 35 - #define PER_CPU_FIRST_SECTION "" 36 34 37 35 #endif 38 36 ··· 111 113 112 114 #define DEFINE_PER_CPU(type, name) \ 113 115 DEFINE_PER_CPU_SECTION(type, name, "") 114 - 115 - /* 116 - * Declaration/definition used for per-CPU variables that must come first in 117 - * the set of variables. 118 - */ 119 - #define DECLARE_PER_CPU_FIRST(type, name) \ 120 - DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) 121 - 122 - #define DEFINE_PER_CPU_FIRST(type, name) \ 123 - DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) 124 116 125 117 /* 126 118 * Declaration/definition used for per-CPU variables that must be cacheline
+8
include/linux/sizes.h
··· 23 23 #define SZ_4K 0x00001000 24 24 #define SZ_8K 0x00002000 25 25 #define SZ_16K 0x00004000 26 + #define SZ_24K 0x00006000 26 27 #define SZ_32K 0x00008000 27 28 #define SZ_64K 0x00010000 28 29 #define SZ_128K 0x00020000 30 + #define SZ_192K 0x00030000 29 31 #define SZ_256K 0x00040000 32 + #define SZ_384K 0x00060000 30 33 #define SZ_512K 0x00080000 31 34 32 35 #define SZ_1M 0x00100000 33 36 #define SZ_2M 0x00200000 37 + #define SZ_3M 0x00300000 34 38 #define SZ_4M 0x00400000 39 + #define SZ_6M 0x00600000 35 40 #define SZ_8M 0x00800000 41 + #define SZ_12M 0x00c00000 36 42 #define SZ_16M 0x01000000 43 + #define SZ_18M 0x01200000 44 + #define SZ_24M 0x01800000 37 45 #define SZ_32M 0x02000000 38 46 #define SZ_64M 0x04000000 39 47 #define SZ_128M 0x08000000
-5
init/Kconfig
··· 1869 1869 1870 1870 Say N unless you really need all symbols, or kernel live patching. 1871 1871 1872 - config KALLSYMS_ABSOLUTE_PERCPU 1873 - bool 1874 - depends on KALLSYMS 1875 - default X86_64 && SMP 1876 - 1877 1872 # end of the "standard kernel features (expert users)" menu 1878 1873 1879 1874 config ARCH_HAS_MEMBARRIER_CALLBACKS
+1 -1
kernel/bpf/verifier.c
··· 21707 21707 * way, it's fine to back out this inlining logic 21708 21708 */ 21709 21709 #ifdef CONFIG_SMP 21710 - insn_buf[0] = BPF_MOV32_IMM(BPF_REG_0, (u32)(unsigned long)&pcpu_hot.cpu_number); 21710 + insn_buf[0] = BPF_MOV64_IMM(BPF_REG_0, (u32)(unsigned long)&pcpu_hot.cpu_number); 21711 21711 insn_buf[1] = BPF_MOV64_PERCPU_REG(BPF_REG_0, BPF_REG_0); 21712 21712 insn_buf[2] = BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0); 21713 21713 cnt = 3;
+3 -2
kernel/iomem.c
··· 6 6 #include <linux/ioremap.h> 7 7 8 8 #ifndef arch_memremap_wb 9 - static void *arch_memremap_wb(resource_size_t offset, unsigned long size) 9 + static void *arch_memremap_wb(resource_size_t offset, unsigned long size, 10 + unsigned long flags) 10 11 { 11 12 #ifdef ioremap_cache 12 13 return (__force void *)ioremap_cache(offset, size); ··· 92 91 if (is_ram == REGION_INTERSECTS) 93 92 addr = try_ram_remap(offset, size, flags); 94 93 if (!addr) 95 - addr = arch_memremap_wb(offset, size); 94 + addr = arch_memremap_wb(offset, size, flags); 96 95 } 97 96 98 97 /*
+2 -10
kernel/kallsyms.c
··· 148 148 149 149 unsigned long kallsyms_sym_address(int idx) 150 150 { 151 - /* values are unsigned offsets if --absolute-percpu is not in effect */ 152 - if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU)) 153 - return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; 154 - 155 - /* ...otherwise, positive offsets are absolute values */ 156 - if (kallsyms_offsets[idx] >= 0) 157 - return kallsyms_offsets[idx]; 158 - 159 - /* ...and negative offsets are relative to kallsyms_relative_base - 1 */ 160 - return kallsyms_relative_base - 1 - kallsyms_offsets[idx]; 151 + /* values are unsigned offsets */ 152 + return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; 161 153 } 162 154 163 155 static unsigned int get_symbol_seq(int index)
+1 -1
lib/atomic64_test.c
··· 254 254 pr_info("passed for %s platform %s CX8 and %s SSE\n", 255 255 #ifdef CONFIG_X86_64 256 256 "x86-64", 257 - #elif defined(CONFIG_X86_CMPXCHG64) 257 + #elif defined(CONFIG_X86_CX8) 258 258 "i586+", 259 259 #else 260 260 "i386+",
+2 -2
mm/percpu.c
··· 3071 3071 continue; 3072 3072 } 3073 3073 /* copy and return the unused part */ 3074 - memcpy(ptr, __per_cpu_load, ai->static_size); 3074 + memcpy(ptr, __per_cpu_start, ai->static_size); 3075 3075 pcpu_fc_free(ptr + size_sum, ai->unit_size - size_sum); 3076 3076 } 3077 3077 } ··· 3240 3240 flush_cache_vmap_early(unit_addr, unit_addr + ai->unit_size); 3241 3241 3242 3242 /* copy static data */ 3243 - memcpy((void *)unit_addr, __per_cpu_load, ai->static_size); 3243 + memcpy((void *)unit_addr, __per_cpu_start, ai->static_size); 3244 3244 } 3245 3245 3246 3246 /* we're ready, commit */
-8
scripts/gcc-x86_32-has-stack-protector.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - # This requires GCC 8.1 or better. Specifically, we require 5 - # -mstack-protector-guard-reg, added by 6 - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81708 7 - 8 - echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -m32 -O0 -fstack-protector -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard - -o - 2> /dev/null | grep -q "%fs"
-4
scripts/gcc-x86_64-has-stack-protector.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -m64 -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+11 -59
scripts/kallsyms.c
··· 5 5 * This software may be used and distributed according to the terms 6 6 * of the GNU General Public License, incorporated herein by reference. 7 7 * 8 - * Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S 8 + * Usage: kallsyms [--all-symbols] in.map > out.S 9 9 * 10 10 * Table compression uses all the unused char codes on the symbols and 11 11 * maps these to the most used substrings (tokens). For instance, it might ··· 37 37 unsigned long long addr; 38 38 unsigned int len; 39 39 unsigned int seq; 40 - bool percpu_absolute; 41 40 unsigned char sym[]; 42 41 }; 43 42 ··· 54 55 #define text_range_text (&text_ranges[0]) 55 56 #define text_range_inittext (&text_ranges[1]) 56 57 57 - static struct addr_range percpu_range = { 58 - "__per_cpu_start", "__per_cpu_end", -1ULL, 0 59 - }; 60 - 61 58 static struct sym_entry **table; 62 59 static unsigned int table_size, table_cnt; 63 60 static int all_symbols; 64 - static int absolute_percpu; 65 61 66 62 static int token_profit[0x10000]; 67 63 ··· 67 73 68 74 static void usage(void) 69 75 { 70 - fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S\n"); 76 + fprintf(stderr, "Usage: kallsyms [--all-symbols] in.map > out.S\n"); 71 77 exit(1); 72 78 } 73 79 ··· 158 164 return NULL; 159 165 160 166 check_symbol_range(name, addr, text_ranges, ARRAY_SIZE(text_ranges)); 161 - check_symbol_range(name, addr, &percpu_range, 1); 162 167 163 168 /* include the type field in the symbol name, so that it gets 164 169 * compressed together */ ··· 168 175 sym->len = len; 169 176 sym->sym[0] = type; 170 177 strcpy(sym_name(sym), name); 171 - sym->percpu_absolute = false; 172 178 173 179 return sym; 174 180 } ··· 311 319 return total; 312 320 } 313 321 314 - static bool symbol_absolute(const struct sym_entry *s) 315 - { 316 - return s->percpu_absolute; 317 - } 318 - 319 322 static int compare_names(const void *a, const void *b) 320 323 { 321 324 int ret; ··· 442 455 */ 443 456 444 457 long long offset; 445 - bool overflow; 446 458 447 - if (!absolute_percpu) { 448 - offset = table[i]->addr - relative_base; 449 - overflow = offset < 0 || offset > UINT_MAX; 450 - } else if (symbol_absolute(table[i])) { 451 - offset = table[i]->addr; 452 - overflow = offset < 0 || offset > INT_MAX; 453 - } else { 454 - offset = relative_base - table[i]->addr - 1; 455 - overflow = offset < INT_MIN || offset >= 0; 456 - } 457 - if (overflow) { 459 + offset = table[i]->addr - relative_base; 460 + if (offset < 0 || offset > UINT_MAX) { 458 461 fprintf(stderr, "kallsyms failure: " 459 - "%s symbol value %#llx out of range in relative mode\n", 460 - symbol_absolute(table[i]) ? "absolute" : "relative", 462 + "relative symbol value %#llx out of range\n", 461 463 table[i]->addr); 462 464 exit(EXIT_FAILURE); 463 465 } ··· 701 725 qsort(table, table_cnt, sizeof(table[0]), compare_symbols); 702 726 } 703 727 704 - static void make_percpus_absolute(void) 705 - { 706 - unsigned int i; 707 - 708 - for (i = 0; i < table_cnt; i++) 709 - if (symbol_in_range(table[i], &percpu_range, 1)) { 710 - /* 711 - * Keep the 'A' override for percpu symbols to 712 - * ensure consistent behavior compared to older 713 - * versions of this tool. 714 - */ 715 - table[i]->sym[0] = 'A'; 716 - table[i]->percpu_absolute = true; 717 - } 718 - } 719 - 720 728 /* find the minimum non-absolute symbol address */ 721 729 static void record_relative_base(void) 722 730 { 723 - unsigned int i; 724 - 725 - for (i = 0; i < table_cnt; i++) 726 - if (!symbol_absolute(table[i])) { 727 - /* 728 - * The table is sorted by address. 729 - * Take the first non-absolute symbol value. 730 - */ 731 - relative_base = table[i]->addr; 732 - return; 733 - } 731 + /* 732 + * The table is sorted by address. 733 + * Take the first symbol value. 734 + */ 735 + if (table_cnt) 736 + relative_base = table[0]->addr; 734 737 } 735 738 736 739 int main(int argc, char **argv) ··· 717 762 while (1) { 718 763 static const struct option long_options[] = { 719 764 {"all-symbols", no_argument, &all_symbols, 1}, 720 - {"absolute-percpu", no_argument, &absolute_percpu, 1}, 721 765 {}, 722 766 }; 723 767 ··· 733 779 734 780 read_map(argv[optind]); 735 781 shrink_table(); 736 - if (absolute_percpu) 737 - make_percpus_absolute(); 738 782 sort_symbols(); 739 783 record_relative_base(); 740 784 optimize_token_table();
+3 -1
scripts/min-tool-version.sh
··· 19 19 gcc) 20 20 if [ "$ARCH" = parisc64 ]; then 21 21 echo 12.0.0 22 + elif [ "$SRCARCH" = x86 ]; then 23 + echo 8.1.0 22 24 else 23 25 echo 5.1.0 24 26 fi 25 27 ;; 26 28 llvm) 27 - if [ "$SRCARCH" = s390 ]; then 29 + if [ "$SRCARCH" = s390 -o "$SRCARCH" = x86 ]; then 28 30 echo 15.0.0 29 31 elif [ "$SRCARCH" = loongarch ]; then 30 32 echo 18.0.0
+1 -1
tools/arch/x86/include/asm/required-features.h
··· 23 23 # define NEED_PAE 0 24 24 #endif 25 25 26 - #ifdef CONFIG_X86_CMPXCHG64 26 + #ifdef CONFIG_X86_CX8 27 27 # define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) 28 28 #else 29 29 # define NEED_CX8 0
+2
tools/objtool/noreturns.h
··· 16 16 NORETURN(__ubsan_handle_builtin_unreachable) 17 17 NORETURN(__x64_sys_exit) 18 18 NORETURN(__x64_sys_exit_group) 19 + NORETURN(acpi_processor_ffh_play_dead) 19 20 NORETURN(arch_cpu_idle_dead) 20 21 NORETURN(bch2_trans_in_restart_error) 21 22 NORETURN(bch2_trans_restart_error) ··· 35 34 NORETURN(machine_real_restart) 36 35 NORETURN(make_task_dead) 37 36 NORETURN(mpt_halt_firmware) 37 + NORETURN(mwait_play_dead) 38 38 NORETURN(nmi_panic_self_stop) 39 39 NORETURN(panic) 40 40 NORETURN(panic_smp_self_stop)
+1 -1
tools/power/x86/turbostat/turbostat.c
··· 1056 1056 * Missing support for 1057 1057 * INTEL_ICELAKE 1058 1058 * INTEL_ATOM_SILVERMONT_MID 1059 - * INTEL_ATOM_AIRMONT_MID 1059 + * INTEL_ATOM_SILVERMONT_MID2 1060 1060 * INTEL_ATOM_AIRMONT_NP 1061 1061 */ 1062 1062 { 0, NULL },
+139 -12
tools/testing/selftests/x86/lam.c
··· 4 4 #include <stdlib.h> 5 5 #include <string.h> 6 6 #include <sys/syscall.h> 7 + #include <sys/ioctl.h> 7 8 #include <time.h> 8 9 #include <signal.h> 9 10 #include <setjmp.h> ··· 44 43 #define FUNC_INHERITE 0x20 45 44 #define FUNC_PASID 0x40 46 45 46 + /* get_user() pointer test cases */ 47 + #define GET_USER_USER 0 48 + #define GET_USER_KERNEL_TOP 1 49 + #define GET_USER_KERNEL_BOT 2 50 + #define GET_USER_KERNEL 3 51 + 47 52 #define TEST_MASK 0x7f 53 + #define L5_SIGN_EXT_MASK (0xFFUL << 56) 54 + #define L4_SIGN_EXT_MASK (0x1FFFFUL << 47) 48 55 49 56 #define LOW_ADDR (0x1UL << 30) 50 57 #define HIGH_ADDR (0x3UL << 48) ··· 124 115 siglongjmp(segv_env, 1); 125 116 } 126 117 127 - static inline int cpu_has_lam(void) 118 + static inline int lam_is_available(void) 128 119 { 129 120 unsigned int cpuinfo[4]; 121 + unsigned long bits = 0; 122 + int ret; 130 123 131 124 __cpuid_count(0x7, 1, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]); 132 125 133 - return (cpuinfo[0] & (1 << 26)); 126 + /* Check if cpu supports LAM */ 127 + if (!(cpuinfo[0] & (1 << 26))) { 128 + ksft_print_msg("LAM is not supported!\n"); 129 + return 0; 130 + } 131 + 132 + /* Return 0 if CONFIG_ADDRESS_MASKING is not set */ 133 + ret = syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &bits); 134 + if (ret) { 135 + ksft_print_msg("LAM is disabled in the kernel!\n"); 136 + return 0; 137 + } 138 + 139 + return 1; 134 140 } 135 141 136 - /* Check 5-level page table feature in CPUID.(EAX=07H, ECX=00H):ECX.[bit 16] */ 137 - static inline int cpu_has_la57(void) 142 + static inline int la57_enabled(void) 138 143 { 139 - unsigned int cpuinfo[4]; 144 + int ret; 145 + void *p; 140 146 141 - __cpuid_count(0x7, 0, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]); 147 + p = mmap((void *)HIGH_ADDR, PAGE_SIZE, PROT_READ | PROT_WRITE, 148 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); 142 149 143 - return (cpuinfo[2] & (1 << 16)); 150 + ret = p == MAP_FAILED ? 0 : 1; 151 + 152 + munmap(p, PAGE_SIZE); 153 + return ret; 144 154 } 145 155 146 156 /* ··· 350 322 flags, -1, 0); 351 323 if (ptr == MAP_FAILED) { 352 324 if (test->addr == HIGH_ADDR) 353 - if (!cpu_has_la57()) 325 + if (!la57_enabled()) 354 326 return 3; /* unsupport LA57 */ 355 327 return 1; 356 328 } ··· 395 367 if (set_lam(test->lam) != -1 && ret == 0) 396 368 ret = 1; 397 369 370 + return ret; 371 + } 372 + 373 + static int get_user_syscall(struct testcases *test) 374 + { 375 + uint64_t ptr_address, bitmask; 376 + int fd, ret = 0; 377 + void *ptr; 378 + 379 + if (la57_enabled()) { 380 + bitmask = L5_SIGN_EXT_MASK; 381 + ptr_address = HIGH_ADDR; 382 + } else { 383 + bitmask = L4_SIGN_EXT_MASK; 384 + ptr_address = LOW_ADDR; 385 + } 386 + 387 + ptr = mmap((void *)ptr_address, PAGE_SIZE, PROT_READ | PROT_WRITE, 388 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); 389 + 390 + if (ptr == MAP_FAILED) { 391 + perror("failed to map byte to pass into get_user"); 392 + return 1; 393 + } 394 + 395 + if (set_lam(test->lam) != 0) { 396 + ret = 2; 397 + goto error; 398 + } 399 + 400 + fd = memfd_create("lam_ioctl", 0); 401 + if (fd == -1) { 402 + munmap(ptr, PAGE_SIZE); 403 + exit(EXIT_FAILURE); 404 + } 405 + 406 + switch (test->later) { 407 + case GET_USER_USER: 408 + /* Control group - properly tagged user pointer */ 409 + ptr = (void *)set_metadata((uint64_t)ptr, test->lam); 410 + break; 411 + case GET_USER_KERNEL_TOP: 412 + /* Kernel address with top bit cleared */ 413 + bitmask &= (bitmask >> 1); 414 + ptr = (void *)((uint64_t)ptr | bitmask); 415 + break; 416 + case GET_USER_KERNEL_BOT: 417 + /* Kernel address with bottom sign-extension bit cleared */ 418 + bitmask &= (bitmask << 1); 419 + ptr = (void *)((uint64_t)ptr | bitmask); 420 + break; 421 + case GET_USER_KERNEL: 422 + /* Try to pass a kernel address */ 423 + ptr = (void *)((uint64_t)ptr | bitmask); 424 + break; 425 + default: 426 + printf("Invalid test case value passed!\n"); 427 + break; 428 + } 429 + 430 + /* 431 + * Use FIOASYNC ioctl because it utilizes get_user() internally and is 432 + * very non-invasive to the system. Pass differently tagged pointers to 433 + * get_user() in order to verify that valid user pointers are going 434 + * through and invalid kernel/non-canonical pointers are not. 435 + */ 436 + if (ioctl(fd, FIOASYNC, ptr) != 0) 437 + ret = 1; 438 + 439 + close(fd); 440 + error: 441 + munmap(ptr, PAGE_SIZE); 398 442 return ret; 399 443 } 400 444 ··· 696 596 fi->file_fd = file_fd; 697 597 698 598 ring = malloc(sizeof(*ring)); 699 - if (!ring) 599 + if (!ring) { 600 + free(fi); 700 601 return 1; 602 + } 701 603 702 604 memset(ring, 0, sizeof(struct io_ring)); 703 605 ··· 984 882 .lam = LAM_U57_BITS, 985 883 .test_func = handle_syscall, 986 884 .msg = "SYSCALL:[Negative] Disable LAM. Dereferencing pointer with metadata.\n", 885 + }, 886 + { 887 + .later = GET_USER_USER, 888 + .lam = LAM_U57_BITS, 889 + .test_func = get_user_syscall, 890 + .msg = "GET_USER: get_user() and pass a properly tagged user pointer.\n", 891 + }, 892 + { 893 + .later = GET_USER_KERNEL_TOP, 894 + .expected = 1, 895 + .lam = LAM_U57_BITS, 896 + .test_func = get_user_syscall, 897 + .msg = "GET_USER:[Negative] get_user() with a kernel pointer and the top bit cleared.\n", 898 + }, 899 + { 900 + .later = GET_USER_KERNEL_BOT, 901 + .expected = 1, 902 + .lam = LAM_U57_BITS, 903 + .test_func = get_user_syscall, 904 + .msg = "GET_USER:[Negative] get_user() with a kernel pointer and the bottom sign-extension bit cleared.\n", 905 + }, 906 + { 907 + .later = GET_USER_KERNEL, 908 + .expected = 1, 909 + .lam = LAM_U57_BITS, 910 + .test_func = get_user_syscall, 911 + .msg = "GET_USER:[Negative] get_user() and pass a kernel pointer.\n", 987 912 }, 988 913 }; 989 914 ··· 1310 1181 1311 1182 tests_cnt = 0; 1312 1183 1313 - if (!cpu_has_lam()) { 1314 - ksft_print_msg("Unsupported LAM feature!\n"); 1184 + if (!lam_is_available()) 1315 1185 return KSFT_SKIP; 1316 - } 1317 1186 1318 1187 while ((c = getopt(argc, argv, "ht:")) != -1) { 1319 1188 switch (c) {