diff options
281 files changed, 3891 insertions, 2398 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-platform-dock b/Documentation/ABI/testing/sysfs-devices-platform-dock new file mode 100644 index 000000000000..1d8c18f905c7 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-platform-dock | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | What: /sys/devices/platform/dock.N/docked | ||
| 2 | Date: Dec, 2006 | ||
| 3 | KernelVersion: 2.6.19 | ||
| 4 | Contact: linux-acpi@vger.kernel.org | ||
| 5 | Description: | ||
| 6 | (RO) Value 1 or 0 indicates whether the software believes the | ||
| 7 | laptop is docked in a docking station. | ||
| 8 | |||
| 9 | What: /sys/devices/platform/dock.N/undock | ||
| 10 | Date: Dec, 2006 | ||
| 11 | KernelVersion: 2.6.19 | ||
| 12 | Contact: linux-acpi@vger.kernel.org | ||
| 13 | Description: | ||
| 14 | (WO) Writing to this file causes the software to initiate an | ||
| 15 | undock request to the firmware. | ||
| 16 | |||
| 17 | What: /sys/devices/platform/dock.N/uid | ||
| 18 | Date: Feb, 2007 | ||
| 19 | KernelVersion: v2.6.21 | ||
| 20 | Contact: linux-acpi@vger.kernel.org | ||
| 21 | Description: | ||
| 22 | (RO) Displays the docking station the laptop is docked to. | ||
| 23 | |||
| 24 | What: /sys/devices/platform/dock.N/flags | ||
| 25 | Date: May, 2007 | ||
| 26 | KernelVersion: v2.6.21 | ||
| 27 | Contact: linux-acpi@vger.kernel.org | ||
| 28 | Description: | ||
| 29 | (RO) Show dock station flags, useful for checking if undock | ||
| 30 | request has been made by the user (from the immediate_undock | ||
| 31 | option). | ||
| 32 | |||
| 33 | What: /sys/devices/platform/dock.N/type | ||
| 34 | Date: Aug, 2008 | ||
| 35 | KernelVersion: v2.6.27 | ||
| 36 | Contact: linux-acpi@vger.kernel.org | ||
| 37 | Description: | ||
| 38 | (RO) Display the dock station type- dock_station, ata_bay or | ||
| 39 | battery_bay. | ||
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index bfd29bc8d37a..4ed63b6cfb15 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu | |||
| @@ -108,6 +108,8 @@ Description: CPU topology files that describe a logical CPU's relationship | |||
| 108 | 108 | ||
| 109 | What: /sys/devices/system/cpu/cpuidle/current_driver | 109 | What: /sys/devices/system/cpu/cpuidle/current_driver |
| 110 | /sys/devices/system/cpu/cpuidle/current_governer_ro | 110 | /sys/devices/system/cpu/cpuidle/current_governer_ro |
| 111 | /sys/devices/system/cpu/cpuidle/available_governors | ||
| 112 | /sys/devices/system/cpu/cpuidle/current_governor | ||
| 111 | Date: September 2007 | 113 | Date: September 2007 |
| 112 | Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> | 114 | Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> |
| 113 | Description: Discover cpuidle policy and mechanism | 115 | Description: Discover cpuidle policy and mechanism |
| @@ -119,13 +121,84 @@ Description: Discover cpuidle policy and mechanism | |||
| 119 | Idle policy (governor) is differentiated from idle mechanism | 121 | Idle policy (governor) is differentiated from idle mechanism |
| 120 | (driver) | 122 | (driver) |
| 121 | 123 | ||
| 122 | current_driver: displays current idle mechanism | 124 | current_driver: (RO) displays current idle mechanism |
| 123 | 125 | ||
| 124 | current_governor_ro: displays current idle policy | 126 | current_governor_ro: (RO) displays current idle policy |
| 127 | |||
| 128 | With the cpuidle_sysfs_switch boot option enabled (meant for | ||
| 129 | developer testing), the following three attributes are visible | ||
| 130 | instead: | ||
| 131 | |||
| 132 | current_driver: same as described above | ||
| 133 | |||
| 134 | available_governors: (RO) displays a space separated list of | ||
| 135 | available governors | ||
| 136 | |||
| 137 | current_governor: (RW) displays current idle policy. Users can | ||
| 138 | switch the governor at runtime by writing to this file. | ||
| 125 | 139 | ||
| 126 | See files in Documentation/cpuidle/ for more information. | 140 | See files in Documentation/cpuidle/ for more information. |
| 127 | 141 | ||
| 128 | 142 | ||
| 143 | What: /sys/devices/system/cpu/cpuX/cpuidle/stateN/name | ||
| 144 | /sys/devices/system/cpu/cpuX/cpuidle/stateN/latency | ||
| 145 | /sys/devices/system/cpu/cpuX/cpuidle/stateN/power | ||
| 146 | /sys/devices/system/cpu/cpuX/cpuidle/stateN/time | ||
| 147 | /sys/devices/system/cpu/cpuX/cpuidle/stateN/usage | ||
| 148 | Date: September 2007 | ||
| 149 | KernelVersion: v2.6.24 | ||
| 150 | Contact: Linux power management list <linux-pm@vger.kernel.org> | ||
| 151 | Description: | ||
| 152 | The directory /sys/devices/system/cpu/cpuX/cpuidle contains per | ||
| 153 | logical CPU specific cpuidle information for each online cpu X. | ||
| 154 | The processor idle states which are available for use have the | ||
| 155 | following attributes: | ||
| 156 | |||
| 157 | name: (RO) Name of the idle state (string). | ||
| 158 | |||
| 159 | latency: (RO) The latency to exit out of this idle state (in | ||
| 160 | microseconds). | ||
| 161 | |||
| 162 | power: (RO) The power consumed while in this idle state (in | ||
| 163 | milliwatts). | ||
| 164 | |||
| 165 | time: (RO) The total time spent in this idle state (in microseconds). | ||
| 166 | |||
| 167 | usage: (RO) Number of times this state was entered (a count). | ||
| 168 | |||
| 169 | |||
| 170 | What: /sys/devices/system/cpu/cpuX/cpuidle/stateN/desc | ||
| 171 | Date: February 2008 | ||
| 172 | KernelVersion: v2.6.25 | ||
| 173 | Contact: Linux power management list <linux-pm@vger.kernel.org> | ||
| 174 | Description: | ||
| 175 | (RO) A small description about the idle state (string). | ||
| 176 | |||
| 177 | |||
| 178 | What: /sys/devices/system/cpu/cpuX/cpuidle/stateN/disable | ||
| 179 | Date: March 2012 | ||
| 180 | KernelVersion: v3.10 | ||
| 181 | Contact: Linux power management list <linux-pm@vger.kernel.org> | ||
| 182 | Description: | ||
| 183 | (RW) Option to disable this idle state (bool). The behavior and | ||
| 184 | the effect of the disable variable depends on the implementation | ||
| 185 | of a particular governor. In the ladder governor, for example, | ||
| 186 | it is not coherent, i.e. if one is disabling a light state, then | ||
| 187 | all deeper states are disabled as well, but the disable variable | ||
| 188 | does not reflect it. Likewise, if one enables a deep state but a | ||
| 189 | lighter state still is disabled, then this has no effect. | ||
| 190 | |||
| 191 | |||
| 192 | What: /sys/devices/system/cpu/cpuX/cpuidle/stateN/residency | ||
| 193 | Date: March 2014 | ||
| 194 | KernelVersion: v3.15 | ||
| 195 | Contact: Linux power management list <linux-pm@vger.kernel.org> | ||
| 196 | Description: | ||
| 197 | (RO) Display the target residency i.e. the minimum amount of | ||
| 198 | time (in microseconds) this cpu should spend in this idle state | ||
| 199 | to make the transition worth the effort. | ||
| 200 | |||
| 201 | |||
| 129 | What: /sys/devices/system/cpu/cpu#/cpufreq/* | 202 | What: /sys/devices/system/cpu/cpu#/cpufreq/* |
| 130 | Date: pre-git history | 203 | Date: pre-git history |
| 131 | Contact: linux-pm@vger.kernel.org | 204 | Contact: linux-pm@vger.kernel.org |
diff --git a/Documentation/ABI/testing/sysfs-platform-dptf b/Documentation/ABI/testing/sysfs-platform-dptf new file mode 100644 index 000000000000..325dc0667dbb --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-dptf | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | What: /sys/bus/platform/devices/INT3407:00/dptf_power/charger_type | ||
| 2 | Date: Jul, 2016 | ||
| 3 | KernelVersion: v4.10 | ||
| 4 | Contact: linux-acpi@vger.kernel.org | ||
| 5 | Description: | ||
| 6 | (RO) The charger type - Traditional, Hybrid or NVDC. | ||
| 7 | |||
| 8 | What: /sys/bus/platform/devices/INT3407:00/dptf_power/adapter_rating_mw | ||
| 9 | Date: Jul, 2016 | ||
| 10 | KernelVersion: v4.10 | ||
| 11 | Contact: linux-acpi@vger.kernel.org | ||
| 12 | Description: | ||
| 13 | (RO) Adapter rating in milliwatts (the maximum Adapter power). | ||
| 14 | Must be 0 if no AC Adaptor is plugged in. | ||
| 15 | |||
| 16 | What: /sys/bus/platform/devices/INT3407:00/dptf_power/max_platform_power_mw | ||
| 17 | Date: Jul, 2016 | ||
| 18 | KernelVersion: v4.10 | ||
| 19 | Contact: linux-acpi@vger.kernel.org | ||
| 20 | Description: | ||
| 21 | (RO) Maximum platform power that can be supported by the battery | ||
| 22 | in milliwatts. | ||
| 23 | |||
| 24 | What: /sys/bus/platform/devices/INT3407:00/dptf_power/platform_power_source | ||
| 25 | Date: Jul, 2016 | ||
| 26 | KernelVersion: v4.10 | ||
| 27 | Contact: linux-acpi@vger.kernel.org | ||
| 28 | Description: | ||
| 29 | (RO) Display the platform power source | ||
| 30 | 0x00 = DC | ||
| 31 | 0x01 = AC | ||
| 32 | 0x02 = USB | ||
| 33 | 0x03 = Wireless Charger | ||
| 34 | |||
| 35 | What: /sys/bus/platform/devices/INT3407:00/dptf_power/battery_steady_power | ||
| 36 | Date: Jul, 2016 | ||
| 37 | KernelVersion: v4.10 | ||
| 38 | Contact: linux-acpi@vger.kernel.org | ||
| 39 | Description: | ||
| 40 | (RO) The maximum sustained power for battery in milliwatts. | ||
diff --git a/Documentation/atomic_bitops.txt b/Documentation/atomic_bitops.txt index 5550bfdcce5f..be70b32c95d9 100644 --- a/Documentation/atomic_bitops.txt +++ b/Documentation/atomic_bitops.txt | |||
| @@ -58,7 +58,12 @@ Like with atomic_t, the rule of thumb is: | |||
| 58 | 58 | ||
| 59 | - RMW operations that have a return value are fully ordered. | 59 | - RMW operations that have a return value are fully ordered. |
| 60 | 60 | ||
| 61 | Except for test_and_set_bit_lock() which has ACQUIRE semantics and | 61 | - RMW operations that are conditional are unordered on FAILURE, |
| 62 | otherwise the above rules apply. In the case of test_and_{}_bit() operations, | ||
| 63 | if the bit in memory is unchanged by the operation then it is deemed to have | ||
| 64 | failed. | ||
| 65 | |||
| 66 | Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics and | ||
| 62 | clear_bit_unlock() which has RELEASE semantics. | 67 | clear_bit_unlock() which has RELEASE semantics. |
| 63 | 68 | ||
| 64 | Since a platform only has a single means of achieving atomic operations | 69 | Since a platform only has a single means of achieving atomic operations |
diff --git a/Documentation/devicetree/bindings/power/mti,mips-cpc.txt b/Documentation/devicetree/bindings/power/mti,mips-cpc.txt new file mode 100644 index 000000000000..c6b82511ae8a --- /dev/null +++ b/Documentation/devicetree/bindings/power/mti,mips-cpc.txt | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | Binding for MIPS Cluster Power Controller (CPC). | ||
| 2 | |||
| 3 | This binding allows a system to specify where the CPC registers are | ||
| 4 | located. | ||
| 5 | |||
| 6 | Required properties: | ||
| 7 | compatible : Should be "mti,mips-cpc". | ||
| 8 | regs: Should describe the address & size of the CPC register region. | ||
diff --git a/Documentation/features/sched/membarrier-sync-core/arch-support.txt b/Documentation/features/sched/membarrier-sync-core/arch-support.txt new file mode 100644 index 000000000000..2c815a7f1ba7 --- /dev/null +++ b/Documentation/features/sched/membarrier-sync-core/arch-support.txt | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | # | ||
| 2 | # Feature name: membarrier-sync-core | ||
| 3 | # Kconfig: ARCH_HAS_MEMBARRIER_SYNC_CORE | ||
| 4 | # description: arch supports core serializing membarrier | ||
| 5 | # | ||
| 6 | # Architecture requirements | ||
| 7 | # | ||
| 8 | # * arm64 | ||
| 9 | # | ||
| 10 | # Rely on eret context synchronization when returning from IPI handler, and | ||
| 11 | # when returning to user-space. | ||
| 12 | # | ||
| 13 | # * x86 | ||
| 14 | # | ||
| 15 | # x86-32 uses IRET as return from interrupt, which takes care of the IPI. | ||
| 16 | # However, it uses both IRET and SYSEXIT to go back to user-space. The IRET | ||
| 17 | # instruction is core serializing, but not SYSEXIT. | ||
| 18 | # | ||
| 19 | # x86-64 uses IRET as return from interrupt, which takes care of the IPI. | ||
| 20 | # However, it can return to user-space through either SYSRETL (compat code), | ||
| 21 | # SYSRETQ, or IRET. | ||
| 22 | # | ||
| 23 | # Given that neither SYSRET{L,Q}, nor SYSEXIT, are core serializing, we rely | ||
| 24 | # instead on write_cr3() performed by switch_mm() to provide core serialization | ||
| 25 | # after changing the current mm, and deal with the special case of kthread -> | ||
| 26 | # uthread (temporarily keeping current mm into active_mm) by issuing a | ||
| 27 | # sync_core_before_usermode() in that specific case. | ||
| 28 | # | ||
| 29 | ----------------------- | ||
| 30 | | arch |status| | ||
| 31 | ----------------------- | ||
| 32 | | alpha: | TODO | | ||
| 33 | | arc: | TODO | | ||
| 34 | | arm: | TODO | | ||
| 35 | | arm64: | ok | | ||
| 36 | | blackfin: | TODO | | ||
| 37 | | c6x: | TODO | | ||
| 38 | | cris: | TODO | | ||
| 39 | | frv: | TODO | | ||
| 40 | | h8300: | TODO | | ||
| 41 | | hexagon: | TODO | | ||
| 42 | | ia64: | TODO | | ||
| 43 | | m32r: | TODO | | ||
| 44 | | m68k: | TODO | | ||
| 45 | | metag: | TODO | | ||
| 46 | | microblaze: | TODO | | ||
| 47 | | mips: | TODO | | ||
| 48 | | mn10300: | TODO | | ||
| 49 | | nios2: | TODO | | ||
| 50 | | openrisc: | TODO | | ||
| 51 | | parisc: | TODO | | ||
| 52 | | powerpc: | TODO | | ||
| 53 | | s390: | TODO | | ||
| 54 | | score: | TODO | | ||
| 55 | | sh: | TODO | | ||
| 56 | | sparc: | TODO | | ||
| 57 | | tile: | TODO | | ||
| 58 | | um: | TODO | | ||
| 59 | | unicore32: | TODO | | ||
| 60 | | x86: | ok | | ||
| 61 | | xtensa: | TODO | | ||
| 62 | ----------------------- | ||
diff --git a/Documentation/locking/mutex-design.txt b/Documentation/locking/mutex-design.txt index 60c482df1a38..818aca19612f 100644 --- a/Documentation/locking/mutex-design.txt +++ b/Documentation/locking/mutex-design.txt | |||
| @@ -21,37 +21,23 @@ Implementation | |||
| 21 | -------------- | 21 | -------------- |
| 22 | 22 | ||
| 23 | Mutexes are represented by 'struct mutex', defined in include/linux/mutex.h | 23 | Mutexes are represented by 'struct mutex', defined in include/linux/mutex.h |
| 24 | and implemented in kernel/locking/mutex.c. These locks use a three | 24 | and implemented in kernel/locking/mutex.c. These locks use an atomic variable |
| 25 | state atomic counter (->count) to represent the different possible | 25 | (->owner) to keep track of the lock state during its lifetime. Field owner |
| 26 | transitions that can occur during the lifetime of a lock: | 26 | actually contains 'struct task_struct *' to the current lock owner and it is |
| 27 | 27 | therefore NULL if not currently owned. Since task_struct pointers are aligned | |
| 28 | 1: unlocked | 28 | at at least L1_CACHE_BYTES, low bits (3) are used to store extra state (e.g., |
| 29 | 0: locked, no waiters | 29 | if waiter list is non-empty). In its most basic form it also includes a |
| 30 | negative: locked, with potential waiters | 30 | wait-queue and a spinlock that serializes access to it. Furthermore, |
| 31 | 31 | CONFIG_MUTEX_SPIN_ON_OWNER=y systems use a spinner MCS lock (->osq), described | |
| 32 | In its most basic form it also includes a wait-queue and a spinlock | 32 | below in (ii). |
| 33 | that serializes access to it. CONFIG_SMP systems can also include | ||
| 34 | a pointer to the lock task owner (->owner) as well as a spinner MCS | ||
| 35 | lock (->osq), both described below in (ii). | ||
| 36 | 33 | ||
| 37 | When acquiring a mutex, there are three possible paths that can be | 34 | When acquiring a mutex, there are three possible paths that can be |
| 38 | taken, depending on the state of the lock: | 35 | taken, depending on the state of the lock: |
| 39 | 36 | ||
| 40 | (i) fastpath: tries to atomically acquire the lock by decrementing the | 37 | (i) fastpath: tries to atomically acquire the lock by cmpxchg()ing the owner with |
| 41 | counter. If it was already taken by another task it goes to the next | 38 | the current task. This only works in the uncontended case (cmpxchg() checks |
| 42 | possible path. This logic is architecture specific. On x86-64, the | 39 | against 0UL, so all 3 state bits above have to be 0). If the lock is |
| 43 | locking fastpath is 2 instructions: | 40 | contended it goes to the next possible path. |
| 44 | |||
| 45 | 0000000000000e10 <mutex_lock>: | ||
| 46 | e21: f0 ff 0b lock decl (%rbx) | ||
| 47 | e24: 79 08 jns e2e <mutex_lock+0x1e> | ||
| 48 | |||
| 49 | the unlocking fastpath is equally tight: | ||
| 50 | |||
| 51 | 0000000000000bc0 <mutex_unlock>: | ||
| 52 | bc8: f0 ff 07 lock incl (%rdi) | ||
| 53 | bcb: 7f 0a jg bd7 <mutex_unlock+0x17> | ||
| 54 | |||
| 55 | 41 | ||
| 56 | (ii) midpath: aka optimistic spinning, tries to spin for acquisition | 42 | (ii) midpath: aka optimistic spinning, tries to spin for acquisition |
| 57 | while the lock owner is running and there are no other tasks ready | 43 | while the lock owner is running and there are no other tasks ready |
| @@ -143,11 +129,10 @@ Test if the mutex is taken: | |||
| 143 | Disadvantages | 129 | Disadvantages |
| 144 | ------------- | 130 | ------------- |
| 145 | 131 | ||
| 146 | Unlike its original design and purpose, 'struct mutex' is larger than | 132 | Unlike its original design and purpose, 'struct mutex' is among the largest |
| 147 | most locks in the kernel. E.g: on x86-64 it is 40 bytes, almost twice | 133 | locks in the kernel. E.g: on x86-64 it is 32 bytes, where 'struct semaphore' |
| 148 | as large as 'struct semaphore' (24 bytes) and tied, along with rwsems, | 134 | is 24 bytes and rw_semaphore is 40 bytes. Larger structure sizes mean more CPU |
| 149 | for the largest lock in the kernel. Larger structure sizes mean more | 135 | cache and memory footprint. |
| 150 | CPU cache and memory footprint. | ||
| 151 | 136 | ||
| 152 | When to use mutexes | 137 | When to use mutexes |
| 153 | ------------------- | 138 | ------------------- |
diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260e36b7..9a7f76eadae9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -9206,6 +9206,7 @@ MIPS GENERIC PLATFORM | |||
| 9206 | M: Paul Burton <paul.burton@mips.com> | 9206 | M: Paul Burton <paul.burton@mips.com> |
| 9207 | L: linux-mips@linux-mips.org | 9207 | L: linux-mips@linux-mips.org |
| 9208 | S: Supported | 9208 | S: Supported |
| 9209 | F: Documentation/devicetree/bindings/power/mti,mips-cpc.txt | ||
| 9209 | F: arch/mips/generic/ | 9210 | F: arch/mips/generic/ |
| 9210 | F: arch/mips/tools/generic-board-config.sh | 9211 | F: arch/mips/tools/generic-board-config.sh |
| 9211 | 9212 | ||
| @@ -9945,6 +9946,7 @@ F: drivers/nfc/nxp-nci | |||
| 9945 | 9946 | ||
| 9946 | OBJTOOL | 9947 | OBJTOOL |
| 9947 | M: Josh Poimboeuf <jpoimboe@redhat.com> | 9948 | M: Josh Poimboeuf <jpoimboe@redhat.com> |
| 9949 | M: Peter Zijlstra <peterz@infradead.org> | ||
| 9948 | S: Supported | 9950 | S: Supported |
| 9949 | F: tools/objtool/ | 9951 | F: tools/objtool/ |
| 9950 | 9952 | ||
| @@ -2,7 +2,7 @@ | |||
| 2 | VERSION = 4 | 2 | VERSION = 4 |
| 3 | PATCHLEVEL = 16 | 3 | PATCHLEVEL = 16 |
| 4 | SUBLEVEL = 0 | 4 | SUBLEVEL = 0 |
| 5 | EXTRAVERSION = -rc1 | 5 | EXTRAVERSION = -rc2 |
| 6 | NAME = Fearless Coyote | 6 | NAME = Fearless Coyote |
| 7 | 7 | ||
| 8 | # *DOCUMENTATION* | 8 | # *DOCUMENTATION* |
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index be7bd19c87ec..eda8c5f629fc 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | #define MPIDR_UP_BITMASK (0x1 << 30) | 21 | #define MPIDR_UP_BITMASK (0x1 << 30) |
| 22 | #define MPIDR_MT_BITMASK (0x1 << 24) | 22 | #define MPIDR_MT_BITMASK (0x1 << 24) |
| 23 | #define MPIDR_HWID_BITMASK 0xff00ffffff | 23 | #define MPIDR_HWID_BITMASK 0xff00ffffffUL |
| 24 | 24 | ||
| 25 | #define MPIDR_LEVEL_BITS_SHIFT 3 | 25 | #define MPIDR_LEVEL_BITS_SHIFT 3 |
| 26 | #define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT) | 26 | #define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT) |
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h index 1dca41bea16a..e73f68569624 100644 --- a/arch/arm64/include/asm/hugetlb.h +++ b/arch/arm64/include/asm/hugetlb.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | static inline pte_t huge_ptep_get(pte_t *ptep) | 23 | static inline pte_t huge_ptep_get(pte_t *ptep) |
| 24 | { | 24 | { |
| 25 | return *ptep; | 25 | return READ_ONCE(*ptep); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | 28 | ||
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 9679067a1574..7faed6e48b46 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h | |||
| @@ -185,42 +185,42 @@ static inline pmd_t kvm_s2pmd_mkexec(pmd_t pmd) | |||
| 185 | return pmd; | 185 | return pmd; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | static inline void kvm_set_s2pte_readonly(pte_t *pte) | 188 | static inline void kvm_set_s2pte_readonly(pte_t *ptep) |
| 189 | { | 189 | { |
| 190 | pteval_t old_pteval, pteval; | 190 | pteval_t old_pteval, pteval; |
| 191 | 191 | ||
| 192 | pteval = READ_ONCE(pte_val(*pte)); | 192 | pteval = READ_ONCE(pte_val(*ptep)); |
| 193 | do { | 193 | do { |
| 194 | old_pteval = pteval; | 194 | old_pteval = pteval; |
| 195 | pteval &= ~PTE_S2_RDWR; | 195 | pteval &= ~PTE_S2_RDWR; |
| 196 | pteval |= PTE_S2_RDONLY; | 196 | pteval |= PTE_S2_RDONLY; |
| 197 | pteval = cmpxchg_relaxed(&pte_val(*pte), old_pteval, pteval); | 197 | pteval = cmpxchg_relaxed(&pte_val(*ptep), old_pteval, pteval); |
| 198 | } while (pteval != old_pteval); | 198 | } while (pteval != old_pteval); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static inline bool kvm_s2pte_readonly(pte_t *pte) | 201 | static inline bool kvm_s2pte_readonly(pte_t *ptep) |
| 202 | { | 202 | { |
| 203 | return (pte_val(*pte) & PTE_S2_RDWR) == PTE_S2_RDONLY; | 203 | return (READ_ONCE(pte_val(*ptep)) & PTE_S2_RDWR) == PTE_S2_RDONLY; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | static inline bool kvm_s2pte_exec(pte_t *pte) | 206 | static inline bool kvm_s2pte_exec(pte_t *ptep) |
| 207 | { | 207 | { |
| 208 | return !(pte_val(*pte) & PTE_S2_XN); | 208 | return !(READ_ONCE(pte_val(*ptep)) & PTE_S2_XN); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static inline void kvm_set_s2pmd_readonly(pmd_t *pmd) | 211 | static inline void kvm_set_s2pmd_readonly(pmd_t *pmdp) |
| 212 | { | 212 | { |
| 213 | kvm_set_s2pte_readonly((pte_t *)pmd); | 213 | kvm_set_s2pte_readonly((pte_t *)pmdp); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | static inline bool kvm_s2pmd_readonly(pmd_t *pmd) | 216 | static inline bool kvm_s2pmd_readonly(pmd_t *pmdp) |
| 217 | { | 217 | { |
| 218 | return kvm_s2pte_readonly((pte_t *)pmd); | 218 | return kvm_s2pte_readonly((pte_t *)pmdp); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | static inline bool kvm_s2pmd_exec(pmd_t *pmd) | 221 | static inline bool kvm_s2pmd_exec(pmd_t *pmdp) |
| 222 | { | 222 | { |
| 223 | return !(pmd_val(*pmd) & PMD_S2_XN); | 223 | return !(READ_ONCE(pmd_val(*pmdp)) & PMD_S2_XN); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | static inline bool kvm_page_empty(void *ptr) | 226 | static inline bool kvm_page_empty(void *ptr) |
diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 8d3331985d2e..39ec0b8a689e 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h | |||
| @@ -141,13 +141,13 @@ static inline void cpu_install_idmap(void) | |||
| 141 | * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, | 141 | * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, |
| 142 | * avoiding the possibility of conflicting TLB entries being allocated. | 142 | * avoiding the possibility of conflicting TLB entries being allocated. |
| 143 | */ | 143 | */ |
| 144 | static inline void cpu_replace_ttbr1(pgd_t *pgd) | 144 | static inline void cpu_replace_ttbr1(pgd_t *pgdp) |
| 145 | { | 145 | { |
| 146 | typedef void (ttbr_replace_func)(phys_addr_t); | 146 | typedef void (ttbr_replace_func)(phys_addr_t); |
| 147 | extern ttbr_replace_func idmap_cpu_replace_ttbr1; | 147 | extern ttbr_replace_func idmap_cpu_replace_ttbr1; |
| 148 | ttbr_replace_func *replace_phys; | 148 | ttbr_replace_func *replace_phys; |
| 149 | 149 | ||
| 150 | phys_addr_t pgd_phys = virt_to_phys(pgd); | 150 | phys_addr_t pgd_phys = virt_to_phys(pgdp); |
| 151 | 151 | ||
| 152 | replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); | 152 | replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); |
| 153 | 153 | ||
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h index e9d9f1b006ef..2e05bcd944c8 100644 --- a/arch/arm64/include/asm/pgalloc.h +++ b/arch/arm64/include/asm/pgalloc.h | |||
| @@ -36,23 +36,23 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) | |||
| 36 | return (pmd_t *)__get_free_page(PGALLOC_GFP); | 36 | return (pmd_t *)__get_free_page(PGALLOC_GFP); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) | 39 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmdp) |
| 40 | { | 40 | { |
| 41 | BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); | 41 | BUG_ON((unsigned long)pmdp & (PAGE_SIZE-1)); |
| 42 | free_page((unsigned long)pmd); | 42 | free_page((unsigned long)pmdp); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static inline void __pud_populate(pud_t *pud, phys_addr_t pmd, pudval_t prot) | 45 | static inline void __pud_populate(pud_t *pudp, phys_addr_t pmdp, pudval_t prot) |
| 46 | { | 46 | { |
| 47 | set_pud(pud, __pud(__phys_to_pud_val(pmd) | prot)); | 47 | set_pud(pudp, __pud(__phys_to_pud_val(pmdp) | prot)); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) | 50 | static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmdp) |
| 51 | { | 51 | { |
| 52 | __pud_populate(pud, __pa(pmd), PMD_TYPE_TABLE); | 52 | __pud_populate(pudp, __pa(pmdp), PMD_TYPE_TABLE); |
| 53 | } | 53 | } |
| 54 | #else | 54 | #else |
| 55 | static inline void __pud_populate(pud_t *pud, phys_addr_t pmd, pudval_t prot) | 55 | static inline void __pud_populate(pud_t *pudp, phys_addr_t pmdp, pudval_t prot) |
| 56 | { | 56 | { |
| 57 | BUILD_BUG(); | 57 | BUILD_BUG(); |
| 58 | } | 58 | } |
| @@ -65,30 +65,30 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) | |||
| 65 | return (pud_t *)__get_free_page(PGALLOC_GFP); | 65 | return (pud_t *)__get_free_page(PGALLOC_GFP); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | static inline void pud_free(struct mm_struct *mm, pud_t *pud) | 68 | static inline void pud_free(struct mm_struct *mm, pud_t *pudp) |
| 69 | { | 69 | { |
| 70 | BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); | 70 | BUG_ON((unsigned long)pudp & (PAGE_SIZE-1)); |
| 71 | free_page((unsigned long)pud); | 71 | free_page((unsigned long)pudp); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pud, pgdval_t prot) | 74 | static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pudp, pgdval_t prot) |
| 75 | { | 75 | { |
| 76 | set_pgd(pgdp, __pgd(__phys_to_pgd_val(pud) | prot)); | 76 | set_pgd(pgdp, __pgd(__phys_to_pgd_val(pudp) | prot)); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud) | 79 | static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgdp, pud_t *pudp) |
| 80 | { | 80 | { |
| 81 | __pgd_populate(pgd, __pa(pud), PUD_TYPE_TABLE); | 81 | __pgd_populate(pgdp, __pa(pudp), PUD_TYPE_TABLE); |
| 82 | } | 82 | } |
| 83 | #else | 83 | #else |
| 84 | static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pud, pgdval_t prot) | 84 | static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pudp, pgdval_t prot) |
| 85 | { | 85 | { |
| 86 | BUILD_BUG(); | 86 | BUILD_BUG(); |
| 87 | } | 87 | } |
| 88 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ | 88 | #endif /* CONFIG_PGTABLE_LEVELS > 3 */ |
| 89 | 89 | ||
| 90 | extern pgd_t *pgd_alloc(struct mm_struct *mm); | 90 | extern pgd_t *pgd_alloc(struct mm_struct *mm); |
| 91 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); | 91 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgdp); |
| 92 | 92 | ||
| 93 | static inline pte_t * | 93 | static inline pte_t * |
| 94 | pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) | 94 | pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) |
| @@ -114,10 +114,10 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr) | |||
| 114 | /* | 114 | /* |
| 115 | * Free a PTE table. | 115 | * Free a PTE table. |
| 116 | */ | 116 | */ |
| 117 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) | 117 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *ptep) |
| 118 | { | 118 | { |
| 119 | if (pte) | 119 | if (ptep) |
| 120 | free_page((unsigned long)pte); | 120 | free_page((unsigned long)ptep); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) | 123 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
| @@ -126,10 +126,10 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte) | |||
| 126 | __free_page(pte); | 126 | __free_page(pte); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte, | 129 | static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t ptep, |
| 130 | pmdval_t prot) | 130 | pmdval_t prot) |
| 131 | { | 131 | { |
| 132 | set_pmd(pmdp, __pmd(__phys_to_pmd_val(pte) | prot)); | 132 | set_pmd(pmdp, __pmd(__phys_to_pmd_val(ptep) | prot)); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* | 135 | /* |
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 094374c82db0..7e2c27e63cd8 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h | |||
| @@ -218,7 +218,7 @@ static inline pmd_t pmd_mkcont(pmd_t pmd) | |||
| 218 | 218 | ||
| 219 | static inline void set_pte(pte_t *ptep, pte_t pte) | 219 | static inline void set_pte(pte_t *ptep, pte_t pte) |
| 220 | { | 220 | { |
| 221 | *ptep = pte; | 221 | WRITE_ONCE(*ptep, pte); |
| 222 | 222 | ||
| 223 | /* | 223 | /* |
| 224 | * Only if the new pte is valid and kernel, otherwise TLB maintenance | 224 | * Only if the new pte is valid and kernel, otherwise TLB maintenance |
| @@ -250,6 +250,8 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr); | |||
| 250 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | 250 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, |
| 251 | pte_t *ptep, pte_t pte) | 251 | pte_t *ptep, pte_t pte) |
| 252 | { | 252 | { |
| 253 | pte_t old_pte; | ||
| 254 | |||
| 253 | if (pte_present(pte) && pte_user_exec(pte) && !pte_special(pte)) | 255 | if (pte_present(pte) && pte_user_exec(pte) && !pte_special(pte)) |
| 254 | __sync_icache_dcache(pte, addr); | 256 | __sync_icache_dcache(pte, addr); |
| 255 | 257 | ||
| @@ -258,14 +260,15 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | |||
| 258 | * hardware updates of the pte (ptep_set_access_flags safely changes | 260 | * hardware updates of the pte (ptep_set_access_flags safely changes |
| 259 | * valid ptes without going through an invalid entry). | 261 | * valid ptes without going through an invalid entry). |
| 260 | */ | 262 | */ |
| 261 | if (IS_ENABLED(CONFIG_DEBUG_VM) && pte_valid(*ptep) && pte_valid(pte) && | 263 | old_pte = READ_ONCE(*ptep); |
| 264 | if (IS_ENABLED(CONFIG_DEBUG_VM) && pte_valid(old_pte) && pte_valid(pte) && | ||
| 262 | (mm == current->active_mm || atomic_read(&mm->mm_users) > 1)) { | 265 | (mm == current->active_mm || atomic_read(&mm->mm_users) > 1)) { |
| 263 | VM_WARN_ONCE(!pte_young(pte), | 266 | VM_WARN_ONCE(!pte_young(pte), |
| 264 | "%s: racy access flag clearing: 0x%016llx -> 0x%016llx", | 267 | "%s: racy access flag clearing: 0x%016llx -> 0x%016llx", |
| 265 | __func__, pte_val(*ptep), pte_val(pte)); | 268 | __func__, pte_val(old_pte), pte_val(pte)); |
| 266 | VM_WARN_ONCE(pte_write(*ptep) && !pte_dirty(pte), | 269 | VM_WARN_ONCE(pte_write(old_pte) && !pte_dirty(pte), |
| 267 | "%s: racy dirty state clearing: 0x%016llx -> 0x%016llx", | 270 | "%s: racy dirty state clearing: 0x%016llx -> 0x%016llx", |
| 268 | __func__, pte_val(*ptep), pte_val(pte)); | 271 | __func__, pte_val(old_pte), pte_val(pte)); |
| 269 | } | 272 | } |
| 270 | 273 | ||
| 271 | set_pte(ptep, pte); | 274 | set_pte(ptep, pte); |
| @@ -431,7 +434,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | |||
| 431 | 434 | ||
| 432 | static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) | 435 | static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) |
| 433 | { | 436 | { |
| 434 | *pmdp = pmd; | 437 | WRITE_ONCE(*pmdp, pmd); |
| 435 | dsb(ishst); | 438 | dsb(ishst); |
| 436 | isb(); | 439 | isb(); |
| 437 | } | 440 | } |
| @@ -482,7 +485,7 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) | |||
| 482 | 485 | ||
| 483 | static inline void set_pud(pud_t *pudp, pud_t pud) | 486 | static inline void set_pud(pud_t *pudp, pud_t pud) |
| 484 | { | 487 | { |
| 485 | *pudp = pud; | 488 | WRITE_ONCE(*pudp, pud); |
| 486 | dsb(ishst); | 489 | dsb(ishst); |
| 487 | isb(); | 490 | isb(); |
| 488 | } | 491 | } |
| @@ -500,7 +503,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud) | |||
| 500 | /* Find an entry in the second-level page table. */ | 503 | /* Find an entry in the second-level page table. */ |
| 501 | #define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) | 504 | #define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) |
| 502 | 505 | ||
| 503 | #define pmd_offset_phys(dir, addr) (pud_page_paddr(*(dir)) + pmd_index(addr) * sizeof(pmd_t)) | 506 | #define pmd_offset_phys(dir, addr) (pud_page_paddr(READ_ONCE(*(dir))) + pmd_index(addr) * sizeof(pmd_t)) |
| 504 | #define pmd_offset(dir, addr) ((pmd_t *)__va(pmd_offset_phys((dir), (addr)))) | 507 | #define pmd_offset(dir, addr) ((pmd_t *)__va(pmd_offset_phys((dir), (addr)))) |
| 505 | 508 | ||
| 506 | #define pmd_set_fixmap(addr) ((pmd_t *)set_fixmap_offset(FIX_PMD, addr)) | 509 | #define pmd_set_fixmap(addr) ((pmd_t *)set_fixmap_offset(FIX_PMD, addr)) |
| @@ -535,7 +538,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud) | |||
| 535 | 538 | ||
| 536 | static inline void set_pgd(pgd_t *pgdp, pgd_t pgd) | 539 | static inline void set_pgd(pgd_t *pgdp, pgd_t pgd) |
| 537 | { | 540 | { |
| 538 | *pgdp = pgd; | 541 | WRITE_ONCE(*pgdp, pgd); |
| 539 | dsb(ishst); | 542 | dsb(ishst); |
| 540 | } | 543 | } |
| 541 | 544 | ||
| @@ -552,7 +555,7 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd) | |||
| 552 | /* Find an entry in the frst-level page table. */ | 555 | /* Find an entry in the frst-level page table. */ |
| 553 | #define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) | 556 | #define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) |
| 554 | 557 | ||
| 555 | #define pud_offset_phys(dir, addr) (pgd_page_paddr(*(dir)) + pud_index(addr) * sizeof(pud_t)) | 558 | #define pud_offset_phys(dir, addr) (pgd_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t)) |
| 556 | #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr)))) | 559 | #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr)))) |
| 557 | 560 | ||
| 558 | #define pud_set_fixmap(addr) ((pud_t *)set_fixmap_offset(FIX_PUD, addr)) | 561 | #define pud_set_fixmap(addr) ((pud_t *)set_fixmap_offset(FIX_PUD, addr)) |
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 07823595b7f0..52f15cd896e1 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c | |||
| @@ -408,6 +408,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { | |||
| 408 | }, | 408 | }, |
| 409 | { | 409 | { |
| 410 | .capability = ARM64_HARDEN_BRANCH_PREDICTOR, | 410 | .capability = ARM64_HARDEN_BRANCH_PREDICTOR, |
| 411 | MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR), | ||
| 412 | .enable = qcom_enable_link_stack_sanitization, | ||
| 413 | }, | ||
| 414 | { | ||
| 415 | .capability = ARM64_HARDEN_BP_POST_GUEST_EXIT, | ||
| 416 | MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR), | ||
| 417 | }, | ||
| 418 | { | ||
| 419 | .capability = ARM64_HARDEN_BRANCH_PREDICTOR, | ||
| 411 | MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), | 420 | MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), |
| 412 | .enable = enable_smccc_arch_workaround_1, | 421 | .enable = enable_smccc_arch_workaround_1, |
| 413 | }, | 422 | }, |
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index f85ac58d08a3..a8bf1c892b90 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c | |||
| @@ -90,7 +90,7 @@ static int __init set_permissions(pte_t *ptep, pgtable_t token, | |||
| 90 | unsigned long addr, void *data) | 90 | unsigned long addr, void *data) |
| 91 | { | 91 | { |
| 92 | efi_memory_desc_t *md = data; | 92 | efi_memory_desc_t *md = data; |
| 93 | pte_t pte = *ptep; | 93 | pte_t pte = READ_ONCE(*ptep); |
| 94 | 94 | ||
| 95 | if (md->attribute & EFI_MEMORY_RO) | 95 | if (md->attribute & EFI_MEMORY_RO) |
| 96 | pte = set_pte_bit(pte, __pgprot(PTE_RDONLY)); | 96 | pte = set_pte_bit(pte, __pgprot(PTE_RDONLY)); |
diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index f20cf7e99249..1ec5f28c39fc 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c | |||
| @@ -202,10 +202,10 @@ static int create_safe_exec_page(void *src_start, size_t length, | |||
| 202 | gfp_t mask) | 202 | gfp_t mask) |
| 203 | { | 203 | { |
| 204 | int rc = 0; | 204 | int rc = 0; |
| 205 | pgd_t *pgd; | 205 | pgd_t *pgdp; |
| 206 | pud_t *pud; | 206 | pud_t *pudp; |
| 207 | pmd_t *pmd; | 207 | pmd_t *pmdp; |
| 208 | pte_t *pte; | 208 | pte_t *ptep; |
| 209 | unsigned long dst = (unsigned long)allocator(mask); | 209 | unsigned long dst = (unsigned long)allocator(mask); |
| 210 | 210 | ||
| 211 | if (!dst) { | 211 | if (!dst) { |
| @@ -216,38 +216,38 @@ static int create_safe_exec_page(void *src_start, size_t length, | |||
| 216 | memcpy((void *)dst, src_start, length); | 216 | memcpy((void *)dst, src_start, length); |
| 217 | flush_icache_range(dst, dst + length); | 217 | flush_icache_range(dst, dst + length); |
| 218 | 218 | ||
| 219 | pgd = pgd_offset_raw(allocator(mask), dst_addr); | 219 | pgdp = pgd_offset_raw(allocator(mask), dst_addr); |
| 220 | if (pgd_none(*pgd)) { | 220 | if (pgd_none(READ_ONCE(*pgdp))) { |
| 221 | pud = allocator(mask); | 221 | pudp = allocator(mask); |
| 222 | if (!pud) { | 222 | if (!pudp) { |
| 223 | rc = -ENOMEM; | 223 | rc = -ENOMEM; |
| 224 | goto out; | 224 | goto out; |
| 225 | } | 225 | } |
| 226 | pgd_populate(&init_mm, pgd, pud); | 226 | pgd_populate(&init_mm, pgdp, pudp); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | pud = pud_offset(pgd, dst_addr); | 229 | pudp = pud_offset(pgdp, dst_addr); |
| 230 | if (pud_none(*pud)) { | 230 | if (pud_none(READ_ONCE(*pudp))) { |
| 231 | pmd = allocator(mask); | 231 | pmdp = allocator(mask); |
| 232 | if (!pmd) { | 232 | if (!pmdp) { |
| 233 | rc = -ENOMEM; | 233 | rc = -ENOMEM; |
| 234 | goto out; | 234 | goto out; |
| 235 | } | 235 | } |
| 236 | pud_populate(&init_mm, pud, pmd); | 236 | pud_populate(&init_mm, pudp, pmdp); |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | pmd = pmd_offset(pud, dst_addr); | 239 | pmdp = pmd_offset(pudp, dst_addr); |
| 240 | if (pmd_none(*pmd)) { | 240 | if (pmd_none(READ_ONCE(*pmdp))) { |
| 241 | pte = allocator(mask); | 241 | ptep = allocator(mask); |
| 242 | if (!pte) { | 242 | if (!ptep) { |
| 243 | rc = -ENOMEM; | 243 | rc = -ENOMEM; |
| 244 | goto out; | 244 | goto out; |
| 245 | } | 245 | } |
| 246 | pmd_populate_kernel(&init_mm, pmd, pte); | 246 | pmd_populate_kernel(&init_mm, pmdp, ptep); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | pte = pte_offset_kernel(pmd, dst_addr); | 249 | ptep = pte_offset_kernel(pmdp, dst_addr); |
| 250 | set_pte(pte, pfn_pte(virt_to_pfn(dst), PAGE_KERNEL_EXEC)); | 250 | set_pte(ptep, pfn_pte(virt_to_pfn(dst), PAGE_KERNEL_EXEC)); |
| 251 | 251 | ||
| 252 | /* | 252 | /* |
| 253 | * Load our new page tables. A strict BBM approach requires that we | 253 | * Load our new page tables. A strict BBM approach requires that we |
| @@ -263,7 +263,7 @@ static int create_safe_exec_page(void *src_start, size_t length, | |||
| 263 | */ | 263 | */ |
| 264 | cpu_set_reserved_ttbr0(); | 264 | cpu_set_reserved_ttbr0(); |
| 265 | local_flush_tlb_all(); | 265 | local_flush_tlb_all(); |
| 266 | write_sysreg(phys_to_ttbr(virt_to_phys(pgd)), ttbr0_el1); | 266 | write_sysreg(phys_to_ttbr(virt_to_phys(pgdp)), ttbr0_el1); |
| 267 | isb(); | 267 | isb(); |
| 268 | 268 | ||
| 269 | *phys_dst_addr = virt_to_phys((void *)dst); | 269 | *phys_dst_addr = virt_to_phys((void *)dst); |
| @@ -320,9 +320,9 @@ int swsusp_arch_suspend(void) | |||
| 320 | return ret; | 320 | return ret; |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | static void _copy_pte(pte_t *dst_pte, pte_t *src_pte, unsigned long addr) | 323 | static void _copy_pte(pte_t *dst_ptep, pte_t *src_ptep, unsigned long addr) |
| 324 | { | 324 | { |
| 325 | pte_t pte = *src_pte; | 325 | pte_t pte = READ_ONCE(*src_ptep); |
| 326 | 326 | ||
| 327 | if (pte_valid(pte)) { | 327 | if (pte_valid(pte)) { |
| 328 | /* | 328 | /* |
| @@ -330,7 +330,7 @@ static void _copy_pte(pte_t *dst_pte, pte_t *src_pte, unsigned long addr) | |||
| 330 | * read only (code, rodata). Clear the RDONLY bit from | 330 | * read only (code, rodata). Clear the RDONLY bit from |
| 331 | * the temporary mappings we use during restore. | 331 | * the temporary mappings we use during restore. |
| 332 | */ | 332 | */ |
| 333 | set_pte(dst_pte, pte_mkwrite(pte)); | 333 | set_pte(dst_ptep, pte_mkwrite(pte)); |
| 334 | } else if (debug_pagealloc_enabled() && !pte_none(pte)) { | 334 | } else if (debug_pagealloc_enabled() && !pte_none(pte)) { |
| 335 | /* | 335 | /* |
| 336 | * debug_pagealloc will removed the PTE_VALID bit if | 336 | * debug_pagealloc will removed the PTE_VALID bit if |
| @@ -343,112 +343,116 @@ static void _copy_pte(pte_t *dst_pte, pte_t *src_pte, unsigned long addr) | |||
| 343 | */ | 343 | */ |
| 344 | BUG_ON(!pfn_valid(pte_pfn(pte))); | 344 | BUG_ON(!pfn_valid(pte_pfn(pte))); |
| 345 | 345 | ||
| 346 | set_pte(dst_pte, pte_mkpresent(pte_mkwrite(pte))); | 346 | set_pte(dst_ptep, pte_mkpresent(pte_mkwrite(pte))); |
| 347 | } | 347 | } |
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | static int copy_pte(pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long start, | 350 | static int copy_pte(pmd_t *dst_pmdp, pmd_t *src_pmdp, unsigned long start, |
| 351 | unsigned long end) | 351 | unsigned long end) |
| 352 | { | 352 | { |
| 353 | pte_t *src_pte; | 353 | pte_t *src_ptep; |
| 354 | pte_t *dst_pte; | 354 | pte_t *dst_ptep; |
| 355 | unsigned long addr = start; | 355 | unsigned long addr = start; |
| 356 | 356 | ||
| 357 | dst_pte = (pte_t *)get_safe_page(GFP_ATOMIC); | 357 | dst_ptep = (pte_t *)get_safe_page(GFP_ATOMIC); |
| 358 | if (!dst_pte) | 358 | if (!dst_ptep) |
| 359 | return -ENOMEM; | 359 | return -ENOMEM; |
| 360 | pmd_populate_kernel(&init_mm, dst_pmd, dst_pte); | 360 | pmd_populate_kernel(&init_mm, dst_pmdp, dst_ptep); |
| 361 | dst_pte = pte_offset_kernel(dst_pmd, start); | 361 | dst_ptep = pte_offset_kernel(dst_pmdp, start); |
| 362 | 362 | ||
| 363 | src_pte = pte_offset_kernel(src_pmd, start); | 363 | src_ptep = pte_offset_kernel(src_pmdp, start); |
| 364 | do { | 364 | do { |
| 365 | _copy_pte(dst_pte, src_pte, addr); | 365 | _copy_pte(dst_ptep, src_ptep, addr); |
| 366 | } while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end); | 366 | } while (dst_ptep++, src_ptep++, addr += PAGE_SIZE, addr != end); |
| 367 | 367 | ||
| 368 | return 0; | 368 | return 0; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | static int copy_pmd(pud_t *dst_pud, pud_t *src_pud, unsigned long start, | 371 | static int copy_pmd(pud_t *dst_pudp, pud_t *src_pudp, unsigned long start, |
| 372 | unsigned long end) | 372 | unsigned long end) |
| 373 | { | 373 | { |
| 374 | pmd_t *src_pmd; | 374 | pmd_t *src_pmdp; |
| 375 | pmd_t *dst_pmd; | 375 | pmd_t *dst_pmdp; |
| 376 | unsigned long next; | 376 | unsigned long next; |
| 377 | unsigned long addr = start; | 377 | unsigned long addr = start; |
| 378 | 378 | ||
| 379 | if (pud_none(*dst_pud)) { | 379 | if (pud_none(READ_ONCE(*dst_pudp))) { |
| 380 | dst_pmd = (pmd_t *)get_safe_page(GFP_ATOMIC); | 380 | dst_pmdp = (pmd_t *)get_safe_page(GFP_ATOMIC); |
| 381 | if (!dst_pmd) | 381 | if (!dst_pmdp) |
| 382 | return -ENOMEM; | 382 | return -ENOMEM; |
| 383 | pud_populate(&init_mm, dst_pud, dst_pmd); | 383 | pud_populate(&init_mm, dst_pudp, dst_pmdp); |
| 384 | } | 384 | } |
| 385 | dst_pmd = pmd_offset(dst_pud, start); | 385 | dst_pmdp = pmd_offset(dst_pudp, start); |
| 386 | 386 | ||
| 387 | src_pmd = pmd_offset(src_pud, start); | 387 | src_pmdp = pmd_offset(src_pudp, start); |
| 388 | do { | 388 | do { |
| 389 | pmd_t pmd = READ_ONCE(*src_pmdp); | ||
| 390 | |||
| 389 | next = pmd_addr_end(addr, end); | 391 | next = pmd_addr_end(addr, end); |
| 390 | if (pmd_none(*src_pmd)) | 392 | if (pmd_none(pmd)) |
| 391 | continue; | 393 | continue; |
| 392 | if (pmd_table(*src_pmd)) { | 394 | if (pmd_table(pmd)) { |
| 393 | if (copy_pte(dst_pmd, src_pmd, addr, next)) | 395 | if (copy_pte(dst_pmdp, src_pmdp, addr, next)) |
| 394 | return -ENOMEM; | 396 | return -ENOMEM; |
| 395 | } else { | 397 | } else { |
| 396 | set_pmd(dst_pmd, | 398 | set_pmd(dst_pmdp, |
| 397 | __pmd(pmd_val(*src_pmd) & ~PMD_SECT_RDONLY)); | 399 | __pmd(pmd_val(pmd) & ~PMD_SECT_RDONLY)); |
| 398 | } | 400 | } |
| 399 | } while (dst_pmd++, src_pmd++, addr = next, addr != end); | 401 | } while (dst_pmdp++, src_pmdp++, addr = next, addr != end); |
| 400 | 402 | ||
| 401 | return 0; | 403 | return 0; |
| 402 | } | 404 | } |
| 403 | 405 | ||
| 404 | static int copy_pud(pgd_t *dst_pgd, pgd_t *src_pgd, unsigned long start, | 406 | static int copy_pud(pgd_t *dst_pgdp, pgd_t *src_pgdp, unsigned long start, |
| 405 | unsigned long end) | 407 | unsigned long end) |
| 406 | { | 408 | { |
| 407 | pud_t *dst_pud; | 409 | pud_t *dst_pudp; |
| 408 | pud_t *src_pud; | 410 | pud_t *src_pudp; |
| 409 | unsigned long next; | 411 | unsigned long next; |
| 410 | unsigned long addr = start; | 412 | unsigned long addr = start; |
| 411 | 413 | ||
| 412 | if (pgd_none(*dst_pgd)) { | 414 | if (pgd_none(READ_ONCE(*dst_pgdp))) { |
| 413 | dst_pud = (pud_t *)get_safe_page(GFP_ATOMIC); | 415 | dst_pudp = (pud_t *)get_safe_page(GFP_ATOMIC); |
| 414 | if (!dst_pud) | 416 | if (!dst_pudp) |
| 415 | return -ENOMEM; | 417 | return -ENOMEM; |
| 416 | pgd_populate(&init_mm, dst_pgd, dst_pud); | 418 | pgd_populate(&init_mm, dst_pgdp, dst_pudp); |
| 417 | } | 419 | } |
| 418 | dst_pud = pud_offset(dst_pgd, start); | 420 | dst_pudp = pud_offset(dst_pgdp, start); |
| 419 | 421 | ||
| 420 | src_pud = pud_offset(src_pgd, start); | 422 | src_pudp = pud_offset(src_pgdp, start); |
| 421 | do { | 423 | do { |
| 424 | pud_t pud = READ_ONCE(*src_pudp); | ||
| 425 | |||
| 422 | next = pud_addr_end(addr, end); | 426 | next = pud_addr_end(addr, end); |
| 423 | if (pud_none(*src_pud)) | 427 | if (pud_none(pud)) |
| 424 | continue; | 428 | continue; |
| 425 | if (pud_table(*(src_pud))) { | 429 | if (pud_table(pud)) { |
| 426 | if (copy_pmd(dst_pud, src_pud, addr, next)) | 430 | if (copy_pmd(dst_pudp, src_pudp, addr, next)) |
| 427 | return -ENOMEM; | 431 | return -ENOMEM; |
| 428 | } else { | 432 | } else { |
| 429 | set_pud(dst_pud, | 433 | set_pud(dst_pudp, |
| 430 | __pud(pud_val(*src_pud) & ~PMD_SECT_RDONLY)); | 434 | __pud(pud_val(pud) & ~PMD_SECT_RDONLY)); |
| 431 | } | 435 | } |
| 432 | } while (dst_pud++, src_pud++, addr = next, addr != end); | 436 | } while (dst_pudp++, src_pudp++, addr = next, addr != end); |
| 433 | 437 | ||
| 434 | return 0; | 438 | return 0; |
| 435 | } | 439 | } |
| 436 | 440 | ||
| 437 | static int copy_page_tables(pgd_t *dst_pgd, unsigned long start, | 441 | static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start, |
| 438 | unsigned long end) | 442 | unsigned long end) |
| 439 | { | 443 | { |
| 440 | unsigned long next; | 444 | unsigned long next; |
| 441 | unsigned long addr = start; | 445 | unsigned long addr = start; |
| 442 | pgd_t *src_pgd = pgd_offset_k(start); | 446 | pgd_t *src_pgdp = pgd_offset_k(start); |
| 443 | 447 | ||
| 444 | dst_pgd = pgd_offset_raw(dst_pgd, start); | 448 | dst_pgdp = pgd_offset_raw(dst_pgdp, start); |
| 445 | do { | 449 | do { |
| 446 | next = pgd_addr_end(addr, end); | 450 | next = pgd_addr_end(addr, end); |
| 447 | if (pgd_none(*src_pgd)) | 451 | if (pgd_none(READ_ONCE(*src_pgdp))) |
| 448 | continue; | 452 | continue; |
| 449 | if (copy_pud(dst_pgd, src_pgd, addr, next)) | 453 | if (copy_pud(dst_pgdp, src_pgdp, addr, next)) |
| 450 | return -ENOMEM; | 454 | return -ENOMEM; |
| 451 | } while (dst_pgd++, src_pgd++, addr = next, addr != end); | 455 | } while (dst_pgdp++, src_pgdp++, addr = next, addr != end); |
| 452 | 456 | ||
| 453 | return 0; | 457 | return 0; |
| 454 | } | 458 | } |
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 116252a8d3a5..870f4b1587f9 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c | |||
| @@ -407,8 +407,10 @@ again: | |||
| 407 | u32 midr = read_cpuid_id(); | 407 | u32 midr = read_cpuid_id(); |
| 408 | 408 | ||
| 409 | /* Apply BTAC predictors mitigation to all Falkor chips */ | 409 | /* Apply BTAC predictors mitigation to all Falkor chips */ |
| 410 | if ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1) | 410 | if (((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR) || |
| 411 | ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1)) { | ||
| 411 | __qcom_hyp_sanitize_btac_predictors(); | 412 | __qcom_hyp_sanitize_btac_predictors(); |
| 413 | } | ||
| 412 | } | 414 | } |
| 413 | 415 | ||
| 414 | fp_enabled = __fpsimd_enabled(); | 416 | fp_enabled = __fpsimd_enabled(); |
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c index 7b60d62ac593..65dfc8571bf8 100644 --- a/arch/arm64/mm/dump.c +++ b/arch/arm64/mm/dump.c | |||
| @@ -286,48 +286,52 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, | |||
| 286 | 286 | ||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start) | 289 | static void walk_pte(struct pg_state *st, pmd_t *pmdp, unsigned long start) |
| 290 | { | 290 | { |
| 291 | pte_t *pte = pte_offset_kernel(pmd, 0UL); | 291 | pte_t *ptep = pte_offset_kernel(pmdp, 0UL); |
| 292 | unsigned long addr; | 292 | unsigned long addr; |
| 293 | unsigned i; | 293 | unsigned i; |
| 294 | 294 | ||
| 295 | for (i = 0; i < PTRS_PER_PTE; i++, pte++) { | 295 | for (i = 0; i < PTRS_PER_PTE; i++, ptep++) { |
| 296 | addr = start + i * PAGE_SIZE; | 296 | addr = start + i * PAGE_SIZE; |
| 297 | note_page(st, addr, 4, pte_val(*pte)); | 297 | note_page(st, addr, 4, READ_ONCE(pte_val(*ptep))); |
| 298 | } | 298 | } |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start) | 301 | static void walk_pmd(struct pg_state *st, pud_t *pudp, unsigned long start) |
| 302 | { | 302 | { |
| 303 | pmd_t *pmd = pmd_offset(pud, 0UL); | 303 | pmd_t *pmdp = pmd_offset(pudp, 0UL); |
| 304 | unsigned long addr; | 304 | unsigned long addr; |
| 305 | unsigned i; | 305 | unsigned i; |
| 306 | 306 | ||
| 307 | for (i = 0; i < PTRS_PER_PMD; i++, pmd++) { | 307 | for (i = 0; i < PTRS_PER_PMD; i++, pmdp++) { |
| 308 | pmd_t pmd = READ_ONCE(*pmdp); | ||
| 309 | |||
| 308 | addr = start + i * PMD_SIZE; | 310 | addr = start + i * PMD_SIZE; |
| 309 | if (pmd_none(*pmd) || pmd_sect(*pmd)) { | 311 | if (pmd_none(pmd) || pmd_sect(pmd)) { |
| 310 | note_page(st, addr, 3, pmd_val(*pmd)); | 312 | note_page(st, addr, 3, pmd_val(pmd)); |
| 311 | } else { | 313 | } else { |
| 312 | BUG_ON(pmd_bad(*pmd)); | 314 | BUG_ON(pmd_bad(pmd)); |
| 313 | walk_pte(st, pmd, addr); | 315 | walk_pte(st, pmdp, addr); |
| 314 | } | 316 | } |
| 315 | } | 317 | } |
| 316 | } | 318 | } |
| 317 | 319 | ||
| 318 | static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start) | 320 | static void walk_pud(struct pg_state *st, pgd_t *pgdp, unsigned long start) |
| 319 | { | 321 | { |
| 320 | pud_t *pud = pud_offset(pgd, 0UL); | 322 | pud_t *pudp = pud_offset(pgdp, 0UL); |
| 321 | unsigned long addr; | 323 | unsigned long addr; |
| 322 | unsigned i; | 324 | unsigned i; |
| 323 | 325 | ||
| 324 | for (i = 0; i < PTRS_PER_PUD; i++, pud++) { | 326 | for (i = 0; i < PTRS_PER_PUD; i++, pudp++) { |
| 327 | pud_t pud = READ_ONCE(*pudp); | ||
| 328 | |||
| 325 | addr = start + i * PUD_SIZE; | 329 | addr = start + i * PUD_SIZE; |
| 326 | if (pud_none(*pud) || pud_sect(*pud)) { | 330 | if (pud_none(pud) || pud_sect(pud)) { |
| 327 | note_page(st, addr, 2, pud_val(*pud)); | 331 | note_page(st, addr, 2, pud_val(pud)); |
| 328 | } else { | 332 | } else { |
| 329 | BUG_ON(pud_bad(*pud)); | 333 | BUG_ON(pud_bad(pud)); |
| 330 | walk_pmd(st, pud, addr); | 334 | walk_pmd(st, pudp, addr); |
| 331 | } | 335 | } |
| 332 | } | 336 | } |
| 333 | } | 337 | } |
| @@ -335,17 +339,19 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start) | |||
| 335 | static void walk_pgd(struct pg_state *st, struct mm_struct *mm, | 339 | static void walk_pgd(struct pg_state *st, struct mm_struct *mm, |
| 336 | unsigned long start) | 340 | unsigned long start) |
| 337 | { | 341 | { |
| 338 | pgd_t *pgd = pgd_offset(mm, 0UL); | 342 | pgd_t *pgdp = pgd_offset(mm, 0UL); |
| 339 | unsigned i; | 343 | unsigned i; |
| 340 | unsigned long addr; | 344 | unsigned long addr; |
| 341 | 345 | ||
| 342 | for (i = 0; i < PTRS_PER_PGD; i++, pgd++) { | 346 | for (i = 0; i < PTRS_PER_PGD; i++, pgdp++) { |
| 347 | pgd_t pgd = READ_ONCE(*pgdp); | ||
| 348 | |||
| 343 | addr = start + i * PGDIR_SIZE; | 349 | addr = start + i * PGDIR_SIZE; |
| 344 | if (pgd_none(*pgd)) { | 350 | if (pgd_none(pgd)) { |
| 345 | note_page(st, addr, 1, pgd_val(*pgd)); | 351 | note_page(st, addr, 1, pgd_val(pgd)); |
| 346 | } else { | 352 | } else { |
| 347 | BUG_ON(pgd_bad(*pgd)); | 353 | BUG_ON(pgd_bad(pgd)); |
| 348 | walk_pud(st, pgd, addr); | 354 | walk_pud(st, pgdp, addr); |
| 349 | } | 355 | } |
| 350 | } | 356 | } |
| 351 | } | 357 | } |
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index f76bb2c3c943..bff11553eb05 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c | |||
| @@ -130,7 +130,8 @@ static void mem_abort_decode(unsigned int esr) | |||
| 130 | void show_pte(unsigned long addr) | 130 | void show_pte(unsigned long addr) |
| 131 | { | 131 | { |
| 132 | struct mm_struct *mm; | 132 | struct mm_struct *mm; |
| 133 | pgd_t *pgd; | 133 | pgd_t *pgdp; |
| 134 | pgd_t pgd; | ||
| 134 | 135 | ||
| 135 | if (addr < TASK_SIZE) { | 136 | if (addr < TASK_SIZE) { |
| 136 | /* TTBR0 */ | 137 | /* TTBR0 */ |
| @@ -149,33 +150,37 @@ void show_pte(unsigned long addr) | |||
| 149 | return; | 150 | return; |
| 150 | } | 151 | } |
| 151 | 152 | ||
| 152 | pr_alert("%s pgtable: %luk pages, %u-bit VAs, pgd = %p\n", | 153 | pr_alert("%s pgtable: %luk pages, %u-bit VAs, pgdp = %p\n", |
| 153 | mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K, | 154 | mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K, |
| 154 | VA_BITS, mm->pgd); | 155 | VA_BITS, mm->pgd); |
| 155 | pgd = pgd_offset(mm, addr); | 156 | pgdp = pgd_offset(mm, addr); |
| 156 | pr_alert("[%016lx] *pgd=%016llx", addr, pgd_val(*pgd)); | 157 | pgd = READ_ONCE(*pgdp); |
| 158 | pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd)); | ||
| 157 | 159 | ||
| 158 | do { | 160 | do { |
| 159 | pud_t *pud; | 161 | pud_t *pudp, pud; |
| 160 | pmd_t *pmd; | 162 | pmd_t *pmdp, pmd; |
| 161 | pte_t *pte; | 163 | pte_t *ptep, pte; |
| 162 | 164 | ||
| 163 | if (pgd_none(*pgd) || pgd_bad(*pgd)) | 165 | if (pgd_none(pgd) || pgd_bad(pgd)) |
| 164 | break; | 166 | break; |
| 165 | 167 | ||
| 166 | pud = pud_offset(pgd, addr); | 168 | pudp = pud_offset(pgdp, addr); |
| 167 | pr_cont(", *pud=%016llx", pud_val(*pud)); | 169 | pud = READ_ONCE(*pudp); |
| 168 | if (pud_none(*pud) || pud_bad(*pud)) | 170 | pr_cont(", pud=%016llx", pud_val(pud)); |
| 171 | if (pud_none(pud) || pud_bad(pud)) | ||
| 169 | break; | 172 | break; |
| 170 | 173 | ||
| 171 | pmd = pmd_offset(pud, addr); | 174 | pmdp = pmd_offset(pudp, addr); |
| 172 | pr_cont(", *pmd=%016llx", pmd_val(*pmd)); | 175 | pmd = READ_ONCE(*pmdp); |
| 173 | if (pmd_none(*pmd) || pmd_bad(*pmd)) | 176 | pr_cont(", pmd=%016llx", pmd_val(pmd)); |
| 177 | if (pmd_none(pmd) || pmd_bad(pmd)) | ||
| 174 | break; | 178 | break; |
| 175 | 179 | ||
| 176 | pte = pte_offset_map(pmd, addr); | 180 | ptep = pte_offset_map(pmdp, addr); |
| 177 | pr_cont(", *pte=%016llx", pte_val(*pte)); | 181 | pte = READ_ONCE(*ptep); |
| 178 | pte_unmap(pte); | 182 | pr_cont(", pte=%016llx", pte_val(pte)); |
| 183 | pte_unmap(ptep); | ||
| 179 | } while(0); | 184 | } while(0); |
| 180 | 185 | ||
| 181 | pr_cont("\n"); | 186 | pr_cont("\n"); |
| @@ -196,8 +201,9 @@ int ptep_set_access_flags(struct vm_area_struct *vma, | |||
| 196 | pte_t entry, int dirty) | 201 | pte_t entry, int dirty) |
| 197 | { | 202 | { |
| 198 | pteval_t old_pteval, pteval; | 203 | pteval_t old_pteval, pteval; |
| 204 | pte_t pte = READ_ONCE(*ptep); | ||
| 199 | 205 | ||
| 200 | if (pte_same(*ptep, entry)) | 206 | if (pte_same(pte, entry)) |
| 201 | return 0; | 207 | return 0; |
| 202 | 208 | ||
| 203 | /* only preserve the access flags and write permission */ | 209 | /* only preserve the access flags and write permission */ |
| @@ -210,7 +216,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, | |||
| 210 | * (calculated as: a & b == ~(~a | ~b)). | 216 | * (calculated as: a & b == ~(~a | ~b)). |
| 211 | */ | 217 | */ |
| 212 | pte_val(entry) ^= PTE_RDONLY; | 218 | pte_val(entry) ^= PTE_RDONLY; |
| 213 | pteval = READ_ONCE(pte_val(*ptep)); | 219 | pteval = pte_val(pte); |
| 214 | do { | 220 | do { |
| 215 | old_pteval = pteval; | 221 | old_pteval = pteval; |
| 216 | pteval ^= PTE_RDONLY; | 222 | pteval ^= PTE_RDONLY; |
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 6cb0fa92a651..ecc6818191df 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c | |||
| @@ -54,14 +54,14 @@ static inline pgprot_t pte_pgprot(pte_t pte) | |||
| 54 | static int find_num_contig(struct mm_struct *mm, unsigned long addr, | 54 | static int find_num_contig(struct mm_struct *mm, unsigned long addr, |
| 55 | pte_t *ptep, size_t *pgsize) | 55 | pte_t *ptep, size_t *pgsize) |
| 56 | { | 56 | { |
| 57 | pgd_t *pgd = pgd_offset(mm, addr); | 57 | pgd_t *pgdp = pgd_offset(mm, addr); |
| 58 | pud_t *pud; | 58 | pud_t *pudp; |
| 59 | pmd_t *pmd; | 59 | pmd_t *pmdp; |
| 60 | 60 | ||
| 61 | *pgsize = PAGE_SIZE; | 61 | *pgsize = PAGE_SIZE; |
| 62 | pud = pud_offset(pgd, addr); | 62 | pudp = pud_offset(pgdp, addr); |
| 63 | pmd = pmd_offset(pud, addr); | 63 | pmdp = pmd_offset(pudp, addr); |
| 64 | if ((pte_t *)pmd == ptep) { | 64 | if ((pte_t *)pmdp == ptep) { |
| 65 | *pgsize = PMD_SIZE; | 65 | *pgsize = PMD_SIZE; |
| 66 | return CONT_PMDS; | 66 | return CONT_PMDS; |
| 67 | } | 67 | } |
| @@ -181,11 +181,8 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, | |||
| 181 | 181 | ||
| 182 | clear_flush(mm, addr, ptep, pgsize, ncontig); | 182 | clear_flush(mm, addr, ptep, pgsize, ncontig); |
| 183 | 183 | ||
| 184 | for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) { | 184 | for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) |
| 185 | pr_debug("%s: set pte %p to 0x%llx\n", __func__, ptep, | ||
| 186 | pte_val(pfn_pte(pfn, hugeprot))); | ||
| 187 | set_pte_at(mm, addr, ptep, pfn_pte(pfn, hugeprot)); | 185 | set_pte_at(mm, addr, ptep, pfn_pte(pfn, hugeprot)); |
| 188 | } | ||
| 189 | } | 186 | } |
| 190 | 187 | ||
| 191 | void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, | 188 | void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, |
| @@ -203,20 +200,20 @@ void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, | |||
| 203 | pte_t *huge_pte_alloc(struct mm_struct *mm, | 200 | pte_t *huge_pte_alloc(struct mm_struct *mm, |
| 204 | unsigned long addr, unsigned long sz) | 201 | unsigned long addr, unsigned long sz) |
| 205 | { | 202 | { |
| 206 | pgd_t *pgd; | 203 | pgd_t *pgdp; |
| 207 | pud_t *pud; | 204 | pud_t *pudp; |
| 208 | pte_t *pte = NULL; | 205 | pmd_t *pmdp; |
| 209 | 206 | pte_t *ptep = NULL; | |
| 210 | pr_debug("%s: addr:0x%lx sz:0x%lx\n", __func__, addr, sz); | 207 | |
| 211 | pgd = pgd_offset(mm, addr); | 208 | pgdp = pgd_offset(mm, addr); |
| 212 | pud = pud_alloc(mm, pgd, addr); | 209 | pudp = pud_alloc(mm, pgdp, addr); |
| 213 | if (!pud) | 210 | if (!pudp) |
| 214 | return NULL; | 211 | return NULL; |
| 215 | 212 | ||
| 216 | if (sz == PUD_SIZE) { | 213 | if (sz == PUD_SIZE) { |
| 217 | pte = (pte_t *)pud; | 214 | ptep = (pte_t *)pudp; |
| 218 | } else if (sz == (PAGE_SIZE * CONT_PTES)) { | 215 | } else if (sz == (PAGE_SIZE * CONT_PTES)) { |
| 219 | pmd_t *pmd = pmd_alloc(mm, pud, addr); | 216 | pmdp = pmd_alloc(mm, pudp, addr); |
| 220 | 217 | ||
| 221 | WARN_ON(addr & (sz - 1)); | 218 | WARN_ON(addr & (sz - 1)); |
| 222 | /* | 219 | /* |
| @@ -226,60 +223,55 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, | |||
| 226 | * will be no pte_unmap() to correspond with this | 223 | * will be no pte_unmap() to correspond with this |
| 227 | * pte_alloc_map(). | 224 | * pte_alloc_map(). |
| 228 | */ | 225 | */ |
| 229 | pte = pte_alloc_map(mm, pmd, addr); | 226 | ptep = pte_alloc_map(mm, pmdp, addr); |
| 230 | } else if (sz == PMD_SIZE) { | 227 | } else if (sz == PMD_SIZE) { |
| 231 | if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && | 228 | if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && |
| 232 | pud_none(*pud)) | 229 | pud_none(READ_ONCE(*pudp))) |
| 233 | pte = huge_pmd_share(mm, addr, pud); | 230 | ptep = huge_pmd_share(mm, addr, pudp); |
| 234 | else | 231 | else |
| 235 | pte = (pte_t *)pmd_alloc(mm, pud, addr); | 232 | ptep = (pte_t *)pmd_alloc(mm, pudp, addr); |
| 236 | } else if (sz == (PMD_SIZE * CONT_PMDS)) { | 233 | } else if (sz == (PMD_SIZE * CONT_PMDS)) { |
| 237 | pmd_t *pmd; | 234 | pmdp = pmd_alloc(mm, pudp, addr); |
| 238 | |||
| 239 | pmd = pmd_alloc(mm, pud, addr); | ||
| 240 | WARN_ON(addr & (sz - 1)); | 235 | WARN_ON(addr & (sz - 1)); |
| 241 | return (pte_t *)pmd; | 236 | return (pte_t *)pmdp; |
| 242 | } | 237 | } |
| 243 | 238 | ||
| 244 | pr_debug("%s: addr:0x%lx sz:0x%lx ret pte=%p/0x%llx\n", __func__, addr, | 239 | return ptep; |
| 245 | sz, pte, pte_val(*pte)); | ||
| 246 | return pte; | ||
| 247 | } | 240 | } |
| 248 | 241 | ||
| 249 | pte_t *huge_pte_offset(struct mm_struct *mm, | 242 | pte_t *huge_pte_offset(struct mm_struct *mm, |
| 250 | unsigned long addr, unsigned long sz) | 243 | unsigned long addr, unsigned long sz) |
| 251 | { | 244 | { |
| 252 | pgd_t *pgd; | 245 | pgd_t *pgdp; |
| 253 | pud_t *pud; | 246 | pud_t *pudp, pud; |
| 254 | pmd_t *pmd; | 247 | pmd_t *pmdp, pmd; |
| 255 | 248 | ||
| 256 | pgd = pgd_offset(mm, addr); | 249 | pgdp = pgd_offset(mm, addr); |
| 257 | pr_debug("%s: addr:0x%lx pgd:%p\n", __func__, addr, pgd); | 250 | if (!pgd_present(READ_ONCE(*pgdp))) |
| 258 | if (!pgd_present(*pgd)) | ||
| 259 | return NULL; | 251 | return NULL; |
| 260 | 252 | ||
| 261 | pud = pud_offset(pgd, addr); | 253 | pudp = pud_offset(pgdp, addr); |
| 262 | if (sz != PUD_SIZE && pud_none(*pud)) | 254 | pud = READ_ONCE(*pudp); |
| 255 | if (sz != PUD_SIZE && pud_none(pud)) | ||
| 263 | return NULL; | 256 | return NULL; |
| 264 | /* hugepage or swap? */ | 257 | /* hugepage or swap? */ |
| 265 | if (pud_huge(*pud) || !pud_present(*pud)) | 258 | if (pud_huge(pud) || !pud_present(pud)) |
| 266 | return (pte_t *)pud; | 259 | return (pte_t *)pudp; |
| 267 | /* table; check the next level */ | 260 | /* table; check the next level */ |
| 268 | 261 | ||
| 269 | if (sz == CONT_PMD_SIZE) | 262 | if (sz == CONT_PMD_SIZE) |
| 270 | addr &= CONT_PMD_MASK; | 263 | addr &= CONT_PMD_MASK; |
| 271 | 264 | ||
| 272 | pmd = pmd_offset(pud, addr); | 265 | pmdp = pmd_offset(pudp, addr); |
| 266 | pmd = READ_ONCE(*pmdp); | ||
| 273 | if (!(sz == PMD_SIZE || sz == CONT_PMD_SIZE) && | 267 | if (!(sz == PMD_SIZE || sz == CONT_PMD_SIZE) && |
| 274 | pmd_none(*pmd)) | 268 | pmd_none(pmd)) |
| 275 | return NULL; | 269 | return NULL; |
| 276 | if (pmd_huge(*pmd) || !pmd_present(*pmd)) | 270 | if (pmd_huge(pmd) || !pmd_present(pmd)) |
| 277 | return (pte_t *)pmd; | 271 | return (pte_t *)pmdp; |
| 278 | 272 | ||
| 279 | if (sz == CONT_PTE_SIZE) { | 273 | if (sz == CONT_PTE_SIZE) |
| 280 | pte_t *pte = pte_offset_kernel(pmd, (addr & CONT_PTE_MASK)); | 274 | return pte_offset_kernel(pmdp, (addr & CONT_PTE_MASK)); |
| 281 | return pte; | ||
| 282 | } | ||
| 283 | 275 | ||
| 284 | return NULL; | 276 | return NULL; |
| 285 | } | 277 | } |
| @@ -367,7 +359,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, | |||
| 367 | size_t pgsize; | 359 | size_t pgsize; |
| 368 | pte_t pte; | 360 | pte_t pte; |
| 369 | 361 | ||
| 370 | if (!pte_cont(*ptep)) { | 362 | if (!pte_cont(READ_ONCE(*ptep))) { |
| 371 | ptep_set_wrprotect(mm, addr, ptep); | 363 | ptep_set_wrprotect(mm, addr, ptep); |
| 372 | return; | 364 | return; |
| 373 | } | 365 | } |
| @@ -391,7 +383,7 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma, | |||
| 391 | size_t pgsize; | 383 | size_t pgsize; |
| 392 | int ncontig; | 384 | int ncontig; |
| 393 | 385 | ||
| 394 | if (!pte_cont(*ptep)) { | 386 | if (!pte_cont(READ_ONCE(*ptep))) { |
| 395 | ptep_clear_flush(vma, addr, ptep); | 387 | ptep_clear_flush(vma, addr, ptep); |
| 396 | return; | 388 | return; |
| 397 | } | 389 | } |
diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 6e02e6fb4c7b..dabfc1ecda3d 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c | |||
| @@ -44,92 +44,92 @@ static phys_addr_t __init kasan_alloc_zeroed_page(int node) | |||
| 44 | return __pa(p); | 44 | return __pa(p); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static pte_t *__init kasan_pte_offset(pmd_t *pmd, unsigned long addr, int node, | 47 | static pte_t *__init kasan_pte_offset(pmd_t *pmdp, unsigned long addr, int node, |
| 48 | bool early) | 48 | bool early) |
| 49 | { | 49 | { |
| 50 | if (pmd_none(*pmd)) { | 50 | if (pmd_none(READ_ONCE(*pmdp))) { |
| 51 | phys_addr_t pte_phys = early ? __pa_symbol(kasan_zero_pte) | 51 | phys_addr_t pte_phys = early ? __pa_symbol(kasan_zero_pte) |
| 52 | : kasan_alloc_zeroed_page(node); | 52 | : kasan_alloc_zeroed_page(node); |
| 53 | __pmd_populate(pmd, pte_phys, PMD_TYPE_TABLE); | 53 | __pmd_populate(pmdp, pte_phys, PMD_TYPE_TABLE); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | return early ? pte_offset_kimg(pmd, addr) | 56 | return early ? pte_offset_kimg(pmdp, addr) |
| 57 | : pte_offset_kernel(pmd, addr); | 57 | : pte_offset_kernel(pmdp, addr); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static pmd_t *__init kasan_pmd_offset(pud_t *pud, unsigned long addr, int node, | 60 | static pmd_t *__init kasan_pmd_offset(pud_t *pudp, unsigned long addr, int node, |
| 61 | bool early) | 61 | bool early) |
| 62 | { | 62 | { |
| 63 | if (pud_none(*pud)) { | 63 | if (pud_none(READ_ONCE(*pudp))) { |
| 64 | phys_addr_t pmd_phys = early ? __pa_symbol(kasan_zero_pmd) | 64 | phys_addr_t pmd_phys = early ? __pa_symbol(kasan_zero_pmd) |
| 65 | : kasan_alloc_zeroed_page(node); | 65 | : kasan_alloc_zeroed_page(node); |
| 66 | __pud_populate(pud, pmd_phys, PMD_TYPE_TABLE); | 66 | __pud_populate(pudp, pmd_phys, PMD_TYPE_TABLE); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | return early ? pmd_offset_kimg(pud, addr) : pmd_offset(pud, addr); | 69 | return early ? pmd_offset_kimg(pudp, addr) : pmd_offset(pudp, addr); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static pud_t *__init kasan_pud_offset(pgd_t *pgd, unsigned long addr, int node, | 72 | static pud_t *__init kasan_pud_offset(pgd_t *pgdp, unsigned long addr, int node, |
| 73 | bool early) | 73 | bool early) |
| 74 | { | 74 | { |
| 75 | if (pgd_none(*pgd)) { | 75 | if (pgd_none(READ_ONCE(*pgdp))) { |
| 76 | phys_addr_t pud_phys = early ? __pa_symbol(kasan_zero_pud) | 76 | phys_addr_t pud_phys = early ? __pa_symbol(kasan_zero_pud) |
| 77 | : kasan_alloc_zeroed_page(node); | 77 | : kasan_alloc_zeroed_page(node); |
| 78 | __pgd_populate(pgd, pud_phys, PMD_TYPE_TABLE); | 78 | __pgd_populate(pgdp, pud_phys, PMD_TYPE_TABLE); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | return early ? pud_offset_kimg(pgd, addr) : pud_offset(pgd, addr); | 81 | return early ? pud_offset_kimg(pgdp, addr) : pud_offset(pgdp, addr); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static void __init kasan_pte_populate(pmd_t *pmd, unsigned long addr, | 84 | static void __init kasan_pte_populate(pmd_t *pmdp, unsigned long addr, |
| 85 | unsigned long end, int node, bool early) | 85 | unsigned long end, int node, bool early) |
| 86 | { | 86 | { |
| 87 | unsigned long next; | 87 | unsigned long next; |
| 88 | pte_t *pte = kasan_pte_offset(pmd, addr, node, early); | 88 | pte_t *ptep = kasan_pte_offset(pmdp, addr, node, early); |
| 89 | 89 | ||
| 90 | do { | 90 | do { |
| 91 | phys_addr_t page_phys = early ? __pa_symbol(kasan_zero_page) | 91 | phys_addr_t page_phys = early ? __pa_symbol(kasan_zero_page) |
| 92 | : kasan_alloc_zeroed_page(node); | 92 | : kasan_alloc_zeroed_page(node); |
| 93 | next = addr + PAGE_SIZE; | 93 | next = addr + PAGE_SIZE; |
| 94 | set_pte(pte, pfn_pte(__phys_to_pfn(page_phys), PAGE_KERNEL)); | 94 | set_pte(ptep, pfn_pte(__phys_to_pfn(page_phys), PAGE_KERNEL)); |
| 95 | } while (pte++, addr = next, addr != end && pte_none(*pte)); | 95 | } while (ptep++, addr = next, addr != end && pte_none(READ_ONCE(*ptep))); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | static void __init kasan_pmd_populate(pud_t *pud, unsigned long addr, | 98 | static void __init kasan_pmd_populate(pud_t *pudp, unsigned long addr, |
| 99 | unsigned long end, int node, bool early) | 99 | unsigned long end, int node, bool early) |
| 100 | { | 100 | { |
| 101 | unsigned long next; | 101 | unsigned long next; |
| 102 | pmd_t *pmd = kasan_pmd_offset(pud, addr, node, early); | 102 | pmd_t *pmdp = kasan_pmd_offset(pudp, addr, node, early); |
| 103 | 103 | ||
| 104 | do { | 104 | do { |
| 105 | next = pmd_addr_end(addr, end); | 105 | next = pmd_addr_end(addr, end); |
| 106 | kasan_pte_populate(pmd, addr, next, node, early); | 106 | kasan_pte_populate(pmdp, addr, next, node, early); |
| 107 | } while (pmd++, addr = next, addr != end && pmd_none(*pmd)); | 107 | } while (pmdp++, addr = next, addr != end && pmd_none(READ_ONCE(*pmdp))); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | static void __init kasan_pud_populate(pgd_t *pgd, unsigned long addr, | 110 | static void __init kasan_pud_populate(pgd_t *pgdp, unsigned long addr, |
| 111 | unsigned long end, int node, bool early) | 111 | unsigned long end, int node, bool early) |
| 112 | { | 112 | { |
| 113 | unsigned long next; | 113 | unsigned long next; |
| 114 | pud_t *pud = kasan_pud_offset(pgd, addr, node, early); | 114 | pud_t *pudp = kasan_pud_offset(pgdp, addr, node, early); |
| 115 | 115 | ||
| 116 | do { | 116 | do { |
| 117 | next = pud_addr_end(addr, end); | 117 | next = pud_addr_end(addr, end); |
| 118 | kasan_pmd_populate(pud, addr, next, node, early); | 118 | kasan_pmd_populate(pudp, addr, next, node, early); |
| 119 | } while (pud++, addr = next, addr != end && pud_none(*pud)); | 119 | } while (pudp++, addr = next, addr != end && pud_none(READ_ONCE(*pudp))); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static void __init kasan_pgd_populate(unsigned long addr, unsigned long end, | 122 | static void __init kasan_pgd_populate(unsigned long addr, unsigned long end, |
| 123 | int node, bool early) | 123 | int node, bool early) |
| 124 | { | 124 | { |
| 125 | unsigned long next; | 125 | unsigned long next; |
| 126 | pgd_t *pgd; | 126 | pgd_t *pgdp; |
| 127 | 127 | ||
| 128 | pgd = pgd_offset_k(addr); | 128 | pgdp = pgd_offset_k(addr); |
| 129 | do { | 129 | do { |
| 130 | next = pgd_addr_end(addr, end); | 130 | next = pgd_addr_end(addr, end); |
| 131 | kasan_pud_populate(pgd, addr, next, node, early); | 131 | kasan_pud_populate(pgdp, addr, next, node, early); |
| 132 | } while (pgd++, addr = next, addr != end); | 132 | } while (pgdp++, addr = next, addr != end); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* The early shadow maps everything to a single page of zeroes */ | 135 | /* The early shadow maps everything to a single page of zeroes */ |
| @@ -155,14 +155,14 @@ static void __init kasan_map_populate(unsigned long start, unsigned long end, | |||
| 155 | */ | 155 | */ |
| 156 | void __init kasan_copy_shadow(pgd_t *pgdir) | 156 | void __init kasan_copy_shadow(pgd_t *pgdir) |
| 157 | { | 157 | { |
| 158 | pgd_t *pgd, *pgd_new, *pgd_end; | 158 | pgd_t *pgdp, *pgdp_new, *pgdp_end; |
| 159 | 159 | ||
| 160 | pgd = pgd_offset_k(KASAN_SHADOW_START); | 160 | pgdp = pgd_offset_k(KASAN_SHADOW_START); |
| 161 | pgd_end = pgd_offset_k(KASAN_SHADOW_END); | 161 | pgdp_end = pgd_offset_k(KASAN_SHADOW_END); |
| 162 | pgd_new = pgd_offset_raw(pgdir, KASAN_SHADOW_START); | 162 | pgdp_new = pgd_offset_raw(pgdir, KASAN_SHADOW_START); |
| 163 | do { | 163 | do { |
| 164 | set_pgd(pgd_new, *pgd); | 164 | set_pgd(pgdp_new, READ_ONCE(*pgdp)); |
| 165 | } while (pgd++, pgd_new++, pgd != pgd_end); | 165 | } while (pgdp++, pgdp_new++, pgdp != pgdp_end); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | static void __init clear_pgds(unsigned long start, | 168 | static void __init clear_pgds(unsigned long start, |
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 4694cda823c9..3161b853f29e 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c | |||
| @@ -125,45 +125,48 @@ static bool pgattr_change_is_safe(u64 old, u64 new) | |||
| 125 | return ((old ^ new) & ~mask) == 0; | 125 | return ((old ^ new) & ~mask) == 0; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | static void init_pte(pmd_t *pmd, unsigned long addr, unsigned long end, | 128 | static void init_pte(pmd_t *pmdp, unsigned long addr, unsigned long end, |
| 129 | phys_addr_t phys, pgprot_t prot) | 129 | phys_addr_t phys, pgprot_t prot) |
| 130 | { | 130 | { |
| 131 | pte_t *pte; | 131 | pte_t *ptep; |
| 132 | 132 | ||
| 133 | pte = pte_set_fixmap_offset(pmd, addr); | 133 | ptep = pte_set_fixmap_offset(pmdp, addr); |
| 134 | do { | 134 | do { |
| 135 | pte_t old_pte = *pte; | 135 | pte_t old_pte = READ_ONCE(*ptep); |
| 136 | 136 | ||
| 137 | set_pte(pte, pfn_pte(__phys_to_pfn(phys), prot)); | 137 | set_pte(ptep, pfn_pte(__phys_to_pfn(phys), prot)); |
| 138 | 138 | ||
| 139 | /* | 139 | /* |
| 140 | * After the PTE entry has been populated once, we | 140 | * After the PTE entry has been populated once, we |
| 141 | * only allow updates to the permission attributes. | 141 | * only allow updates to the permission attributes. |
| 142 | */ | 142 | */ |
| 143 | BUG_ON(!pgattr_change_is_safe(pte_val(old_pte), pte_val(*pte))); | 143 | BUG_ON(!pgattr_change_is_safe(pte_val(old_pte), |
| 144 | READ_ONCE(pte_val(*ptep)))); | ||
| 144 | 145 | ||
| 145 | phys += PAGE_SIZE; | 146 | phys += PAGE_SIZE; |
| 146 | } while (pte++, addr += PAGE_SIZE, addr != end); | 147 | } while (ptep++, addr += PAGE_SIZE, addr != end); |
| 147 | 148 | ||
| 148 | pte_clear_fixmap(); | 149 | pte_clear_fixmap(); |
| 149 | } | 150 | } |
| 150 | 151 | ||
| 151 | static void alloc_init_cont_pte(pmd_t *pmd, unsigned long addr, | 152 | static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, |
| 152 | unsigned long end, phys_addr_t phys, | 153 | unsigned long end, phys_addr_t phys, |
| 153 | pgprot_t prot, | 154 | pgprot_t prot, |
| 154 | phys_addr_t (*pgtable_alloc)(void), | 155 | phys_addr_t (*pgtable_alloc)(void), |
| 155 | int flags) | 156 | int flags) |
| 156 | { | 157 | { |
| 157 | unsigned long next; | 158 | unsigned long next; |
| 159 | pmd_t pmd = READ_ONCE(*pmdp); | ||
| 158 | 160 | ||
| 159 | BUG_ON(pmd_sect(*pmd)); | 161 | BUG_ON(pmd_sect(pmd)); |
| 160 | if (pmd_none(*pmd)) { | 162 | if (pmd_none(pmd)) { |
| 161 | phys_addr_t pte_phys; | 163 | phys_addr_t pte_phys; |
| 162 | BUG_ON(!pgtable_alloc); | 164 | BUG_ON(!pgtable_alloc); |
| 163 | pte_phys = pgtable_alloc(); | 165 | pte_phys = pgtable_alloc(); |
| 164 | __pmd_populate(pmd, pte_phys, PMD_TYPE_TABLE); | 166 | __pmd_populate(pmdp, pte_phys, PMD_TYPE_TABLE); |
| 167 | pmd = READ_ONCE(*pmdp); | ||
| 165 | } | 168 | } |
| 166 | BUG_ON(pmd_bad(*pmd)); | 169 | BUG_ON(pmd_bad(pmd)); |
| 167 | 170 | ||
| 168 | do { | 171 | do { |
| 169 | pgprot_t __prot = prot; | 172 | pgprot_t __prot = prot; |
| @@ -175,67 +178,69 @@ static void alloc_init_cont_pte(pmd_t *pmd, unsigned long addr, | |||
| 175 | (flags & NO_CONT_MAPPINGS) == 0) | 178 | (flags & NO_CONT_MAPPINGS) == 0) |
| 176 | __prot = __pgprot(pgprot_val(prot) | PTE_CONT); | 179 | __prot = __pgprot(pgprot_val(prot) | PTE_CONT); |
| 177 | 180 | ||
| 178 | init_pte(pmd, addr, next, phys, __prot); | 181 | init_pte(pmdp, addr, next, phys, __prot); |
| 179 | 182 | ||
| 180 | phys += next - addr; | 183 | phys += next - addr; |
| 181 | } while (addr = next, addr != end); | 184 | } while (addr = next, addr != end); |
| 182 | } | 185 | } |
| 183 | 186 | ||
| 184 | static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end, | 187 | static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end, |
| 185 | phys_addr_t phys, pgprot_t prot, | 188 | phys_addr_t phys, pgprot_t prot, |
| 186 | phys_addr_t (*pgtable_alloc)(void), int flags) | 189 | phys_addr_t (*pgtable_alloc)(void), int flags) |
| 187 | { | 190 | { |
| 188 | unsigned long next; | 191 | unsigned long next; |
| 189 | pmd_t *pmd; | 192 | pmd_t *pmdp; |
| 190 | 193 | ||
| 191 | pmd = pmd_set_fixmap_offset(pud, addr); | 194 | pmdp = pmd_set_fixmap_offset(pudp, addr); |
| 192 | do { | 195 | do { |
| 193 | pmd_t old_pmd = *pmd; | 196 | pmd_t old_pmd = READ_ONCE(*pmdp); |
| 194 | 197 | ||
| 195 | next = pmd_addr_end(addr, end); | 198 | next = pmd_addr_end(addr, end); |
| 196 | 199 | ||
| 197 | /* try section mapping first */ | 200 | /* try section mapping first */ |
| 198 | if (((addr | next | phys) & ~SECTION_MASK) == 0 && | 201 | if (((addr | next | phys) & ~SECTION_MASK) == 0 && |
| 199 | (flags & NO_BLOCK_MAPPINGS) == 0) { | 202 | (flags & NO_BLOCK_MAPPINGS) == 0) { |
| 200 | pmd_set_huge(pmd, phys, prot); | 203 | pmd_set_huge(pmdp, phys, prot); |
| 201 | 204 | ||
| 202 | /* | 205 | /* |
| 203 | * After the PMD entry has been populated once, we | 206 | * After the PMD entry has been populated once, we |
| 204 | * only allow updates to the permission attributes. | 207 | * only allow updates to the permission attributes. |
| 205 | */ | 208 | */ |
| 206 | BUG_ON(!pgattr_change_is_safe(pmd_val(old_pmd), | 209 | BUG_ON(!pgattr_change_is_safe(pmd_val(old_pmd), |
| 207 | pmd_val(*pmd))); | 210 | READ_ONCE(pmd_val(*pmdp)))); |
| 208 | } else { | 211 | } else { |
| 209 | alloc_init_cont_pte(pmd, addr, next, phys, prot, | 212 | alloc_init_cont_pte(pmdp, addr, next, phys, prot, |
| 210 | pgtable_alloc, flags); | 213 | pgtable_alloc, flags); |
| 211 | 214 | ||
| 212 | BUG_ON(pmd_val(old_pmd) != 0 && | 215 | BUG_ON(pmd_val(old_pmd) != 0 && |
| 213 | pmd_val(old_pmd) != pmd_val(*pmd)); | 216 | pmd_val(old_pmd) != READ_ONCE(pmd_val(*pmdp))); |
| 214 | } | 217 | } |
| 215 | phys += next - addr; | 218 | phys += next - addr; |
| 216 | } while (pmd++, addr = next, addr != end); | 219 | } while (pmdp++, addr = next, addr != end); |
| 217 | 220 | ||
| 218 | pmd_clear_fixmap(); | 221 | pmd_clear_fixmap(); |
| 219 | } | 222 | } |
| 220 | 223 | ||
| 221 | static void alloc_init_cont_pmd(pud_t *pud, unsigned long addr, | 224 | static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr, |
| 222 | unsigned long end, phys_addr_t phys, | 225 | unsigned long end, phys_addr_t phys, |
| 223 | pgprot_t prot, | 226 | pgprot_t prot, |
| 224 | phys_addr_t (*pgtable_alloc)(void), int flags) | 227 | phys_addr_t (*pgtable_alloc)(void), int flags) |
| 225 | { | 228 | { |
| 226 | unsigned long next; | 229 | unsigned long next; |
| 230 | pud_t pud = READ_ONCE(*pudp); | ||
| 227 | 231 | ||
| 228 | /* | 232 | /* |
| 229 | * Check for initial section mappings in the pgd/pud. | 233 | * Check for initial section mappings in the pgd/pud. |
| 230 | */ | 234 | */ |
| 231 | BUG_ON(pud_sect(*pud)); | 235 | BUG_ON(pud_sect(pud)); |
| 232 | if (pud_none(*pud)) { | 236 | if (pud_none(pud)) { |
| 233 | phys_addr_t pmd_phys; | 237 | phys_addr_t pmd_phys; |
| 234 | BUG_ON(!pgtable_alloc); | 238 | BUG_ON(!pgtable_alloc); |
| 235 | pmd_phys = pgtable_alloc(); | 239 | pmd_phys = pgtable_alloc(); |
| 236 | __pud_populate(pud, pmd_phys, PUD_TYPE_TABLE); | 240 | __pud_populate(pudp, pmd_phys, PUD_TYPE_TABLE); |
| 241 | pud = READ_ONCE(*pudp); | ||
| 237 | } | 242 | } |
| 238 | BUG_ON(pud_bad(*pud)); | 243 | BUG_ON(pud_bad(pud)); |
| 239 | 244 | ||
| 240 | do { | 245 | do { |
| 241 | pgprot_t __prot = prot; | 246 | pgprot_t __prot = prot; |
| @@ -247,7 +252,7 @@ static void alloc_init_cont_pmd(pud_t *pud, unsigned long addr, | |||
| 247 | (flags & NO_CONT_MAPPINGS) == 0) | 252 | (flags & NO_CONT_MAPPINGS) == 0) |
| 248 | __prot = __pgprot(pgprot_val(prot) | PTE_CONT); | 253 | __prot = __pgprot(pgprot_val(prot) | PTE_CONT); |
| 249 | 254 | ||
| 250 | init_pmd(pud, addr, next, phys, __prot, pgtable_alloc, flags); | 255 | init_pmd(pudp, addr, next, phys, __prot, pgtable_alloc, flags); |
| 251 | 256 | ||
| 252 | phys += next - addr; | 257 | phys += next - addr; |
| 253 | } while (addr = next, addr != end); | 258 | } while (addr = next, addr != end); |
| @@ -265,25 +270,27 @@ static inline bool use_1G_block(unsigned long addr, unsigned long next, | |||
| 265 | return true; | 270 | return true; |
| 266 | } | 271 | } |
| 267 | 272 | ||
| 268 | static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, | 273 | static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, |
| 269 | phys_addr_t phys, pgprot_t prot, | 274 | phys_addr_t phys, pgprot_t prot, |
| 270 | phys_addr_t (*pgtable_alloc)(void), | 275 | phys_addr_t (*pgtable_alloc)(void), |
| 271 | int flags) | 276 | int flags) |
| 272 | { | 277 | { |
| 273 | pud_t *pud; | ||
| 274 | unsigned long next; | 278 | unsigned long next; |
| 279 | pud_t *pudp; | ||
| 280 | pgd_t pgd = READ_ONCE(*pgdp); | ||
| 275 | 281 | ||
| 276 | if (pgd_none(*pgd)) { | 282 | if (pgd_none(pgd)) { |
| 277 | phys_addr_t pud_phys; | 283 | phys_addr_t pud_phys; |
| 278 | BUG_ON(!pgtable_alloc); | 284 | BUG_ON(!pgtable_alloc); |
| 279 | pud_phys = pgtable_alloc(); | 285 | pud_phys = pgtable_alloc(); |
| 280 | __pgd_populate(pgd, pud_phys, PUD_TYPE_TABLE); | 286 | __pgd_populate(pgdp, pud_phys, PUD_TYPE_TABLE); |
| 287 | pgd = READ_ONCE(*pgdp); | ||
| 281 | } | 288 | } |
| 282 | BUG_ON(pgd_bad(*pgd)); | 289 | BUG_ON(pgd_bad(pgd)); |
| 283 | 290 | ||
| 284 | pud = pud_set_fixmap_offset(pgd, addr); | 291 | pudp = pud_set_fixmap_offset(pgdp, addr); |
| 285 | do { | 292 | do { |
| 286 | pud_t old_pud = *pud; | 293 | pud_t old_pud = READ_ONCE(*pudp); |
| 287 | 294 | ||
| 288 | next = pud_addr_end(addr, end); | 295 | next = pud_addr_end(addr, end); |
| 289 | 296 | ||
| @@ -292,23 +299,23 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, | |||
| 292 | */ | 299 | */ |
| 293 | if (use_1G_block(addr, next, phys) && | 300 | if (use_1G_block(addr, next, phys) && |
| 294 | (flags & NO_BLOCK_MAPPINGS) == 0) { | 301 | (flags & NO_BLOCK_MAPPINGS) == 0) { |
| 295 | pud_set_huge(pud, phys, prot); | 302 | pud_set_huge(pudp, phys, prot); |
| 296 | 303 | ||
| 297 | /* | 304 | /* |
| 298 | * After the PUD entry has been populated once, we | 305 | * After the PUD entry has been populated once, we |
| 299 | * only allow updates to the permission attributes. | 306 | * only allow updates to the permission attributes. |
| 300 | */ | 307 | */ |
| 301 | BUG_ON(!pgattr_change_is_safe(pud_val(old_pud), | 308 | BUG_ON(!pgattr_change_is_safe(pud_val(old_pud), |
| 302 | pud_val(*pud))); | 309 | READ_ONCE(pud_val(*pudp)))); |
| 303 | } else { | 310 | } else { |
| 304 | alloc_init_cont_pmd(pud, addr, next, phys, prot, | 311 | alloc_init_cont_pmd(pudp, addr, next, phys, prot, |
| 305 | pgtable_alloc, flags); | 312 | pgtable_alloc, flags); |
| 306 | 313 | ||
| 307 | BUG_ON(pud_val(old_pud) != 0 && | 314 | BUG_ON(pud_val(old_pud) != 0 && |
| 308 | pud_val(old_pud) != pud_val(*pud)); | 315 | pud_val(old_pud) != READ_ONCE(pud_val(*pudp))); |
| 309 | } | 316 | } |
| 310 | phys += next - addr; | 317 | phys += next - addr; |
| 311 | } while (pud++, addr = next, addr != end); | 318 | } while (pudp++, addr = next, addr != end); |
| 312 | 319 | ||
| 313 | pud_clear_fixmap(); | 320 | pud_clear_fixmap(); |
| 314 | } | 321 | } |
| @@ -320,7 +327,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, | |||
| 320 | int flags) | 327 | int flags) |
| 321 | { | 328 | { |
| 322 | unsigned long addr, length, end, next; | 329 | unsigned long addr, length, end, next; |
| 323 | pgd_t *pgd = pgd_offset_raw(pgdir, virt); | 330 | pgd_t *pgdp = pgd_offset_raw(pgdir, virt); |
| 324 | 331 | ||
| 325 | /* | 332 | /* |
| 326 | * If the virtual and physical address don't have the same offset | 333 | * If the virtual and physical address don't have the same offset |
| @@ -336,10 +343,10 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, | |||
| 336 | end = addr + length; | 343 | end = addr + length; |
| 337 | do { | 344 | do { |
| 338 | next = pgd_addr_end(addr, end); | 345 | next = pgd_addr_end(addr, end); |
| 339 | alloc_init_pud(pgd, addr, next, phys, prot, pgtable_alloc, | 346 | alloc_init_pud(pgdp, addr, next, phys, prot, pgtable_alloc, |
| 340 | flags); | 347 | flags); |
| 341 | phys += next - addr; | 348 | phys += next - addr; |
| 342 | } while (pgd++, addr = next, addr != end); | 349 | } while (pgdp++, addr = next, addr != end); |
| 343 | } | 350 | } |
| 344 | 351 | ||
| 345 | static phys_addr_t pgd_pgtable_alloc(void) | 352 | static phys_addr_t pgd_pgtable_alloc(void) |
| @@ -401,10 +408,10 @@ static void update_mapping_prot(phys_addr_t phys, unsigned long virt, | |||
| 401 | flush_tlb_kernel_range(virt, virt + size); | 408 | flush_tlb_kernel_range(virt, virt + size); |
| 402 | } | 409 | } |
| 403 | 410 | ||
| 404 | static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, | 411 | static void __init __map_memblock(pgd_t *pgdp, phys_addr_t start, |
| 405 | phys_addr_t end, pgprot_t prot, int flags) | 412 | phys_addr_t end, pgprot_t prot, int flags) |
| 406 | { | 413 | { |
| 407 | __create_pgd_mapping(pgd, start, __phys_to_virt(start), end - start, | 414 | __create_pgd_mapping(pgdp, start, __phys_to_virt(start), end - start, |
| 408 | prot, early_pgtable_alloc, flags); | 415 | prot, early_pgtable_alloc, flags); |
| 409 | } | 416 | } |
| 410 | 417 | ||
| @@ -418,7 +425,7 @@ void __init mark_linear_text_alias_ro(void) | |||
| 418 | PAGE_KERNEL_RO); | 425 | PAGE_KERNEL_RO); |
| 419 | } | 426 | } |
| 420 | 427 | ||
| 421 | static void __init map_mem(pgd_t *pgd) | 428 | static void __init map_mem(pgd_t *pgdp) |
| 422 | { | 429 | { |
| 423 | phys_addr_t kernel_start = __pa_symbol(_text); | 430 | phys_addr_t kernel_start = __pa_symbol(_text); |
| 424 | phys_addr_t kernel_end = __pa_symbol(__init_begin); | 431 | phys_addr_t kernel_end = __pa_symbol(__init_begin); |
| @@ -451,7 +458,7 @@ static void __init map_mem(pgd_t *pgd) | |||
| 451 | if (memblock_is_nomap(reg)) | 458 | if (memblock_is_nomap(reg)) |
| 452 | continue; | 459 | continue; |
| 453 | 460 | ||
| 454 | __map_memblock(pgd, start, end, PAGE_KERNEL, flags); | 461 | __map_memblock(pgdp, start, end, PAGE_KERNEL, flags); |
| 455 | } | 462 | } |
| 456 | 463 | ||
| 457 | /* | 464 | /* |
| @@ -464,7 +471,7 @@ static void __init map_mem(pgd_t *pgd) | |||
| 464 | * Note that contiguous mappings cannot be remapped in this way, | 471 | * Note that contiguous mappings cannot be remapped in this way, |
| 465 | * so we should avoid them here. | 472 | * so we should avoid them here. |
| 466 | */ | 473 | */ |
| 467 | __map_memblock(pgd, kernel_start, kernel_end, | 474 | __map_memblock(pgdp, kernel_start, kernel_end, |
| 468 | PAGE_KERNEL, NO_CONT_MAPPINGS); | 475 | PAGE_KERNEL, NO_CONT_MAPPINGS); |
| 469 | memblock_clear_nomap(kernel_start, kernel_end - kernel_start); | 476 | memblock_clear_nomap(kernel_start, kernel_end - kernel_start); |
| 470 | 477 | ||
| @@ -475,7 +482,7 @@ static void __init map_mem(pgd_t *pgd) | |||
| 475 | * through /sys/kernel/kexec_crash_size interface. | 482 | * through /sys/kernel/kexec_crash_size interface. |
| 476 | */ | 483 | */ |
| 477 | if (crashk_res.end) { | 484 | if (crashk_res.end) { |
| 478 | __map_memblock(pgd, crashk_res.start, crashk_res.end + 1, | 485 | __map_memblock(pgdp, crashk_res.start, crashk_res.end + 1, |
| 479 | PAGE_KERNEL, | 486 | PAGE_KERNEL, |
| 480 | NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); | 487 | NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); |
| 481 | memblock_clear_nomap(crashk_res.start, | 488 | memblock_clear_nomap(crashk_res.start, |
| @@ -499,7 +506,7 @@ void mark_rodata_ro(void) | |||
| 499 | debug_checkwx(); | 506 | debug_checkwx(); |
| 500 | } | 507 | } |
| 501 | 508 | ||
| 502 | static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, | 509 | static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end, |
| 503 | pgprot_t prot, struct vm_struct *vma, | 510 | pgprot_t prot, struct vm_struct *vma, |
| 504 | int flags, unsigned long vm_flags) | 511 | int flags, unsigned long vm_flags) |
| 505 | { | 512 | { |
| @@ -509,7 +516,7 @@ static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, | |||
| 509 | BUG_ON(!PAGE_ALIGNED(pa_start)); | 516 | BUG_ON(!PAGE_ALIGNED(pa_start)); |
| 510 | BUG_ON(!PAGE_ALIGNED(size)); | 517 | BUG_ON(!PAGE_ALIGNED(size)); |
| 511 | 518 | ||
| 512 | __create_pgd_mapping(pgd, pa_start, (unsigned long)va_start, size, prot, | 519 | __create_pgd_mapping(pgdp, pa_start, (unsigned long)va_start, size, prot, |
| 513 | early_pgtable_alloc, flags); | 520 | early_pgtable_alloc, flags); |
| 514 | 521 | ||
| 515 | if (!(vm_flags & VM_NO_GUARD)) | 522 | if (!(vm_flags & VM_NO_GUARD)) |
| @@ -562,7 +569,7 @@ core_initcall(map_entry_trampoline); | |||
| 562 | /* | 569 | /* |
| 563 | * Create fine-grained mappings for the kernel. | 570 | * Create fine-grained mappings for the kernel. |
| 564 | */ | 571 | */ |
| 565 | static void __init map_kernel(pgd_t *pgd) | 572 | static void __init map_kernel(pgd_t *pgdp) |
| 566 | { | 573 | { |
| 567 | static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_inittext, | 574 | static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_inittext, |
| 568 | vmlinux_initdata, vmlinux_data; | 575 | vmlinux_initdata, vmlinux_data; |
| @@ -578,24 +585,24 @@ static void __init map_kernel(pgd_t *pgd) | |||
| 578 | * Only rodata will be remapped with different permissions later on, | 585 | * Only rodata will be remapped with different permissions later on, |
| 579 | * all other segments are allowed to use contiguous mappings. | 586 | * all other segments are allowed to use contiguous mappings. |
| 580 | */ | 587 | */ |
| 581 | map_kernel_segment(pgd, _text, _etext, text_prot, &vmlinux_text, 0, | 588 | map_kernel_segment(pgdp, _text, _etext, text_prot, &vmlinux_text, 0, |
| 582 | VM_NO_GUARD); | 589 | VM_NO_GUARD); |
| 583 | map_kernel_segment(pgd, __start_rodata, __inittext_begin, PAGE_KERNEL, | 590 | map_kernel_segment(pgdp, __start_rodata, __inittext_begin, PAGE_KERNEL, |
| 584 | &vmlinux_rodata, NO_CONT_MAPPINGS, VM_NO_GUARD); | 591 | &vmlinux_rodata, NO_CONT_MAPPINGS, VM_NO_GUARD); |
| 585 | map_kernel_segment(pgd, __inittext_begin, __inittext_end, text_prot, | 592 | map_kernel_segment(pgdp, __inittext_begin, __inittext_end, text_prot, |
| 586 | &vmlinux_inittext, 0, VM_NO_GUARD); | 593 | &vmlinux_inittext, 0, VM_NO_GUARD); |
| 587 | map_kernel_segment(pgd, __initdata_begin, __initdata_end, PAGE_KERNEL, | 594 | map_kernel_segment(pgdp, __initdata_begin, __initdata_end, PAGE_KERNEL, |
| 588 | &vmlinux_initdata, 0, VM_NO_GUARD); | 595 | &vmlinux_initdata, 0, VM_NO_GUARD); |
| 589 | map_kernel_segment(pgd, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0); | 596 | map_kernel_segment(pgdp, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0); |
| 590 | 597 | ||
| 591 | if (!pgd_val(*pgd_offset_raw(pgd, FIXADDR_START))) { | 598 | if (!READ_ONCE(pgd_val(*pgd_offset_raw(pgdp, FIXADDR_START)))) { |
| 592 | /* | 599 | /* |
| 593 | * The fixmap falls in a separate pgd to the kernel, and doesn't | 600 | * The fixmap falls in a separate pgd to the kernel, and doesn't |
| 594 | * live in the carveout for the swapper_pg_dir. We can simply | 601 | * live in the carveout for the swapper_pg_dir. We can simply |
| 595 | * re-use the existing dir for the fixmap. | 602 | * re-use the existing dir for the fixmap. |
| 596 | */ | 603 | */ |
| 597 | set_pgd(pgd_offset_raw(pgd, FIXADDR_START), | 604 | set_pgd(pgd_offset_raw(pgdp, FIXADDR_START), |
| 598 | *pgd_offset_k(FIXADDR_START)); | 605 | READ_ONCE(*pgd_offset_k(FIXADDR_START))); |
| 599 | } else if (CONFIG_PGTABLE_LEVELS > 3) { | 606 | } else if (CONFIG_PGTABLE_LEVELS > 3) { |
| 600 | /* | 607 | /* |
| 601 | * The fixmap shares its top level pgd entry with the kernel | 608 | * The fixmap shares its top level pgd entry with the kernel |
| @@ -604,14 +611,15 @@ static void __init map_kernel(pgd_t *pgd) | |||
| 604 | * entry instead. | 611 | * entry instead. |
| 605 | */ | 612 | */ |
| 606 | BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); | 613 | BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); |
| 607 | pud_populate(&init_mm, pud_set_fixmap_offset(pgd, FIXADDR_START), | 614 | pud_populate(&init_mm, |
| 615 | pud_set_fixmap_offset(pgdp, FIXADDR_START), | ||
| 608 | lm_alias(bm_pmd)); | 616 | lm_alias(bm_pmd)); |
| 609 | pud_clear_fixmap(); | 617 | pud_clear_fixmap(); |
| 610 | } else { | 618 | } else { |
| 611 | BUG(); | 619 | BUG(); |
| 612 | } | 620 | } |
| 613 | 621 | ||
| 614 | kasan_copy_shadow(pgd); | 622 | kasan_copy_shadow(pgdp); |
| 615 | } | 623 | } |
| 616 | 624 | ||
| 617 | /* | 625 | /* |
| @@ -621,10 +629,10 @@ static void __init map_kernel(pgd_t *pgd) | |||
| 621 | void __init paging_init(void) | 629 | void __init paging_init(void) |
| 622 | { | 630 | { |
| 623 | phys_addr_t pgd_phys = early_pgtable_alloc(); | 631 | phys_addr_t pgd_phys = early_pgtable_alloc(); |
| 624 | pgd_t *pgd = pgd_set_fixmap(pgd_phys); | 632 | pgd_t *pgdp = pgd_set_fixmap(pgd_phys); |
| 625 | 633 | ||
| 626 | map_kernel(pgd); | 634 | map_kernel(pgdp); |
| 627 | map_mem(pgd); | 635 | map_mem(pgdp); |
| 628 | 636 | ||
| 629 | /* | 637 | /* |
| 630 | * We want to reuse the original swapper_pg_dir so we don't have to | 638 | * We want to reuse the original swapper_pg_dir so we don't have to |
| @@ -635,7 +643,7 @@ void __init paging_init(void) | |||
| 635 | * To do this we need to go via a temporary pgd. | 643 | * To do this we need to go via a temporary pgd. |
| 636 | */ | 644 | */ |
| 637 | cpu_replace_ttbr1(__va(pgd_phys)); | 645 | cpu_replace_ttbr1(__va(pgd_phys)); |
| 638 | memcpy(swapper_pg_dir, pgd, PGD_SIZE); | 646 | memcpy(swapper_pg_dir, pgdp, PGD_SIZE); |
| 639 | cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); | 647 | cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); |
| 640 | 648 | ||
| 641 | pgd_clear_fixmap(); | 649 | pgd_clear_fixmap(); |
| @@ -655,37 +663,40 @@ void __init paging_init(void) | |||
| 655 | */ | 663 | */ |
| 656 | int kern_addr_valid(unsigned long addr) | 664 | int kern_addr_valid(unsigned long addr) |
| 657 | { | 665 | { |
| 658 | pgd_t *pgd; | 666 | pgd_t *pgdp; |
| 659 | pud_t *pud; | 667 | pud_t *pudp, pud; |
| 660 | pmd_t *pmd; | 668 | pmd_t *pmdp, pmd; |
| 661 | pte_t *pte; | 669 | pte_t *ptep, pte; |
| 662 | 670 | ||
| 663 | if ((((long)addr) >> VA_BITS) != -1UL) | 671 | if ((((long)addr) >> VA_BITS) != -1UL) |
| 664 | return 0; | 672 | return 0; |
| 665 | 673 | ||
| 666 | pgd = pgd_offset_k(addr); | 674 | pgdp = pgd_offset_k(addr); |
| 667 | if (pgd_none(*pgd)) | 675 | if (pgd_none(READ_ONCE(*pgdp))) |
| 668 | return 0; | 676 | return 0; |
| 669 | 677 | ||
| 670 | pud = pud_offset(pgd, addr); | 678 | pudp = pud_offset(pgdp, addr); |
| 671 | if (pud_none(*pud)) | 679 | pud = READ_ONCE(*pudp); |
| 680 | if (pud_none(pud)) | ||
| 672 | return 0; | 681 | return 0; |
| 673 | 682 | ||
| 674 | if (pud_sect(*pud)) | 683 | if (pud_sect(pud)) |
| 675 | return pfn_valid(pud_pfn(*pud)); | 684 | return pfn_valid(pud_pfn(pud)); |
| 676 | 685 | ||
| 677 | pmd = pmd_offset(pud, addr); | 686 | pmdp = pmd_offset(pudp, addr); |
| 678 | if (pmd_none(*pmd)) | 687 | pmd = READ_ONCE(*pmdp); |
| 688 | if (pmd_none(pmd)) | ||
| 679 | return 0; | 689 | return 0; |
| 680 | 690 | ||
| 681 | if (pmd_sect(*pmd)) | 691 | if (pmd_sect(pmd)) |
| 682 | return pfn_valid(pmd_pfn(*pmd)); | 692 | return pfn_valid(pmd_pfn(pmd)); |
| 683 | 693 | ||
| 684 | pte = pte_offset_kernel(pmd, addr); | 694 | ptep = pte_offset_kernel(pmdp, addr); |
| 685 | if (pte_none(*pte)) | 695 | pte = READ_ONCE(*ptep); |
| 696 | if (pte_none(pte)) | ||
| 686 | return 0; | 697 | return 0; |
| 687 | 698 | ||
| 688 | return pfn_valid(pte_pfn(*pte)); | 699 | return pfn_valid(pte_pfn(pte)); |
| 689 | } | 700 | } |
| 690 | #ifdef CONFIG_SPARSEMEM_VMEMMAP | 701 | #ifdef CONFIG_SPARSEMEM_VMEMMAP |
| 691 | #if !ARM64_SWAPPER_USES_SECTION_MAPS | 702 | #if !ARM64_SWAPPER_USES_SECTION_MAPS |
| @@ -700,32 +711,32 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, | |||
| 700 | { | 711 | { |
| 701 | unsigned long addr = start; | 712 | unsigned long addr = start; |
| 702 | unsigned long next; | 713 | unsigned long next; |
| 703 | pgd_t *pgd; | 714 | pgd_t *pgdp; |
| 704 | pud_t *pud; | 715 | pud_t *pudp; |
| 705 | pmd_t *pmd; | 716 | pmd_t *pmdp; |
| 706 | 717 | ||
| 707 | do { | 718 | do { |
| 708 | next = pmd_addr_end(addr, end); | 719 | next = pmd_addr_end(addr, end); |
| 709 | 720 | ||
| 710 | pgd = vmemmap_pgd_populate(addr, node); | 721 | pgdp = vmemmap_pgd_populate(addr, node); |
| 711 | if (!pgd) | 722 | if (!pgdp) |
| 712 | return -ENOMEM; | 723 | return -ENOMEM; |
| 713 | 724 | ||
| 714 | pud = vmemmap_pud_populate(pgd, addr, node); | 725 | pudp = vmemmap_pud_populate(pgdp, addr, node); |
| 715 | if (!pud) | 726 | if (!pudp) |
| 716 | return -ENOMEM; | 727 | return -ENOMEM; |
| 717 | 728 | ||
| 718 | pmd = pmd_offset(pud, addr); | 729 | pmdp = pmd_offset(pudp, addr); |
| 719 | if (pmd_none(*pmd)) { | 730 | if (pmd_none(READ_ONCE(*pmdp))) { |
| 720 | void *p = NULL; | 731 | void *p = NULL; |
| 721 | 732 | ||
| 722 | p = vmemmap_alloc_block_buf(PMD_SIZE, node); | 733 | p = vmemmap_alloc_block_buf(PMD_SIZE, node); |
| 723 | if (!p) | 734 | if (!p) |
| 724 | return -ENOMEM; | 735 | return -ENOMEM; |
| 725 | 736 | ||
| 726 | pmd_set_huge(pmd, __pa(p), __pgprot(PROT_SECT_NORMAL)); | 737 | pmd_set_huge(pmdp, __pa(p), __pgprot(PROT_SECT_NORMAL)); |
| 727 | } else | 738 | } else |
| 728 | vmemmap_verify((pte_t *)pmd, node, addr, next); | 739 | vmemmap_verify((pte_t *)pmdp, node, addr, next); |
| 729 | } while (addr = next, addr != end); | 740 | } while (addr = next, addr != end); |
| 730 | 741 | ||
| 731 | return 0; | 742 | return 0; |
| @@ -739,20 +750,22 @@ void vmemmap_free(unsigned long start, unsigned long end, | |||
| 739 | 750 | ||
| 740 | static inline pud_t * fixmap_pud(unsigned long addr) | 751 | static inline pud_t * fixmap_pud(unsigned long addr) |
| 741 | { | 752 | { |
| 742 | pgd_t *pgd = pgd_offset_k(addr); | 753 | pgd_t *pgdp = pgd_offset_k(addr); |
| 754 | pgd_t pgd = READ_ONCE(*pgdp); | ||
| 743 | 755 | ||
| 744 | BUG_ON(pgd_none(*pgd) || pgd_bad(*pgd)); | 756 | BUG_ON(pgd_none(pgd) || pgd_bad(pgd)); |
| 745 | 757 | ||
| 746 | return pud_offset_kimg(pgd, addr); | 758 | return pud_offset_kimg(pgdp, addr); |
| 747 | } | 759 | } |
| 748 | 760 | ||
| 749 | static inline pmd_t * fixmap_pmd(unsigned long addr) | 761 | static inline pmd_t * fixmap_pmd(unsigned long addr) |
| 750 | { | 762 | { |
| 751 | pud_t *pud = fixmap_pud(addr); | 763 | pud_t *pudp = fixmap_pud(addr); |
| 764 | pud_t pud = READ_ONCE(*pudp); | ||
| 752 | 765 | ||
| 753 | BUG_ON(pud_none(*pud) || pud_bad(*pud)); | 766 | BUG_ON(pud_none(pud) || pud_bad(pud)); |
| 754 | 767 | ||
| 755 | return pmd_offset_kimg(pud, addr); | 768 | return pmd_offset_kimg(pudp, addr); |
| 756 | } | 769 | } |
| 757 | 770 | ||
| 758 | static inline pte_t * fixmap_pte(unsigned long addr) | 771 | static inline pte_t * fixmap_pte(unsigned long addr) |
| @@ -768,30 +781,31 @@ static inline pte_t * fixmap_pte(unsigned long addr) | |||
| 768 | */ | 781 | */ |
| 769 | void __init early_fixmap_init(void) | 782 | void __init early_fixmap_init(void) |
| 770 | { | 783 | { |
| 771 | pgd_t *pgd; | 784 | pgd_t *pgdp, pgd; |
| 772 | pud_t *pud; | 785 | pud_t *pudp; |
| 773 | pmd_t *pmd; | 786 | pmd_t *pmdp; |
| 774 | unsigned long addr = FIXADDR_START; | 787 | unsigned long addr = FIXADDR_START; |
| 775 | 788 | ||
| 776 | pgd = pgd_offset_k(addr); | 789 | pgdp = pgd_offset_k(addr); |
| 790 | pgd = READ_ONCE(*pgdp); | ||
| 777 | if (CONFIG_PGTABLE_LEVELS > 3 && | 791 | if (CONFIG_PGTABLE_LEVELS > 3 && |
| 778 | !(pgd_none(*pgd) || pgd_page_paddr(*pgd) == __pa_symbol(bm_pud))) { | 792 | !(pgd_none(pgd) || pgd_page_paddr(pgd) == __pa_symbol(bm_pud))) { |
| 779 | /* | 793 | /* |
| 780 | * We only end up here if the kernel mapping and the fixmap | 794 | * We only end up here if the kernel mapping and the fixmap |
| 781 | * share the top level pgd entry, which should only happen on | 795 | * share the top level pgd entry, which should only happen on |
| 782 | * 16k/4 levels configurations. | 796 | * 16k/4 levels configurations. |
| 783 | */ | 797 | */ |
| 784 | BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); | 798 | BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); |
| 785 | pud = pud_offset_kimg(pgd, addr); | 799 | pudp = pud_offset_kimg(pgdp, addr); |
| 786 | } else { | 800 | } else { |
| 787 | if (pgd_none(*pgd)) | 801 | if (pgd_none(pgd)) |
| 788 | __pgd_populate(pgd, __pa_symbol(bm_pud), PUD_TYPE_TABLE); | 802 | __pgd_populate(pgdp, __pa_symbol(bm_pud), PUD_TYPE_TABLE); |
| 789 | pud = fixmap_pud(addr); | 803 | pudp = fixmap_pud(addr); |
| 790 | } | 804 | } |
| 791 | if (pud_none(*pud)) | 805 | if (pud_none(READ_ONCE(*pudp))) |
| 792 | __pud_populate(pud, __pa_symbol(bm_pmd), PMD_TYPE_TABLE); | 806 | __pud_populate(pudp, __pa_symbol(bm_pmd), PMD_TYPE_TABLE); |
| 793 | pmd = fixmap_pmd(addr); | 807 | pmdp = fixmap_pmd(addr); |
| 794 | __pmd_populate(pmd, __pa_symbol(bm_pte), PMD_TYPE_TABLE); | 808 | __pmd_populate(pmdp, __pa_symbol(bm_pte), PMD_TYPE_TABLE); |
| 795 | 809 | ||
| 796 | /* | 810 | /* |
| 797 | * The boot-ioremap range spans multiple pmds, for which | 811 | * The boot-ioremap range spans multiple pmds, for which |
| @@ -800,11 +814,11 @@ void __init early_fixmap_init(void) | |||
| 800 | BUILD_BUG_ON((__fix_to_virt(FIX_BTMAP_BEGIN) >> PMD_SHIFT) | 814 | BUILD_BUG_ON((__fix_to_virt(FIX_BTMAP_BEGIN) >> PMD_SHIFT) |
| 801 | != (__fix_to_virt(FIX_BTMAP_END) >> PMD_SHIFT)); | 815 | != (__fix_to_virt(FIX_BTMAP_END) >> PMD_SHIFT)); |
| 802 | 816 | ||
| 803 | if ((pmd != fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN))) | 817 | if ((pmdp != fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN))) |
| 804 | || pmd != fixmap_pmd(fix_to_virt(FIX_BTMAP_END))) { | 818 | || pmdp != fixmap_pmd(fix_to_virt(FIX_BTMAP_END))) { |
| 805 | WARN_ON(1); | 819 | WARN_ON(1); |
| 806 | pr_warn("pmd %p != %p, %p\n", | 820 | pr_warn("pmdp %p != %p, %p\n", |
| 807 | pmd, fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)), | 821 | pmdp, fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)), |
| 808 | fixmap_pmd(fix_to_virt(FIX_BTMAP_END))); | 822 | fixmap_pmd(fix_to_virt(FIX_BTMAP_END))); |
| 809 | pr_warn("fix_to_virt(FIX_BTMAP_BEGIN): %08lx\n", | 823 | pr_warn("fix_to_virt(FIX_BTMAP_BEGIN): %08lx\n", |
| 810 | fix_to_virt(FIX_BTMAP_BEGIN)); | 824 | fix_to_virt(FIX_BTMAP_BEGIN)); |
| @@ -824,16 +838,16 @@ void __set_fixmap(enum fixed_addresses idx, | |||
| 824 | phys_addr_t phys, pgprot_t flags) | 838 | phys_addr_t phys, pgprot_t flags) |
| 825 | { | 839 | { |
| 826 | unsigned long addr = __fix_to_virt(idx); | 840 | unsigned long addr = __fix_to_virt(idx); |
| 827 | pte_t *pte; | 841 | pte_t *ptep; |
| 828 | 842 | ||
| 829 | BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses); | 843 | BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses); |
| 830 | 844 | ||
| 831 | pte = fixmap_pte(addr); | 845 | ptep = fixmap_pte(addr); |
| 832 | 846 | ||
| 833 | if (pgprot_val(flags)) { | 847 | if (pgprot_val(flags)) { |
| 834 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); | 848 | set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags)); |
| 835 | } else { | 849 | } else { |
| 836 | pte_clear(&init_mm, addr, pte); | 850 | pte_clear(&init_mm, addr, ptep); |
| 837 | flush_tlb_kernel_range(addr, addr+PAGE_SIZE); | 851 | flush_tlb_kernel_range(addr, addr+PAGE_SIZE); |
| 838 | } | 852 | } |
| 839 | } | 853 | } |
| @@ -915,36 +929,36 @@ int __init arch_ioremap_pmd_supported(void) | |||
| 915 | return 1; | 929 | return 1; |
| 916 | } | 930 | } |
| 917 | 931 | ||
| 918 | int pud_set_huge(pud_t *pud, phys_addr_t phys, pgprot_t prot) | 932 | int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) |
| 919 | { | 933 | { |
| 920 | pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT | | 934 | pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT | |
| 921 | pgprot_val(mk_sect_prot(prot))); | 935 | pgprot_val(mk_sect_prot(prot))); |
| 922 | BUG_ON(phys & ~PUD_MASK); | 936 | BUG_ON(phys & ~PUD_MASK); |
| 923 | set_pud(pud, pfn_pud(__phys_to_pfn(phys), sect_prot)); | 937 | set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot)); |
| 924 | return 1; | 938 | return 1; |
| 925 | } | 939 | } |
| 926 | 940 | ||
| 927 | int pmd_set_huge(pmd_t *pmd, phys_addr_t phys, pgprot_t prot) | 941 | int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot) |
| 928 | { | 942 | { |
| 929 | pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT | | 943 | pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT | |
| 930 | pgprot_val(mk_sect_prot(prot))); | 944 | pgprot_val(mk_sect_prot(prot))); |
| 931 | BUG_ON(phys & ~PMD_MASK); | 945 | BUG_ON(phys & ~PMD_MASK); |
| 932 | set_pmd(pmd, pfn_pmd(__phys_to_pfn(phys), sect_prot)); | 946 | set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot)); |
| 933 | return 1; | 947 | return 1; |
| 934 | } | 948 | } |
| 935 | 949 | ||
| 936 | int pud_clear_huge(pud_t *pud) | 950 | int pud_clear_huge(pud_t *pudp) |
| 937 | { | 951 | { |
| 938 | if (!pud_sect(*pud)) | 952 | if (!pud_sect(READ_ONCE(*pudp))) |
| 939 | return 0; | 953 | return 0; |
| 940 | pud_clear(pud); | 954 | pud_clear(pudp); |
| 941 | return 1; | 955 | return 1; |
| 942 | } | 956 | } |
| 943 | 957 | ||
| 944 | int pmd_clear_huge(pmd_t *pmd) | 958 | int pmd_clear_huge(pmd_t *pmdp) |
| 945 | { | 959 | { |
| 946 | if (!pmd_sect(*pmd)) | 960 | if (!pmd_sect(READ_ONCE(*pmdp))) |
| 947 | return 0; | 961 | return 0; |
| 948 | pmd_clear(pmd); | 962 | pmd_clear(pmdp); |
| 949 | return 1; | 963 | return 1; |
| 950 | } | 964 | } |
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index a682a0a2a0fa..a56359373d8b 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c | |||
| @@ -29,7 +29,7 @@ static int change_page_range(pte_t *ptep, pgtable_t token, unsigned long addr, | |||
| 29 | void *data) | 29 | void *data) |
| 30 | { | 30 | { |
| 31 | struct page_change_data *cdata = data; | 31 | struct page_change_data *cdata = data; |
| 32 | pte_t pte = *ptep; | 32 | pte_t pte = READ_ONCE(*ptep); |
| 33 | 33 | ||
| 34 | pte = clear_pte_bit(pte, cdata->clear_mask); | 34 | pte = clear_pte_bit(pte, cdata->clear_mask); |
| 35 | pte = set_pte_bit(pte, cdata->set_mask); | 35 | pte = set_pte_bit(pte, cdata->set_mask); |
| @@ -156,30 +156,32 @@ void __kernel_map_pages(struct page *page, int numpages, int enable) | |||
| 156 | */ | 156 | */ |
| 157 | bool kernel_page_present(struct page *page) | 157 | bool kernel_page_present(struct page *page) |
| 158 | { | 158 | { |
| 159 | pgd_t *pgd; | 159 | pgd_t *pgdp; |
| 160 | pud_t *pud; | 160 | pud_t *pudp, pud; |
| 161 | pmd_t *pmd; | 161 | pmd_t *pmdp, pmd; |
| 162 | pte_t *pte; | 162 | pte_t *ptep; |
| 163 | unsigned long addr = (unsigned long)page_address(page); | 163 | unsigned long addr = (unsigned long)page_address(page); |
| 164 | 164 | ||
| 165 | pgd = pgd_offset_k(addr); | 165 | pgdp = pgd_offset_k(addr); |
| 166 | if (pgd_none(*pgd)) | 166 | if (pgd_none(READ_ONCE(*pgdp))) |
| 167 | return false; | 167 | return false; |
| 168 | 168 | ||
| 169 | pud = pud_offset(pgd, addr); | 169 | pudp = pud_offset(pgdp, addr); |
| 170 | if (pud_none(*pud)) | 170 | pud = READ_ONCE(*pudp); |
| 171 | if (pud_none(pud)) | ||
| 171 | return false; | 172 | return false; |
| 172 | if (pud_sect(*pud)) | 173 | if (pud_sect(pud)) |
| 173 | return true; | 174 | return true; |
| 174 | 175 | ||
| 175 | pmd = pmd_offset(pud, addr); | 176 | pmdp = pmd_offset(pudp, addr); |
| 176 | if (pmd_none(*pmd)) | 177 | pmd = READ_ONCE(*pmdp); |
| 178 | if (pmd_none(pmd)) | ||
| 177 | return false; | 179 | return false; |
| 178 | if (pmd_sect(*pmd)) | 180 | if (pmd_sect(pmd)) |
| 179 | return true; | 181 | return true; |
| 180 | 182 | ||
| 181 | pte = pte_offset_kernel(pmd, addr); | 183 | ptep = pte_offset_kernel(pmdp, addr); |
| 182 | return pte_valid(*pte); | 184 | return pte_valid(READ_ONCE(*ptep)); |
| 183 | } | 185 | } |
| 184 | #endif /* CONFIG_HIBERNATION */ | 186 | #endif /* CONFIG_HIBERNATION */ |
| 185 | #endif /* CONFIG_DEBUG_PAGEALLOC */ | 187 | #endif /* CONFIG_DEBUG_PAGEALLOC */ |
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 71baed7e592a..c0af47617299 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S | |||
| @@ -205,7 +205,8 @@ ENDPROC(idmap_cpu_replace_ttbr1) | |||
| 205 | dc cvac, cur_\()\type\()p // Ensure any existing dirty | 205 | dc cvac, cur_\()\type\()p // Ensure any existing dirty |
| 206 | dmb sy // lines are written back before | 206 | dmb sy // lines are written back before |
| 207 | ldr \type, [cur_\()\type\()p] // loading the entry | 207 | ldr \type, [cur_\()\type\()p] // loading the entry |
| 208 | tbz \type, #0, next_\()\type // Skip invalid entries | 208 | tbz \type, #0, skip_\()\type // Skip invalid and |
| 209 | tbnz \type, #11, skip_\()\type // non-global entries | ||
| 209 | .endm | 210 | .endm |
| 210 | 211 | ||
| 211 | .macro __idmap_kpti_put_pgtable_ent_ng, type | 212 | .macro __idmap_kpti_put_pgtable_ent_ng, type |
| @@ -265,8 +266,9 @@ ENTRY(idmap_kpti_install_ng_mappings) | |||
| 265 | add end_pgdp, cur_pgdp, #(PTRS_PER_PGD * 8) | 266 | add end_pgdp, cur_pgdp, #(PTRS_PER_PGD * 8) |
| 266 | do_pgd: __idmap_kpti_get_pgtable_ent pgd | 267 | do_pgd: __idmap_kpti_get_pgtable_ent pgd |
| 267 | tbnz pgd, #1, walk_puds | 268 | tbnz pgd, #1, walk_puds |
| 268 | __idmap_kpti_put_pgtable_ent_ng pgd | ||
| 269 | next_pgd: | 269 | next_pgd: |
| 270 | __idmap_kpti_put_pgtable_ent_ng pgd | ||
| 271 | skip_pgd: | ||
| 270 | add cur_pgdp, cur_pgdp, #8 | 272 | add cur_pgdp, cur_pgdp, #8 |
| 271 | cmp cur_pgdp, end_pgdp | 273 | cmp cur_pgdp, end_pgdp |
| 272 | b.ne do_pgd | 274 | b.ne do_pgd |
| @@ -294,8 +296,9 @@ walk_puds: | |||
| 294 | add end_pudp, cur_pudp, #(PTRS_PER_PUD * 8) | 296 | add end_pudp, cur_pudp, #(PTRS_PER_PUD * 8) |
| 295 | do_pud: __idmap_kpti_get_pgtable_ent pud | 297 | do_pud: __idmap_kpti_get_pgtable_ent pud |
| 296 | tbnz pud, #1, walk_pmds | 298 | tbnz pud, #1, walk_pmds |
| 297 | __idmap_kpti_put_pgtable_ent_ng pud | ||
| 298 | next_pud: | 299 | next_pud: |
| 300 | __idmap_kpti_put_pgtable_ent_ng pud | ||
| 301 | skip_pud: | ||
| 299 | add cur_pudp, cur_pudp, 8 | 302 | add cur_pudp, cur_pudp, 8 |
| 300 | cmp cur_pudp, end_pudp | 303 | cmp cur_pudp, end_pudp |
| 301 | b.ne do_pud | 304 | b.ne do_pud |
| @@ -314,8 +317,9 @@ walk_pmds: | |||
| 314 | add end_pmdp, cur_pmdp, #(PTRS_PER_PMD * 8) | 317 | add end_pmdp, cur_pmdp, #(PTRS_PER_PMD * 8) |
| 315 | do_pmd: __idmap_kpti_get_pgtable_ent pmd | 318 | do_pmd: __idmap_kpti_get_pgtable_ent pmd |
| 316 | tbnz pmd, #1, walk_ptes | 319 | tbnz pmd, #1, walk_ptes |
| 317 | __idmap_kpti_put_pgtable_ent_ng pmd | ||
| 318 | next_pmd: | 320 | next_pmd: |
| 321 | __idmap_kpti_put_pgtable_ent_ng pmd | ||
| 322 | skip_pmd: | ||
| 319 | add cur_pmdp, cur_pmdp, #8 | 323 | add cur_pmdp, cur_pmdp, #8 |
| 320 | cmp cur_pmdp, end_pmdp | 324 | cmp cur_pmdp, end_pmdp |
| 321 | b.ne do_pmd | 325 | b.ne do_pmd |
| @@ -333,7 +337,7 @@ walk_ptes: | |||
| 333 | add end_ptep, cur_ptep, #(PTRS_PER_PTE * 8) | 337 | add end_ptep, cur_ptep, #(PTRS_PER_PTE * 8) |
| 334 | do_pte: __idmap_kpti_get_pgtable_ent pte | 338 | do_pte: __idmap_kpti_get_pgtable_ent pte |
| 335 | __idmap_kpti_put_pgtable_ent_ng pte | 339 | __idmap_kpti_put_pgtable_ent_ng pte |
| 336 | next_pte: | 340 | skip_pte: |
| 337 | add cur_ptep, cur_ptep, #8 | 341 | add cur_ptep, cur_ptep, #8 |
| 338 | cmp cur_ptep, end_ptep | 342 | cmp cur_ptep, end_ptep |
| 339 | b.ne do_pte | 343 | b.ne do_pte |
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index 0b4c65a1af25..498f3da3f225 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile | |||
| @@ -41,7 +41,6 @@ ifneq ($(CONFIG_IA64_ESI),) | |||
| 41 | obj-y += esi_stub.o # must be in kernel proper | 41 | obj-y += esi_stub.o # must be in kernel proper |
| 42 | endif | 42 | endif |
| 43 | obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o | 43 | obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o |
| 44 | obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o | ||
| 45 | 44 | ||
| 46 | obj-$(CONFIG_BINFMT_ELF) += elfcore.o | 45 | obj-$(CONFIG_BINFMT_ELF) += elfcore.o |
| 47 | 46 | ||
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c index 19c88d770054..fcf9af492d60 100644 --- a/arch/mips/kernel/mips-cpc.c +++ b/arch/mips/kernel/mips-cpc.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
| 12 | #include <linux/percpu.h> | 12 | #include <linux/percpu.h> |
| 13 | #include <linux/of.h> | ||
| 14 | #include <linux/of_address.h> | ||
| 13 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 14 | 16 | ||
| 15 | #include <asm/mips-cps.h> | 17 | #include <asm/mips-cps.h> |
| @@ -22,6 +24,17 @@ static DEFINE_PER_CPU_ALIGNED(unsigned long, cpc_core_lock_flags); | |||
| 22 | 24 | ||
| 23 | phys_addr_t __weak mips_cpc_default_phys_base(void) | 25 | phys_addr_t __weak mips_cpc_default_phys_base(void) |
| 24 | { | 26 | { |
| 27 | struct device_node *cpc_node; | ||
| 28 | struct resource res; | ||
| 29 | int err; | ||
| 30 | |||
| 31 | cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc"); | ||
| 32 | if (cpc_node) { | ||
| 33 | err = of_address_to_resource(cpc_node, 0, &res); | ||
| 34 | if (!err) | ||
| 35 | return res.start; | ||
| 36 | } | ||
| 37 | |||
| 25 | return 0; | 38 | return 0; |
| 26 | } | 39 | } |
| 27 | 40 | ||
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 85bc601e9a0d..5f8b0a9e30b3 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c | |||
| @@ -375,6 +375,7 @@ static void __init bootmem_init(void) | |||
| 375 | unsigned long reserved_end; | 375 | unsigned long reserved_end; |
| 376 | unsigned long mapstart = ~0UL; | 376 | unsigned long mapstart = ~0UL; |
| 377 | unsigned long bootmap_size; | 377 | unsigned long bootmap_size; |
| 378 | phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX; | ||
| 378 | bool bootmap_valid = false; | 379 | bool bootmap_valid = false; |
| 379 | int i; | 380 | int i; |
| 380 | 381 | ||
| @@ -395,7 +396,8 @@ static void __init bootmem_init(void) | |||
| 395 | max_low_pfn = 0; | 396 | max_low_pfn = 0; |
| 396 | 397 | ||
| 397 | /* | 398 | /* |
| 398 | * Find the highest page frame number we have available. | 399 | * Find the highest page frame number we have available |
| 400 | * and the lowest used RAM address | ||
| 399 | */ | 401 | */ |
| 400 | for (i = 0; i < boot_mem_map.nr_map; i++) { | 402 | for (i = 0; i < boot_mem_map.nr_map; i++) { |
| 401 | unsigned long start, end; | 403 | unsigned long start, end; |
| @@ -407,6 +409,8 @@ static void __init bootmem_init(void) | |||
| 407 | end = PFN_DOWN(boot_mem_map.map[i].addr | 409 | end = PFN_DOWN(boot_mem_map.map[i].addr |
| 408 | + boot_mem_map.map[i].size); | 410 | + boot_mem_map.map[i].size); |
| 409 | 411 | ||
| 412 | ramstart = min(ramstart, boot_mem_map.map[i].addr); | ||
| 413 | |||
| 410 | #ifndef CONFIG_HIGHMEM | 414 | #ifndef CONFIG_HIGHMEM |
| 411 | /* | 415 | /* |
| 412 | * Skip highmem here so we get an accurate max_low_pfn if low | 416 | * Skip highmem here so we get an accurate max_low_pfn if low |
| @@ -436,6 +440,13 @@ static void __init bootmem_init(void) | |||
| 436 | mapstart = max(reserved_end, start); | 440 | mapstart = max(reserved_end, start); |
| 437 | } | 441 | } |
| 438 | 442 | ||
| 443 | /* | ||
| 444 | * Reserve any memory between the start of RAM and PHYS_OFFSET | ||
| 445 | */ | ||
| 446 | if (ramstart > PHYS_OFFSET) | ||
| 447 | add_memory_region(PHYS_OFFSET, ramstart - PHYS_OFFSET, | ||
| 448 | BOOT_MEM_RESERVED); | ||
| 449 | |||
| 439 | if (min_low_pfn >= max_low_pfn) | 450 | if (min_low_pfn >= max_low_pfn) |
| 440 | panic("Incorrect memory mapping !!!"); | 451 | panic("Incorrect memory mapping !!!"); |
| 441 | if (min_low_pfn > ARCH_PFN_OFFSET) { | 452 | if (min_low_pfn > ARCH_PFN_OFFSET) { |
| @@ -664,9 +675,6 @@ static int __init early_parse_mem(char *p) | |||
| 664 | 675 | ||
| 665 | add_memory_region(start, size, BOOT_MEM_RAM); | 676 | add_memory_region(start, size, BOOT_MEM_RAM); |
| 666 | 677 | ||
| 667 | if (start && start > PHYS_OFFSET) | ||
| 668 | add_memory_region(PHYS_OFFSET, start - PHYS_OFFSET, | ||
| 669 | BOOT_MEM_RESERVED); | ||
| 670 | return 0; | 678 | return 0; |
| 671 | } | 679 | } |
| 672 | early_param("mem", early_parse_mem); | 680 | early_param("mem", early_parse_mem); |
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 87dcac2447c8..9d41732a9146 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c | |||
| @@ -572,7 +572,7 @@ asmlinkage void __weak plat_wired_tlb_setup(void) | |||
| 572 | */ | 572 | */ |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | void __init bmips_cpu_setup(void) | 575 | void bmips_cpu_setup(void) |
| 576 | { | 576 | { |
| 577 | void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); | 577 | void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); |
| 578 | u32 __maybe_unused cfg; | 578 | u32 __maybe_unused cfg; |
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 30a155c0a6b0..c615abdce119 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) | 16 | #define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) |
| 17 | 17 | ||
| 18 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE | 18 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE |
| 19 | #define PUD_CACHE_INDEX PUD_INDEX_SIZE | ||
| 19 | 20 | ||
| 20 | #ifndef __ASSEMBLY__ | 21 | #ifndef __ASSEMBLY__ |
| 21 | #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) | 22 | #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) |
diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h index 949d691094a4..67c5475311ee 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h | |||
| @@ -63,7 +63,8 @@ static inline int hash__hugepd_ok(hugepd_t hpd) | |||
| 63 | * keeping the prototype consistent across the two formats. | 63 | * keeping the prototype consistent across the two formats. |
| 64 | */ | 64 | */ |
| 65 | static inline unsigned long pte_set_hidx(pte_t *ptep, real_pte_t rpte, | 65 | static inline unsigned long pte_set_hidx(pte_t *ptep, real_pte_t rpte, |
| 66 | unsigned int subpg_index, unsigned long hidx) | 66 | unsigned int subpg_index, unsigned long hidx, |
| 67 | int offset) | ||
| 67 | { | 68 | { |
| 68 | return (hidx << H_PAGE_F_GIX_SHIFT) & | 69 | return (hidx << H_PAGE_F_GIX_SHIFT) & |
| 69 | (H_PAGE_F_SECOND | H_PAGE_F_GIX); | 70 | (H_PAGE_F_SECOND | H_PAGE_F_GIX); |
diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h index 338b7da468ce..3bcf269f8f55 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | * generic accessors and iterators here | 45 | * generic accessors and iterators here |
| 46 | */ | 46 | */ |
| 47 | #define __real_pte __real_pte | 47 | #define __real_pte __real_pte |
| 48 | static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep) | 48 | static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep, int offset) |
| 49 | { | 49 | { |
| 50 | real_pte_t rpte; | 50 | real_pte_t rpte; |
| 51 | unsigned long *hidxp; | 51 | unsigned long *hidxp; |
| @@ -59,7 +59,7 @@ static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep) | |||
| 59 | */ | 59 | */ |
| 60 | smp_rmb(); | 60 | smp_rmb(); |
| 61 | 61 | ||
| 62 | hidxp = (unsigned long *)(ptep + PTRS_PER_PTE); | 62 | hidxp = (unsigned long *)(ptep + offset); |
| 63 | rpte.hidx = *hidxp; | 63 | rpte.hidx = *hidxp; |
| 64 | return rpte; | 64 | return rpte; |
| 65 | } | 65 | } |
| @@ -86,9 +86,10 @@ static inline unsigned long __rpte_to_hidx(real_pte_t rpte, unsigned long index) | |||
| 86 | * expected to modify the PTE bits accordingly and commit the PTE to memory. | 86 | * expected to modify the PTE bits accordingly and commit the PTE to memory. |
| 87 | */ | 87 | */ |
| 88 | static inline unsigned long pte_set_hidx(pte_t *ptep, real_pte_t rpte, | 88 | static inline unsigned long pte_set_hidx(pte_t *ptep, real_pte_t rpte, |
| 89 | unsigned int subpg_index, unsigned long hidx) | 89 | unsigned int subpg_index, |
| 90 | unsigned long hidx, int offset) | ||
| 90 | { | 91 | { |
| 91 | unsigned long *hidxp = (unsigned long *)(ptep + PTRS_PER_PTE); | 92 | unsigned long *hidxp = (unsigned long *)(ptep + offset); |
| 92 | 93 | ||
| 93 | rpte.hidx &= ~HIDX_BITS(0xfUL, subpg_index); | 94 | rpte.hidx &= ~HIDX_BITS(0xfUL, subpg_index); |
| 94 | *hidxp = rpte.hidx | HIDX_BITS(HIDX_SHIFT_BY_ONE(hidx), subpg_index); | 95 | *hidxp = rpte.hidx | HIDX_BITS(HIDX_SHIFT_BY_ONE(hidx), subpg_index); |
| @@ -140,13 +141,18 @@ static inline int hash__remap_4k_pfn(struct vm_area_struct *vma, unsigned long a | |||
| 140 | } | 141 | } |
| 141 | 142 | ||
| 142 | #define H_PTE_TABLE_SIZE PTE_FRAG_SIZE | 143 | #define H_PTE_TABLE_SIZE PTE_FRAG_SIZE |
| 143 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 144 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined (CONFIG_HUGETLB_PAGE) |
| 144 | #define H_PMD_TABLE_SIZE ((sizeof(pmd_t) << PMD_INDEX_SIZE) + \ | 145 | #define H_PMD_TABLE_SIZE ((sizeof(pmd_t) << PMD_INDEX_SIZE) + \ |
| 145 | (sizeof(unsigned long) << PMD_INDEX_SIZE)) | 146 | (sizeof(unsigned long) << PMD_INDEX_SIZE)) |
| 146 | #else | 147 | #else |
| 147 | #define H_PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE) | 148 | #define H_PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE) |
| 148 | #endif | 149 | #endif |
| 150 | #ifdef CONFIG_HUGETLB_PAGE | ||
| 151 | #define H_PUD_TABLE_SIZE ((sizeof(pud_t) << PUD_INDEX_SIZE) + \ | ||
| 152 | (sizeof(unsigned long) << PUD_INDEX_SIZE)) | ||
| 153 | #else | ||
| 149 | #define H_PUD_TABLE_SIZE (sizeof(pud_t) << PUD_INDEX_SIZE) | 154 | #define H_PUD_TABLE_SIZE (sizeof(pud_t) << PUD_INDEX_SIZE) |
| 155 | #endif | ||
| 150 | #define H_PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) | 156 | #define H_PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) |
| 151 | 157 | ||
| 152 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 158 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h index 0920eff731b3..935adcd92a81 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h | |||
| @@ -23,7 +23,8 @@ | |||
| 23 | H_PUD_INDEX_SIZE + H_PGD_INDEX_SIZE + PAGE_SHIFT) | 23 | H_PUD_INDEX_SIZE + H_PGD_INDEX_SIZE + PAGE_SHIFT) |
| 24 | #define H_PGTABLE_RANGE (ASM_CONST(1) << H_PGTABLE_EADDR_SIZE) | 24 | #define H_PGTABLE_RANGE (ASM_CONST(1) << H_PGTABLE_EADDR_SIZE) |
| 25 | 25 | ||
| 26 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_PPC_64K_PAGES) | 26 | #if (defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLB_PAGE)) && \ |
| 27 | defined(CONFIG_PPC_64K_PAGES) | ||
| 27 | /* | 28 | /* |
| 28 | * only with hash 64k we need to use the second half of pmd page table | 29 | * only with hash 64k we need to use the second half of pmd page table |
| 29 | * to store pointer to deposited pgtable_t | 30 | * to store pointer to deposited pgtable_t |
| @@ -33,6 +34,16 @@ | |||
| 33 | #define H_PMD_CACHE_INDEX H_PMD_INDEX_SIZE | 34 | #define H_PMD_CACHE_INDEX H_PMD_INDEX_SIZE |
| 34 | #endif | 35 | #endif |
| 35 | /* | 36 | /* |
| 37 | * We store the slot details in the second half of page table. | ||
| 38 | * Increase the pud level table so that hugetlb ptes can be stored | ||
| 39 | * at pud level. | ||
| 40 | */ | ||
| 41 | #if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_PPC_64K_PAGES) | ||
| 42 | #define H_PUD_CACHE_INDEX (H_PUD_INDEX_SIZE + 1) | ||
| 43 | #else | ||
| 44 | #define H_PUD_CACHE_INDEX (H_PUD_INDEX_SIZE) | ||
| 45 | #endif | ||
| 46 | /* | ||
| 36 | * Define the address range of the kernel non-linear virtual area | 47 | * Define the address range of the kernel non-linear virtual area |
| 37 | */ | 48 | */ |
| 38 | #define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) | 49 | #define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) |
diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h index 1fcfa425cefa..4746bc68d446 100644 --- a/arch/powerpc/include/asm/book3s/64/pgalloc.h +++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h | |||
| @@ -73,10 +73,16 @@ static inline void radix__pgd_free(struct mm_struct *mm, pgd_t *pgd) | |||
| 73 | 73 | ||
| 74 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | 74 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 75 | { | 75 | { |
| 76 | pgd_t *pgd; | ||
| 77 | |||
| 76 | if (radix_enabled()) | 78 | if (radix_enabled()) |
| 77 | return radix__pgd_alloc(mm); | 79 | return radix__pgd_alloc(mm); |
| 78 | return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE), | 80 | |
| 79 | pgtable_gfp_flags(mm, GFP_KERNEL)); | 81 | pgd = kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE), |
| 82 | pgtable_gfp_flags(mm, GFP_KERNEL)); | ||
| 83 | memset(pgd, 0, PGD_TABLE_SIZE); | ||
| 84 | |||
| 85 | return pgd; | ||
| 80 | } | 86 | } |
| 81 | 87 | ||
| 82 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) | 88 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
| @@ -93,13 +99,13 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud) | |||
| 93 | 99 | ||
| 94 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) | 100 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) |
| 95 | { | 101 | { |
| 96 | return kmem_cache_alloc(PGT_CACHE(PUD_INDEX_SIZE), | 102 | return kmem_cache_alloc(PGT_CACHE(PUD_CACHE_INDEX), |
| 97 | pgtable_gfp_flags(mm, GFP_KERNEL)); | 103 | pgtable_gfp_flags(mm, GFP_KERNEL)); |
| 98 | } | 104 | } |
| 99 | 105 | ||
| 100 | static inline void pud_free(struct mm_struct *mm, pud_t *pud) | 106 | static inline void pud_free(struct mm_struct *mm, pud_t *pud) |
| 101 | { | 107 | { |
| 102 | kmem_cache_free(PGT_CACHE(PUD_INDEX_SIZE), pud); | 108 | kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), pud); |
| 103 | } | 109 | } |
| 104 | 110 | ||
| 105 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) | 111 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) |
| @@ -115,7 +121,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, | |||
| 115 | * ahead and flush the page walk cache | 121 | * ahead and flush the page walk cache |
| 116 | */ | 122 | */ |
| 117 | flush_tlb_pgtable(tlb, address); | 123 | flush_tlb_pgtable(tlb, address); |
| 118 | pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE); | 124 | pgtable_free_tlb(tlb, pud, PUD_CACHE_INDEX); |
| 119 | } | 125 | } |
| 120 | 126 | ||
| 121 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) | 127 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 51017726d495..a6b9f1d74600 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h | |||
| @@ -232,11 +232,13 @@ extern unsigned long __pmd_index_size; | |||
| 232 | extern unsigned long __pud_index_size; | 232 | extern unsigned long __pud_index_size; |
| 233 | extern unsigned long __pgd_index_size; | 233 | extern unsigned long __pgd_index_size; |
| 234 | extern unsigned long __pmd_cache_index; | 234 | extern unsigned long __pmd_cache_index; |
| 235 | extern unsigned long __pud_cache_index; | ||
| 235 | #define PTE_INDEX_SIZE __pte_index_size | 236 | #define PTE_INDEX_SIZE __pte_index_size |
| 236 | #define PMD_INDEX_SIZE __pmd_index_size | 237 | #define PMD_INDEX_SIZE __pmd_index_size |
| 237 | #define PUD_INDEX_SIZE __pud_index_size | 238 | #define PUD_INDEX_SIZE __pud_index_size |
| 238 | #define PGD_INDEX_SIZE __pgd_index_size | 239 | #define PGD_INDEX_SIZE __pgd_index_size |
| 239 | #define PMD_CACHE_INDEX __pmd_cache_index | 240 | #define PMD_CACHE_INDEX __pmd_cache_index |
| 241 | #define PUD_CACHE_INDEX __pud_cache_index | ||
| 240 | /* | 242 | /* |
| 241 | * Because of use of pte fragments and THP, size of page table | 243 | * Because of use of pte fragments and THP, size of page table |
| 242 | * are not always derived out of index size above. | 244 | * are not always derived out of index size above. |
| @@ -348,7 +350,7 @@ extern unsigned long pci_io_base; | |||
| 348 | */ | 350 | */ |
| 349 | #ifndef __real_pte | 351 | #ifndef __real_pte |
| 350 | 352 | ||
| 351 | #define __real_pte(e,p) ((real_pte_t){(e)}) | 353 | #define __real_pte(e, p, o) ((real_pte_t){(e)}) |
| 352 | #define __rpte_to_pte(r) ((r).pte) | 354 | #define __rpte_to_pte(r) ((r).pte) |
| 353 | #define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> H_PAGE_F_GIX_SHIFT) | 355 | #define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> H_PAGE_F_GIX_SHIFT) |
| 354 | 356 | ||
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h index 176dfb73d42c..471b2274fbeb 100644 --- a/arch/powerpc/include/asm/exception-64s.h +++ b/arch/powerpc/include/asm/exception-64s.h | |||
| @@ -645,7 +645,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943) | |||
| 645 | EXC_HV, SOFTEN_TEST_HV, bitmask) | 645 | EXC_HV, SOFTEN_TEST_HV, bitmask) |
| 646 | 646 | ||
| 647 | #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label, bitmask) \ | 647 | #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label, bitmask) \ |
| 648 | MASKABLE_EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_NOTEST_HV, vec, bitmask);\ | 648 | MASKABLE_EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec, bitmask);\ |
| 649 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) | 649 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) |
| 650 | 650 | ||
| 651 | /* | 651 | /* |
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index 88e5e8f17e98..855e17d158b1 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h | |||
| @@ -30,6 +30,16 @@ | |||
| 30 | #define PACA_IRQ_PMI 0x40 | 30 | #define PACA_IRQ_PMI 0x40 |
| 31 | 31 | ||
| 32 | /* | 32 | /* |
| 33 | * Some soft-masked interrupts must be hard masked until they are replayed | ||
| 34 | * (e.g., because the soft-masked handler does not clear the exception). | ||
| 35 | */ | ||
| 36 | #ifdef CONFIG_PPC_BOOK3S | ||
| 37 | #define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE|PACA_IRQ_PMI) | ||
| 38 | #else | ||
| 39 | #define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE) | ||
| 40 | #endif | ||
| 41 | |||
| 42 | /* | ||
| 33 | * flags for paca->irq_soft_mask | 43 | * flags for paca->irq_soft_mask |
| 34 | */ | 44 | */ |
| 35 | #define IRQS_ENABLED 0 | 45 | #define IRQS_ENABLED 0 |
| @@ -244,7 +254,7 @@ static inline bool lazy_irq_pending(void) | |||
| 244 | static inline void may_hard_irq_enable(void) | 254 | static inline void may_hard_irq_enable(void) |
| 245 | { | 255 | { |
| 246 | get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS; | 256 | get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS; |
| 247 | if (!(get_paca()->irq_happened & PACA_IRQ_EE)) | 257 | if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK)) |
| 248 | __hard_irq_enable(); | 258 | __hard_irq_enable(); |
| 249 | } | 259 | } |
| 250 | 260 | ||
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h index 9dcbfa6bbb91..d8b1e8e7e035 100644 --- a/arch/powerpc/include/asm/kexec.h +++ b/arch/powerpc/include/asm/kexec.h | |||
| @@ -140,6 +140,12 @@ static inline bool kdump_in_progress(void) | |||
| 140 | return false; | 140 | return false; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | static inline void crash_ipi_callback(struct pt_regs *regs) { } | ||
| 144 | |||
| 145 | static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)) | ||
| 146 | { | ||
| 147 | } | ||
| 148 | |||
| 143 | #endif /* CONFIG_KEXEC_CORE */ | 149 | #endif /* CONFIG_KEXEC_CORE */ |
| 144 | #endif /* ! __ASSEMBLY__ */ | 150 | #endif /* ! __ASSEMBLY__ */ |
| 145 | #endif /* __KERNEL__ */ | 151 | #endif /* __KERNEL__ */ |
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h index 504a3c36ce5c..03bbd1149530 100644 --- a/arch/powerpc/include/asm/nohash/32/pgtable.h +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h | |||
| @@ -24,6 +24,7 @@ extern int icache_44x_need_flush; | |||
| 24 | #define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) | 24 | #define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) |
| 25 | 25 | ||
| 26 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE | 26 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE |
| 27 | #define PUD_CACHE_INDEX PUD_INDEX_SIZE | ||
| 27 | 28 | ||
| 28 | #ifndef __ASSEMBLY__ | 29 | #ifndef __ASSEMBLY__ |
| 29 | #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) | 30 | #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) |
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h index abddf5830ad5..5c5f75d005ad 100644 --- a/arch/powerpc/include/asm/nohash/64/pgtable.h +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #else | 27 | #else |
| 28 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE | 28 | #define PMD_CACHE_INDEX PMD_INDEX_SIZE |
| 29 | #endif | 29 | #endif |
| 30 | #define PUD_CACHE_INDEX PUD_INDEX_SIZE | ||
| 30 | 31 | ||
| 31 | /* | 32 | /* |
| 32 | * Define the address range of the kernel non-linear virtual area | 33 | * Define the address range of the kernel non-linear virtual area |
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 88187c285c70..9f421641a35c 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h | |||
| @@ -44,6 +44,11 @@ extern int sysfs_add_device_to_node(struct device *dev, int nid); | |||
| 44 | extern void sysfs_remove_device_from_node(struct device *dev, int nid); | 44 | extern void sysfs_remove_device_from_node(struct device *dev, int nid); |
| 45 | extern int numa_update_cpu_topology(bool cpus_locked); | 45 | extern int numa_update_cpu_topology(bool cpus_locked); |
| 46 | 46 | ||
| 47 | static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) | ||
| 48 | { | ||
| 49 | numa_cpu_lookup_table[cpu] = node; | ||
| 50 | } | ||
| 51 | |||
| 47 | static inline int early_cpu_to_node(int cpu) | 52 | static inline int early_cpu_to_node(int cpu) |
| 48 | { | 53 | { |
| 49 | int nid; | 54 | int nid; |
| @@ -76,12 +81,16 @@ static inline int numa_update_cpu_topology(bool cpus_locked) | |||
| 76 | { | 81 | { |
| 77 | return 0; | 82 | return 0; |
| 78 | } | 83 | } |
| 84 | |||
| 85 | static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {} | ||
| 86 | |||
| 79 | #endif /* CONFIG_NUMA */ | 87 | #endif /* CONFIG_NUMA */ |
| 80 | 88 | ||
| 81 | #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR) | 89 | #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR) |
| 82 | extern int start_topology_update(void); | 90 | extern int start_topology_update(void); |
| 83 | extern int stop_topology_update(void); | 91 | extern int stop_topology_update(void); |
| 84 | extern int prrn_is_enabled(void); | 92 | extern int prrn_is_enabled(void); |
| 93 | extern int find_and_online_cpu_nid(int cpu); | ||
| 85 | #else | 94 | #else |
| 86 | static inline int start_topology_update(void) | 95 | static inline int start_topology_update(void) |
| 87 | { | 96 | { |
| @@ -95,6 +104,10 @@ static inline int prrn_is_enabled(void) | |||
| 95 | { | 104 | { |
| 96 | return 0; | 105 | return 0; |
| 97 | } | 106 | } |
| 107 | static inline int find_and_online_cpu_nid(int cpu) | ||
| 108 | { | ||
| 109 | return 0; | ||
| 110 | } | ||
| 98 | #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ | 111 | #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ |
| 99 | 112 | ||
| 100 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES) | 113 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES) |
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S index ee832d344a5a..9b6e653e501a 100644 --- a/arch/powerpc/kernel/exceptions-64e.S +++ b/arch/powerpc/kernel/exceptions-64e.S | |||
| @@ -943,6 +943,8 @@ kernel_dbg_exc: | |||
| 943 | /* | 943 | /* |
| 944 | * An interrupt came in while soft-disabled; We mark paca->irq_happened | 944 | * An interrupt came in while soft-disabled; We mark paca->irq_happened |
| 945 | * accordingly and if the interrupt is level sensitive, we hard disable | 945 | * accordingly and if the interrupt is level sensitive, we hard disable |
| 946 | * hard disable (full_mask) corresponds to PACA_IRQ_MUST_HARD_MASK, so | ||
| 947 | * keep these in synch. | ||
| 946 | */ | 948 | */ |
| 947 | 949 | ||
| 948 | .macro masked_interrupt_book3e paca_irq full_mask | 950 | .macro masked_interrupt_book3e paca_irq full_mask |
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 243d072a225a..3ac87e53b3da 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
| @@ -1426,7 +1426,7 @@ EXC_COMMON_BEGIN(soft_nmi_common) | |||
| 1426 | * triggered and won't automatically refire. | 1426 | * triggered and won't automatically refire. |
| 1427 | * - If it was a HMI we return immediately since we handled it in realmode | 1427 | * - If it was a HMI we return immediately since we handled it in realmode |
| 1428 | * and it won't refire. | 1428 | * and it won't refire. |
| 1429 | * - else we hard disable and return. | 1429 | * - Else it is one of PACA_IRQ_MUST_HARD_MASK, so hard disable and return. |
| 1430 | * This is called with r10 containing the value to OR to the paca field. | 1430 | * This is called with r10 containing the value to OR to the paca field. |
| 1431 | */ | 1431 | */ |
| 1432 | #define MASKED_INTERRUPT(_H) \ | 1432 | #define MASKED_INTERRUPT(_H) \ |
| @@ -1441,8 +1441,8 @@ masked_##_H##interrupt: \ | |||
| 1441 | ori r10,r10,0xffff; \ | 1441 | ori r10,r10,0xffff; \ |
| 1442 | mtspr SPRN_DEC,r10; \ | 1442 | mtspr SPRN_DEC,r10; \ |
| 1443 | b MASKED_DEC_HANDLER_LABEL; \ | 1443 | b MASKED_DEC_HANDLER_LABEL; \ |
| 1444 | 1: andi. r10,r10,(PACA_IRQ_DBELL|PACA_IRQ_HMI); \ | 1444 | 1: andi. r10,r10,PACA_IRQ_MUST_HARD_MASK; \ |
| 1445 | bne 2f; \ | 1445 | beq 2f; \ |
| 1446 | mfspr r10,SPRN_##_H##SRR1; \ | 1446 | mfspr r10,SPRN_##_H##SRR1; \ |
| 1447 | xori r10,r10,MSR_EE; /* clear MSR_EE */ \ | 1447 | xori r10,r10,MSR_EE; /* clear MSR_EE */ \ |
| 1448 | mtspr SPRN_##_H##SRR1,r10; \ | 1448 | mtspr SPRN_##_H##SRR1,r10; \ |
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 5a8bfee6e187..04d0bbd7a1dd 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
| @@ -788,7 +788,8 @@ static int register_cpu_online(unsigned int cpu) | |||
| 788 | if (cpu_has_feature(CPU_FTR_PPCAS_ARCH_V2)) | 788 | if (cpu_has_feature(CPU_FTR_PPCAS_ARCH_V2)) |
| 789 | device_create_file(s, &dev_attr_pir); | 789 | device_create_file(s, &dev_attr_pir); |
| 790 | 790 | ||
| 791 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | 791 | if (cpu_has_feature(CPU_FTR_ARCH_206) && |
| 792 | !firmware_has_feature(FW_FEATURE_LPAR)) | ||
| 792 | device_create_file(s, &dev_attr_tscr); | 793 | device_create_file(s, &dev_attr_tscr); |
| 793 | #endif /* CONFIG_PPC64 */ | 794 | #endif /* CONFIG_PPC64 */ |
| 794 | 795 | ||
| @@ -873,7 +874,8 @@ static int unregister_cpu_online(unsigned int cpu) | |||
| 873 | if (cpu_has_feature(CPU_FTR_PPCAS_ARCH_V2)) | 874 | if (cpu_has_feature(CPU_FTR_PPCAS_ARCH_V2)) |
| 874 | device_remove_file(s, &dev_attr_pir); | 875 | device_remove_file(s, &dev_attr_pir); |
| 875 | 876 | ||
| 876 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | 877 | if (cpu_has_feature(CPU_FTR_ARCH_206) && |
| 878 | !firmware_has_feature(FW_FEATURE_LPAR)) | ||
| 877 | device_remove_file(s, &dev_attr_tscr); | 879 | device_remove_file(s, &dev_attr_tscr); |
| 878 | #endif /* CONFIG_PPC64 */ | 880 | #endif /* CONFIG_PPC64 */ |
| 879 | 881 | ||
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c index 1604110c4238..916844f99c64 100644 --- a/arch/powerpc/mm/drmem.c +++ b/arch/powerpc/mm/drmem.c | |||
| @@ -216,6 +216,8 @@ static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm, | |||
| 216 | u32 i, n_lmbs; | 216 | u32 i, n_lmbs; |
| 217 | 217 | ||
| 218 | n_lmbs = of_read_number(prop++, 1); | 218 | n_lmbs = of_read_number(prop++, 1); |
| 219 | if (n_lmbs == 0) | ||
| 220 | return; | ||
| 219 | 221 | ||
| 220 | for (i = 0; i < n_lmbs; i++) { | 222 | for (i = 0; i < n_lmbs; i++) { |
| 221 | read_drconf_v1_cell(&lmb, &prop); | 223 | read_drconf_v1_cell(&lmb, &prop); |
| @@ -245,6 +247,8 @@ static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm, | |||
| 245 | u32 i, j, lmb_sets; | 247 | u32 i, j, lmb_sets; |
| 246 | 248 | ||
| 247 | lmb_sets = of_read_number(prop++, 1); | 249 | lmb_sets = of_read_number(prop++, 1); |
| 250 | if (lmb_sets == 0) | ||
| 251 | return; | ||
| 248 | 252 | ||
| 249 | for (i = 0; i < lmb_sets; i++) { | 253 | for (i = 0; i < lmb_sets; i++) { |
| 250 | read_drconf_v2_cell(&dr_cell, &prop); | 254 | read_drconf_v2_cell(&dr_cell, &prop); |
| @@ -354,6 +358,8 @@ static void __init init_drmem_v1_lmbs(const __be32 *prop) | |||
| 354 | struct drmem_lmb *lmb; | 358 | struct drmem_lmb *lmb; |
| 355 | 359 | ||
| 356 | drmem_info->n_lmbs = of_read_number(prop++, 1); | 360 | drmem_info->n_lmbs = of_read_number(prop++, 1); |
| 361 | if (drmem_info->n_lmbs == 0) | ||
| 362 | return; | ||
| 357 | 363 | ||
| 358 | drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb), | 364 | drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb), |
| 359 | GFP_KERNEL); | 365 | GFP_KERNEL); |
| @@ -373,6 +379,8 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop) | |||
| 373 | int lmb_index; | 379 | int lmb_index; |
| 374 | 380 | ||
| 375 | lmb_sets = of_read_number(prop++, 1); | 381 | lmb_sets = of_read_number(prop++, 1); |
| 382 | if (lmb_sets == 0) | ||
| 383 | return; | ||
| 376 | 384 | ||
| 377 | /* first pass, calculate the number of LMBs */ | 385 | /* first pass, calculate the number of LMBs */ |
| 378 | p = prop; | 386 | p = prop; |
diff --git a/arch/powerpc/mm/hash64_4k.c b/arch/powerpc/mm/hash64_4k.c index 5a69b51d08a3..d573d7d07f25 100644 --- a/arch/powerpc/mm/hash64_4k.c +++ b/arch/powerpc/mm/hash64_4k.c | |||
| @@ -55,7 +55,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid, | |||
| 55 | * need to add in 0x1 if it's a read-only user page | 55 | * need to add in 0x1 if it's a read-only user page |
| 56 | */ | 56 | */ |
| 57 | rflags = htab_convert_pte_flags(new_pte); | 57 | rflags = htab_convert_pte_flags(new_pte); |
| 58 | rpte = __real_pte(__pte(old_pte), ptep); | 58 | rpte = __real_pte(__pte(old_pte), ptep, PTRS_PER_PTE); |
| 59 | 59 | ||
| 60 | if (cpu_has_feature(CPU_FTR_NOEXECUTE) && | 60 | if (cpu_has_feature(CPU_FTR_NOEXECUTE) && |
| 61 | !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | 61 | !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) |
| @@ -117,7 +117,7 @@ repeat: | |||
| 117 | return -1; | 117 | return -1; |
| 118 | } | 118 | } |
| 119 | new_pte = (new_pte & ~_PAGE_HPTEFLAGS) | H_PAGE_HASHPTE; | 119 | new_pte = (new_pte & ~_PAGE_HPTEFLAGS) | H_PAGE_HASHPTE; |
| 120 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot); | 120 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot, PTRS_PER_PTE); |
| 121 | } | 121 | } |
| 122 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); | 122 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); |
| 123 | return 0; | 123 | return 0; |
diff --git a/arch/powerpc/mm/hash64_64k.c b/arch/powerpc/mm/hash64_64k.c index 2253bbc6a599..e601d95c3b20 100644 --- a/arch/powerpc/mm/hash64_64k.c +++ b/arch/powerpc/mm/hash64_64k.c | |||
| @@ -86,7 +86,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid, | |||
| 86 | 86 | ||
| 87 | subpg_index = (ea & (PAGE_SIZE - 1)) >> shift; | 87 | subpg_index = (ea & (PAGE_SIZE - 1)) >> shift; |
| 88 | vpn = hpt_vpn(ea, vsid, ssize); | 88 | vpn = hpt_vpn(ea, vsid, ssize); |
| 89 | rpte = __real_pte(__pte(old_pte), ptep); | 89 | rpte = __real_pte(__pte(old_pte), ptep, PTRS_PER_PTE); |
| 90 | /* | 90 | /* |
| 91 | *None of the sub 4k page is hashed | 91 | *None of the sub 4k page is hashed |
| 92 | */ | 92 | */ |
| @@ -214,7 +214,7 @@ repeat: | |||
| 214 | return -1; | 214 | return -1; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | new_pte |= pte_set_hidx(ptep, rpte, subpg_index, slot); | 217 | new_pte |= pte_set_hidx(ptep, rpte, subpg_index, slot, PTRS_PER_PTE); |
| 218 | new_pte |= H_PAGE_HASHPTE; | 218 | new_pte |= H_PAGE_HASHPTE; |
| 219 | 219 | ||
| 220 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); | 220 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); |
| @@ -262,7 +262,7 @@ int __hash_page_64K(unsigned long ea, unsigned long access, | |||
| 262 | } while (!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); | 262 | } while (!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); |
| 263 | 263 | ||
| 264 | rflags = htab_convert_pte_flags(new_pte); | 264 | rflags = htab_convert_pte_flags(new_pte); |
| 265 | rpte = __real_pte(__pte(old_pte), ptep); | 265 | rpte = __real_pte(__pte(old_pte), ptep, PTRS_PER_PTE); |
| 266 | 266 | ||
| 267 | if (cpu_has_feature(CPU_FTR_NOEXECUTE) && | 267 | if (cpu_has_feature(CPU_FTR_NOEXECUTE) && |
| 268 | !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | 268 | !cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) |
| @@ -327,7 +327,7 @@ repeat: | |||
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | new_pte = (new_pte & ~_PAGE_HPTEFLAGS) | H_PAGE_HASHPTE; | 329 | new_pte = (new_pte & ~_PAGE_HPTEFLAGS) | H_PAGE_HASHPTE; |
| 330 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot); | 330 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot, PTRS_PER_PTE); |
| 331 | } | 331 | } |
| 332 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); | 332 | *ptep = __pte(new_pte & ~H_PAGE_BUSY); |
| 333 | return 0; | 333 | return 0; |
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 7d07c7e17db6..cf290d415dcd 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c | |||
| @@ -1008,6 +1008,7 @@ void __init hash__early_init_mmu(void) | |||
| 1008 | __pmd_index_size = H_PMD_INDEX_SIZE; | 1008 | __pmd_index_size = H_PMD_INDEX_SIZE; |
| 1009 | __pud_index_size = H_PUD_INDEX_SIZE; | 1009 | __pud_index_size = H_PUD_INDEX_SIZE; |
| 1010 | __pgd_index_size = H_PGD_INDEX_SIZE; | 1010 | __pgd_index_size = H_PGD_INDEX_SIZE; |
| 1011 | __pud_cache_index = H_PUD_CACHE_INDEX; | ||
| 1011 | __pmd_cache_index = H_PMD_CACHE_INDEX; | 1012 | __pmd_cache_index = H_PMD_CACHE_INDEX; |
| 1012 | __pte_table_size = H_PTE_TABLE_SIZE; | 1013 | __pte_table_size = H_PTE_TABLE_SIZE; |
| 1013 | __pmd_table_size = H_PMD_TABLE_SIZE; | 1014 | __pmd_table_size = H_PMD_TABLE_SIZE; |
diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c index 12511f5a015f..b320f5097a06 100644 --- a/arch/powerpc/mm/hugetlbpage-hash64.c +++ b/arch/powerpc/mm/hugetlbpage-hash64.c | |||
| @@ -27,7 +27,7 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, | |||
| 27 | unsigned long vpn; | 27 | unsigned long vpn; |
| 28 | unsigned long old_pte, new_pte; | 28 | unsigned long old_pte, new_pte; |
| 29 | unsigned long rflags, pa, sz; | 29 | unsigned long rflags, pa, sz; |
| 30 | long slot; | 30 | long slot, offset; |
| 31 | 31 | ||
| 32 | BUG_ON(shift != mmu_psize_defs[mmu_psize].shift); | 32 | BUG_ON(shift != mmu_psize_defs[mmu_psize].shift); |
| 33 | 33 | ||
| @@ -63,7 +63,11 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, | |||
| 63 | } while(!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); | 63 | } while(!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); |
| 64 | 64 | ||
| 65 | rflags = htab_convert_pte_flags(new_pte); | 65 | rflags = htab_convert_pte_flags(new_pte); |
| 66 | rpte = __real_pte(__pte(old_pte), ptep); | 66 | if (unlikely(mmu_psize == MMU_PAGE_16G)) |
| 67 | offset = PTRS_PER_PUD; | ||
| 68 | else | ||
| 69 | offset = PTRS_PER_PMD; | ||
| 70 | rpte = __real_pte(__pte(old_pte), ptep, offset); | ||
| 67 | 71 | ||
| 68 | sz = ((1UL) << shift); | 72 | sz = ((1UL) << shift); |
| 69 | if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | 73 | if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) |
| @@ -104,7 +108,7 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, | |||
| 104 | return -1; | 108 | return -1; |
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot); | 111 | new_pte |= pte_set_hidx(ptep, rpte, 0, slot, offset); |
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | /* | 114 | /* |
diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c index eb8c6c8c4851..2b656e67f2ea 100644 --- a/arch/powerpc/mm/init-common.c +++ b/arch/powerpc/mm/init-common.c | |||
| @@ -100,6 +100,6 @@ void pgtable_cache_init(void) | |||
| 100 | * same size as either the pgd or pmd index except with THP enabled | 100 | * same size as either the pgd or pmd index except with THP enabled |
| 101 | * on book3s 64 | 101 | * on book3s 64 |
| 102 | */ | 102 | */ |
| 103 | if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) | 103 | if (PUD_CACHE_INDEX && !PGT_CACHE(PUD_CACHE_INDEX)) |
| 104 | pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor); | 104 | pgtable_cache_add(PUD_CACHE_INDEX, pud_ctor); |
| 105 | } | 105 | } |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 314d19ab9385..edd8d0bc9364 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
| @@ -143,11 +143,6 @@ static void reset_numa_cpu_lookup_table(void) | |||
| 143 | numa_cpu_lookup_table[cpu] = -1; | 143 | numa_cpu_lookup_table[cpu] = -1; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static void update_numa_cpu_lookup_table(unsigned int cpu, int node) | ||
| 147 | { | ||
| 148 | numa_cpu_lookup_table[cpu] = node; | ||
| 149 | } | ||
| 150 | |||
| 151 | static void map_cpu_to_node(int cpu, int node) | 146 | static void map_cpu_to_node(int cpu, int node) |
| 152 | { | 147 | { |
| 153 | update_numa_cpu_lookup_table(cpu, node); | 148 | update_numa_cpu_lookup_table(cpu, node); |
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c index 573a9a2ee455..2e10a964e290 100644 --- a/arch/powerpc/mm/pgtable-radix.c +++ b/arch/powerpc/mm/pgtable-radix.c | |||
| @@ -17,9 +17,11 @@ | |||
| 17 | #include <linux/of_fdt.h> | 17 | #include <linux/of_fdt.h> |
| 18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
| 19 | #include <linux/string_helpers.h> | 19 | #include <linux/string_helpers.h> |
| 20 | #include <linux/stop_machine.h> | ||
| 20 | 21 | ||
| 21 | #include <asm/pgtable.h> | 22 | #include <asm/pgtable.h> |
| 22 | #include <asm/pgalloc.h> | 23 | #include <asm/pgalloc.h> |
| 24 | #include <asm/mmu_context.h> | ||
| 23 | #include <asm/dma.h> | 25 | #include <asm/dma.h> |
| 24 | #include <asm/machdep.h> | 26 | #include <asm/machdep.h> |
| 25 | #include <asm/mmu.h> | 27 | #include <asm/mmu.h> |
| @@ -333,6 +335,22 @@ static void __init radix_init_pgtable(void) | |||
| 333 | "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); | 335 | "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); |
| 334 | asm volatile("eieio; tlbsync; ptesync" : : : "memory"); | 336 | asm volatile("eieio; tlbsync; ptesync" : : : "memory"); |
| 335 | trace_tlbie(0, 0, TLBIEL_INVAL_SET_LPID, 0, 2, 1, 1); | 337 | trace_tlbie(0, 0, TLBIEL_INVAL_SET_LPID, 0, 2, 1, 1); |
| 338 | |||
| 339 | /* | ||
| 340 | * The init_mm context is given the first available (non-zero) PID, | ||
| 341 | * which is the "guard PID" and contains no page table. PIDR should | ||
| 342 | * never be set to zero because that duplicates the kernel address | ||
| 343 | * space at the 0x0... offset (quadrant 0)! | ||
| 344 | * | ||
| 345 | * An arbitrary PID that may later be allocated by the PID allocator | ||
| 346 | * for userspace processes must not be used either, because that | ||
| 347 | * would cause stale user mappings for that PID on CPUs outside of | ||
| 348 | * the TLB invalidation scheme (because it won't be in mm_cpumask). | ||
| 349 | * | ||
| 350 | * So permanently carve out one PID for the purpose of a guard PID. | ||
| 351 | */ | ||
| 352 | init_mm.context.id = mmu_base_pid; | ||
| 353 | mmu_base_pid++; | ||
| 336 | } | 354 | } |
| 337 | 355 | ||
| 338 | static void __init radix_init_partition_table(void) | 356 | static void __init radix_init_partition_table(void) |
| @@ -535,6 +553,7 @@ void __init radix__early_init_mmu(void) | |||
| 535 | __pmd_index_size = RADIX_PMD_INDEX_SIZE; | 553 | __pmd_index_size = RADIX_PMD_INDEX_SIZE; |
| 536 | __pud_index_size = RADIX_PUD_INDEX_SIZE; | 554 | __pud_index_size = RADIX_PUD_INDEX_SIZE; |
| 537 | __pgd_index_size = RADIX_PGD_INDEX_SIZE; | 555 | __pgd_index_size = RADIX_PGD_INDEX_SIZE; |
| 556 | __pud_cache_index = RADIX_PUD_INDEX_SIZE; | ||
| 538 | __pmd_cache_index = RADIX_PMD_INDEX_SIZE; | 557 | __pmd_cache_index = RADIX_PMD_INDEX_SIZE; |
| 539 | __pte_table_size = RADIX_PTE_TABLE_SIZE; | 558 | __pte_table_size = RADIX_PTE_TABLE_SIZE; |
| 540 | __pmd_table_size = RADIX_PMD_TABLE_SIZE; | 559 | __pmd_table_size = RADIX_PMD_TABLE_SIZE; |
| @@ -579,7 +598,8 @@ void __init radix__early_init_mmu(void) | |||
| 579 | 598 | ||
| 580 | radix_init_iamr(); | 599 | radix_init_iamr(); |
| 581 | radix_init_pgtable(); | 600 | radix_init_pgtable(); |
| 582 | 601 | /* Switch to the guard PID before turning on MMU */ | |
| 602 | radix__switch_mmu_context(NULL, &init_mm); | ||
| 583 | if (cpu_has_feature(CPU_FTR_HVMODE)) | 603 | if (cpu_has_feature(CPU_FTR_HVMODE)) |
| 584 | tlbiel_all(); | 604 | tlbiel_all(); |
| 585 | } | 605 | } |
| @@ -604,6 +624,7 @@ void radix__early_init_mmu_secondary(void) | |||
| 604 | } | 624 | } |
| 605 | radix_init_iamr(); | 625 | radix_init_iamr(); |
| 606 | 626 | ||
| 627 | radix__switch_mmu_context(NULL, &init_mm); | ||
| 607 | if (cpu_has_feature(CPU_FTR_HVMODE)) | 628 | if (cpu_has_feature(CPU_FTR_HVMODE)) |
| 608 | tlbiel_all(); | 629 | tlbiel_all(); |
| 609 | } | 630 | } |
| @@ -666,6 +687,30 @@ static void free_pmd_table(pmd_t *pmd_start, pud_t *pud) | |||
| 666 | pud_clear(pud); | 687 | pud_clear(pud); |
| 667 | } | 688 | } |
| 668 | 689 | ||
| 690 | struct change_mapping_params { | ||
| 691 | pte_t *pte; | ||
| 692 | unsigned long start; | ||
| 693 | unsigned long end; | ||
| 694 | unsigned long aligned_start; | ||
| 695 | unsigned long aligned_end; | ||
| 696 | }; | ||
| 697 | |||
| 698 | static int stop_machine_change_mapping(void *data) | ||
| 699 | { | ||
| 700 | struct change_mapping_params *params = | ||
| 701 | (struct change_mapping_params *)data; | ||
| 702 | |||
| 703 | if (!data) | ||
| 704 | return -1; | ||
| 705 | |||
| 706 | spin_unlock(&init_mm.page_table_lock); | ||
| 707 | pte_clear(&init_mm, params->aligned_start, params->pte); | ||
| 708 | create_physical_mapping(params->aligned_start, params->start); | ||
| 709 | create_physical_mapping(params->end, params->aligned_end); | ||
| 710 | spin_lock(&init_mm.page_table_lock); | ||
| 711 | return 0; | ||
| 712 | } | ||
| 713 | |||
| 669 | static void remove_pte_table(pte_t *pte_start, unsigned long addr, | 714 | static void remove_pte_table(pte_t *pte_start, unsigned long addr, |
| 670 | unsigned long end) | 715 | unsigned long end) |
| 671 | { | 716 | { |
| @@ -694,6 +739,52 @@ static void remove_pte_table(pte_t *pte_start, unsigned long addr, | |||
| 694 | } | 739 | } |
| 695 | } | 740 | } |
| 696 | 741 | ||
| 742 | /* | ||
| 743 | * clear the pte and potentially split the mapping helper | ||
| 744 | */ | ||
| 745 | static void split_kernel_mapping(unsigned long addr, unsigned long end, | ||
| 746 | unsigned long size, pte_t *pte) | ||
| 747 | { | ||
| 748 | unsigned long mask = ~(size - 1); | ||
| 749 | unsigned long aligned_start = addr & mask; | ||
| 750 | unsigned long aligned_end = addr + size; | ||
| 751 | struct change_mapping_params params; | ||
| 752 | bool split_region = false; | ||
| 753 | |||
| 754 | if ((end - addr) < size) { | ||
| 755 | /* | ||
| 756 | * We're going to clear the PTE, but not flushed | ||
| 757 | * the mapping, time to remap and flush. The | ||
| 758 | * effects if visible outside the processor or | ||
| 759 | * if we are running in code close to the | ||
| 760 | * mapping we cleared, we are in trouble. | ||
| 761 | */ | ||
| 762 | if (overlaps_kernel_text(aligned_start, addr) || | ||
| 763 | overlaps_kernel_text(end, aligned_end)) { | ||
| 764 | /* | ||
| 765 | * Hack, just return, don't pte_clear | ||
| 766 | */ | ||
| 767 | WARN_ONCE(1, "Linear mapping %lx->%lx overlaps kernel " | ||
| 768 | "text, not splitting\n", addr, end); | ||
| 769 | return; | ||
| 770 | } | ||
| 771 | split_region = true; | ||
| 772 | } | ||
| 773 | |||
| 774 | if (split_region) { | ||
| 775 | params.pte = pte; | ||
| 776 | params.start = addr; | ||
| 777 | params.end = end; | ||
| 778 | params.aligned_start = addr & ~(size - 1); | ||
| 779 | params.aligned_end = min_t(unsigned long, aligned_end, | ||
| 780 | (unsigned long)__va(memblock_end_of_DRAM())); | ||
| 781 | stop_machine(stop_machine_change_mapping, ¶ms, NULL); | ||
| 782 | return; | ||
| 783 | } | ||
| 784 | |||
| 785 | pte_clear(&init_mm, addr, pte); | ||
| 786 | } | ||
| 787 | |||
| 697 | static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr, | 788 | static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr, |
| 698 | unsigned long end) | 789 | unsigned long end) |
| 699 | { | 790 | { |
| @@ -709,13 +800,7 @@ static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr, | |||
| 709 | continue; | 800 | continue; |
| 710 | 801 | ||
| 711 | if (pmd_huge(*pmd)) { | 802 | if (pmd_huge(*pmd)) { |
| 712 | if (!IS_ALIGNED(addr, PMD_SIZE) || | 803 | split_kernel_mapping(addr, end, PMD_SIZE, (pte_t *)pmd); |
| 713 | !IS_ALIGNED(next, PMD_SIZE)) { | ||
| 714 | WARN_ONCE(1, "%s: unaligned range\n", __func__); | ||
| 715 | continue; | ||
| 716 | } | ||
| 717 | |||
| 718 | pte_clear(&init_mm, addr, (pte_t *)pmd); | ||
| 719 | continue; | 804 | continue; |
| 720 | } | 805 | } |
| 721 | 806 | ||
| @@ -740,13 +825,7 @@ static void remove_pud_table(pud_t *pud_start, unsigned long addr, | |||
| 740 | continue; | 825 | continue; |
| 741 | 826 | ||
| 742 | if (pud_huge(*pud)) { | 827 | if (pud_huge(*pud)) { |
| 743 | if (!IS_ALIGNED(addr, PUD_SIZE) || | 828 | split_kernel_mapping(addr, end, PUD_SIZE, (pte_t *)pud); |
| 744 | !IS_ALIGNED(next, PUD_SIZE)) { | ||
| 745 | WARN_ONCE(1, "%s: unaligned range\n", __func__); | ||
| 746 | continue; | ||
| 747 | } | ||
| 748 | |||
| 749 | pte_clear(&init_mm, addr, (pte_t *)pud); | ||
| 750 | continue; | 829 | continue; |
| 751 | } | 830 | } |
| 752 | 831 | ||
| @@ -772,13 +851,7 @@ static void remove_pagetable(unsigned long start, unsigned long end) | |||
| 772 | continue; | 851 | continue; |
| 773 | 852 | ||
| 774 | if (pgd_huge(*pgd)) { | 853 | if (pgd_huge(*pgd)) { |
| 775 | if (!IS_ALIGNED(addr, PGDIR_SIZE) || | 854 | split_kernel_mapping(addr, end, PGDIR_SIZE, (pte_t *)pgd); |
| 776 | !IS_ALIGNED(next, PGDIR_SIZE)) { | ||
| 777 | WARN_ONCE(1, "%s: unaligned range\n", __func__); | ||
| 778 | continue; | ||
| 779 | } | ||
| 780 | |||
| 781 | pte_clear(&init_mm, addr, (pte_t *)pgd); | ||
| 782 | continue; | 855 | continue; |
| 783 | } | 856 | } |
| 784 | 857 | ||
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index c9a623c2d8a2..28c980eb4422 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c | |||
| @@ -82,6 +82,8 @@ unsigned long __pgd_index_size; | |||
| 82 | EXPORT_SYMBOL(__pgd_index_size); | 82 | EXPORT_SYMBOL(__pgd_index_size); |
| 83 | unsigned long __pmd_cache_index; | 83 | unsigned long __pmd_cache_index; |
| 84 | EXPORT_SYMBOL(__pmd_cache_index); | 84 | EXPORT_SYMBOL(__pmd_cache_index); |
| 85 | unsigned long __pud_cache_index; | ||
| 86 | EXPORT_SYMBOL(__pud_cache_index); | ||
| 85 | unsigned long __pte_table_size; | 87 | unsigned long __pte_table_size; |
| 86 | EXPORT_SYMBOL(__pte_table_size); | 88 | EXPORT_SYMBOL(__pte_table_size); |
| 87 | unsigned long __pmd_table_size; | 89 | unsigned long __pmd_table_size; |
| @@ -471,6 +473,8 @@ void mmu_partition_table_set_entry(unsigned int lpid, unsigned long dw0, | |||
| 471 | if (old & PATB_HR) { | 473 | if (old & PATB_HR) { |
| 472 | asm volatile(PPC_TLBIE_5(%0,%1,2,0,1) : : | 474 | asm volatile(PPC_TLBIE_5(%0,%1,2,0,1) : : |
| 473 | "r" (TLBIEL_INVAL_SET_LPID), "r" (lpid)); | 475 | "r" (TLBIEL_INVAL_SET_LPID), "r" (lpid)); |
| 476 | asm volatile(PPC_TLBIE_5(%0,%1,2,1,1) : : | ||
| 477 | "r" (TLBIEL_INVAL_SET_LPID), "r" (lpid)); | ||
| 474 | trace_tlbie(lpid, 0, TLBIEL_INVAL_SET_LPID, lpid, 2, 0, 1); | 478 | trace_tlbie(lpid, 0, TLBIEL_INVAL_SET_LPID, lpid, 2, 0, 1); |
| 475 | } else { | 479 | } else { |
| 476 | asm volatile(PPC_TLBIE_5(%0,%1,2,0,0) : : | 480 | asm volatile(PPC_TLBIE_5(%0,%1,2,0,0) : : |
diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c index 881ebd53ffc2..9b23f12e863c 100644 --- a/arch/powerpc/mm/tlb_hash64.c +++ b/arch/powerpc/mm/tlb_hash64.c | |||
| @@ -51,7 +51,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, | |||
| 51 | unsigned int psize; | 51 | unsigned int psize; |
| 52 | int ssize; | 52 | int ssize; |
| 53 | real_pte_t rpte; | 53 | real_pte_t rpte; |
| 54 | int i; | 54 | int i, offset; |
| 55 | 55 | ||
| 56 | i = batch->index; | 56 | i = batch->index; |
| 57 | 57 | ||
| @@ -67,6 +67,10 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, | |||
| 67 | psize = get_slice_psize(mm, addr); | 67 | psize = get_slice_psize(mm, addr); |
| 68 | /* Mask the address for the correct page size */ | 68 | /* Mask the address for the correct page size */ |
| 69 | addr &= ~((1UL << mmu_psize_defs[psize].shift) - 1); | 69 | addr &= ~((1UL << mmu_psize_defs[psize].shift) - 1); |
| 70 | if (unlikely(psize == MMU_PAGE_16G)) | ||
| 71 | offset = PTRS_PER_PUD; | ||
| 72 | else | ||
| 73 | offset = PTRS_PER_PMD; | ||
| 70 | #else | 74 | #else |
| 71 | BUG(); | 75 | BUG(); |
| 72 | psize = pte_pagesize_index(mm, addr, pte); /* shutup gcc */ | 76 | psize = pte_pagesize_index(mm, addr, pte); /* shutup gcc */ |
| @@ -78,6 +82,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, | |||
| 78 | * support 64k pages, this might be different from the | 82 | * support 64k pages, this might be different from the |
| 79 | * hardware page size encoded in the slice table. */ | 83 | * hardware page size encoded in the slice table. */ |
| 80 | addr &= PAGE_MASK; | 84 | addr &= PAGE_MASK; |
| 85 | offset = PTRS_PER_PTE; | ||
| 81 | } | 86 | } |
| 82 | 87 | ||
| 83 | 88 | ||
| @@ -91,7 +96,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, | |||
| 91 | } | 96 | } |
| 92 | WARN_ON(vsid == 0); | 97 | WARN_ON(vsid == 0); |
| 93 | vpn = hpt_vpn(addr, vsid, ssize); | 98 | vpn = hpt_vpn(addr, vsid, ssize); |
| 94 | rpte = __real_pte(__pte(pte), ptep); | 99 | rpte = __real_pte(__pte(pte), ptep, offset); |
| 95 | 100 | ||
| 96 | /* | 101 | /* |
| 97 | * Check if we have an active batch on this CPU. If not, just | 102 | * Check if we have an active batch on this CPU. If not, just |
diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c index dd4c9b8b8a81..f6f55ab4980e 100644 --- a/arch/powerpc/platforms/powernv/opal-imc.c +++ b/arch/powerpc/platforms/powernv/opal-imc.c | |||
| @@ -199,9 +199,11 @@ static void disable_nest_pmu_counters(void) | |||
| 199 | const struct cpumask *l_cpumask; | 199 | const struct cpumask *l_cpumask; |
| 200 | 200 | ||
| 201 | get_online_cpus(); | 201 | get_online_cpus(); |
| 202 | for_each_online_node(nid) { | 202 | for_each_node_with_cpus(nid) { |
| 203 | l_cpumask = cpumask_of_node(nid); | 203 | l_cpumask = cpumask_of_node(nid); |
| 204 | cpu = cpumask_first(l_cpumask); | 204 | cpu = cpumask_first_and(l_cpumask, cpu_online_mask); |
| 205 | if (cpu >= nr_cpu_ids) | ||
| 206 | continue; | ||
| 205 | opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST, | 207 | opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST, |
| 206 | get_hard_smp_processor_id(cpu)); | 208 | get_hard_smp_processor_id(cpu)); |
| 207 | } | 209 | } |
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c index 2b3eb01ab110..b7c53a51c31b 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c | |||
| @@ -1063,16 +1063,16 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop, | |||
| 1063 | rc = PTR_ERR(txwin->paste_kaddr); | 1063 | rc = PTR_ERR(txwin->paste_kaddr); |
| 1064 | goto free_window; | 1064 | goto free_window; |
| 1065 | } | 1065 | } |
| 1066 | } else { | ||
| 1067 | /* | ||
| 1068 | * A user mapping must ensure that context switch issues | ||
| 1069 | * CP_ABORT for this thread. | ||
| 1070 | */ | ||
| 1071 | rc = set_thread_uses_vas(); | ||
| 1072 | if (rc) | ||
| 1073 | goto free_window; | ||
| 1066 | } | 1074 | } |
| 1067 | 1075 | ||
| 1068 | /* | ||
| 1069 | * Now that we have a send window, ensure context switch issues | ||
| 1070 | * CP_ABORT for this thread. | ||
| 1071 | */ | ||
| 1072 | rc = -EINVAL; | ||
| 1073 | if (set_thread_uses_vas() < 0) | ||
| 1074 | goto free_window; | ||
| 1075 | |||
| 1076 | set_vinst_win(vinst, txwin); | 1076 | set_vinst_win(vinst, txwin); |
| 1077 | 1077 | ||
| 1078 | return txwin; | 1078 | return txwin; |
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index dceb51454d8d..652d3e96b812 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <asm/xics.h> | 36 | #include <asm/xics.h> |
| 37 | #include <asm/xive.h> | 37 | #include <asm/xive.h> |
| 38 | #include <asm/plpar_wrappers.h> | 38 | #include <asm/plpar_wrappers.h> |
| 39 | #include <asm/topology.h> | ||
| 39 | 40 | ||
| 40 | #include "pseries.h" | 41 | #include "pseries.h" |
| 41 | #include "offline_states.h" | 42 | #include "offline_states.h" |
| @@ -331,6 +332,7 @@ static void pseries_remove_processor(struct device_node *np) | |||
| 331 | BUG_ON(cpu_online(cpu)); | 332 | BUG_ON(cpu_online(cpu)); |
| 332 | set_cpu_present(cpu, false); | 333 | set_cpu_present(cpu, false); |
| 333 | set_hard_smp_processor_id(cpu, -1); | 334 | set_hard_smp_processor_id(cpu, -1); |
| 335 | update_numa_cpu_lookup_table(cpu, -1); | ||
| 334 | break; | 336 | break; |
| 335 | } | 337 | } |
| 336 | if (cpu >= nr_cpu_ids) | 338 | if (cpu >= nr_cpu_ids) |
| @@ -340,8 +342,6 @@ static void pseries_remove_processor(struct device_node *np) | |||
| 340 | cpu_maps_update_done(); | 342 | cpu_maps_update_done(); |
| 341 | } | 343 | } |
| 342 | 344 | ||
| 343 | extern int find_and_online_cpu_nid(int cpu); | ||
| 344 | |||
| 345 | static int dlpar_online_cpu(struct device_node *dn) | 345 | static int dlpar_online_cpu(struct device_node *dn) |
| 346 | { | 346 | { |
| 347 | int rc = 0; | 347 | int rc = 0; |
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 81d8614e7379..5e1ef9150182 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c | |||
| @@ -49,6 +49,28 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id); | |||
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | /* | 51 | /* |
| 52 | * Enable the hotplug interrupt late because processing them may touch other | ||
| 53 | * devices or systems (e.g. hugepages) that have not been initialized at the | ||
| 54 | * subsys stage. | ||
| 55 | */ | ||
| 56 | int __init init_ras_hotplug_IRQ(void) | ||
| 57 | { | ||
| 58 | struct device_node *np; | ||
| 59 | |||
| 60 | /* Hotplug Events */ | ||
| 61 | np = of_find_node_by_path("/event-sources/hot-plug-events"); | ||
| 62 | if (np != NULL) { | ||
| 63 | if (dlpar_workqueue_init() == 0) | ||
| 64 | request_event_sources_irqs(np, ras_hotplug_interrupt, | ||
| 65 | "RAS_HOTPLUG"); | ||
| 66 | of_node_put(np); | ||
| 67 | } | ||
| 68 | |||
| 69 | return 0; | ||
| 70 | } | ||
| 71 | machine_late_initcall(pseries, init_ras_hotplug_IRQ); | ||
| 72 | |||
| 73 | /* | ||
| 52 | * Initialize handlers for the set of interrupts caused by hardware errors | 74 | * Initialize handlers for the set of interrupts caused by hardware errors |
| 53 | * and power system events. | 75 | * and power system events. |
| 54 | */ | 76 | */ |
| @@ -66,15 +88,6 @@ static int __init init_ras_IRQ(void) | |||
| 66 | of_node_put(np); | 88 | of_node_put(np); |
| 67 | } | 89 | } |
| 68 | 90 | ||
| 69 | /* Hotplug Events */ | ||
| 70 | np = of_find_node_by_path("/event-sources/hot-plug-events"); | ||
| 71 | if (np != NULL) { | ||
| 72 | if (dlpar_workqueue_init() == 0) | ||
| 73 | request_event_sources_irqs(np, ras_hotplug_interrupt, | ||
| 74 | "RAS_HOTPLUG"); | ||
| 75 | of_node_put(np); | ||
| 76 | } | ||
| 77 | |||
| 78 | /* EPOW Events */ | 91 | /* EPOW Events */ |
| 79 | np = of_find_node_by_path("/event-sources/epow-events"); | 92 | np = of_find_node_by_path("/event-sources/epow-events"); |
| 80 | if (np != NULL) { | 93 | if (np != NULL) { |
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c index d9c4c9366049..091f1d0d0af1 100644 --- a/arch/powerpc/sysdev/xive/spapr.c +++ b/arch/powerpc/sysdev/xive/spapr.c | |||
| @@ -356,7 +356,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio, | |||
| 356 | 356 | ||
| 357 | rc = plpar_int_get_queue_info(0, target, prio, &esn_page, &esn_size); | 357 | rc = plpar_int_get_queue_info(0, target, prio, &esn_page, &esn_size); |
| 358 | if (rc) { | 358 | if (rc) { |
| 359 | pr_err("Error %lld getting queue info prio %d\n", rc, prio); | 359 | pr_err("Error %lld getting queue info CPU %d prio %d\n", rc, |
| 360 | target, prio); | ||
| 360 | rc = -EIO; | 361 | rc = -EIO; |
| 361 | goto fail; | 362 | goto fail; |
| 362 | } | 363 | } |
| @@ -370,7 +371,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio, | |||
| 370 | /* Configure and enable the queue in HW */ | 371 | /* Configure and enable the queue in HW */ |
| 371 | rc = plpar_int_set_queue_config(flags, target, prio, qpage_phys, order); | 372 | rc = plpar_int_set_queue_config(flags, target, prio, qpage_phys, order); |
| 372 | if (rc) { | 373 | if (rc) { |
| 373 | pr_err("Error %lld setting queue for prio %d\n", rc, prio); | 374 | pr_err("Error %lld setting queue for CPU %d prio %d\n", rc, |
| 375 | target, prio); | ||
| 374 | rc = -EIO; | 376 | rc = -EIO; |
| 375 | } else { | 377 | } else { |
| 376 | q->qpage = qpage; | 378 | q->qpage = qpage; |
| @@ -389,8 +391,8 @@ static int xive_spapr_setup_queue(unsigned int cpu, struct xive_cpu *xc, | |||
| 389 | if (IS_ERR(qpage)) | 391 | if (IS_ERR(qpage)) |
| 390 | return PTR_ERR(qpage); | 392 | return PTR_ERR(qpage); |
| 391 | 393 | ||
| 392 | return xive_spapr_configure_queue(cpu, q, prio, qpage, | 394 | return xive_spapr_configure_queue(get_hard_smp_processor_id(cpu), |
| 393 | xive_queue_shift); | 395 | q, prio, qpage, xive_queue_shift); |
| 394 | } | 396 | } |
| 395 | 397 | ||
| 396 | static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, | 398 | static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, |
| @@ -399,10 +401,12 @@ static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, | |||
| 399 | struct xive_q *q = &xc->queue[prio]; | 401 | struct xive_q *q = &xc->queue[prio]; |
| 400 | unsigned int alloc_order; | 402 | unsigned int alloc_order; |
| 401 | long rc; | 403 | long rc; |
| 404 | int hw_cpu = get_hard_smp_processor_id(cpu); | ||
| 402 | 405 | ||
| 403 | rc = plpar_int_set_queue_config(0, cpu, prio, 0, 0); | 406 | rc = plpar_int_set_queue_config(0, hw_cpu, prio, 0, 0); |
| 404 | if (rc) | 407 | if (rc) |
| 405 | pr_err("Error %ld setting queue for prio %d\n", rc, prio); | 408 | pr_err("Error %ld setting queue for CPU %d prio %d\n", rc, |
| 409 | hw_cpu, prio); | ||
| 406 | 410 | ||
| 407 | alloc_order = xive_alloc_order(xive_queue_shift); | 411 | alloc_order = xive_alloc_order(xive_queue_shift); |
| 408 | free_pages((unsigned long)q->qpage, alloc_order); | 412 | free_pages((unsigned long)q->qpage, alloc_order); |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 6bf594ace663..8767e45f1b2b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -430,6 +430,8 @@ config SPARC_LEON | |||
| 430 | depends on SPARC32 | 430 | depends on SPARC32 |
| 431 | select USB_EHCI_BIG_ENDIAN_MMIO | 431 | select USB_EHCI_BIG_ENDIAN_MMIO |
| 432 | select USB_EHCI_BIG_ENDIAN_DESC | 432 | select USB_EHCI_BIG_ENDIAN_DESC |
| 433 | select USB_UHCI_BIG_ENDIAN_MMIO | ||
| 434 | select USB_UHCI_BIG_ENDIAN_DESC | ||
| 433 | ---help--- | 435 | ---help--- |
| 434 | If you say Y here if you are running on a SPARC-LEON processor. | 436 | If you say Y here if you are running on a SPARC-LEON processor. |
| 435 | The LEON processor is a synthesizable VHDL model of the | 437 | The LEON processor is a synthesizable VHDL model of the |
diff --git a/arch/x86/.gitignore b/arch/x86/.gitignore index aff152c87cf4..5a82bac5e0bc 100644 --- a/arch/x86/.gitignore +++ b/arch/x86/.gitignore | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | boot/compressed/vmlinux | 1 | boot/compressed/vmlinux |
| 2 | tools/test_get_len | 2 | tools/test_get_len |
| 3 | tools/insn_sanity | 3 | tools/insn_sanity |
| 4 | tools/insn_decoder_test | ||
| 4 | purgatory/kexec-purgatory.c | 5 | purgatory/kexec-purgatory.c |
| 5 | purgatory/purgatory.ro | 6 | purgatory/purgatory.ro |
| 6 | 7 | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 63bf349b2b24..c1236b187824 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -423,12 +423,6 @@ config X86_MPPARSE | |||
| 423 | For old smp systems that do not have proper acpi support. Newer systems | 423 | For old smp systems that do not have proper acpi support. Newer systems |
| 424 | (esp with 64bit cpus) with acpi support, MADT and DSDT will override it | 424 | (esp with 64bit cpus) with acpi support, MADT and DSDT will override it |
| 425 | 425 | ||
| 426 | config X86_BIGSMP | ||
| 427 | bool "Support for big SMP systems with more than 8 CPUs" | ||
| 428 | depends on X86_32 && SMP | ||
| 429 | ---help--- | ||
| 430 | This option is needed for the systems that have more than 8 CPUs | ||
| 431 | |||
| 432 | config GOLDFISH | 426 | config GOLDFISH |
| 433 | def_bool y | 427 | def_bool y |
| 434 | depends on X86_GOLDFISH | 428 | depends on X86_GOLDFISH |
| @@ -460,6 +454,12 @@ config INTEL_RDT | |||
| 460 | Say N if unsure. | 454 | Say N if unsure. |
| 461 | 455 | ||
| 462 | if X86_32 | 456 | if X86_32 |
| 457 | config X86_BIGSMP | ||
| 458 | bool "Support for big SMP systems with more than 8 CPUs" | ||
| 459 | depends on SMP | ||
| 460 | ---help--- | ||
| 461 | This option is needed for the systems that have more than 8 CPUs | ||
| 462 | |||
| 463 | config X86_EXTENDED_PLATFORM | 463 | config X86_EXTENDED_PLATFORM |
| 464 | bool "Support for extended (non-PC) x86 platforms" | 464 | bool "Support for extended (non-PC) x86 platforms" |
| 465 | default y | 465 | default y |
| @@ -949,25 +949,66 @@ config MAXSMP | |||
| 949 | Enable maximum number of CPUS and NUMA Nodes for this architecture. | 949 | Enable maximum number of CPUS and NUMA Nodes for this architecture. |
| 950 | If unsure, say N. | 950 | If unsure, say N. |
| 951 | 951 | ||
| 952 | # | ||
| 953 | # The maximum number of CPUs supported: | ||
| 954 | # | ||
| 955 | # The main config value is NR_CPUS, which defaults to NR_CPUS_DEFAULT, | ||
| 956 | # and which can be configured interactively in the | ||
| 957 | # [NR_CPUS_RANGE_BEGIN ... NR_CPUS_RANGE_END] range. | ||
| 958 | # | ||
| 959 | # The ranges are different on 32-bit and 64-bit kernels, depending on | ||
| 960 | # hardware capabilities and scalability features of the kernel. | ||
| 961 | # | ||
| 962 | # ( If MAXSMP is enabled we just use the highest possible value and disable | ||
| 963 | # interactive configuration. ) | ||
| 964 | # | ||
| 965 | |||
| 966 | config NR_CPUS_RANGE_BEGIN | ||
| 967 | int | ||
| 968 | default NR_CPUS_RANGE_END if MAXSMP | ||
| 969 | default 1 if !SMP | ||
| 970 | default 2 | ||
| 971 | |||
| 972 | config NR_CPUS_RANGE_END | ||
| 973 | int | ||
| 974 | depends on X86_32 | ||
| 975 | default 64 if SMP && X86_BIGSMP | ||
| 976 | default 8 if SMP && !X86_BIGSMP | ||
| 977 | default 1 if !SMP | ||
| 978 | |||
| 979 | config NR_CPUS_RANGE_END | ||
| 980 | int | ||
| 981 | depends on X86_64 | ||
| 982 | default 8192 if SMP && ( MAXSMP || CPUMASK_OFFSTACK) | ||
| 983 | default 512 if SMP && (!MAXSMP && !CPUMASK_OFFSTACK) | ||
| 984 | default 1 if !SMP | ||
| 985 | |||
| 986 | config NR_CPUS_DEFAULT | ||
| 987 | int | ||
| 988 | depends on X86_32 | ||
| 989 | default 32 if X86_BIGSMP | ||
| 990 | default 8 if SMP | ||
| 991 | default 1 if !SMP | ||
| 992 | |||
| 993 | config NR_CPUS_DEFAULT | ||
| 994 | int | ||
| 995 | depends on X86_64 | ||
| 996 | default 8192 if MAXSMP | ||
| 997 | default 64 if SMP | ||
| 998 | default 1 if !SMP | ||
| 999 | |||
| 952 | config NR_CPUS | 1000 | config NR_CPUS |
| 953 | int "Maximum number of CPUs" if SMP && !MAXSMP | 1001 | int "Maximum number of CPUs" if SMP && !MAXSMP |
| 954 | range 2 8 if SMP && X86_32 && !X86_BIGSMP | 1002 | range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END |
| 955 | range 2 64 if SMP && X86_32 && X86_BIGSMP | 1003 | default NR_CPUS_DEFAULT |
| 956 | range 2 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64 | ||
| 957 | range 2 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64 | ||
| 958 | default "1" if !SMP | ||
| 959 | default "8192" if MAXSMP | ||
| 960 | default "32" if SMP && X86_BIGSMP | ||
| 961 | default "8" if SMP && X86_32 | ||
| 962 | default "64" if SMP | ||
| 963 | ---help--- | 1004 | ---help--- |
| 964 | This allows you to specify the maximum number of CPUs which this | 1005 | This allows you to specify the maximum number of CPUs which this |
| 965 | kernel will support. If CPUMASK_OFFSTACK is enabled, the maximum | 1006 | kernel will support. If CPUMASK_OFFSTACK is enabled, the maximum |
| 966 | supported value is 8192, otherwise the maximum value is 512. The | 1007 | supported value is 8192, otherwise the maximum value is 512. The |
| 967 | minimum value which makes sense is 2. | 1008 | minimum value which makes sense is 2. |
| 968 | 1009 | ||
| 969 | This is purely to save memory - each supported CPU adds | 1010 | This is purely to save memory: each supported CPU adds about 8KB |
| 970 | approximately eight kilobytes to the kernel image. | 1011 | to the kernel image. |
| 971 | 1012 | ||
| 972 | config SCHED_SMT | 1013 | config SCHED_SMT |
| 973 | bool "SMT (Hyperthreading) scheduler support" | 1014 | bool "SMT (Hyperthreading) scheduler support" |
| @@ -1363,7 +1404,7 @@ config HIGHMEM4G | |||
| 1363 | 1404 | ||
| 1364 | config HIGHMEM64G | 1405 | config HIGHMEM64G |
| 1365 | bool "64GB" | 1406 | bool "64GB" |
| 1366 | depends on !M486 | 1407 | depends on !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !WINCHIP3D && !MK6 |
| 1367 | select X86_PAE | 1408 | select X86_PAE |
| 1368 | ---help--- | 1409 | ---help--- |
| 1369 | Select this if you have a 32-bit processor and more than 4 | 1410 | Select this if you have a 32-bit processor and more than 4 |
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 65a9a4716e34..8b8d2297d486 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu | |||
| @@ -374,7 +374,7 @@ config X86_TSC | |||
| 374 | 374 | ||
| 375 | config X86_CMPXCHG64 | 375 | config X86_CMPXCHG64 |
| 376 | def_bool y | 376 | def_bool y |
| 377 | depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM | 377 | depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586TSC || M586MMX || MATOM || MGEODE_LX || MGEODEGX1 || MK6 || MK7 || MK8 |
| 378 | 378 | ||
| 379 | # this should be set for all -march=.. options where the compiler | 379 | # this should be set for all -march=.. options where the compiler |
| 380 | # generates cmov. | 380 | # generates cmov. |
| @@ -385,7 +385,7 @@ config X86_CMOV | |||
| 385 | config X86_MINIMUM_CPU_FAMILY | 385 | config X86_MINIMUM_CPU_FAMILY |
| 386 | int | 386 | int |
| 387 | default "64" if X86_64 | 387 | default "64" if X86_64 |
| 388 | default "6" if X86_32 && X86_P6_NOP | 388 | default "6" if X86_32 && (MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MEFFICEON || MATOM || MCRUSOE || MCORE2 || MK7 || MK8) |
| 389 | default "5" if X86_32 && X86_CMPXCHG64 | 389 | default "5" if X86_32 && X86_CMPXCHG64 |
| 390 | default "4" | 390 | default "4" |
| 391 | 391 | ||
diff --git a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_init_avx2.c b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_init_avx2.c index 36870b26067a..d08805032f01 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_init_avx2.c +++ b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_init_avx2.c | |||
| @@ -57,10 +57,12 @@ void sha512_mb_mgr_init_avx2(struct sha512_mb_mgr *state) | |||
| 57 | { | 57 | { |
| 58 | unsigned int j; | 58 | unsigned int j; |
| 59 | 59 | ||
| 60 | state->lens[0] = 0; | 60 | /* initially all lanes are unused */ |
| 61 | state->lens[1] = 1; | 61 | state->lens[0] = 0xFFFFFFFF00000000; |
| 62 | state->lens[2] = 2; | 62 | state->lens[1] = 0xFFFFFFFF00000001; |
| 63 | state->lens[3] = 3; | 63 | state->lens[2] = 0xFFFFFFFF00000002; |
| 64 | state->lens[3] = 0xFFFFFFFF00000003; | ||
| 65 | |||
| 64 | state->unused_lanes = 0xFF03020100; | 66 | state->unused_lanes = 0xFF03020100; |
| 65 | for (j = 0; j < 4; j++) | 67 | for (j = 0; j < 4; j++) |
| 66 | state->ldata[j].job_in_lane = NULL; | 68 | state->ldata[j].job_in_lane = NULL; |
diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index 3f48f695d5e6..dce7092ab24a 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h | |||
| @@ -97,80 +97,69 @@ For 32-bit we have the following conventions - kernel is built with | |||
| 97 | 97 | ||
| 98 | #define SIZEOF_PTREGS 21*8 | 98 | #define SIZEOF_PTREGS 21*8 |
| 99 | 99 | ||
| 100 | .macro ALLOC_PT_GPREGS_ON_STACK | 100 | .macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax |
| 101 | addq $-(15*8), %rsp | 101 | /* |
| 102 | .endm | 102 | * Push registers and sanitize registers of values that a |
| 103 | * speculation attack might otherwise want to exploit. The | ||
| 104 | * lower registers are likely clobbered well before they | ||
| 105 | * could be put to use in a speculative execution gadget. | ||
| 106 | * Interleave XOR with PUSH for better uop scheduling: | ||
| 107 | */ | ||
| 108 | pushq %rdi /* pt_regs->di */ | ||
| 109 | pushq %rsi /* pt_regs->si */ | ||
| 110 | pushq \rdx /* pt_regs->dx */ | ||
| 111 | pushq %rcx /* pt_regs->cx */ | ||
| 112 | pushq \rax /* pt_regs->ax */ | ||
| 113 | pushq %r8 /* pt_regs->r8 */ | ||
| 114 | xorq %r8, %r8 /* nospec r8 */ | ||
| 115 | pushq %r9 /* pt_regs->r9 */ | ||
| 116 | xorq %r9, %r9 /* nospec r9 */ | ||
| 117 | pushq %r10 /* pt_regs->r10 */ | ||
| 118 | xorq %r10, %r10 /* nospec r10 */ | ||
| 119 | pushq %r11 /* pt_regs->r11 */ | ||
| 120 | xorq %r11, %r11 /* nospec r11*/ | ||
| 121 | pushq %rbx /* pt_regs->rbx */ | ||
| 122 | xorl %ebx, %ebx /* nospec rbx*/ | ||
| 123 | pushq %rbp /* pt_regs->rbp */ | ||
| 124 | xorl %ebp, %ebp /* nospec rbp*/ | ||
| 125 | pushq %r12 /* pt_regs->r12 */ | ||
| 126 | xorq %r12, %r12 /* nospec r12*/ | ||
| 127 | pushq %r13 /* pt_regs->r13 */ | ||
| 128 | xorq %r13, %r13 /* nospec r13*/ | ||
| 129 | pushq %r14 /* pt_regs->r14 */ | ||
| 130 | xorq %r14, %r14 /* nospec r14*/ | ||
| 131 | pushq %r15 /* pt_regs->r15 */ | ||
| 132 | xorq %r15, %r15 /* nospec r15*/ | ||
| 133 | UNWIND_HINT_REGS | ||
| 134 | .endm | ||
| 103 | 135 | ||
| 104 | .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1 | 136 | .macro POP_REGS pop_rdi=1 skip_r11rcx=0 |
| 105 | .if \r11 | ||
| 106 | movq %r11, 6*8+\offset(%rsp) | ||
| 107 | .endif | ||
| 108 | .if \r8910 | ||
| 109 | movq %r10, 7*8+\offset(%rsp) | ||
| 110 | movq %r9, 8*8+\offset(%rsp) | ||
| 111 | movq %r8, 9*8+\offset(%rsp) | ||
| 112 | .endif | ||
| 113 | .if \rax | ||
| 114 | movq %rax, 10*8+\offset(%rsp) | ||
| 115 | .endif | ||
| 116 | .if \rcx | ||
| 117 | movq %rcx, 11*8+\offset(%rsp) | ||
| 118 | .endif | ||
| 119 | movq %rdx, 12*8+\offset(%rsp) | ||
| 120 | movq %rsi, 13*8+\offset(%rsp) | ||
| 121 | movq %rdi, 14*8+\offset(%rsp) | ||
| 122 | UNWIND_HINT_REGS offset=\offset extra=0 | ||
| 123 | .endm | ||
| 124 | .macro SAVE_C_REGS offset=0 | ||
| 125 | SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1 | ||
| 126 | .endm | ||
| 127 | .macro SAVE_C_REGS_EXCEPT_RAX_RCX offset=0 | ||
| 128 | SAVE_C_REGS_HELPER \offset, 0, 0, 1, 1 | ||
| 129 | .endm | ||
| 130 | .macro SAVE_C_REGS_EXCEPT_R891011 | ||
| 131 | SAVE_C_REGS_HELPER 0, 1, 1, 0, 0 | ||
| 132 | .endm | ||
| 133 | .macro SAVE_C_REGS_EXCEPT_RCX_R891011 | ||
| 134 | SAVE_C_REGS_HELPER 0, 1, 0, 0, 0 | ||
| 135 | .endm | ||
| 136 | .macro SAVE_C_REGS_EXCEPT_RAX_RCX_R11 | ||
| 137 | SAVE_C_REGS_HELPER 0, 0, 0, 1, 0 | ||
| 138 | .endm | ||
| 139 | |||
| 140 | .macro SAVE_EXTRA_REGS offset=0 | ||
| 141 | movq %r15, 0*8+\offset(%rsp) | ||
| 142 | movq %r14, 1*8+\offset(%rsp) | ||
| 143 | movq %r13, 2*8+\offset(%rsp) | ||
| 144 | movq %r12, 3*8+\offset(%rsp) | ||
| 145 | movq %rbp, 4*8+\offset(%rsp) | ||
| 146 | movq %rbx, 5*8+\offset(%rsp) | ||
| 147 | UNWIND_HINT_REGS offset=\offset | ||
| 148 | .endm | ||
| 149 | |||
| 150 | .macro POP_EXTRA_REGS | ||
| 151 | popq %r15 | 137 | popq %r15 |
| 152 | popq %r14 | 138 | popq %r14 |
| 153 | popq %r13 | 139 | popq %r13 |
| 154 | popq %r12 | 140 | popq %r12 |
| 155 | popq %rbp | 141 | popq %rbp |
| 156 | popq %rbx | 142 | popq %rbx |
| 157 | .endm | 143 | .if \skip_r11rcx |
| 158 | 144 | popq %rsi | |
| 159 | .macro POP_C_REGS | 145 | .else |
| 160 | popq %r11 | 146 | popq %r11 |
| 147 | .endif | ||
| 161 | popq %r10 | 148 | popq %r10 |
| 162 | popq %r9 | 149 | popq %r9 |
| 163 | popq %r8 | 150 | popq %r8 |
| 164 | popq %rax | 151 | popq %rax |
| 152 | .if \skip_r11rcx | ||
| 153 | popq %rsi | ||
| 154 | .else | ||
| 165 | popq %rcx | 155 | popq %rcx |
| 156 | .endif | ||
| 166 | popq %rdx | 157 | popq %rdx |
| 167 | popq %rsi | 158 | popq %rsi |
| 159 | .if \pop_rdi | ||
| 168 | popq %rdi | 160 | popq %rdi |
| 169 | .endm | 161 | .endif |
| 170 | 162 | .endm | |
| 171 | .macro icebp | ||
| 172 | .byte 0xf1 | ||
| 173 | .endm | ||
| 174 | 163 | ||
| 175 | /* | 164 | /* |
| 176 | * This is a sneaky trick to help the unwinder find pt_regs on the stack. The | 165 | * This is a sneaky trick to help the unwinder find pt_regs on the stack. The |
| @@ -178,7 +167,7 @@ For 32-bit we have the following conventions - kernel is built with | |||
| 178 | * is just setting the LSB, which makes it an invalid stack address and is also | 167 | * is just setting the LSB, which makes it an invalid stack address and is also |
| 179 | * a signal to the unwinder that it's a pt_regs pointer in disguise. | 168 | * a signal to the unwinder that it's a pt_regs pointer in disguise. |
| 180 | * | 169 | * |
| 181 | * NOTE: This macro must be used *after* SAVE_EXTRA_REGS because it corrupts | 170 | * NOTE: This macro must be used *after* PUSH_AND_CLEAR_REGS because it corrupts |
| 182 | * the original rbp. | 171 | * the original rbp. |
| 183 | */ | 172 | */ |
| 184 | .macro ENCODE_FRAME_POINTER ptregs_offset=0 | 173 | .macro ENCODE_FRAME_POINTER ptregs_offset=0 |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 30c8c5344c4a..8971bd64d515 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S | |||
| @@ -213,7 +213,7 @@ ENTRY(entry_SYSCALL_64) | |||
| 213 | 213 | ||
| 214 | swapgs | 214 | swapgs |
| 215 | /* | 215 | /* |
| 216 | * This path is not taken when PAGE_TABLE_ISOLATION is disabled so it | 216 | * This path is only taken when PAGE_TABLE_ISOLATION is disabled so it |
| 217 | * is not required to switch CR3. | 217 | * is not required to switch CR3. |
| 218 | */ | 218 | */ |
| 219 | movq %rsp, PER_CPU_VAR(rsp_scratch) | 219 | movq %rsp, PER_CPU_VAR(rsp_scratch) |
| @@ -227,22 +227,8 @@ ENTRY(entry_SYSCALL_64) | |||
| 227 | pushq %rcx /* pt_regs->ip */ | 227 | pushq %rcx /* pt_regs->ip */ |
| 228 | GLOBAL(entry_SYSCALL_64_after_hwframe) | 228 | GLOBAL(entry_SYSCALL_64_after_hwframe) |
| 229 | pushq %rax /* pt_regs->orig_ax */ | 229 | pushq %rax /* pt_regs->orig_ax */ |
| 230 | pushq %rdi /* pt_regs->di */ | 230 | |
| 231 | pushq %rsi /* pt_regs->si */ | 231 | PUSH_AND_CLEAR_REGS rax=$-ENOSYS |
| 232 | pushq %rdx /* pt_regs->dx */ | ||
| 233 | pushq %rcx /* pt_regs->cx */ | ||
| 234 | pushq $-ENOSYS /* pt_regs->ax */ | ||
| 235 | pushq %r8 /* pt_regs->r8 */ | ||
| 236 | pushq %r9 /* pt_regs->r9 */ | ||
| 237 | pushq %r10 /* pt_regs->r10 */ | ||
| 238 | pushq %r11 /* pt_regs->r11 */ | ||
| 239 | pushq %rbx /* pt_regs->rbx */ | ||
| 240 | pushq %rbp /* pt_regs->rbp */ | ||
| 241 | pushq %r12 /* pt_regs->r12 */ | ||
| 242 | pushq %r13 /* pt_regs->r13 */ | ||
| 243 | pushq %r14 /* pt_regs->r14 */ | ||
| 244 | pushq %r15 /* pt_regs->r15 */ | ||
| 245 | UNWIND_HINT_REGS | ||
| 246 | 232 | ||
| 247 | TRACE_IRQS_OFF | 233 | TRACE_IRQS_OFF |
| 248 | 234 | ||
| @@ -321,15 +307,7 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) | |||
| 321 | syscall_return_via_sysret: | 307 | syscall_return_via_sysret: |
| 322 | /* rcx and r11 are already restored (see code above) */ | 308 | /* rcx and r11 are already restored (see code above) */ |
| 323 | UNWIND_HINT_EMPTY | 309 | UNWIND_HINT_EMPTY |
| 324 | POP_EXTRA_REGS | 310 | POP_REGS pop_rdi=0 skip_r11rcx=1 |
| 325 | popq %rsi /* skip r11 */ | ||
| 326 | popq %r10 | ||
| 327 | popq %r9 | ||
| 328 | popq %r8 | ||
| 329 | popq %rax | ||
| 330 | popq %rsi /* skip rcx */ | ||
| 331 | popq %rdx | ||
| 332 | popq %rsi | ||
| 333 | 311 | ||
| 334 | /* | 312 | /* |
| 335 | * Now all regs are restored except RSP and RDI. | 313 | * Now all regs are restored except RSP and RDI. |
| @@ -559,9 +537,7 @@ END(irq_entries_start) | |||
| 559 | call switch_to_thread_stack | 537 | call switch_to_thread_stack |
| 560 | 1: | 538 | 1: |
| 561 | 539 | ||
| 562 | ALLOC_PT_GPREGS_ON_STACK | 540 | PUSH_AND_CLEAR_REGS |
| 563 | SAVE_C_REGS | ||
| 564 | SAVE_EXTRA_REGS | ||
| 565 | ENCODE_FRAME_POINTER | 541 | ENCODE_FRAME_POINTER |
| 566 | 542 | ||
| 567 | testb $3, CS(%rsp) | 543 | testb $3, CS(%rsp) |
| @@ -622,15 +598,7 @@ GLOBAL(swapgs_restore_regs_and_return_to_usermode) | |||
| 622 | ud2 | 598 | ud2 |
| 623 | 1: | 599 | 1: |
| 624 | #endif | 600 | #endif |
| 625 | POP_EXTRA_REGS | 601 | POP_REGS pop_rdi=0 |
| 626 | popq %r11 | ||
| 627 | popq %r10 | ||
| 628 | popq %r9 | ||
| 629 | popq %r8 | ||
| 630 | popq %rax | ||
| 631 | popq %rcx | ||
| 632 | popq %rdx | ||
| 633 | popq %rsi | ||
| 634 | 602 | ||
| 635 | /* | 603 | /* |
| 636 | * The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS. | 604 | * The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS. |
| @@ -688,8 +656,7 @@ GLOBAL(restore_regs_and_return_to_kernel) | |||
| 688 | ud2 | 656 | ud2 |
| 689 | 1: | 657 | 1: |
| 690 | #endif | 658 | #endif |
| 691 | POP_EXTRA_REGS | 659 | POP_REGS |
| 692 | POP_C_REGS | ||
| 693 | addq $8, %rsp /* skip regs->orig_ax */ | 660 | addq $8, %rsp /* skip regs->orig_ax */ |
| 694 | /* | 661 | /* |
| 695 | * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on IRET core serialization | 662 | * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on IRET core serialization |
| @@ -908,7 +875,9 @@ ENTRY(\sym) | |||
| 908 | pushq $-1 /* ORIG_RAX: no syscall to restart */ | 875 | pushq $-1 /* ORIG_RAX: no syscall to restart */ |
| 909 | .endif | 876 | .endif |
| 910 | 877 | ||
| 911 | ALLOC_PT_GPREGS_ON_STACK | 878 | /* Save all registers in pt_regs */ |
| 879 | PUSH_AND_CLEAR_REGS | ||
| 880 | ENCODE_FRAME_POINTER | ||
| 912 | 881 | ||
| 913 | .if \paranoid < 2 | 882 | .if \paranoid < 2 |
| 914 | testb $3, CS(%rsp) /* If coming from userspace, switch stacks */ | 883 | testb $3, CS(%rsp) /* If coming from userspace, switch stacks */ |
| @@ -1121,9 +1090,7 @@ ENTRY(xen_failsafe_callback) | |||
| 1121 | addq $0x30, %rsp | 1090 | addq $0x30, %rsp |
| 1122 | UNWIND_HINT_IRET_REGS | 1091 | UNWIND_HINT_IRET_REGS |
| 1123 | pushq $-1 /* orig_ax = -1 => not a system call */ | 1092 | pushq $-1 /* orig_ax = -1 => not a system call */ |
| 1124 | ALLOC_PT_GPREGS_ON_STACK | 1093 | PUSH_AND_CLEAR_REGS |
| 1125 | SAVE_C_REGS | ||
| 1126 | SAVE_EXTRA_REGS | ||
| 1127 | ENCODE_FRAME_POINTER | 1094 | ENCODE_FRAME_POINTER |
| 1128 | jmp error_exit | 1095 | jmp error_exit |
| 1129 | END(xen_failsafe_callback) | 1096 | END(xen_failsafe_callback) |
| @@ -1163,16 +1130,13 @@ idtentry machine_check do_mce has_error_code=0 paranoid=1 | |||
| 1163 | #endif | 1130 | #endif |
| 1164 | 1131 | ||
| 1165 | /* | 1132 | /* |
| 1166 | * Save all registers in pt_regs, and switch gs if needed. | 1133 | * Switch gs if needed. |
| 1167 | * Use slow, but surefire "are we in kernel?" check. | 1134 | * Use slow, but surefire "are we in kernel?" check. |
| 1168 | * Return: ebx=0: need swapgs on exit, ebx=1: otherwise | 1135 | * Return: ebx=0: need swapgs on exit, ebx=1: otherwise |
| 1169 | */ | 1136 | */ |
| 1170 | ENTRY(paranoid_entry) | 1137 | ENTRY(paranoid_entry) |
| 1171 | UNWIND_HINT_FUNC | 1138 | UNWIND_HINT_FUNC |
| 1172 | cld | 1139 | cld |
| 1173 | SAVE_C_REGS 8 | ||
| 1174 | SAVE_EXTRA_REGS 8 | ||
| 1175 | ENCODE_FRAME_POINTER 8 | ||
| 1176 | movl $1, %ebx | 1140 | movl $1, %ebx |
| 1177 | movl $MSR_GS_BASE, %ecx | 1141 | movl $MSR_GS_BASE, %ecx |
| 1178 | rdmsr | 1142 | rdmsr |
| @@ -1211,21 +1175,18 @@ ENTRY(paranoid_exit) | |||
| 1211 | jmp .Lparanoid_exit_restore | 1175 | jmp .Lparanoid_exit_restore |
| 1212 | .Lparanoid_exit_no_swapgs: | 1176 | .Lparanoid_exit_no_swapgs: |
| 1213 | TRACE_IRQS_IRETQ_DEBUG | 1177 | TRACE_IRQS_IRETQ_DEBUG |
| 1178 | RESTORE_CR3 scratch_reg=%rbx save_reg=%r14 | ||
| 1214 | .Lparanoid_exit_restore: | 1179 | .Lparanoid_exit_restore: |
| 1215 | jmp restore_regs_and_return_to_kernel | 1180 | jmp restore_regs_and_return_to_kernel |
| 1216 | END(paranoid_exit) | 1181 | END(paranoid_exit) |
| 1217 | 1182 | ||
| 1218 | /* | 1183 | /* |
| 1219 | * Save all registers in pt_regs, and switch gs if needed. | 1184 | * Switch gs if needed. |
| 1220 | * Return: EBX=0: came from user mode; EBX=1: otherwise | 1185 | * Return: EBX=0: came from user mode; EBX=1: otherwise |
| 1221 | */ | 1186 | */ |
| 1222 | ENTRY(error_entry) | 1187 | ENTRY(error_entry) |
| 1223 | UNWIND_HINT_FUNC | 1188 | UNWIND_HINT_REGS offset=8 |
| 1224 | cld | 1189 | cld |
| 1225 | SAVE_C_REGS 8 | ||
| 1226 | SAVE_EXTRA_REGS 8 | ||
| 1227 | ENCODE_FRAME_POINTER 8 | ||
| 1228 | xorl %ebx, %ebx | ||
| 1229 | testb $3, CS+8(%rsp) | 1190 | testb $3, CS+8(%rsp) |
| 1230 | jz .Lerror_kernelspace | 1191 | jz .Lerror_kernelspace |
| 1231 | 1192 | ||
| @@ -1406,22 +1367,7 @@ ENTRY(nmi) | |||
| 1406 | pushq 1*8(%rdx) /* pt_regs->rip */ | 1367 | pushq 1*8(%rdx) /* pt_regs->rip */ |
| 1407 | UNWIND_HINT_IRET_REGS | 1368 | UNWIND_HINT_IRET_REGS |
| 1408 | pushq $-1 /* pt_regs->orig_ax */ | 1369 | pushq $-1 /* pt_regs->orig_ax */ |
| 1409 | pushq %rdi /* pt_regs->di */ | 1370 | PUSH_AND_CLEAR_REGS rdx=(%rdx) |
| 1410 | pushq %rsi /* pt_regs->si */ | ||
| 1411 | pushq (%rdx) /* pt_regs->dx */ | ||
| 1412 | pushq %rcx /* pt_regs->cx */ | ||
| 1413 | pushq %rax /* pt_regs->ax */ | ||
| 1414 | pushq %r8 /* pt_regs->r8 */ | ||
| 1415 | pushq %r9 /* pt_regs->r9 */ | ||
| 1416 | pushq %r10 /* pt_regs->r10 */ | ||
| 1417 | pushq %r11 /* pt_regs->r11 */ | ||
| 1418 | pushq %rbx /* pt_regs->rbx */ | ||
| 1419 | pushq %rbp /* pt_regs->rbp */ | ||
| 1420 | pushq %r12 /* pt_regs->r12 */ | ||
| 1421 | pushq %r13 /* pt_regs->r13 */ | ||
| 1422 | pushq %r14 /* pt_regs->r14 */ | ||
| 1423 | pushq %r15 /* pt_regs->r15 */ | ||
| 1424 | UNWIND_HINT_REGS | ||
| 1425 | ENCODE_FRAME_POINTER | 1371 | ENCODE_FRAME_POINTER |
| 1426 | 1372 | ||
| 1427 | /* | 1373 | /* |
| @@ -1631,7 +1577,8 @@ end_repeat_nmi: | |||
| 1631 | * frame to point back to repeat_nmi. | 1577 | * frame to point back to repeat_nmi. |
| 1632 | */ | 1578 | */ |
| 1633 | pushq $-1 /* ORIG_RAX: no syscall to restart */ | 1579 | pushq $-1 /* ORIG_RAX: no syscall to restart */ |
| 1634 | ALLOC_PT_GPREGS_ON_STACK | 1580 | PUSH_AND_CLEAR_REGS |
| 1581 | ENCODE_FRAME_POINTER | ||
| 1635 | 1582 | ||
| 1636 | /* | 1583 | /* |
| 1637 | * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit | 1584 | * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit |
| @@ -1655,8 +1602,7 @@ end_repeat_nmi: | |||
| 1655 | nmi_swapgs: | 1602 | nmi_swapgs: |
| 1656 | SWAPGS_UNSAFE_STACK | 1603 | SWAPGS_UNSAFE_STACK |
| 1657 | nmi_restore: | 1604 | nmi_restore: |
| 1658 | POP_EXTRA_REGS | 1605 | POP_REGS |
| 1659 | POP_C_REGS | ||
| 1660 | 1606 | ||
| 1661 | /* | 1607 | /* |
| 1662 | * Skip orig_ax and the "outermost" frame to point RSP at the "iret" | 1608 | * Skip orig_ax and the "outermost" frame to point RSP at the "iret" |
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index 98d5358e4041..fd65e016e413 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S | |||
| @@ -85,15 +85,25 @@ ENTRY(entry_SYSENTER_compat) | |||
| 85 | pushq %rcx /* pt_regs->cx */ | 85 | pushq %rcx /* pt_regs->cx */ |
| 86 | pushq $-ENOSYS /* pt_regs->ax */ | 86 | pushq $-ENOSYS /* pt_regs->ax */ |
| 87 | pushq $0 /* pt_regs->r8 = 0 */ | 87 | pushq $0 /* pt_regs->r8 = 0 */ |
| 88 | xorq %r8, %r8 /* nospec r8 */ | ||
| 88 | pushq $0 /* pt_regs->r9 = 0 */ | 89 | pushq $0 /* pt_regs->r9 = 0 */ |
| 90 | xorq %r9, %r9 /* nospec r9 */ | ||
| 89 | pushq $0 /* pt_regs->r10 = 0 */ | 91 | pushq $0 /* pt_regs->r10 = 0 */ |
| 92 | xorq %r10, %r10 /* nospec r10 */ | ||
| 90 | pushq $0 /* pt_regs->r11 = 0 */ | 93 | pushq $0 /* pt_regs->r11 = 0 */ |
| 94 | xorq %r11, %r11 /* nospec r11 */ | ||
| 91 | pushq %rbx /* pt_regs->rbx */ | 95 | pushq %rbx /* pt_regs->rbx */ |
| 96 | xorl %ebx, %ebx /* nospec rbx */ | ||
| 92 | pushq %rbp /* pt_regs->rbp (will be overwritten) */ | 97 | pushq %rbp /* pt_regs->rbp (will be overwritten) */ |
| 98 | xorl %ebp, %ebp /* nospec rbp */ | ||
| 93 | pushq $0 /* pt_regs->r12 = 0 */ | 99 | pushq $0 /* pt_regs->r12 = 0 */ |
| 100 | xorq %r12, %r12 /* nospec r12 */ | ||
| 94 | pushq $0 /* pt_regs->r13 = 0 */ | 101 | pushq $0 /* pt_regs->r13 = 0 */ |
| 102 | xorq %r13, %r13 /* nospec r13 */ | ||
| 95 | pushq $0 /* pt_regs->r14 = 0 */ | 103 | pushq $0 /* pt_regs->r14 = 0 */ |
| 104 | xorq %r14, %r14 /* nospec r14 */ | ||
| 96 | pushq $0 /* pt_regs->r15 = 0 */ | 105 | pushq $0 /* pt_regs->r15 = 0 */ |
| 106 | xorq %r15, %r15 /* nospec r15 */ | ||
| 97 | cld | 107 | cld |
| 98 | 108 | ||
| 99 | /* | 109 | /* |
| @@ -214,15 +224,25 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe) | |||
| 214 | pushq %rbp /* pt_regs->cx (stashed in bp) */ | 224 | pushq %rbp /* pt_regs->cx (stashed in bp) */ |
| 215 | pushq $-ENOSYS /* pt_regs->ax */ | 225 | pushq $-ENOSYS /* pt_regs->ax */ |
| 216 | pushq $0 /* pt_regs->r8 = 0 */ | 226 | pushq $0 /* pt_regs->r8 = 0 */ |
| 227 | xorq %r8, %r8 /* nospec r8 */ | ||
| 217 | pushq $0 /* pt_regs->r9 = 0 */ | 228 | pushq $0 /* pt_regs->r9 = 0 */ |
| 229 | xorq %r9, %r9 /* nospec r9 */ | ||
| 218 | pushq $0 /* pt_regs->r10 = 0 */ | 230 | pushq $0 /* pt_regs->r10 = 0 */ |
| 231 | xorq %r10, %r10 /* nospec r10 */ | ||
| 219 | pushq $0 /* pt_regs->r11 = 0 */ | 232 | pushq $0 /* pt_regs->r11 = 0 */ |
| 233 | xorq %r11, %r11 /* nospec r11 */ | ||
| 220 | pushq %rbx /* pt_regs->rbx */ | 234 | pushq %rbx /* pt_regs->rbx */ |
| 235 | xorl %ebx, %ebx /* nospec rbx */ | ||
| 221 | pushq %rbp /* pt_regs->rbp (will be overwritten) */ | 236 | pushq %rbp /* pt_regs->rbp (will be overwritten) */ |
| 237 | xorl %ebp, %ebp /* nospec rbp */ | ||
| 222 | pushq $0 /* pt_regs->r12 = 0 */ | 238 | pushq $0 /* pt_regs->r12 = 0 */ |
| 239 | xorq %r12, %r12 /* nospec r12 */ | ||
| 223 | pushq $0 /* pt_regs->r13 = 0 */ | 240 | pushq $0 /* pt_regs->r13 = 0 */ |
| 241 | xorq %r13, %r13 /* nospec r13 */ | ||
| 224 | pushq $0 /* pt_regs->r14 = 0 */ | 242 | pushq $0 /* pt_regs->r14 = 0 */ |
| 243 | xorq %r14, %r14 /* nospec r14 */ | ||
| 225 | pushq $0 /* pt_regs->r15 = 0 */ | 244 | pushq $0 /* pt_regs->r15 = 0 */ |
| 245 | xorq %r15, %r15 /* nospec r15 */ | ||
| 226 | 246 | ||
| 227 | /* | 247 | /* |
| 228 | * User mode is traced as though IRQs are on, and SYSENTER | 248 | * User mode is traced as though IRQs are on, and SYSENTER |
| @@ -338,15 +358,25 @@ ENTRY(entry_INT80_compat) | |||
| 338 | pushq %rcx /* pt_regs->cx */ | 358 | pushq %rcx /* pt_regs->cx */ |
| 339 | pushq $-ENOSYS /* pt_regs->ax */ | 359 | pushq $-ENOSYS /* pt_regs->ax */ |
| 340 | pushq $0 /* pt_regs->r8 = 0 */ | 360 | pushq $0 /* pt_regs->r8 = 0 */ |
| 361 | xorq %r8, %r8 /* nospec r8 */ | ||
| 341 | pushq $0 /* pt_regs->r9 = 0 */ | 362 | pushq $0 /* pt_regs->r9 = 0 */ |
| 363 | xorq %r9, %r9 /* nospec r9 */ | ||
| 342 | pushq $0 /* pt_regs->r10 = 0 */ | 364 | pushq $0 /* pt_regs->r10 = 0 */ |
| 365 | xorq %r10, %r10 /* nospec r10 */ | ||
| 343 | pushq $0 /* pt_regs->r11 = 0 */ | 366 | pushq $0 /* pt_regs->r11 = 0 */ |
| 367 | xorq %r11, %r11 /* nospec r11 */ | ||
| 344 | pushq %rbx /* pt_regs->rbx */ | 368 | pushq %rbx /* pt_regs->rbx */ |
| 369 | xorl %ebx, %ebx /* nospec rbx */ | ||
| 345 | pushq %rbp /* pt_regs->rbp */ | 370 | pushq %rbp /* pt_regs->rbp */ |
| 371 | xorl %ebp, %ebp /* nospec rbp */ | ||
| 346 | pushq %r12 /* pt_regs->r12 */ | 372 | pushq %r12 /* pt_regs->r12 */ |
| 373 | xorq %r12, %r12 /* nospec r12 */ | ||
| 347 | pushq %r13 /* pt_regs->r13 */ | 374 | pushq %r13 /* pt_regs->r13 */ |
| 375 | xorq %r13, %r13 /* nospec r13 */ | ||
| 348 | pushq %r14 /* pt_regs->r14 */ | 376 | pushq %r14 /* pt_regs->r14 */ |
| 377 | xorq %r14, %r14 /* nospec r14 */ | ||
| 349 | pushq %r15 /* pt_regs->r15 */ | 378 | pushq %r15 /* pt_regs->r15 */ |
| 379 | xorq %r15, %r15 /* nospec r15 */ | ||
| 350 | cld | 380 | cld |
| 351 | 381 | ||
| 352 | /* | 382 | /* |
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 731153a4681e..56457cb73448 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c | |||
| @@ -3559,7 +3559,7 @@ static int intel_snb_pebs_broken(int cpu) | |||
| 3559 | break; | 3559 | break; |
| 3560 | 3560 | ||
| 3561 | case INTEL_FAM6_SANDYBRIDGE_X: | 3561 | case INTEL_FAM6_SANDYBRIDGE_X: |
| 3562 | switch (cpu_data(cpu).x86_mask) { | 3562 | switch (cpu_data(cpu).x86_stepping) { |
| 3563 | case 6: rev = 0x618; break; | 3563 | case 6: rev = 0x618; break; |
| 3564 | case 7: rev = 0x70c; break; | 3564 | case 7: rev = 0x70c; break; |
| 3565 | } | 3565 | } |
diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index ae64d0b69729..cf372b90557e 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c | |||
| @@ -1186,7 +1186,7 @@ void __init intel_pmu_lbr_init_atom(void) | |||
| 1186 | * on PMU interrupt | 1186 | * on PMU interrupt |
| 1187 | */ | 1187 | */ |
| 1188 | if (boot_cpu_data.x86_model == 28 | 1188 | if (boot_cpu_data.x86_model == 28 |
| 1189 | && boot_cpu_data.x86_mask < 10) { | 1189 | && boot_cpu_data.x86_stepping < 10) { |
| 1190 | pr_cont("LBR disabled due to erratum"); | 1190 | pr_cont("LBR disabled due to erratum"); |
| 1191 | return; | 1191 | return; |
| 1192 | } | 1192 | } |
diff --git a/arch/x86/events/intel/p6.c b/arch/x86/events/intel/p6.c index a5604c352930..408879b0c0d4 100644 --- a/arch/x86/events/intel/p6.c +++ b/arch/x86/events/intel/p6.c | |||
| @@ -234,7 +234,7 @@ static __initconst const struct x86_pmu p6_pmu = { | |||
| 234 | 234 | ||
| 235 | static __init void p6_pmu_rdpmc_quirk(void) | 235 | static __init void p6_pmu_rdpmc_quirk(void) |
| 236 | { | 236 | { |
| 237 | if (boot_cpu_data.x86_mask < 9) { | 237 | if (boot_cpu_data.x86_stepping < 9) { |
| 238 | /* | 238 | /* |
| 239 | * PPro erratum 26; fixed in stepping 9 and above. | 239 | * PPro erratum 26; fixed in stepping 9 and above. |
| 240 | */ | 240 | */ |
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 44f5d79d5105..11881726ed37 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h | |||
| @@ -94,7 +94,7 @@ static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate) | |||
| 94 | if (boot_cpu_data.x86 == 0x0F && | 94 | if (boot_cpu_data.x86 == 0x0F && |
| 95 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD && | 95 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD && |
| 96 | boot_cpu_data.x86_model <= 0x05 && | 96 | boot_cpu_data.x86_model <= 0x05 && |
| 97 | boot_cpu_data.x86_mask < 0x0A) | 97 | boot_cpu_data.x86_stepping < 0x0A) |
| 98 | return 1; | 98 | return 1; |
| 99 | else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E)) | 99 | else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E)) |
| 100 | return 1; | 100 | return 1; |
diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index 30d406146016..e1259f043ae9 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h | |||
| @@ -40,7 +40,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, | |||
| 40 | 40 | ||
| 41 | asm ("cmp %1,%2; sbb %0,%0;" | 41 | asm ("cmp %1,%2; sbb %0,%0;" |
| 42 | :"=r" (mask) | 42 | :"=r" (mask) |
| 43 | :"r"(size),"r" (index) | 43 | :"g"(size),"r" (index) |
| 44 | :"cc"); | 44 | :"cc"); |
| 45 | return mask; | 45 | return mask; |
| 46 | } | 46 | } |
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 34d99af43994..6804d6642767 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h | |||
| @@ -5,23 +5,20 @@ | |||
| 5 | #include <linux/stringify.h> | 5 | #include <linux/stringify.h> |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Since some emulators terminate on UD2, we cannot use it for WARN. | 8 | * Despite that some emulators terminate on UD2, we use it for WARN(). |
| 9 | * Since various instruction decoders disagree on the length of UD1, | ||
| 10 | * we cannot use it either. So use UD0 for WARN. | ||
| 11 | * | 9 | * |
| 12 | * (binutils knows about "ud1" but {en,de}codes it as 2 bytes, whereas | 10 | * Since various instruction decoders/specs disagree on the encoding of |
| 13 | * our kernel decoder thinks it takes a ModRM byte, which seems consistent | 11 | * UD0/UD1. |
| 14 | * with various things like the Intel SDM instruction encoding rules) | ||
| 15 | */ | 12 | */ |
| 16 | 13 | ||
| 17 | #define ASM_UD0 ".byte 0x0f, 0xff" | 14 | #define ASM_UD0 ".byte 0x0f, 0xff" /* + ModRM (for Intel) */ |
| 18 | #define ASM_UD1 ".byte 0x0f, 0xb9" /* + ModRM */ | 15 | #define ASM_UD1 ".byte 0x0f, 0xb9" /* + ModRM */ |
| 19 | #define ASM_UD2 ".byte 0x0f, 0x0b" | 16 | #define ASM_UD2 ".byte 0x0f, 0x0b" |
| 20 | 17 | ||
| 21 | #define INSN_UD0 0xff0f | 18 | #define INSN_UD0 0xff0f |
| 22 | #define INSN_UD2 0x0b0f | 19 | #define INSN_UD2 0x0b0f |
| 23 | 20 | ||
| 24 | #define LEN_UD0 2 | 21 | #define LEN_UD2 2 |
| 25 | 22 | ||
| 26 | #ifdef CONFIG_GENERIC_BUG | 23 | #ifdef CONFIG_GENERIC_BUG |
| 27 | 24 | ||
| @@ -77,7 +74,11 @@ do { \ | |||
| 77 | unreachable(); \ | 74 | unreachable(); \ |
| 78 | } while (0) | 75 | } while (0) |
| 79 | 76 | ||
| 80 | #define __WARN_FLAGS(flags) _BUG_FLAGS(ASM_UD0, BUGFLAG_WARNING|(flags)) | 77 | #define __WARN_FLAGS(flags) \ |
| 78 | do { \ | ||
| 79 | _BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \ | ||
| 80 | annotate_reachable(); \ | ||
| 81 | } while (0) | ||
| 81 | 82 | ||
| 82 | #include <asm-generic/bug.h> | 83 | #include <asm-generic/bug.h> |
| 83 | 84 | ||
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 70eddb3922ff..736771c9822e 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
| @@ -148,45 +148,46 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); | |||
| 148 | */ | 148 | */ |
| 149 | static __always_inline __pure bool _static_cpu_has(u16 bit) | 149 | static __always_inline __pure bool _static_cpu_has(u16 bit) |
| 150 | { | 150 | { |
| 151 | asm_volatile_goto("1: jmp 6f\n" | 151 | asm_volatile_goto("1: jmp 6f\n" |
| 152 | "2:\n" | 152 | "2:\n" |
| 153 | ".skip -(((5f-4f) - (2b-1b)) > 0) * " | 153 | ".skip -(((5f-4f) - (2b-1b)) > 0) * " |
| 154 | "((5f-4f) - (2b-1b)),0x90\n" | 154 | "((5f-4f) - (2b-1b)),0x90\n" |
| 155 | "3:\n" | 155 | "3:\n" |
| 156 | ".section .altinstructions,\"a\"\n" | 156 | ".section .altinstructions,\"a\"\n" |
| 157 | " .long 1b - .\n" /* src offset */ | 157 | " .long 1b - .\n" /* src offset */ |
| 158 | " .long 4f - .\n" /* repl offset */ | 158 | " .long 4f - .\n" /* repl offset */ |
| 159 | " .word %P1\n" /* always replace */ | 159 | " .word %P[always]\n" /* always replace */ |
| 160 | " .byte 3b - 1b\n" /* src len */ | 160 | " .byte 3b - 1b\n" /* src len */ |
| 161 | " .byte 5f - 4f\n" /* repl len */ | 161 | " .byte 5f - 4f\n" /* repl len */ |
| 162 | " .byte 3b - 2b\n" /* pad len */ | 162 | " .byte 3b - 2b\n" /* pad len */ |
| 163 | ".previous\n" | 163 | ".previous\n" |
| 164 | ".section .altinstr_replacement,\"ax\"\n" | 164 | ".section .altinstr_replacement,\"ax\"\n" |
| 165 | "4: jmp %l[t_no]\n" | 165 | "4: jmp %l[t_no]\n" |
| 166 | "5:\n" | 166 | "5:\n" |
| 167 | ".previous\n" | 167 | ".previous\n" |
| 168 | ".section .altinstructions,\"a\"\n" | 168 | ".section .altinstructions,\"a\"\n" |
| 169 | " .long 1b - .\n" /* src offset */ | 169 | " .long 1b - .\n" /* src offset */ |
| 170 | " .long 0\n" /* no replacement */ | 170 | " .long 0\n" /* no replacement */ |
| 171 | " .word %P0\n" /* feature bit */ | 171 | " .word %P[feature]\n" /* feature bit */ |
| 172 | " .byte 3b - 1b\n" /* src len */ | 172 | " .byte 3b - 1b\n" /* src len */ |
| 173 | " .byte 0\n" /* repl len */ | 173 | " .byte 0\n" /* repl len */ |
| 174 | " .byte 0\n" /* pad len */ | 174 | " .byte 0\n" /* pad len */ |
| 175 | ".previous\n" | 175 | ".previous\n" |
| 176 | ".section .altinstr_aux,\"ax\"\n" | 176 | ".section .altinstr_aux,\"ax\"\n" |
| 177 | "6:\n" | 177 | "6:\n" |
| 178 | " testb %[bitnum],%[cap_byte]\n" | 178 | " testb %[bitnum],%[cap_byte]\n" |
| 179 | " jnz %l[t_yes]\n" | 179 | " jnz %l[t_yes]\n" |
| 180 | " jmp %l[t_no]\n" | 180 | " jmp %l[t_no]\n" |
| 181 | ".previous\n" | 181 | ".previous\n" |
| 182 | : : "i" (bit), "i" (X86_FEATURE_ALWAYS), | 182 | : : [feature] "i" (bit), |
| 183 | [bitnum] "i" (1 << (bit & 7)), | 183 | [always] "i" (X86_FEATURE_ALWAYS), |
| 184 | [cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3]) | 184 | [bitnum] "i" (1 << (bit & 7)), |
| 185 | : : t_yes, t_no); | 185 | [cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3]) |
| 186 | t_yes: | 186 | : : t_yes, t_no); |
| 187 | return true; | 187 | t_yes: |
| 188 | t_no: | 188 | return true; |
| 189 | return false; | 189 | t_no: |
| 190 | return false; | ||
| 190 | } | 191 | } |
| 191 | 192 | ||
| 192 | #define static_cpu_has(bit) \ | 193 | #define static_cpu_has(bit) \ |
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 4d57894635f2..76b058533e47 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <asm/alternative.h> | 6 | #include <asm/alternative.h> |
| 7 | #include <asm/alternative-asm.h> | 7 | #include <asm/alternative-asm.h> |
| 8 | #include <asm/cpufeatures.h> | 8 | #include <asm/cpufeatures.h> |
| 9 | #include <asm/msr-index.h> | ||
| 9 | 10 | ||
| 10 | #ifdef __ASSEMBLY__ | 11 | #ifdef __ASSEMBLY__ |
| 11 | 12 | ||
| @@ -164,10 +165,15 @@ static inline void vmexit_fill_RSB(void) | |||
| 164 | 165 | ||
| 165 | static inline void indirect_branch_prediction_barrier(void) | 166 | static inline void indirect_branch_prediction_barrier(void) |
| 166 | { | 167 | { |
| 167 | alternative_input("", | 168 | asm volatile(ALTERNATIVE("", |
| 168 | "call __ibp_barrier", | 169 | "movl %[msr], %%ecx\n\t" |
| 169 | X86_FEATURE_USE_IBPB, | 170 | "movl %[val], %%eax\n\t" |
| 170 | ASM_NO_INPUT_CLOBBER("eax", "ecx", "edx", "memory")); | 171 | "movl $0, %%edx\n\t" |
| 172 | "wrmsr", | ||
| 173 | X86_FEATURE_USE_IBPB) | ||
| 174 | : : [msr] "i" (MSR_IA32_PRED_CMD), | ||
| 175 | [val] "i" (PRED_CMD_IBPB) | ||
| 176 | : "eax", "ecx", "edx", "memory"); | ||
| 171 | } | 177 | } |
| 172 | 178 | ||
| 173 | #endif /* __ASSEMBLY__ */ | 179 | #endif /* __ASSEMBLY__ */ |
diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h index 4baa6bceb232..d652a3808065 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h | |||
| @@ -52,10 +52,6 @@ static inline void clear_page(void *page) | |||
| 52 | 52 | ||
| 53 | void copy_page(void *to, void *from); | 53 | void copy_page(void *to, void *from); |
| 54 | 54 | ||
| 55 | #ifdef CONFIG_X86_MCE | ||
| 56 | #define arch_unmap_kpfn arch_unmap_kpfn | ||
| 57 | #endif | ||
| 58 | |||
| 59 | #endif /* !__ASSEMBLY__ */ | 55 | #endif /* !__ASSEMBLY__ */ |
| 60 | 56 | ||
| 61 | #ifdef CONFIG_X86_VSYSCALL_EMULATION | 57 | #ifdef CONFIG_X86_VSYSCALL_EMULATION |
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index 892df375b615..554841fab717 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h | |||
| @@ -297,9 +297,9 @@ static inline void __flush_tlb_global(void) | |||
| 297 | { | 297 | { |
| 298 | PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel); | 298 | PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel); |
| 299 | } | 299 | } |
| 300 | static inline void __flush_tlb_single(unsigned long addr) | 300 | static inline void __flush_tlb_one_user(unsigned long addr) |
| 301 | { | 301 | { |
| 302 | PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr); | 302 | PVOP_VCALL1(pv_mmu_ops.flush_tlb_one_user, addr); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | static inline void flush_tlb_others(const struct cpumask *cpumask, | 305 | static inline void flush_tlb_others(const struct cpumask *cpumask, |
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index 6ec54d01972d..f624f1f10316 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h | |||
| @@ -217,7 +217,7 @@ struct pv_mmu_ops { | |||
| 217 | /* TLB operations */ | 217 | /* TLB operations */ |
| 218 | void (*flush_tlb_user)(void); | 218 | void (*flush_tlb_user)(void); |
| 219 | void (*flush_tlb_kernel)(void); | 219 | void (*flush_tlb_kernel)(void); |
| 220 | void (*flush_tlb_single)(unsigned long addr); | 220 | void (*flush_tlb_one_user)(unsigned long addr); |
| 221 | void (*flush_tlb_others)(const struct cpumask *cpus, | 221 | void (*flush_tlb_others)(const struct cpumask *cpus, |
| 222 | const struct flush_tlb_info *info); | 222 | const struct flush_tlb_info *info); |
| 223 | 223 | ||
diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h index e67c0620aec2..e55466760ff8 100644 --- a/arch/x86/include/asm/pgtable_32.h +++ b/arch/x86/include/asm/pgtable_32.h | |||
| @@ -61,7 +61,7 @@ void paging_init(void); | |||
| 61 | #define kpte_clear_flush(ptep, vaddr) \ | 61 | #define kpte_clear_flush(ptep, vaddr) \ |
| 62 | do { \ | 62 | do { \ |
| 63 | pte_clear(&init_mm, (vaddr), (ptep)); \ | 63 | pte_clear(&init_mm, (vaddr), (ptep)); \ |
| 64 | __flush_tlb_one((vaddr)); \ | 64 | __flush_tlb_one_kernel((vaddr)); \ |
| 65 | } while (0) | 65 | } while (0) |
| 66 | 66 | ||
| 67 | #endif /* !__ASSEMBLY__ */ | 67 | #endif /* !__ASSEMBLY__ */ |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 793bae7e7ce3..1bd9ed87606f 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
| @@ -91,7 +91,7 @@ struct cpuinfo_x86 { | |||
| 91 | __u8 x86; /* CPU family */ | 91 | __u8 x86; /* CPU family */ |
| 92 | __u8 x86_vendor; /* CPU vendor */ | 92 | __u8 x86_vendor; /* CPU vendor */ |
| 93 | __u8 x86_model; | 93 | __u8 x86_model; |
| 94 | __u8 x86_mask; | 94 | __u8 x86_stepping; |
| 95 | #ifdef CONFIG_X86_64 | 95 | #ifdef CONFIG_X86_64 |
| 96 | /* Number of 4K pages in DTLB/ITLB combined(in pages): */ | 96 | /* Number of 4K pages in DTLB/ITLB combined(in pages): */ |
| 97 | int x86_tlbsize; | 97 | int x86_tlbsize; |
| @@ -109,7 +109,7 @@ struct cpuinfo_x86 { | |||
| 109 | char x86_vendor_id[16]; | 109 | char x86_vendor_id[16]; |
| 110 | char x86_model_id[64]; | 110 | char x86_model_id[64]; |
| 111 | /* in KB - valid for CPUS which support this call: */ | 111 | /* in KB - valid for CPUS which support this call: */ |
| 112 | int x86_cache_size; | 112 | unsigned int x86_cache_size; |
| 113 | int x86_cache_alignment; /* In bytes */ | 113 | int x86_cache_alignment; /* In bytes */ |
| 114 | /* Cache QoS architectural values: */ | 114 | /* Cache QoS architectural values: */ |
| 115 | int x86_cache_max_rmid; /* max index */ | 115 | int x86_cache_max_rmid; /* max index */ |
| @@ -977,7 +977,4 @@ bool xen_set_default_idle(void); | |||
| 977 | 977 | ||
| 978 | void stop_this_cpu(void *dummy); | 978 | void stop_this_cpu(void *dummy); |
| 979 | void df_debug(struct pt_regs *regs, long error_code); | 979 | void df_debug(struct pt_regs *regs, long error_code); |
| 980 | |||
| 981 | void __ibp_barrier(void); | ||
| 982 | |||
| 983 | #endif /* _ASM_X86_PROCESSOR_H */ | 980 | #endif /* _ASM_X86_PROCESSOR_H */ |
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 461f53d27708..a4189762b266 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
| @@ -129,6 +129,7 @@ static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask) | |||
| 129 | void cpu_disable_common(void); | 129 | void cpu_disable_common(void); |
| 130 | void native_smp_prepare_boot_cpu(void); | 130 | void native_smp_prepare_boot_cpu(void); |
| 131 | void native_smp_prepare_cpus(unsigned int max_cpus); | 131 | void native_smp_prepare_cpus(unsigned int max_cpus); |
| 132 | void calculate_max_logical_packages(void); | ||
| 132 | void native_smp_cpus_done(unsigned int max_cpus); | 133 | void native_smp_cpus_done(unsigned int max_cpus); |
| 133 | void common_cpu_up(unsigned int cpunum, struct task_struct *tidle); | 134 | void common_cpu_up(unsigned int cpunum, struct task_struct *tidle); |
| 134 | int native_cpu_up(unsigned int cpunum, struct task_struct *tidle); | 135 | int native_cpu_up(unsigned int cpunum, struct task_struct *tidle); |
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 2b8f18ca5874..84137c22fdfa 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h | |||
| @@ -140,7 +140,7 @@ static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid) | |||
| 140 | #else | 140 | #else |
| 141 | #define __flush_tlb() __native_flush_tlb() | 141 | #define __flush_tlb() __native_flush_tlb() |
| 142 | #define __flush_tlb_global() __native_flush_tlb_global() | 142 | #define __flush_tlb_global() __native_flush_tlb_global() |
| 143 | #define __flush_tlb_single(addr) __native_flush_tlb_single(addr) | 143 | #define __flush_tlb_one_user(addr) __native_flush_tlb_one_user(addr) |
| 144 | #endif | 144 | #endif |
| 145 | 145 | ||
| 146 | static inline bool tlb_defer_switch_to_init_mm(void) | 146 | static inline bool tlb_defer_switch_to_init_mm(void) |
| @@ -400,7 +400,7 @@ static inline void __native_flush_tlb_global(void) | |||
| 400 | /* | 400 | /* |
| 401 | * flush one page in the user mapping | 401 | * flush one page in the user mapping |
| 402 | */ | 402 | */ |
| 403 | static inline void __native_flush_tlb_single(unsigned long addr) | 403 | static inline void __native_flush_tlb_one_user(unsigned long addr) |
| 404 | { | 404 | { |
| 405 | u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid); | 405 | u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid); |
| 406 | 406 | ||
| @@ -437,18 +437,31 @@ static inline void __flush_tlb_all(void) | |||
| 437 | /* | 437 | /* |
| 438 | * flush one page in the kernel mapping | 438 | * flush one page in the kernel mapping |
| 439 | */ | 439 | */ |
| 440 | static inline void __flush_tlb_one(unsigned long addr) | 440 | static inline void __flush_tlb_one_kernel(unsigned long addr) |
| 441 | { | 441 | { |
| 442 | count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE); | 442 | count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE); |
| 443 | __flush_tlb_single(addr); | 443 | |
| 444 | /* | ||
| 445 | * If PTI is off, then __flush_tlb_one_user() is just INVLPG or its | ||
| 446 | * paravirt equivalent. Even with PCID, this is sufficient: we only | ||
| 447 | * use PCID if we also use global PTEs for the kernel mapping, and | ||
| 448 | * INVLPG flushes global translations across all address spaces. | ||
| 449 | * | ||
| 450 | * If PTI is on, then the kernel is mapped with non-global PTEs, and | ||
| 451 | * __flush_tlb_one_user() will flush the given address for the current | ||
| 452 | * kernel address space and for its usermode counterpart, but it does | ||
| 453 | * not flush it for other address spaces. | ||
| 454 | */ | ||
| 455 | __flush_tlb_one_user(addr); | ||
| 444 | 456 | ||
| 445 | if (!static_cpu_has(X86_FEATURE_PTI)) | 457 | if (!static_cpu_has(X86_FEATURE_PTI)) |
| 446 | return; | 458 | return; |
| 447 | 459 | ||
| 448 | /* | 460 | /* |
| 449 | * __flush_tlb_single() will have cleared the TLB entry for this ASID, | 461 | * See above. We need to propagate the flush to all other address |
| 450 | * but since kernel space is replicated across all, we must also | 462 | * spaces. In principle, we only need to propagate it to kernelmode |
| 451 | * invalidate all others. | 463 | * address spaces, but the extra bookkeeping we would need is not |
| 464 | * worth it. | ||
| 452 | */ | 465 | */ |
| 453 | invalidate_other_asid(); | 466 | invalidate_other_asid(); |
| 454 | } | 467 | } |
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 6db28f17ff28..c88e0b127810 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c | |||
| @@ -235,7 +235,7 @@ int amd_cache_northbridges(void) | |||
| 235 | if (boot_cpu_data.x86 == 0x10 && | 235 | if (boot_cpu_data.x86 == 0x10 && |
| 236 | boot_cpu_data.x86_model >= 0x8 && | 236 | boot_cpu_data.x86_model >= 0x8 && |
| 237 | (boot_cpu_data.x86_model > 0x9 || | 237 | (boot_cpu_data.x86_model > 0x9 || |
| 238 | boot_cpu_data.x86_mask >= 0x1)) | 238 | boot_cpu_data.x86_stepping >= 0x1)) |
| 239 | amd_northbridges.flags |= AMD_NB_L3_INDEX_DISABLE; | 239 | amd_northbridges.flags |= AMD_NB_L3_INDEX_DISABLE; |
| 240 | 240 | ||
| 241 | if (boot_cpu_data.x86 == 0x15) | 241 | if (boot_cpu_data.x86 == 0x15) |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 25ddf02598d2..b203af0855b5 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
| @@ -546,7 +546,7 @@ static DEFINE_PER_CPU(struct clock_event_device, lapic_events); | |||
| 546 | 546 | ||
| 547 | static u32 hsx_deadline_rev(void) | 547 | static u32 hsx_deadline_rev(void) |
| 548 | { | 548 | { |
| 549 | switch (boot_cpu_data.x86_mask) { | 549 | switch (boot_cpu_data.x86_stepping) { |
| 550 | case 0x02: return 0x3a; /* EP */ | 550 | case 0x02: return 0x3a; /* EP */ |
| 551 | case 0x04: return 0x0f; /* EX */ | 551 | case 0x04: return 0x0f; /* EX */ |
| 552 | } | 552 | } |
| @@ -556,7 +556,7 @@ static u32 hsx_deadline_rev(void) | |||
| 556 | 556 | ||
| 557 | static u32 bdx_deadline_rev(void) | 557 | static u32 bdx_deadline_rev(void) |
| 558 | { | 558 | { |
| 559 | switch (boot_cpu_data.x86_mask) { | 559 | switch (boot_cpu_data.x86_stepping) { |
| 560 | case 0x02: return 0x00000011; | 560 | case 0x02: return 0x00000011; |
| 561 | case 0x03: return 0x0700000e; | 561 | case 0x03: return 0x0700000e; |
| 562 | case 0x04: return 0x0f00000c; | 562 | case 0x04: return 0x0f00000c; |
| @@ -568,7 +568,7 @@ static u32 bdx_deadline_rev(void) | |||
| 568 | 568 | ||
| 569 | static u32 skx_deadline_rev(void) | 569 | static u32 skx_deadline_rev(void) |
| 570 | { | 570 | { |
| 571 | switch (boot_cpu_data.x86_mask) { | 571 | switch (boot_cpu_data.x86_stepping) { |
| 572 | case 0x03: return 0x01000136; | 572 | case 0x03: return 0x01000136; |
| 573 | case 0x04: return 0x02000014; | 573 | case 0x04: return 0x02000014; |
| 574 | } | 574 | } |
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 46b675aaf20b..f11910b44638 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
| @@ -1176,16 +1176,25 @@ static void __init decode_gam_rng_tbl(unsigned long ptr) | |||
| 1176 | 1176 | ||
| 1177 | uv_gre_table = gre; | 1177 | uv_gre_table = gre; |
| 1178 | for (; gre->type != UV_GAM_RANGE_TYPE_UNUSED; gre++) { | 1178 | for (; gre->type != UV_GAM_RANGE_TYPE_UNUSED; gre++) { |
| 1179 | unsigned long size = ((unsigned long)(gre->limit - lgre) | ||
| 1180 | << UV_GAM_RANGE_SHFT); | ||
| 1181 | int order = 0; | ||
| 1182 | char suffix[] = " KMGTPE"; | ||
| 1183 | |||
| 1184 | while (size > 9999 && order < sizeof(suffix)) { | ||
| 1185 | size /= 1024; | ||
| 1186 | order++; | ||
| 1187 | } | ||
| 1188 | |||
| 1179 | if (!index) { | 1189 | if (!index) { |
| 1180 | pr_info("UV: GAM Range Table...\n"); | 1190 | pr_info("UV: GAM Range Table...\n"); |
| 1181 | pr_info("UV: # %20s %14s %5s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN"); | 1191 | pr_info("UV: # %20s %14s %5s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN"); |
| 1182 | } | 1192 | } |
| 1183 | pr_info("UV: %2d: 0x%014lx-0x%014lx %5luG %3d %04x %02x %02x\n", | 1193 | pr_info("UV: %2d: 0x%014lx-0x%014lx %5lu%c %3d %04x %02x %02x\n", |
| 1184 | index++, | 1194 | index++, |
| 1185 | (unsigned long)lgre << UV_GAM_RANGE_SHFT, | 1195 | (unsigned long)lgre << UV_GAM_RANGE_SHFT, |
| 1186 | (unsigned long)gre->limit << UV_GAM_RANGE_SHFT, | 1196 | (unsigned long)gre->limit << UV_GAM_RANGE_SHFT, |
| 1187 | ((unsigned long)(gre->limit - lgre)) >> | 1197 | size, suffix[order], |
| 1188 | (30 - UV_GAM_RANGE_SHFT), /* 64M -> 1G */ | ||
| 1189 | gre->type, gre->nasid, gre->sockid, gre->pnode); | 1198 | gre->type, gre->nasid, gre->sockid, gre->pnode); |
| 1190 | 1199 | ||
| 1191 | lgre = gre->limit; | 1200 | lgre = gre->limit; |
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index fa1261eefa16..f91ba53e06c8 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c | |||
| @@ -18,7 +18,7 @@ void foo(void) | |||
| 18 | OFFSET(CPUINFO_x86, cpuinfo_x86, x86); | 18 | OFFSET(CPUINFO_x86, cpuinfo_x86, x86); |
| 19 | OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor); | 19 | OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor); |
| 20 | OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model); | 20 | OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model); |
| 21 | OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask); | 21 | OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping); |
| 22 | OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level); | 22 | OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level); |
| 23 | OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability); | 23 | OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability); |
| 24 | OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id); | 24 | OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id); |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 5bddbdcbc4a3..f0e6456ca7d3 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -119,7 +119,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c) | |||
| 119 | return; | 119 | return; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | if (c->x86_model == 6 && c->x86_mask == 1) { | 122 | if (c->x86_model == 6 && c->x86_stepping == 1) { |
| 123 | const int K6_BUG_LOOP = 1000000; | 123 | const int K6_BUG_LOOP = 1000000; |
| 124 | int n; | 124 | int n; |
| 125 | void (*f_vide)(void); | 125 | void (*f_vide)(void); |
| @@ -149,7 +149,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c) | |||
| 149 | 149 | ||
| 150 | /* K6 with old style WHCR */ | 150 | /* K6 with old style WHCR */ |
| 151 | if (c->x86_model < 8 || | 151 | if (c->x86_model < 8 || |
| 152 | (c->x86_model == 8 && c->x86_mask < 8)) { | 152 | (c->x86_model == 8 && c->x86_stepping < 8)) { |
| 153 | /* We can only write allocate on the low 508Mb */ | 153 | /* We can only write allocate on the low 508Mb */ |
| 154 | if (mbytes > 508) | 154 | if (mbytes > 508) |
| 155 | mbytes = 508; | 155 | mbytes = 508; |
| @@ -168,7 +168,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c) | |||
| 168 | return; | 168 | return; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | if ((c->x86_model == 8 && c->x86_mask > 7) || | 171 | if ((c->x86_model == 8 && c->x86_stepping > 7) || |
| 172 | c->x86_model == 9 || c->x86_model == 13) { | 172 | c->x86_model == 9 || c->x86_model == 13) { |
| 173 | /* The more serious chips .. */ | 173 | /* The more serious chips .. */ |
| 174 | 174 | ||
| @@ -221,7 +221,7 @@ static void init_amd_k7(struct cpuinfo_x86 *c) | |||
| 221 | * are more robust with CLK_CTL set to 200xxxxx instead of 600xxxxx | 221 | * are more robust with CLK_CTL set to 200xxxxx instead of 600xxxxx |
| 222 | * As per AMD technical note 27212 0.2 | 222 | * As per AMD technical note 27212 0.2 |
| 223 | */ | 223 | */ |
| 224 | if ((c->x86_model == 8 && c->x86_mask >= 1) || (c->x86_model > 8)) { | 224 | if ((c->x86_model == 8 && c->x86_stepping >= 1) || (c->x86_model > 8)) { |
| 225 | rdmsr(MSR_K7_CLK_CTL, l, h); | 225 | rdmsr(MSR_K7_CLK_CTL, l, h); |
| 226 | if ((l & 0xfff00000) != 0x20000000) { | 226 | if ((l & 0xfff00000) != 0x20000000) { |
| 227 | pr_info("CPU: CLK_CTL MSR was %x. Reprogramming to %x\n", | 227 | pr_info("CPU: CLK_CTL MSR was %x. Reprogramming to %x\n", |
| @@ -241,12 +241,12 @@ static void init_amd_k7(struct cpuinfo_x86 *c) | |||
| 241 | * but they are not certified as MP capable. | 241 | * but they are not certified as MP capable. |
| 242 | */ | 242 | */ |
| 243 | /* Athlon 660/661 is valid. */ | 243 | /* Athlon 660/661 is valid. */ |
| 244 | if ((c->x86_model == 6) && ((c->x86_mask == 0) || | 244 | if ((c->x86_model == 6) && ((c->x86_stepping == 0) || |
| 245 | (c->x86_mask == 1))) | 245 | (c->x86_stepping == 1))) |
| 246 | return; | 246 | return; |
| 247 | 247 | ||
| 248 | /* Duron 670 is valid */ | 248 | /* Duron 670 is valid */ |
| 249 | if ((c->x86_model == 7) && (c->x86_mask == 0)) | 249 | if ((c->x86_model == 7) && (c->x86_stepping == 0)) |
| 250 | return; | 250 | return; |
| 251 | 251 | ||
| 252 | /* | 252 | /* |
| @@ -256,8 +256,8 @@ static void init_amd_k7(struct cpuinfo_x86 *c) | |||
| 256 | * See http://www.heise.de/newsticker/data/jow-18.10.01-000 for | 256 | * See http://www.heise.de/newsticker/data/jow-18.10.01-000 for |
| 257 | * more. | 257 | * more. |
| 258 | */ | 258 | */ |
| 259 | if (((c->x86_model == 6) && (c->x86_mask >= 2)) || | 259 | if (((c->x86_model == 6) && (c->x86_stepping >= 2)) || |
| 260 | ((c->x86_model == 7) && (c->x86_mask >= 1)) || | 260 | ((c->x86_model == 7) && (c->x86_stepping >= 1)) || |
| 261 | (c->x86_model > 7)) | 261 | (c->x86_model > 7)) |
| 262 | if (cpu_has(c, X86_FEATURE_MP)) | 262 | if (cpu_has(c, X86_FEATURE_MP)) |
| 263 | return; | 263 | return; |
| @@ -628,7 +628,7 @@ static void early_init_amd(struct cpuinfo_x86 *c) | |||
| 628 | /* Set MTRR capability flag if appropriate */ | 628 | /* Set MTRR capability flag if appropriate */ |
| 629 | if (c->x86 == 5) | 629 | if (c->x86 == 5) |
| 630 | if (c->x86_model == 13 || c->x86_model == 9 || | 630 | if (c->x86_model == 13 || c->x86_model == 9 || |
| 631 | (c->x86_model == 8 && c->x86_mask >= 8)) | 631 | (c->x86_model == 8 && c->x86_stepping >= 8)) |
| 632 | set_cpu_cap(c, X86_FEATURE_K6_MTRR); | 632 | set_cpu_cap(c, X86_FEATURE_K6_MTRR); |
| 633 | #endif | 633 | #endif |
| 634 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_PCI) | 634 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_PCI) |
| @@ -795,7 +795,7 @@ static void init_amd_zn(struct cpuinfo_x86 *c) | |||
| 795 | * Fix erratum 1076: CPB feature bit not being set in CPUID. It affects | 795 | * Fix erratum 1076: CPB feature bit not being set in CPUID. It affects |
| 796 | * all up to and including B1. | 796 | * all up to and including B1. |
| 797 | */ | 797 | */ |
| 798 | if (c->x86_model <= 1 && c->x86_mask <= 1) | 798 | if (c->x86_model <= 1 && c->x86_stepping <= 1) |
| 799 | set_cpu_cap(c, X86_FEATURE_CPB); | 799 | set_cpu_cap(c, X86_FEATURE_CPB); |
| 800 | } | 800 | } |
| 801 | 801 | ||
| @@ -906,11 +906,11 @@ static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) | |||
| 906 | /* AMD errata T13 (order #21922) */ | 906 | /* AMD errata T13 (order #21922) */ |
| 907 | if ((c->x86 == 6)) { | 907 | if ((c->x86 == 6)) { |
| 908 | /* Duron Rev A0 */ | 908 | /* Duron Rev A0 */ |
| 909 | if (c->x86_model == 3 && c->x86_mask == 0) | 909 | if (c->x86_model == 3 && c->x86_stepping == 0) |
| 910 | size = 64; | 910 | size = 64; |
| 911 | /* Tbird rev A1/A2 */ | 911 | /* Tbird rev A1/A2 */ |
| 912 | if (c->x86_model == 4 && | 912 | if (c->x86_model == 4 && |
| 913 | (c->x86_mask == 0 || c->x86_mask == 1)) | 913 | (c->x86_stepping == 0 || c->x86_stepping == 1)) |
| 914 | size = 256; | 914 | size = 256; |
| 915 | } | 915 | } |
| 916 | return size; | 916 | return size; |
| @@ -1047,7 +1047,7 @@ static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum) | |||
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | /* OSVW unavailable or ID unknown, match family-model-stepping range */ | 1049 | /* OSVW unavailable or ID unknown, match family-model-stepping range */ |
| 1050 | ms = (cpu->x86_model << 4) | cpu->x86_mask; | 1050 | ms = (cpu->x86_model << 4) | cpu->x86_stepping; |
| 1051 | while ((range = *erratum++)) | 1051 | while ((range = *erratum++)) |
| 1052 | if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) && | 1052 | if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) && |
| 1053 | (ms >= AMD_MODEL_RANGE_START(range)) && | 1053 | (ms >= AMD_MODEL_RANGE_START(range)) && |
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 71949bf2de5a..d71c8b54b696 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c | |||
| @@ -162,8 +162,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) | |||
| 162 | if (cmdline_find_option_bool(boot_command_line, "nospectre_v2")) | 162 | if (cmdline_find_option_bool(boot_command_line, "nospectre_v2")) |
| 163 | return SPECTRE_V2_CMD_NONE; | 163 | return SPECTRE_V2_CMD_NONE; |
| 164 | else { | 164 | else { |
| 165 | ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, | 165 | ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg)); |
| 166 | sizeof(arg)); | ||
| 167 | if (ret < 0) | 166 | if (ret < 0) |
| 168 | return SPECTRE_V2_CMD_AUTO; | 167 | return SPECTRE_V2_CMD_AUTO; |
| 169 | 168 | ||
| @@ -175,8 +174,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) | |||
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | if (i >= ARRAY_SIZE(mitigation_options)) { | 176 | if (i >= ARRAY_SIZE(mitigation_options)) { |
| 178 | pr_err("unknown option (%s). Switching to AUTO select\n", | 177 | pr_err("unknown option (%s). Switching to AUTO select\n", arg); |
| 179 | mitigation_options[i].option); | ||
| 180 | return SPECTRE_V2_CMD_AUTO; | 178 | return SPECTRE_V2_CMD_AUTO; |
| 181 | } | 179 | } |
| 182 | } | 180 | } |
| @@ -185,8 +183,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) | |||
| 185 | cmd == SPECTRE_V2_CMD_RETPOLINE_AMD || | 183 | cmd == SPECTRE_V2_CMD_RETPOLINE_AMD || |
| 186 | cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) && | 184 | cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) && |
| 187 | !IS_ENABLED(CONFIG_RETPOLINE)) { | 185 | !IS_ENABLED(CONFIG_RETPOLINE)) { |
| 188 | pr_err("%s selected but not compiled in. Switching to AUTO select\n", | 186 | pr_err("%s selected but not compiled in. Switching to AUTO select\n", mitigation_options[i].option); |
| 189 | mitigation_options[i].option); | ||
| 190 | return SPECTRE_V2_CMD_AUTO; | 187 | return SPECTRE_V2_CMD_AUTO; |
| 191 | } | 188 | } |
| 192 | 189 | ||
| @@ -256,14 +253,14 @@ static void __init spectre_v2_select_mitigation(void) | |||
| 256 | goto retpoline_auto; | 253 | goto retpoline_auto; |
| 257 | break; | 254 | break; |
| 258 | } | 255 | } |
| 259 | pr_err("kernel not compiled with retpoline; no mitigation available!"); | 256 | pr_err("Spectre mitigation: kernel not compiled with retpoline; no mitigation available!"); |
| 260 | return; | 257 | return; |
| 261 | 258 | ||
| 262 | retpoline_auto: | 259 | retpoline_auto: |
| 263 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { | 260 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { |
| 264 | retpoline_amd: | 261 | retpoline_amd: |
| 265 | if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) { | 262 | if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) { |
| 266 | pr_err("LFENCE not serializing. Switching to generic retpoline\n"); | 263 | pr_err("Spectre mitigation: LFENCE not serializing, switching to generic retpoline\n"); |
| 267 | goto retpoline_generic; | 264 | goto retpoline_generic; |
| 268 | } | 265 | } |
| 269 | mode = retp_compiler() ? SPECTRE_V2_RETPOLINE_AMD : | 266 | mode = retp_compiler() ? SPECTRE_V2_RETPOLINE_AMD : |
| @@ -281,7 +278,7 @@ retpoline_auto: | |||
| 281 | pr_info("%s\n", spectre_v2_strings[mode]); | 278 | pr_info("%s\n", spectre_v2_strings[mode]); |
| 282 | 279 | ||
| 283 | /* | 280 | /* |
| 284 | * If neither SMEP or KPTI are available, there is a risk of | 281 | * If neither SMEP nor PTI are available, there is a risk of |
| 285 | * hitting userspace addresses in the RSB after a context switch | 282 | * hitting userspace addresses in the RSB after a context switch |
| 286 | * from a shallow call stack to a deeper one. To prevent this fill | 283 | * from a shallow call stack to a deeper one. To prevent this fill |
| 287 | * the entire RSB, even when using IBRS. | 284 | * the entire RSB, even when using IBRS. |
| @@ -295,21 +292,20 @@ retpoline_auto: | |||
| 295 | if ((!boot_cpu_has(X86_FEATURE_PTI) && | 292 | if ((!boot_cpu_has(X86_FEATURE_PTI) && |
| 296 | !boot_cpu_has(X86_FEATURE_SMEP)) || is_skylake_era()) { | 293 | !boot_cpu_has(X86_FEATURE_SMEP)) || is_skylake_era()) { |
| 297 | setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW); | 294 | setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW); |
| 298 | pr_info("Filling RSB on context switch\n"); | 295 | pr_info("Spectre v2 mitigation: Filling RSB on context switch\n"); |
| 299 | } | 296 | } |
| 300 | 297 | ||
| 301 | /* Initialize Indirect Branch Prediction Barrier if supported */ | 298 | /* Initialize Indirect Branch Prediction Barrier if supported */ |
| 302 | if (boot_cpu_has(X86_FEATURE_IBPB)) { | 299 | if (boot_cpu_has(X86_FEATURE_IBPB)) { |
| 303 | setup_force_cpu_cap(X86_FEATURE_USE_IBPB); | 300 | setup_force_cpu_cap(X86_FEATURE_USE_IBPB); |
| 304 | pr_info("Enabling Indirect Branch Prediction Barrier\n"); | 301 | pr_info("Spectre v2 mitigation: Enabling Indirect Branch Prediction Barrier\n"); |
| 305 | } | 302 | } |
| 306 | } | 303 | } |
| 307 | 304 | ||
| 308 | #undef pr_fmt | 305 | #undef pr_fmt |
| 309 | 306 | ||
| 310 | #ifdef CONFIG_SYSFS | 307 | #ifdef CONFIG_SYSFS |
| 311 | ssize_t cpu_show_meltdown(struct device *dev, | 308 | ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf) |
| 312 | struct device_attribute *attr, char *buf) | ||
| 313 | { | 309 | { |
| 314 | if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN)) | 310 | if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN)) |
| 315 | return sprintf(buf, "Not affected\n"); | 311 | return sprintf(buf, "Not affected\n"); |
| @@ -318,16 +314,14 @@ ssize_t cpu_show_meltdown(struct device *dev, | |||
| 318 | return sprintf(buf, "Vulnerable\n"); | 314 | return sprintf(buf, "Vulnerable\n"); |
| 319 | } | 315 | } |
| 320 | 316 | ||
| 321 | ssize_t cpu_show_spectre_v1(struct device *dev, | 317 | ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, char *buf) |
| 322 | struct device_attribute *attr, char *buf) | ||
| 323 | { | 318 | { |
| 324 | if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1)) | 319 | if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1)) |
| 325 | return sprintf(buf, "Not affected\n"); | 320 | return sprintf(buf, "Not affected\n"); |
| 326 | return sprintf(buf, "Mitigation: __user pointer sanitization\n"); | 321 | return sprintf(buf, "Mitigation: __user pointer sanitization\n"); |
| 327 | } | 322 | } |
| 328 | 323 | ||
| 329 | ssize_t cpu_show_spectre_v2(struct device *dev, | 324 | ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, char *buf) |
| 330 | struct device_attribute *attr, char *buf) | ||
| 331 | { | 325 | { |
| 332 | if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) | 326 | if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) |
| 333 | return sprintf(buf, "Not affected\n"); | 327 | return sprintf(buf, "Not affected\n"); |
| @@ -337,9 +331,3 @@ ssize_t cpu_show_spectre_v2(struct device *dev, | |||
| 337 | spectre_v2_module_string()); | 331 | spectre_v2_module_string()); |
| 338 | } | 332 | } |
| 339 | #endif | 333 | #endif |
| 340 | |||
| 341 | void __ibp_barrier(void) | ||
| 342 | { | ||
| 343 | __wrmsr(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, 0); | ||
| 344 | } | ||
| 345 | EXPORT_SYMBOL_GPL(__ibp_barrier); | ||
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index c578cd29c2d2..e5ec0f11c0de 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c | |||
| @@ -140,7 +140,7 @@ static void init_centaur(struct cpuinfo_x86 *c) | |||
| 140 | clear_cpu_cap(c, X86_FEATURE_TSC); | 140 | clear_cpu_cap(c, X86_FEATURE_TSC); |
| 141 | break; | 141 | break; |
| 142 | case 8: | 142 | case 8: |
| 143 | switch (c->x86_mask) { | 143 | switch (c->x86_stepping) { |
| 144 | default: | 144 | default: |
| 145 | name = "2"; | 145 | name = "2"; |
| 146 | break; | 146 | break; |
| @@ -215,7 +215,7 @@ centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size) | |||
| 215 | * - Note, it seems this may only be in engineering samples. | 215 | * - Note, it seems this may only be in engineering samples. |
| 216 | */ | 216 | */ |
| 217 | if ((c->x86 == 6) && (c->x86_model == 9) && | 217 | if ((c->x86 == 6) && (c->x86_model == 9) && |
| 218 | (c->x86_mask == 1) && (size == 65)) | 218 | (c->x86_stepping == 1) && (size == 65)) |
| 219 | size -= 1; | 219 | size -= 1; |
| 220 | return size; | 220 | return size; |
| 221 | } | 221 | } |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index d63f4b5706e4..824aee0117bb 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
| @@ -731,7 +731,7 @@ void cpu_detect(struct cpuinfo_x86 *c) | |||
| 731 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); | 731 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); |
| 732 | c->x86 = x86_family(tfms); | 732 | c->x86 = x86_family(tfms); |
| 733 | c->x86_model = x86_model(tfms); | 733 | c->x86_model = x86_model(tfms); |
| 734 | c->x86_mask = x86_stepping(tfms); | 734 | c->x86_stepping = x86_stepping(tfms); |
| 735 | 735 | ||
| 736 | if (cap0 & (1<<19)) { | 736 | if (cap0 & (1<<19)) { |
| 737 | c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; | 737 | c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; |
| @@ -1184,9 +1184,9 @@ static void identify_cpu(struct cpuinfo_x86 *c) | |||
| 1184 | int i; | 1184 | int i; |
| 1185 | 1185 | ||
| 1186 | c->loops_per_jiffy = loops_per_jiffy; | 1186 | c->loops_per_jiffy = loops_per_jiffy; |
| 1187 | c->x86_cache_size = -1; | 1187 | c->x86_cache_size = 0; |
| 1188 | c->x86_vendor = X86_VENDOR_UNKNOWN; | 1188 | c->x86_vendor = X86_VENDOR_UNKNOWN; |
| 1189 | c->x86_model = c->x86_mask = 0; /* So far unknown... */ | 1189 | c->x86_model = c->x86_stepping = 0; /* So far unknown... */ |
| 1190 | c->x86_vendor_id[0] = '\0'; /* Unset */ | 1190 | c->x86_vendor_id[0] = '\0'; /* Unset */ |
| 1191 | c->x86_model_id[0] = '\0'; /* Unset */ | 1191 | c->x86_model_id[0] = '\0'; /* Unset */ |
| 1192 | c->x86_max_cores = 1; | 1192 | c->x86_max_cores = 1; |
| @@ -1378,8 +1378,8 @@ void print_cpu_info(struct cpuinfo_x86 *c) | |||
| 1378 | 1378 | ||
| 1379 | pr_cont(" (family: 0x%x, model: 0x%x", c->x86, c->x86_model); | 1379 | pr_cont(" (family: 0x%x, model: 0x%x", c->x86, c->x86_model); |
| 1380 | 1380 | ||
| 1381 | if (c->x86_mask || c->cpuid_level >= 0) | 1381 | if (c->x86_stepping || c->cpuid_level >= 0) |
| 1382 | pr_cont(", stepping: 0x%x)\n", c->x86_mask); | 1382 | pr_cont(", stepping: 0x%x)\n", c->x86_stepping); |
| 1383 | else | 1383 | else |
| 1384 | pr_cont(")\n"); | 1384 | pr_cont(")\n"); |
| 1385 | } | 1385 | } |
diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c index 6b4bb335641f..8949b7ae6d92 100644 --- a/arch/x86/kernel/cpu/cyrix.c +++ b/arch/x86/kernel/cpu/cyrix.c | |||
| @@ -215,7 +215,7 @@ static void init_cyrix(struct cpuinfo_x86 *c) | |||
| 215 | 215 | ||
| 216 | /* common case step number/rev -- exceptions handled below */ | 216 | /* common case step number/rev -- exceptions handled below */ |
| 217 | c->x86_model = (dir1 >> 4) + 1; | 217 | c->x86_model = (dir1 >> 4) + 1; |
| 218 | c->x86_mask = dir1 & 0xf; | 218 | c->x86_stepping = dir1 & 0xf; |
| 219 | 219 | ||
| 220 | /* Now cook; the original recipe is by Channing Corn, from Cyrix. | 220 | /* Now cook; the original recipe is by Channing Corn, from Cyrix. |
| 221 | * We do the same thing for each generation: we work out | 221 | * We do the same thing for each generation: we work out |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 319bf989fad1..d19e903214b4 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
| @@ -116,14 +116,13 @@ struct sku_microcode { | |||
| 116 | u32 microcode; | 116 | u32 microcode; |
| 117 | }; | 117 | }; |
| 118 | static const struct sku_microcode spectre_bad_microcodes[] = { | 118 | static const struct sku_microcode spectre_bad_microcodes[] = { |
| 119 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0B, 0x84 }, | 119 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0B, 0x80 }, |
| 120 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0A, 0x84 }, | 120 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0A, 0x80 }, |
| 121 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x09, 0x84 }, | 121 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x09, 0x80 }, |
| 122 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x0A, 0x84 }, | 122 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x0A, 0x80 }, |
| 123 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x09, 0x84 }, | 123 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x09, 0x80 }, |
| 124 | { INTEL_FAM6_SKYLAKE_X, 0x03, 0x0100013e }, | 124 | { INTEL_FAM6_SKYLAKE_X, 0x03, 0x0100013e }, |
| 125 | { INTEL_FAM6_SKYLAKE_X, 0x04, 0x0200003c }, | 125 | { INTEL_FAM6_SKYLAKE_X, 0x04, 0x0200003c }, |
| 126 | { INTEL_FAM6_SKYLAKE_MOBILE, 0x03, 0xc2 }, | ||
| 127 | { INTEL_FAM6_SKYLAKE_DESKTOP, 0x03, 0xc2 }, | 126 | { INTEL_FAM6_SKYLAKE_DESKTOP, 0x03, 0xc2 }, |
| 128 | { INTEL_FAM6_BROADWELL_CORE, 0x04, 0x28 }, | 127 | { INTEL_FAM6_BROADWELL_CORE, 0x04, 0x28 }, |
| 129 | { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x1b }, | 128 | { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x1b }, |
| @@ -136,8 +135,6 @@ static const struct sku_microcode spectre_bad_microcodes[] = { | |||
| 136 | { INTEL_FAM6_HASWELL_X, 0x02, 0x3b }, | 135 | { INTEL_FAM6_HASWELL_X, 0x02, 0x3b }, |
| 137 | { INTEL_FAM6_HASWELL_X, 0x04, 0x10 }, | 136 | { INTEL_FAM6_HASWELL_X, 0x04, 0x10 }, |
| 138 | { INTEL_FAM6_IVYBRIDGE_X, 0x04, 0x42a }, | 137 | { INTEL_FAM6_IVYBRIDGE_X, 0x04, 0x42a }, |
| 139 | /* Updated in the 20180108 release; blacklist until we know otherwise */ | ||
| 140 | { INTEL_FAM6_ATOM_GEMINI_LAKE, 0x01, 0x22 }, | ||
| 141 | /* Observed in the wild */ | 138 | /* Observed in the wild */ |
| 142 | { INTEL_FAM6_SANDYBRIDGE_X, 0x06, 0x61b }, | 139 | { INTEL_FAM6_SANDYBRIDGE_X, 0x06, 0x61b }, |
| 143 | { INTEL_FAM6_SANDYBRIDGE_X, 0x07, 0x712 }, | 140 | { INTEL_FAM6_SANDYBRIDGE_X, 0x07, 0x712 }, |
| @@ -149,7 +146,7 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c) | |||
| 149 | 146 | ||
| 150 | for (i = 0; i < ARRAY_SIZE(spectre_bad_microcodes); i++) { | 147 | for (i = 0; i < ARRAY_SIZE(spectre_bad_microcodes); i++) { |
| 151 | if (c->x86_model == spectre_bad_microcodes[i].model && | 148 | if (c->x86_model == spectre_bad_microcodes[i].model && |
| 152 | c->x86_mask == spectre_bad_microcodes[i].stepping) | 149 | c->x86_stepping == spectre_bad_microcodes[i].stepping) |
| 153 | return (c->microcode <= spectre_bad_microcodes[i].microcode); | 150 | return (c->microcode <= spectre_bad_microcodes[i].microcode); |
| 154 | } | 151 | } |
| 155 | return false; | 152 | return false; |
| @@ -196,7 +193,7 @@ static void early_init_intel(struct cpuinfo_x86 *c) | |||
| 196 | * need the microcode to have already been loaded... so if it is | 193 | * need the microcode to have already been loaded... so if it is |
| 197 | * not, recommend a BIOS update and disable large pages. | 194 | * not, recommend a BIOS update and disable large pages. |
| 198 | */ | 195 | */ |
| 199 | if (c->x86 == 6 && c->x86_model == 0x1c && c->x86_mask <= 2 && | 196 | if (c->x86 == 6 && c->x86_model == 0x1c && c->x86_stepping <= 2 && |
| 200 | c->microcode < 0x20e) { | 197 | c->microcode < 0x20e) { |
| 201 | pr_warn("Atom PSE erratum detected, BIOS microcode update recommended\n"); | 198 | pr_warn("Atom PSE erratum detected, BIOS microcode update recommended\n"); |
| 202 | clear_cpu_cap(c, X86_FEATURE_PSE); | 199 | clear_cpu_cap(c, X86_FEATURE_PSE); |
| @@ -212,7 +209,7 @@ static void early_init_intel(struct cpuinfo_x86 *c) | |||
| 212 | 209 | ||
| 213 | /* CPUID workaround for 0F33/0F34 CPU */ | 210 | /* CPUID workaround for 0F33/0F34 CPU */ |
| 214 | if (c->x86 == 0xF && c->x86_model == 0x3 | 211 | if (c->x86 == 0xF && c->x86_model == 0x3 |
| 215 | && (c->x86_mask == 0x3 || c->x86_mask == 0x4)) | 212 | && (c->x86_stepping == 0x3 || c->x86_stepping == 0x4)) |
| 216 | c->x86_phys_bits = 36; | 213 | c->x86_phys_bits = 36; |
| 217 | 214 | ||
| 218 | /* | 215 | /* |
| @@ -310,7 +307,7 @@ int ppro_with_ram_bug(void) | |||
| 310 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && | 307 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && |
| 311 | boot_cpu_data.x86 == 6 && | 308 | boot_cpu_data.x86 == 6 && |
| 312 | boot_cpu_data.x86_model == 1 && | 309 | boot_cpu_data.x86_model == 1 && |
| 313 | boot_cpu_data.x86_mask < 8) { | 310 | boot_cpu_data.x86_stepping < 8) { |
| 314 | pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n"); | 311 | pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n"); |
| 315 | return 1; | 312 | return 1; |
| 316 | } | 313 | } |
| @@ -327,7 +324,7 @@ static void intel_smp_check(struct cpuinfo_x86 *c) | |||
| 327 | * Mask B, Pentium, but not Pentium MMX | 324 | * Mask B, Pentium, but not Pentium MMX |
| 328 | */ | 325 | */ |
| 329 | if (c->x86 == 5 && | 326 | if (c->x86 == 5 && |
| 330 | c->x86_mask >= 1 && c->x86_mask <= 4 && | 327 | c->x86_stepping >= 1 && c->x86_stepping <= 4 && |
| 331 | c->x86_model <= 3) { | 328 | c->x86_model <= 3) { |
| 332 | /* | 329 | /* |
| 333 | * Remember we have B step Pentia with bugs | 330 | * Remember we have B step Pentia with bugs |
| @@ -370,7 +367,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c) | |||
| 370 | * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until | 367 | * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until |
| 371 | * model 3 mask 3 | 368 | * model 3 mask 3 |
| 372 | */ | 369 | */ |
| 373 | if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633) | 370 | if ((c->x86<<8 | c->x86_model<<4 | c->x86_stepping) < 0x633) |
| 374 | clear_cpu_cap(c, X86_FEATURE_SEP); | 371 | clear_cpu_cap(c, X86_FEATURE_SEP); |
| 375 | 372 | ||
| 376 | /* | 373 | /* |
| @@ -388,7 +385,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c) | |||
| 388 | * P4 Xeon erratum 037 workaround. | 385 | * P4 Xeon erratum 037 workaround. |
| 389 | * Hardware prefetcher may cause stale data to be loaded into the cache. | 386 | * Hardware prefetcher may cause stale data to be loaded into the cache. |
| 390 | */ | 387 | */ |
| 391 | if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) { | 388 | if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_stepping == 1)) { |
| 392 | if (msr_set_bit(MSR_IA32_MISC_ENABLE, | 389 | if (msr_set_bit(MSR_IA32_MISC_ENABLE, |
| 393 | MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) { | 390 | MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) { |
| 394 | pr_info("CPU: C0 stepping P4 Xeon detected.\n"); | 391 | pr_info("CPU: C0 stepping P4 Xeon detected.\n"); |
| @@ -403,7 +400,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c) | |||
| 403 | * Specification Update"). | 400 | * Specification Update"). |
| 404 | */ | 401 | */ |
| 405 | if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 && | 402 | if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 && |
| 406 | (c->x86_mask < 0x6 || c->x86_mask == 0xb)) | 403 | (c->x86_stepping < 0x6 || c->x86_stepping == 0xb)) |
| 407 | set_cpu_bug(c, X86_BUG_11AP); | 404 | set_cpu_bug(c, X86_BUG_11AP); |
| 408 | 405 | ||
| 409 | 406 | ||
| @@ -650,7 +647,7 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
| 650 | case 6: | 647 | case 6: |
| 651 | if (l2 == 128) | 648 | if (l2 == 128) |
| 652 | p = "Celeron (Mendocino)"; | 649 | p = "Celeron (Mendocino)"; |
| 653 | else if (c->x86_mask == 0 || c->x86_mask == 5) | 650 | else if (c->x86_stepping == 0 || c->x86_stepping == 5) |
| 654 | p = "Celeron-A"; | 651 | p = "Celeron-A"; |
| 655 | break; | 652 | break; |
| 656 | 653 | ||
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c index 410629f10ad3..589b948e6e01 100644 --- a/arch/x86/kernel/cpu/intel_rdt.c +++ b/arch/x86/kernel/cpu/intel_rdt.c | |||
| @@ -819,7 +819,7 @@ static __init void rdt_quirks(void) | |||
| 819 | cache_alloc_hsw_probe(); | 819 | cache_alloc_hsw_probe(); |
| 820 | break; | 820 | break; |
| 821 | case INTEL_FAM6_SKYLAKE_X: | 821 | case INTEL_FAM6_SKYLAKE_X: |
| 822 | if (boot_cpu_data.x86_mask <= 4) | 822 | if (boot_cpu_data.x86_stepping <= 4) |
| 823 | set_rdt_options("!cmt,!mbmtotal,!mbmlocal,!l3cat"); | 823 | set_rdt_options("!cmt,!mbmtotal,!mbmlocal,!l3cat"); |
| 824 | } | 824 | } |
| 825 | } | 825 | } |
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h index aa0d5df9dc60..e956eb267061 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-internal.h +++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h | |||
| @@ -115,4 +115,19 @@ static inline void mce_unregister_injector_chain(struct notifier_block *nb) { } | |||
| 115 | 115 | ||
| 116 | extern struct mca_config mca_cfg; | 116 | extern struct mca_config mca_cfg; |
| 117 | 117 | ||
| 118 | #ifndef CONFIG_X86_64 | ||
| 119 | /* | ||
| 120 | * On 32-bit systems it would be difficult to safely unmap a poison page | ||
| 121 | * from the kernel 1:1 map because there are no non-canonical addresses that | ||
| 122 | * we can use to refer to the address without risking a speculative access. | ||
| 123 | * However, this isn't much of an issue because: | ||
| 124 | * 1) Few unmappable pages are in the 1:1 map. Most are in HIGHMEM which | ||
| 125 | * are only mapped into the kernel as needed | ||
| 126 | * 2) Few people would run a 32-bit kernel on a machine that supports | ||
| 127 | * recoverable errors because they have too much memory to boot 32-bit. | ||
| 128 | */ | ||
| 129 | static inline void mce_unmap_kpfn(unsigned long pfn) {} | ||
| 130 | #define mce_unmap_kpfn mce_unmap_kpfn | ||
| 131 | #endif | ||
| 132 | |||
| 118 | #endif /* __X86_MCE_INTERNAL_H__ */ | 133 | #endif /* __X86_MCE_INTERNAL_H__ */ |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 3a8e88a611eb..8ff94d1e2dce 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
| @@ -105,6 +105,10 @@ static struct irq_work mce_irq_work; | |||
| 105 | 105 | ||
| 106 | static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs); | 106 | static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs); |
| 107 | 107 | ||
| 108 | #ifndef mce_unmap_kpfn | ||
| 109 | static void mce_unmap_kpfn(unsigned long pfn); | ||
| 110 | #endif | ||
| 111 | |||
| 108 | /* | 112 | /* |
| 109 | * CPU/chipset specific EDAC code can register a notifier call here to print | 113 | * CPU/chipset specific EDAC code can register a notifier call here to print |
| 110 | * MCE errors in a human-readable form. | 114 | * MCE errors in a human-readable form. |
| @@ -234,7 +238,7 @@ static void __print_mce(struct mce *m) | |||
| 234 | m->cs, m->ip); | 238 | m->cs, m->ip); |
| 235 | 239 | ||
| 236 | if (m->cs == __KERNEL_CS) | 240 | if (m->cs == __KERNEL_CS) |
| 237 | pr_cont("{%pS}", (void *)m->ip); | 241 | pr_cont("{%pS}", (void *)(unsigned long)m->ip); |
| 238 | pr_cont("\n"); | 242 | pr_cont("\n"); |
| 239 | } | 243 | } |
| 240 | 244 | ||
| @@ -590,7 +594,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val, | |||
| 590 | 594 | ||
| 591 | if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) { | 595 | if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) { |
| 592 | pfn = mce->addr >> PAGE_SHIFT; | 596 | pfn = mce->addr >> PAGE_SHIFT; |
| 593 | memory_failure(pfn, 0); | 597 | if (!memory_failure(pfn, 0)) |
| 598 | mce_unmap_kpfn(pfn); | ||
| 594 | } | 599 | } |
| 595 | 600 | ||
| 596 | return NOTIFY_OK; | 601 | return NOTIFY_OK; |
| @@ -1057,12 +1062,13 @@ static int do_memory_failure(struct mce *m) | |||
| 1057 | ret = memory_failure(m->addr >> PAGE_SHIFT, flags); | 1062 | ret = memory_failure(m->addr >> PAGE_SHIFT, flags); |
| 1058 | if (ret) | 1063 | if (ret) |
| 1059 | pr_err("Memory error not recovered"); | 1064 | pr_err("Memory error not recovered"); |
| 1065 | else | ||
| 1066 | mce_unmap_kpfn(m->addr >> PAGE_SHIFT); | ||
| 1060 | return ret; | 1067 | return ret; |
| 1061 | } | 1068 | } |
| 1062 | 1069 | ||
| 1063 | #if defined(arch_unmap_kpfn) && defined(CONFIG_MEMORY_FAILURE) | 1070 | #ifndef mce_unmap_kpfn |
| 1064 | 1071 | static void mce_unmap_kpfn(unsigned long pfn) | |
| 1065 | void arch_unmap_kpfn(unsigned long pfn) | ||
| 1066 | { | 1072 | { |
| 1067 | unsigned long decoy_addr; | 1073 | unsigned long decoy_addr; |
| 1068 | 1074 | ||
| @@ -1073,7 +1079,7 @@ void arch_unmap_kpfn(unsigned long pfn) | |||
| 1073 | * We would like to just call: | 1079 | * We would like to just call: |
| 1074 | * set_memory_np((unsigned long)pfn_to_kaddr(pfn), 1); | 1080 | * set_memory_np((unsigned long)pfn_to_kaddr(pfn), 1); |
| 1075 | * but doing that would radically increase the odds of a | 1081 | * but doing that would radically increase the odds of a |
| 1076 | * speculative access to the posion page because we'd have | 1082 | * speculative access to the poison page because we'd have |
| 1077 | * the virtual address of the kernel 1:1 mapping sitting | 1083 | * the virtual address of the kernel 1:1 mapping sitting |
| 1078 | * around in registers. | 1084 | * around in registers. |
| 1079 | * Instead we get tricky. We create a non-canonical address | 1085 | * Instead we get tricky. We create a non-canonical address |
| @@ -1098,7 +1104,6 @@ void arch_unmap_kpfn(unsigned long pfn) | |||
| 1098 | 1104 | ||
| 1099 | if (set_memory_np(decoy_addr, 1)) | 1105 | if (set_memory_np(decoy_addr, 1)) |
| 1100 | pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); | 1106 | pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); |
| 1101 | |||
| 1102 | } | 1107 | } |
| 1103 | #endif | 1108 | #endif |
| 1104 | 1109 | ||
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index f7c55b0e753a..a15db2b4e0d6 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c | |||
| @@ -921,7 +921,7 @@ static bool is_blacklisted(unsigned int cpu) | |||
| 921 | */ | 921 | */ |
| 922 | if (c->x86 == 6 && | 922 | if (c->x86 == 6 && |
| 923 | c->x86_model == INTEL_FAM6_BROADWELL_X && | 923 | c->x86_model == INTEL_FAM6_BROADWELL_X && |
| 924 | c->x86_mask == 0x01 && | 924 | c->x86_stepping == 0x01 && |
| 925 | llc_size_per_core > 2621440 && | 925 | llc_size_per_core > 2621440 && |
| 926 | c->microcode < 0x0b000021) { | 926 | c->microcode < 0x0b000021) { |
| 927 | pr_err_once("Erratum BDF90: late loading with revision < 0x0b000021 (0x%x) disabled.\n", c->microcode); | 927 | pr_err_once("Erratum BDF90: late loading with revision < 0x0b000021 (0x%x) disabled.\n", c->microcode); |
| @@ -944,7 +944,7 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device, | |||
| 944 | return UCODE_NFOUND; | 944 | return UCODE_NFOUND; |
| 945 | 945 | ||
| 946 | sprintf(name, "intel-ucode/%02x-%02x-%02x", | 946 | sprintf(name, "intel-ucode/%02x-%02x-%02x", |
| 947 | c->x86, c->x86_model, c->x86_mask); | 947 | c->x86, c->x86_model, c->x86_stepping); |
| 948 | 948 | ||
| 949 | if (request_firmware_direct(&firmware, name, device)) { | 949 | if (request_firmware_direct(&firmware, name, device)) { |
| 950 | pr_debug("data file %s load failed\n", name); | 950 | pr_debug("data file %s load failed\n", name); |
| @@ -982,7 +982,7 @@ static struct microcode_ops microcode_intel_ops = { | |||
| 982 | 982 | ||
| 983 | static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) | 983 | static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) |
| 984 | { | 984 | { |
| 985 | u64 llc_size = c->x86_cache_size * 1024; | 985 | u64 llc_size = c->x86_cache_size * 1024ULL; |
| 986 | 986 | ||
| 987 | do_div(llc_size, c->x86_max_cores); | 987 | do_div(llc_size, c->x86_max_cores); |
| 988 | 988 | ||
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index fdc55215d44d..e12ee86906c6 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
| @@ -859,7 +859,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size, | |||
| 859 | */ | 859 | */ |
| 860 | if (is_cpu(INTEL) && boot_cpu_data.x86 == 6 && | 860 | if (is_cpu(INTEL) && boot_cpu_data.x86 == 6 && |
| 861 | boot_cpu_data.x86_model == 1 && | 861 | boot_cpu_data.x86_model == 1 && |
| 862 | boot_cpu_data.x86_mask <= 7) { | 862 | boot_cpu_data.x86_stepping <= 7) { |
| 863 | if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) { | 863 | if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) { |
| 864 | pr_warn("mtrr: base(0x%lx000) is not 4 MiB aligned\n", base); | 864 | pr_warn("mtrr: base(0x%lx000) is not 4 MiB aligned\n", base); |
| 865 | return -EINVAL; | 865 | return -EINVAL; |
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 40d5a8a75212..7468de429087 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
| @@ -711,8 +711,8 @@ void __init mtrr_bp_init(void) | |||
| 711 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && | 711 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && |
| 712 | boot_cpu_data.x86 == 0xF && | 712 | boot_cpu_data.x86 == 0xF && |
| 713 | boot_cpu_data.x86_model == 0x3 && | 713 | boot_cpu_data.x86_model == 0x3 && |
| 714 | (boot_cpu_data.x86_mask == 0x3 || | 714 | (boot_cpu_data.x86_stepping == 0x3 || |
| 715 | boot_cpu_data.x86_mask == 0x4)) | 715 | boot_cpu_data.x86_stepping == 0x4)) |
| 716 | phys_addr = 36; | 716 | phys_addr = 36; |
| 717 | 717 | ||
| 718 | size_or_mask = SIZE_OR_MASK_BITS(phys_addr); | 718 | size_or_mask = SIZE_OR_MASK_BITS(phys_addr); |
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c index e7ecedafa1c8..2c8522a39ed5 100644 --- a/arch/x86/kernel/cpu/proc.c +++ b/arch/x86/kernel/cpu/proc.c | |||
| @@ -72,8 +72,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
| 72 | c->x86_model, | 72 | c->x86_model, |
| 73 | c->x86_model_id[0] ? c->x86_model_id : "unknown"); | 73 | c->x86_model_id[0] ? c->x86_model_id : "unknown"); |
| 74 | 74 | ||
| 75 | if (c->x86_mask || c->cpuid_level >= 0) | 75 | if (c->x86_stepping || c->cpuid_level >= 0) |
| 76 | seq_printf(m, "stepping\t: %d\n", c->x86_mask); | 76 | seq_printf(m, "stepping\t: %d\n", c->x86_stepping); |
| 77 | else | 77 | else |
| 78 | seq_puts(m, "stepping\t: unknown\n"); | 78 | seq_puts(m, "stepping\t: unknown\n"); |
| 79 | if (c->microcode) | 79 | if (c->microcode) |
| @@ -91,8 +91,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /* Cache size */ | 93 | /* Cache size */ |
| 94 | if (c->x86_cache_size >= 0) | 94 | if (c->x86_cache_size) |
| 95 | seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); | 95 | seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size); |
| 96 | 96 | ||
| 97 | show_cpuinfo_core(m, c, cpu); | 97 | show_cpuinfo_core(m, c, cpu); |
| 98 | show_cpuinfo_misc(m, c); | 98 | show_cpuinfo_misc(m, c); |
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index c29020907886..b59e4fb40fd9 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | #define X86 new_cpu_data+CPUINFO_x86 | 37 | #define X86 new_cpu_data+CPUINFO_x86 |
| 38 | #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor | 38 | #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor |
| 39 | #define X86_MODEL new_cpu_data+CPUINFO_x86_model | 39 | #define X86_MODEL new_cpu_data+CPUINFO_x86_model |
| 40 | #define X86_MASK new_cpu_data+CPUINFO_x86_mask | 40 | #define X86_STEPPING new_cpu_data+CPUINFO_x86_stepping |
| 41 | #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math | 41 | #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math |
| 42 | #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level | 42 | #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level |
| 43 | #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability | 43 | #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability |
| @@ -332,7 +332,7 @@ ENTRY(startup_32_smp) | |||
| 332 | shrb $4,%al | 332 | shrb $4,%al |
| 333 | movb %al,X86_MODEL | 333 | movb %al,X86_MODEL |
| 334 | andb $0x0f,%cl # mask mask revision | 334 | andb $0x0f,%cl # mask mask revision |
| 335 | movb %cl,X86_MASK | 335 | movb %cl,X86_STEPPING |
| 336 | movl %edx,X86_CAPABILITY | 336 | movl %edx,X86_CAPABILITY |
| 337 | 337 | ||
| 338 | .Lis486: | 338 | .Lis486: |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 27d0a1712663..f1c5eb99d445 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
| @@ -410,7 +410,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) | |||
| 410 | processor.apicver = mpc_default_type > 4 ? 0x10 : 0x01; | 410 | processor.apicver = mpc_default_type > 4 ? 0x10 : 0x01; |
| 411 | processor.cpuflag = CPU_ENABLED; | 411 | processor.cpuflag = CPU_ENABLED; |
| 412 | processor.cpufeature = (boot_cpu_data.x86 << 8) | | 412 | processor.cpufeature = (boot_cpu_data.x86 << 8) | |
| 413 | (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; | 413 | (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_stepping; |
| 414 | processor.featureflag = boot_cpu_data.x86_capability[CPUID_1_EDX]; | 414 | processor.featureflag = boot_cpu_data.x86_capability[CPUID_1_EDX]; |
| 415 | processor.reserved[0] = 0; | 415 | processor.reserved[0] = 0; |
| 416 | processor.reserved[1] = 0; | 416 | processor.reserved[1] = 0; |
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 041096bdef86..99dc79e76bdc 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c | |||
| @@ -200,9 +200,9 @@ static void native_flush_tlb_global(void) | |||
| 200 | __native_flush_tlb_global(); | 200 | __native_flush_tlb_global(); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | static void native_flush_tlb_single(unsigned long addr) | 203 | static void native_flush_tlb_one_user(unsigned long addr) |
| 204 | { | 204 | { |
| 205 | __native_flush_tlb_single(addr); | 205 | __native_flush_tlb_one_user(addr); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | struct static_key paravirt_steal_enabled; | 208 | struct static_key paravirt_steal_enabled; |
| @@ -401,7 +401,7 @@ struct pv_mmu_ops pv_mmu_ops __ro_after_init = { | |||
| 401 | 401 | ||
| 402 | .flush_tlb_user = native_flush_tlb, | 402 | .flush_tlb_user = native_flush_tlb, |
| 403 | .flush_tlb_kernel = native_flush_tlb_global, | 403 | .flush_tlb_kernel = native_flush_tlb_global, |
| 404 | .flush_tlb_single = native_flush_tlb_single, | 404 | .flush_tlb_one_user = native_flush_tlb_one_user, |
| 405 | .flush_tlb_others = native_flush_tlb_others, | 405 | .flush_tlb_others = native_flush_tlb_others, |
| 406 | 406 | ||
| 407 | .pgd_alloc = __paravirt_pgd_alloc, | 407 | .pgd_alloc = __paravirt_pgd_alloc, |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6f27facbaa9b..9eee25d07586 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
| @@ -1281,11 +1281,10 @@ void __init native_smp_prepare_boot_cpu(void) | |||
| 1281 | cpu_set_state_online(me); | 1281 | cpu_set_state_online(me); |
| 1282 | } | 1282 | } |
| 1283 | 1283 | ||
| 1284 | void __init native_smp_cpus_done(unsigned int max_cpus) | 1284 | void __init calculate_max_logical_packages(void) |
| 1285 | { | 1285 | { |
| 1286 | int ncpus; | 1286 | int ncpus; |
| 1287 | 1287 | ||
| 1288 | pr_debug("Boot done\n"); | ||
| 1289 | /* | 1288 | /* |
| 1290 | * Today neither Intel nor AMD support heterogenous systems so | 1289 | * Today neither Intel nor AMD support heterogenous systems so |
| 1291 | * extrapolate the boot cpu's data to all packages. | 1290 | * extrapolate the boot cpu's data to all packages. |
| @@ -1293,6 +1292,13 @@ void __init native_smp_cpus_done(unsigned int max_cpus) | |||
| 1293 | ncpus = cpu_data(0).booted_cores * topology_max_smt_threads(); | 1292 | ncpus = cpu_data(0).booted_cores * topology_max_smt_threads(); |
| 1294 | __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); | 1293 | __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); |
| 1295 | pr_info("Max logical packages: %u\n", __max_logical_packages); | 1294 | pr_info("Max logical packages: %u\n", __max_logical_packages); |
| 1295 | } | ||
| 1296 | |||
| 1297 | void __init native_smp_cpus_done(unsigned int max_cpus) | ||
| 1298 | { | ||
| 1299 | pr_debug("Boot done\n"); | ||
| 1300 | |||
| 1301 | calculate_max_logical_packages(); | ||
| 1296 | 1302 | ||
| 1297 | if (x86_has_numa_in_package) | 1303 | if (x86_has_numa_in_package) |
| 1298 | set_sched_topology(x86_numa_in_package_topology); | 1304 | set_sched_topology(x86_numa_in_package_topology); |
| @@ -1430,7 +1436,6 @@ static void remove_siblinginfo(int cpu) | |||
| 1430 | cpumask_clear(cpu_llc_shared_mask(cpu)); | 1436 | cpumask_clear(cpu_llc_shared_mask(cpu)); |
| 1431 | cpumask_clear(topology_sibling_cpumask(cpu)); | 1437 | cpumask_clear(topology_sibling_cpumask(cpu)); |
| 1432 | cpumask_clear(topology_core_cpumask(cpu)); | 1438 | cpumask_clear(topology_core_cpumask(cpu)); |
| 1433 | c->phys_proc_id = 0; | ||
| 1434 | c->cpu_core_id = 0; | 1439 | c->cpu_core_id = 0; |
| 1435 | cpumask_clear_cpu(cpu, cpu_sibling_setup_mask); | 1440 | cpumask_clear_cpu(cpu, cpu_sibling_setup_mask); |
| 1436 | recompute_smt_state(); | 1441 | recompute_smt_state(); |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 446c9ef8cfc3..3d9b2308e7fa 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
| @@ -181,7 +181,7 @@ int fixup_bug(struct pt_regs *regs, int trapnr) | |||
| 181 | break; | 181 | break; |
| 182 | 182 | ||
| 183 | case BUG_TRAP_TYPE_WARN: | 183 | case BUG_TRAP_TYPE_WARN: |
| 184 | regs->ip += LEN_UD0; | 184 | regs->ip += LEN_UD2; |
| 185 | return 1; | 185 | return 1; |
| 186 | } | 186 | } |
| 187 | 187 | ||
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 8eca1d04aeb8..46ff304140c7 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
| @@ -5080,7 +5080,7 @@ void kvm_mmu_uninit_vm(struct kvm *kvm) | |||
| 5080 | typedef bool (*slot_level_handler) (struct kvm *kvm, struct kvm_rmap_head *rmap_head); | 5080 | typedef bool (*slot_level_handler) (struct kvm *kvm, struct kvm_rmap_head *rmap_head); |
| 5081 | 5081 | ||
| 5082 | /* The caller should hold mmu-lock before calling this function. */ | 5082 | /* The caller should hold mmu-lock before calling this function. */ |
| 5083 | static bool | 5083 | static __always_inline bool |
| 5084 | slot_handle_level_range(struct kvm *kvm, struct kvm_memory_slot *memslot, | 5084 | slot_handle_level_range(struct kvm *kvm, struct kvm_memory_slot *memslot, |
| 5085 | slot_level_handler fn, int start_level, int end_level, | 5085 | slot_level_handler fn, int start_level, int end_level, |
| 5086 | gfn_t start_gfn, gfn_t end_gfn, bool lock_flush_tlb) | 5086 | gfn_t start_gfn, gfn_t end_gfn, bool lock_flush_tlb) |
| @@ -5110,7 +5110,7 @@ slot_handle_level_range(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 5110 | return flush; | 5110 | return flush; |
| 5111 | } | 5111 | } |
| 5112 | 5112 | ||
| 5113 | static bool | 5113 | static __always_inline bool |
| 5114 | slot_handle_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | 5114 | slot_handle_level(struct kvm *kvm, struct kvm_memory_slot *memslot, |
| 5115 | slot_level_handler fn, int start_level, int end_level, | 5115 | slot_level_handler fn, int start_level, int end_level, |
| 5116 | bool lock_flush_tlb) | 5116 | bool lock_flush_tlb) |
| @@ -5121,7 +5121,7 @@ slot_handle_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 5121 | lock_flush_tlb); | 5121 | lock_flush_tlb); |
| 5122 | } | 5122 | } |
| 5123 | 5123 | ||
| 5124 | static bool | 5124 | static __always_inline bool |
| 5125 | slot_handle_all_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | 5125 | slot_handle_all_level(struct kvm *kvm, struct kvm_memory_slot *memslot, |
| 5126 | slot_level_handler fn, bool lock_flush_tlb) | 5126 | slot_level_handler fn, bool lock_flush_tlb) |
| 5127 | { | 5127 | { |
| @@ -5129,7 +5129,7 @@ slot_handle_all_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 5129 | PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb); | 5129 | PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb); |
| 5130 | } | 5130 | } |
| 5131 | 5131 | ||
| 5132 | static bool | 5132 | static __always_inline bool |
| 5133 | slot_handle_large_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | 5133 | slot_handle_large_level(struct kvm *kvm, struct kvm_memory_slot *memslot, |
| 5134 | slot_level_handler fn, bool lock_flush_tlb) | 5134 | slot_level_handler fn, bool lock_flush_tlb) |
| 5135 | { | 5135 | { |
| @@ -5137,7 +5137,7 @@ slot_handle_large_level(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 5137 | PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb); | 5137 | PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb); |
| 5138 | } | 5138 | } |
| 5139 | 5139 | ||
| 5140 | static bool | 5140 | static __always_inline bool |
| 5141 | slot_handle_leaf(struct kvm *kvm, struct kvm_memory_slot *memslot, | 5141 | slot_handle_leaf(struct kvm *kvm, struct kvm_memory_slot *memslot, |
| 5142 | slot_level_handler fn, bool lock_flush_tlb) | 5142 | slot_level_handler fn, bool lock_flush_tlb) |
| 5143 | { | 5143 | { |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f427723dc7db..3dec126aa302 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
| @@ -10136,7 +10136,10 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu, | |||
| 10136 | (unsigned long)(vmcs12->posted_intr_desc_addr & | 10136 | (unsigned long)(vmcs12->posted_intr_desc_addr & |
| 10137 | (PAGE_SIZE - 1))); | 10137 | (PAGE_SIZE - 1))); |
| 10138 | } | 10138 | } |
| 10139 | if (!nested_vmx_prepare_msr_bitmap(vcpu, vmcs12)) | 10139 | if (nested_vmx_prepare_msr_bitmap(vcpu, vmcs12)) |
| 10140 | vmcs_set_bits(CPU_BASED_VM_EXEC_CONTROL, | ||
| 10141 | CPU_BASED_USE_MSR_BITMAPS); | ||
| 10142 | else | ||
| 10140 | vmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL, | 10143 | vmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL, |
| 10141 | CPU_BASED_USE_MSR_BITMAPS); | 10144 | CPU_BASED_USE_MSR_BITMAPS); |
| 10142 | } | 10145 | } |
| @@ -10224,8 +10227,8 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu, | |||
| 10224 | * updated to reflect this when L1 (or its L2s) actually write to | 10227 | * updated to reflect this when L1 (or its L2s) actually write to |
| 10225 | * the MSR. | 10228 | * the MSR. |
| 10226 | */ | 10229 | */ |
| 10227 | bool pred_cmd = msr_write_intercepted_l01(vcpu, MSR_IA32_PRED_CMD); | 10230 | bool pred_cmd = !msr_write_intercepted_l01(vcpu, MSR_IA32_PRED_CMD); |
| 10228 | bool spec_ctrl = msr_write_intercepted_l01(vcpu, MSR_IA32_SPEC_CTRL); | 10231 | bool spec_ctrl = !msr_write_intercepted_l01(vcpu, MSR_IA32_SPEC_CTRL); |
| 10229 | 10232 | ||
| 10230 | /* Nothing to do if the MSR bitmap is not in use. */ | 10233 | /* Nothing to do if the MSR bitmap is not in use. */ |
| 10231 | if (!cpu_has_vmx_msr_bitmap() || | 10234 | if (!cpu_has_vmx_msr_bitmap() || |
diff --git a/arch/x86/lib/cpu.c b/arch/x86/lib/cpu.c index d6f848d1211d..2dd1fe13a37b 100644 --- a/arch/x86/lib/cpu.c +++ b/arch/x86/lib/cpu.c | |||
| @@ -18,7 +18,7 @@ unsigned int x86_model(unsigned int sig) | |||
| 18 | { | 18 | { |
| 19 | unsigned int fam, model; | 19 | unsigned int fam, model; |
| 20 | 20 | ||
| 21 | fam = x86_family(sig); | 21 | fam = x86_family(sig); |
| 22 | 22 | ||
| 23 | model = (sig >> 4) & 0xf; | 23 | model = (sig >> 4) & 0xf; |
| 24 | 24 | ||
diff --git a/arch/x86/lib/error-inject.c b/arch/x86/lib/error-inject.c index 7b881d03d0dd..3cdf06128d13 100644 --- a/arch/x86/lib/error-inject.c +++ b/arch/x86/lib/error-inject.c | |||
| @@ -7,6 +7,7 @@ asmlinkage void just_return_func(void); | |||
| 7 | 7 | ||
| 8 | asm( | 8 | asm( |
| 9 | ".type just_return_func, @function\n" | 9 | ".type just_return_func, @function\n" |
| 10 | ".globl just_return_func\n" | ||
| 10 | "just_return_func:\n" | 11 | "just_return_func:\n" |
| 11 | " ret\n" | 12 | " ret\n" |
| 12 | ".size just_return_func, .-just_return_func\n" | 13 | ".size just_return_func, .-just_return_func\n" |
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 1ab42c852069..8b72923f1d35 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
| @@ -256,7 +256,7 @@ static void __set_pte_vaddr(pud_t *pud, unsigned long vaddr, pte_t new_pte) | |||
| 256 | * It's enough to flush this one mapping. | 256 | * It's enough to flush this one mapping. |
| 257 | * (PGE mappings get flushed as well) | 257 | * (PGE mappings get flushed as well) |
| 258 | */ | 258 | */ |
| 259 | __flush_tlb_one(vaddr); | 259 | __flush_tlb_one_kernel(vaddr); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte) | 262 | void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte) |
| @@ -1193,8 +1193,8 @@ void __init mem_init(void) | |||
| 1193 | register_page_bootmem_info(); | 1193 | register_page_bootmem_info(); |
| 1194 | 1194 | ||
| 1195 | /* Register memory areas for /proc/kcore */ | 1195 | /* Register memory areas for /proc/kcore */ |
| 1196 | kclist_add(&kcore_vsyscall, (void *)VSYSCALL_ADDR, | 1196 | if (get_gate_vma(&init_mm)) |
| 1197 | PAGE_SIZE, KCORE_OTHER); | 1197 | kclist_add(&kcore_vsyscall, (void *)VSYSCALL_ADDR, PAGE_SIZE, KCORE_USER); |
| 1198 | 1198 | ||
| 1199 | mem_init_print_info(NULL); | 1199 | mem_init_print_info(NULL); |
| 1200 | } | 1200 | } |
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index c45b6ec5357b..e2db83bebc3b 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
| @@ -820,5 +820,5 @@ void __init __early_set_fixmap(enum fixed_addresses idx, | |||
| 820 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); | 820 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); |
| 821 | else | 821 | else |
| 822 | pte_clear(&init_mm, addr, pte); | 822 | pte_clear(&init_mm, addr, pte); |
| 823 | __flush_tlb_one(addr); | 823 | __flush_tlb_one_kernel(addr); |
| 824 | } | 824 | } |
diff --git a/arch/x86/mm/kmmio.c b/arch/x86/mm/kmmio.c index 58477ec3d66d..7c8686709636 100644 --- a/arch/x86/mm/kmmio.c +++ b/arch/x86/mm/kmmio.c | |||
| @@ -168,7 +168,7 @@ static int clear_page_presence(struct kmmio_fault_page *f, bool clear) | |||
| 168 | return -1; | 168 | return -1; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | __flush_tlb_one(f->addr); | 171 | __flush_tlb_one_kernel(f->addr); |
| 172 | return 0; | 172 | return 0; |
| 173 | } | 173 | } |
| 174 | 174 | ||
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c index c3c5274410a9..9bb7f0ab9fe6 100644 --- a/arch/x86/mm/pgtable_32.c +++ b/arch/x86/mm/pgtable_32.c | |||
| @@ -63,7 +63,7 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval) | |||
| 63 | * It's enough to flush this one mapping. | 63 | * It's enough to flush this one mapping. |
| 64 | * (PGE mappings get flushed as well) | 64 | * (PGE mappings get flushed as well) |
| 65 | */ | 65 | */ |
| 66 | __flush_tlb_one(vaddr); | 66 | __flush_tlb_one_kernel(vaddr); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | unsigned long __FIXADDR_TOP = 0xfffff000; | 69 | unsigned long __FIXADDR_TOP = 0xfffff000; |
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 8dcc0607f805..7f1a51399674 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c | |||
| @@ -498,7 +498,7 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, | |||
| 498 | * flush that changes context.tlb_gen from 2 to 3. If they get | 498 | * flush that changes context.tlb_gen from 2 to 3. If they get |
| 499 | * processed on this CPU in reverse order, we'll see | 499 | * processed on this CPU in reverse order, we'll see |
| 500 | * local_tlb_gen == 1, mm_tlb_gen == 3, and end != TLB_FLUSH_ALL. | 500 | * local_tlb_gen == 1, mm_tlb_gen == 3, and end != TLB_FLUSH_ALL. |
| 501 | * If we were to use __flush_tlb_single() and set local_tlb_gen to | 501 | * If we were to use __flush_tlb_one_user() and set local_tlb_gen to |
| 502 | * 3, we'd be break the invariant: we'd update local_tlb_gen above | 502 | * 3, we'd be break the invariant: we'd update local_tlb_gen above |
| 503 | * 1 without the full flush that's needed for tlb_gen 2. | 503 | * 1 without the full flush that's needed for tlb_gen 2. |
| 504 | * | 504 | * |
| @@ -519,7 +519,7 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, | |||
| 519 | 519 | ||
| 520 | addr = f->start; | 520 | addr = f->start; |
| 521 | while (addr < f->end) { | 521 | while (addr < f->end) { |
| 522 | __flush_tlb_single(addr); | 522 | __flush_tlb_one_user(addr); |
| 523 | addr += PAGE_SIZE; | 523 | addr += PAGE_SIZE; |
| 524 | } | 524 | } |
| 525 | if (local) | 525 | if (local) |
| @@ -666,7 +666,7 @@ static void do_kernel_range_flush(void *info) | |||
| 666 | 666 | ||
| 667 | /* flush range by one by one 'invlpg' */ | 667 | /* flush range by one by one 'invlpg' */ |
| 668 | for (addr = f->start; addr < f->end; addr += PAGE_SIZE) | 668 | for (addr = f->start; addr < f->end; addr += PAGE_SIZE) |
| 669 | __flush_tlb_one(addr); | 669 | __flush_tlb_one_kernel(addr); |
| 670 | } | 670 | } |
| 671 | 671 | ||
| 672 | void flush_tlb_kernel_range(unsigned long start, unsigned long end) | 672 | void flush_tlb_kernel_range(unsigned long start, unsigned long end) |
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index c2e9285d1bf1..db77e087adaf 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c | |||
| @@ -299,7 +299,7 @@ static void bau_process_message(struct msg_desc *mdp, struct bau_control *bcp, | |||
| 299 | local_flush_tlb(); | 299 | local_flush_tlb(); |
| 300 | stat->d_alltlb++; | 300 | stat->d_alltlb++; |
| 301 | } else { | 301 | } else { |
| 302 | __flush_tlb_single(msg->address); | 302 | __flush_tlb_one_user(msg->address); |
| 303 | stat->d_onetlb++; | 303 | stat->d_onetlb++; |
| 304 | } | 304 | } |
| 305 | stat->d_requestee++; | 305 | stat->d_requestee++; |
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index d85076223a69..aae88fec9941 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c | |||
| @@ -1300,12 +1300,12 @@ static void xen_flush_tlb(void) | |||
| 1300 | preempt_enable(); | 1300 | preempt_enable(); |
| 1301 | } | 1301 | } |
| 1302 | 1302 | ||
| 1303 | static void xen_flush_tlb_single(unsigned long addr) | 1303 | static void xen_flush_tlb_one_user(unsigned long addr) |
| 1304 | { | 1304 | { |
| 1305 | struct mmuext_op *op; | 1305 | struct mmuext_op *op; |
| 1306 | struct multicall_space mcs; | 1306 | struct multicall_space mcs; |
| 1307 | 1307 | ||
| 1308 | trace_xen_mmu_flush_tlb_single(addr); | 1308 | trace_xen_mmu_flush_tlb_one_user(addr); |
| 1309 | 1309 | ||
| 1310 | preempt_disable(); | 1310 | preempt_disable(); |
| 1311 | 1311 | ||
| @@ -2370,7 +2370,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = { | |||
| 2370 | 2370 | ||
| 2371 | .flush_tlb_user = xen_flush_tlb, | 2371 | .flush_tlb_user = xen_flush_tlb, |
| 2372 | .flush_tlb_kernel = xen_flush_tlb, | 2372 | .flush_tlb_kernel = xen_flush_tlb, |
| 2373 | .flush_tlb_single = xen_flush_tlb_single, | 2373 | .flush_tlb_one_user = xen_flush_tlb_one_user, |
| 2374 | .flush_tlb_others = xen_flush_tlb_others, | 2374 | .flush_tlb_others = xen_flush_tlb_others, |
| 2375 | 2375 | ||
| 2376 | .pgd_alloc = xen_pgd_alloc, | 2376 | .pgd_alloc = xen_pgd_alloc, |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 77c959cf81e7..7a43b2ae19f1 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
| @@ -122,6 +122,8 @@ void __init xen_smp_cpus_done(unsigned int max_cpus) | |||
| 122 | 122 | ||
| 123 | if (xen_hvm_domain()) | 123 | if (xen_hvm_domain()) |
| 124 | native_smp_cpus_done(max_cpus); | 124 | native_smp_cpus_done(max_cpus); |
| 125 | else | ||
| 126 | calculate_max_logical_packages(); | ||
| 125 | 127 | ||
| 126 | if (xen_have_vcpu_info_placement) | 128 | if (xen_have_vcpu_info_placement) |
| 127 | return; | 129 | return; |
diff --git a/block/blk-mq.c b/block/blk-mq.c index df93102e2149..357492712b0e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -3164,6 +3164,7 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq) | |||
| 3164 | cpu_relax(); | 3164 | cpu_relax(); |
| 3165 | } | 3165 | } |
| 3166 | 3166 | ||
| 3167 | __set_current_state(TASK_RUNNING); | ||
| 3167 | return false; | 3168 | return false; |
| 3168 | } | 3169 | } |
| 3169 | 3170 | ||
diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c index a965b9d80559..ded148783303 100644 --- a/crypto/sha3_generic.c +++ b/crypto/sha3_generic.c | |||
| @@ -20,6 +20,20 @@ | |||
| 20 | #include <crypto/sha3.h> | 20 | #include <crypto/sha3.h> |
| 21 | #include <asm/unaligned.h> | 21 | #include <asm/unaligned.h> |
| 22 | 22 | ||
| 23 | /* | ||
| 24 | * On some 32-bit architectures (mn10300 and h8300), GCC ends up using | ||
| 25 | * over 1 KB of stack if we inline the round calculation into the loop | ||
| 26 | * in keccakf(). On the other hand, on 64-bit architectures with plenty | ||
| 27 | * of [64-bit wide] general purpose registers, not inlining it severely | ||
| 28 | * hurts performance. So let's use 64-bitness as a heuristic to decide | ||
| 29 | * whether to inline or not. | ||
| 30 | */ | ||
| 31 | #ifdef CONFIG_64BIT | ||
| 32 | #define SHA3_INLINE inline | ||
| 33 | #else | ||
| 34 | #define SHA3_INLINE noinline | ||
| 35 | #endif | ||
| 36 | |||
| 23 | #define KECCAK_ROUNDS 24 | 37 | #define KECCAK_ROUNDS 24 |
| 24 | 38 | ||
| 25 | static const u64 keccakf_rndc[24] = { | 39 | static const u64 keccakf_rndc[24] = { |
| @@ -35,111 +49,115 @@ static const u64 keccakf_rndc[24] = { | |||
| 35 | 49 | ||
| 36 | /* update the state with given number of rounds */ | 50 | /* update the state with given number of rounds */ |
| 37 | 51 | ||
| 38 | static void __attribute__((__optimize__("O3"))) keccakf(u64 st[25]) | 52 | static SHA3_INLINE void keccakf_round(u64 st[25]) |
| 39 | { | 53 | { |
| 40 | u64 t[5], tt, bc[5]; | 54 | u64 t[5], tt, bc[5]; |
| 41 | int round; | ||
| 42 | 55 | ||
| 43 | for (round = 0; round < KECCAK_ROUNDS; round++) { | 56 | /* Theta */ |
| 57 | bc[0] = st[0] ^ st[5] ^ st[10] ^ st[15] ^ st[20]; | ||
| 58 | bc[1] = st[1] ^ st[6] ^ st[11] ^ st[16] ^ st[21]; | ||
| 59 | bc[2] = st[2] ^ st[7] ^ st[12] ^ st[17] ^ st[22]; | ||
| 60 | bc[3] = st[3] ^ st[8] ^ st[13] ^ st[18] ^ st[23]; | ||
| 61 | bc[4] = st[4] ^ st[9] ^ st[14] ^ st[19] ^ st[24]; | ||
| 62 | |||
| 63 | t[0] = bc[4] ^ rol64(bc[1], 1); | ||
| 64 | t[1] = bc[0] ^ rol64(bc[2], 1); | ||
| 65 | t[2] = bc[1] ^ rol64(bc[3], 1); | ||
| 66 | t[3] = bc[2] ^ rol64(bc[4], 1); | ||
| 67 | t[4] = bc[3] ^ rol64(bc[0], 1); | ||
| 68 | |||
| 69 | st[0] ^= t[0]; | ||
| 70 | |||
| 71 | /* Rho Pi */ | ||
| 72 | tt = st[1]; | ||
| 73 | st[ 1] = rol64(st[ 6] ^ t[1], 44); | ||
| 74 | st[ 6] = rol64(st[ 9] ^ t[4], 20); | ||
| 75 | st[ 9] = rol64(st[22] ^ t[2], 61); | ||
| 76 | st[22] = rol64(st[14] ^ t[4], 39); | ||
| 77 | st[14] = rol64(st[20] ^ t[0], 18); | ||
| 78 | st[20] = rol64(st[ 2] ^ t[2], 62); | ||
| 79 | st[ 2] = rol64(st[12] ^ t[2], 43); | ||
| 80 | st[12] = rol64(st[13] ^ t[3], 25); | ||
| 81 | st[13] = rol64(st[19] ^ t[4], 8); | ||
| 82 | st[19] = rol64(st[23] ^ t[3], 56); | ||
| 83 | st[23] = rol64(st[15] ^ t[0], 41); | ||
| 84 | st[15] = rol64(st[ 4] ^ t[4], 27); | ||
| 85 | st[ 4] = rol64(st[24] ^ t[4], 14); | ||
| 86 | st[24] = rol64(st[21] ^ t[1], 2); | ||
| 87 | st[21] = rol64(st[ 8] ^ t[3], 55); | ||
| 88 | st[ 8] = rol64(st[16] ^ t[1], 45); | ||
| 89 | st[16] = rol64(st[ 5] ^ t[0], 36); | ||
| 90 | st[ 5] = rol64(st[ 3] ^ t[3], 28); | ||
| 91 | st[ 3] = rol64(st[18] ^ t[3], 21); | ||
| 92 | st[18] = rol64(st[17] ^ t[2], 15); | ||
| 93 | st[17] = rol64(st[11] ^ t[1], 10); | ||
| 94 | st[11] = rol64(st[ 7] ^ t[2], 6); | ||
| 95 | st[ 7] = rol64(st[10] ^ t[0], 3); | ||
| 96 | st[10] = rol64( tt ^ t[1], 1); | ||
| 97 | |||
| 98 | /* Chi */ | ||
| 99 | bc[ 0] = ~st[ 1] & st[ 2]; | ||
| 100 | bc[ 1] = ~st[ 2] & st[ 3]; | ||
| 101 | bc[ 2] = ~st[ 3] & st[ 4]; | ||
| 102 | bc[ 3] = ~st[ 4] & st[ 0]; | ||
| 103 | bc[ 4] = ~st[ 0] & st[ 1]; | ||
| 104 | st[ 0] ^= bc[ 0]; | ||
| 105 | st[ 1] ^= bc[ 1]; | ||
| 106 | st[ 2] ^= bc[ 2]; | ||
| 107 | st[ 3] ^= bc[ 3]; | ||
| 108 | st[ 4] ^= bc[ 4]; | ||
| 109 | |||
| 110 | bc[ 0] = ~st[ 6] & st[ 7]; | ||
| 111 | bc[ 1] = ~st[ 7] & st[ 8]; | ||
| 112 | bc[ 2] = ~st[ 8] & st[ 9]; | ||
| 113 | bc[ 3] = ~st[ 9] & st[ 5]; | ||
| 114 | bc[ 4] = ~st[ 5] & st[ 6]; | ||
| 115 | st[ 5] ^= bc[ 0]; | ||
| 116 | st[ 6] ^= bc[ 1]; | ||
| 117 | st[ 7] ^= bc[ 2]; | ||
| 118 | st[ 8] ^= bc[ 3]; | ||
| 119 | st[ 9] ^= bc[ 4]; | ||
| 120 | |||
| 121 | bc[ 0] = ~st[11] & st[12]; | ||
| 122 | bc[ 1] = ~st[12] & st[13]; | ||
| 123 | bc[ 2] = ~st[13] & st[14]; | ||
| 124 | bc[ 3] = ~st[14] & st[10]; | ||
| 125 | bc[ 4] = ~st[10] & st[11]; | ||
| 126 | st[10] ^= bc[ 0]; | ||
| 127 | st[11] ^= bc[ 1]; | ||
| 128 | st[12] ^= bc[ 2]; | ||
| 129 | st[13] ^= bc[ 3]; | ||
| 130 | st[14] ^= bc[ 4]; | ||
| 131 | |||
| 132 | bc[ 0] = ~st[16] & st[17]; | ||
| 133 | bc[ 1] = ~st[17] & st[18]; | ||
| 134 | bc[ 2] = ~st[18] & st[19]; | ||
| 135 | bc[ 3] = ~st[19] & st[15]; | ||
| 136 | bc[ 4] = ~st[15] & st[16]; | ||
| 137 | st[15] ^= bc[ 0]; | ||
| 138 | st[16] ^= bc[ 1]; | ||
| 139 | st[17] ^= bc[ 2]; | ||
| 140 | st[18] ^= bc[ 3]; | ||
| 141 | st[19] ^= bc[ 4]; | ||
| 142 | |||
| 143 | bc[ 0] = ~st[21] & st[22]; | ||
| 144 | bc[ 1] = ~st[22] & st[23]; | ||
| 145 | bc[ 2] = ~st[23] & st[24]; | ||
| 146 | bc[ 3] = ~st[24] & st[20]; | ||
| 147 | bc[ 4] = ~st[20] & st[21]; | ||
| 148 | st[20] ^= bc[ 0]; | ||
| 149 | st[21] ^= bc[ 1]; | ||
| 150 | st[22] ^= bc[ 2]; | ||
| 151 | st[23] ^= bc[ 3]; | ||
| 152 | st[24] ^= bc[ 4]; | ||
| 153 | } | ||
| 44 | 154 | ||
| 45 | /* Theta */ | 155 | static void __optimize("O3") keccakf(u64 st[25]) |
| 46 | bc[0] = st[0] ^ st[5] ^ st[10] ^ st[15] ^ st[20]; | 156 | { |
| 47 | bc[1] = st[1] ^ st[6] ^ st[11] ^ st[16] ^ st[21]; | 157 | int round; |
| 48 | bc[2] = st[2] ^ st[7] ^ st[12] ^ st[17] ^ st[22]; | ||
| 49 | bc[3] = st[3] ^ st[8] ^ st[13] ^ st[18] ^ st[23]; | ||
| 50 | bc[4] = st[4] ^ st[9] ^ st[14] ^ st[19] ^ st[24]; | ||
| 51 | |||
| 52 | t[0] = bc[4] ^ rol64(bc[1], 1); | ||
| 53 | t[1] = bc[0] ^ rol64(bc[2], 1); | ||
| 54 | t[2] = bc[1] ^ rol64(bc[3], 1); | ||
| 55 | t[3] = bc[2] ^ rol64(bc[4], 1); | ||
| 56 | t[4] = bc[3] ^ rol64(bc[0], 1); | ||
| 57 | |||
| 58 | st[0] ^= t[0]; | ||
| 59 | |||
| 60 | /* Rho Pi */ | ||
| 61 | tt = st[1]; | ||
| 62 | st[ 1] = rol64(st[ 6] ^ t[1], 44); | ||
| 63 | st[ 6] = rol64(st[ 9] ^ t[4], 20); | ||
| 64 | st[ 9] = rol64(st[22] ^ t[2], 61); | ||
| 65 | st[22] = rol64(st[14] ^ t[4], 39); | ||
| 66 | st[14] = rol64(st[20] ^ t[0], 18); | ||
| 67 | st[20] = rol64(st[ 2] ^ t[2], 62); | ||
| 68 | st[ 2] = rol64(st[12] ^ t[2], 43); | ||
| 69 | st[12] = rol64(st[13] ^ t[3], 25); | ||
| 70 | st[13] = rol64(st[19] ^ t[4], 8); | ||
| 71 | st[19] = rol64(st[23] ^ t[3], 56); | ||
| 72 | st[23] = rol64(st[15] ^ t[0], 41); | ||
| 73 | st[15] = rol64(st[ 4] ^ t[4], 27); | ||
| 74 | st[ 4] = rol64(st[24] ^ t[4], 14); | ||
| 75 | st[24] = rol64(st[21] ^ t[1], 2); | ||
| 76 | st[21] = rol64(st[ 8] ^ t[3], 55); | ||
| 77 | st[ 8] = rol64(st[16] ^ t[1], 45); | ||
| 78 | st[16] = rol64(st[ 5] ^ t[0], 36); | ||
| 79 | st[ 5] = rol64(st[ 3] ^ t[3], 28); | ||
| 80 | st[ 3] = rol64(st[18] ^ t[3], 21); | ||
| 81 | st[18] = rol64(st[17] ^ t[2], 15); | ||
| 82 | st[17] = rol64(st[11] ^ t[1], 10); | ||
| 83 | st[11] = rol64(st[ 7] ^ t[2], 6); | ||
| 84 | st[ 7] = rol64(st[10] ^ t[0], 3); | ||
| 85 | st[10] = rol64( tt ^ t[1], 1); | ||
| 86 | |||
| 87 | /* Chi */ | ||
| 88 | bc[ 0] = ~st[ 1] & st[ 2]; | ||
| 89 | bc[ 1] = ~st[ 2] & st[ 3]; | ||
| 90 | bc[ 2] = ~st[ 3] & st[ 4]; | ||
| 91 | bc[ 3] = ~st[ 4] & st[ 0]; | ||
| 92 | bc[ 4] = ~st[ 0] & st[ 1]; | ||
| 93 | st[ 0] ^= bc[ 0]; | ||
| 94 | st[ 1] ^= bc[ 1]; | ||
| 95 | st[ 2] ^= bc[ 2]; | ||
| 96 | st[ 3] ^= bc[ 3]; | ||
| 97 | st[ 4] ^= bc[ 4]; | ||
| 98 | |||
| 99 | bc[ 0] = ~st[ 6] & st[ 7]; | ||
| 100 | bc[ 1] = ~st[ 7] & st[ 8]; | ||
| 101 | bc[ 2] = ~st[ 8] & st[ 9]; | ||
| 102 | bc[ 3] = ~st[ 9] & st[ 5]; | ||
| 103 | bc[ 4] = ~st[ 5] & st[ 6]; | ||
| 104 | st[ 5] ^= bc[ 0]; | ||
| 105 | st[ 6] ^= bc[ 1]; | ||
| 106 | st[ 7] ^= bc[ 2]; | ||
| 107 | st[ 8] ^= bc[ 3]; | ||
| 108 | st[ 9] ^= bc[ 4]; | ||
| 109 | |||
| 110 | bc[ 0] = ~st[11] & st[12]; | ||
| 111 | bc[ 1] = ~st[12] & st[13]; | ||
| 112 | bc[ 2] = ~st[13] & st[14]; | ||
| 113 | bc[ 3] = ~st[14] & st[10]; | ||
| 114 | bc[ 4] = ~st[10] & st[11]; | ||
| 115 | st[10] ^= bc[ 0]; | ||
| 116 | st[11] ^= bc[ 1]; | ||
| 117 | st[12] ^= bc[ 2]; | ||
| 118 | st[13] ^= bc[ 3]; | ||
| 119 | st[14] ^= bc[ 4]; | ||
| 120 | |||
| 121 | bc[ 0] = ~st[16] & st[17]; | ||
| 122 | bc[ 1] = ~st[17] & st[18]; | ||
| 123 | bc[ 2] = ~st[18] & st[19]; | ||
| 124 | bc[ 3] = ~st[19] & st[15]; | ||
| 125 | bc[ 4] = ~st[15] & st[16]; | ||
| 126 | st[15] ^= bc[ 0]; | ||
| 127 | st[16] ^= bc[ 1]; | ||
| 128 | st[17] ^= bc[ 2]; | ||
| 129 | st[18] ^= bc[ 3]; | ||
| 130 | st[19] ^= bc[ 4]; | ||
| 131 | |||
| 132 | bc[ 0] = ~st[21] & st[22]; | ||
| 133 | bc[ 1] = ~st[22] & st[23]; | ||
| 134 | bc[ 2] = ~st[23] & st[24]; | ||
| 135 | bc[ 3] = ~st[24] & st[20]; | ||
| 136 | bc[ 4] = ~st[20] & st[21]; | ||
| 137 | st[20] ^= bc[ 0]; | ||
| 138 | st[21] ^= bc[ 1]; | ||
| 139 | st[22] ^= bc[ 2]; | ||
| 140 | st[23] ^= bc[ 3]; | ||
| 141 | st[24] ^= bc[ 4]; | ||
| 142 | 158 | ||
| 159 | for (round = 0; round < KECCAK_ROUNDS; round++) { | ||
| 160 | keccakf_round(st); | ||
| 143 | /* Iota */ | 161 | /* Iota */ |
| 144 | st[0] ^= keccakf_rndc[round]; | 162 | st[0] ^= keccakf_rndc[round]; |
| 145 | } | 163 | } |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 676c9788e1c8..0dad0bd9327b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
| @@ -660,13 +660,15 @@ struct acpi_device *acpi_companion_match(const struct device *dev) | |||
| 660 | * acpi_of_match_device - Match device object using the "compatible" property. | 660 | * acpi_of_match_device - Match device object using the "compatible" property. |
| 661 | * @adev: ACPI device object to match. | 661 | * @adev: ACPI device object to match. |
| 662 | * @of_match_table: List of device IDs to match against. | 662 | * @of_match_table: List of device IDs to match against. |
| 663 | * @of_id: OF ID if matched | ||
| 663 | * | 664 | * |
| 664 | * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of | 665 | * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of |
| 665 | * identifiers and a _DSD object with the "compatible" property, use that | 666 | * identifiers and a _DSD object with the "compatible" property, use that |
| 666 | * property to match against the given list of identifiers. | 667 | * property to match against the given list of identifiers. |
| 667 | */ | 668 | */ |
| 668 | static bool acpi_of_match_device(struct acpi_device *adev, | 669 | static bool acpi_of_match_device(struct acpi_device *adev, |
| 669 | const struct of_device_id *of_match_table) | 670 | const struct of_device_id *of_match_table, |
| 671 | const struct of_device_id **of_id) | ||
| 670 | { | 672 | { |
| 671 | const union acpi_object *of_compatible, *obj; | 673 | const union acpi_object *of_compatible, *obj; |
| 672 | int i, nval; | 674 | int i, nval; |
| @@ -690,8 +692,11 @@ static bool acpi_of_match_device(struct acpi_device *adev, | |||
| 690 | const struct of_device_id *id; | 692 | const struct of_device_id *id; |
| 691 | 693 | ||
| 692 | for (id = of_match_table; id->compatible[0]; id++) | 694 | for (id = of_match_table; id->compatible[0]; id++) |
| 693 | if (!strcasecmp(obj->string.pointer, id->compatible)) | 695 | if (!strcasecmp(obj->string.pointer, id->compatible)) { |
| 696 | if (of_id) | ||
| 697 | *of_id = id; | ||
| 694 | return true; | 698 | return true; |
| 699 | } | ||
| 695 | } | 700 | } |
| 696 | 701 | ||
| 697 | return false; | 702 | return false; |
| @@ -762,10 +767,11 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id, | |||
| 762 | return true; | 767 | return true; |
| 763 | } | 768 | } |
| 764 | 769 | ||
| 765 | static const struct acpi_device_id *__acpi_match_device( | 770 | static bool __acpi_match_device(struct acpi_device *device, |
| 766 | struct acpi_device *device, | 771 | const struct acpi_device_id *acpi_ids, |
| 767 | const struct acpi_device_id *ids, | 772 | const struct of_device_id *of_ids, |
| 768 | const struct of_device_id *of_ids) | 773 | const struct acpi_device_id **acpi_id, |
| 774 | const struct of_device_id **of_id) | ||
| 769 | { | 775 | { |
| 770 | const struct acpi_device_id *id; | 776 | const struct acpi_device_id *id; |
| 771 | struct acpi_hardware_id *hwid; | 777 | struct acpi_hardware_id *hwid; |
| @@ -775,30 +781,32 @@ static const struct acpi_device_id *__acpi_match_device( | |||
| 775 | * driver for it. | 781 | * driver for it. |
| 776 | */ | 782 | */ |
| 777 | if (!device || !device->status.present) | 783 | if (!device || !device->status.present) |
| 778 | return NULL; | 784 | return false; |
| 779 | 785 | ||
| 780 | list_for_each_entry(hwid, &device->pnp.ids, list) { | 786 | list_for_each_entry(hwid, &device->pnp.ids, list) { |
| 781 | /* First, check the ACPI/PNP IDs provided by the caller. */ | 787 | /* First, check the ACPI/PNP IDs provided by the caller. */ |
| 782 | for (id = ids; id->id[0] || id->cls; id++) { | 788 | if (acpi_ids) { |
| 783 | if (id->id[0] && !strcmp((char *) id->id, hwid->id)) | 789 | for (id = acpi_ids; id->id[0] || id->cls; id++) { |
| 784 | return id; | 790 | if (id->id[0] && !strcmp((char *)id->id, hwid->id)) |
| 785 | else if (id->cls && __acpi_match_device_cls(id, hwid)) | 791 | goto out_acpi_match; |
| 786 | return id; | 792 | if (id->cls && __acpi_match_device_cls(id, hwid)) |
| 793 | goto out_acpi_match; | ||
| 794 | } | ||
| 787 | } | 795 | } |
| 788 | 796 | ||
| 789 | /* | 797 | /* |
| 790 | * Next, check ACPI_DT_NAMESPACE_HID and try to match the | 798 | * Next, check ACPI_DT_NAMESPACE_HID and try to match the |
| 791 | * "compatible" property if found. | 799 | * "compatible" property if found. |
| 792 | * | ||
| 793 | * The id returned by the below is not valid, but the only | ||
| 794 | * caller passing non-NULL of_ids here is only interested in | ||
| 795 | * whether or not the return value is NULL. | ||
| 796 | */ | 800 | */ |
| 797 | if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id) | 801 | if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id)) |
| 798 | && acpi_of_match_device(device, of_ids)) | 802 | return acpi_of_match_device(device, of_ids, of_id); |
| 799 | return id; | ||
| 800 | } | 803 | } |
| 801 | return NULL; | 804 | return false; |
| 805 | |||
| 806 | out_acpi_match: | ||
| 807 | if (acpi_id) | ||
| 808 | *acpi_id = id; | ||
| 809 | return true; | ||
| 802 | } | 810 | } |
| 803 | 811 | ||
| 804 | /** | 812 | /** |
| @@ -815,32 +823,29 @@ static const struct acpi_device_id *__acpi_match_device( | |||
| 815 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, | 823 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, |
| 816 | const struct device *dev) | 824 | const struct device *dev) |
| 817 | { | 825 | { |
| 818 | return __acpi_match_device(acpi_companion_match(dev), ids, NULL); | 826 | const struct acpi_device_id *id = NULL; |
| 827 | |||
| 828 | __acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL); | ||
| 829 | return id; | ||
| 819 | } | 830 | } |
| 820 | EXPORT_SYMBOL_GPL(acpi_match_device); | 831 | EXPORT_SYMBOL_GPL(acpi_match_device); |
| 821 | 832 | ||
| 822 | void *acpi_get_match_data(const struct device *dev) | 833 | const void *acpi_device_get_match_data(const struct device *dev) |
| 823 | { | 834 | { |
| 824 | const struct acpi_device_id *match; | 835 | const struct acpi_device_id *match; |
| 825 | 836 | ||
| 826 | if (!dev->driver) | ||
| 827 | return NULL; | ||
| 828 | |||
| 829 | if (!dev->driver->acpi_match_table) | ||
| 830 | return NULL; | ||
| 831 | |||
| 832 | match = acpi_match_device(dev->driver->acpi_match_table, dev); | 837 | match = acpi_match_device(dev->driver->acpi_match_table, dev); |
| 833 | if (!match) | 838 | if (!match) |
| 834 | return NULL; | 839 | return NULL; |
| 835 | 840 | ||
| 836 | return (void *)match->driver_data; | 841 | return (const void *)match->driver_data; |
| 837 | } | 842 | } |
| 838 | EXPORT_SYMBOL_GPL(acpi_get_match_data); | 843 | EXPORT_SYMBOL_GPL(acpi_device_get_match_data); |
| 839 | 844 | ||
| 840 | int acpi_match_device_ids(struct acpi_device *device, | 845 | int acpi_match_device_ids(struct acpi_device *device, |
| 841 | const struct acpi_device_id *ids) | 846 | const struct acpi_device_id *ids) |
| 842 | { | 847 | { |
| 843 | return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT; | 848 | return __acpi_match_device(device, ids, NULL, NULL, NULL) ? 0 : -ENOENT; |
| 844 | } | 849 | } |
| 845 | EXPORT_SYMBOL(acpi_match_device_ids); | 850 | EXPORT_SYMBOL(acpi_match_device_ids); |
| 846 | 851 | ||
| @@ -849,10 +854,12 @@ bool acpi_driver_match_device(struct device *dev, | |||
| 849 | { | 854 | { |
| 850 | if (!drv->acpi_match_table) | 855 | if (!drv->acpi_match_table) |
| 851 | return acpi_of_match_device(ACPI_COMPANION(dev), | 856 | return acpi_of_match_device(ACPI_COMPANION(dev), |
| 852 | drv->of_match_table); | 857 | drv->of_match_table, |
| 858 | NULL); | ||
| 853 | 859 | ||
| 854 | return !!__acpi_match_device(acpi_companion_match(dev), | 860 | return __acpi_match_device(acpi_companion_match(dev), |
| 855 | drv->acpi_match_table, drv->of_match_table); | 861 | drv->acpi_match_table, drv->of_match_table, |
| 862 | NULL, NULL); | ||
| 856 | } | 863 | } |
| 857 | EXPORT_SYMBOL_GPL(acpi_driver_match_device); | 864 | EXPORT_SYMBOL_GPL(acpi_driver_match_device); |
| 858 | 865 | ||
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d9f38c645e4a..30a572956557 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
| @@ -1927,6 +1927,9 @@ static int acpi_ec_suspend_noirq(struct device *dev) | |||
| 1927 | ec->reference_count >= 1) | 1927 | ec->reference_count >= 1) |
| 1928 | acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE); | 1928 | acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE); |
| 1929 | 1929 | ||
| 1930 | if (acpi_sleep_no_ec_events()) | ||
| 1931 | acpi_ec_enter_noirq(ec); | ||
| 1932 | |||
| 1930 | return 0; | 1933 | return 0; |
| 1931 | } | 1934 | } |
| 1932 | 1935 | ||
| @@ -1934,6 +1937,9 @@ static int acpi_ec_resume_noirq(struct device *dev) | |||
| 1934 | { | 1937 | { |
| 1935 | struct acpi_ec *ec = acpi_driver_data(to_acpi_device(dev)); | 1938 | struct acpi_ec *ec = acpi_driver_data(to_acpi_device(dev)); |
| 1936 | 1939 | ||
| 1940 | if (acpi_sleep_no_ec_events()) | ||
| 1941 | acpi_ec_leave_noirq(ec); | ||
| 1942 | |||
| 1937 | if (ec_no_wakeup && test_bit(EC_FLAGS_STARTED, &ec->flags) && | 1943 | if (ec_no_wakeup && test_bit(EC_FLAGS_STARTED, &ec->flags) && |
| 1938 | ec->reference_count >= 1) | 1944 | ec->reference_count >= 1) |
| 1939 | acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE); | 1945 | acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE); |
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 466d1503aba0..5815356ea6ad 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c | |||
| @@ -1271,11 +1271,11 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, | |||
| 1271 | return 0; | 1271 | return 0; |
| 1272 | } | 1272 | } |
| 1273 | 1273 | ||
| 1274 | static void * | 1274 | static const void * |
| 1275 | acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, | 1275 | acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, |
| 1276 | const struct device *dev) | 1276 | const struct device *dev) |
| 1277 | { | 1277 | { |
| 1278 | return acpi_get_match_data(dev); | 1278 | return acpi_device_get_match_data(dev); |
| 1279 | } | 1279 | } |
| 1280 | 1280 | ||
| 1281 | #define DECLARE_ACPI_FWNODE_OPS(ops) \ | 1281 | #define DECLARE_ACPI_FWNODE_OPS(ops) \ |
diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index 89e97d21a89c..9d52743080a4 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c | |||
| @@ -115,6 +115,7 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console) | |||
| 115 | table->serial_port.access_width))) { | 115 | table->serial_port.access_width))) { |
| 116 | default: | 116 | default: |
| 117 | pr_err("Unexpected SPCR Access Width. Defaulting to byte size\n"); | 117 | pr_err("Unexpected SPCR Access Width. Defaulting to byte size\n"); |
| 118 | /* fall through */ | ||
| 118 | case 8: | 119 | case 8: |
| 119 | iotype = "mmio"; | 120 | iotype = "mmio"; |
| 120 | break; | 121 | break; |
diff --git a/drivers/base/core.c b/drivers/base/core.c index b2261f92f2f1..5847364f25d9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
| @@ -310,6 +310,9 @@ static void __device_link_del(struct device_link *link) | |||
| 310 | dev_info(link->consumer, "Dropping the link to %s\n", | 310 | dev_info(link->consumer, "Dropping the link to %s\n", |
| 311 | dev_name(link->supplier)); | 311 | dev_name(link->supplier)); |
| 312 | 312 | ||
| 313 | if (link->flags & DL_FLAG_PM_RUNTIME) | ||
| 314 | pm_runtime_drop_link(link->consumer); | ||
| 315 | |||
| 313 | list_del(&link->s_node); | 316 | list_del(&link->s_node); |
| 314 | list_del(&link->c_node); | 317 | list_del(&link->c_node); |
| 315 | device_link_free(link); | 318 | device_link_free(link); |
diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c index a8ac86e4d79e..6637fc319269 100644 --- a/drivers/base/power/wakeirq.c +++ b/drivers/base/power/wakeirq.c | |||
| @@ -321,7 +321,8 @@ void dev_pm_arm_wake_irq(struct wake_irq *wirq) | |||
| 321 | return; | 321 | return; |
| 322 | 322 | ||
| 323 | if (device_may_wakeup(wirq->dev)) { | 323 | if (device_may_wakeup(wirq->dev)) { |
| 324 | if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED) | 324 | if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED && |
| 325 | !pm_runtime_status_suspended(wirq->dev)) | ||
| 325 | enable_irq(wirq->irq); | 326 | enable_irq(wirq->irq); |
| 326 | 327 | ||
| 327 | enable_irq_wake(wirq->irq); | 328 | enable_irq_wake(wirq->irq); |
| @@ -343,7 +344,8 @@ void dev_pm_disarm_wake_irq(struct wake_irq *wirq) | |||
| 343 | if (device_may_wakeup(wirq->dev)) { | 344 | if (device_may_wakeup(wirq->dev)) { |
| 344 | disable_irq_wake(wirq->irq); | 345 | disable_irq_wake(wirq->irq); |
| 345 | 346 | ||
| 346 | if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED) | 347 | if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED && |
| 348 | !pm_runtime_status_suspended(wirq->dev)) | ||
| 347 | disable_irq_nosync(wirq->irq); | 349 | disable_irq_nosync(wirq->irq); |
| 348 | } | 350 | } |
| 349 | } | 351 | } |
diff --git a/drivers/base/property.c b/drivers/base/property.c index 302236281d83..8f205f6461ed 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
| @@ -1410,9 +1410,8 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, | |||
| 1410 | } | 1410 | } |
| 1411 | EXPORT_SYMBOL(fwnode_graph_parse_endpoint); | 1411 | EXPORT_SYMBOL(fwnode_graph_parse_endpoint); |
| 1412 | 1412 | ||
| 1413 | void *device_get_match_data(struct device *dev) | 1413 | const void *device_get_match_data(struct device *dev) |
| 1414 | { | 1414 | { |
| 1415 | return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, | 1415 | return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); |
| 1416 | dev); | ||
| 1417 | } | 1416 | } |
| 1418 | EXPORT_SYMBOL_GPL(device_get_match_data); | 1417 | EXPORT_SYMBOL_GPL(device_get_match_data); |
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index d1f5bb534e0e..6e9df558325b 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c | |||
| @@ -162,7 +162,7 @@ static int via_rng_init(struct hwrng *rng) | |||
| 162 | /* Enable secondary noise source on CPUs where it is present. */ | 162 | /* Enable secondary noise source on CPUs where it is present. */ |
| 163 | 163 | ||
| 164 | /* Nehemiah stepping 8 and higher */ | 164 | /* Nehemiah stepping 8 and higher */ |
| 165 | if ((c->x86_model == 9) && (c->x86_mask > 7)) | 165 | if ((c->x86_model == 9) && (c->x86_stepping > 7)) |
| 166 | lo |= VIA_NOISESRC2; | 166 | lo |= VIA_NOISESRC2; |
| 167 | 167 | ||
| 168 | /* Esther */ | 168 | /* Esther */ |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 3a2ca0f79daf..d0c34df0529c 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -629,7 +629,7 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) | |||
| 629 | if (c->x86_vendor == X86_VENDOR_INTEL) { | 629 | if (c->x86_vendor == X86_VENDOR_INTEL) { |
| 630 | if ((c->x86 == 15) && | 630 | if ((c->x86 == 15) && |
| 631 | (c->x86_model == 6) && | 631 | (c->x86_model == 6) && |
| 632 | (c->x86_mask == 8)) { | 632 | (c->x86_stepping == 8)) { |
| 633 | pr_info("Intel(R) Xeon(R) 7100 Errata AL30, processors may lock up on frequency changes: disabling acpi-cpufreq\n"); | 633 | pr_info("Intel(R) Xeon(R) 7100 Errata AL30, processors may lock up on frequency changes: disabling acpi-cpufreq\n"); |
| 634 | return -ENODEV; | 634 | return -ENODEV; |
| 635 | } | 635 | } |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 942632a27b50..f730b6528c18 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
| @@ -775,7 +775,7 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 775 | break; | 775 | break; |
| 776 | 776 | ||
| 777 | case 7: | 777 | case 7: |
| 778 | switch (c->x86_mask) { | 778 | switch (c->x86_stepping) { |
| 779 | case 0: | 779 | case 0: |
| 780 | longhaul_version = TYPE_LONGHAUL_V1; | 780 | longhaul_version = TYPE_LONGHAUL_V1; |
| 781 | cpu_model = CPU_SAMUEL2; | 781 | cpu_model = CPU_SAMUEL2; |
| @@ -787,7 +787,7 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 787 | break; | 787 | break; |
| 788 | case 1 ... 15: | 788 | case 1 ... 15: |
| 789 | longhaul_version = TYPE_LONGHAUL_V2; | 789 | longhaul_version = TYPE_LONGHAUL_V2; |
| 790 | if (c->x86_mask < 8) { | 790 | if (c->x86_stepping < 8) { |
| 791 | cpu_model = CPU_SAMUEL2; | 791 | cpu_model = CPU_SAMUEL2; |
| 792 | cpuname = "C3 'Samuel 2' [C5B]"; | 792 | cpuname = "C3 'Samuel 2' [C5B]"; |
| 793 | } else { | 793 | } else { |
| @@ -814,7 +814,7 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 814 | numscales = 32; | 814 | numscales = 32; |
| 815 | memcpy(mults, nehemiah_mults, sizeof(nehemiah_mults)); | 815 | memcpy(mults, nehemiah_mults, sizeof(nehemiah_mults)); |
| 816 | memcpy(eblcr, nehemiah_eblcr, sizeof(nehemiah_eblcr)); | 816 | memcpy(eblcr, nehemiah_eblcr, sizeof(nehemiah_eblcr)); |
| 817 | switch (c->x86_mask) { | 817 | switch (c->x86_stepping) { |
| 818 | case 0 ... 1: | 818 | case 0 ... 1: |
| 819 | cpu_model = CPU_NEHEMIAH; | 819 | cpu_model = CPU_NEHEMIAH; |
| 820 | cpuname = "C3 'Nehemiah A' [C5XLOE]"; | 820 | cpuname = "C3 'Nehemiah A' [C5XLOE]"; |
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index fd77812313f3..a25741b1281b 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
| @@ -168,7 +168,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) | |||
| 168 | #endif | 168 | #endif |
| 169 | 169 | ||
| 170 | /* Errata workaround */ | 170 | /* Errata workaround */ |
| 171 | cpuid = (c->x86 << 8) | (c->x86_model << 4) | c->x86_mask; | 171 | cpuid = (c->x86 << 8) | (c->x86_model << 4) | c->x86_stepping; |
| 172 | switch (cpuid) { | 172 | switch (cpuid) { |
| 173 | case 0x0f07: | 173 | case 0x0f07: |
| 174 | case 0x0f0a: | 174 | case 0x0f0a: |
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 80ac313e6c59..302e9ce793a0 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
| @@ -131,7 +131,7 @@ static int check_powernow(void) | |||
| 131 | return 0; | 131 | return 0; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | if ((c->x86_model == 6) && (c->x86_mask == 0)) { | 134 | if ((c->x86_model == 6) && (c->x86_stepping == 0)) { |
| 135 | pr_info("K7 660[A0] core detected, enabling errata workarounds\n"); | 135 | pr_info("K7 660[A0] core detected, enabling errata workarounds\n"); |
| 136 | have_a0 = 1; | 136 | have_a0 = 1; |
| 137 | } | 137 | } |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 41bc5397f4bb..4fa5adf16c70 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
| @@ -37,7 +37,7 @@ struct cpu_id | |||
| 37 | { | 37 | { |
| 38 | __u8 x86; /* CPU family */ | 38 | __u8 x86; /* CPU family */ |
| 39 | __u8 x86_model; /* model */ | 39 | __u8 x86_model; /* model */ |
| 40 | __u8 x86_mask; /* stepping */ | 40 | __u8 x86_stepping; /* stepping */ |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | enum { | 43 | enum { |
| @@ -277,7 +277,7 @@ static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, | |||
| 277 | { | 277 | { |
| 278 | if ((c->x86 == x->x86) && | 278 | if ((c->x86 == x->x86) && |
| 279 | (c->x86_model == x->x86_model) && | 279 | (c->x86_model == x->x86_model) && |
| 280 | (c->x86_mask == x->x86_mask)) | 280 | (c->x86_stepping == x->x86_stepping)) |
| 281 | return 1; | 281 | return 1; |
| 282 | return 0; | 282 | return 0; |
| 283 | } | 283 | } |
diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-lib.c index 8085ec9000d1..e3a9962ee410 100644 --- a/drivers/cpufreq/speedstep-lib.c +++ b/drivers/cpufreq/speedstep-lib.c | |||
| @@ -272,9 +272,9 @@ unsigned int speedstep_detect_processor(void) | |||
| 272 | ebx = cpuid_ebx(0x00000001); | 272 | ebx = cpuid_ebx(0x00000001); |
| 273 | ebx &= 0x000000FF; | 273 | ebx &= 0x000000FF; |
| 274 | 274 | ||
| 275 | pr_debug("ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask); | 275 | pr_debug("ebx value is %x, x86_stepping is %x\n", ebx, c->x86_stepping); |
| 276 | 276 | ||
| 277 | switch (c->x86_mask) { | 277 | switch (c->x86_stepping) { |
| 278 | case 4: | 278 | case 4: |
| 279 | /* | 279 | /* |
| 280 | * B-stepping [M-P4-M] | 280 | * B-stepping [M-P4-M] |
| @@ -361,7 +361,7 @@ unsigned int speedstep_detect_processor(void) | |||
| 361 | msr_lo, msr_hi); | 361 | msr_lo, msr_hi); |
| 362 | if ((msr_hi & (1<<18)) && | 362 | if ((msr_hi & (1<<18)) && |
| 363 | (relaxed_check ? 1 : (msr_hi & (3<<24)))) { | 363 | (relaxed_check ? 1 : (msr_hi & (3<<24)))) { |
| 364 | if (c->x86_mask == 0x01) { | 364 | if (c->x86_stepping == 0x01) { |
| 365 | pr_debug("early PIII version\n"); | 365 | pr_debug("early PIII version\n"); |
| 366 | return SPEEDSTEP_CPU_PIII_C_EARLY; | 366 | return SPEEDSTEP_CPU_PIII_C_EARLY; |
| 367 | } else | 367 | } else |
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 75d280cb2dc0..e843cf410373 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
| @@ -228,12 +228,16 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, | |||
| 228 | * without any error (HW optimizations for later | 228 | * without any error (HW optimizations for later |
| 229 | * CAAM eras), then try again. | 229 | * CAAM eras), then try again. |
| 230 | */ | 230 | */ |
| 231 | if (ret) | ||
| 232 | break; | ||
| 233 | |||
| 231 | rdsta_val = rd_reg32(&ctrl->r4tst[0].rdsta) & RDSTA_IFMASK; | 234 | rdsta_val = rd_reg32(&ctrl->r4tst[0].rdsta) & RDSTA_IFMASK; |
| 232 | if ((status && status != JRSTA_SSRC_JUMP_HALT_CC) || | 235 | if ((status && status != JRSTA_SSRC_JUMP_HALT_CC) || |
| 233 | !(rdsta_val & (1 << sh_idx))) | 236 | !(rdsta_val & (1 << sh_idx))) { |
| 234 | ret = -EAGAIN; | 237 | ret = -EAGAIN; |
| 235 | if (ret) | ||
| 236 | break; | 238 | break; |
| 239 | } | ||
| 240 | |||
| 237 | dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); | 241 | dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); |
| 238 | /* Clear the contents before recreating the descriptor */ | 242 | /* Clear the contents before recreating the descriptor */ |
| 239 | memset(desc, 0x00, CAAM_CMD_SZ * 7); | 243 | memset(desc, 0x00, CAAM_CMD_SZ * 7); |
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index 4b6642a25df5..1c6cbda56afe 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
| @@ -512,7 +512,7 @@ static int __init padlock_init(void) | |||
| 512 | 512 | ||
| 513 | printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n"); | 513 | printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n"); |
| 514 | 514 | ||
| 515 | if (c->x86 == 6 && c->x86_model == 15 && c->x86_mask == 2) { | 515 | if (c->x86 == 6 && c->x86_model == 15 && c->x86_stepping == 2) { |
| 516 | ecb_fetch_blocks = MAX_ECB_FETCH_BLOCKS; | 516 | ecb_fetch_blocks = MAX_ECB_FETCH_BLOCKS; |
| 517 | cbc_fetch_blocks = MAX_CBC_FETCH_BLOCKS; | 517 | cbc_fetch_blocks = MAX_CBC_FETCH_BLOCKS; |
| 518 | printk(KERN_NOTICE PFX "VIA Nano stepping 2 detected: enabling workaround.\n"); | 518 | printk(KERN_NOTICE PFX "VIA Nano stepping 2 detected: enabling workaround.\n"); |
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-prng.c b/drivers/crypto/sunxi-ss/sun4i-ss-prng.c index 0d01d1624252..63d636424161 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-prng.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-prng.c | |||
| @@ -28,7 +28,7 @@ int sun4i_ss_prng_generate(struct crypto_rng *tfm, const u8 *src, | |||
| 28 | algt = container_of(alg, struct sun4i_ss_alg_template, alg.rng); | 28 | algt = container_of(alg, struct sun4i_ss_alg_template, alg.rng); |
| 29 | ss = algt->ss; | 29 | ss = algt->ss; |
| 30 | 30 | ||
| 31 | spin_lock(&ss->slock); | 31 | spin_lock_bh(&ss->slock); |
| 32 | 32 | ||
| 33 | writel(mode, ss->base + SS_CTL); | 33 | writel(mode, ss->base + SS_CTL); |
| 34 | 34 | ||
| @@ -51,6 +51,6 @@ int sun4i_ss_prng_generate(struct crypto_rng *tfm, const u8 *src, | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | writel(0, ss->base + SS_CTL); | 53 | writel(0, ss->base + SS_CTL); |
| 54 | spin_unlock(&ss->slock); | 54 | spin_unlock_bh(&ss->slock); |
| 55 | return dlen; | 55 | return 0; |
| 56 | } | 56 | } |
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 9c80e0cb1664..6882fa2f8bad 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
| @@ -1138,6 +1138,10 @@ static int talitos_sg_map(struct device *dev, struct scatterlist *src, | |||
| 1138 | struct talitos_private *priv = dev_get_drvdata(dev); | 1138 | struct talitos_private *priv = dev_get_drvdata(dev); |
| 1139 | bool is_sec1 = has_ftr_sec1(priv); | 1139 | bool is_sec1 = has_ftr_sec1(priv); |
| 1140 | 1140 | ||
| 1141 | if (!src) { | ||
| 1142 | to_talitos_ptr(ptr, 0, 0, is_sec1); | ||
| 1143 | return 1; | ||
| 1144 | } | ||
| 1141 | if (sg_count == 1) { | 1145 | if (sg_count == 1) { |
| 1142 | to_talitos_ptr(ptr, sg_dma_address(src) + offset, len, is_sec1); | 1146 | to_talitos_ptr(ptr, sg_dma_address(src) + offset, len, is_sec1); |
| 1143 | return sg_count; | 1147 | return sg_count; |
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 8b16ec595fa7..329cb96f886f 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
| @@ -3147,7 +3147,7 @@ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt) | |||
| 3147 | struct amd64_family_type *fam_type = NULL; | 3147 | struct amd64_family_type *fam_type = NULL; |
| 3148 | 3148 | ||
| 3149 | pvt->ext_model = boot_cpu_data.x86_model >> 4; | 3149 | pvt->ext_model = boot_cpu_data.x86_model >> 4; |
| 3150 | pvt->stepping = boot_cpu_data.x86_mask; | 3150 | pvt->stepping = boot_cpu_data.x86_stepping; |
| 3151 | pvt->model = boot_cpu_data.x86_model; | 3151 | pvt->model = boot_cpu_data.x86_model; |
| 3152 | pvt->fam = boot_cpu_data.x86; | 3152 | pvt->fam = boot_cpu_data.x86; |
| 3153 | 3153 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c index e2c3c5ec42d1..c53095b3b0fb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | |||
| @@ -568,6 +568,7 @@ static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = { | |||
| 568 | /* HG _PR3 doesn't seem to work on this A+A weston board */ | 568 | /* HG _PR3 doesn't seem to work on this A+A weston board */ |
| 569 | { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX }, | 569 | { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX }, |
| 570 | { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, | 570 | { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, |
| 571 | { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX }, | ||
| 571 | { 0, 0, 0, 0, 0 }, | 572 | { 0, 0, 0, 0, 0 }, |
| 572 | }; | 573 | }; |
| 573 | 574 | ||
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 909499b73d03..021f722e2481 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c | |||
| @@ -733,6 +733,25 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char *buf, | |||
| 733 | return ret == 0 ? count : ret; | 733 | return ret == 0 ? count : ret; |
| 734 | } | 734 | } |
| 735 | 735 | ||
| 736 | static bool gtt_entry(struct mdev_device *mdev, loff_t *ppos) | ||
| 737 | { | ||
| 738 | struct intel_vgpu *vgpu = mdev_get_drvdata(mdev); | ||
| 739 | unsigned int index = VFIO_PCI_OFFSET_TO_INDEX(*ppos); | ||
| 740 | struct intel_gvt *gvt = vgpu->gvt; | ||
| 741 | int offset; | ||
| 742 | |||
| 743 | /* Only allow MMIO GGTT entry access */ | ||
| 744 | if (index != PCI_BASE_ADDRESS_0) | ||
| 745 | return false; | ||
| 746 | |||
| 747 | offset = (u64)(*ppos & VFIO_PCI_OFFSET_MASK) - | ||
| 748 | intel_vgpu_get_bar_gpa(vgpu, PCI_BASE_ADDRESS_0); | ||
| 749 | |||
| 750 | return (offset >= gvt->device_info.gtt_start_offset && | ||
| 751 | offset < gvt->device_info.gtt_start_offset + gvt_ggtt_sz(gvt)) ? | ||
| 752 | true : false; | ||
| 753 | } | ||
| 754 | |||
| 736 | static ssize_t intel_vgpu_read(struct mdev_device *mdev, char __user *buf, | 755 | static ssize_t intel_vgpu_read(struct mdev_device *mdev, char __user *buf, |
| 737 | size_t count, loff_t *ppos) | 756 | size_t count, loff_t *ppos) |
| 738 | { | 757 | { |
| @@ -742,7 +761,21 @@ static ssize_t intel_vgpu_read(struct mdev_device *mdev, char __user *buf, | |||
| 742 | while (count) { | 761 | while (count) { |
| 743 | size_t filled; | 762 | size_t filled; |
| 744 | 763 | ||
| 745 | if (count >= 4 && !(*ppos % 4)) { | 764 | /* Only support GGTT entry 8 bytes read */ |
| 765 | if (count >= 8 && !(*ppos % 8) && | ||
| 766 | gtt_entry(mdev, ppos)) { | ||
| 767 | u64 val; | ||
| 768 | |||
| 769 | ret = intel_vgpu_rw(mdev, (char *)&val, sizeof(val), | ||
| 770 | ppos, false); | ||
| 771 | if (ret <= 0) | ||
| 772 | goto read_err; | ||
| 773 | |||
| 774 | if (copy_to_user(buf, &val, sizeof(val))) | ||
| 775 | goto read_err; | ||
| 776 | |||
| 777 | filled = 8; | ||
| 778 | } else if (count >= 4 && !(*ppos % 4)) { | ||
| 746 | u32 val; | 779 | u32 val; |
| 747 | 780 | ||
| 748 | ret = intel_vgpu_rw(mdev, (char *)&val, sizeof(val), | 781 | ret = intel_vgpu_rw(mdev, (char *)&val, sizeof(val), |
| @@ -802,7 +835,21 @@ static ssize_t intel_vgpu_write(struct mdev_device *mdev, | |||
| 802 | while (count) { | 835 | while (count) { |
| 803 | size_t filled; | 836 | size_t filled; |
| 804 | 837 | ||
| 805 | if (count >= 4 && !(*ppos % 4)) { | 838 | /* Only support GGTT entry 8 bytes write */ |
| 839 | if (count >= 8 && !(*ppos % 8) && | ||
| 840 | gtt_entry(mdev, ppos)) { | ||
| 841 | u64 val; | ||
| 842 | |||
| 843 | if (copy_from_user(&val, buf, sizeof(val))) | ||
| 844 | goto write_err; | ||
| 845 | |||
| 846 | ret = intel_vgpu_rw(mdev, (char *)&val, sizeof(val), | ||
| 847 | ppos, true); | ||
| 848 | if (ret <= 0) | ||
| 849 | goto write_err; | ||
| 850 | |||
| 851 | filled = 8; | ||
| 852 | } else if (count >= 4 && !(*ppos % 4)) { | ||
| 806 | u32 val; | 853 | u32 val; |
| 807 | 854 | ||
| 808 | if (copy_from_user(&val, buf, sizeof(val))) | 855 | if (copy_from_user(&val, buf, sizeof(val))) |
diff --git a/drivers/gpu/drm/i915/gvt/mmio_context.c b/drivers/gpu/drm/i915/gvt/mmio_context.c index 73ad6e90e49d..256f1bb522b7 100644 --- a/drivers/gpu/drm/i915/gvt/mmio_context.c +++ b/drivers/gpu/drm/i915/gvt/mmio_context.c | |||
| @@ -118,6 +118,7 @@ static struct engine_mmio gen9_engine_mmio_list[] __cacheline_aligned = { | |||
| 118 | {RCS, HALF_SLICE_CHICKEN3, 0xffff, true}, /* 0xe184 */ | 118 | {RCS, HALF_SLICE_CHICKEN3, 0xffff, true}, /* 0xe184 */ |
| 119 | {RCS, GEN9_HALF_SLICE_CHICKEN5, 0xffff, true}, /* 0xe188 */ | 119 | {RCS, GEN9_HALF_SLICE_CHICKEN5, 0xffff, true}, /* 0xe188 */ |
| 120 | {RCS, GEN9_HALF_SLICE_CHICKEN7, 0xffff, true}, /* 0xe194 */ | 120 | {RCS, GEN9_HALF_SLICE_CHICKEN7, 0xffff, true}, /* 0xe194 */ |
| 121 | {RCS, GEN8_ROW_CHICKEN, 0xffff, true}, /* 0xe4f0 */ | ||
| 121 | {RCS, TRVATTL3PTRDW(0), 0, false}, /* 0x4de0 */ | 122 | {RCS, TRVATTL3PTRDW(0), 0, false}, /* 0x4de0 */ |
| 122 | {RCS, TRVATTL3PTRDW(1), 0, false}, /* 0x4de4 */ | 123 | {RCS, TRVATTL3PTRDW(1), 0, false}, /* 0x4de4 */ |
| 123 | {RCS, TRNULLDETCT, 0, false}, /* 0x4de8 */ | 124 | {RCS, TRNULLDETCT, 0, false}, /* 0x4de8 */ |
diff --git a/drivers/gpu/drm/i915/gvt/trace.h b/drivers/gpu/drm/i915/gvt/trace.h index 7a2511538f34..736bd2bc5127 100644 --- a/drivers/gpu/drm/i915/gvt/trace.h +++ b/drivers/gpu/drm/i915/gvt/trace.h | |||
| @@ -333,7 +333,7 @@ TRACE_EVENT(render_mmio, | |||
| 333 | TP_PROTO(int old_id, int new_id, char *action, unsigned int reg, | 333 | TP_PROTO(int old_id, int new_id, char *action, unsigned int reg, |
| 334 | unsigned int old_val, unsigned int new_val), | 334 | unsigned int old_val, unsigned int new_val), |
| 335 | 335 | ||
| 336 | TP_ARGS(old_id, new_id, action, reg, new_val, old_val), | 336 | TP_ARGS(old_id, new_id, action, reg, old_val, new_val), |
| 337 | 337 | ||
| 338 | TP_STRUCT__entry( | 338 | TP_STRUCT__entry( |
| 339 | __field(int, old_id) | 339 | __field(int, old_id) |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 173d0095e3b2..2f5209de0391 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
| @@ -1433,19 +1433,7 @@ void i915_driver_unload(struct drm_device *dev) | |||
| 1433 | 1433 | ||
| 1434 | intel_modeset_cleanup(dev); | 1434 | intel_modeset_cleanup(dev); |
| 1435 | 1435 | ||
| 1436 | /* | 1436 | intel_bios_cleanup(dev_priv); |
| 1437 | * free the memory space allocated for the child device | ||
| 1438 | * config parsed from VBT | ||
| 1439 | */ | ||
| 1440 | if (dev_priv->vbt.child_dev && dev_priv->vbt.child_dev_num) { | ||
| 1441 | kfree(dev_priv->vbt.child_dev); | ||
| 1442 | dev_priv->vbt.child_dev = NULL; | ||
| 1443 | dev_priv->vbt.child_dev_num = 0; | ||
| 1444 | } | ||
| 1445 | kfree(dev_priv->vbt.sdvo_lvds_vbt_mode); | ||
| 1446 | dev_priv->vbt.sdvo_lvds_vbt_mode = NULL; | ||
| 1447 | kfree(dev_priv->vbt.lfp_lvds_vbt_mode); | ||
| 1448 | dev_priv->vbt.lfp_lvds_vbt_mode = NULL; | ||
| 1449 | 1437 | ||
| 1450 | vga_switcheroo_unregister_client(pdev); | 1438 | vga_switcheroo_unregister_client(pdev); |
| 1451 | vga_client_register(pdev, NULL, NULL, NULL); | 1439 | vga_client_register(pdev, NULL, NULL, NULL); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a42deebedb0f..d307429a5ae0 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -1349,6 +1349,7 @@ struct intel_vbt_data { | |||
| 1349 | u32 size; | 1349 | u32 size; |
| 1350 | u8 *data; | 1350 | u8 *data; |
| 1351 | const u8 *sequence[MIPI_SEQ_MAX]; | 1351 | const u8 *sequence[MIPI_SEQ_MAX]; |
| 1352 | u8 *deassert_seq; /* Used by fixup_mipi_sequences() */ | ||
| 1352 | } dsi; | 1353 | } dsi; |
| 1353 | 1354 | ||
| 1354 | int crt_ddc_pin; | 1355 | int crt_ddc_pin; |
| @@ -3657,6 +3658,7 @@ extern void intel_i2c_reset(struct drm_i915_private *dev_priv); | |||
| 3657 | 3658 | ||
| 3658 | /* intel_bios.c */ | 3659 | /* intel_bios.c */ |
| 3659 | void intel_bios_init(struct drm_i915_private *dev_priv); | 3660 | void intel_bios_init(struct drm_i915_private *dev_priv); |
| 3661 | void intel_bios_cleanup(struct drm_i915_private *dev_priv); | ||
| 3660 | bool intel_bios_is_valid_vbt(const void *buf, size_t size); | 3662 | bool intel_bios_is_valid_vbt(const void *buf, size_t size); |
| 3661 | bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv); | 3663 | bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv); |
| 3662 | bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin); | 3664 | bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 648e7536ff51..0c963fcf31ff 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
| @@ -803,7 +803,7 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, | |||
| 803 | 803 | ||
| 804 | case I915_CONTEXT_PARAM_PRIORITY: | 804 | case I915_CONTEXT_PARAM_PRIORITY: |
| 805 | { | 805 | { |
| 806 | int priority = args->value; | 806 | s64 priority = args->value; |
| 807 | 807 | ||
| 808 | if (args->size) | 808 | if (args->size) |
| 809 | ret = -EINVAL; | 809 | ret = -EINVAL; |
diff --git a/drivers/gpu/drm/i915/i915_oa_cflgt3.c b/drivers/gpu/drm/i915/i915_oa_cflgt3.c index 42ff06fe54a3..792facdb6702 100644 --- a/drivers/gpu/drm/i915/i915_oa_cflgt3.c +++ b/drivers/gpu/drm/i915/i915_oa_cflgt3.c | |||
| @@ -84,9 +84,9 @@ show_test_oa_id(struct device *kdev, struct device_attribute *attr, char *buf) | |||
| 84 | void | 84 | void |
| 85 | i915_perf_load_test_config_cflgt3(struct drm_i915_private *dev_priv) | 85 | i915_perf_load_test_config_cflgt3(struct drm_i915_private *dev_priv) |
| 86 | { | 86 | { |
| 87 | strncpy(dev_priv->perf.oa.test_config.uuid, | 87 | strlcpy(dev_priv->perf.oa.test_config.uuid, |
| 88 | "577e8e2c-3fa0-4875-8743-3538d585e3b0", | 88 | "577e8e2c-3fa0-4875-8743-3538d585e3b0", |
| 89 | UUID_STRING_LEN); | 89 | sizeof(dev_priv->perf.oa.test_config.uuid)); |
| 90 | dev_priv->perf.oa.test_config.id = 1; | 90 | dev_priv->perf.oa.test_config.id = 1; |
| 91 | 91 | ||
| 92 | dev_priv->perf.oa.test_config.mux_regs = mux_config_test_oa; | 92 | dev_priv->perf.oa.test_config.mux_regs = mux_config_test_oa; |
diff --git a/drivers/gpu/drm/i915/i915_oa_cnl.c b/drivers/gpu/drm/i915/i915_oa_cnl.c index ff0ac3627cc4..ba9140c87cc0 100644 --- a/drivers/gpu/drm/i915/i915_oa_cnl.c +++ b/drivers/gpu/drm/i915/i915_oa_cnl.c | |||
| @@ -96,9 +96,9 @@ show_test_oa_id(struct device *kdev, struct device_attribute *attr, char *buf) | |||
| 96 | void | 96 | void |
| 97 | i915_perf_load_test_config_cnl(struct drm_i915_private *dev_priv) | 97 | i915_perf_load_test_config_cnl(struct drm_i915_private *dev_priv) |
| 98 | { | 98 | { |
| 99 | strncpy(dev_priv->perf.oa.test_config.uuid, | 99 | strlcpy(dev_priv->perf.oa.test_config.uuid, |
| 100 | "db41edd4-d8e7-4730-ad11-b9a2d6833503", | 100 | "db41edd4-d8e7-4730-ad11-b9a2d6833503", |
| 101 | UUID_STRING_LEN); | 101 | sizeof(dev_priv->perf.oa.test_config.uuid)); |
| 102 | dev_priv->perf.oa.test_config.id = 1; | 102 | dev_priv->perf.oa.test_config.id = 1; |
| 103 | 103 | ||
| 104 | dev_priv->perf.oa.test_config.mux_regs = mux_config_test_oa; | 104 | dev_priv->perf.oa.test_config.mux_regs = mux_config_test_oa; |
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 55a8a1e29424..0e9b98c32b62 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c | |||
| @@ -285,26 +285,41 @@ static u64 count_interrupts(struct drm_i915_private *i915) | |||
| 285 | return sum; | 285 | return sum; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | static void i915_pmu_event_destroy(struct perf_event *event) | 288 | static void engine_event_destroy(struct perf_event *event) |
| 289 | { | 289 | { |
| 290 | WARN_ON(event->parent); | 290 | struct drm_i915_private *i915 = |
| 291 | container_of(event->pmu, typeof(*i915), pmu.base); | ||
| 292 | struct intel_engine_cs *engine; | ||
| 293 | |||
| 294 | engine = intel_engine_lookup_user(i915, | ||
| 295 | engine_event_class(event), | ||
| 296 | engine_event_instance(event)); | ||
| 297 | if (WARN_ON_ONCE(!engine)) | ||
| 298 | return; | ||
| 299 | |||
| 300 | if (engine_event_sample(event) == I915_SAMPLE_BUSY && | ||
| 301 | intel_engine_supports_stats(engine)) | ||
| 302 | intel_disable_engine_stats(engine); | ||
| 291 | } | 303 | } |
| 292 | 304 | ||
| 293 | static int engine_event_init(struct perf_event *event) | 305 | static void i915_pmu_event_destroy(struct perf_event *event) |
| 294 | { | 306 | { |
| 295 | struct drm_i915_private *i915 = | 307 | WARN_ON(event->parent); |
| 296 | container_of(event->pmu, typeof(*i915), pmu.base); | ||
| 297 | 308 | ||
| 298 | if (!intel_engine_lookup_user(i915, engine_event_class(event), | 309 | if (is_engine_event(event)) |
| 299 | engine_event_instance(event))) | 310 | engine_event_destroy(event); |
| 300 | return -ENODEV; | 311 | } |
| 301 | 312 | ||
| 302 | switch (engine_event_sample(event)) { | 313 | static int |
| 314 | engine_event_status(struct intel_engine_cs *engine, | ||
| 315 | enum drm_i915_pmu_engine_sample sample) | ||
| 316 | { | ||
| 317 | switch (sample) { | ||
| 303 | case I915_SAMPLE_BUSY: | 318 | case I915_SAMPLE_BUSY: |
| 304 | case I915_SAMPLE_WAIT: | 319 | case I915_SAMPLE_WAIT: |
| 305 | break; | 320 | break; |
| 306 | case I915_SAMPLE_SEMA: | 321 | case I915_SAMPLE_SEMA: |
| 307 | if (INTEL_GEN(i915) < 6) | 322 | if (INTEL_GEN(engine->i915) < 6) |
| 308 | return -ENODEV; | 323 | return -ENODEV; |
| 309 | break; | 324 | break; |
| 310 | default: | 325 | default: |
| @@ -314,6 +329,30 @@ static int engine_event_init(struct perf_event *event) | |||
| 314 | return 0; | 329 | return 0; |
| 315 | } | 330 | } |
| 316 | 331 | ||
| 332 | static int engine_event_init(struct perf_event *event) | ||
| 333 | { | ||
| 334 | struct drm_i915_private *i915 = | ||
| 335 | container_of(event->pmu, typeof(*i915), pmu.base); | ||
| 336 | struct intel_engine_cs *engine; | ||
| 337 | u8 sample; | ||
| 338 | int ret; | ||
| 339 | |||
| 340 | engine = intel_engine_lookup_user(i915, engine_event_class(event), | ||
| 341 | engine_event_instance(event)); | ||
| 342 | if (!engine) | ||
| 343 | return -ENODEV; | ||
| 344 | |||
| 345 | sample = engine_event_sample(event); | ||
| 346 | ret = engine_event_status(engine, sample); | ||
| 347 | if (ret) | ||
| 348 | return ret; | ||
| 349 | |||
| 350 | if (sample == I915_SAMPLE_BUSY && intel_engine_supports_stats(engine)) | ||
| 351 | ret = intel_enable_engine_stats(engine); | ||
| 352 | |||
| 353 | return ret; | ||
| 354 | } | ||
| 355 | |||
| 317 | static int i915_pmu_event_init(struct perf_event *event) | 356 | static int i915_pmu_event_init(struct perf_event *event) |
| 318 | { | 357 | { |
| 319 | struct drm_i915_private *i915 = | 358 | struct drm_i915_private *i915 = |
| @@ -370,7 +409,94 @@ static int i915_pmu_event_init(struct perf_event *event) | |||
| 370 | return 0; | 409 | return 0; |
| 371 | } | 410 | } |
| 372 | 411 | ||
| 373 | static u64 __i915_pmu_event_read(struct perf_event *event) | 412 | static u64 __get_rc6(struct drm_i915_private *i915) |
| 413 | { | ||
| 414 | u64 val; | ||
| 415 | |||
| 416 | val = intel_rc6_residency_ns(i915, | ||
| 417 | IS_VALLEYVIEW(i915) ? | ||
| 418 | VLV_GT_RENDER_RC6 : | ||
| 419 | GEN6_GT_GFX_RC6); | ||
| 420 | |||
| 421 | if (HAS_RC6p(i915)) | ||
| 422 | val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6p); | ||
| 423 | |||
| 424 | if (HAS_RC6pp(i915)) | ||
| 425 | val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6pp); | ||
| 426 | |||
| 427 | return val; | ||
| 428 | } | ||
| 429 | |||
| 430 | static u64 get_rc6(struct drm_i915_private *i915, bool locked) | ||
| 431 | { | ||
| 432 | #if IS_ENABLED(CONFIG_PM) | ||
| 433 | unsigned long flags; | ||
| 434 | u64 val; | ||
| 435 | |||
| 436 | if (intel_runtime_pm_get_if_in_use(i915)) { | ||
| 437 | val = __get_rc6(i915); | ||
| 438 | intel_runtime_pm_put(i915); | ||
| 439 | |||
| 440 | /* | ||
| 441 | * If we are coming back from being runtime suspended we must | ||
| 442 | * be careful not to report a larger value than returned | ||
| 443 | * previously. | ||
| 444 | */ | ||
| 445 | |||
| 446 | if (!locked) | ||
| 447 | spin_lock_irqsave(&i915->pmu.lock, flags); | ||
| 448 | |||
| 449 | if (val >= i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) { | ||
| 450 | i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = 0; | ||
| 451 | i915->pmu.sample[__I915_SAMPLE_RC6].cur = val; | ||
| 452 | } else { | ||
| 453 | val = i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur; | ||
| 454 | } | ||
| 455 | |||
| 456 | if (!locked) | ||
| 457 | spin_unlock_irqrestore(&i915->pmu.lock, flags); | ||
| 458 | } else { | ||
| 459 | struct pci_dev *pdev = i915->drm.pdev; | ||
| 460 | struct device *kdev = &pdev->dev; | ||
| 461 | unsigned long flags2; | ||
| 462 | |||
| 463 | /* | ||
| 464 | * We are runtime suspended. | ||
| 465 | * | ||
| 466 | * Report the delta from when the device was suspended to now, | ||
| 467 | * on top of the last known real value, as the approximated RC6 | ||
| 468 | * counter value. | ||
| 469 | */ | ||
| 470 | if (!locked) | ||
| 471 | spin_lock_irqsave(&i915->pmu.lock, flags); | ||
| 472 | |||
| 473 | spin_lock_irqsave(&kdev->power.lock, flags2); | ||
| 474 | |||
| 475 | if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) | ||
| 476 | i915->pmu.suspended_jiffies_last = | ||
| 477 | kdev->power.suspended_jiffies; | ||
| 478 | |||
| 479 | val = kdev->power.suspended_jiffies - | ||
| 480 | i915->pmu.suspended_jiffies_last; | ||
| 481 | val += jiffies - kdev->power.accounting_timestamp; | ||
| 482 | |||
| 483 | spin_unlock_irqrestore(&kdev->power.lock, flags2); | ||
| 484 | |||
| 485 | val = jiffies_to_nsecs(val); | ||
| 486 | val += i915->pmu.sample[__I915_SAMPLE_RC6].cur; | ||
| 487 | i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; | ||
| 488 | |||
| 489 | if (!locked) | ||
| 490 | spin_unlock_irqrestore(&i915->pmu.lock, flags); | ||
| 491 | } | ||
| 492 | |||
| 493 | return val; | ||
| 494 | #else | ||
| 495 | return __get_rc6(i915); | ||
| 496 | #endif | ||
| 497 | } | ||
| 498 | |||
| 499 | static u64 __i915_pmu_event_read(struct perf_event *event, bool locked) | ||
| 374 | { | 500 | { |
| 375 | struct drm_i915_private *i915 = | 501 | struct drm_i915_private *i915 = |
| 376 | container_of(event->pmu, typeof(*i915), pmu.base); | 502 | container_of(event->pmu, typeof(*i915), pmu.base); |
| @@ -387,7 +513,7 @@ static u64 __i915_pmu_event_read(struct perf_event *event) | |||
| 387 | if (WARN_ON_ONCE(!engine)) { | 513 | if (WARN_ON_ONCE(!engine)) { |
| 388 | /* Do nothing */ | 514 | /* Do nothing */ |
| 389 | } else if (sample == I915_SAMPLE_BUSY && | 515 | } else if (sample == I915_SAMPLE_BUSY && |
| 390 | engine->pmu.busy_stats) { | 516 | intel_engine_supports_stats(engine)) { |
| 391 | val = ktime_to_ns(intel_engine_get_busy_time(engine)); | 517 | val = ktime_to_ns(intel_engine_get_busy_time(engine)); |
| 392 | } else { | 518 | } else { |
| 393 | val = engine->pmu.sample[sample].cur; | 519 | val = engine->pmu.sample[sample].cur; |
| @@ -408,18 +534,7 @@ static u64 __i915_pmu_event_read(struct perf_event *event) | |||
| 408 | val = count_interrupts(i915); | 534 | val = count_interrupts(i915); |
| 409 | break; | 535 | break; |
| 410 | case I915_PMU_RC6_RESIDENCY: | 536 | case I915_PMU_RC6_RESIDENCY: |
| 411 | intel_runtime_pm_get(i915); | 537 | val = get_rc6(i915, locked); |
| 412 | val = intel_rc6_residency_ns(i915, | ||
| 413 | IS_VALLEYVIEW(i915) ? | ||
| 414 | VLV_GT_RENDER_RC6 : | ||
| 415 | GEN6_GT_GFX_RC6); | ||
| 416 | if (HAS_RC6p(i915)) | ||
| 417 | val += intel_rc6_residency_ns(i915, | ||
| 418 | GEN6_GT_GFX_RC6p); | ||
| 419 | if (HAS_RC6pp(i915)) | ||
| 420 | val += intel_rc6_residency_ns(i915, | ||
| 421 | GEN6_GT_GFX_RC6pp); | ||
| 422 | intel_runtime_pm_put(i915); | ||
| 423 | break; | 538 | break; |
| 424 | } | 539 | } |
| 425 | } | 540 | } |
| @@ -434,7 +549,7 @@ static void i915_pmu_event_read(struct perf_event *event) | |||
| 434 | 549 | ||
| 435 | again: | 550 | again: |
| 436 | prev = local64_read(&hwc->prev_count); | 551 | prev = local64_read(&hwc->prev_count); |
| 437 | new = __i915_pmu_event_read(event); | 552 | new = __i915_pmu_event_read(event, false); |
| 438 | 553 | ||
| 439 | if (local64_cmpxchg(&hwc->prev_count, prev, new) != prev) | 554 | if (local64_cmpxchg(&hwc->prev_count, prev, new) != prev) |
| 440 | goto again; | 555 | goto again; |
| @@ -442,12 +557,6 @@ again: | |||
| 442 | local64_add(new - prev, &event->count); | 557 | local64_add(new - prev, &event->count); |
| 443 | } | 558 | } |
| 444 | 559 | ||
| 445 | static bool engine_needs_busy_stats(struct intel_engine_cs *engine) | ||
| 446 | { | ||
| 447 | return intel_engine_supports_stats(engine) && | ||
| 448 | (engine->pmu.enable & BIT(I915_SAMPLE_BUSY)); | ||
| 449 | } | ||
| 450 | |||
| 451 | static void i915_pmu_enable(struct perf_event *event) | 560 | static void i915_pmu_enable(struct perf_event *event) |
| 452 | { | 561 | { |
| 453 | struct drm_i915_private *i915 = | 562 | struct drm_i915_private *i915 = |
| @@ -487,21 +596,7 @@ static void i915_pmu_enable(struct perf_event *event) | |||
| 487 | 596 | ||
| 488 | GEM_BUG_ON(sample >= I915_PMU_SAMPLE_BITS); | 597 | GEM_BUG_ON(sample >= I915_PMU_SAMPLE_BITS); |
| 489 | GEM_BUG_ON(engine->pmu.enable_count[sample] == ~0); | 598 | GEM_BUG_ON(engine->pmu.enable_count[sample] == ~0); |
| 490 | if (engine->pmu.enable_count[sample]++ == 0) { | 599 | engine->pmu.enable_count[sample]++; |
| 491 | /* | ||
| 492 | * Enable engine busy stats tracking if needed or | ||
| 493 | * alternatively cancel the scheduled disable. | ||
| 494 | * | ||
| 495 | * If the delayed disable was pending, cancel it and | ||
| 496 | * in this case do not enable since it already is. | ||
| 497 | */ | ||
| 498 | if (engine_needs_busy_stats(engine) && | ||
| 499 | !engine->pmu.busy_stats) { | ||
| 500 | engine->pmu.busy_stats = true; | ||
| 501 | if (!cancel_delayed_work(&engine->pmu.disable_busy_stats)) | ||
| 502 | intel_enable_engine_stats(engine); | ||
| 503 | } | ||
| 504 | } | ||
| 505 | } | 600 | } |
| 506 | 601 | ||
| 507 | /* | 602 | /* |
| @@ -509,19 +604,11 @@ static void i915_pmu_enable(struct perf_event *event) | |||
| 509 | * for all listeners. Even when the event was already enabled and has | 604 | * for all listeners. Even when the event was already enabled and has |
| 510 | * an existing non-zero value. | 605 | * an existing non-zero value. |
| 511 | */ | 606 | */ |
| 512 | local64_set(&event->hw.prev_count, __i915_pmu_event_read(event)); | 607 | local64_set(&event->hw.prev_count, __i915_pmu_event_read(event, true)); |
| 513 | 608 | ||
| 514 | spin_unlock_irqrestore(&i915->pmu.lock, flags); | 609 | spin_unlock_irqrestore(&i915->pmu.lock, flags); |
| 515 | } | 610 | } |
| 516 | 611 | ||
| 517 | static void __disable_busy_stats(struct work_struct *work) | ||
| 518 | { | ||
| 519 | struct intel_engine_cs *engine = | ||
| 520 | container_of(work, typeof(*engine), pmu.disable_busy_stats.work); | ||
| 521 | |||
| 522 | intel_disable_engine_stats(engine); | ||
| 523 | } | ||
| 524 | |||
| 525 | static void i915_pmu_disable(struct perf_event *event) | 612 | static void i915_pmu_disable(struct perf_event *event) |
| 526 | { | 613 | { |
| 527 | struct drm_i915_private *i915 = | 614 | struct drm_i915_private *i915 = |
| @@ -545,26 +632,8 @@ static void i915_pmu_disable(struct perf_event *event) | |||
| 545 | * Decrement the reference count and clear the enabled | 632 | * Decrement the reference count and clear the enabled |
| 546 | * bitmask when the last listener on an event goes away. | 633 | * bitmask when the last listener on an event goes away. |
| 547 | */ | 634 | */ |
| 548 | if (--engine->pmu.enable_count[sample] == 0) { | 635 | if (--engine->pmu.enable_count[sample] == 0) |
| 549 | engine->pmu.enable &= ~BIT(sample); | 636 | engine->pmu.enable &= ~BIT(sample); |
| 550 | if (!engine_needs_busy_stats(engine) && | ||
| 551 | engine->pmu.busy_stats) { | ||
| 552 | engine->pmu.busy_stats = false; | ||
| 553 | /* | ||
| 554 | * We request a delayed disable to handle the | ||
| 555 | * rapid on/off cycles on events, which can | ||
| 556 | * happen when tools like perf stat start, in a | ||
| 557 | * nicer way. | ||
| 558 | * | ||
| 559 | * In addition, this also helps with busy stats | ||
| 560 | * accuracy with background CPU offline/online | ||
| 561 | * migration events. | ||
| 562 | */ | ||
| 563 | queue_delayed_work(system_wq, | ||
| 564 | &engine->pmu.disable_busy_stats, | ||
| 565 | round_jiffies_up_relative(HZ)); | ||
| 566 | } | ||
| 567 | } | ||
| 568 | } | 637 | } |
| 569 | 638 | ||
| 570 | GEM_BUG_ON(bit >= I915_PMU_MASK_BITS); | 639 | GEM_BUG_ON(bit >= I915_PMU_MASK_BITS); |
| @@ -797,8 +866,6 @@ static void i915_pmu_unregister_cpuhp_state(struct drm_i915_private *i915) | |||
| 797 | 866 | ||
| 798 | void i915_pmu_register(struct drm_i915_private *i915) | 867 | void i915_pmu_register(struct drm_i915_private *i915) |
| 799 | { | 868 | { |
| 800 | struct intel_engine_cs *engine; | ||
| 801 | enum intel_engine_id id; | ||
| 802 | int ret; | 869 | int ret; |
| 803 | 870 | ||
| 804 | if (INTEL_GEN(i915) <= 2) { | 871 | if (INTEL_GEN(i915) <= 2) { |
| @@ -820,10 +887,6 @@ void i915_pmu_register(struct drm_i915_private *i915) | |||
| 820 | hrtimer_init(&i915->pmu.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 887 | hrtimer_init(&i915->pmu.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
| 821 | i915->pmu.timer.function = i915_sample; | 888 | i915->pmu.timer.function = i915_sample; |
| 822 | 889 | ||
| 823 | for_each_engine(engine, i915, id) | ||
| 824 | INIT_DELAYED_WORK(&engine->pmu.disable_busy_stats, | ||
| 825 | __disable_busy_stats); | ||
| 826 | |||
| 827 | ret = perf_pmu_register(&i915->pmu.base, "i915", -1); | 890 | ret = perf_pmu_register(&i915->pmu.base, "i915", -1); |
| 828 | if (ret) | 891 | if (ret) |
| 829 | goto err; | 892 | goto err; |
| @@ -843,9 +906,6 @@ err: | |||
| 843 | 906 | ||
| 844 | void i915_pmu_unregister(struct drm_i915_private *i915) | 907 | void i915_pmu_unregister(struct drm_i915_private *i915) |
| 845 | { | 908 | { |
| 846 | struct intel_engine_cs *engine; | ||
| 847 | enum intel_engine_id id; | ||
| 848 | |||
| 849 | if (!i915->pmu.base.event_init) | 909 | if (!i915->pmu.base.event_init) |
| 850 | return; | 910 | return; |
| 851 | 911 | ||
| @@ -853,11 +913,6 @@ void i915_pmu_unregister(struct drm_i915_private *i915) | |||
| 853 | 913 | ||
| 854 | hrtimer_cancel(&i915->pmu.timer); | 914 | hrtimer_cancel(&i915->pmu.timer); |
| 855 | 915 | ||
| 856 | for_each_engine(engine, i915, id) { | ||
| 857 | GEM_BUG_ON(engine->pmu.busy_stats); | ||
| 858 | flush_delayed_work(&engine->pmu.disable_busy_stats); | ||
| 859 | } | ||
| 860 | |||
| 861 | i915_pmu_unregister_cpuhp_state(i915); | 916 | i915_pmu_unregister_cpuhp_state(i915); |
| 862 | 917 | ||
| 863 | perf_pmu_unregister(&i915->pmu.base); | 918 | perf_pmu_unregister(&i915->pmu.base); |
diff --git a/drivers/gpu/drm/i915/i915_pmu.h b/drivers/gpu/drm/i915/i915_pmu.h index 40c154d13565..bb62df15afa4 100644 --- a/drivers/gpu/drm/i915/i915_pmu.h +++ b/drivers/gpu/drm/i915/i915_pmu.h | |||
| @@ -27,6 +27,8 @@ | |||
| 27 | enum { | 27 | enum { |
| 28 | __I915_SAMPLE_FREQ_ACT = 0, | 28 | __I915_SAMPLE_FREQ_ACT = 0, |
| 29 | __I915_SAMPLE_FREQ_REQ, | 29 | __I915_SAMPLE_FREQ_REQ, |
| 30 | __I915_SAMPLE_RC6, | ||
| 31 | __I915_SAMPLE_RC6_ESTIMATED, | ||
| 30 | __I915_NUM_PMU_SAMPLERS | 32 | __I915_NUM_PMU_SAMPLERS |
| 31 | }; | 33 | }; |
| 32 | 34 | ||
| @@ -94,6 +96,10 @@ struct i915_pmu { | |||
| 94 | * struct intel_engine_cs. | 96 | * struct intel_engine_cs. |
| 95 | */ | 97 | */ |
| 96 | struct i915_pmu_sample sample[__I915_NUM_PMU_SAMPLERS]; | 98 | struct i915_pmu_sample sample[__I915_NUM_PMU_SAMPLERS]; |
| 99 | /** | ||
| 100 | * @suspended_jiffies_last: Cached suspend time from PM core. | ||
| 101 | */ | ||
| 102 | unsigned long suspended_jiffies_last; | ||
| 97 | }; | 103 | }; |
| 98 | 104 | ||
| 99 | #ifdef CONFIG_PERF_EVENTS | 105 | #ifdef CONFIG_PERF_EVENTS |
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index f7f771749e48..b49a2df44430 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c | |||
| @@ -947,6 +947,86 @@ static int goto_next_sequence_v3(const u8 *data, int index, int total) | |||
| 947 | return 0; | 947 | return 0; |
| 948 | } | 948 | } |
| 949 | 949 | ||
| 950 | /* | ||
| 951 | * Get len of pre-fixed deassert fragment from a v1 init OTP sequence, | ||
| 952 | * skip all delay + gpio operands and stop at the first DSI packet op. | ||
| 953 | */ | ||
| 954 | static int get_init_otp_deassert_fragment_len(struct drm_i915_private *dev_priv) | ||
| 955 | { | ||
| 956 | const u8 *data = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP]; | ||
| 957 | int index, len; | ||
| 958 | |||
| 959 | if (WARN_ON(!data || dev_priv->vbt.dsi.seq_version != 1)) | ||
| 960 | return 0; | ||
| 961 | |||
| 962 | /* index = 1 to skip sequence byte */ | ||
| 963 | for (index = 1; data[index] != MIPI_SEQ_ELEM_END; index += len) { | ||
| 964 | switch (data[index]) { | ||
| 965 | case MIPI_SEQ_ELEM_SEND_PKT: | ||
| 966 | return index == 1 ? 0 : index; | ||
| 967 | case MIPI_SEQ_ELEM_DELAY: | ||
| 968 | len = 5; /* 1 byte for operand + uint32 */ | ||
| 969 | break; | ||
| 970 | case MIPI_SEQ_ELEM_GPIO: | ||
| 971 | len = 3; /* 1 byte for op, 1 for gpio_nr, 1 for value */ | ||
| 972 | break; | ||
| 973 | default: | ||
| 974 | return 0; | ||
| 975 | } | ||
| 976 | } | ||
| 977 | |||
| 978 | return 0; | ||
| 979 | } | ||
| 980 | |||
| 981 | /* | ||
| 982 | * Some v1 VBT MIPI sequences do the deassert in the init OTP sequence. | ||
| 983 | * The deassert must be done before calling intel_dsi_device_ready, so for | ||
| 984 | * these devices we split the init OTP sequence into a deassert sequence and | ||
| 985 | * the actual init OTP part. | ||
| 986 | */ | ||
| 987 | static void fixup_mipi_sequences(struct drm_i915_private *dev_priv) | ||
| 988 | { | ||
| 989 | u8 *init_otp; | ||
| 990 | int len; | ||
| 991 | |||
| 992 | /* Limit this to VLV for now. */ | ||
| 993 | if (!IS_VALLEYVIEW(dev_priv)) | ||
| 994 | return; | ||
| 995 | |||
| 996 | /* Limit this to v1 vid-mode sequences */ | ||
| 997 | if (dev_priv->vbt.dsi.config->is_cmd_mode || | ||
| 998 | dev_priv->vbt.dsi.seq_version != 1) | ||
| 999 | return; | ||
| 1000 | |||
| 1001 | /* Only do this if there are otp and assert seqs and no deassert seq */ | ||
| 1002 | if (!dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP] || | ||
| 1003 | !dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET] || | ||
| 1004 | dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET]) | ||
| 1005 | return; | ||
| 1006 | |||
| 1007 | /* The deassert-sequence ends at the first DSI packet */ | ||
| 1008 | len = get_init_otp_deassert_fragment_len(dev_priv); | ||
| 1009 | if (!len) | ||
| 1010 | return; | ||
| 1011 | |||
| 1012 | DRM_DEBUG_KMS("Using init OTP fragment to deassert reset\n"); | ||
| 1013 | |||
| 1014 | /* Copy the fragment, update seq byte and terminate it */ | ||
| 1015 | init_otp = (u8 *)dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP]; | ||
| 1016 | dev_priv->vbt.dsi.deassert_seq = kmemdup(init_otp, len + 1, GFP_KERNEL); | ||
| 1017 | if (!dev_priv->vbt.dsi.deassert_seq) | ||
| 1018 | return; | ||
| 1019 | dev_priv->vbt.dsi.deassert_seq[0] = MIPI_SEQ_DEASSERT_RESET; | ||
| 1020 | dev_priv->vbt.dsi.deassert_seq[len] = MIPI_SEQ_ELEM_END; | ||
| 1021 | /* Use the copy for deassert */ | ||
| 1022 | dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET] = | ||
| 1023 | dev_priv->vbt.dsi.deassert_seq; | ||
| 1024 | /* Replace the last byte of the fragment with init OTP seq byte */ | ||
| 1025 | init_otp[len - 1] = MIPI_SEQ_INIT_OTP; | ||
| 1026 | /* And make MIPI_MIPI_SEQ_INIT_OTP point to it */ | ||
| 1027 | dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP] = init_otp + len - 1; | ||
| 1028 | } | ||
| 1029 | |||
| 950 | static void | 1030 | static void |
| 951 | parse_mipi_sequence(struct drm_i915_private *dev_priv, | 1031 | parse_mipi_sequence(struct drm_i915_private *dev_priv, |
| 952 | const struct bdb_header *bdb) | 1032 | const struct bdb_header *bdb) |
| @@ -1016,6 +1096,8 @@ parse_mipi_sequence(struct drm_i915_private *dev_priv, | |||
| 1016 | dev_priv->vbt.dsi.size = seq_size; | 1096 | dev_priv->vbt.dsi.size = seq_size; |
| 1017 | dev_priv->vbt.dsi.seq_version = sequence->version; | 1097 | dev_priv->vbt.dsi.seq_version = sequence->version; |
| 1018 | 1098 | ||
| 1099 | fixup_mipi_sequences(dev_priv); | ||
| 1100 | |||
| 1019 | DRM_DEBUG_DRIVER("MIPI related VBT parsing complete\n"); | 1101 | DRM_DEBUG_DRIVER("MIPI related VBT parsing complete\n"); |
| 1020 | return; | 1102 | return; |
| 1021 | 1103 | ||
| @@ -1589,6 +1671,29 @@ out: | |||
| 1589 | } | 1671 | } |
| 1590 | 1672 | ||
| 1591 | /** | 1673 | /** |
| 1674 | * intel_bios_cleanup - Free any resources allocated by intel_bios_init() | ||
| 1675 | * @dev_priv: i915 device instance | ||
| 1676 | */ | ||
| 1677 | void intel_bios_cleanup(struct drm_i915_private *dev_priv) | ||
| 1678 | { | ||
| 1679 | kfree(dev_priv->vbt.child_dev); | ||
| 1680 | dev_priv->vbt.child_dev = NULL; | ||
| 1681 | dev_priv->vbt.child_dev_num = 0; | ||
| 1682 | kfree(dev_priv->vbt.sdvo_lvds_vbt_mode); | ||
| 1683 | dev_priv->vbt.sdvo_lvds_vbt_mode = NULL; | ||
| 1684 | kfree(dev_priv->vbt.lfp_lvds_vbt_mode); | ||
| 1685 | dev_priv->vbt.lfp_lvds_vbt_mode = NULL; | ||
| 1686 | kfree(dev_priv->vbt.dsi.data); | ||
| 1687 | dev_priv->vbt.dsi.data = NULL; | ||
| 1688 | kfree(dev_priv->vbt.dsi.pps); | ||
| 1689 | dev_priv->vbt.dsi.pps = NULL; | ||
| 1690 | kfree(dev_priv->vbt.dsi.config); | ||
| 1691 | dev_priv->vbt.dsi.config = NULL; | ||
| 1692 | kfree(dev_priv->vbt.dsi.deassert_seq); | ||
| 1693 | dev_priv->vbt.dsi.deassert_seq = NULL; | ||
| 1694 | } | ||
| 1695 | |||
| 1696 | /** | ||
| 1592 | * intel_bios_is_tv_present - is integrated TV present in VBT | 1697 | * intel_bios_is_tv_present - is integrated TV present in VBT |
| 1593 | * @dev_priv: i915 device instance | 1698 | * @dev_priv: i915 device instance |
| 1594 | * | 1699 | * |
diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c index bd40fea16b4f..f54ddda9fdad 100644 --- a/drivers/gpu/drm/i915/intel_breadcrumbs.c +++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c | |||
| @@ -594,29 +594,16 @@ void intel_engine_remove_wait(struct intel_engine_cs *engine, | |||
| 594 | spin_unlock_irq(&b->rb_lock); | 594 | spin_unlock_irq(&b->rb_lock); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | static bool signal_valid(const struct drm_i915_gem_request *request) | ||
| 598 | { | ||
| 599 | return intel_wait_check_request(&request->signaling.wait, request); | ||
| 600 | } | ||
| 601 | |||
| 602 | static bool signal_complete(const struct drm_i915_gem_request *request) | 597 | static bool signal_complete(const struct drm_i915_gem_request *request) |
| 603 | { | 598 | { |
| 604 | if (!request) | 599 | if (!request) |
| 605 | return false; | 600 | return false; |
| 606 | 601 | ||
| 607 | /* If another process served as the bottom-half it may have already | 602 | /* |
| 608 | * signalled that this wait is already completed. | 603 | * Carefully check if the request is complete, giving time for the |
| 609 | */ | ||
| 610 | if (intel_wait_complete(&request->signaling.wait)) | ||
| 611 | return signal_valid(request); | ||
| 612 | |||
| 613 | /* Carefully check if the request is complete, giving time for the | ||
| 614 | * seqno to be visible or if the GPU hung. | 604 | * seqno to be visible or if the GPU hung. |
| 615 | */ | 605 | */ |
| 616 | if (__i915_request_irq_complete(request)) | 606 | return __i915_request_irq_complete(request); |
| 617 | return true; | ||
| 618 | |||
| 619 | return false; | ||
| 620 | } | 607 | } |
| 621 | 608 | ||
| 622 | static struct drm_i915_gem_request *to_signaler(struct rb_node *rb) | 609 | static struct drm_i915_gem_request *to_signaler(struct rb_node *rb) |
| @@ -659,9 +646,13 @@ static int intel_breadcrumbs_signaler(void *arg) | |||
| 659 | request = i915_gem_request_get_rcu(request); | 646 | request = i915_gem_request_get_rcu(request); |
| 660 | rcu_read_unlock(); | 647 | rcu_read_unlock(); |
| 661 | if (signal_complete(request)) { | 648 | if (signal_complete(request)) { |
| 662 | local_bh_disable(); | 649 | if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, |
| 663 | dma_fence_signal(&request->fence); | 650 | &request->fence.flags)) { |
| 664 | local_bh_enable(); /* kick start the tasklets */ | 651 | local_bh_disable(); |
| 652 | dma_fence_signal(&request->fence); | ||
| 653 | GEM_BUG_ON(!i915_gem_request_completed(request)); | ||
| 654 | local_bh_enable(); /* kick start the tasklets */ | ||
| 655 | } | ||
| 665 | 656 | ||
| 666 | spin_lock_irq(&b->rb_lock); | 657 | spin_lock_irq(&b->rb_lock); |
| 667 | 658 | ||
diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c index 5dc118f26b51..1704c8897afd 100644 --- a/drivers/gpu/drm/i915/intel_cdclk.c +++ b/drivers/gpu/drm/i915/intel_cdclk.c | |||
| @@ -1952,6 +1952,14 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) | |||
| 1952 | if (crtc_state->has_audio && INTEL_GEN(dev_priv) >= 9) | 1952 | if (crtc_state->has_audio && INTEL_GEN(dev_priv) >= 9) |
| 1953 | min_cdclk = max(2 * 96000, min_cdclk); | 1953 | min_cdclk = max(2 * 96000, min_cdclk); |
| 1954 | 1954 | ||
| 1955 | /* | ||
| 1956 | * On Valleyview some DSI panels lose (v|h)sync when the clock is lower | ||
| 1957 | * than 320000KHz. | ||
| 1958 | */ | ||
| 1959 | if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI) && | ||
| 1960 | IS_VALLEYVIEW(dev_priv)) | ||
| 1961 | min_cdclk = max(320000, min_cdclk); | ||
| 1962 | |||
| 1955 | if (min_cdclk > dev_priv->max_cdclk_freq) { | 1963 | if (min_cdclk > dev_priv->max_cdclk_freq) { |
| 1956 | DRM_DEBUG_KMS("required cdclk (%d kHz) exceeds max (%d kHz)\n", | 1964 | DRM_DEBUG_KMS("required cdclk (%d kHz) exceeds max (%d kHz)\n", |
| 1957 | min_cdclk, dev_priv->max_cdclk_freq); | 1965 | min_cdclk, dev_priv->max_cdclk_freq); |
diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c index d790bdc227ff..fa960cfd2764 100644 --- a/drivers/gpu/drm/i915/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/intel_engine_cs.c | |||
| @@ -1458,7 +1458,9 @@ static bool ring_is_idle(struct intel_engine_cs *engine) | |||
| 1458 | struct drm_i915_private *dev_priv = engine->i915; | 1458 | struct drm_i915_private *dev_priv = engine->i915; |
| 1459 | bool idle = true; | 1459 | bool idle = true; |
| 1460 | 1460 | ||
| 1461 | intel_runtime_pm_get(dev_priv); | 1461 | /* If the whole device is asleep, the engine must be idle */ |
| 1462 | if (!intel_runtime_pm_get_if_in_use(dev_priv)) | ||
| 1463 | return true; | ||
| 1462 | 1464 | ||
| 1463 | /* First check that no commands are left in the ring */ | 1465 | /* First check that no commands are left in the ring */ |
| 1464 | if ((I915_READ_HEAD(engine) & HEAD_ADDR) != | 1466 | if ((I915_READ_HEAD(engine) & HEAD_ADDR) != |
| @@ -1943,16 +1945,22 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance) | |||
| 1943 | */ | 1945 | */ |
| 1944 | int intel_enable_engine_stats(struct intel_engine_cs *engine) | 1946 | int intel_enable_engine_stats(struct intel_engine_cs *engine) |
| 1945 | { | 1947 | { |
| 1948 | struct intel_engine_execlists *execlists = &engine->execlists; | ||
| 1946 | unsigned long flags; | 1949 | unsigned long flags; |
| 1950 | int err = 0; | ||
| 1947 | 1951 | ||
| 1948 | if (!intel_engine_supports_stats(engine)) | 1952 | if (!intel_engine_supports_stats(engine)) |
| 1949 | return -ENODEV; | 1953 | return -ENODEV; |
| 1950 | 1954 | ||
| 1955 | tasklet_disable(&execlists->tasklet); | ||
| 1951 | spin_lock_irqsave(&engine->stats.lock, flags); | 1956 | spin_lock_irqsave(&engine->stats.lock, flags); |
| 1952 | if (engine->stats.enabled == ~0) | 1957 | |
| 1953 | goto busy; | 1958 | if (unlikely(engine->stats.enabled == ~0)) { |
| 1959 | err = -EBUSY; | ||
| 1960 | goto unlock; | ||
| 1961 | } | ||
| 1962 | |||
| 1954 | if (engine->stats.enabled++ == 0) { | 1963 | if (engine->stats.enabled++ == 0) { |
| 1955 | struct intel_engine_execlists *execlists = &engine->execlists; | ||
| 1956 | const struct execlist_port *port = execlists->port; | 1964 | const struct execlist_port *port = execlists->port; |
| 1957 | unsigned int num_ports = execlists_num_ports(execlists); | 1965 | unsigned int num_ports = execlists_num_ports(execlists); |
| 1958 | 1966 | ||
| @@ -1967,14 +1975,12 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine) | |||
| 1967 | if (engine->stats.active) | 1975 | if (engine->stats.active) |
| 1968 | engine->stats.start = engine->stats.enabled_at; | 1976 | engine->stats.start = engine->stats.enabled_at; |
| 1969 | } | 1977 | } |
| 1970 | spin_unlock_irqrestore(&engine->stats.lock, flags); | ||
| 1971 | |||
| 1972 | return 0; | ||
| 1973 | 1978 | ||
| 1974 | busy: | 1979 | unlock: |
| 1975 | spin_unlock_irqrestore(&engine->stats.lock, flags); | 1980 | spin_unlock_irqrestore(&engine->stats.lock, flags); |
| 1981 | tasklet_enable(&execlists->tasklet); | ||
| 1976 | 1982 | ||
| 1977 | return -EBUSY; | 1983 | return err; |
| 1978 | } | 1984 | } |
| 1979 | 1985 | ||
| 1980 | static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine) | 1986 | static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine) |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index c5ff203e42d6..a0e7a6c2a57c 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
| @@ -366,20 +366,6 @@ struct intel_engine_cs { | |||
| 366 | */ | 366 | */ |
| 367 | #define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_SEMA + 1) | 367 | #define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_SEMA + 1) |
| 368 | struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX]; | 368 | struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX]; |
| 369 | /** | ||
| 370 | * @busy_stats: Has enablement of engine stats tracking been | ||
| 371 | * requested. | ||
| 372 | */ | ||
| 373 | bool busy_stats; | ||
| 374 | /** | ||
| 375 | * @disable_busy_stats: Work item for busy stats disabling. | ||
| 376 | * | ||
| 377 | * Same as with @enable_busy_stats action, with the difference | ||
| 378 | * that we delay it in case there are rapid enable-disable | ||
| 379 | * actions, which can happen during tool startup (like perf | ||
| 380 | * stat). | ||
| 381 | */ | ||
| 382 | struct delayed_work disable_busy_stats; | ||
| 383 | } pmu; | 369 | } pmu; |
| 384 | 370 | ||
| 385 | /* | 371 | /* |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c index bf62303571b3..3695cde669f8 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c | |||
| @@ -301,7 +301,7 @@ nvkm_therm_attr_set(struct nvkm_therm *therm, | |||
| 301 | void | 301 | void |
| 302 | nvkm_therm_clkgate_enable(struct nvkm_therm *therm) | 302 | nvkm_therm_clkgate_enable(struct nvkm_therm *therm) |
| 303 | { | 303 | { |
| 304 | if (!therm->func->clkgate_enable || !therm->clkgating_enabled) | 304 | if (!therm || !therm->func->clkgate_enable || !therm->clkgating_enabled) |
| 305 | return; | 305 | return; |
| 306 | 306 | ||
| 307 | nvkm_debug(&therm->subdev, | 307 | nvkm_debug(&therm->subdev, |
| @@ -312,7 +312,7 @@ nvkm_therm_clkgate_enable(struct nvkm_therm *therm) | |||
| 312 | void | 312 | void |
| 313 | nvkm_therm_clkgate_fini(struct nvkm_therm *therm, bool suspend) | 313 | nvkm_therm_clkgate_fini(struct nvkm_therm *therm, bool suspend) |
| 314 | { | 314 | { |
| 315 | if (!therm->func->clkgate_fini || !therm->clkgating_enabled) | 315 | if (!therm || !therm->func->clkgate_fini || !therm->clkgating_enabled) |
| 316 | return; | 316 | return; |
| 317 | 317 | ||
| 318 | nvkm_debug(&therm->subdev, | 318 | nvkm_debug(&therm->subdev, |
| @@ -395,7 +395,7 @@ void | |||
| 395 | nvkm_therm_clkgate_init(struct nvkm_therm *therm, | 395 | nvkm_therm_clkgate_init(struct nvkm_therm *therm, |
| 396 | const struct nvkm_therm_clkgate_pack *p) | 396 | const struct nvkm_therm_clkgate_pack *p) |
| 397 | { | 397 | { |
| 398 | if (!therm->func->clkgate_init || !therm->clkgating_enabled) | 398 | if (!therm || !therm->func->clkgate_init || !therm->clkgating_enabled) |
| 399 | return; | 399 | return; |
| 400 | 400 | ||
| 401 | therm->func->clkgate_init(therm, p); | 401 | therm->func->clkgate_init(therm, p); |
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 4bdbf77f7197..72c338eb5fae 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
| @@ -269,13 +269,13 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | |||
| 269 | for (i = 0; i < ARRAY_SIZE(tjmax_model_table); i++) { | 269 | for (i = 0; i < ARRAY_SIZE(tjmax_model_table); i++) { |
| 270 | const struct tjmax_model *tm = &tjmax_model_table[i]; | 270 | const struct tjmax_model *tm = &tjmax_model_table[i]; |
| 271 | if (c->x86_model == tm->model && | 271 | if (c->x86_model == tm->model && |
| 272 | (tm->mask == ANY || c->x86_mask == tm->mask)) | 272 | (tm->mask == ANY || c->x86_stepping == tm->mask)) |
| 273 | return tm->tjmax; | 273 | return tm->tjmax; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | /* Early chips have no MSR for TjMax */ | 276 | /* Early chips have no MSR for TjMax */ |
| 277 | 277 | ||
| 278 | if (c->x86_model == 0xf && c->x86_mask < 4) | 278 | if (c->x86_model == 0xf && c->x86_stepping < 4) |
| 279 | usemsr_ee = 0; | 279 | usemsr_ee = 0; |
| 280 | 280 | ||
| 281 | if (c->x86_model > 0xe && usemsr_ee) { | 281 | if (c->x86_model > 0xe && usemsr_ee) { |
| @@ -426,7 +426,7 @@ static int chk_ucode_version(unsigned int cpu) | |||
| 426 | * Readings might stop update when processor visited too deep sleep, | 426 | * Readings might stop update when processor visited too deep sleep, |
| 427 | * fixed for stepping D0 (6EC). | 427 | * fixed for stepping D0 (6EC). |
| 428 | */ | 428 | */ |
| 429 | if (c->x86_model == 0xe && c->x86_mask < 0xc && c->microcode < 0x39) { | 429 | if (c->x86_model == 0xe && c->x86_stepping < 0xc && c->microcode < 0x39) { |
| 430 | pr_err("Errata AE18 not fixed, update BIOS or microcode of the CPU!\n"); | 430 | pr_err("Errata AE18 not fixed, update BIOS or microcode of the CPU!\n"); |
| 431 | return -ENODEV; | 431 | return -ENODEV; |
| 432 | } | 432 | } |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index ef91b8a67549..84e91286fc4f 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
| @@ -293,7 +293,7 @@ u8 vid_which_vrm(void) | |||
| 293 | if (c->x86 < 6) /* Any CPU with family lower than 6 */ | 293 | if (c->x86 < 6) /* Any CPU with family lower than 6 */ |
| 294 | return 0; /* doesn't have VID */ | 294 | return 0; /* doesn't have VID */ |
| 295 | 295 | ||
| 296 | vrm_ret = find_vrm(c->x86, c->x86_model, c->x86_mask, c->x86_vendor); | 296 | vrm_ret = find_vrm(c->x86, c->x86_model, c->x86_stepping, c->x86_vendor); |
| 297 | if (vrm_ret == 134) | 297 | if (vrm_ret == 134) |
| 298 | vrm_ret = get_via_model_d_vrm(); | 298 | vrm_ret = get_via_model_d_vrm(); |
| 299 | if (vrm_ret == 0) | 299 | if (vrm_ret == 0) |
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 06b4e1c78bd8..051a72eecb24 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c | |||
| @@ -129,7 +129,10 @@ static ssize_t temp1_input_show(struct device *dev, | |||
| 129 | 129 | ||
| 130 | data->read_tempreg(data->pdev, ®val); | 130 | data->read_tempreg(data->pdev, ®val); |
| 131 | temp = (regval >> 21) * 125; | 131 | temp = (regval >> 21) * 125; |
| 132 | temp -= data->temp_offset; | 132 | if (temp > data->temp_offset) |
| 133 | temp -= data->temp_offset; | ||
| 134 | else | ||
| 135 | temp = 0; | ||
| 133 | 136 | ||
| 134 | return sprintf(buf, "%u\n", temp); | 137 | return sprintf(buf, "%u\n", temp); |
| 135 | } | 138 | } |
| @@ -227,7 +230,7 @@ static bool has_erratum_319(struct pci_dev *pdev) | |||
| 227 | * and AM3 formats, but that's the best we can do. | 230 | * and AM3 formats, but that's the best we can do. |
| 228 | */ | 231 | */ |
| 229 | return boot_cpu_data.x86_model < 4 || | 232 | return boot_cpu_data.x86_model < 4 || |
| 230 | (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_mask <= 2); | 233 | (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_stepping <= 2); |
| 231 | } | 234 | } |
| 232 | 235 | ||
| 233 | static int k10temp_probe(struct pci_dev *pdev, | 236 | static int k10temp_probe(struct pci_dev *pdev, |
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 5a632bcf869b..e59f9113fb93 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c | |||
| @@ -187,7 +187,7 @@ static int k8temp_probe(struct pci_dev *pdev, | |||
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
| 188 | 188 | ||
| 189 | model = boot_cpu_data.x86_model; | 189 | model = boot_cpu_data.x86_model; |
| 190 | stepping = boot_cpu_data.x86_mask; | 190 | stepping = boot_cpu_data.x86_stepping; |
| 191 | 191 | ||
| 192 | /* feature available since SH-C0, exclude older revisions */ | 192 | /* feature available since SH-C0, exclude older revisions */ |
| 193 | if ((model == 4 && stepping == 0) || | 193 | if ((model == 4 && stepping == 0) || |
diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c index 55cfb986225b..faf734ff4cf3 100644 --- a/drivers/irqchip/irq-bcm7038-l1.c +++ b/drivers/irqchip/irq-bcm7038-l1.c | |||
| @@ -339,9 +339,6 @@ int __init bcm7038_l1_of_init(struct device_node *dn, | |||
| 339 | goto out_unmap; | 339 | goto out_unmap; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | pr_info("registered BCM7038 L1 intc (mem: 0x%p, IRQs: %d)\n", | ||
| 343 | intc->cpus[0]->map_base, IRQS_PER_WORD * intc->n_words); | ||
| 344 | |||
| 345 | return 0; | 342 | return 0; |
| 346 | 343 | ||
| 347 | out_unmap: | 344 | out_unmap: |
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c index 983640eba418..8968e5e93fcb 100644 --- a/drivers/irqchip/irq-bcm7120-l2.c +++ b/drivers/irqchip/irq-bcm7120-l2.c | |||
| @@ -318,9 +318,6 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn, | |||
| 318 | } | 318 | } |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | pr_info("registered %s intc (mem: 0x%p, parent IRQ(s): %d)\n", | ||
| 322 | intc_name, data->map_base[0], data->num_parent_irqs); | ||
| 323 | |||
| 324 | return 0; | 321 | return 0; |
| 325 | 322 | ||
| 326 | out_free_domain: | 323 | out_free_domain: |
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c index 691d20eb0bec..0e65f609352e 100644 --- a/drivers/irqchip/irq-brcmstb-l2.c +++ b/drivers/irqchip/irq-brcmstb-l2.c | |||
| @@ -262,9 +262,6 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np, | |||
| 262 | ct->chip.irq_set_wake = irq_gc_set_wake; | 262 | ct->chip.irq_set_wake = irq_gc_set_wake; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | pr_info("registered L2 intc (mem: 0x%p, parent irq: %d)\n", | ||
| 266 | base, parent_irq); | ||
| 267 | |||
| 268 | return 0; | 265 | return 0; |
| 269 | 266 | ||
| 270 | out_free_domain: | 267 | out_free_domain: |
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 993a8426a453..1ff38aff9f29 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c | |||
| @@ -94,7 +94,7 @@ static struct irq_chip gicv2m_msi_irq_chip = { | |||
| 94 | 94 | ||
| 95 | static struct msi_domain_info gicv2m_msi_domain_info = { | 95 | static struct msi_domain_info gicv2m_msi_domain_info = { |
| 96 | .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | | 96 | .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | |
| 97 | MSI_FLAG_PCI_MSIX), | 97 | MSI_FLAG_PCI_MSIX | MSI_FLAG_MULTI_PCI_MSI), |
| 98 | .chip = &gicv2m_msi_irq_chip, | 98 | .chip = &gicv2m_msi_irq_chip, |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| @@ -155,18 +155,12 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain, | |||
| 155 | return 0; | 155 | return 0; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | static void gicv2m_unalloc_msi(struct v2m_data *v2m, unsigned int hwirq) | 158 | static void gicv2m_unalloc_msi(struct v2m_data *v2m, unsigned int hwirq, |
| 159 | int nr_irqs) | ||
| 159 | { | 160 | { |
| 160 | int pos; | ||
| 161 | |||
| 162 | pos = hwirq - v2m->spi_start; | ||
| 163 | if (pos < 0 || pos >= v2m->nr_spis) { | ||
| 164 | pr_err("Failed to teardown msi. Invalid hwirq %d\n", hwirq); | ||
| 165 | return; | ||
| 166 | } | ||
| 167 | |||
| 168 | spin_lock(&v2m_lock); | 161 | spin_lock(&v2m_lock); |
| 169 | __clear_bit(pos, v2m->bm); | 162 | bitmap_release_region(v2m->bm, hwirq - v2m->spi_start, |
| 163 | get_count_order(nr_irqs)); | ||
| 170 | spin_unlock(&v2m_lock); | 164 | spin_unlock(&v2m_lock); |
| 171 | } | 165 | } |
| 172 | 166 | ||
| @@ -174,13 +168,13 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
| 174 | unsigned int nr_irqs, void *args) | 168 | unsigned int nr_irqs, void *args) |
| 175 | { | 169 | { |
| 176 | struct v2m_data *v2m = NULL, *tmp; | 170 | struct v2m_data *v2m = NULL, *tmp; |
| 177 | int hwirq, offset, err = 0; | 171 | int hwirq, offset, i, err = 0; |
| 178 | 172 | ||
| 179 | spin_lock(&v2m_lock); | 173 | spin_lock(&v2m_lock); |
| 180 | list_for_each_entry(tmp, &v2m_nodes, entry) { | 174 | list_for_each_entry(tmp, &v2m_nodes, entry) { |
| 181 | offset = find_first_zero_bit(tmp->bm, tmp->nr_spis); | 175 | offset = bitmap_find_free_region(tmp->bm, tmp->nr_spis, |
| 182 | if (offset < tmp->nr_spis) { | 176 | get_count_order(nr_irqs)); |
| 183 | __set_bit(offset, tmp->bm); | 177 | if (offset >= 0) { |
| 184 | v2m = tmp; | 178 | v2m = tmp; |
| 185 | break; | 179 | break; |
| 186 | } | 180 | } |
| @@ -192,16 +186,21 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
| 192 | 186 | ||
| 193 | hwirq = v2m->spi_start + offset; | 187 | hwirq = v2m->spi_start + offset; |
| 194 | 188 | ||
| 195 | err = gicv2m_irq_gic_domain_alloc(domain, virq, hwirq); | 189 | for (i = 0; i < nr_irqs; i++) { |
| 196 | if (err) { | 190 | err = gicv2m_irq_gic_domain_alloc(domain, virq + i, hwirq + i); |
| 197 | gicv2m_unalloc_msi(v2m, hwirq); | 191 | if (err) |
| 198 | return err; | 192 | goto fail; |
| 199 | } | ||
| 200 | 193 | ||
| 201 | irq_domain_set_hwirq_and_chip(domain, virq, hwirq, | 194 | irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i, |
| 202 | &gicv2m_irq_chip, v2m); | 195 | &gicv2m_irq_chip, v2m); |
| 196 | } | ||
| 203 | 197 | ||
| 204 | return 0; | 198 | return 0; |
| 199 | |||
| 200 | fail: | ||
| 201 | irq_domain_free_irqs_parent(domain, virq, nr_irqs); | ||
| 202 | gicv2m_unalloc_msi(v2m, hwirq, get_count_order(nr_irqs)); | ||
| 203 | return err; | ||
| 205 | } | 204 | } |
| 206 | 205 | ||
| 207 | static void gicv2m_irq_domain_free(struct irq_domain *domain, | 206 | static void gicv2m_irq_domain_free(struct irq_domain *domain, |
| @@ -210,8 +209,7 @@ static void gicv2m_irq_domain_free(struct irq_domain *domain, | |||
| 210 | struct irq_data *d = irq_domain_get_irq_data(domain, virq); | 209 | struct irq_data *d = irq_domain_get_irq_data(domain, virq); |
| 211 | struct v2m_data *v2m = irq_data_get_irq_chip_data(d); | 210 | struct v2m_data *v2m = irq_data_get_irq_chip_data(d); |
| 212 | 211 | ||
| 213 | BUG_ON(nr_irqs != 1); | 212 | gicv2m_unalloc_msi(v2m, d->hwirq, nr_irqs); |
| 214 | gicv2m_unalloc_msi(v2m, d->hwirq); | ||
| 215 | irq_domain_free_irqs_parent(domain, virq, nr_irqs); | 213 | irq_domain_free_irqs_parent(domain, virq, nr_irqs); |
| 216 | } | 214 | } |
| 217 | 215 | ||
diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index 14a8c0a7e095..25a98de5cfb2 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c | |||
| @@ -132,6 +132,8 @@ static int __init its_pci_of_msi_init(void) | |||
| 132 | 132 | ||
| 133 | for (np = of_find_matching_node(NULL, its_device_id); np; | 133 | for (np = of_find_matching_node(NULL, its_device_id); np; |
| 134 | np = of_find_matching_node(np, its_device_id)) { | 134 | np = of_find_matching_node(np, its_device_id)) { |
| 135 | if (!of_device_is_available(np)) | ||
| 136 | continue; | ||
| 135 | if (!of_property_read_bool(np, "msi-controller")) | 137 | if (!of_property_read_bool(np, "msi-controller")) |
| 136 | continue; | 138 | continue; |
| 137 | 139 | ||
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 833a90fe33ae..8881a053c173 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c | |||
| @@ -154,6 +154,8 @@ static void __init its_pmsi_of_init(void) | |||
| 154 | 154 | ||
| 155 | for (np = of_find_matching_node(NULL, its_device_id); np; | 155 | for (np = of_find_matching_node(NULL, its_device_id); np; |
| 156 | np = of_find_matching_node(np, its_device_id)) { | 156 | np = of_find_matching_node(np, its_device_id)) { |
| 157 | if (!of_device_is_available(np)) | ||
| 158 | continue; | ||
| 157 | if (!of_property_read_bool(np, "msi-controller")) | 159 | if (!of_property_read_bool(np, "msi-controller")) |
| 158 | continue; | 160 | continue; |
| 159 | 161 | ||
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 06f025fd5726..1d3056f53747 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
| @@ -3314,6 +3314,8 @@ static int __init its_of_probe(struct device_node *node) | |||
| 3314 | 3314 | ||
| 3315 | for (np = of_find_matching_node(node, its_device_id); np; | 3315 | for (np = of_find_matching_node(node, its_device_id); np; |
| 3316 | np = of_find_matching_node(np, its_device_id)) { | 3316 | np = of_find_matching_node(np, its_device_id)) { |
| 3317 | if (!of_device_is_available(np)) | ||
| 3318 | continue; | ||
| 3317 | if (!of_property_read_bool(np, "msi-controller")) { | 3319 | if (!of_property_read_bool(np, "msi-controller")) { |
| 3318 | pr_warn("%pOF: no msi-controller property, ITS ignored\n", | 3320 | pr_warn("%pOF: no msi-controller property, ITS ignored\n", |
| 3319 | np); | 3321 | np); |
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index a57c0fbbd34a..d99cc07903ec 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c | |||
| @@ -673,7 +673,7 @@ static void gic_send_sgi(u64 cluster_id, u16 tlist, unsigned int irq) | |||
| 673 | MPIDR_TO_SGI_RS(cluster_id) | | 673 | MPIDR_TO_SGI_RS(cluster_id) | |
| 674 | tlist << ICC_SGI1R_TARGET_LIST_SHIFT); | 674 | tlist << ICC_SGI1R_TARGET_LIST_SHIFT); |
| 675 | 675 | ||
| 676 | pr_debug("CPU%d: ICC_SGI1R_EL1 %llx\n", smp_processor_id(), val); | 676 | pr_devel("CPU%d: ICC_SGI1R_EL1 %llx\n", smp_processor_id(), val); |
| 677 | gic_write_sgi1r(val); | 677 | gic_write_sgi1r(val); |
| 678 | } | 678 | } |
| 679 | 679 | ||
| @@ -688,7 +688,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) | |||
| 688 | * Ensure that stores to Normal memory are visible to the | 688 | * Ensure that stores to Normal memory are visible to the |
| 689 | * other CPUs before issuing the IPI. | 689 | * other CPUs before issuing the IPI. |
| 690 | */ | 690 | */ |
| 691 | smp_wmb(); | 691 | wmb(); |
| 692 | 692 | ||
| 693 | for_each_cpu(cpu, mask) { | 693 | for_each_cpu(cpu, mask) { |
| 694 | u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu)); | 694 | u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu)); |
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index ef92a4d2038e..d32268cc1174 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
| @@ -424,8 +424,6 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq, | |||
| 424 | spin_lock_irqsave(&gic_lock, flags); | 424 | spin_lock_irqsave(&gic_lock, flags); |
| 425 | write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); | 425 | write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); |
| 426 | write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); | 426 | write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); |
| 427 | gic_clear_pcpu_masks(intr); | ||
| 428 | set_bit(intr, per_cpu_ptr(pcpu_masks, cpu)); | ||
| 429 | irq_data_update_effective_affinity(data, cpumask_of(cpu)); | 427 | irq_data_update_effective_affinity(data, cpumask_of(cpu)); |
| 430 | spin_unlock_irqrestore(&gic_lock, flags); | 428 | spin_unlock_irqrestore(&gic_lock, flags); |
| 431 | 429 | ||
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 62f541f968f6..07074820a167 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
| @@ -375,6 +375,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, | |||
| 375 | dev->ofdev.dev.of_node = np; | 375 | dev->ofdev.dev.of_node = np; |
| 376 | dev->ofdev.archdata.dma_mask = 0xffffffffUL; | 376 | dev->ofdev.archdata.dma_mask = 0xffffffffUL; |
| 377 | dev->ofdev.dev.dma_mask = &dev->ofdev.archdata.dma_mask; | 377 | dev->ofdev.dev.dma_mask = &dev->ofdev.archdata.dma_mask; |
| 378 | dev->ofdev.dev.coherent_dma_mask = dev->ofdev.archdata.dma_mask; | ||
| 378 | dev->ofdev.dev.parent = parent; | 379 | dev->ofdev.dev.parent = parent; |
| 379 | dev->ofdev.dev.bus = &macio_bus_type; | 380 | dev->ofdev.dev.bus = &macio_bus_type; |
| 380 | dev->ofdev.dev.release = macio_release_dev; | 381 | dev->ofdev.dev.release = macio_release_dev; |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index d6de00f367ef..68136806d365 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -903,7 +903,8 @@ static void dec_pending(struct dm_io *io, blk_status_t error) | |||
| 903 | queue_io(md, bio); | 903 | queue_io(md, bio); |
| 904 | } else { | 904 | } else { |
| 905 | /* done with normal IO or empty flush */ | 905 | /* done with normal IO or empty flush */ |
| 906 | bio->bi_status = io_error; | 906 | if (io_error) |
| 907 | bio->bi_status = io_error; | ||
| 907 | bio_endio(bio); | 908 | bio_endio(bio); |
| 908 | } | 909 | } |
| 909 | } | 910 | } |
diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index d9aa407db06a..2dd2db9bc1c9 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c | |||
| @@ -277,7 +277,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count, | |||
| 277 | struct ocxl_context *ctx = file->private_data; | 277 | struct ocxl_context *ctx = file->private_data; |
| 278 | struct ocxl_kernel_event_header header; | 278 | struct ocxl_kernel_event_header header; |
| 279 | ssize_t rc; | 279 | ssize_t rc; |
| 280 | size_t used = 0; | 280 | ssize_t used = 0; |
| 281 | DEFINE_WAIT(event_wait); | 281 | DEFINE_WAIT(event_wait); |
| 282 | 282 | ||
| 283 | memset(&header, 0, sizeof(header)); | 283 | memset(&header, 0, sizeof(header)); |
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 229dc18f0581..768972af8b85 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c | |||
| @@ -1265,7 +1265,8 @@ static int bcm2835_add_host(struct bcm2835_host *host) | |||
| 1265 | char pio_limit_string[20]; | 1265 | char pio_limit_string[20]; |
| 1266 | int ret; | 1266 | int ret; |
| 1267 | 1267 | ||
| 1268 | mmc->f_max = host->max_clk; | 1268 | if (!mmc->f_max || mmc->f_max > host->max_clk) |
| 1269 | mmc->f_max = host->max_clk; | ||
| 1269 | mmc->f_min = host->max_clk / SDCDIV_MAX_CDIV; | 1270 | mmc->f_min = host->max_clk / SDCDIV_MAX_CDIV; |
| 1270 | 1271 | ||
| 1271 | mmc->max_busy_timeout = ~0 / (mmc->f_max / 1000); | 1272 | mmc->max_busy_timeout = ~0 / (mmc->f_max / 1000); |
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 22438ebfe4e6..4f972b879fe6 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c | |||
| @@ -717,22 +717,6 @@ static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode, | |||
| 717 | static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) | 717 | static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) |
| 718 | { | 718 | { |
| 719 | struct meson_host *host = mmc_priv(mmc); | 719 | struct meson_host *host = mmc_priv(mmc); |
| 720 | int ret; | ||
| 721 | |||
| 722 | /* | ||
| 723 | * If this is the initial tuning, try to get a sane Rx starting | ||
| 724 | * phase before doing the actual tuning. | ||
| 725 | */ | ||
| 726 | if (!mmc->doing_retune) { | ||
| 727 | ret = meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); | ||
| 728 | |||
| 729 | if (ret) | ||
| 730 | return ret; | ||
| 731 | } | ||
| 732 | |||
| 733 | ret = meson_mmc_clk_phase_tuning(mmc, opcode, host->tx_clk); | ||
| 734 | if (ret) | ||
| 735 | return ret; | ||
| 736 | 720 | ||
| 737 | return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); | 721 | return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); |
| 738 | } | 722 | } |
| @@ -763,9 +747,8 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
| 763 | if (!IS_ERR(mmc->supply.vmmc)) | 747 | if (!IS_ERR(mmc->supply.vmmc)) |
| 764 | mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); | 748 | mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); |
| 765 | 749 | ||
| 766 | /* Reset phases */ | 750 | /* Reset rx phase */ |
| 767 | clk_set_phase(host->rx_clk, 0); | 751 | clk_set_phase(host->rx_clk, 0); |
| 768 | clk_set_phase(host->tx_clk, 270); | ||
| 769 | 752 | ||
| 770 | break; | 753 | break; |
| 771 | 754 | ||
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index e6b8c59f2c0d..736ac887303c 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
| @@ -328,7 +328,7 @@ config MTD_NAND_MARVELL | |||
| 328 | tristate "NAND controller support on Marvell boards" | 328 | tristate "NAND controller support on Marvell boards" |
| 329 | depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU || \ | 329 | depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU || \ |
| 330 | COMPILE_TEST | 330 | COMPILE_TEST |
| 331 | depends on HAS_IOMEM | 331 | depends on HAS_IOMEM && HAS_DMA |
| 332 | help | 332 | help |
| 333 | This enables the NAND flash controller driver for Marvell boards, | 333 | This enables the NAND flash controller driver for Marvell boards, |
| 334 | including: | 334 | including: |
diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 80d31a58e558..f367144f3c6f 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c | |||
| @@ -752,10 +752,8 @@ static int vf610_nfc_probe(struct platform_device *pdev) | |||
| 752 | if (mtd->oobsize > 64) | 752 | if (mtd->oobsize > 64) |
| 753 | mtd->oobsize = 64; | 753 | mtd->oobsize = 64; |
| 754 | 754 | ||
| 755 | /* | 755 | /* Use default large page ECC layout defined in NAND core */ |
| 756 | * mtd->ecclayout is not specified here because we're using the | 756 | mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops); |
| 757 | * default large page ECC layout defined in NAND core. | ||
| 758 | */ | ||
| 759 | if (chip->ecc.strength == 32) { | 757 | if (chip->ecc.strength == 32) { |
| 760 | nfc->ecc_mode = ECC_60_BYTE; | 758 | nfc->ecc_mode = ECC_60_BYTE; |
| 761 | chip->ecc.bytes = 60; | 759 | chip->ecc.bytes = 60; |
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f431c32774f3..0fe7ea35c221 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
| @@ -120,8 +120,12 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl) | |||
| 120 | int ret; | 120 | int ret; |
| 121 | 121 | ||
| 122 | ret = nvme_reset_ctrl(ctrl); | 122 | ret = nvme_reset_ctrl(ctrl); |
| 123 | if (!ret) | 123 | if (!ret) { |
| 124 | flush_work(&ctrl->reset_work); | 124 | flush_work(&ctrl->reset_work); |
| 125 | if (ctrl->state != NVME_CTRL_LIVE) | ||
| 126 | ret = -ENETRESET; | ||
| 127 | } | ||
| 128 | |||
| 125 | return ret; | 129 | return ret; |
| 126 | } | 130 | } |
| 127 | EXPORT_SYMBOL_GPL(nvme_reset_ctrl_sync); | 131 | EXPORT_SYMBOL_GPL(nvme_reset_ctrl_sync); |
| @@ -265,7 +269,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | |||
| 265 | switch (new_state) { | 269 | switch (new_state) { |
| 266 | case NVME_CTRL_ADMIN_ONLY: | 270 | case NVME_CTRL_ADMIN_ONLY: |
| 267 | switch (old_state) { | 271 | switch (old_state) { |
| 268 | case NVME_CTRL_RECONNECTING: | 272 | case NVME_CTRL_CONNECTING: |
| 269 | changed = true; | 273 | changed = true; |
| 270 | /* FALLTHRU */ | 274 | /* FALLTHRU */ |
| 271 | default: | 275 | default: |
| @@ -276,7 +280,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | |||
| 276 | switch (old_state) { | 280 | switch (old_state) { |
| 277 | case NVME_CTRL_NEW: | 281 | case NVME_CTRL_NEW: |
| 278 | case NVME_CTRL_RESETTING: | 282 | case NVME_CTRL_RESETTING: |
| 279 | case NVME_CTRL_RECONNECTING: | 283 | case NVME_CTRL_CONNECTING: |
| 280 | changed = true; | 284 | changed = true; |
| 281 | /* FALLTHRU */ | 285 | /* FALLTHRU */ |
| 282 | default: | 286 | default: |
| @@ -294,9 +298,9 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | |||
| 294 | break; | 298 | break; |
| 295 | } | 299 | } |
| 296 | break; | 300 | break; |
| 297 | case NVME_CTRL_RECONNECTING: | 301 | case NVME_CTRL_CONNECTING: |
| 298 | switch (old_state) { | 302 | switch (old_state) { |
| 299 | case NVME_CTRL_LIVE: | 303 | case NVME_CTRL_NEW: |
| 300 | case NVME_CTRL_RESETTING: | 304 | case NVME_CTRL_RESETTING: |
| 301 | changed = true; | 305 | changed = true; |
| 302 | /* FALLTHRU */ | 306 | /* FALLTHRU */ |
| @@ -309,7 +313,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | |||
| 309 | case NVME_CTRL_LIVE: | 313 | case NVME_CTRL_LIVE: |
| 310 | case NVME_CTRL_ADMIN_ONLY: | 314 | case NVME_CTRL_ADMIN_ONLY: |
| 311 | case NVME_CTRL_RESETTING: | 315 | case NVME_CTRL_RESETTING: |
| 312 | case NVME_CTRL_RECONNECTING: | 316 | case NVME_CTRL_CONNECTING: |
| 313 | changed = true; | 317 | changed = true; |
| 314 | /* FALLTHRU */ | 318 | /* FALLTHRU */ |
| 315 | default: | 319 | default: |
| @@ -518,9 +522,11 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, | |||
| 518 | u64 slba = nvme_block_nr(ns, bio->bi_iter.bi_sector); | 522 | u64 slba = nvme_block_nr(ns, bio->bi_iter.bi_sector); |
| 519 | u32 nlb = bio->bi_iter.bi_size >> ns->lba_shift; | 523 | u32 nlb = bio->bi_iter.bi_size >> ns->lba_shift; |
| 520 | 524 | ||
| 521 | range[n].cattr = cpu_to_le32(0); | 525 | if (n < segments) { |
| 522 | range[n].nlb = cpu_to_le32(nlb); | 526 | range[n].cattr = cpu_to_le32(0); |
| 523 | range[n].slba = cpu_to_le64(slba); | 527 | range[n].nlb = cpu_to_le32(nlb); |
| 528 | range[n].slba = cpu_to_le64(slba); | ||
| 529 | } | ||
| 524 | n++; | 530 | n++; |
| 525 | } | 531 | } |
| 526 | 532 | ||
| @@ -794,13 +800,9 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status) | |||
| 794 | 800 | ||
| 795 | static int nvme_keep_alive(struct nvme_ctrl *ctrl) | 801 | static int nvme_keep_alive(struct nvme_ctrl *ctrl) |
| 796 | { | 802 | { |
| 797 | struct nvme_command c; | ||
| 798 | struct request *rq; | 803 | struct request *rq; |
| 799 | 804 | ||
| 800 | memset(&c, 0, sizeof(c)); | 805 | rq = nvme_alloc_request(ctrl->admin_q, &ctrl->ka_cmd, BLK_MQ_REQ_RESERVED, |
| 801 | c.common.opcode = nvme_admin_keep_alive; | ||
| 802 | |||
| 803 | rq = nvme_alloc_request(ctrl->admin_q, &c, BLK_MQ_REQ_RESERVED, | ||
| 804 | NVME_QID_ANY); | 806 | NVME_QID_ANY); |
| 805 | if (IS_ERR(rq)) | 807 | if (IS_ERR(rq)) |
| 806 | return PTR_ERR(rq); | 808 | return PTR_ERR(rq); |
| @@ -832,6 +834,8 @@ void nvme_start_keep_alive(struct nvme_ctrl *ctrl) | |||
| 832 | return; | 834 | return; |
| 833 | 835 | ||
| 834 | INIT_DELAYED_WORK(&ctrl->ka_work, nvme_keep_alive_work); | 836 | INIT_DELAYED_WORK(&ctrl->ka_work, nvme_keep_alive_work); |
| 837 | memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd)); | ||
| 838 | ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive; | ||
| 835 | schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); | 839 | schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); |
| 836 | } | 840 | } |
| 837 | EXPORT_SYMBOL_GPL(nvme_start_keep_alive); | 841 | EXPORT_SYMBOL_GPL(nvme_start_keep_alive); |
| @@ -1117,14 +1121,19 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, | |||
| 1117 | 1121 | ||
| 1118 | static void nvme_update_formats(struct nvme_ctrl *ctrl) | 1122 | static void nvme_update_formats(struct nvme_ctrl *ctrl) |
| 1119 | { | 1123 | { |
| 1120 | struct nvme_ns *ns; | 1124 | struct nvme_ns *ns, *next; |
| 1125 | LIST_HEAD(rm_list); | ||
| 1121 | 1126 | ||
| 1122 | mutex_lock(&ctrl->namespaces_mutex); | 1127 | mutex_lock(&ctrl->namespaces_mutex); |
| 1123 | list_for_each_entry(ns, &ctrl->namespaces, list) { | 1128 | list_for_each_entry(ns, &ctrl->namespaces, list) { |
| 1124 | if (ns->disk && nvme_revalidate_disk(ns->disk)) | 1129 | if (ns->disk && nvme_revalidate_disk(ns->disk)) { |
| 1125 | nvme_ns_remove(ns); | 1130 | list_move_tail(&ns->list, &rm_list); |
| 1131 | } | ||
| 1126 | } | 1132 | } |
| 1127 | mutex_unlock(&ctrl->namespaces_mutex); | 1133 | mutex_unlock(&ctrl->namespaces_mutex); |
| 1134 | |||
| 1135 | list_for_each_entry_safe(ns, next, &rm_list, list) | ||
| 1136 | nvme_ns_remove(ns); | ||
| 1128 | } | 1137 | } |
| 1129 | 1138 | ||
| 1130 | static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) | 1139 | static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) |
| @@ -2687,7 +2696,7 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, | |||
| 2687 | [NVME_CTRL_LIVE] = "live", | 2696 | [NVME_CTRL_LIVE] = "live", |
| 2688 | [NVME_CTRL_ADMIN_ONLY] = "only-admin", | 2697 | [NVME_CTRL_ADMIN_ONLY] = "only-admin", |
| 2689 | [NVME_CTRL_RESETTING] = "resetting", | 2698 | [NVME_CTRL_RESETTING] = "resetting", |
| 2690 | [NVME_CTRL_RECONNECTING]= "reconnecting", | 2699 | [NVME_CTRL_CONNECTING] = "connecting", |
| 2691 | [NVME_CTRL_DELETING] = "deleting", | 2700 | [NVME_CTRL_DELETING] = "deleting", |
| 2692 | [NVME_CTRL_DEAD] = "dead", | 2701 | [NVME_CTRL_DEAD] = "dead", |
| 2693 | }; | 2702 | }; |
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 25b19f722f5b..a3145d90c1d2 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h | |||
| @@ -171,13 +171,14 @@ static inline blk_status_t nvmf_check_init_req(struct nvme_ctrl *ctrl, | |||
| 171 | cmd->common.opcode != nvme_fabrics_command || | 171 | cmd->common.opcode != nvme_fabrics_command || |
| 172 | cmd->fabrics.fctype != nvme_fabrics_type_connect) { | 172 | cmd->fabrics.fctype != nvme_fabrics_type_connect) { |
| 173 | /* | 173 | /* |
| 174 | * Reconnecting state means transport disruption, which can take | 174 | * Connecting state means transport disruption or initial |
| 175 | * a long time and even might fail permanently, fail fast to | 175 | * establishment, which can take a long time and even might |
| 176 | * give upper layers a chance to failover. | 176 | * fail permanently, fail fast to give upper layers a chance |
| 177 | * to failover. | ||
| 177 | * Deleting state means that the ctrl will never accept commands | 178 | * Deleting state means that the ctrl will never accept commands |
| 178 | * again, fail it permanently. | 179 | * again, fail it permanently. |
| 179 | */ | 180 | */ |
| 180 | if (ctrl->state == NVME_CTRL_RECONNECTING || | 181 | if (ctrl->state == NVME_CTRL_CONNECTING || |
| 181 | ctrl->state == NVME_CTRL_DELETING) { | 182 | ctrl->state == NVME_CTRL_DELETING) { |
| 182 | nvme_req(rq)->status = NVME_SC_ABORT_REQ; | 183 | nvme_req(rq)->status = NVME_SC_ABORT_REQ; |
| 183 | return BLK_STS_IOERR; | 184 | return BLK_STS_IOERR; |
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b856d7c919d2..7f51f8414b97 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c | |||
| @@ -55,9 +55,7 @@ struct nvme_fc_queue { | |||
| 55 | 55 | ||
| 56 | enum nvme_fcop_flags { | 56 | enum nvme_fcop_flags { |
| 57 | FCOP_FLAGS_TERMIO = (1 << 0), | 57 | FCOP_FLAGS_TERMIO = (1 << 0), |
| 58 | FCOP_FLAGS_RELEASED = (1 << 1), | 58 | FCOP_FLAGS_AEN = (1 << 1), |
| 59 | FCOP_FLAGS_COMPLETE = (1 << 2), | ||
| 60 | FCOP_FLAGS_AEN = (1 << 3), | ||
| 61 | }; | 59 | }; |
| 62 | 60 | ||
| 63 | struct nvmefc_ls_req_op { | 61 | struct nvmefc_ls_req_op { |
| @@ -532,7 +530,7 @@ nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) | |||
| 532 | { | 530 | { |
| 533 | switch (ctrl->ctrl.state) { | 531 | switch (ctrl->ctrl.state) { |
| 534 | case NVME_CTRL_NEW: | 532 | case NVME_CTRL_NEW: |
| 535 | case NVME_CTRL_RECONNECTING: | 533 | case NVME_CTRL_CONNECTING: |
| 536 | /* | 534 | /* |
| 537 | * As all reconnects were suppressed, schedule a | 535 | * As all reconnects were suppressed, schedule a |
| 538 | * connect. | 536 | * connect. |
| @@ -777,7 +775,7 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) | |||
| 777 | } | 775 | } |
| 778 | break; | 776 | break; |
| 779 | 777 | ||
| 780 | case NVME_CTRL_RECONNECTING: | 778 | case NVME_CTRL_CONNECTING: |
| 781 | /* | 779 | /* |
| 782 | * The association has already been terminated and the | 780 | * The association has already been terminated and the |
| 783 | * controller is attempting reconnects. No need to do anything | 781 | * controller is attempting reconnects. No need to do anything |
| @@ -1470,7 +1468,6 @@ nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) | |||
| 1470 | 1468 | ||
| 1471 | /* *********************** NVME Ctrl Routines **************************** */ | 1469 | /* *********************** NVME Ctrl Routines **************************** */ |
| 1472 | 1470 | ||
| 1473 | static void __nvme_fc_final_op_cleanup(struct request *rq); | ||
| 1474 | static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg); | 1471 | static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg); |
| 1475 | 1472 | ||
| 1476 | static int | 1473 | static int |
| @@ -1512,13 +1509,19 @@ nvme_fc_exit_request(struct blk_mq_tag_set *set, struct request *rq, | |||
| 1512 | static int | 1509 | static int |
| 1513 | __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) | 1510 | __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) |
| 1514 | { | 1511 | { |
| 1515 | int state; | 1512 | unsigned long flags; |
| 1513 | int opstate; | ||
| 1514 | |||
| 1515 | spin_lock_irqsave(&ctrl->lock, flags); | ||
| 1516 | opstate = atomic_xchg(&op->state, FCPOP_STATE_ABORTED); | ||
| 1517 | if (opstate != FCPOP_STATE_ACTIVE) | ||
| 1518 | atomic_set(&op->state, opstate); | ||
| 1519 | else if (ctrl->flags & FCCTRL_TERMIO) | ||
| 1520 | ctrl->iocnt++; | ||
| 1521 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 1516 | 1522 | ||
| 1517 | state = atomic_xchg(&op->state, FCPOP_STATE_ABORTED); | 1523 | if (opstate != FCPOP_STATE_ACTIVE) |
| 1518 | if (state != FCPOP_STATE_ACTIVE) { | ||
| 1519 | atomic_set(&op->state, state); | ||
| 1520 | return -ECANCELED; | 1524 | return -ECANCELED; |
| 1521 | } | ||
| 1522 | 1525 | ||
| 1523 | ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, | 1526 | ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, |
| 1524 | &ctrl->rport->remoteport, | 1527 | &ctrl->rport->remoteport, |
| @@ -1532,60 +1535,26 @@ static void | |||
| 1532 | nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) | 1535 | nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) |
| 1533 | { | 1536 | { |
| 1534 | struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; | 1537 | struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; |
| 1535 | unsigned long flags; | 1538 | int i; |
| 1536 | int i, ret; | ||
| 1537 | |||
| 1538 | for (i = 0; i < NVME_NR_AEN_COMMANDS; i++, aen_op++) { | ||
| 1539 | if (atomic_read(&aen_op->state) != FCPOP_STATE_ACTIVE) | ||
| 1540 | continue; | ||
| 1541 | |||
| 1542 | spin_lock_irqsave(&ctrl->lock, flags); | ||
| 1543 | if (ctrl->flags & FCCTRL_TERMIO) { | ||
| 1544 | ctrl->iocnt++; | ||
| 1545 | aen_op->flags |= FCOP_FLAGS_TERMIO; | ||
| 1546 | } | ||
| 1547 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 1548 | |||
| 1549 | ret = __nvme_fc_abort_op(ctrl, aen_op); | ||
| 1550 | if (ret) { | ||
| 1551 | /* | ||
| 1552 | * if __nvme_fc_abort_op failed the io wasn't | ||
| 1553 | * active. Thus this call path is running in | ||
| 1554 | * parallel to the io complete. Treat as non-error. | ||
| 1555 | */ | ||
| 1556 | 1539 | ||
| 1557 | /* back out the flags/counters */ | 1540 | for (i = 0; i < NVME_NR_AEN_COMMANDS; i++, aen_op++) |
| 1558 | spin_lock_irqsave(&ctrl->lock, flags); | 1541 | __nvme_fc_abort_op(ctrl, aen_op); |
| 1559 | if (ctrl->flags & FCCTRL_TERMIO) | ||
| 1560 | ctrl->iocnt--; | ||
| 1561 | aen_op->flags &= ~FCOP_FLAGS_TERMIO; | ||
| 1562 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 1563 | return; | ||
| 1564 | } | ||
| 1565 | } | ||
| 1566 | } | 1542 | } |
| 1567 | 1543 | ||
| 1568 | static inline int | 1544 | static inline void |
| 1569 | __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, | 1545 | __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, |
| 1570 | struct nvme_fc_fcp_op *op) | 1546 | struct nvme_fc_fcp_op *op, int opstate) |
| 1571 | { | 1547 | { |
| 1572 | unsigned long flags; | 1548 | unsigned long flags; |
| 1573 | bool complete_rq = false; | ||
| 1574 | 1549 | ||
| 1575 | spin_lock_irqsave(&ctrl->lock, flags); | 1550 | if (opstate == FCPOP_STATE_ABORTED) { |
| 1576 | if (unlikely(op->flags & FCOP_FLAGS_TERMIO)) { | 1551 | spin_lock_irqsave(&ctrl->lock, flags); |
| 1577 | if (ctrl->flags & FCCTRL_TERMIO) { | 1552 | if (ctrl->flags & FCCTRL_TERMIO) { |
| 1578 | if (!--ctrl->iocnt) | 1553 | if (!--ctrl->iocnt) |
| 1579 | wake_up(&ctrl->ioabort_wait); | 1554 | wake_up(&ctrl->ioabort_wait); |
| 1580 | } | 1555 | } |
| 1556 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 1581 | } | 1557 | } |
| 1582 | if (op->flags & FCOP_FLAGS_RELEASED) | ||
| 1583 | complete_rq = true; | ||
| 1584 | else | ||
| 1585 | op->flags |= FCOP_FLAGS_COMPLETE; | ||
| 1586 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 1587 | |||
| 1588 | return complete_rq; | ||
| 1589 | } | 1558 | } |
| 1590 | 1559 | ||
| 1591 | static void | 1560 | static void |
| @@ -1601,6 +1570,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) | |||
| 1601 | __le16 status = cpu_to_le16(NVME_SC_SUCCESS << 1); | 1570 | __le16 status = cpu_to_le16(NVME_SC_SUCCESS << 1); |
| 1602 | union nvme_result result; | 1571 | union nvme_result result; |
| 1603 | bool terminate_assoc = true; | 1572 | bool terminate_assoc = true; |
| 1573 | int opstate; | ||
| 1604 | 1574 | ||
| 1605 | /* | 1575 | /* |
| 1606 | * WARNING: | 1576 | * WARNING: |
| @@ -1639,11 +1609,12 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) | |||
| 1639 | * association to be terminated. | 1609 | * association to be terminated. |
| 1640 | */ | 1610 | */ |
| 1641 | 1611 | ||
| 1612 | opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE); | ||
| 1613 | |||
| 1642 | fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, | 1614 | fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, |
| 1643 | sizeof(op->rsp_iu), DMA_FROM_DEVICE); | 1615 | sizeof(op->rsp_iu), DMA_FROM_DEVICE); |
| 1644 | 1616 | ||
| 1645 | if (atomic_read(&op->state) == FCPOP_STATE_ABORTED || | 1617 | if (opstate == FCPOP_STATE_ABORTED) |
| 1646 | op->flags & FCOP_FLAGS_TERMIO) | ||
| 1647 | status = cpu_to_le16(NVME_SC_ABORT_REQ << 1); | 1618 | status = cpu_to_le16(NVME_SC_ABORT_REQ << 1); |
| 1648 | else if (freq->status) | 1619 | else if (freq->status) |
| 1649 | status = cpu_to_le16(NVME_SC_INTERNAL << 1); | 1620 | status = cpu_to_le16(NVME_SC_INTERNAL << 1); |
| @@ -1708,7 +1679,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) | |||
| 1708 | done: | 1679 | done: |
| 1709 | if (op->flags & FCOP_FLAGS_AEN) { | 1680 | if (op->flags & FCOP_FLAGS_AEN) { |
| 1710 | nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); | 1681 | nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); |
| 1711 | __nvme_fc_fcpop_chk_teardowns(ctrl, op); | 1682 | __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); |
| 1712 | atomic_set(&op->state, FCPOP_STATE_IDLE); | 1683 | atomic_set(&op->state, FCPOP_STATE_IDLE); |
| 1713 | op->flags = FCOP_FLAGS_AEN; /* clear other flags */ | 1684 | op->flags = FCOP_FLAGS_AEN; /* clear other flags */ |
| 1714 | nvme_fc_ctrl_put(ctrl); | 1685 | nvme_fc_ctrl_put(ctrl); |
| @@ -1722,13 +1693,11 @@ done: | |||
| 1722 | if (status && | 1693 | if (status && |
| 1723 | (blk_queue_dying(rq->q) || | 1694 | (blk_queue_dying(rq->q) || |
| 1724 | ctrl->ctrl.state == NVME_CTRL_NEW || | 1695 | ctrl->ctrl.state == NVME_CTRL_NEW || |
| 1725 | ctrl->ctrl.state == NVME_CTRL_RECONNECTING)) | 1696 | ctrl->ctrl.state == NVME_CTRL_CONNECTING)) |
| 1726 | status |= cpu_to_le16(NVME_SC_DNR << 1); | 1697 | status |= cpu_to_le16(NVME_SC_DNR << 1); |
| 1727 | 1698 | ||
| 1728 | if (__nvme_fc_fcpop_chk_teardowns(ctrl, op)) | 1699 | __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); |
| 1729 | __nvme_fc_final_op_cleanup(rq); | 1700 | nvme_end_request(rq, status, result); |
| 1730 | else | ||
| 1731 | nvme_end_request(rq, status, result); | ||
| 1732 | 1701 | ||
| 1733 | check_error: | 1702 | check_error: |
| 1734 | if (terminate_assoc) | 1703 | if (terminate_assoc) |
| @@ -2415,46 +2384,16 @@ nvme_fc_submit_async_event(struct nvme_ctrl *arg) | |||
| 2415 | } | 2384 | } |
| 2416 | 2385 | ||
| 2417 | static void | 2386 | static void |
| 2418 | __nvme_fc_final_op_cleanup(struct request *rq) | 2387 | nvme_fc_complete_rq(struct request *rq) |
| 2419 | { | 2388 | { |
| 2420 | struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq); | 2389 | struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq); |
| 2421 | struct nvme_fc_ctrl *ctrl = op->ctrl; | 2390 | struct nvme_fc_ctrl *ctrl = op->ctrl; |
| 2422 | 2391 | ||
| 2423 | atomic_set(&op->state, FCPOP_STATE_IDLE); | 2392 | atomic_set(&op->state, FCPOP_STATE_IDLE); |
| 2424 | op->flags &= ~(FCOP_FLAGS_TERMIO | FCOP_FLAGS_RELEASED | | ||
| 2425 | FCOP_FLAGS_COMPLETE); | ||
| 2426 | 2393 | ||
| 2427 | nvme_fc_unmap_data(ctrl, rq, op); | 2394 | nvme_fc_unmap_data(ctrl, rq, op); |
| 2428 | nvme_complete_rq(rq); | 2395 | nvme_complete_rq(rq); |
| 2429 | nvme_fc_ctrl_put(ctrl); | 2396 | nvme_fc_ctrl_put(ctrl); |
| 2430 | |||
| 2431 | } | ||
| 2432 | |||
| 2433 | static void | ||
| 2434 | nvme_fc_complete_rq(struct request *rq) | ||
| 2435 | { | ||
| 2436 | struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq); | ||
| 2437 | struct nvme_fc_ctrl *ctrl = op->ctrl; | ||
| 2438 | unsigned long flags; | ||
| 2439 | bool completed = false; | ||
| 2440 | |||
| 2441 | /* | ||
| 2442 | * the core layer, on controller resets after calling | ||
| 2443 | * nvme_shutdown_ctrl(), calls complete_rq without our | ||
| 2444 | * calling blk_mq_complete_request(), thus there may still | ||
| 2445 | * be live i/o outstanding with the LLDD. Means transport has | ||
| 2446 | * to track complete calls vs fcpio_done calls to know what | ||
| 2447 | * path to take on completes and dones. | ||
| 2448 | */ | ||
| 2449 | spin_lock_irqsave(&ctrl->lock, flags); | ||
| 2450 | if (op->flags & FCOP_FLAGS_COMPLETE) | ||
| 2451 | completed = true; | ||
| 2452 | else | ||
| 2453 | op->flags |= FCOP_FLAGS_RELEASED; | ||
| 2454 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 2455 | |||
| 2456 | if (completed) | ||
| 2457 | __nvme_fc_final_op_cleanup(rq); | ||
| 2458 | } | 2397 | } |
| 2459 | 2398 | ||
| 2460 | /* | 2399 | /* |
| @@ -2476,35 +2415,11 @@ nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved) | |||
| 2476 | struct nvme_ctrl *nctrl = data; | 2415 | struct nvme_ctrl *nctrl = data; |
| 2477 | struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); | 2416 | struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); |
| 2478 | struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req); | 2417 | struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req); |
| 2479 | unsigned long flags; | ||
| 2480 | int status; | ||
| 2481 | 2418 | ||
| 2482 | if (!blk_mq_request_started(req)) | 2419 | if (!blk_mq_request_started(req)) |
| 2483 | return; | 2420 | return; |
| 2484 | 2421 | ||
| 2485 | spin_lock_irqsave(&ctrl->lock, flags); | 2422 | __nvme_fc_abort_op(ctrl, op); |
| 2486 | if (ctrl->flags & FCCTRL_TERMIO) { | ||
| 2487 | ctrl->iocnt++; | ||
| 2488 | op->flags |= FCOP_FLAGS_TERMIO; | ||
| 2489 | } | ||
| 2490 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 2491 | |||
| 2492 | status = __nvme_fc_abort_op(ctrl, op); | ||
| 2493 | if (status) { | ||
| 2494 | /* | ||
| 2495 | * if __nvme_fc_abort_op failed the io wasn't | ||
| 2496 | * active. Thus this call path is running in | ||
| 2497 | * parallel to the io complete. Treat as non-error. | ||
| 2498 | */ | ||
| 2499 | |||
| 2500 | /* back out the flags/counters */ | ||
| 2501 | spin_lock_irqsave(&ctrl->lock, flags); | ||
| 2502 | if (ctrl->flags & FCCTRL_TERMIO) | ||
| 2503 | ctrl->iocnt--; | ||
| 2504 | op->flags &= ~FCOP_FLAGS_TERMIO; | ||
| 2505 | spin_unlock_irqrestore(&ctrl->lock, flags); | ||
| 2506 | return; | ||
| 2507 | } | ||
| 2508 | } | 2423 | } |
| 2509 | 2424 | ||
| 2510 | 2425 | ||
| @@ -2943,7 +2858,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) | |||
| 2943 | unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; | 2858 | unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; |
| 2944 | bool recon = true; | 2859 | bool recon = true; |
| 2945 | 2860 | ||
| 2946 | if (ctrl->ctrl.state != NVME_CTRL_RECONNECTING) | 2861 | if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) |
| 2947 | return; | 2862 | return; |
| 2948 | 2863 | ||
| 2949 | if (portptr->port_state == FC_OBJSTATE_ONLINE) | 2864 | if (portptr->port_state == FC_OBJSTATE_ONLINE) |
| @@ -2991,10 +2906,10 @@ nvme_fc_reset_ctrl_work(struct work_struct *work) | |||
| 2991 | /* will block will waiting for io to terminate */ | 2906 | /* will block will waiting for io to terminate */ |
| 2992 | nvme_fc_delete_association(ctrl); | 2907 | nvme_fc_delete_association(ctrl); |
| 2993 | 2908 | ||
| 2994 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { | 2909 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { |
| 2995 | dev_err(ctrl->ctrl.device, | 2910 | dev_err(ctrl->ctrl.device, |
| 2996 | "NVME-FC{%d}: error_recovery: Couldn't change state " | 2911 | "NVME-FC{%d}: error_recovery: Couldn't change state " |
| 2997 | "to RECONNECTING\n", ctrl->cnum); | 2912 | "to CONNECTING\n", ctrl->cnum); |
| 2998 | return; | 2913 | return; |
| 2999 | } | 2914 | } |
| 3000 | 2915 | ||
| @@ -3195,7 +3110,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, | |||
| 3195 | * transport errors (frame drop, LS failure) inherently must kill | 3110 | * transport errors (frame drop, LS failure) inherently must kill |
| 3196 | * the association. The transport is coded so that any command used | 3111 | * the association. The transport is coded so that any command used |
| 3197 | * to create the association (prior to a LIVE state transition | 3112 | * to create the association (prior to a LIVE state transition |
| 3198 | * while NEW or RECONNECTING) will fail if it completes in error or | 3113 | * while NEW or CONNECTING) will fail if it completes in error or |
| 3199 | * times out. | 3114 | * times out. |
| 3200 | * | 3115 | * |
| 3201 | * As such: as the connect request was mostly likely due to a | 3116 | * As such: as the connect request was mostly likely due to a |
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 8e4550fa08f8..0521e4707d1c 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h | |||
| @@ -123,7 +123,7 @@ enum nvme_ctrl_state { | |||
| 123 | NVME_CTRL_LIVE, | 123 | NVME_CTRL_LIVE, |
| 124 | NVME_CTRL_ADMIN_ONLY, /* Only admin queue live */ | 124 | NVME_CTRL_ADMIN_ONLY, /* Only admin queue live */ |
| 125 | NVME_CTRL_RESETTING, | 125 | NVME_CTRL_RESETTING, |
| 126 | NVME_CTRL_RECONNECTING, | 126 | NVME_CTRL_CONNECTING, |
| 127 | NVME_CTRL_DELETING, | 127 | NVME_CTRL_DELETING, |
| 128 | NVME_CTRL_DEAD, | 128 | NVME_CTRL_DEAD, |
| 129 | }; | 129 | }; |
| @@ -183,6 +183,7 @@ struct nvme_ctrl { | |||
| 183 | struct work_struct scan_work; | 183 | struct work_struct scan_work; |
| 184 | struct work_struct async_event_work; | 184 | struct work_struct async_event_work; |
| 185 | struct delayed_work ka_work; | 185 | struct delayed_work ka_work; |
| 186 | struct nvme_command ka_cmd; | ||
| 186 | struct work_struct fw_act_work; | 187 | struct work_struct fw_act_work; |
| 187 | 188 | ||
| 188 | /* Power saving configuration */ | 189 | /* Power saving configuration */ |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 6fe7af00a1f4..73036d2fbbd5 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
| @@ -1141,7 +1141,7 @@ static bool nvme_should_reset(struct nvme_dev *dev, u32 csts) | |||
| 1141 | /* If there is a reset/reinit ongoing, we shouldn't reset again. */ | 1141 | /* If there is a reset/reinit ongoing, we shouldn't reset again. */ |
| 1142 | switch (dev->ctrl.state) { | 1142 | switch (dev->ctrl.state) { |
| 1143 | case NVME_CTRL_RESETTING: | 1143 | case NVME_CTRL_RESETTING: |
| 1144 | case NVME_CTRL_RECONNECTING: | 1144 | case NVME_CTRL_CONNECTING: |
| 1145 | return false; | 1145 | return false; |
| 1146 | default: | 1146 | default: |
| 1147 | break; | 1147 | break; |
| @@ -1215,13 +1215,17 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) | |||
| 1215 | * cancellation error. All outstanding requests are completed on | 1215 | * cancellation error. All outstanding requests are completed on |
| 1216 | * shutdown, so we return BLK_EH_HANDLED. | 1216 | * shutdown, so we return BLK_EH_HANDLED. |
| 1217 | */ | 1217 | */ |
| 1218 | if (dev->ctrl.state == NVME_CTRL_RESETTING) { | 1218 | switch (dev->ctrl.state) { |
| 1219 | case NVME_CTRL_CONNECTING: | ||
| 1220 | case NVME_CTRL_RESETTING: | ||
| 1219 | dev_warn(dev->ctrl.device, | 1221 | dev_warn(dev->ctrl.device, |
| 1220 | "I/O %d QID %d timeout, disable controller\n", | 1222 | "I/O %d QID %d timeout, disable controller\n", |
| 1221 | req->tag, nvmeq->qid); | 1223 | req->tag, nvmeq->qid); |
| 1222 | nvme_dev_disable(dev, false); | 1224 | nvme_dev_disable(dev, false); |
| 1223 | nvme_req(req)->flags |= NVME_REQ_CANCELLED; | 1225 | nvme_req(req)->flags |= NVME_REQ_CANCELLED; |
| 1224 | return BLK_EH_HANDLED; | 1226 | return BLK_EH_HANDLED; |
| 1227 | default: | ||
| 1228 | break; | ||
| 1225 | } | 1229 | } |
| 1226 | 1230 | ||
| 1227 | /* | 1231 | /* |
| @@ -1364,18 +1368,14 @@ static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues, | |||
| 1364 | static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq, | 1368 | static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq, |
| 1365 | int qid, int depth) | 1369 | int qid, int depth) |
| 1366 | { | 1370 | { |
| 1367 | if (qid && dev->cmb && use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS)) { | 1371 | /* CMB SQEs will be mapped before creation */ |
| 1368 | unsigned offset = (qid - 1) * roundup(SQ_SIZE(depth), | 1372 | if (qid && dev->cmb && use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS)) |
| 1369 | dev->ctrl.page_size); | 1373 | return 0; |
| 1370 | nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset; | ||
| 1371 | nvmeq->sq_cmds_io = dev->cmb + offset; | ||
| 1372 | } else { | ||
| 1373 | nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth), | ||
| 1374 | &nvmeq->sq_dma_addr, GFP_KERNEL); | ||
| 1375 | if (!nvmeq->sq_cmds) | ||
| 1376 | return -ENOMEM; | ||
| 1377 | } | ||
| 1378 | 1374 | ||
| 1375 | nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth), | ||
| 1376 | &nvmeq->sq_dma_addr, GFP_KERNEL); | ||
| 1377 | if (!nvmeq->sq_cmds) | ||
| 1378 | return -ENOMEM; | ||
| 1379 | return 0; | 1379 | return 0; |
| 1380 | } | 1380 | } |
| 1381 | 1381 | ||
| @@ -1449,6 +1449,13 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) | |||
| 1449 | struct nvme_dev *dev = nvmeq->dev; | 1449 | struct nvme_dev *dev = nvmeq->dev; |
| 1450 | int result; | 1450 | int result; |
| 1451 | 1451 | ||
| 1452 | if (dev->cmb && use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS)) { | ||
| 1453 | unsigned offset = (qid - 1) * roundup(SQ_SIZE(nvmeq->q_depth), | ||
| 1454 | dev->ctrl.page_size); | ||
| 1455 | nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset; | ||
| 1456 | nvmeq->sq_cmds_io = dev->cmb + offset; | ||
| 1457 | } | ||
| 1458 | |||
| 1452 | nvmeq->cq_vector = qid - 1; | 1459 | nvmeq->cq_vector = qid - 1; |
| 1453 | result = adapter_alloc_cq(dev, qid, nvmeq); | 1460 | result = adapter_alloc_cq(dev, qid, nvmeq); |
| 1454 | if (result < 0) | 1461 | if (result < 0) |
| @@ -2288,12 +2295,12 @@ static void nvme_reset_work(struct work_struct *work) | |||
| 2288 | nvme_dev_disable(dev, false); | 2295 | nvme_dev_disable(dev, false); |
| 2289 | 2296 | ||
| 2290 | /* | 2297 | /* |
| 2291 | * Introduce RECONNECTING state from nvme-fc/rdma transports to mark the | 2298 | * Introduce CONNECTING state from nvme-fc/rdma transports to mark the |
| 2292 | * initializing procedure here. | 2299 | * initializing procedure here. |
| 2293 | */ | 2300 | */ |
| 2294 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RECONNECTING)) { | 2301 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_CONNECTING)) { |
| 2295 | dev_warn(dev->ctrl.device, | 2302 | dev_warn(dev->ctrl.device, |
| 2296 | "failed to mark controller RECONNECTING\n"); | 2303 | "failed to mark controller CONNECTING\n"); |
| 2297 | goto out; | 2304 | goto out; |
| 2298 | } | 2305 | } |
| 2299 | 2306 | ||
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 2bc059f7d73c..3a51ed50eff2 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c | |||
| @@ -887,7 +887,7 @@ free_ctrl: | |||
| 887 | static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) | 887 | static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) |
| 888 | { | 888 | { |
| 889 | /* If we are resetting/deleting then do nothing */ | 889 | /* If we are resetting/deleting then do nothing */ |
| 890 | if (ctrl->ctrl.state != NVME_CTRL_RECONNECTING) { | 890 | if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) { |
| 891 | WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || | 891 | WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || |
| 892 | ctrl->ctrl.state == NVME_CTRL_LIVE); | 892 | ctrl->ctrl.state == NVME_CTRL_LIVE); |
| 893 | return; | 893 | return; |
| @@ -973,7 +973,7 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work) | |||
| 973 | blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); | 973 | blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); |
| 974 | nvme_start_queues(&ctrl->ctrl); | 974 | nvme_start_queues(&ctrl->ctrl); |
| 975 | 975 | ||
| 976 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { | 976 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { |
| 977 | /* state change failure should never happen */ | 977 | /* state change failure should never happen */ |
| 978 | WARN_ON_ONCE(1); | 978 | WARN_ON_ONCE(1); |
| 979 | return; | 979 | return; |
| @@ -1756,7 +1756,7 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work) | |||
| 1756 | nvme_stop_ctrl(&ctrl->ctrl); | 1756 | nvme_stop_ctrl(&ctrl->ctrl); |
| 1757 | nvme_rdma_shutdown_ctrl(ctrl, false); | 1757 | nvme_rdma_shutdown_ctrl(ctrl, false); |
| 1758 | 1758 | ||
| 1759 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { | 1759 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { |
| 1760 | /* state change failure should never happen */ | 1760 | /* state change failure should never happen */ |
| 1761 | WARN_ON_ONCE(1); | 1761 | WARN_ON_ONCE(1); |
| 1762 | return; | 1762 | return; |
| @@ -1784,11 +1784,8 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work) | |||
| 1784 | return; | 1784 | return; |
| 1785 | 1785 | ||
| 1786 | out_fail: | 1786 | out_fail: |
| 1787 | dev_warn(ctrl->ctrl.device, "Removing after reset failure\n"); | 1787 | ++ctrl->ctrl.nr_reconnects; |
| 1788 | nvme_remove_namespaces(&ctrl->ctrl); | 1788 | nvme_rdma_reconnect_or_remove(ctrl); |
| 1789 | nvme_rdma_shutdown_ctrl(ctrl, true); | ||
| 1790 | nvme_uninit_ctrl(&ctrl->ctrl); | ||
| 1791 | nvme_put_ctrl(&ctrl->ctrl); | ||
| 1792 | } | 1789 | } |
| 1793 | 1790 | ||
| 1794 | static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { | 1791 | static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { |
| @@ -1942,6 +1939,9 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, | |||
| 1942 | if (!ctrl->queues) | 1939 | if (!ctrl->queues) |
| 1943 | goto out_uninit_ctrl; | 1940 | goto out_uninit_ctrl; |
| 1944 | 1941 | ||
| 1942 | changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); | ||
| 1943 | WARN_ON_ONCE(!changed); | ||
| 1944 | |||
| 1945 | ret = nvme_rdma_configure_admin_queue(ctrl, true); | 1945 | ret = nvme_rdma_configure_admin_queue(ctrl, true); |
| 1946 | if (ret) | 1946 | if (ret) |
| 1947 | goto out_kfree_queues; | 1947 | goto out_kfree_queues; |
diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c index 0a4372a016f2..28bbdff4a88b 100644 --- a/drivers/nvme/target/io-cmd.c +++ b/drivers/nvme/target/io-cmd.c | |||
| @@ -105,10 +105,13 @@ static void nvmet_execute_flush(struct nvmet_req *req) | |||
| 105 | static u16 nvmet_discard_range(struct nvmet_ns *ns, | 105 | static u16 nvmet_discard_range(struct nvmet_ns *ns, |
| 106 | struct nvme_dsm_range *range, struct bio **bio) | 106 | struct nvme_dsm_range *range, struct bio **bio) |
| 107 | { | 107 | { |
| 108 | if (__blkdev_issue_discard(ns->bdev, | 108 | int ret; |
| 109 | |||
| 110 | ret = __blkdev_issue_discard(ns->bdev, | ||
| 109 | le64_to_cpu(range->slba) << (ns->blksize_shift - 9), | 111 | le64_to_cpu(range->slba) << (ns->blksize_shift - 9), |
| 110 | le32_to_cpu(range->nlb) << (ns->blksize_shift - 9), | 112 | le32_to_cpu(range->nlb) << (ns->blksize_shift - 9), |
| 111 | GFP_KERNEL, 0, bio)) | 113 | GFP_KERNEL, 0, bio); |
| 114 | if (ret && ret != -EOPNOTSUPP) | ||
| 112 | return NVME_SC_INTERNAL | NVME_SC_DNR; | 115 | return NVME_SC_INTERNAL | NVME_SC_DNR; |
| 113 | return 0; | 116 | return 0; |
| 114 | } | 117 | } |
diff --git a/drivers/of/property.c b/drivers/of/property.c index 36ed84e26d9c..f46828e3b082 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c | |||
| @@ -977,11 +977,11 @@ static int of_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, | |||
| 977 | return 0; | 977 | return 0; |
| 978 | } | 978 | } |
| 979 | 979 | ||
| 980 | static void * | 980 | static const void * |
| 981 | of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, | 981 | of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, |
| 982 | const struct device *dev) | 982 | const struct device *dev) |
| 983 | { | 983 | { |
| 984 | return (void *)of_device_get_match_data(dev); | 984 | return of_device_get_match_data(dev); |
| 985 | } | 985 | } |
| 986 | 986 | ||
| 987 | const struct fwnode_operations of_fwnode_ops = { | 987 | const struct fwnode_operations of_fwnode_ops = { |
diff --git a/drivers/opp/cpu.c b/drivers/opp/cpu.c index 2d87bc1adf38..0c0910709435 100644 --- a/drivers/opp/cpu.c +++ b/drivers/opp/cpu.c | |||
| @@ -55,7 +55,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, | |||
| 55 | if (max_opps <= 0) | 55 | if (max_opps <= 0) |
| 56 | return max_opps ? max_opps : -ENODATA; | 56 | return max_opps ? max_opps : -ENODATA; |
| 57 | 57 | ||
| 58 | freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_ATOMIC); | 58 | freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_KERNEL); |
| 59 | if (!freq_table) | 59 | if (!freq_table) |
| 60 | return -ENOMEM; | 60 | return -ENOMEM; |
| 61 | 61 | ||
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 2a68f59d2228..c52c6723374b 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
| @@ -127,24 +127,6 @@ static const struct dmi_system_id dell_device_table[] __initconst = { | |||
| 127 | }, | 127 | }, |
| 128 | }, | 128 | }, |
| 129 | { | 129 | { |
| 130 | .matches = { | ||
| 131 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 132 | DMI_MATCH(DMI_CHASSIS_TYPE, "30"), /*Tablet*/ | ||
| 133 | }, | ||
| 134 | }, | ||
| 135 | { | ||
| 136 | .matches = { | ||
| 137 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 138 | DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /*Convertible*/ | ||
| 139 | }, | ||
| 140 | }, | ||
| 141 | { | ||
| 142 | .matches = { | ||
| 143 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 144 | DMI_MATCH(DMI_CHASSIS_TYPE, "32"), /*Detachable*/ | ||
| 145 | }, | ||
| 146 | }, | ||
| 147 | { | ||
| 148 | .ident = "Dell Computer Corporation", | 130 | .ident = "Dell Computer Corporation", |
| 149 | .matches = { | 131 | .matches = { |
| 150 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), | 132 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), |
| @@ -1279,7 +1261,7 @@ static int kbd_get_state(struct kbd_state *state) | |||
| 1279 | struct calling_interface_buffer buffer; | 1261 | struct calling_interface_buffer buffer; |
| 1280 | int ret; | 1262 | int ret; |
| 1281 | 1263 | ||
| 1282 | dell_fill_request(&buffer, 0, 0, 0, 0); | 1264 | dell_fill_request(&buffer, 0x1, 0, 0, 0); |
| 1283 | ret = dell_send_request(&buffer, | 1265 | ret = dell_send_request(&buffer, |
| 1284 | CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT); | 1266 | CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT); |
| 1285 | if (ret) | 1267 | if (ret) |
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5b6f18b18801..535199c9e6bc 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c | |||
| @@ -113,7 +113,7 @@ MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); | |||
| 113 | /* | 113 | /* |
| 114 | * ACPI Helpers | 114 | * ACPI Helpers |
| 115 | */ | 115 | */ |
| 116 | #define IDEAPAD_EC_TIMEOUT (100) /* in ms */ | 116 | #define IDEAPAD_EC_TIMEOUT (200) /* in ms */ |
| 117 | 117 | ||
| 118 | static int read_method_int(acpi_handle handle, const char *method, int *val) | 118 | static int read_method_int(acpi_handle handle, const char *method, int *val) |
| 119 | { | 119 | { |
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index daa68acbc900..c0c8945603cb 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c | |||
| @@ -933,7 +933,7 @@ static int wmi_dev_probe(struct device *dev) | |||
| 933 | goto probe_failure; | 933 | goto probe_failure; |
| 934 | } | 934 | } |
| 935 | 935 | ||
| 936 | buf = kmalloc(strlen(wdriver->driver.name) + 4, GFP_KERNEL); | 936 | buf = kmalloc(strlen(wdriver->driver.name) + 5, GFP_KERNEL); |
| 937 | if (!buf) { | 937 | if (!buf) { |
| 938 | ret = -ENOMEM; | 938 | ret = -ENOMEM; |
| 939 | goto probe_string_failure; | 939 | goto probe_string_failure; |
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index ba2e0856d22c..8f5c1d7f751a 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c | |||
| @@ -1297,6 +1297,9 @@ static int virtio_ccw_cio_notify(struct ccw_device *cdev, int event) | |||
| 1297 | vcdev->device_lost = true; | 1297 | vcdev->device_lost = true; |
| 1298 | rc = NOTIFY_DONE; | 1298 | rc = NOTIFY_DONE; |
| 1299 | break; | 1299 | break; |
| 1300 | case CIO_OPER: | ||
| 1301 | rc = NOTIFY_OK; | ||
| 1302 | break; | ||
| 1300 | default: | 1303 | default: |
| 1301 | rc = NOTIFY_DONE; | 1304 | rc = NOTIFY_DONE; |
| 1302 | break; | 1305 | break; |
| @@ -1309,6 +1312,27 @@ static struct ccw_device_id virtio_ids[] = { | |||
| 1309 | {}, | 1312 | {}, |
| 1310 | }; | 1313 | }; |
| 1311 | 1314 | ||
| 1315 | #ifdef CONFIG_PM_SLEEP | ||
| 1316 | static int virtio_ccw_freeze(struct ccw_device *cdev) | ||
| 1317 | { | ||
| 1318 | struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); | ||
| 1319 | |||
| 1320 | return virtio_device_freeze(&vcdev->vdev); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | static int virtio_ccw_restore(struct ccw_device *cdev) | ||
| 1324 | { | ||
| 1325 | struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); | ||
| 1326 | int ret; | ||
| 1327 | |||
| 1328 | ret = virtio_ccw_set_transport_rev(vcdev); | ||
| 1329 | if (ret) | ||
| 1330 | return ret; | ||
| 1331 | |||
| 1332 | return virtio_device_restore(&vcdev->vdev); | ||
| 1333 | } | ||
| 1334 | #endif | ||
| 1335 | |||
| 1312 | static struct ccw_driver virtio_ccw_driver = { | 1336 | static struct ccw_driver virtio_ccw_driver = { |
| 1313 | .driver = { | 1337 | .driver = { |
| 1314 | .owner = THIS_MODULE, | 1338 | .owner = THIS_MODULE, |
| @@ -1321,6 +1345,11 @@ static struct ccw_driver virtio_ccw_driver = { | |||
| 1321 | .set_online = virtio_ccw_online, | 1345 | .set_online = virtio_ccw_online, |
| 1322 | .notify = virtio_ccw_cio_notify, | 1346 | .notify = virtio_ccw_cio_notify, |
| 1323 | .int_class = IRQIO_VIR, | 1347 | .int_class = IRQIO_VIR, |
| 1348 | #ifdef CONFIG_PM_SLEEP | ||
| 1349 | .freeze = virtio_ccw_freeze, | ||
| 1350 | .thaw = virtio_ccw_restore, | ||
| 1351 | .restore = virtio_ccw_restore, | ||
| 1352 | #endif | ||
| 1324 | }; | 1353 | }; |
| 1325 | 1354 | ||
| 1326 | static int __init pure_hex(char **cp, unsigned int *val, int min_digit, | 1355 | static int __init pure_hex(char **cp, unsigned int *val, int min_digit, |
diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c index 5064d5ddf581..fc2013aade51 100644 --- a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | |||
| @@ -73,6 +73,8 @@ static int __init its_fsl_mc_msi_init(void) | |||
| 73 | 73 | ||
| 74 | for (np = of_find_matching_node(NULL, its_device_id); np; | 74 | for (np = of_find_matching_node(NULL, its_device_id); np; |
| 75 | np = of_find_matching_node(np, its_device_id)) { | 75 | np = of_find_matching_node(np, its_device_id)) { |
| 76 | if (!of_device_is_available(np)) | ||
| 77 | continue; | ||
| 76 | if (!of_property_read_bool(np, "msi-controller")) | 78 | if (!of_property_read_bool(np, "msi-controller")) |
| 77 | continue; | 79 | continue; |
| 78 | 80 | ||
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index f699abab1787..148f3ee70286 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
| @@ -19,6 +19,12 @@ config USB_EHCI_BIG_ENDIAN_MMIO | |||
| 19 | config USB_EHCI_BIG_ENDIAN_DESC | 19 | config USB_EHCI_BIG_ENDIAN_DESC |
| 20 | bool | 20 | bool |
| 21 | 21 | ||
| 22 | config USB_UHCI_BIG_ENDIAN_MMIO | ||
| 23 | bool | ||
| 24 | |||
| 25 | config USB_UHCI_BIG_ENDIAN_DESC | ||
| 26 | bool | ||
| 27 | |||
| 22 | menuconfig USB_SUPPORT | 28 | menuconfig USB_SUPPORT |
| 23 | bool "USB support" | 29 | bool "USB support" |
| 24 | depends on HAS_IOMEM | 30 | depends on HAS_IOMEM |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 6150bed7cfa8..4fcfb3084b36 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
| @@ -633,14 +633,6 @@ config USB_UHCI_ASPEED | |||
| 633 | bool | 633 | bool |
| 634 | default y if ARCH_ASPEED | 634 | default y if ARCH_ASPEED |
| 635 | 635 | ||
| 636 | config USB_UHCI_BIG_ENDIAN_MMIO | ||
| 637 | bool | ||
| 638 | default y if SPARC_LEON | ||
| 639 | |||
| 640 | config USB_UHCI_BIG_ENDIAN_DESC | ||
| 641 | bool | ||
| 642 | default y if SPARC_LEON | ||
| 643 | |||
| 644 | config USB_FHCI_HCD | 636 | config USB_FHCI_HCD |
| 645 | tristate "Freescale QE USB Host Controller support" | 637 | tristate "Freescale QE USB Host Controller support" |
| 646 | depends on OF_GPIO && QE_GPIO && QUICC_ENGINE | 638 | depends on OF_GPIO && QE_GPIO && QUICC_ENGINE |
diff --git a/drivers/video/fbdev/geode/video_gx.c b/drivers/video/fbdev/geode/video_gx.c index 6082f653c68a..67773e8bbb95 100644 --- a/drivers/video/fbdev/geode/video_gx.c +++ b/drivers/video/fbdev/geode/video_gx.c | |||
| @@ -127,7 +127,7 @@ void gx_set_dclk_frequency(struct fb_info *info) | |||
| 127 | int timeout = 1000; | 127 | int timeout = 1000; |
| 128 | 128 | ||
| 129 | /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ | 129 | /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ |
| 130 | if (cpu_data(0).x86_mask == 1) { | 130 | if (cpu_data(0).x86_stepping == 1) { |
| 131 | pll_table = gx_pll_table_14MHz; | 131 | pll_table = gx_pll_table_14MHz; |
| 132 | pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); | 132 | pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); |
| 133 | } else { | 133 | } else { |
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index 753d9cb437d0..aedbee3b2838 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c | |||
| @@ -60,6 +60,7 @@ struct sock_mapping { | |||
| 60 | bool active_socket; | 60 | bool active_socket; |
| 61 | struct list_head list; | 61 | struct list_head list; |
| 62 | struct socket *sock; | 62 | struct socket *sock; |
| 63 | atomic_t refcount; | ||
| 63 | union { | 64 | union { |
| 64 | struct { | 65 | struct { |
| 65 | int irq; | 66 | int irq; |
| @@ -93,6 +94,32 @@ struct sock_mapping { | |||
| 93 | }; | 94 | }; |
| 94 | }; | 95 | }; |
| 95 | 96 | ||
| 97 | static inline struct sock_mapping *pvcalls_enter_sock(struct socket *sock) | ||
| 98 | { | ||
| 99 | struct sock_mapping *map; | ||
| 100 | |||
| 101 | if (!pvcalls_front_dev || | ||
| 102 | dev_get_drvdata(&pvcalls_front_dev->dev) == NULL) | ||
| 103 | return ERR_PTR(-ENOTCONN); | ||
| 104 | |||
| 105 | map = (struct sock_mapping *)sock->sk->sk_send_head; | ||
| 106 | if (map == NULL) | ||
| 107 | return ERR_PTR(-ENOTSOCK); | ||
| 108 | |||
| 109 | pvcalls_enter(); | ||
| 110 | atomic_inc(&map->refcount); | ||
| 111 | return map; | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void pvcalls_exit_sock(struct socket *sock) | ||
| 115 | { | ||
| 116 | struct sock_mapping *map; | ||
| 117 | |||
| 118 | map = (struct sock_mapping *)sock->sk->sk_send_head; | ||
| 119 | atomic_dec(&map->refcount); | ||
| 120 | pvcalls_exit(); | ||
| 121 | } | ||
| 122 | |||
| 96 | static inline int get_request(struct pvcalls_bedata *bedata, int *req_id) | 123 | static inline int get_request(struct pvcalls_bedata *bedata, int *req_id) |
| 97 | { | 124 | { |
| 98 | *req_id = bedata->ring.req_prod_pvt & (RING_SIZE(&bedata->ring) - 1); | 125 | *req_id = bedata->ring.req_prod_pvt & (RING_SIZE(&bedata->ring) - 1); |
| @@ -369,31 +396,23 @@ int pvcalls_front_connect(struct socket *sock, struct sockaddr *addr, | |||
| 369 | if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) | 396 | if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) |
| 370 | return -EOPNOTSUPP; | 397 | return -EOPNOTSUPP; |
| 371 | 398 | ||
| 372 | pvcalls_enter(); | 399 | map = pvcalls_enter_sock(sock); |
| 373 | if (!pvcalls_front_dev) { | 400 | if (IS_ERR(map)) |
| 374 | pvcalls_exit(); | 401 | return PTR_ERR(map); |
| 375 | return -ENOTCONN; | ||
| 376 | } | ||
| 377 | 402 | ||
| 378 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 403 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 379 | 404 | ||
| 380 | map = (struct sock_mapping *)sock->sk->sk_send_head; | ||
| 381 | if (!map) { | ||
| 382 | pvcalls_exit(); | ||
| 383 | return -ENOTSOCK; | ||
| 384 | } | ||
| 385 | |||
| 386 | spin_lock(&bedata->socket_lock); | 405 | spin_lock(&bedata->socket_lock); |
| 387 | ret = get_request(bedata, &req_id); | 406 | ret = get_request(bedata, &req_id); |
| 388 | if (ret < 0) { | 407 | if (ret < 0) { |
| 389 | spin_unlock(&bedata->socket_lock); | 408 | spin_unlock(&bedata->socket_lock); |
| 390 | pvcalls_exit(); | 409 | pvcalls_exit_sock(sock); |
| 391 | return ret; | 410 | return ret; |
| 392 | } | 411 | } |
| 393 | ret = create_active(map, &evtchn); | 412 | ret = create_active(map, &evtchn); |
| 394 | if (ret < 0) { | 413 | if (ret < 0) { |
| 395 | spin_unlock(&bedata->socket_lock); | 414 | spin_unlock(&bedata->socket_lock); |
| 396 | pvcalls_exit(); | 415 | pvcalls_exit_sock(sock); |
| 397 | return ret; | 416 | return ret; |
| 398 | } | 417 | } |
| 399 | 418 | ||
| @@ -423,7 +442,7 @@ int pvcalls_front_connect(struct socket *sock, struct sockaddr *addr, | |||
| 423 | smp_rmb(); | 442 | smp_rmb(); |
| 424 | ret = bedata->rsp[req_id].ret; | 443 | ret = bedata->rsp[req_id].ret; |
| 425 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; | 444 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; |
| 426 | pvcalls_exit(); | 445 | pvcalls_exit_sock(sock); |
| 427 | return ret; | 446 | return ret; |
| 428 | } | 447 | } |
| 429 | 448 | ||
| @@ -488,23 +507,15 @@ int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg, | |||
| 488 | if (flags & (MSG_CONFIRM|MSG_DONTROUTE|MSG_EOR|MSG_OOB)) | 507 | if (flags & (MSG_CONFIRM|MSG_DONTROUTE|MSG_EOR|MSG_OOB)) |
| 489 | return -EOPNOTSUPP; | 508 | return -EOPNOTSUPP; |
| 490 | 509 | ||
| 491 | pvcalls_enter(); | 510 | map = pvcalls_enter_sock(sock); |
| 492 | if (!pvcalls_front_dev) { | 511 | if (IS_ERR(map)) |
| 493 | pvcalls_exit(); | 512 | return PTR_ERR(map); |
| 494 | return -ENOTCONN; | ||
| 495 | } | ||
| 496 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 513 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 497 | 514 | ||
| 498 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 499 | if (!map) { | ||
| 500 | pvcalls_exit(); | ||
| 501 | return -ENOTSOCK; | ||
| 502 | } | ||
| 503 | |||
| 504 | mutex_lock(&map->active.out_mutex); | 515 | mutex_lock(&map->active.out_mutex); |
| 505 | if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { | 516 | if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { |
| 506 | mutex_unlock(&map->active.out_mutex); | 517 | mutex_unlock(&map->active.out_mutex); |
| 507 | pvcalls_exit(); | 518 | pvcalls_exit_sock(sock); |
| 508 | return -EAGAIN; | 519 | return -EAGAIN; |
| 509 | } | 520 | } |
| 510 | if (len > INT_MAX) | 521 | if (len > INT_MAX) |
| @@ -526,7 +537,7 @@ again: | |||
| 526 | tot_sent = sent; | 537 | tot_sent = sent; |
| 527 | 538 | ||
| 528 | mutex_unlock(&map->active.out_mutex); | 539 | mutex_unlock(&map->active.out_mutex); |
| 529 | pvcalls_exit(); | 540 | pvcalls_exit_sock(sock); |
| 530 | return tot_sent; | 541 | return tot_sent; |
| 531 | } | 542 | } |
| 532 | 543 | ||
| @@ -591,19 +602,11 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, | |||
| 591 | if (flags & (MSG_CMSG_CLOEXEC|MSG_ERRQUEUE|MSG_OOB|MSG_TRUNC)) | 602 | if (flags & (MSG_CMSG_CLOEXEC|MSG_ERRQUEUE|MSG_OOB|MSG_TRUNC)) |
| 592 | return -EOPNOTSUPP; | 603 | return -EOPNOTSUPP; |
| 593 | 604 | ||
| 594 | pvcalls_enter(); | 605 | map = pvcalls_enter_sock(sock); |
| 595 | if (!pvcalls_front_dev) { | 606 | if (IS_ERR(map)) |
| 596 | pvcalls_exit(); | 607 | return PTR_ERR(map); |
| 597 | return -ENOTCONN; | ||
| 598 | } | ||
| 599 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 608 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 600 | 609 | ||
| 601 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 602 | if (!map) { | ||
| 603 | pvcalls_exit(); | ||
| 604 | return -ENOTSOCK; | ||
| 605 | } | ||
| 606 | |||
| 607 | mutex_lock(&map->active.in_mutex); | 610 | mutex_lock(&map->active.in_mutex); |
| 608 | if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER)) | 611 | if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER)) |
| 609 | len = XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER); | 612 | len = XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER); |
| @@ -623,7 +626,7 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, | |||
| 623 | ret = 0; | 626 | ret = 0; |
| 624 | 627 | ||
| 625 | mutex_unlock(&map->active.in_mutex); | 628 | mutex_unlock(&map->active.in_mutex); |
| 626 | pvcalls_exit(); | 629 | pvcalls_exit_sock(sock); |
| 627 | return ret; | 630 | return ret; |
| 628 | } | 631 | } |
| 629 | 632 | ||
| @@ -637,24 +640,16 @@ int pvcalls_front_bind(struct socket *sock, struct sockaddr *addr, int addr_len) | |||
| 637 | if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) | 640 | if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM) |
| 638 | return -EOPNOTSUPP; | 641 | return -EOPNOTSUPP; |
| 639 | 642 | ||
| 640 | pvcalls_enter(); | 643 | map = pvcalls_enter_sock(sock); |
| 641 | if (!pvcalls_front_dev) { | 644 | if (IS_ERR(map)) |
| 642 | pvcalls_exit(); | 645 | return PTR_ERR(map); |
| 643 | return -ENOTCONN; | ||
| 644 | } | ||
| 645 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 646 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 646 | 647 | ||
| 647 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 648 | if (map == NULL) { | ||
| 649 | pvcalls_exit(); | ||
| 650 | return -ENOTSOCK; | ||
| 651 | } | ||
| 652 | |||
| 653 | spin_lock(&bedata->socket_lock); | 648 | spin_lock(&bedata->socket_lock); |
| 654 | ret = get_request(bedata, &req_id); | 649 | ret = get_request(bedata, &req_id); |
| 655 | if (ret < 0) { | 650 | if (ret < 0) { |
| 656 | spin_unlock(&bedata->socket_lock); | 651 | spin_unlock(&bedata->socket_lock); |
| 657 | pvcalls_exit(); | 652 | pvcalls_exit_sock(sock); |
| 658 | return ret; | 653 | return ret; |
| 659 | } | 654 | } |
| 660 | req = RING_GET_REQUEST(&bedata->ring, req_id); | 655 | req = RING_GET_REQUEST(&bedata->ring, req_id); |
| @@ -684,7 +679,7 @@ int pvcalls_front_bind(struct socket *sock, struct sockaddr *addr, int addr_len) | |||
| 684 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; | 679 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; |
| 685 | 680 | ||
| 686 | map->passive.status = PVCALLS_STATUS_BIND; | 681 | map->passive.status = PVCALLS_STATUS_BIND; |
| 687 | pvcalls_exit(); | 682 | pvcalls_exit_sock(sock); |
| 688 | return 0; | 683 | return 0; |
| 689 | } | 684 | } |
| 690 | 685 | ||
| @@ -695,21 +690,13 @@ int pvcalls_front_listen(struct socket *sock, int backlog) | |||
| 695 | struct xen_pvcalls_request *req; | 690 | struct xen_pvcalls_request *req; |
| 696 | int notify, req_id, ret; | 691 | int notify, req_id, ret; |
| 697 | 692 | ||
| 698 | pvcalls_enter(); | 693 | map = pvcalls_enter_sock(sock); |
| 699 | if (!pvcalls_front_dev) { | 694 | if (IS_ERR(map)) |
| 700 | pvcalls_exit(); | 695 | return PTR_ERR(map); |
| 701 | return -ENOTCONN; | ||
| 702 | } | ||
| 703 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 696 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 704 | 697 | ||
| 705 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 706 | if (!map) { | ||
| 707 | pvcalls_exit(); | ||
| 708 | return -ENOTSOCK; | ||
| 709 | } | ||
| 710 | |||
| 711 | if (map->passive.status != PVCALLS_STATUS_BIND) { | 698 | if (map->passive.status != PVCALLS_STATUS_BIND) { |
| 712 | pvcalls_exit(); | 699 | pvcalls_exit_sock(sock); |
| 713 | return -EOPNOTSUPP; | 700 | return -EOPNOTSUPP; |
| 714 | } | 701 | } |
| 715 | 702 | ||
| @@ -717,7 +704,7 @@ int pvcalls_front_listen(struct socket *sock, int backlog) | |||
| 717 | ret = get_request(bedata, &req_id); | 704 | ret = get_request(bedata, &req_id); |
| 718 | if (ret < 0) { | 705 | if (ret < 0) { |
| 719 | spin_unlock(&bedata->socket_lock); | 706 | spin_unlock(&bedata->socket_lock); |
| 720 | pvcalls_exit(); | 707 | pvcalls_exit_sock(sock); |
| 721 | return ret; | 708 | return ret; |
| 722 | } | 709 | } |
| 723 | req = RING_GET_REQUEST(&bedata->ring, req_id); | 710 | req = RING_GET_REQUEST(&bedata->ring, req_id); |
| @@ -741,7 +728,7 @@ int pvcalls_front_listen(struct socket *sock, int backlog) | |||
| 741 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; | 728 | bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID; |
| 742 | 729 | ||
| 743 | map->passive.status = PVCALLS_STATUS_LISTEN; | 730 | map->passive.status = PVCALLS_STATUS_LISTEN; |
| 744 | pvcalls_exit(); | 731 | pvcalls_exit_sock(sock); |
| 745 | return ret; | 732 | return ret; |
| 746 | } | 733 | } |
| 747 | 734 | ||
| @@ -753,21 +740,13 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 753 | struct xen_pvcalls_request *req; | 740 | struct xen_pvcalls_request *req; |
| 754 | int notify, req_id, ret, evtchn, nonblock; | 741 | int notify, req_id, ret, evtchn, nonblock; |
| 755 | 742 | ||
| 756 | pvcalls_enter(); | 743 | map = pvcalls_enter_sock(sock); |
| 757 | if (!pvcalls_front_dev) { | 744 | if (IS_ERR(map)) |
| 758 | pvcalls_exit(); | 745 | return PTR_ERR(map); |
| 759 | return -ENOTCONN; | ||
| 760 | } | ||
| 761 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 746 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 762 | 747 | ||
| 763 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 764 | if (!map) { | ||
| 765 | pvcalls_exit(); | ||
| 766 | return -ENOTSOCK; | ||
| 767 | } | ||
| 768 | |||
| 769 | if (map->passive.status != PVCALLS_STATUS_LISTEN) { | 748 | if (map->passive.status != PVCALLS_STATUS_LISTEN) { |
| 770 | pvcalls_exit(); | 749 | pvcalls_exit_sock(sock); |
| 771 | return -EINVAL; | 750 | return -EINVAL; |
| 772 | } | 751 | } |
| 773 | 752 | ||
| @@ -785,13 +764,13 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 785 | goto received; | 764 | goto received; |
| 786 | } | 765 | } |
| 787 | if (nonblock) { | 766 | if (nonblock) { |
| 788 | pvcalls_exit(); | 767 | pvcalls_exit_sock(sock); |
| 789 | return -EAGAIN; | 768 | return -EAGAIN; |
| 790 | } | 769 | } |
| 791 | if (wait_event_interruptible(map->passive.inflight_accept_req, | 770 | if (wait_event_interruptible(map->passive.inflight_accept_req, |
| 792 | !test_and_set_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, | 771 | !test_and_set_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, |
| 793 | (void *)&map->passive.flags))) { | 772 | (void *)&map->passive.flags))) { |
| 794 | pvcalls_exit(); | 773 | pvcalls_exit_sock(sock); |
| 795 | return -EINTR; | 774 | return -EINTR; |
| 796 | } | 775 | } |
| 797 | } | 776 | } |
| @@ -802,7 +781,7 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 802 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, | 781 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, |
| 803 | (void *)&map->passive.flags); | 782 | (void *)&map->passive.flags); |
| 804 | spin_unlock(&bedata->socket_lock); | 783 | spin_unlock(&bedata->socket_lock); |
| 805 | pvcalls_exit(); | 784 | pvcalls_exit_sock(sock); |
| 806 | return ret; | 785 | return ret; |
| 807 | } | 786 | } |
| 808 | map2 = kzalloc(sizeof(*map2), GFP_ATOMIC); | 787 | map2 = kzalloc(sizeof(*map2), GFP_ATOMIC); |
| @@ -810,7 +789,7 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 810 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, | 789 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, |
| 811 | (void *)&map->passive.flags); | 790 | (void *)&map->passive.flags); |
| 812 | spin_unlock(&bedata->socket_lock); | 791 | spin_unlock(&bedata->socket_lock); |
| 813 | pvcalls_exit(); | 792 | pvcalls_exit_sock(sock); |
| 814 | return -ENOMEM; | 793 | return -ENOMEM; |
| 815 | } | 794 | } |
| 816 | ret = create_active(map2, &evtchn); | 795 | ret = create_active(map2, &evtchn); |
| @@ -819,7 +798,7 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 819 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, | 798 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, |
| 820 | (void *)&map->passive.flags); | 799 | (void *)&map->passive.flags); |
| 821 | spin_unlock(&bedata->socket_lock); | 800 | spin_unlock(&bedata->socket_lock); |
| 822 | pvcalls_exit(); | 801 | pvcalls_exit_sock(sock); |
| 823 | return ret; | 802 | return ret; |
| 824 | } | 803 | } |
| 825 | list_add_tail(&map2->list, &bedata->socket_mappings); | 804 | list_add_tail(&map2->list, &bedata->socket_mappings); |
| @@ -841,13 +820,13 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags) | |||
| 841 | /* We could check if we have received a response before returning. */ | 820 | /* We could check if we have received a response before returning. */ |
| 842 | if (nonblock) { | 821 | if (nonblock) { |
| 843 | WRITE_ONCE(map->passive.inflight_req_id, req_id); | 822 | WRITE_ONCE(map->passive.inflight_req_id, req_id); |
| 844 | pvcalls_exit(); | 823 | pvcalls_exit_sock(sock); |
| 845 | return -EAGAIN; | 824 | return -EAGAIN; |
| 846 | } | 825 | } |
| 847 | 826 | ||
| 848 | if (wait_event_interruptible(bedata->inflight_req, | 827 | if (wait_event_interruptible(bedata->inflight_req, |
| 849 | READ_ONCE(bedata->rsp[req_id].req_id) == req_id)) { | 828 | READ_ONCE(bedata->rsp[req_id].req_id) == req_id)) { |
| 850 | pvcalls_exit(); | 829 | pvcalls_exit_sock(sock); |
| 851 | return -EINTR; | 830 | return -EINTR; |
| 852 | } | 831 | } |
| 853 | /* read req_id, then the content */ | 832 | /* read req_id, then the content */ |
| @@ -862,7 +841,7 @@ received: | |||
| 862 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, | 841 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, |
| 863 | (void *)&map->passive.flags); | 842 | (void *)&map->passive.flags); |
| 864 | pvcalls_front_free_map(bedata, map2); | 843 | pvcalls_front_free_map(bedata, map2); |
| 865 | pvcalls_exit(); | 844 | pvcalls_exit_sock(sock); |
| 866 | return -ENOMEM; | 845 | return -ENOMEM; |
| 867 | } | 846 | } |
| 868 | newsock->sk->sk_send_head = (void *)map2; | 847 | newsock->sk->sk_send_head = (void *)map2; |
| @@ -874,7 +853,7 @@ received: | |||
| 874 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, (void *)&map->passive.flags); | 853 | clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, (void *)&map->passive.flags); |
| 875 | wake_up(&map->passive.inflight_accept_req); | 854 | wake_up(&map->passive.inflight_accept_req); |
| 876 | 855 | ||
| 877 | pvcalls_exit(); | 856 | pvcalls_exit_sock(sock); |
| 878 | return ret; | 857 | return ret; |
| 879 | } | 858 | } |
| 880 | 859 | ||
| @@ -965,23 +944,16 @@ __poll_t pvcalls_front_poll(struct file *file, struct socket *sock, | |||
| 965 | struct sock_mapping *map; | 944 | struct sock_mapping *map; |
| 966 | __poll_t ret; | 945 | __poll_t ret; |
| 967 | 946 | ||
| 968 | pvcalls_enter(); | 947 | map = pvcalls_enter_sock(sock); |
| 969 | if (!pvcalls_front_dev) { | 948 | if (IS_ERR(map)) |
| 970 | pvcalls_exit(); | ||
| 971 | return EPOLLNVAL; | 949 | return EPOLLNVAL; |
| 972 | } | ||
| 973 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 950 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 974 | 951 | ||
| 975 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 976 | if (!map) { | ||
| 977 | pvcalls_exit(); | ||
| 978 | return EPOLLNVAL; | ||
| 979 | } | ||
| 980 | if (map->active_socket) | 952 | if (map->active_socket) |
| 981 | ret = pvcalls_front_poll_active(file, bedata, map, wait); | 953 | ret = pvcalls_front_poll_active(file, bedata, map, wait); |
| 982 | else | 954 | else |
| 983 | ret = pvcalls_front_poll_passive(file, bedata, map, wait); | 955 | ret = pvcalls_front_poll_passive(file, bedata, map, wait); |
| 984 | pvcalls_exit(); | 956 | pvcalls_exit_sock(sock); |
| 985 | return ret; | 957 | return ret; |
| 986 | } | 958 | } |
| 987 | 959 | ||
| @@ -995,25 +967,20 @@ int pvcalls_front_release(struct socket *sock) | |||
| 995 | if (sock->sk == NULL) | 967 | if (sock->sk == NULL) |
| 996 | return 0; | 968 | return 0; |
| 997 | 969 | ||
| 998 | pvcalls_enter(); | 970 | map = pvcalls_enter_sock(sock); |
| 999 | if (!pvcalls_front_dev) { | 971 | if (IS_ERR(map)) { |
| 1000 | pvcalls_exit(); | 972 | if (PTR_ERR(map) == -ENOTCONN) |
| 1001 | return -EIO; | 973 | return -EIO; |
| 974 | else | ||
| 975 | return 0; | ||
| 1002 | } | 976 | } |
| 1003 | |||
| 1004 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); | 977 | bedata = dev_get_drvdata(&pvcalls_front_dev->dev); |
| 1005 | 978 | ||
| 1006 | map = (struct sock_mapping *) sock->sk->sk_send_head; | ||
| 1007 | if (map == NULL) { | ||
| 1008 | pvcalls_exit(); | ||
| 1009 | return 0; | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | spin_lock(&bedata->socket_lock); | 979 | spin_lock(&bedata->socket_lock); |
| 1013 | ret = get_request(bedata, &req_id); | 980 | ret = get_request(bedata, &req_id); |
| 1014 | if (ret < 0) { | 981 | if (ret < 0) { |
| 1015 | spin_unlock(&bedata->socket_lock); | 982 | spin_unlock(&bedata->socket_lock); |
| 1016 | pvcalls_exit(); | 983 | pvcalls_exit_sock(sock); |
| 1017 | return ret; | 984 | return ret; |
| 1018 | } | 985 | } |
| 1019 | sock->sk->sk_send_head = NULL; | 986 | sock->sk->sk_send_head = NULL; |
| @@ -1043,14 +1010,20 @@ int pvcalls_front_release(struct socket *sock) | |||
| 1043 | /* | 1010 | /* |
| 1044 | * We need to make sure that sendmsg/recvmsg on this socket have | 1011 | * We need to make sure that sendmsg/recvmsg on this socket have |
| 1045 | * not started before we've cleared sk_send_head here. The | 1012 | * not started before we've cleared sk_send_head here. The |
| 1046 | * easiest (though not optimal) way to guarantee this is to see | 1013 | * easiest way to guarantee this is to see that no pvcalls |
| 1047 | * that no pvcall (other than us) is in progress. | 1014 | * (other than us) is in progress on this socket. |
| 1048 | */ | 1015 | */ |
| 1049 | while (atomic_read(&pvcalls_refcount) > 1) | 1016 | while (atomic_read(&map->refcount) > 1) |
| 1050 | cpu_relax(); | 1017 | cpu_relax(); |
| 1051 | 1018 | ||
| 1052 | pvcalls_front_free_map(bedata, map); | 1019 | pvcalls_front_free_map(bedata, map); |
| 1053 | } else { | 1020 | } else { |
| 1021 | wake_up(&bedata->inflight_req); | ||
| 1022 | wake_up(&map->passive.inflight_accept_req); | ||
| 1023 | |||
| 1024 | while (atomic_read(&map->refcount) > 1) | ||
| 1025 | cpu_relax(); | ||
| 1026 | |||
| 1054 | spin_lock(&bedata->socket_lock); | 1027 | spin_lock(&bedata->socket_lock); |
| 1055 | list_del(&map->list); | 1028 | list_del(&map->list); |
| 1056 | spin_unlock(&bedata->socket_lock); | 1029 | spin_unlock(&bedata->socket_lock); |
diff --git a/drivers/xen/xenbus/xenbus.h b/drivers/xen/xenbus/xenbus.h index 149c5e7efc89..092981171df1 100644 --- a/drivers/xen/xenbus/xenbus.h +++ b/drivers/xen/xenbus/xenbus.h | |||
| @@ -76,6 +76,7 @@ struct xb_req_data { | |||
| 76 | struct list_head list; | 76 | struct list_head list; |
| 77 | wait_queue_head_t wq; | 77 | wait_queue_head_t wq; |
| 78 | struct xsd_sockmsg msg; | 78 | struct xsd_sockmsg msg; |
| 79 | uint32_t caller_req_id; | ||
| 79 | enum xsd_sockmsg_type type; | 80 | enum xsd_sockmsg_type type; |
| 80 | char *body; | 81 | char *body; |
| 81 | const struct kvec *vec; | 82 | const struct kvec *vec; |
diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c index 5b081a01779d..d239fc3c5e3d 100644 --- a/drivers/xen/xenbus/xenbus_comms.c +++ b/drivers/xen/xenbus/xenbus_comms.c | |||
| @@ -309,6 +309,7 @@ static int process_msg(void) | |||
| 309 | goto out; | 309 | goto out; |
| 310 | 310 | ||
| 311 | if (req->state == xb_req_state_wait_reply) { | 311 | if (req->state == xb_req_state_wait_reply) { |
| 312 | req->msg.req_id = req->caller_req_id; | ||
| 312 | req->msg.type = state.msg.type; | 313 | req->msg.type = state.msg.type; |
| 313 | req->msg.len = state.msg.len; | 314 | req->msg.len = state.msg.len; |
| 314 | req->body = state.body; | 315 | req->body = state.body; |
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c index 3e59590c7254..3f3b29398ab8 100644 --- a/drivers/xen/xenbus/xenbus_xs.c +++ b/drivers/xen/xenbus/xenbus_xs.c | |||
| @@ -227,6 +227,8 @@ static void xs_send(struct xb_req_data *req, struct xsd_sockmsg *msg) | |||
| 227 | req->state = xb_req_state_queued; | 227 | req->state = xb_req_state_queued; |
| 228 | init_waitqueue_head(&req->wq); | 228 | init_waitqueue_head(&req->wq); |
| 229 | 229 | ||
| 230 | /* Save the caller req_id and restore it later in the reply */ | ||
| 231 | req->caller_req_id = req->msg.req_id; | ||
| 230 | req->msg.req_id = xs_request_enter(req); | 232 | req->msg.req_id = xs_request_enter(req); |
| 231 | 233 | ||
| 232 | mutex_lock(&xb_write_mutex); | 234 | mutex_lock(&xb_write_mutex); |
| @@ -310,6 +312,7 @@ static void *xs_talkv(struct xenbus_transaction t, | |||
| 310 | req->num_vecs = num_vecs; | 312 | req->num_vecs = num_vecs; |
| 311 | req->cb = xs_wake_up; | 313 | req->cb = xs_wake_up; |
| 312 | 314 | ||
| 315 | msg.req_id = 0; | ||
| 313 | msg.tx_id = t.id; | 316 | msg.tx_id = t.id; |
| 314 | msg.type = type; | 317 | msg.type = type; |
| 315 | msg.len = 0; | 318 | msg.len = 0; |
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index e4054e533f6d..f94b2d8c744a 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
| @@ -1264,7 +1264,16 @@ again: | |||
| 1264 | while (node) { | 1264 | while (node) { |
| 1265 | ref = rb_entry(node, struct prelim_ref, rbnode); | 1265 | ref = rb_entry(node, struct prelim_ref, rbnode); |
| 1266 | node = rb_next(&ref->rbnode); | 1266 | node = rb_next(&ref->rbnode); |
| 1267 | WARN_ON(ref->count < 0); | 1267 | /* |
| 1268 | * ref->count < 0 can happen here if there are delayed | ||
| 1269 | * refs with a node->action of BTRFS_DROP_DELAYED_REF. | ||
| 1270 | * prelim_ref_insert() relies on this when merging | ||
| 1271 | * identical refs to keep the overall count correct. | ||
| 1272 | * prelim_ref_insert() will merge only those refs | ||
| 1273 | * which compare identically. Any refs having | ||
| 1274 | * e.g. different offsets would not be merged, | ||
| 1275 | * and would retain their original ref->count < 0. | ||
| 1276 | */ | ||
| 1268 | if (roots && ref->count && ref->root_id && ref->parent == 0) { | 1277 | if (roots && ref->count && ref->root_id && ref->parent == 0) { |
| 1269 | if (sc && sc->root_objectid && | 1278 | if (sc && sc->root_objectid && |
| 1270 | ref->root_id != sc->root_objectid) { | 1279 | ref->root_id != sc->root_objectid) { |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index a1a40cf382e3..7ab5e0128f0c 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
| @@ -821,7 +821,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | |||
| 821 | spin_unlock(&delayed_refs->lock); | 821 | spin_unlock(&delayed_refs->lock); |
| 822 | 822 | ||
| 823 | if (qrecord_inserted) | 823 | if (qrecord_inserted) |
| 824 | return btrfs_qgroup_trace_extent_post(fs_info, record); | 824 | btrfs_qgroup_trace_extent_post(fs_info, record); |
| 825 | |||
| 825 | return 0; | 826 | return 0; |
| 826 | 827 | ||
| 827 | free_head_ref: | 828 | free_head_ref: |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 05751a677da4..c1618ab9fecf 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -2147,6 +2147,10 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, | |||
| 2147 | u64 bytes; | 2147 | u64 bytes; |
| 2148 | struct request_queue *req_q; | 2148 | struct request_queue *req_q; |
| 2149 | 2149 | ||
| 2150 | if (!stripe->dev->bdev) { | ||
| 2151 | ASSERT(btrfs_test_opt(fs_info, DEGRADED)); | ||
| 2152 | continue; | ||
| 2153 | } | ||
| 2150 | req_q = bdev_get_queue(stripe->dev->bdev); | 2154 | req_q = bdev_get_queue(stripe->dev->bdev); |
| 2151 | if (!blk_queue_discard(req_q)) | 2155 | if (!blk_queue_discard(req_q)) |
| 2152 | continue; | 2156 | continue; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 53ca025655fc..a79299a89b7d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -1335,8 +1335,11 @@ next_slot: | |||
| 1335 | leaf = path->nodes[0]; | 1335 | leaf = path->nodes[0]; |
| 1336 | if (path->slots[0] >= btrfs_header_nritems(leaf)) { | 1336 | if (path->slots[0] >= btrfs_header_nritems(leaf)) { |
| 1337 | ret = btrfs_next_leaf(root, path); | 1337 | ret = btrfs_next_leaf(root, path); |
| 1338 | if (ret < 0) | 1338 | if (ret < 0) { |
| 1339 | if (cow_start != (u64)-1) | ||
| 1340 | cur_offset = cow_start; | ||
| 1339 | goto error; | 1341 | goto error; |
| 1342 | } | ||
| 1340 | if (ret > 0) | 1343 | if (ret > 0) |
| 1341 | break; | 1344 | break; |
| 1342 | leaf = path->nodes[0]; | 1345 | leaf = path->nodes[0]; |
| @@ -3385,6 +3388,11 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, | |||
| 3385 | ret = btrfs_orphan_reserve_metadata(trans, inode); | 3388 | ret = btrfs_orphan_reserve_metadata(trans, inode); |
| 3386 | ASSERT(!ret); | 3389 | ASSERT(!ret); |
| 3387 | if (ret) { | 3390 | if (ret) { |
| 3391 | /* | ||
| 3392 | * dec doesn't need spin_lock as ->orphan_block_rsv | ||
| 3393 | * would be released only if ->orphan_inodes is | ||
| 3394 | * zero. | ||
| 3395 | */ | ||
| 3388 | atomic_dec(&root->orphan_inodes); | 3396 | atomic_dec(&root->orphan_inodes); |
| 3389 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, | 3397 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, |
| 3390 | &inode->runtime_flags); | 3398 | &inode->runtime_flags); |
| @@ -3399,12 +3407,17 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, | |||
| 3399 | if (insert >= 1) { | 3407 | if (insert >= 1) { |
| 3400 | ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); | 3408 | ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); |
| 3401 | if (ret) { | 3409 | if (ret) { |
| 3402 | atomic_dec(&root->orphan_inodes); | ||
| 3403 | if (reserve) { | 3410 | if (reserve) { |
| 3404 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, | 3411 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, |
| 3405 | &inode->runtime_flags); | 3412 | &inode->runtime_flags); |
| 3406 | btrfs_orphan_release_metadata(inode); | 3413 | btrfs_orphan_release_metadata(inode); |
| 3407 | } | 3414 | } |
| 3415 | /* | ||
| 3416 | * btrfs_orphan_commit_root may race with us and set | ||
| 3417 | * ->orphan_block_rsv to zero, in order to avoid that, | ||
| 3418 | * decrease ->orphan_inodes after everything is done. | ||
| 3419 | */ | ||
| 3420 | atomic_dec(&root->orphan_inodes); | ||
| 3408 | if (ret != -EEXIST) { | 3421 | if (ret != -EEXIST) { |
| 3409 | clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, | 3422 | clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, |
| 3410 | &inode->runtime_flags); | 3423 | &inode->runtime_flags); |
| @@ -3436,28 +3449,26 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, | |||
| 3436 | { | 3449 | { |
| 3437 | struct btrfs_root *root = inode->root; | 3450 | struct btrfs_root *root = inode->root; |
| 3438 | int delete_item = 0; | 3451 | int delete_item = 0; |
| 3439 | int release_rsv = 0; | ||
| 3440 | int ret = 0; | 3452 | int ret = 0; |
| 3441 | 3453 | ||
| 3442 | spin_lock(&root->orphan_lock); | ||
| 3443 | if (test_and_clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, | 3454 | if (test_and_clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, |
| 3444 | &inode->runtime_flags)) | 3455 | &inode->runtime_flags)) |
| 3445 | delete_item = 1; | 3456 | delete_item = 1; |
| 3446 | 3457 | ||
| 3458 | if (delete_item && trans) | ||
| 3459 | ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode)); | ||
| 3460 | |||
| 3447 | if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, | 3461 | if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, |
| 3448 | &inode->runtime_flags)) | 3462 | &inode->runtime_flags)) |
| 3449 | release_rsv = 1; | 3463 | btrfs_orphan_release_metadata(inode); |
| 3450 | spin_unlock(&root->orphan_lock); | ||
| 3451 | 3464 | ||
| 3452 | if (delete_item) { | 3465 | /* |
| 3466 | * btrfs_orphan_commit_root may race with us and set ->orphan_block_rsv | ||
| 3467 | * to zero, in order to avoid that, decrease ->orphan_inodes after | ||
| 3468 | * everything is done. | ||
| 3469 | */ | ||
| 3470 | if (delete_item) | ||
| 3453 | atomic_dec(&root->orphan_inodes); | 3471 | atomic_dec(&root->orphan_inodes); |
| 3454 | if (trans) | ||
| 3455 | ret = btrfs_del_orphan_item(trans, root, | ||
| 3456 | btrfs_ino(inode)); | ||
| 3457 | } | ||
| 3458 | |||
| 3459 | if (release_rsv) | ||
| 3460 | btrfs_orphan_release_metadata(inode); | ||
| 3461 | 3472 | ||
| 3462 | return ret; | 3473 | return ret; |
| 3463 | } | 3474 | } |
| @@ -5281,7 +5292,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
| 5281 | trace_btrfs_inode_evict(inode); | 5292 | trace_btrfs_inode_evict(inode); |
| 5282 | 5293 | ||
| 5283 | if (!root) { | 5294 | if (!root) { |
| 5284 | kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); | 5295 | clear_inode(inode); |
| 5285 | return; | 5296 | return; |
| 5286 | } | 5297 | } |
| 5287 | 5298 | ||
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 9e61dd624f7b..aa259d6986e1 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
| @@ -1442,8 +1442,13 @@ int btrfs_qgroup_trace_extent_post(struct btrfs_fs_info *fs_info, | |||
| 1442 | int ret; | 1442 | int ret; |
| 1443 | 1443 | ||
| 1444 | ret = btrfs_find_all_roots(NULL, fs_info, bytenr, 0, &old_root, false); | 1444 | ret = btrfs_find_all_roots(NULL, fs_info, bytenr, 0, &old_root, false); |
| 1445 | if (ret < 0) | 1445 | if (ret < 0) { |
| 1446 | return ret; | 1446 | fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; |
| 1447 | btrfs_warn(fs_info, | ||
| 1448 | "error accounting new delayed refs extent (err code: %d), quota inconsistent", | ||
| 1449 | ret); | ||
| 1450 | return 0; | ||
| 1451 | } | ||
| 1447 | 1452 | ||
| 1448 | /* | 1453 | /* |
| 1449 | * Here we don't need to get the lock of | 1454 | * Here we don't need to get the lock of |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index afadaadab18e..4fd19b4d6675 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "hash.h" | 29 | #include "hash.h" |
| 30 | #include "compression.h" | 30 | #include "compression.h" |
| 31 | #include "qgroup.h" | 31 | #include "qgroup.h" |
| 32 | #include "inode-map.h" | ||
| 32 | 33 | ||
| 33 | /* magic values for the inode_only field in btrfs_log_inode: | 34 | /* magic values for the inode_only field in btrfs_log_inode: |
| 34 | * | 35 | * |
| @@ -2472,6 +2473,9 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
| 2472 | clean_tree_block(fs_info, next); | 2473 | clean_tree_block(fs_info, next); |
| 2473 | btrfs_wait_tree_block_writeback(next); | 2474 | btrfs_wait_tree_block_writeback(next); |
| 2474 | btrfs_tree_unlock(next); | 2475 | btrfs_tree_unlock(next); |
| 2476 | } else { | ||
| 2477 | if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) | ||
| 2478 | clear_extent_buffer_dirty(next); | ||
| 2475 | } | 2479 | } |
| 2476 | 2480 | ||
| 2477 | WARN_ON(root_owner != | 2481 | WARN_ON(root_owner != |
| @@ -2552,6 +2556,9 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, | |||
| 2552 | clean_tree_block(fs_info, next); | 2556 | clean_tree_block(fs_info, next); |
| 2553 | btrfs_wait_tree_block_writeback(next); | 2557 | btrfs_wait_tree_block_writeback(next); |
| 2554 | btrfs_tree_unlock(next); | 2558 | btrfs_tree_unlock(next); |
| 2559 | } else { | ||
| 2560 | if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) | ||
| 2561 | clear_extent_buffer_dirty(next); | ||
| 2555 | } | 2562 | } |
| 2556 | 2563 | ||
| 2557 | WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); | 2564 | WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); |
| @@ -2630,6 +2637,9 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, | |||
| 2630 | clean_tree_block(fs_info, next); | 2637 | clean_tree_block(fs_info, next); |
| 2631 | btrfs_wait_tree_block_writeback(next); | 2638 | btrfs_wait_tree_block_writeback(next); |
| 2632 | btrfs_tree_unlock(next); | 2639 | btrfs_tree_unlock(next); |
| 2640 | } else { | ||
| 2641 | if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) | ||
| 2642 | clear_extent_buffer_dirty(next); | ||
| 2633 | } | 2643 | } |
| 2634 | 2644 | ||
| 2635 | WARN_ON(log->root_key.objectid != | 2645 | WARN_ON(log->root_key.objectid != |
| @@ -3018,13 +3028,14 @@ static void free_log_tree(struct btrfs_trans_handle *trans, | |||
| 3018 | 3028 | ||
| 3019 | while (1) { | 3029 | while (1) { |
| 3020 | ret = find_first_extent_bit(&log->dirty_log_pages, | 3030 | ret = find_first_extent_bit(&log->dirty_log_pages, |
| 3021 | 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW, | 3031 | 0, &start, &end, |
| 3032 | EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT, | ||
| 3022 | NULL); | 3033 | NULL); |
| 3023 | if (ret) | 3034 | if (ret) |
| 3024 | break; | 3035 | break; |
| 3025 | 3036 | ||
| 3026 | clear_extent_bits(&log->dirty_log_pages, start, end, | 3037 | clear_extent_bits(&log->dirty_log_pages, start, end, |
| 3027 | EXTENT_DIRTY | EXTENT_NEW); | 3038 | EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT); |
| 3028 | } | 3039 | } |
| 3029 | 3040 | ||
| 3030 | /* | 3041 | /* |
| @@ -5677,6 +5688,23 @@ again: | |||
| 5677 | path); | 5688 | path); |
| 5678 | } | 5689 | } |
| 5679 | 5690 | ||
| 5691 | if (!ret && wc.stage == LOG_WALK_REPLAY_ALL) { | ||
| 5692 | struct btrfs_root *root = wc.replay_dest; | ||
| 5693 | |||
| 5694 | btrfs_release_path(path); | ||
| 5695 | |||
| 5696 | /* | ||
| 5697 | * We have just replayed everything, and the highest | ||
| 5698 | * objectid of fs roots probably has changed in case | ||
| 5699 | * some inode_item's got replayed. | ||
| 5700 | * | ||
| 5701 | * root->objectid_mutex is not acquired as log replay | ||
| 5702 | * could only happen during mount. | ||
| 5703 | */ | ||
| 5704 | ret = btrfs_find_highest_objectid(root, | ||
| 5705 | &root->highest_objectid); | ||
| 5706 | } | ||
| 5707 | |||
| 5680 | key.offset = found_key.offset - 1; | 5708 | key.offset = found_key.offset - 1; |
| 5681 | wc.replay_dest->log_root = NULL; | 5709 | wc.replay_dest->log_root = NULL; |
| 5682 | free_extent_buffer(log->node); | 5710 | free_extent_buffer(log->node); |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b5036bd69e6a..2ceb924ca0d6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -645,6 +645,7 @@ static void btrfs_free_stale_devices(const char *path, | |||
| 645 | btrfs_sysfs_remove_fsid(fs_devs); | 645 | btrfs_sysfs_remove_fsid(fs_devs); |
| 646 | list_del(&fs_devs->list); | 646 | list_del(&fs_devs->list); |
| 647 | free_fs_devices(fs_devs); | 647 | free_fs_devices(fs_devs); |
| 648 | break; | ||
| 648 | } else { | 649 | } else { |
| 649 | fs_devs->num_devices--; | 650 | fs_devs->num_devices--; |
| 650 | list_del(&dev->dev_list); | 651 | list_del(&dev->dev_list); |
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 86863792f36a..86d6a4435c87 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
| @@ -716,7 +716,7 @@ int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, | |||
| 716 | __be64 *ptr; | 716 | __be64 *ptr; |
| 717 | sector_t lblock; | 717 | sector_t lblock; |
| 718 | sector_t lend; | 718 | sector_t lend; |
| 719 | int ret; | 719 | int ret = 0; |
| 720 | int eob; | 720 | int eob; |
| 721 | unsigned int len; | 721 | unsigned int len; |
| 722 | struct buffer_head *bh; | 722 | struct buffer_head *bh; |
| @@ -728,12 +728,14 @@ int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, | |||
| 728 | goto out; | 728 | goto out; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | if ((flags & IOMAP_REPORT) && gfs2_is_stuffed(ip)) { | 731 | if (gfs2_is_stuffed(ip)) { |
| 732 | gfs2_stuffed_iomap(inode, iomap); | 732 | if (flags & IOMAP_REPORT) { |
| 733 | if (pos >= iomap->length) | 733 | gfs2_stuffed_iomap(inode, iomap); |
| 734 | return -ENOENT; | 734 | if (pos >= iomap->length) |
| 735 | ret = 0; | 735 | ret = -ENOENT; |
| 736 | goto out; | 736 | goto out; |
| 737 | } | ||
| 738 | BUG_ON(!(flags & IOMAP_WRITE)); | ||
| 737 | } | 739 | } |
| 738 | 740 | ||
| 739 | lblock = pos >> inode->i_blkbits; | 741 | lblock = pos >> inode->i_blkbits; |
| @@ -744,7 +746,7 @@ int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, | |||
| 744 | iomap->type = IOMAP_HOLE; | 746 | iomap->type = IOMAP_HOLE; |
| 745 | iomap->length = (u64)(lend - lblock) << inode->i_blkbits; | 747 | iomap->length = (u64)(lend - lblock) << inode->i_blkbits; |
| 746 | iomap->flags = IOMAP_F_MERGED; | 748 | iomap->flags = IOMAP_F_MERGED; |
| 747 | bmap_lock(ip, 0); | 749 | bmap_lock(ip, flags & IOMAP_WRITE); |
| 748 | 750 | ||
| 749 | /* | 751 | /* |
| 750 | * Directory data blocks have a struct gfs2_meta_header header, so the | 752 | * Directory data blocks have a struct gfs2_meta_header header, so the |
| @@ -787,27 +789,28 @@ int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, | |||
| 787 | iomap->flags |= IOMAP_F_BOUNDARY; | 789 | iomap->flags |= IOMAP_F_BOUNDARY; |
| 788 | iomap->length = (u64)len << inode->i_blkbits; | 790 | iomap->length = (u64)len << inode->i_blkbits; |
| 789 | 791 | ||
| 790 | ret = 0; | ||
| 791 | |||
| 792 | out_release: | 792 | out_release: |
| 793 | release_metapath(&mp); | 793 | release_metapath(&mp); |
| 794 | bmap_unlock(ip, 0); | 794 | bmap_unlock(ip, flags & IOMAP_WRITE); |
| 795 | out: | 795 | out: |
| 796 | trace_gfs2_iomap_end(ip, iomap, ret); | 796 | trace_gfs2_iomap_end(ip, iomap, ret); |
| 797 | return ret; | 797 | return ret; |
| 798 | 798 | ||
| 799 | do_alloc: | 799 | do_alloc: |
| 800 | if (!(flags & IOMAP_WRITE)) { | 800 | if (flags & IOMAP_WRITE) { |
| 801 | if (pos >= i_size_read(inode)) { | 801 | ret = gfs2_iomap_alloc(inode, iomap, flags, &mp); |
| 802 | } else if (flags & IOMAP_REPORT) { | ||
| 803 | loff_t size = i_size_read(inode); | ||
| 804 | if (pos >= size) | ||
| 802 | ret = -ENOENT; | 805 | ret = -ENOENT; |
| 803 | goto out_release; | 806 | else if (height <= ip->i_height) |
| 804 | } | 807 | iomap->length = hole_size(inode, lblock, &mp); |
| 805 | ret = 0; | 808 | else |
| 806 | iomap->length = hole_size(inode, lblock, &mp); | 809 | iomap->length = size - pos; |
| 807 | goto out_release; | 810 | } else { |
| 811 | if (height <= ip->i_height) | ||
| 812 | iomap->length = hole_size(inode, lblock, &mp); | ||
| 808 | } | 813 | } |
| 809 | |||
| 810 | ret = gfs2_iomap_alloc(inode, iomap, flags, &mp); | ||
| 811 | goto out_release; | 814 | goto out_release; |
| 812 | } | 815 | } |
| 813 | 816 | ||
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index e8a93bc8285d..d1e82761de81 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
| @@ -510,6 +510,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
| 510 | /* we have to zero-fill user buffer even if no read */ | 510 | /* we have to zero-fill user buffer even if no read */ |
| 511 | if (copy_to_user(buffer, buf, tsz)) | 511 | if (copy_to_user(buffer, buf, tsz)) |
| 512 | return -EFAULT; | 512 | return -EFAULT; |
| 513 | } else if (m->type == KCORE_USER) { | ||
| 514 | /* User page is handled prior to normal kernel page: */ | ||
| 515 | if (copy_to_user(buffer, (char *)start, tsz)) | ||
| 516 | return -EFAULT; | ||
| 513 | } else { | 517 | } else { |
| 514 | if (kern_addr_valid(start)) { | 518 | if (kern_addr_valid(start)) { |
| 515 | /* | 519 | /* |
diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h index bc397573c43a..67ab280ad134 100644 --- a/include/asm-generic/bitops/lock.h +++ b/include/asm-generic/bitops/lock.h | |||
| @@ -7,7 +7,8 @@ | |||
| 7 | * @nr: Bit to set | 7 | * @nr: Bit to set |
| 8 | * @addr: Address to count from | 8 | * @addr: Address to count from |
| 9 | * | 9 | * |
| 10 | * This operation is atomic and provides acquire barrier semantics. | 10 | * This operation is atomic and provides acquire barrier semantics if |
| 11 | * the returned value is 0. | ||
| 11 | * It can be used to implement bit locks. | 12 | * It can be used to implement bit locks. |
| 12 | */ | 13 | */ |
| 13 | #define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) | 14 | #define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 64e10746f282..968173ec2726 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -587,7 +587,7 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), | |||
| 587 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, | 587 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, |
| 588 | const struct device *dev); | 588 | const struct device *dev); |
| 589 | 589 | ||
| 590 | void *acpi_get_match_data(const struct device *dev); | 590 | const void *acpi_device_get_match_data(const struct device *dev); |
| 591 | extern bool acpi_driver_match_device(struct device *dev, | 591 | extern bool acpi_driver_match_device(struct device *dev, |
| 592 | const struct device_driver *drv); | 592 | const struct device_driver *drv); |
| 593 | int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); | 593 | int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); |
| @@ -766,7 +766,7 @@ static inline const struct acpi_device_id *acpi_match_device( | |||
| 766 | return NULL; | 766 | return NULL; |
| 767 | } | 767 | } |
| 768 | 768 | ||
| 769 | static inline void *acpi_get_match_data(const struct device *dev) | 769 | static inline const void *acpi_device_get_match_data(const struct device *dev) |
| 770 | { | 770 | { |
| 771 | return NULL; | 771 | return NULL; |
| 772 | } | 772 | } |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 4f3df807cf8f..ed63f3b69c12 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -49,7 +49,7 @@ struct blk_stat_callback; | |||
| 49 | #define BLKDEV_MIN_RQ 4 | 49 | #define BLKDEV_MIN_RQ 4 |
| 50 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ | 50 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ |
| 51 | 51 | ||
| 52 | /* Must be consisitent with blk_mq_poll_stats_bkt() */ | 52 | /* Must be consistent with blk_mq_poll_stats_bkt() */ |
| 53 | #define BLK_MQ_POLL_STATS_BKTS 16 | 53 | #define BLK_MQ_POLL_STATS_BKTS 16 |
| 54 | 54 | ||
| 55 | /* | 55 | /* |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 631354acfa72..73bc63e0a1c4 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
| @@ -167,8 +167,6 @@ | |||
| 167 | 167 | ||
| 168 | #if GCC_VERSION >= 40100 | 168 | #if GCC_VERSION >= 40100 |
| 169 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | 169 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
| 170 | |||
| 171 | #define __nostackprotector __attribute__((__optimize__("no-stack-protector"))) | ||
| 172 | #endif | 170 | #endif |
| 173 | 171 | ||
| 174 | #if GCC_VERSION >= 40300 | 172 | #if GCC_VERSION >= 40300 |
| @@ -196,6 +194,11 @@ | |||
| 196 | #endif /* __CHECKER__ */ | 194 | #endif /* __CHECKER__ */ |
| 197 | #endif /* GCC_VERSION >= 40300 */ | 195 | #endif /* GCC_VERSION >= 40300 */ |
| 198 | 196 | ||
| 197 | #if GCC_VERSION >= 40400 | ||
| 198 | #define __optimize(level) __attribute__((__optimize__(level))) | ||
| 199 | #define __nostackprotector __optimize("no-stack-protector") | ||
| 200 | #endif /* GCC_VERSION >= 40400 */ | ||
| 201 | |||
| 199 | #if GCC_VERSION >= 40500 | 202 | #if GCC_VERSION >= 40500 |
| 200 | 203 | ||
| 201 | #ifndef __CHECKER__ | 204 | #ifndef __CHECKER__ |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index c2cc57a2f508..e835fc0423ec 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
| @@ -277,6 +277,10 @@ unsigned long read_word_at_a_time(const void *addr) | |||
| 277 | 277 | ||
| 278 | #endif /* __ASSEMBLY__ */ | 278 | #endif /* __ASSEMBLY__ */ |
| 279 | 279 | ||
| 280 | #ifndef __optimize | ||
| 281 | # define __optimize(level) | ||
| 282 | #endif | ||
| 283 | |||
| 280 | /* Compile time object size, -1 for unknown */ | 284 | /* Compile time object size, -1 for unknown */ |
| 281 | #ifndef __compiletime_object_size | 285 | #ifndef __compiletime_object_size |
| 282 | # define __compiletime_object_size(obj) -1 | 286 | # define __compiletime_object_size(obj) -1 |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 871f9e21810c..0b3fc229086c 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
| @@ -225,7 +225,7 @@ static inline void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, | |||
| 225 | } | 225 | } |
| 226 | #endif | 226 | #endif |
| 227 | 227 | ||
| 228 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX | 228 | #if defined(CONFIG_CPU_IDLE) && defined(CONFIG_ARCH_HAS_CPU_RELAX) |
| 229 | void cpuidle_poll_state_init(struct cpuidle_driver *drv); | 229 | void cpuidle_poll_state_init(struct cpuidle_driver *drv); |
| 230 | #else | 230 | #else |
| 231 | static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {} | 231 | static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {} |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index d4a2a7dcd72d..bf53d893ad02 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
| @@ -170,6 +170,8 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) | |||
| 170 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) | 170 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) |
| 171 | #define for_each_cpu_not(cpu, mask) \ | 171 | #define for_each_cpu_not(cpu, mask) \ |
| 172 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) | 172 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) |
| 173 | #define for_each_cpu_wrap(cpu, mask, start) \ | ||
| 174 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)(start)) | ||
| 173 | #define for_each_cpu_and(cpu, mask, and) \ | 175 | #define for_each_cpu_and(cpu, mask, and) \ |
| 174 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and) | 176 | for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and) |
| 175 | #else | 177 | #else |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 34fe8463d10e..eb9eab4ecd6d 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
| @@ -578,7 +578,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
| 578 | 578 | ||
| 579 | /* | 579 | /* |
| 580 | * This is a hack for the legacy x86 forbid_dac and iommu_sac_force. Please | 580 | * This is a hack for the legacy x86 forbid_dac and iommu_sac_force. Please |
| 581 | * don't use this is new code. | 581 | * don't use this in new code. |
| 582 | */ | 582 | */ |
| 583 | #ifndef arch_dma_supported | 583 | #ifndef arch_dma_supported |
| 584 | #define arch_dma_supported(dev, mask) (1) | 584 | #define arch_dma_supported(dev, mask) (1) |
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 4fa1a489efe4..4fe8f289b3f6 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h | |||
| @@ -73,8 +73,8 @@ struct fwnode_operations { | |||
| 73 | struct fwnode_handle *(*get)(struct fwnode_handle *fwnode); | 73 | struct fwnode_handle *(*get)(struct fwnode_handle *fwnode); |
| 74 | void (*put)(struct fwnode_handle *fwnode); | 74 | void (*put)(struct fwnode_handle *fwnode); |
| 75 | bool (*device_is_available)(const struct fwnode_handle *fwnode); | 75 | bool (*device_is_available)(const struct fwnode_handle *fwnode); |
| 76 | void *(*device_get_match_data)(const struct fwnode_handle *fwnode, | 76 | const void *(*device_get_match_data)(const struct fwnode_handle *fwnode, |
| 77 | const struct device *dev); | 77 | const struct device *dev); |
| 78 | bool (*property_present)(const struct fwnode_handle *fwnode, | 78 | bool (*property_present)(const struct fwnode_handle *fwnode, |
| 79 | const char *propname); | 79 | const char *propname); |
| 80 | int (*property_read_int_array)(const struct fwnode_handle *fwnode, | 80 | int (*property_read_int_array)(const struct fwnode_handle *fwnode, |
diff --git a/include/linux/kcore.h b/include/linux/kcore.h index 7ff25a808fef..80db19d3a505 100644 --- a/include/linux/kcore.h +++ b/include/linux/kcore.h | |||
| @@ -10,6 +10,7 @@ enum kcore_type { | |||
| 10 | KCORE_VMALLOC, | 10 | KCORE_VMALLOC, |
| 11 | KCORE_RAM, | 11 | KCORE_RAM, |
| 12 | KCORE_VMEMMAP, | 12 | KCORE_VMEMMAP, |
| 13 | KCORE_USER, | ||
| 13 | KCORE_OTHER, | 14 | KCORE_OTHER, |
| 14 | }; | 15 | }; |
| 15 | 16 | ||
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index c30b32e3c862..10191c28fc04 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h | |||
| @@ -127,10 +127,4 @@ static __always_inline enum lru_list page_lru(struct page *page) | |||
| 127 | 127 | ||
| 128 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) | 128 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) |
| 129 | 129 | ||
| 130 | #ifdef arch_unmap_kpfn | ||
| 131 | extern void arch_unmap_kpfn(unsigned long pfn); | ||
| 132 | #else | ||
| 133 | static __always_inline void arch_unmap_kpfn(unsigned long pfn) { } | ||
| 134 | #endif | ||
| 135 | |||
| 136 | #endif | 130 | #endif |
diff --git a/include/linux/nospec.h b/include/linux/nospec.h index b99bced39ac2..fbc98e2c8228 100644 --- a/include/linux/nospec.h +++ b/include/linux/nospec.h | |||
| @@ -20,20 +20,6 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, | |||
| 20 | unsigned long size) | 20 | unsigned long size) |
| 21 | { | 21 | { |
| 22 | /* | 22 | /* |
| 23 | * Warn developers about inappropriate array_index_nospec() usage. | ||
| 24 | * | ||
| 25 | * Even if the CPU speculates past the WARN_ONCE branch, the | ||
| 26 | * sign bit of @index is taken into account when generating the | ||
| 27 | * mask. | ||
| 28 | * | ||
| 29 | * This warning is compiled out when the compiler can infer that | ||
| 30 | * @index and @size are less than LONG_MAX. | ||
| 31 | */ | ||
| 32 | if (WARN_ONCE(index > LONG_MAX || size > LONG_MAX, | ||
| 33 | "array_index_nospec() limited to range of [0, LONG_MAX]\n")) | ||
| 34 | return 0; | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Always calculate and emit the mask even if the compiler | 23 | * Always calculate and emit the mask even if the compiler |
| 38 | * thinks the mask is not needed. The compiler does not take | 24 | * thinks the mask is not needed. The compiler does not take |
| 39 | * into account the value of @index under speculation. | 25 | * into account the value of @index under speculation. |
| @@ -44,6 +30,26 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, | |||
| 44 | #endif | 30 | #endif |
| 45 | 31 | ||
| 46 | /* | 32 | /* |
| 33 | * Warn developers about inappropriate array_index_nospec() usage. | ||
| 34 | * | ||
| 35 | * Even if the CPU speculates past the WARN_ONCE branch, the | ||
| 36 | * sign bit of @index is taken into account when generating the | ||
| 37 | * mask. | ||
| 38 | * | ||
| 39 | * This warning is compiled out when the compiler can infer that | ||
| 40 | * @index and @size are less than LONG_MAX. | ||
| 41 | */ | ||
| 42 | #define array_index_mask_nospec_check(index, size) \ | ||
| 43 | ({ \ | ||
| 44 | if (WARN_ONCE(index > LONG_MAX || size > LONG_MAX, \ | ||
| 45 | "array_index_nospec() limited to range of [0, LONG_MAX]\n")) \ | ||
| 46 | _mask = 0; \ | ||
| 47 | else \ | ||
| 48 | _mask = array_index_mask_nospec(index, size); \ | ||
| 49 | _mask; \ | ||
| 50 | }) | ||
| 51 | |||
| 52 | /* | ||
| 47 | * array_index_nospec - sanitize an array index after a bounds check | 53 | * array_index_nospec - sanitize an array index after a bounds check |
| 48 | * | 54 | * |
| 49 | * For a code sequence like: | 55 | * For a code sequence like: |
| @@ -61,7 +67,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, | |||
| 61 | ({ \ | 67 | ({ \ |
| 62 | typeof(index) _i = (index); \ | 68 | typeof(index) _i = (index); \ |
| 63 | typeof(size) _s = (size); \ | 69 | typeof(size) _s = (size); \ |
| 64 | unsigned long _mask = array_index_mask_nospec(_i, _s); \ | 70 | unsigned long _mask = array_index_mask_nospec_check(_i, _s); \ |
| 65 | \ | 71 | \ |
| 66 | BUILD_BUG_ON(sizeof(_i) > sizeof(long)); \ | 72 | BUILD_BUG_ON(sizeof(_i) > sizeof(long)); \ |
| 67 | BUILD_BUG_ON(sizeof(_s) > sizeof(long)); \ | 73 | BUILD_BUG_ON(sizeof(_s) > sizeof(long)); \ |
diff --git a/include/linux/property.h b/include/linux/property.h index 769d372c1edf..2eea4b310fc2 100644 --- a/include/linux/property.h +++ b/include/linux/property.h | |||
| @@ -283,7 +283,7 @@ bool device_dma_supported(struct device *dev); | |||
| 283 | 283 | ||
| 284 | enum dev_dma_attr device_get_dma_attr(struct device *dev); | 284 | enum dev_dma_attr device_get_dma_attr(struct device *dev); |
| 285 | 285 | ||
| 286 | void *device_get_match_data(struct device *dev); | 286 | const void *device_get_match_data(struct device *dev); |
| 287 | 287 | ||
| 288 | int device_get_phy_mode(struct device *dev); | 288 | int device_get_phy_mode(struct device *dev); |
| 289 | 289 | ||
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h index dc368b8ce215..11c86fbfeb98 100644 --- a/include/linux/semaphore.h +++ b/include/linux/semaphore.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * | 4 | * |
| 5 | * Distributed under the terms of the GNU GPL, version 2 | 5 | * Distributed under the terms of the GNU GPL, version 2 |
| 6 | * | 6 | * |
| 7 | * Please see kernel/semaphore.c for documentation of these functions | 7 | * Please see kernel/locking/semaphore.c for documentation of these functions |
| 8 | */ | 8 | */ |
| 9 | #ifndef __LINUX_SEMAPHORE_H | 9 | #ifndef __LINUX_SEMAPHORE_H |
| 10 | #define __LINUX_SEMAPHORE_H | 10 | #define __LINUX_SEMAPHORE_H |
diff --git a/include/sound/ac97/regs.h b/include/sound/ac97/regs.h index 4bb86d379bd5..9a4fa0c3264a 100644 --- a/include/sound/ac97/regs.h +++ b/include/sound/ac97/regs.h | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #define AC97_HEADPHONE 0x04 /* Headphone Volume (optional) */ | 31 | #define AC97_HEADPHONE 0x04 /* Headphone Volume (optional) */ |
| 32 | #define AC97_MASTER_MONO 0x06 /* Master Volume Mono (optional) */ | 32 | #define AC97_MASTER_MONO 0x06 /* Master Volume Mono (optional) */ |
| 33 | #define AC97_MASTER_TONE 0x08 /* Master Tone (Bass & Treble) (optional) */ | 33 | #define AC97_MASTER_TONE 0x08 /* Master Tone (Bass & Treble) (optional) */ |
| 34 | #define AC97_PC_BEEP 0x0a /* PC Beep Volume (optinal) */ | 34 | #define AC97_PC_BEEP 0x0a /* PC Beep Volume (optional) */ |
| 35 | #define AC97_PHONE 0x0c /* Phone Volume (optional) */ | 35 | #define AC97_PHONE 0x0c /* Phone Volume (optional) */ |
| 36 | #define AC97_MIC 0x0e /* MIC Volume */ | 36 | #define AC97_MIC 0x0e /* MIC Volume */ |
| 37 | #define AC97_LINE 0x10 /* Line In Volume */ | 37 | #define AC97_LINE 0x10 /* Line In Volume */ |
diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h index b8adf05c534e..7dd8f34c37df 100644 --- a/include/trace/events/xen.h +++ b/include/trace/events/xen.h | |||
| @@ -368,7 +368,7 @@ TRACE_EVENT(xen_mmu_flush_tlb, | |||
| 368 | TP_printk("%s", "") | 368 | TP_printk("%s", "") |
| 369 | ); | 369 | ); |
| 370 | 370 | ||
| 371 | TRACE_EVENT(xen_mmu_flush_tlb_single, | 371 | TRACE_EVENT(xen_mmu_flush_tlb_one_user, |
| 372 | TP_PROTO(unsigned long addr), | 372 | TP_PROTO(unsigned long addr), |
| 373 | TP_ARGS(addr), | 373 | TP_ARGS(addr), |
| 374 | TP_STRUCT__entry( | 374 | TP_STRUCT__entry( |
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index e6a9c36470ee..82b8b18ee1eb 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
| @@ -1726,25 +1726,14 @@ static int irq_domain_debug_show(struct seq_file *m, void *p) | |||
| 1726 | irq_domain_debug_show_one(m, d, 0); | 1726 | irq_domain_debug_show_one(m, d, 0); |
| 1727 | return 0; | 1727 | return 0; |
| 1728 | } | 1728 | } |
| 1729 | 1729 | DEFINE_SHOW_ATTRIBUTE(irq_domain_debug); | |
| 1730 | static int irq_domain_debug_open(struct inode *inode, struct file *file) | ||
| 1731 | { | ||
| 1732 | return single_open(file, irq_domain_debug_show, inode->i_private); | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | static const struct file_operations dfs_domain_ops = { | ||
| 1736 | .open = irq_domain_debug_open, | ||
| 1737 | .read = seq_read, | ||
| 1738 | .llseek = seq_lseek, | ||
| 1739 | .release = single_release, | ||
| 1740 | }; | ||
| 1741 | 1730 | ||
| 1742 | static void debugfs_add_domain_dir(struct irq_domain *d) | 1731 | static void debugfs_add_domain_dir(struct irq_domain *d) |
| 1743 | { | 1732 | { |
| 1744 | if (!d->name || !domain_dir || d->debugfs_file) | 1733 | if (!d->name || !domain_dir || d->debugfs_file) |
| 1745 | return; | 1734 | return; |
| 1746 | d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d, | 1735 | d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d, |
| 1747 | &dfs_domain_ops); | 1736 | &irq_domain_debug_fops); |
| 1748 | } | 1737 | } |
| 1749 | 1738 | ||
| 1750 | static void debugfs_remove_domain_dir(struct irq_domain *d) | 1739 | static void debugfs_remove_domain_dir(struct irq_domain *d) |
| @@ -1760,7 +1749,8 @@ void __init irq_domain_debugfs_init(struct dentry *root) | |||
| 1760 | if (!domain_dir) | 1749 | if (!domain_dir) |
| 1761 | return; | 1750 | return; |
| 1762 | 1751 | ||
| 1763 | debugfs_create_file("default", 0444, domain_dir, NULL, &dfs_domain_ops); | 1752 | debugfs_create_file("default", 0444, domain_dir, NULL, |
| 1753 | &irq_domain_debug_fops); | ||
| 1764 | mutex_lock(&irq_domain_mutex); | 1754 | mutex_lock(&irq_domain_mutex); |
| 1765 | list_for_each_entry(d, &irq_domain_list, link) | 1755 | list_for_each_entry(d, &irq_domain_list, link) |
| 1766 | debugfs_add_domain_dir(d); | 1756 | debugfs_add_domain_dir(d); |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index da2ccf142358..102160ff5c66 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -978,67 +978,90 @@ static int prepare_kprobe(struct kprobe *p) | |||
| 978 | } | 978 | } |
| 979 | 979 | ||
| 980 | /* Caller must lock kprobe_mutex */ | 980 | /* Caller must lock kprobe_mutex */ |
| 981 | static void arm_kprobe_ftrace(struct kprobe *p) | 981 | static int arm_kprobe_ftrace(struct kprobe *p) |
| 982 | { | 982 | { |
| 983 | int ret; | 983 | int ret = 0; |
| 984 | 984 | ||
| 985 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, | 985 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, |
| 986 | (unsigned long)p->addr, 0, 0); | 986 | (unsigned long)p->addr, 0, 0); |
| 987 | WARN(ret < 0, "Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret); | 987 | if (ret) { |
| 988 | kprobe_ftrace_enabled++; | 988 | pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret); |
| 989 | if (kprobe_ftrace_enabled == 1) { | 989 | return ret; |
| 990 | } | ||
| 991 | |||
| 992 | if (kprobe_ftrace_enabled == 0) { | ||
| 990 | ret = register_ftrace_function(&kprobe_ftrace_ops); | 993 | ret = register_ftrace_function(&kprobe_ftrace_ops); |
| 991 | WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret); | 994 | if (ret) { |
| 995 | pr_debug("Failed to init kprobe-ftrace (%d)\n", ret); | ||
| 996 | goto err_ftrace; | ||
| 997 | } | ||
| 992 | } | 998 | } |
| 999 | |||
| 1000 | kprobe_ftrace_enabled++; | ||
| 1001 | return ret; | ||
| 1002 | |||
| 1003 | err_ftrace: | ||
| 1004 | /* | ||
| 1005 | * Note: Since kprobe_ftrace_ops has IPMODIFY set, and ftrace requires a | ||
| 1006 | * non-empty filter_hash for IPMODIFY ops, we're safe from an accidental | ||
| 1007 | * empty filter_hash which would undesirably trace all functions. | ||
| 1008 | */ | ||
| 1009 | ftrace_set_filter_ip(&kprobe_ftrace_ops, (unsigned long)p->addr, 1, 0); | ||
| 1010 | return ret; | ||
| 993 | } | 1011 | } |
| 994 | 1012 | ||
| 995 | /* Caller must lock kprobe_mutex */ | 1013 | /* Caller must lock kprobe_mutex */ |
| 996 | static void disarm_kprobe_ftrace(struct kprobe *p) | 1014 | static int disarm_kprobe_ftrace(struct kprobe *p) |
| 997 | { | 1015 | { |
| 998 | int ret; | 1016 | int ret = 0; |
| 999 | 1017 | ||
| 1000 | kprobe_ftrace_enabled--; | 1018 | if (kprobe_ftrace_enabled == 1) { |
| 1001 | if (kprobe_ftrace_enabled == 0) { | ||
| 1002 | ret = unregister_ftrace_function(&kprobe_ftrace_ops); | 1019 | ret = unregister_ftrace_function(&kprobe_ftrace_ops); |
| 1003 | WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret); | 1020 | if (WARN(ret < 0, "Failed to unregister kprobe-ftrace (%d)\n", ret)) |
| 1021 | return ret; | ||
| 1004 | } | 1022 | } |
| 1023 | |||
| 1024 | kprobe_ftrace_enabled--; | ||
| 1025 | |||
| 1005 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, | 1026 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, |
| 1006 | (unsigned long)p->addr, 1, 0); | 1027 | (unsigned long)p->addr, 1, 0); |
| 1007 | WARN(ret < 0, "Failed to disarm kprobe-ftrace at %p (%d)\n", p->addr, ret); | 1028 | WARN(ret < 0, "Failed to disarm kprobe-ftrace at %p (%d)\n", p->addr, ret); |
| 1029 | return ret; | ||
| 1008 | } | 1030 | } |
| 1009 | #else /* !CONFIG_KPROBES_ON_FTRACE */ | 1031 | #else /* !CONFIG_KPROBES_ON_FTRACE */ |
| 1010 | #define prepare_kprobe(p) arch_prepare_kprobe(p) | 1032 | #define prepare_kprobe(p) arch_prepare_kprobe(p) |
| 1011 | #define arm_kprobe_ftrace(p) do {} while (0) | 1033 | #define arm_kprobe_ftrace(p) (-ENODEV) |
| 1012 | #define disarm_kprobe_ftrace(p) do {} while (0) | 1034 | #define disarm_kprobe_ftrace(p) (-ENODEV) |
| 1013 | #endif | 1035 | #endif |
| 1014 | 1036 | ||
| 1015 | /* Arm a kprobe with text_mutex */ | 1037 | /* Arm a kprobe with text_mutex */ |
| 1016 | static void arm_kprobe(struct kprobe *kp) | 1038 | static int arm_kprobe(struct kprobe *kp) |
| 1017 | { | 1039 | { |
| 1018 | if (unlikely(kprobe_ftrace(kp))) { | 1040 | if (unlikely(kprobe_ftrace(kp))) |
| 1019 | arm_kprobe_ftrace(kp); | 1041 | return arm_kprobe_ftrace(kp); |
| 1020 | return; | 1042 | |
| 1021 | } | ||
| 1022 | cpus_read_lock(); | 1043 | cpus_read_lock(); |
| 1023 | mutex_lock(&text_mutex); | 1044 | mutex_lock(&text_mutex); |
| 1024 | __arm_kprobe(kp); | 1045 | __arm_kprobe(kp); |
| 1025 | mutex_unlock(&text_mutex); | 1046 | mutex_unlock(&text_mutex); |
| 1026 | cpus_read_unlock(); | 1047 | cpus_read_unlock(); |
| 1048 | |||
| 1049 | return 0; | ||
| 1027 | } | 1050 | } |
| 1028 | 1051 | ||
| 1029 | /* Disarm a kprobe with text_mutex */ | 1052 | /* Disarm a kprobe with text_mutex */ |
| 1030 | static void disarm_kprobe(struct kprobe *kp, bool reopt) | 1053 | static int disarm_kprobe(struct kprobe *kp, bool reopt) |
| 1031 | { | 1054 | { |
| 1032 | if (unlikely(kprobe_ftrace(kp))) { | 1055 | if (unlikely(kprobe_ftrace(kp))) |
| 1033 | disarm_kprobe_ftrace(kp); | 1056 | return disarm_kprobe_ftrace(kp); |
| 1034 | return; | ||
| 1035 | } | ||
| 1036 | 1057 | ||
| 1037 | cpus_read_lock(); | 1058 | cpus_read_lock(); |
| 1038 | mutex_lock(&text_mutex); | 1059 | mutex_lock(&text_mutex); |
| 1039 | __disarm_kprobe(kp, reopt); | 1060 | __disarm_kprobe(kp, reopt); |
| 1040 | mutex_unlock(&text_mutex); | 1061 | mutex_unlock(&text_mutex); |
| 1041 | cpus_read_unlock(); | 1062 | cpus_read_unlock(); |
| 1063 | |||
| 1064 | return 0; | ||
| 1042 | } | 1065 | } |
| 1043 | 1066 | ||
| 1044 | /* | 1067 | /* |
| @@ -1362,9 +1385,15 @@ out: | |||
| 1362 | 1385 | ||
| 1363 | if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) { | 1386 | if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) { |
| 1364 | ap->flags &= ~KPROBE_FLAG_DISABLED; | 1387 | ap->flags &= ~KPROBE_FLAG_DISABLED; |
| 1365 | if (!kprobes_all_disarmed) | 1388 | if (!kprobes_all_disarmed) { |
| 1366 | /* Arm the breakpoint again. */ | 1389 | /* Arm the breakpoint again. */ |
| 1367 | arm_kprobe(ap); | 1390 | ret = arm_kprobe(ap); |
| 1391 | if (ret) { | ||
| 1392 | ap->flags |= KPROBE_FLAG_DISABLED; | ||
| 1393 | list_del_rcu(&p->list); | ||
| 1394 | synchronize_sched(); | ||
| 1395 | } | ||
| 1396 | } | ||
| 1368 | } | 1397 | } |
| 1369 | return ret; | 1398 | return ret; |
| 1370 | } | 1399 | } |
| @@ -1573,8 +1602,14 @@ int register_kprobe(struct kprobe *p) | |||
| 1573 | hlist_add_head_rcu(&p->hlist, | 1602 | hlist_add_head_rcu(&p->hlist, |
| 1574 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); | 1603 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); |
| 1575 | 1604 | ||
| 1576 | if (!kprobes_all_disarmed && !kprobe_disabled(p)) | 1605 | if (!kprobes_all_disarmed && !kprobe_disabled(p)) { |
| 1577 | arm_kprobe(p); | 1606 | ret = arm_kprobe(p); |
| 1607 | if (ret) { | ||
| 1608 | hlist_del_rcu(&p->hlist); | ||
| 1609 | synchronize_sched(); | ||
| 1610 | goto out; | ||
| 1611 | } | ||
| 1612 | } | ||
| 1578 | 1613 | ||
| 1579 | /* Try to optimize kprobe */ | 1614 | /* Try to optimize kprobe */ |
| 1580 | try_to_optimize_kprobe(p); | 1615 | try_to_optimize_kprobe(p); |
| @@ -1608,11 +1643,12 @@ static int aggr_kprobe_disabled(struct kprobe *ap) | |||
| 1608 | static struct kprobe *__disable_kprobe(struct kprobe *p) | 1643 | static struct kprobe *__disable_kprobe(struct kprobe *p) |
| 1609 | { | 1644 | { |
| 1610 | struct kprobe *orig_p; | 1645 | struct kprobe *orig_p; |
| 1646 | int ret; | ||
| 1611 | 1647 | ||
| 1612 | /* Get an original kprobe for return */ | 1648 | /* Get an original kprobe for return */ |
| 1613 | orig_p = __get_valid_kprobe(p); | 1649 | orig_p = __get_valid_kprobe(p); |
| 1614 | if (unlikely(orig_p == NULL)) | 1650 | if (unlikely(orig_p == NULL)) |
| 1615 | return NULL; | 1651 | return ERR_PTR(-EINVAL); |
| 1616 | 1652 | ||
| 1617 | if (!kprobe_disabled(p)) { | 1653 | if (!kprobe_disabled(p)) { |
| 1618 | /* Disable probe if it is a child probe */ | 1654 | /* Disable probe if it is a child probe */ |
| @@ -1626,8 +1662,13 @@ static struct kprobe *__disable_kprobe(struct kprobe *p) | |||
| 1626 | * should have already been disarmed, so | 1662 | * should have already been disarmed, so |
| 1627 | * skip unneed disarming process. | 1663 | * skip unneed disarming process. |
| 1628 | */ | 1664 | */ |
| 1629 | if (!kprobes_all_disarmed) | 1665 | if (!kprobes_all_disarmed) { |
| 1630 | disarm_kprobe(orig_p, true); | 1666 | ret = disarm_kprobe(orig_p, true); |
| 1667 | if (ret) { | ||
| 1668 | p->flags &= ~KPROBE_FLAG_DISABLED; | ||
| 1669 | return ERR_PTR(ret); | ||
| 1670 | } | ||
| 1671 | } | ||
| 1631 | orig_p->flags |= KPROBE_FLAG_DISABLED; | 1672 | orig_p->flags |= KPROBE_FLAG_DISABLED; |
| 1632 | } | 1673 | } |
| 1633 | } | 1674 | } |
| @@ -1644,8 +1685,8 @@ static int __unregister_kprobe_top(struct kprobe *p) | |||
| 1644 | 1685 | ||
| 1645 | /* Disable kprobe. This will disarm it if needed. */ | 1686 | /* Disable kprobe. This will disarm it if needed. */ |
| 1646 | ap = __disable_kprobe(p); | 1687 | ap = __disable_kprobe(p); |
| 1647 | if (ap == NULL) | 1688 | if (IS_ERR(ap)) |
| 1648 | return -EINVAL; | 1689 | return PTR_ERR(ap); |
| 1649 | 1690 | ||
| 1650 | if (ap == p) | 1691 | if (ap == p) |
| 1651 | /* | 1692 | /* |
| @@ -2078,12 +2119,14 @@ static void kill_kprobe(struct kprobe *p) | |||
| 2078 | int disable_kprobe(struct kprobe *kp) | 2119 | int disable_kprobe(struct kprobe *kp) |
| 2079 | { | 2120 | { |
| 2080 | int ret = 0; | 2121 | int ret = 0; |
| 2122 | struct kprobe *p; | ||
| 2081 | 2123 | ||
| 2082 | mutex_lock(&kprobe_mutex); | 2124 | mutex_lock(&kprobe_mutex); |
| 2083 | 2125 | ||
| 2084 | /* Disable this kprobe */ | 2126 | /* Disable this kprobe */ |
| 2085 | if (__disable_kprobe(kp) == NULL) | 2127 | p = __disable_kprobe(kp); |
| 2086 | ret = -EINVAL; | 2128 | if (IS_ERR(p)) |
| 2129 | ret = PTR_ERR(p); | ||
| 2087 | 2130 | ||
| 2088 | mutex_unlock(&kprobe_mutex); | 2131 | mutex_unlock(&kprobe_mutex); |
| 2089 | return ret; | 2132 | return ret; |
| @@ -2116,7 +2159,9 @@ int enable_kprobe(struct kprobe *kp) | |||
| 2116 | 2159 | ||
| 2117 | if (!kprobes_all_disarmed && kprobe_disabled(p)) { | 2160 | if (!kprobes_all_disarmed && kprobe_disabled(p)) { |
| 2118 | p->flags &= ~KPROBE_FLAG_DISABLED; | 2161 | p->flags &= ~KPROBE_FLAG_DISABLED; |
| 2119 | arm_kprobe(p); | 2162 | ret = arm_kprobe(p); |
| 2163 | if (ret) | ||
| 2164 | p->flags |= KPROBE_FLAG_DISABLED; | ||
| 2120 | } | 2165 | } |
| 2121 | out: | 2166 | out: |
| 2122 | mutex_unlock(&kprobe_mutex); | 2167 | mutex_unlock(&kprobe_mutex); |
| @@ -2407,11 +2452,12 @@ static const struct file_operations debugfs_kprobe_blacklist_ops = { | |||
| 2407 | .release = seq_release, | 2452 | .release = seq_release, |
| 2408 | }; | 2453 | }; |
| 2409 | 2454 | ||
| 2410 | static void arm_all_kprobes(void) | 2455 | static int arm_all_kprobes(void) |
| 2411 | { | 2456 | { |
| 2412 | struct hlist_head *head; | 2457 | struct hlist_head *head; |
| 2413 | struct kprobe *p; | 2458 | struct kprobe *p; |
| 2414 | unsigned int i; | 2459 | unsigned int i, total = 0, errors = 0; |
| 2460 | int err, ret = 0; | ||
| 2415 | 2461 | ||
| 2416 | mutex_lock(&kprobe_mutex); | 2462 | mutex_lock(&kprobe_mutex); |
| 2417 | 2463 | ||
| @@ -2428,46 +2474,74 @@ static void arm_all_kprobes(void) | |||
| 2428 | /* Arming kprobes doesn't optimize kprobe itself */ | 2474 | /* Arming kprobes doesn't optimize kprobe itself */ |
| 2429 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 2475 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
| 2430 | head = &kprobe_table[i]; | 2476 | head = &kprobe_table[i]; |
| 2431 | hlist_for_each_entry_rcu(p, head, hlist) | 2477 | /* Arm all kprobes on a best-effort basis */ |
| 2432 | if (!kprobe_disabled(p)) | 2478 | hlist_for_each_entry_rcu(p, head, hlist) { |
| 2433 | arm_kprobe(p); | 2479 | if (!kprobe_disabled(p)) { |
| 2480 | err = arm_kprobe(p); | ||
| 2481 | if (err) { | ||
| 2482 | errors++; | ||
| 2483 | ret = err; | ||
| 2484 | } | ||
| 2485 | total++; | ||
| 2486 | } | ||
| 2487 | } | ||
| 2434 | } | 2488 | } |
| 2435 | 2489 | ||
| 2436 | printk(KERN_INFO "Kprobes globally enabled\n"); | 2490 | if (errors) |
| 2491 | pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n", | ||
| 2492 | errors, total); | ||
| 2493 | else | ||
| 2494 | pr_info("Kprobes globally enabled\n"); | ||
| 2437 | 2495 | ||
| 2438 | already_enabled: | 2496 | already_enabled: |
| 2439 | mutex_unlock(&kprobe_mutex); | 2497 | mutex_unlock(&kprobe_mutex); |
| 2440 | return; | 2498 | return ret; |
| 2441 | } | 2499 | } |
| 2442 | 2500 | ||
| 2443 | static void disarm_all_kprobes(void) | 2501 | static int disarm_all_kprobes(void) |
| 2444 | { | 2502 | { |
| 2445 | struct hlist_head *head; | 2503 | struct hlist_head *head; |
| 2446 | struct kprobe *p; | 2504 | struct kprobe *p; |
| 2447 | unsigned int i; | 2505 | unsigned int i, total = 0, errors = 0; |
| 2506 | int err, ret = 0; | ||
| 2448 | 2507 | ||
| 2449 | mutex_lock(&kprobe_mutex); | 2508 | mutex_lock(&kprobe_mutex); |
| 2450 | 2509 | ||
| 2451 | /* If kprobes are already disarmed, just return */ | 2510 | /* If kprobes are already disarmed, just return */ |
| 2452 | if (kprobes_all_disarmed) { | 2511 | if (kprobes_all_disarmed) { |
| 2453 | mutex_unlock(&kprobe_mutex); | 2512 | mutex_unlock(&kprobe_mutex); |
| 2454 | return; | 2513 | return 0; |
| 2455 | } | 2514 | } |
| 2456 | 2515 | ||
| 2457 | kprobes_all_disarmed = true; | 2516 | kprobes_all_disarmed = true; |
| 2458 | printk(KERN_INFO "Kprobes globally disabled\n"); | ||
| 2459 | 2517 | ||
| 2460 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 2518 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
| 2461 | head = &kprobe_table[i]; | 2519 | head = &kprobe_table[i]; |
| 2520 | /* Disarm all kprobes on a best-effort basis */ | ||
| 2462 | hlist_for_each_entry_rcu(p, head, hlist) { | 2521 | hlist_for_each_entry_rcu(p, head, hlist) { |
| 2463 | if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) | 2522 | if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) { |
| 2464 | disarm_kprobe(p, false); | 2523 | err = disarm_kprobe(p, false); |
| 2524 | if (err) { | ||
| 2525 | errors++; | ||
| 2526 | ret = err; | ||
| 2527 | } | ||
| 2528 | total++; | ||
| 2529 | } | ||
| 2465 | } | 2530 | } |
| 2466 | } | 2531 | } |
| 2532 | |||
| 2533 | if (errors) | ||
| 2534 | pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n", | ||
| 2535 | errors, total); | ||
| 2536 | else | ||
| 2537 | pr_info("Kprobes globally disabled\n"); | ||
| 2538 | |||
| 2467 | mutex_unlock(&kprobe_mutex); | 2539 | mutex_unlock(&kprobe_mutex); |
| 2468 | 2540 | ||
| 2469 | /* Wait for disarming all kprobes by optimizer */ | 2541 | /* Wait for disarming all kprobes by optimizer */ |
| 2470 | wait_for_kprobe_optimizer(); | 2542 | wait_for_kprobe_optimizer(); |
| 2543 | |||
| 2544 | return ret; | ||
| 2471 | } | 2545 | } |
| 2472 | 2546 | ||
| 2473 | /* | 2547 | /* |
| @@ -2494,6 +2568,7 @@ static ssize_t write_enabled_file_bool(struct file *file, | |||
| 2494 | { | 2568 | { |
| 2495 | char buf[32]; | 2569 | char buf[32]; |
| 2496 | size_t buf_size; | 2570 | size_t buf_size; |
| 2571 | int ret = 0; | ||
| 2497 | 2572 | ||
| 2498 | buf_size = min(count, (sizeof(buf)-1)); | 2573 | buf_size = min(count, (sizeof(buf)-1)); |
| 2499 | if (copy_from_user(buf, user_buf, buf_size)) | 2574 | if (copy_from_user(buf, user_buf, buf_size)) |
| @@ -2504,17 +2579,20 @@ static ssize_t write_enabled_file_bool(struct file *file, | |||
| 2504 | case 'y': | 2579 | case 'y': |
| 2505 | case 'Y': | 2580 | case 'Y': |
| 2506 | case '1': | 2581 | case '1': |
| 2507 | arm_all_kprobes(); | 2582 | ret = arm_all_kprobes(); |
| 2508 | break; | 2583 | break; |
| 2509 | case 'n': | 2584 | case 'n': |
| 2510 | case 'N': | 2585 | case 'N': |
| 2511 | case '0': | 2586 | case '0': |
| 2512 | disarm_all_kprobes(); | 2587 | ret = disarm_all_kprobes(); |
| 2513 | break; | 2588 | break; |
| 2514 | default: | 2589 | default: |
| 2515 | return -EINVAL; | 2590 | return -EINVAL; |
| 2516 | } | 2591 | } |
| 2517 | 2592 | ||
| 2593 | if (ret) | ||
| 2594 | return ret; | ||
| 2595 | |||
| 2518 | return count; | 2596 | return count; |
| 2519 | } | 2597 | } |
| 2520 | 2598 | ||
diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 38ece035039e..d880296245c5 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c | |||
| @@ -379,6 +379,14 @@ queue: | |||
| 379 | tail = encode_tail(smp_processor_id(), idx); | 379 | tail = encode_tail(smp_processor_id(), idx); |
| 380 | 380 | ||
| 381 | node += idx; | 381 | node += idx; |
| 382 | |||
| 383 | /* | ||
| 384 | * Ensure that we increment the head node->count before initialising | ||
| 385 | * the actual node. If the compiler is kind enough to reorder these | ||
| 386 | * stores, then an IRQ could overwrite our assignments. | ||
| 387 | */ | ||
| 388 | barrier(); | ||
| 389 | |||
| 382 | node->locked = 0; | 390 | node->locked = 0; |
| 383 | node->next = NULL; | 391 | node->next = NULL; |
| 384 | pv_init_node(node); | 392 | pv_init_node(node); |
| @@ -408,14 +416,15 @@ queue: | |||
| 408 | */ | 416 | */ |
| 409 | if (old & _Q_TAIL_MASK) { | 417 | if (old & _Q_TAIL_MASK) { |
| 410 | prev = decode_tail(old); | 418 | prev = decode_tail(old); |
| 419 | |||
| 411 | /* | 420 | /* |
| 412 | * The above xchg_tail() is also a load of @lock which | 421 | * We must ensure that the stores to @node are observed before |
| 413 | * generates, through decode_tail(), a pointer. The address | 422 | * the write to prev->next. The address dependency from |
| 414 | * dependency matches the RELEASE of xchg_tail() such that | 423 | * xchg_tail is not sufficient to ensure this because the read |
| 415 | * the subsequent access to @prev happens after. | 424 | * component of xchg_tail is unordered with respect to the |
| 425 | * initialisation of @node. | ||
| 416 | */ | 426 | */ |
| 417 | 427 | smp_store_release(&prev->next, node); | |
| 418 | WRITE_ONCE(prev->next, node); | ||
| 419 | 428 | ||
| 420 | pv_wait_node(node, prev); | 429 | pv_wait_node(node, prev); |
| 421 | arch_mcs_spin_lock_contended(&node->locked); | 430 | arch_mcs_spin_lock_contended(&node->locked); |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bf724c1952ea..e7c535eee0a6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -2601,19 +2601,31 @@ static inline void finish_task(struct task_struct *prev) | |||
| 2601 | #endif | 2601 | #endif |
| 2602 | } | 2602 | } |
| 2603 | 2603 | ||
| 2604 | static inline void finish_lock_switch(struct rq *rq) | 2604 | static inline void |
| 2605 | prepare_lock_switch(struct rq *rq, struct task_struct *next, struct rq_flags *rf) | ||
| 2605 | { | 2606 | { |
| 2607 | /* | ||
| 2608 | * Since the runqueue lock will be released by the next | ||
| 2609 | * task (which is an invalid locking op but in the case | ||
| 2610 | * of the scheduler it's an obvious special-case), so we | ||
| 2611 | * do an early lockdep release here: | ||
| 2612 | */ | ||
| 2613 | rq_unpin_lock(rq, rf); | ||
| 2614 | spin_release(&rq->lock.dep_map, 1, _THIS_IP_); | ||
| 2606 | #ifdef CONFIG_DEBUG_SPINLOCK | 2615 | #ifdef CONFIG_DEBUG_SPINLOCK |
| 2607 | /* this is a valid case when another task releases the spinlock */ | 2616 | /* this is a valid case when another task releases the spinlock */ |
| 2608 | rq->lock.owner = current; | 2617 | rq->lock.owner = next; |
| 2609 | #endif | 2618 | #endif |
| 2619 | } | ||
| 2620 | |||
| 2621 | static inline void finish_lock_switch(struct rq *rq) | ||
| 2622 | { | ||
| 2610 | /* | 2623 | /* |
| 2611 | * If we are tracking spinlock dependencies then we have to | 2624 | * If we are tracking spinlock dependencies then we have to |
| 2612 | * fix up the runqueue lock - which gets 'carried over' from | 2625 | * fix up the runqueue lock - which gets 'carried over' from |
| 2613 | * prev into current: | 2626 | * prev into current: |
| 2614 | */ | 2627 | */ |
| 2615 | spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_); | 2628 | spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_); |
| 2616 | |||
| 2617 | raw_spin_unlock_irq(&rq->lock); | 2629 | raw_spin_unlock_irq(&rq->lock); |
| 2618 | } | 2630 | } |
| 2619 | 2631 | ||
| @@ -2844,14 +2856,7 @@ context_switch(struct rq *rq, struct task_struct *prev, | |||
| 2844 | 2856 | ||
| 2845 | rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); | 2857 | rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); |
| 2846 | 2858 | ||
| 2847 | /* | 2859 | prepare_lock_switch(rq, next, rf); |
| 2848 | * Since the runqueue lock will be released by the next | ||
| 2849 | * task (which is an invalid locking op but in the case | ||
| 2850 | * of the scheduler it's an obvious special-case), so we | ||
| 2851 | * do an early lockdep release here: | ||
| 2852 | */ | ||
| 2853 | rq_unpin_lock(rq, rf); | ||
| 2854 | spin_release(&rq->lock.dep_map, 1, _THIS_IP_); | ||
| 2855 | 2860 | ||
| 2856 | /* Here we just switch the register state and the stack. */ | 2861 | /* Here we just switch the register state and the stack. */ |
| 2857 | switch_to(prev, next, prev); | 2862 | switch_to(prev, next, prev); |
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index dd062a1c8cf0..7936f548e071 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c | |||
| @@ -19,8 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | #include "sched.h" | 20 | #include "sched.h" |
| 21 | 21 | ||
| 22 | #define SUGOV_KTHREAD_PRIORITY 50 | ||
| 23 | |||
| 24 | struct sugov_tunables { | 22 | struct sugov_tunables { |
| 25 | struct gov_attr_set attr_set; | 23 | struct gov_attr_set attr_set; |
| 26 | unsigned int rate_limit_us; | 24 | unsigned int rate_limit_us; |
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 9bb0e0c412ec..9df09782025c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
| @@ -1153,6 +1153,7 @@ static void update_curr_dl(struct rq *rq) | |||
| 1153 | struct sched_dl_entity *dl_se = &curr->dl; | 1153 | struct sched_dl_entity *dl_se = &curr->dl; |
| 1154 | u64 delta_exec, scaled_delta_exec; | 1154 | u64 delta_exec, scaled_delta_exec; |
| 1155 | int cpu = cpu_of(rq); | 1155 | int cpu = cpu_of(rq); |
| 1156 | u64 now; | ||
| 1156 | 1157 | ||
| 1157 | if (!dl_task(curr) || !on_dl_rq(dl_se)) | 1158 | if (!dl_task(curr) || !on_dl_rq(dl_se)) |
| 1158 | return; | 1159 | return; |
| @@ -1165,7 +1166,8 @@ static void update_curr_dl(struct rq *rq) | |||
| 1165 | * natural solution, but the full ramifications of this | 1166 | * natural solution, but the full ramifications of this |
| 1166 | * approach need further study. | 1167 | * approach need further study. |
| 1167 | */ | 1168 | */ |
| 1168 | delta_exec = rq_clock_task(rq) - curr->se.exec_start; | 1169 | now = rq_clock_task(rq); |
| 1170 | delta_exec = now - curr->se.exec_start; | ||
| 1169 | if (unlikely((s64)delta_exec <= 0)) { | 1171 | if (unlikely((s64)delta_exec <= 0)) { |
| 1170 | if (unlikely(dl_se->dl_yielded)) | 1172 | if (unlikely(dl_se->dl_yielded)) |
| 1171 | goto throttle; | 1173 | goto throttle; |
| @@ -1178,7 +1180,7 @@ static void update_curr_dl(struct rq *rq) | |||
| 1178 | curr->se.sum_exec_runtime += delta_exec; | 1180 | curr->se.sum_exec_runtime += delta_exec; |
| 1179 | account_group_exec_runtime(curr, delta_exec); | 1181 | account_group_exec_runtime(curr, delta_exec); |
| 1180 | 1182 | ||
| 1181 | curr->se.exec_start = rq_clock_task(rq); | 1183 | curr->se.exec_start = now; |
| 1182 | cgroup_account_cputime(curr, delta_exec); | 1184 | cgroup_account_cputime(curr, delta_exec); |
| 1183 | 1185 | ||
| 1184 | sched_rt_avg_update(rq, delta_exec); | 1186 | sched_rt_avg_update(rq, delta_exec); |
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 663b2355a3aa..aad49451584e 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c | |||
| @@ -950,12 +950,13 @@ static void update_curr_rt(struct rq *rq) | |||
| 950 | { | 950 | { |
| 951 | struct task_struct *curr = rq->curr; | 951 | struct task_struct *curr = rq->curr; |
| 952 | struct sched_rt_entity *rt_se = &curr->rt; | 952 | struct sched_rt_entity *rt_se = &curr->rt; |
| 953 | u64 now = rq_clock_task(rq); | ||
| 954 | u64 delta_exec; | 953 | u64 delta_exec; |
| 954 | u64 now; | ||
| 955 | 955 | ||
| 956 | if (curr->sched_class != &rt_sched_class) | 956 | if (curr->sched_class != &rt_sched_class) |
| 957 | return; | 957 | return; |
| 958 | 958 | ||
| 959 | now = rq_clock_task(rq); | ||
| 959 | delta_exec = now - curr->se.exec_start; | 960 | delta_exec = now - curr->se.exec_start; |
| 960 | if (unlikely((s64)delta_exec <= 0)) | 961 | if (unlikely((s64)delta_exec <= 0)) |
| 961 | return; | 962 | return; |
diff --git a/lib/dma-direct.c b/lib/dma-direct.c index 40b1f92f2214..c9e8e21cb334 100644 --- a/lib/dma-direct.c +++ b/lib/dma-direct.c | |||
| @@ -84,6 +84,10 @@ again: | |||
| 84 | return page_address(page); | 84 | return page_address(page); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | /* | ||
| 88 | * NOTE: this function must never look at the dma_addr argument, because we want | ||
| 89 | * to be able to use it as a helper for iommu implementations as well. | ||
| 90 | */ | ||
| 87 | void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, | 91 | void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, |
| 88 | dma_addr_t dma_addr, unsigned long attrs) | 92 | dma_addr_t dma_addr, unsigned long attrs) |
| 89 | { | 93 | { |
| @@ -152,5 +156,6 @@ const struct dma_map_ops dma_direct_ops = { | |||
| 152 | .map_sg = dma_direct_map_sg, | 156 | .map_sg = dma_direct_map_sg, |
| 153 | .dma_supported = dma_direct_supported, | 157 | .dma_supported = dma_direct_supported, |
| 154 | .mapping_error = dma_direct_mapping_error, | 158 | .mapping_error = dma_direct_mapping_error, |
| 159 | .is_phys = 1, | ||
| 155 | }; | 160 | }; |
| 156 | EXPORT_SYMBOL(dma_direct_ops); | 161 | EXPORT_SYMBOL(dma_direct_ops); |
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 4b80ccee4535..8291b75f42c8 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
| @@ -1139,8 +1139,6 @@ int memory_failure(unsigned long pfn, int flags) | |||
| 1139 | return 0; | 1139 | return 0; |
| 1140 | } | 1140 | } |
| 1141 | 1141 | ||
| 1142 | arch_unmap_kpfn(pfn); | ||
| 1143 | |||
| 1144 | orig_head = hpage = compound_head(p); | 1142 | orig_head = hpage = compound_head(p); |
| 1145 | num_poisoned_pages_inc(); | 1143 | num_poisoned_pages_inc(); |
| 1146 | 1144 | ||
diff --git a/mm/memory.c b/mm/memory.c index dd8de96f5547..5fcfc24904d1 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -80,7 +80,7 @@ | |||
| 80 | 80 | ||
| 81 | #include "internal.h" | 81 | #include "internal.h" |
| 82 | 82 | ||
| 83 | #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS | 83 | #if defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) && !defined(CONFIG_COMPILE_TEST) |
| 84 | #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid. | 84 | #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid. |
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index f3a4efcf1456..3aa5a93ad107 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
| @@ -160,7 +160,8 @@ static void req_done(struct virtqueue *vq) | |||
| 160 | spin_unlock_irqrestore(&chan->lock, flags); | 160 | spin_unlock_irqrestore(&chan->lock, flags); |
| 161 | /* Wakeup if anyone waiting for VirtIO ring space. */ | 161 | /* Wakeup if anyone waiting for VirtIO ring space. */ |
| 162 | wake_up(chan->vc_wq); | 162 | wake_up(chan->vc_wq); |
| 163 | p9_client_cb(chan->client, req, REQ_STATUS_RCVD); | 163 | if (len) |
| 164 | p9_client_cb(chan->client, req, REQ_STATUS_RCVD); | ||
| 164 | } | 165 | } |
| 165 | } | 166 | } |
| 166 | 167 | ||
diff --git a/sound/ac97/Kconfig b/sound/ac97/Kconfig index f8a64e15e5bf..baa5f8ef89d2 100644 --- a/sound/ac97/Kconfig +++ b/sound/ac97/Kconfig | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | 5 | ||
| 6 | config AC97_BUS_NEW | 6 | config AC97_BUS_NEW |
| 7 | tristate | 7 | tristate |
| 8 | select AC97 | ||
| 9 | help | 8 | help |
| 10 | This is the new AC97 bus type, successor of AC97_BUS. The ported | 9 | This is the new AC97 bus type, successor of AC97_BUS. The ported |
| 11 | drivers which benefit from the AC97 automatic probing should "select" | 10 | drivers which benefit from the AC97 automatic probing should "select" |
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 60db32785f62..04d4db44fae5 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c | |||
| @@ -1003,7 +1003,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, | |||
| 1003 | { | 1003 | { |
| 1004 | struct snd_seq_client *client = file->private_data; | 1004 | struct snd_seq_client *client = file->private_data; |
| 1005 | int written = 0, len; | 1005 | int written = 0, len; |
| 1006 | int err = -EINVAL; | 1006 | int err; |
| 1007 | struct snd_seq_event event; | 1007 | struct snd_seq_event event; |
| 1008 | 1008 | ||
| 1009 | if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT)) | 1009 | if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT)) |
| @@ -1018,11 +1018,15 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, | |||
| 1018 | 1018 | ||
| 1019 | /* allocate the pool now if the pool is not allocated yet */ | 1019 | /* allocate the pool now if the pool is not allocated yet */ |
| 1020 | if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { | 1020 | if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { |
| 1021 | if (snd_seq_pool_init(client->pool) < 0) | 1021 | mutex_lock(&client->ioctl_mutex); |
| 1022 | err = snd_seq_pool_init(client->pool); | ||
| 1023 | mutex_unlock(&client->ioctl_mutex); | ||
| 1024 | if (err < 0) | ||
| 1022 | return -ENOMEM; | 1025 | return -ENOMEM; |
| 1023 | } | 1026 | } |
| 1024 | 1027 | ||
| 1025 | /* only process whole events */ | 1028 | /* only process whole events */ |
| 1029 | err = -EINVAL; | ||
| 1026 | while (count >= sizeof(struct snd_seq_event)) { | 1030 | while (count >= sizeof(struct snd_seq_event)) { |
| 1027 | /* Read in the event header from the user */ | 1031 | /* Read in the event header from the user */ |
| 1028 | len = sizeof(event); | 1032 | len = sizeof(event); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 23475888192b..ce28f7ce64e6 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -3465,6 +3465,19 @@ static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, | |||
| 3465 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; | 3465 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 3466 | } | 3466 | } |
| 3467 | 3467 | ||
| 3468 | static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec, | ||
| 3469 | const struct hda_fixup *fix, | ||
| 3470 | int action) | ||
| 3471 | { | ||
| 3472 | unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21); | ||
| 3473 | unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19); | ||
| 3474 | |||
| 3475 | if (cfg_headphone && cfg_headset_mic == 0x411111f0) | ||
| 3476 | snd_hda_codec_set_pincfg(codec, 0x19, | ||
| 3477 | (cfg_headphone & ~AC_DEFCFG_DEVICE) | | ||
| 3478 | (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT)); | ||
| 3479 | } | ||
| 3480 | |||
| 3468 | static void alc269_fixup_hweq(struct hda_codec *codec, | 3481 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 3469 | const struct hda_fixup *fix, int action) | 3482 | const struct hda_fixup *fix, int action) |
| 3470 | { | 3483 | { |
| @@ -4972,6 +4985,28 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec, | |||
| 4972 | } | 4985 | } |
| 4973 | } | 4986 | } |
| 4974 | 4987 | ||
| 4988 | static void alc_fixup_tpt470_dock(struct hda_codec *codec, | ||
| 4989 | const struct hda_fixup *fix, int action) | ||
| 4990 | { | ||
| 4991 | static const struct hda_pintbl pincfgs[] = { | ||
| 4992 | { 0x17, 0x21211010 }, /* dock headphone */ | ||
| 4993 | { 0x19, 0x21a11010 }, /* dock mic */ | ||
| 4994 | { } | ||
| 4995 | }; | ||
| 4996 | struct alc_spec *spec = codec->spec; | ||
| 4997 | |||
| 4998 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
| 4999 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; | ||
| 5000 | /* Enable DOCK device */ | ||
| 5001 | snd_hda_codec_write(codec, 0x17, 0, | ||
| 5002 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0); | ||
| 5003 | /* Enable DOCK device */ | ||
| 5004 | snd_hda_codec_write(codec, 0x19, 0, | ||
| 5005 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0); | ||
| 5006 | snd_hda_apply_pincfgs(codec, pincfgs); | ||
| 5007 | } | ||
| 5008 | } | ||
| 5009 | |||
| 4975 | static void alc_shutup_dell_xps13(struct hda_codec *codec) | 5010 | static void alc_shutup_dell_xps13(struct hda_codec *codec) |
| 4976 | { | 5011 | { |
| 4977 | struct alc_spec *spec = codec->spec; | 5012 | struct alc_spec *spec = codec->spec; |
| @@ -5351,6 +5386,7 @@ enum { | |||
| 5351 | ALC269_FIXUP_LIFEBOOK_EXTMIC, | 5386 | ALC269_FIXUP_LIFEBOOK_EXTMIC, |
| 5352 | ALC269_FIXUP_LIFEBOOK_HP_PIN, | 5387 | ALC269_FIXUP_LIFEBOOK_HP_PIN, |
| 5353 | ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT, | 5388 | ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT, |
| 5389 | ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, | ||
| 5354 | ALC269_FIXUP_AMIC, | 5390 | ALC269_FIXUP_AMIC, |
| 5355 | ALC269_FIXUP_DMIC, | 5391 | ALC269_FIXUP_DMIC, |
| 5356 | ALC269VB_FIXUP_AMIC, | 5392 | ALC269VB_FIXUP_AMIC, |
| @@ -5446,6 +5482,7 @@ enum { | |||
| 5446 | ALC700_FIXUP_INTEL_REFERENCE, | 5482 | ALC700_FIXUP_INTEL_REFERENCE, |
| 5447 | ALC274_FIXUP_DELL_BIND_DACS, | 5483 | ALC274_FIXUP_DELL_BIND_DACS, |
| 5448 | ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, | 5484 | ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, |
| 5485 | ALC298_FIXUP_TPT470_DOCK, | ||
| 5449 | }; | 5486 | }; |
| 5450 | 5487 | ||
| 5451 | static const struct hda_fixup alc269_fixups[] = { | 5488 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -5556,6 +5593,10 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 5556 | .type = HDA_FIXUP_FUNC, | 5593 | .type = HDA_FIXUP_FUNC, |
| 5557 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, | 5594 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 5558 | }, | 5595 | }, |
| 5596 | [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = { | ||
| 5597 | .type = HDA_FIXUP_FUNC, | ||
| 5598 | .v.func = alc269_fixup_pincfg_U7x7_headset_mic, | ||
| 5599 | }, | ||
| 5559 | [ALC269_FIXUP_AMIC] = { | 5600 | [ALC269_FIXUP_AMIC] = { |
| 5560 | .type = HDA_FIXUP_PINS, | 5601 | .type = HDA_FIXUP_PINS, |
| 5561 | .v.pins = (const struct hda_pintbl[]) { | 5602 | .v.pins = (const struct hda_pintbl[]) { |
| @@ -6271,6 +6312,12 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 6271 | .chained = true, | 6312 | .chained = true, |
| 6272 | .chain_id = ALC274_FIXUP_DELL_BIND_DACS | 6313 | .chain_id = ALC274_FIXUP_DELL_BIND_DACS |
| 6273 | }, | 6314 | }, |
| 6315 | [ALC298_FIXUP_TPT470_DOCK] = { | ||
| 6316 | .type = HDA_FIXUP_FUNC, | ||
| 6317 | .v.func = alc_fixup_tpt470_dock, | ||
| 6318 | .chained = true, | ||
| 6319 | .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE | ||
| 6320 | }, | ||
| 6274 | }; | 6321 | }; |
| 6275 | 6322 | ||
| 6276 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { | 6323 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -6321,6 +6368,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 6321 | SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), | 6368 | SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), |
| 6322 | SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), | 6369 | SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), |
| 6323 | SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), | 6370 | SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), |
| 6371 | SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB), | ||
| 6372 | SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB), | ||
| 6324 | SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), | 6373 | SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 6325 | SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), | 6374 | SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 6326 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), | 6375 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
| @@ -6422,6 +6471,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 6422 | SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT), | 6471 | SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT), |
| 6423 | SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN), | 6472 | SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN), |
| 6424 | SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), | 6473 | SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), |
| 6474 | SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC), | ||
| 6425 | SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), | 6475 | SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), |
| 6426 | SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), | 6476 | SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), |
| 6427 | SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), | 6477 | SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), |
| @@ -6450,8 +6500,16 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 6450 | SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK), | 6500 | SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK), |
| 6451 | SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK), | 6501 | SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK), |
| 6452 | SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK), | 6502 | SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK), |
| 6503 | SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6504 | SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6453 | SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460), | 6505 | SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460), |
| 6454 | SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460), | 6506 | SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460), |
| 6507 | SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK), | ||
| 6508 | SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6509 | SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6510 | SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6511 | SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6512 | SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6455 | SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), | 6513 | SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), |
| 6456 | SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), | 6514 | SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), |
| 6457 | SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), | 6515 | SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), |
| @@ -6472,7 +6530,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 6472 | SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460), | 6530 | SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460), |
| 6473 | SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460), | 6531 | SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460), |
| 6474 | SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460), | 6532 | SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460), |
| 6533 | SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6534 | SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6535 | SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6475 | SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), | 6536 | SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
| 6537 | SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6538 | SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), | ||
| 6476 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), | 6539 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
| 6477 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), | 6540 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
| 6478 | SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ | 6541 | SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ |
| @@ -6735,6 +6798,11 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { | |||
| 6735 | {0x14, 0x90170110}, | 6798 | {0x14, 0x90170110}, |
| 6736 | {0x21, 0x02211020}), | 6799 | {0x21, 0x02211020}), |
| 6737 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, | 6800 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, |
| 6801 | {0x12, 0x90a60130}, | ||
| 6802 | {0x14, 0x90170110}, | ||
| 6803 | {0x14, 0x01011020}, | ||
| 6804 | {0x21, 0x0221101f}), | ||
| 6805 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, | ||
| 6738 | ALC256_STANDARD_PINS), | 6806 | ALC256_STANDARD_PINS), |
| 6739 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC, | 6807 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC, |
| 6740 | {0x14, 0x90170110}, | 6808 | {0x14, 0x90170110}, |
| @@ -6803,6 +6871,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { | |||
| 6803 | {0x12, 0x90a60120}, | 6871 | {0x12, 0x90a60120}, |
| 6804 | {0x14, 0x90170110}, | 6872 | {0x14, 0x90170110}, |
| 6805 | {0x21, 0x0321101f}), | 6873 | {0x21, 0x0321101f}), |
| 6874 | SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, | ||
| 6875 | {0x12, 0xb7a60130}, | ||
| 6876 | {0x14, 0x90170110}, | ||
| 6877 | {0x21, 0x04211020}), | ||
| 6806 | SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1, | 6878 | SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1, |
| 6807 | ALC290_STANDARD_PINS, | 6879 | ALC290_STANDARD_PINS, |
| 6808 | {0x15, 0x04211040}, | 6880 | {0x15, 0x04211040}, |
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 9afb8ab524c7..06b22624ab7a 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
| @@ -347,17 +347,20 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, | |||
| 347 | int validx, int *value_ret) | 347 | int validx, int *value_ret) |
| 348 | { | 348 | { |
| 349 | struct snd_usb_audio *chip = cval->head.mixer->chip; | 349 | struct snd_usb_audio *chip = cval->head.mixer->chip; |
| 350 | unsigned char buf[4 + 3 * sizeof(__u32)]; /* enough space for one range */ | 350 | /* enough space for one range */ |
| 351 | unsigned char buf[sizeof(__u16) + 3 * sizeof(__u32)]; | ||
| 351 | unsigned char *val; | 352 | unsigned char *val; |
| 352 | int idx = 0, ret, size; | 353 | int idx = 0, ret, val_size, size; |
| 353 | __u8 bRequest; | 354 | __u8 bRequest; |
| 354 | 355 | ||
| 356 | val_size = uac2_ctl_value_size(cval->val_type); | ||
| 357 | |||
| 355 | if (request == UAC_GET_CUR) { | 358 | if (request == UAC_GET_CUR) { |
| 356 | bRequest = UAC2_CS_CUR; | 359 | bRequest = UAC2_CS_CUR; |
| 357 | size = uac2_ctl_value_size(cval->val_type); | 360 | size = val_size; |
| 358 | } else { | 361 | } else { |
| 359 | bRequest = UAC2_CS_RANGE; | 362 | bRequest = UAC2_CS_RANGE; |
| 360 | size = sizeof(buf); | 363 | size = sizeof(__u16) + 3 * val_size; |
| 361 | } | 364 | } |
| 362 | 365 | ||
| 363 | memset(buf, 0, sizeof(buf)); | 366 | memset(buf, 0, sizeof(buf)); |
| @@ -390,16 +393,17 @@ error: | |||
| 390 | val = buf + sizeof(__u16); | 393 | val = buf + sizeof(__u16); |
| 391 | break; | 394 | break; |
| 392 | case UAC_GET_MAX: | 395 | case UAC_GET_MAX: |
| 393 | val = buf + sizeof(__u16) * 2; | 396 | val = buf + sizeof(__u16) + val_size; |
| 394 | break; | 397 | break; |
| 395 | case UAC_GET_RES: | 398 | case UAC_GET_RES: |
| 396 | val = buf + sizeof(__u16) * 3; | 399 | val = buf + sizeof(__u16) + val_size * 2; |
| 397 | break; | 400 | break; |
| 398 | default: | 401 | default: |
| 399 | return -EINVAL; | 402 | return -EINVAL; |
| 400 | } | 403 | } |
| 401 | 404 | ||
| 402 | *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(val, sizeof(__u16))); | 405 | *value_ret = convert_signed_value(cval, |
| 406 | snd_usb_combine_bytes(val, val_size)); | ||
| 403 | 407 | ||
| 404 | return 0; | 408 | return 0; |
| 405 | } | 409 | } |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index b9c9a19f9588..3cbfae6604f9 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
| @@ -357,6 +357,15 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, | |||
| 357 | 357 | ||
| 358 | alts = &iface->altsetting[1]; | 358 | alts = &iface->altsetting[1]; |
| 359 | goto add_sync_ep; | 359 | goto add_sync_ep; |
| 360 | case USB_ID(0x1397, 0x0002): | ||
| 361 | ep = 0x81; | ||
| 362 | iface = usb_ifnum_to_if(dev, 1); | ||
| 363 | |||
| 364 | if (!iface || iface->num_altsetting == 0) | ||
| 365 | return -EINVAL; | ||
| 366 | |||
| 367 | alts = &iface->altsetting[1]; | ||
| 368 | goto add_sync_ep; | ||
| 360 | 369 | ||
| 361 | } | 370 | } |
| 362 | if (attr == USB_ENDPOINT_SYNC_ASYNC && | 371 | if (attr == USB_ENDPOINT_SYNC_ASYNC && |
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index a66ef5777887..ea8f3de92fa4 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
| @@ -1363,8 +1363,11 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | |||
| 1363 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; | 1363 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
| 1364 | break; | 1364 | break; |
| 1365 | 1365 | ||
| 1366 | /* Amanero Combo384 USB interface with native DSD support */ | 1366 | /* Amanero Combo384 USB based DACs with native DSD support */ |
| 1367 | case USB_ID(0x16d0, 0x071a): | 1367 | case USB_ID(0x16d0, 0x071a): /* Amanero - Combo384 */ |
| 1368 | case USB_ID(0x2ab6, 0x0004): /* T+A DAC8DSD-V2.0, MP1000E-V2.0, MP2000R-V2.0, MP2500R-V2.0, MP3100HV-V2.0 */ | ||
| 1369 | case USB_ID(0x2ab6, 0x0005): /* T+A USB HD Audio 1 */ | ||
| 1370 | case USB_ID(0x2ab6, 0x0006): /* T+A USB HD Audio 2 */ | ||
| 1368 | if (fp->altsetting == 2) { | 1371 | if (fp->altsetting == 2) { |
| 1369 | switch (le16_to_cpu(chip->dev->descriptor.bcdDevice)) { | 1372 | switch (le16_to_cpu(chip->dev->descriptor.bcdDevice)) { |
| 1370 | case 0x199: | 1373 | case 0x199: |
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h index 637b7263cb86..833ed9a16adf 100644 --- a/tools/arch/powerpc/include/uapi/asm/kvm.h +++ b/tools/arch/powerpc/include/uapi/asm/kvm.h | |||
| @@ -632,6 +632,8 @@ struct kvm_ppc_cpu_char { | |||
| 632 | #define KVM_REG_PPC_TIDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbc) | 632 | #define KVM_REG_PPC_TIDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbc) |
| 633 | #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) | 633 | #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) |
| 634 | 634 | ||
| 635 | #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) | ||
| 636 | |||
| 635 | /* Transactional Memory checkpointed state: | 637 | /* Transactional Memory checkpointed state: |
| 636 | * This is all GPRs, all VSX regs and a subset of SPRs | 638 | * This is all GPRs, all VSX regs and a subset of SPRs |
| 637 | */ | 639 | */ |
diff --git a/tools/arch/s390/include/uapi/asm/unistd.h b/tools/arch/s390/include/uapi/asm/unistd.h deleted file mode 100644 index 725120939051..000000000000 --- a/tools/arch/s390/include/uapi/asm/unistd.h +++ /dev/null | |||
| @@ -1,412 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| 2 | /* | ||
| 3 | * S390 version | ||
| 4 | * | ||
| 5 | * Derived from "include/asm-i386/unistd.h" | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _UAPI_ASM_S390_UNISTD_H_ | ||
| 9 | #define _UAPI_ASM_S390_UNISTD_H_ | ||
| 10 | |||
| 11 | /* | ||
| 12 | * This file contains the system call numbers. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #define __NR_exit 1 | ||
| 16 | #define __NR_fork 2 | ||
| 17 | #define __NR_read 3 | ||
| 18 | #define __NR_write 4 | ||
| 19 | #define __NR_open 5 | ||
| 20 | #define __NR_close 6 | ||
| 21 | #define __NR_restart_syscall 7 | ||
| 22 | #define __NR_creat 8 | ||
| 23 | #define __NR_link 9 | ||
| 24 | #define __NR_unlink 10 | ||
| 25 | #define __NR_execve 11 | ||
| 26 | #define __NR_chdir 12 | ||
| 27 | #define __NR_mknod 14 | ||
| 28 | #define __NR_chmod 15 | ||
| 29 | #define __NR_lseek 19 | ||
| 30 | #define __NR_getpid 20 | ||
| 31 | #define __NR_mount 21 | ||
| 32 | #define __NR_umount 22 | ||
| 33 | #define __NR_ptrace 26 | ||
| 34 | #define __NR_alarm 27 | ||
| 35 | #define __NR_pause 29 | ||
| 36 | #define __NR_utime 30 | ||
| 37 | #define __NR_access 33 | ||
| 38 | #define __NR_nice 34 | ||
| 39 | #define __NR_sync 36 | ||
| 40 | #define __NR_kill 37 | ||
| 41 | #define __NR_rename 38 | ||
| 42 | #define __NR_mkdir 39 | ||
| 43 | #define __NR_rmdir 40 | ||
| 44 | #define __NR_dup 41 | ||
| 45 | #define __NR_pipe 42 | ||
| 46 | #define __NR_times 43 | ||
| 47 | #define __NR_brk 45 | ||
| 48 | #define __NR_signal 48 | ||
| 49 | #define __NR_acct 51 | ||
| 50 | #define __NR_umount2 52 | ||
| 51 | #define __NR_ioctl 54 | ||
| 52 | #define __NR_fcntl 55 | ||
| 53 | #define __NR_setpgid 57 | ||
| 54 | #define __NR_umask 60 | ||
| 55 | #define __NR_chroot 61 | ||
| 56 | #define __NR_ustat 62 | ||
| 57 | #define __NR_dup2 63 | ||
| 58 | #define __NR_getppid 64 | ||
| 59 | #define __NR_getpgrp 65 | ||
| 60 | #define __NR_setsid 66 | ||
| 61 | #define __NR_sigaction 67 | ||
| 62 | #define __NR_sigsuspend 72 | ||
| 63 | #define __NR_sigpending 73 | ||
| 64 | #define __NR_sethostname 74 | ||
| 65 | #define __NR_setrlimit 75 | ||
| 66 | #define __NR_getrusage 77 | ||
| 67 | #define __NR_gettimeofday 78 | ||
| 68 | #define __NR_settimeofday 79 | ||
| 69 | #define __NR_symlink 83 | ||
| 70 | #define __NR_readlink 85 | ||
| 71 | #define __NR_uselib 86 | ||
| 72 | #define __NR_swapon 87 | ||
| 73 | #define __NR_reboot 88 | ||
| 74 | #define __NR_readdir 89 | ||
| 75 | #define __NR_mmap 90 | ||
| 76 | #define __NR_munmap 91 | ||
| 77 | #define __NR_truncate 92 | ||
| 78 | #define __NR_ftruncate 93 | ||
| 79 | #define __NR_fchmod 94 | ||
| 80 | #define __NR_getpriority 96 | ||
| 81 | #define __NR_setpriority 97 | ||
| 82 | #define __NR_statfs 99 | ||
| 83 | #define __NR_fstatfs 100 | ||
| 84 | #define __NR_socketcall 102 | ||
| 85 | #define __NR_syslog 103 | ||
| 86 | #define __NR_setitimer 104 | ||
| 87 | #define __NR_getitimer 105 | ||
| 88 | #define __NR_stat 106 | ||
| 89 | #define __NR_lstat 107 | ||
| 90 | #define __NR_fstat 108 | ||
| 91 | #define __NR_lookup_dcookie 110 | ||
| 92 | #define __NR_vhangup 111 | ||
| 93 | #define __NR_idle 112 | ||
| 94 | #define __NR_wait4 114 | ||
| 95 | #define __NR_swapoff 115 | ||
| 96 | #define __NR_sysinfo 116 | ||
| 97 | #define __NR_ipc 117 | ||
| 98 | #define __NR_fsync 118 | ||
| 99 | #define __NR_sigreturn 119 | ||
| 100 | #define __NR_clone 120 | ||
| 101 | #define __NR_setdomainname 121 | ||
| 102 | #define __NR_uname 122 | ||
| 103 | #define __NR_adjtimex 124 | ||
| 104 | #define __NR_mprotect 125 | ||
| 105 | #define __NR_sigprocmask 126 | ||
| 106 | #define __NR_create_module 127 | ||
| 107 | #define __NR_init_module 128 | ||
| 108 | #define __NR_delete_module 129 | ||
| 109 | #define __NR_get_kernel_syms 130 | ||
| 110 | #define __NR_quotactl 131 | ||
| 111 | #define __NR_getpgid 132 | ||
| 112 | #define __NR_fchdir 133 | ||
| 113 | #define __NR_bdflush 134 | ||
| 114 | #define __NR_sysfs 135 | ||
| 115 | #define __NR_personality 136 | ||
| 116 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
| 117 | #define __NR_getdents 141 | ||
| 118 | #define __NR_flock 143 | ||
| 119 | #define __NR_msync 144 | ||
| 120 | #define __NR_readv 145 | ||
| 121 | #define __NR_writev 146 | ||
| 122 | #define __NR_getsid 147 | ||
| 123 | #define __NR_fdatasync 148 | ||
| 124 | #define __NR__sysctl 149 | ||
| 125 | #define __NR_mlock 150 | ||
| 126 | #define __NR_munlock 151 | ||
| 127 | #define __NR_mlockall 152 | ||
| 128 | #define __NR_munlockall 153 | ||
| 129 | #define __NR_sched_setparam 154 | ||
| 130 | #define __NR_sched_getparam 155 | ||
| 131 | #define __NR_sched_setscheduler 156 | ||
| 132 | #define __NR_sched_getscheduler 157 | ||
| 133 | #define __NR_sched_yield 158 | ||
| 134 | #define __NR_sched_get_priority_max 159 | ||
| 135 | #define __NR_sched_get_priority_min 160 | ||
| 136 | #define __NR_sched_rr_get_interval 161 | ||
| 137 | #define __NR_nanosleep 162 | ||
| 138 | #define __NR_mremap 163 | ||
| 139 | #define __NR_query_module 167 | ||
| 140 | #define __NR_poll 168 | ||
| 141 | #define __NR_nfsservctl 169 | ||
| 142 | #define __NR_prctl 172 | ||
| 143 | #define __NR_rt_sigreturn 173 | ||
| 144 | #define __NR_rt_sigaction 174 | ||
| 145 | #define __NR_rt_sigprocmask 175 | ||
| 146 | #define __NR_rt_sigpending 176 | ||
| 147 | #define __NR_rt_sigtimedwait 177 | ||
| 148 | #define __NR_rt_sigqueueinfo 178 | ||
| 149 | #define __NR_rt_sigsuspend 179 | ||
| 150 | #define __NR_pread64 180 | ||
| 151 | #define __NR_pwrite64 181 | ||
| 152 | #define __NR_getcwd 183 | ||
| 153 | #define __NR_capget 184 | ||
| 154 | #define __NR_capset 185 | ||
| 155 | #define __NR_sigaltstack 186 | ||
| 156 | #define __NR_sendfile 187 | ||
| 157 | #define __NR_getpmsg 188 | ||
| 158 | #define __NR_putpmsg 189 | ||
| 159 | #define __NR_vfork 190 | ||
| 160 | #define __NR_pivot_root 217 | ||
| 161 | #define __NR_mincore 218 | ||
| 162 | #define __NR_madvise 219 | ||
| 163 | #define __NR_getdents64 220 | ||
| 164 | #define __NR_readahead 222 | ||
| 165 | #define __NR_setxattr 224 | ||
| 166 | #define __NR_lsetxattr 225 | ||
| 167 | #define __NR_fsetxattr 226 | ||
| 168 | #define __NR_getxattr 227 | ||
| 169 | #define __NR_lgetxattr 228 | ||
| 170 | #define __NR_fgetxattr 229 | ||
| 171 | #define __NR_listxattr 230 | ||
| 172 | #define __NR_llistxattr 231 | ||
| 173 | #define __NR_flistxattr 232 | ||
| 174 | #define __NR_removexattr 233 | ||
| 175 | #define __NR_lremovexattr 234 | ||
| 176 | #define __NR_fremovexattr 235 | ||
| 177 | #define __NR_gettid 236 | ||
| 178 | #define __NR_tkill 237 | ||
| 179 | #define __NR_futex 238 | ||
| 180 | #define __NR_sched_setaffinity 239 | ||
| 181 | #define __NR_sched_getaffinity 240 | ||
| 182 | #define __NR_tgkill 241 | ||
| 183 | /* Number 242 is reserved for tux */ | ||
| 184 | #define __NR_io_setup 243 | ||
| 185 | #define __NR_io_destroy 244 | ||
| 186 | #define __NR_io_getevents 245 | ||
| 187 | #define __NR_io_submit 246 | ||
| 188 | #define __NR_io_cancel 247 | ||
| 189 | #define __NR_exit_group 248 | ||
| 190 | #define __NR_epoll_create 249 | ||
| 191 | #define __NR_epoll_ctl 250 | ||
| 192 | #define __NR_epoll_wait 251 | ||
| 193 | #define __NR_set_tid_address 252 | ||
| 194 | #define __NR_fadvise64 253 | ||
| 195 | #define __NR_timer_create 254 | ||
| 196 | #define __NR_timer_settime 255 | ||
| 197 | #define __NR_timer_gettime 256 | ||
| 198 | #define __NR_timer_getoverrun 257 | ||
| 199 | #define __NR_timer_delete 258 | ||
| 200 | #define __NR_clock_settime 259 | ||
| 201 | #define __NR_clock_gettime 260 | ||
| 202 | #define __NR_clock_getres 261 | ||
| 203 | #define __NR_clock_nanosleep 262 | ||
| 204 | /* Number 263 is reserved for vserver */ | ||
| 205 | #define __NR_statfs64 265 | ||
| 206 | #define __NR_fstatfs64 266 | ||
| 207 | #define __NR_remap_file_pages 267 | ||
| 208 | #define __NR_mbind 268 | ||
| 209 | #define __NR_get_mempolicy 269 | ||
| 210 | #define __NR_set_mempolicy 270 | ||
| 211 | #define __NR_mq_open 271 | ||
| 212 | #define __NR_mq_unlink 272 | ||
| 213 | #define __NR_mq_timedsend 273 | ||
| 214 | #define __NR_mq_timedreceive 274 | ||
| 215 | #define __NR_mq_notify 275 | ||
| 216 | #define __NR_mq_getsetattr 276 | ||
| 217 | #define __NR_kexec_load 277 | ||
| 218 | #define __NR_add_key 278 | ||
| 219 | #define __NR_request_key 279 | ||
| 220 | #define __NR_keyctl 280 | ||
| 221 | #define __NR_waitid 281 | ||
| 222 | #define __NR_ioprio_set 282 | ||
| 223 | #define __NR_ioprio_get 283 | ||
| 224 | #define __NR_inotify_init 284 | ||
| 225 | #define __NR_inotify_add_watch 285 | ||
| 226 | #define __NR_inotify_rm_watch 286 | ||
| 227 | #define __NR_migrate_pages 287 | ||
| 228 | #define __NR_openat 288 | ||
| 229 | #define __NR_mkdirat 289 | ||
| 230 | #define __NR_mknodat 290 | ||
| 231 | #define __NR_fchownat 291 | ||
| 232 | #define __NR_futimesat 292 | ||
| 233 | #define __NR_unlinkat 294 | ||
| 234 | #define __NR_renameat 295 | ||
| 235 | #define __NR_linkat 296 | ||
| 236 | #define __NR_symlinkat 297 | ||
| 237 | #define __NR_readlinkat 298 | ||
| 238 | #define __NR_fchmodat 299 | ||
| 239 | #define __NR_faccessat 300 | ||
| 240 | #define __NR_pselect6 301 | ||
| 241 | #define __NR_ppoll 302 | ||
| 242 | #define __NR_unshare 303 | ||
| 243 | #define __NR_set_robust_list 304 | ||
| 244 | #define __NR_get_robust_list 305 | ||
| 245 | #define __NR_splice 306 | ||
| 246 | #define __NR_sync_file_range 307 | ||
| 247 | #define __NR_tee 308 | ||
| 248 | #define __NR_vmsplice 309 | ||
| 249 | #define __NR_move_pages 310 | ||
| 250 | #define __NR_getcpu 311 | ||
| 251 | #define __NR_epoll_pwait 312 | ||
| 252 | #define __NR_utimes 313 | ||
| 253 | #define __NR_fallocate 314 | ||
| 254 | #define __NR_utimensat 315 | ||
| 255 | #define __NR_signalfd 316 | ||
| 256 | #define __NR_timerfd 317 | ||
| 257 | #define __NR_eventfd 318 | ||
| 258 | #define __NR_timerfd_create 319 | ||
| 259 | #define __NR_timerfd_settime 320 | ||
| 260 | #define __NR_timerfd_gettime 321 | ||
| 261 | #define __NR_signalfd4 322 | ||
| 262 | #define __NR_eventfd2 323 | ||
| 263 | #define __NR_inotify_init1 324 | ||
| 264 | #define __NR_pipe2 325 | ||
| 265 | #define __NR_dup3 326 | ||
| 266 | #define __NR_epoll_create1 327 | ||
| 267 | #define __NR_preadv 328 | ||
| 268 | #define __NR_pwritev 329 | ||
| 269 | #define __NR_rt_tgsigqueueinfo 330 | ||
| 270 | #define __NR_perf_event_open 331 | ||
| 271 | #define __NR_fanotify_init 332 | ||
| 272 | #define __NR_fanotify_mark 333 | ||
| 273 | #define __NR_prlimit64 334 | ||
| 274 | #define __NR_name_to_handle_at 335 | ||
| 275 | #define __NR_open_by_handle_at 336 | ||
| 276 | #define __NR_clock_adjtime 337 | ||
| 277 | #define __NR_syncfs 338 | ||
| 278 | #define __NR_setns 339 | ||
| 279 | #define __NR_process_vm_readv 340 | ||
| 280 | #define __NR_process_vm_writev 341 | ||
| 281 | #define __NR_s390_runtime_instr 342 | ||
| 282 | #define __NR_kcmp 343 | ||
| 283 | #define __NR_finit_module 344 | ||
| 284 | #define __NR_sched_setattr 345 | ||
| 285 | #define __NR_sched_getattr 346 | ||
| 286 | #define __NR_renameat2 347 | ||
| 287 | #define __NR_seccomp 348 | ||
| 288 | #define __NR_getrandom 349 | ||
| 289 | #define __NR_memfd_create 350 | ||
| 290 | #define __NR_bpf 351 | ||
| 291 | #define __NR_s390_pci_mmio_write 352 | ||
| 292 | #define __NR_s390_pci_mmio_read 353 | ||
| 293 | #define __NR_execveat 354 | ||
| 294 | #define __NR_userfaultfd 355 | ||
| 295 | #define __NR_membarrier 356 | ||
| 296 | #define __NR_recvmmsg 357 | ||
| 297 | #define __NR_sendmmsg 358 | ||
| 298 | #define __NR_socket 359 | ||
| 299 | #define __NR_socketpair 360 | ||
| 300 | #define __NR_bind 361 | ||
| 301 | #define __NR_connect 362 | ||
| 302 | #define __NR_listen 363 | ||
| 303 | #define __NR_accept4 364 | ||
| 304 | #define __NR_getsockopt 365 | ||
| 305 | #define __NR_setsockopt 366 | ||
| 306 | #define __NR_getsockname 367 | ||
| 307 | #define __NR_getpeername 368 | ||
| 308 | #define __NR_sendto 369 | ||
| 309 | #define __NR_sendmsg 370 | ||
| 310 | #define __NR_recvfrom 371 | ||
| 311 | #define __NR_recvmsg 372 | ||
| 312 | #define __NR_shutdown 373 | ||
| 313 | #define __NR_mlock2 374 | ||
| 314 | #define __NR_copy_file_range 375 | ||
| 315 | #define __NR_preadv2 376 | ||
| 316 | #define __NR_pwritev2 377 | ||
| 317 | #define __NR_s390_guarded_storage 378 | ||
| 318 | #define __NR_statx 379 | ||
| 319 | #define __NR_s390_sthyi 380 | ||
| 320 | #define NR_syscalls 381 | ||
| 321 | |||
| 322 | /* | ||
| 323 | * There are some system calls that are not present on 64 bit, some | ||
| 324 | * have a different name although they do the same (e.g. __NR_chown32 | ||
| 325 | * is __NR_chown on 64 bit). | ||
| 326 | */ | ||
| 327 | #ifndef __s390x__ | ||
| 328 | |||
| 329 | #define __NR_time 13 | ||
| 330 | #define __NR_lchown 16 | ||
| 331 | #define __NR_setuid 23 | ||
| 332 | #define __NR_getuid 24 | ||
| 333 | #define __NR_stime 25 | ||
| 334 | #define __NR_setgid 46 | ||
| 335 | #define __NR_getgid 47 | ||
| 336 | #define __NR_geteuid 49 | ||
| 337 | #define __NR_getegid 50 | ||
| 338 | #define __NR_setreuid 70 | ||
| 339 | #define __NR_setregid 71 | ||
| 340 | #define __NR_getrlimit 76 | ||
| 341 | #define __NR_getgroups 80 | ||
| 342 | #define __NR_setgroups 81 | ||
| 343 | #define __NR_fchown 95 | ||
| 344 | #define __NR_ioperm 101 | ||
| 345 | #define __NR_setfsuid 138 | ||
| 346 | #define __NR_setfsgid 139 | ||
| 347 | #define __NR__llseek 140 | ||
| 348 | #define __NR__newselect 142 | ||
| 349 | #define __NR_setresuid 164 | ||
| 350 | #define __NR_getresuid 165 | ||
| 351 | #define __NR_setresgid 170 | ||
| 352 | #define __NR_getresgid 171 | ||
| 353 | #define __NR_chown 182 | ||
| 354 | #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ | ||
| 355 | #define __NR_mmap2 192 | ||
| 356 | #define __NR_truncate64 193 | ||
| 357 | #define __NR_ftruncate64 194 | ||
| 358 | #define __NR_stat64 195 | ||
| 359 | #define __NR_lstat64 196 | ||
| 360 | #define __NR_fstat64 197 | ||
| 361 | #define __NR_lchown32 198 | ||
| 362 | #define __NR_getuid32 199 | ||
| 363 | #define __NR_getgid32 200 | ||
| 364 | #define __NR_geteuid32 201 | ||
| 365 | #define __NR_getegid32 202 | ||
| 366 | #define __NR_setreuid32 203 | ||
| 367 | #define __NR_setregid32 204 | ||
| 368 | #define __NR_getgroups32 205 | ||
| 369 | #define __NR_setgroups32 206 | ||
| 370 | #define __NR_fchown32 207 | ||
| 371 | #define __NR_setresuid32 208 | ||
| 372 | #define __NR_getresuid32 209 | ||
| 373 | #define __NR_setresgid32 210 | ||
| 374 | #define __NR_getresgid32 211 | ||
| 375 | #define __NR_chown32 212 | ||
| 376 | #define __NR_setuid32 213 | ||
| 377 | #define __NR_setgid32 214 | ||
| 378 | #define __NR_setfsuid32 215 | ||
| 379 | #define __NR_setfsgid32 216 | ||
| 380 | #define __NR_fcntl64 221 | ||
| 381 | #define __NR_sendfile64 223 | ||
| 382 | #define __NR_fadvise64_64 264 | ||
| 383 | #define __NR_fstatat64 293 | ||
| 384 | |||
| 385 | #else | ||
| 386 | |||
| 387 | #define __NR_select 142 | ||
| 388 | #define __NR_getrlimit 191 /* SuS compliant getrlimit */ | ||
| 389 | #define __NR_lchown 198 | ||
| 390 | #define __NR_getuid 199 | ||
| 391 | #define __NR_getgid 200 | ||
| 392 | #define __NR_geteuid 201 | ||
| 393 | #define __NR_getegid 202 | ||
| 394 | #define __NR_setreuid 203 | ||
| 395 | #define __NR_setregid 204 | ||
| 396 | #define __NR_getgroups 205 | ||
| 397 | #define __NR_setgroups 206 | ||
| 398 | #define __NR_fchown 207 | ||
| 399 | #define __NR_setresuid 208 | ||
| 400 | #define __NR_getresuid 209 | ||
| 401 | #define __NR_setresgid 210 | ||
| 402 | #define __NR_getresgid 211 | ||
| 403 | #define __NR_chown 212 | ||
| 404 | #define __NR_setuid 213 | ||
| 405 | #define __NR_setgid 214 | ||
| 406 | #define __NR_setfsuid 215 | ||
| 407 | #define __NR_setfsgid 216 | ||
| 408 | #define __NR_newfstatat 293 | ||
| 409 | |||
| 410 | #endif | ||
| 411 | |||
| 412 | #endif /* _UAPI_ASM_S390_UNISTD_H_ */ | ||
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index 1d9199e1c2ad..0dfe4d3f74e2 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h | |||
| @@ -210,6 +210,7 @@ | |||
| 210 | 210 | ||
| 211 | #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ | 211 | #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ |
| 212 | #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */ | 212 | #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */ |
| 213 | #define X86_FEATURE_SEV ( 7*32+20) /* AMD Secure Encrypted Virtualization */ | ||
| 213 | 214 | ||
| 214 | #define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */ | 215 | #define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */ |
| 215 | 216 | ||
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h index ac3c6503ca27..536ee4febd74 100644 --- a/tools/include/uapi/drm/i915_drm.h +++ b/tools/include/uapi/drm/i915_drm.h | |||
| @@ -86,6 +86,62 @@ enum i915_mocs_table_index { | |||
| 86 | I915_MOCS_CACHED, | 86 | I915_MOCS_CACHED, |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | /* | ||
| 90 | * Different engines serve different roles, and there may be more than one | ||
| 91 | * engine serving each role. enum drm_i915_gem_engine_class provides a | ||
| 92 | * classification of the role of the engine, which may be used when requesting | ||
| 93 | * operations to be performed on a certain subset of engines, or for providing | ||
| 94 | * information about that group. | ||
| 95 | */ | ||
| 96 | enum drm_i915_gem_engine_class { | ||
| 97 | I915_ENGINE_CLASS_RENDER = 0, | ||
| 98 | I915_ENGINE_CLASS_COPY = 1, | ||
| 99 | I915_ENGINE_CLASS_VIDEO = 2, | ||
| 100 | I915_ENGINE_CLASS_VIDEO_ENHANCE = 3, | ||
| 101 | |||
| 102 | I915_ENGINE_CLASS_INVALID = -1 | ||
| 103 | }; | ||
| 104 | |||
| 105 | /** | ||
| 106 | * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915 | ||
| 107 | * | ||
| 108 | */ | ||
| 109 | |||
| 110 | enum drm_i915_pmu_engine_sample { | ||
| 111 | I915_SAMPLE_BUSY = 0, | ||
| 112 | I915_SAMPLE_WAIT = 1, | ||
| 113 | I915_SAMPLE_SEMA = 2 | ||
| 114 | }; | ||
| 115 | |||
| 116 | #define I915_PMU_SAMPLE_BITS (4) | ||
| 117 | #define I915_PMU_SAMPLE_MASK (0xf) | ||
| 118 | #define I915_PMU_SAMPLE_INSTANCE_BITS (8) | ||
| 119 | #define I915_PMU_CLASS_SHIFT \ | ||
| 120 | (I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS) | ||
| 121 | |||
| 122 | #define __I915_PMU_ENGINE(class, instance, sample) \ | ||
| 123 | ((class) << I915_PMU_CLASS_SHIFT | \ | ||
| 124 | (instance) << I915_PMU_SAMPLE_BITS | \ | ||
| 125 | (sample)) | ||
| 126 | |||
| 127 | #define I915_PMU_ENGINE_BUSY(class, instance) \ | ||
| 128 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY) | ||
| 129 | |||
| 130 | #define I915_PMU_ENGINE_WAIT(class, instance) \ | ||
| 131 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT) | ||
| 132 | |||
| 133 | #define I915_PMU_ENGINE_SEMA(class, instance) \ | ||
| 134 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA) | ||
| 135 | |||
| 136 | #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | ||
| 137 | |||
| 138 | #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0) | ||
| 139 | #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1) | ||
| 140 | #define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2) | ||
| 141 | #define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3) | ||
| 142 | |||
| 143 | #define I915_PMU_LAST I915_PMU_RC6_RESIDENCY | ||
| 144 | |||
| 89 | /* Each region is a minimum of 16k, and there are at most 255 of them. | 145 | /* Each region is a minimum of 16k, and there are at most 255 of them. |
| 90 | */ | 146 | */ |
| 91 | #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use | 147 | #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use |
| @@ -450,6 +506,27 @@ typedef struct drm_i915_irq_wait { | |||
| 450 | */ | 506 | */ |
| 451 | #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49 | 507 | #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49 |
| 452 | 508 | ||
| 509 | /* | ||
| 510 | * Query whether every context (both per-file default and user created) is | ||
| 511 | * isolated (insofar as HW supports). If this parameter is not true, then | ||
| 512 | * freshly created contexts may inherit values from an existing context, | ||
| 513 | * rather than default HW values. If true, it also ensures (insofar as HW | ||
| 514 | * supports) that all state set by this context will not leak to any other | ||
| 515 | * context. | ||
| 516 | * | ||
| 517 | * As not every engine across every gen support contexts, the returned | ||
| 518 | * value reports the support of context isolation for individual engines by | ||
| 519 | * returning a bitmask of each engine class set to true if that class supports | ||
| 520 | * isolation. | ||
| 521 | */ | ||
| 522 | #define I915_PARAM_HAS_CONTEXT_ISOLATION 50 | ||
| 523 | |||
| 524 | /* Frequency of the command streamer timestamps given by the *_TIMESTAMP | ||
| 525 | * registers. This used to be fixed per platform but from CNL onwards, this | ||
| 526 | * might vary depending on the parts. | ||
| 527 | */ | ||
| 528 | #define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51 | ||
| 529 | |||
| 453 | typedef struct drm_i915_getparam { | 530 | typedef struct drm_i915_getparam { |
| 454 | __s32 param; | 531 | __s32 param; |
| 455 | /* | 532 | /* |
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index 8616131e2c61..6d9447700e18 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h | |||
| @@ -163,6 +163,7 @@ enum { | |||
| 163 | IFLA_IF_NETNSID, | 163 | IFLA_IF_NETNSID, |
| 164 | IFLA_CARRIER_UP_COUNT, | 164 | IFLA_CARRIER_UP_COUNT, |
| 165 | IFLA_CARRIER_DOWN_COUNT, | 165 | IFLA_CARRIER_DOWN_COUNT, |
| 166 | IFLA_NEW_IFINDEX, | ||
| 166 | __IFLA_MAX | 167 | __IFLA_MAX |
| 167 | }; | 168 | }; |
| 168 | 169 | ||
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 8fb90a0819c3..0fb5ef939732 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h | |||
| @@ -1362,6 +1362,96 @@ struct kvm_s390_ucas_mapping { | |||
| 1362 | /* Available with KVM_CAP_S390_CMMA_MIGRATION */ | 1362 | /* Available with KVM_CAP_S390_CMMA_MIGRATION */ |
| 1363 | #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) | 1363 | #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) |
| 1364 | #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) | 1364 | #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) |
| 1365 | /* Memory Encryption Commands */ | ||
| 1366 | #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) | ||
| 1367 | |||
| 1368 | struct kvm_enc_region { | ||
| 1369 | __u64 addr; | ||
| 1370 | __u64 size; | ||
| 1371 | }; | ||
| 1372 | |||
| 1373 | #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) | ||
| 1374 | #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) | ||
| 1375 | |||
| 1376 | /* Secure Encrypted Virtualization command */ | ||
| 1377 | enum sev_cmd_id { | ||
| 1378 | /* Guest initialization commands */ | ||
| 1379 | KVM_SEV_INIT = 0, | ||
| 1380 | KVM_SEV_ES_INIT, | ||
| 1381 | /* Guest launch commands */ | ||
| 1382 | KVM_SEV_LAUNCH_START, | ||
| 1383 | KVM_SEV_LAUNCH_UPDATE_DATA, | ||
| 1384 | KVM_SEV_LAUNCH_UPDATE_VMSA, | ||
| 1385 | KVM_SEV_LAUNCH_SECRET, | ||
| 1386 | KVM_SEV_LAUNCH_MEASURE, | ||
| 1387 | KVM_SEV_LAUNCH_FINISH, | ||
| 1388 | /* Guest migration commands (outgoing) */ | ||
| 1389 | KVM_SEV_SEND_START, | ||
| 1390 | KVM_SEV_SEND_UPDATE_DATA, | ||
| 1391 | KVM_SEV_SEND_UPDATE_VMSA, | ||
| 1392 | KVM_SEV_SEND_FINISH, | ||
| 1393 | /* Guest migration commands (incoming) */ | ||
| 1394 | KVM_SEV_RECEIVE_START, | ||
| 1395 | KVM_SEV_RECEIVE_UPDATE_DATA, | ||
| 1396 | KVM_SEV_RECEIVE_UPDATE_VMSA, | ||
| 1397 | KVM_SEV_RECEIVE_FINISH, | ||
| 1398 | /* Guest status and debug commands */ | ||
| 1399 | KVM_SEV_GUEST_STATUS, | ||
| 1400 | KVM_SEV_DBG_DECRYPT, | ||
| 1401 | KVM_SEV_DBG_ENCRYPT, | ||
| 1402 | /* Guest certificates commands */ | ||
| 1403 | KVM_SEV_CERT_EXPORT, | ||
| 1404 | |||
| 1405 | KVM_SEV_NR_MAX, | ||
| 1406 | }; | ||
| 1407 | |||
| 1408 | struct kvm_sev_cmd { | ||
| 1409 | __u32 id; | ||
| 1410 | __u64 data; | ||
| 1411 | __u32 error; | ||
| 1412 | __u32 sev_fd; | ||
| 1413 | }; | ||
| 1414 | |||
| 1415 | struct kvm_sev_launch_start { | ||
| 1416 | __u32 handle; | ||
| 1417 | __u32 policy; | ||
| 1418 | __u64 dh_uaddr; | ||
| 1419 | __u32 dh_len; | ||
| 1420 | __u64 session_uaddr; | ||
| 1421 | __u32 session_len; | ||
| 1422 | }; | ||
| 1423 | |||
| 1424 | struct kvm_sev_launch_update_data { | ||
| 1425 | __u64 uaddr; | ||
| 1426 | __u32 len; | ||
| 1427 | }; | ||
| 1428 | |||
| 1429 | |||
| 1430 | struct kvm_sev_launch_secret { | ||
| 1431 | __u64 hdr_uaddr; | ||
| 1432 | __u32 hdr_len; | ||
| 1433 | __u64 guest_uaddr; | ||
| 1434 | __u32 guest_len; | ||
| 1435 | __u64 trans_uaddr; | ||
| 1436 | __u32 trans_len; | ||
| 1437 | }; | ||
| 1438 | |||
| 1439 | struct kvm_sev_launch_measure { | ||
| 1440 | __u64 uaddr; | ||
| 1441 | __u32 len; | ||
| 1442 | }; | ||
| 1443 | |||
| 1444 | struct kvm_sev_guest_status { | ||
| 1445 | __u32 handle; | ||
| 1446 | __u32 policy; | ||
| 1447 | __u32 state; | ||
| 1448 | }; | ||
| 1449 | |||
| 1450 | struct kvm_sev_dbg { | ||
| 1451 | __u64 src_uaddr; | ||
| 1452 | __u64 dst_uaddr; | ||
| 1453 | __u32 len; | ||
| 1454 | }; | ||
| 1365 | 1455 | ||
| 1366 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | 1456 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) |
| 1367 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) | 1457 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) |
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b00b1896547e..a8cb69a26576 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c | |||
| @@ -852,8 +852,14 @@ static int add_switch_table(struct objtool_file *file, struct symbol *func, | |||
| 852 | * This is a fairly uncommon pattern which is new for GCC 6. As of this | 852 | * This is a fairly uncommon pattern which is new for GCC 6. As of this |
| 853 | * writing, there are 11 occurrences of it in the allmodconfig kernel. | 853 | * writing, there are 11 occurrences of it in the allmodconfig kernel. |
| 854 | * | 854 | * |
| 855 | * As of GCC 7 there are quite a few more of these and the 'in between' code | ||
| 856 | * is significant. Esp. with KASAN enabled some of the code between the mov | ||
| 857 | * and jmpq uses .rodata itself, which can confuse things. | ||
| 858 | * | ||
| 855 | * TODO: Once we have DWARF CFI and smarter instruction decoding logic, | 859 | * TODO: Once we have DWARF CFI and smarter instruction decoding logic, |
| 856 | * ensure the same register is used in the mov and jump instructions. | 860 | * ensure the same register is used in the mov and jump instructions. |
| 861 | * | ||
| 862 | * NOTE: RETPOLINE made it harder still to decode dynamic jumps. | ||
| 857 | */ | 863 | */ |
| 858 | static struct rela *find_switch_table(struct objtool_file *file, | 864 | static struct rela *find_switch_table(struct objtool_file *file, |
| 859 | struct symbol *func, | 865 | struct symbol *func, |
| @@ -875,12 +881,25 @@ static struct rela *find_switch_table(struct objtool_file *file, | |||
| 875 | text_rela->addend + 4); | 881 | text_rela->addend + 4); |
| 876 | if (!rodata_rela) | 882 | if (!rodata_rela) |
| 877 | return NULL; | 883 | return NULL; |
| 884 | |||
| 878 | file->ignore_unreachables = true; | 885 | file->ignore_unreachables = true; |
| 879 | return rodata_rela; | 886 | return rodata_rela; |
| 880 | } | 887 | } |
| 881 | 888 | ||
| 882 | /* case 3 */ | 889 | /* case 3 */ |
| 883 | func_for_each_insn_continue_reverse(file, func, insn) { | 890 | /* |
| 891 | * Backward search using the @first_jump_src links, these help avoid | ||
| 892 | * much of the 'in between' code. Which avoids us getting confused by | ||
| 893 | * it. | ||
| 894 | */ | ||
| 895 | for (insn = list_prev_entry(insn, list); | ||
| 896 | |||
| 897 | &insn->list != &file->insn_list && | ||
| 898 | insn->sec == func->sec && | ||
| 899 | insn->offset >= func->offset; | ||
| 900 | |||
| 901 | insn = insn->first_jump_src ?: list_prev_entry(insn, list)) { | ||
| 902 | |||
| 884 | if (insn->type == INSN_JUMP_DYNAMIC) | 903 | if (insn->type == INSN_JUMP_DYNAMIC) |
| 885 | break; | 904 | break; |
| 886 | 905 | ||
| @@ -910,14 +929,32 @@ static struct rela *find_switch_table(struct objtool_file *file, | |||
| 910 | return NULL; | 929 | return NULL; |
| 911 | } | 930 | } |
| 912 | 931 | ||
| 932 | |||
| 913 | static int add_func_switch_tables(struct objtool_file *file, | 933 | static int add_func_switch_tables(struct objtool_file *file, |
| 914 | struct symbol *func) | 934 | struct symbol *func) |
| 915 | { | 935 | { |
| 916 | struct instruction *insn, *prev_jump = NULL; | 936 | struct instruction *insn, *last = NULL, *prev_jump = NULL; |
| 917 | struct rela *rela, *prev_rela = NULL; | 937 | struct rela *rela, *prev_rela = NULL; |
| 918 | int ret; | 938 | int ret; |
| 919 | 939 | ||
| 920 | func_for_each_insn(file, func, insn) { | 940 | func_for_each_insn(file, func, insn) { |
| 941 | if (!last) | ||
| 942 | last = insn; | ||
| 943 | |||
| 944 | /* | ||
| 945 | * Store back-pointers for unconditional forward jumps such | ||
| 946 | * that find_switch_table() can back-track using those and | ||
| 947 | * avoid some potentially confusing code. | ||
| 948 | */ | ||
| 949 | if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest && | ||
| 950 | insn->offset > last->offset && | ||
| 951 | insn->jump_dest->offset > insn->offset && | ||
| 952 | !insn->jump_dest->first_jump_src) { | ||
| 953 | |||
| 954 | insn->jump_dest->first_jump_src = insn; | ||
| 955 | last = insn->jump_dest; | ||
| 956 | } | ||
| 957 | |||
| 921 | if (insn->type != INSN_JUMP_DYNAMIC) | 958 | if (insn->type != INSN_JUMP_DYNAMIC) |
| 922 | continue; | 959 | continue; |
| 923 | 960 | ||
| @@ -1899,13 +1936,19 @@ static bool ignore_unreachable_insn(struct instruction *insn) | |||
| 1899 | if (is_kasan_insn(insn) || is_ubsan_insn(insn)) | 1936 | if (is_kasan_insn(insn) || is_ubsan_insn(insn)) |
| 1900 | return true; | 1937 | return true; |
| 1901 | 1938 | ||
| 1902 | if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest) { | 1939 | if (insn->type == INSN_JUMP_UNCONDITIONAL) { |
| 1903 | insn = insn->jump_dest; | 1940 | if (insn->jump_dest && |
| 1904 | continue; | 1941 | insn->jump_dest->func == insn->func) { |
| 1942 | insn = insn->jump_dest; | ||
| 1943 | continue; | ||
| 1944 | } | ||
| 1945 | |||
| 1946 | break; | ||
| 1905 | } | 1947 | } |
| 1906 | 1948 | ||
| 1907 | if (insn->offset + insn->len >= insn->func->offset + insn->func->len) | 1949 | if (insn->offset + insn->len >= insn->func->offset + insn->func->len) |
| 1908 | break; | 1950 | break; |
| 1951 | |||
| 1909 | insn = list_next_entry(insn, list); | 1952 | insn = list_next_entry(insn, list); |
| 1910 | } | 1953 | } |
| 1911 | 1954 | ||
diff --git a/tools/objtool/check.h b/tools/objtool/check.h index dbadb304a410..23a1d065cae1 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h | |||
| @@ -47,6 +47,7 @@ struct instruction { | |||
| 47 | bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts; | 47 | bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts; |
| 48 | struct symbol *call_dest; | 48 | struct symbol *call_dest; |
| 49 | struct instruction *jump_dest; | 49 | struct instruction *jump_dest; |
| 50 | struct instruction *first_jump_src; | ||
| 50 | struct list_head alts; | 51 | struct list_head alts; |
| 51 | struct symbol *func; | 52 | struct symbol *func; |
| 52 | struct stack_op stack_op; | 53 | struct stack_op stack_op; |
diff --git a/tools/perf/Documentation/perf-data.txt b/tools/perf/Documentation/perf-data.txt index f0796a47dfa3..90bb4aabe4f8 100644 --- a/tools/perf/Documentation/perf-data.txt +++ b/tools/perf/Documentation/perf-data.txt | |||
| @@ -30,6 +30,10 @@ OPTIONS for 'convert' | |||
| 30 | -i:: | 30 | -i:: |
| 31 | Specify input perf data file path. | 31 | Specify input perf data file path. |
| 32 | 32 | ||
| 33 | -f:: | ||
| 34 | --force:: | ||
| 35 | Don't complain, do it. | ||
| 36 | |||
| 33 | -v:: | 37 | -v:: |
| 34 | --verbose:: | 38 | --verbose:: |
| 35 | Be more verbose (show counter open errors, etc). | 39 | Be more verbose (show counter open errors, etc). |
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile index 48228de415d0..dfa6e3103437 100644 --- a/tools/perf/arch/s390/Makefile +++ b/tools/perf/arch/s390/Makefile | |||
| @@ -10,15 +10,19 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 | |||
| 10 | 10 | ||
| 11 | out := $(OUTPUT)arch/s390/include/generated/asm | 11 | out := $(OUTPUT)arch/s390/include/generated/asm |
| 12 | header := $(out)/syscalls_64.c | 12 | header := $(out)/syscalls_64.c |
| 13 | sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h | 13 | syskrn := $(srctree)/arch/s390/kernel/syscalls/syscall.tbl |
| 14 | sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/ | 14 | sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls |
| 15 | sysdef := $(sysprf)/syscall.tbl | ||
| 15 | systbl := $(sysprf)/mksyscalltbl | 16 | systbl := $(sysprf)/mksyscalltbl |
| 16 | 17 | ||
| 17 | # Create output directory if not already present | 18 | # Create output directory if not already present |
| 18 | _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') | 19 | _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') |
| 19 | 20 | ||
| 20 | $(header): $(sysdef) $(systbl) | 21 | $(header): $(sysdef) $(systbl) |
| 21 | $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@ | 22 | @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ |
| 23 | (diff -B $(sysdef) $(syskrn) >/dev/null) \ | ||
| 24 | || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true | ||
| 25 | $(Q)$(SHELL) '$(systbl)' $(sysdef) > $@ | ||
| 22 | 26 | ||
| 23 | clean:: | 27 | clean:: |
| 24 | $(call QUIET_CLEAN, s390) $(RM) $(header) | 28 | $(call QUIET_CLEAN, s390) $(RM) $(header) |
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl index 7fa0d0abd419..72ecbb676370 100755 --- a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl +++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl | |||
| @@ -3,25 +3,23 @@ | |||
| 3 | # | 3 | # |
| 4 | # Generate system call table for perf | 4 | # Generate system call table for perf |
| 5 | # | 5 | # |
| 6 | # | 6 | # Copyright IBM Corp. 2017, 2018 |
| 7 | # Copyright IBM Corp. 2017 | ||
| 8 | # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | 7 | # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> |
| 9 | # | 8 | # |
| 10 | 9 | ||
| 11 | gcc=$1 | 10 | SYSCALL_TBL=$1 |
| 12 | input=$2 | ||
| 13 | 11 | ||
| 14 | if ! test -r $input; then | 12 | if ! test -r $SYSCALL_TBL; then |
| 15 | echo "Could not read input file" >&2 | 13 | echo "Could not read input file" >&2 |
| 16 | exit 1 | 14 | exit 1 |
| 17 | fi | 15 | fi |
| 18 | 16 | ||
| 19 | create_table() | 17 | create_table() |
| 20 | { | 18 | { |
| 21 | local max_nr | 19 | local max_nr nr abi sc discard |
| 22 | 20 | ||
| 23 | echo 'static const char *syscalltbl_s390_64[] = {' | 21 | echo 'static const char *syscalltbl_s390_64[] = {' |
| 24 | while read sc nr; do | 22 | while read nr abi sc discard; do |
| 25 | printf '\t[%d] = "%s",\n' $nr $sc | 23 | printf '\t[%d] = "%s",\n' $nr $sc |
| 26 | max_nr=$nr | 24 | max_nr=$nr |
| 27 | done | 25 | done |
| @@ -29,8 +27,6 @@ create_table() | |||
| 29 | echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr" | 27 | echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr" |
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | 30 | grep -E "^[[:digit:]]+[[:space:]]+(common|64)" $SYSCALL_TBL \ | |
| 33 | $gcc -m64 -E -dM -x c $input \ | 31 | |sort -k1 -n \ |
| 34 | |sed -ne 's/^#define __NR_//p' \ | ||
| 35 | |sort -t' ' -k2 -nu \ | ||
| 36 | |create_table | 32 | |create_table |
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl new file mode 100644 index 000000000000..b38d48464368 --- /dev/null +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl | |||
| @@ -0,0 +1,390 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note | ||
| 2 | # | ||
| 3 | # System call table for s390 | ||
| 4 | # | ||
| 5 | # Format: | ||
| 6 | # | ||
| 7 | # <nr> <abi> <syscall> <entry-64bit> <compat-entry> | ||
| 8 | # | ||
| 9 | # where <abi> can be common, 64, or 32 | ||
| 10 | |||
| 11 | 1 common exit sys_exit sys_exit | ||
| 12 | 2 common fork sys_fork sys_fork | ||
| 13 | 3 common read sys_read compat_sys_s390_read | ||
| 14 | 4 common write sys_write compat_sys_s390_write | ||
| 15 | 5 common open sys_open compat_sys_open | ||
| 16 | 6 common close sys_close sys_close | ||
| 17 | 7 common restart_syscall sys_restart_syscall sys_restart_syscall | ||
| 18 | 8 common creat sys_creat compat_sys_creat | ||
| 19 | 9 common link sys_link compat_sys_link | ||
| 20 | 10 common unlink sys_unlink compat_sys_unlink | ||
| 21 | 11 common execve sys_execve compat_sys_execve | ||
| 22 | 12 common chdir sys_chdir compat_sys_chdir | ||
| 23 | 13 32 time - compat_sys_time | ||
| 24 | 14 common mknod sys_mknod compat_sys_mknod | ||
| 25 | 15 common chmod sys_chmod compat_sys_chmod | ||
| 26 | 16 32 lchown - compat_sys_s390_lchown16 | ||
| 27 | 19 common lseek sys_lseek compat_sys_lseek | ||
| 28 | 20 common getpid sys_getpid sys_getpid | ||
| 29 | 21 common mount sys_mount compat_sys_mount | ||
| 30 | 22 common umount sys_oldumount compat_sys_oldumount | ||
| 31 | 23 32 setuid - compat_sys_s390_setuid16 | ||
| 32 | 24 32 getuid - compat_sys_s390_getuid16 | ||
| 33 | 25 32 stime - compat_sys_stime | ||
| 34 | 26 common ptrace sys_ptrace compat_sys_ptrace | ||
| 35 | 27 common alarm sys_alarm sys_alarm | ||
| 36 | 29 common pause sys_pause sys_pause | ||
| 37 | 30 common utime sys_utime compat_sys_utime | ||
| 38 | 33 common access sys_access compat_sys_access | ||
| 39 | 34 common nice sys_nice sys_nice | ||
| 40 | 36 common sync sys_sync sys_sync | ||
| 41 | 37 common kill sys_kill sys_kill | ||
| 42 | 38 common rename sys_rename compat_sys_rename | ||
| 43 | 39 common mkdir sys_mkdir compat_sys_mkdir | ||
| 44 | 40 common rmdir sys_rmdir compat_sys_rmdir | ||
| 45 | 41 common dup sys_dup sys_dup | ||
| 46 | 42 common pipe sys_pipe compat_sys_pipe | ||
| 47 | 43 common times sys_times compat_sys_times | ||
| 48 | 45 common brk sys_brk compat_sys_brk | ||
| 49 | 46 32 setgid - compat_sys_s390_setgid16 | ||
| 50 | 47 32 getgid - compat_sys_s390_getgid16 | ||
| 51 | 48 common signal sys_signal compat_sys_signal | ||
| 52 | 49 32 geteuid - compat_sys_s390_geteuid16 | ||
| 53 | 50 32 getegid - compat_sys_s390_getegid16 | ||
| 54 | 51 common acct sys_acct compat_sys_acct | ||
| 55 | 52 common umount2 sys_umount compat_sys_umount | ||
| 56 | 54 common ioctl sys_ioctl compat_sys_ioctl | ||
| 57 | 55 common fcntl sys_fcntl compat_sys_fcntl | ||
| 58 | 57 common setpgid sys_setpgid sys_setpgid | ||
| 59 | 60 common umask sys_umask sys_umask | ||
| 60 | 61 common chroot sys_chroot compat_sys_chroot | ||
| 61 | 62 common ustat sys_ustat compat_sys_ustat | ||
| 62 | 63 common dup2 sys_dup2 sys_dup2 | ||
| 63 | 64 common getppid sys_getppid sys_getppid | ||
| 64 | 65 common getpgrp sys_getpgrp sys_getpgrp | ||
| 65 | 66 common setsid sys_setsid sys_setsid | ||
| 66 | 67 common sigaction sys_sigaction compat_sys_sigaction | ||
| 67 | 70 32 setreuid - compat_sys_s390_setreuid16 | ||
| 68 | 71 32 setregid - compat_sys_s390_setregid16 | ||
| 69 | 72 common sigsuspend sys_sigsuspend compat_sys_sigsuspend | ||
| 70 | 73 common sigpending sys_sigpending compat_sys_sigpending | ||
| 71 | 74 common sethostname sys_sethostname compat_sys_sethostname | ||
| 72 | 75 common setrlimit sys_setrlimit compat_sys_setrlimit | ||
| 73 | 76 32 getrlimit - compat_sys_old_getrlimit | ||
| 74 | 77 common getrusage sys_getrusage compat_sys_getrusage | ||
| 75 | 78 common gettimeofday sys_gettimeofday compat_sys_gettimeofday | ||
| 76 | 79 common settimeofday sys_settimeofday compat_sys_settimeofday | ||
| 77 | 80 32 getgroups - compat_sys_s390_getgroups16 | ||
| 78 | 81 32 setgroups - compat_sys_s390_setgroups16 | ||
| 79 | 83 common symlink sys_symlink compat_sys_symlink | ||
| 80 | 85 common readlink sys_readlink compat_sys_readlink | ||
| 81 | 86 common uselib sys_uselib compat_sys_uselib | ||
| 82 | 87 common swapon sys_swapon compat_sys_swapon | ||
| 83 | 88 common reboot sys_reboot compat_sys_reboot | ||
| 84 | 89 common readdir - compat_sys_old_readdir | ||
| 85 | 90 common mmap sys_old_mmap compat_sys_s390_old_mmap | ||
| 86 | 91 common munmap sys_munmap compat_sys_munmap | ||
| 87 | 92 common truncate sys_truncate compat_sys_truncate | ||
| 88 | 93 common ftruncate sys_ftruncate compat_sys_ftruncate | ||
| 89 | 94 common fchmod sys_fchmod sys_fchmod | ||
| 90 | 95 32 fchown - compat_sys_s390_fchown16 | ||
| 91 | 96 common getpriority sys_getpriority sys_getpriority | ||
| 92 | 97 common setpriority sys_setpriority sys_setpriority | ||
| 93 | 99 common statfs sys_statfs compat_sys_statfs | ||
| 94 | 100 common fstatfs sys_fstatfs compat_sys_fstatfs | ||
| 95 | 101 32 ioperm - - | ||
| 96 | 102 common socketcall sys_socketcall compat_sys_socketcall | ||
| 97 | 103 common syslog sys_syslog compat_sys_syslog | ||
| 98 | 104 common setitimer sys_setitimer compat_sys_setitimer | ||
| 99 | 105 common getitimer sys_getitimer compat_sys_getitimer | ||
| 100 | 106 common stat sys_newstat compat_sys_newstat | ||
| 101 | 107 common lstat sys_newlstat compat_sys_newlstat | ||
| 102 | 108 common fstat sys_newfstat compat_sys_newfstat | ||
| 103 | 110 common lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie | ||
| 104 | 111 common vhangup sys_vhangup sys_vhangup | ||
| 105 | 112 common idle - - | ||
| 106 | 114 common wait4 sys_wait4 compat_sys_wait4 | ||
| 107 | 115 common swapoff sys_swapoff compat_sys_swapoff | ||
| 108 | 116 common sysinfo sys_sysinfo compat_sys_sysinfo | ||
| 109 | 117 common ipc sys_s390_ipc compat_sys_s390_ipc | ||
| 110 | 118 common fsync sys_fsync sys_fsync | ||
| 111 | 119 common sigreturn sys_sigreturn compat_sys_sigreturn | ||
| 112 | 120 common clone sys_clone compat_sys_clone | ||
| 113 | 121 common setdomainname sys_setdomainname compat_sys_setdomainname | ||
| 114 | 122 common uname sys_newuname compat_sys_newuname | ||
| 115 | 124 common adjtimex sys_adjtimex compat_sys_adjtimex | ||
| 116 | 125 common mprotect sys_mprotect compat_sys_mprotect | ||
| 117 | 126 common sigprocmask sys_sigprocmask compat_sys_sigprocmask | ||
| 118 | 127 common create_module - - | ||
| 119 | 128 common init_module sys_init_module compat_sys_init_module | ||
| 120 | 129 common delete_module sys_delete_module compat_sys_delete_module | ||
| 121 | 130 common get_kernel_syms - - | ||
| 122 | 131 common quotactl sys_quotactl compat_sys_quotactl | ||
| 123 | 132 common getpgid sys_getpgid sys_getpgid | ||
| 124 | 133 common fchdir sys_fchdir sys_fchdir | ||
| 125 | 134 common bdflush sys_bdflush compat_sys_bdflush | ||
| 126 | 135 common sysfs sys_sysfs compat_sys_sysfs | ||
| 127 | 136 common personality sys_s390_personality sys_s390_personality | ||
| 128 | 137 common afs_syscall - - | ||
| 129 | 138 32 setfsuid - compat_sys_s390_setfsuid16 | ||
| 130 | 139 32 setfsgid - compat_sys_s390_setfsgid16 | ||
| 131 | 140 32 _llseek - compat_sys_llseek | ||
| 132 | 141 common getdents sys_getdents compat_sys_getdents | ||
| 133 | 142 32 _newselect - compat_sys_select | ||
| 134 | 142 64 select sys_select - | ||
| 135 | 143 common flock sys_flock sys_flock | ||
| 136 | 144 common msync sys_msync compat_sys_msync | ||
| 137 | 145 common readv sys_readv compat_sys_readv | ||
| 138 | 146 common writev sys_writev compat_sys_writev | ||
| 139 | 147 common getsid sys_getsid sys_getsid | ||
| 140 | 148 common fdatasync sys_fdatasync sys_fdatasync | ||
| 141 | 149 common _sysctl sys_sysctl compat_sys_sysctl | ||
| 142 | 150 common mlock sys_mlock compat_sys_mlock | ||
| 143 | 151 common munlock sys_munlock compat_sys_munlock | ||
| 144 | 152 common mlockall sys_mlockall sys_mlockall | ||
| 145 | 153 common munlockall sys_munlockall sys_munlockall | ||
| 146 | 154 common sched_setparam sys_sched_setparam compat_sys_sched_setparam | ||
| 147 | 155 common sched_getparam sys_sched_getparam compat_sys_sched_getparam | ||
| 148 | 156 common sched_setscheduler sys_sched_setscheduler compat_sys_sched_setscheduler | ||
| 149 | 157 common sched_getscheduler sys_sched_getscheduler sys_sched_getscheduler | ||
| 150 | 158 common sched_yield sys_sched_yield sys_sched_yield | ||
| 151 | 159 common sched_get_priority_max sys_sched_get_priority_max sys_sched_get_priority_max | ||
| 152 | 160 common sched_get_priority_min sys_sched_get_priority_min sys_sched_get_priority_min | ||
| 153 | 161 common sched_rr_get_interval sys_sched_rr_get_interval compat_sys_sched_rr_get_interval | ||
| 154 | 162 common nanosleep sys_nanosleep compat_sys_nanosleep | ||
| 155 | 163 common mremap sys_mremap compat_sys_mremap | ||
| 156 | 164 32 setresuid - compat_sys_s390_setresuid16 | ||
| 157 | 165 32 getresuid - compat_sys_s390_getresuid16 | ||
| 158 | 167 common query_module - - | ||
| 159 | 168 common poll sys_poll compat_sys_poll | ||
| 160 | 169 common nfsservctl - - | ||
| 161 | 170 32 setresgid - compat_sys_s390_setresgid16 | ||
| 162 | 171 32 getresgid - compat_sys_s390_getresgid16 | ||
| 163 | 172 common prctl sys_prctl compat_sys_prctl | ||
| 164 | 173 common rt_sigreturn sys_rt_sigreturn compat_sys_rt_sigreturn | ||
| 165 | 174 common rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction | ||
| 166 | 175 common rt_sigprocmask sys_rt_sigprocmask compat_sys_rt_sigprocmask | ||
| 167 | 176 common rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending | ||
| 168 | 177 common rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait | ||
| 169 | 178 common rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo | ||
| 170 | 179 common rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend | ||
| 171 | 180 common pread64 sys_pread64 compat_sys_s390_pread64 | ||
| 172 | 181 common pwrite64 sys_pwrite64 compat_sys_s390_pwrite64 | ||
| 173 | 182 32 chown - compat_sys_s390_chown16 | ||
| 174 | 183 common getcwd sys_getcwd compat_sys_getcwd | ||
| 175 | 184 common capget sys_capget compat_sys_capget | ||
| 176 | 185 common capset sys_capset compat_sys_capset | ||
| 177 | 186 common sigaltstack sys_sigaltstack compat_sys_sigaltstack | ||
| 178 | 187 common sendfile sys_sendfile64 compat_sys_sendfile | ||
| 179 | 188 common getpmsg - - | ||
| 180 | 189 common putpmsg - - | ||
| 181 | 190 common vfork sys_vfork sys_vfork | ||
| 182 | 191 32 ugetrlimit - compat_sys_getrlimit | ||
| 183 | 191 64 getrlimit sys_getrlimit - | ||
| 184 | 192 32 mmap2 - compat_sys_s390_mmap2 | ||
| 185 | 193 32 truncate64 - compat_sys_s390_truncate64 | ||
| 186 | 194 32 ftruncate64 - compat_sys_s390_ftruncate64 | ||
| 187 | 195 32 stat64 - compat_sys_s390_stat64 | ||
| 188 | 196 32 lstat64 - compat_sys_s390_lstat64 | ||
| 189 | 197 32 fstat64 - compat_sys_s390_fstat64 | ||
| 190 | 198 32 lchown32 - compat_sys_lchown | ||
| 191 | 198 64 lchown sys_lchown - | ||
| 192 | 199 32 getuid32 - sys_getuid | ||
| 193 | 199 64 getuid sys_getuid - | ||
| 194 | 200 32 getgid32 - sys_getgid | ||
| 195 | 200 64 getgid sys_getgid - | ||
| 196 | 201 32 geteuid32 - sys_geteuid | ||
| 197 | 201 64 geteuid sys_geteuid - | ||
| 198 | 202 32 getegid32 - sys_getegid | ||
| 199 | 202 64 getegid sys_getegid - | ||
| 200 | 203 32 setreuid32 - sys_setreuid | ||
| 201 | 203 64 setreuid sys_setreuid - | ||
| 202 | 204 32 setregid32 - sys_setregid | ||
| 203 | 204 64 setregid sys_setregid - | ||
| 204 | 205 32 getgroups32 - compat_sys_getgroups | ||
| 205 | 205 64 getgroups sys_getgroups - | ||
| 206 | 206 32 setgroups32 - compat_sys_setgroups | ||
| 207 | 206 64 setgroups sys_setgroups - | ||
| 208 | 207 32 fchown32 - sys_fchown | ||
| 209 | 207 64 fchown sys_fchown - | ||
| 210 | 208 32 setresuid32 - sys_setresuid | ||
| 211 | 208 64 setresuid sys_setresuid - | ||
| 212 | 209 32 getresuid32 - compat_sys_getresuid | ||
| 213 | 209 64 getresuid sys_getresuid - | ||
| 214 | 210 32 setresgid32 - sys_setresgid | ||
| 215 | 210 64 setresgid sys_setresgid - | ||
| 216 | 211 32 getresgid32 - compat_sys_getresgid | ||
| 217 | 211 64 getresgid sys_getresgid - | ||
| 218 | 212 32 chown32 - compat_sys_chown | ||
| 219 | 212 64 chown sys_chown - | ||
| 220 | 213 32 setuid32 - sys_setuid | ||
| 221 | 213 64 setuid sys_setuid - | ||
| 222 | 214 32 setgid32 - sys_setgid | ||
| 223 | 214 64 setgid sys_setgid - | ||
| 224 | 215 32 setfsuid32 - sys_setfsuid | ||
| 225 | 215 64 setfsuid sys_setfsuid - | ||
| 226 | 216 32 setfsgid32 - sys_setfsgid | ||
| 227 | 216 64 setfsgid sys_setfsgid - | ||
| 228 | 217 common pivot_root sys_pivot_root compat_sys_pivot_root | ||
| 229 | 218 common mincore sys_mincore compat_sys_mincore | ||
| 230 | 219 common madvise sys_madvise compat_sys_madvise | ||
| 231 | 220 common getdents64 sys_getdents64 compat_sys_getdents64 | ||
| 232 | 221 32 fcntl64 - compat_sys_fcntl64 | ||
| 233 | 222 common readahead sys_readahead compat_sys_s390_readahead | ||
| 234 | 223 32 sendfile64 - compat_sys_sendfile64 | ||
| 235 | 224 common setxattr sys_setxattr compat_sys_setxattr | ||
| 236 | 225 common lsetxattr sys_lsetxattr compat_sys_lsetxattr | ||
| 237 | 226 common fsetxattr sys_fsetxattr compat_sys_fsetxattr | ||
| 238 | 227 common getxattr sys_getxattr compat_sys_getxattr | ||
| 239 | 228 common lgetxattr sys_lgetxattr compat_sys_lgetxattr | ||
| 240 | 229 common fgetxattr sys_fgetxattr compat_sys_fgetxattr | ||
| 241 | 230 common listxattr sys_listxattr compat_sys_listxattr | ||
| 242 | 231 common llistxattr sys_llistxattr compat_sys_llistxattr | ||
| 243 | 232 common flistxattr sys_flistxattr compat_sys_flistxattr | ||
| 244 | 233 common removexattr sys_removexattr compat_sys_removexattr | ||
| 245 | 234 common lremovexattr sys_lremovexattr compat_sys_lremovexattr | ||
| 246 | 235 common fremovexattr sys_fremovexattr compat_sys_fremovexattr | ||
| 247 | 236 common gettid sys_gettid sys_gettid | ||
| 248 | 237 common tkill sys_tkill sys_tkill | ||
| 249 | 238 common futex sys_futex compat_sys_futex | ||
| 250 | 239 common sched_setaffinity sys_sched_setaffinity compat_sys_sched_setaffinity | ||
| 251 | 240 common sched_getaffinity sys_sched_getaffinity compat_sys_sched_getaffinity | ||
| 252 | 241 common tgkill sys_tgkill sys_tgkill | ||
| 253 | 243 common io_setup sys_io_setup compat_sys_io_setup | ||
| 254 | 244 common io_destroy sys_io_destroy compat_sys_io_destroy | ||
| 255 | 245 common io_getevents sys_io_getevents compat_sys_io_getevents | ||
| 256 | 246 common io_submit sys_io_submit compat_sys_io_submit | ||
| 257 | 247 common io_cancel sys_io_cancel compat_sys_io_cancel | ||
| 258 | 248 common exit_group sys_exit_group sys_exit_group | ||
| 259 | 249 common epoll_create sys_epoll_create sys_epoll_create | ||
| 260 | 250 common epoll_ctl sys_epoll_ctl compat_sys_epoll_ctl | ||
| 261 | 251 common epoll_wait sys_epoll_wait compat_sys_epoll_wait | ||
| 262 | 252 common set_tid_address sys_set_tid_address compat_sys_set_tid_address | ||
| 263 | 253 common fadvise64 sys_fadvise64_64 compat_sys_s390_fadvise64 | ||
| 264 | 254 common timer_create sys_timer_create compat_sys_timer_create | ||
| 265 | 255 common timer_settime sys_timer_settime compat_sys_timer_settime | ||
| 266 | 256 common timer_gettime sys_timer_gettime compat_sys_timer_gettime | ||
| 267 | 257 common timer_getoverrun sys_timer_getoverrun sys_timer_getoverrun | ||
| 268 | 258 common timer_delete sys_timer_delete sys_timer_delete | ||
| 269 | 259 common clock_settime sys_clock_settime compat_sys_clock_settime | ||
| 270 | 260 common clock_gettime sys_clock_gettime compat_sys_clock_gettime | ||
| 271 | 261 common clock_getres sys_clock_getres compat_sys_clock_getres | ||
| 272 | 262 common clock_nanosleep sys_clock_nanosleep compat_sys_clock_nanosleep | ||
| 273 | 264 32 fadvise64_64 - compat_sys_s390_fadvise64_64 | ||
| 274 | 265 common statfs64 sys_statfs64 compat_sys_statfs64 | ||
| 275 | 266 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64 | ||
| 276 | 267 common remap_file_pages sys_remap_file_pages compat_sys_remap_file_pages | ||
| 277 | 268 common mbind sys_mbind compat_sys_mbind | ||
| 278 | 269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy | ||
| 279 | 270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy | ||
| 280 | 271 common mq_open sys_mq_open compat_sys_mq_open | ||
| 281 | 272 common mq_unlink sys_mq_unlink compat_sys_mq_unlink | ||
| 282 | 273 common mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend | ||
| 283 | 274 common mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive | ||
| 284 | 275 common mq_notify sys_mq_notify compat_sys_mq_notify | ||
| 285 | 276 common mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr | ||
| 286 | 277 common kexec_load sys_kexec_load compat_sys_kexec_load | ||
| 287 | 278 common add_key sys_add_key compat_sys_add_key | ||
| 288 | 279 common request_key sys_request_key compat_sys_request_key | ||
| 289 | 280 common keyctl sys_keyctl compat_sys_keyctl | ||
| 290 | 281 common waitid sys_waitid compat_sys_waitid | ||
| 291 | 282 common ioprio_set sys_ioprio_set sys_ioprio_set | ||
| 292 | 283 common ioprio_get sys_ioprio_get sys_ioprio_get | ||
| 293 | 284 common inotify_init sys_inotify_init sys_inotify_init | ||
| 294 | 285 common inotify_add_watch sys_inotify_add_watch compat_sys_inotify_add_watch | ||
| 295 | 286 common inotify_rm_watch sys_inotify_rm_watch sys_inotify_rm_watch | ||
| 296 | 287 common migrate_pages sys_migrate_pages compat_sys_migrate_pages | ||
| 297 | 288 common openat sys_openat compat_sys_openat | ||
| 298 | 289 common mkdirat sys_mkdirat compat_sys_mkdirat | ||
| 299 | 290 common mknodat sys_mknodat compat_sys_mknodat | ||
| 300 | 291 common fchownat sys_fchownat compat_sys_fchownat | ||
| 301 | 292 common futimesat sys_futimesat compat_sys_futimesat | ||
| 302 | 293 32 fstatat64 - compat_sys_s390_fstatat64 | ||
| 303 | 293 64 newfstatat sys_newfstatat - | ||
| 304 | 294 common unlinkat sys_unlinkat compat_sys_unlinkat | ||
| 305 | 295 common renameat sys_renameat compat_sys_renameat | ||
| 306 | 296 common linkat sys_linkat compat_sys_linkat | ||
| 307 | 297 common symlinkat sys_symlinkat compat_sys_symlinkat | ||
| 308 | 298 common readlinkat sys_readlinkat compat_sys_readlinkat | ||
| 309 | 299 common fchmodat sys_fchmodat compat_sys_fchmodat | ||
| 310 | 300 common faccessat sys_faccessat compat_sys_faccessat | ||
| 311 | 301 common pselect6 sys_pselect6 compat_sys_pselect6 | ||
| 312 | 302 common ppoll sys_ppoll compat_sys_ppoll | ||
| 313 | 303 common unshare sys_unshare compat_sys_unshare | ||
| 314 | 304 common set_robust_list sys_set_robust_list compat_sys_set_robust_list | ||
| 315 | 305 common get_robust_list sys_get_robust_list compat_sys_get_robust_list | ||
| 316 | 306 common splice sys_splice compat_sys_splice | ||
| 317 | 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range | ||
| 318 | 308 common tee sys_tee compat_sys_tee | ||
| 319 | 309 common vmsplice sys_vmsplice compat_sys_vmsplice | ||
| 320 | 310 common move_pages sys_move_pages compat_sys_move_pages | ||
| 321 | 311 common getcpu sys_getcpu compat_sys_getcpu | ||
| 322 | 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait | ||
| 323 | 313 common utimes sys_utimes compat_sys_utimes | ||
| 324 | 314 common fallocate sys_fallocate compat_sys_s390_fallocate | ||
| 325 | 315 common utimensat sys_utimensat compat_sys_utimensat | ||
| 326 | 316 common signalfd sys_signalfd compat_sys_signalfd | ||
| 327 | 317 common timerfd - - | ||
| 328 | 318 common eventfd sys_eventfd sys_eventfd | ||
| 329 | 319 common timerfd_create sys_timerfd_create sys_timerfd_create | ||
| 330 | 320 common timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime | ||
| 331 | 321 common timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime | ||
| 332 | 322 common signalfd4 sys_signalfd4 compat_sys_signalfd4 | ||
| 333 | 323 common eventfd2 sys_eventfd2 sys_eventfd2 | ||
| 334 | 324 common inotify_init1 sys_inotify_init1 sys_inotify_init1 | ||
| 335 | 325 common pipe2 sys_pipe2 compat_sys_pipe2 | ||
| 336 | 326 common dup3 sys_dup3 sys_dup3 | ||
| 337 | 327 common epoll_create1 sys_epoll_create1 sys_epoll_create1 | ||
| 338 | 328 common preadv sys_preadv compat_sys_preadv | ||
| 339 | 329 common pwritev sys_pwritev compat_sys_pwritev | ||
| 340 | 330 common rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo | ||
| 341 | 331 common perf_event_open sys_perf_event_open compat_sys_perf_event_open | ||
| 342 | 332 common fanotify_init sys_fanotify_init sys_fanotify_init | ||
| 343 | 333 common fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark | ||
| 344 | 334 common prlimit64 sys_prlimit64 compat_sys_prlimit64 | ||
| 345 | 335 common name_to_handle_at sys_name_to_handle_at compat_sys_name_to_handle_at | ||
| 346 | 336 common open_by_handle_at sys_open_by_handle_at compat_sys_open_by_handle_at | ||
| 347 | 337 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime | ||
| 348 | 338 common syncfs sys_syncfs sys_syncfs | ||
| 349 | 339 common setns sys_setns sys_setns | ||
| 350 | 340 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv | ||
| 351 | 341 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev | ||
| 352 | 342 common s390_runtime_instr sys_s390_runtime_instr sys_s390_runtime_instr | ||
| 353 | 343 common kcmp sys_kcmp compat_sys_kcmp | ||
| 354 | 344 common finit_module sys_finit_module compat_sys_finit_module | ||
| 355 | 345 common sched_setattr sys_sched_setattr compat_sys_sched_setattr | ||
| 356 | 346 common sched_getattr sys_sched_getattr compat_sys_sched_getattr | ||
| 357 | 347 common renameat2 sys_renameat2 compat_sys_renameat2 | ||
| 358 | 348 common seccomp sys_seccomp compat_sys_seccomp | ||
| 359 | 349 common getrandom sys_getrandom compat_sys_getrandom | ||
| 360 | 350 common memfd_create sys_memfd_create compat_sys_memfd_create | ||
| 361 | 351 common bpf sys_bpf compat_sys_bpf | ||
| 362 | 352 common s390_pci_mmio_write sys_s390_pci_mmio_write compat_sys_s390_pci_mmio_write | ||
| 363 | 353 common s390_pci_mmio_read sys_s390_pci_mmio_read compat_sys_s390_pci_mmio_read | ||
| 364 | 354 common execveat sys_execveat compat_sys_execveat | ||
| 365 | 355 common userfaultfd sys_userfaultfd sys_userfaultfd | ||
| 366 | 356 common membarrier sys_membarrier sys_membarrier | ||
| 367 | 357 common recvmmsg sys_recvmmsg compat_sys_recvmmsg | ||
| 368 | 358 common sendmmsg sys_sendmmsg compat_sys_sendmmsg | ||
| 369 | 359 common socket sys_socket sys_socket | ||
| 370 | 360 common socketpair sys_socketpair compat_sys_socketpair | ||
| 371 | 361 common bind sys_bind compat_sys_bind | ||
| 372 | 362 common connect sys_connect compat_sys_connect | ||
| 373 | 363 common listen sys_listen sys_listen | ||
| 374 | 364 common accept4 sys_accept4 compat_sys_accept4 | ||
| 375 | 365 common getsockopt sys_getsockopt compat_sys_getsockopt | ||
| 376 | 366 common setsockopt sys_setsockopt compat_sys_setsockopt | ||
| 377 | 367 common getsockname sys_getsockname compat_sys_getsockname | ||
| 378 | 368 common getpeername sys_getpeername compat_sys_getpeername | ||
| 379 | 369 common sendto sys_sendto compat_sys_sendto | ||
| 380 | 370 common sendmsg sys_sendmsg compat_sys_sendmsg | ||
| 381 | 371 common recvfrom sys_recvfrom compat_sys_recvfrom | ||
| 382 | 372 common recvmsg sys_recvmsg compat_sys_recvmsg | ||
| 383 | 373 common shutdown sys_shutdown sys_shutdown | ||
| 384 | 374 common mlock2 sys_mlock2 compat_sys_mlock2 | ||
| 385 | 375 common copy_file_range sys_copy_file_range compat_sys_copy_file_range | ||
| 386 | 376 common preadv2 sys_preadv2 compat_sys_preadv2 | ||
| 387 | 377 common pwritev2 sys_pwritev2 compat_sys_pwritev2 | ||
| 388 | 378 common s390_guarded_storage sys_s390_guarded_storage compat_sys_s390_guarded_storage | ||
| 389 | 379 common statx sys_statx compat_sys_statx | ||
| 390 | 380 common s390_sthyi sys_s390_sthyi compat_sys_s390_sthyi | ||
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c0815a37fdb5..539c3d460158 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
| @@ -2245,7 +2245,7 @@ static int perf_c2c__browse_cacheline(struct hist_entry *he) | |||
| 2245 | c2c_browser__update_nr_entries(browser); | 2245 | c2c_browser__update_nr_entries(browser); |
| 2246 | 2246 | ||
| 2247 | while (1) { | 2247 | while (1) { |
| 2248 | key = hist_browser__run(browser, "? - help"); | 2248 | key = hist_browser__run(browser, "? - help", true); |
| 2249 | 2249 | ||
| 2250 | switch (key) { | 2250 | switch (key) { |
| 2251 | case 's': | 2251 | case 's': |
| @@ -2314,7 +2314,7 @@ static int perf_c2c__hists_browse(struct hists *hists) | |||
| 2314 | c2c_browser__update_nr_entries(browser); | 2314 | c2c_browser__update_nr_entries(browser); |
| 2315 | 2315 | ||
| 2316 | while (1) { | 2316 | while (1) { |
| 2317 | key = hist_browser__run(browser, "? - help"); | 2317 | key = hist_browser__run(browser, "? - help", true); |
| 2318 | 2318 | ||
| 2319 | switch (key) { | 2319 | switch (key) { |
| 2320 | case 'q': | 2320 | case 'q': |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 42a52dcc41cd..4ad5dc649716 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -530,7 +530,8 @@ static int report__browse_hists(struct report *rep) | |||
| 530 | case 1: | 530 | case 1: |
| 531 | ret = perf_evlist__tui_browse_hists(evlist, help, NULL, | 531 | ret = perf_evlist__tui_browse_hists(evlist, help, NULL, |
| 532 | rep->min_percent, | 532 | rep->min_percent, |
| 533 | &session->header.env); | 533 | &session->header.env, |
| 534 | true); | ||
| 534 | /* | 535 | /* |
| 535 | * Usually "ret" is the last pressed key, and we only | 536 | * Usually "ret" is the last pressed key, and we only |
| 536 | * care if the key notifies us to switch data file. | 537 | * care if the key notifies us to switch data file. |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c6ccda52117d..b7c823ba8374 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -283,8 +283,9 @@ static void perf_top__print_sym_table(struct perf_top *top) | |||
| 283 | 283 | ||
| 284 | printf("%-*.*s\n", win_width, win_width, graph_dotted_line); | 284 | printf("%-*.*s\n", win_width, win_width, graph_dotted_line); |
| 285 | 285 | ||
| 286 | if (hists->stats.nr_lost_warned != | 286 | if (!top->record_opts.overwrite && |
| 287 | hists->stats.nr_events[PERF_RECORD_LOST]) { | 287 | (hists->stats.nr_lost_warned != |
| 288 | hists->stats.nr_events[PERF_RECORD_LOST])) { | ||
| 288 | hists->stats.nr_lost_warned = | 289 | hists->stats.nr_lost_warned = |
| 289 | hists->stats.nr_events[PERF_RECORD_LOST]; | 290 | hists->stats.nr_events[PERF_RECORD_LOST]; |
| 290 | color_fprintf(stdout, PERF_COLOR_RED, | 291 | color_fprintf(stdout, PERF_COLOR_RED, |
| @@ -611,7 +612,8 @@ static void *display_thread_tui(void *arg) | |||
| 611 | 612 | ||
| 612 | perf_evlist__tui_browse_hists(top->evlist, help, &hbt, | 613 | perf_evlist__tui_browse_hists(top->evlist, help, &hbt, |
| 613 | top->min_percent, | 614 | top->min_percent, |
| 614 | &top->session->header.env); | 615 | &top->session->header.env, |
| 616 | !top->record_opts.overwrite); | ||
| 615 | 617 | ||
| 616 | done = 1; | 618 | done = 1; |
| 617 | return NULL; | 619 | return NULL; |
| @@ -807,15 +809,23 @@ static void perf_event__process_sample(struct perf_tool *tool, | |||
| 807 | 809 | ||
| 808 | static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | 810 | static void perf_top__mmap_read_idx(struct perf_top *top, int idx) |
| 809 | { | 811 | { |
| 812 | struct record_opts *opts = &top->record_opts; | ||
| 813 | struct perf_evlist *evlist = top->evlist; | ||
| 810 | struct perf_sample sample; | 814 | struct perf_sample sample; |
| 811 | struct perf_evsel *evsel; | 815 | struct perf_evsel *evsel; |
| 816 | struct perf_mmap *md; | ||
| 812 | struct perf_session *session = top->session; | 817 | struct perf_session *session = top->session; |
| 813 | union perf_event *event; | 818 | union perf_event *event; |
| 814 | struct machine *machine; | 819 | struct machine *machine; |
| 820 | u64 end, start; | ||
| 815 | int ret; | 821 | int ret; |
| 816 | 822 | ||
| 817 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { | 823 | md = opts->overwrite ? &evlist->overwrite_mmap[idx] : &evlist->mmap[idx]; |
| 818 | ret = perf_evlist__parse_sample(top->evlist, event, &sample); | 824 | if (perf_mmap__read_init(md, opts->overwrite, &start, &end) < 0) |
| 825 | return; | ||
| 826 | |||
| 827 | while ((event = perf_mmap__read_event(md, opts->overwrite, &start, end)) != NULL) { | ||
| 828 | ret = perf_evlist__parse_sample(evlist, event, &sample); | ||
| 819 | if (ret) { | 829 | if (ret) { |
| 820 | pr_err("Can't parse sample, err = %d\n", ret); | 830 | pr_err("Can't parse sample, err = %d\n", ret); |
| 821 | goto next_event; | 831 | goto next_event; |
| @@ -869,16 +879,120 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
| 869 | } else | 879 | } else |
| 870 | ++session->evlist->stats.nr_unknown_events; | 880 | ++session->evlist->stats.nr_unknown_events; |
| 871 | next_event: | 881 | next_event: |
| 872 | perf_evlist__mmap_consume(top->evlist, idx); | 882 | perf_mmap__consume(md, opts->overwrite); |
| 873 | } | 883 | } |
| 884 | |||
| 885 | perf_mmap__read_done(md); | ||
| 874 | } | 886 | } |
| 875 | 887 | ||
| 876 | static void perf_top__mmap_read(struct perf_top *top) | 888 | static void perf_top__mmap_read(struct perf_top *top) |
| 877 | { | 889 | { |
| 890 | bool overwrite = top->record_opts.overwrite; | ||
| 891 | struct perf_evlist *evlist = top->evlist; | ||
| 892 | unsigned long long start, end; | ||
| 878 | int i; | 893 | int i; |
| 879 | 894 | ||
| 895 | start = rdclock(); | ||
| 896 | if (overwrite) | ||
| 897 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_DATA_PENDING); | ||
| 898 | |||
| 880 | for (i = 0; i < top->evlist->nr_mmaps; i++) | 899 | for (i = 0; i < top->evlist->nr_mmaps; i++) |
| 881 | perf_top__mmap_read_idx(top, i); | 900 | perf_top__mmap_read_idx(top, i); |
| 901 | |||
| 902 | if (overwrite) { | ||
| 903 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY); | ||
| 904 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING); | ||
| 905 | } | ||
| 906 | end = rdclock(); | ||
| 907 | |||
| 908 | if ((end - start) > (unsigned long long)top->delay_secs * NSEC_PER_SEC) | ||
| 909 | ui__warning("Too slow to read ring buffer.\n" | ||
| 910 | "Please try increasing the period (-c) or\n" | ||
| 911 | "decreasing the freq (-F) or\n" | ||
| 912 | "limiting the number of CPUs (-C)\n"); | ||
| 913 | } | ||
| 914 | |||
| 915 | /* | ||
| 916 | * Check per-event overwrite term. | ||
| 917 | * perf top should support consistent term for all events. | ||
| 918 | * - All events don't have per-event term | ||
| 919 | * E.g. "cpu/cpu-cycles/,cpu/instructions/" | ||
| 920 | * Nothing change, return 0. | ||
| 921 | * - All events have same per-event term | ||
| 922 | * E.g. "cpu/cpu-cycles,no-overwrite/,cpu/instructions,no-overwrite/ | ||
| 923 | * Using the per-event setting to replace the opts->overwrite if | ||
| 924 | * they are different, then return 0. | ||
| 925 | * - Events have different per-event term | ||
| 926 | * E.g. "cpu/cpu-cycles,overwrite/,cpu/instructions,no-overwrite/" | ||
| 927 | * Return -1 | ||
| 928 | * - Some of the event set per-event term, but some not. | ||
| 929 | * E.g. "cpu/cpu-cycles/,cpu/instructions,no-overwrite/" | ||
| 930 | * Return -1 | ||
| 931 | */ | ||
| 932 | static int perf_top__overwrite_check(struct perf_top *top) | ||
| 933 | { | ||
| 934 | struct record_opts *opts = &top->record_opts; | ||
| 935 | struct perf_evlist *evlist = top->evlist; | ||
| 936 | struct perf_evsel_config_term *term; | ||
| 937 | struct list_head *config_terms; | ||
| 938 | struct perf_evsel *evsel; | ||
| 939 | int set, overwrite = -1; | ||
| 940 | |||
| 941 | evlist__for_each_entry(evlist, evsel) { | ||
| 942 | set = -1; | ||
| 943 | config_terms = &evsel->config_terms; | ||
| 944 | list_for_each_entry(term, config_terms, list) { | ||
| 945 | if (term->type == PERF_EVSEL__CONFIG_TERM_OVERWRITE) | ||
| 946 | set = term->val.overwrite ? 1 : 0; | ||
| 947 | } | ||
| 948 | |||
| 949 | /* no term for current and previous event (likely) */ | ||
| 950 | if ((overwrite < 0) && (set < 0)) | ||
| 951 | continue; | ||
| 952 | |||
| 953 | /* has term for both current and previous event, compare */ | ||
| 954 | if ((overwrite >= 0) && (set >= 0) && (overwrite != set)) | ||
| 955 | return -1; | ||
| 956 | |||
| 957 | /* no term for current event but has term for previous one */ | ||
| 958 | if ((overwrite >= 0) && (set < 0)) | ||
| 959 | return -1; | ||
| 960 | |||
| 961 | /* has term for current event */ | ||
| 962 | if ((overwrite < 0) && (set >= 0)) { | ||
| 963 | /* if it's first event, set overwrite */ | ||
| 964 | if (evsel == perf_evlist__first(evlist)) | ||
| 965 | overwrite = set; | ||
| 966 | else | ||
| 967 | return -1; | ||
| 968 | } | ||
| 969 | } | ||
| 970 | |||
| 971 | if ((overwrite >= 0) && (opts->overwrite != overwrite)) | ||
| 972 | opts->overwrite = overwrite; | ||
| 973 | |||
| 974 | return 0; | ||
| 975 | } | ||
| 976 | |||
| 977 | static int perf_top_overwrite_fallback(struct perf_top *top, | ||
| 978 | struct perf_evsel *evsel) | ||
| 979 | { | ||
| 980 | struct record_opts *opts = &top->record_opts; | ||
| 981 | struct perf_evlist *evlist = top->evlist; | ||
| 982 | struct perf_evsel *counter; | ||
| 983 | |||
| 984 | if (!opts->overwrite) | ||
| 985 | return 0; | ||
| 986 | |||
| 987 | /* only fall back when first event fails */ | ||
| 988 | if (evsel != perf_evlist__first(evlist)) | ||
| 989 | return 0; | ||
| 990 | |||
| 991 | evlist__for_each_entry(evlist, counter) | ||
| 992 | counter->attr.write_backward = false; | ||
| 993 | opts->overwrite = false; | ||
| 994 | ui__warning("fall back to non-overwrite mode\n"); | ||
| 995 | return 1; | ||
| 882 | } | 996 | } |
| 883 | 997 | ||
| 884 | static int perf_top__start_counters(struct perf_top *top) | 998 | static int perf_top__start_counters(struct perf_top *top) |
| @@ -888,12 +1002,33 @@ static int perf_top__start_counters(struct perf_top *top) | |||
| 888 | struct perf_evlist *evlist = top->evlist; | 1002 | struct perf_evlist *evlist = top->evlist; |
| 889 | struct record_opts *opts = &top->record_opts; | 1003 | struct record_opts *opts = &top->record_opts; |
| 890 | 1004 | ||
| 1005 | if (perf_top__overwrite_check(top)) { | ||
| 1006 | ui__error("perf top only support consistent per-event " | ||
| 1007 | "overwrite setting for all events\n"); | ||
| 1008 | goto out_err; | ||
| 1009 | } | ||
| 1010 | |||
| 891 | perf_evlist__config(evlist, opts, &callchain_param); | 1011 | perf_evlist__config(evlist, opts, &callchain_param); |
| 892 | 1012 | ||
| 893 | evlist__for_each_entry(evlist, counter) { | 1013 | evlist__for_each_entry(evlist, counter) { |
| 894 | try_again: | 1014 | try_again: |
| 895 | if (perf_evsel__open(counter, top->evlist->cpus, | 1015 | if (perf_evsel__open(counter, top->evlist->cpus, |
| 896 | top->evlist->threads) < 0) { | 1016 | top->evlist->threads) < 0) { |
| 1017 | |||
| 1018 | /* | ||
| 1019 | * Specially handle overwrite fall back. | ||
| 1020 | * Because perf top is the only tool which has | ||
| 1021 | * overwrite mode by default, support | ||
| 1022 | * both overwrite and non-overwrite mode, and | ||
| 1023 | * require consistent mode for all events. | ||
| 1024 | * | ||
| 1025 | * May move it to generic code with more tools | ||
| 1026 | * have similar attribute. | ||
| 1027 | */ | ||
| 1028 | if (perf_missing_features.write_backward && | ||
| 1029 | perf_top_overwrite_fallback(top, counter)) | ||
| 1030 | goto try_again; | ||
| 1031 | |||
| 897 | if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { | 1032 | if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { |
| 898 | if (verbose > 0) | 1033 | if (verbose > 0) |
| 899 | ui__warning("%s\n", msg); | 1034 | ui__warning("%s\n", msg); |
| @@ -1033,7 +1168,7 @@ static int __cmd_top(struct perf_top *top) | |||
| 1033 | 1168 | ||
| 1034 | perf_top__mmap_read(top); | 1169 | perf_top__mmap_read(top); |
| 1035 | 1170 | ||
| 1036 | if (hits == top->samples) | 1171 | if (opts->overwrite || (hits == top->samples)) |
| 1037 | ret = perf_evlist__poll(top->evlist, 100); | 1172 | ret = perf_evlist__poll(top->evlist, 100); |
| 1038 | 1173 | ||
| 1039 | if (resize) { | 1174 | if (resize) { |
| @@ -1127,6 +1262,7 @@ int cmd_top(int argc, const char **argv) | |||
| 1127 | .uses_mmap = true, | 1262 | .uses_mmap = true, |
| 1128 | }, | 1263 | }, |
| 1129 | .proc_map_timeout = 500, | 1264 | .proc_map_timeout = 500, |
| 1265 | .overwrite = 1, | ||
| 1130 | }, | 1266 | }, |
| 1131 | .max_stack = sysctl_perf_event_max_stack, | 1267 | .max_stack = sysctl_perf_event_max_stack, |
| 1132 | .sym_pcnt_filter = 5, | 1268 | .sym_pcnt_filter = 5, |
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 51abdb0a4047..790ec25919a0 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh | |||
| @@ -33,7 +33,6 @@ arch/s390/include/uapi/asm/kvm.h | |||
| 33 | arch/s390/include/uapi/asm/kvm_perf.h | 33 | arch/s390/include/uapi/asm/kvm_perf.h |
| 34 | arch/s390/include/uapi/asm/ptrace.h | 34 | arch/s390/include/uapi/asm/ptrace.h |
| 35 | arch/s390/include/uapi/asm/sie.h | 35 | arch/s390/include/uapi/asm/sie.h |
| 36 | arch/s390/include/uapi/asm/unistd.h | ||
| 37 | arch/arm/include/uapi/asm/kvm.h | 36 | arch/arm/include/uapi/asm/kvm.h |
| 38 | arch/arm64/include/uapi/asm/kvm.h | 37 | arch/arm64/include/uapi/asm/kvm.h |
| 39 | arch/alpha/include/uapi/asm/errno.h | 38 | arch/alpha/include/uapi/asm/errno.h |
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json new file mode 100644 index 000000000000..3b6208763e50 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0x7A", | ||
| 4 | "EventName": "BR_INDIRECT_SPEC", | ||
| 5 | "BriefDescription": "Branch speculatively executed - Indirect branch" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0xC9", | ||
| 9 | "EventName": "BR_COND", | ||
| 10 | "BriefDescription": "Conditional branch executed" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xCA", | ||
| 14 | "EventName": "BR_INDIRECT_MISPRED", | ||
| 15 | "BriefDescription": "Indirect branch mispredicted" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xCB", | ||
| 19 | "EventName": "BR_INDIRECT_MISPRED_ADDR", | ||
| 20 | "BriefDescription": "Indirect branch mispredicted because of address miscompare" | ||
| 21 | }, | ||
| 22 | {, | ||
| 23 | "EventCode": "0xCC", | ||
| 24 | "EventName": "BR_COND_MISPRED", | ||
| 25 | "BriefDescription": "Conditional branch mispredicted" | ||
| 26 | } | ||
| 27 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json new file mode 100644 index 000000000000..480d9f7460ab --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0x60", | ||
| 4 | "EventName": "BUS_ACCESS_LD", | ||
| 5 | "BriefDescription": "Bus access - Read" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0x61", | ||
| 9 | "EventName": "BUS_ACCESS_ST", | ||
| 10 | "BriefDescription": "Bus access - Write" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xC0", | ||
| 14 | "EventName": "EXT_MEM_REQ", | ||
| 15 | "BriefDescription": "External memory request" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xC1", | ||
| 19 | "EventName": "EXT_MEM_REQ_NC", | ||
| 20 | "BriefDescription": "Non-cacheable external memory request" | ||
| 21 | } | ||
| 22 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json new file mode 100644 index 000000000000..11baad6344b9 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0xC2", | ||
| 4 | "EventName": "PREFETCH_LINEFILL", | ||
| 5 | "BriefDescription": "Linefill because of prefetch" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0xC3", | ||
| 9 | "EventName": "PREFETCH_LINEFILL_DROP", | ||
| 10 | "BriefDescription": "Instruction Cache Throttle occurred" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xC4", | ||
| 14 | "EventName": "READ_ALLOC_ENTER", | ||
| 15 | "BriefDescription": "Entering read allocate mode" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xC5", | ||
| 19 | "EventName": "READ_ALLOC", | ||
| 20 | "BriefDescription": "Read allocate mode" | ||
| 21 | }, | ||
| 22 | {, | ||
| 23 | "EventCode": "0xC8", | ||
| 24 | "EventName": "EXT_SNOOP", | ||
| 25 | "BriefDescription": "SCU Snooped data from another CPU for this CPU" | ||
| 26 | } | ||
| 27 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json new file mode 100644 index 000000000000..480d9f7460ab --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0x60", | ||
| 4 | "EventName": "BUS_ACCESS_LD", | ||
| 5 | "BriefDescription": "Bus access - Read" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0x61", | ||
| 9 | "EventName": "BUS_ACCESS_ST", | ||
| 10 | "BriefDescription": "Bus access - Write" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xC0", | ||
| 14 | "EventName": "EXT_MEM_REQ", | ||
| 15 | "BriefDescription": "External memory request" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xC1", | ||
| 19 | "EventName": "EXT_MEM_REQ_NC", | ||
| 20 | "BriefDescription": "Non-cacheable external memory request" | ||
| 21 | } | ||
| 22 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json new file mode 100644 index 000000000000..73a22402d003 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0x86", | ||
| 4 | "EventName": "EXC_IRQ", | ||
| 5 | "BriefDescription": "Exception taken, IRQ" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0x87", | ||
| 9 | "EventName": "EXC_FIQ", | ||
| 10 | "BriefDescription": "Exception taken, FIQ" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xC6", | ||
| 14 | "EventName": "PRE_DECODE_ERR", | ||
| 15 | "BriefDescription": "Pre-decode error" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xD0", | ||
| 19 | "EventName": "L1I_CACHE_ERR", | ||
| 20 | "BriefDescription": "L1 Instruction Cache (data or tag) memory error" | ||
| 21 | }, | ||
| 22 | {, | ||
| 23 | "EventCode": "0xD1", | ||
| 24 | "EventName": "L1D_CACHE_ERR", | ||
| 25 | "BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable" | ||
| 26 | }, | ||
| 27 | {, | ||
| 28 | "EventCode": "0xD2", | ||
| 29 | "EventName": "TLB_ERR", | ||
| 30 | "BriefDescription": "TLB memory error" | ||
| 31 | } | ||
| 32 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json new file mode 100644 index 000000000000..3149fb90555a --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | [ | ||
| 2 | {, | ||
| 3 | "EventCode": "0xC7", | ||
| 4 | "EventName": "STALL_SB_FULL", | ||
| 5 | "BriefDescription": "Data Write operation that stalls the pipeline because the store buffer is full" | ||
| 6 | }, | ||
| 7 | {, | ||
| 8 | "EventCode": "0xE0", | ||
| 9 | "EventName": "OTHER_IQ_DEP_STALL", | ||
| 10 | "BriefDescription": "Cycles that the DPU IQ is empty and that is not because of a recent micro-TLB miss, instruction cache miss or pre-decode error" | ||
| 11 | }, | ||
| 12 | {, | ||
| 13 | "EventCode": "0xE1", | ||
| 14 | "EventName": "IC_DEP_STALL", | ||
| 15 | "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction cache miss being processed" | ||
| 16 | }, | ||
| 17 | {, | ||
| 18 | "EventCode": "0xE2", | ||
| 19 | "EventName": "IUTLB_DEP_STALL", | ||
| 20 | "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction micro-TLB miss being processed" | ||
| 21 | }, | ||
| 22 | {, | ||
| 23 | "EventCode": "0xE3", | ||
| 24 | "EventName": "DECODE_DEP_STALL", | ||
| 25 | "BriefDescription": "Cycles the DPU IQ is empty and there is a pre-decode error being processed" | ||
| 26 | }, | ||
| 27 | {, | ||
| 28 | "EventCode": "0xE4", | ||
| 29 | "EventName": "OTHER_INTERLOCK_STALL", | ||
| 30 | "BriefDescription": "Cycles there is an interlock other than Advanced SIMD/Floating-point instructions or load/store instruction" | ||
| 31 | }, | ||
| 32 | {, | ||
| 33 | "EventCode": "0xE5", | ||
| 34 | "EventName": "AGU_DEP_STALL", | ||
| 35 | "BriefDescription": "Cycles there is an interlock for a load/store instruction waiting for data to calculate the address in the AGU" | ||
| 36 | }, | ||
| 37 | {, | ||
| 38 | "EventCode": "0xE6", | ||
| 39 | "EventName": "SIMD_DEP_STALL", | ||
| 40 | "BriefDescription": "Cycles there is an interlock for an Advanced SIMD/Floating-point operation." | ||
| 41 | }, | ||
| 42 | {, | ||
| 43 | "EventCode": "0xE7", | ||
| 44 | "EventName": "LD_DEP_STALL", | ||
| 45 | "BriefDescription": "Cycles there is a stall in the Wr stage because of a load miss" | ||
| 46 | }, | ||
| 47 | {, | ||
| 48 | "EventCode": "0xE8", | ||
| 49 | "EventName": "ST_DEP_STALL", | ||
| 50 | "BriefDescription": "Cycles there is a stall in the Wr stage because of a store" | ||
| 51 | } | ||
| 52 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv index 219d6756134e..e61c9ca6cf9e 100644 --- a/tools/perf/pmu-events/arch/arm64/mapfile.csv +++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv | |||
| @@ -13,3 +13,4 @@ | |||
| 13 | # | 13 | # |
| 14 | #Family-model,Version,Filename,EventType | 14 | #Family-model,Version,Filename,EventType |
| 15 | 0x00000000420f5160,v1,cavium,core | 15 | 0x00000000420f5160,v1,cavium,core |
| 16 | 0x00000000410fd03[[:xdigit:]],v1,cortex-a53,core | ||
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 4035d43523c3..e0b1b414d466 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c | |||
| @@ -31,10 +31,12 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, | |||
| 31 | int i; | 31 | int i; |
| 32 | 32 | ||
| 33 | for (i = 0; i < evlist->nr_mmaps; i++) { | 33 | for (i = 0; i < evlist->nr_mmaps; i++) { |
| 34 | struct perf_mmap *map = &evlist->overwrite_mmap[i]; | ||
| 34 | union perf_event *event; | 35 | union perf_event *event; |
| 36 | u64 start, end; | ||
| 35 | 37 | ||
| 36 | perf_mmap__read_catchup(&evlist->overwrite_mmap[i]); | 38 | perf_mmap__read_init(map, true, &start, &end); |
| 37 | while ((event = perf_mmap__read_backward(&evlist->overwrite_mmap[i])) != NULL) { | 39 | while ((event = perf_mmap__read_event(map, true, &start, end)) != NULL) { |
| 38 | const u32 type = event->header.type; | 40 | const u32 type = event->header.type; |
| 39 | 41 | ||
| 40 | switch (type) { | 42 | switch (type) { |
| @@ -49,6 +51,7 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, | |||
| 49 | return TEST_FAIL; | 51 | return TEST_FAIL; |
| 50 | } | 52 | } |
| 51 | } | 53 | } |
| 54 | perf_mmap__read_done(map); | ||
| 52 | } | 55 | } |
| 53 | return TEST_OK; | 56 | return TEST_OK; |
| 54 | } | 57 | } |
diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh index 8b3da21a08f1..c446c894b297 100755 --- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | |||
| @@ -22,10 +22,23 @@ trace_libc_inet_pton_backtrace() { | |||
| 22 | expected[4]="rtt min.*" | 22 | expected[4]="rtt min.*" |
| 23 | expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" | 23 | expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" |
| 24 | expected[6]=".*inet_pton[[:space:]]\($libc\)$" | 24 | expected[6]=".*inet_pton[[:space:]]\($libc\)$" |
| 25 | expected[7]="getaddrinfo[[:space:]]\($libc\)$" | 25 | case "$(uname -m)" in |
| 26 | expected[8]=".*\(.*/bin/ping.*\)$" | 26 | s390x) |
| 27 | 27 | eventattr='call-graph=dwarf' | |
| 28 | perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do | 28 | expected[7]="gaih_inet[[:space:]]\(inlined\)$" |
| 29 | expected[8]="__GI_getaddrinfo[[:space:]]\(inlined\)$" | ||
| 30 | expected[9]="main[[:space:]]\(.*/bin/ping.*\)$" | ||
| 31 | expected[10]="__libc_start_main[[:space:]]\($libc\)$" | ||
| 32 | expected[11]="_start[[:space:]]\(.*/bin/ping.*\)$" | ||
| 33 | ;; | ||
| 34 | *) | ||
| 35 | eventattr='max-stack=3' | ||
| 36 | expected[7]="getaddrinfo[[:space:]]\($libc\)$" | ||
| 37 | expected[8]=".*\(.*/bin/ping.*\)$" | ||
| 38 | ;; | ||
| 39 | esac | ||
| 40 | |||
| 41 | perf trace --no-syscalls -e probe_libc:inet_pton/$eventattr/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do | ||
| 29 | echo $line | 42 | echo $line |
| 30 | echo "$line" | egrep -q "${expected[$idx]}" | 43 | echo "$line" | egrep -q "${expected[$idx]}" |
| 31 | if [ $? -ne 0 ] ; then | 44 | if [ $? -ne 0 ] ; then |
| @@ -33,7 +46,7 @@ trace_libc_inet_pton_backtrace() { | |||
| 33 | exit 1 | 46 | exit 1 |
| 34 | fi | 47 | fi |
| 35 | let idx+=1 | 48 | let idx+=1 |
| 36 | [ $idx -eq 9 ] && break | 49 | [ -z "${expected[$idx]}" ] && break |
| 37 | done | 50 | done |
| 38 | } | 51 | } |
| 39 | 52 | ||
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 68146f4620a5..6495ee55d9c3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
| @@ -608,7 +608,8 @@ static int hist_browser__title(struct hist_browser *browser, char *bf, size_t si | |||
| 608 | return browser->title ? browser->title(browser, bf, size) : 0; | 608 | return browser->title ? browser->title(browser, bf, size) : 0; |
| 609 | } | 609 | } |
| 610 | 610 | ||
| 611 | int hist_browser__run(struct hist_browser *browser, const char *help) | 611 | int hist_browser__run(struct hist_browser *browser, const char *help, |
| 612 | bool warn_lost_event) | ||
| 612 | { | 613 | { |
| 613 | int key; | 614 | int key; |
| 614 | char title[160]; | 615 | char title[160]; |
| @@ -638,8 +639,9 @@ int hist_browser__run(struct hist_browser *browser, const char *help) | |||
| 638 | nr_entries = hist_browser__nr_entries(browser); | 639 | nr_entries = hist_browser__nr_entries(browser); |
| 639 | ui_browser__update_nr_entries(&browser->b, nr_entries); | 640 | ui_browser__update_nr_entries(&browser->b, nr_entries); |
| 640 | 641 | ||
| 641 | if (browser->hists->stats.nr_lost_warned != | 642 | if (warn_lost_event && |
| 642 | browser->hists->stats.nr_events[PERF_RECORD_LOST]) { | 643 | (browser->hists->stats.nr_lost_warned != |
| 644 | browser->hists->stats.nr_events[PERF_RECORD_LOST])) { | ||
| 643 | browser->hists->stats.nr_lost_warned = | 645 | browser->hists->stats.nr_lost_warned = |
| 644 | browser->hists->stats.nr_events[PERF_RECORD_LOST]; | 646 | browser->hists->stats.nr_events[PERF_RECORD_LOST]; |
| 645 | ui_browser__warn_lost_events(&browser->b); | 647 | ui_browser__warn_lost_events(&browser->b); |
| @@ -2763,7 +2765,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
| 2763 | bool left_exits, | 2765 | bool left_exits, |
| 2764 | struct hist_browser_timer *hbt, | 2766 | struct hist_browser_timer *hbt, |
| 2765 | float min_pcnt, | 2767 | float min_pcnt, |
| 2766 | struct perf_env *env) | 2768 | struct perf_env *env, |
| 2769 | bool warn_lost_event) | ||
| 2767 | { | 2770 | { |
| 2768 | struct hists *hists = evsel__hists(evsel); | 2771 | struct hists *hists = evsel__hists(evsel); |
| 2769 | struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); | 2772 | struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); |
| @@ -2844,7 +2847,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
| 2844 | 2847 | ||
| 2845 | nr_options = 0; | 2848 | nr_options = 0; |
| 2846 | 2849 | ||
| 2847 | key = hist_browser__run(browser, helpline); | 2850 | key = hist_browser__run(browser, helpline, |
| 2851 | warn_lost_event); | ||
| 2848 | 2852 | ||
| 2849 | if (browser->he_selection != NULL) { | 2853 | if (browser->he_selection != NULL) { |
| 2850 | thread = hist_browser__selected_thread(browser); | 2854 | thread = hist_browser__selected_thread(browser); |
| @@ -3184,7 +3188,8 @@ static void perf_evsel_menu__write(struct ui_browser *browser, | |||
| 3184 | 3188 | ||
| 3185 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | 3189 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, |
| 3186 | int nr_events, const char *help, | 3190 | int nr_events, const char *help, |
| 3187 | struct hist_browser_timer *hbt) | 3191 | struct hist_browser_timer *hbt, |
| 3192 | bool warn_lost_event) | ||
| 3188 | { | 3193 | { |
| 3189 | struct perf_evlist *evlist = menu->b.priv; | 3194 | struct perf_evlist *evlist = menu->b.priv; |
| 3190 | struct perf_evsel *pos; | 3195 | struct perf_evsel *pos; |
| @@ -3203,7 +3208,9 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | |||
| 3203 | case K_TIMER: | 3208 | case K_TIMER: |
| 3204 | hbt->timer(hbt->arg); | 3209 | hbt->timer(hbt->arg); |
| 3205 | 3210 | ||
| 3206 | if (!menu->lost_events_warned && menu->lost_events) { | 3211 | if (!menu->lost_events_warned && |
| 3212 | menu->lost_events && | ||
| 3213 | warn_lost_event) { | ||
| 3207 | ui_browser__warn_lost_events(&menu->b); | 3214 | ui_browser__warn_lost_events(&menu->b); |
| 3208 | menu->lost_events_warned = true; | 3215 | menu->lost_events_warned = true; |
| 3209 | } | 3216 | } |
| @@ -3224,7 +3231,8 @@ browse_hists: | |||
| 3224 | key = perf_evsel__hists_browse(pos, nr_events, help, | 3231 | key = perf_evsel__hists_browse(pos, nr_events, help, |
| 3225 | true, hbt, | 3232 | true, hbt, |
| 3226 | menu->min_pcnt, | 3233 | menu->min_pcnt, |
| 3227 | menu->env); | 3234 | menu->env, |
| 3235 | warn_lost_event); | ||
| 3228 | ui_browser__show_title(&menu->b, title); | 3236 | ui_browser__show_title(&menu->b, title); |
| 3229 | switch (key) { | 3237 | switch (key) { |
| 3230 | case K_TAB: | 3238 | case K_TAB: |
| @@ -3282,7 +3290,8 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
| 3282 | int nr_entries, const char *help, | 3290 | int nr_entries, const char *help, |
| 3283 | struct hist_browser_timer *hbt, | 3291 | struct hist_browser_timer *hbt, |
| 3284 | float min_pcnt, | 3292 | float min_pcnt, |
| 3285 | struct perf_env *env) | 3293 | struct perf_env *env, |
| 3294 | bool warn_lost_event) | ||
| 3286 | { | 3295 | { |
| 3287 | struct perf_evsel *pos; | 3296 | struct perf_evsel *pos; |
| 3288 | struct perf_evsel_menu menu = { | 3297 | struct perf_evsel_menu menu = { |
| @@ -3309,13 +3318,15 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
| 3309 | menu.b.width = line_len; | 3318 | menu.b.width = line_len; |
| 3310 | } | 3319 | } |
| 3311 | 3320 | ||
| 3312 | return perf_evsel_menu__run(&menu, nr_entries, help, hbt); | 3321 | return perf_evsel_menu__run(&menu, nr_entries, help, |
| 3322 | hbt, warn_lost_event); | ||
| 3313 | } | 3323 | } |
| 3314 | 3324 | ||
| 3315 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 3325 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
| 3316 | struct hist_browser_timer *hbt, | 3326 | struct hist_browser_timer *hbt, |
| 3317 | float min_pcnt, | 3327 | float min_pcnt, |
| 3318 | struct perf_env *env) | 3328 | struct perf_env *env, |
| 3329 | bool warn_lost_event) | ||
| 3319 | { | 3330 | { |
| 3320 | int nr_entries = evlist->nr_entries; | 3331 | int nr_entries = evlist->nr_entries; |
| 3321 | 3332 | ||
| @@ -3325,7 +3336,7 @@ single_entry: | |||
| 3325 | 3336 | ||
| 3326 | return perf_evsel__hists_browse(first, nr_entries, help, | 3337 | return perf_evsel__hists_browse(first, nr_entries, help, |
| 3327 | false, hbt, min_pcnt, | 3338 | false, hbt, min_pcnt, |
| 3328 | env); | 3339 | env, warn_lost_event); |
| 3329 | } | 3340 | } |
| 3330 | 3341 | ||
| 3331 | if (symbol_conf.event_group) { | 3342 | if (symbol_conf.event_group) { |
| @@ -3342,5 +3353,6 @@ single_entry: | |||
| 3342 | } | 3353 | } |
| 3343 | 3354 | ||
| 3344 | return __perf_evlist__tui_browse_hists(evlist, nr_entries, help, | 3355 | return __perf_evlist__tui_browse_hists(evlist, nr_entries, help, |
| 3345 | hbt, min_pcnt, env); | 3356 | hbt, min_pcnt, env, |
| 3357 | warn_lost_event); | ||
| 3346 | } | 3358 | } |
diff --git a/tools/perf/ui/browsers/hists.h b/tools/perf/ui/browsers/hists.h index ba431777f559..9428bee076f2 100644 --- a/tools/perf/ui/browsers/hists.h +++ b/tools/perf/ui/browsers/hists.h | |||
| @@ -28,7 +28,8 @@ struct hist_browser { | |||
| 28 | 28 | ||
| 29 | struct hist_browser *hist_browser__new(struct hists *hists); | 29 | struct hist_browser *hist_browser__new(struct hists *hists); |
| 30 | void hist_browser__delete(struct hist_browser *browser); | 30 | void hist_browser__delete(struct hist_browser *browser); |
| 31 | int hist_browser__run(struct hist_browser *browser, const char *help); | 31 | int hist_browser__run(struct hist_browser *browser, const char *help, |
| 32 | bool warn_lost_event); | ||
| 32 | void hist_browser__init(struct hist_browser *browser, | 33 | void hist_browser__init(struct hist_browser *browser, |
| 33 | struct hists *hists); | 34 | struct hists *hists); |
| 34 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ | 35 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ac35cd214feb..e5fc14e53c05 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
| @@ -715,28 +715,11 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int | |||
| 715 | return perf_mmap__read_forward(md); | 715 | return perf_mmap__read_forward(md); |
| 716 | } | 716 | } |
| 717 | 717 | ||
| 718 | union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx) | ||
| 719 | { | ||
| 720 | struct perf_mmap *md = &evlist->mmap[idx]; | ||
| 721 | |||
| 722 | /* | ||
| 723 | * No need to check messup for backward ring buffer: | ||
| 724 | * We can always read arbitrary long data from a backward | ||
| 725 | * ring buffer unless we forget to pause it before reading. | ||
| 726 | */ | ||
| 727 | return perf_mmap__read_backward(md); | ||
| 728 | } | ||
| 729 | |||
| 730 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) | 718 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) |
| 731 | { | 719 | { |
| 732 | return perf_evlist__mmap_read_forward(evlist, idx); | 720 | return perf_evlist__mmap_read_forward(evlist, idx); |
| 733 | } | 721 | } |
| 734 | 722 | ||
| 735 | void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx) | ||
| 736 | { | ||
| 737 | perf_mmap__read_catchup(&evlist->mmap[idx]); | ||
| 738 | } | ||
| 739 | |||
| 740 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) | 723 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) |
| 741 | { | 724 | { |
| 742 | perf_mmap__consume(&evlist->mmap[idx], false); | 725 | perf_mmap__consume(&evlist->mmap[idx], false); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 75f8e0ad5d76..336b838e6957 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
| @@ -133,10 +133,6 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx); | |||
| 133 | 133 | ||
| 134 | union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, | 134 | union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, |
| 135 | int idx); | 135 | int idx); |
| 136 | union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, | ||
| 137 | int idx); | ||
| 138 | void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx); | ||
| 139 | |||
| 140 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); | 136 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); |
| 141 | 137 | ||
| 142 | int perf_evlist__open(struct perf_evlist *evlist); | 138 | int perf_evlist__open(struct perf_evlist *evlist); |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ff359c9ece2e..ef351688b797 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -41,17 +41,7 @@ | |||
| 41 | 41 | ||
| 42 | #include "sane_ctype.h" | 42 | #include "sane_ctype.h" |
| 43 | 43 | ||
| 44 | static struct { | 44 | struct perf_missing_features perf_missing_features; |
| 45 | bool sample_id_all; | ||
| 46 | bool exclude_guest; | ||
| 47 | bool mmap2; | ||
| 48 | bool cloexec; | ||
| 49 | bool clockid; | ||
| 50 | bool clockid_wrong; | ||
| 51 | bool lbr_flags; | ||
| 52 | bool write_backward; | ||
| 53 | bool group_read; | ||
| 54 | } perf_missing_features; | ||
| 55 | 45 | ||
| 56 | static clockid_t clockid; | 46 | static clockid_t clockid; |
| 57 | 47 | ||
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 846e41644525..a7487c6d1866 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
| @@ -149,6 +149,20 @@ union u64_swap { | |||
| 149 | u32 val32[2]; | 149 | u32 val32[2]; |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | struct perf_missing_features { | ||
| 153 | bool sample_id_all; | ||
| 154 | bool exclude_guest; | ||
| 155 | bool mmap2; | ||
| 156 | bool cloexec; | ||
| 157 | bool clockid; | ||
| 158 | bool clockid_wrong; | ||
| 159 | bool lbr_flags; | ||
| 160 | bool write_backward; | ||
| 161 | bool group_read; | ||
| 162 | }; | ||
| 163 | |||
| 164 | extern struct perf_missing_features perf_missing_features; | ||
| 165 | |||
| 152 | struct cpu_map; | 166 | struct cpu_map; |
| 153 | struct target; | 167 | struct target; |
| 154 | struct thread_map; | 168 | struct thread_map; |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index f6630cb95eff..02721b579746 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
| @@ -430,7 +430,8 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, | |||
| 430 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 430 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
| 431 | struct hist_browser_timer *hbt, | 431 | struct hist_browser_timer *hbt, |
| 432 | float min_pcnt, | 432 | float min_pcnt, |
| 433 | struct perf_env *env); | 433 | struct perf_env *env, |
| 434 | bool warn_lost_event); | ||
| 434 | int script_browse(const char *script_opt); | 435 | int script_browse(const char *script_opt); |
| 435 | #else | 436 | #else |
| 436 | static inline | 437 | static inline |
| @@ -438,7 +439,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, | |||
| 438 | const char *help __maybe_unused, | 439 | const char *help __maybe_unused, |
| 439 | struct hist_browser_timer *hbt __maybe_unused, | 440 | struct hist_browser_timer *hbt __maybe_unused, |
| 440 | float min_pcnt __maybe_unused, | 441 | float min_pcnt __maybe_unused, |
| 441 | struct perf_env *env __maybe_unused) | 442 | struct perf_env *env __maybe_unused, |
| 443 | bool warn_lost_event __maybe_unused) | ||
| 442 | { | 444 | { |
| 443 | return 0; | 445 | return 0; |
| 444 | } | 446 | } |
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 05076e683938..91531a7c8fbf 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c | |||
| @@ -22,29 +22,27 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map) | |||
| 22 | 22 | ||
| 23 | /* When check_messup is true, 'end' must points to a good entry */ | 23 | /* When check_messup is true, 'end' must points to a good entry */ |
| 24 | static union perf_event *perf_mmap__read(struct perf_mmap *map, | 24 | static union perf_event *perf_mmap__read(struct perf_mmap *map, |
| 25 | u64 start, u64 end, u64 *prev) | 25 | u64 *startp, u64 end) |
| 26 | { | 26 | { |
| 27 | unsigned char *data = map->base + page_size; | 27 | unsigned char *data = map->base + page_size; |
| 28 | union perf_event *event = NULL; | 28 | union perf_event *event = NULL; |
| 29 | int diff = end - start; | 29 | int diff = end - *startp; |
| 30 | 30 | ||
| 31 | if (diff >= (int)sizeof(event->header)) { | 31 | if (diff >= (int)sizeof(event->header)) { |
| 32 | size_t size; | 32 | size_t size; |
| 33 | 33 | ||
| 34 | event = (union perf_event *)&data[start & map->mask]; | 34 | event = (union perf_event *)&data[*startp & map->mask]; |
| 35 | size = event->header.size; | 35 | size = event->header.size; |
| 36 | 36 | ||
| 37 | if (size < sizeof(event->header) || diff < (int)size) { | 37 | if (size < sizeof(event->header) || diff < (int)size) |
| 38 | event = NULL; | 38 | return NULL; |
| 39 | goto broken_event; | ||
| 40 | } | ||
| 41 | 39 | ||
| 42 | /* | 40 | /* |
| 43 | * Event straddles the mmap boundary -- header should always | 41 | * Event straddles the mmap boundary -- header should always |
| 44 | * be inside due to u64 alignment of output. | 42 | * be inside due to u64 alignment of output. |
| 45 | */ | 43 | */ |
| 46 | if ((start & map->mask) + size != ((start + size) & map->mask)) { | 44 | if ((*startp & map->mask) + size != ((*startp + size) & map->mask)) { |
| 47 | unsigned int offset = start; | 45 | unsigned int offset = *startp; |
| 48 | unsigned int len = min(sizeof(*event), size), cpy; | 46 | unsigned int len = min(sizeof(*event), size), cpy; |
| 49 | void *dst = map->event_copy; | 47 | void *dst = map->event_copy; |
| 50 | 48 | ||
| @@ -59,20 +57,19 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map, | |||
| 59 | event = (union perf_event *)map->event_copy; | 57 | event = (union perf_event *)map->event_copy; |
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | start += size; | 60 | *startp += size; |
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | broken_event: | ||
| 66 | if (prev) | ||
| 67 | *prev = start; | ||
| 68 | |||
| 69 | return event; | 63 | return event; |
| 70 | } | 64 | } |
| 71 | 65 | ||
| 66 | /* | ||
| 67 | * legacy interface for mmap read. | ||
| 68 | * Don't use it. Use perf_mmap__read_event(). | ||
| 69 | */ | ||
| 72 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map) | 70 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map) |
| 73 | { | 71 | { |
| 74 | u64 head; | 72 | u64 head; |
| 75 | u64 old = map->prev; | ||
| 76 | 73 | ||
| 77 | /* | 74 | /* |
| 78 | * Check if event was unmapped due to a POLLHUP/POLLERR. | 75 | * Check if event was unmapped due to a POLLHUP/POLLERR. |
| @@ -82,13 +79,26 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map) | |||
| 82 | 79 | ||
| 83 | head = perf_mmap__read_head(map); | 80 | head = perf_mmap__read_head(map); |
| 84 | 81 | ||
| 85 | return perf_mmap__read(map, old, head, &map->prev); | 82 | return perf_mmap__read(map, &map->prev, head); |
| 86 | } | 83 | } |
| 87 | 84 | ||
| 88 | union perf_event *perf_mmap__read_backward(struct perf_mmap *map) | 85 | /* |
| 86 | * Read event from ring buffer one by one. | ||
| 87 | * Return one event for each call. | ||
| 88 | * | ||
| 89 | * Usage: | ||
| 90 | * perf_mmap__read_init() | ||
| 91 | * while(event = perf_mmap__read_event()) { | ||
| 92 | * //process the event | ||
| 93 | * perf_mmap__consume() | ||
| 94 | * } | ||
| 95 | * perf_mmap__read_done() | ||
| 96 | */ | ||
| 97 | union perf_event *perf_mmap__read_event(struct perf_mmap *map, | ||
| 98 | bool overwrite, | ||
| 99 | u64 *startp, u64 end) | ||
| 89 | { | 100 | { |
| 90 | u64 head, end; | 101 | union perf_event *event; |
| 91 | u64 start = map->prev; | ||
| 92 | 102 | ||
| 93 | /* | 103 | /* |
| 94 | * Check if event was unmapped due to a POLLHUP/POLLERR. | 104 | * Check if event was unmapped due to a POLLHUP/POLLERR. |
| @@ -96,40 +106,19 @@ union perf_event *perf_mmap__read_backward(struct perf_mmap *map) | |||
| 96 | if (!refcount_read(&map->refcnt)) | 106 | if (!refcount_read(&map->refcnt)) |
| 97 | return NULL; | 107 | return NULL; |
| 98 | 108 | ||
| 99 | head = perf_mmap__read_head(map); | 109 | if (startp == NULL) |
| 100 | if (!head) | ||
| 101 | return NULL; | 110 | return NULL; |
| 102 | 111 | ||
| 103 | /* | 112 | /* non-overwirte doesn't pause the ringbuffer */ |
| 104 | * 'head' pointer starts from 0. Kernel minus sizeof(record) form | 113 | if (!overwrite) |
| 105 | * it each time when kernel writes to it, so in fact 'head' is | 114 | end = perf_mmap__read_head(map); |
| 106 | * negative. 'end' pointer is made manually by adding the size of | ||
| 107 | * the ring buffer to 'head' pointer, means the validate data can | ||
| 108 | * read is the whole ring buffer. If 'end' is positive, the ring | ||
| 109 | * buffer has not fully filled, so we must adjust 'end' to 0. | ||
| 110 | * | ||
| 111 | * However, since both 'head' and 'end' is unsigned, we can't | ||
| 112 | * simply compare 'end' against 0. Here we compare '-head' and | ||
| 113 | * the size of the ring buffer, where -head is the number of bytes | ||
| 114 | * kernel write to the ring buffer. | ||
| 115 | */ | ||
| 116 | if (-head < (u64)(map->mask + 1)) | ||
| 117 | end = 0; | ||
| 118 | else | ||
| 119 | end = head + map->mask + 1; | ||
| 120 | |||
| 121 | return perf_mmap__read(map, start, end, &map->prev); | ||
| 122 | } | ||
| 123 | 115 | ||
| 124 | void perf_mmap__read_catchup(struct perf_mmap *map) | 116 | event = perf_mmap__read(map, startp, end); |
| 125 | { | ||
| 126 | u64 head; | ||
| 127 | 117 | ||
| 128 | if (!refcount_read(&map->refcnt)) | 118 | if (!overwrite) |
| 129 | return; | 119 | map->prev = *startp; |
| 130 | 120 | ||
| 131 | head = perf_mmap__read_head(map); | 121 | return event; |
| 132 | map->prev = head; | ||
| 133 | } | 122 | } |
| 134 | 123 | ||
| 135 | static bool perf_mmap__empty(struct perf_mmap *map) | 124 | static bool perf_mmap__empty(struct perf_mmap *map) |
| @@ -267,41 +256,60 @@ static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u6 | |||
| 267 | return -1; | 256 | return -1; |
| 268 | } | 257 | } |
| 269 | 258 | ||
| 270 | int perf_mmap__push(struct perf_mmap *md, bool overwrite, | 259 | /* |
| 271 | void *to, int push(void *to, void *buf, size_t size)) | 260 | * Report the start and end of the available data in ringbuffer |
| 261 | */ | ||
| 262 | int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, | ||
| 263 | u64 *startp, u64 *endp) | ||
| 272 | { | 264 | { |
| 273 | u64 head = perf_mmap__read_head(md); | 265 | u64 head = perf_mmap__read_head(md); |
| 274 | u64 old = md->prev; | 266 | u64 old = md->prev; |
| 275 | u64 end = head, start = old; | ||
| 276 | unsigned char *data = md->base + page_size; | 267 | unsigned char *data = md->base + page_size; |
| 277 | unsigned long size; | 268 | unsigned long size; |
| 278 | void *buf; | ||
| 279 | int rc = 0; | ||
| 280 | 269 | ||
| 281 | start = overwrite ? head : old; | 270 | *startp = overwrite ? head : old; |
| 282 | end = overwrite ? old : head; | 271 | *endp = overwrite ? old : head; |
| 283 | 272 | ||
| 284 | if (start == end) | 273 | if (*startp == *endp) |
| 285 | return 0; | 274 | return -EAGAIN; |
| 286 | 275 | ||
| 287 | size = end - start; | 276 | size = *endp - *startp; |
| 288 | if (size > (unsigned long)(md->mask) + 1) { | 277 | if (size > (unsigned long)(md->mask) + 1) { |
| 289 | if (!overwrite) { | 278 | if (!overwrite) { |
| 290 | WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n"); | 279 | WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n"); |
| 291 | 280 | ||
| 292 | md->prev = head; | 281 | md->prev = head; |
| 293 | perf_mmap__consume(md, overwrite); | 282 | perf_mmap__consume(md, overwrite); |
| 294 | return 0; | 283 | return -EAGAIN; |
| 295 | } | 284 | } |
| 296 | 285 | ||
| 297 | /* | 286 | /* |
| 298 | * Backward ring buffer is full. We still have a chance to read | 287 | * Backward ring buffer is full. We still have a chance to read |
| 299 | * most of data from it. | 288 | * most of data from it. |
| 300 | */ | 289 | */ |
| 301 | if (overwrite_rb_find_range(data, md->mask, head, &start, &end)) | 290 | if (overwrite_rb_find_range(data, md->mask, head, startp, endp)) |
| 302 | return -1; | 291 | return -EINVAL; |
| 303 | } | 292 | } |
| 304 | 293 | ||
| 294 | return 0; | ||
| 295 | } | ||
| 296 | |||
| 297 | int perf_mmap__push(struct perf_mmap *md, bool overwrite, | ||
| 298 | void *to, int push(void *to, void *buf, size_t size)) | ||
| 299 | { | ||
| 300 | u64 head = perf_mmap__read_head(md); | ||
| 301 | u64 end, start; | ||
| 302 | unsigned char *data = md->base + page_size; | ||
| 303 | unsigned long size; | ||
| 304 | void *buf; | ||
| 305 | int rc = 0; | ||
| 306 | |||
| 307 | rc = perf_mmap__read_init(md, overwrite, &start, &end); | ||
| 308 | if (rc < 0) | ||
| 309 | return (rc == -EAGAIN) ? 0 : -1; | ||
| 310 | |||
| 311 | size = end - start; | ||
| 312 | |||
| 305 | if ((start & md->mask) + size != (end & md->mask)) { | 313 | if ((start & md->mask) + size != (end & md->mask)) { |
| 306 | buf = &data[start & md->mask]; | 314 | buf = &data[start & md->mask]; |
| 307 | size = md->mask + 1 - (start & md->mask); | 315 | size = md->mask + 1 - (start & md->mask); |
| @@ -327,3 +335,14 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite, | |||
| 327 | out: | 335 | out: |
| 328 | return rc; | 336 | return rc; |
| 329 | } | 337 | } |
| 338 | |||
| 339 | /* | ||
| 340 | * Mandatory for overwrite mode | ||
| 341 | * The direction of overwrite mode is backward. | ||
| 342 | * The last perf_mmap__read() will set tail to map->prev. | ||
| 343 | * Need to correct the map->prev to head which is the end of next read. | ||
| 344 | */ | ||
| 345 | void perf_mmap__read_done(struct perf_mmap *map) | ||
| 346 | { | ||
| 347 | map->prev = perf_mmap__read_head(map); | ||
| 348 | } | ||
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index e43d7b55a55f..ec7d3a24e276 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h | |||
| @@ -65,8 +65,6 @@ void perf_mmap__put(struct perf_mmap *map); | |||
| 65 | 65 | ||
| 66 | void perf_mmap__consume(struct perf_mmap *map, bool overwrite); | 66 | void perf_mmap__consume(struct perf_mmap *map, bool overwrite); |
| 67 | 67 | ||
| 68 | void perf_mmap__read_catchup(struct perf_mmap *md); | ||
| 69 | |||
| 70 | static inline u64 perf_mmap__read_head(struct perf_mmap *mm) | 68 | static inline u64 perf_mmap__read_head(struct perf_mmap *mm) |
| 71 | { | 69 | { |
| 72 | struct perf_event_mmap_page *pc = mm->base; | 70 | struct perf_event_mmap_page *pc = mm->base; |
| @@ -87,11 +85,17 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail) | |||
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map); | 87 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map); |
| 90 | union perf_event *perf_mmap__read_backward(struct perf_mmap *map); | 88 | |
| 89 | union perf_event *perf_mmap__read_event(struct perf_mmap *map, | ||
| 90 | bool overwrite, | ||
| 91 | u64 *startp, u64 end); | ||
| 91 | 92 | ||
| 92 | int perf_mmap__push(struct perf_mmap *md, bool backward, | 93 | int perf_mmap__push(struct perf_mmap *md, bool backward, |
| 93 | void *to, int push(void *to, void *buf, size_t size)); | 94 | void *to, int push(void *to, void *buf, size_t size)); |
| 94 | 95 | ||
| 95 | size_t perf_mmap__mmap_len(struct perf_mmap *map); | 96 | size_t perf_mmap__mmap_len(struct perf_mmap *map); |
| 96 | 97 | ||
| 98 | int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, | ||
| 99 | u64 *startp, u64 *endp); | ||
| 100 | void perf_mmap__read_done(struct perf_mmap *map); | ||
| 97 | #endif /*__PERF_MMAP_H */ | 101 | #endif /*__PERF_MMAP_H */ |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 443892dabedb..1019bbc5dbd8 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
| @@ -340,35 +340,15 @@ size_t hex_width(u64 v) | |||
| 340 | return n; | 340 | return n; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | static int hex(char ch) | ||
| 344 | { | ||
| 345 | if ((ch >= '0') && (ch <= '9')) | ||
| 346 | return ch - '0'; | ||
| 347 | if ((ch >= 'a') && (ch <= 'f')) | ||
| 348 | return ch - 'a' + 10; | ||
| 349 | if ((ch >= 'A') && (ch <= 'F')) | ||
| 350 | return ch - 'A' + 10; | ||
| 351 | return -1; | ||
| 352 | } | ||
| 353 | |||
| 354 | /* | 343 | /* |
| 355 | * While we find nice hex chars, build a long_val. | 344 | * While we find nice hex chars, build a long_val. |
| 356 | * Return number of chars processed. | 345 | * Return number of chars processed. |
| 357 | */ | 346 | */ |
| 358 | int hex2u64(const char *ptr, u64 *long_val) | 347 | int hex2u64(const char *ptr, u64 *long_val) |
| 359 | { | 348 | { |
| 360 | const char *p = ptr; | 349 | char *p; |
| 361 | *long_val = 0; | ||
| 362 | |||
| 363 | while (*p) { | ||
| 364 | const int hex_val = hex(*p); | ||
| 365 | 350 | ||
| 366 | if (hex_val < 0) | 351 | *long_val = strtoull(ptr, &p, 16); |
| 367 | break; | ||
| 368 | |||
| 369 | *long_val = (*long_val << 4) | hex_val; | ||
| 370 | p++; | ||
| 371 | } | ||
| 372 | 352 | ||
| 373 | return p - ptr; | 353 | return p - ptr; |
| 374 | } | 354 | } |
diff --git a/tools/testing/selftests/powerpc/alignment/alignment_handler.c b/tools/testing/selftests/powerpc/alignment/alignment_handler.c index 39fd362415cf..0f2698f9fd6d 100644 --- a/tools/testing/selftests/powerpc/alignment/alignment_handler.c +++ b/tools/testing/selftests/powerpc/alignment/alignment_handler.c | |||
| @@ -57,7 +57,7 @@ volatile int gotsig; | |||
| 57 | 57 | ||
| 58 | void sighandler(int sig, siginfo_t *info, void *ctx) | 58 | void sighandler(int sig, siginfo_t *info, void *ctx) |
| 59 | { | 59 | { |
| 60 | struct ucontext *ucp = ctx; | 60 | ucontext_t *ucp = ctx; |
| 61 | 61 | ||
| 62 | if (!testing) { | 62 | if (!testing) { |
| 63 | signal(sig, SIG_DFL); | 63 | signal(sig, SIG_DFL); |
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index 10ca46df1449..d744991c0f4f 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile | |||
| @@ -5,16 +5,26 @@ include ../lib.mk | |||
| 5 | 5 | ||
| 6 | .PHONY: all all_32 all_64 warn_32bit_failure clean | 6 | .PHONY: all all_32 all_64 warn_32bit_failure clean |
| 7 | 7 | ||
| 8 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall test_mremap_vdso \ | 8 | UNAME_M := $(shell uname -m) |
| 9 | check_initial_reg_state sigreturn ldt_gdt iopl mpx-mini-test ioperm \ | 9 | CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) |
| 10 | CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) | ||
| 11 | |||
| 12 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ | ||
| 13 | check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \ | ||
| 10 | protection_keys test_vdso test_vsyscall | 14 | protection_keys test_vdso test_vsyscall |
| 11 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ | 15 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ |
| 12 | test_FCMOV test_FCOMI test_FISTTP \ | 16 | test_FCMOV test_FCOMI test_FISTTP \ |
| 13 | vdso_restorer | 17 | vdso_restorer |
| 14 | TARGETS_C_64BIT_ONLY := fsgsbase sysret_rip 5lvl | 18 | TARGETS_C_64BIT_ONLY := fsgsbase sysret_rip |
| 19 | # Some selftests require 32bit support enabled also on 64bit systems | ||
| 20 | TARGETS_C_32BIT_NEEDED := ldt_gdt ptrace_syscall | ||
| 15 | 21 | ||
| 16 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) | 22 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) $(TARGETS_C_32BIT_NEEDED) |
| 17 | TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY) | 23 | TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY) |
| 24 | ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),11) | ||
| 25 | TARGETS_C_64BIT_ALL += $(TARGETS_C_32BIT_NEEDED) | ||
| 26 | endif | ||
| 27 | |||
| 18 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) | 28 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) |
| 19 | BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) | 29 | BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) |
| 20 | 30 | ||
| @@ -23,10 +33,6 @@ BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) | |||
| 23 | 33 | ||
| 24 | CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie | 34 | CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie |
| 25 | 35 | ||
| 26 | UNAME_M := $(shell uname -m) | ||
| 27 | CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) | ||
| 28 | CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) | ||
| 29 | |||
| 30 | define gen-target-rule-32 | 36 | define gen-target-rule-32 |
| 31 | $(1) $(1)_32: $(OUTPUT)/$(1)_32 | 37 | $(1) $(1)_32: $(OUTPUT)/$(1)_32 |
| 32 | .PHONY: $(1) $(1)_32 | 38 | .PHONY: $(1) $(1)_32 |
| @@ -40,12 +46,14 @@ endef | |||
| 40 | ifeq ($(CAN_BUILD_I386),1) | 46 | ifeq ($(CAN_BUILD_I386),1) |
| 41 | all: all_32 | 47 | all: all_32 |
| 42 | TEST_PROGS += $(BINARIES_32) | 48 | TEST_PROGS += $(BINARIES_32) |
| 49 | EXTRA_CFLAGS += -DCAN_BUILD_32 | ||
| 43 | $(foreach t,$(TARGETS_C_32BIT_ALL),$(eval $(call gen-target-rule-32,$(t)))) | 50 | $(foreach t,$(TARGETS_C_32BIT_ALL),$(eval $(call gen-target-rule-32,$(t)))) |
| 44 | endif | 51 | endif |
| 45 | 52 | ||
| 46 | ifeq ($(CAN_BUILD_X86_64),1) | 53 | ifeq ($(CAN_BUILD_X86_64),1) |
| 47 | all: all_64 | 54 | all: all_64 |
| 48 | TEST_PROGS += $(BINARIES_64) | 55 | TEST_PROGS += $(BINARIES_64) |
| 56 | EXTRA_CFLAGS += -DCAN_BUILD_64 | ||
| 49 | $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(call gen-target-rule-64,$(t)))) | 57 | $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(call gen-target-rule-64,$(t)))) |
| 50 | endif | 58 | endif |
| 51 | 59 | ||
diff --git a/tools/testing/selftests/x86/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c index ec0f6b45ce8b..9c0325e1ea68 100644 --- a/tools/testing/selftests/x86/mpx-mini-test.c +++ b/tools/testing/selftests/x86/mpx-mini-test.c | |||
| @@ -315,11 +315,39 @@ static inline void *__si_bounds_upper(siginfo_t *si) | |||
| 315 | return si->si_upper; | 315 | return si->si_upper; |
| 316 | } | 316 | } |
| 317 | #else | 317 | #else |
| 318 | |||
| 319 | /* | ||
| 320 | * This deals with old version of _sigfault in some distros: | ||
| 321 | * | ||
| 322 | |||
| 323 | old _sigfault: | ||
| 324 | struct { | ||
| 325 | void *si_addr; | ||
| 326 | } _sigfault; | ||
| 327 | |||
| 328 | new _sigfault: | ||
| 329 | struct { | ||
| 330 | void __user *_addr; | ||
| 331 | int _trapno; | ||
| 332 | short _addr_lsb; | ||
| 333 | union { | ||
| 334 | struct { | ||
| 335 | void __user *_lower; | ||
| 336 | void __user *_upper; | ||
| 337 | } _addr_bnd; | ||
| 338 | __u32 _pkey; | ||
| 339 | }; | ||
| 340 | } _sigfault; | ||
| 341 | * | ||
| 342 | */ | ||
| 343 | |||
| 318 | static inline void **__si_bounds_hack(siginfo_t *si) | 344 | static inline void **__si_bounds_hack(siginfo_t *si) |
| 319 | { | 345 | { |
| 320 | void *sigfault = &si->_sifields._sigfault; | 346 | void *sigfault = &si->_sifields._sigfault; |
| 321 | void *end_sigfault = sigfault + sizeof(si->_sifields._sigfault); | 347 | void *end_sigfault = sigfault + sizeof(si->_sifields._sigfault); |
| 322 | void **__si_lower = end_sigfault; | 348 | int *trapno = (int*)end_sigfault; |
| 349 | /* skip _trapno and _addr_lsb */ | ||
| 350 | void **__si_lower = (void**)(trapno + 2); | ||
| 323 | 351 | ||
| 324 | return __si_lower; | 352 | return __si_lower; |
| 325 | } | 353 | } |
| @@ -331,7 +359,7 @@ static inline void *__si_bounds_lower(siginfo_t *si) | |||
| 331 | 359 | ||
| 332 | static inline void *__si_bounds_upper(siginfo_t *si) | 360 | static inline void *__si_bounds_upper(siginfo_t *si) |
| 333 | { | 361 | { |
| 334 | return (*__si_bounds_hack(si)) + sizeof(void *); | 362 | return *(__si_bounds_hack(si) + 1); |
| 335 | } | 363 | } |
| 336 | #endif | 364 | #endif |
| 337 | 365 | ||
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index bc1b0735bb50..f15aa5a76fe3 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c | |||
| @@ -393,34 +393,6 @@ pid_t fork_lazy_child(void) | |||
| 393 | return forkret; | 393 | return forkret; |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | void davecmp(void *_a, void *_b, int len) | ||
| 397 | { | ||
| 398 | int i; | ||
| 399 | unsigned long *a = _a; | ||
| 400 | unsigned long *b = _b; | ||
| 401 | |||
| 402 | for (i = 0; i < len / sizeof(*a); i++) { | ||
| 403 | if (a[i] == b[i]) | ||
| 404 | continue; | ||
| 405 | |||
| 406 | dprintf3("[%3d]: a: %016lx b: %016lx\n", i, a[i], b[i]); | ||
| 407 | } | ||
| 408 | } | ||
| 409 | |||
| 410 | void dumpit(char *f) | ||
| 411 | { | ||
| 412 | int fd = open(f, O_RDONLY); | ||
| 413 | char buf[100]; | ||
| 414 | int nr_read; | ||
| 415 | |||
| 416 | dprintf2("maps fd: %d\n", fd); | ||
| 417 | do { | ||
| 418 | nr_read = read(fd, &buf[0], sizeof(buf)); | ||
| 419 | write(1, buf, nr_read); | ||
| 420 | } while (nr_read > 0); | ||
| 421 | close(fd); | ||
| 422 | } | ||
| 423 | |||
| 424 | #define PKEY_DISABLE_ACCESS 0x1 | 396 | #define PKEY_DISABLE_ACCESS 0x1 |
| 425 | #define PKEY_DISABLE_WRITE 0x2 | 397 | #define PKEY_DISABLE_WRITE 0x2 |
| 426 | 398 | ||
diff --git a/tools/testing/selftests/x86/single_step_syscall.c b/tools/testing/selftests/x86/single_step_syscall.c index a48da95c18fd..ddfdd635de16 100644 --- a/tools/testing/selftests/x86/single_step_syscall.c +++ b/tools/testing/selftests/x86/single_step_syscall.c | |||
| @@ -119,7 +119,9 @@ static void check_result(void) | |||
| 119 | 119 | ||
| 120 | int main() | 120 | int main() |
| 121 | { | 121 | { |
| 122 | #ifdef CAN_BUILD_32 | ||
| 122 | int tmp; | 123 | int tmp; |
| 124 | #endif | ||
| 123 | 125 | ||
| 124 | sethandler(SIGTRAP, sigtrap, 0); | 126 | sethandler(SIGTRAP, sigtrap, 0); |
| 125 | 127 | ||
| @@ -139,12 +141,13 @@ int main() | |||
| 139 | : : "c" (post_nop) : "r11"); | 141 | : : "c" (post_nop) : "r11"); |
| 140 | check_result(); | 142 | check_result(); |
| 141 | #endif | 143 | #endif |
| 142 | 144 | #ifdef CAN_BUILD_32 | |
| 143 | printf("[RUN]\tSet TF and check int80\n"); | 145 | printf("[RUN]\tSet TF and check int80\n"); |
| 144 | set_eflags(get_eflags() | X86_EFLAGS_TF); | 146 | set_eflags(get_eflags() | X86_EFLAGS_TF); |
| 145 | asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) | 147 | asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) |
| 146 | : INT80_CLOBBERS); | 148 | : INT80_CLOBBERS); |
| 147 | check_result(); | 149 | check_result(); |
| 150 | #endif | ||
| 148 | 151 | ||
| 149 | /* | 152 | /* |
| 150 | * This test is particularly interesting if fast syscalls use | 153 | * This test is particularly interesting if fast syscalls use |
diff --git a/tools/testing/selftests/x86/test_mremap_vdso.c b/tools/testing/selftests/x86/test_mremap_vdso.c index bf0d687c7db7..64f11c8d9b76 100644 --- a/tools/testing/selftests/x86/test_mremap_vdso.c +++ b/tools/testing/selftests/x86/test_mremap_vdso.c | |||
| @@ -90,8 +90,12 @@ int main(int argc, char **argv, char **envp) | |||
| 90 | vdso_size += PAGE_SIZE; | 90 | vdso_size += PAGE_SIZE; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | #ifdef __i386__ | ||
| 93 | /* Glibc is likely to explode now - exit with raw syscall */ | 94 | /* Glibc is likely to explode now - exit with raw syscall */ |
| 94 | asm volatile ("int $0x80" : : "a" (__NR_exit), "b" (!!ret)); | 95 | asm volatile ("int $0x80" : : "a" (__NR_exit), "b" (!!ret)); |
| 96 | #else /* __x86_64__ */ | ||
| 97 | syscall(SYS_exit, ret); | ||
| 98 | #endif | ||
| 95 | } else { | 99 | } else { |
| 96 | int status; | 100 | int status; |
| 97 | 101 | ||
diff --git a/tools/testing/selftests/x86/test_vdso.c b/tools/testing/selftests/x86/test_vdso.c index 29973cde06d3..235259011704 100644 --- a/tools/testing/selftests/x86/test_vdso.c +++ b/tools/testing/selftests/x86/test_vdso.c | |||
| @@ -26,20 +26,59 @@ | |||
| 26 | # endif | 26 | # endif |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | /* max length of lines in /proc/self/maps - anything longer is skipped here */ | ||
| 30 | #define MAPS_LINE_LEN 128 | ||
| 31 | |||
| 29 | int nerrs = 0; | 32 | int nerrs = 0; |
| 30 | 33 | ||
| 34 | typedef long (*getcpu_t)(unsigned *, unsigned *, void *); | ||
| 35 | |||
| 36 | getcpu_t vgetcpu; | ||
| 37 | getcpu_t vdso_getcpu; | ||
| 38 | |||
| 39 | static void *vsyscall_getcpu(void) | ||
| 40 | { | ||
| 31 | #ifdef __x86_64__ | 41 | #ifdef __x86_64__ |
| 32 | # define VSYS(x) (x) | 42 | FILE *maps; |
| 43 | char line[MAPS_LINE_LEN]; | ||
| 44 | bool found = false; | ||
| 45 | |||
| 46 | maps = fopen("/proc/self/maps", "r"); | ||
| 47 | if (!maps) /* might still be present, but ignore it here, as we test vDSO not vsyscall */ | ||
| 48 | return NULL; | ||
| 49 | |||
| 50 | while (fgets(line, MAPS_LINE_LEN, maps)) { | ||
| 51 | char r, x; | ||
| 52 | void *start, *end; | ||
| 53 | char name[MAPS_LINE_LEN]; | ||
| 54 | |||
| 55 | /* sscanf() is safe here as strlen(name) >= strlen(line) */ | ||
| 56 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", | ||
| 57 | &start, &end, &r, &x, name) != 5) | ||
| 58 | continue; | ||
| 59 | |||
| 60 | if (strcmp(name, "[vsyscall]")) | ||
| 61 | continue; | ||
| 62 | |||
| 63 | /* assume entries are OK, as we test vDSO here not vsyscall */ | ||
| 64 | found = true; | ||
| 65 | break; | ||
| 66 | } | ||
| 67 | |||
| 68 | fclose(maps); | ||
| 69 | |||
| 70 | if (!found) { | ||
| 71 | printf("Warning: failed to find vsyscall getcpu\n"); | ||
| 72 | return NULL; | ||
| 73 | } | ||
| 74 | return (void *) (0xffffffffff600800); | ||
| 33 | #else | 75 | #else |
| 34 | # define VSYS(x) 0 | 76 | return NULL; |
| 35 | #endif | 77 | #endif |
| 78 | } | ||
| 36 | 79 | ||
| 37 | typedef long (*getcpu_t)(unsigned *, unsigned *, void *); | ||
| 38 | |||
| 39 | const getcpu_t vgetcpu = (getcpu_t)VSYS(0xffffffffff600800); | ||
| 40 | getcpu_t vdso_getcpu; | ||
| 41 | 80 | ||
| 42 | void fill_function_pointers() | 81 | static void fill_function_pointers() |
| 43 | { | 82 | { |
| 44 | void *vdso = dlopen("linux-vdso.so.1", | 83 | void *vdso = dlopen("linux-vdso.so.1", |
| 45 | RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); | 84 | RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); |
| @@ -54,6 +93,8 @@ void fill_function_pointers() | |||
| 54 | vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); | 93 | vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); |
| 55 | if (!vdso_getcpu) | 94 | if (!vdso_getcpu) |
| 56 | printf("Warning: failed to find getcpu in vDSO\n"); | 95 | printf("Warning: failed to find getcpu in vDSO\n"); |
| 96 | |||
| 97 | vgetcpu = (getcpu_t) vsyscall_getcpu(); | ||
| 57 | } | 98 | } |
| 58 | 99 | ||
| 59 | static long sys_getcpu(unsigned * cpu, unsigned * node, | 100 | static long sys_getcpu(unsigned * cpu, unsigned * node, |
diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c index 7a744fa7b786..be81621446f0 100644 --- a/tools/testing/selftests/x86/test_vsyscall.c +++ b/tools/testing/selftests/x86/test_vsyscall.c | |||
| @@ -33,6 +33,9 @@ | |||
| 33 | # endif | 33 | # endif |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | /* max length of lines in /proc/self/maps - anything longer is skipped here */ | ||
| 37 | #define MAPS_LINE_LEN 128 | ||
| 38 | |||
| 36 | static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), | 39 | static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), |
| 37 | int flags) | 40 | int flags) |
| 38 | { | 41 | { |
| @@ -98,7 +101,7 @@ static int init_vsys(void) | |||
| 98 | #ifdef __x86_64__ | 101 | #ifdef __x86_64__ |
| 99 | int nerrs = 0; | 102 | int nerrs = 0; |
| 100 | FILE *maps; | 103 | FILE *maps; |
| 101 | char line[128]; | 104 | char line[MAPS_LINE_LEN]; |
| 102 | bool found = false; | 105 | bool found = false; |
| 103 | 106 | ||
| 104 | maps = fopen("/proc/self/maps", "r"); | 107 | maps = fopen("/proc/self/maps", "r"); |
| @@ -108,10 +111,12 @@ static int init_vsys(void) | |||
| 108 | return 0; | 111 | return 0; |
| 109 | } | 112 | } |
| 110 | 113 | ||
| 111 | while (fgets(line, sizeof(line), maps)) { | 114 | while (fgets(line, MAPS_LINE_LEN, maps)) { |
| 112 | char r, x; | 115 | char r, x; |
| 113 | void *start, *end; | 116 | void *start, *end; |
| 114 | char name[128]; | 117 | char name[MAPS_LINE_LEN]; |
| 118 | |||
| 119 | /* sscanf() is safe here as strlen(name) >= strlen(line) */ | ||
| 115 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", | 120 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", |
| 116 | &start, &end, &r, &x, name) != 5) | 121 | &start, &end, &r, &x, name) != 5) |
| 117 | continue; | 122 | continue; |
