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

Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 updates from Will Deacon:
- Errata workarounds for Qualcomm's Falkor CPU
- Qualcomm L2 Cache PMU driver
- Qualcomm SMCCC firmware quirk
- Support for DEBUG_VIRTUAL
- CPU feature detection for userspace via MRS emulation
- Preliminary work for the Statistical Profiling Extension
- Misc cleanups and non-critical fixes

* tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (74 commits)
arm64/kprobes: consistently handle MRS/MSR with XZR
arm64: cpufeature: correctly handle MRS to XZR
arm64: traps: correctly handle MRS/MSR with XZR
arm64: ptrace: add XZR-safe regs accessors
arm64: include asm/assembler.h in entry-ftrace.S
arm64: fix warning about swapper_pg_dir overflow
arm64: Work around Falkor erratum 1003
arm64: head.S: Enable EL1 (host) access to SPE when entered at EL2
arm64: arch_timer: document Hisilicon erratum 161010101
arm64: use is_vmalloc_addr
arm64: use linux/sizes.h for constants
arm64: uaccess: consistently check object sizes
perf: add qcom l2 cache perf events driver
arm64: remove wrong CONFIG_PROC_SYSCTL ifdef
ARM: smccc: Update HVC comment to describe new quirk parameter
arm64: do not trace atomic operations
ACPI/IORT: Fix the error return code in iort_add_smmu_platform_device()
ACPI/IORT: Fix iort_node_get_id() mapping entries indexing
arm64: mm: enable CONFIG_HOLES_IN_ZONE for NUMA
perf: xgene: Include module.h
...

+2394 -437
+240
Documentation/arm64/cpu-feature-registers.txt
··· 1 + ARM64 CPU Feature Registers 2 + =========================== 3 + 4 + Author: Suzuki K Poulose <suzuki.poulose@arm.com> 5 + 6 + 7 + This file describes the ABI for exporting the AArch64 CPU ID/feature 8 + registers to userspace. The availability of this ABI is advertised 9 + via the HWCAP_CPUID in HWCAPs. 10 + 11 + 1. Motivation 12 + --------------- 13 + 14 + The ARM architecture defines a set of feature registers, which describe 15 + the capabilities of the CPU/system. Access to these system registers is 16 + restricted from EL0 and there is no reliable way for an application to 17 + extract this information to make better decisions at runtime. There is 18 + limited information available to the application via HWCAPs, however 19 + there are some issues with their usage. 20 + 21 + a) Any change to the HWCAPs requires an update to userspace (e.g libc) 22 + to detect the new changes, which can take a long time to appear in 23 + distributions. Exposing the registers allows applications to get the 24 + information without requiring updates to the toolchains. 25 + 26 + b) Access to HWCAPs is sometimes limited (e.g prior to libc, or 27 + when ld is initialised at startup time). 28 + 29 + c) HWCAPs cannot represent non-boolean information effectively. The 30 + architecture defines a canonical format for representing features 31 + in the ID registers; this is well defined and is capable of 32 + representing all valid architecture variations. 33 + 34 + 35 + 2. Requirements 36 + ----------------- 37 + 38 + a) Safety : 39 + Applications should be able to use the information provided by the 40 + infrastructure to run safely across the system. This has greater 41 + implications on a system with heterogeneous CPUs. 42 + The infrastructure exports a value that is safe across all the 43 + available CPU on the system. 44 + 45 + e.g, If at least one CPU doesn't implement CRC32 instructions, while 46 + others do, we should report that the CRC32 is not implemented. 47 + Otherwise an application could crash when scheduled on the CPU 48 + which doesn't support CRC32. 49 + 50 + b) Security : 51 + Applications should only be able to receive information that is 52 + relevant to the normal operation in userspace. Hence, some of the 53 + fields are masked out(i.e, made invisible) and their values are set to 54 + indicate the feature is 'not supported'. See Section 4 for the list 55 + of visible features. Also, the kernel may manipulate the fields 56 + based on what it supports. e.g, If FP is not supported by the 57 + kernel, the values could indicate that the FP is not available 58 + (even when the CPU provides it). 59 + 60 + c) Implementation Defined Features 61 + The infrastructure doesn't expose any register which is 62 + IMPLEMENTATION DEFINED as per ARMv8-A Architecture. 63 + 64 + d) CPU Identification : 65 + MIDR_EL1 is exposed to help identify the processor. On a 66 + heterogeneous system, this could be racy (just like getcpu()). The 67 + process could be migrated to another CPU by the time it uses the 68 + register value, unless the CPU affinity is set. Hence, there is no 69 + guarantee that the value reflects the processor that it is 70 + currently executing on. The REVIDR is not exposed due to this 71 + constraint, as REVIDR makes sense only in conjunction with the 72 + MIDR. Alternately, MIDR_EL1 and REVIDR_EL1 are exposed via sysfs 73 + at: 74 + 75 + /sys/devices/system/cpu/cpu$ID/regs/identification/ 76 + \- midr 77 + \- revidr 78 + 79 + 3. Implementation 80 + -------------------- 81 + 82 + The infrastructure is built on the emulation of the 'MRS' instruction. 83 + Accessing a restricted system register from an application generates an 84 + exception and ends up in SIGILL being delivered to the process. 85 + The infrastructure hooks into the exception handler and emulates the 86 + operation if the source belongs to the supported system register space. 87 + 88 + The infrastructure emulates only the following system register space: 89 + Op0=3, Op1=0, CRn=0, CRm=0,4,5,6,7 90 + 91 + (See Table C5-6 'System instruction encodings for non-Debug System 92 + register accesses' in ARMv8 ARM DDI 0487A.h, for the list of 93 + registers). 94 + 95 + The following rules are applied to the value returned by the 96 + infrastructure: 97 + 98 + a) The value of an 'IMPLEMENTATION DEFINED' field is set to 0. 99 + b) The value of a reserved field is populated with the reserved 100 + value as defined by the architecture. 101 + c) The value of a 'visible' field holds the system wide safe value 102 + for the particular feature (except for MIDR_EL1, see section 4). 103 + d) All other fields (i.e, invisible fields) are set to indicate 104 + the feature is missing (as defined by the architecture). 105 + 106 + 4. List of registers with visible features 107 + ------------------------------------------- 108 + 109 + 1) ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0 110 + x--------------------------------------------------x 111 + | Name | bits | visible | 112 + |--------------------------------------------------| 113 + | RES0 | [63-32] | n | 114 + |--------------------------------------------------| 115 + | RDM | [31-28] | y | 116 + |--------------------------------------------------| 117 + | ATOMICS | [23-20] | y | 118 + |--------------------------------------------------| 119 + | CRC32 | [19-16] | y | 120 + |--------------------------------------------------| 121 + | SHA2 | [15-12] | y | 122 + |--------------------------------------------------| 123 + | SHA1 | [11-8] | y | 124 + |--------------------------------------------------| 125 + | AES | [7-4] | y | 126 + |--------------------------------------------------| 127 + | RES0 | [3-0] | n | 128 + x--------------------------------------------------x 129 + 130 + 131 + 2) ID_AA64PFR0_EL1 - Processor Feature Register 0 132 + x--------------------------------------------------x 133 + | Name | bits | visible | 134 + |--------------------------------------------------| 135 + | RES0 | [63-28] | n | 136 + |--------------------------------------------------| 137 + | GIC | [27-24] | n | 138 + |--------------------------------------------------| 139 + | AdvSIMD | [23-20] | y | 140 + |--------------------------------------------------| 141 + | FP | [19-16] | y | 142 + |--------------------------------------------------| 143 + | EL3 | [15-12] | n | 144 + |--------------------------------------------------| 145 + | EL2 | [11-8] | n | 146 + |--------------------------------------------------| 147 + | EL1 | [7-4] | n | 148 + |--------------------------------------------------| 149 + | EL0 | [3-0] | n | 150 + x--------------------------------------------------x 151 + 152 + 153 + 3) MIDR_EL1 - Main ID Register 154 + x--------------------------------------------------x 155 + | Name | bits | visible | 156 + |--------------------------------------------------| 157 + | Implementer | [31-24] | y | 158 + |--------------------------------------------------| 159 + | Variant | [23-20] | y | 160 + |--------------------------------------------------| 161 + | Architecture | [19-16] | y | 162 + |--------------------------------------------------| 163 + | PartNum | [15-4] | y | 164 + |--------------------------------------------------| 165 + | Revision | [3-0] | y | 166 + x--------------------------------------------------x 167 + 168 + NOTE: The 'visible' fields of MIDR_EL1 will contain the value 169 + as available on the CPU where it is fetched and is not a system 170 + wide safe value. 171 + 172 + Appendix I: Example 173 + --------------------------- 174 + 175 + /* 176 + * Sample program to demonstrate the MRS emulation ABI. 177 + * 178 + * Copyright (C) 2015-2016, ARM Ltd 179 + * 180 + * Author: Suzuki K Poulose <suzuki.poulose@arm.com> 181 + * 182 + * This program is free software; you can redistribute it and/or modify 183 + * it under the terms of the GNU General Public License version 2 as 184 + * published by the Free Software Foundation. 185 + * 186 + * This program is distributed in the hope that it will be useful, 187 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 188 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 189 + * GNU General Public License for more details. 190 + * This program is free software; you can redistribute it and/or modify 191 + * it under the terms of the GNU General Public License version 2 as 192 + * published by the Free Software Foundation. 193 + * 194 + * This program is distributed in the hope that it will be useful, 195 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 196 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 197 + * GNU General Public License for more details. 198 + */ 199 + 200 + #include <asm/hwcap.h> 201 + #include <stdio.h> 202 + #include <sys/auxv.h> 203 + 204 + #define get_cpu_ftr(id) ({ \ 205 + unsigned long __val; \ 206 + asm("mrs %0, "#id : "=r" (__val)); \ 207 + printf("%-20s: 0x%016lx\n", #id, __val); \ 208 + }) 209 + 210 + int main(void) 211 + { 212 + 213 + if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { 214 + fputs("CPUID registers unavailable\n", stderr); 215 + return 1; 216 + } 217 + 218 + get_cpu_ftr(ID_AA64ISAR0_EL1); 219 + get_cpu_ftr(ID_AA64ISAR1_EL1); 220 + get_cpu_ftr(ID_AA64MMFR0_EL1); 221 + get_cpu_ftr(ID_AA64MMFR1_EL1); 222 + get_cpu_ftr(ID_AA64PFR0_EL1); 223 + get_cpu_ftr(ID_AA64PFR1_EL1); 224 + get_cpu_ftr(ID_AA64DFR0_EL1); 225 + get_cpu_ftr(ID_AA64DFR1_EL1); 226 + 227 + get_cpu_ftr(MIDR_EL1); 228 + get_cpu_ftr(MPIDR_EL1); 229 + get_cpu_ftr(REVIDR_EL1); 230 + 231 + #if 0 232 + /* Unexposed register access causes SIGILL */ 233 + get_cpu_ftr(ID_MMFR0_EL1); 234 + #endif 235 + 236 + return 0; 237 + } 238 + 239 + 240 +
+26 -21
Documentation/arm64/silicon-errata.txt
··· 42 42 will be updated when new workarounds are committed and backported to 43 43 stable kernels. 44 44 45 - | Implementor | Component | Erratum ID | Kconfig | 46 - +----------------+-----------------+-----------------+-------------------------+ 47 - | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | 48 - | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 | 49 - | ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 | 50 - | ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 | 51 - | ARM | Cortex-A53 | #845719 | ARM64_ERRATUM_845719 | 52 - | ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 | 53 - | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | 54 - | ARM | Cortex-A57 | #852523 | N/A | 55 - | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | 56 - | ARM | Cortex-A72 | #853709 | N/A | 57 - | ARM | MMU-500 | #841119,#826419 | N/A | 58 - | | | | | 59 - | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | 60 - | Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 | 61 - | Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 | 62 - | Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | 63 - | Cavium | ThunderX SMMUv2 | #27704 | N/A | 64 - | | | | | 65 - | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | 45 + | Implementor | Component | Erratum ID | Kconfig | 46 + +----------------+-----------------+-----------------+-----------------------------+ 47 + | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | 48 + | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 | 49 + | ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 | 50 + | ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 | 51 + | ARM | Cortex-A53 | #845719 | ARM64_ERRATUM_845719 | 52 + | ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 | 53 + | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | 54 + | ARM | Cortex-A57 | #852523 | N/A | 55 + | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | 56 + | ARM | Cortex-A72 | #853709 | N/A | 57 + | ARM | MMU-500 | #841119,#826419 | N/A | 58 + | | | | | 59 + | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | 60 + | Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 | 61 + | Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 | 62 + | Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | 63 + | Cavium | ThunderX SMMUv2 | #27704 | N/A | 64 + | | | | | 65 + | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | 66 + | | | | | 67 + | Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 | 68 + | | | | | 69 + | Qualcomm Tech. | Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | 70 + | Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
+38
Documentation/perf/qcom_l2_pmu.txt
··· 1 + Qualcomm Technologies Level-2 Cache Performance Monitoring Unit (PMU) 2 + ===================================================================== 3 + 4 + This driver supports the L2 cache clusters found in Qualcomm Technologies 5 + Centriq SoCs. There are multiple physical L2 cache clusters, each with their 6 + own PMU. Each cluster has one or more CPUs associated with it. 7 + 8 + There is one logical L2 PMU exposed, which aggregates the results from 9 + the physical PMUs. 10 + 11 + The driver provides a description of its available events and configuration 12 + options in sysfs, see /sys/devices/l2cache_0. 13 + 14 + The "format" directory describes the format of the events. 15 + 16 + Events can be envisioned as a 2-dimensional array. Each column represents 17 + a group of events. There are 8 groups. Only one entry from each 18 + group can be in use at a time. If multiple events from the same group 19 + are specified, the conflicting events cannot be counted at the same time. 20 + 21 + Events are specified as 0xCCG, where CC is 2 hex digits specifying 22 + the code (array row) and G specifies the group (column) 0-7. 23 + 24 + In addition there is a cycle counter event specified by the value 0xFE 25 + which is outside the above scheme. 26 + 27 + The driver provides a "cpumask" sysfs attribute which contains a mask 28 + consisting of one CPU per cluster which will be used to handle all the PMU 29 + events on that cluster. 30 + 31 + Examples for use with perf: 32 + 33 + perf stat -e l2cache_0/config=0x001/,l2cache_0/config=0x042/ -a sleep 1 34 + 35 + perf stat -e l2cache_0/config=0xfe/ -C 2 sleep 1 36 + 37 + The driver does not support sampling, therefore "perf record" will 38 + not work. Per-task perf sessions are not supported.
+2 -2
arch/arm/kernel/armksyms.c
··· 178 178 #endif 179 179 180 180 #ifdef CONFIG_HAVE_ARM_SMCCC 181 - EXPORT_SYMBOL(arm_smccc_smc); 182 - EXPORT_SYMBOL(arm_smccc_hvc); 181 + EXPORT_SYMBOL(__arm_smccc_smc); 182 + EXPORT_SYMBOL(__arm_smccc_hvc); 183 183 #endif
+1 -5
arch/arm/kernel/perf_event_v6.c
··· 581 581 .probe = armv6_pmu_device_probe, 582 582 }; 583 583 584 - static int __init register_armv6_pmu_driver(void) 585 - { 586 - return platform_driver_register(&armv6_pmu_driver); 587 - } 588 - device_initcall(register_armv6_pmu_driver); 584 + builtin_platform_driver(armv6_pmu_driver); 589 585 #endif /* CONFIG_CPU_V6 || CONFIG_CPU_V6K */
+1 -5
arch/arm/kernel/perf_event_v7.c
··· 2034 2034 .probe = armv7_pmu_device_probe, 2035 2035 }; 2036 2036 2037 - static int __init register_armv7_pmu_driver(void) 2038 - { 2039 - return platform_driver_register(&armv7_pmu_driver); 2040 - } 2041 - device_initcall(register_armv7_pmu_driver); 2037 + builtin_platform_driver(armv7_pmu_driver); 2042 2038 #endif /* CONFIG_CPU_V7 */
+1 -5
arch/arm/kernel/perf_event_xscale.c
··· 767 767 .probe = xscale_pmu_device_probe, 768 768 }; 769 769 770 - static int __init register_xscale_pmu_driver(void) 771 - { 772 - return platform_driver_register(&xscale_pmu_driver); 773 - } 774 - device_initcall(register_xscale_pmu_driver); 770 + builtin_platform_driver(xscale_pmu_driver); 775 771 #endif /* CONFIG_CPU_XSCALE */
+8 -6
arch/arm/kernel/smccc-call.S
··· 46 46 /* 47 47 * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, 48 48 * unsigned long a3, unsigned long a4, unsigned long a5, 49 - * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) 49 + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, 50 + * struct arm_smccc_quirk *quirk) 50 51 */ 51 - ENTRY(arm_smccc_smc) 52 + ENTRY(__arm_smccc_smc) 52 53 SMCCC SMCCC_SMC 53 - ENDPROC(arm_smccc_smc) 54 + ENDPROC(__arm_smccc_smc) 54 55 55 56 /* 56 57 * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, 57 58 * unsigned long a3, unsigned long a4, unsigned long a5, 58 - * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) 59 + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, 60 + * struct arm_smccc_quirk *quirk) 59 61 */ 60 - ENTRY(arm_smccc_hvc) 62 + ENTRY(__arm_smccc_hvc) 61 63 SMCCC SMCCC_HVC 62 - ENDPROC(arm_smccc_hvc) 64 + ENDPROC(__arm_smccc_hvc)
+34 -1
arch/arm64/Kconfig
··· 6 6 select ACPI_MCFG if ACPI 7 7 select ACPI_SPCR_TABLE if ACPI 8 8 select ARCH_CLOCKSOURCE_DATA 9 + select ARCH_HAS_DEBUG_VIRTUAL 9 10 select ARCH_HAS_DEVMEM_IS_ALLOWED 10 11 select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI 11 12 select ARCH_HAS_ELF_RANDOMIZE ··· 480 479 481 480 If unsure, say Y. 482 481 482 + config QCOM_FALKOR_ERRATUM_1003 483 + bool "Falkor E1003: Incorrect translation due to ASID change" 484 + default y 485 + select ARM64_PAN if ARM64_SW_TTBR0_PAN 486 + help 487 + On Falkor v1, an incorrect ASID may be cached in the TLB when ASID 488 + and BADDR are changed together in TTBRx_EL1. The workaround for this 489 + issue is to use a reserved ASID in cpu_do_switch_mm() before 490 + switching to the new ASID. Saying Y here selects ARM64_PAN if 491 + ARM64_SW_TTBR0_PAN is selected. This is done because implementing and 492 + maintaining the E1003 workaround in the software PAN emulation code 493 + would be an unnecessary complication. The affected Falkor v1 CPU 494 + implements ARMv8.1 hardware PAN support and using hardware PAN 495 + support versus software PAN emulation is mutually exclusive at 496 + runtime. 497 + 498 + If unsure, say Y. 499 + 500 + config QCOM_FALKOR_ERRATUM_1009 501 + bool "Falkor E1009: Prematurely complete a DSB after a TLBI" 502 + default y 503 + help 504 + On Falkor v1, the CPU may prematurely complete a DSB following a 505 + TLBI xxIS invalidate maintenance operation. Repeat the TLBI operation 506 + one more time to fix the issue. 507 + 508 + If unsure, say Y. 509 + 483 510 endmenu 484 511 485 512 ··· 640 611 depends on NUMA 641 612 642 613 config NEED_PER_CPU_EMBED_FIRST_CHUNK 614 + def_bool y 615 + depends on NUMA 616 + 617 + config HOLES_IN_ZONE 643 618 def_bool y 644 619 depends on NUMA 645 620 ··· 1043 1010 config COMPAT 1044 1011 bool "Kernel support for 32-bit EL0" 1045 1012 depends on ARM64_4K_PAGES || EXPERT 1046 - select COMPAT_BINFMT_ELF 1013 + select COMPAT_BINFMT_ELF if BINFMT_ELF 1047 1014 select HAVE_UID16 1048 1015 select OLD_SIGSUSPEND3 1049 1016 select COMPAT_OLD_SIGACTION
+8
arch/arm64/Kconfig.debug
··· 84 84 85 85 If in doubt, say N. 86 86 87 + config DEBUG_EFI 88 + depends on EFI && DEBUG_INFO 89 + bool "UEFI debugging" 90 + help 91 + Enable this option to include EFI specific debugging features into 92 + the kernel that are only useful when using a debug build of the 93 + UEFI firmware 94 + 87 95 source "drivers/hwtracing/coresight/Kconfig" 88 96 89 97 endmenu
+23
arch/arm64/include/asm/assembler.h
··· 25 25 26 26 #include <asm/asm-offsets.h> 27 27 #include <asm/cpufeature.h> 28 + #include <asm/mmu_context.h> 28 29 #include <asm/page.h> 29 30 #include <asm/pgtable-hwdef.h> 30 31 #include <asm/ptrace.h> ··· 439 438 */ 440 439 .macro get_thread_info, rd 441 440 mrs \rd, sp_el0 441 + .endm 442 + 443 + /* 444 + * Errata workaround prior to TTBR0_EL1 update 445 + * 446 + * val: TTBR value with new BADDR, preserved 447 + * tmp0: temporary register, clobbered 448 + * tmp1: other temporary register, clobbered 449 + */ 450 + .macro pre_ttbr0_update_workaround, val, tmp0, tmp1 451 + #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 452 + alternative_if ARM64_WORKAROUND_QCOM_FALKOR_E1003 453 + mrs \tmp0, ttbr0_el1 454 + mov \tmp1, #FALKOR_RESERVED_ASID 455 + bfi \tmp0, \tmp1, #48, #16 // reserved ASID + old BADDR 456 + msr ttbr0_el1, \tmp0 457 + isb 458 + bfi \tmp0, \val, #0, #48 // reserved ASID + new BADDR 459 + msr ttbr0_el1, \tmp0 460 + isb 461 + alternative_else_nop_endif 462 + #endif 442 463 .endm 443 464 444 465 /*
+3 -1
arch/arm64/include/asm/cpucaps.h
··· 35 35 #define ARM64_HYP_OFFSET_LOW 14 36 36 #define ARM64_MISMATCHED_CACHE_LINE_SIZE 15 37 37 #define ARM64_HAS_NO_FPSIMD 16 38 + #define ARM64_WORKAROUND_REPEAT_TLBI 17 39 + #define ARM64_WORKAROUND_QCOM_FALKOR_E1003 18 38 40 39 - #define ARM64_NCAPS 17 41 + #define ARM64_NCAPS 19 40 42 41 43 #endif /* __ASM_CPUCAPS_H */
+25 -1
arch/arm64/include/asm/cpufeature.h
··· 29 29 #include <linux/jump_label.h> 30 30 #include <linux/kernel.h> 31 31 32 - /* CPU feature register tracking */ 32 + /* 33 + * CPU feature register tracking 34 + * 35 + * The safe value of a CPUID feature field is dependent on the implications 36 + * of the values assigned to it by the architecture. Based on the relationship 37 + * between the values, the features are classified into 3 types - LOWER_SAFE, 38 + * HIGHER_SAFE and EXACT. 39 + * 40 + * The lowest value of all the CPUs is chosen for LOWER_SAFE and highest 41 + * for HIGHER_SAFE. It is expected that all CPUs have the same value for 42 + * a field when EXACT is specified, failing which, the safe value specified 43 + * in the table is chosen. 44 + */ 45 + 33 46 enum ftr_type { 34 47 FTR_EXACT, /* Use a predefined safe value */ 35 48 FTR_LOWER_SAFE, /* Smaller value is safe */ ··· 55 42 #define FTR_SIGNED true /* Value should be treated as signed */ 56 43 #define FTR_UNSIGNED false /* Value should be treated as unsigned */ 57 44 45 + #define FTR_VISIBLE true /* Feature visible to the user space */ 46 + #define FTR_HIDDEN false /* Feature is hidden from the user */ 47 + 58 48 struct arm64_ftr_bits { 59 49 bool sign; /* Value is signed ? */ 50 + bool visible; 60 51 bool strict; /* CPU Sanity check: strict matching required ? */ 61 52 enum ftr_type type; 62 53 u8 shift; ··· 76 59 struct arm64_ftr_reg { 77 60 const char *name; 78 61 u64 strict_mask; 62 + u64 user_mask; 79 63 u64 sys_val; 64 + u64 user_val; 80 65 const struct arm64_ftr_bits *ftr_bits; 81 66 }; 82 67 ··· 176 157 static inline u64 arm64_ftr_mask(const struct arm64_ftr_bits *ftrp) 177 158 { 178 159 return (u64)GENMASK(ftrp->shift + ftrp->width - 1, ftrp->shift); 160 + } 161 + 162 + static inline u64 arm64_ftr_reg_user_value(const struct arm64_ftr_reg *reg) 163 + { 164 + return (reg->user_val | (reg->sys_val & reg->user_mask)); 179 165 } 180 166 181 167 static inline int __attribute_const__
+7
arch/arm64/include/asm/cputype.h
··· 56 56 (0xf << MIDR_ARCHITECTURE_SHIFT) | \ 57 57 ((partnum) << MIDR_PARTNUM_SHIFT)) 58 58 59 + #define MIDR_CPU_VAR_REV(var, rev) \ 60 + (((var) << MIDR_VARIANT_SHIFT) | (rev)) 61 + 59 62 #define MIDR_CPU_MODEL_MASK (MIDR_IMPLEMENTOR_MASK | MIDR_PARTNUM_MASK | \ 60 63 MIDR_ARCHITECTURE_MASK) 61 64 ··· 74 71 #define ARM_CPU_IMP_APM 0x50 75 72 #define ARM_CPU_IMP_CAVIUM 0x43 76 73 #define ARM_CPU_IMP_BRCM 0x42 74 + #define ARM_CPU_IMP_QCOM 0x51 77 75 78 76 #define ARM_CPU_PART_AEM_V8 0xD0F 79 77 #define ARM_CPU_PART_FOUNDATION 0xD00 ··· 88 84 89 85 #define BRCM_CPU_PART_VULCAN 0x516 90 86 87 + #define QCOM_CPU_PART_FALKOR_V1 0x800 88 + 91 89 #define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53) 92 90 #define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57) 93 91 #define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX) 94 92 #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) 93 + #define MIDR_QCOM_FALKOR_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR_V1) 95 94 96 95 #ifndef __ASSEMBLY__ 97 96
+2
arch/arm64/include/asm/insn.h
··· 332 332 u64 aarch64_insn_decode_immediate(enum aarch64_insn_imm_type type, u32 insn); 333 333 u32 aarch64_insn_encode_immediate(enum aarch64_insn_imm_type type, 334 334 u32 insn, u64 imm); 335 + u32 aarch64_insn_decode_register(enum aarch64_insn_register_type type, 336 + u32 insn); 335 337 u32 aarch64_insn_gen_branch_imm(unsigned long pc, unsigned long addr, 336 338 enum aarch64_insn_branch_type type); 337 339 u32 aarch64_insn_gen_comp_branch_imm(unsigned long pc, unsigned long addr,
+3
arch/arm64/include/asm/kvm_arm.h
··· 188 188 #define CPTR_EL2_DEFAULT 0x000033ff 189 189 190 190 /* Hyp Debug Configuration Register bits */ 191 + #define MDCR_EL2_TPMS (1 << 14) 192 + #define MDCR_EL2_E2PB_MASK (UL(0x3)) 193 + #define MDCR_EL2_E2PB_SHIFT (UL(12)) 191 194 #define MDCR_EL2_TDRA (1 << 11) 192 195 #define MDCR_EL2_TDOSA (1 << 10) 193 196 #define MDCR_EL2_TDA (1 << 9)
+6 -1
arch/arm64/include/asm/kvm_host.h
··· 229 229 230 230 /* Pointer to host CPU context */ 231 231 kvm_cpu_context_t *host_cpu_context; 232 - struct kvm_guest_debug_arch host_debug_state; 232 + struct { 233 + /* {Break,watch}point registers */ 234 + struct kvm_guest_debug_arch regs; 235 + /* Statistical profiling extension */ 236 + u64 pmscr_el1; 237 + } host_debug_state; 233 238 234 239 /* VGIC state */ 235 240 struct vgic_cpu vgic_cpu;
+2 -2
arch/arm64/include/asm/kvm_mmu.h
··· 47 47 * If the page is in the bottom half, we have to use the top half. If 48 48 * the page is in the top half, we have to use the bottom half: 49 49 * 50 - * T = __virt_to_phys(__hyp_idmap_text_start) 50 + * T = __pa_symbol(__hyp_idmap_text_start) 51 51 * if (T & BIT(VA_BITS - 1)) 52 52 * HYP_VA_MIN = 0 //idmap in upper half 53 53 * else ··· 271 271 kvm_flush_dcache_to_poc(page_address(page), PUD_SIZE); 272 272 } 273 273 274 - #define kvm_virt_to_phys(x) __virt_to_phys((unsigned long)(x)) 274 + #define kvm_virt_to_phys(x) __pa_symbol(x) 275 275 276 276 void kvm_set_way_flush(struct kvm_vcpu *vcpu); 277 277 void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled);
+1 -1
arch/arm64/include/asm/lse.h
··· 19 19 __asm__(".arch_extension lse"); 20 20 21 21 /* Move the ll/sc atomics out-of-line */ 22 - #define __LL_SC_INLINE 22 + #define __LL_SC_INLINE notrace 23 23 #define __LL_SC_PREFIX(x) __ll_sc_##x 24 24 #define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x)) 25 25
+46 -20
arch/arm64/include/asm/memory.h
··· 102 102 #endif 103 103 104 104 /* 105 - * Physical vs virtual RAM address space conversion. These are 106 - * private definitions which should NOT be used outside memory.h 107 - * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. 108 - */ 109 - #define __virt_to_phys(x) ({ \ 110 - phys_addr_t __x = (phys_addr_t)(x); \ 111 - __x & BIT(VA_BITS - 1) ? (__x & ~PAGE_OFFSET) + PHYS_OFFSET : \ 112 - (__x - kimage_voffset); }) 113 - 114 - #define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET) 115 - #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) 116 - 117 - /* 118 - * Convert a page to/from a physical address 119 - */ 120 - #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) 121 - #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) 122 - 123 - /* 124 105 * Memory types available. 125 106 */ 126 107 #define MT_DEVICE_nGnRnE 0 ··· 168 187 #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) 169 188 170 189 /* 190 + * Physical vs virtual RAM address space conversion. These are 191 + * private definitions which should NOT be used outside memory.h 192 + * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. 193 + */ 194 + 195 + 196 + /* 197 + * The linear kernel range starts in the middle of the virtual adddress 198 + * space. Testing the top bit for the start of the region is a 199 + * sufficient check. 200 + */ 201 + #define __is_lm_address(addr) (!!((addr) & BIT(VA_BITS - 1))) 202 + 203 + #define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET) 204 + #define __kimg_to_phys(addr) ((addr) - kimage_voffset) 205 + 206 + #define __virt_to_phys_nodebug(x) ({ \ 207 + phys_addr_t __x = (phys_addr_t)(x); \ 208 + __is_lm_address(__x) ? __lm_to_phys(__x) : \ 209 + __kimg_to_phys(__x); \ 210 + }) 211 + 212 + #define __pa_symbol_nodebug(x) __kimg_to_phys((phys_addr_t)(x)) 213 + 214 + #ifdef CONFIG_DEBUG_VIRTUAL 215 + extern phys_addr_t __virt_to_phys(unsigned long x); 216 + extern phys_addr_t __phys_addr_symbol(unsigned long x); 217 + #else 218 + #define __virt_to_phys(x) __virt_to_phys_nodebug(x) 219 + #define __phys_addr_symbol(x) __pa_symbol_nodebug(x) 220 + #endif 221 + 222 + #define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET) 223 + #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) 224 + 225 + /* 226 + * Convert a page to/from a physical address 227 + */ 228 + #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) 229 + #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) 230 + 231 + /* 171 232 * Note: Drivers should NOT use these. They are the wrong 172 233 * translation for translating DMA addresses. Use the driver 173 234 * DMA support - see dma-mapping.h. ··· 230 207 * Drivers should NOT use these either. 231 208 */ 232 209 #define __pa(x) __virt_to_phys((unsigned long)(x)) 210 + #define __pa_symbol(x) __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0)) 211 + #define __pa_nodebug(x) __virt_to_phys_nodebug((unsigned long)(x)) 233 212 #define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) 234 213 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 235 - #define virt_to_pfn(x) __phys_to_pfn(__virt_to_phys(x)) 214 + #define virt_to_pfn(x) __phys_to_pfn(__virt_to_phys((unsigned long)(x))) 215 + #define sym_to_pfn(x) __phys_to_pfn(__pa_symbol(x)) 236 216 237 217 /* 238 218 * virt_to_page(k) convert a _valid_ virtual address to struct page *
+10 -4
arch/arm64/include/asm/mmu_context.h
··· 19 19 #ifndef __ASM_MMU_CONTEXT_H 20 20 #define __ASM_MMU_CONTEXT_H 21 21 22 + #define FALKOR_RESERVED_ASID 1 23 + 24 + #ifndef __ASSEMBLY__ 25 + 22 26 #include <linux/compiler.h> 23 27 #include <linux/sched.h> 24 28 ··· 49 45 */ 50 46 static inline void cpu_set_reserved_ttbr0(void) 51 47 { 52 - unsigned long ttbr = virt_to_phys(empty_zero_page); 48 + unsigned long ttbr = __pa_symbol(empty_zero_page); 53 49 54 50 write_sysreg(ttbr, ttbr0_el1); 55 51 isb(); ··· 118 114 local_flush_tlb_all(); 119 115 cpu_set_idmap_tcr_t0sz(); 120 116 121 - cpu_switch_mm(idmap_pg_dir, &init_mm); 117 + cpu_switch_mm(lm_alias(idmap_pg_dir), &init_mm); 122 118 } 123 119 124 120 /* ··· 133 129 134 130 phys_addr_t pgd_phys = virt_to_phys(pgd); 135 131 136 - replace_phys = (void *)virt_to_phys(idmap_cpu_replace_ttbr1); 132 + replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); 137 133 138 134 cpu_install_idmap(); 139 135 replace_phys(pgd_phys); ··· 224 220 225 221 void verify_cpu_asid_bits(void); 226 222 227 - #endif 223 + #endif /* !__ASSEMBLY__ */ 224 + 225 + #endif /* !__ASM_MMU_CONTEXT_H */
+10 -7
arch/arm64/include/asm/pgtable.h
··· 52 52 * for zero-mapped memory areas etc.. 53 53 */ 54 54 extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; 55 - #define ZERO_PAGE(vaddr) pfn_to_page(PHYS_PFN(__pa(empty_zero_page))) 55 + #define ZERO_PAGE(vaddr) phys_to_page(__pa_symbol(empty_zero_page)) 56 56 57 57 #define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte)) 58 58 ··· 71 71 #define pte_young(pte) (!!(pte_val(pte) & PTE_AF)) 72 72 #define pte_special(pte) (!!(pte_val(pte) & PTE_SPECIAL)) 73 73 #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) 74 - #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) 74 + #define pte_user_exec(pte) (!(pte_val(pte) & PTE_UXN)) 75 75 #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) 76 - #define pte_ng(pte) (!!(pte_val(pte) & PTE_NG)) 77 76 78 77 #ifdef CONFIG_ARM64_HW_AFDBM 79 78 #define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) ··· 83 84 #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte)) 84 85 85 86 #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) 86 - #define pte_valid_global(pte) \ 87 - ((pte_val(pte) & (PTE_VALID | PTE_NG)) == PTE_VALID) 87 + /* 88 + * Execute-only user mappings do not have the PTE_USER bit set. All valid 89 + * kernel mappings have the PTE_UXN bit set. 90 + */ 91 + #define pte_valid_not_user(pte) \ 92 + ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == (PTE_VALID | PTE_UXN)) 88 93 #define pte_valid_young(pte) \ 89 94 ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF)) 90 95 ··· 181 178 * Only if the new pte is valid and kernel, otherwise TLB maintenance 182 179 * or update_mmu_cache() have the necessary barriers. 183 180 */ 184 - if (pte_valid_global(pte)) { 181 + if (pte_valid_not_user(pte)) { 185 182 dsb(ishst); 186 183 isb(); 187 184 } ··· 215 212 pte_val(pte) &= ~PTE_RDONLY; 216 213 else 217 214 pte_val(pte) |= PTE_RDONLY; 218 - if (pte_ng(pte) && pte_exec(pte) && !pte_special(pte)) 215 + if (pte_user_exec(pte) && !pte_special(pte)) 219 216 __sync_icache_dcache(pte, addr); 220 217 } 221 218
-1
arch/arm64/include/asm/processor.h
··· 187 187 #endif 188 188 189 189 int cpu_enable_pan(void *__unused); 190 - int cpu_enable_uao(void *__unused); 191 190 int cpu_enable_cache_maint_trap(void *__unused); 192 191 193 192 #endif /* __ASM_PROCESSOR_H */
+20
arch/arm64/include/asm/ptrace.h
··· 194 194 return val; 195 195 } 196 196 197 + /* 198 + * Read a register given an architectural register index r. 199 + * This handles the common case where 31 means XZR, not SP. 200 + */ 201 + static inline unsigned long pt_regs_read_reg(const struct pt_regs *regs, int r) 202 + { 203 + return (r == 31) ? 0 : regs->regs[r]; 204 + } 205 + 206 + /* 207 + * Write a register given an architectural register index r. 208 + * This handles the common case where 31 means XZR, not SP. 209 + */ 210 + static inline void pt_regs_write_reg(struct pt_regs *regs, int r, 211 + unsigned long val) 212 + { 213 + if (r != 31) 214 + regs->regs[r] = val; 215 + } 216 + 197 217 /* Valid only for Kernel mode traps. */ 198 218 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) 199 219 {
+25 -1
arch/arm64/include/asm/sysreg.h
··· 32 32 * [11-8] : CRm 33 33 * [7-5] : Op2 34 34 */ 35 + #define Op0_shift 19 36 + #define Op0_mask 0x3 37 + #define Op1_shift 16 38 + #define Op1_mask 0x7 39 + #define CRn_shift 12 40 + #define CRn_mask 0xf 41 + #define CRm_shift 8 42 + #define CRm_mask 0xf 43 + #define Op2_shift 5 44 + #define Op2_mask 0x7 45 + 35 46 #define sys_reg(op0, op1, crn, crm, op2) \ 36 - ((((op0)&3)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5)) 47 + (((op0) << Op0_shift) | ((op1) << Op1_shift) | \ 48 + ((crn) << CRn_shift) | ((crm) << CRm_shift) | \ 49 + ((op2) << Op2_shift)) 50 + 51 + #define sys_reg_Op0(id) (((id) >> Op0_shift) & Op0_mask) 52 + #define sys_reg_Op1(id) (((id) >> Op1_shift) & Op1_mask) 53 + #define sys_reg_CRn(id) (((id) >> CRn_shift) & CRn_mask) 54 + #define sys_reg_CRm(id) (((id) >> CRm_shift) & CRm_mask) 55 + #define sys_reg_Op2(id) (((id) >> Op2_shift) & Op2_mask) 37 56 38 57 #ifndef CONFIG_BROKEN_GAS_INST 39 58 ··· 209 190 #define ID_AA64MMFR2_CNP_SHIFT 0 210 191 211 192 /* id_aa64dfr0 */ 193 + #define ID_AA64DFR0_PMSVER_SHIFT 32 212 194 #define ID_AA64DFR0_CTX_CMPS_SHIFT 28 213 195 #define ID_AA64DFR0_WRPS_SHIFT 20 214 196 #define ID_AA64DFR0_BRPS_SHIFT 12 ··· 264 244 #define ID_AA64MMFR0_TGRAN_SHIFT ID_AA64MMFR0_TGRAN64_SHIFT 265 245 #define ID_AA64MMFR0_TGRAN_SUPPORTED ID_AA64MMFR0_TGRAN64_SUPPORTED 266 246 #endif 247 + 248 + 249 + /* Safe value for MPIDR_EL1: Bit31:RES1, Bit30:U:0, Bit24:MT:0 */ 250 + #define SYS_MPIDR_SAFE_VAL (1UL << 31) 267 251 268 252 #ifdef __ASSEMBLY__ 269 253
+15 -3
arch/arm64/include/asm/tlbflush.h
··· 36 36 * not. The macros handles invoking the asm with or without the 37 37 * register argument as appropriate. 38 38 */ 39 - #define __TLBI_0(op, arg) asm ("tlbi " #op) 40 - #define __TLBI_1(op, arg) asm ("tlbi " #op ", %0" : : "r" (arg)) 41 - #define __TLBI_N(op, arg, n, ...) __TLBI_##n(op, arg) 39 + #define __TLBI_0(op, arg) asm ("tlbi " #op "\n" \ 40 + ALTERNATIVE("nop\n nop", \ 41 + "dsb ish\n tlbi " #op, \ 42 + ARM64_WORKAROUND_REPEAT_TLBI, \ 43 + CONFIG_QCOM_FALKOR_ERRATUM_1009) \ 44 + : : ) 45 + 46 + #define __TLBI_1(op, arg) asm ("tlbi " #op ", %0\n" \ 47 + ALTERNATIVE("nop\n nop", \ 48 + "dsb ish\n tlbi " #op ", %0", \ 49 + ARM64_WORKAROUND_REPEAT_TLBI, \ 50 + CONFIG_QCOM_FALKOR_ERRATUM_1009) \ 51 + : : "r" (arg)) 52 + 53 + #define __TLBI_N(op, arg, n, ...) __TLBI_##n(op, arg) 42 54 43 55 #define __tlbi(op, ...) __TLBI_N(op, ##__VA_ARGS__, 1, 0) 44 56
+2 -2
arch/arm64/include/asm/uaccess.h
··· 379 379 { 380 380 unsigned long res = n; 381 381 kasan_check_write(to, n); 382 + check_object_size(to, n, false); 382 383 383 384 if (access_ok(VERIFY_READ, from, n)) { 384 - check_object_size(to, n, false); 385 385 res = __arch_copy_from_user(to, from, n); 386 386 } 387 387 if (unlikely(res)) ··· 392 392 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n) 393 393 { 394 394 kasan_check_read(from, n); 395 + check_object_size(from, n, true); 395 396 396 397 if (access_ok(VERIFY_WRITE, to, n)) { 397 - check_object_size(from, n, true); 398 398 n = __arch_copy_to_user(to, from, n); 399 399 } 400 400 return n;
+2
arch/arm64/include/uapi/asm/hwcap.h
··· 30 30 #define HWCAP_ATOMICS (1 << 8) 31 31 #define HWCAP_FPHP (1 << 9) 32 32 #define HWCAP_ASIMDHP (1 << 10) 33 + #define HWCAP_CPUID (1 << 11) 34 + #define HWCAP_ASIMDRDM (1 << 12) 33 35 34 36 #endif /* _UAPI__ASM_HWCAP_H */
+4
arch/arm64/kernel/Makefile
··· 55 55 obj-m += $(arm64-obj-m) 56 56 head-y := head.o 57 57 extra-y += $(head-y) vmlinux.lds 58 + 59 + ifeq ($(CONFIG_DEBUG_EFI),y) 60 + AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" 61 + endif
+2 -1
arch/arm64/kernel/acpi_parking_protocol.c
··· 17 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 #include <linux/acpi.h> 20 + #include <linux/mm.h> 20 21 #include <linux/types.h> 21 22 22 23 #include <asm/cpu_ops.h> ··· 110 109 * that read this address need to convert this address to the 111 110 * Boot-Loader's endianness before jumping. 112 111 */ 113 - writeq_relaxed(__pa(secondary_entry), &mailbox->entry_point); 112 + writeq_relaxed(__pa_symbol(secondary_entry), &mailbox->entry_point); 114 113 writel_relaxed(cpu_entry->gic_cpu_id, &mailbox->cpu_id); 115 114 116 115 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+2 -2
arch/arm64/kernel/arm64ksyms.c
··· 73 73 #endif 74 74 75 75 /* arm-smccc */ 76 - EXPORT_SYMBOL(arm_smccc_smc); 77 - EXPORT_SYMBOL(arm_smccc_hvc); 76 + EXPORT_SYMBOL(__arm_smccc_smc); 77 + EXPORT_SYMBOL(__arm_smccc_hvc);
+1 -1
arch/arm64/kernel/armv8_deprecated.c
··· 636 636 if(system_supports_mixed_endian_el0()) 637 637 register_insn_emulation(&setend_ops); 638 638 else 639 - pr_info("setend instruction emulation is not supported on the system"); 639 + pr_info("setend instruction emulation is not supported on this system\n"); 640 640 } 641 641 642 642 cpuhp_setup_state_nocalls(CPUHP_AP_ARM64_ISNDEP_STARTING,
+5 -2
arch/arm64/kernel/asm-offsets.c
··· 143 143 DEFINE(SLEEP_STACK_DATA_SYSTEM_REGS, offsetof(struct sleep_stack_data, system_regs)); 144 144 DEFINE(SLEEP_STACK_DATA_CALLEE_REGS, offsetof(struct sleep_stack_data, callee_saved_regs)); 145 145 #endif 146 - DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0)); 147 - DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2)); 146 + DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0)); 147 + DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2)); 148 + DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id)); 149 + DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state)); 150 + 148 151 BLANK(); 149 152 DEFINE(HIBERN_PBE_ORIG, offsetof(struct pbe, orig_address)); 150 153 DEFINE(HIBERN_PBE_ADDR, offsetof(struct pbe, address));
+12 -1
arch/arm64/kernel/cacheinfo.c
··· 84 84 85 85 static int __init_cache_level(unsigned int cpu) 86 86 { 87 - unsigned int ctype, level, leaves; 87 + unsigned int ctype, level, leaves, of_level; 88 88 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); 89 89 90 90 for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) { ··· 95 95 } 96 96 /* Separate instruction and data caches */ 97 97 leaves += (ctype == CACHE_TYPE_SEPARATE) ? 2 : 1; 98 + } 99 + 100 + of_level = of_find_last_cache_level(cpu); 101 + if (level < of_level) { 102 + /* 103 + * some external caches not specified in CLIDR_EL1 104 + * the information may be available in the device tree 105 + * only unified external caches are considered here 106 + */ 107 + leaves += (of_level - level); 108 + level = of_level; 98 109 } 99 110 100 111 this_cpu_ci->num_levels = level;
+1 -1
arch/arm64/kernel/cpu-reset.h
··· 24 24 25 25 el2_switch = el2_switch && !is_kernel_in_hyp_mode() && 26 26 is_hyp_mode_available(); 27 - restart = (void *)virt_to_phys(__cpu_soft_restart); 27 + restart = (void *)__pa_symbol(__cpu_soft_restart); 28 28 29 29 cpu_install_idmap(); 30 30 restart(el2_switch, entry, arg0, arg1, arg2);
+27 -6
arch/arm64/kernel/cpu_errata.c
··· 79 79 /* Cortex-A57 r0p0 - r1p2 */ 80 80 .desc = "ARM erratum 832075", 81 81 .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE, 82 - MIDR_RANGE(MIDR_CORTEX_A57, 0x00, 83 - (1 << MIDR_VARIANT_SHIFT) | 2), 82 + MIDR_RANGE(MIDR_CORTEX_A57, 83 + MIDR_CPU_VAR_REV(0, 0), 84 + MIDR_CPU_VAR_REV(1, 2)), 84 85 }, 85 86 #endif 86 87 #ifdef CONFIG_ARM64_ERRATUM_834220 ··· 89 88 /* Cortex-A57 r0p0 - r1p2 */ 90 89 .desc = "ARM erratum 834220", 91 90 .capability = ARM64_WORKAROUND_834220, 92 - MIDR_RANGE(MIDR_CORTEX_A57, 0x00, 93 - (1 << MIDR_VARIANT_SHIFT) | 2), 91 + MIDR_RANGE(MIDR_CORTEX_A57, 92 + MIDR_CPU_VAR_REV(0, 0), 93 + MIDR_CPU_VAR_REV(1, 2)), 94 94 }, 95 95 #endif 96 96 #ifdef CONFIG_ARM64_ERRATUM_845719 ··· 115 113 /* Cavium ThunderX, T88 pass 1.x - 2.1 */ 116 114 .desc = "Cavium erratum 27456", 117 115 .capability = ARM64_WORKAROUND_CAVIUM_27456, 118 - MIDR_RANGE(MIDR_THUNDERX, 0x00, 119 - (1 << MIDR_VARIANT_SHIFT) | 1), 116 + MIDR_RANGE(MIDR_THUNDERX, 117 + MIDR_CPU_VAR_REV(0, 0), 118 + MIDR_CPU_VAR_REV(1, 1)), 120 119 }, 121 120 { 122 121 /* Cavium ThunderX, T81 pass 1.0 */ ··· 133 130 .def_scope = SCOPE_LOCAL_CPU, 134 131 .enable = cpu_enable_trap_ctr_access, 135 132 }, 133 + #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 134 + { 135 + .desc = "Qualcomm Technologies Falkor erratum 1003", 136 + .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003, 137 + MIDR_RANGE(MIDR_QCOM_FALKOR_V1, 138 + MIDR_CPU_VAR_REV(0, 0), 139 + MIDR_CPU_VAR_REV(0, 0)), 140 + }, 141 + #endif 142 + #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009 143 + { 144 + .desc = "Qualcomm Technologies Falkor erratum 1009", 145 + .capability = ARM64_WORKAROUND_REPEAT_TLBI, 146 + MIDR_RANGE(MIDR_QCOM_FALKOR_V1, 147 + MIDR_CPU_VAR_REV(0, 0), 148 + MIDR_CPU_VAR_REV(0, 0)), 149 + }, 150 + #endif 136 151 { 137 152 } 138 153 };
+269 -153
arch/arm64/kernel/cpufeature.c
··· 23 23 #include <linux/sort.h> 24 24 #include <linux/stop_machine.h> 25 25 #include <linux/types.h> 26 + #include <linux/mm.h> 26 27 #include <asm/cpu.h> 27 28 #include <asm/cpufeature.h> 28 29 #include <asm/cpu_ops.h> 29 30 #include <asm/mmu_context.h> 30 31 #include <asm/processor.h> 31 32 #include <asm/sysreg.h> 33 + #include <asm/traps.h> 32 34 #include <asm/virt.h> 33 35 34 36 unsigned long elf_hwcap __read_mostly; ··· 54 52 DEFINE_STATIC_KEY_ARRAY_FALSE(cpu_hwcap_keys, ARM64_NCAPS); 55 53 EXPORT_SYMBOL(cpu_hwcap_keys); 56 54 57 - #define __ARM64_FTR_BITS(SIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 55 + #define __ARM64_FTR_BITS(SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 58 56 { \ 59 57 .sign = SIGNED, \ 58 + .visible = VISIBLE, \ 60 59 .strict = STRICT, \ 61 60 .type = TYPE, \ 62 61 .shift = SHIFT, \ ··· 66 63 } 67 64 68 65 /* Define a feature with unsigned values */ 69 - #define ARM64_FTR_BITS(STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 70 - __ARM64_FTR_BITS(FTR_UNSIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) 66 + #define ARM64_FTR_BITS(VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 67 + __ARM64_FTR_BITS(FTR_UNSIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) 71 68 72 69 /* Define a feature with a signed value */ 73 - #define S_ARM64_FTR_BITS(STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 74 - __ARM64_FTR_BITS(FTR_SIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) 70 + #define S_ARM64_FTR_BITS(VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ 71 + __ARM64_FTR_BITS(FTR_SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) 75 72 76 73 #define ARM64_FTR_END \ 77 74 { \ ··· 83 80 cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused); 84 81 85 82 83 + /* 84 + * NOTE: Any changes to the visibility of features should be kept in 85 + * sync with the documentation of the CPU feature register ABI. 86 + */ 86 87 static const struct arm64_ftr_bits ftr_id_aa64isar0[] = { 87 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0), 88 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64ISAR0_RDM_SHIFT, 4, 0), 89 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 24, 4, 0), 90 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_ATOMICS_SHIFT, 4, 0), 91 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_CRC32_SHIFT, 4, 0), 92 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_SHA2_SHIFT, 4, 0), 93 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_SHA1_SHIFT, 4, 0), 94 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_AES_SHIFT, 4, 0), 95 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 4, 0), /* RAZ */ 88 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64ISAR0_RDM_SHIFT, 4, 0), 89 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_ATOMICS_SHIFT, 4, 0), 90 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_CRC32_SHIFT, 4, 0), 91 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_SHA2_SHIFT, 4, 0), 92 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_SHA1_SHIFT, 4, 0), 93 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64ISAR0_AES_SHIFT, 4, 0), 96 94 ARM64_FTR_END, 97 95 }; 98 96 99 97 static const struct arm64_ftr_bits ftr_id_aa64pfr0[] = { 100 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0), 101 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 28, 4, 0), 102 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64PFR0_GIC_SHIFT, 4, 0), 103 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_ASIMD_SHIFT, 4, ID_AA64PFR0_ASIMD_NI), 104 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_FP_SHIFT, 4, ID_AA64PFR0_FP_NI), 98 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64PFR0_GIC_SHIFT, 4, 0), 99 + S_ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_ASIMD_SHIFT, 4, ID_AA64PFR0_ASIMD_NI), 100 + S_ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_FP_SHIFT, 4, ID_AA64PFR0_FP_NI), 105 101 /* Linux doesn't care about the EL3 */ 106 - ARM64_FTR_BITS(FTR_NONSTRICT, FTR_EXACT, ID_AA64PFR0_EL3_SHIFT, 4, 0), 107 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL2_SHIFT, 4, 0), 108 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL1_SHIFT, 4, ID_AA64PFR0_EL1_64BIT_ONLY), 109 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL0_SHIFT, 4, ID_AA64PFR0_EL0_64BIT_ONLY), 102 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64PFR0_EL3_SHIFT, 4, 0), 103 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL2_SHIFT, 4, 0), 104 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL1_SHIFT, 4, ID_AA64PFR0_EL1_64BIT_ONLY), 105 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64PFR0_EL0_SHIFT, 4, ID_AA64PFR0_EL0_64BIT_ONLY), 110 106 ARM64_FTR_END, 111 107 }; 112 108 113 109 static const struct arm64_ftr_bits ftr_id_aa64mmfr0[] = { 114 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0), 115 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN4_SHIFT, 4, ID_AA64MMFR0_TGRAN4_NI), 116 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN64_SHIFT, 4, ID_AA64MMFR0_TGRAN64_NI), 117 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN16_SHIFT, 4, ID_AA64MMFR0_TGRAN16_NI), 118 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_BIGENDEL0_SHIFT, 4, 0), 110 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN4_SHIFT, 4, ID_AA64MMFR0_TGRAN4_NI), 111 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN64_SHIFT, 4, ID_AA64MMFR0_TGRAN64_NI), 112 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_TGRAN16_SHIFT, 4, ID_AA64MMFR0_TGRAN16_NI), 113 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_BIGENDEL0_SHIFT, 4, 0), 119 114 /* Linux shouldn't care about secure memory */ 120 - ARM64_FTR_BITS(FTR_NONSTRICT, FTR_EXACT, ID_AA64MMFR0_SNSMEM_SHIFT, 4, 0), 121 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_BIGENDEL_SHIFT, 4, 0), 122 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_ASID_SHIFT, 4, 0), 115 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64MMFR0_SNSMEM_SHIFT, 4, 0), 116 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_BIGENDEL_SHIFT, 4, 0), 117 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR0_ASID_SHIFT, 4, 0), 123 118 /* 124 119 * Differing PARange is fine as long as all peripherals and memory are mapped 125 120 * within the minimum PARange of all CPUs 126 121 */ 127 - ARM64_FTR_BITS(FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR0_PARANGE_SHIFT, 4, 0), 122 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR0_PARANGE_SHIFT, 4, 0), 128 123 ARM64_FTR_END, 129 124 }; 130 125 131 126 static const struct arm64_ftr_bits ftr_id_aa64mmfr1[] = { 132 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0), 133 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_PAN_SHIFT, 4, 0), 134 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_LOR_SHIFT, 4, 0), 135 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_HPD_SHIFT, 4, 0), 136 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_VHE_SHIFT, 4, 0), 137 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_VMIDBITS_SHIFT, 4, 0), 138 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_HADBS_SHIFT, 4, 0), 127 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_PAN_SHIFT, 4, 0), 128 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_LOR_SHIFT, 4, 0), 129 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_HPD_SHIFT, 4, 0), 130 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_VHE_SHIFT, 4, 0), 131 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_VMIDBITS_SHIFT, 4, 0), 132 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR1_HADBS_SHIFT, 4, 0), 139 133 ARM64_FTR_END, 140 134 }; 141 135 142 136 static const struct arm64_ftr_bits ftr_id_aa64mmfr2[] = { 143 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_LVA_SHIFT, 4, 0), 144 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_IESB_SHIFT, 4, 0), 145 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_LSM_SHIFT, 4, 0), 146 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_UAO_SHIFT, 4, 0), 147 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_CNP_SHIFT, 4, 0), 137 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_LVA_SHIFT, 4, 0), 138 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_IESB_SHIFT, 4, 0), 139 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_LSM_SHIFT, 4, 0), 140 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_UAO_SHIFT, 4, 0), 141 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64MMFR2_CNP_SHIFT, 4, 0), 148 142 ARM64_FTR_END, 149 143 }; 150 144 151 145 static const struct arm64_ftr_bits ftr_ctr[] = { 152 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */ 153 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 28, 3, 0), 154 - ARM64_FTR_BITS(FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */ 155 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */ 156 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */ 146 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */ 147 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */ 148 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */ 149 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */ 157 150 /* 158 151 * Linux can handle differing I-cache policies. Userspace JITs will 159 152 * make use of *minLine. 160 153 * If we have differing I-cache policies, report it as the weakest - AIVIVT. 161 154 */ 162 - ARM64_FTR_BITS(FTR_NONSTRICT, FTR_EXACT, 14, 2, ICACHE_POLICY_AIVIVT), /* L1Ip */ 163 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 10, 0), /* RAZ */ 164 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* IminLine */ 155 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_EXACT, 14, 2, ICACHE_POLICY_AIVIVT), /* L1Ip */ 156 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* IminLine */ 165 157 ARM64_FTR_END, 166 158 }; 167 159 ··· 166 168 }; 167 169 168 170 static const struct arm64_ftr_bits ftr_id_mmfr0[] = { 169 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 28, 4, 0xf), /* InnerShr */ 170 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 24, 4, 0), /* FCSE */ 171 - ARM64_FTR_BITS(FTR_NONSTRICT, FTR_LOWER_SAFE, 20, 4, 0), /* AuxReg */ 172 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 16, 4, 0), /* TCM */ 173 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 12, 4, 0), /* ShareLvl */ 174 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 8, 4, 0xf), /* OuterShr */ 175 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 4, 0), /* PMSA */ 176 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 4, 0), /* VMSA */ 171 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 28, 4, 0xf), /* InnerShr */ 172 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 24, 4, 0), /* FCSE */ 173 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, 20, 4, 0), /* AuxReg */ 174 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 16, 4, 0), /* TCM */ 175 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 12, 4, 0), /* ShareLvl */ 176 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 8, 4, 0xf), /* OuterShr */ 177 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 4, 4, 0), /* PMSA */ 178 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 0, 4, 0), /* VMSA */ 177 179 ARM64_FTR_END, 178 180 }; 179 181 180 182 static const struct arm64_ftr_bits ftr_id_aa64dfr0[] = { 181 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0), 182 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_CTX_CMPS_SHIFT, 4, 0), 183 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_WRPS_SHIFT, 4, 0), 184 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_BRPS_SHIFT, 4, 0), 185 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_PMUVER_SHIFT, 4, 0), 186 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_TRACEVER_SHIFT, 4, 0), 187 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_DEBUGVER_SHIFT, 4, 0x6), 183 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 36, 28, 0), 184 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64DFR0_PMSVER_SHIFT, 4, 0), 185 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_CTX_CMPS_SHIFT, 4, 0), 186 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_WRPS_SHIFT, 4, 0), 187 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_BRPS_SHIFT, 4, 0), 188 + /* 189 + * We can instantiate multiple PMU instances with different levels 190 + * of support. 191 + */ 192 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64DFR0_PMUVER_SHIFT, 4, 0), 193 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64DFR0_TRACEVER_SHIFT, 4, 0), 194 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64DFR0_DEBUGVER_SHIFT, 4, 0x6), 188 195 ARM64_FTR_END, 189 196 }; 190 197 191 198 static const struct arm64_ftr_bits ftr_mvfr2[] = { 192 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 8, 24, 0), /* RAZ */ 193 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 4, 0), /* FPMisc */ 194 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 4, 0), /* SIMDMisc */ 199 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 4, 4, 0), /* FPMisc */ 200 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 0, 4, 0), /* SIMDMisc */ 195 201 ARM64_FTR_END, 196 202 }; 197 203 198 204 static const struct arm64_ftr_bits ftr_dczid[] = { 199 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 5, 27, 0), /* RAZ */ 200 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 1, 1), /* DZP */ 201 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* BS */ 205 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 4, 1, 1), /* DZP */ 206 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* BS */ 202 207 ARM64_FTR_END, 203 208 }; 204 209 205 210 206 211 static const struct arm64_ftr_bits ftr_id_isar5[] = { 207 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_RDM_SHIFT, 4, 0), 208 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 20, 4, 0), /* RAZ */ 209 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_CRC32_SHIFT, 4, 0), 210 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_SHA2_SHIFT, 4, 0), 211 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_SHA1_SHIFT, 4, 0), 212 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_AES_SHIFT, 4, 0), 213 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_ISAR5_SEVL_SHIFT, 4, 0), 212 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_RDM_SHIFT, 4, 0), 213 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_CRC32_SHIFT, 4, 0), 214 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_SHA2_SHIFT, 4, 0), 215 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_SHA1_SHIFT, 4, 0), 216 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_AES_SHIFT, 4, 0), 217 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_ISAR5_SEVL_SHIFT, 4, 0), 214 218 ARM64_FTR_END, 215 219 }; 216 220 217 221 static const struct arm64_ftr_bits ftr_id_mmfr4[] = { 218 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 8, 24, 0), /* RAZ */ 219 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 4, 0), /* ac2 */ 220 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 4, 0), /* RAZ */ 222 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 4, 4, 0), /* ac2 */ 221 223 ARM64_FTR_END, 222 224 }; 223 225 224 226 static const struct arm64_ftr_bits ftr_id_pfr0[] = { 225 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 16, 16, 0), /* RAZ */ 226 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 12, 4, 0), /* State3 */ 227 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 8, 4, 0), /* State2 */ 228 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 4, 0), /* State1 */ 229 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 4, 0), /* State0 */ 227 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 12, 4, 0), /* State3 */ 228 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 8, 4, 0), /* State2 */ 229 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 4, 4, 0), /* State1 */ 230 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 0, 4, 0), /* State0 */ 230 231 ARM64_FTR_END, 231 232 }; 232 233 233 234 static const struct arm64_ftr_bits ftr_id_dfr0[] = { 234 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 28, 4, 0), 235 - S_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 24, 4, 0xf), /* PerfMon */ 236 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), 237 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 0), 238 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 12, 4, 0), 239 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 8, 4, 0), 240 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 4, 4, 0), 241 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), 235 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 28, 4, 0), 236 + S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 24, 4, 0xf), /* PerfMon */ 237 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), 238 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 0), 239 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 12, 4, 0), 240 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 8, 4, 0), 241 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 4, 4, 0), 242 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), 242 243 ARM64_FTR_END, 243 244 }; 244 245 ··· 248 251 * id_isar[0-4], id_mmfr[1-3], id_pfr1, mvfr[0-1] 249 252 */ 250 253 static const struct arm64_ftr_bits ftr_generic_32bits[] = { 251 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 28, 4, 0), 252 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 24, 4, 0), 253 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), 254 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 0), 255 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 12, 4, 0), 256 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 8, 4, 0), 257 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 4, 4, 0), 258 - ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), 254 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 28, 4, 0), 255 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 24, 4, 0), 256 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), 257 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 0), 258 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 12, 4, 0), 259 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 8, 4, 0), 260 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 4, 4, 0), 261 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), 259 262 ARM64_FTR_END, 260 263 }; 261 264 262 - static const struct arm64_ftr_bits ftr_generic[] = { 263 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 64, 0), 265 + /* Table for a single 32bit feature value */ 266 + static const struct arm64_ftr_bits ftr_single32[] = { 267 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, 0, 32, 0), 264 268 ARM64_FTR_END, 265 269 }; 266 270 267 - static const struct arm64_ftr_bits ftr_generic32[] = { 268 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 32, 0), 269 - ARM64_FTR_END, 270 - }; 271 - 272 - static const struct arm64_ftr_bits ftr_aa64raz[] = { 273 - ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 0, 64, 0), 271 + static const struct arm64_ftr_bits ftr_raz[] = { 274 272 ARM64_FTR_END, 275 273 }; 276 274 ··· 306 314 307 315 /* Op1 = 0, CRn = 0, CRm = 4 */ 308 316 ARM64_FTR_REG(SYS_ID_AA64PFR0_EL1, ftr_id_aa64pfr0), 309 - ARM64_FTR_REG(SYS_ID_AA64PFR1_EL1, ftr_aa64raz), 317 + ARM64_FTR_REG(SYS_ID_AA64PFR1_EL1, ftr_raz), 310 318 311 319 /* Op1 = 0, CRn = 0, CRm = 5 */ 312 320 ARM64_FTR_REG(SYS_ID_AA64DFR0_EL1, ftr_id_aa64dfr0), 313 - ARM64_FTR_REG(SYS_ID_AA64DFR1_EL1, ftr_generic), 321 + ARM64_FTR_REG(SYS_ID_AA64DFR1_EL1, ftr_raz), 314 322 315 323 /* Op1 = 0, CRn = 0, CRm = 6 */ 316 324 ARM64_FTR_REG(SYS_ID_AA64ISAR0_EL1, ftr_id_aa64isar0), 317 - ARM64_FTR_REG(SYS_ID_AA64ISAR1_EL1, ftr_aa64raz), 325 + ARM64_FTR_REG(SYS_ID_AA64ISAR1_EL1, ftr_raz), 318 326 319 327 /* Op1 = 0, CRn = 0, CRm = 7 */ 320 328 ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0), ··· 326 334 ARM64_FTR_REG(SYS_DCZID_EL0, ftr_dczid), 327 335 328 336 /* Op1 = 3, CRn = 14, CRm = 0 */ 329 - ARM64_FTR_REG(SYS_CNTFRQ_EL0, ftr_generic32), 337 + ARM64_FTR_REG(SYS_CNTFRQ_EL0, ftr_single32), 330 338 }; 331 339 332 340 static int search_cmp_ftr_reg(const void *id, const void *regp) ··· 402 410 /* 403 411 * Initialise the CPU feature register from Boot CPU values. 404 412 * Also initiliases the strict_mask for the register. 413 + * Any bits that are not covered by an arm64_ftr_bits entry are considered 414 + * RES0 for the system-wide value, and must strictly match. 405 415 */ 406 416 static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) 407 417 { 408 418 u64 val = 0; 409 419 u64 strict_mask = ~0x0ULL; 420 + u64 user_mask = 0; 421 + u64 valid_mask = 0; 422 + 410 423 const struct arm64_ftr_bits *ftrp; 411 424 struct arm64_ftr_reg *reg = get_arm64_ftr_reg(sys_reg); 412 425 413 426 BUG_ON(!reg); 414 427 415 428 for (ftrp = reg->ftr_bits; ftrp->width; ftrp++) { 429 + u64 ftr_mask = arm64_ftr_mask(ftrp); 416 430 s64 ftr_new = arm64_ftr_value(ftrp, new); 417 431 418 432 val = arm64_ftr_set_value(ftrp, val, ftr_new); 433 + 434 + valid_mask |= ftr_mask; 419 435 if (!ftrp->strict) 420 - strict_mask &= ~arm64_ftr_mask(ftrp); 436 + strict_mask &= ~ftr_mask; 437 + if (ftrp->visible) 438 + user_mask |= ftr_mask; 439 + else 440 + reg->user_val = arm64_ftr_set_value(ftrp, 441 + reg->user_val, 442 + ftrp->safe_val); 421 443 } 444 + 445 + val &= valid_mask; 446 + 422 447 reg->sys_val = val; 423 448 reg->strict_mask = strict_mask; 449 + reg->user_mask = user_mask; 424 450 } 425 451 426 452 void __init init_cpu_features(struct cpuinfo_arm64 *info) ··· 645 635 return regp->sys_val; 646 636 } 647 637 638 + #define read_sysreg_case(r) \ 639 + case r: return read_sysreg_s(r) 640 + 648 641 /* 649 642 * __raw_read_system_reg() - Used by a STARTING cpu before cpuinfo is populated. 650 643 * Read the system register on the current CPU ··· 655 642 static u64 __raw_read_system_reg(u32 sys_id) 656 643 { 657 644 switch (sys_id) { 658 - case SYS_ID_PFR0_EL1: return read_cpuid(ID_PFR0_EL1); 659 - case SYS_ID_PFR1_EL1: return read_cpuid(ID_PFR1_EL1); 660 - case SYS_ID_DFR0_EL1: return read_cpuid(ID_DFR0_EL1); 661 - case SYS_ID_MMFR0_EL1: return read_cpuid(ID_MMFR0_EL1); 662 - case SYS_ID_MMFR1_EL1: return read_cpuid(ID_MMFR1_EL1); 663 - case SYS_ID_MMFR2_EL1: return read_cpuid(ID_MMFR2_EL1); 664 - case SYS_ID_MMFR3_EL1: return read_cpuid(ID_MMFR3_EL1); 665 - case SYS_ID_ISAR0_EL1: return read_cpuid(ID_ISAR0_EL1); 666 - case SYS_ID_ISAR1_EL1: return read_cpuid(ID_ISAR1_EL1); 667 - case SYS_ID_ISAR2_EL1: return read_cpuid(ID_ISAR2_EL1); 668 - case SYS_ID_ISAR3_EL1: return read_cpuid(ID_ISAR3_EL1); 669 - case SYS_ID_ISAR4_EL1: return read_cpuid(ID_ISAR4_EL1); 670 - case SYS_ID_ISAR5_EL1: return read_cpuid(ID_ISAR4_EL1); 671 - case SYS_MVFR0_EL1: return read_cpuid(MVFR0_EL1); 672 - case SYS_MVFR1_EL1: return read_cpuid(MVFR1_EL1); 673 - case SYS_MVFR2_EL1: return read_cpuid(MVFR2_EL1); 645 + read_sysreg_case(SYS_ID_PFR0_EL1); 646 + read_sysreg_case(SYS_ID_PFR1_EL1); 647 + read_sysreg_case(SYS_ID_DFR0_EL1); 648 + read_sysreg_case(SYS_ID_MMFR0_EL1); 649 + read_sysreg_case(SYS_ID_MMFR1_EL1); 650 + read_sysreg_case(SYS_ID_MMFR2_EL1); 651 + read_sysreg_case(SYS_ID_MMFR3_EL1); 652 + read_sysreg_case(SYS_ID_ISAR0_EL1); 653 + read_sysreg_case(SYS_ID_ISAR1_EL1); 654 + read_sysreg_case(SYS_ID_ISAR2_EL1); 655 + read_sysreg_case(SYS_ID_ISAR3_EL1); 656 + read_sysreg_case(SYS_ID_ISAR4_EL1); 657 + read_sysreg_case(SYS_ID_ISAR5_EL1); 658 + read_sysreg_case(SYS_MVFR0_EL1); 659 + read_sysreg_case(SYS_MVFR1_EL1); 660 + read_sysreg_case(SYS_MVFR2_EL1); 674 661 675 - case SYS_ID_AA64PFR0_EL1: return read_cpuid(ID_AA64PFR0_EL1); 676 - case SYS_ID_AA64PFR1_EL1: return read_cpuid(ID_AA64PFR0_EL1); 677 - case SYS_ID_AA64DFR0_EL1: return read_cpuid(ID_AA64DFR0_EL1); 678 - case SYS_ID_AA64DFR1_EL1: return read_cpuid(ID_AA64DFR0_EL1); 679 - case SYS_ID_AA64MMFR0_EL1: return read_cpuid(ID_AA64MMFR0_EL1); 680 - case SYS_ID_AA64MMFR1_EL1: return read_cpuid(ID_AA64MMFR1_EL1); 681 - case SYS_ID_AA64MMFR2_EL1: return read_cpuid(ID_AA64MMFR2_EL1); 682 - case SYS_ID_AA64ISAR0_EL1: return read_cpuid(ID_AA64ISAR0_EL1); 683 - case SYS_ID_AA64ISAR1_EL1: return read_cpuid(ID_AA64ISAR1_EL1); 662 + read_sysreg_case(SYS_ID_AA64PFR0_EL1); 663 + read_sysreg_case(SYS_ID_AA64PFR1_EL1); 664 + read_sysreg_case(SYS_ID_AA64DFR0_EL1); 665 + read_sysreg_case(SYS_ID_AA64DFR1_EL1); 666 + read_sysreg_case(SYS_ID_AA64MMFR0_EL1); 667 + read_sysreg_case(SYS_ID_AA64MMFR1_EL1); 668 + read_sysreg_case(SYS_ID_AA64MMFR2_EL1); 669 + read_sysreg_case(SYS_ID_AA64ISAR0_EL1); 670 + read_sysreg_case(SYS_ID_AA64ISAR1_EL1); 684 671 685 - case SYS_CNTFRQ_EL0: return read_cpuid(CNTFRQ_EL0); 686 - case SYS_CTR_EL0: return read_cpuid(CTR_EL0); 687 - case SYS_DCZID_EL0: return read_cpuid(DCZID_EL0); 672 + read_sysreg_case(SYS_CNTFRQ_EL0); 673 + read_sysreg_case(SYS_CTR_EL0); 674 + read_sysreg_case(SYS_DCZID_EL0); 675 + 688 676 default: 689 677 BUG(); 690 678 return 0; ··· 734 720 static bool has_no_hw_prefetch(const struct arm64_cpu_capabilities *entry, int __unused) 735 721 { 736 722 u32 midr = read_cpuid_id(); 737 - u32 rv_min, rv_max; 738 723 739 724 /* Cavium ThunderX pass 1.x and 2.x */ 740 - rv_min = 0; 741 - rv_max = (1 << MIDR_VARIANT_SHIFT) | MIDR_REVISION_MASK; 742 - 743 - return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX, rv_min, rv_max); 725 + return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX, 726 + MIDR_CPU_VAR_REV(0, 0), 727 + MIDR_CPU_VAR_REV(1, MIDR_REVISION_MASK)); 744 728 } 745 729 746 730 static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int __unused) ··· 749 737 static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry, 750 738 int __unused) 751 739 { 752 - phys_addr_t idmap_addr = virt_to_phys(__hyp_idmap_text_start); 740 + phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start); 753 741 754 742 /* 755 743 * Activate the lower HYP offset only if: ··· 818 806 .sys_reg = SYS_ID_AA64MMFR2_EL1, 819 807 .field_pos = ID_AA64MMFR2_UAO_SHIFT, 820 808 .min_field_value = 1, 821 - .enable = cpu_enable_uao, 809 + /* 810 + * We rely on stop_machine() calling uao_thread_switch() to set 811 + * UAO immediately after patching. 812 + */ 822 813 }, 823 814 #endif /* CONFIG_ARM64_UAO */ 824 815 #ifdef CONFIG_ARM64_PAN ··· 883 868 HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_SHA2_SHIFT, FTR_UNSIGNED, 1, CAP_HWCAP, HWCAP_SHA2), 884 869 HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_CRC32_SHIFT, FTR_UNSIGNED, 1, CAP_HWCAP, HWCAP_CRC32), 885 870 HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_ATOMICS_SHIFT, FTR_UNSIGNED, 2, CAP_HWCAP, HWCAP_ATOMICS), 871 + HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_RDM_SHIFT, FTR_UNSIGNED, 1, CAP_HWCAP, HWCAP_ASIMDRDM), 886 872 HWCAP_CAP(SYS_ID_AA64PFR0_EL1, ID_AA64PFR0_FP_SHIFT, FTR_SIGNED, 0, CAP_HWCAP, HWCAP_FP), 887 873 HWCAP_CAP(SYS_ID_AA64PFR0_EL1, ID_AA64PFR0_FP_SHIFT, FTR_SIGNED, 1, CAP_HWCAP, HWCAP_FPHP), 888 874 HWCAP_CAP(SYS_ID_AA64PFR0_EL1, ID_AA64PFR0_ASIMD_SHIFT, FTR_SIGNED, 0, CAP_HWCAP, HWCAP_ASIMD), ··· 949 933 950 934 static void __init setup_elf_hwcaps(const struct arm64_cpu_capabilities *hwcaps) 951 935 { 936 + /* We support emulation of accesses to CPU ID feature registers */ 937 + elf_hwcap |= HWCAP_CPUID; 952 938 for (; hwcaps->matches; hwcaps++) 953 939 if (hwcaps->matches(hwcaps, hwcaps->def_scope)) 954 940 cap_set_elf_hwcap(hwcaps); ··· 1138 1120 { 1139 1121 return (cpus_have_const_cap(ARM64_HAS_PAN) && !cpus_have_const_cap(ARM64_HAS_UAO)); 1140 1122 } 1123 + 1124 + /* 1125 + * We emulate only the following system register space. 1126 + * Op0 = 0x3, CRn = 0x0, Op1 = 0x0, CRm = [0, 4 - 7] 1127 + * See Table C5-6 System instruction encodings for System register accesses, 1128 + * ARMv8 ARM(ARM DDI 0487A.f) for more details. 1129 + */ 1130 + static inline bool __attribute_const__ is_emulated(u32 id) 1131 + { 1132 + return (sys_reg_Op0(id) == 0x3 && 1133 + sys_reg_CRn(id) == 0x0 && 1134 + sys_reg_Op1(id) == 0x0 && 1135 + (sys_reg_CRm(id) == 0 || 1136 + ((sys_reg_CRm(id) >= 4) && (sys_reg_CRm(id) <= 7)))); 1137 + } 1138 + 1139 + /* 1140 + * With CRm == 0, reg should be one of : 1141 + * MIDR_EL1, MPIDR_EL1 or REVIDR_EL1. 1142 + */ 1143 + static inline int emulate_id_reg(u32 id, u64 *valp) 1144 + { 1145 + switch (id) { 1146 + case SYS_MIDR_EL1: 1147 + *valp = read_cpuid_id(); 1148 + break; 1149 + case SYS_MPIDR_EL1: 1150 + *valp = SYS_MPIDR_SAFE_VAL; 1151 + break; 1152 + case SYS_REVIDR_EL1: 1153 + /* IMPLEMENTATION DEFINED values are emulated with 0 */ 1154 + *valp = 0; 1155 + break; 1156 + default: 1157 + return -EINVAL; 1158 + } 1159 + 1160 + return 0; 1161 + } 1162 + 1163 + static int emulate_sys_reg(u32 id, u64 *valp) 1164 + { 1165 + struct arm64_ftr_reg *regp; 1166 + 1167 + if (!is_emulated(id)) 1168 + return -EINVAL; 1169 + 1170 + if (sys_reg_CRm(id) == 0) 1171 + return emulate_id_reg(id, valp); 1172 + 1173 + regp = get_arm64_ftr_reg(id); 1174 + if (regp) 1175 + *valp = arm64_ftr_reg_user_value(regp); 1176 + else 1177 + /* 1178 + * The untracked registers are either IMPLEMENTATION DEFINED 1179 + * (e.g, ID_AFR0_EL1) or reserved RAZ. 1180 + */ 1181 + *valp = 0; 1182 + return 0; 1183 + } 1184 + 1185 + static int emulate_mrs(struct pt_regs *regs, u32 insn) 1186 + { 1187 + int rc; 1188 + u32 sys_reg, dst; 1189 + u64 val; 1190 + 1191 + /* 1192 + * sys_reg values are defined as used in mrs/msr instruction. 1193 + * shift the imm value to get the encoding. 1194 + */ 1195 + sys_reg = (u32)aarch64_insn_decode_immediate(AARCH64_INSN_IMM_16, insn) << 5; 1196 + rc = emulate_sys_reg(sys_reg, &val); 1197 + if (!rc) { 1198 + dst = aarch64_insn_decode_register(AARCH64_INSN_REGTYPE_RT, insn); 1199 + pt_regs_write_reg(regs, dst, val); 1200 + regs->pc += 4; 1201 + } 1202 + 1203 + return rc; 1204 + } 1205 + 1206 + static struct undef_hook mrs_hook = { 1207 + .instr_mask = 0xfff00000, 1208 + .instr_val = 0xd5300000, 1209 + .pstate_mask = COMPAT_PSR_MODE_MASK, 1210 + .pstate_val = PSR_MODE_EL0t, 1211 + .fn = emulate_mrs, 1212 + }; 1213 + 1214 + static int __init enable_mrs_emulation(void) 1215 + { 1216 + register_undef_hook(&mrs_hook); 1217 + return 0; 1218 + } 1219 + 1220 + late_initcall(enable_mrs_emulation);
+2
arch/arm64/kernel/cpuinfo.c
··· 63 63 "atomics", 64 64 "fphp", 65 65 "asimdhp", 66 + "cpuid", 67 + "asimdrdm", 66 68 NULL 67 69 }; 68 70
+3 -6
arch/arm64/kernel/efi-entry.S
··· 46 46 * efi_system_table_t *sys_table, 47 47 * unsigned long *image_addr) ; 48 48 */ 49 - adrp x8, _text 50 - add x8, x8, #:lo12:_text 49 + adr_l x8, _text 51 50 add x2, sp, 16 52 51 str x8, [x2] 53 52 bl efi_entry ··· 67 68 /* 68 69 * Calculate size of the kernel Image (same for original and copy). 69 70 */ 70 - adrp x1, _text 71 - add x1, x1, #:lo12:_text 72 - adrp x2, _edata 73 - add x2, x2, #:lo12:_edata 71 + adr_l x1, _text 72 + adr_l x2, _edata 74 73 sub x1, x2, x1 75 74 76 75 /*
+5 -8
arch/arm64/kernel/entry-ftrace.S
··· 10 10 */ 11 11 12 12 #include <linux/linkage.h> 13 + #include <asm/assembler.h> 13 14 #include <asm/ftrace.h> 14 15 #include <asm/insn.h> 15 16 ··· 99 98 ENTRY(_mcount) 100 99 mcount_enter 101 100 102 - adrp x0, ftrace_trace_function 103 - ldr x2, [x0, #:lo12:ftrace_trace_function] 101 + ldr_l x2, ftrace_trace_function 104 102 adr x0, ftrace_stub 105 103 cmp x0, x2 // if (ftrace_trace_function 106 104 b.eq skip_ftrace_call // != ftrace_stub) { ··· 115 115 mcount_exit // return; 116 116 // } 117 117 skip_ftrace_call: 118 - adrp x1, ftrace_graph_return 119 - ldr x2, [x1, #:lo12:ftrace_graph_return] 118 + ldr_l x2, ftrace_graph_return 120 119 cmp x0, x2 // if ((ftrace_graph_return 121 120 b.ne ftrace_graph_caller // != ftrace_stub) 122 121 123 - adrp x1, ftrace_graph_entry // || (ftrace_graph_entry 124 - adrp x0, ftrace_graph_entry_stub // != ftrace_graph_entry_stub)) 125 - ldr x2, [x1, #:lo12:ftrace_graph_entry] 126 - add x0, x0, #:lo12:ftrace_graph_entry_stub 122 + ldr_l x2, ftrace_graph_entry // || (ftrace_graph_entry 123 + adr_l x0, ftrace_graph_entry_stub // != ftrace_graph_entry_stub)) 127 124 cmp x0, x2 128 125 b.ne ftrace_graph_caller // ftrace_graph_caller(); 129 126
+64 -9
arch/arm64/kernel/head.S
··· 149 149 .quad 0 // SizeOfHeapReserve 150 150 .quad 0 // SizeOfHeapCommit 151 151 .long 0 // LoaderFlags 152 - .long 0x6 // NumberOfRvaAndSizes 152 + .long (section_table - .) / 8 // NumberOfRvaAndSizes 153 153 154 154 .quad 0 // ExportTable 155 155 .quad 0 // ImportTable ··· 157 157 .quad 0 // ExceptionTable 158 158 .quad 0 // CertificationTable 159 159 .quad 0 // BaseRelocationTable 160 + 161 + #ifdef CONFIG_DEBUG_EFI 162 + .long efi_debug_table - _head // DebugTable 163 + .long efi_debug_table_size 164 + #endif 160 165 161 166 // Section table 162 167 section_table: ··· 199 194 .short 0 // NumberOfRelocations (0 for executables) 200 195 .short 0 // NumberOfLineNumbers (0 for executables) 201 196 .long 0xe0500020 // Characteristics (section flags) 197 + 198 + #ifdef CONFIG_DEBUG_EFI 199 + /* 200 + * The debug table is referenced via its Relative Virtual Address (RVA), 201 + * which is only defined for those parts of the image that are covered 202 + * by a section declaration. Since this header is not covered by any 203 + * section, the debug table must be emitted elsewhere. So stick it in 204 + * the .init.rodata section instead. 205 + * 206 + * Note that the EFI debug entry itself may legally have a zero RVA, 207 + * which means we can simply put it right after the section headers. 208 + */ 209 + __INITRODATA 210 + 211 + .align 2 212 + efi_debug_table: 213 + // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY 214 + .long 0 // Characteristics 215 + .long 0 // TimeDateStamp 216 + .short 0 // MajorVersion 217 + .short 0 // MinorVersion 218 + .long 2 // Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW 219 + .long efi_debug_entry_size // SizeOfData 220 + .long 0 // RVA 221 + .long efi_debug_entry - _head // FileOffset 222 + 223 + .set efi_debug_table_size, . - efi_debug_table 224 + .previous 225 + 226 + efi_debug_entry: 227 + // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY 228 + .ascii "NB10" // Signature 229 + .long 0 // Unknown 230 + .long 0 // Unknown2 231 + .long 0 // Unknown3 232 + 233 + .asciz VMLINUX_PATH 234 + 235 + .set efi_debug_entry_size, . - efi_debug_entry 236 + #endif 202 237 203 238 /* 204 239 * EFI will load .text onwards at the 4k section alignment ··· 528 483 * If we're fortunate enough to boot at EL2, ensure that the world is 529 484 * sane before dropping to EL1. 530 485 * 531 - * Returns either BOOT_CPU_MODE_EL1 or BOOT_CPU_MODE_EL2 in x20 if 486 + * Returns either BOOT_CPU_MODE_EL1 or BOOT_CPU_MODE_EL2 in w0 if 532 487 * booted in EL1 or EL2 respectively. 533 488 */ 534 489 ENTRY(el2_setup) ··· 637 592 #endif 638 593 639 594 /* EL2 debug */ 640 - mrs x0, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer 641 - sbfx x0, x0, #8, #4 595 + mrs x1, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer 596 + sbfx x0, x1, #8, #4 642 597 cmp x0, #1 643 598 b.lt 4f // Skip if no PMU present 644 599 mrs x0, pmcr_el0 // Disable debug access traps 645 600 ubfx x0, x0, #11, #5 // to EL2 and allow access to 646 601 4: 647 - csel x0, xzr, x0, lt // all PMU counters from EL1 648 - msr mdcr_el2, x0 // (if they exist) 602 + csel x3, xzr, x0, lt // all PMU counters from EL1 603 + 604 + /* Statistical profiling */ 605 + ubfx x0, x1, #32, #4 // Check ID_AA64DFR0_EL1 PMSVer 606 + cbz x0, 6f // Skip if SPE not present 607 + cbnz x2, 5f // VHE? 608 + mov x1, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT) 609 + orr x3, x3, x1 // If we don't have VHE, then 610 + b 6f // use EL1&0 translation. 611 + 5: // For VHE, use EL2 translation 612 + orr x3, x3, #MDCR_EL2_TPMS // and disable access from EL1 613 + 6: 614 + msr mdcr_el2, x3 // Configure debug traps 649 615 650 616 /* Stage-2 translation */ 651 617 msr vttbr_el2, xzr ··· 669 613 670 614 install_el2_stub: 671 615 /* Hypervisor stub */ 672 - adrp x0, __hyp_stub_vectors 673 - add x0, x0, #:lo12:__hyp_stub_vectors 616 + adr_l x0, __hyp_stub_vectors 674 617 msr vbar_el2, x0 675 618 676 619 /* spsr */ ··· 683 628 684 629 /* 685 630 * Sets the __boot_cpu_mode flag depending on the CPU boot mode passed 686 - * in x20. See arch/arm64/include/asm/virt.h for more info. 631 + * in w0. See arch/arm64/include/asm/virt.h for more info. 687 632 */ 688 633 set_cpu_boot_mode_flag: 689 634 adr_l x1, __boot_cpu_mode
+8 -18
arch/arm64/kernel/hibernate.c
··· 50 50 */ 51 51 extern int in_suspend; 52 52 53 - /* Find a symbols alias in the linear map */ 54 - #define LMADDR(x) phys_to_virt(virt_to_phys(x)) 55 - 56 53 /* Do we need to reset el2? */ 57 54 #define el2_reset_needed() (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) 58 55 ··· 99 102 100 103 int pfn_is_nosave(unsigned long pfn) 101 104 { 102 - unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin); 103 - unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1); 105 + unsigned long nosave_begin_pfn = sym_to_pfn(&__nosave_begin); 106 + unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1); 104 107 105 108 return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn); 106 109 } ··· 122 125 return -EOVERFLOW; 123 126 124 127 arch_hdr_invariants(&hdr->invariants); 125 - hdr->ttbr1_el1 = virt_to_phys(swapper_pg_dir); 128 + hdr->ttbr1_el1 = __pa_symbol(swapper_pg_dir); 126 129 hdr->reenter_kernel = _cpu_resume; 127 130 128 131 /* We can't use __hyp_get_vectors() because kvm may still be loaded */ 129 132 if (el2_reset_needed()) 130 - hdr->__hyp_stub_vectors = virt_to_phys(__hyp_stub_vectors); 133 + hdr->__hyp_stub_vectors = __pa_symbol(__hyp_stub_vectors); 131 134 else 132 135 hdr->__hyp_stub_vectors = 0; 133 136 ··· 457 460 void *zero_page; 458 461 size_t exit_size; 459 462 pgd_t *tmp_pg_dir; 460 - void *lm_restore_pblist; 461 463 phys_addr_t phys_hibernate_exit; 462 464 void __noreturn (*hibernate_exit)(phys_addr_t, phys_addr_t, void *, 463 465 void *, phys_addr_t, phys_addr_t); ··· 468 472 */ 469 473 tmp_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC); 470 474 if (!tmp_pg_dir) { 471 - pr_err("Failed to allocate memory for temporary page tables."); 475 + pr_err("Failed to allocate memory for temporary page tables.\n"); 472 476 rc = -ENOMEM; 473 477 goto out; 474 478 } ··· 477 481 goto out; 478 482 479 483 /* 480 - * Since we only copied the linear map, we need to find restore_pblist's 481 - * linear map address. 482 - */ 483 - lm_restore_pblist = LMADDR(restore_pblist); 484 - 485 - /* 486 484 * We need a zero page that is zero before & after resume in order to 487 485 * to break before make on the ttbr1 page tables. 488 486 */ 489 487 zero_page = (void *)get_safe_page(GFP_ATOMIC); 490 488 if (!zero_page) { 491 - pr_err("Failed to allocate zero page."); 489 + pr_err("Failed to allocate zero page.\n"); 492 490 rc = -ENOMEM; 493 491 goto out; 494 492 } ··· 502 512 &phys_hibernate_exit, 503 513 (void *)get_safe_page, GFP_ATOMIC); 504 514 if (rc) { 505 - pr_err("Failed to create safe executable page for hibernate_exit code."); 515 + pr_err("Failed to create safe executable page for hibernate_exit code.\n"); 506 516 goto out; 507 517 } 508 518 ··· 527 537 } 528 538 529 539 hibernate_exit(virt_to_phys(tmp_pg_dir), resume_hdr.ttbr1_el1, 530 - resume_hdr.reenter_kernel, lm_restore_pblist, 540 + resume_hdr.reenter_kernel, restore_pblist, 531 541 resume_hdr.__hyp_stub_vectors, virt_to_phys(zero_page)); 532 542 533 543 out:
+30 -1
arch/arm64/kernel/insn.c
··· 96 96 if (module && IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) 97 97 page = vmalloc_to_page(addr); 98 98 else if (!module) 99 - page = pfn_to_page(PHYS_PFN(__pa(addr))); 99 + page = phys_to_page(__pa_symbol(addr)); 100 100 else 101 101 return addr; 102 102 ··· 415 415 insn |= (imm & mask) << shift; 416 416 417 417 return insn; 418 + } 419 + 420 + u32 aarch64_insn_decode_register(enum aarch64_insn_register_type type, 421 + u32 insn) 422 + { 423 + int shift; 424 + 425 + switch (type) { 426 + case AARCH64_INSN_REGTYPE_RT: 427 + case AARCH64_INSN_REGTYPE_RD: 428 + shift = 0; 429 + break; 430 + case AARCH64_INSN_REGTYPE_RN: 431 + shift = 5; 432 + break; 433 + case AARCH64_INSN_REGTYPE_RT2: 434 + case AARCH64_INSN_REGTYPE_RA: 435 + shift = 10; 436 + break; 437 + case AARCH64_INSN_REGTYPE_RM: 438 + shift = 16; 439 + break; 440 + default: 441 + pr_err("%s: unknown register type encoding %d\n", __func__, 442 + type); 443 + return 0; 444 + } 445 + 446 + return (insn >> shift) & GENMASK(4, 0); 418 447 } 419 448 420 449 static u32 aarch64_insn_encode_register(enum aarch64_insn_register_type type,
+6 -12
arch/arm64/kernel/probes/simulate-insn.c
··· 17 17 #include <linux/kernel.h> 18 18 #include <linux/kprobes.h> 19 19 20 + #include <asm/ptrace.h> 21 + 20 22 #include "simulate-insn.h" 21 23 22 24 #define bbl_displacement(insn) \ ··· 38 36 39 37 static inline void set_x_reg(struct pt_regs *regs, int reg, u64 val) 40 38 { 41 - if (reg < 31) 42 - regs->regs[reg] = val; 39 + pt_regs_write_reg(regs, reg, val); 43 40 } 44 41 45 42 static inline void set_w_reg(struct pt_regs *regs, int reg, u64 val) 46 43 { 47 - if (reg < 31) 48 - regs->regs[reg] = lower_32_bits(val); 44 + pt_regs_write_reg(regs, reg, lower_32_bits(val)); 49 45 } 50 46 51 47 static inline u64 get_x_reg(struct pt_regs *regs, int reg) 52 48 { 53 - if (reg < 31) 54 - return regs->regs[reg]; 55 - else 56 - return 0; 49 + return pt_regs_read_reg(regs, reg); 57 50 } 58 51 59 52 static inline u32 get_w_reg(struct pt_regs *regs, int reg) 60 53 { 61 - if (reg < 31) 62 - return lower_32_bits(regs->regs[reg]); 63 - else 64 - return 0; 54 + return lower_32_bits(pt_regs_read_reg(regs, reg)); 65 55 } 66 56 67 57 static bool __kprobes check_cbz(u32 opcode, struct pt_regs *regs)
+3 -3
arch/arm64/kernel/process.c
··· 339 339 /* 340 340 * Thread switching. 341 341 */ 342 - struct task_struct *__switch_to(struct task_struct *prev, 342 + __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, 343 343 struct task_struct *next) 344 344 { 345 345 struct task_struct *last; ··· 407 407 unsigned long arch_randomize_brk(struct mm_struct *mm) 408 408 { 409 409 if (is_compat_task()) 410 - return randomize_page(mm->brk, 0x02000000); 410 + return randomize_page(mm->brk, SZ_32M); 411 411 else 412 - return randomize_page(mm->brk, 0x40000000); 412 + return randomize_page(mm->brk, SZ_1G); 413 413 }
+2 -1
arch/arm64/kernel/psci.c
··· 20 20 #include <linux/smp.h> 21 21 #include <linux/delay.h> 22 22 #include <linux/psci.h> 23 + #include <linux/mm.h> 23 24 24 25 #include <uapi/linux/psci.h> 25 26 ··· 46 45 47 46 static int cpu_psci_cpu_boot(unsigned int cpu) 48 47 { 49 - int err = psci_ops.cpu_on(cpu_logical_map(cpu), __pa(secondary_entry)); 48 + int err = psci_ops.cpu_on(cpu_logical_map(cpu), __pa_symbol(secondary_entry)); 50 49 if (err) 51 50 pr_err("failed to boot CPU%d (%d)\n", cpu, err); 52 51
+7 -6
arch/arm64/kernel/setup.c
··· 42 42 #include <linux/of_fdt.h> 43 43 #include <linux/efi.h> 44 44 #include <linux/psci.h> 45 + #include <linux/mm.h> 45 46 46 47 #include <asm/acpi.h> 47 48 #include <asm/fixmap.h> ··· 200 199 struct memblock_region *region; 201 200 struct resource *res; 202 201 203 - kernel_code.start = virt_to_phys(_text); 204 - kernel_code.end = virt_to_phys(__init_begin - 1); 205 - kernel_data.start = virt_to_phys(_sdata); 206 - kernel_data.end = virt_to_phys(_end - 1); 202 + kernel_code.start = __pa_symbol(_text); 203 + kernel_code.end = __pa_symbol(__init_begin - 1); 204 + kernel_data.start = __pa_symbol(_sdata); 205 + kernel_data.end = __pa_symbol(_end - 1); 207 206 208 207 for_each_memblock(memory, region) { 209 208 res = alloc_bootmem_low(sizeof(*res)); 210 209 if (memblock_is_nomap(region)) { 211 210 res->name = "reserved"; 212 - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 211 + res->flags = IORESOURCE_MEM; 213 212 } else { 214 213 res->name = "System RAM"; 215 214 res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; ··· 298 297 * faults in case uaccess_enable() is inadvertently called by the init 299 298 * thread. 300 299 */ 301 - init_task.thread_info.ttbr0 = virt_to_phys(empty_zero_page); 300 + init_task.thread_info.ttbr0 = __pa_symbol(empty_zero_page); 302 301 #endif 303 302 304 303 #ifdef CONFIG_VT
+16 -7
arch/arm64/kernel/smccc-call.S
··· 12 12 * 13 13 */ 14 14 #include <linux/linkage.h> 15 + #include <linux/arm-smccc.h> 15 16 #include <asm/asm-offsets.h> 16 17 17 18 .macro SMCCC instr ··· 21 20 ldr x4, [sp] 22 21 stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] 23 22 stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] 24 - ret 23 + ldr x4, [sp, #8] 24 + cbz x4, 1f /* no quirk structure */ 25 + ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS] 26 + cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 27 + b.ne 1f 28 + str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS] 29 + 1: ret 25 30 .cfi_endproc 26 31 .endm 27 32 28 33 /* 29 34 * void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, 30 35 * unsigned long a3, unsigned long a4, unsigned long a5, 31 - * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) 36 + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, 37 + * struct arm_smccc_quirk *quirk) 32 38 */ 33 - ENTRY(arm_smccc_smc) 39 + ENTRY(__arm_smccc_smc) 34 40 SMCCC smc 35 - ENDPROC(arm_smccc_smc) 41 + ENDPROC(__arm_smccc_smc) 36 42 37 43 /* 38 44 * void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, 39 45 * unsigned long a3, unsigned long a4, unsigned long a5, 40 - * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) 46 + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, 47 + * struct arm_smccc_quirk *quirk) 41 48 */ 42 - ENTRY(arm_smccc_hvc) 49 + ENTRY(__arm_smccc_hvc) 43 50 SMCCC hvc 44 - ENDPROC(arm_smccc_hvc) 51 + ENDPROC(__arm_smccc_hvc)
+2 -2
arch/arm64/kernel/smp.c
··· 603 603 */ 604 604 static void __init of_parse_and_init_cpus(void) 605 605 { 606 - struct device_node *dn = NULL; 606 + struct device_node *dn; 607 607 608 - while ((dn = of_find_node_by_type(dn, "cpu"))) { 608 + for_each_node_by_type(dn, "cpu") { 609 609 u64 hwid = of_get_cpu_mpidr(dn); 610 610 611 611 if (hwid == INVALID_HWID)
+2 -1
arch/arm64/kernel/smp_spin_table.c
··· 21 21 #include <linux/of.h> 22 22 #include <linux/smp.h> 23 23 #include <linux/types.h> 24 + #include <linux/mm.h> 24 25 25 26 #include <asm/cacheflush.h> 26 27 #include <asm/cpu_ops.h> ··· 99 98 * boot-loader's endianess before jumping. This is mandated by 100 99 * the boot protocol. 101 100 */ 102 - writeq_relaxed(__pa(secondary_holding_pen), release_addr); 101 + writeq_relaxed(__pa_symbol(secondary_holding_pen), release_addr); 103 102 __flush_dcache_area((__force void *)release_addr, 104 103 sizeof(*release_addr)); 105 104
-2
arch/arm64/kernel/topology.c
··· 41 41 per_cpu(cpu_scale, cpu) = capacity; 42 42 } 43 43 44 - #ifdef CONFIG_PROC_SYSCTL 45 44 static ssize_t cpu_capacity_show(struct device *dev, 46 45 struct device_attribute *attr, 47 46 char *buf) ··· 97 98 return 0; 98 99 } 99 100 subsys_initcall(register_cpu_capacity_sysctl); 100 - #endif 101 101 102 102 static u32 capacity_scale; 103 103 static u32 *raw_capacity;
+10 -3
arch/arm64/kernel/traps.c
··· 466 466 int crm = (esr & ESR_ELx_SYS64_ISS_CRM_MASK) >> ESR_ELx_SYS64_ISS_CRM_SHIFT; 467 467 int ret = 0; 468 468 469 - address = (rt == 31) ? 0 : regs->regs[rt]; 469 + address = pt_regs_read_reg(regs, rt); 470 470 471 471 switch (crm) { 472 472 case ESR_ELx_SYS64_ISS_CRM_DC_CVAU: /* DC CVAU, gets promoted */ ··· 495 495 static void ctr_read_handler(unsigned int esr, struct pt_regs *regs) 496 496 { 497 497 int rt = (esr & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT; 498 + unsigned long val = arm64_ftr_reg_user_value(&arm64_ftr_reg_ctrel0); 498 499 499 - regs->regs[rt] = arm64_ftr_reg_ctrel0.sys_val; 500 + pt_regs_write_reg(regs, rt, val); 501 + 500 502 regs->pc += 4; 501 503 } 502 504 ··· 533 531 return; 534 532 } 535 533 536 - force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0); 534 + /* 535 + * New SYS instructions may previously have been undefined at EL0. Fall 536 + * back to our usual undefined instruction handler so that we handle 537 + * these consistently. 538 + */ 539 + do_undefinstr(regs); 537 540 } 538 541 539 542 long compat_arm_syscall(struct pt_regs *regs);
+6 -2
arch/arm64/kernel/vdso.c
··· 123 123 { 124 124 int i; 125 125 struct page **vdso_pagelist; 126 + unsigned long pfn; 126 127 127 128 if (memcmp(&vdso_start, "\177ELF", 4)) { 128 129 pr_err("vDSO is not a valid ELF object!\n"); ··· 141 140 return -ENOMEM; 142 141 143 142 /* Grab the vDSO data page. */ 144 - vdso_pagelist[0] = pfn_to_page(PHYS_PFN(__pa(vdso_data))); 143 + vdso_pagelist[0] = phys_to_page(__pa_symbol(vdso_data)); 144 + 145 145 146 146 /* Grab the vDSO code pages. */ 147 + pfn = sym_to_pfn(&vdso_start); 148 + 147 149 for (i = 0; i < vdso_pages; i++) 148 - vdso_pagelist[i + 1] = pfn_to_page(PHYS_PFN(__pa(&vdso_start)) + i); 150 + vdso_pagelist[i + 1] = pfn_to_page(pfn + i); 149 151 150 152 vdso_spec[0].pages = &vdso_pagelist[0]; 151 153 vdso_spec[1].pages = &vdso_pagelist[1];
+6
arch/arm64/kvm/debug.c
··· 95 95 * - Performance monitors (MDCR_EL2_TPM/MDCR_EL2_TPMCR) 96 96 * - Debug ROM Address (MDCR_EL2_TDRA) 97 97 * - OS related registers (MDCR_EL2_TDOSA) 98 + * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB) 98 99 * 99 100 * Additionally, KVM only traps guest accesses to the debug registers if 100 101 * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY ··· 111 110 112 111 trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); 113 112 113 + /* 114 + * This also clears MDCR_EL2_E2PB_MASK to disable guest access 115 + * to the profiling buffer. 116 + */ 114 117 vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; 115 118 vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | 119 + MDCR_EL2_TPMS | 116 120 MDCR_EL2_TPMCR | 117 121 MDCR_EL2_TDRA | 118 122 MDCR_EL2_TDOSA);
+64 -2
arch/arm64/kvm/hyp/debug-sr.c
··· 65 65 default: write_debug(ptr[0], reg, 0); \ 66 66 } 67 67 68 + #define PMSCR_EL1 sys_reg(3, 0, 9, 9, 0) 69 + 70 + #define PMBLIMITR_EL1 sys_reg(3, 0, 9, 10, 0) 71 + #define PMBLIMITR_EL1_E BIT(0) 72 + 73 + #define PMBIDR_EL1 sys_reg(3, 0, 9, 10, 7) 74 + #define PMBIDR_EL1_P BIT(4) 75 + 76 + #define psb_csync() asm volatile("hint #17") 77 + 78 + static void __hyp_text __debug_save_spe_vhe(u64 *pmscr_el1) 79 + { 80 + /* The vcpu can run. but it can't hide. */ 81 + } 82 + 83 + static void __hyp_text __debug_save_spe_nvhe(u64 *pmscr_el1) 84 + { 85 + u64 reg; 86 + 87 + /* SPE present on this CPU? */ 88 + if (!cpuid_feature_extract_unsigned_field(read_sysreg(id_aa64dfr0_el1), 89 + ID_AA64DFR0_PMSVER_SHIFT)) 90 + return; 91 + 92 + /* Yes; is it owned by EL3? */ 93 + reg = read_sysreg_s(PMBIDR_EL1); 94 + if (reg & PMBIDR_EL1_P) 95 + return; 96 + 97 + /* No; is the host actually using the thing? */ 98 + reg = read_sysreg_s(PMBLIMITR_EL1); 99 + if (!(reg & PMBLIMITR_EL1_E)) 100 + return; 101 + 102 + /* Yes; save the control register and disable data generation */ 103 + *pmscr_el1 = read_sysreg_s(PMSCR_EL1); 104 + write_sysreg_s(0, PMSCR_EL1); 105 + isb(); 106 + 107 + /* Now drain all buffered data to memory */ 108 + psb_csync(); 109 + dsb(nsh); 110 + } 111 + 112 + static hyp_alternate_select(__debug_save_spe, 113 + __debug_save_spe_nvhe, __debug_save_spe_vhe, 114 + ARM64_HAS_VIRT_HOST_EXTN); 115 + 116 + static void __hyp_text __debug_restore_spe(u64 pmscr_el1) 117 + { 118 + if (!pmscr_el1) 119 + return; 120 + 121 + /* The host page table is installed, but not yet synchronised */ 122 + isb(); 123 + 124 + /* Re-enable data generation */ 125 + write_sysreg_s(pmscr_el1, PMSCR_EL1); 126 + } 127 + 68 128 void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu, 69 129 struct kvm_guest_debug_arch *dbg, 70 130 struct kvm_cpu_context *ctxt) ··· 178 118 (vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_MDE)) 179 119 vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY; 180 120 181 - __debug_save_state(vcpu, &vcpu->arch.host_debug_state, 121 + __debug_save_state(vcpu, &vcpu->arch.host_debug_state.regs, 182 122 kern_hyp_va(vcpu->arch.host_cpu_context)); 123 + __debug_save_spe()(&vcpu->arch.host_debug_state.pmscr_el1); 183 124 } 184 125 185 126 void __hyp_text __debug_cond_restore_host_state(struct kvm_vcpu *vcpu) 186 127 { 187 - __debug_restore_state(vcpu, &vcpu->arch.host_debug_state, 128 + __debug_restore_spe(vcpu->arch.host_debug_state.pmscr_el1); 129 + __debug_restore_state(vcpu, &vcpu->arch.host_debug_state.regs, 188 130 kern_hyp_va(vcpu->arch.host_cpu_context)); 189 131 190 132 if (vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
+16 -1
arch/arm64/kvm/hyp/switch.c
··· 103 103 static void __hyp_text __deactivate_traps_vhe(void) 104 104 { 105 105 extern char vectors[]; /* kernel exception vectors */ 106 + u64 mdcr_el2 = read_sysreg(mdcr_el2); 106 107 108 + mdcr_el2 &= MDCR_EL2_HPMN_MASK | 109 + MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT | 110 + MDCR_EL2_TPMS; 111 + 112 + write_sysreg(mdcr_el2, mdcr_el2); 107 113 write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2); 108 114 write_sysreg(CPACR_EL1_FPEN, cpacr_el1); 109 115 write_sysreg(vectors, vbar_el1); ··· 117 111 118 112 static void __hyp_text __deactivate_traps_nvhe(void) 119 113 { 114 + u64 mdcr_el2 = read_sysreg(mdcr_el2); 115 + 116 + mdcr_el2 &= MDCR_EL2_HPMN_MASK; 117 + mdcr_el2 |= MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT; 118 + 119 + write_sysreg(mdcr_el2, mdcr_el2); 120 120 write_sysreg(HCR_RW, hcr_el2); 121 121 write_sysreg(CPTR_EL2_DEFAULT, cptr_el2); 122 122 } ··· 144 132 145 133 __deactivate_traps_arch()(); 146 134 write_sysreg(0, hstr_el2); 147 - write_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, mdcr_el2); 148 135 write_sysreg(0, pmuserenr_el0); 149 136 } 150 137 ··· 368 357 } 369 358 370 359 __debug_save_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt); 360 + /* 361 + * This must come after restoring the host sysregs, since a non-VHE 362 + * system may enable SPE here and make use of the TTBRs. 363 + */ 371 364 __debug_cond_restore_host_state(vcpu); 372 365 373 366 return exit_code;
+7 -6
arch/arm64/kvm/hyp/tlb.c
··· 16 16 */ 17 17 18 18 #include <asm/kvm_hyp.h> 19 + #include <asm/tlbflush.h> 19 20 20 21 void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) 21 22 { ··· 33 32 * whole of Stage-1. Weep... 34 33 */ 35 34 ipa >>= 12; 36 - asm volatile("tlbi ipas2e1is, %0" : : "r" (ipa)); 35 + __tlbi(ipas2e1is, ipa); 37 36 38 37 /* 39 38 * We have to ensure completion of the invalidation at Stage-2, ··· 42 41 * the Stage-1 invalidation happened first. 43 42 */ 44 43 dsb(ish); 45 - asm volatile("tlbi vmalle1is" : : ); 44 + __tlbi(vmalle1is); 46 45 dsb(ish); 47 46 isb(); 48 47 ··· 58 57 write_sysreg(kvm->arch.vttbr, vttbr_el2); 59 58 isb(); 60 59 61 - asm volatile("tlbi vmalls12e1is" : : ); 60 + __tlbi(vmalls12e1is); 62 61 dsb(ish); 63 62 isb(); 64 63 ··· 73 72 write_sysreg(kvm->arch.vttbr, vttbr_el2); 74 73 isb(); 75 74 76 - asm volatile("tlbi vmalle1" : : ); 75 + __tlbi(vmalle1); 77 76 dsb(nsh); 78 77 isb(); 79 78 ··· 83 82 void __hyp_text __kvm_flush_vm_context(void) 84 83 { 85 84 dsb(ishst); 86 - asm volatile("tlbi alle1is \n" 87 - "ic ialluis ": : ); 85 + __tlbi(alle1is); 86 + asm volatile("ic ialluis" : : ); 88 87 dsb(ish); 89 88 }
+2
arch/arm64/mm/Makefile
··· 6 6 obj-$(CONFIG_ARM64_PTDUMP_CORE) += dump.o 7 7 obj-$(CONFIG_ARM64_PTDUMP_DEBUGFS) += ptdump_debugfs.o 8 8 obj-$(CONFIG_NUMA) += numa.o 9 + obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o 10 + KASAN_SANITIZE_physaddr.o += n 9 11 10 12 obj-$(CONFIG_KASAN) += kasan_init.o 11 13 KASAN_SANITIZE_kasan_init.o := n
+11
arch/arm64/mm/context.c
··· 79 79 } 80 80 } 81 81 82 + static void set_reserved_asid_bits(void) 83 + { 84 + if (IS_ENABLED(CONFIG_QCOM_FALKOR_ERRATUM_1003) && 85 + cpus_have_const_cap(ARM64_WORKAROUND_QCOM_FALKOR_E1003)) 86 + __set_bit(FALKOR_RESERVED_ASID, asid_map); 87 + } 88 + 82 89 static void flush_context(unsigned int cpu) 83 90 { 84 91 int i; ··· 93 86 94 87 /* Update the list of reserved ASIDs and the ASID bitmap. */ 95 88 bitmap_clear(asid_map, 0, NUM_USER_ASIDS); 89 + 90 + set_reserved_asid_bits(); 96 91 97 92 /* 98 93 * Ensure the generation bump is observed before we xchg the ··· 252 243 if (!asid_map) 253 244 panic("Failed to allocate bitmap for %lu ASIDs\n", 254 245 NUM_USER_ASIDS); 246 + 247 + set_reserved_asid_bits(); 255 248 256 249 pr_info("ASID allocator initialised with %lu entries\n", NUM_USER_ASIDS); 257 250 return 0;
+28 -10
arch/arm64/mm/dma-mapping.c
··· 211 211 dma_addr_t dev_addr; 212 212 213 213 dev_addr = swiotlb_map_page(dev, page, offset, size, dir, attrs); 214 - if (!is_device_dma_coherent(dev)) 214 + if (!is_device_dma_coherent(dev) && 215 + (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) 215 216 __dma_map_area(phys_to_virt(dma_to_phys(dev, dev_addr)), size, dir); 216 217 217 218 return dev_addr; ··· 223 222 size_t size, enum dma_data_direction dir, 224 223 unsigned long attrs) 225 224 { 226 - if (!is_device_dma_coherent(dev)) 225 + if (!is_device_dma_coherent(dev) && 226 + (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) 227 227 __dma_unmap_area(phys_to_virt(dma_to_phys(dev, dev_addr)), size, dir); 228 228 swiotlb_unmap_page(dev, dev_addr, size, dir, attrs); 229 229 } ··· 237 235 int i, ret; 238 236 239 237 ret = swiotlb_map_sg_attrs(dev, sgl, nelems, dir, attrs); 240 - if (!is_device_dma_coherent(dev)) 238 + if (!is_device_dma_coherent(dev) && 239 + (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) 241 240 for_each_sg(sgl, sg, ret, i) 242 241 __dma_map_area(phys_to_virt(dma_to_phys(dev, sg->dma_address)), 243 242 sg->length, dir); ··· 254 251 struct scatterlist *sg; 255 252 int i; 256 253 257 - if (!is_device_dma_coherent(dev)) 254 + if (!is_device_dma_coherent(dev) && 255 + (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) 258 256 for_each_sg(sgl, sg, nelems, i) 259 257 __dma_unmap_area(phys_to_virt(dma_to_phys(dev, sg->dma_address)), 260 258 sg->length, dir); ··· 356 352 return 1; 357 353 } 358 354 355 + static int __swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t addr) 356 + { 357 + if (swiotlb) 358 + return swiotlb_dma_mapping_error(hwdev, addr); 359 + return 0; 360 + } 361 + 359 362 static struct dma_map_ops swiotlb_dma_ops = { 360 363 .alloc = __dma_alloc, 361 364 .free = __dma_free, ··· 377 366 .sync_sg_for_cpu = __swiotlb_sync_sg_for_cpu, 378 367 .sync_sg_for_device = __swiotlb_sync_sg_for_device, 379 368 .dma_supported = __swiotlb_dma_supported, 380 - .mapping_error = swiotlb_dma_mapping_error, 369 + .mapping_error = __swiotlb_dma_mapping_error, 381 370 }; 382 371 383 372 static int __init atomic_pool_init(void) ··· 841 830 * then the IOMMU core will have already configured a group for this 842 831 * device, and allocated the default domain for that group. 843 832 */ 844 - if (!domain || iommu_dma_init_domain(domain, dma_base, size, dev)) { 845 - pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", 846 - dev_name(dev)); 847 - return false; 833 + if (!domain) 834 + goto out_err; 835 + 836 + if (domain->type == IOMMU_DOMAIN_DMA) { 837 + if (iommu_dma_init_domain(domain, dma_base, size, dev)) 838 + goto out_err; 839 + 840 + dev->archdata.dma_ops = &iommu_dma_ops; 848 841 } 849 842 850 - dev->archdata.dma_ops = &iommu_dma_ops; 851 843 return true; 844 + out_err: 845 + pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", 846 + dev_name(dev)); 847 + return false; 852 848 } 853 849 854 850 static void queue_iommu_attach(struct device *dev, const struct iommu_ops *ops,
-14
arch/arm64/mm/fault.c
··· 691 691 return 0; 692 692 } 693 693 #endif /* CONFIG_ARM64_PAN */ 694 - 695 - #ifdef CONFIG_ARM64_UAO 696 - /* 697 - * Kernel threads have fs=KERNEL_DS by default, and don't need to call 698 - * set_fs(), devtmpfs in particular relies on this behaviour. 699 - * We need to enable the feature at runtime (instead of adding it to 700 - * PSR_MODE_EL1h) as the feature may not be implemented by the cpu. 701 - */ 702 - int cpu_enable_uao(void *__unused) 703 - { 704 - asm(SET_PSTATE_UAO(1)); 705 - return 0; 706 - } 707 - #endif /* CONFIG_ARM64_UAO */
+7 -5
arch/arm64/mm/init.c
··· 36 36 #include <linux/efi.h> 37 37 #include <linux/swiotlb.h> 38 38 #include <linux/vmalloc.h> 39 + #include <linux/mm.h> 39 40 40 41 #include <asm/boot.h> 41 42 #include <asm/fixmap.h> ··· 210 209 * linear mapping. Take care not to clip the kernel which may be 211 210 * high in memory. 212 211 */ 213 - memblock_remove(max_t(u64, memstart_addr + linear_region_size, __pa(_end)), 214 - ULLONG_MAX); 212 + memblock_remove(max_t(u64, memstart_addr + linear_region_size, 213 + __pa_symbol(_end)), ULLONG_MAX); 215 214 if (memstart_addr + linear_region_size < memblock_end_of_DRAM()) { 216 215 /* ensure that memstart_addr remains sufficiently aligned */ 217 216 memstart_addr = round_up(memblock_end_of_DRAM() - linear_region_size, ··· 226 225 */ 227 226 if (memory_limit != (phys_addr_t)ULLONG_MAX) { 228 227 memblock_mem_limit_remove_map(memory_limit); 229 - memblock_add(__pa(_text), (u64)(_end - _text)); 228 + memblock_add(__pa_symbol(_text), (u64)(_end - _text)); 230 229 } 231 230 232 231 if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { ··· 279 278 * Register the kernel text, kernel data, initrd, and initial 280 279 * pagetables with memblock. 281 280 */ 282 - memblock_reserve(__pa(_text), _end - _text); 281 + memblock_reserve(__pa_symbol(_text), _end - _text); 283 282 #ifdef CONFIG_BLK_DEV_INITRD 284 283 if (initrd_start) { 285 284 memblock_reserve(initrd_start, initrd_end - initrd_start); ··· 487 486 488 487 void free_initmem(void) 489 488 { 490 - free_reserved_area(__va(__pa(__init_begin)), __va(__pa(__init_end)), 489 + free_reserved_area(lm_alias(__init_begin), 490 + lm_alias(__init_end), 491 491 0, "unused kernel"); 492 492 /* 493 493 * Unmap the __init region but leave the VM area in place. This
+1 -1
arch/arm64/mm/ioremap.c
··· 88 88 * We could get an address outside vmalloc range in case 89 89 * of ioremap_cache() reusing a RAM mapping. 90 90 */ 91 - if (VMALLOC_START <= addr && addr < VMALLOC_END) 91 + if (is_vmalloc_addr((void *)addr)) 92 92 vunmap((void *)addr); 93 93 } 94 94 EXPORT_SYMBOL(__iounmap);
+15 -7
arch/arm64/mm/kasan_init.c
··· 15 15 #include <linux/kernel.h> 16 16 #include <linux/memblock.h> 17 17 #include <linux/start_kernel.h> 18 + #include <linux/mm.h> 18 19 19 20 #include <asm/mmu_context.h> 20 21 #include <asm/kernel-pgtable.h> ··· 27 26 28 27 static pgd_t tmp_pg_dir[PTRS_PER_PGD] __initdata __aligned(PGD_SIZE); 29 28 29 + /* 30 + * The p*d_populate functions call virt_to_phys implicitly so they can't be used 31 + * directly on kernel symbols (bm_p*d). All the early functions are called too 32 + * early to use lm_alias so __p*d_populate functions must be used to populate 33 + * with the physical address from __pa_symbol. 34 + */ 35 + 30 36 static void __init kasan_early_pte_populate(pmd_t *pmd, unsigned long addr, 31 37 unsigned long end) 32 38 { ··· 41 33 unsigned long next; 42 34 43 35 if (pmd_none(*pmd)) 44 - pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); 36 + __pmd_populate(pmd, __pa_symbol(kasan_zero_pte), PMD_TYPE_TABLE); 45 37 46 38 pte = pte_offset_kimg(pmd, addr); 47 39 do { 48 40 next = addr + PAGE_SIZE; 49 - set_pte(pte, pfn_pte(virt_to_pfn(kasan_zero_page), 41 + set_pte(pte, pfn_pte(sym_to_pfn(kasan_zero_page), 50 42 PAGE_KERNEL)); 51 43 } while (pte++, addr = next, addr != end && pte_none(*pte)); 52 44 } ··· 59 51 unsigned long next; 60 52 61 53 if (pud_none(*pud)) 62 - pud_populate(&init_mm, pud, kasan_zero_pmd); 54 + __pud_populate(pud, __pa_symbol(kasan_zero_pmd), PMD_TYPE_TABLE); 63 55 64 56 pmd = pmd_offset_kimg(pud, addr); 65 57 do { ··· 76 68 unsigned long next; 77 69 78 70 if (pgd_none(*pgd)) 79 - pgd_populate(&init_mm, pgd, kasan_zero_pud); 71 + __pgd_populate(pgd, __pa_symbol(kasan_zero_pud), PUD_TYPE_TABLE); 80 72 81 73 pud = pud_offset_kimg(pgd, addr); 82 74 do { ··· 156 148 */ 157 149 memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir)); 158 150 dsb(ishst); 159 - cpu_replace_ttbr1(tmp_pg_dir); 151 + cpu_replace_ttbr1(lm_alias(tmp_pg_dir)); 160 152 161 153 clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); 162 154 ··· 207 199 */ 208 200 for (i = 0; i < PTRS_PER_PTE; i++) 209 201 set_pte(&kasan_zero_pte[i], 210 - pfn_pte(virt_to_pfn(kasan_zero_page), PAGE_KERNEL_RO)); 202 + pfn_pte(sym_to_pfn(kasan_zero_page), PAGE_KERNEL_RO)); 211 203 212 204 memset(kasan_zero_page, 0, PAGE_SIZE); 213 - cpu_replace_ttbr1(swapper_pg_dir); 205 + cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); 214 206 215 207 /* At this point kasan is fully initialized. Enable error messages */ 216 208 init_task.kasan_depth = 0;
+22 -13
arch/arm64/mm/mmu.c
··· 28 28 #include <linux/memblock.h> 29 29 #include <linux/fs.h> 30 30 #include <linux/io.h> 31 + #include <linux/mm.h> 31 32 32 33 #include <asm/barrier.h> 33 34 #include <asm/cputype.h> ··· 360 359 361 360 static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end) 362 361 { 363 - unsigned long kernel_start = __pa(_text); 364 - unsigned long kernel_end = __pa(__init_begin); 362 + phys_addr_t kernel_start = __pa_symbol(_text); 363 + phys_addr_t kernel_end = __pa_symbol(__init_begin); 365 364 366 365 /* 367 366 * Take care not to create a writable alias for the ··· 428 427 unsigned long section_size; 429 428 430 429 section_size = (unsigned long)_etext - (unsigned long)_text; 431 - create_mapping_late(__pa(_text), (unsigned long)_text, 430 + create_mapping_late(__pa_symbol(_text), (unsigned long)_text, 432 431 section_size, PAGE_KERNEL_ROX); 433 432 /* 434 433 * mark .rodata as read only. Use __init_begin rather than __end_rodata 435 434 * to cover NOTES and EXCEPTION_TABLE. 436 435 */ 437 436 section_size = (unsigned long)__init_begin - (unsigned long)__start_rodata; 438 - create_mapping_late(__pa(__start_rodata), (unsigned long)__start_rodata, 437 + create_mapping_late(__pa_symbol(__start_rodata), (unsigned long)__start_rodata, 439 438 section_size, PAGE_KERNEL_RO); 440 439 441 440 /* flush the TLBs after updating live kernel mappings */ ··· 447 446 static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, 448 447 pgprot_t prot, struct vm_struct *vma) 449 448 { 450 - phys_addr_t pa_start = __pa(va_start); 449 + phys_addr_t pa_start = __pa_symbol(va_start); 451 450 unsigned long size = va_end - va_start; 452 451 453 452 BUG_ON(!PAGE_ALIGNED(pa_start)); ··· 495 494 */ 496 495 BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); 497 496 set_pud(pud_set_fixmap_offset(pgd, FIXADDR_START), 498 - __pud(__pa(bm_pmd) | PUD_TYPE_TABLE)); 497 + __pud(__pa_symbol(bm_pmd) | PUD_TYPE_TABLE)); 499 498 pud_clear_fixmap(); 500 499 } else { 501 500 BUG(); ··· 525 524 * To do this we need to go via a temporary pgd. 526 525 */ 527 526 cpu_replace_ttbr1(__va(pgd_phys)); 528 - memcpy(swapper_pg_dir, pgd, PAGE_SIZE); 529 - cpu_replace_ttbr1(swapper_pg_dir); 527 + memcpy(swapper_pg_dir, pgd, PGD_SIZE); 528 + cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); 530 529 531 530 pgd_clear_fixmap(); 532 531 memblock_free(pgd_phys, PAGE_SIZE); ··· 535 534 * We only reuse the PGD from the swapper_pg_dir, not the pud + pmd 536 535 * allocated with it. 537 536 */ 538 - memblock_free(__pa(swapper_pg_dir) + PAGE_SIZE, 537 + memblock_free(__pa_symbol(swapper_pg_dir) + PAGE_SIZE, 539 538 SWAPPER_DIR_SIZE - PAGE_SIZE); 540 539 } 541 540 ··· 646 645 return &bm_pte[pte_index(addr)]; 647 646 } 648 647 648 + /* 649 + * The p*d_populate functions call virt_to_phys implicitly so they can't be used 650 + * directly on kernel symbols (bm_p*d). This function is called too early to use 651 + * lm_alias so __p*d_populate functions must be used to populate with the 652 + * physical address from __pa_symbol. 653 + */ 649 654 void __init early_fixmap_init(void) 650 655 { 651 656 pgd_t *pgd; ··· 661 654 662 655 pgd = pgd_offset_k(addr); 663 656 if (CONFIG_PGTABLE_LEVELS > 3 && 664 - !(pgd_none(*pgd) || pgd_page_paddr(*pgd) == __pa(bm_pud))) { 657 + !(pgd_none(*pgd) || pgd_page_paddr(*pgd) == __pa_symbol(bm_pud))) { 665 658 /* 666 659 * We only end up here if the kernel mapping and the fixmap 667 660 * share the top level pgd entry, which should only happen on ··· 670 663 BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); 671 664 pud = pud_offset_kimg(pgd, addr); 672 665 } else { 673 - pgd_populate(&init_mm, pgd, bm_pud); 666 + if (pgd_none(*pgd)) 667 + __pgd_populate(pgd, __pa_symbol(bm_pud), PUD_TYPE_TABLE); 674 668 pud = fixmap_pud(addr); 675 669 } 676 - pud_populate(&init_mm, pud, bm_pmd); 670 + if (pud_none(*pud)) 671 + __pud_populate(pud, __pa_symbol(bm_pmd), PMD_TYPE_TABLE); 677 672 pmd = fixmap_pmd(addr); 678 - pmd_populate_kernel(&init_mm, pmd, bm_pte); 673 + __pmd_populate(pmd, __pa_symbol(bm_pte), PMD_TYPE_TABLE); 679 674 680 675 /* 681 676 * The boot-ioremap range spans multiple pmds, for which
+30
arch/arm64/mm/physaddr.c
··· 1 + #include <linux/bug.h> 2 + #include <linux/export.h> 3 + #include <linux/types.h> 4 + #include <linux/mmdebug.h> 5 + #include <linux/mm.h> 6 + 7 + #include <asm/memory.h> 8 + 9 + phys_addr_t __virt_to_phys(unsigned long x) 10 + { 11 + WARN(!__is_lm_address(x), 12 + "virt_to_phys used for non-linear address: %pK (%pS)\n", 13 + (void *)x, 14 + (void *)x); 15 + 16 + return __virt_to_phys_nodebug(x); 17 + } 18 + EXPORT_SYMBOL(__virt_to_phys); 19 + 20 + phys_addr_t __phys_addr_symbol(unsigned long x) 21 + { 22 + /* 23 + * This is bounds checking against the kernel image only. 24 + * __pa_symbol should only be used on kernel symbol addresses. 25 + */ 26 + VIRTUAL_BUG_ON(x < (unsigned long) KERNEL_START || 27 + x > (unsigned long) KERNEL_END); 28 + return __pa_symbol_nodebug(x); 29 + } 30 + EXPORT_SYMBOL(__phys_addr_symbol);
+1
arch/arm64/mm/proc.S
··· 138 138 * - pgd_phys - physical address of new TTB 139 139 */ 140 140 ENTRY(cpu_do_switch_mm) 141 + pre_ttbr0_update_workaround x0, x1, x2 141 142 mmid x1, x1 // get mm->context.id 142 143 bfi x0, x1, #48, #16 // set the ASID 143 144 msr ttbr0_el1, x0 // set TTBR0
+1
arch/x86/Kconfig
··· 46 46 select ARCH_CLOCKSOURCE_DATA 47 47 select ARCH_DISCARD_MEMBLOCK 48 48 select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI 49 + select ARCH_HAS_DEBUG_VIRTUAL 49 50 select ARCH_HAS_DEVMEM_IS_ALLOWED 50 51 select ARCH_HAS_ELF_RANDOMIZE 51 52 select ARCH_HAS_FAST_MULTIPLIER
+4 -4
drivers/acpi/arm64/iort.c
··· 333 333 return NULL; 334 334 335 335 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, 336 - node->mapping_offset); 336 + node->mapping_offset + index * sizeof(*map)); 337 337 338 338 /* Firmware bug! */ 339 339 if (!map->output_reference) { ··· 348 348 if (!(IORT_TYPE_MASK(parent->type) & type_mask)) 349 349 return NULL; 350 350 351 - if (map[index].flags & ACPI_IORT_ID_SINGLE_MAPPING) { 351 + if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { 352 352 if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || 353 353 node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { 354 - *id_out = map[index].output_base; 354 + *id_out = map->output_base; 355 355 return parent; 356 356 } 357 357 } ··· 828 828 829 829 pdev = platform_device_alloc(ops->name, PLATFORM_DEVID_AUTO); 830 830 if (!pdev) 831 - return PTR_ERR(pdev); 831 + return -ENOMEM; 832 832 833 833 count = ops->iommu_count_resources(node); 834 834
+2 -2
drivers/firmware/psci.c
··· 383 383 u32 *state = __this_cpu_read(psci_power_state); 384 384 385 385 return psci_ops.cpu_suspend(state[index - 1], 386 - virt_to_phys(cpu_resume)); 386 + __pa_symbol(cpu_resume)); 387 387 } 388 388 389 389 int psci_cpu_suspend_enter(unsigned long index) ··· 419 419 static int psci_system_suspend(unsigned long unused) 420 420 { 421 421 return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), 422 - virt_to_phys(cpu_resume), 0, 0); 422 + __pa_symbol(cpu_resume), 0, 0); 423 423 } 424 424 425 425 static int psci_system_suspend_enter(suspend_state_t state)
+10 -3
drivers/firmware/qcom_scm-64.c
··· 91 91 dma_addr_t args_phys = 0; 92 92 void *args_virt = NULL; 93 93 size_t alloc_len; 94 + struct arm_smccc_quirk quirk = {.id = ARM_SMCCC_QUIRK_QCOM_A6}; 94 95 95 96 if (unlikely(arglen > N_REGISTER_ARGS)) { 96 97 alloc_len = N_EXT_QCOM_SCM_ARGS * sizeof(u64); ··· 132 131 qcom_smccc_convention, 133 132 ARM_SMCCC_OWNER_SIP, fn_id); 134 133 134 + quirk.state.a6 = 0; 135 + 135 136 do { 136 - arm_smccc_smc(cmd, desc->arginfo, desc->args[0], 137 - desc->args[1], desc->args[2], x5, 0, 0, 138 - res); 137 + arm_smccc_smc_quirk(cmd, desc->arginfo, desc->args[0], 138 + desc->args[1], desc->args[2], x5, 139 + quirk.state.a6, 0, res, &quirk); 140 + 141 + if (res->a0 == QCOM_SCM_INTERRUPTED) 142 + cmd = res->a0; 143 + 139 144 } while (res->a0 == QCOM_SCM_INTERRUPTED); 140 145 141 146 mutex_unlock(&qcom_scm_lock);
+26
drivers/of/base.c
··· 25 25 #include <linux/cpu.h> 26 26 #include <linux/module.h> 27 27 #include <linux/of.h> 28 + #include <linux/of_device.h> 28 29 #include <linux/of_graph.h> 29 30 #include <linux/spinlock.h> 30 31 #include <linux/slab.h> ··· 2266 2265 return child; 2267 2266 2268 2267 return NULL; 2268 + } 2269 + 2270 + /** 2271 + * of_find_last_cache_level - Find the level at which the last cache is 2272 + * present for the given logical cpu 2273 + * 2274 + * @cpu: cpu number(logical index) for which the last cache level is needed 2275 + * 2276 + * Returns the the level at which the last cache is present. It is exactly 2277 + * same as the total number of cache levels for the given logical cpu. 2278 + */ 2279 + int of_find_last_cache_level(unsigned int cpu) 2280 + { 2281 + u32 cache_level = 0; 2282 + struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu); 2283 + 2284 + while (np) { 2285 + prev = np; 2286 + of_node_put(np); 2287 + np = of_find_next_cache_node(np); 2288 + } 2289 + 2290 + of_property_read_u32(prev, "cache-level", &cache_level); 2291 + 2292 + return cache_level; 2269 2293 } 2270 2294 2271 2295 /**
+9
drivers/perf/Kconfig
··· 12 12 Say y if you want to use CPU performance monitors on ARM-based 13 13 systems. 14 14 15 + config QCOM_L2_PMU 16 + bool "Qualcomm Technologies L2-cache PMU" 17 + depends on ARCH_QCOM && ARM64 && PERF_EVENTS && ACPI 18 + help 19 + Provides support for the L2 cache performance monitor unit (PMU) 20 + in Qualcomm Technologies processors. 21 + Adds the L2 cache PMU into the perf events subsystem for 22 + monitoring L2 cache events. 23 + 15 24 config XGENE_PMU 16 25 depends on PERF_EVENTS && ARCH_XGENE 17 26 bool "APM X-Gene SoC PMU"
+1
drivers/perf/Makefile
··· 1 1 obj-$(CONFIG_ARM_PMU) += arm_pmu.o 2 + obj-$(CONFIG_QCOM_L2_PMU) += qcom_l2_pmu.o 2 3 obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o
+1013
drivers/perf/qcom_l2_pmu.c
··· 1 + /* Copyright (c) 2015-2017 The Linux Foundation. All rights reserved. 2 + * 3 + * This program is free software; you can redistribute it and/or modify 4 + * it under the terms of the GNU General Public License version 2 and 5 + * only version 2 as published by the Free Software Foundation. 6 + * 7 + * This program is distributed in the hope that it will be useful, 8 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 + * GNU General Public License for more details. 11 + */ 12 + #include <linux/acpi.h> 13 + #include <linux/bitops.h> 14 + #include <linux/bug.h> 15 + #include <linux/cpuhotplug.h> 16 + #include <linux/cpumask.h> 17 + #include <linux/device.h> 18 + #include <linux/errno.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/irq.h> 21 + #include <linux/kernel.h> 22 + #include <linux/list.h> 23 + #include <linux/percpu.h> 24 + #include <linux/perf_event.h> 25 + #include <linux/platform_device.h> 26 + #include <linux/smp.h> 27 + #include <linux/spinlock.h> 28 + #include <linux/sysfs.h> 29 + #include <linux/types.h> 30 + 31 + #include <asm/barrier.h> 32 + #include <asm/local64.h> 33 + #include <asm/sysreg.h> 34 + 35 + #define MAX_L2_CTRS 9 36 + 37 + #define L2PMCR_NUM_EV_SHIFT 11 38 + #define L2PMCR_NUM_EV_MASK 0x1F 39 + 40 + #define L2PMCR 0x400 41 + #define L2PMCNTENCLR 0x403 42 + #define L2PMCNTENSET 0x404 43 + #define L2PMINTENCLR 0x405 44 + #define L2PMINTENSET 0x406 45 + #define L2PMOVSCLR 0x407 46 + #define L2PMOVSSET 0x408 47 + #define L2PMCCNTCR 0x409 48 + #define L2PMCCNTR 0x40A 49 + #define L2PMCCNTSR 0x40C 50 + #define L2PMRESR 0x410 51 + #define IA_L2PMXEVCNTCR_BASE 0x420 52 + #define IA_L2PMXEVCNTR_BASE 0x421 53 + #define IA_L2PMXEVFILTER_BASE 0x423 54 + #define IA_L2PMXEVTYPER_BASE 0x424 55 + 56 + #define IA_L2_REG_OFFSET 0x10 57 + 58 + #define L2PMXEVFILTER_SUFILTER_ALL 0x000E0000 59 + #define L2PMXEVFILTER_ORGFILTER_IDINDEP 0x00000004 60 + #define L2PMXEVFILTER_ORGFILTER_ALL 0x00000003 61 + 62 + #define L2EVTYPER_REG_SHIFT 3 63 + 64 + #define L2PMRESR_GROUP_BITS 8 65 + #define L2PMRESR_GROUP_MASK GENMASK(7, 0) 66 + 67 + #define L2CYCLE_CTR_BIT 31 68 + #define L2CYCLE_CTR_RAW_CODE 0xFE 69 + 70 + #define L2PMCR_RESET_ALL 0x6 71 + #define L2PMCR_COUNTERS_ENABLE 0x1 72 + #define L2PMCR_COUNTERS_DISABLE 0x0 73 + 74 + #define L2PMRESR_EN BIT_ULL(63) 75 + 76 + #define L2_EVT_MASK 0x00000FFF 77 + #define L2_EVT_CODE_MASK 0x00000FF0 78 + #define L2_EVT_GRP_MASK 0x0000000F 79 + #define L2_EVT_CODE_SHIFT 4 80 + #define L2_EVT_GRP_SHIFT 0 81 + 82 + #define L2_EVT_CODE(event) (((event) & L2_EVT_CODE_MASK) >> L2_EVT_CODE_SHIFT) 83 + #define L2_EVT_GROUP(event) (((event) & L2_EVT_GRP_MASK) >> L2_EVT_GRP_SHIFT) 84 + 85 + #define L2_EVT_GROUP_MAX 7 86 + 87 + #define L2_COUNTER_RELOAD BIT_ULL(31) 88 + #define L2_CYCLE_COUNTER_RELOAD BIT_ULL(63) 89 + 90 + #define L2CPUSRSELR_EL1 sys_reg(3, 3, 15, 0, 6) 91 + #define L2CPUSRDR_EL1 sys_reg(3, 3, 15, 0, 7) 92 + 93 + #define reg_idx(reg, i) (((i) * IA_L2_REG_OFFSET) + reg##_BASE) 94 + 95 + static DEFINE_RAW_SPINLOCK(l2_access_lock); 96 + 97 + /** 98 + * set_l2_indirect_reg: write value to an L2 register 99 + * @reg: Address of L2 register. 100 + * @value: Value to be written to register. 101 + * 102 + * Use architecturally required barriers for ordering between system register 103 + * accesses 104 + */ 105 + static void set_l2_indirect_reg(u64 reg, u64 val) 106 + { 107 + unsigned long flags; 108 + 109 + raw_spin_lock_irqsave(&l2_access_lock, flags); 110 + write_sysreg_s(reg, L2CPUSRSELR_EL1); 111 + isb(); 112 + write_sysreg_s(val, L2CPUSRDR_EL1); 113 + isb(); 114 + raw_spin_unlock_irqrestore(&l2_access_lock, flags); 115 + } 116 + 117 + /** 118 + * get_l2_indirect_reg: read an L2 register value 119 + * @reg: Address of L2 register. 120 + * 121 + * Use architecturally required barriers for ordering between system register 122 + * accesses 123 + */ 124 + static u64 get_l2_indirect_reg(u64 reg) 125 + { 126 + u64 val; 127 + unsigned long flags; 128 + 129 + raw_spin_lock_irqsave(&l2_access_lock, flags); 130 + write_sysreg_s(reg, L2CPUSRSELR_EL1); 131 + isb(); 132 + val = read_sysreg_s(L2CPUSRDR_EL1); 133 + raw_spin_unlock_irqrestore(&l2_access_lock, flags); 134 + 135 + return val; 136 + } 137 + 138 + struct cluster_pmu; 139 + 140 + /* 141 + * Aggregate PMU. Implements the core pmu functions and manages 142 + * the hardware PMUs. 143 + */ 144 + struct l2cache_pmu { 145 + struct hlist_node node; 146 + u32 num_pmus; 147 + struct pmu pmu; 148 + int num_counters; 149 + cpumask_t cpumask; 150 + struct platform_device *pdev; 151 + struct cluster_pmu * __percpu *pmu_cluster; 152 + struct list_head clusters; 153 + }; 154 + 155 + /* 156 + * The cache is made up of one or more clusters, each cluster has its own PMU. 157 + * Each cluster is associated with one or more CPUs. 158 + * This structure represents one of the hardware PMUs. 159 + * 160 + * Events can be envisioned as a 2-dimensional array. Each column represents 161 + * a group of events. There are 8 groups. Only one entry from each 162 + * group can be in use at a time. 163 + * 164 + * Events are specified as 0xCCG, where CC is 2 hex digits specifying 165 + * the code (array row) and G specifies the group (column). 166 + * 167 + * In addition there is a cycle counter event specified by L2CYCLE_CTR_RAW_CODE 168 + * which is outside the above scheme. 169 + */ 170 + struct cluster_pmu { 171 + struct list_head next; 172 + struct perf_event *events[MAX_L2_CTRS]; 173 + struct l2cache_pmu *l2cache_pmu; 174 + DECLARE_BITMAP(used_counters, MAX_L2_CTRS); 175 + DECLARE_BITMAP(used_groups, L2_EVT_GROUP_MAX + 1); 176 + int irq; 177 + int cluster_id; 178 + /* The CPU that is used for collecting events on this cluster */ 179 + int on_cpu; 180 + /* All the CPUs associated with this cluster */ 181 + cpumask_t cluster_cpus; 182 + spinlock_t pmu_lock; 183 + }; 184 + 185 + #define to_l2cache_pmu(p) (container_of(p, struct l2cache_pmu, pmu)) 186 + 187 + static u32 l2_cycle_ctr_idx; 188 + static u32 l2_counter_present_mask; 189 + 190 + static inline u32 idx_to_reg_bit(u32 idx) 191 + { 192 + if (idx == l2_cycle_ctr_idx) 193 + return BIT(L2CYCLE_CTR_BIT); 194 + 195 + return BIT(idx); 196 + } 197 + 198 + static inline struct cluster_pmu *get_cluster_pmu( 199 + struct l2cache_pmu *l2cache_pmu, int cpu) 200 + { 201 + return *per_cpu_ptr(l2cache_pmu->pmu_cluster, cpu); 202 + } 203 + 204 + static void cluster_pmu_reset(void) 205 + { 206 + /* Reset all counters */ 207 + set_l2_indirect_reg(L2PMCR, L2PMCR_RESET_ALL); 208 + set_l2_indirect_reg(L2PMCNTENCLR, l2_counter_present_mask); 209 + set_l2_indirect_reg(L2PMINTENCLR, l2_counter_present_mask); 210 + set_l2_indirect_reg(L2PMOVSCLR, l2_counter_present_mask); 211 + } 212 + 213 + static inline void cluster_pmu_enable(void) 214 + { 215 + set_l2_indirect_reg(L2PMCR, L2PMCR_COUNTERS_ENABLE); 216 + } 217 + 218 + static inline void cluster_pmu_disable(void) 219 + { 220 + set_l2_indirect_reg(L2PMCR, L2PMCR_COUNTERS_DISABLE); 221 + } 222 + 223 + static inline void cluster_pmu_counter_set_value(u32 idx, u64 value) 224 + { 225 + if (idx == l2_cycle_ctr_idx) 226 + set_l2_indirect_reg(L2PMCCNTR, value); 227 + else 228 + set_l2_indirect_reg(reg_idx(IA_L2PMXEVCNTR, idx), value); 229 + } 230 + 231 + static inline u64 cluster_pmu_counter_get_value(u32 idx) 232 + { 233 + u64 value; 234 + 235 + if (idx == l2_cycle_ctr_idx) 236 + value = get_l2_indirect_reg(L2PMCCNTR); 237 + else 238 + value = get_l2_indirect_reg(reg_idx(IA_L2PMXEVCNTR, idx)); 239 + 240 + return value; 241 + } 242 + 243 + static inline void cluster_pmu_counter_enable(u32 idx) 244 + { 245 + set_l2_indirect_reg(L2PMCNTENSET, idx_to_reg_bit(idx)); 246 + } 247 + 248 + static inline void cluster_pmu_counter_disable(u32 idx) 249 + { 250 + set_l2_indirect_reg(L2PMCNTENCLR, idx_to_reg_bit(idx)); 251 + } 252 + 253 + static inline void cluster_pmu_counter_enable_interrupt(u32 idx) 254 + { 255 + set_l2_indirect_reg(L2PMINTENSET, idx_to_reg_bit(idx)); 256 + } 257 + 258 + static inline void cluster_pmu_counter_disable_interrupt(u32 idx) 259 + { 260 + set_l2_indirect_reg(L2PMINTENCLR, idx_to_reg_bit(idx)); 261 + } 262 + 263 + static inline void cluster_pmu_set_evccntcr(u32 val) 264 + { 265 + set_l2_indirect_reg(L2PMCCNTCR, val); 266 + } 267 + 268 + static inline void cluster_pmu_set_evcntcr(u32 ctr, u32 val) 269 + { 270 + set_l2_indirect_reg(reg_idx(IA_L2PMXEVCNTCR, ctr), val); 271 + } 272 + 273 + static inline void cluster_pmu_set_evtyper(u32 ctr, u32 val) 274 + { 275 + set_l2_indirect_reg(reg_idx(IA_L2PMXEVTYPER, ctr), val); 276 + } 277 + 278 + static void cluster_pmu_set_resr(struct cluster_pmu *cluster, 279 + u32 event_group, u32 event_cc) 280 + { 281 + u64 field; 282 + u64 resr_val; 283 + u32 shift; 284 + unsigned long flags; 285 + 286 + shift = L2PMRESR_GROUP_BITS * event_group; 287 + field = ((u64)(event_cc & L2PMRESR_GROUP_MASK) << shift); 288 + 289 + spin_lock_irqsave(&cluster->pmu_lock, flags); 290 + 291 + resr_val = get_l2_indirect_reg(L2PMRESR); 292 + resr_val &= ~(L2PMRESR_GROUP_MASK << shift); 293 + resr_val |= field; 294 + resr_val |= L2PMRESR_EN; 295 + set_l2_indirect_reg(L2PMRESR, resr_val); 296 + 297 + spin_unlock_irqrestore(&cluster->pmu_lock, flags); 298 + } 299 + 300 + /* 301 + * Hardware allows filtering of events based on the originating 302 + * CPU. Turn this off by setting filter bits to allow events from 303 + * all CPUS, subunits and ID independent events in this cluster. 304 + */ 305 + static inline void cluster_pmu_set_evfilter_sys_mode(u32 ctr) 306 + { 307 + u32 val = L2PMXEVFILTER_SUFILTER_ALL | 308 + L2PMXEVFILTER_ORGFILTER_IDINDEP | 309 + L2PMXEVFILTER_ORGFILTER_ALL; 310 + 311 + set_l2_indirect_reg(reg_idx(IA_L2PMXEVFILTER, ctr), val); 312 + } 313 + 314 + static inline u32 cluster_pmu_getreset_ovsr(void) 315 + { 316 + u32 result = get_l2_indirect_reg(L2PMOVSSET); 317 + 318 + set_l2_indirect_reg(L2PMOVSCLR, result); 319 + return result; 320 + } 321 + 322 + static inline bool cluster_pmu_has_overflowed(u32 ovsr) 323 + { 324 + return !!(ovsr & l2_counter_present_mask); 325 + } 326 + 327 + static inline bool cluster_pmu_counter_has_overflowed(u32 ovsr, u32 idx) 328 + { 329 + return !!(ovsr & idx_to_reg_bit(idx)); 330 + } 331 + 332 + static void l2_cache_event_update(struct perf_event *event) 333 + { 334 + struct hw_perf_event *hwc = &event->hw; 335 + u64 delta, prev, now; 336 + u32 idx = hwc->idx; 337 + 338 + do { 339 + prev = local64_read(&hwc->prev_count); 340 + now = cluster_pmu_counter_get_value(idx); 341 + } while (local64_cmpxchg(&hwc->prev_count, prev, now) != prev); 342 + 343 + /* 344 + * The cycle counter is 64-bit, but all other counters are 345 + * 32-bit, and we must handle 32-bit overflow explicitly. 346 + */ 347 + delta = now - prev; 348 + if (idx != l2_cycle_ctr_idx) 349 + delta &= 0xffffffff; 350 + 351 + local64_add(delta, &event->count); 352 + } 353 + 354 + static void l2_cache_cluster_set_period(struct cluster_pmu *cluster, 355 + struct hw_perf_event *hwc) 356 + { 357 + u32 idx = hwc->idx; 358 + u64 new; 359 + 360 + /* 361 + * We limit the max period to half the max counter value so 362 + * that even in the case of extreme interrupt latency the 363 + * counter will (hopefully) not wrap past its initial value. 364 + */ 365 + if (idx == l2_cycle_ctr_idx) 366 + new = L2_CYCLE_COUNTER_RELOAD; 367 + else 368 + new = L2_COUNTER_RELOAD; 369 + 370 + local64_set(&hwc->prev_count, new); 371 + cluster_pmu_counter_set_value(idx, new); 372 + } 373 + 374 + static int l2_cache_get_event_idx(struct cluster_pmu *cluster, 375 + struct perf_event *event) 376 + { 377 + struct hw_perf_event *hwc = &event->hw; 378 + int idx; 379 + int num_ctrs = cluster->l2cache_pmu->num_counters - 1; 380 + unsigned int group; 381 + 382 + if (hwc->config_base == L2CYCLE_CTR_RAW_CODE) { 383 + if (test_and_set_bit(l2_cycle_ctr_idx, cluster->used_counters)) 384 + return -EAGAIN; 385 + 386 + return l2_cycle_ctr_idx; 387 + } 388 + 389 + idx = find_first_zero_bit(cluster->used_counters, num_ctrs); 390 + if (idx == num_ctrs) 391 + /* The counters are all in use. */ 392 + return -EAGAIN; 393 + 394 + /* 395 + * Check for column exclusion: event column already in use by another 396 + * event. This is for events which are not in the same group. 397 + * Conflicting events in the same group are detected in event_init. 398 + */ 399 + group = L2_EVT_GROUP(hwc->config_base); 400 + if (test_bit(group, cluster->used_groups)) 401 + return -EAGAIN; 402 + 403 + set_bit(idx, cluster->used_counters); 404 + set_bit(group, cluster->used_groups); 405 + 406 + return idx; 407 + } 408 + 409 + static void l2_cache_clear_event_idx(struct cluster_pmu *cluster, 410 + struct perf_event *event) 411 + { 412 + struct hw_perf_event *hwc = &event->hw; 413 + int idx = hwc->idx; 414 + 415 + clear_bit(idx, cluster->used_counters); 416 + if (hwc->config_base != L2CYCLE_CTR_RAW_CODE) 417 + clear_bit(L2_EVT_GROUP(hwc->config_base), cluster->used_groups); 418 + } 419 + 420 + static irqreturn_t l2_cache_handle_irq(int irq_num, void *data) 421 + { 422 + struct cluster_pmu *cluster = data; 423 + int num_counters = cluster->l2cache_pmu->num_counters; 424 + u32 ovsr; 425 + int idx; 426 + 427 + ovsr = cluster_pmu_getreset_ovsr(); 428 + if (!cluster_pmu_has_overflowed(ovsr)) 429 + return IRQ_NONE; 430 + 431 + for_each_set_bit(idx, cluster->used_counters, num_counters) { 432 + struct perf_event *event = cluster->events[idx]; 433 + struct hw_perf_event *hwc; 434 + 435 + if (WARN_ON_ONCE(!event)) 436 + continue; 437 + 438 + if (!cluster_pmu_counter_has_overflowed(ovsr, idx)) 439 + continue; 440 + 441 + l2_cache_event_update(event); 442 + hwc = &event->hw; 443 + 444 + l2_cache_cluster_set_period(cluster, hwc); 445 + } 446 + 447 + return IRQ_HANDLED; 448 + } 449 + 450 + /* 451 + * Implementation of abstract pmu functionality required by 452 + * the core perf events code. 453 + */ 454 + 455 + static void l2_cache_pmu_enable(struct pmu *pmu) 456 + { 457 + /* 458 + * Although there is only one PMU (per socket) controlling multiple 459 + * physical PMUs (per cluster), because we do not support per-task mode 460 + * each event is associated with a CPU. Each event has pmu_enable 461 + * called on its CPU, so here it is only necessary to enable the 462 + * counters for the current CPU. 463 + */ 464 + 465 + cluster_pmu_enable(); 466 + } 467 + 468 + static void l2_cache_pmu_disable(struct pmu *pmu) 469 + { 470 + cluster_pmu_disable(); 471 + } 472 + 473 + static int l2_cache_event_init(struct perf_event *event) 474 + { 475 + struct hw_perf_event *hwc = &event->hw; 476 + struct cluster_pmu *cluster; 477 + struct perf_event *sibling; 478 + struct l2cache_pmu *l2cache_pmu; 479 + 480 + if (event->attr.type != event->pmu->type) 481 + return -ENOENT; 482 + 483 + l2cache_pmu = to_l2cache_pmu(event->pmu); 484 + 485 + if (hwc->sample_period) { 486 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 487 + "Sampling not supported\n"); 488 + return -EOPNOTSUPP; 489 + } 490 + 491 + if (event->cpu < 0) { 492 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 493 + "Per-task mode not supported\n"); 494 + return -EOPNOTSUPP; 495 + } 496 + 497 + /* We cannot filter accurately so we just don't allow it. */ 498 + if (event->attr.exclude_user || event->attr.exclude_kernel || 499 + event->attr.exclude_hv || event->attr.exclude_idle) { 500 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 501 + "Can't exclude execution levels\n"); 502 + return -EOPNOTSUPP; 503 + } 504 + 505 + if (((L2_EVT_GROUP(event->attr.config) > L2_EVT_GROUP_MAX) || 506 + ((event->attr.config & ~L2_EVT_MASK) != 0)) && 507 + (event->attr.config != L2CYCLE_CTR_RAW_CODE)) { 508 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 509 + "Invalid config %llx\n", 510 + event->attr.config); 511 + return -EINVAL; 512 + } 513 + 514 + /* Don't allow groups with mixed PMUs, except for s/w events */ 515 + if (event->group_leader->pmu != event->pmu && 516 + !is_software_event(event->group_leader)) { 517 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 518 + "Can't create mixed PMU group\n"); 519 + return -EINVAL; 520 + } 521 + 522 + list_for_each_entry(sibling, &event->group_leader->sibling_list, 523 + group_entry) 524 + if (sibling->pmu != event->pmu && 525 + !is_software_event(sibling)) { 526 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 527 + "Can't create mixed PMU group\n"); 528 + return -EINVAL; 529 + } 530 + 531 + cluster = get_cluster_pmu(l2cache_pmu, event->cpu); 532 + if (!cluster) { 533 + /* CPU has not been initialised */ 534 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 535 + "CPU%d not associated with L2 cluster\n", event->cpu); 536 + return -EINVAL; 537 + } 538 + 539 + /* Ensure all events in a group are on the same cpu */ 540 + if ((event->group_leader != event) && 541 + (cluster->on_cpu != event->group_leader->cpu)) { 542 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 543 + "Can't create group on CPUs %d and %d", 544 + event->cpu, event->group_leader->cpu); 545 + return -EINVAL; 546 + } 547 + 548 + if ((event != event->group_leader) && 549 + (L2_EVT_GROUP(event->group_leader->attr.config) == 550 + L2_EVT_GROUP(event->attr.config))) { 551 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 552 + "Column exclusion: conflicting events %llx %llx\n", 553 + event->group_leader->attr.config, 554 + event->attr.config); 555 + return -EINVAL; 556 + } 557 + 558 + list_for_each_entry(sibling, &event->group_leader->sibling_list, 559 + group_entry) { 560 + if ((sibling != event) && 561 + (L2_EVT_GROUP(sibling->attr.config) == 562 + L2_EVT_GROUP(event->attr.config))) { 563 + dev_dbg_ratelimited(&l2cache_pmu->pdev->dev, 564 + "Column exclusion: conflicting events %llx %llx\n", 565 + sibling->attr.config, 566 + event->attr.config); 567 + return -EINVAL; 568 + } 569 + } 570 + 571 + hwc->idx = -1; 572 + hwc->config_base = event->attr.config; 573 + 574 + /* 575 + * Ensure all events are on the same cpu so all events are in the 576 + * same cpu context, to avoid races on pmu_enable etc. 577 + */ 578 + event->cpu = cluster->on_cpu; 579 + 580 + return 0; 581 + } 582 + 583 + static void l2_cache_event_start(struct perf_event *event, int flags) 584 + { 585 + struct cluster_pmu *cluster; 586 + struct hw_perf_event *hwc = &event->hw; 587 + int idx = hwc->idx; 588 + u32 config; 589 + u32 event_cc, event_group; 590 + 591 + hwc->state = 0; 592 + 593 + cluster = get_cluster_pmu(to_l2cache_pmu(event->pmu), event->cpu); 594 + 595 + l2_cache_cluster_set_period(cluster, hwc); 596 + 597 + if (hwc->config_base == L2CYCLE_CTR_RAW_CODE) { 598 + cluster_pmu_set_evccntcr(0); 599 + } else { 600 + config = hwc->config_base; 601 + event_cc = L2_EVT_CODE(config); 602 + event_group = L2_EVT_GROUP(config); 603 + 604 + cluster_pmu_set_evcntcr(idx, 0); 605 + cluster_pmu_set_evtyper(idx, event_group); 606 + cluster_pmu_set_resr(cluster, event_group, event_cc); 607 + cluster_pmu_set_evfilter_sys_mode(idx); 608 + } 609 + 610 + cluster_pmu_counter_enable_interrupt(idx); 611 + cluster_pmu_counter_enable(idx); 612 + } 613 + 614 + static void l2_cache_event_stop(struct perf_event *event, int flags) 615 + { 616 + struct hw_perf_event *hwc = &event->hw; 617 + int idx = hwc->idx; 618 + 619 + if (hwc->state & PERF_HES_STOPPED) 620 + return; 621 + 622 + cluster_pmu_counter_disable_interrupt(idx); 623 + cluster_pmu_counter_disable(idx); 624 + 625 + if (flags & PERF_EF_UPDATE) 626 + l2_cache_event_update(event); 627 + hwc->state |= PERF_HES_STOPPED | PERF_HES_UPTODATE; 628 + } 629 + 630 + static int l2_cache_event_add(struct perf_event *event, int flags) 631 + { 632 + struct hw_perf_event *hwc = &event->hw; 633 + int idx; 634 + int err = 0; 635 + struct cluster_pmu *cluster; 636 + 637 + cluster = get_cluster_pmu(to_l2cache_pmu(event->pmu), event->cpu); 638 + 639 + idx = l2_cache_get_event_idx(cluster, event); 640 + if (idx < 0) 641 + return idx; 642 + 643 + hwc->idx = idx; 644 + hwc->state = PERF_HES_STOPPED | PERF_HES_UPTODATE; 645 + cluster->events[idx] = event; 646 + local64_set(&hwc->prev_count, 0); 647 + 648 + if (flags & PERF_EF_START) 649 + l2_cache_event_start(event, flags); 650 + 651 + /* Propagate changes to the userspace mapping. */ 652 + perf_event_update_userpage(event); 653 + 654 + return err; 655 + } 656 + 657 + static void l2_cache_event_del(struct perf_event *event, int flags) 658 + { 659 + struct hw_perf_event *hwc = &event->hw; 660 + struct cluster_pmu *cluster; 661 + int idx = hwc->idx; 662 + 663 + cluster = get_cluster_pmu(to_l2cache_pmu(event->pmu), event->cpu); 664 + 665 + l2_cache_event_stop(event, flags | PERF_EF_UPDATE); 666 + cluster->events[idx] = NULL; 667 + l2_cache_clear_event_idx(cluster, event); 668 + 669 + perf_event_update_userpage(event); 670 + } 671 + 672 + static void l2_cache_event_read(struct perf_event *event) 673 + { 674 + l2_cache_event_update(event); 675 + } 676 + 677 + static ssize_t l2_cache_pmu_cpumask_show(struct device *dev, 678 + struct device_attribute *attr, 679 + char *buf) 680 + { 681 + struct l2cache_pmu *l2cache_pmu = to_l2cache_pmu(dev_get_drvdata(dev)); 682 + 683 + return cpumap_print_to_pagebuf(true, buf, &l2cache_pmu->cpumask); 684 + } 685 + 686 + static struct device_attribute l2_cache_pmu_cpumask_attr = 687 + __ATTR(cpumask, S_IRUGO, l2_cache_pmu_cpumask_show, NULL); 688 + 689 + static struct attribute *l2_cache_pmu_cpumask_attrs[] = { 690 + &l2_cache_pmu_cpumask_attr.attr, 691 + NULL, 692 + }; 693 + 694 + static struct attribute_group l2_cache_pmu_cpumask_group = { 695 + .attrs = l2_cache_pmu_cpumask_attrs, 696 + }; 697 + 698 + /* CCG format for perf RAW codes. */ 699 + PMU_FORMAT_ATTR(l2_code, "config:4-11"); 700 + PMU_FORMAT_ATTR(l2_group, "config:0-3"); 701 + static struct attribute *l2_cache_pmu_formats[] = { 702 + &format_attr_l2_code.attr, 703 + &format_attr_l2_group.attr, 704 + NULL, 705 + }; 706 + 707 + static struct attribute_group l2_cache_pmu_format_group = { 708 + .name = "format", 709 + .attrs = l2_cache_pmu_formats, 710 + }; 711 + 712 + static const struct attribute_group *l2_cache_pmu_attr_grps[] = { 713 + &l2_cache_pmu_format_group, 714 + &l2_cache_pmu_cpumask_group, 715 + NULL, 716 + }; 717 + 718 + /* 719 + * Generic device handlers 720 + */ 721 + 722 + static const struct acpi_device_id l2_cache_pmu_acpi_match[] = { 723 + { "QCOM8130", }, 724 + { } 725 + }; 726 + 727 + static int get_num_counters(void) 728 + { 729 + int val; 730 + 731 + val = get_l2_indirect_reg(L2PMCR); 732 + 733 + /* 734 + * Read number of counters from L2PMCR and add 1 735 + * for the cycle counter. 736 + */ 737 + return ((val >> L2PMCR_NUM_EV_SHIFT) & L2PMCR_NUM_EV_MASK) + 1; 738 + } 739 + 740 + static struct cluster_pmu *l2_cache_associate_cpu_with_cluster( 741 + struct l2cache_pmu *l2cache_pmu, int cpu) 742 + { 743 + u64 mpidr; 744 + int cpu_cluster_id; 745 + struct cluster_pmu *cluster = NULL; 746 + 747 + /* 748 + * This assumes that the cluster_id is in MPIDR[aff1] for 749 + * single-threaded cores, and MPIDR[aff2] for multi-threaded 750 + * cores. This logic will have to be updated if this changes. 751 + */ 752 + mpidr = read_cpuid_mpidr(); 753 + if (mpidr & MPIDR_MT_BITMASK) 754 + cpu_cluster_id = MPIDR_AFFINITY_LEVEL(mpidr, 2); 755 + else 756 + cpu_cluster_id = MPIDR_AFFINITY_LEVEL(mpidr, 1); 757 + 758 + list_for_each_entry(cluster, &l2cache_pmu->clusters, next) { 759 + if (cluster->cluster_id != cpu_cluster_id) 760 + continue; 761 + 762 + dev_info(&l2cache_pmu->pdev->dev, 763 + "CPU%d associated with cluster %d\n", cpu, 764 + cluster->cluster_id); 765 + cpumask_set_cpu(cpu, &cluster->cluster_cpus); 766 + *per_cpu_ptr(l2cache_pmu->pmu_cluster, cpu) = cluster; 767 + break; 768 + } 769 + 770 + return cluster; 771 + } 772 + 773 + static int l2cache_pmu_online_cpu(unsigned int cpu, struct hlist_node *node) 774 + { 775 + struct cluster_pmu *cluster; 776 + struct l2cache_pmu *l2cache_pmu; 777 + 778 + l2cache_pmu = hlist_entry_safe(node, struct l2cache_pmu, node); 779 + cluster = get_cluster_pmu(l2cache_pmu, cpu); 780 + if (!cluster) { 781 + /* First time this CPU has come online */ 782 + cluster = l2_cache_associate_cpu_with_cluster(l2cache_pmu, cpu); 783 + if (!cluster) { 784 + /* Only if broken firmware doesn't list every cluster */ 785 + WARN_ONCE(1, "No L2 cache cluster for CPU%d\n", cpu); 786 + return 0; 787 + } 788 + } 789 + 790 + /* If another CPU is managing this cluster, we're done */ 791 + if (cluster->on_cpu != -1) 792 + return 0; 793 + 794 + /* 795 + * All CPUs on this cluster were down, use this one. 796 + * Reset to put it into sane state. 797 + */ 798 + cluster->on_cpu = cpu; 799 + cpumask_set_cpu(cpu, &l2cache_pmu->cpumask); 800 + cluster_pmu_reset(); 801 + 802 + WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(cpu))); 803 + enable_irq(cluster->irq); 804 + 805 + return 0; 806 + } 807 + 808 + static int l2cache_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) 809 + { 810 + struct cluster_pmu *cluster; 811 + struct l2cache_pmu *l2cache_pmu; 812 + cpumask_t cluster_online_cpus; 813 + unsigned int target; 814 + 815 + l2cache_pmu = hlist_entry_safe(node, struct l2cache_pmu, node); 816 + cluster = get_cluster_pmu(l2cache_pmu, cpu); 817 + if (!cluster) 818 + return 0; 819 + 820 + /* If this CPU is not managing the cluster, we're done */ 821 + if (cluster->on_cpu != cpu) 822 + return 0; 823 + 824 + /* Give up ownership of cluster */ 825 + cpumask_clear_cpu(cpu, &l2cache_pmu->cpumask); 826 + cluster->on_cpu = -1; 827 + 828 + /* Any other CPU for this cluster which is still online */ 829 + cpumask_and(&cluster_online_cpus, &cluster->cluster_cpus, 830 + cpu_online_mask); 831 + target = cpumask_any_but(&cluster_online_cpus, cpu); 832 + if (target >= nr_cpu_ids) { 833 + disable_irq(cluster->irq); 834 + return 0; 835 + } 836 + 837 + perf_pmu_migrate_context(&l2cache_pmu->pmu, cpu, target); 838 + cluster->on_cpu = target; 839 + cpumask_set_cpu(target, &l2cache_pmu->cpumask); 840 + WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(target))); 841 + 842 + return 0; 843 + } 844 + 845 + static int l2_cache_pmu_probe_cluster(struct device *dev, void *data) 846 + { 847 + struct platform_device *pdev = to_platform_device(dev->parent); 848 + struct platform_device *sdev = to_platform_device(dev); 849 + struct l2cache_pmu *l2cache_pmu = data; 850 + struct cluster_pmu *cluster; 851 + struct acpi_device *device; 852 + unsigned long fw_cluster_id; 853 + int err; 854 + int irq; 855 + 856 + if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) 857 + return -ENODEV; 858 + 859 + if (kstrtoul(device->pnp.unique_id, 10, &fw_cluster_id) < 0) { 860 + dev_err(&pdev->dev, "unable to read ACPI uid\n"); 861 + return -ENODEV; 862 + } 863 + 864 + cluster = devm_kzalloc(&pdev->dev, sizeof(*cluster), GFP_KERNEL); 865 + if (!cluster) 866 + return -ENOMEM; 867 + 868 + INIT_LIST_HEAD(&cluster->next); 869 + list_add(&cluster->next, &l2cache_pmu->clusters); 870 + cluster->cluster_id = fw_cluster_id; 871 + 872 + irq = platform_get_irq(sdev, 0); 873 + if (irq < 0) { 874 + dev_err(&pdev->dev, 875 + "Failed to get valid irq for cluster %ld\n", 876 + fw_cluster_id); 877 + return irq; 878 + } 879 + irq_set_status_flags(irq, IRQ_NOAUTOEN); 880 + cluster->irq = irq; 881 + 882 + cluster->l2cache_pmu = l2cache_pmu; 883 + cluster->on_cpu = -1; 884 + 885 + err = devm_request_irq(&pdev->dev, irq, l2_cache_handle_irq, 886 + IRQF_NOBALANCING | IRQF_NO_THREAD, 887 + "l2-cache-pmu", cluster); 888 + if (err) { 889 + dev_err(&pdev->dev, 890 + "Unable to request IRQ%d for L2 PMU counters\n", irq); 891 + return err; 892 + } 893 + 894 + dev_info(&pdev->dev, 895 + "Registered L2 cache PMU cluster %ld\n", fw_cluster_id); 896 + 897 + spin_lock_init(&cluster->pmu_lock); 898 + 899 + l2cache_pmu->num_pmus++; 900 + 901 + return 0; 902 + } 903 + 904 + static int l2_cache_pmu_probe(struct platform_device *pdev) 905 + { 906 + int err; 907 + struct l2cache_pmu *l2cache_pmu; 908 + 909 + l2cache_pmu = 910 + devm_kzalloc(&pdev->dev, sizeof(*l2cache_pmu), GFP_KERNEL); 911 + if (!l2cache_pmu) 912 + return -ENOMEM; 913 + 914 + INIT_LIST_HEAD(&l2cache_pmu->clusters); 915 + 916 + platform_set_drvdata(pdev, l2cache_pmu); 917 + l2cache_pmu->pmu = (struct pmu) { 918 + /* suffix is instance id for future use with multiple sockets */ 919 + .name = "l2cache_0", 920 + .task_ctx_nr = perf_invalid_context, 921 + .pmu_enable = l2_cache_pmu_enable, 922 + .pmu_disable = l2_cache_pmu_disable, 923 + .event_init = l2_cache_event_init, 924 + .add = l2_cache_event_add, 925 + .del = l2_cache_event_del, 926 + .start = l2_cache_event_start, 927 + .stop = l2_cache_event_stop, 928 + .read = l2_cache_event_read, 929 + .attr_groups = l2_cache_pmu_attr_grps, 930 + }; 931 + 932 + l2cache_pmu->num_counters = get_num_counters(); 933 + l2cache_pmu->pdev = pdev; 934 + l2cache_pmu->pmu_cluster = devm_alloc_percpu(&pdev->dev, 935 + struct cluster_pmu *); 936 + if (!l2cache_pmu->pmu_cluster) 937 + return -ENOMEM; 938 + 939 + l2_cycle_ctr_idx = l2cache_pmu->num_counters - 1; 940 + l2_counter_present_mask = GENMASK(l2cache_pmu->num_counters - 2, 0) | 941 + BIT(L2CYCLE_CTR_BIT); 942 + 943 + cpumask_clear(&l2cache_pmu->cpumask); 944 + 945 + /* Read cluster info and initialize each cluster */ 946 + err = device_for_each_child(&pdev->dev, l2cache_pmu, 947 + l2_cache_pmu_probe_cluster); 948 + if (err) 949 + return err; 950 + 951 + if (l2cache_pmu->num_pmus == 0) { 952 + dev_err(&pdev->dev, "No hardware L2 cache PMUs found\n"); 953 + return -ENODEV; 954 + } 955 + 956 + err = cpuhp_state_add_instance(CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE, 957 + &l2cache_pmu->node); 958 + if (err) { 959 + dev_err(&pdev->dev, "Error %d registering hotplug", err); 960 + return err; 961 + } 962 + 963 + err = perf_pmu_register(&l2cache_pmu->pmu, l2cache_pmu->pmu.name, -1); 964 + if (err) { 965 + dev_err(&pdev->dev, "Error %d registering L2 cache PMU\n", err); 966 + goto out_unregister; 967 + } 968 + 969 + dev_info(&pdev->dev, "Registered L2 cache PMU using %d HW PMUs\n", 970 + l2cache_pmu->num_pmus); 971 + 972 + return err; 973 + 974 + out_unregister: 975 + cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE, 976 + &l2cache_pmu->node); 977 + return err; 978 + } 979 + 980 + static int l2_cache_pmu_remove(struct platform_device *pdev) 981 + { 982 + struct l2cache_pmu *l2cache_pmu = 983 + to_l2cache_pmu(platform_get_drvdata(pdev)); 984 + 985 + perf_pmu_unregister(&l2cache_pmu->pmu); 986 + cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE, 987 + &l2cache_pmu->node); 988 + return 0; 989 + } 990 + 991 + static struct platform_driver l2_cache_pmu_driver = { 992 + .driver = { 993 + .name = "qcom-l2cache-pmu", 994 + .acpi_match_table = ACPI_PTR(l2_cache_pmu_acpi_match), 995 + }, 996 + .probe = l2_cache_pmu_probe, 997 + .remove = l2_cache_pmu_remove, 998 + }; 999 + 1000 + static int __init register_l2_cache_pmu_driver(void) 1001 + { 1002 + int err; 1003 + 1004 + err = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE, 1005 + "AP_PERF_ARM_QCOM_L2_ONLINE", 1006 + l2cache_pmu_online_cpu, 1007 + l2cache_pmu_offline_cpu); 1008 + if (err) 1009 + return err; 1010 + 1011 + return platform_driver_register(&l2_cache_pmu_driver); 1012 + } 1013 + device_initcall(register_l2_cache_pmu_driver);
+1
drivers/perf/xgene_pmu.c
··· 25 25 #include <linux/interrupt.h> 26 26 #include <linux/io.h> 27 27 #include <linux/mfd/syscon.h> 28 + #include <linux/module.h> 28 29 #include <linux/of_address.h> 29 30 #include <linux/of_fdt.h> 30 31 #include <linux/of_irq.h>
+41 -11
include/linux/arm-smccc.h
··· 14 14 #ifndef __LINUX_ARM_SMCCC_H 15 15 #define __LINUX_ARM_SMCCC_H 16 16 17 - #include <linux/linkage.h> 18 - #include <linux/types.h> 19 - 20 17 /* 21 18 * This file provides common defines for ARM SMC Calling Convention as 22 19 * specified in ··· 57 60 #define ARM_SMCCC_OWNER_TRUSTED_OS 50 58 61 #define ARM_SMCCC_OWNER_TRUSTED_OS_END 63 59 62 63 + #define ARM_SMCCC_QUIRK_NONE 0 64 + #define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */ 65 + 66 + #ifndef __ASSEMBLY__ 67 + 68 + #include <linux/linkage.h> 69 + #include <linux/types.h> 60 70 /** 61 71 * struct arm_smccc_res - Result from SMC/HVC call 62 72 * @a0-a3 result values from registers 0 to 3 ··· 76 72 }; 77 73 78 74 /** 79 - * arm_smccc_smc() - make SMC calls 75 + * struct arm_smccc_quirk - Contains quirk information 76 + * @id: quirk identification 77 + * @state: quirk specific information 78 + * @a6: Qualcomm quirk entry for returning post-smc call contents of a6 79 + */ 80 + struct arm_smccc_quirk { 81 + int id; 82 + union { 83 + unsigned long a6; 84 + } state; 85 + }; 86 + 87 + /** 88 + * __arm_smccc_smc() - make SMC calls 80 89 * @a0-a7: arguments passed in registers 0 to 7 81 90 * @res: result values from registers 0 to 3 91 + * @quirk: points to an arm_smccc_quirk, or NULL when no quirks are required. 82 92 * 83 93 * This function is used to make SMC calls following SMC Calling Convention. 84 94 * The content of the supplied param are copied to registers 0 to 7 prior 85 95 * to the SMC instruction. The return values are updated with the content 86 - * from register 0 to 3 on return from the SMC instruction. 96 + * from register 0 to 3 on return from the SMC instruction. An optional 97 + * quirk structure provides vendor specific behavior. 87 98 */ 88 - asmlinkage void arm_smccc_smc(unsigned long a0, unsigned long a1, 99 + asmlinkage void __arm_smccc_smc(unsigned long a0, unsigned long a1, 89 100 unsigned long a2, unsigned long a3, unsigned long a4, 90 101 unsigned long a5, unsigned long a6, unsigned long a7, 91 - struct arm_smccc_res *res); 102 + struct arm_smccc_res *res, struct arm_smccc_quirk *quirk); 92 103 93 104 /** 94 - * arm_smccc_hvc() - make HVC calls 105 + * __arm_smccc_hvc() - make HVC calls 95 106 * @a0-a7: arguments passed in registers 0 to 7 96 107 * @res: result values from registers 0 to 3 108 + * @quirk: points to an arm_smccc_quirk, or NULL when no quirks are required. 97 109 * 98 110 * This function is used to make HVC calls following SMC Calling 99 111 * Convention. The content of the supplied param are copied to registers 0 100 112 * to 7 prior to the HVC instruction. The return values are updated with 101 - * the content from register 0 to 3 on return from the HVC instruction. 113 + * the content from register 0 to 3 on return from the HVC instruction. An 114 + * optional quirk structure provides vendor specific behavior. 102 115 */ 103 - asmlinkage void arm_smccc_hvc(unsigned long a0, unsigned long a1, 116 + asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1, 104 117 unsigned long a2, unsigned long a3, unsigned long a4, 105 118 unsigned long a5, unsigned long a6, unsigned long a7, 106 - struct arm_smccc_res *res); 119 + struct arm_smccc_res *res, struct arm_smccc_quirk *quirk); 107 120 121 + #define arm_smccc_smc(...) __arm_smccc_smc(__VA_ARGS__, NULL) 122 + 123 + #define arm_smccc_smc_quirk(...) __arm_smccc_smc(__VA_ARGS__) 124 + 125 + #define arm_smccc_hvc(...) __arm_smccc_hvc(__VA_ARGS__, NULL) 126 + 127 + #define arm_smccc_hvc_quirk(...) __arm_smccc_hvc(__VA_ARGS__) 128 + 129 + #endif /*__ASSEMBLY__*/ 108 130 #endif /*__LINUX_ARM_SMCCC_H*/
+1
include/linux/cpuhotplug.h
··· 137 137 CPUHP_AP_PERF_ARM_CCI_ONLINE, 138 138 CPUHP_AP_PERF_ARM_CCN_ONLINE, 139 139 CPUHP_AP_PERF_ARM_L2X0_ONLINE, 140 + CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE, 140 141 CPUHP_AP_WORKQUEUE_ONLINE, 141 142 CPUHP_AP_RCUTREE_ONLINE, 142 143 CPUHP_AP_ONLINE_DYN,
+4
include/linux/mm.h
··· 76 76 #define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) 77 77 #endif 78 78 79 + #ifndef lm_alias 80 + #define lm_alias(x) __va(__pa_symbol(x)) 81 + #endif 82 + 79 83 /* 80 84 * To prevent common memory management code establishing 81 85 * a zero page mapping on a read fault.
+1
include/linux/of.h
··· 280 280 281 281 /* cache lookup */ 282 282 extern struct device_node *of_find_next_cache_node(const struct device_node *); 283 + extern int of_find_last_cache_level(unsigned int cpu); 283 284 extern struct device_node *of_find_node_with_property( 284 285 struct device_node *from, const char *prop_name); 285 286
+1 -1
kernel/kexec_core.c
··· 1399 1399 1400 1400 phys_addr_t __weak paddr_vmcoreinfo_note(void) 1401 1401 { 1402 - return __pa((unsigned long)(char *)&vmcoreinfo_note); 1402 + return __pa_symbol((unsigned long)(char *)&vmcoreinfo_note); 1403 1403 } 1404 1404 1405 1405 static int __init crash_save_vmcoreinfo_init(void)
+4 -1
lib/Kconfig.debug
··· 622 622 623 623 If unsure, say N. 624 624 625 + config ARCH_HAS_DEBUG_VIRTUAL 626 + bool 627 + 625 628 config DEBUG_VIRTUAL 626 629 bool "Debug VM translations" 627 - depends on DEBUG_KERNEL && X86 630 + depends on DEBUG_KERNEL && ARCH_HAS_DEBUG_VIRTUAL 628 631 help 629 632 Enable some costly sanity checks in virtual to page code. This can 630 633 catch mistakes with virt_to_page() and friends.
+5 -10
mm/cma.c
··· 235 235 phys_addr_t highmem_start; 236 236 int ret = 0; 237 237 238 - #ifdef CONFIG_X86 239 238 /* 240 - * high_memory isn't direct mapped memory so retrieving its physical 241 - * address isn't appropriate. But it would be useful to check the 242 - * physical address of the highmem boundary so it's justifiable to get 243 - * the physical address from it. On x86 there is a validation check for 244 - * this case, so the following workaround is needed to avoid it. 239 + * We can't use __pa(high_memory) directly, since high_memory 240 + * isn't a valid direct map VA, and DEBUG_VIRTUAL will (validly) 241 + * complain. Find the boundary by adding one to the last valid 242 + * address. 245 243 */ 246 - highmem_start = __pa_nodebug(high_memory); 247 - #else 248 - highmem_start = __pa(high_memory); 249 - #endif 244 + highmem_start = __pa(high_memory - 1) + 1; 250 245 pr_debug("%s(size %pa, base %pa, limit %pa alignment %pa)\n", 251 246 __func__, &size, &base, &limit, &alignment); 252 247
+8 -7
mm/kasan/kasan_init.c
··· 15 15 #include <linux/kasan.h> 16 16 #include <linux/kernel.h> 17 17 #include <linux/memblock.h> 18 + #include <linux/mm.h> 18 19 #include <linux/pfn.h> 19 20 20 21 #include <asm/page.h> ··· 50 49 pte_t *pte = pte_offset_kernel(pmd, addr); 51 50 pte_t zero_pte; 52 51 53 - zero_pte = pfn_pte(PFN_DOWN(__pa(kasan_zero_page)), PAGE_KERNEL); 52 + zero_pte = pfn_pte(PFN_DOWN(__pa_symbol(kasan_zero_page)), PAGE_KERNEL); 54 53 zero_pte = pte_wrprotect(zero_pte); 55 54 56 55 while (addr + PAGE_SIZE <= end) { ··· 70 69 next = pmd_addr_end(addr, end); 71 70 72 71 if (IS_ALIGNED(addr, PMD_SIZE) && end - addr >= PMD_SIZE) { 73 - pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); 72 + pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); 74 73 continue; 75 74 } 76 75 ··· 93 92 if (IS_ALIGNED(addr, PUD_SIZE) && end - addr >= PUD_SIZE) { 94 93 pmd_t *pmd; 95 94 96 - pud_populate(&init_mm, pud, kasan_zero_pmd); 95 + pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd)); 97 96 pmd = pmd_offset(pud, addr); 98 - pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); 97 + pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); 99 98 continue; 100 99 } 101 100 ··· 136 135 * puds,pmds, so pgd_populate(), pud_populate() 137 136 * is noops. 138 137 */ 139 - pgd_populate(&init_mm, pgd, kasan_zero_pud); 138 + pgd_populate(&init_mm, pgd, lm_alias(kasan_zero_pud)); 140 139 pud = pud_offset(pgd, addr); 141 - pud_populate(&init_mm, pud, kasan_zero_pmd); 140 + pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd)); 142 141 pmd = pmd_offset(pud, addr); 143 - pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); 142 + pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); 144 143 continue; 145 144 } 146 145
+2 -2
mm/usercopy.c
··· 108 108 * __pa() is not just the reverse of __va(). This can be detected 109 109 * and checked: 110 110 */ 111 - textlow_linear = (unsigned long)__va(__pa(textlow)); 111 + textlow_linear = (unsigned long)lm_alias(textlow); 112 112 /* No different mapping: we're done. */ 113 113 if (textlow_linear == textlow) 114 114 return NULL; 115 115 116 116 /* Check the secondary mapping... */ 117 - texthigh_linear = (unsigned long)__va(__pa(texthigh)); 117 + texthigh_linear = (unsigned long)lm_alias(texthigh); 118 118 if (overlaps(ptr, n, textlow_linear, texthigh_linear)) 119 119 return "<linear kernel text>"; 120 120