aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-block-zram11
-rw-r--r--Documentation/blockdev/zram.txt74
-rw-r--r--Documentation/features/core/cBPF-JIT/arch-support.txt1
-rw-r--r--Documentation/features/core/eBPF-JIT/arch-support.txt1
-rw-r--r--Documentation/features/core/generic-idle-thread/arch-support.txt1
-rw-r--r--Documentation/features/core/jump-labels/arch-support.txt1
-rw-r--r--Documentation/features/core/tracehook/arch-support.txt1
-rw-r--r--Documentation/features/debug/KASAN/arch-support.txt1
-rw-r--r--Documentation/features/debug/gcov-profile-all/arch-support.txt1
-rw-r--r--Documentation/features/debug/kgdb/arch-support.txt1
-rw-r--r--Documentation/features/debug/kprobes-on-ftrace/arch-support.txt1
-rw-r--r--Documentation/features/debug/kprobes/arch-support.txt1
-rw-r--r--Documentation/features/debug/kretprobes/arch-support.txt1
-rw-r--r--Documentation/features/debug/optprobes/arch-support.txt1
-rw-r--r--Documentation/features/debug/stackprotector/arch-support.txt1
-rw-r--r--Documentation/features/debug/uprobes/arch-support.txt1
-rw-r--r--Documentation/features/debug/user-ret-profiler/arch-support.txt1
-rw-r--r--Documentation/features/io/dma-contiguous/arch-support.txt1
-rw-r--r--Documentation/features/locking/cmpxchg-local/arch-support.txt1
-rw-r--r--Documentation/features/locking/lockdep/arch-support.txt1
-rw-r--r--Documentation/features/locking/queued-rwlocks/arch-support.txt1
-rw-r--r--Documentation/features/locking/queued-spinlocks/arch-support.txt1
-rw-r--r--Documentation/features/locking/rwsem-optimized/arch-support.txt1
-rw-r--r--Documentation/features/perf/kprobes-event/arch-support.txt1
-rw-r--r--Documentation/features/perf/perf-regs/arch-support.txt1
-rw-r--r--Documentation/features/perf/perf-stackdump/arch-support.txt1
-rw-r--r--Documentation/features/sched/membarrier-sync-core/arch-support.txt1
-rw-r--r--Documentation/features/sched/numa-balancing/arch-support.txt1
-rw-r--r--Documentation/features/seccomp/seccomp-filter/arch-support.txt1
-rw-r--r--Documentation/features/time/arch-tick-broadcast/arch-support.txt1
-rw-r--r--Documentation/features/time/clockevents/arch-support.txt1
-rw-r--r--Documentation/features/time/context-tracking/arch-support.txt1
-rw-r--r--Documentation/features/time/irq-time-acct/arch-support.txt1
-rw-r--r--Documentation/features/time/modern-timekeeping/arch-support.txt1
-rw-r--r--Documentation/features/time/virt-cpuacct/arch-support.txt1
-rw-r--r--Documentation/features/vm/ELF-ASLR/arch-support.txt1
-rw-r--r--Documentation/features/vm/PG_uncached/arch-support.txt1
-rw-r--r--Documentation/features/vm/THP/arch-support.txt1
-rw-r--r--Documentation/features/vm/TLB/arch-support.txt1
-rw-r--r--Documentation/features/vm/huge-vmap/arch-support.txt1
-rw-r--r--Documentation/features/vm/ioremap_prot/arch-support.txt1
-rw-r--r--Documentation/features/vm/numa-memblock/arch-support.txt1
-rw-r--r--Documentation/features/vm/pte_special/arch-support.txt1
-rw-r--r--Documentation/trace/coresight-cpu-debug.txt2
-rw-r--r--Documentation/virtual/kvm/amd-memory-encryption.rst2
-rw-r--r--Documentation/x86/resctrl_ui.txt2
-rw-r--r--MAINTAINERS10
-rw-r--r--arch/arm64/include/asm/asm-prototypes.h2
-rw-r--r--arch/arm64/include/asm/cache.h6
-rw-r--r--arch/arm64/include/asm/mmu.h41
-rw-r--r--arch/arm64/include/asm/pgtable-prot.h4
-rw-r--r--arch/arm64/kernel/cpu_errata.c2
-rw-r--r--arch/arm64/kernel/cpufeature.c9
-rw-r--r--arch/arm64/kernel/head.S1
-rw-r--r--arch/arm64/kernel/machine_kexec_file.c4
-rw-r--r--arch/csky/include/asm/io.h25
-rw-r--r--arch/csky/include/asm/pgalloc.h43
-rw-r--r--arch/csky/kernel/module.c38
-rw-r--r--arch/openrisc/include/asm/uaccess.h8
-rw-r--r--arch/riscv/Kconfig4
-rw-r--r--arch/riscv/include/asm/module.h28
-rw-r--r--arch/riscv/include/asm/ptrace.h5
-rw-r--r--arch/riscv/include/asm/syscall.h10
-rw-r--r--arch/riscv/include/asm/thread_info.h6
-rw-r--r--arch/riscv/include/asm/unistd.h2
-rw-r--r--arch/riscv/kernel/entry.S4
-rw-r--r--arch/riscv/kernel/module-sections.c30
-rw-r--r--arch/riscv/kernel/ptrace.c9
-rw-r--r--arch/riscv/kernel/setup.c9
-rw-r--r--arch/riscv/kernel/smp.c43
-rw-r--r--arch/riscv/kernel/vmlinux.lds.S8
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/include/asm/resctrl_sched.h4
-rw-r--r--arch/x86/kernel/cpu/Makefile2
-rw-r--r--arch/x86/kernel/cpu/bugs.c2
-rw-r--r--arch/x86/kernel/cpu/resctrl/Makefile4
-rw-r--r--arch/x86/kvm/svm.c3
-rw-r--r--arch/x86/kvm/vmx/nested.c3
-rw-r--r--arch/x86/kvm/vmx/vmx.c4
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/arm64/iort.c5
-rw-r--r--drivers/acpi/numa.c6
-rw-r--r--drivers/acpi/pmic/intel_pmic_xpower.c41
-rw-r--r--drivers/acpi/power.c22
-rw-r--r--drivers/base/power/main.c3
-rw-r--r--drivers/base/power/runtime.c11
-rw-r--r--drivers/block/rbd.c9
-rw-r--r--drivers/block/zram/zram_drv.c90
-rw-r--r--drivers/block/zram/zram_drv.h5
-rw-r--r--drivers/cpufreq/cpufreq.c12
-rw-r--r--drivers/cpufreq/scmi-cpufreq.c8
-rw-r--r--drivers/cpufreq/scpi-cpufreq.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_display.c38
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c22
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_virtual.c17
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c48
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c14
-rw-r--r--drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c3
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c37
-rw-r--r--drivers/gpu/drm/amd/include/kgd_pp_interface.h13
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c24
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c8
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c12
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c34
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h2
-rw-r--r--drivers/gpu/drm/bridge/tc358767.c48
-rw-r--r--drivers/gpu/drm/drm_atomic_uapi.c3
-rw-r--r--drivers/gpu/drm/drm_dp_helper.c2
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c133
-rw-r--r--drivers/gpu/drm/drm_mode_object.c4
-rw-r--r--drivers/gpu/drm/i915/gvt/scheduler.c64
-rw-r--r--drivers/gpu/drm/i915/gvt/scheduler.h1
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c12
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c15
-rw-r--r--drivers/gpu/drm/i915/i915_gpu_error.c23
-rw-r--r--drivers/gpu/drm/i915/i915_sysfs.c4
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c3
-rw-r--r--drivers/gpu/drm/i915/intel_psr.c6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_backlight.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/falcon.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c7
-rw-r--r--drivers/i2c/busses/i2c-tegra.c15
-rw-r--r--drivers/i2c/i2c-dev.c6
-rw-r--r--drivers/irqchip/irq-csky-apb-intc.c77
-rw-r--r--drivers/mtd/mtdcore.c2
-rw-r--r--drivers/mtd/mtdcore.h2
-rw-r--r--drivers/mtd/mtdpart.c36
-rw-r--r--drivers/mtd/nand/raw/qcom_nandc.c20
-rw-r--r--drivers/opp/core.c63
-rw-r--r--drivers/pci/controller/dwc/pci-meson.c1
-rw-r--r--drivers/tty/serial/Kconfig12
-rw-r--r--drivers/tty/serial/Makefile1
-rw-r--r--drivers/tty/serial/earlycon-riscv-sbi.c28
-rw-r--r--drivers/vfio/pci/trace.h2
-rw-r--r--drivers/vfio/vfio_iommu_type1.c2
-rw-r--r--fs/ceph/addr.c5
-rw-r--r--fs/ceph/super.c4
-rw-r--r--fs/hugetlbfs/inode.c61
-rw-r--r--include/drm/drm_dp_helper.h7
-rw-r--r--include/drm/drm_dp_mst_helper.h3
-rw-r--r--include/linux/ceph/libceph.h6
-rw-r--r--include/linux/ceph/osd_client.h1
-rw-r--r--include/linux/compiler-gcc.h2
-rw-r--r--include/linux/mmzone.h6
-rw-r--r--include/linux/module.h2
-rw-r--r--include/linux/pm_opp.h5
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/uapi/linux/audit.h2
-rw-r--r--kernel/fork.c14
-rw-r--r--mm/hugetlb.c81
-rw-r--r--mm/kasan/common.c65
-rw-r--r--mm/memory-failure.c16
-rw-r--r--mm/memory.c26
-rw-r--r--mm/migrate.c13
-rw-r--r--mm/page_alloc.c8
-rw-r--r--mm/rmap.c8
-rw-r--r--mm/slab.c6
-rw-r--r--mm/slub.c2
-rw-r--r--mm/usercopy.c9
-rw-r--r--mm/userfaultfd.c11
-rw-r--r--mm/util.c2
-rw-r--r--net/ceph/ceph_common.c11
-rw-r--r--net/ceph/debugfs.c2
-rw-r--r--net/ceph/osd_client.c4
-rw-r--r--samples/seccomp/Makefile1
-rw-r--r--scripts/mod/modpost.c2
-rw-r--r--sound/pci/cs46xx/dsp_spos.c3
-rw-r--r--sound/pci/hda/patch_realtek.c18
-rw-r--r--sound/usb/card.c2
-rw-r--r--sound/usb/mixer.c29
-rw-r--r--sound/usb/quirks-table.h6
-rw-r--r--sound/usb/quirks.c2
-rw-r--r--sound/usb/stream.c36
-rw-r--r--tools/arch/powerpc/include/uapi/asm/unistd.h404
-rw-r--r--tools/arch/riscv/include/uapi/asm/bitsperlong.h25
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/arch/x86/include/asm/disabled-features.h8
-rw-r--r--tools/include/uapi/asm-generic/unistd.h4
-rw-r--r--tools/include/uapi/asm/bitsperlong.h2
-rw-r--r--tools/include/uapi/drm/i915_drm.h8
-rw-r--r--tools/include/uapi/linux/fs.h60
-rw-r--r--tools/include/uapi/linux/if_link.h19
-rw-r--r--tools/include/uapi/linux/in.h10
-rw-r--r--tools/include/uapi/linux/kvm.h19
-rw-r--r--tools/include/uapi/linux/mount.h58
-rw-r--r--tools/include/uapi/linux/prctl.h8
-rw-r--r--tools/include/uapi/linux/vhost.h113
-rw-r--r--tools/lib/traceevent/event-parse-api.c4
-rw-r--r--tools/lib/traceevent/event-parse-local.h4
-rw-r--r--tools/lib/traceevent/event-parse.c129
-rw-r--r--tools/lib/traceevent/event-parse.h17
-rw-r--r--tools/lib/traceevent/plugin_kvm.c2
-rw-r--r--tools/lib/traceevent/trace-seq.c17
-rw-r--r--tools/perf/Makefile.perf8
-rw-r--r--tools/perf/arch/arm/tests/Build1
-rw-r--r--tools/perf/arch/arm/tests/arch-tests.c4
-rw-r--r--tools/perf/arch/arm/tests/vectors-page.c24
-rw-r--r--tools/perf/arch/powerpc/Makefile15
-rwxr-xr-xtools/perf/arch/powerpc/entry/syscalls/mksyscalltbl22
-rw-r--r--tools/perf/arch/powerpc/entry/syscalls/syscall.tbl427
-rw-r--r--tools/perf/builtin-stat.c3
-rw-r--r--tools/perf/builtin-top.c7
-rw-r--r--tools/perf/builtin-trace.c15
-rwxr-xr-xtools/perf/check-headers.sh2
-rw-r--r--tools/perf/perf-read-vdso.c6
-rw-r--r--tools/perf/tests/shell/lib/probe_vfs_getname.sh3
-rw-r--r--tools/perf/tests/tests.h5
-rwxr-xr-xtools/perf/trace/beauty/mount_flags.sh4
-rwxr-xr-xtools/perf/trace/beauty/prctl_option.sh2
-rw-r--r--tools/perf/util/annotate.c8
-rw-r--r--tools/perf/util/callchain.c32
-rw-r--r--tools/perf/util/callchain.h1
-rw-r--r--tools/perf/util/find-map.c (renamed from tools/perf/util/find-vdso-map.c)7
-rw-r--r--tools/perf/util/machine.c2
-rw-r--r--tools/perf/util/strbuf.c1
-rw-r--r--tools/perf/util/symbol.c1
-rw-r--r--tools/perf/util/vdso.c6
-rw-r--r--tools/thermal/tmon/Makefile2
-rw-r--r--tools/vm/page_owner_sort.c4
-rw-r--r--virt/kvm/kvm_main.c9
223 files changed, 2255 insertions, 1377 deletions
diff --git a/Documentation/ABI/testing/sysfs-block-zram b/Documentation/ABI/testing/sysfs-block-zram
index 9d2339a485c8..14b2bf2e5105 100644
--- a/Documentation/ABI/testing/sysfs-block-zram
+++ b/Documentation/ABI/testing/sysfs-block-zram
@@ -122,11 +122,18 @@ Description:
122 statistics (bd_count, bd_reads, bd_writes) in a format 122 statistics (bd_count, bd_reads, bd_writes) in a format
123 similar to block layer statistics file format. 123 similar to block layer statistics file format.
124 124
125What: /sys/block/zram<id>/writeback_limit_enable
126Date: November 2018
127Contact: Minchan Kim <minchan@kernel.org>
128Description:
129 The writeback_limit_enable file is read-write and specifies
130 eanbe of writeback_limit feature. "1" means eable the feature.
131 No limit "0" is the initial state.
132
125What: /sys/block/zram<id>/writeback_limit 133What: /sys/block/zram<id>/writeback_limit
126Date: November 2018 134Date: November 2018
127Contact: Minchan Kim <minchan@kernel.org> 135Contact: Minchan Kim <minchan@kernel.org>
128Description: 136Description:
129 The writeback_limit file is read-write and specifies the maximum 137 The writeback_limit file is read-write and specifies the maximum
130 amount of writeback ZRAM can do. The limit could be changed 138 amount of writeback ZRAM can do. The limit could be changed
131 in run time and "0" means disable the limit. 139 in run time.
132 No limit is the initial state.
diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index 436c5e98e1b6..4df0ce271085 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -156,22 +156,23 @@ Per-device statistics are exported as various nodes under /sys/block/zram<id>/
156A brief description of exported device attributes. For more details please 156A brief description of exported device attributes. For more details please
157read Documentation/ABI/testing/sysfs-block-zram. 157read Documentation/ABI/testing/sysfs-block-zram.
158 158
159Name access description 159Name access description
160---- ------ ----------- 160---- ------ -----------
161disksize RW show and set the device's disk size 161disksize RW show and set the device's disk size
162initstate RO shows the initialization state of the device 162initstate RO shows the initialization state of the device
163reset WO trigger device reset 163reset WO trigger device reset
164mem_used_max WO reset the `mem_used_max' counter (see later) 164mem_used_max WO reset the `mem_used_max' counter (see later)
165mem_limit WO specifies the maximum amount of memory ZRAM can use 165mem_limit WO specifies the maximum amount of memory ZRAM can use
166 to store the compressed data 166 to store the compressed data
167writeback_limit WO specifies the maximum amount of write IO zram can 167writeback_limit WO specifies the maximum amount of write IO zram can
168 write out to backing device as 4KB unit 168 write out to backing device as 4KB unit
169max_comp_streams RW the number of possible concurrent compress operations 169writeback_limit_enable RW show and set writeback_limit feature
170comp_algorithm RW show and change the compression algorithm 170max_comp_streams RW the number of possible concurrent compress operations
171compact WO trigger memory compaction 171comp_algorithm RW show and change the compression algorithm
172debug_stat RO this file is used for zram debugging purposes 172compact WO trigger memory compaction
173backing_dev RW set up backend storage for zram to write out 173debug_stat RO this file is used for zram debugging purposes
174idle WO mark allocated slot as idle 174backing_dev RW set up backend storage for zram to write out
175idle WO mark allocated slot as idle
175 176
176 177
177User space is advised to use the following files to read the device statistics. 178User space is advised to use the following files to read the device statistics.
@@ -280,32 +281,51 @@ With the command, zram writeback idle pages from memory to the storage.
280If there are lots of write IO with flash device, potentially, it has 281If there are lots of write IO with flash device, potentially, it has
281flash wearout problem so that admin needs to design write limitation 282flash wearout problem so that admin needs to design write limitation
282to guarantee storage health for entire product life. 283to guarantee storage health for entire product life.
283To overcome the concern, zram supports "writeback_limit". 284
284The "writeback_limit"'s default value is 0 so that it doesn't limit 285To overcome the concern, zram supports "writeback_limit" feature.
285any writeback. If admin want to measure writeback count in a certain 286The "writeback_limit_enable"'s default value is 0 so that it doesn't limit
286period, he could know it via /sys/block/zram0/bd_stat's 3rd column. 287any writeback. IOW, if admin want to apply writeback budget, he should
288enable writeback_limit_enable via
289
290 $ echo 1 > /sys/block/zramX/writeback_limit_enable
291
292Once writeback_limit_enable is set, zram doesn't allow any writeback
293until admin set the budget via /sys/block/zramX/writeback_limit.
294
295(If admin doesn't enable writeback_limit_enable, writeback_limit's value
296assigned via /sys/block/zramX/writeback_limit is meaninless.)
287 297
288If admin want to limit writeback as per-day 400M, he could do it 298If admin want to limit writeback as per-day 400M, he could do it
289like below. 299like below.
290 300
291 MB_SHIFT=20 301 $ MB_SHIFT=20
292 4K_SHIFT=12 302 $ 4K_SHIFT=12
293 echo $((400<<MB_SHIFT>>4K_SHIFT)) > \ 303 $ echo $((400<<MB_SHIFT>>4K_SHIFT)) > \
294 /sys/block/zram0/writeback_limit. 304 /sys/block/zram0/writeback_limit.
305 $ echo 1 > /sys/block/zram0/writeback_limit_enable
295 306
296If admin want to allow further write again, he could do it like below 307If admin want to allow further write again once the bugdet is exausted,
308he could do it like below
297 309
298 echo 0 > /sys/block/zram0/writeback_limit 310 $ echo $((400<<MB_SHIFT>>4K_SHIFT)) > \
311 /sys/block/zram0/writeback_limit
299 312
300If admin want to see remaining writeback budget since he set, 313If admin want to see remaining writeback budget since he set,
301 314
302 cat /sys/block/zram0/writeback_limit 315 $ cat /sys/block/zramX/writeback_limit
316
317If admin want to disable writeback limit, he could do
318
319 $ echo 0 > /sys/block/zramX/writeback_limit_enable
303 320
304The writeback_limit count will reset whenever you reset zram(e.g., 321The writeback_limit count will reset whenever you reset zram(e.g.,
305system reboot, echo 1 > /sys/block/zramX/reset) so keeping how many of 322system reboot, echo 1 > /sys/block/zramX/reset) so keeping how many of
306writeback happened until you reset the zram to allocate extra writeback 323writeback happened until you reset the zram to allocate extra writeback
307budget in next setting is user's job. 324budget in next setting is user's job.
308 325
326If admin want to measure writeback count in a certain period, he could
327know it via /sys/block/zram0/bd_stat's 3rd column.
328
309= memory tracking 329= memory tracking
310 330
311With CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the 331With CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the
diff --git a/Documentation/features/core/cBPF-JIT/arch-support.txt b/Documentation/features/core/cBPF-JIT/arch-support.txt
index 90459cdde314..8620c38d4db0 100644
--- a/Documentation/features/core/cBPF-JIT/arch-support.txt
+++ b/Documentation/features/core/cBPF-JIT/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/core/eBPF-JIT/arch-support.txt b/Documentation/features/core/eBPF-JIT/arch-support.txt
index c90a0382fe66..9ae6e8d0d10d 100644
--- a/Documentation/features/core/eBPF-JIT/arch-support.txt
+++ b/Documentation/features/core/eBPF-JIT/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/core/generic-idle-thread/arch-support.txt b/Documentation/features/core/generic-idle-thread/arch-support.txt
index 0ef6acdb991c..365df2c2ff0b 100644
--- a/Documentation/features/core/generic-idle-thread/arch-support.txt
+++ b/Documentation/features/core/generic-idle-thread/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | ok |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/core/jump-labels/arch-support.txt b/Documentation/features/core/jump-labels/arch-support.txt
index 60111395f932..7fc2e243dee9 100644
--- a/Documentation/features/core/jump-labels/arch-support.txt
+++ b/Documentation/features/core/jump-labels/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/core/tracehook/arch-support.txt b/Documentation/features/core/tracehook/arch-support.txt
index f44c274e40ed..d344b99aae1e 100644
--- a/Documentation/features/core/tracehook/arch-support.txt
+++ b/Documentation/features/core/tracehook/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | ok | 13 | c6x: | ok |
14 | csky: | ok |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/debug/KASAN/arch-support.txt b/Documentation/features/debug/KASAN/arch-support.txt
index 282ecc8ea1da..304dcd461795 100644
--- a/Documentation/features/debug/KASAN/arch-support.txt
+++ b/Documentation/features/debug/KASAN/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/gcov-profile-all/arch-support.txt b/Documentation/features/debug/gcov-profile-all/arch-support.txt
index 01b2b3004e0a..059d58a549c7 100644
--- a/Documentation/features/debug/gcov-profile-all/arch-support.txt
+++ b/Documentation/features/debug/gcov-profile-all/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/kgdb/arch-support.txt b/Documentation/features/debug/kgdb/arch-support.txt
index 3b4dff22329f..3e6b8f07d5d0 100644
--- a/Documentation/features/debug/kgdb/arch-support.txt
+++ b/Documentation/features/debug/kgdb/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | ok | 15 | h8300: | ok |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt b/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
index 7e963d0ae646..68f266944d5f 100644
--- a/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
+++ b/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/kprobes/arch-support.txt b/Documentation/features/debug/kprobes/arch-support.txt
index 4ada027faf16..f4e45bd58fea 100644
--- a/Documentation/features/debug/kprobes/arch-support.txt
+++ b/Documentation/features/debug/kprobes/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/debug/kretprobes/arch-support.txt b/Documentation/features/debug/kretprobes/arch-support.txt
index 044e13fcca5d..1d5651ef11f8 100644
--- a/Documentation/features/debug/kretprobes/arch-support.txt
+++ b/Documentation/features/debug/kretprobes/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/debug/optprobes/arch-support.txt b/Documentation/features/debug/optprobes/arch-support.txt
index dce7669c918f..fb297a88f62c 100644
--- a/Documentation/features/debug/optprobes/arch-support.txt
+++ b/Documentation/features/debug/optprobes/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/stackprotector/arch-support.txt b/Documentation/features/debug/stackprotector/arch-support.txt
index 954ac1c95553..9999ea521f3e 100644
--- a/Documentation/features/debug/stackprotector/arch-support.txt
+++ b/Documentation/features/debug/stackprotector/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/uprobes/arch-support.txt b/Documentation/features/debug/uprobes/arch-support.txt
index 1a3f9d3229bf..1c577d0cfc7f 100644
--- a/Documentation/features/debug/uprobes/arch-support.txt
+++ b/Documentation/features/debug/uprobes/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/debug/user-ret-profiler/arch-support.txt b/Documentation/features/debug/user-ret-profiler/arch-support.txt
index 1d78d1069a5f..6bfa36b0e017 100644
--- a/Documentation/features/debug/user-ret-profiler/arch-support.txt
+++ b/Documentation/features/debug/user-ret-profiler/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/io/dma-contiguous/arch-support.txt b/Documentation/features/io/dma-contiguous/arch-support.txt
index 30c072d2b67c..eb28b5c97ca6 100644
--- a/Documentation/features/io/dma-contiguous/arch-support.txt
+++ b/Documentation/features/io/dma-contiguous/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | ok |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/locking/cmpxchg-local/arch-support.txt b/Documentation/features/locking/cmpxchg-local/arch-support.txt
index 51704a2dc8d1..242ff5a6586e 100644
--- a/Documentation/features/locking/cmpxchg-local/arch-support.txt
+++ b/Documentation/features/locking/cmpxchg-local/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/locking/lockdep/arch-support.txt b/Documentation/features/locking/lockdep/arch-support.txt
index bd39c5edd460..941fd5b1094d 100644
--- a/Documentation/features/locking/lockdep/arch-support.txt
+++ b/Documentation/features/locking/lockdep/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/locking/queued-rwlocks/arch-support.txt b/Documentation/features/locking/queued-rwlocks/arch-support.txt
index da7aff3bee0b..c683da198f31 100644
--- a/Documentation/features/locking/queued-rwlocks/arch-support.txt
+++ b/Documentation/features/locking/queued-rwlocks/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | ok |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/locking/queued-spinlocks/arch-support.txt b/Documentation/features/locking/queued-spinlocks/arch-support.txt
index 478e9101322c..e3080b82aefd 100644
--- a/Documentation/features/locking/queued-spinlocks/arch-support.txt
+++ b/Documentation/features/locking/queued-spinlocks/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/locking/rwsem-optimized/arch-support.txt b/Documentation/features/locking/rwsem-optimized/arch-support.txt
index e54b1f1a8091..7521d7500fbe 100644
--- a/Documentation/features/locking/rwsem-optimized/arch-support.txt
+++ b/Documentation/features/locking/rwsem-optimized/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/perf/kprobes-event/arch-support.txt b/Documentation/features/perf/kprobes-event/arch-support.txt
index 7331402d1887..d8278bf62b85 100644
--- a/Documentation/features/perf/kprobes-event/arch-support.txt
+++ b/Documentation/features/perf/kprobes-event/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/perf/perf-regs/arch-support.txt b/Documentation/features/perf/perf-regs/arch-support.txt
index 53feeee6cdad..687d049d9cee 100644
--- a/Documentation/features/perf/perf-regs/arch-support.txt
+++ b/Documentation/features/perf/perf-regs/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/perf/perf-stackdump/arch-support.txt b/Documentation/features/perf/perf-stackdump/arch-support.txt
index 16164348e0ea..90996e3d18a8 100644
--- a/Documentation/features/perf/perf-stackdump/arch-support.txt
+++ b/Documentation/features/perf/perf-stackdump/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/sched/membarrier-sync-core/arch-support.txt b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
index c7858dd1ea8f..8a521a622966 100644
--- a/Documentation/features/sched/membarrier-sync-core/arch-support.txt
+++ b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
@@ -34,6 +34,7 @@
34 | arm: | ok | 34 | arm: | ok |
35 | arm64: | ok | 35 | arm64: | ok |
36 | c6x: | TODO | 36 | c6x: | TODO |
37 | csky: | TODO |
37 | h8300: | TODO | 38 | h8300: | TODO |
38 | hexagon: | TODO | 39 | hexagon: | TODO |
39 | ia64: | TODO | 40 | ia64: | TODO |
diff --git a/Documentation/features/sched/numa-balancing/arch-support.txt b/Documentation/features/sched/numa-balancing/arch-support.txt
index c68bb2c2cb62..350823692f28 100644
--- a/Documentation/features/sched/numa-balancing/arch-support.txt
+++ b/Documentation/features/sched/numa-balancing/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | .. | 11 | arm: | .. |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | .. | 13 | c6x: | .. |
14 | csky: | .. |
14 | h8300: | .. | 15 | h8300: | .. |
15 | hexagon: | .. | 16 | hexagon: | .. |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/seccomp/seccomp-filter/arch-support.txt b/Documentation/features/seccomp/seccomp-filter/arch-support.txt
index d4271b493b41..4fe6c3c3be5c 100644
--- a/Documentation/features/seccomp/seccomp-filter/arch-support.txt
+++ b/Documentation/features/seccomp/seccomp-filter/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/time/arch-tick-broadcast/arch-support.txt b/Documentation/features/time/arch-tick-broadcast/arch-support.txt
index 83d9e68462bb..593536f7925b 100644
--- a/Documentation/features/time/arch-tick-broadcast/arch-support.txt
+++ b/Documentation/features/time/arch-tick-broadcast/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/time/clockevents/arch-support.txt b/Documentation/features/time/clockevents/arch-support.txt
index 3d4908fce6da..7a27157da408 100644
--- a/Documentation/features/time/clockevents/arch-support.txt
+++ b/Documentation/features/time/clockevents/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | ok | 13 | c6x: | ok |
14 | csky: | ok |
14 | h8300: | ok | 15 | h8300: | ok |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/time/context-tracking/arch-support.txt b/Documentation/features/time/context-tracking/arch-support.txt
index c29974afffaa..048bfb6d3872 100644
--- a/Documentation/features/time/context-tracking/arch-support.txt
+++ b/Documentation/features/time/context-tracking/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/time/irq-time-acct/arch-support.txt b/Documentation/features/time/irq-time-acct/arch-support.txt
index 8d73c463ec27..a14bbad8e948 100644
--- a/Documentation/features/time/irq-time-acct/arch-support.txt
+++ b/Documentation/features/time/irq-time-acct/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | .. | 17 | ia64: | .. |
diff --git a/Documentation/features/time/modern-timekeeping/arch-support.txt b/Documentation/features/time/modern-timekeeping/arch-support.txt
index e7c6ea6b8fb3..2855dfe2464d 100644
--- a/Documentation/features/time/modern-timekeeping/arch-support.txt
+++ b/Documentation/features/time/modern-timekeeping/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | ok | 13 | c6x: | ok |
14 | csky: | ok |
14 | h8300: | ok | 15 | h8300: | ok |
15 | hexagon: | ok | 16 | hexagon: | ok |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/time/virt-cpuacct/arch-support.txt b/Documentation/features/time/virt-cpuacct/arch-support.txt
index 4646457461cf..fb0d0cab9cab 100644
--- a/Documentation/features/time/virt-cpuacct/arch-support.txt
+++ b/Documentation/features/time/virt-cpuacct/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/vm/ELF-ASLR/arch-support.txt b/Documentation/features/vm/ELF-ASLR/arch-support.txt
index 1f71d090ff2c..adc25878d217 100644
--- a/Documentation/features/vm/ELF-ASLR/arch-support.txt
+++ b/Documentation/features/vm/ELF-ASLR/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/vm/PG_uncached/arch-support.txt b/Documentation/features/vm/PG_uncached/arch-support.txt
index fbd5aa463b0a..f05588f9e4b4 100644
--- a/Documentation/features/vm/PG_uncached/arch-support.txt
+++ b/Documentation/features/vm/PG_uncached/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/vm/THP/arch-support.txt b/Documentation/features/vm/THP/arch-support.txt
index 5d7ecc378f29..cdfe8925f881 100644
--- a/Documentation/features/vm/THP/arch-support.txt
+++ b/Documentation/features/vm/THP/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | .. | 13 | c6x: | .. |
14 | csky: | .. |
14 | h8300: | .. | 15 | h8300: | .. |
15 | hexagon: | .. | 16 | hexagon: | .. |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/vm/TLB/arch-support.txt b/Documentation/features/vm/TLB/arch-support.txt
index f7af9678eb66..2bdd3b6cee3c 100644
--- a/Documentation/features/vm/TLB/arch-support.txt
+++ b/Documentation/features/vm/TLB/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | .. | 13 | c6x: | .. |
14 | csky: | TODO |
14 | h8300: | .. | 15 | h8300: | .. |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/vm/huge-vmap/arch-support.txt b/Documentation/features/vm/huge-vmap/arch-support.txt
index d0713ccc7117..019131c5acce 100644
--- a/Documentation/features/vm/huge-vmap/arch-support.txt
+++ b/Documentation/features/vm/huge-vmap/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Documentation/features/vm/ioremap_prot/arch-support.txt
index 326e4797bc65..3a6b87de6a19 100644
--- a/Documentation/features/vm/ioremap_prot/arch-support.txt
+++ b/Documentation/features/vm/ioremap_prot/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | TODO | 11 | arm: | TODO |
12 | arm64: | TODO | 12 | arm64: | TODO |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/features/vm/numa-memblock/arch-support.txt b/Documentation/features/vm/numa-memblock/arch-support.txt
index 1a988052cd24..3004beb0fd71 100644
--- a/Documentation/features/vm/numa-memblock/arch-support.txt
+++ b/Documentation/features/vm/numa-memblock/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | .. | 11 | arm: | .. |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | .. | 13 | c6x: | .. |
14 | csky: | .. |
14 | h8300: | .. | 15 | h8300: | .. |
15 | hexagon: | .. | 16 | hexagon: | .. |
16 | ia64: | ok | 17 | ia64: | ok |
diff --git a/Documentation/features/vm/pte_special/arch-support.txt b/Documentation/features/vm/pte_special/arch-support.txt
index a8378424bc98..2dc5df6a1cf5 100644
--- a/Documentation/features/vm/pte_special/arch-support.txt
+++ b/Documentation/features/vm/pte_special/arch-support.txt
@@ -11,6 +11,7 @@
11 | arm: | ok | 11 | arm: | ok |
12 | arm64: | ok | 12 | arm64: | ok |
13 | c6x: | TODO | 13 | c6x: | TODO |
14 | csky: | TODO |
14 | h8300: | TODO | 15 | h8300: | TODO |
15 | hexagon: | TODO | 16 | hexagon: | TODO |
16 | ia64: | TODO | 17 | ia64: | TODO |
diff --git a/Documentation/trace/coresight-cpu-debug.txt b/Documentation/trace/coresight-cpu-debug.txt
index 89ab09e78e8d..f07e38094b40 100644
--- a/Documentation/trace/coresight-cpu-debug.txt
+++ b/Documentation/trace/coresight-cpu-debug.txt
@@ -165,7 +165,7 @@ Do some work...
165The same can also be done from an application program. 165The same can also be done from an application program.
166 166
167Disable specific CPU's specific idle state from cpuidle sysfs (see 167Disable specific CPU's specific idle state from cpuidle sysfs (see
168Documentation/cpuidle/sysfs.txt): 168Documentation/admin-guide/pm/cpuidle.rst):
169# echo 1 > /sys/devices/system/cpu/cpu$cpu/cpuidle/state$state/disable 169# echo 1 > /sys/devices/system/cpu/cpu$cpu/cpuidle/state$state/disable
170 170
171 171
diff --git a/Documentation/virtual/kvm/amd-memory-encryption.rst b/Documentation/virtual/kvm/amd-memory-encryption.rst
index 71d6d257074f..659bbc093b52 100644
--- a/Documentation/virtual/kvm/amd-memory-encryption.rst
+++ b/Documentation/virtual/kvm/amd-memory-encryption.rst
@@ -242,6 +242,6 @@ References
242========== 242==========
243 243
244.. [white-paper] http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_Memory_Encryption_Whitepaper_v7-Public.pdf 244.. [white-paper] http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_Memory_Encryption_Whitepaper_v7-Public.pdf
245.. [api-spec] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Specification.pdf 245.. [api-spec] http://support.amd.com/TechDocs/55766_SEV-KM_API_Specification.pdf
246.. [amd-apm] http://support.amd.com/TechDocs/24593.pdf (section 15.34) 246.. [amd-apm] http://support.amd.com/TechDocs/24593.pdf (section 15.34)
247.. [kvm-forum] http://www.linux-kvm.org/images/7/74/02x08A-Thomas_Lendacky-AMDs_Virtualizatoin_Memory_Encryption_Technology.pdf 247.. [kvm-forum] http://www.linux-kvm.org/images/7/74/02x08A-Thomas_Lendacky-AMDs_Virtualizatoin_Memory_Encryption_Technology.pdf
diff --git a/Documentation/x86/resctrl_ui.txt b/Documentation/x86/resctrl_ui.txt
index d9aed8303984..e8e8d14d3c4e 100644
--- a/Documentation/x86/resctrl_ui.txt
+++ b/Documentation/x86/resctrl_ui.txt
@@ -9,7 +9,7 @@ Fenghua Yu <fenghua.yu@intel.com>
9Tony Luck <tony.luck@intel.com> 9Tony Luck <tony.luck@intel.com>
10Vikas Shivappa <vikas.shivappa@intel.com> 10Vikas Shivappa <vikas.shivappa@intel.com>
11 11
12This feature is enabled by the CONFIG_RESCTRL and the X86 /proc/cpuinfo 12This feature is enabled by the CONFIG_X86_RESCTRL and the x86 /proc/cpuinfo
13flag bits: 13flag bits:
14RDT (Resource Director Technology) Allocation - "rdt_a" 14RDT (Resource Director Technology) Allocation - "rdt_a"
15CAT (Cache Allocation Technology) - "cat_l3", "cat_l2" 15CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
diff --git a/MAINTAINERS b/MAINTAINERS
index 32d444476a90..2cf9c1ceb502 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3951,7 +3951,7 @@ L: netdev@vger.kernel.org
3951S: Maintained 3951S: Maintained
3952F: drivers/net/ethernet/ti/cpmac.c 3952F: drivers/net/ethernet/ti/cpmac.c
3953 3953
3954CPU FREQUENCY DRIVERS 3954CPU FREQUENCY SCALING FRAMEWORK
3955M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 3955M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
3956M: Viresh Kumar <viresh.kumar@linaro.org> 3956M: Viresh Kumar <viresh.kumar@linaro.org>
3957L: linux-pm@vger.kernel.org 3957L: linux-pm@vger.kernel.org
@@ -3959,6 +3959,8 @@ S: Maintained
3959T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 3959T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
3960T: git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates) 3960T: git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates)
3961B: https://bugzilla.kernel.org 3961B: https://bugzilla.kernel.org
3962F: Documentation/admin-guide/pm/cpufreq.rst
3963F: Documentation/admin-guide/pm/intel_pstate.rst
3962F: Documentation/cpu-freq/ 3964F: Documentation/cpu-freq/
3963F: Documentation/devicetree/bindings/cpufreq/ 3965F: Documentation/devicetree/bindings/cpufreq/
3964F: drivers/cpufreq/ 3966F: drivers/cpufreq/
@@ -4006,13 +4008,14 @@ S: Supported
4006F: drivers/cpuidle/cpuidle-exynos.c 4008F: drivers/cpuidle/cpuidle-exynos.c
4007F: arch/arm/mach-exynos/pm.c 4009F: arch/arm/mach-exynos/pm.c
4008 4010
4009CPUIDLE DRIVERS 4011CPU IDLE TIME MANAGEMENT FRAMEWORK
4010M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 4012M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
4011M: Daniel Lezcano <daniel.lezcano@linaro.org> 4013M: Daniel Lezcano <daniel.lezcano@linaro.org>
4012L: linux-pm@vger.kernel.org 4014L: linux-pm@vger.kernel.org
4013S: Maintained 4015S: Maintained
4014T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 4016T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
4015B: https://bugzilla.kernel.org 4017B: https://bugzilla.kernel.org
4018F: Documentation/admin-guide/pm/cpuidle.rst
4016F: drivers/cpuidle/* 4019F: drivers/cpuidle/*
4017F: include/linux/cpuidle.h 4020F: include/linux/cpuidle.h
4018 4021
@@ -13820,8 +13823,9 @@ F: drivers/media/mmc/siano/
13820 13823
13821SIFIVE DRIVERS 13824SIFIVE DRIVERS
13822M: Palmer Dabbelt <palmer@sifive.com> 13825M: Palmer Dabbelt <palmer@sifive.com>
13826M: Paul Walmsley <paul.walmsley@sifive.com>
13823L: linux-riscv@lists.infradead.org 13827L: linux-riscv@lists.infradead.org
13824T: git git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux.git 13828T: git git://github.com/sifive/riscv-linux.git
13825S: Supported 13829S: Supported
13826K: sifive 13830K: sifive
13827N: sifive 13831N: sifive
diff --git a/arch/arm64/include/asm/asm-prototypes.h b/arch/arm64/include/asm/asm-prototypes.h
index 2173ad32d550..1c9a3a0c5fa5 100644
--- a/arch/arm64/include/asm/asm-prototypes.h
+++ b/arch/arm64/include/asm/asm-prototypes.h
@@ -2,7 +2,7 @@
2#ifndef __ASM_PROTOTYPES_H 2#ifndef __ASM_PROTOTYPES_H
3#define __ASM_PROTOTYPES_H 3#define __ASM_PROTOTYPES_H
4/* 4/*
5 * CONFIG_MODEVERIONS requires a C declaration to generate the appropriate CRC 5 * CONFIG_MODVERSIONS requires a C declaration to generate the appropriate CRC
6 * for each symbol. Since commit: 6 * for each symbol. Since commit:
7 * 7 *
8 * 4efca4ed05cbdfd1 ("kbuild: modversions for EXPORT_SYMBOL() for asm") 8 * 4efca4ed05cbdfd1 ("kbuild: modversions for EXPORT_SYMBOL() for asm")
diff --git a/arch/arm64/include/asm/cache.h b/arch/arm64/include/asm/cache.h
index 13dd42c3ad4e..eb43e09c1980 100644
--- a/arch/arm64/include/asm/cache.h
+++ b/arch/arm64/include/asm/cache.h
@@ -58,6 +58,12 @@
58 */ 58 */
59#define ARCH_DMA_MINALIGN (128) 59#define ARCH_DMA_MINALIGN (128)
60 60
61#ifdef CONFIG_KASAN_SW_TAGS
62#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)
63#else
64#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
65#endif
66
61#ifndef __ASSEMBLY__ 67#ifndef __ASSEMBLY__
62 68
63#include <linux/bitops.h> 69#include <linux/bitops.h>
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index 7689c7aa1d77..ac352accb3d9 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -16,6 +16,8 @@
16#ifndef __ASM_MMU_H 16#ifndef __ASM_MMU_H
17#define __ASM_MMU_H 17#define __ASM_MMU_H
18 18
19#include <asm/cputype.h>
20
19#define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */ 21#define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */
20#define USER_ASID_BIT 48 22#define USER_ASID_BIT 48
21#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT) 23#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
@@ -44,6 +46,45 @@ static inline bool arm64_kernel_unmapped_at_el0(void)
44 cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0); 46 cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0);
45} 47}
46 48
49static inline bool arm64_kernel_use_ng_mappings(void)
50{
51 bool tx1_bug;
52
53 /* What's a kpti? Use global mappings if we don't know. */
54 if (!IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0))
55 return false;
56
57 /*
58 * Note: this function is called before the CPU capabilities have
59 * been configured, so our early mappings will be global. If we
60 * later determine that kpti is required, then
61 * kpti_install_ng_mappings() will make them non-global.
62 */
63 if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
64 return arm64_kernel_unmapped_at_el0();
65
66 /*
67 * KASLR is enabled so we're going to be enabling kpti on non-broken
68 * CPUs regardless of their susceptibility to Meltdown. Rather
69 * than force everybody to go through the G -> nG dance later on,
70 * just put down non-global mappings from the beginning.
71 */
72 if (!IS_ENABLED(CONFIG_CAVIUM_ERRATUM_27456)) {
73 tx1_bug = false;
74#ifndef MODULE
75 } else if (!static_branch_likely(&arm64_const_caps_ready)) {
76 extern const struct midr_range cavium_erratum_27456_cpus[];
77
78 tx1_bug = is_midr_in_range_list(read_cpuid_id(),
79 cavium_erratum_27456_cpus);
80#endif
81 } else {
82 tx1_bug = __cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456);
83 }
84
85 return !tx1_bug && kaslr_offset() > 0;
86}
87
47typedef void (*bp_hardening_cb_t)(void); 88typedef void (*bp_hardening_cb_t)(void);
48 89
49struct bp_hardening_data { 90struct bp_hardening_data {
diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
index 78b942c1bea4..986e41c4c32b 100644
--- a/arch/arm64/include/asm/pgtable-prot.h
+++ b/arch/arm64/include/asm/pgtable-prot.h
@@ -37,8 +37,8 @@
37#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) 37#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED)
38#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) 38#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S)
39 39
40#define PTE_MAYBE_NG (arm64_kernel_unmapped_at_el0() ? PTE_NG : 0) 40#define PTE_MAYBE_NG (arm64_kernel_use_ng_mappings() ? PTE_NG : 0)
41#define PMD_MAYBE_NG (arm64_kernel_unmapped_at_el0() ? PMD_SECT_NG : 0) 41#define PMD_MAYBE_NG (arm64_kernel_use_ng_mappings() ? PMD_SECT_NG : 0)
42 42
43#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) 43#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG)
44#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) 44#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG)
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 09ac548c9d44..9950bb0cbd52 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -553,7 +553,7 @@ static const struct midr_range arm64_repeat_tlbi_cpus[] = {
553#endif 553#endif
554 554
555#ifdef CONFIG_CAVIUM_ERRATUM_27456 555#ifdef CONFIG_CAVIUM_ERRATUM_27456
556static const struct midr_range cavium_erratum_27456_cpus[] = { 556const struct midr_range cavium_erratum_27456_cpus[] = {
557 /* Cavium ThunderX, T88 pass 1.x - 2.1 */ 557 /* Cavium ThunderX, T88 pass 1.x - 2.1 */
558 MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 1), 558 MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 1),
559 /* Cavium ThunderX, T81 pass 1.0 */ 559 /* Cavium ThunderX, T81 pass 1.0 */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 4f272399de89..f6d84e2c92fe 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -983,7 +983,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
983 983
984 /* Useful for KASLR robustness */ 984 /* Useful for KASLR robustness */
985 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) 985 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE))
986 return true; 986 return kaslr_offset() > 0;
987 987
988 /* Don't force KPTI for CPUs that are not vulnerable */ 988 /* Don't force KPTI for CPUs that are not vulnerable */
989 if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) 989 if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list))
@@ -1003,7 +1003,12 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused)
1003 static bool kpti_applied = false; 1003 static bool kpti_applied = false;
1004 int cpu = smp_processor_id(); 1004 int cpu = smp_processor_id();
1005 1005
1006 if (kpti_applied) 1006 /*
1007 * We don't need to rewrite the page-tables if either we've done
1008 * it already or we have KASLR enabled and therefore have not
1009 * created any global mappings at all.
1010 */
1011 if (kpti_applied || kaslr_offset() > 0)
1007 return; 1012 return;
1008 1013
1009 remap_fn = (void *)__pa_symbol(idmap_kpti_install_ng_mappings); 1014 remap_fn = (void *)__pa_symbol(idmap_kpti_install_ng_mappings);
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index c7213674cb24..15d79a8e5e5e 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -475,6 +475,7 @@ ENDPROC(__primary_switched)
475 475
476ENTRY(kimage_vaddr) 476ENTRY(kimage_vaddr)
477 .quad _text - TEXT_OFFSET 477 .quad _text - TEXT_OFFSET
478EXPORT_SYMBOL(kimage_vaddr)
478 479
479/* 480/*
480 * If we're fortunate enough to boot at EL2, ensure that the world is 481 * If we're fortunate enough to boot at EL2, ensure that the world is
diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 10e33860e47a..f2c211a6229b 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -87,7 +87,9 @@ static int setup_dtb(struct kimage *image,
87 87
88 /* add kaslr-seed */ 88 /* add kaslr-seed */
89 ret = fdt_delprop(dtb, off, FDT_PROP_KASLR_SEED); 89 ret = fdt_delprop(dtb, off, FDT_PROP_KASLR_SEED);
90 if (ret && (ret != -FDT_ERR_NOTFOUND)) 90 if (ret == -FDT_ERR_NOTFOUND)
91 ret = 0;
92 else if (ret)
91 goto out; 93 goto out;
92 94
93 if (rng_is_initialized()) { 95 if (rng_is_initialized()) {
diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h
index ecae6b358f95..c1dfa9c10e36 100644
--- a/arch/csky/include/asm/io.h
+++ b/arch/csky/include/asm/io.h
@@ -15,6 +15,31 @@ extern void iounmap(void *addr);
15extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr, 15extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr,
16 size_t size, unsigned long flags); 16 size_t size, unsigned long flags);
17 17
18/*
19 * I/O memory access primitives. Reads are ordered relative to any
20 * following Normal memory access. Writes are ordered relative to any prior
21 * Normal memory access.
22 *
23 * For CACHEV1 (807, 810), store instruction could fast retire, so we need
24 * another mb() to prevent st fast retire.
25 *
26 * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't
27 * fast retire.
28 */
29#define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; })
30#define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; })
31#define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; })
32
33#ifdef CONFIG_CPU_HAS_CACHEV2
34#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); })
35#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); })
36#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); })
37#else
38#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); mb(); })
39#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); mb(); })
40#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); })
41#endif
42
18#define ioremap_nocache(phy, sz) ioremap(phy, sz) 43#define ioremap_nocache(phy, sz) ioremap(phy, sz)
19#define ioremap_wc ioremap_nocache 44#define ioremap_wc ioremap_nocache
20#define ioremap_wt ioremap_nocache 45#define ioremap_wt ioremap_nocache
diff --git a/arch/csky/include/asm/pgalloc.h b/arch/csky/include/asm/pgalloc.h
index bf4f4a0e140e..d213bb47b717 100644
--- a/arch/csky/include/asm/pgalloc.h
+++ b/arch/csky/include/asm/pgalloc.h
@@ -24,41 +24,34 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
24 24
25extern void pgd_init(unsigned long *p); 25extern void pgd_init(unsigned long *p);
26 26
27static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 27static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
28 unsigned long address)
29{ 28{
30 pte_t *pte; 29 pte_t *pte;
31 unsigned long *kaddr, i; 30 unsigned long i;
32 31
33 pte = (pte_t *) __get_free_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL, 32 pte = (pte_t *) __get_free_page(GFP_KERNEL);
34 PTE_ORDER); 33 if (!pte)
35 kaddr = (unsigned long *)pte; 34 return NULL;
36 if (address & 0x80000000) 35
37 for (i = 0; i < (PAGE_SIZE/4); i++) 36 for (i = 0; i < PAGE_SIZE/sizeof(pte_t); i++)
38 *(kaddr + i) = 0x1; 37 (pte + i)->pte_low = _PAGE_GLOBAL;
39 else
40 clear_page(kaddr);
41 38
42 return pte; 39 return pte;
43} 40}
44 41
45static inline struct page *pte_alloc_one(struct mm_struct *mm, 42static inline struct page *pte_alloc_one(struct mm_struct *mm)
46 unsigned long address)
47{ 43{
48 struct page *pte; 44 struct page *pte;
49 unsigned long *kaddr, i; 45
50 46 pte = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
51 pte = alloc_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL, PTE_ORDER); 47 if (!pte)
52 if (pte) { 48 return NULL;
53 kaddr = kmap_atomic(pte); 49
54 if (address & 0x80000000) { 50 if (!pgtable_page_ctor(pte)) {
55 for (i = 0; i < (PAGE_SIZE/4); i++) 51 __free_page(pte);
56 *(kaddr + i) = 0x1; 52 return NULL;
57 } else
58 clear_page(kaddr);
59 kunmap_atomic(kaddr);
60 pgtable_page_ctor(pte);
61 } 53 }
54
62 return pte; 55 return pte;
63} 56}
64 57
diff --git a/arch/csky/kernel/module.c b/arch/csky/kernel/module.c
index 65abab0c7a47..b5ad7d9de18c 100644
--- a/arch/csky/kernel/module.c
+++ b/arch/csky/kernel/module.c
@@ -12,7 +12,7 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <asm/pgtable.h> 13#include <asm/pgtable.h>
14 14
15#if defined(__CSKYABIV2__) 15#ifdef CONFIG_CPU_CK810
16#define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000) 16#define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000)
17#define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0) 17#define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0)
18 18
@@ -25,6 +25,26 @@
25 *(uint16_t *)(addr) = 0xE8Fa; \ 25 *(uint16_t *)(addr) = 0xE8Fa; \
26 *((uint16_t *)(addr) + 1) = 0x0000; \ 26 *((uint16_t *)(addr) + 1) = 0x0000; \
27} while (0) 27} while (0)
28
29static void jsri_2_lrw_jsr(uint32_t *location)
30{
31 uint16_t *location_tmp = (uint16_t *)location;
32
33 if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
34 return;
35
36 if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
37 /* jsri 0x... --> lrw r26, 0x... */
38 CHANGE_JSRI_TO_LRW(location);
39 /* lsli r0, r0 --> jsr r26 */
40 SET_JSR32_R26(location + 1);
41 }
42}
43#else
44static void inline jsri_2_lrw_jsr(uint32_t *location)
45{
46 return;
47}
28#endif 48#endif
29 49
30int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, 50int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
@@ -35,9 +55,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
35 Elf32_Sym *sym; 55 Elf32_Sym *sym;
36 uint32_t *location; 56 uint32_t *location;
37 short *temp; 57 short *temp;
38#if defined(__CSKYABIV2__)
39 uint16_t *location_tmp;
40#endif
41 58
42 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 59 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
43 /* This is where to make the change */ 60 /* This is where to make the change */
@@ -59,18 +76,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
59 case R_CSKY_PCRELJSR_IMM11BY2: 76 case R_CSKY_PCRELJSR_IMM11BY2:
60 break; 77 break;
61 case R_CSKY_PCRELJSR_IMM26BY2: 78 case R_CSKY_PCRELJSR_IMM26BY2:
62#if defined(__CSKYABIV2__) 79 jsri_2_lrw_jsr(location);
63 location_tmp = (uint16_t *)location;
64 if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
65 break;
66
67 if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
68 /* jsri 0x... --> lrw r26, 0x... */
69 CHANGE_JSRI_TO_LRW(location);
70 /* lsli r0, r0 --> jsr r26 */
71 SET_JSR32_R26(location + 1);
72 }
73#endif
74 break; 80 break;
75 case R_CSKY_ADDR_HI16: 81 case R_CSKY_ADDR_HI16:
76 temp = ((short *)location) + 1; 82 temp = ((short *)location) + 1;
diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
index bc8191a34db7..a44682c8adc3 100644
--- a/arch/openrisc/include/asm/uaccess.h
+++ b/arch/openrisc/include/asm/uaccess.h
@@ -58,8 +58,12 @@
58/* Ensure that addr is below task's addr_limit */ 58/* Ensure that addr is below task's addr_limit */
59#define __addr_ok(addr) ((unsigned long) addr < get_fs()) 59#define __addr_ok(addr) ((unsigned long) addr < get_fs())
60 60
61#define access_ok(addr, size) \ 61#define access_ok(addr, size) \
62 __range_ok((unsigned long)addr, (unsigned long)size) 62({ \
63 unsigned long __ao_addr = (unsigned long)(addr); \
64 unsigned long __ao_size = (unsigned long)(size); \
65 __range_ok(__ao_addr, __ao_size); \
66})
63 67
64/* 68/*
65 * These are the main single-value transfer routines. They automatically 69 * These are the main single-value transfer routines. They automatically
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index e0d7d61779a6..feeeaa60697c 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -28,11 +28,13 @@ config RISCV
28 select GENERIC_STRNLEN_USER 28 select GENERIC_STRNLEN_USER
29 select GENERIC_SMP_IDLE_THREAD 29 select GENERIC_SMP_IDLE_THREAD
30 select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A 30 select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A
31 select HAVE_ARCH_AUDITSYSCALL
31 select HAVE_MEMBLOCK_NODE_MAP 32 select HAVE_MEMBLOCK_NODE_MAP
32 select HAVE_DMA_CONTIGUOUS 33 select HAVE_DMA_CONTIGUOUS
33 select HAVE_FUTEX_CMPXCHG if FUTEX 34 select HAVE_FUTEX_CMPXCHG if FUTEX
34 select HAVE_GENERIC_DMA_COHERENT 35 select HAVE_GENERIC_DMA_COHERENT
35 select HAVE_PERF_EVENTS 36 select HAVE_PERF_EVENTS
37 select HAVE_SYSCALL_TRACEPOINTS
36 select IRQ_DOMAIN 38 select IRQ_DOMAIN
37 select RISCV_ISA_A if SMP 39 select RISCV_ISA_A if SMP
38 select SPARSE_IRQ 40 select SPARSE_IRQ
@@ -40,6 +42,7 @@ config RISCV
40 select HAVE_ARCH_TRACEHOOK 42 select HAVE_ARCH_TRACEHOOK
41 select HAVE_PCI 43 select HAVE_PCI
42 select MODULES_USE_ELF_RELA if MODULES 44 select MODULES_USE_ELF_RELA if MODULES
45 select MODULE_SECTIONS if MODULES
43 select THREAD_INFO_IN_TASK 46 select THREAD_INFO_IN_TASK
44 select PCI_DOMAINS_GENERIC if PCI 47 select PCI_DOMAINS_GENERIC if PCI
45 select PCI_MSI if PCI 48 select PCI_MSI if PCI
@@ -152,7 +155,6 @@ choice
152 bool "2GiB" 155 bool "2GiB"
153 config MAXPHYSMEM_128GB 156 config MAXPHYSMEM_128GB
154 depends on 64BIT && CMODEL_MEDANY 157 depends on 64BIT && CMODEL_MEDANY
155 select MODULE_SECTIONS if MODULES
156 bool "128GiB" 158 bool "128GiB"
157endchoice 159endchoice
158 160
diff --git a/arch/riscv/include/asm/module.h b/arch/riscv/include/asm/module.h
index cd2af4b013e3..46202dad365d 100644
--- a/arch/riscv/include/asm/module.h
+++ b/arch/riscv/include/asm/module.h
@@ -9,12 +9,12 @@
9#define MODULE_ARCH_VERMAGIC "riscv" 9#define MODULE_ARCH_VERMAGIC "riscv"
10 10
11struct module; 11struct module;
12u64 module_emit_got_entry(struct module *mod, u64 val); 12unsigned long module_emit_got_entry(struct module *mod, unsigned long val);
13u64 module_emit_plt_entry(struct module *mod, u64 val); 13unsigned long module_emit_plt_entry(struct module *mod, unsigned long val);
14 14
15#ifdef CONFIG_MODULE_SECTIONS 15#ifdef CONFIG_MODULE_SECTIONS
16struct mod_section { 16struct mod_section {
17 struct elf64_shdr *shdr; 17 Elf_Shdr *shdr;
18 int num_entries; 18 int num_entries;
19 int max_entries; 19 int max_entries;
20}; 20};
@@ -26,18 +26,18 @@ struct mod_arch_specific {
26}; 26};
27 27
28struct got_entry { 28struct got_entry {
29 u64 symbol_addr; /* the real variable address */ 29 unsigned long symbol_addr; /* the real variable address */
30}; 30};
31 31
32static inline struct got_entry emit_got_entry(u64 val) 32static inline struct got_entry emit_got_entry(unsigned long val)
33{ 33{
34 return (struct got_entry) {val}; 34 return (struct got_entry) {val};
35} 35}
36 36
37static inline struct got_entry *get_got_entry(u64 val, 37static inline struct got_entry *get_got_entry(unsigned long val,
38 const struct mod_section *sec) 38 const struct mod_section *sec)
39{ 39{
40 struct got_entry *got = (struct got_entry *)sec->shdr->sh_addr; 40 struct got_entry *got = (struct got_entry *)(sec->shdr->sh_addr);
41 int i; 41 int i;
42 for (i = 0; i < sec->num_entries; i++) { 42 for (i = 0; i < sec->num_entries; i++) {
43 if (got[i].symbol_addr == val) 43 if (got[i].symbol_addr == val)
@@ -62,7 +62,9 @@ struct plt_entry {
62#define REG_T0 0x5 62#define REG_T0 0x5
63#define REG_T1 0x6 63#define REG_T1 0x6
64 64
65static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt) 65static inline struct plt_entry emit_plt_entry(unsigned long val,
66 unsigned long plt,
67 unsigned long got_plt)
66{ 68{
67 /* 69 /*
68 * U-Type encoding: 70 * U-Type encoding:
@@ -76,7 +78,7 @@ static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt)
76 * +------------+------------+--------+----------+----------+ 78 * +------------+------------+--------+----------+----------+
77 * 79 *
78 */ 80 */
79 u64 offset = got_plt - plt; 81 unsigned long offset = got_plt - plt;
80 u32 hi20 = (offset + 0x800) & 0xfffff000; 82 u32 hi20 = (offset + 0x800) & 0xfffff000;
81 u32 lo12 = (offset - hi20); 83 u32 lo12 = (offset - hi20);
82 return (struct plt_entry) { 84 return (struct plt_entry) {
@@ -86,7 +88,7 @@ static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt)
86 }; 88 };
87} 89}
88 90
89static inline int get_got_plt_idx(u64 val, const struct mod_section *sec) 91static inline int get_got_plt_idx(unsigned long val, const struct mod_section *sec)
90{ 92{
91 struct got_entry *got_plt = (struct got_entry *)sec->shdr->sh_addr; 93 struct got_entry *got_plt = (struct got_entry *)sec->shdr->sh_addr;
92 int i; 94 int i;
@@ -97,9 +99,9 @@ static inline int get_got_plt_idx(u64 val, const struct mod_section *sec)
97 return -1; 99 return -1;
98} 100}
99 101
100static inline struct plt_entry *get_plt_entry(u64 val, 102static inline struct plt_entry *get_plt_entry(unsigned long val,
101 const struct mod_section *sec_plt, 103 const struct mod_section *sec_plt,
102 const struct mod_section *sec_got_plt) 104 const struct mod_section *sec_got_plt)
103{ 105{
104 struct plt_entry *plt = (struct plt_entry *)sec_plt->shdr->sh_addr; 106 struct plt_entry *plt = (struct plt_entry *)sec_plt->shdr->sh_addr;
105 int got_plt_idx = get_got_plt_idx(val, sec_got_plt); 107 int got_plt_idx = get_got_plt_idx(val, sec_got_plt);
diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h
index bbe1862e8f80..d35ec2f41381 100644
--- a/arch/riscv/include/asm/ptrace.h
+++ b/arch/riscv/include/asm/ptrace.h
@@ -113,6 +113,11 @@ static inline void frame_pointer_set(struct pt_regs *regs,
113 SET_FP(regs, val); 113 SET_FP(regs, val);
114} 114}
115 115
116static inline unsigned long regs_return_value(struct pt_regs *regs)
117{
118 return regs->a0;
119}
120
116#endif /* __ASSEMBLY__ */ 121#endif /* __ASSEMBLY__ */
117 122
118#endif /* _ASM_RISCV_PTRACE_H */ 123#endif /* _ASM_RISCV_PTRACE_H */
diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index 8d25f8904c00..bba3da6ef157 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -18,6 +18,7 @@
18#ifndef _ASM_RISCV_SYSCALL_H 18#ifndef _ASM_RISCV_SYSCALL_H
19#define _ASM_RISCV_SYSCALL_H 19#define _ASM_RISCV_SYSCALL_H
20 20
21#include <uapi/linux/audit.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/err.h> 23#include <linux/err.h>
23 24
@@ -99,4 +100,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
99 memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0)); 100 memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
100} 101}
101 102
103static inline int syscall_get_arch(void)
104{
105#ifdef CONFIG_64BIT
106 return AUDIT_ARCH_RISCV64;
107#else
108 return AUDIT_ARCH_RISCV32;
109#endif
110}
111
102#endif /* _ASM_RISCV_SYSCALL_H */ 112#endif /* _ASM_RISCV_SYSCALL_H */
diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h
index f8fa1cd2dad9..1c9cc8389928 100644
--- a/arch/riscv/include/asm/thread_info.h
+++ b/arch/riscv/include/asm/thread_info.h
@@ -80,13 +80,19 @@ struct thread_info {
80#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ 80#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
81#define TIF_MEMDIE 5 /* is terminating due to OOM killer */ 81#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
82#define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ 82#define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
83#define TIF_SYSCALL_AUDIT 7 /* syscall auditing */
83 84
84#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 85#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
85#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 86#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
86#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 87#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
87#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 88#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
89#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
90#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
88 91
89#define _TIF_WORK_MASK \ 92#define _TIF_WORK_MASK \
90 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED) 93 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
91 94
95#define _TIF_SYSCALL_WORK \
96 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_SYSCALL_AUDIT)
97
92#endif /* _ASM_RISCV_THREAD_INFO_H */ 98#endif /* _ASM_RISCV_THREAD_INFO_H */
diff --git a/arch/riscv/include/asm/unistd.h b/arch/riscv/include/asm/unistd.h
index fef96f117b4d..073ee80fdf74 100644
--- a/arch/riscv/include/asm/unistd.h
+++ b/arch/riscv/include/asm/unistd.h
@@ -19,3 +19,5 @@
19#define __ARCH_WANT_SYS_CLONE 19#define __ARCH_WANT_SYS_CLONE
20 20
21#include <uapi/asm/unistd.h> 21#include <uapi/asm/unistd.h>
22
23#define NR_syscalls (__NR_syscalls)
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
index 13d4826ab2a1..355166f57205 100644
--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -201,7 +201,7 @@ handle_syscall:
201 REG_S s2, PT_SEPC(sp) 201 REG_S s2, PT_SEPC(sp)
202 /* Trace syscalls, but only if requested by the user. */ 202 /* Trace syscalls, but only if requested by the user. */
203 REG_L t0, TASK_TI_FLAGS(tp) 203 REG_L t0, TASK_TI_FLAGS(tp)
204 andi t0, t0, _TIF_SYSCALL_TRACE 204 andi t0, t0, _TIF_SYSCALL_WORK
205 bnez t0, handle_syscall_trace_enter 205 bnez t0, handle_syscall_trace_enter
206check_syscall_nr: 206check_syscall_nr:
207 /* Check to make sure we don't jump to a bogus syscall number. */ 207 /* Check to make sure we don't jump to a bogus syscall number. */
@@ -221,7 +221,7 @@ ret_from_syscall:
221 REG_S a0, PT_A0(sp) 221 REG_S a0, PT_A0(sp)
222 /* Trace syscalls, but only if requested by the user. */ 222 /* Trace syscalls, but only if requested by the user. */
223 REG_L t0, TASK_TI_FLAGS(tp) 223 REG_L t0, TASK_TI_FLAGS(tp)
224 andi t0, t0, _TIF_SYSCALL_TRACE 224 andi t0, t0, _TIF_SYSCALL_WORK
225 bnez t0, handle_syscall_trace_exit 225 bnez t0, handle_syscall_trace_exit
226 226
227ret_from_exception: 227ret_from_exception:
diff --git a/arch/riscv/kernel/module-sections.c b/arch/riscv/kernel/module-sections.c
index bbbd26e19bfd..c9ae48333114 100644
--- a/arch/riscv/kernel/module-sections.c
+++ b/arch/riscv/kernel/module-sections.c
@@ -9,14 +9,14 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11 11
12u64 module_emit_got_entry(struct module *mod, u64 val) 12unsigned long module_emit_got_entry(struct module *mod, unsigned long val)
13{ 13{
14 struct mod_section *got_sec = &mod->arch.got; 14 struct mod_section *got_sec = &mod->arch.got;
15 int i = got_sec->num_entries; 15 int i = got_sec->num_entries;
16 struct got_entry *got = get_got_entry(val, got_sec); 16 struct got_entry *got = get_got_entry(val, got_sec);
17 17
18 if (got) 18 if (got)
19 return (u64)got; 19 return (unsigned long)got;
20 20
21 /* There is no duplicate entry, create a new one */ 21 /* There is no duplicate entry, create a new one */
22 got = (struct got_entry *)got_sec->shdr->sh_addr; 22 got = (struct got_entry *)got_sec->shdr->sh_addr;
@@ -25,10 +25,10 @@ u64 module_emit_got_entry(struct module *mod, u64 val)
25 got_sec->num_entries++; 25 got_sec->num_entries++;
26 BUG_ON(got_sec->num_entries > got_sec->max_entries); 26 BUG_ON(got_sec->num_entries > got_sec->max_entries);
27 27
28 return (u64)&got[i]; 28 return (unsigned long)&got[i];
29} 29}
30 30
31u64 module_emit_plt_entry(struct module *mod, u64 val) 31unsigned long module_emit_plt_entry(struct module *mod, unsigned long val)
32{ 32{
33 struct mod_section *got_plt_sec = &mod->arch.got_plt; 33 struct mod_section *got_plt_sec = &mod->arch.got_plt;
34 struct got_entry *got_plt; 34 struct got_entry *got_plt;
@@ -37,27 +37,29 @@ u64 module_emit_plt_entry(struct module *mod, u64 val)
37 int i = plt_sec->num_entries; 37 int i = plt_sec->num_entries;
38 38
39 if (plt) 39 if (plt)
40 return (u64)plt; 40 return (unsigned long)plt;
41 41
42 /* There is no duplicate entry, create a new one */ 42 /* There is no duplicate entry, create a new one */
43 got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr; 43 got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr;
44 got_plt[i] = emit_got_entry(val); 44 got_plt[i] = emit_got_entry(val);
45 plt = (struct plt_entry *)plt_sec->shdr->sh_addr; 45 plt = (struct plt_entry *)plt_sec->shdr->sh_addr;
46 plt[i] = emit_plt_entry(val, (u64)&plt[i], (u64)&got_plt[i]); 46 plt[i] = emit_plt_entry(val,
47 (unsigned long)&plt[i],
48 (unsigned long)&got_plt[i]);
47 49
48 plt_sec->num_entries++; 50 plt_sec->num_entries++;
49 got_plt_sec->num_entries++; 51 got_plt_sec->num_entries++;
50 BUG_ON(plt_sec->num_entries > plt_sec->max_entries); 52 BUG_ON(plt_sec->num_entries > plt_sec->max_entries);
51 53
52 return (u64)&plt[i]; 54 return (unsigned long)&plt[i];
53} 55}
54 56
55static int is_rela_equal(const Elf64_Rela *x, const Elf64_Rela *y) 57static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y)
56{ 58{
57 return x->r_info == y->r_info && x->r_addend == y->r_addend; 59 return x->r_info == y->r_info && x->r_addend == y->r_addend;
58} 60}
59 61
60static bool duplicate_rela(const Elf64_Rela *rela, int idx) 62static bool duplicate_rela(const Elf_Rela *rela, int idx)
61{ 63{
62 int i; 64 int i;
63 for (i = 0; i < idx; i++) { 65 for (i = 0; i < idx; i++) {
@@ -67,13 +69,13 @@ static bool duplicate_rela(const Elf64_Rela *rela, int idx)
67 return false; 69 return false;
68} 70}
69 71
70static void count_max_entries(Elf64_Rela *relas, int num, 72static void count_max_entries(Elf_Rela *relas, int num,
71 unsigned int *plts, unsigned int *gots) 73 unsigned int *plts, unsigned int *gots)
72{ 74{
73 unsigned int type, i; 75 unsigned int type, i;
74 76
75 for (i = 0; i < num; i++) { 77 for (i = 0; i < num; i++) {
76 type = ELF64_R_TYPE(relas[i].r_info); 78 type = ELF_RISCV_R_TYPE(relas[i].r_info);
77 if (type == R_RISCV_CALL_PLT) { 79 if (type == R_RISCV_CALL_PLT) {
78 if (!duplicate_rela(relas, i)) 80 if (!duplicate_rela(relas, i))
79 (*plts)++; 81 (*plts)++;
@@ -118,9 +120,9 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
118 120
119 /* Calculate the maxinum number of entries */ 121 /* Calculate the maxinum number of entries */
120 for (i = 0; i < ehdr->e_shnum; i++) { 122 for (i = 0; i < ehdr->e_shnum; i++) {
121 Elf64_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset; 123 Elf_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset;
122 int num_rela = sechdrs[i].sh_size / sizeof(Elf64_Rela); 124 int num_rela = sechdrs[i].sh_size / sizeof(Elf_Rela);
123 Elf64_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info; 125 Elf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;
124 126
125 if (sechdrs[i].sh_type != SHT_RELA) 127 if (sechdrs[i].sh_type != SHT_RELA)
126 continue; 128 continue;
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index 60f1e02eed36..2ae5e0284f56 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -18,12 +18,15 @@
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
19#include <asm/syscall.h> 19#include <asm/syscall.h>
20#include <asm/thread_info.h> 20#include <asm/thread_info.h>
21#include <linux/audit.h>
21#include <linux/ptrace.h> 22#include <linux/ptrace.h>
22#include <linux/elf.h> 23#include <linux/elf.h>
23#include <linux/regset.h> 24#include <linux/regset.h>
24#include <linux/sched.h> 25#include <linux/sched.h>
25#include <linux/sched/task_stack.h> 26#include <linux/sched/task_stack.h>
26#include <linux/tracehook.h> 27#include <linux/tracehook.h>
28
29#define CREATE_TRACE_POINTS
27#include <trace/events/syscalls.h> 30#include <trace/events/syscalls.h>
28 31
29enum riscv_regset { 32enum riscv_regset {
@@ -163,15 +166,19 @@ void do_syscall_trace_enter(struct pt_regs *regs)
163 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 166 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
164 trace_sys_enter(regs, syscall_get_nr(current, regs)); 167 trace_sys_enter(regs, syscall_get_nr(current, regs));
165#endif 168#endif
169
170 audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3);
166} 171}
167 172
168void do_syscall_trace_exit(struct pt_regs *regs) 173void do_syscall_trace_exit(struct pt_regs *regs)
169{ 174{
175 audit_syscall_exit(regs);
176
170 if (test_thread_flag(TIF_SYSCALL_TRACE)) 177 if (test_thread_flag(TIF_SYSCALL_TRACE))
171 tracehook_report_syscall_exit(regs, 0); 178 tracehook_report_syscall_exit(regs, 0);
172 179
173#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS 180#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
174 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 181 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
175 trace_sys_exit(regs, regs->regs[0]); 182 trace_sys_exit(regs, regs_return_value(regs));
176#endif 183#endif
177} 184}
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index fc8006a042eb..6e079e94b638 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -149,7 +149,14 @@ asmlinkage void __init setup_vm(void)
149 149
150void __init parse_dtb(unsigned int hartid, void *dtb) 150void __init parse_dtb(unsigned int hartid, void *dtb)
151{ 151{
152 early_init_dt_scan(__va(dtb)); 152 if (!early_init_dt_scan(__va(dtb)))
153 return;
154
155 pr_err("No DTB passed to the kernel\n");
156#ifdef CONFIG_CMDLINE_FORCE
157 strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
158 pr_info("Forcing kernel command line to: %s\n", boot_command_line);
159#endif
153} 160}
154 161
155static void __init setup_bootmem(void) 162static void __init setup_bootmem(void)
diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index 57b1383e5ef7..246635eac7bb 100644
--- a/arch/riscv/kernel/smp.c
+++ b/arch/riscv/kernel/smp.c
@@ -23,6 +23,7 @@
23#include <linux/smp.h> 23#include <linux/smp.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/seq_file.h> 25#include <linux/seq_file.h>
26#include <linux/delay.h>
26 27
27#include <asm/sbi.h> 28#include <asm/sbi.h>
28#include <asm/tlbflush.h> 29#include <asm/tlbflush.h>
@@ -31,6 +32,7 @@
31enum ipi_message_type { 32enum ipi_message_type {
32 IPI_RESCHEDULE, 33 IPI_RESCHEDULE,
33 IPI_CALL_FUNC, 34 IPI_CALL_FUNC,
35 IPI_CPU_STOP,
34 IPI_MAX 36 IPI_MAX
35}; 37};
36 38
@@ -66,6 +68,13 @@ int setup_profiling_timer(unsigned int multiplier)
66 return -EINVAL; 68 return -EINVAL;
67} 69}
68 70
71static void ipi_stop(void)
72{
73 set_cpu_online(smp_processor_id(), false);
74 while (1)
75 wait_for_interrupt();
76}
77
69void riscv_software_interrupt(void) 78void riscv_software_interrupt(void)
70{ 79{
71 unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits; 80 unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits;
@@ -94,6 +103,11 @@ void riscv_software_interrupt(void)
94 generic_smp_call_function_interrupt(); 103 generic_smp_call_function_interrupt();
95 } 104 }
96 105
106 if (ops & (1 << IPI_CPU_STOP)) {
107 stats[IPI_CPU_STOP]++;
108 ipi_stop();
109 }
110
97 BUG_ON((ops >> IPI_MAX) != 0); 111 BUG_ON((ops >> IPI_MAX) != 0);
98 112
99 /* Order data access and bit testing. */ 113 /* Order data access and bit testing. */
@@ -121,6 +135,7 @@ send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation)
121static const char * const ipi_names[] = { 135static const char * const ipi_names[] = {
122 [IPI_RESCHEDULE] = "Rescheduling interrupts", 136 [IPI_RESCHEDULE] = "Rescheduling interrupts",
123 [IPI_CALL_FUNC] = "Function call interrupts", 137 [IPI_CALL_FUNC] = "Function call interrupts",
138 [IPI_CPU_STOP] = "CPU stop interrupts",
124}; 139};
125 140
126void show_ipi_stats(struct seq_file *p, int prec) 141void show_ipi_stats(struct seq_file *p, int prec)
@@ -146,15 +161,29 @@ void arch_send_call_function_single_ipi(int cpu)
146 send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC); 161 send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC);
147} 162}
148 163
149static void ipi_stop(void *unused)
150{
151 while (1)
152 wait_for_interrupt();
153}
154
155void smp_send_stop(void) 164void smp_send_stop(void)
156{ 165{
157 on_each_cpu(ipi_stop, NULL, 1); 166 unsigned long timeout;
167
168 if (num_online_cpus() > 1) {
169 cpumask_t mask;
170
171 cpumask_copy(&mask, cpu_online_mask);
172 cpumask_clear_cpu(smp_processor_id(), &mask);
173
174 if (system_state <= SYSTEM_RUNNING)
175 pr_crit("SMP: stopping secondary CPUs\n");
176 send_ipi_message(&mask, IPI_CPU_STOP);
177 }
178
179 /* Wait up to one second for other CPUs to stop */
180 timeout = USEC_PER_SEC;
181 while (num_online_cpus() > 1 && timeout--)
182 udelay(1);
183
184 if (num_online_cpus() > 1)
185 pr_warn("SMP: failed to stop secondary CPUs %*pbl\n",
186 cpumask_pr_args(cpu_online_mask));
158} 187}
159 188
160void smp_send_reschedule(int cpu) 189void smp_send_reschedule(int cpu)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 65df1dfdc303..1e1395d63dab 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -18,6 +18,8 @@
18#include <asm/cache.h> 18#include <asm/cache.h>
19#include <asm/thread_info.h> 19#include <asm/thread_info.h>
20 20
21#define MAX_BYTES_PER_LONG 0x10
22
21OUTPUT_ARCH(riscv) 23OUTPUT_ARCH(riscv)
22ENTRY(_start) 24ENTRY(_start)
23 25
@@ -74,8 +76,6 @@ SECTIONS
74 *(.sbss*) 76 *(.sbss*)
75 } 77 }
76 78
77 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
78
79 EXCEPTION_TABLE(0x10) 79 EXCEPTION_TABLE(0x10)
80 NOTES 80 NOTES
81 81
@@ -83,6 +83,10 @@ SECTIONS
83 *(.rel.dyn*) 83 *(.rel.dyn*)
84 } 84 }
85 85
86 BSS_SECTION(MAX_BYTES_PER_LONG,
87 MAX_BYTES_PER_LONG,
88 MAX_BYTES_PER_LONG)
89
86 _end = .; 90 _end = .;
87 91
88 STABS_DEBUG 92 STABS_DEBUG
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6185d4f33296..15af091611e2 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -446,7 +446,7 @@ config RETPOLINE
446 branches. Requires a compiler with -mindirect-branch=thunk-extern 446 branches. Requires a compiler with -mindirect-branch=thunk-extern
447 support for full protection. The kernel may run slower. 447 support for full protection. The kernel may run slower.
448 448
449config RESCTRL 449config X86_RESCTRL
450 bool "Resource Control support" 450 bool "Resource Control support"
451 depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) 451 depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
452 select KERNFS 452 select KERNFS
diff --git a/arch/x86/include/asm/resctrl_sched.h b/arch/x86/include/asm/resctrl_sched.h
index 54990fe2a3ae..40ebddde6ac2 100644
--- a/arch/x86/include/asm/resctrl_sched.h
+++ b/arch/x86/include/asm/resctrl_sched.h
@@ -2,7 +2,7 @@
2#ifndef _ASM_X86_RESCTRL_SCHED_H 2#ifndef _ASM_X86_RESCTRL_SCHED_H
3#define _ASM_X86_RESCTRL_SCHED_H 3#define _ASM_X86_RESCTRL_SCHED_H
4 4
5#ifdef CONFIG_RESCTRL 5#ifdef CONFIG_X86_RESCTRL
6 6
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/jump_label.h> 8#include <linux/jump_label.h>
@@ -88,6 +88,6 @@ static inline void resctrl_sched_in(void)
88 88
89static inline void resctrl_sched_in(void) {} 89static inline void resctrl_sched_in(void) {}
90 90
91#endif /* CONFIG_RESCTRL */ 91#endif /* CONFIG_X86_RESCTRL */
92 92
93#endif /* _ASM_X86_RESCTRL_SCHED_H */ 93#endif /* _ASM_X86_RESCTRL_SCHED_H */
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index ac78f90aea56..b6fa0869f7aa 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -39,7 +39,7 @@ obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o
39obj-$(CONFIG_X86_MCE) += mce/ 39obj-$(CONFIG_X86_MCE) += mce/
40obj-$(CONFIG_MTRR) += mtrr/ 40obj-$(CONFIG_MTRR) += mtrr/
41obj-$(CONFIG_MICROCODE) += microcode/ 41obj-$(CONFIG_MICROCODE) += microcode/
42obj-$(CONFIG_RESCTRL) += resctrl/ 42obj-$(CONFIG_X86_RESCTRL) += resctrl/
43 43
44obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o 44obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
45 45
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 8654b8b0c848..1de0f4170178 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -215,7 +215,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
215static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init = 215static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
216 SPECTRE_V2_USER_NONE; 216 SPECTRE_V2_USER_NONE;
217 217
218#ifdef RETPOLINE 218#ifdef CONFIG_RETPOLINE
219static bool spectre_v2_bad_module; 219static bool spectre_v2_bad_module;
220 220
221bool retpoline_module_ok(bool has_retpoline) 221bool retpoline_module_ok(bool has_retpoline)
diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/resctrl/Makefile
index 6895049ceef7..1cabe6fd8e11 100644
--- a/arch/x86/kernel/cpu/resctrl/Makefile
+++ b/arch/x86/kernel/cpu/resctrl/Makefile
@@ -1,4 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2obj-$(CONFIG_RESCTRL) += core.o rdtgroup.o monitor.o 2obj-$(CONFIG_X86_RESCTRL) += core.o rdtgroup.o monitor.o
3obj-$(CONFIG_RESCTRL) += ctrlmondata.o pseudo_lock.o 3obj-$(CONFIG_X86_RESCTRL) += ctrlmondata.o pseudo_lock.o
4CFLAGS_pseudo_lock.o = -I$(src) 4CFLAGS_pseudo_lock.o = -I$(src)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 307e5bddb6d9..a157ca5b6869 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6278,6 +6278,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
6278 int asid, ret; 6278 int asid, ret;
6279 6279
6280 ret = -EBUSY; 6280 ret = -EBUSY;
6281 if (unlikely(sev->active))
6282 return ret;
6283
6281 asid = sev_asid_new(); 6284 asid = sev_asid_new();
6282 if (asid < 0) 6285 if (asid < 0)
6283 return ret; 6286 return ret;
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 3170e291215d..2616bd2c7f2c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4540,9 +4540,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
4540 * given physical address won't match the required 4540 * given physical address won't match the required
4541 * VMCS12_REVISION identifier. 4541 * VMCS12_REVISION identifier.
4542 */ 4542 */
4543 nested_vmx_failValid(vcpu, 4543 return nested_vmx_failValid(vcpu,
4544 VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); 4544 VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
4545 return kvm_skip_emulated_instruction(vcpu);
4546 } 4545 }
4547 new_vmcs12 = kmap(page); 4546 new_vmcs12 = kmap(page);
4548 if (new_vmcs12->hdr.revision_id != VMCS12_REVISION || 4547 if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 4d39f731bc33..f6915f10e584 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -453,7 +453,7 @@ static int hv_remote_flush_tlb_with_range(struct kvm *kvm,
453 struct kvm_tlb_range *range) 453 struct kvm_tlb_range *range)
454{ 454{
455 struct kvm_vcpu *vcpu; 455 struct kvm_vcpu *vcpu;
456 int ret = -ENOTSUPP, i; 456 int ret = 0, i;
457 457
458 spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock); 458 spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock);
459 459
@@ -7044,7 +7044,7 @@ static void update_intel_pt_cfg(struct kvm_vcpu *vcpu)
7044 7044
7045 /* unmask address range configure area */ 7045 /* unmask address range configure area */
7046 for (i = 0; i < vmx->pt_desc.addr_range; i++) 7046 for (i = 0; i < vmx->pt_desc.addr_range; i++)
7047 vmx->pt_desc.ctl_bitmask &= ~(0xf << (32 + i * 4)); 7047 vmx->pt_desc.ctl_bitmask &= ~(0xfULL << (32 + i * 4));
7048} 7048}
7049 7049
7050static void vmx_cpuid_update(struct kvm_vcpu *vcpu) 7050static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 7b65a807b3dd..90ff0a47c12e 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -10,6 +10,7 @@ menuconfig ACPI
10 bool "ACPI (Advanced Configuration and Power Interface) Support" 10 bool "ACPI (Advanced Configuration and Power Interface) Support"
11 depends on ARCH_SUPPORTS_ACPI 11 depends on ARCH_SUPPORTS_ACPI
12 select PNP 12 select PNP
13 select NLS
13 default y if X86 14 default y if X86
14 help 15 help
15 Advanced Configuration and Power Interface (ACPI) support for 16 Advanced Configuration and Power Interface (ACPI) support for
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index fdd90ffceb85..e48894e002ba 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -876,7 +876,7 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
876 return (resv == its->its_count) ? resv : -ENODEV; 876 return (resv == its->its_count) ? resv : -ENODEV;
877} 877}
878#else 878#else
879static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device *dev); 879static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device *dev)
880{ return NULL; } 880{ return NULL; }
881static inline int iort_add_device_replay(const struct iommu_ops *ops, 881static inline int iort_add_device_replay(const struct iommu_ops *ops,
882 struct device *dev) 882 struct device *dev)
@@ -952,9 +952,10 @@ static int rc_dma_get_range(struct device *dev, u64 *size)
952{ 952{
953 struct acpi_iort_node *node; 953 struct acpi_iort_node *node;
954 struct acpi_iort_root_complex *rc; 954 struct acpi_iort_root_complex *rc;
955 struct pci_bus *pbus = to_pci_dev(dev)->bus;
955 956
956 node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX, 957 node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX,
957 iort_match_node_callback, dev); 958 iort_match_node_callback, &pbus->dev);
958 if (!node || node->revision < 1) 959 if (!node || node->revision < 1)
959 return -ENODEV; 960 return -ENODEV;
960 961
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 274699463b4f..7bbbf8256a41 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -146,9 +146,9 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
146 { 146 {
147 struct acpi_srat_mem_affinity *p = 147 struct acpi_srat_mem_affinity *p =
148 (struct acpi_srat_mem_affinity *)header; 148 (struct acpi_srat_mem_affinity *)header;
149 pr_debug("SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s%s\n", 149 pr_debug("SRAT Memory (0x%llx length 0x%llx) in proximity domain %d %s%s%s\n",
150 (unsigned long)p->base_address, 150 (unsigned long long)p->base_address,
151 (unsigned long)p->length, 151 (unsigned long long)p->length,
152 p->proximity_domain, 152 p->proximity_domain,
153 (p->flags & ACPI_SRAT_MEM_ENABLED) ? 153 (p->flags & ACPI_SRAT_MEM_ENABLED) ?
154 "enabled" : "disabled", 154 "enabled" : "disabled",
diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
index 2579675b7082..e7c0006e6602 100644
--- a/drivers/acpi/pmic/intel_pmic_xpower.c
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -20,8 +20,11 @@
20#define GPI1_LDO_ON (3 << 0) 20#define GPI1_LDO_ON (3 << 0)
21#define GPI1_LDO_OFF (4 << 0) 21#define GPI1_LDO_OFF (4 << 0)
22 22
23#define AXP288_ADC_TS_PIN_GPADC 0xf2 23#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0)
24#define AXP288_ADC_TS_PIN_ON 0xf3 24#define AXP288_ADC_TS_CURRENT_OFF (0 << 0)
25#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0)
26#define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0)
27#define AXP288_ADC_TS_CURRENT_ON (3 << 0)
25 28
26static struct pmic_table power_table[] = { 29static struct pmic_table power_table[] = {
27 { 30 {
@@ -212,22 +215,44 @@ out:
212 */ 215 */
213static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) 216static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
214{ 217{
218 int ret, adc_ts_pin_ctrl;
215 u8 buf[2]; 219 u8 buf[2];
216 int ret;
217 220
218 ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, 221 /*
219 AXP288_ADC_TS_PIN_GPADC); 222 * The current-source used for the battery temp-sensor (TS) is shared
223 * with the GPADC. For proper fuel-gauge and charger operation the TS
224 * current-source needs to be permanently on. But to read the GPADC we
225 * need to temporary switch the TS current-source to ondemand, so that
226 * the GPADC can use it, otherwise we will always read an all 0 value.
227 *
228 * Note that the switching from on to on-ondemand is not necessary
229 * when the TS current-source is off (this happens on devices which
230 * do not use the TS-pin).
231 */
232 ret = regmap_read(regmap, AXP288_ADC_TS_PIN_CTRL, &adc_ts_pin_ctrl);
220 if (ret) 233 if (ret)
221 return ret; 234 return ret;
222 235
223 /* After switching to the GPADC pin give things some time to settle */ 236 if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
224 usleep_range(6000, 10000); 237 ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
238 AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
239 AXP288_ADC_TS_CURRENT_ON_ONDEMAND);
240 if (ret)
241 return ret;
242
243 /* Wait a bit after switching the current-source */
244 usleep_range(6000, 10000);
245 }
225 246
226 ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); 247 ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
227 if (ret == 0) 248 if (ret == 0)
228 ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); 249 ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
229 250
230 regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON); 251 if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
252 regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
253 AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
254 AXP288_ADC_TS_CURRENT_ON);
255 }
231 256
232 return ret; 257 return ret;
233} 258}
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 1b475bc1ae16..665e93ca0b40 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -131,6 +131,23 @@ void acpi_power_resources_list_free(struct list_head *list)
131 } 131 }
132} 132}
133 133
134static bool acpi_power_resource_is_dup(union acpi_object *package,
135 unsigned int start, unsigned int i)
136{
137 acpi_handle rhandle, dup;
138 unsigned int j;
139
140 /* The caller is expected to check the package element types */
141 rhandle = package->package.elements[i].reference.handle;
142 for (j = start; j < i; j++) {
143 dup = package->package.elements[j].reference.handle;
144 if (dup == rhandle)
145 return true;
146 }
147
148 return false;
149}
150
134int acpi_extract_power_resources(union acpi_object *package, unsigned int start, 151int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
135 struct list_head *list) 152 struct list_head *list)
136{ 153{
@@ -150,6 +167,11 @@ int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
150 err = -ENODEV; 167 err = -ENODEV;
151 break; 168 break;
152 } 169 }
170
171 /* Some ACPI tables contain duplicate power resource references */
172 if (acpi_power_resource_is_dup(package, start, i))
173 continue;
174
153 err = acpi_add_power_resource(rhandle); 175 err = acpi_add_power_resource(rhandle);
154 if (err) 176 if (err)
155 break; 177 break;
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index a690fd400260..0992e67e862b 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -32,6 +32,7 @@
32#include <trace/events/power.h> 32#include <trace/events/power.h>
33#include <linux/cpufreq.h> 33#include <linux/cpufreq.h>
34#include <linux/cpuidle.h> 34#include <linux/cpuidle.h>
35#include <linux/devfreq.h>
35#include <linux/timer.h> 36#include <linux/timer.h>
36 37
37#include "../base.h" 38#include "../base.h"
@@ -1078,6 +1079,7 @@ void dpm_resume(pm_message_t state)
1078 dpm_show_time(starttime, state, 0, NULL); 1079 dpm_show_time(starttime, state, 0, NULL);
1079 1080
1080 cpufreq_resume(); 1081 cpufreq_resume();
1082 devfreq_resume();
1081 trace_suspend_resume(TPS("dpm_resume"), state.event, false); 1083 trace_suspend_resume(TPS("dpm_resume"), state.event, false);
1082} 1084}
1083 1085
@@ -1852,6 +1854,7 @@ int dpm_suspend(pm_message_t state)
1852 trace_suspend_resume(TPS("dpm_suspend"), state.event, true); 1854 trace_suspend_resume(TPS("dpm_suspend"), state.event, true);
1853 might_sleep(); 1855 might_sleep();
1854 1856
1857 devfreq_suspend();
1855 cpufreq_suspend(); 1858 cpufreq_suspend();
1856 1859
1857 mutex_lock(&dpm_list_mtx); 1860 mutex_lock(&dpm_list_mtx);
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 70624695b6d5..457be03b744d 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -121,7 +121,7 @@ static void pm_runtime_cancel_pending(struct device *dev)
121 * Compute the autosuspend-delay expiration time based on the device's 121 * Compute the autosuspend-delay expiration time based on the device's
122 * power.last_busy time. If the delay has already expired or is disabled 122 * power.last_busy time. If the delay has already expired or is disabled
123 * (negative) or the power.use_autosuspend flag isn't set, return 0. 123 * (negative) or the power.use_autosuspend flag isn't set, return 0.
124 * Otherwise return the expiration time in jiffies (adjusted to be nonzero). 124 * Otherwise return the expiration time in nanoseconds (adjusted to be nonzero).
125 * 125 *
126 * This function may be called either with or without dev->power.lock held. 126 * This function may be called either with or without dev->power.lock held.
127 * Either way it can be racy, since power.last_busy may be updated at any time. 127 * Either way it can be racy, since power.last_busy may be updated at any time.
@@ -141,7 +141,7 @@ u64 pm_runtime_autosuspend_expiration(struct device *dev)
141 141
142 last_busy = READ_ONCE(dev->power.last_busy); 142 last_busy = READ_ONCE(dev->power.last_busy);
143 143
144 expires = last_busy + autosuspend_delay * NSEC_PER_MSEC; 144 expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
145 if (expires <= now) 145 if (expires <= now)
146 expires = 0; /* Already expired. */ 146 expires = 0; /* Already expired. */
147 147
@@ -525,7 +525,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
525 * We add a slack of 25% to gather wakeups 525 * We add a slack of 25% to gather wakeups
526 * without sacrificing the granularity. 526 * without sacrificing the granularity.
527 */ 527 */
528 u64 slack = READ_ONCE(dev->power.autosuspend_delay) * 528 u64 slack = (u64)READ_ONCE(dev->power.autosuspend_delay) *
529 (NSEC_PER_MSEC >> 2); 529 (NSEC_PER_MSEC >> 2);
530 530
531 dev->power.timer_expires = expires; 531 dev->power.timer_expires = expires;
@@ -905,7 +905,10 @@ static enum hrtimer_restart pm_suspend_timer_fn(struct hrtimer *timer)
905 spin_lock_irqsave(&dev->power.lock, flags); 905 spin_lock_irqsave(&dev->power.lock, flags);
906 906
907 expires = dev->power.timer_expires; 907 expires = dev->power.timer_expires;
908 /* If 'expire' is after 'jiffies' we've been called too early. */ 908 /*
909 * If 'expires' is after the current time, we've been called
910 * too early.
911 */
909 if (expires > 0 && expires < ktime_to_ns(ktime_get())) { 912 if (expires > 0 && expires < ktime_to_ns(ktime_get())) {
910 dev->power.timer_expires = 0; 913 dev->power.timer_expires = 0;
911 rpm_suspend(dev, dev->power.timer_autosuspends ? 914 rpm_suspend(dev, dev->power.timer_autosuspends ?
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8e5140bbf241..1e92b61d0bd5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5986,7 +5986,6 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
5986 struct list_head *tmp; 5986 struct list_head *tmp;
5987 int dev_id; 5987 int dev_id;
5988 char opt_buf[6]; 5988 char opt_buf[6];
5989 bool already = false;
5990 bool force = false; 5989 bool force = false;
5991 int ret; 5990 int ret;
5992 5991
@@ -6019,13 +6018,13 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
6019 spin_lock_irq(&rbd_dev->lock); 6018 spin_lock_irq(&rbd_dev->lock);
6020 if (rbd_dev->open_count && !force) 6019 if (rbd_dev->open_count && !force)
6021 ret = -EBUSY; 6020 ret = -EBUSY;
6022 else 6021 else if (test_and_set_bit(RBD_DEV_FLAG_REMOVING,
6023 already = test_and_set_bit(RBD_DEV_FLAG_REMOVING, 6022 &rbd_dev->flags))
6024 &rbd_dev->flags); 6023 ret = -EINPROGRESS;
6025 spin_unlock_irq(&rbd_dev->lock); 6024 spin_unlock_irq(&rbd_dev->lock);
6026 } 6025 }
6027 spin_unlock(&rbd_dev_list_lock); 6026 spin_unlock(&rbd_dev_list_lock);
6028 if (ret < 0 || already) 6027 if (ret)
6029 return ret; 6028 return ret;
6030 6029
6031 if (force) { 6030 if (force) {
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 33c5cc879f24..04ca65912638 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -316,11 +316,9 @@ static ssize_t idle_store(struct device *dev,
316 * See the comment in writeback_store. 316 * See the comment in writeback_store.
317 */ 317 */
318 zram_slot_lock(zram, index); 318 zram_slot_lock(zram, index);
319 if (!zram_allocated(zram, index) || 319 if (zram_allocated(zram, index) &&
320 zram_test_flag(zram, index, ZRAM_UNDER_WB)) 320 !zram_test_flag(zram, index, ZRAM_UNDER_WB))
321 goto next; 321 zram_set_flag(zram, index, ZRAM_IDLE);
322 zram_set_flag(zram, index, ZRAM_IDLE);
323next:
324 zram_slot_unlock(zram, index); 322 zram_slot_unlock(zram, index);
325 } 323 }
326 324
@@ -330,6 +328,41 @@ next:
330} 328}
331 329
332#ifdef CONFIG_ZRAM_WRITEBACK 330#ifdef CONFIG_ZRAM_WRITEBACK
331static ssize_t writeback_limit_enable_store(struct device *dev,
332 struct device_attribute *attr, const char *buf, size_t len)
333{
334 struct zram *zram = dev_to_zram(dev);
335 u64 val;
336 ssize_t ret = -EINVAL;
337
338 if (kstrtoull(buf, 10, &val))
339 return ret;
340
341 down_read(&zram->init_lock);
342 spin_lock(&zram->wb_limit_lock);
343 zram->wb_limit_enable = val;
344 spin_unlock(&zram->wb_limit_lock);
345 up_read(&zram->init_lock);
346 ret = len;
347
348 return ret;
349}
350
351static ssize_t writeback_limit_enable_show(struct device *dev,
352 struct device_attribute *attr, char *buf)
353{
354 bool val;
355 struct zram *zram = dev_to_zram(dev);
356
357 down_read(&zram->init_lock);
358 spin_lock(&zram->wb_limit_lock);
359 val = zram->wb_limit_enable;
360 spin_unlock(&zram->wb_limit_lock);
361 up_read(&zram->init_lock);
362
363 return scnprintf(buf, PAGE_SIZE, "%d\n", val);
364}
365
333static ssize_t writeback_limit_store(struct device *dev, 366static ssize_t writeback_limit_store(struct device *dev,
334 struct device_attribute *attr, const char *buf, size_t len) 367 struct device_attribute *attr, const char *buf, size_t len)
335{ 368{
@@ -341,9 +374,9 @@ static ssize_t writeback_limit_store(struct device *dev,
341 return ret; 374 return ret;
342 375
343 down_read(&zram->init_lock); 376 down_read(&zram->init_lock);
344 atomic64_set(&zram->stats.bd_wb_limit, val); 377 spin_lock(&zram->wb_limit_lock);
345 if (val == 0) 378 zram->bd_wb_limit = val;
346 zram->stop_writeback = false; 379 spin_unlock(&zram->wb_limit_lock);
347 up_read(&zram->init_lock); 380 up_read(&zram->init_lock);
348 ret = len; 381 ret = len;
349 382
@@ -357,7 +390,9 @@ static ssize_t writeback_limit_show(struct device *dev,
357 struct zram *zram = dev_to_zram(dev); 390 struct zram *zram = dev_to_zram(dev);
358 391
359 down_read(&zram->init_lock); 392 down_read(&zram->init_lock);
360 val = atomic64_read(&zram->stats.bd_wb_limit); 393 spin_lock(&zram->wb_limit_lock);
394 val = zram->bd_wb_limit;
395 spin_unlock(&zram->wb_limit_lock);
361 up_read(&zram->init_lock); 396 up_read(&zram->init_lock);
362 397
363 return scnprintf(buf, PAGE_SIZE, "%llu\n", val); 398 return scnprintf(buf, PAGE_SIZE, "%llu\n", val);
@@ -588,8 +623,8 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
588 return 1; 623 return 1;
589} 624}
590 625
591#define HUGE_WRITEBACK 0x1 626#define HUGE_WRITEBACK 1
592#define IDLE_WRITEBACK 0x2 627#define IDLE_WRITEBACK 2
593 628
594static ssize_t writeback_store(struct device *dev, 629static ssize_t writeback_store(struct device *dev,
595 struct device_attribute *attr, const char *buf, size_t len) 630 struct device_attribute *attr, const char *buf, size_t len)
@@ -602,7 +637,7 @@ static ssize_t writeback_store(struct device *dev,
602 struct page *page; 637 struct page *page;
603 ssize_t ret, sz; 638 ssize_t ret, sz;
604 char mode_buf[8]; 639 char mode_buf[8];
605 unsigned long mode = -1UL; 640 int mode = -1;
606 unsigned long blk_idx = 0; 641 unsigned long blk_idx = 0;
607 642
608 sz = strscpy(mode_buf, buf, sizeof(mode_buf)); 643 sz = strscpy(mode_buf, buf, sizeof(mode_buf));
@@ -618,7 +653,7 @@ static ssize_t writeback_store(struct device *dev,
618 else if (!strcmp(mode_buf, "huge")) 653 else if (!strcmp(mode_buf, "huge"))
619 mode = HUGE_WRITEBACK; 654 mode = HUGE_WRITEBACK;
620 655
621 if (mode == -1UL) 656 if (mode == -1)
622 return -EINVAL; 657 return -EINVAL;
623 658
624 down_read(&zram->init_lock); 659 down_read(&zram->init_lock);
@@ -645,10 +680,13 @@ static ssize_t writeback_store(struct device *dev,
645 bvec.bv_len = PAGE_SIZE; 680 bvec.bv_len = PAGE_SIZE;
646 bvec.bv_offset = 0; 681 bvec.bv_offset = 0;
647 682
648 if (zram->stop_writeback) { 683 spin_lock(&zram->wb_limit_lock);
684 if (zram->wb_limit_enable && !zram->bd_wb_limit) {
685 spin_unlock(&zram->wb_limit_lock);
649 ret = -EIO; 686 ret = -EIO;
650 break; 687 break;
651 } 688 }
689 spin_unlock(&zram->wb_limit_lock);
652 690
653 if (!blk_idx) { 691 if (!blk_idx) {
654 blk_idx = alloc_block_bdev(zram); 692 blk_idx = alloc_block_bdev(zram);
@@ -667,10 +705,11 @@ static ssize_t writeback_store(struct device *dev,
667 zram_test_flag(zram, index, ZRAM_UNDER_WB)) 705 zram_test_flag(zram, index, ZRAM_UNDER_WB))
668 goto next; 706 goto next;
669 707
670 if ((mode & IDLE_WRITEBACK && 708 if (mode == IDLE_WRITEBACK &&
671 !zram_test_flag(zram, index, ZRAM_IDLE)) && 709 !zram_test_flag(zram, index, ZRAM_IDLE))
672 (mode & HUGE_WRITEBACK && 710 goto next;
673 !zram_test_flag(zram, index, ZRAM_HUGE))) 711 if (mode == HUGE_WRITEBACK &&
712 !zram_test_flag(zram, index, ZRAM_HUGE))
674 goto next; 713 goto next;
675 /* 714 /*
676 * Clearing ZRAM_UNDER_WB is duty of caller. 715 * Clearing ZRAM_UNDER_WB is duty of caller.
@@ -732,11 +771,10 @@ static ssize_t writeback_store(struct device *dev,
732 zram_set_element(zram, index, blk_idx); 771 zram_set_element(zram, index, blk_idx);
733 blk_idx = 0; 772 blk_idx = 0;
734 atomic64_inc(&zram->stats.pages_stored); 773 atomic64_inc(&zram->stats.pages_stored);
735 if (atomic64_add_unless(&zram->stats.bd_wb_limit, 774 spin_lock(&zram->wb_limit_lock);
736 -1 << (PAGE_SHIFT - 12), 0)) { 775 if (zram->wb_limit_enable && zram->bd_wb_limit > 0)
737 if (atomic64_read(&zram->stats.bd_wb_limit) == 0) 776 zram->bd_wb_limit -= 1UL << (PAGE_SHIFT - 12);
738 zram->stop_writeback = true; 777 spin_unlock(&zram->wb_limit_lock);
739 }
740next: 778next:
741 zram_slot_unlock(zram, index); 779 zram_slot_unlock(zram, index);
742 } 780 }
@@ -1812,6 +1850,7 @@ static DEVICE_ATTR_RW(comp_algorithm);
1812static DEVICE_ATTR_RW(backing_dev); 1850static DEVICE_ATTR_RW(backing_dev);
1813static DEVICE_ATTR_WO(writeback); 1851static DEVICE_ATTR_WO(writeback);
1814static DEVICE_ATTR_RW(writeback_limit); 1852static DEVICE_ATTR_RW(writeback_limit);
1853static DEVICE_ATTR_RW(writeback_limit_enable);
1815#endif 1854#endif
1816 1855
1817static struct attribute *zram_disk_attrs[] = { 1856static struct attribute *zram_disk_attrs[] = {
@@ -1828,6 +1867,7 @@ static struct attribute *zram_disk_attrs[] = {
1828 &dev_attr_backing_dev.attr, 1867 &dev_attr_backing_dev.attr,
1829 &dev_attr_writeback.attr, 1868 &dev_attr_writeback.attr,
1830 &dev_attr_writeback_limit.attr, 1869 &dev_attr_writeback_limit.attr,
1870 &dev_attr_writeback_limit_enable.attr,
1831#endif 1871#endif
1832 &dev_attr_io_stat.attr, 1872 &dev_attr_io_stat.attr,
1833 &dev_attr_mm_stat.attr, 1873 &dev_attr_mm_stat.attr,
@@ -1867,7 +1907,9 @@ static int zram_add(void)
1867 device_id = ret; 1907 device_id = ret;
1868 1908
1869 init_rwsem(&zram->init_lock); 1909 init_rwsem(&zram->init_lock);
1870 1910#ifdef CONFIG_ZRAM_WRITEBACK
1911 spin_lock_init(&zram->wb_limit_lock);
1912#endif
1871 queue = blk_alloc_queue(GFP_KERNEL); 1913 queue = blk_alloc_queue(GFP_KERNEL);
1872 if (!queue) { 1914 if (!queue) {
1873 pr_err("Error allocating disk queue for device %d\n", 1915 pr_err("Error allocating disk queue for device %d\n",
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 4bd3afd15e83..f2fd46daa760 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -86,7 +86,6 @@ struct zram_stats {
86 atomic64_t bd_count; /* no. of pages in backing device */ 86 atomic64_t bd_count; /* no. of pages in backing device */
87 atomic64_t bd_reads; /* no. of reads from backing device */ 87 atomic64_t bd_reads; /* no. of reads from backing device */
88 atomic64_t bd_writes; /* no. of writes from backing device */ 88 atomic64_t bd_writes; /* no. of writes from backing device */
89 atomic64_t bd_wb_limit; /* writeback limit of backing device */
90#endif 89#endif
91}; 90};
92 91
@@ -114,8 +113,10 @@ struct zram {
114 */ 113 */
115 bool claim; /* Protected by bdev->bd_mutex */ 114 bool claim; /* Protected by bdev->bd_mutex */
116 struct file *backing_dev; 115 struct file *backing_dev;
117 bool stop_writeback;
118#ifdef CONFIG_ZRAM_WRITEBACK 116#ifdef CONFIG_ZRAM_WRITEBACK
117 spinlock_t wb_limit_lock;
118 bool wb_limit_enable;
119 u64 bd_wb_limit;
119 struct block_device *bdev; 120 struct block_device *bdev;
120 unsigned int old_block_size; 121 unsigned int old_block_size;
121 unsigned long *bitmap; 122 unsigned long *bitmap;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6f23ebb395f1..e35a886e00bc 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1530,17 +1530,16 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
1530{ 1530{
1531 unsigned int ret_freq = 0; 1531 unsigned int ret_freq = 0;
1532 1532
1533 if (!cpufreq_driver->get) 1533 if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
1534 return ret_freq; 1534 return ret_freq;
1535 1535
1536 ret_freq = cpufreq_driver->get(policy->cpu); 1536 ret_freq = cpufreq_driver->get(policy->cpu);
1537 1537
1538 /* 1538 /*
1539 * Updating inactive policies is invalid, so avoid doing that. Also 1539 * If fast frequency switching is used with the given policy, the check
1540 * if fast frequency switching is used with the given policy, the check
1541 * against policy->cur is pointless, so skip it in that case too. 1540 * against policy->cur is pointless, so skip it in that case too.
1542 */ 1541 */
1543 if (unlikely(policy_is_inactive(policy)) || policy->fast_switch_enabled) 1542 if (policy->fast_switch_enabled)
1544 return ret_freq; 1543 return ret_freq;
1545 1544
1546 if (ret_freq && policy->cur && 1545 if (ret_freq && policy->cur &&
@@ -1569,10 +1568,7 @@ unsigned int cpufreq_get(unsigned int cpu)
1569 1568
1570 if (policy) { 1569 if (policy) {
1571 down_read(&policy->rwsem); 1570 down_read(&policy->rwsem);
1572 1571 ret_freq = __cpufreq_get(policy);
1573 if (!policy_is_inactive(policy))
1574 ret_freq = __cpufreq_get(policy);
1575
1576 up_read(&policy->rwsem); 1572 up_read(&policy->rwsem);
1577 1573
1578 cpufreq_cpu_put(policy); 1574 cpufreq_cpu_put(policy);
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 50b1551ba894..242c3370544e 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
52 int ret; 52 int ret;
53 struct scmi_data *priv = policy->driver_data; 53 struct scmi_data *priv = policy->driver_data;
54 struct scmi_perf_ops *perf_ops = handle->perf_ops; 54 struct scmi_perf_ops *perf_ops = handle->perf_ops;
55 u64 freq = policy->freq_table[index].frequency * 1000; 55 u64 freq = policy->freq_table[index].frequency;
56 56
57 ret = perf_ops->freq_set(handle, priv->domain_id, freq, false); 57 ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
58 if (!ret) 58 if (!ret)
59 arch_set_freq_scale(policy->related_cpus, freq, 59 arch_set_freq_scale(policy->related_cpus, freq,
60 policy->cpuinfo.max_freq); 60 policy->cpuinfo.max_freq);
@@ -176,7 +176,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
176out_free_priv: 176out_free_priv:
177 kfree(priv); 177 kfree(priv);
178out_free_opp: 178out_free_opp:
179 dev_pm_opp_cpumask_remove_table(policy->cpus); 179 dev_pm_opp_remove_all_dynamic(cpu_dev);
180 180
181 return ret; 181 return ret;
182} 182}
@@ -188,7 +188,7 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
188 cpufreq_cooling_unregister(priv->cdev); 188 cpufreq_cooling_unregister(priv->cdev);
189 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); 189 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
190 kfree(priv); 190 kfree(priv);
191 dev_pm_opp_cpumask_remove_table(policy->related_cpus); 191 dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
192 192
193 return 0; 193 return 0;
194} 194}
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 87a98ec77773..99449738faa4 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -177,7 +177,7 @@ out_free_cpufreq_table:
177out_free_priv: 177out_free_priv:
178 kfree(priv); 178 kfree(priv);
179out_free_opp: 179out_free_opp:
180 dev_pm_opp_cpumask_remove_table(policy->cpus); 180 dev_pm_opp_remove_all_dynamic(cpu_dev);
181 181
182 return ret; 182 return ret;
183} 183}
@@ -190,7 +190,7 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
190 clk_put(priv->clk); 190 clk_put(priv->clk);
191 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); 191 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
192 kfree(priv); 192 kfree(priv);
193 dev_pm_opp_cpumask_remove_table(policy->related_cpus); 193 dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
194 194
195 return 0; 195 return 0;
196} 196}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 8a078f4ae73d..7ff3a28fc903 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1701,8 +1701,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
1701 amdgpu_xgmi_add_device(adev); 1701 amdgpu_xgmi_add_device(adev);
1702 amdgpu_amdkfd_device_init(adev); 1702 amdgpu_amdkfd_device_init(adev);
1703 1703
1704 if (amdgpu_sriov_vf(adev)) 1704 if (amdgpu_sriov_vf(adev)) {
1705 amdgpu_virt_init_data_exchange(adev);
1705 amdgpu_virt_release_full_gpu(adev, true); 1706 amdgpu_virt_release_full_gpu(adev, true);
1707 }
1706 1708
1707 return 0; 1709 return 0;
1708} 1710}
@@ -2632,9 +2634,6 @@ fence_driver_init:
2632 goto failed; 2634 goto failed;
2633 } 2635 }
2634 2636
2635 if (amdgpu_sriov_vf(adev))
2636 amdgpu_virt_init_data_exchange(adev);
2637
2638 amdgpu_fbdev_init(adev); 2637 amdgpu_fbdev_init(adev);
2639 2638
2640 r = amdgpu_pm_sysfs_init(adev); 2639 r = amdgpu_pm_sysfs_init(adev);
@@ -2798,7 +2797,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
2798 struct drm_framebuffer *fb = crtc->primary->fb; 2797 struct drm_framebuffer *fb = crtc->primary->fb;
2799 struct amdgpu_bo *robj; 2798 struct amdgpu_bo *robj;
2800 2799
2801 if (amdgpu_crtc->cursor_bo) { 2800 if (amdgpu_crtc->cursor_bo && !adev->enable_virtual_display) {
2802 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); 2801 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
2803 r = amdgpu_bo_reserve(aobj, true); 2802 r = amdgpu_bo_reserve(aobj, true);
2804 if (r == 0) { 2803 if (r == 0) {
@@ -2906,7 +2905,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
2906 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 2905 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2907 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2906 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2908 2907
2909 if (amdgpu_crtc->cursor_bo) { 2908 if (amdgpu_crtc->cursor_bo && !adev->enable_virtual_display) {
2910 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); 2909 struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
2911 r = amdgpu_bo_reserve(aobj, true); 2910 r = amdgpu_bo_reserve(aobj, true);
2912 if (r == 0) { 2911 if (r == 0) {
@@ -3226,6 +3225,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
3226 r = amdgpu_ib_ring_tests(adev); 3225 r = amdgpu_ib_ring_tests(adev);
3227 3226
3228error: 3227error:
3228 amdgpu_virt_init_data_exchange(adev);
3229 amdgpu_virt_release_full_gpu(adev, true); 3229 amdgpu_virt_release_full_gpu(adev, true);
3230 if (!r && adev->virt.gim_feature & AMDGIM_FEATURE_GIM_FLR_VRAMLOST) { 3230 if (!r && adev->virt.gim_feature & AMDGIM_FEATURE_GIM_FLR_VRAMLOST) {
3231 atomic_inc(&adev->vram_lost_counter); 3231 atomic_inc(&adev->vram_lost_counter);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 15ce7e681d67..dafc645b2e4e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -188,10 +188,12 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
188 goto cleanup; 188 goto cleanup;
189 } 189 }
190 190
191 r = amdgpu_bo_pin(new_abo, amdgpu_display_supported_domains(adev)); 191 if (!adev->enable_virtual_display) {
192 if (unlikely(r != 0)) { 192 r = amdgpu_bo_pin(new_abo, amdgpu_display_supported_domains(adev));
193 DRM_ERROR("failed to pin new abo buffer before flip\n"); 193 if (unlikely(r != 0)) {
194 goto unreserve; 194 DRM_ERROR("failed to pin new abo buffer before flip\n");
195 goto unreserve;
196 }
195 } 197 }
196 198
197 r = amdgpu_ttm_alloc_gart(&new_abo->tbo); 199 r = amdgpu_ttm_alloc_gart(&new_abo->tbo);
@@ -211,7 +213,8 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
211 amdgpu_bo_get_tiling_flags(new_abo, &tiling_flags); 213 amdgpu_bo_get_tiling_flags(new_abo, &tiling_flags);
212 amdgpu_bo_unreserve(new_abo); 214 amdgpu_bo_unreserve(new_abo);
213 215
214 work->base = amdgpu_bo_gpu_offset(new_abo); 216 if (!adev->enable_virtual_display)
217 work->base = amdgpu_bo_gpu_offset(new_abo);
215 work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) + 218 work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) +
216 amdgpu_get_vblank_counter_kms(dev, work->crtc_id); 219 amdgpu_get_vblank_counter_kms(dev, work->crtc_id);
217 220
@@ -242,9 +245,10 @@ pflip_cleanup:
242 goto cleanup; 245 goto cleanup;
243 } 246 }
244unpin: 247unpin:
245 if (unlikely(amdgpu_bo_unpin(new_abo) != 0)) { 248 if (!adev->enable_virtual_display)
246 DRM_ERROR("failed to unpin new abo in error path\n"); 249 if (unlikely(amdgpu_bo_unpin(new_abo) != 0))
247 } 250 DRM_ERROR("failed to unpin new abo in error path\n");
251
248unreserve: 252unreserve:
249 amdgpu_bo_unreserve(new_abo); 253 amdgpu_bo_unreserve(new_abo);
250 254
@@ -527,6 +531,17 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
527 struct drm_gem_object *obj; 531 struct drm_gem_object *obj;
528 struct amdgpu_framebuffer *amdgpu_fb; 532 struct amdgpu_framebuffer *amdgpu_fb;
529 int ret; 533 int ret;
534 int height;
535 struct amdgpu_device *adev = dev->dev_private;
536 int cpp = drm_format_plane_cpp(mode_cmd->pixel_format, 0);
537 int pitch = mode_cmd->pitches[0] / cpp;
538
539 pitch = amdgpu_align_pitch(adev, pitch, cpp, false);
540 if (mode_cmd->pitches[0] != pitch) {
541 DRM_DEBUG_KMS("Invalid pitch: expecting %d but got %d\n",
542 pitch, mode_cmd->pitches[0]);
543 return ERR_PTR(-EINVAL);
544 }
530 545
531 obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); 546 obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
532 if (obj == NULL) { 547 if (obj == NULL) {
@@ -541,6 +556,13 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
541 return ERR_PTR(-EINVAL); 556 return ERR_PTR(-EINVAL);
542 } 557 }
543 558
559 height = ALIGN(mode_cmd->height, 8);
560 if (obj->size < pitch * height) {
561 DRM_DEBUG_KMS("Invalid GEM size: expecting >= %d but got %zu\n",
562 pitch * height, obj->size);
563 return ERR_PTR(-EINVAL);
564 }
565
544 amdgpu_fb = kzalloc(sizeof(*amdgpu_fb), GFP_KERNEL); 566 amdgpu_fb = kzalloc(sizeof(*amdgpu_fb), GFP_KERNEL);
545 if (amdgpu_fb == NULL) { 567 if (amdgpu_fb == NULL) {
546 drm_gem_object_put_unlocked(obj); 568 drm_gem_object_put_unlocked(obj);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 1f61ed95727c..6896dec97fc7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -2008,6 +2008,7 @@ void amdgpu_pm_print_power_states(struct amdgpu_device *adev)
2008 2008
2009int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) 2009int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
2010{ 2010{
2011 struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
2011 int ret; 2012 int ret;
2012 2013
2013 if (adev->pm.sysfs_initialized) 2014 if (adev->pm.sysfs_initialized)
@@ -2091,12 +2092,14 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
2091 "pp_power_profile_mode\n"); 2092 "pp_power_profile_mode\n");
2092 return ret; 2093 return ret;
2093 } 2094 }
2094 ret = device_create_file(adev->dev, 2095 if (hwmgr->od_enabled) {
2095 &dev_attr_pp_od_clk_voltage); 2096 ret = device_create_file(adev->dev,
2096 if (ret) { 2097 &dev_attr_pp_od_clk_voltage);
2097 DRM_ERROR("failed to create device file " 2098 if (ret) {
2098 "pp_od_clk_voltage\n"); 2099 DRM_ERROR("failed to create device file "
2099 return ret; 2100 "pp_od_clk_voltage\n");
2101 return ret;
2102 }
2100 } 2103 }
2101 ret = device_create_file(adev->dev, 2104 ret = device_create_file(adev->dev,
2102 &dev_attr_gpu_busy_percent); 2105 &dev_attr_gpu_busy_percent);
@@ -2118,6 +2121,8 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
2118 2121
2119void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) 2122void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
2120{ 2123{
2124 struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
2125
2121 if (adev->pm.dpm_enabled == 0) 2126 if (adev->pm.dpm_enabled == 0)
2122 return; 2127 return;
2123 2128
@@ -2138,8 +2143,9 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
2138 device_remove_file(adev->dev, &dev_attr_pp_mclk_od); 2143 device_remove_file(adev->dev, &dev_attr_pp_mclk_od);
2139 device_remove_file(adev->dev, 2144 device_remove_file(adev->dev,
2140 &dev_attr_pp_power_profile_mode); 2145 &dev_attr_pp_power_profile_mode);
2141 device_remove_file(adev->dev, 2146 if (hwmgr->od_enabled)
2142 &dev_attr_pp_od_clk_voltage); 2147 device_remove_file(adev->dev,
2148 &dev_attr_pp_od_clk_voltage);
2143 device_remove_file(adev->dev, &dev_attr_gpu_busy_percent); 2149 device_remove_file(adev->dev, &dev_attr_gpu_busy_percent);
2144} 2150}
2145 2151
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index e73d152659a2..d2ea5ce2cefb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -847,9 +847,6 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
847 bp->size = amdgpu_vm_bo_size(adev, level); 847 bp->size = amdgpu_vm_bo_size(adev, level);
848 bp->byte_align = AMDGPU_GPU_PAGE_SIZE; 848 bp->byte_align = AMDGPU_GPU_PAGE_SIZE;
849 bp->domain = AMDGPU_GEM_DOMAIN_VRAM; 849 bp->domain = AMDGPU_GEM_DOMAIN_VRAM;
850 if (bp->size <= PAGE_SIZE && adev->asic_type >= CHIP_VEGA10 &&
851 adev->flags & AMD_IS_APU)
852 bp->domain |= AMDGPU_GEM_DOMAIN_GTT;
853 bp->domain = amdgpu_bo_get_preferred_pin_domain(adev, bp->domain); 850 bp->domain = amdgpu_bo_get_preferred_pin_domain(adev, bp->domain);
854 bp->flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | 851 bp->flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
855 AMDGPU_GEM_CREATE_CPU_GTT_USWC; 852 AMDGPU_GEM_CREATE_CPU_GTT_USWC;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index fdace004544d..e4cc1d48eaab 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -167,19 +167,6 @@ static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
167 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 167 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
168 168
169 dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); 169 dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
170 if (crtc->primary->fb) {
171 int r;
172 struct amdgpu_bo *abo;
173
174 abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
175 r = amdgpu_bo_reserve(abo, true);
176 if (unlikely(r))
177 DRM_ERROR("failed to reserve abo before unpin\n");
178 else {
179 amdgpu_bo_unpin(abo);
180 amdgpu_bo_unreserve(abo);
181 }
182 }
183 170
184 amdgpu_crtc->pll_id = ATOM_PPLL_INVALID; 171 amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
185 amdgpu_crtc->encoder = NULL; 172 amdgpu_crtc->encoder = NULL;
@@ -692,7 +679,9 @@ static int dce_virtual_pageflip(struct amdgpu_device *adev,
692 spin_unlock_irqrestore(&adev->ddev->event_lock, flags); 679 spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
693 680
694 drm_crtc_vblank_put(&amdgpu_crtc->base); 681 drm_crtc_vblank_put(&amdgpu_crtc->base);
695 schedule_work(&works->unpin_work); 682 amdgpu_bo_unref(&works->old_abo);
683 kfree(works->shared);
684 kfree(works);
696 685
697 return 0; 686 return 0;
698} 687}
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 381f593b0cda..57cb3a51bda7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -4233,7 +4233,6 @@ static int gfx_v8_0_cp_gfx_resume(struct amdgpu_device *adev)
4233 u32 tmp; 4233 u32 tmp;
4234 u32 rb_bufsz; 4234 u32 rb_bufsz;
4235 u64 rb_addr, rptr_addr, wptr_gpu_addr; 4235 u64 rb_addr, rptr_addr, wptr_gpu_addr;
4236 int r;
4237 4236
4238 /* Set the write pointer delay */ 4237 /* Set the write pointer delay */
4239 WREG32(mmCP_RB_WPTR_DELAY, 0); 4238 WREG32(mmCP_RB_WPTR_DELAY, 0);
@@ -4278,9 +4277,8 @@ static int gfx_v8_0_cp_gfx_resume(struct amdgpu_device *adev)
4278 amdgpu_ring_clear_ring(ring); 4277 amdgpu_ring_clear_ring(ring);
4279 gfx_v8_0_cp_gfx_start(adev); 4278 gfx_v8_0_cp_gfx_start(adev);
4280 ring->sched.ready = true; 4279 ring->sched.ready = true;
4281 r = amdgpu_ring_test_helper(ring);
4282 4280
4283 return r; 4281 return 0;
4284} 4282}
4285 4283
4286static void gfx_v8_0_cp_compute_enable(struct amdgpu_device *adev, bool enable) 4284static void gfx_v8_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)
@@ -4369,10 +4367,9 @@ static int gfx_v8_0_kiq_kcq_enable(struct amdgpu_device *adev)
4369 amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr)); 4367 amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr));
4370 } 4368 }
4371 4369
4372 r = amdgpu_ring_test_helper(kiq_ring); 4370 amdgpu_ring_commit(kiq_ring);
4373 if (r) 4371
4374 DRM_ERROR("KCQ enable failed\n"); 4372 return 0;
4375 return r;
4376} 4373}
4377 4374
4378static int gfx_v8_0_deactivate_hqd(struct amdgpu_device *adev, u32 req) 4375static int gfx_v8_0_deactivate_hqd(struct amdgpu_device *adev, u32 req)
@@ -4709,16 +4706,32 @@ static int gfx_v8_0_kcq_resume(struct amdgpu_device *adev)
4709 if (r) 4706 if (r)
4710 goto done; 4707 goto done;
4711 4708
4712 /* Test KCQs - reversing the order of rings seems to fix ring test failure 4709done:
4713 * after GPU reset 4710 return r;
4714 */ 4711}
4715 for (i = adev->gfx.num_compute_rings - 1; i >= 0; i--) { 4712
4713static int gfx_v8_0_cp_test_all_rings(struct amdgpu_device *adev)
4714{
4715 int r, i;
4716 struct amdgpu_ring *ring;
4717
4718 /* collect all the ring_tests here, gfx, kiq, compute */
4719 ring = &adev->gfx.gfx_ring[0];
4720 r = amdgpu_ring_test_helper(ring);
4721 if (r)
4722 return r;
4723
4724 ring = &adev->gfx.kiq.ring;
4725 r = amdgpu_ring_test_helper(ring);
4726 if (r)
4727 return r;
4728
4729 for (i = 0; i < adev->gfx.num_compute_rings; i++) {
4716 ring = &adev->gfx.compute_ring[i]; 4730 ring = &adev->gfx.compute_ring[i];
4717 r = amdgpu_ring_test_helper(ring); 4731 amdgpu_ring_test_helper(ring);
4718 } 4732 }
4719 4733
4720done: 4734 return 0;
4721 return r;
4722} 4735}
4723 4736
4724static int gfx_v8_0_cp_resume(struct amdgpu_device *adev) 4737static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)
@@ -4739,6 +4752,11 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)
4739 r = gfx_v8_0_kcq_resume(adev); 4752 r = gfx_v8_0_kcq_resume(adev);
4740 if (r) 4753 if (r)
4741 return r; 4754 return r;
4755
4756 r = gfx_v8_0_cp_test_all_rings(adev);
4757 if (r)
4758 return r;
4759
4742 gfx_v8_0_enable_gui_idle_interrupt(adev, true); 4760 gfx_v8_0_enable_gui_idle_interrupt(adev, true);
4743 4761
4744 return 0; 4762 return 0;
@@ -5086,6 +5104,8 @@ static int gfx_v8_0_post_soft_reset(void *handle)
5086 REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET, SOFT_RESET_GFX)) 5104 REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET, SOFT_RESET_GFX))
5087 gfx_v8_0_cp_gfx_resume(adev); 5105 gfx_v8_0_cp_gfx_resume(adev);
5088 5106
5107 gfx_v8_0_cp_test_all_rings(adev);
5108
5089 adev->gfx.rlc.funcs->start(adev); 5109 adev->gfx.rlc.funcs->start(adev);
5090 5110
5091 return 0; 5111 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 7556716038d3..fbca0494f871 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -113,7 +113,10 @@ static const struct soc15_reg_golden golden_settings_gc_9_0[] =
113 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68), 113 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68),
114 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197), 114 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197),
115 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), 115 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000),
116 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff) 116 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff),
117 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
118 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
119 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
117}; 120};
118 121
119static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = 122static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
@@ -135,10 +138,7 @@ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
135 SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), 138 SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000),
136 SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), 139 SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107),
137 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800), 140 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800),
138 SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080), 141 SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080)
139 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
140 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
141 SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
142}; 142};
143 143
144static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] = 144static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] =
@@ -3587,6 +3587,8 @@ static void gfx_v9_0_update_medium_grain_clock_gating(struct amdgpu_device *adev
3587{ 3587{
3588 uint32_t data, def; 3588 uint32_t data, def;
3589 3589
3590 amdgpu_gfx_rlc_enter_safe_mode(adev);
3591
3590 /* It is disabled by HW by default */ 3592 /* It is disabled by HW by default */
3591 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) { 3593 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) {
3592 /* 1 - RLC_CGTT_MGCG_OVERRIDE */ 3594 /* 1 - RLC_CGTT_MGCG_OVERRIDE */
@@ -3651,6 +3653,8 @@ static void gfx_v9_0_update_medium_grain_clock_gating(struct amdgpu_device *adev
3651 WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data); 3653 WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data);
3652 } 3654 }
3653 } 3655 }
3656
3657 amdgpu_gfx_rlc_exit_safe_mode(adev);
3654} 3658}
3655 3659
3656static void gfx_v9_0_update_3d_clock_gating(struct amdgpu_device *adev, 3660static void gfx_v9_0_update_3d_clock_gating(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index 8cbb4655896a..b11a1c17a7f2 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -174,7 +174,7 @@ static int xgpu_ai_send_access_requests(struct amdgpu_device *adev,
174 return r; 174 return r;
175 } 175 }
176 /* Retrieve checksum from mailbox2 */ 176 /* Retrieve checksum from mailbox2 */
177 if (req == IDH_REQ_GPU_INIT_ACCESS) { 177 if (req == IDH_REQ_GPU_INIT_ACCESS || req == IDH_REQ_GPU_RESET_ACCESS) {
178 adev->virt.fw_reserve.checksum_key = 178 adev->virt.fw_reserve.checksum_key =
179 RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, 179 RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0,
180 mmBIF_BX_PF0_MAILBOX_MSGBUF_RCV_DW2)); 180 mmBIF_BX_PF0_MAILBOX_MSGBUF_RCV_DW2));
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index fd0bfe140ee0..6811a5d05b27 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -78,7 +78,6 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = {
78 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), 78 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000),
79 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), 79 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0),
80 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000), 80 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000),
81 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831f07),
82 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100), 81 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100),
83 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100), 82 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100),
84 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), 83 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000),
@@ -96,6 +95,7 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = {
96static const struct soc15_reg_golden golden_settings_sdma_vg10[] = { 95static const struct soc15_reg_golden golden_settings_sdma_vg10[] = {
97 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104002), 96 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104002),
98 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002), 97 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002),
98 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831d07),
99 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104002), 99 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104002),
100 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002) 100 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002)
101}; 101};
@@ -103,6 +103,7 @@ static const struct soc15_reg_golden golden_settings_sdma_vg10[] = {
103static const struct soc15_reg_golden golden_settings_sdma_vg12[] = { 103static const struct soc15_reg_golden golden_settings_sdma_vg12[] = {
104 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104001), 104 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104001),
105 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001), 105 SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001),
106 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831d07),
106 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104001), 107 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104001),
107 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001) 108 SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001)
108}; 109};
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a9a28dbc3e24..34f35e9a3c46 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -699,22 +699,36 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
699{ 699{
700 struct amdgpu_dm_connector *aconnector; 700 struct amdgpu_dm_connector *aconnector;
701 struct drm_connector *connector; 701 struct drm_connector *connector;
702 struct drm_dp_mst_topology_mgr *mgr;
703 int ret;
704 bool need_hotplug = false;
702 705
703 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); 706 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
704 707
705 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 708 list_for_each_entry(connector, &dev->mode_config.connector_list,
706 aconnector = to_amdgpu_dm_connector(connector); 709 head) {
707 if (aconnector->dc_link->type == dc_connection_mst_branch && 710 aconnector = to_amdgpu_dm_connector(connector);
708 !aconnector->mst_port) { 711 if (aconnector->dc_link->type != dc_connection_mst_branch ||
712 aconnector->mst_port)
713 continue;
709 714
710 if (suspend) 715 mgr = &aconnector->mst_mgr;
711 drm_dp_mst_topology_mgr_suspend(&aconnector->mst_mgr); 716
712 else 717 if (suspend) {
713 drm_dp_mst_topology_mgr_resume(&aconnector->mst_mgr); 718 drm_dp_mst_topology_mgr_suspend(mgr);
714 } 719 } else {
720 ret = drm_dp_mst_topology_mgr_resume(mgr);
721 if (ret < 0) {
722 drm_dp_mst_topology_mgr_set_mst(mgr, false);
723 need_hotplug = true;
724 }
725 }
715 } 726 }
716 727
717 drm_modeset_unlock(&dev->mode_config.connection_mutex); 728 drm_modeset_unlock(&dev->mode_config.connection_mutex);
729
730 if (need_hotplug)
731 drm_kms_helper_hotplug_event(dev);
718} 732}
719 733
720/** 734/**
@@ -898,7 +912,6 @@ static int dm_resume(void *handle)
898 struct drm_plane_state *new_plane_state; 912 struct drm_plane_state *new_plane_state;
899 struct dm_plane_state *dm_new_plane_state; 913 struct dm_plane_state *dm_new_plane_state;
900 enum dc_connection_type new_connection_type = dc_connection_none; 914 enum dc_connection_type new_connection_type = dc_connection_none;
901 int ret;
902 int i; 915 int i;
903 916
904 /* power on hardware */ 917 /* power on hardware */
@@ -971,13 +984,13 @@ static int dm_resume(void *handle)
971 } 984 }
972 } 985 }
973 986
974 ret = drm_atomic_helper_resume(ddev, dm->cached_state); 987 drm_atomic_helper_resume(ddev, dm->cached_state);
975 988
976 dm->cached_state = NULL; 989 dm->cached_state = NULL;
977 990
978 amdgpu_dm_irq_resume_late(adev); 991 amdgpu_dm_irq_resume_late(adev);
979 992
980 return ret; 993 return 0;
981} 994}
982 995
983/** 996/**
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 1479ea1dc3e7..789c4f288485 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -127,12 +127,13 @@ enum amd_pp_task {
127}; 127};
128 128
129enum PP_SMC_POWER_PROFILE { 129enum PP_SMC_POWER_PROFILE {
130 PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x0, 130 PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT = 0x0,
131 PP_SMC_POWER_PROFILE_POWERSAVING = 0x1, 131 PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x1,
132 PP_SMC_POWER_PROFILE_VIDEO = 0x2, 132 PP_SMC_POWER_PROFILE_POWERSAVING = 0x2,
133 PP_SMC_POWER_PROFILE_VR = 0x3, 133 PP_SMC_POWER_PROFILE_VIDEO = 0x3,
134 PP_SMC_POWER_PROFILE_COMPUTE = 0x4, 134 PP_SMC_POWER_PROFILE_VR = 0x4,
135 PP_SMC_POWER_PROFILE_CUSTOM = 0x5, 135 PP_SMC_POWER_PROFILE_COMPUTE = 0x5,
136 PP_SMC_POWER_PROFILE_CUSTOM = 0x6,
136}; 137};
137 138
138enum { 139enum {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 0173d0480024..310b102a9292 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -64,17 +64,19 @@ static int ci_set_asic_special_caps(struct pp_hwmgr *hwmgr);
64 64
65static void hwmgr_init_workload_prority(struct pp_hwmgr *hwmgr) 65static void hwmgr_init_workload_prority(struct pp_hwmgr *hwmgr)
66{ 66{
67 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D] = 2; 67 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;
68 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_POWERSAVING] = 0; 68 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D] = 1;
69 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VIDEO] = 1; 69 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_POWERSAVING] = 2;
70 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VR] = 3; 70 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VIDEO] = 3;
71 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE] = 4; 71 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VR] = 4;
72 72 hwmgr->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE] = 5;
73 hwmgr->workload_setting[0] = PP_SMC_POWER_PROFILE_POWERSAVING; 73
74 hwmgr->workload_setting[1] = PP_SMC_POWER_PROFILE_VIDEO; 74 hwmgr->workload_setting[0] = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
75 hwmgr->workload_setting[2] = PP_SMC_POWER_PROFILE_FULLSCREEN3D; 75 hwmgr->workload_setting[1] = PP_SMC_POWER_PROFILE_FULLSCREEN3D;
76 hwmgr->workload_setting[3] = PP_SMC_POWER_PROFILE_VR; 76 hwmgr->workload_setting[2] = PP_SMC_POWER_PROFILE_POWERSAVING;
77 hwmgr->workload_setting[4] = PP_SMC_POWER_PROFILE_COMPUTE; 77 hwmgr->workload_setting[3] = PP_SMC_POWER_PROFILE_VIDEO;
78 hwmgr->workload_setting[4] = PP_SMC_POWER_PROFILE_VR;
79 hwmgr->workload_setting[5] = PP_SMC_POWER_PROFILE_COMPUTE;
78} 80}
79 81
80int hwmgr_early_init(struct pp_hwmgr *hwmgr) 82int hwmgr_early_init(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index d91390459326..c8f5c00dd1e7 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -77,8 +77,9 @@
77#define PCIE_BUS_CLK 10000 77#define PCIE_BUS_CLK 10000
78#define TCLK (PCIE_BUS_CLK / 10) 78#define TCLK (PCIE_BUS_CLK / 10)
79 79
80static const struct profile_mode_setting smu7_profiling[6] = 80static const struct profile_mode_setting smu7_profiling[7] =
81 {{1, 0, 100, 30, 1, 0, 100, 10}, 81 {{0, 0, 0, 0, 0, 0, 0, 0},
82 {1, 0, 100, 30, 1, 0, 100, 10},
82 {1, 10, 0, 30, 0, 0, 0, 0}, 83 {1, 10, 0, 30, 0, 0, 0, 0},
83 {0, 0, 0, 0, 1, 10, 16, 31}, 84 {0, 0, 0, 0, 1, 10, 16, 31},
84 {1, 0, 11, 50, 1, 0, 100, 10}, 85 {1, 0, 11, 50, 1, 0, 100, 10},
@@ -4889,7 +4890,8 @@ static int smu7_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
4889 uint32_t i, size = 0; 4890 uint32_t i, size = 0;
4890 uint32_t len; 4891 uint32_t len;
4891 4892
4892 static const char *profile_name[6] = {"3D_FULL_SCREEN", 4893 static const char *profile_name[7] = {"BOOTUP_DEFAULT",
4894 "3D_FULL_SCREEN",
4893 "POWER_SAVING", 4895 "POWER_SAVING",
4894 "VIDEO", 4896 "VIDEO",
4895 "VR", 4897 "VR",
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index 79c86247d0ac..91e3bbe6d61d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -804,9 +804,9 @@ static int vega10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
804 804
805 hwmgr->backend = data; 805 hwmgr->backend = data;
806 806
807 hwmgr->workload_mask = 1 << hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VIDEO]; 807 hwmgr->workload_mask = 1 << hwmgr->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
808 hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO; 808 hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
809 hwmgr->default_power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO; 809 hwmgr->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
810 810
811 vega10_set_default_registry_data(hwmgr); 811 vega10_set_default_registry_data(hwmgr);
812 data->disable_dpm_mask = 0xff; 812 data->disable_dpm_mask = 0xff;
@@ -4668,13 +4668,15 @@ static int vega10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
4668{ 4668{
4669 struct vega10_hwmgr *data = hwmgr->backend; 4669 struct vega10_hwmgr *data = hwmgr->backend;
4670 uint32_t i, size = 0; 4670 uint32_t i, size = 0;
4671 static const uint8_t profile_mode_setting[5][4] = {{70, 60, 1, 3,}, 4671 static const uint8_t profile_mode_setting[6][4] = {{70, 60, 0, 0,},
4672 {70, 60, 1, 3,},
4672 {90, 60, 0, 0,}, 4673 {90, 60, 0, 0,},
4673 {70, 60, 0, 0,}, 4674 {70, 60, 0, 0,},
4674 {70, 90, 0, 0,}, 4675 {70, 90, 0, 0,},
4675 {30, 60, 0, 6,}, 4676 {30, 60, 0, 6,},
4676 }; 4677 };
4677 static const char *profile_name[6] = {"3D_FULL_SCREEN", 4678 static const char *profile_name[7] = {"BOOTUP_DEFAULT",
4679 "3D_FULL_SCREEN",
4678 "POWER_SAVING", 4680 "POWER_SAVING",
4679 "VIDEO", 4681 "VIDEO",
4680 "VR", 4682 "VR",
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
index 26154f9b2178..82935a3bd950 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
@@ -390,9 +390,9 @@ static int vega20_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
390 390
391 hwmgr->backend = data; 391 hwmgr->backend = data;
392 392
393 hwmgr->workload_mask = 1 << hwmgr->workload_prority[PP_SMC_POWER_PROFILE_VIDEO]; 393 hwmgr->workload_mask = 1 << hwmgr->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
394 hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO; 394 hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
395 hwmgr->default_power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO; 395 hwmgr->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
396 396
397 vega20_set_default_registry_data(hwmgr); 397 vega20_set_default_registry_data(hwmgr);
398 398
@@ -980,6 +980,9 @@ static int vega20_od8_set_feature_capabilities(
980 pp_table->FanZeroRpmEnable) 980 pp_table->FanZeroRpmEnable)
981 od_settings->overdrive8_capabilities |= OD8_FAN_ZERO_RPM_CONTROL; 981 od_settings->overdrive8_capabilities |= OD8_FAN_ZERO_RPM_CONTROL;
982 982
983 if (!od_settings->overdrive8_capabilities)
984 hwmgr->od_enabled = false;
985
983 return 0; 986 return 0;
984} 987}
985 988
@@ -1689,13 +1692,6 @@ static int vega20_upload_dpm_min_level(struct pp_hwmgr *hwmgr, uint32_t feature_
1689 (PPCLK_UCLK << 16) | (min_freq & 0xffff))), 1692 (PPCLK_UCLK << 16) | (min_freq & 0xffff))),
1690 "Failed to set soft min memclk !", 1693 "Failed to set soft min memclk !",
1691 return ret); 1694 return ret);
1692
1693 min_freq = data->dpm_table.mem_table.dpm_state.hard_min_level;
1694 PP_ASSERT_WITH_CODE(!(ret = smum_send_msg_to_smc_with_parameter(
1695 hwmgr, PPSMC_MSG_SetHardMinByFreq,
1696 (PPCLK_UCLK << 16) | (min_freq & 0xffff))),
1697 "Failed to set hard min memclk !",
1698 return ret);
1699 } 1695 }
1700 1696
1701 if (data->smu_features[GNLD_DPM_UVD].enabled && 1697 if (data->smu_features[GNLD_DPM_UVD].enabled &&
@@ -2248,6 +2244,13 @@ static int vega20_force_clock_level(struct pp_hwmgr *hwmgr,
2248 soft_min_level = mask ? (ffs(mask) - 1) : 0; 2244 soft_min_level = mask ? (ffs(mask) - 1) : 0;
2249 soft_max_level = mask ? (fls(mask) - 1) : 0; 2245 soft_max_level = mask ? (fls(mask) - 1) : 0;
2250 2246
2247 if (soft_max_level >= data->dpm_table.gfx_table.count) {
2248 pr_err("Clock level specified %d is over max allowed %d\n",
2249 soft_max_level,
2250 data->dpm_table.gfx_table.count - 1);
2251 return -EINVAL;
2252 }
2253
2251 data->dpm_table.gfx_table.dpm_state.soft_min_level = 2254 data->dpm_table.gfx_table.dpm_state.soft_min_level =
2252 data->dpm_table.gfx_table.dpm_levels[soft_min_level].value; 2255 data->dpm_table.gfx_table.dpm_levels[soft_min_level].value;
2253 data->dpm_table.gfx_table.dpm_state.soft_max_level = 2256 data->dpm_table.gfx_table.dpm_state.soft_max_level =
@@ -2268,6 +2271,13 @@ static int vega20_force_clock_level(struct pp_hwmgr *hwmgr,
2268 soft_min_level = mask ? (ffs(mask) - 1) : 0; 2271 soft_min_level = mask ? (ffs(mask) - 1) : 0;
2269 soft_max_level = mask ? (fls(mask) - 1) : 0; 2272 soft_max_level = mask ? (fls(mask) - 1) : 0;
2270 2273
2274 if (soft_max_level >= data->dpm_table.mem_table.count) {
2275 pr_err("Clock level specified %d is over max allowed %d\n",
2276 soft_max_level,
2277 data->dpm_table.mem_table.count - 1);
2278 return -EINVAL;
2279 }
2280
2271 data->dpm_table.mem_table.dpm_state.soft_min_level = 2281 data->dpm_table.mem_table.dpm_state.soft_min_level =
2272 data->dpm_table.mem_table.dpm_levels[soft_min_level].value; 2282 data->dpm_table.mem_table.dpm_levels[soft_min_level].value;
2273 data->dpm_table.mem_table.dpm_state.soft_max_level = 2283 data->dpm_table.mem_table.dpm_state.soft_max_level =
@@ -3261,6 +3271,9 @@ static int conv_power_profile_to_pplib_workload(int power_profile)
3261 int pplib_workload = 0; 3271 int pplib_workload = 0;
3262 3272
3263 switch (power_profile) { 3273 switch (power_profile) {
3274 case PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT:
3275 pplib_workload = WORKLOAD_DEFAULT_BIT;
3276 break;
3264 case PP_SMC_POWER_PROFILE_FULLSCREEN3D: 3277 case PP_SMC_POWER_PROFILE_FULLSCREEN3D:
3265 pplib_workload = WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT; 3278 pplib_workload = WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT;
3266 break; 3279 break;
@@ -3290,6 +3303,7 @@ static int vega20_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
3290 uint32_t i, size = 0; 3303 uint32_t i, size = 0;
3291 uint16_t workload_type = 0; 3304 uint16_t workload_type = 0;
3292 static const char *profile_name[] = { 3305 static const char *profile_name[] = {
3306 "BOOTUP_DEFAULT",
3293 "3D_FULL_SCREEN", 3307 "3D_FULL_SCREEN",
3294 "POWER_SAVING", 3308 "POWER_SAVING",
3295 "VIDEO", 3309 "VIDEO",
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 0d298a0409f5..8cb831b6a016 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -705,7 +705,7 @@ enum PP_TABLE_VERSION {
705/** 705/**
706 * The main hardware manager structure. 706 * The main hardware manager structure.
707 */ 707 */
708#define Workload_Policy_Max 5 708#define Workload_Policy_Max 6
709 709
710struct pp_hwmgr { 710struct pp_hwmgr {
711 void *adev; 711 void *adev;
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 8e28e738cb52..e6403b9549f1 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -98,6 +98,8 @@
98#define DP0_STARTVAL 0x064c 98#define DP0_STARTVAL 0x064c
99#define DP0_ACTIVEVAL 0x0650 99#define DP0_ACTIVEVAL 0x0650
100#define DP0_SYNCVAL 0x0654 100#define DP0_SYNCVAL 0x0654
101#define SYNCVAL_HS_POL_ACTIVE_LOW (1 << 15)
102#define SYNCVAL_VS_POL_ACTIVE_LOW (1 << 31)
101#define DP0_MISC 0x0658 103#define DP0_MISC 0x0658
102#define TU_SIZE_RECOMMENDED (63) /* LSCLK cycles per TU */ 104#define TU_SIZE_RECOMMENDED (63) /* LSCLK cycles per TU */
103#define BPC_6 (0 << 5) 105#define BPC_6 (0 << 5)
@@ -142,6 +144,8 @@
142#define DP0_LTLOOPCTRL 0x06d8 144#define DP0_LTLOOPCTRL 0x06d8
143#define DP0_SNKLTCTRL 0x06e4 145#define DP0_SNKLTCTRL 0x06e4
144 146
147#define DP1_SRCCTRL 0x07a0
148
145/* PHY */ 149/* PHY */
146#define DP_PHY_CTRL 0x0800 150#define DP_PHY_CTRL 0x0800
147#define DP_PHY_RST BIT(28) /* DP PHY Global Soft Reset */ 151#define DP_PHY_RST BIT(28) /* DP PHY Global Soft Reset */
@@ -150,6 +154,7 @@
150#define PHY_M1_RST BIT(12) /* Reset PHY1 Main Channel */ 154#define PHY_M1_RST BIT(12) /* Reset PHY1 Main Channel */
151#define PHY_RDY BIT(16) /* PHY Main Channels Ready */ 155#define PHY_RDY BIT(16) /* PHY Main Channels Ready */
152#define PHY_M0_RST BIT(8) /* Reset PHY0 Main Channel */ 156#define PHY_M0_RST BIT(8) /* Reset PHY0 Main Channel */
157#define PHY_2LANE BIT(2) /* PHY Enable 2 lanes */
153#define PHY_A0_EN BIT(1) /* PHY Aux Channel0 Enable */ 158#define PHY_A0_EN BIT(1) /* PHY Aux Channel0 Enable */
154#define PHY_M0_EN BIT(0) /* PHY Main Channel0 Enable */ 159#define PHY_M0_EN BIT(0) /* PHY Main Channel0 Enable */
155 160
@@ -540,6 +545,7 @@ static int tc_aux_link_setup(struct tc_data *tc)
540 unsigned long rate; 545 unsigned long rate;
541 u32 value; 546 u32 value;
542 int ret; 547 int ret;
548 u32 dp_phy_ctrl;
543 549
544 rate = clk_get_rate(tc->refclk); 550 rate = clk_get_rate(tc->refclk);
545 switch (rate) { 551 switch (rate) {
@@ -564,7 +570,10 @@ static int tc_aux_link_setup(struct tc_data *tc)
564 value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2; 570 value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2;
565 tc_write(SYS_PLLPARAM, value); 571 tc_write(SYS_PLLPARAM, value);
566 572
567 tc_write(DP_PHY_CTRL, BGREN | PWR_SW_EN | BIT(2) | PHY_A0_EN); 573 dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN;
574 if (tc->link.base.num_lanes == 2)
575 dp_phy_ctrl |= PHY_2LANE;
576 tc_write(DP_PHY_CTRL, dp_phy_ctrl);
568 577
569 /* 578 /*
570 * Initially PLLs are in bypass. Force PLL parameter update, 579 * Initially PLLs are in bypass. Force PLL parameter update,
@@ -719,7 +728,9 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode)
719 728
720 tc_write(DP0_ACTIVEVAL, (mode->vdisplay << 16) | (mode->hdisplay)); 729 tc_write(DP0_ACTIVEVAL, (mode->vdisplay << 16) | (mode->hdisplay));
721 730
722 tc_write(DP0_SYNCVAL, (vsync_len << 16) | (hsync_len << 0)); 731 tc_write(DP0_SYNCVAL, (vsync_len << 16) | (hsync_len << 0) |
732 ((mode->flags & DRM_MODE_FLAG_NHSYNC) ? SYNCVAL_HS_POL_ACTIVE_LOW : 0) |
733 ((mode->flags & DRM_MODE_FLAG_NVSYNC) ? SYNCVAL_VS_POL_ACTIVE_LOW : 0));
723 734
724 tc_write(DPIPXLFMT, VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW | 735 tc_write(DPIPXLFMT, VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW |
725 DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | DPI_BPP_RGB888); 736 DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | DPI_BPP_RGB888);
@@ -829,12 +840,11 @@ static int tc_main_link_setup(struct tc_data *tc)
829 if (!tc->mode) 840 if (!tc->mode)
830 return -EINVAL; 841 return -EINVAL;
831 842
832 /* from excel file - DP0_SrcCtrl */ 843 tc_write(DP0_SRCCTRL, tc_srcctrl(tc));
833 tc_write(DP0_SRCCTRL, DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_EN810B | 844 /* SSCG and BW27 on DP1 must be set to the same as on DP0 */
834 DP0_SRCCTRL_LANESKEW | DP0_SRCCTRL_LANES_2 | 845 tc_write(DP1_SRCCTRL,
835 DP0_SRCCTRL_BW27 | DP0_SRCCTRL_AUTOCORRECT); 846 (tc->link.spread ? DP0_SRCCTRL_SSCG : 0) |
836 /* from excel file - DP1_SrcCtrl */ 847 ((tc->link.base.rate != 162000) ? DP0_SRCCTRL_BW27 : 0));
837 tc_write(0x07a0, 0x00003083);
838 848
839 rate = clk_get_rate(tc->refclk); 849 rate = clk_get_rate(tc->refclk);
840 switch (rate) { 850 switch (rate) {
@@ -855,8 +865,11 @@ static int tc_main_link_setup(struct tc_data *tc)
855 } 865 }
856 value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2; 866 value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2;
857 tc_write(SYS_PLLPARAM, value); 867 tc_write(SYS_PLLPARAM, value);
868
858 /* Setup Main Link */ 869 /* Setup Main Link */
859 dp_phy_ctrl = BGREN | PWR_SW_EN | BIT(2) | PHY_A0_EN | PHY_M0_EN; 870 dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN | PHY_M0_EN;
871 if (tc->link.base.num_lanes == 2)
872 dp_phy_ctrl |= PHY_2LANE;
860 tc_write(DP_PHY_CTRL, dp_phy_ctrl); 873 tc_write(DP_PHY_CTRL, dp_phy_ctrl);
861 msleep(100); 874 msleep(100);
862 875
@@ -1105,10 +1118,20 @@ static bool tc_bridge_mode_fixup(struct drm_bridge *bridge,
1105static enum drm_mode_status tc_connector_mode_valid(struct drm_connector *connector, 1118static enum drm_mode_status tc_connector_mode_valid(struct drm_connector *connector,
1106 struct drm_display_mode *mode) 1119 struct drm_display_mode *mode)
1107{ 1120{
1121 struct tc_data *tc = connector_to_tc(connector);
1122 u32 req, avail;
1123 u32 bits_per_pixel = 24;
1124
1108 /* DPI interface clock limitation: upto 154 MHz */ 1125 /* DPI interface clock limitation: upto 154 MHz */
1109 if (mode->clock > 154000) 1126 if (mode->clock > 154000)
1110 return MODE_CLOCK_HIGH; 1127 return MODE_CLOCK_HIGH;
1111 1128
1129 req = mode->clock * bits_per_pixel / 8;
1130 avail = tc->link.base.num_lanes * tc->link.base.rate;
1131
1132 if (req > avail)
1133 return MODE_BAD;
1134
1112 return MODE_OK; 1135 return MODE_OK;
1113} 1136}
1114 1137
@@ -1186,7 +1209,8 @@ static int tc_bridge_attach(struct drm_bridge *bridge)
1186 /* Create eDP connector */ 1209 /* Create eDP connector */
1187 drm_connector_helper_add(&tc->connector, &tc_connector_helper_funcs); 1210 drm_connector_helper_add(&tc->connector, &tc_connector_helper_funcs);
1188 ret = drm_connector_init(drm, &tc->connector, &tc_connector_funcs, 1211 ret = drm_connector_init(drm, &tc->connector, &tc_connector_funcs,
1189 DRM_MODE_CONNECTOR_eDP); 1212 tc->panel ? DRM_MODE_CONNECTOR_eDP :
1213 DRM_MODE_CONNECTOR_DisplayPort);
1190 if (ret) 1214 if (ret)
1191 return ret; 1215 return ret;
1192 1216
@@ -1195,6 +1219,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge)
1195 1219
1196 drm_display_info_set_bus_formats(&tc->connector.display_info, 1220 drm_display_info_set_bus_formats(&tc->connector.display_info,
1197 &bus_format, 1); 1221 &bus_format, 1);
1222 tc->connector.display_info.bus_flags =
1223 DRM_BUS_FLAG_DE_HIGH |
1224 DRM_BUS_FLAG_PIXDATA_NEGEDGE |
1225 DRM_BUS_FLAG_SYNC_NEGEDGE;
1198 drm_connector_attach_encoder(&tc->connector, tc->bridge.encoder); 1226 drm_connector_attach_encoder(&tc->connector, tc->bridge.encoder);
1199 1227
1200 return 0; 1228 return 0;
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index c40889888a16..9a1f41adfc67 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1296,12 +1296,11 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
1296 (arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) 1296 (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
1297 return -EINVAL; 1297 return -EINVAL;
1298 1298
1299 drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
1300
1301 state = drm_atomic_state_alloc(dev); 1299 state = drm_atomic_state_alloc(dev);
1302 if (!state) 1300 if (!state)
1303 return -ENOMEM; 1301 return -ENOMEM;
1304 1302
1303 drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
1305 state->acquire_ctx = &ctx; 1304 state->acquire_ctx = &ctx;
1306 state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); 1305 state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
1307 1306
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 2d6c491a0542..516e82d0ed50 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -1273,6 +1273,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
1273 { OUI(0x00, 0x22, 0xb9), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_CONSTANT_N) }, 1273 { OUI(0x00, 0x22, 0xb9), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_CONSTANT_N) },
1274 /* LG LP140WF6-SPM1 eDP panel */ 1274 /* LG LP140WF6-SPM1 eDP panel */
1275 { OUI(0x00, 0x22, 0xb9), DEVICE_ID('s', 'i', 'v', 'a', 'r', 'T'), false, BIT(DP_DPCD_QUIRK_CONSTANT_N) }, 1275 { OUI(0x00, 0x22, 0xb9), DEVICE_ID('s', 'i', 'v', 'a', 'r', 'T'), false, BIT(DP_DPCD_QUIRK_CONSTANT_N) },
1276 /* Apple panels need some additional handling to support PSR */
1277 { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) }
1276}; 1278};
1277 1279
1278#undef OUI 1280#undef OUI
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index d3af098b0922..d73703a695e8 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1621,6 +1621,64 @@ static bool drm_fb_pixel_format_equal(const struct fb_var_screeninfo *var_1,
1621 var_1->transp.msb_right == var_2->transp.msb_right; 1621 var_1->transp.msb_right == var_2->transp.msb_right;
1622} 1622}
1623 1623
1624static void drm_fb_helper_fill_pixel_fmt(struct fb_var_screeninfo *var,
1625 u8 depth)
1626{
1627 switch (depth) {
1628 case 8:
1629 var->red.offset = 0;
1630 var->green.offset = 0;
1631 var->blue.offset = 0;
1632 var->red.length = 8; /* 8bit DAC */
1633 var->green.length = 8;
1634 var->blue.length = 8;
1635 var->transp.offset = 0;
1636 var->transp.length = 0;
1637 break;
1638 case 15:
1639 var->red.offset = 10;
1640 var->green.offset = 5;
1641 var->blue.offset = 0;
1642 var->red.length = 5;
1643 var->green.length = 5;
1644 var->blue.length = 5;
1645 var->transp.offset = 15;
1646 var->transp.length = 1;
1647 break;
1648 case 16:
1649 var->red.offset = 11;
1650 var->green.offset = 5;
1651 var->blue.offset = 0;
1652 var->red.length = 5;
1653 var->green.length = 6;
1654 var->blue.length = 5;
1655 var->transp.offset = 0;
1656 break;
1657 case 24:
1658 var->red.offset = 16;
1659 var->green.offset = 8;
1660 var->blue.offset = 0;
1661 var->red.length = 8;
1662 var->green.length = 8;
1663 var->blue.length = 8;
1664 var->transp.offset = 0;
1665 var->transp.length = 0;
1666 break;
1667 case 32:
1668 var->red.offset = 16;
1669 var->green.offset = 8;
1670 var->blue.offset = 0;
1671 var->red.length = 8;
1672 var->green.length = 8;
1673 var->blue.length = 8;
1674 var->transp.offset = 24;
1675 var->transp.length = 8;
1676 break;
1677 default:
1678 break;
1679 }
1680}
1681
1624/** 1682/**
1625 * drm_fb_helper_check_var - implementation for &fb_ops.fb_check_var 1683 * drm_fb_helper_check_var - implementation for &fb_ops.fb_check_var
1626 * @var: screeninfo to check 1684 * @var: screeninfo to check
@@ -1632,9 +1690,14 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
1632 struct drm_fb_helper *fb_helper = info->par; 1690 struct drm_fb_helper *fb_helper = info->par;
1633 struct drm_framebuffer *fb = fb_helper->fb; 1691 struct drm_framebuffer *fb = fb_helper->fb;
1634 1692
1635 if (var->pixclock != 0 || in_dbg_master()) 1693 if (in_dbg_master())
1636 return -EINVAL; 1694 return -EINVAL;
1637 1695
1696 if (var->pixclock != 0) {
1697 DRM_DEBUG("fbdev emulation doesn't support changing the pixel clock, value of pixclock is ignored\n");
1698 var->pixclock = 0;
1699 }
1700
1638 if ((drm_format_info_block_width(fb->format, 0) > 1) || 1701 if ((drm_format_info_block_width(fb->format, 0) > 1) ||
1639 (drm_format_info_block_height(fb->format, 0) > 1)) 1702 (drm_format_info_block_height(fb->format, 0) > 1))
1640 return -EINVAL; 1703 return -EINVAL;
@@ -1655,6 +1718,20 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
1655 } 1718 }
1656 1719
1657 /* 1720 /*
1721 * Workaround for SDL 1.2, which is known to be setting all pixel format
1722 * fields values to zero in some cases. We treat this situation as a
1723 * kind of "use some reasonable autodetected values".
1724 */
1725 if (!var->red.offset && !var->green.offset &&
1726 !var->blue.offset && !var->transp.offset &&
1727 !var->red.length && !var->green.length &&
1728 !var->blue.length && !var->transp.length &&
1729 !var->red.msb_right && !var->green.msb_right &&
1730 !var->blue.msb_right && !var->transp.msb_right) {
1731 drm_fb_helper_fill_pixel_fmt(var, fb->format->depth);
1732 }
1733
1734 /*
1658 * drm fbdev emulation doesn't support changing the pixel format at all, 1735 * drm fbdev emulation doesn't support changing the pixel format at all,
1659 * so reject all pixel format changing requests. 1736 * so reject all pixel format changing requests.
1660 */ 1737 */
@@ -1967,59 +2044,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe
1967 info->var.yoffset = 0; 2044 info->var.yoffset = 0;
1968 info->var.activate = FB_ACTIVATE_NOW; 2045 info->var.activate = FB_ACTIVATE_NOW;
1969 2046
1970 switch (fb->format->depth) { 2047 drm_fb_helper_fill_pixel_fmt(&info->var, fb->format->depth);
1971 case 8:
1972 info->var.red.offset = 0;
1973 info->var.green.offset = 0;
1974 info->var.blue.offset = 0;
1975 info->var.red.length = 8; /* 8bit DAC */
1976 info->var.green.length = 8;
1977 info->var.blue.length = 8;
1978 info->var.transp.offset = 0;
1979 info->var.transp.length = 0;
1980 break;
1981 case 15:
1982 info->var.red.offset = 10;
1983 info->var.green.offset = 5;
1984 info->var.blue.offset = 0;
1985 info->var.red.length = 5;
1986 info->var.green.length = 5;
1987 info->var.blue.length = 5;
1988 info->var.transp.offset = 15;
1989 info->var.transp.length = 1;
1990 break;
1991 case 16:
1992 info->var.red.offset = 11;
1993 info->var.green.offset = 5;
1994 info->var.blue.offset = 0;
1995 info->var.red.length = 5;
1996 info->var.green.length = 6;
1997 info->var.blue.length = 5;
1998 info->var.transp.offset = 0;
1999 break;
2000 case 24:
2001 info->var.red.offset = 16;
2002 info->var.green.offset = 8;
2003 info->var.blue.offset = 0;
2004 info->var.red.length = 8;
2005 info->var.green.length = 8;
2006 info->var.blue.length = 8;
2007 info->var.transp.offset = 0;
2008 info->var.transp.length = 0;
2009 break;
2010 case 32:
2011 info->var.red.offset = 16;
2012 info->var.green.offset = 8;
2013 info->var.blue.offset = 0;
2014 info->var.red.length = 8;
2015 info->var.green.length = 8;
2016 info->var.blue.length = 8;
2017 info->var.transp.offset = 24;
2018 info->var.transp.length = 8;
2019 break;
2020 default:
2021 break;
2022 }
2023 2048
2024 info->var.xres = fb_width; 2049 info->var.xres = fb_width;
2025 info->var.yres = fb_height; 2050 info->var.yres = fb_height;
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index cd9bc0ce9be0..004191d01772 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -459,11 +459,11 @@ static int set_property_atomic(struct drm_mode_object *obj,
459 struct drm_modeset_acquire_ctx ctx; 459 struct drm_modeset_acquire_ctx ctx;
460 int ret; 460 int ret;
461 461
462 drm_modeset_acquire_init(&ctx, 0);
463
464 state = drm_atomic_state_alloc(dev); 462 state = drm_atomic_state_alloc(dev);
465 if (!state) 463 if (!state)
466 return -ENOMEM; 464 return -ENOMEM;
465
466 drm_modeset_acquire_init(&ctx, 0);
467 state->acquire_ctx = &ctx; 467 state->acquire_ctx = &ctx;
468retry: 468retry:
469 if (prop == state->dev->mode_config.dpms_property) { 469 if (prop == state->dev->mode_config.dpms_property) {
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 1ad8c5e1455d..5567ddc7760f 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -356,6 +356,33 @@ static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
356 return 0; 356 return 0;
357} 357}
358 358
359static int
360intel_gvt_workload_req_alloc(struct intel_vgpu_workload *workload)
361{
362 struct intel_vgpu *vgpu = workload->vgpu;
363 struct intel_vgpu_submission *s = &vgpu->submission;
364 struct i915_gem_context *shadow_ctx = s->shadow_ctx;
365 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
366 struct intel_engine_cs *engine = dev_priv->engine[workload->ring_id];
367 struct i915_request *rq;
368 int ret = 0;
369
370 lockdep_assert_held(&dev_priv->drm.struct_mutex);
371
372 if (workload->req)
373 goto out;
374
375 rq = i915_request_alloc(engine, shadow_ctx);
376 if (IS_ERR(rq)) {
377 gvt_vgpu_err("fail to allocate gem request\n");
378 ret = PTR_ERR(rq);
379 goto out;
380 }
381 workload->req = i915_request_get(rq);
382out:
383 return ret;
384}
385
359/** 386/**
360 * intel_gvt_scan_and_shadow_workload - audit the workload by scanning and 387 * intel_gvt_scan_and_shadow_workload - audit the workload by scanning and
361 * shadow it as well, include ringbuffer,wa_ctx and ctx. 388 * shadow it as well, include ringbuffer,wa_ctx and ctx.
@@ -372,12 +399,11 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
372 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; 399 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
373 struct intel_engine_cs *engine = dev_priv->engine[workload->ring_id]; 400 struct intel_engine_cs *engine = dev_priv->engine[workload->ring_id];
374 struct intel_context *ce; 401 struct intel_context *ce;
375 struct i915_request *rq;
376 int ret; 402 int ret;
377 403
378 lockdep_assert_held(&dev_priv->drm.struct_mutex); 404 lockdep_assert_held(&dev_priv->drm.struct_mutex);
379 405
380 if (workload->req) 406 if (workload->shadow)
381 return 0; 407 return 0;
382 408
383 ret = set_context_ppgtt_from_shadow(workload, shadow_ctx); 409 ret = set_context_ppgtt_from_shadow(workload, shadow_ctx);
@@ -417,22 +443,8 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
417 goto err_shadow; 443 goto err_shadow;
418 } 444 }
419 445
420 rq = i915_request_alloc(engine, shadow_ctx); 446 workload->shadow = true;
421 if (IS_ERR(rq)) {
422 gvt_vgpu_err("fail to allocate gem request\n");
423 ret = PTR_ERR(rq);
424 goto err_shadow;
425 }
426 workload->req = i915_request_get(rq);
427
428 ret = populate_shadow_context(workload);
429 if (ret)
430 goto err_req;
431
432 return 0; 447 return 0;
433err_req:
434 rq = fetch_and_zero(&workload->req);
435 i915_request_put(rq);
436err_shadow: 448err_shadow:
437 release_shadow_wa_ctx(&workload->wa_ctx); 449 release_shadow_wa_ctx(&workload->wa_ctx);
438err_unpin: 450err_unpin:
@@ -671,23 +683,31 @@ static int dispatch_workload(struct intel_vgpu_workload *workload)
671 mutex_lock(&vgpu->vgpu_lock); 683 mutex_lock(&vgpu->vgpu_lock);
672 mutex_lock(&dev_priv->drm.struct_mutex); 684 mutex_lock(&dev_priv->drm.struct_mutex);
673 685
686 ret = intel_gvt_workload_req_alloc(workload);
687 if (ret)
688 goto err_req;
689
674 ret = intel_gvt_scan_and_shadow_workload(workload); 690 ret = intel_gvt_scan_and_shadow_workload(workload);
675 if (ret) 691 if (ret)
676 goto out; 692 goto out;
677 693
678 ret = prepare_workload(workload); 694 ret = populate_shadow_context(workload);
695 if (ret) {
696 release_shadow_wa_ctx(&workload->wa_ctx);
697 goto out;
698 }
679 699
700 ret = prepare_workload(workload);
680out: 701out:
681 if (ret)
682 workload->status = ret;
683
684 if (!IS_ERR_OR_NULL(workload->req)) { 702 if (!IS_ERR_OR_NULL(workload->req)) {
685 gvt_dbg_sched("ring id %d submit workload to i915 %p\n", 703 gvt_dbg_sched("ring id %d submit workload to i915 %p\n",
686 ring_id, workload->req); 704 ring_id, workload->req);
687 i915_request_add(workload->req); 705 i915_request_add(workload->req);
688 workload->dispatched = true; 706 workload->dispatched = true;
689 } 707 }
690 708err_req:
709 if (ret)
710 workload->status = ret;
691 mutex_unlock(&dev_priv->drm.struct_mutex); 711 mutex_unlock(&dev_priv->drm.struct_mutex);
692 mutex_unlock(&vgpu->vgpu_lock); 712 mutex_unlock(&vgpu->vgpu_lock);
693 return ret; 713 return ret;
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.h b/drivers/gpu/drm/i915/gvt/scheduler.h
index ca5529d0e48e..2065cba59aab 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.h
+++ b/drivers/gpu/drm/i915/gvt/scheduler.h
@@ -83,6 +83,7 @@ struct intel_vgpu_workload {
83 struct i915_request *req; 83 struct i915_request *req;
84 /* if this workload has been dispatched to i915? */ 84 /* if this workload has been dispatched to i915? */
85 bool dispatched; 85 bool dispatched;
86 bool shadow; /* if workload has done shadow of guest request */
86 int status; 87 int status;
87 88
88 struct intel_vgpu_mm *shadow_mm; 89 struct intel_vgpu_mm *shadow_mm;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 38dcee1ca062..40a61ef9aac1 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -984,8 +984,8 @@ static int i915_gpu_info_open(struct inode *inode, struct file *file)
984 intel_runtime_pm_get(i915); 984 intel_runtime_pm_get(i915);
985 gpu = i915_capture_gpu_state(i915); 985 gpu = i915_capture_gpu_state(i915);
986 intel_runtime_pm_put(i915); 986 intel_runtime_pm_put(i915);
987 if (!gpu) 987 if (IS_ERR(gpu))
988 return -ENOMEM; 988 return PTR_ERR(gpu);
989 989
990 file->private_data = gpu; 990 file->private_data = gpu;
991 return 0; 991 return 0;
@@ -1018,7 +1018,13 @@ i915_error_state_write(struct file *filp,
1018 1018
1019static int i915_error_state_open(struct inode *inode, struct file *file) 1019static int i915_error_state_open(struct inode *inode, struct file *file)
1020{ 1020{
1021 file->private_data = i915_first_error_state(inode->i_private); 1021 struct i915_gpu_state *error;
1022
1023 error = i915_first_error_state(inode->i_private);
1024 if (IS_ERR(error))
1025 return PTR_ERR(error);
1026
1027 file->private_data = error;
1022 return 0; 1028 return 0;
1023} 1029}
1024 1030
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index add1fe7aeb93..bd17dd1f5da5 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2075,6 +2075,7 @@ static struct i915_vma *pd_vma_create(struct gen6_hw_ppgtt *ppgtt, int size)
2075int gen6_ppgtt_pin(struct i915_hw_ppgtt *base) 2075int gen6_ppgtt_pin(struct i915_hw_ppgtt *base)
2076{ 2076{
2077 struct gen6_hw_ppgtt *ppgtt = to_gen6_ppgtt(base); 2077 struct gen6_hw_ppgtt *ppgtt = to_gen6_ppgtt(base);
2078 int err;
2078 2079
2079 /* 2080 /*
2080 * Workaround the limited maximum vma->pin_count and the aliasing_ppgtt 2081 * Workaround the limited maximum vma->pin_count and the aliasing_ppgtt
@@ -2090,9 +2091,17 @@ int gen6_ppgtt_pin(struct i915_hw_ppgtt *base)
2090 * allocator works in address space sizes, so it's multiplied by page 2091 * allocator works in address space sizes, so it's multiplied by page
2091 * size. We allocate at the top of the GTT to avoid fragmentation. 2092 * size. We allocate at the top of the GTT to avoid fragmentation.
2092 */ 2093 */
2093 return i915_vma_pin(ppgtt->vma, 2094 err = i915_vma_pin(ppgtt->vma,
2094 0, GEN6_PD_ALIGN, 2095 0, GEN6_PD_ALIGN,
2095 PIN_GLOBAL | PIN_HIGH); 2096 PIN_GLOBAL | PIN_HIGH);
2097 if (err)
2098 goto unpin;
2099
2100 return 0;
2101
2102unpin:
2103 ppgtt->pin_count = 0;
2104 return err;
2096} 2105}
2097 2106
2098void gen6_ppgtt_unpin(struct i915_hw_ppgtt *base) 2107void gen6_ppgtt_unpin(struct i915_hw_ppgtt *base)
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 07465123c166..3f9ce403c755 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1907,9 +1907,16 @@ i915_capture_gpu_state(struct drm_i915_private *i915)
1907{ 1907{
1908 struct i915_gpu_state *error; 1908 struct i915_gpu_state *error;
1909 1909
1910 /* Check if GPU capture has been disabled */
1911 error = READ_ONCE(i915->gpu_error.first_error);
1912 if (IS_ERR(error))
1913 return error;
1914
1910 error = kzalloc(sizeof(*error), GFP_ATOMIC); 1915 error = kzalloc(sizeof(*error), GFP_ATOMIC);
1911 if (!error) 1916 if (!error) {
1912 return NULL; 1917 i915_disable_error_state(i915, -ENOMEM);
1918 return ERR_PTR(-ENOMEM);
1919 }
1913 1920
1914 kref_init(&error->ref); 1921 kref_init(&error->ref);
1915 error->i915 = i915; 1922 error->i915 = i915;
@@ -1945,11 +1952,8 @@ void i915_capture_error_state(struct drm_i915_private *i915,
1945 return; 1952 return;
1946 1953
1947 error = i915_capture_gpu_state(i915); 1954 error = i915_capture_gpu_state(i915);
1948 if (!error) { 1955 if (IS_ERR(error))
1949 DRM_DEBUG_DRIVER("out of memory, not capturing error state\n");
1950 i915_disable_error_state(i915, -ENOMEM);
1951 return; 1956 return;
1952 }
1953 1957
1954 i915_error_capture_msg(i915, error, engine_mask, error_msg); 1958 i915_error_capture_msg(i915, error, engine_mask, error_msg);
1955 DRM_INFO("%s\n", error->error_msg); 1959 DRM_INFO("%s\n", error->error_msg);
@@ -1987,7 +1991,7 @@ i915_first_error_state(struct drm_i915_private *i915)
1987 1991
1988 spin_lock_irq(&i915->gpu_error.lock); 1992 spin_lock_irq(&i915->gpu_error.lock);
1989 error = i915->gpu_error.first_error; 1993 error = i915->gpu_error.first_error;
1990 if (error) 1994 if (!IS_ERR_OR_NULL(error))
1991 i915_gpu_state_get(error); 1995 i915_gpu_state_get(error);
1992 spin_unlock_irq(&i915->gpu_error.lock); 1996 spin_unlock_irq(&i915->gpu_error.lock);
1993 1997
@@ -2000,10 +2004,11 @@ void i915_reset_error_state(struct drm_i915_private *i915)
2000 2004
2001 spin_lock_irq(&i915->gpu_error.lock); 2005 spin_lock_irq(&i915->gpu_error.lock);
2002 error = i915->gpu_error.first_error; 2006 error = i915->gpu_error.first_error;
2003 i915->gpu_error.first_error = NULL; 2007 if (error != ERR_PTR(-ENODEV)) /* if disabled, always disabled */
2008 i915->gpu_error.first_error = NULL;
2004 spin_unlock_irq(&i915->gpu_error.lock); 2009 spin_unlock_irq(&i915->gpu_error.lock);
2005 2010
2006 if (!IS_ERR(error)) 2011 if (!IS_ERR_OR_NULL(error))
2007 i915_gpu_state_put(error); 2012 i915_gpu_state_put(error);
2008} 2013}
2009 2014
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 535caebd9813..c0cfe7ae2ba5 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -521,7 +521,9 @@ static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
521 ssize_t ret; 521 ssize_t ret;
522 522
523 gpu = i915_first_error_state(i915); 523 gpu = i915_first_error_state(i915);
524 if (gpu) { 524 if (IS_ERR(gpu)) {
525 ret = PTR_ERR(gpu);
526 } else if (gpu) {
525 ret = i915_gpu_state_copy_to_buffer(gpu, buf, off, count); 527 ret = i915_gpu_state_copy_to_buffer(gpu, buf, off, count);
526 i915_gpu_state_put(gpu); 528 i915_gpu_state_put(gpu);
527 } else { 529 } else {
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 4be167dcd209..4796f40a6d4f 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2244,6 +2244,8 @@ static int logical_ring_init(struct intel_engine_cs *engine)
2244 if (ret) 2244 if (ret)
2245 return ret; 2245 return ret;
2246 2246
2247 intel_engine_init_workarounds(engine);
2248
2247 if (HAS_LOGICAL_RING_ELSQ(i915)) { 2249 if (HAS_LOGICAL_RING_ELSQ(i915)) {
2248 execlists->submit_reg = i915->regs + 2250 execlists->submit_reg = i915->regs +
2249 i915_mmio_reg_offset(RING_EXECLIST_SQ_CONTENTS(engine)); 2251 i915_mmio_reg_offset(RING_EXECLIST_SQ_CONTENTS(engine));
@@ -2310,7 +2312,6 @@ int logical_render_ring_init(struct intel_engine_cs *engine)
2310 } 2312 }
2311 2313
2312 intel_engine_init_whitelist(engine); 2314 intel_engine_init_whitelist(engine);
2313 intel_engine_init_workarounds(engine);
2314 2315
2315 return 0; 2316 return 0;
2316} 2317}
diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c
index 419e56342523..f71970df9936 100644
--- a/drivers/gpu/drm/i915/intel_psr.c
+++ b/drivers/gpu/drm/i915/intel_psr.c
@@ -274,10 +274,16 @@ void intel_psr_init_dpcd(struct intel_dp *intel_dp)
274 DRM_DEBUG_KMS("eDP panel supports PSR version %x\n", 274 DRM_DEBUG_KMS("eDP panel supports PSR version %x\n",
275 intel_dp->psr_dpcd[0]); 275 intel_dp->psr_dpcd[0]);
276 276
277 if (drm_dp_has_quirk(&intel_dp->desc, DP_DPCD_QUIRK_NO_PSR)) {
278 DRM_DEBUG_KMS("PSR support not currently available for this panel\n");
279 return;
280 }
281
277 if (!(intel_dp->edp_dpcd[1] & DP_EDP_SET_POWER_CAP)) { 282 if (!(intel_dp->edp_dpcd[1] & DP_EDP_SET_POWER_CAP)) {
278 DRM_DEBUG_KMS("Panel lacks power state control, PSR cannot be enabled\n"); 283 DRM_DEBUG_KMS("Panel lacks power state control, PSR cannot be enabled\n");
279 return; 284 return;
280 } 285 }
286
281 dev_priv->psr.sink_support = true; 287 dev_priv->psr.sink_support = true;
282 dev_priv->psr.sink_sync_latency = 288 dev_priv->psr.sink_sync_latency =
283 intel_dp_get_sink_sync_latency(intel_dp); 289 intel_dp_get_sink_sync_latency(intel_dp);
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 5f5be6368aed..c7a94c94dbf3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -253,6 +253,9 @@ nouveau_backlight_init(struct drm_connector *connector)
253 case NV_DEVICE_INFO_V0_FERMI: 253 case NV_DEVICE_INFO_V0_FERMI:
254 case NV_DEVICE_INFO_V0_KEPLER: 254 case NV_DEVICE_INFO_V0_KEPLER:
255 case NV_DEVICE_INFO_V0_MAXWELL: 255 case NV_DEVICE_INFO_V0_MAXWELL:
256 case NV_DEVICE_INFO_V0_PASCAL:
257 case NV_DEVICE_INFO_V0_VOLTA:
258 case NV_DEVICE_INFO_V0_TURING:
256 ret = nv50_backlight_init(nv_encoder, &props, &ops); 259 ret = nv50_backlight_init(nv_encoder, &props, &ops);
257 break; 260 break;
258 default: 261 default:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c b/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
index 816ccaedfc73..8675613e142b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
@@ -22,6 +22,7 @@
22#include <engine/falcon.h> 22#include <engine/falcon.h>
23 23
24#include <core/gpuobj.h> 24#include <core/gpuobj.h>
25#include <subdev/mc.h>
25#include <subdev/timer.h> 26#include <subdev/timer.h>
26#include <engine/fifo.h> 27#include <engine/fifo.h>
27 28
@@ -107,8 +108,10 @@ nvkm_falcon_fini(struct nvkm_engine *engine, bool suspend)
107 } 108 }
108 } 109 }
109 110
110 nvkm_mask(device, base + 0x048, 0x00000003, 0x00000000); 111 if (nvkm_mc_enabled(device, engine->subdev.index)) {
111 nvkm_wr32(device, base + 0x014, 0xffffffff); 112 nvkm_mask(device, base + 0x048, 0x00000003, 0x00000000);
113 nvkm_wr32(device, base + 0x014, 0xffffffff);
114 }
112 return 0; 115 return 0;
113} 116}
114 117
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
index 3695cde669f8..07914e36939e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
@@ -132,11 +132,12 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)
132 duty = nvkm_therm_update_linear(therm); 132 duty = nvkm_therm_update_linear(therm);
133 break; 133 break;
134 case NVBIOS_THERM_FAN_OTHER: 134 case NVBIOS_THERM_FAN_OTHER:
135 if (therm->cstate) 135 if (therm->cstate) {
136 duty = therm->cstate; 136 duty = therm->cstate;
137 else 137 poll = false;
138 } else {
138 duty = nvkm_therm_update_linear_fallback(therm); 139 duty = nvkm_therm_update_linear_fallback(therm);
139 poll = false; 140 }
140 break; 141 break;
141 } 142 }
142 immd = false; 143 immd = false;
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e417ebf7628c..c77adbbea0c7 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -155,6 +155,8 @@ enum msg_end_type {
155 * @has_mst_fifo: The I2C controller contains the new MST FIFO interface that 155 * @has_mst_fifo: The I2C controller contains the new MST FIFO interface that
156 * provides additional features and allows for longer messages to 156 * provides additional features and allows for longer messages to
157 * be transferred in one go. 157 * be transferred in one go.
158 * @quirks: i2c adapter quirks for limiting write/read transfer size and not
159 * allowing 0 length transfers.
158 */ 160 */
159struct tegra_i2c_hw_feature { 161struct tegra_i2c_hw_feature {
160 bool has_continue_xfer_support; 162 bool has_continue_xfer_support;
@@ -167,6 +169,7 @@ struct tegra_i2c_hw_feature {
167 bool has_multi_master_mode; 169 bool has_multi_master_mode;
168 bool has_slcg_override_reg; 170 bool has_slcg_override_reg;
169 bool has_mst_fifo; 171 bool has_mst_fifo;
172 const struct i2c_adapter_quirks *quirks;
170}; 173};
171 174
172/** 175/**
@@ -837,6 +840,10 @@ static const struct i2c_adapter_quirks tegra_i2c_quirks = {
837 .max_write_len = 4096, 840 .max_write_len = 4096,
838}; 841};
839 842
843static const struct i2c_adapter_quirks tegra194_i2c_quirks = {
844 .flags = I2C_AQ_NO_ZERO_LEN,
845};
846
840static const struct tegra_i2c_hw_feature tegra20_i2c_hw = { 847static const struct tegra_i2c_hw_feature tegra20_i2c_hw = {
841 .has_continue_xfer_support = false, 848 .has_continue_xfer_support = false,
842 .has_per_pkt_xfer_complete_irq = false, 849 .has_per_pkt_xfer_complete_irq = false,
@@ -848,6 +855,7 @@ static const struct tegra_i2c_hw_feature tegra20_i2c_hw = {
848 .has_multi_master_mode = false, 855 .has_multi_master_mode = false,
849 .has_slcg_override_reg = false, 856 .has_slcg_override_reg = false,
850 .has_mst_fifo = false, 857 .has_mst_fifo = false,
858 .quirks = &tegra_i2c_quirks,
851}; 859};
852 860
853static const struct tegra_i2c_hw_feature tegra30_i2c_hw = { 861static const struct tegra_i2c_hw_feature tegra30_i2c_hw = {
@@ -861,6 +869,7 @@ static const struct tegra_i2c_hw_feature tegra30_i2c_hw = {
861 .has_multi_master_mode = false, 869 .has_multi_master_mode = false,
862 .has_slcg_override_reg = false, 870 .has_slcg_override_reg = false,
863 .has_mst_fifo = false, 871 .has_mst_fifo = false,
872 .quirks = &tegra_i2c_quirks,
864}; 873};
865 874
866static const struct tegra_i2c_hw_feature tegra114_i2c_hw = { 875static const struct tegra_i2c_hw_feature tegra114_i2c_hw = {
@@ -874,6 +883,7 @@ static const struct tegra_i2c_hw_feature tegra114_i2c_hw = {
874 .has_multi_master_mode = false, 883 .has_multi_master_mode = false,
875 .has_slcg_override_reg = false, 884 .has_slcg_override_reg = false,
876 .has_mst_fifo = false, 885 .has_mst_fifo = false,
886 .quirks = &tegra_i2c_quirks,
877}; 887};
878 888
879static const struct tegra_i2c_hw_feature tegra124_i2c_hw = { 889static const struct tegra_i2c_hw_feature tegra124_i2c_hw = {
@@ -887,6 +897,7 @@ static const struct tegra_i2c_hw_feature tegra124_i2c_hw = {
887 .has_multi_master_mode = false, 897 .has_multi_master_mode = false,
888 .has_slcg_override_reg = true, 898 .has_slcg_override_reg = true,
889 .has_mst_fifo = false, 899 .has_mst_fifo = false,
900 .quirks = &tegra_i2c_quirks,
890}; 901};
891 902
892static const struct tegra_i2c_hw_feature tegra210_i2c_hw = { 903static const struct tegra_i2c_hw_feature tegra210_i2c_hw = {
@@ -900,6 +911,7 @@ static const struct tegra_i2c_hw_feature tegra210_i2c_hw = {
900 .has_multi_master_mode = true, 911 .has_multi_master_mode = true,
901 .has_slcg_override_reg = true, 912 .has_slcg_override_reg = true,
902 .has_mst_fifo = false, 913 .has_mst_fifo = false,
914 .quirks = &tegra_i2c_quirks,
903}; 915};
904 916
905static const struct tegra_i2c_hw_feature tegra194_i2c_hw = { 917static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
@@ -913,6 +925,7 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
913 .has_multi_master_mode = true, 925 .has_multi_master_mode = true,
914 .has_slcg_override_reg = true, 926 .has_slcg_override_reg = true,
915 .has_mst_fifo = true, 927 .has_mst_fifo = true,
928 .quirks = &tegra194_i2c_quirks,
916}; 929};
917 930
918/* Match table for of_platform binding */ 931/* Match table for of_platform binding */
@@ -964,7 +977,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
964 i2c_dev->base = base; 977 i2c_dev->base = base;
965 i2c_dev->div_clk = div_clk; 978 i2c_dev->div_clk = div_clk;
966 i2c_dev->adapter.algo = &tegra_i2c_algo; 979 i2c_dev->adapter.algo = &tegra_i2c_algo;
967 i2c_dev->adapter.quirks = &tegra_i2c_quirks;
968 i2c_dev->irq = irq; 980 i2c_dev->irq = irq;
969 i2c_dev->cont_id = pdev->id; 981 i2c_dev->cont_id = pdev->id;
970 i2c_dev->dev = &pdev->dev; 982 i2c_dev->dev = &pdev->dev;
@@ -980,6 +992,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
980 i2c_dev->hw = of_device_get_match_data(&pdev->dev); 992 i2c_dev->hw = of_device_get_match_data(&pdev->dev);
981 i2c_dev->is_dvc = of_device_is_compatible(pdev->dev.of_node, 993 i2c_dev->is_dvc = of_device_is_compatible(pdev->dev.of_node,
982 "nvidia,tegra20-i2c-dvc"); 994 "nvidia,tegra20-i2c-dvc");
995 i2c_dev->adapter.quirks = i2c_dev->hw->quirks;
983 init_completion(&i2c_dev->msg_complete); 996 init_completion(&i2c_dev->msg_complete);
984 spin_lock_init(&i2c_dev->xfer_lock); 997 spin_lock_init(&i2c_dev->xfer_lock);
985 998
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 1aca742fde4a..ccd76c71af09 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -470,9 +470,15 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
470 data_arg.data); 470 data_arg.data);
471 } 471 }
472 case I2C_RETRIES: 472 case I2C_RETRIES:
473 if (arg > INT_MAX)
474 return -EINVAL;
475
473 client->adapter->retries = arg; 476 client->adapter->retries = arg;
474 break; 477 break;
475 case I2C_TIMEOUT: 478 case I2C_TIMEOUT:
479 if (arg > INT_MAX)
480 return -EINVAL;
481
476 /* For historical reasons, user-space sets the timeout 482 /* For historical reasons, user-space sets the timeout
477 * value in units of 10 ms. 483 * value in units of 10 ms.
478 */ 484 */
diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index 2543baba8b1f..5a2ec43b7ddd 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -95,7 +95,7 @@ static inline void setup_irq_channel(u32 magic, void __iomem *reg_addr)
95 95
96 /* Setup 64 channel slots */ 96 /* Setup 64 channel slots */
97 for (i = 0; i < INTC_IRQS; i += 4) 97 for (i = 0; i < INTC_IRQS; i += 4)
98 writel_relaxed(build_channel_val(i, magic), reg_addr + i); 98 writel(build_channel_val(i, magic), reg_addr + i);
99} 99}
100 100
101static int __init 101static int __init
@@ -135,16 +135,10 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
135static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq, 135static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
136 u32 irq_base) 136 u32 irq_base)
137{ 137{
138 u32 irq;
139
140 if (hwirq == 0) 138 if (hwirq == 0)
141 return 0; 139 return 0;
142 140
143 while (hwirq) { 141 handle_domain_irq(root_domain, irq_base + __fls(hwirq), regs);
144 irq = __ffs(hwirq);
145 hwirq &= ~BIT(irq);
146 handle_domain_irq(root_domain, irq_base + irq, regs);
147 }
148 142
149 return 1; 143 return 1;
150} 144}
@@ -154,12 +148,16 @@ static void gx_irq_handler(struct pt_regs *regs)
154{ 148{
155 bool ret; 149 bool ret;
156 150
157 do { 151retry:
158 ret = handle_irq_perbit(regs, 152 ret = handle_irq_perbit(regs,
159 readl_relaxed(reg_base + GX_INTC_PEN31_00), 0); 153 readl(reg_base + GX_INTC_PEN63_32), 32);
160 ret |= handle_irq_perbit(regs, 154 if (ret)
161 readl_relaxed(reg_base + GX_INTC_PEN63_32), 32); 155 goto retry;
162 } while (ret); 156
157 ret = handle_irq_perbit(regs,
158 readl(reg_base + GX_INTC_PEN31_00), 0);
159 if (ret)
160 goto retry;
163} 161}
164 162
165static int __init 163static int __init
@@ -174,14 +172,14 @@ gx_intc_init(struct device_node *node, struct device_node *parent)
174 /* 172 /*
175 * Initial enable reg to disable all interrupts 173 * Initial enable reg to disable all interrupts
176 */ 174 */
177 writel_relaxed(0x0, reg_base + GX_INTC_NEN31_00); 175 writel(0x0, reg_base + GX_INTC_NEN31_00);
178 writel_relaxed(0x0, reg_base + GX_INTC_NEN63_32); 176 writel(0x0, reg_base + GX_INTC_NEN63_32);
179 177
180 /* 178 /*
181 * Initial mask reg with all unmasked, because we only use enalbe reg 179 * Initial mask reg with all unmasked, because we only use enalbe reg
182 */ 180 */
183 writel_relaxed(0x0, reg_base + GX_INTC_NMASK31_00); 181 writel(0x0, reg_base + GX_INTC_NMASK31_00);
184 writel_relaxed(0x0, reg_base + GX_INTC_NMASK63_32); 182 writel(0x0, reg_base + GX_INTC_NMASK63_32);
185 183
186 setup_irq_channel(0x03020100, reg_base + GX_INTC_SOURCE); 184 setup_irq_channel(0x03020100, reg_base + GX_INTC_SOURCE);
187 185
@@ -204,20 +202,29 @@ static void ck_irq_handler(struct pt_regs *regs)
204 void __iomem *reg_pen_lo = reg_base + CK_INTC_PEN31_00; 202 void __iomem *reg_pen_lo = reg_base + CK_INTC_PEN31_00;
205 void __iomem *reg_pen_hi = reg_base + CK_INTC_PEN63_32; 203 void __iomem *reg_pen_hi = reg_base + CK_INTC_PEN63_32;
206 204
207 do { 205retry:
208 /* handle 0 - 31 irqs */ 206 /* handle 0 - 63 irqs */
209 ret = handle_irq_perbit(regs, readl_relaxed(reg_pen_lo), 0); 207 ret = handle_irq_perbit(regs, readl(reg_pen_hi), 32);
210 ret |= handle_irq_perbit(regs, readl_relaxed(reg_pen_hi), 32); 208 if (ret)
209 goto retry;
211 210
212 if (nr_irq == INTC_IRQS) 211 ret = handle_irq_perbit(regs, readl(reg_pen_lo), 0);
213 continue; 212 if (ret)
213 goto retry;
214
215 if (nr_irq == INTC_IRQS)
216 return;
214 217
215 /* handle 64 - 127 irqs */ 218 /* handle 64 - 127 irqs */
216 ret |= handle_irq_perbit(regs, 219 ret = handle_irq_perbit(regs,
217 readl_relaxed(reg_pen_lo + CK_INTC_DUAL_BASE), 64); 220 readl(reg_pen_hi + CK_INTC_DUAL_BASE), 96);
218 ret |= handle_irq_perbit(regs, 221 if (ret)
219 readl_relaxed(reg_pen_hi + CK_INTC_DUAL_BASE), 96); 222 goto retry;
220 } while (ret); 223
224 ret = handle_irq_perbit(regs,
225 readl(reg_pen_lo + CK_INTC_DUAL_BASE), 64);
226 if (ret)
227 goto retry;
221} 228}
222 229
223static int __init 230static int __init
@@ -230,11 +237,11 @@ ck_intc_init(struct device_node *node, struct device_node *parent)
230 return ret; 237 return ret;
231 238
232 /* Initial enable reg to disable all interrupts */ 239 /* Initial enable reg to disable all interrupts */
233 writel_relaxed(0, reg_base + CK_INTC_NEN31_00); 240 writel(0, reg_base + CK_INTC_NEN31_00);
234 writel_relaxed(0, reg_base + CK_INTC_NEN63_32); 241 writel(0, reg_base + CK_INTC_NEN63_32);
235 242
236 /* Enable irq intc */ 243 /* Enable irq intc */
237 writel_relaxed(BIT(31), reg_base + CK_INTC_ICR); 244 writel(BIT(31), reg_base + CK_INTC_ICR);
238 245
239 ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0); 246 ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0);
240 ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 32); 247 ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 32);
@@ -260,8 +267,8 @@ ck_dual_intc_init(struct device_node *node, struct device_node *parent)
260 return ret; 267 return ret;
261 268
262 /* Initial enable reg to disable all interrupts */ 269 /* Initial enable reg to disable all interrupts */
263 writel_relaxed(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE); 270 writel(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE);
264 writel_relaxed(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE); 271 writel(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE);
265 272
266 ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 64); 273 ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 64);
267 ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 96); 274 ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 96);
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 21e3cdc04036..999b705769a8 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -522,7 +522,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
522 mtd->nvmem = nvmem_register(&config); 522 mtd->nvmem = nvmem_register(&config);
523 if (IS_ERR(mtd->nvmem)) { 523 if (IS_ERR(mtd->nvmem)) {
524 /* Just ignore if there is no NVMEM support in the kernel */ 524 /* Just ignore if there is no NVMEM support in the kernel */
525 if (PTR_ERR(mtd->nvmem) == -ENOSYS) { 525 if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) {
526 mtd->nvmem = NULL; 526 mtd->nvmem = NULL;
527 } else { 527 } else {
528 dev_err(&mtd->dev, "Failed to register NVMEM device\n"); 528 dev_err(&mtd->dev, "Failed to register NVMEM device\n");
diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h
index 9887bda317cd..b31c868019ad 100644
--- a/drivers/mtd/mtdcore.h
+++ b/drivers/mtd/mtdcore.h
@@ -7,7 +7,7 @@
7extern struct mutex mtd_table_mutex; 7extern struct mutex mtd_table_mutex;
8 8
9struct mtd_info *__mtd_next_device(int i); 9struct mtd_info *__mtd_next_device(int i);
10int add_mtd_device(struct mtd_info *mtd); 10int __must_check add_mtd_device(struct mtd_info *mtd);
11int del_mtd_device(struct mtd_info *mtd); 11int del_mtd_device(struct mtd_info *mtd);
12int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); 12int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
13int del_mtd_partitions(struct mtd_info *); 13int del_mtd_partitions(struct mtd_info *);
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index b6af41b04622..60104e1079c5 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -618,10 +618,22 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,
618 list_add(&new->list, &mtd_partitions); 618 list_add(&new->list, &mtd_partitions);
619 mutex_unlock(&mtd_partitions_mutex); 619 mutex_unlock(&mtd_partitions_mutex);
620 620
621 add_mtd_device(&new->mtd); 621 ret = add_mtd_device(&new->mtd);
622 if (ret)
623 goto err_remove_part;
622 624
623 mtd_add_partition_attrs(new); 625 mtd_add_partition_attrs(new);
624 626
627 return 0;
628
629err_remove_part:
630 mutex_lock(&mtd_partitions_mutex);
631 list_del(&new->list);
632 mutex_unlock(&mtd_partitions_mutex);
633
634 free_partition(new);
635 pr_info("%s:%i\n", __func__, __LINE__);
636
625 return ret; 637 return ret;
626} 638}
627EXPORT_SYMBOL_GPL(mtd_add_partition); 639EXPORT_SYMBOL_GPL(mtd_add_partition);
@@ -712,22 +724,31 @@ int add_mtd_partitions(struct mtd_info *master,
712{ 724{
713 struct mtd_part *slave; 725 struct mtd_part *slave;
714 uint64_t cur_offset = 0; 726 uint64_t cur_offset = 0;
715 int i; 727 int i, ret;
716 728
717 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); 729 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
718 730
719 for (i = 0; i < nbparts; i++) { 731 for (i = 0; i < nbparts; i++) {
720 slave = allocate_partition(master, parts + i, i, cur_offset); 732 slave = allocate_partition(master, parts + i, i, cur_offset);
721 if (IS_ERR(slave)) { 733 if (IS_ERR(slave)) {
722 del_mtd_partitions(master); 734 ret = PTR_ERR(slave);
723 return PTR_ERR(slave); 735 goto err_del_partitions;
724 } 736 }
725 737
726 mutex_lock(&mtd_partitions_mutex); 738 mutex_lock(&mtd_partitions_mutex);
727 list_add(&slave->list, &mtd_partitions); 739 list_add(&slave->list, &mtd_partitions);
728 mutex_unlock(&mtd_partitions_mutex); 740 mutex_unlock(&mtd_partitions_mutex);
729 741
730 add_mtd_device(&slave->mtd); 742 ret = add_mtd_device(&slave->mtd);
743 if (ret) {
744 mutex_lock(&mtd_partitions_mutex);
745 list_del(&slave->list);
746 mutex_unlock(&mtd_partitions_mutex);
747
748 free_partition(slave);
749 goto err_del_partitions;
750 }
751
731 mtd_add_partition_attrs(slave); 752 mtd_add_partition_attrs(slave);
732 /* Look for subpartitions */ 753 /* Look for subpartitions */
733 parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); 754 parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
@@ -736,6 +757,11 @@ int add_mtd_partitions(struct mtd_info *master,
736 } 757 }
737 758
738 return 0; 759 return 0;
760
761err_del_partitions:
762 del_mtd_partitions(master);
763
764 return ret;
739} 765}
740 766
741static DEFINE_SPINLOCK(part_parser_lock); 767static DEFINE_SPINLOCK(part_parser_lock);
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 46c62a31fa46..920e7375084f 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2833,6 +2833,16 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
2833 if (ret) 2833 if (ret)
2834 return ret; 2834 return ret;
2835 2835
2836 if (nandc->props->is_bam) {
2837 free_bam_transaction(nandc);
2838 nandc->bam_txn = alloc_bam_transaction(nandc);
2839 if (!nandc->bam_txn) {
2840 dev_err(nandc->dev,
2841 "failed to allocate bam transaction\n");
2842 return -ENOMEM;
2843 }
2844 }
2845
2836 ret = mtd_device_register(mtd, NULL, 0); 2846 ret = mtd_device_register(mtd, NULL, 0);
2837 if (ret) 2847 if (ret)
2838 nand_cleanup(chip); 2848 nand_cleanup(chip);
@@ -2847,16 +2857,6 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc)
2847 struct qcom_nand_host *host; 2857 struct qcom_nand_host *host;
2848 int ret; 2858 int ret;
2849 2859
2850 if (nandc->props->is_bam) {
2851 free_bam_transaction(nandc);
2852 nandc->bam_txn = alloc_bam_transaction(nandc);
2853 if (!nandc->bam_txn) {
2854 dev_err(nandc->dev,
2855 "failed to allocate bam transaction\n");
2856 return -ENOMEM;
2857 }
2858 }
2859
2860 for_each_available_child_of_node(dn, child) { 2860 for_each_available_child_of_node(dn, child) {
2861 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); 2861 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
2862 if (!host) { 2862 if (!host) {
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index e5507add8f04..18f1639dbc4a 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -988,11 +988,9 @@ void _opp_free(struct dev_pm_opp *opp)
988 kfree(opp); 988 kfree(opp);
989} 989}
990 990
991static void _opp_kref_release(struct kref *kref) 991static void _opp_kref_release(struct dev_pm_opp *opp,
992 struct opp_table *opp_table)
992{ 993{
993 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref);
994 struct opp_table *opp_table = opp->opp_table;
995
996 /* 994 /*
997 * Notify the changes in the availability of the operable 995 * Notify the changes in the availability of the operable
998 * frequency/voltage list. 996 * frequency/voltage list.
@@ -1002,7 +1000,22 @@ static void _opp_kref_release(struct kref *kref)
1002 opp_debug_remove_one(opp); 1000 opp_debug_remove_one(opp);
1003 list_del(&opp->node); 1001 list_del(&opp->node);
1004 kfree(opp); 1002 kfree(opp);
1003}
1005 1004
1005static void _opp_kref_release_unlocked(struct kref *kref)
1006{
1007 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref);
1008 struct opp_table *opp_table = opp->opp_table;
1009
1010 _opp_kref_release(opp, opp_table);
1011}
1012
1013static void _opp_kref_release_locked(struct kref *kref)
1014{
1015 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref);
1016 struct opp_table *opp_table = opp->opp_table;
1017
1018 _opp_kref_release(opp, opp_table);
1006 mutex_unlock(&opp_table->lock); 1019 mutex_unlock(&opp_table->lock);
1007} 1020}
1008 1021
@@ -1013,10 +1026,16 @@ void dev_pm_opp_get(struct dev_pm_opp *opp)
1013 1026
1014void dev_pm_opp_put(struct dev_pm_opp *opp) 1027void dev_pm_opp_put(struct dev_pm_opp *opp)
1015{ 1028{
1016 kref_put_mutex(&opp->kref, _opp_kref_release, &opp->opp_table->lock); 1029 kref_put_mutex(&opp->kref, _opp_kref_release_locked,
1030 &opp->opp_table->lock);
1017} 1031}
1018EXPORT_SYMBOL_GPL(dev_pm_opp_put); 1032EXPORT_SYMBOL_GPL(dev_pm_opp_put);
1019 1033
1034static void dev_pm_opp_put_unlocked(struct dev_pm_opp *opp)
1035{
1036 kref_put(&opp->kref, _opp_kref_release_unlocked);
1037}
1038
1020/** 1039/**
1021 * dev_pm_opp_remove() - Remove an OPP from OPP table 1040 * dev_pm_opp_remove() - Remove an OPP from OPP table
1022 * @dev: device for which we do this operation 1041 * @dev: device for which we do this operation
@@ -1060,6 +1079,40 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq)
1060} 1079}
1061EXPORT_SYMBOL_GPL(dev_pm_opp_remove); 1080EXPORT_SYMBOL_GPL(dev_pm_opp_remove);
1062 1081
1082/**
1083 * dev_pm_opp_remove_all_dynamic() - Remove all dynamically created OPPs
1084 * @dev: device for which we do this operation
1085 *
1086 * This function removes all dynamically created OPPs from the opp table.
1087 */
1088void dev_pm_opp_remove_all_dynamic(struct device *dev)
1089{
1090 struct opp_table *opp_table;
1091 struct dev_pm_opp *opp, *temp;
1092 int count = 0;
1093
1094 opp_table = _find_opp_table(dev);
1095 if (IS_ERR(opp_table))
1096 return;
1097
1098 mutex_lock(&opp_table->lock);
1099 list_for_each_entry_safe(opp, temp, &opp_table->opp_list, node) {
1100 if (opp->dynamic) {
1101 dev_pm_opp_put_unlocked(opp);
1102 count++;
1103 }
1104 }
1105 mutex_unlock(&opp_table->lock);
1106
1107 /* Drop the references taken by dev_pm_opp_add() */
1108 while (count--)
1109 dev_pm_opp_put_opp_table(opp_table);
1110
1111 /* Drop the reference taken by _find_opp_table() */
1112 dev_pm_opp_put_opp_table(opp_table);
1113}
1114EXPORT_SYMBOL_GPL(dev_pm_opp_remove_all_dynamic);
1115
1063struct dev_pm_opp *_opp_allocate(struct opp_table *table) 1116struct dev_pm_opp *_opp_allocate(struct opp_table *table)
1064{ 1117{
1065 struct dev_pm_opp *opp; 1118 struct dev_pm_opp *opp;
diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 241ebe0c4505..e35e9eaa50ee 100644
--- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/clk.h> 9#include <linux/clk.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/gpio/consumer.h>
11#include <linux/of_device.h> 12#include <linux/of_device.h>
12#include <linux/of_gpio.h> 13#include <linux/of_gpio.h>
13#include <linux/pci.h> 14#include <linux/pci.h>
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 67b9bf3b500e..089a6f285d5e 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -85,6 +85,18 @@ config SERIAL_EARLYCON_ARM_SEMIHOST
85 with "earlycon=smh" on the kernel command line. The console is 85 with "earlycon=smh" on the kernel command line. The console is
86 enabled when early_param is processed. 86 enabled when early_param is processed.
87 87
88config SERIAL_EARLYCON_RISCV_SBI
89 bool "Early console using RISC-V SBI"
90 depends on RISCV
91 select SERIAL_CORE
92 select SERIAL_CORE_CONSOLE
93 select SERIAL_EARLYCON
94 help
95 Support for early debug console using RISC-V SBI. This enables
96 the console before standard serial driver is probed. This is enabled
97 with "earlycon=sbi" on the kernel command line. The console is
98 enabled when early_param is processed.
99
88config SERIAL_SB1250_DUART 100config SERIAL_SB1250_DUART
89 tristate "BCM1xxx on-chip DUART serial support" 101 tristate "BCM1xxx on-chip DUART serial support"
90 depends on SIBYTE_SB1xxx_SOC=y 102 depends on SIBYTE_SB1xxx_SOC=y
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 8c303736b7e8..1511e8a9f856 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_CORE) += serial_core.o
7 7
8obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o 8obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o
9obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o 9obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o
10obj-$(CONFIG_SERIAL_EARLYCON_RISCV_SBI) += earlycon-riscv-sbi.o
10 11
11# These Sparc drivers have to appear before others such as 8250 12# These Sparc drivers have to appear before others such as 8250
12# which share ttySx minor node space. Otherwise console device 13# which share ttySx minor node space. Otherwise console device
diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
new file mode 100644
index 000000000000..e1a551aae336
--- /dev/null
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -0,0 +1,28 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * RISC-V SBI based earlycon
4 *
5 * Copyright (C) 2018 Anup Patel <anup@brainfault.org>
6 */
7#include <linux/kernel.h>
8#include <linux/console.h>
9#include <linux/init.h>
10#include <linux/serial_core.h>
11#include <asm/sbi.h>
12
13static void sbi_console_write(struct console *con,
14 const char *s, unsigned int n)
15{
16 int i;
17
18 for (i = 0; i < n; ++i)
19 sbi_console_putchar(s[i]);
20}
21
22static int __init early_sbi_setup(struct earlycon_device *device,
23 const char *opt)
24{
25 device->con->write = sbi_console_write;
26 return 0;
27}
28EARLYCON_DECLARE(sbi, early_sbi_setup);
diff --git a/drivers/vfio/pci/trace.h b/drivers/vfio/pci/trace.h
index 228ccdb8d1c8..4d13e510590e 100644
--- a/drivers/vfio/pci/trace.h
+++ b/drivers/vfio/pci/trace.h
@@ -94,7 +94,7 @@ TRACE_EVENT(vfio_pci_npu2_mmap,
94#endif /* _TRACE_VFIO_PCI_H */ 94#endif /* _TRACE_VFIO_PCI_H */
95 95
96#undef TRACE_INCLUDE_PATH 96#undef TRACE_INCLUDE_PATH
97#define TRACE_INCLUDE_PATH . 97#define TRACE_INCLUDE_PATH ../../drivers/vfio/pci
98#undef TRACE_INCLUDE_FILE 98#undef TRACE_INCLUDE_FILE
99#define TRACE_INCLUDE_FILE trace 99#define TRACE_INCLUDE_FILE trace
100 100
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 7651cfb14836..73652e21efec 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -878,7 +878,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
878 return -EINVAL; 878 return -EINVAL;
879 if (!unmap->size || unmap->size & mask) 879 if (!unmap->size || unmap->size & mask)
880 return -EINVAL; 880 return -EINVAL;
881 if (unmap->iova + unmap->size < unmap->iova || 881 if (unmap->iova + unmap->size - 1 < unmap->iova ||
882 unmap->size > SIZE_MAX) 882 unmap->size > SIZE_MAX)
883 return -EINVAL; 883 return -EINVAL;
884 884
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5d0c05e288cc..a47c541f8006 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1494,10 +1494,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
1494 if (err < 0 || off >= i_size_read(inode)) { 1494 if (err < 0 || off >= i_size_read(inode)) {
1495 unlock_page(page); 1495 unlock_page(page);
1496 put_page(page); 1496 put_page(page);
1497 if (err == -ENOMEM) 1497 ret = vmf_error(err);
1498 ret = VM_FAULT_OOM;
1499 else
1500 ret = VM_FAULT_SIGBUS;
1501 goto out_inline; 1498 goto out_inline;
1502 } 1499 }
1503 if (err < PAGE_SIZE) 1500 if (err < PAGE_SIZE)
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 4e9a7cc488da..da2cd8e89062 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -530,7 +530,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
530 seq_putc(m, ','); 530 seq_putc(m, ',');
531 pos = m->count; 531 pos = m->count;
532 532
533 ret = ceph_print_client_options(m, fsc->client); 533 ret = ceph_print_client_options(m, fsc->client, false);
534 if (ret) 534 if (ret)
535 return ret; 535 return ret;
536 536
@@ -640,7 +640,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
640 opt = NULL; /* fsc->client now owns this */ 640 opt = NULL; /* fsc->client now owns this */
641 641
642 fsc->client->extra_mon_dispatch = extra_mon_dispatch; 642 fsc->client->extra_mon_dispatch = extra_mon_dispatch;
643 fsc->client->osdc.abort_on_full = true; 643 ceph_set_opt(fsc->client, ABORT_ON_FULL);
644 644
645 if (!fsopt->mds_namespace) { 645 if (!fsopt->mds_namespace) {
646 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP, 646 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a2fcea5f8225..32920a10100e 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -383,16 +383,17 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end)
383 * truncation is indicated by end of range being LLONG_MAX 383 * truncation is indicated by end of range being LLONG_MAX
384 * In this case, we first scan the range and release found pages. 384 * In this case, we first scan the range and release found pages.
385 * After releasing pages, hugetlb_unreserve_pages cleans up region/reserv 385 * After releasing pages, hugetlb_unreserve_pages cleans up region/reserv
386 * maps and global counts. 386 * maps and global counts. Page faults can not race with truncation
387 * in this routine. hugetlb_no_page() prevents page faults in the
388 * truncated range. It checks i_size before allocation, and again after
389 * with the page table lock for the page held. The same lock must be
390 * acquired to unmap a page.
387 * hole punch is indicated if end is not LLONG_MAX 391 * hole punch is indicated if end is not LLONG_MAX
388 * In the hole punch case we scan the range and release found pages. 392 * In the hole punch case we scan the range and release found pages.
389 * Only when releasing a page is the associated region/reserv map 393 * Only when releasing a page is the associated region/reserv map
390 * deleted. The region/reserv map for ranges without associated 394 * deleted. The region/reserv map for ranges without associated
391 * pages are not modified. 395 * pages are not modified. Page faults can race with hole punch.
392 * 396 * This is indicated if we find a mapped page.
393 * Callers of this routine must hold the i_mmap_rwsem in write mode to prevent
394 * races with page faults.
395 *
396 * Note: If the passed end of range value is beyond the end of file, but 397 * Note: If the passed end of range value is beyond the end of file, but
397 * not LLONG_MAX this routine still performs a hole punch operation. 398 * not LLONG_MAX this routine still performs a hole punch operation.
398 */ 399 */
@@ -422,14 +423,32 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
422 423
423 for (i = 0; i < pagevec_count(&pvec); ++i) { 424 for (i = 0; i < pagevec_count(&pvec); ++i) {
424 struct page *page = pvec.pages[i]; 425 struct page *page = pvec.pages[i];
426 u32 hash;
425 427
426 index = page->index; 428 index = page->index;
429 hash = hugetlb_fault_mutex_hash(h, current->mm,
430 &pseudo_vma,
431 mapping, index, 0);
432 mutex_lock(&hugetlb_fault_mutex_table[hash]);
433
427 /* 434 /*
428 * A mapped page is impossible as callers should unmap 435 * If page is mapped, it was faulted in after being
429 * all references before calling. And, i_mmap_rwsem 436 * unmapped in caller. Unmap (again) now after taking
430 * prevents the creation of additional mappings. 437 * the fault mutex. The mutex will prevent faults
438 * until we finish removing the page.
439 *
440 * This race can only happen in the hole punch case.
441 * Getting here in a truncate operation is a bug.
431 */ 442 */
432 VM_BUG_ON(page_mapped(page)); 443 if (unlikely(page_mapped(page))) {
444 BUG_ON(truncate_op);
445
446 i_mmap_lock_write(mapping);
447 hugetlb_vmdelete_list(&mapping->i_mmap,
448 index * pages_per_huge_page(h),
449 (index + 1) * pages_per_huge_page(h));
450 i_mmap_unlock_write(mapping);
451 }
433 452
434 lock_page(page); 453 lock_page(page);
435 /* 454 /*
@@ -451,6 +470,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
451 } 470 }
452 471
453 unlock_page(page); 472 unlock_page(page);
473 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
454 } 474 }
455 huge_pagevec_release(&pvec); 475 huge_pagevec_release(&pvec);
456 cond_resched(); 476 cond_resched();
@@ -462,20 +482,9 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
462 482
463static void hugetlbfs_evict_inode(struct inode *inode) 483static void hugetlbfs_evict_inode(struct inode *inode)
464{ 484{
465 struct address_space *mapping = inode->i_mapping;
466 struct resv_map *resv_map; 485 struct resv_map *resv_map;
467 486
468 /*
469 * The vfs layer guarantees that there are no other users of this
470 * inode. Therefore, it would be safe to call remove_inode_hugepages
471 * without holding i_mmap_rwsem. We acquire and hold here to be
472 * consistent with other callers. Since there will be no contention
473 * on the semaphore, overhead is negligible.
474 */
475 i_mmap_lock_write(mapping);
476 remove_inode_hugepages(inode, 0, LLONG_MAX); 487 remove_inode_hugepages(inode, 0, LLONG_MAX);
477 i_mmap_unlock_write(mapping);
478
479 resv_map = (struct resv_map *)inode->i_mapping->private_data; 488 resv_map = (struct resv_map *)inode->i_mapping->private_data;
480 /* root inode doesn't have the resv_map, so we should check it */ 489 /* root inode doesn't have the resv_map, so we should check it */
481 if (resv_map) 490 if (resv_map)
@@ -496,8 +505,8 @@ static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
496 i_mmap_lock_write(mapping); 505 i_mmap_lock_write(mapping);
497 if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)) 506 if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
498 hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0); 507 hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0);
499 remove_inode_hugepages(inode, offset, LLONG_MAX);
500 i_mmap_unlock_write(mapping); 508 i_mmap_unlock_write(mapping);
509 remove_inode_hugepages(inode, offset, LLONG_MAX);
501 return 0; 510 return 0;
502} 511}
503 512
@@ -531,8 +540,8 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
531 hugetlb_vmdelete_list(&mapping->i_mmap, 540 hugetlb_vmdelete_list(&mapping->i_mmap,
532 hole_start >> PAGE_SHIFT, 541 hole_start >> PAGE_SHIFT,
533 hole_end >> PAGE_SHIFT); 542 hole_end >> PAGE_SHIFT);
534 remove_inode_hugepages(inode, hole_start, hole_end);
535 i_mmap_unlock_write(mapping); 543 i_mmap_unlock_write(mapping);
544 remove_inode_hugepages(inode, hole_start, hole_end);
536 inode_unlock(inode); 545 inode_unlock(inode);
537 } 546 }
538 547
@@ -615,11 +624,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
615 /* addr is the offset within the file (zero based) */ 624 /* addr is the offset within the file (zero based) */
616 addr = index * hpage_size; 625 addr = index * hpage_size;
617 626
618 /* 627 /* mutex taken here, fault path and hole punch */
619 * fault mutex taken here, protects against fault path
620 * and hole punch. inode_lock previously taken protects
621 * against truncation.
622 */
623 hash = hugetlb_fault_mutex_hash(h, mm, &pseudo_vma, mapping, 628 hash = hugetlb_fault_mutex_hash(h, mm, &pseudo_vma, mapping,
624 index, addr); 629 index, addr);
625 mutex_lock(&hugetlb_fault_mutex_table[hash]); 630 mutex_lock(&hugetlb_fault_mutex_table[hash]);
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 5736c942c85b..2d4fc2d33810 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -1365,6 +1365,13 @@ enum drm_dp_quirk {
1365 * to 16 bits. So will give a constant value (0x8000) for compatability. 1365 * to 16 bits. So will give a constant value (0x8000) for compatability.
1366 */ 1366 */
1367 DP_DPCD_QUIRK_CONSTANT_N, 1367 DP_DPCD_QUIRK_CONSTANT_N,
1368 /**
1369 * @DP_DPCD_QUIRK_NO_PSR:
1370 *
1371 * The device does not support PSR even if reports that it supports or
1372 * driver still need to implement proper handling for such device.
1373 */
1374 DP_DPCD_QUIRK_NO_PSR,
1368}; 1375};
1369 1376
1370/** 1377/**
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 59f005b419cf..727af08e5ea6 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -616,7 +616,8 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
616 struct drm_dp_mst_topology_mgr *mgr); 616 struct drm_dp_mst_topology_mgr *mgr);
617 617
618void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); 618void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);
619int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr); 619int __must_check
620drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr);
620struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state, 621struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state,
621 struct drm_dp_mst_topology_mgr *mgr); 622 struct drm_dp_mst_topology_mgr *mgr);
622int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, 623int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index 68bb09c29ce8..a420c07904bc 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -35,6 +35,7 @@
35#define CEPH_OPT_NOMSGAUTH (1<<4) /* don't require msg signing feat */ 35#define CEPH_OPT_NOMSGAUTH (1<<4) /* don't require msg signing feat */
36#define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */ 36#define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */
37#define CEPH_OPT_NOMSGSIGN (1<<6) /* don't sign msgs */ 37#define CEPH_OPT_NOMSGSIGN (1<<6) /* don't sign msgs */
38#define CEPH_OPT_ABORT_ON_FULL (1<<7) /* abort w/ ENOSPC when full */
38 39
39#define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY) 40#define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY)
40 41
@@ -53,7 +54,7 @@ struct ceph_options {
53 unsigned long osd_request_timeout; /* jiffies */ 54 unsigned long osd_request_timeout; /* jiffies */
54 55
55 /* 56 /*
56 * any type that can't be simply compared or doesn't need need 57 * any type that can't be simply compared or doesn't need
57 * to be compared should go beyond this point, 58 * to be compared should go beyond this point,
58 * ceph_compare_options() should be updated accordingly 59 * ceph_compare_options() should be updated accordingly
59 */ 60 */
@@ -281,7 +282,8 @@ extern struct ceph_options *ceph_parse_options(char *options,
281 const char *dev_name, const char *dev_name_end, 282 const char *dev_name, const char *dev_name_end,
282 int (*parse_extra_token)(char *c, void *private), 283 int (*parse_extra_token)(char *c, void *private),
283 void *private); 284 void *private);
284int ceph_print_client_options(struct seq_file *m, struct ceph_client *client); 285int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
286 bool show_all);
285extern void ceph_destroy_options(struct ceph_options *opt); 287extern void ceph_destroy_options(struct ceph_options *opt);
286extern int ceph_compare_options(struct ceph_options *new_opt, 288extern int ceph_compare_options(struct ceph_options *new_opt,
287 struct ceph_client *client); 289 struct ceph_client *client);
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 7a2af5034278..2294f963dab7 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -354,7 +354,6 @@ struct ceph_osd_client {
354 struct rb_root linger_map_checks; 354 struct rb_root linger_map_checks;
355 atomic_t num_requests; 355 atomic_t num_requests;
356 atomic_t num_homeless; 356 atomic_t num_homeless;
357 bool abort_on_full; /* abort w/ ENOSPC when full */
358 int abort_err; 357 int abort_err;
359 struct delayed_work timeout_work; 358 struct delayed_work timeout_work;
360 struct delayed_work osds_timeout_work; 359 struct delayed_work osds_timeout_work;
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 5776da43da97..dd8268f5f5f0 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -68,7 +68,7 @@
68 */ 68 */
69#define uninitialized_var(x) x = x 69#define uninitialized_var(x) x = x
70 70
71#ifdef RETPOLINE 71#ifdef CONFIG_RETPOLINE
72#define __noretpoline __attribute__((__indirect_branch__("keep"))) 72#define __noretpoline __attribute__((__indirect_branch__("keep")))
73#endif 73#endif
74 74
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index cc4a507d7ca4..842f9189537b 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -520,6 +520,12 @@ enum pgdat_flags {
520 PGDAT_RECLAIM_LOCKED, /* prevents concurrent reclaim */ 520 PGDAT_RECLAIM_LOCKED, /* prevents concurrent reclaim */
521}; 521};
522 522
523enum zone_flags {
524 ZONE_BOOSTED_WATERMARK, /* zone recently boosted watermarks.
525 * Cleared when kswapd is woken.
526 */
527};
528
523static inline unsigned long zone_managed_pages(struct zone *zone) 529static inline unsigned long zone_managed_pages(struct zone *zone)
524{ 530{
525 return (unsigned long)atomic_long_read(&zone->managed_pages); 531 return (unsigned long)atomic_long_read(&zone->managed_pages);
diff --git a/include/linux/module.h b/include/linux/module.h
index 9a21fe3509af..8fa38d3e7538 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -828,7 +828,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
828static inline void module_bug_cleanup(struct module *mod) {} 828static inline void module_bug_cleanup(struct module *mod) {}
829#endif /* CONFIG_GENERIC_BUG */ 829#endif /* CONFIG_GENERIC_BUG */
830 830
831#ifdef RETPOLINE 831#ifdef CONFIG_RETPOLINE
832extern bool retpoline_module_ok(bool has_retpoline); 832extern bool retpoline_module_ok(bool has_retpoline);
833#else 833#else
834static inline bool retpoline_module_ok(bool has_retpoline) 834static inline bool retpoline_module_ok(bool has_retpoline)
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 0a2a88e5a383..b895f4e79868 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -108,6 +108,7 @@ void dev_pm_opp_put(struct dev_pm_opp *opp);
108int dev_pm_opp_add(struct device *dev, unsigned long freq, 108int dev_pm_opp_add(struct device *dev, unsigned long freq,
109 unsigned long u_volt); 109 unsigned long u_volt);
110void dev_pm_opp_remove(struct device *dev, unsigned long freq); 110void dev_pm_opp_remove(struct device *dev, unsigned long freq);
111void dev_pm_opp_remove_all_dynamic(struct device *dev);
111 112
112int dev_pm_opp_enable(struct device *dev, unsigned long freq); 113int dev_pm_opp_enable(struct device *dev, unsigned long freq);
113 114
@@ -217,6 +218,10 @@ static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
217{ 218{
218} 219}
219 220
221static inline void dev_pm_opp_remove_all_dynamic(struct device *dev)
222{
223}
224
220static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) 225static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
221{ 226{
222 return 0; 227 return 0;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 89541d248893..224666226e87 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -995,7 +995,7 @@ struct task_struct {
995 /* cg_list protected by css_set_lock and tsk->alloc_lock: */ 995 /* cg_list protected by css_set_lock and tsk->alloc_lock: */
996 struct list_head cg_list; 996 struct list_head cg_list;
997#endif 997#endif
998#ifdef CONFIG_RESCTRL 998#ifdef CONFIG_X86_RESCTRL
999 u32 closid; 999 u32 closid;
1000 u32 rmid; 1000 u32 rmid;
1001#endif 1001#endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 36a7e3f18e69..f28acd952d03 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -400,6 +400,8 @@ enum {
400/* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */ 400/* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
401#define AUDIT_ARCH_PPC64 (EM_PPC64|__AUDIT_ARCH_64BIT) 401#define AUDIT_ARCH_PPC64 (EM_PPC64|__AUDIT_ARCH_64BIT)
402#define AUDIT_ARCH_PPC64LE (EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 402#define AUDIT_ARCH_PPC64LE (EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
403#define AUDIT_ARCH_RISCV32 (EM_RISCV|__AUDIT_ARCH_LE)
404#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
403#define AUDIT_ARCH_S390 (EM_S390) 405#define AUDIT_ARCH_S390 (EM_S390)
404#define AUDIT_ARCH_S390X (EM_S390|__AUDIT_ARCH_64BIT) 406#define AUDIT_ARCH_S390X (EM_S390|__AUDIT_ARCH_64BIT)
405#define AUDIT_ARCH_SH (EM_SH) 407#define AUDIT_ARCH_SH (EM_SH)
diff --git a/kernel/fork.c b/kernel/fork.c
index a60459947f18..b69248e6f0e0 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -217,6 +217,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
217 memset(s->addr, 0, THREAD_SIZE); 217 memset(s->addr, 0, THREAD_SIZE);
218 218
219 tsk->stack_vm_area = s; 219 tsk->stack_vm_area = s;
220 tsk->stack = s->addr;
220 return s->addr; 221 return s->addr;
221 } 222 }
222 223
@@ -1833,8 +1834,6 @@ static __latent_entropy struct task_struct *copy_process(
1833 1834
1834 posix_cpu_timers_init(p); 1835 posix_cpu_timers_init(p);
1835 1836
1836 p->start_time = ktime_get_ns();
1837 p->real_start_time = ktime_get_boot_ns();
1838 p->io_context = NULL; 1837 p->io_context = NULL;
1839 audit_set_context(p, NULL); 1838 audit_set_context(p, NULL);
1840 cgroup_fork(p); 1839 cgroup_fork(p);
@@ -2001,6 +2000,17 @@ static __latent_entropy struct task_struct *copy_process(
2001 goto bad_fork_free_pid; 2000 goto bad_fork_free_pid;
2002 2001
2003 /* 2002 /*
2003 * From this point on we must avoid any synchronous user-space
2004 * communication until we take the tasklist-lock. In particular, we do
2005 * not want user-space to be able to predict the process start-time by
2006 * stalling fork(2) after we recorded the start_time but before it is
2007 * visible to the system.
2008 */
2009
2010 p->start_time = ktime_get_ns();
2011 p->real_start_time = ktime_get_boot_ns();
2012
2013 /*
2004 * Make it visible to the rest of the system, but dont wake it up yet. 2014 * Make it visible to the rest of the system, but dont wake it up yet.
2005 * Need tasklist lock for parent etc handling! 2015 * Need tasklist lock for parent etc handling!
2006 */ 2016 */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 745088810965..df2e7dd5ff17 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3238,7 +3238,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3238 struct page *ptepage; 3238 struct page *ptepage;
3239 unsigned long addr; 3239 unsigned long addr;
3240 int cow; 3240 int cow;
3241 struct address_space *mapping = vma->vm_file->f_mapping;
3242 struct hstate *h = hstate_vma(vma); 3241 struct hstate *h = hstate_vma(vma);
3243 unsigned long sz = huge_page_size(h); 3242 unsigned long sz = huge_page_size(h);
3244 struct mmu_notifier_range range; 3243 struct mmu_notifier_range range;
@@ -3250,23 +3249,13 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3250 mmu_notifier_range_init(&range, src, vma->vm_start, 3249 mmu_notifier_range_init(&range, src, vma->vm_start,
3251 vma->vm_end); 3250 vma->vm_end);
3252 mmu_notifier_invalidate_range_start(&range); 3251 mmu_notifier_invalidate_range_start(&range);
3253 } else {
3254 /*
3255 * For shared mappings i_mmap_rwsem must be held to call
3256 * huge_pte_alloc, otherwise the returned ptep could go
3257 * away if part of a shared pmd and another thread calls
3258 * huge_pmd_unshare.
3259 */
3260 i_mmap_lock_read(mapping);
3261 } 3252 }
3262 3253
3263 for (addr = vma->vm_start; addr < vma->vm_end; addr += sz) { 3254 for (addr = vma->vm_start; addr < vma->vm_end; addr += sz) {
3264 spinlock_t *src_ptl, *dst_ptl; 3255 spinlock_t *src_ptl, *dst_ptl;
3265
3266 src_pte = huge_pte_offset(src, addr, sz); 3256 src_pte = huge_pte_offset(src, addr, sz);
3267 if (!src_pte) 3257 if (!src_pte)
3268 continue; 3258 continue;
3269
3270 dst_pte = huge_pte_alloc(dst, addr, sz); 3259 dst_pte = huge_pte_alloc(dst, addr, sz);
3271 if (!dst_pte) { 3260 if (!dst_pte) {
3272 ret = -ENOMEM; 3261 ret = -ENOMEM;
@@ -3337,8 +3326,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3337 3326
3338 if (cow) 3327 if (cow)
3339 mmu_notifier_invalidate_range_end(&range); 3328 mmu_notifier_invalidate_range_end(&range);
3340 else
3341 i_mmap_unlock_read(mapping);
3342 3329
3343 return ret; 3330 return ret;
3344} 3331}
@@ -3755,16 +3742,16 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
3755 } 3742 }
3756 3743
3757 /* 3744 /*
3758 * We can not race with truncation due to holding i_mmap_rwsem. 3745 * Use page lock to guard against racing truncation
3759 * Check once here for faults beyond end of file. 3746 * before we get page_table_lock.
3760 */ 3747 */
3761 size = i_size_read(mapping->host) >> huge_page_shift(h);
3762 if (idx >= size)
3763 goto out;
3764
3765retry: 3748retry:
3766 page = find_lock_page(mapping, idx); 3749 page = find_lock_page(mapping, idx);
3767 if (!page) { 3750 if (!page) {
3751 size = i_size_read(mapping->host) >> huge_page_shift(h);
3752 if (idx >= size)
3753 goto out;
3754
3768 /* 3755 /*
3769 * Check for page in userfault range 3756 * Check for page in userfault range
3770 */ 3757 */
@@ -3784,18 +3771,14 @@ retry:
3784 }; 3771 };
3785 3772
3786 /* 3773 /*
3787 * hugetlb_fault_mutex and i_mmap_rwsem must be 3774 * hugetlb_fault_mutex must be dropped before
3788 * dropped before handling userfault. Reacquire 3775 * handling userfault. Reacquire after handling
3789 * after handling fault to make calling code simpler. 3776 * fault to make calling code simpler.
3790 */ 3777 */
3791 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, 3778 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping,
3792 idx, haddr); 3779 idx, haddr);
3793 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 3780 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
3794 i_mmap_unlock_read(mapping);
3795
3796 ret = handle_userfault(&vmf, VM_UFFD_MISSING); 3781 ret = handle_userfault(&vmf, VM_UFFD_MISSING);
3797
3798 i_mmap_lock_read(mapping);
3799 mutex_lock(&hugetlb_fault_mutex_table[hash]); 3782 mutex_lock(&hugetlb_fault_mutex_table[hash]);
3800 goto out; 3783 goto out;
3801 } 3784 }
@@ -3854,6 +3837,9 @@ retry:
3854 } 3837 }
3855 3838
3856 ptl = huge_pte_lock(h, mm, ptep); 3839 ptl = huge_pte_lock(h, mm, ptep);
3840 size = i_size_read(mapping->host) >> huge_page_shift(h);
3841 if (idx >= size)
3842 goto backout;
3857 3843
3858 ret = 0; 3844 ret = 0;
3859 if (!huge_pte_none(huge_ptep_get(ptep))) 3845 if (!huge_pte_none(huge_ptep_get(ptep)))
@@ -3940,11 +3926,6 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3940 3926
3941 ptep = huge_pte_offset(mm, haddr, huge_page_size(h)); 3927 ptep = huge_pte_offset(mm, haddr, huge_page_size(h));
3942 if (ptep) { 3928 if (ptep) {
3943 /*
3944 * Since we hold no locks, ptep could be stale. That is
3945 * OK as we are only making decisions based on content and
3946 * not actually modifying content here.
3947 */
3948 entry = huge_ptep_get(ptep); 3929 entry = huge_ptep_get(ptep);
3949 if (unlikely(is_hugetlb_entry_migration(entry))) { 3930 if (unlikely(is_hugetlb_entry_migration(entry))) {
3950 migration_entry_wait_huge(vma, mm, ptep); 3931 migration_entry_wait_huge(vma, mm, ptep);
@@ -3952,33 +3933,20 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3952 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) 3933 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry)))
3953 return VM_FAULT_HWPOISON_LARGE | 3934 return VM_FAULT_HWPOISON_LARGE |
3954 VM_FAULT_SET_HINDEX(hstate_index(h)); 3935 VM_FAULT_SET_HINDEX(hstate_index(h));
3936 } else {
3937 ptep = huge_pte_alloc(mm, haddr, huge_page_size(h));
3938 if (!ptep)
3939 return VM_FAULT_OOM;
3955 } 3940 }
3956 3941
3957 /*
3958 * Acquire i_mmap_rwsem before calling huge_pte_alloc and hold
3959 * until finished with ptep. This serves two purposes:
3960 * 1) It prevents huge_pmd_unshare from being called elsewhere
3961 * and making the ptep no longer valid.
3962 * 2) It synchronizes us with file truncation.
3963 *
3964 * ptep could have already be assigned via huge_pte_offset. That
3965 * is OK, as huge_pte_alloc will return the same value unless
3966 * something changed.
3967 */
3968 mapping = vma->vm_file->f_mapping; 3942 mapping = vma->vm_file->f_mapping;
3969 i_mmap_lock_read(mapping); 3943 idx = vma_hugecache_offset(h, vma, haddr);
3970 ptep = huge_pte_alloc(mm, haddr, huge_page_size(h));
3971 if (!ptep) {
3972 i_mmap_unlock_read(mapping);
3973 return VM_FAULT_OOM;
3974 }
3975 3944
3976 /* 3945 /*
3977 * Serialize hugepage allocation and instantiation, so that we don't 3946 * Serialize hugepage allocation and instantiation, so that we don't
3978 * get spurious allocation failures if two CPUs race to instantiate 3947 * get spurious allocation failures if two CPUs race to instantiate
3979 * the same page in the page cache. 3948 * the same page in the page cache.
3980 */ 3949 */
3981 idx = vma_hugecache_offset(h, vma, haddr);
3982 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, haddr); 3950 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, haddr);
3983 mutex_lock(&hugetlb_fault_mutex_table[hash]); 3951 mutex_lock(&hugetlb_fault_mutex_table[hash]);
3984 3952
@@ -4066,7 +4034,6 @@ out_ptl:
4066 } 4034 }
4067out_mutex: 4035out_mutex:
4068 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 4036 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
4069 i_mmap_unlock_read(mapping);
4070 /* 4037 /*
4071 * Generally it's safe to hold refcount during waiting page lock. But 4038 * Generally it's safe to hold refcount during waiting page lock. But
4072 * here we just wait to defer the next page fault to avoid busy loop and 4039 * here we just wait to defer the next page fault to avoid busy loop and
@@ -4671,12 +4638,10 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
4671 * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc() 4638 * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
4672 * and returns the corresponding pte. While this is not necessary for the 4639 * and returns the corresponding pte. While this is not necessary for the
4673 * !shared pmd case because we can allocate the pmd later as well, it makes the 4640 * !shared pmd case because we can allocate the pmd later as well, it makes the
4674 * code much cleaner. 4641 * code much cleaner. pmd allocation is essential for the shared case because
4675 * 4642 * pud has to be populated inside the same i_mmap_rwsem section - otherwise
4676 * This routine must be called with i_mmap_rwsem held in at least read mode. 4643 * racing tasks could either miss the sharing (see huge_pte_offset) or select a
4677 * For hugetlbfs, this prevents removal of any page table entries associated 4644 * bad pmd for sharing.
4678 * with the address space. This is important as we are setting up sharing
4679 * based on existing page table entries (mappings).
4680 */ 4645 */
4681pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) 4646pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
4682{ 4647{
@@ -4693,6 +4658,7 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
4693 if (!vma_shareable(vma, addr)) 4658 if (!vma_shareable(vma, addr))
4694 return (pte_t *)pmd_alloc(mm, pud, addr); 4659 return (pte_t *)pmd_alloc(mm, pud, addr);
4695 4660
4661 i_mmap_lock_write(mapping);
4696 vma_interval_tree_foreach(svma, &mapping->i_mmap, idx, idx) { 4662 vma_interval_tree_foreach(svma, &mapping->i_mmap, idx, idx) {
4697 if (svma == vma) 4663 if (svma == vma)
4698 continue; 4664 continue;
@@ -4722,6 +4688,7 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
4722 spin_unlock(ptl); 4688 spin_unlock(ptl);
4723out: 4689out:
4724 pte = (pte_t *)pmd_alloc(mm, pud, addr); 4690 pte = (pte_t *)pmd_alloc(mm, pud, addr);
4691 i_mmap_unlock_write(mapping);
4725 return pte; 4692 return pte;
4726} 4693}
4727 4694
@@ -4732,7 +4699,7 @@ out:
4732 * indicated by page_count > 1, unmap is achieved by clearing pud and 4699 * indicated by page_count > 1, unmap is achieved by clearing pud and
4733 * decrementing the ref count. If count == 1, the pte page is not shared. 4700 * decrementing the ref count. If count == 1, the pte page is not shared.
4734 * 4701 *
4735 * Called with page table lock held and i_mmap_rwsem held in write mode. 4702 * called with page table lock held.
4736 * 4703 *
4737 * returns: 1 successfully unmapped a shared pte page 4704 * returns: 1 successfully unmapped a shared pte page
4738 * 0 the underlying pte page is not shared, or it is the last user 4705 * 0 the underlying pte page is not shared, or it is the last user
diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 03d5d1374ca7..73c9cbfdedf4 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -298,8 +298,6 @@ void kasan_cache_create(struct kmem_cache *cache, unsigned int *size,
298 return; 298 return;
299 } 299 }
300 300
301 cache->align = round_up(cache->align, KASAN_SHADOW_SCALE_SIZE);
302
303 *flags |= SLAB_KASAN; 301 *flags |= SLAB_KASAN;
304} 302}
305 303
@@ -349,28 +347,43 @@ void kasan_poison_object_data(struct kmem_cache *cache, void *object)
349} 347}
350 348
351/* 349/*
352 * Since it's desirable to only call object contructors once during slab 350 * This function assigns a tag to an object considering the following:
353 * allocation, we preassign tags to all such objects. Also preassign tags for 351 * 1. A cache might have a constructor, which might save a pointer to a slab
354 * SLAB_TYPESAFE_BY_RCU slabs to avoid use-after-free reports. 352 * object somewhere (e.g. in the object itself). We preassign a tag for
355 * For SLAB allocator we can't preassign tags randomly since the freelist is 353 * each object in caches with constructors during slab creation and reuse
356 * stored as an array of indexes instead of a linked list. Assign tags based 354 * the same tag each time a particular object is allocated.
357 * on objects indexes, so that objects that are next to each other get 355 * 2. A cache might be SLAB_TYPESAFE_BY_RCU, which means objects can be
358 * different tags. 356 * accessed after being freed. We preassign tags for objects in these
359 * After a tag is assigned, the object always gets allocated with the same tag. 357 * caches as well.
360 * The reason is that we can't change tags for objects with constructors on 358 * 3. For SLAB allocator we can't preassign tags randomly since the freelist
361 * reallocation (even for non-SLAB_TYPESAFE_BY_RCU), because the constructor 359 * is stored as an array of indexes instead of a linked list. Assign tags
362 * code can save the pointer to the object somewhere (e.g. in the object 360 * based on objects indexes, so that objects that are next to each other
363 * itself). Then if we retag it, the old saved pointer will become invalid. 361 * get different tags.
364 */ 362 */
365static u8 assign_tag(struct kmem_cache *cache, const void *object, bool new) 363static u8 assign_tag(struct kmem_cache *cache, const void *object,
364 bool init, bool krealloc)
366{ 365{
366 /* Reuse the same tag for krealloc'ed objects. */
367 if (krealloc)
368 return get_tag(object);
369
370 /*
371 * If the cache neither has a constructor nor has SLAB_TYPESAFE_BY_RCU
372 * set, assign a tag when the object is being allocated (init == false).
373 */
367 if (!cache->ctor && !(cache->flags & SLAB_TYPESAFE_BY_RCU)) 374 if (!cache->ctor && !(cache->flags & SLAB_TYPESAFE_BY_RCU))
368 return new ? KASAN_TAG_KERNEL : random_tag(); 375 return init ? KASAN_TAG_KERNEL : random_tag();
369 376
377 /* For caches that either have a constructor or SLAB_TYPESAFE_BY_RCU: */
370#ifdef CONFIG_SLAB 378#ifdef CONFIG_SLAB
379 /* For SLAB assign tags based on the object index in the freelist. */
371 return (u8)obj_to_index(cache, virt_to_page(object), (void *)object); 380 return (u8)obj_to_index(cache, virt_to_page(object), (void *)object);
372#else 381#else
373 return new ? random_tag() : get_tag(object); 382 /*
383 * For SLUB assign a random tag during slab creation, otherwise reuse
384 * the already assigned tag.
385 */
386 return init ? random_tag() : get_tag(object);
374#endif 387#endif
375} 388}
376 389
@@ -386,7 +399,8 @@ void * __must_check kasan_init_slab_obj(struct kmem_cache *cache,
386 __memset(alloc_info, 0, sizeof(*alloc_info)); 399 __memset(alloc_info, 0, sizeof(*alloc_info));
387 400
388 if (IS_ENABLED(CONFIG_KASAN_SW_TAGS)) 401 if (IS_ENABLED(CONFIG_KASAN_SW_TAGS))
389 object = set_tag(object, assign_tag(cache, object, true)); 402 object = set_tag(object,
403 assign_tag(cache, object, true, false));
390 404
391 return (void *)object; 405 return (void *)object;
392} 406}
@@ -452,8 +466,8 @@ bool kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip)
452 return __kasan_slab_free(cache, object, ip, true); 466 return __kasan_slab_free(cache, object, ip, true);
453} 467}
454 468
455void * __must_check kasan_kmalloc(struct kmem_cache *cache, const void *object, 469static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object,
456 size_t size, gfp_t flags) 470 size_t size, gfp_t flags, bool krealloc)
457{ 471{
458 unsigned long redzone_start; 472 unsigned long redzone_start;
459 unsigned long redzone_end; 473 unsigned long redzone_end;
@@ -471,7 +485,7 @@ void * __must_check kasan_kmalloc(struct kmem_cache *cache, const void *object,
471 KASAN_SHADOW_SCALE_SIZE); 485 KASAN_SHADOW_SCALE_SIZE);
472 486
473 if (IS_ENABLED(CONFIG_KASAN_SW_TAGS)) 487 if (IS_ENABLED(CONFIG_KASAN_SW_TAGS))
474 tag = assign_tag(cache, object, false); 488 tag = assign_tag(cache, object, false, krealloc);
475 489
476 /* Tag is ignored in set_tag without CONFIG_KASAN_SW_TAGS */ 490 /* Tag is ignored in set_tag without CONFIG_KASAN_SW_TAGS */
477 kasan_unpoison_shadow(set_tag(object, tag), size); 491 kasan_unpoison_shadow(set_tag(object, tag), size);
@@ -483,6 +497,12 @@ void * __must_check kasan_kmalloc(struct kmem_cache *cache, const void *object,
483 497
484 return set_tag(object, tag); 498 return set_tag(object, tag);
485} 499}
500
501void * __must_check kasan_kmalloc(struct kmem_cache *cache, const void *object,
502 size_t size, gfp_t flags)
503{
504 return __kasan_kmalloc(cache, object, size, flags, false);
505}
486EXPORT_SYMBOL(kasan_kmalloc); 506EXPORT_SYMBOL(kasan_kmalloc);
487 507
488void * __must_check kasan_kmalloc_large(const void *ptr, size_t size, 508void * __must_check kasan_kmalloc_large(const void *ptr, size_t size,
@@ -522,7 +542,8 @@ void * __must_check kasan_krealloc(const void *object, size_t size, gfp_t flags)
522 if (unlikely(!PageSlab(page))) 542 if (unlikely(!PageSlab(page)))
523 return kasan_kmalloc_large(object, size, flags); 543 return kasan_kmalloc_large(object, size, flags);
524 else 544 else
525 return kasan_kmalloc(page->slab_cache, object, size, flags); 545 return __kasan_kmalloc(page->slab_cache, object, size,
546 flags, true);
526} 547}
527 548
528void kasan_poison_kfree(void *ptr, unsigned long ip) 549void kasan_poison_kfree(void *ptr, unsigned long ip)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 6379fff1a5ff..7c72f2a95785 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -966,7 +966,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
966 enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS; 966 enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
967 struct address_space *mapping; 967 struct address_space *mapping;
968 LIST_HEAD(tokill); 968 LIST_HEAD(tokill);
969 bool unmap_success = true; 969 bool unmap_success;
970 int kill = 1, forcekill; 970 int kill = 1, forcekill;
971 struct page *hpage = *hpagep; 971 struct page *hpage = *hpagep;
972 bool mlocked = PageMlocked(hpage); 972 bool mlocked = PageMlocked(hpage);
@@ -1028,19 +1028,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
1028 if (kill) 1028 if (kill)
1029 collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED); 1029 collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
1030 1030
1031 if (!PageHuge(hpage)) { 1031 unmap_success = try_to_unmap(hpage, ttu);
1032 unmap_success = try_to_unmap(hpage, ttu);
1033 } else if (mapping) {
1034 /*
1035 * For hugetlb pages, try_to_unmap could potentially call
1036 * huge_pmd_unshare. Because of this, take semaphore in
1037 * write mode here and set TTU_RMAP_LOCKED to indicate we
1038 * have taken the lock at this higer level.
1039 */
1040 i_mmap_lock_write(mapping);
1041 unmap_success = try_to_unmap(hpage, ttu|TTU_RMAP_LOCKED);
1042 i_mmap_unlock_write(mapping);
1043 }
1044 if (!unmap_success) 1032 if (!unmap_success)
1045 pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n", 1033 pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n",
1046 pfn, page_mapcount(hpage)); 1034 pfn, page_mapcount(hpage));
diff --git a/mm/memory.c b/mm/memory.c
index a52663c0612d..e11ca9dd823f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2994,6 +2994,28 @@ static vm_fault_t __do_fault(struct vm_fault *vmf)
2994 struct vm_area_struct *vma = vmf->vma; 2994 struct vm_area_struct *vma = vmf->vma;
2995 vm_fault_t ret; 2995 vm_fault_t ret;
2996 2996
2997 /*
2998 * Preallocate pte before we take page_lock because this might lead to
2999 * deadlocks for memcg reclaim which waits for pages under writeback:
3000 * lock_page(A)
3001 * SetPageWriteback(A)
3002 * unlock_page(A)
3003 * lock_page(B)
3004 * lock_page(B)
3005 * pte_alloc_pne
3006 * shrink_page_list
3007 * wait_on_page_writeback(A)
3008 * SetPageWriteback(B)
3009 * unlock_page(B)
3010 * # flush A, B to clear the writeback
3011 */
3012 if (pmd_none(*vmf->pmd) && !vmf->prealloc_pte) {
3013 vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm);
3014 if (!vmf->prealloc_pte)
3015 return VM_FAULT_OOM;
3016 smp_wmb(); /* See comment in __pte_alloc() */
3017 }
3018
2997 ret = vma->vm_ops->fault(vmf); 3019 ret = vma->vm_ops->fault(vmf);
2998 if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY | 3020 if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY |
2999 VM_FAULT_DONE_COW))) 3021 VM_FAULT_DONE_COW)))
@@ -4077,8 +4099,8 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
4077 goto out; 4099 goto out;
4078 4100
4079 if (range) { 4101 if (range) {
4080 range->start = address & PAGE_MASK; 4102 mmu_notifier_range_init(range, mm, address & PAGE_MASK,
4081 range->end = range->start + PAGE_SIZE; 4103 (address & PAGE_MASK) + PAGE_SIZE);
4082 mmu_notifier_invalidate_range_start(range); 4104 mmu_notifier_invalidate_range_start(range);
4083 } 4105 }
4084 ptep = pte_offset_map_lock(mm, pmd, address, ptlp); 4106 ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
diff --git a/mm/migrate.c b/mm/migrate.c
index ccf8966caf6f..a16b15090df3 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1324,19 +1324,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
1324 goto put_anon; 1324 goto put_anon;
1325 1325
1326 if (page_mapped(hpage)) { 1326 if (page_mapped(hpage)) {
1327 struct address_space *mapping = page_mapping(hpage);
1328
1329 /*
1330 * try_to_unmap could potentially call huge_pmd_unshare.
1331 * Because of this, take semaphore in write mode here and
1332 * set TTU_RMAP_LOCKED to let lower levels know we have
1333 * taken the lock.
1334 */
1335 i_mmap_lock_write(mapping);
1336 try_to_unmap(hpage, 1327 try_to_unmap(hpage,
1337 TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS| 1328 TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
1338 TTU_RMAP_LOCKED);
1339 i_mmap_unlock_write(mapping);
1340 page_was_mapped = 1; 1329 page_was_mapped = 1;
1341 } 1330 }
1342 1331
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index cde5dac6229a..d295c9bc01a8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2214,7 +2214,7 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,
2214 */ 2214 */
2215 boost_watermark(zone); 2215 boost_watermark(zone);
2216 if (alloc_flags & ALLOC_KSWAPD) 2216 if (alloc_flags & ALLOC_KSWAPD)
2217 wakeup_kswapd(zone, 0, 0, zone_idx(zone)); 2217 set_bit(ZONE_BOOSTED_WATERMARK, &zone->flags);
2218 2218
2219 /* We are not allowed to try stealing from the whole block */ 2219 /* We are not allowed to try stealing from the whole block */
2220 if (!whole_block) 2220 if (!whole_block)
@@ -3102,6 +3102,12 @@ struct page *rmqueue(struct zone *preferred_zone,
3102 local_irq_restore(flags); 3102 local_irq_restore(flags);
3103 3103
3104out: 3104out:
3105 /* Separate test+clear to avoid unnecessary atomics */
3106 if (test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags)) {
3107 clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags);
3108 wakeup_kswapd(zone, 0, 0, zone_idx(zone));
3109 }
3110
3105 VM_BUG_ON_PAGE(page && bad_range(zone, page), page); 3111 VM_BUG_ON_PAGE(page && bad_range(zone, page), page);
3106 return page; 3112 return page;
3107 3113
diff --git a/mm/rmap.c b/mm/rmap.c
index 21a26cf51114..0454ecc29537 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -25,7 +25,6 @@
25 * page->flags PG_locked (lock_page) 25 * page->flags PG_locked (lock_page)
26 * hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share) 26 * hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share)
27 * mapping->i_mmap_rwsem 27 * mapping->i_mmap_rwsem
28 * hugetlb_fault_mutex (hugetlbfs specific page fault mutex)
29 * anon_vma->rwsem 28 * anon_vma->rwsem
30 * mm->page_table_lock or pte_lock 29 * mm->page_table_lock or pte_lock
31 * zone_lru_lock (in mark_page_accessed, isolate_lru_page) 30 * zone_lru_lock (in mark_page_accessed, isolate_lru_page)
@@ -1372,16 +1371,13 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1372 * Note that the page can not be free in this function as call of 1371 * Note that the page can not be free in this function as call of
1373 * try_to_unmap() must hold a reference on the page. 1372 * try_to_unmap() must hold a reference on the page.
1374 */ 1373 */
1375 mmu_notifier_range_init(&range, vma->vm_mm, vma->vm_start, 1374 mmu_notifier_range_init(&range, vma->vm_mm, address,
1376 min(vma->vm_end, vma->vm_start + 1375 min(vma->vm_end, address +
1377 (PAGE_SIZE << compound_order(page)))); 1376 (PAGE_SIZE << compound_order(page))));
1378 if (PageHuge(page)) { 1377 if (PageHuge(page)) {
1379 /* 1378 /*
1380 * If sharing is possible, start and end will be adjusted 1379 * If sharing is possible, start and end will be adjusted
1381 * accordingly. 1380 * accordingly.
1382 *
1383 * If called for a huge page, caller must hold i_mmap_rwsem
1384 * in write mode as it is possible to call huge_pmd_unshare.
1385 */ 1381 */
1386 adjust_range_if_pmd_sharing_possible(vma, &range.start, 1382 adjust_range_if_pmd_sharing_possible(vma, &range.start,
1387 &range.end); 1383 &range.end);
diff --git a/mm/slab.c b/mm/slab.c
index 73fe23e649c9..78eb8c5bf4e4 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -666,8 +666,10 @@ static struct alien_cache *__alloc_alien_cache(int node, int entries,
666 struct alien_cache *alc = NULL; 666 struct alien_cache *alc = NULL;
667 667
668 alc = kmalloc_node(memsize, gfp, node); 668 alc = kmalloc_node(memsize, gfp, node);
669 init_arraycache(&alc->ac, entries, batch); 669 if (alc) {
670 spin_lock_init(&alc->lock); 670 init_arraycache(&alc->ac, entries, batch);
671 spin_lock_init(&alc->lock);
672 }
671 return alc; 673 return alc;
672} 674}
673 675
diff --git a/mm/slub.c b/mm/slub.c
index 36c0befeebd8..1e3d0ec4e200 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3846,6 +3846,8 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page,
3846 unsigned int offset; 3846 unsigned int offset;
3847 size_t object_size; 3847 size_t object_size;
3848 3848
3849 ptr = kasan_reset_tag(ptr);
3850
3849 /* Find object and usable object size. */ 3851 /* Find object and usable object size. */
3850 s = page->slab_cache; 3852 s = page->slab_cache;
3851 3853
diff --git a/mm/usercopy.c b/mm/usercopy.c
index 852eb4e53f06..14faadcedd06 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -247,7 +247,8 @@ static DEFINE_STATIC_KEY_FALSE_RO(bypass_usercopy_checks);
247/* 247/*
248 * Validates that the given object is: 248 * Validates that the given object is:
249 * - not bogus address 249 * - not bogus address
250 * - known-safe heap or stack object 250 * - fully contained by stack (or stack frame, when available)
251 * - fully within SLAB object (or object whitelist area, when available)
251 * - not in kernel text 252 * - not in kernel text
252 */ 253 */
253void __check_object_size(const void *ptr, unsigned long n, bool to_user) 254void __check_object_size(const void *ptr, unsigned long n, bool to_user)
@@ -262,9 +263,6 @@ void __check_object_size(const void *ptr, unsigned long n, bool to_user)
262 /* Check for invalid addresses. */ 263 /* Check for invalid addresses. */
263 check_bogus_address((const unsigned long)ptr, n, to_user); 264 check_bogus_address((const unsigned long)ptr, n, to_user);
264 265
265 /* Check for bad heap object. */
266 check_heap_object(ptr, n, to_user);
267
268 /* Check for bad stack object. */ 266 /* Check for bad stack object. */
269 switch (check_stack_object(ptr, n)) { 267 switch (check_stack_object(ptr, n)) {
270 case NOT_STACK: 268 case NOT_STACK:
@@ -282,6 +280,9 @@ void __check_object_size(const void *ptr, unsigned long n, bool to_user)
282 usercopy_abort("process stack", NULL, to_user, 0, n); 280 usercopy_abort("process stack", NULL, to_user, 0, n);
283 } 281 }
284 282
283 /* Check for bad heap object. */
284 check_heap_object(ptr, n, to_user);
285
285 /* Check for object in kernel to avoid text exposure. */ 286 /* Check for object in kernel to avoid text exposure. */
286 check_kernel_text_object((const unsigned long)ptr, n, to_user); 287 check_kernel_text_object((const unsigned long)ptr, n, to_user);
287} 288}
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 065c1ce191c4..d59b5a73dfb3 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -267,14 +267,10 @@ retry:
267 VM_BUG_ON(dst_addr & ~huge_page_mask(h)); 267 VM_BUG_ON(dst_addr & ~huge_page_mask(h));
268 268
269 /* 269 /*
270 * Serialize via i_mmap_rwsem and hugetlb_fault_mutex. 270 * Serialize via hugetlb_fault_mutex
271 * i_mmap_rwsem ensures the dst_pte remains valid even
272 * in the case of shared pmds. fault mutex prevents
273 * races with other faulting threads.
274 */ 271 */
275 mapping = dst_vma->vm_file->f_mapping;
276 i_mmap_lock_read(mapping);
277 idx = linear_page_index(dst_vma, dst_addr); 272 idx = linear_page_index(dst_vma, dst_addr);
273 mapping = dst_vma->vm_file->f_mapping;
278 hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping, 274 hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping,
279 idx, dst_addr); 275 idx, dst_addr);
280 mutex_lock(&hugetlb_fault_mutex_table[hash]); 276 mutex_lock(&hugetlb_fault_mutex_table[hash]);
@@ -283,7 +279,6 @@ retry:
283 dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h)); 279 dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h));
284 if (!dst_pte) { 280 if (!dst_pte) {
285 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 281 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
286 i_mmap_unlock_read(mapping);
287 goto out_unlock; 282 goto out_unlock;
288 } 283 }
289 284
@@ -291,7 +286,6 @@ retry:
291 dst_pteval = huge_ptep_get(dst_pte); 286 dst_pteval = huge_ptep_get(dst_pte);
292 if (!huge_pte_none(dst_pteval)) { 287 if (!huge_pte_none(dst_pteval)) {
293 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 288 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
294 i_mmap_unlock_read(mapping);
295 goto out_unlock; 289 goto out_unlock;
296 } 290 }
297 291
@@ -299,7 +293,6 @@ retry:
299 dst_addr, src_addr, &page); 293 dst_addr, src_addr, &page);
300 294
301 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 295 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
302 i_mmap_unlock_read(mapping);
303 vm_alloc_shared = vm_shared; 296 vm_alloc_shared = vm_shared;
304 297
305 cond_resched(); 298 cond_resched();
diff --git a/mm/util.c b/mm/util.c
index 4df23d64aac7..1ea055138043 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -478,7 +478,7 @@ bool page_mapped(struct page *page)
478 return true; 478 return true;
479 if (PageHuge(page)) 479 if (PageHuge(page))
480 return false; 480 return false;
481 for (i = 0; i < hpage_nr_pages(page); i++) { 481 for (i = 0; i < (1 << compound_order(page)); i++) {
482 if (atomic_read(&page[i]._mapcount) >= 0) 482 if (atomic_read(&page[i]._mapcount) >= 0)
483 return true; 483 return true;
484 } 484 }
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 87afb9ec4c68..9cab80207ced 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -255,6 +255,7 @@ enum {
255 Opt_nocephx_sign_messages, 255 Opt_nocephx_sign_messages,
256 Opt_tcp_nodelay, 256 Opt_tcp_nodelay,
257 Opt_notcp_nodelay, 257 Opt_notcp_nodelay,
258 Opt_abort_on_full,
258}; 259};
259 260
260static match_table_t opt_tokens = { 261static match_table_t opt_tokens = {
@@ -280,6 +281,7 @@ static match_table_t opt_tokens = {
280 {Opt_nocephx_sign_messages, "nocephx_sign_messages"}, 281 {Opt_nocephx_sign_messages, "nocephx_sign_messages"},
281 {Opt_tcp_nodelay, "tcp_nodelay"}, 282 {Opt_tcp_nodelay, "tcp_nodelay"},
282 {Opt_notcp_nodelay, "notcp_nodelay"}, 283 {Opt_notcp_nodelay, "notcp_nodelay"},
284 {Opt_abort_on_full, "abort_on_full"},
283 {-1, NULL} 285 {-1, NULL}
284}; 286};
285 287
@@ -535,6 +537,10 @@ ceph_parse_options(char *options, const char *dev_name,
535 opt->flags &= ~CEPH_OPT_TCP_NODELAY; 537 opt->flags &= ~CEPH_OPT_TCP_NODELAY;
536 break; 538 break;
537 539
540 case Opt_abort_on_full:
541 opt->flags |= CEPH_OPT_ABORT_ON_FULL;
542 break;
543
538 default: 544 default:
539 BUG_ON(token); 545 BUG_ON(token);
540 } 546 }
@@ -549,7 +555,8 @@ out:
549} 555}
550EXPORT_SYMBOL(ceph_parse_options); 556EXPORT_SYMBOL(ceph_parse_options);
551 557
552int ceph_print_client_options(struct seq_file *m, struct ceph_client *client) 558int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
559 bool show_all)
553{ 560{
554 struct ceph_options *opt = client->options; 561 struct ceph_options *opt = client->options;
555 size_t pos = m->count; 562 size_t pos = m->count;
@@ -574,6 +581,8 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)
574 seq_puts(m, "nocephx_sign_messages,"); 581 seq_puts(m, "nocephx_sign_messages,");
575 if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0) 582 if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0)
576 seq_puts(m, "notcp_nodelay,"); 583 seq_puts(m, "notcp_nodelay,");
584 if (show_all && (opt->flags & CEPH_OPT_ABORT_ON_FULL))
585 seq_puts(m, "abort_on_full,");
577 586
578 if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT) 587 if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT)
579 seq_printf(m, "mount_timeout=%d,", 588 seq_printf(m, "mount_timeout=%d,",
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index 02952605d121..46f65709a6ff 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -375,7 +375,7 @@ static int client_options_show(struct seq_file *s, void *p)
375 struct ceph_client *client = s->private; 375 struct ceph_client *client = s->private;
376 int ret; 376 int ret;
377 377
378 ret = ceph_print_client_options(s, client); 378 ret = ceph_print_client_options(s, client, true);
379 if (ret) 379 if (ret)
380 return ret; 380 return ret;
381 381
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d23a9f81f3d7..fa9530dd876e 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2315,7 +2315,7 @@ again:
2315 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || 2315 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
2316 pool_full(osdc, req->r_t.base_oloc.pool))) { 2316 pool_full(osdc, req->r_t.base_oloc.pool))) {
2317 dout("req %p full/pool_full\n", req); 2317 dout("req %p full/pool_full\n", req);
2318 if (osdc->abort_on_full) { 2318 if (ceph_test_opt(osdc->client, ABORT_ON_FULL)) {
2319 err = -ENOSPC; 2319 err = -ENOSPC;
2320 } else { 2320 } else {
2321 pr_warn_ratelimited("FULL or reached pool quota\n"); 2321 pr_warn_ratelimited("FULL or reached pool quota\n");
@@ -2545,7 +2545,7 @@ static void ceph_osdc_abort_on_full(struct ceph_osd_client *osdc)
2545{ 2545{
2546 bool victims = false; 2546 bool victims = false;
2547 2547
2548 if (osdc->abort_on_full && 2548 if (ceph_test_opt(osdc->client, ABORT_ON_FULL) &&
2549 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc))) 2549 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc)))
2550 for_each_request(osdc, abort_on_full_fn, &victims); 2550 for_each_request(osdc, abort_on_full_fn, &victims);
2551} 2551}
diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
index 4920903c8009..fb43a814d4c0 100644
--- a/samples/seccomp/Makefile
+++ b/samples/seccomp/Makefile
@@ -34,6 +34,7 @@ HOSTCFLAGS_bpf-direct.o += $(MFLAG)
34HOSTCFLAGS_dropper.o += $(MFLAG) 34HOSTCFLAGS_dropper.o += $(MFLAG)
35HOSTCFLAGS_bpf-helper.o += $(MFLAG) 35HOSTCFLAGS_bpf-helper.o += $(MFLAG)
36HOSTCFLAGS_bpf-fancy.o += $(MFLAG) 36HOSTCFLAGS_bpf-fancy.o += $(MFLAG)
37HOSTCFLAGS_user-trap.o += $(MFLAG)
37HOSTLDLIBS_bpf-direct += $(MFLAG) 38HOSTLDLIBS_bpf-direct += $(MFLAG)
38HOSTLDLIBS_bpf-fancy += $(MFLAG) 39HOSTLDLIBS_bpf-fancy += $(MFLAG)
39HOSTLDLIBS_dropper += $(MFLAG) 40HOSTLDLIBS_dropper += $(MFLAG)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0de2fb236640..26bf886bd168 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2185,7 +2185,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)
2185/* Cannot check for assembler */ 2185/* Cannot check for assembler */
2186static void add_retpoline(struct buffer *b) 2186static void add_retpoline(struct buffer *b)
2187{ 2187{
2188 buf_printf(b, "\n#ifdef RETPOLINE\n"); 2188 buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
2189 buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n"); 2189 buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
2190 buf_printf(b, "#endif\n"); 2190 buf_printf(b, "#endif\n");
2191} 2191}
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 598d140bb7cb..5fc497c6d738 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -903,6 +903,9 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
903 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 903 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
904 int i; 904 int i;
905 905
906 if (!ins)
907 return 0;
908
906 snd_info_free_entry(ins->proc_sym_info_entry); 909 snd_info_free_entry(ins->proc_sym_info_entry);
907 ins->proc_sym_info_entry = NULL; 910 ins->proc_sym_info_entry = NULL;
908 911
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index aee4cbd29d53..0b3e7a18ca78 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4102,6 +4102,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
4102 case 0x10ec0295: 4102 case 0x10ec0295:
4103 case 0x10ec0289: 4103 case 0x10ec0289:
4104 case 0x10ec0299: 4104 case 0x10ec0299:
4105 alc_process_coef_fw(codec, alc225_pre_hsmode);
4105 alc_process_coef_fw(codec, coef0225); 4106 alc_process_coef_fw(codec, coef0225);
4106 break; 4107 break;
4107 case 0x10ec0867: 4108 case 0x10ec0867:
@@ -5440,6 +5441,13 @@ static void alc_fixup_headset_jack(struct hda_codec *codec,
5440 } 5441 }
5441} 5442}
5442 5443
5444static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
5445 const struct hda_fixup *fix, int action)
5446{
5447 if (action == HDA_FIXUP_ACT_PRE_PROBE)
5448 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5449}
5450
5443/* for hda_fixup_thinkpad_acpi() */ 5451/* for hda_fixup_thinkpad_acpi() */
5444#include "thinkpad_helper.c" 5452#include "thinkpad_helper.c"
5445 5453
@@ -5549,6 +5557,7 @@ enum {
5549 ALC293_FIXUP_LENOVO_SPK_NOISE, 5557 ALC293_FIXUP_LENOVO_SPK_NOISE,
5550 ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, 5558 ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
5551 ALC255_FIXUP_DELL_SPK_NOISE, 5559 ALC255_FIXUP_DELL_SPK_NOISE,
5560 ALC225_FIXUP_DISABLE_MIC_VREF,
5552 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, 5561 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
5553 ALC295_FIXUP_DISABLE_DAC3, 5562 ALC295_FIXUP_DISABLE_DAC3,
5554 ALC280_FIXUP_HP_HEADSET_MIC, 5563 ALC280_FIXUP_HP_HEADSET_MIC,
@@ -6268,6 +6277,12 @@ static const struct hda_fixup alc269_fixups[] = {
6268 .chained = true, 6277 .chained = true,
6269 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE 6278 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6270 }, 6279 },
6280 [ALC225_FIXUP_DISABLE_MIC_VREF] = {
6281 .type = HDA_FIXUP_FUNC,
6282 .v.func = alc_fixup_disable_mic_vref,
6283 .chained = true,
6284 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
6285 },
6271 [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = { 6286 [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6272 .type = HDA_FIXUP_VERBS, 6287 .type = HDA_FIXUP_VERBS,
6273 .v.verbs = (const struct hda_verb[]) { 6288 .v.verbs = (const struct hda_verb[]) {
@@ -6277,7 +6292,7 @@ static const struct hda_fixup alc269_fixups[] = {
6277 {} 6292 {}
6278 }, 6293 },
6279 .chained = true, 6294 .chained = true,
6280 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE 6295 .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
6281 }, 6296 },
6282 [ALC280_FIXUP_HP_HEADSET_MIC] = { 6297 [ALC280_FIXUP_HP_HEADSET_MIC] = {
6283 .type = HDA_FIXUP_FUNC, 6298 .type = HDA_FIXUP_FUNC,
@@ -6584,6 +6599,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6584 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 6599 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6585 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 6600 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
6586 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB), 6601 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
6602 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6587 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 6603 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6588 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 6604 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6589 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 6605 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
diff --git a/sound/usb/card.c b/sound/usb/card.c
index a105947eaf55..746a72e23cf9 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -246,7 +246,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
246 h1 = snd_usb_find_csint_desc(host_iface->extra, 246 h1 = snd_usb_find_csint_desc(host_iface->extra,
247 host_iface->extralen, 247 host_iface->extralen,
248 NULL, UAC_HEADER); 248 NULL, UAC_HEADER);
249 if (!h1) { 249 if (!h1 || h1->bLength < sizeof(*h1)) {
250 dev_err(&dev->dev, "cannot find UAC_HEADER\n"); 250 dev_err(&dev->dev, "cannot find UAC_HEADER\n");
251 return -EINVAL; 251 return -EINVAL;
252 } 252 }
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index c63c84b54969..e7d441d0e839 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -753,8 +753,9 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state,
753 struct uac_mixer_unit_descriptor *desc) 753 struct uac_mixer_unit_descriptor *desc)
754{ 754{
755 int mu_channels; 755 int mu_channels;
756 void *c;
756 757
757 if (desc->bLength < 11) 758 if (desc->bLength < sizeof(*desc))
758 return -EINVAL; 759 return -EINVAL;
759 if (!desc->bNrInPins) 760 if (!desc->bNrInPins)
760 return -EINVAL; 761 return -EINVAL;
@@ -763,6 +764,8 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state,
763 case UAC_VERSION_1: 764 case UAC_VERSION_1:
764 case UAC_VERSION_2: 765 case UAC_VERSION_2:
765 default: 766 default:
767 if (desc->bLength < sizeof(*desc) + desc->bNrInPins + 1)
768 return 0; /* no bmControls -> skip */
766 mu_channels = uac_mixer_unit_bNrChannels(desc); 769 mu_channels = uac_mixer_unit_bNrChannels(desc);
767 break; 770 break;
768 case UAC_VERSION_3: 771 case UAC_VERSION_3:
@@ -772,7 +775,11 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state,
772 } 775 }
773 776
774 if (!mu_channels) 777 if (!mu_channels)
775 return -EINVAL; 778 return 0;
779
780 c = uac_mixer_unit_bmControls(desc, state->mixer->protocol);
781 if (c - (void *)desc + (mu_channels - 1) / 8 >= desc->bLength)
782 return 0; /* no bmControls -> skip */
776 783
777 return mu_channels; 784 return mu_channels;
778} 785}
@@ -944,7 +951,7 @@ static int check_input_term(struct mixer_build *state, int id,
944 struct uac_mixer_unit_descriptor *d = p1; 951 struct uac_mixer_unit_descriptor *d = p1;
945 952
946 err = uac_mixer_unit_get_channels(state, d); 953 err = uac_mixer_unit_get_channels(state, d);
947 if (err < 0) 954 if (err <= 0)
948 return err; 955 return err;
949 956
950 term->channels = err; 957 term->channels = err;
@@ -2068,11 +2075,15 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,
2068 2075
2069 if (state->mixer->protocol == UAC_VERSION_2) { 2076 if (state->mixer->protocol == UAC_VERSION_2) {
2070 struct uac2_input_terminal_descriptor *d_v2 = raw_desc; 2077 struct uac2_input_terminal_descriptor *d_v2 = raw_desc;
2078 if (d_v2->bLength < sizeof(*d_v2))
2079 return -EINVAL;
2071 control = UAC2_TE_CONNECTOR; 2080 control = UAC2_TE_CONNECTOR;
2072 term_id = d_v2->bTerminalID; 2081 term_id = d_v2->bTerminalID;
2073 bmctls = le16_to_cpu(d_v2->bmControls); 2082 bmctls = le16_to_cpu(d_v2->bmControls);
2074 } else if (state->mixer->protocol == UAC_VERSION_3) { 2083 } else if (state->mixer->protocol == UAC_VERSION_3) {
2075 struct uac3_input_terminal_descriptor *d_v3 = raw_desc; 2084 struct uac3_input_terminal_descriptor *d_v3 = raw_desc;
2085 if (d_v3->bLength < sizeof(*d_v3))
2086 return -EINVAL;
2076 control = UAC3_TE_INSERTION; 2087 control = UAC3_TE_INSERTION;
2077 term_id = d_v3->bTerminalID; 2088 term_id = d_v3->bTerminalID;
2078 bmctls = le32_to_cpu(d_v3->bmControls); 2089 bmctls = le32_to_cpu(d_v3->bmControls);
@@ -2118,7 +2129,7 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid,
2118 if (err < 0) 2129 if (err < 0)
2119 continue; 2130 continue;
2120 /* no bmControls field (e.g. Maya44) -> ignore */ 2131 /* no bmControls field (e.g. Maya44) -> ignore */
2121 if (desc->bLength <= 10 + input_pins) 2132 if (!num_outs)
2122 continue; 2133 continue;
2123 err = check_input_term(state, desc->baSourceID[pin], &iterm); 2134 err = check_input_term(state, desc->baSourceID[pin], &iterm);
2124 if (err < 0) 2135 if (err < 0)
@@ -2314,7 +2325,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
2314 char *name) 2325 char *name)
2315{ 2326{
2316 struct uac_processing_unit_descriptor *desc = raw_desc; 2327 struct uac_processing_unit_descriptor *desc = raw_desc;
2317 int num_ins = desc->bNrInPins; 2328 int num_ins;
2318 struct usb_mixer_elem_info *cval; 2329 struct usb_mixer_elem_info *cval;
2319 struct snd_kcontrol *kctl; 2330 struct snd_kcontrol *kctl;
2320 int i, err, nameid, type, len; 2331 int i, err, nameid, type, len;
@@ -2329,7 +2340,13 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
2329 0, NULL, default_value_info 2340 0, NULL, default_value_info
2330 }; 2341 };
2331 2342
2332 if (desc->bLength < 13 || desc->bLength < 13 + num_ins || 2343 if (desc->bLength < 13) {
2344 usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid);
2345 return -EINVAL;
2346 }
2347
2348 num_ins = desc->bNrInPins;
2349 if (desc->bLength < 13 + num_ins ||
2333 desc->bLength < num_ins + uac_processing_unit_bControlSize(desc, state->mixer->protocol)) { 2350 desc->bLength < num_ins + uac_processing_unit_bControlSize(desc, state->mixer->protocol)) {
2334 usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid); 2351 usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid);
2335 return -EINVAL; 2352 return -EINVAL;
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 37fc0447c071..b345beb447bd 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3326,6 +3326,9 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
3326 } 3326 }
3327 } 3327 }
3328 }, 3328 },
3329 {
3330 .ifnum = -1
3331 },
3329 } 3332 }
3330 } 3333 }
3331}, 3334},
@@ -3369,6 +3372,9 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
3369 } 3372 }
3370 } 3373 }
3371 }, 3374 },
3375 {
3376 .ifnum = -1
3377 },
3372 } 3378 }
3373 } 3379 }
3374}, 3380},
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 96340f23f86d..ebbadb3a7094 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -768,7 +768,7 @@ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
768 * REG1: PLL binary search enable, soft mute enable. 768 * REG1: PLL binary search enable, soft mute enable.
769 */ 769 */
770 CM6206_REG1_PLLBIN_EN | 770 CM6206_REG1_PLLBIN_EN |
771 CM6206_REG1_SOFT_MUTE_EN | 771 CM6206_REG1_SOFT_MUTE_EN,
772 /* 772 /*
773 * REG2: enable output drivers, 773 * REG2: enable output drivers,
774 * select front channels to the headphone output, 774 * select front channels to the headphone output,
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 67cf849aa16b..d9e3de495c16 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -596,12 +596,8 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
596 csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT); 596 csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT);
597 597
598 if (!csep || csep->bLength < 7 || 598 if (!csep || csep->bLength < 7 ||
599 csep->bDescriptorSubtype != UAC_EP_GENERAL) { 599 csep->bDescriptorSubtype != UAC_EP_GENERAL)
600 usb_audio_warn(chip, 600 goto error;
601 "%u:%d : no or invalid class specific endpoint descriptor\n",
602 iface_no, altsd->bAlternateSetting);
603 return 0;
604 }
605 601
606 if (protocol == UAC_VERSION_1) { 602 if (protocol == UAC_VERSION_1) {
607 attributes = csep->bmAttributes; 603 attributes = csep->bmAttributes;
@@ -609,6 +605,8 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
609 struct uac2_iso_endpoint_descriptor *csep2 = 605 struct uac2_iso_endpoint_descriptor *csep2 =
610 (struct uac2_iso_endpoint_descriptor *) csep; 606 (struct uac2_iso_endpoint_descriptor *) csep;
611 607
608 if (csep2->bLength < sizeof(*csep2))
609 goto error;
612 attributes = csep->bmAttributes & UAC_EP_CS_ATTR_FILL_MAX; 610 attributes = csep->bmAttributes & UAC_EP_CS_ATTR_FILL_MAX;
613 611
614 /* emulate the endpoint attributes of a v1 device */ 612 /* emulate the endpoint attributes of a v1 device */
@@ -618,12 +616,20 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
618 struct uac3_iso_endpoint_descriptor *csep3 = 616 struct uac3_iso_endpoint_descriptor *csep3 =
619 (struct uac3_iso_endpoint_descriptor *) csep; 617 (struct uac3_iso_endpoint_descriptor *) csep;
620 618
619 if (csep3->bLength < sizeof(*csep3))
620 goto error;
621 /* emulate the endpoint attributes of a v1 device */ 621 /* emulate the endpoint attributes of a v1 device */
622 if (le32_to_cpu(csep3->bmControls) & UAC2_CONTROL_PITCH) 622 if (le32_to_cpu(csep3->bmControls) & UAC2_CONTROL_PITCH)
623 attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL; 623 attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
624 } 624 }
625 625
626 return attributes; 626 return attributes;
627
628 error:
629 usb_audio_warn(chip,
630 "%u:%d : no or invalid class specific endpoint descriptor\n",
631 iface_no, altsd->bAlternateSetting);
632 return 0;
627} 633}
628 634
629/* find an input terminal descriptor (either UAC1 or UAC2) with the given 635/* find an input terminal descriptor (either UAC1 or UAC2) with the given
@@ -631,13 +637,17 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
631 */ 637 */
632static void * 638static void *
633snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface, 639snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface,
634 int terminal_id) 640 int terminal_id, bool uac23)
635{ 641{
636 struct uac2_input_terminal_descriptor *term = NULL; 642 struct uac2_input_terminal_descriptor *term = NULL;
643 size_t minlen = uac23 ? sizeof(struct uac2_input_terminal_descriptor) :
644 sizeof(struct uac_input_terminal_descriptor);
637 645
638 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra, 646 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
639 ctrl_iface->extralen, 647 ctrl_iface->extralen,
640 term, UAC_INPUT_TERMINAL))) { 648 term, UAC_INPUT_TERMINAL))) {
649 if (term->bLength < minlen)
650 continue;
641 if (term->bTerminalID == terminal_id) 651 if (term->bTerminalID == terminal_id)
642 return term; 652 return term;
643 } 653 }
@@ -655,7 +665,8 @@ snd_usb_find_output_terminal_descriptor(struct usb_host_interface *ctrl_iface,
655 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra, 665 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
656 ctrl_iface->extralen, 666 ctrl_iface->extralen,
657 term, UAC_OUTPUT_TERMINAL))) { 667 term, UAC_OUTPUT_TERMINAL))) {
658 if (term->bTerminalID == terminal_id) 668 if (term->bLength >= sizeof(*term) &&
669 term->bTerminalID == terminal_id)
659 return term; 670 return term;
660 } 671 }
661 672
@@ -729,7 +740,8 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
729 format = le16_to_cpu(as->wFormatTag); /* remember the format value */ 740 format = le16_to_cpu(as->wFormatTag); /* remember the format value */
730 741
731 iterm = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf, 742 iterm = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
732 as->bTerminalLink); 743 as->bTerminalLink,
744 false);
733 if (iterm) { 745 if (iterm) {
734 num_channels = iterm->bNrChannels; 746 num_channels = iterm->bNrChannels;
735 chconfig = le16_to_cpu(iterm->wChannelConfig); 747 chconfig = le16_to_cpu(iterm->wChannelConfig);
@@ -764,7 +776,8 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
764 * to extract the clock 776 * to extract the clock
765 */ 777 */
766 input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf, 778 input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
767 as->bTerminalLink); 779 as->bTerminalLink,
780 true);
768 if (input_term) { 781 if (input_term) {
769 clock = input_term->bCSourceID; 782 clock = input_term->bCSourceID;
770 if (!chconfig && (num_channels == input_term->bNrChannels)) 783 if (!chconfig && (num_channels == input_term->bNrChannels))
@@ -998,7 +1011,8 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
998 * to extract the clock 1011 * to extract the clock
999 */ 1012 */
1000 input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf, 1013 input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
1001 as->bTerminalLink); 1014 as->bTerminalLink,
1015 true);
1002 if (input_term) { 1016 if (input_term) {
1003 clock = input_term->bCSourceID; 1017 clock = input_term->bCSourceID;
1004 goto found_clock; 1018 goto found_clock;
diff --git a/tools/arch/powerpc/include/uapi/asm/unistd.h b/tools/arch/powerpc/include/uapi/asm/unistd.h
deleted file mode 100644
index 985534d0b448..000000000000
--- a/tools/arch/powerpc/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,404 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2/*
3 * This file contains the system call numbers.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10#ifndef _UAPI_ASM_POWERPC_UNISTD_H_
11#define _UAPI_ASM_POWERPC_UNISTD_H_
12
13
14#define __NR_restart_syscall 0
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_waitpid 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_time 13
28#define __NR_mknod 14
29#define __NR_chmod 15
30#define __NR_lchown 16
31#define __NR_break 17
32#define __NR_oldstat 18
33#define __NR_lseek 19
34#define __NR_getpid 20
35#define __NR_mount 21
36#define __NR_umount 22
37#define __NR_setuid 23
38#define __NR_getuid 24
39#define __NR_stime 25
40#define __NR_ptrace 26
41#define __NR_alarm 27
42#define __NR_oldfstat 28
43#define __NR_pause 29
44#define __NR_utime 30
45#define __NR_stty 31
46#define __NR_gtty 32
47#define __NR_access 33
48#define __NR_nice 34
49#define __NR_ftime 35
50#define __NR_sync 36
51#define __NR_kill 37
52#define __NR_rename 38
53#define __NR_mkdir 39
54#define __NR_rmdir 40
55#define __NR_dup 41
56#define __NR_pipe 42
57#define __NR_times 43
58#define __NR_prof 44
59#define __NR_brk 45
60#define __NR_setgid 46
61#define __NR_getgid 47
62#define __NR_signal 48
63#define __NR_geteuid 49
64#define __NR_getegid 50
65#define __NR_acct 51
66#define __NR_umount2 52
67#define __NR_lock 53
68#define __NR_ioctl 54
69#define __NR_fcntl 55
70#define __NR_mpx 56
71#define __NR_setpgid 57
72#define __NR_ulimit 58
73#define __NR_oldolduname 59
74#define __NR_umask 60
75#define __NR_chroot 61
76#define __NR_ustat 62
77#define __NR_dup2 63
78#define __NR_getppid 64
79#define __NR_getpgrp 65
80#define __NR_setsid 66
81#define __NR_sigaction 67
82#define __NR_sgetmask 68
83#define __NR_ssetmask 69
84#define __NR_setreuid 70
85#define __NR_setregid 71
86#define __NR_sigsuspend 72
87#define __NR_sigpending 73
88#define __NR_sethostname 74
89#define __NR_setrlimit 75
90#define __NR_getrlimit 76
91#define __NR_getrusage 77
92#define __NR_gettimeofday 78
93#define __NR_settimeofday 79
94#define __NR_getgroups 80
95#define __NR_setgroups 81
96#define __NR_select 82
97#define __NR_symlink 83
98#define __NR_oldlstat 84
99#define __NR_readlink 85
100#define __NR_uselib 86
101#define __NR_swapon 87
102#define __NR_reboot 88
103#define __NR_readdir 89
104#define __NR_mmap 90
105#define __NR_munmap 91
106#define __NR_truncate 92
107#define __NR_ftruncate 93
108#define __NR_fchmod 94
109#define __NR_fchown 95
110#define __NR_getpriority 96
111#define __NR_setpriority 97
112#define __NR_profil 98
113#define __NR_statfs 99
114#define __NR_fstatfs 100
115#define __NR_ioperm 101
116#define __NR_socketcall 102
117#define __NR_syslog 103
118#define __NR_setitimer 104
119#define __NR_getitimer 105
120#define __NR_stat 106
121#define __NR_lstat 107
122#define __NR_fstat 108
123#define __NR_olduname 109
124#define __NR_iopl 110
125#define __NR_vhangup 111
126#define __NR_idle 112
127#define __NR_vm86 113
128#define __NR_wait4 114
129#define __NR_swapoff 115
130#define __NR_sysinfo 116
131#define __NR_ipc 117
132#define __NR_fsync 118
133#define __NR_sigreturn 119
134#define __NR_clone 120
135#define __NR_setdomainname 121
136#define __NR_uname 122
137#define __NR_modify_ldt 123
138#define __NR_adjtimex 124
139#define __NR_mprotect 125
140#define __NR_sigprocmask 126
141#define __NR_create_module 127
142#define __NR_init_module 128
143#define __NR_delete_module 129
144#define __NR_get_kernel_syms 130
145#define __NR_quotactl 131
146#define __NR_getpgid 132
147#define __NR_fchdir 133
148#define __NR_bdflush 134
149#define __NR_sysfs 135
150#define __NR_personality 136
151#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
152#define __NR_setfsuid 138
153#define __NR_setfsgid 139
154#define __NR__llseek 140
155#define __NR_getdents 141
156#define __NR__newselect 142
157#define __NR_flock 143
158#define __NR_msync 144
159#define __NR_readv 145
160#define __NR_writev 146
161#define __NR_getsid 147
162#define __NR_fdatasync 148
163#define __NR__sysctl 149
164#define __NR_mlock 150
165#define __NR_munlock 151
166#define __NR_mlockall 152
167#define __NR_munlockall 153
168#define __NR_sched_setparam 154
169#define __NR_sched_getparam 155
170#define __NR_sched_setscheduler 156
171#define __NR_sched_getscheduler 157
172#define __NR_sched_yield 158
173#define __NR_sched_get_priority_max 159
174#define __NR_sched_get_priority_min 160
175#define __NR_sched_rr_get_interval 161
176#define __NR_nanosleep 162
177#define __NR_mremap 163
178#define __NR_setresuid 164
179#define __NR_getresuid 165
180#define __NR_query_module 166
181#define __NR_poll 167
182#define __NR_nfsservctl 168
183#define __NR_setresgid 169
184#define __NR_getresgid 170
185#define __NR_prctl 171
186#define __NR_rt_sigreturn 172
187#define __NR_rt_sigaction 173
188#define __NR_rt_sigprocmask 174
189#define __NR_rt_sigpending 175
190#define __NR_rt_sigtimedwait 176
191#define __NR_rt_sigqueueinfo 177
192#define __NR_rt_sigsuspend 178
193#define __NR_pread64 179
194#define __NR_pwrite64 180
195#define __NR_chown 181
196#define __NR_getcwd 182
197#define __NR_capget 183
198#define __NR_capset 184
199#define __NR_sigaltstack 185
200#define __NR_sendfile 186
201#define __NR_getpmsg 187 /* some people actually want streams */
202#define __NR_putpmsg 188 /* some people actually want streams */
203#define __NR_vfork 189
204#define __NR_ugetrlimit 190 /* SuS compliant getrlimit */
205#define __NR_readahead 191
206#ifndef __powerpc64__ /* these are 32-bit only */
207#define __NR_mmap2 192
208#define __NR_truncate64 193
209#define __NR_ftruncate64 194
210#define __NR_stat64 195
211#define __NR_lstat64 196
212#define __NR_fstat64 197
213#endif
214#define __NR_pciconfig_read 198
215#define __NR_pciconfig_write 199
216#define __NR_pciconfig_iobase 200
217#define __NR_multiplexer 201
218#define __NR_getdents64 202
219#define __NR_pivot_root 203
220#ifndef __powerpc64__
221#define __NR_fcntl64 204
222#endif
223#define __NR_madvise 205
224#define __NR_mincore 206
225#define __NR_gettid 207
226#define __NR_tkill 208
227#define __NR_setxattr 209
228#define __NR_lsetxattr 210
229#define __NR_fsetxattr 211
230#define __NR_getxattr 212
231#define __NR_lgetxattr 213
232#define __NR_fgetxattr 214
233#define __NR_listxattr 215
234#define __NR_llistxattr 216
235#define __NR_flistxattr 217
236#define __NR_removexattr 218
237#define __NR_lremovexattr 219
238#define __NR_fremovexattr 220
239#define __NR_futex 221
240#define __NR_sched_setaffinity 222
241#define __NR_sched_getaffinity 223
242/* 224 currently unused */
243#define __NR_tuxcall 225
244#ifndef __powerpc64__
245#define __NR_sendfile64 226
246#endif
247#define __NR_io_setup 227
248#define __NR_io_destroy 228
249#define __NR_io_getevents 229
250#define __NR_io_submit 230
251#define __NR_io_cancel 231
252#define __NR_set_tid_address 232
253#define __NR_fadvise64 233
254#define __NR_exit_group 234
255#define __NR_lookup_dcookie 235
256#define __NR_epoll_create 236
257#define __NR_epoll_ctl 237
258#define __NR_epoll_wait 238
259#define __NR_remap_file_pages 239
260#define __NR_timer_create 240
261#define __NR_timer_settime 241
262#define __NR_timer_gettime 242
263#define __NR_timer_getoverrun 243
264#define __NR_timer_delete 244
265#define __NR_clock_settime 245
266#define __NR_clock_gettime 246
267#define __NR_clock_getres 247
268#define __NR_clock_nanosleep 248
269#define __NR_swapcontext 249
270#define __NR_tgkill 250
271#define __NR_utimes 251
272#define __NR_statfs64 252
273#define __NR_fstatfs64 253
274#ifndef __powerpc64__
275#define __NR_fadvise64_64 254
276#endif
277#define __NR_rtas 255
278#define __NR_sys_debug_setcontext 256
279/* Number 257 is reserved for vserver */
280#define __NR_migrate_pages 258
281#define __NR_mbind 259
282#define __NR_get_mempolicy 260
283#define __NR_set_mempolicy 261
284#define __NR_mq_open 262
285#define __NR_mq_unlink 263
286#define __NR_mq_timedsend 264
287#define __NR_mq_timedreceive 265
288#define __NR_mq_notify 266
289#define __NR_mq_getsetattr 267
290#define __NR_kexec_load 268
291#define __NR_add_key 269
292#define __NR_request_key 270
293#define __NR_keyctl 271
294#define __NR_waitid 272
295#define __NR_ioprio_set 273
296#define __NR_ioprio_get 274
297#define __NR_inotify_init 275
298#define __NR_inotify_add_watch 276
299#define __NR_inotify_rm_watch 277
300#define __NR_spu_run 278
301#define __NR_spu_create 279
302#define __NR_pselect6 280
303#define __NR_ppoll 281
304#define __NR_unshare 282
305#define __NR_splice 283
306#define __NR_tee 284
307#define __NR_vmsplice 285
308#define __NR_openat 286
309#define __NR_mkdirat 287
310#define __NR_mknodat 288
311#define __NR_fchownat 289
312#define __NR_futimesat 290
313#ifdef __powerpc64__
314#define __NR_newfstatat 291
315#else
316#define __NR_fstatat64 291
317#endif
318#define __NR_unlinkat 292
319#define __NR_renameat 293
320#define __NR_linkat 294
321#define __NR_symlinkat 295
322#define __NR_readlinkat 296
323#define __NR_fchmodat 297
324#define __NR_faccessat 298
325#define __NR_get_robust_list 299
326#define __NR_set_robust_list 300
327#define __NR_move_pages 301
328#define __NR_getcpu 302
329#define __NR_epoll_pwait 303
330#define __NR_utimensat 304
331#define __NR_signalfd 305
332#define __NR_timerfd_create 306
333#define __NR_eventfd 307
334#define __NR_sync_file_range2 308
335#define __NR_fallocate 309
336#define __NR_subpage_prot 310
337#define __NR_timerfd_settime 311
338#define __NR_timerfd_gettime 312
339#define __NR_signalfd4 313
340#define __NR_eventfd2 314
341#define __NR_epoll_create1 315
342#define __NR_dup3 316
343#define __NR_pipe2 317
344#define __NR_inotify_init1 318
345#define __NR_perf_event_open 319
346#define __NR_preadv 320
347#define __NR_pwritev 321
348#define __NR_rt_tgsigqueueinfo 322
349#define __NR_fanotify_init 323
350#define __NR_fanotify_mark 324
351#define __NR_prlimit64 325
352#define __NR_socket 326
353#define __NR_bind 327
354#define __NR_connect 328
355#define __NR_listen 329
356#define __NR_accept 330
357#define __NR_getsockname 331
358#define __NR_getpeername 332
359#define __NR_socketpair 333
360#define __NR_send 334
361#define __NR_sendto 335
362#define __NR_recv 336
363#define __NR_recvfrom 337
364#define __NR_shutdown 338
365#define __NR_setsockopt 339
366#define __NR_getsockopt 340
367#define __NR_sendmsg 341
368#define __NR_recvmsg 342
369#define __NR_recvmmsg 343
370#define __NR_accept4 344
371#define __NR_name_to_handle_at 345
372#define __NR_open_by_handle_at 346
373#define __NR_clock_adjtime 347
374#define __NR_syncfs 348
375#define __NR_sendmmsg 349
376#define __NR_setns 350
377#define __NR_process_vm_readv 351
378#define __NR_process_vm_writev 352
379#define __NR_finit_module 353
380#define __NR_kcmp 354
381#define __NR_sched_setattr 355
382#define __NR_sched_getattr 356
383#define __NR_renameat2 357
384#define __NR_seccomp 358
385#define __NR_getrandom 359
386#define __NR_memfd_create 360
387#define __NR_bpf 361
388#define __NR_execveat 362
389#define __NR_switch_endian 363
390#define __NR_userfaultfd 364
391#define __NR_membarrier 365
392#define __NR_mlock2 378
393#define __NR_copy_file_range 379
394#define __NR_preadv2 380
395#define __NR_pwritev2 381
396#define __NR_kexec_file_load 382
397#define __NR_statx 383
398#define __NR_pkey_alloc 384
399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387
402#define __NR_io_pgetevents 388
403
404#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/tools/arch/riscv/include/uapi/asm/bitsperlong.h b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
new file mode 100644
index 000000000000..0b3cb52fd29d
--- /dev/null
+++ b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 * Copyright (C) 2015 Regents of the University of California
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _UAPI_ASM_RISCV_BITSPERLONG_H
19#define _UAPI_ASM_RISCV_BITSPERLONG_H
20
21#define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8)
22
23#include <asm-generic/bitsperlong.h>
24
25#endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 28c4a502b419..6d6122524711 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -281,9 +281,11 @@
281#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ 281#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
282#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ 282#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
283#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */ 283#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
284#define X86_FEATURE_WBNOINVD (13*32+ 9) /* WBNOINVD instruction */
284#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */ 285#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */
285#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */ 286#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */
286#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */ 287#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */
288#define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* "" Single Thread Indirect Branch Predictors always-on preferred */
287#define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */ 289#define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */
288#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ 290#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */
289#define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */ 291#define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */
diff --git a/tools/arch/x86/include/asm/disabled-features.h b/tools/arch/x86/include/asm/disabled-features.h
index 33833d1909af..a5ea841cc6d2 100644
--- a/tools/arch/x86/include/asm/disabled-features.h
+++ b/tools/arch/x86/include/asm/disabled-features.h
@@ -16,6 +16,12 @@
16# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31)) 16# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31))
17#endif 17#endif
18 18
19#ifdef CONFIG_X86_SMAP
20# define DISABLE_SMAP 0
21#else
22# define DISABLE_SMAP (1<<(X86_FEATURE_SMAP & 31))
23#endif
24
19#ifdef CONFIG_X86_INTEL_UMIP 25#ifdef CONFIG_X86_INTEL_UMIP
20# define DISABLE_UMIP 0 26# define DISABLE_UMIP 0
21#else 27#else
@@ -68,7 +74,7 @@
68#define DISABLED_MASK6 0 74#define DISABLED_MASK6 0
69#define DISABLED_MASK7 (DISABLE_PTI) 75#define DISABLED_MASK7 (DISABLE_PTI)
70#define DISABLED_MASK8 0 76#define DISABLED_MASK8 0
71#define DISABLED_MASK9 (DISABLE_MPX) 77#define DISABLED_MASK9 (DISABLE_MPX|DISABLE_SMAP)
72#define DISABLED_MASK10 0 78#define DISABLED_MASK10 0
73#define DISABLED_MASK11 0 79#define DISABLED_MASK11 0
74#define DISABLED_MASK12 0 80#define DISABLED_MASK12 0
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index c7f3321fbe43..d90127298f12 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -738,9 +738,11 @@ __SYSCALL(__NR_statx, sys_statx)
738__SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents) 738__SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents)
739#define __NR_rseq 293 739#define __NR_rseq 293
740__SYSCALL(__NR_rseq, sys_rseq) 740__SYSCALL(__NR_rseq, sys_rseq)
741#define __NR_kexec_file_load 294
742__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)
741 743
742#undef __NR_syscalls 744#undef __NR_syscalls
743#define __NR_syscalls 294 745#define __NR_syscalls 295
744 746
745/* 747/*
746 * 32 bit systems traditionally used different 748 * 32 bit systems traditionally used different
diff --git a/tools/include/uapi/asm/bitsperlong.h b/tools/include/uapi/asm/bitsperlong.h
index 8dd6aefdafa4..fd92ce8388fc 100644
--- a/tools/include/uapi/asm/bitsperlong.h
+++ b/tools/include/uapi/asm/bitsperlong.h
@@ -13,6 +13,8 @@
13#include "../../arch/mips/include/uapi/asm/bitsperlong.h" 13#include "../../arch/mips/include/uapi/asm/bitsperlong.h"
14#elif defined(__ia64__) 14#elif defined(__ia64__)
15#include "../../arch/ia64/include/uapi/asm/bitsperlong.h" 15#include "../../arch/ia64/include/uapi/asm/bitsperlong.h"
16#elif defined(__riscv)
17#include "../../arch/riscv/include/uapi/asm/bitsperlong.h"
16#else 18#else
17#include <asm-generic/bitsperlong.h> 19#include <asm-generic/bitsperlong.h>
18#endif 20#endif
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index a4446f452040..298b2e197744 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -412,6 +412,14 @@ typedef struct drm_i915_irq_wait {
412 int irq_seq; 412 int irq_seq;
413} drm_i915_irq_wait_t; 413} drm_i915_irq_wait_t;
414 414
415/*
416 * Different modes of per-process Graphics Translation Table,
417 * see I915_PARAM_HAS_ALIASING_PPGTT
418 */
419#define I915_GEM_PPGTT_NONE 0
420#define I915_GEM_PPGTT_ALIASING 1
421#define I915_GEM_PPGTT_FULL 2
422
415/* Ioctl to query kernel params: 423/* Ioctl to query kernel params:
416 */ 424 */
417#define I915_PARAM_IRQ_ACTIVE 1 425#define I915_PARAM_IRQ_ACTIVE 1
diff --git a/tools/include/uapi/linux/fs.h b/tools/include/uapi/linux/fs.h
index a441ea1bfe6d..121e82ce296b 100644
--- a/tools/include/uapi/linux/fs.h
+++ b/tools/include/uapi/linux/fs.h
@@ -14,6 +14,11 @@
14#include <linux/ioctl.h> 14#include <linux/ioctl.h>
15#include <linux/types.h> 15#include <linux/types.h>
16 16
17/* Use of MS_* flags within the kernel is restricted to core mount(2) code. */
18#if !defined(__KERNEL__)
19#include <linux/mount.h>
20#endif
21
17/* 22/*
18 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change 23 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
19 * the file limit at runtime and only root can increase the per-process 24 * the file limit at runtime and only root can increase the per-process
@@ -101,57 +106,6 @@ struct inodes_stat_t {
101 106
102#define NR_FILE 8192 /* this can well be larger on a larger system */ 107#define NR_FILE 8192 /* this can well be larger on a larger system */
103 108
104
105/*
106 * These are the fs-independent mount-flags: up to 32 flags are supported
107 */
108#define MS_RDONLY 1 /* Mount read-only */
109#define MS_NOSUID 2 /* Ignore suid and sgid bits */
110#define MS_NODEV 4 /* Disallow access to device special files */
111#define MS_NOEXEC 8 /* Disallow program execution */
112#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
113#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
114#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
115#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
116#define MS_NOATIME 1024 /* Do not update access times. */
117#define MS_NODIRATIME 2048 /* Do not update directory access times */
118#define MS_BIND 4096
119#define MS_MOVE 8192
120#define MS_REC 16384
121#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
122 MS_VERBOSE is deprecated. */
123#define MS_SILENT 32768
124#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
125#define MS_UNBINDABLE (1<<17) /* change to unbindable */
126#define MS_PRIVATE (1<<18) /* change to private */
127#define MS_SLAVE (1<<19) /* change to slave */
128#define MS_SHARED (1<<20) /* change to shared */
129#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
130#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
131#define MS_I_VERSION (1<<23) /* Update inode I_version field */
132#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
133#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
134
135/* These sb flags are internal to the kernel */
136#define MS_SUBMOUNT (1<<26)
137#define MS_NOREMOTELOCK (1<<27)
138#define MS_NOSEC (1<<28)
139#define MS_BORN (1<<29)
140#define MS_ACTIVE (1<<30)
141#define MS_NOUSER (1<<31)
142
143/*
144 * Superblock flags that can be altered by MS_REMOUNT
145 */
146#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
147 MS_LAZYTIME)
148
149/*
150 * Old magic mount flag and mask
151 */
152#define MS_MGC_VAL 0xC0ED0000
153#define MS_MGC_MSK 0xffff0000
154
155/* 109/*
156 * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR. 110 * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR.
157 */ 111 */
@@ -269,7 +223,8 @@ struct fsxattr {
269#define FS_POLICY_FLAGS_PAD_16 0x02 223#define FS_POLICY_FLAGS_PAD_16 0x02
270#define FS_POLICY_FLAGS_PAD_32 0x03 224#define FS_POLICY_FLAGS_PAD_32 0x03
271#define FS_POLICY_FLAGS_PAD_MASK 0x03 225#define FS_POLICY_FLAGS_PAD_MASK 0x03
272#define FS_POLICY_FLAGS_VALID 0x03 226#define FS_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */
227#define FS_POLICY_FLAGS_VALID 0x07
273 228
274/* Encryption algorithms */ 229/* Encryption algorithms */
275#define FS_ENCRYPTION_MODE_INVALID 0 230#define FS_ENCRYPTION_MODE_INVALID 0
@@ -281,6 +236,7 @@ struct fsxattr {
281#define FS_ENCRYPTION_MODE_AES_128_CTS 6 236#define FS_ENCRYPTION_MODE_AES_128_CTS 6
282#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* Removed, do not use. */ 237#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* Removed, do not use. */
283#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* Removed, do not use. */ 238#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* Removed, do not use. */
239#define FS_ENCRYPTION_MODE_ADIANTUM 9
284 240
285struct fscrypt_policy { 241struct fscrypt_policy {
286 __u8 version; 242 __u8 version;
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 1debfa42cba1..d6533828123a 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -288,6 +288,7 @@ enum {
288 IFLA_BR_MCAST_IGMP_VERSION, 288 IFLA_BR_MCAST_IGMP_VERSION,
289 IFLA_BR_MCAST_MLD_VERSION, 289 IFLA_BR_MCAST_MLD_VERSION,
290 IFLA_BR_VLAN_STATS_PER_PORT, 290 IFLA_BR_VLAN_STATS_PER_PORT,
291 IFLA_BR_MULTI_BOOLOPT,
291 __IFLA_BR_MAX, 292 __IFLA_BR_MAX,
292}; 293};
293 294
@@ -533,6 +534,7 @@ enum {
533 IFLA_VXLAN_LABEL, 534 IFLA_VXLAN_LABEL,
534 IFLA_VXLAN_GPE, 535 IFLA_VXLAN_GPE,
535 IFLA_VXLAN_TTL_INHERIT, 536 IFLA_VXLAN_TTL_INHERIT,
537 IFLA_VXLAN_DF,
536 __IFLA_VXLAN_MAX 538 __IFLA_VXLAN_MAX
537}; 539};
538#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) 540#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
@@ -542,6 +544,14 @@ struct ifla_vxlan_port_range {
542 __be16 high; 544 __be16 high;
543}; 545};
544 546
547enum ifla_vxlan_df {
548 VXLAN_DF_UNSET = 0,
549 VXLAN_DF_SET,
550 VXLAN_DF_INHERIT,
551 __VXLAN_DF_END,
552 VXLAN_DF_MAX = __VXLAN_DF_END - 1,
553};
554
545/* GENEVE section */ 555/* GENEVE section */
546enum { 556enum {
547 IFLA_GENEVE_UNSPEC, 557 IFLA_GENEVE_UNSPEC,
@@ -557,10 +567,19 @@ enum {
557 IFLA_GENEVE_UDP_ZERO_CSUM6_RX, 567 IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
558 IFLA_GENEVE_LABEL, 568 IFLA_GENEVE_LABEL,
559 IFLA_GENEVE_TTL_INHERIT, 569 IFLA_GENEVE_TTL_INHERIT,
570 IFLA_GENEVE_DF,
560 __IFLA_GENEVE_MAX 571 __IFLA_GENEVE_MAX
561}; 572};
562#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1) 573#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
563 574
575enum ifla_geneve_df {
576 GENEVE_DF_UNSET = 0,
577 GENEVE_DF_SET,
578 GENEVE_DF_INHERIT,
579 __GENEVE_DF_END,
580 GENEVE_DF_MAX = __GENEVE_DF_END - 1,
581};
582
564/* PPP section */ 583/* PPP section */
565enum { 584enum {
566 IFLA_PPP_UNSPEC, 585 IFLA_PPP_UNSPEC,
diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
index 48e8a225b985..f6052e70bf40 100644
--- a/tools/include/uapi/linux/in.h
+++ b/tools/include/uapi/linux/in.h
@@ -266,10 +266,14 @@ struct sockaddr_in {
266 266
267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
268#define IN_MULTICAST(a) IN_CLASSD(a) 268#define IN_MULTICAST(a) IN_CLASSD(a)
269#define IN_MULTICAST_NET 0xF0000000 269#define IN_MULTICAST_NET 0xe0000000
270 270
271#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 271#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff)
272#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) 272#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
273
274#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
275#define IN_CLASSE_NET 0xffffffff
276#define IN_CLASSE_NSHIFT 0
273 277
274/* Address to accept any incoming messages. */ 278/* Address to accept any incoming messages. */
275#define INADDR_ANY ((unsigned long int) 0x00000000) 279#define INADDR_ANY ((unsigned long int) 0x00000000)
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 2b7a652c9fa4..6d4ea4b6c922 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -492,6 +492,17 @@ struct kvm_dirty_log {
492 }; 492 };
493}; 493};
494 494
495/* for KVM_CLEAR_DIRTY_LOG */
496struct kvm_clear_dirty_log {
497 __u32 slot;
498 __u32 num_pages;
499 __u64 first_page;
500 union {
501 void __user *dirty_bitmap; /* one bit per page */
502 __u64 padding2;
503 };
504};
505
495/* for KVM_SET_SIGNAL_MASK */ 506/* for KVM_SET_SIGNAL_MASK */
496struct kvm_signal_mask { 507struct kvm_signal_mask {
497 __u32 len; 508 __u32 len;
@@ -975,6 +986,8 @@ struct kvm_ppc_resize_hpt {
975#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 986#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
976#define KVM_CAP_EXCEPTION_PAYLOAD 164 987#define KVM_CAP_EXCEPTION_PAYLOAD 164
977#define KVM_CAP_ARM_VM_IPA_SIZE 165 988#define KVM_CAP_ARM_VM_IPA_SIZE 165
989#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166
990#define KVM_CAP_HYPERV_CPUID 167
978 991
979#ifdef KVM_CAP_IRQ_ROUTING 992#ifdef KVM_CAP_IRQ_ROUTING
980 993
@@ -1421,6 +1434,12 @@ struct kvm_enc_region {
1421#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1434#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1422#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 1435#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state)
1423 1436
1437/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT */
1438#define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1439
1440/* Available with KVM_CAP_HYPERV_CPUID */
1441#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1442
1424/* Secure Encrypted Virtualization command */ 1443/* Secure Encrypted Virtualization command */
1425enum sev_cmd_id { 1444enum sev_cmd_id {
1426 /* Guest initialization commands */ 1445 /* Guest initialization commands */
diff --git a/tools/include/uapi/linux/mount.h b/tools/include/uapi/linux/mount.h
new file mode 100644
index 000000000000..3f9ec42510b0
--- /dev/null
+++ b/tools/include/uapi/linux/mount.h
@@ -0,0 +1,58 @@
1#ifndef _UAPI_LINUX_MOUNT_H
2#define _UAPI_LINUX_MOUNT_H
3
4/*
5 * These are the fs-independent mount-flags: up to 32 flags are supported
6 *
7 * Usage of these is restricted within the kernel to core mount(2) code and
8 * callers of sys_mount() only. Filesystems should be using the SB_*
9 * equivalent instead.
10 */
11#define MS_RDONLY 1 /* Mount read-only */
12#define MS_NOSUID 2 /* Ignore suid and sgid bits */
13#define MS_NODEV 4 /* Disallow access to device special files */
14#define MS_NOEXEC 8 /* Disallow program execution */
15#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
16#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
17#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
18#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
19#define MS_NOATIME 1024 /* Do not update access times. */
20#define MS_NODIRATIME 2048 /* Do not update directory access times */
21#define MS_BIND 4096
22#define MS_MOVE 8192
23#define MS_REC 16384
24#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
25 MS_VERBOSE is deprecated. */
26#define MS_SILENT 32768
27#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
28#define MS_UNBINDABLE (1<<17) /* change to unbindable */
29#define MS_PRIVATE (1<<18) /* change to private */
30#define MS_SLAVE (1<<19) /* change to slave */
31#define MS_SHARED (1<<20) /* change to shared */
32#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
33#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
34#define MS_I_VERSION (1<<23) /* Update inode I_version field */
35#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
36#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
37
38/* These sb flags are internal to the kernel */
39#define MS_SUBMOUNT (1<<26)
40#define MS_NOREMOTELOCK (1<<27)
41#define MS_NOSEC (1<<28)
42#define MS_BORN (1<<29)
43#define MS_ACTIVE (1<<30)
44#define MS_NOUSER (1<<31)
45
46/*
47 * Superblock flags that can be altered by MS_REMOUNT
48 */
49#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
50 MS_LAZYTIME)
51
52/*
53 * Old magic mount flag and mask
54 */
55#define MS_MGC_VAL 0xC0ED0000
56#define MS_MGC_MSK 0xffff0000
57
58#endif /* _UAPI_LINUX_MOUNT_H */
diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index b17201edfa09..b4875a93363a 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -220,4 +220,12 @@ struct prctl_mm_map {
220# define PR_SPEC_DISABLE (1UL << 2) 220# define PR_SPEC_DISABLE (1UL << 2)
221# define PR_SPEC_FORCE_DISABLE (1UL << 3) 221# define PR_SPEC_FORCE_DISABLE (1UL << 3)
222 222
223/* Reset arm64 pointer authentication keys */
224#define PR_PAC_RESET_KEYS 54
225# define PR_PAC_APIAKEY (1UL << 0)
226# define PR_PAC_APIBKEY (1UL << 1)
227# define PR_PAC_APDAKEY (1UL << 2)
228# define PR_PAC_APDBKEY (1UL << 3)
229# define PR_PAC_APGAKEY (1UL << 4)
230
223#endif /* _LINUX_PRCTL_H */ 231#endif /* _LINUX_PRCTL_H */
diff --git a/tools/include/uapi/linux/vhost.h b/tools/include/uapi/linux/vhost.h
index 84c3de89696a..40d028eed645 100644
--- a/tools/include/uapi/linux/vhost.h
+++ b/tools/include/uapi/linux/vhost.h
@@ -11,94 +11,9 @@
11 * device configuration. 11 * device configuration.
12 */ 12 */
13 13
14#include <linux/vhost_types.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <linux/compiler.h>
16#include <linux/ioctl.h> 16#include <linux/ioctl.h>
17#include <linux/virtio_config.h>
18#include <linux/virtio_ring.h>
19
20struct vhost_vring_state {
21 unsigned int index;
22 unsigned int num;
23};
24
25struct vhost_vring_file {
26 unsigned int index;
27 int fd; /* Pass -1 to unbind from file. */
28
29};
30
31struct vhost_vring_addr {
32 unsigned int index;
33 /* Option flags. */
34 unsigned int flags;
35 /* Flag values: */
36 /* Whether log address is valid. If set enables logging. */
37#define VHOST_VRING_F_LOG 0
38
39 /* Start of array of descriptors (virtually contiguous) */
40 __u64 desc_user_addr;
41 /* Used structure address. Must be 32 bit aligned */
42 __u64 used_user_addr;
43 /* Available structure address. Must be 16 bit aligned */
44 __u64 avail_user_addr;
45 /* Logging support. */
46 /* Log writes to used structure, at offset calculated from specified
47 * address. Address must be 32 bit aligned. */
48 __u64 log_guest_addr;
49};
50
51/* no alignment requirement */
52struct vhost_iotlb_msg {
53 __u64 iova;
54 __u64 size;
55 __u64 uaddr;
56#define VHOST_ACCESS_RO 0x1
57#define VHOST_ACCESS_WO 0x2
58#define VHOST_ACCESS_RW 0x3
59 __u8 perm;
60#define VHOST_IOTLB_MISS 1
61#define VHOST_IOTLB_UPDATE 2
62#define VHOST_IOTLB_INVALIDATE 3
63#define VHOST_IOTLB_ACCESS_FAIL 4
64 __u8 type;
65};
66
67#define VHOST_IOTLB_MSG 0x1
68#define VHOST_IOTLB_MSG_V2 0x2
69
70struct vhost_msg {
71 int type;
72 union {
73 struct vhost_iotlb_msg iotlb;
74 __u8 padding[64];
75 };
76};
77
78struct vhost_msg_v2 {
79 __u32 type;
80 __u32 reserved;
81 union {
82 struct vhost_iotlb_msg iotlb;
83 __u8 padding[64];
84 };
85};
86
87struct vhost_memory_region {
88 __u64 guest_phys_addr;
89 __u64 memory_size; /* bytes */
90 __u64 userspace_addr;
91 __u64 flags_padding; /* No flags are currently specified. */
92};
93
94/* All region addresses and sizes must be 4K aligned. */
95#define VHOST_PAGE_SIZE 0x1000
96
97struct vhost_memory {
98 __u32 nregions;
99 __u32 padding;
100 struct vhost_memory_region regions[0];
101};
102 17
103/* ioctls */ 18/* ioctls */
104 19
@@ -186,31 +101,7 @@ struct vhost_memory {
186 * device. This can be used to stop the ring (e.g. for migration). */ 101 * device. This can be used to stop the ring (e.g. for migration). */
187#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file) 102#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
188 103
189/* Feature bits */ 104/* VHOST_SCSI specific defines */
190/* Log all write descriptors. Can be changed while device is active. */
191#define VHOST_F_LOG_ALL 26
192/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
193#define VHOST_NET_F_VIRTIO_NET_HDR 27
194
195/* VHOST_SCSI specific definitions */
196
197/*
198 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
199 *
200 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
201 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
202 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
203 * All the targets under vhost_wwpn can be seen and used by guset.
204 */
205
206#define VHOST_SCSI_ABI_VERSION 1
207
208struct vhost_scsi_target {
209 int abi_version;
210 char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
211 unsigned short vhost_tpgt;
212 unsigned short reserved;
213};
214 105
215#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target) 106#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
216#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target) 107#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 8b31c0e00ba3..d463761a58f4 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -194,13 +194,13 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size)
194} 194}
195 195
196/** 196/**
197 * tep_is_file_bigendian - get if the file is in big endian order 197 * tep_file_bigendian - get if the file is in big endian order
198 * @pevent: a handle to the tep_handle 198 * @pevent: a handle to the tep_handle
199 * 199 *
200 * This returns if the file is in big endian order 200 * This returns if the file is in big endian order
201 * If @pevent is NULL, 0 is returned. 201 * If @pevent is NULL, 0 is returned.
202 */ 202 */
203int tep_is_file_bigendian(struct tep_handle *pevent) 203int tep_file_bigendian(struct tep_handle *pevent)
204{ 204{
205 if(pevent) 205 if(pevent)
206 return pevent->file_bigendian; 206 return pevent->file_bigendian;
diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h
index 9a092dd4a86d..35833ee32d6c 100644
--- a/tools/lib/traceevent/event-parse-local.h
+++ b/tools/lib/traceevent/event-parse-local.h
@@ -7,7 +7,7 @@
7#ifndef _PARSE_EVENTS_INT_H 7#ifndef _PARSE_EVENTS_INT_H
8#define _PARSE_EVENTS_INT_H 8#define _PARSE_EVENTS_INT_H
9 9
10struct cmdline; 10struct tep_cmdline;
11struct cmdline_list; 11struct cmdline_list;
12struct func_map; 12struct func_map;
13struct func_list; 13struct func_list;
@@ -36,7 +36,7 @@ struct tep_handle {
36 int long_size; 36 int long_size;
37 int page_size; 37 int page_size;
38 38
39 struct cmdline *cmdlines; 39 struct tep_cmdline *cmdlines;
40 struct cmdline_list *cmdlist; 40 struct cmdline_list *cmdlist;
41 int cmdline_count; 41 int cmdline_count;
42 42
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 69a96e39f0ab..abd4fa5d3088 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -124,15 +124,15 @@ struct tep_print_arg *alloc_arg(void)
124 return calloc(1, sizeof(struct tep_print_arg)); 124 return calloc(1, sizeof(struct tep_print_arg));
125} 125}
126 126
127struct cmdline { 127struct tep_cmdline {
128 char *comm; 128 char *comm;
129 int pid; 129 int pid;
130}; 130};
131 131
132static int cmdline_cmp(const void *a, const void *b) 132static int cmdline_cmp(const void *a, const void *b)
133{ 133{
134 const struct cmdline *ca = a; 134 const struct tep_cmdline *ca = a;
135 const struct cmdline *cb = b; 135 const struct tep_cmdline *cb = b;
136 136
137 if (ca->pid < cb->pid) 137 if (ca->pid < cb->pid)
138 return -1; 138 return -1;
@@ -152,7 +152,7 @@ static int cmdline_init(struct tep_handle *pevent)
152{ 152{
153 struct cmdline_list *cmdlist = pevent->cmdlist; 153 struct cmdline_list *cmdlist = pevent->cmdlist;
154 struct cmdline_list *item; 154 struct cmdline_list *item;
155 struct cmdline *cmdlines; 155 struct tep_cmdline *cmdlines;
156 int i; 156 int i;
157 157
158 cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count); 158 cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count);
@@ -179,8 +179,8 @@ static int cmdline_init(struct tep_handle *pevent)
179 179
180static const char *find_cmdline(struct tep_handle *pevent, int pid) 180static const char *find_cmdline(struct tep_handle *pevent, int pid)
181{ 181{
182 const struct cmdline *comm; 182 const struct tep_cmdline *comm;
183 struct cmdline key; 183 struct tep_cmdline key;
184 184
185 if (!pid) 185 if (!pid)
186 return "<idle>"; 186 return "<idle>";
@@ -208,8 +208,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)
208 */ 208 */
209int tep_pid_is_registered(struct tep_handle *pevent, int pid) 209int tep_pid_is_registered(struct tep_handle *pevent, int pid)
210{ 210{
211 const struct cmdline *comm; 211 const struct tep_cmdline *comm;
212 struct cmdline key; 212 struct tep_cmdline key;
213 213
214 if (!pid) 214 if (!pid)
215 return 1; 215 return 1;
@@ -232,11 +232,13 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)
232 * we must add this pid. This is much slower than when cmdlines 232 * we must add this pid. This is much slower than when cmdlines
233 * are added before the array is initialized. 233 * are added before the array is initialized.
234 */ 234 */
235static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) 235static int add_new_comm(struct tep_handle *pevent,
236 const char *comm, int pid, bool override)
236{ 237{
237 struct cmdline *cmdlines = pevent->cmdlines; 238 struct tep_cmdline *cmdlines = pevent->cmdlines;
238 const struct cmdline *cmdline; 239 struct tep_cmdline *cmdline;
239 struct cmdline key; 240 struct tep_cmdline key;
241 char *new_comm;
240 242
241 if (!pid) 243 if (!pid)
242 return 0; 244 return 0;
@@ -247,8 +249,19 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
247 cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count, 249 cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count,
248 sizeof(*pevent->cmdlines), cmdline_cmp); 250 sizeof(*pevent->cmdlines), cmdline_cmp);
249 if (cmdline) { 251 if (cmdline) {
250 errno = EEXIST; 252 if (!override) {
251 return -1; 253 errno = EEXIST;
254 return -1;
255 }
256 new_comm = strdup(comm);
257 if (!new_comm) {
258 errno = ENOMEM;
259 return -1;
260 }
261 free(cmdline->comm);
262 cmdline->comm = new_comm;
263
264 return 0;
252 } 265 }
253 266
254 cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1)); 267 cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1));
@@ -275,21 +288,13 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
275 return 0; 288 return 0;
276} 289}
277 290
278/** 291static int _tep_register_comm(struct tep_handle *pevent,
279 * tep_register_comm - register a pid / comm mapping 292 const char *comm, int pid, bool override)
280 * @pevent: handle for the pevent
281 * @comm: the command line to register
282 * @pid: the pid to map the command line to
283 *
284 * This adds a mapping to search for command line names with
285 * a given pid. The comm is duplicated.
286 */
287int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
288{ 293{
289 struct cmdline_list *item; 294 struct cmdline_list *item;
290 295
291 if (pevent->cmdlines) 296 if (pevent->cmdlines)
292 return add_new_comm(pevent, comm, pid); 297 return add_new_comm(pevent, comm, pid, override);
293 298
294 item = malloc(sizeof(*item)); 299 item = malloc(sizeof(*item));
295 if (!item) 300 if (!item)
@@ -312,6 +317,40 @@ int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
312 return 0; 317 return 0;
313} 318}
314 319
320/**
321 * tep_register_comm - register a pid / comm mapping
322 * @pevent: handle for the pevent
323 * @comm: the command line to register
324 * @pid: the pid to map the command line to
325 *
326 * This adds a mapping to search for command line names with
327 * a given pid. The comm is duplicated. If a command with the same pid
328 * already exist, -1 is returned and errno is set to EEXIST
329 */
330int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
331{
332 return _tep_register_comm(pevent, comm, pid, false);
333}
334
335/**
336 * tep_override_comm - register a pid / comm mapping
337 * @pevent: handle for the pevent
338 * @comm: the command line to register
339 * @pid: the pid to map the command line to
340 *
341 * This adds a mapping to search for command line names with
342 * a given pid. The comm is duplicated. If a command with the same pid
343 * already exist, the command string is udapted with the new one
344 */
345int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid)
346{
347 if (!pevent->cmdlines && cmdline_init(pevent)) {
348 errno = ENOMEM;
349 return -1;
350 }
351 return _tep_register_comm(pevent, comm, pid, true);
352}
353
315int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock) 354int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock)
316{ 355{
317 pevent->trace_clock = strdup(trace_clock); 356 pevent->trace_clock = strdup(trace_clock);
@@ -5227,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
5227} 5266}
5228 5267
5229/** 5268/**
5230 * tep_data_event_from_type - find the event by a given type
5231 * @pevent: a handle to the pevent
5232 * @type: the type of the event.
5233 *
5234 * This returns the event form a given @type;
5235 */
5236struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type)
5237{
5238 return tep_find_event(pevent, type);
5239}
5240
5241/**
5242 * tep_data_pid - parse the PID from record 5269 * tep_data_pid - parse the PID from record
5243 * @pevent: a handle to the pevent 5270 * @pevent: a handle to the pevent
5244 * @rec: the record to parse 5271 * @rec: the record to parse
@@ -5292,8 +5319,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)
5292 return comm; 5319 return comm;
5293} 5320}
5294 5321
5295static struct cmdline * 5322static struct tep_cmdline *
5296pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next) 5323pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct tep_cmdline *next)
5297{ 5324{
5298 struct cmdline_list *cmdlist = (struct cmdline_list *)next; 5325 struct cmdline_list *cmdlist = (struct cmdline_list *)next;
5299 5326
@@ -5305,7 +5332,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
5305 while (cmdlist && strcmp(cmdlist->comm, comm) != 0) 5332 while (cmdlist && strcmp(cmdlist->comm, comm) != 0)
5306 cmdlist = cmdlist->next; 5333 cmdlist = cmdlist->next;
5307 5334
5308 return (struct cmdline *)cmdlist; 5335 return (struct tep_cmdline *)cmdlist;
5309} 5336}
5310 5337
5311/** 5338/**
@@ -5321,10 +5348,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
5321 * next pid. 5348 * next pid.
5322 * Also, it does a linear search, so it may be slow. 5349 * Also, it does a linear search, so it may be slow.
5323 */ 5350 */
5324struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, 5351struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
5325 struct cmdline *next) 5352 struct tep_cmdline *next)
5326{ 5353{
5327 struct cmdline *cmdline; 5354 struct tep_cmdline *cmdline;
5328 5355
5329 /* 5356 /*
5330 * If the cmdlines have not been converted yet, then use 5357 * If the cmdlines have not been converted yet, then use
@@ -5363,7 +5390,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co
5363 * Returns the pid for a give cmdline. If @cmdline is NULL, then 5390 * Returns the pid for a give cmdline. If @cmdline is NULL, then
5364 * -1 is returned. 5391 * -1 is returned.
5365 */ 5392 */
5366int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) 5393int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline)
5367{ 5394{
5368 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; 5395 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
5369 5396
@@ -6593,6 +6620,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id,
6593 * 6620 *
6594 * If @id is >= 0, then it is used to find the event. 6621 * If @id is >= 0, then it is used to find the event.
6595 * else @sys_name and @event_name are used. 6622 * else @sys_name and @event_name are used.
6623 *
6624 * Returns:
6625 * TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten
6626 * TEP_REGISTER_SUCCESS if a new handler is registered successfully
6627 * negative TEP_ERRNO_... in case of an error
6628 *
6596 */ 6629 */
6597int tep_register_event_handler(struct tep_handle *pevent, int id, 6630int tep_register_event_handler(struct tep_handle *pevent, int id,
6598 const char *sys_name, const char *event_name, 6631 const char *sys_name, const char *event_name,
@@ -6610,7 +6643,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
6610 6643
6611 event->handler = func; 6644 event->handler = func;
6612 event->context = context; 6645 event->context = context;
6613 return 0; 6646 return TEP_REGISTER_SUCCESS_OVERWRITE;
6614 6647
6615 not_found: 6648 not_found:
6616 /* Save for later use. */ 6649 /* Save for later use. */
@@ -6640,7 +6673,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
6640 pevent->handlers = handle; 6673 pevent->handlers = handle;
6641 handle->context = context; 6674 handle->context = context;
6642 6675
6643 return -1; 6676 return TEP_REGISTER_SUCCESS;
6644} 6677}
6645 6678
6646static int handle_matches(struct event_handler *handler, int id, 6679static int handle_matches(struct event_handler *handler, int id,
@@ -6723,8 +6756,10 @@ struct tep_handle *tep_alloc(void)
6723{ 6756{
6724 struct tep_handle *pevent = calloc(1, sizeof(*pevent)); 6757 struct tep_handle *pevent = calloc(1, sizeof(*pevent));
6725 6758
6726 if (pevent) 6759 if (pevent) {
6727 pevent->ref_count = 1; 6760 pevent->ref_count = 1;
6761 pevent->host_bigendian = tep_host_bigendian();
6762 }
6728 6763
6729 return pevent; 6764 return pevent;
6730} 6765}
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 35d37087d3c5..aec48f2aea8a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -432,6 +432,7 @@ int tep_set_function_resolver(struct tep_handle *pevent,
432 tep_func_resolver_t *func, void *priv); 432 tep_func_resolver_t *func, void *priv);
433void tep_reset_function_resolver(struct tep_handle *pevent); 433void tep_reset_function_resolver(struct tep_handle *pevent);
434int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); 434int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid);
435int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid);
435int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); 436int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock);
436int tep_register_function(struct tep_handle *pevent, char *name, 437int tep_register_function(struct tep_handle *pevent, char *name,
437 unsigned long long addr, char *mod); 438 unsigned long long addr, char *mod);
@@ -484,6 +485,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt,
484 struct tep_event *event, const char *name, 485 struct tep_event *event, const char *name,
485 struct tep_record *record, int err); 486 struct tep_record *record, int err);
486 487
488enum tep_reg_handler {
489 TEP_REGISTER_SUCCESS = 0,
490 TEP_REGISTER_SUCCESS_OVERWRITE,
491};
492
487int tep_register_event_handler(struct tep_handle *pevent, int id, 493int tep_register_event_handler(struct tep_handle *pevent, int id,
488 const char *sys_name, const char *event_name, 494 const char *sys_name, const char *event_name,
489 tep_event_handler_func func, void *context); 495 tep_event_handler_func func, void *context);
@@ -520,15 +526,14 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
520void tep_data_lat_fmt(struct tep_handle *pevent, 526void tep_data_lat_fmt(struct tep_handle *pevent,
521 struct trace_seq *s, struct tep_record *record); 527 struct trace_seq *s, struct tep_record *record);
522int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); 528int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
523struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type);
524int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); 529int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
525int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); 530int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
526int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); 531int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
527const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid); 532const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
528struct cmdline; 533struct tep_cmdline;
529struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, 534struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
530 struct cmdline *next); 535 struct tep_cmdline *next);
531int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); 536int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline);
532 537
533void tep_print_field(struct trace_seq *s, void *data, 538void tep_print_field(struct trace_seq *s, void *data,
534 struct tep_format_field *field); 539 struct tep_format_field *field);
@@ -553,7 +558,7 @@ int tep_get_long_size(struct tep_handle *pevent);
553void tep_set_long_size(struct tep_handle *pevent, int long_size); 558void tep_set_long_size(struct tep_handle *pevent, int long_size);
554int tep_get_page_size(struct tep_handle *pevent); 559int tep_get_page_size(struct tep_handle *pevent);
555void tep_set_page_size(struct tep_handle *pevent, int _page_size); 560void tep_set_page_size(struct tep_handle *pevent, int _page_size);
556int tep_is_file_bigendian(struct tep_handle *pevent); 561int tep_file_bigendian(struct tep_handle *pevent);
557void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); 562void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian);
558int tep_is_host_bigendian(struct tep_handle *pevent); 563int tep_is_host_bigendian(struct tep_handle *pevent);
559void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); 564void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian);
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 754050eea467..64b9c25a1fd3 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,7 +389,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
389 * We can only use the structure if file is of the same 389 * We can only use the structure if file is of the same
390 * endianness. 390 * endianness.
391 */ 391 */
392 if (tep_is_file_bigendian(event->pevent) == 392 if (tep_file_bigendian(event->pevent) ==
393 tep_is_host_bigendian(event->pevent)) { 393 tep_is_host_bigendian(event->pevent)) {
394 394
395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", 395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 8ff1d55954d1..8d5ecd2bf877 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s)
100 * @fmt: printf format string 100 * @fmt: printf format string
101 * 101 *
102 * It returns 0 if the trace oversizes the buffer's free 102 * It returns 0 if the trace oversizes the buffer's free
103 * space, 1 otherwise. 103 * space, the number of characters printed, or a negative
104 * value in case of an error.
104 * 105 *
105 * The tracer may use either sequence operations or its own 106 * The tracer may use either sequence operations or its own
106 * copy to user routines. To simplify formating of a trace 107 * copy to user routines. To simplify formating of a trace
@@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
129 goto try_again; 130 goto try_again;
130 } 131 }
131 132
132 s->len += ret; 133 if (ret > 0)
134 s->len += ret;
133 135
134 return 1; 136 return ret;
135} 137}
136 138
137/** 139/**
@@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
139 * @s: trace sequence descriptor 141 * @s: trace sequence descriptor
140 * @fmt: printf format string 142 * @fmt: printf format string
141 * 143 *
144 * It returns 0 if the trace oversizes the buffer's free
145 * space, the number of characters printed, or a negative
146 * value in case of an error.
147 * *
142 * The tracer may use either sequence operations or its own 148 * The tracer may use either sequence operations or its own
143 * copy to user routines. To simplify formating of a trace 149 * copy to user routines. To simplify formating of a trace
144 * trace_seq_printf is used to store strings into a special 150 * trace_seq_printf is used to store strings into a special
@@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
163 goto try_again; 169 goto try_again;
164 } 170 }
165 171
166 s->len += ret; 172 if (ret > 0)
173 s->len += ret;
167 174
168 return len; 175 return ret;
169} 176}
170 177
171/** 178/**
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ff29c3372ec3..0ee6795d82cc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -524,12 +524,14 @@ $(arch_errno_name_array): $(arch_errno_tbl)
524 524
525all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) 525all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
526 526
527# Create python binding output directory if not already present
528_dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
529
527$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) 530$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
528 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ 531 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
529 CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \ 532 CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
530 $(PYTHON_WORD) util/setup.py \ 533 $(PYTHON_WORD) util/setup.py \
531 --quiet build_ext; \ 534 --quiet build_ext; \
532 mkdir -p $(OUTPUT)python && \
533 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/ 535 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
534 536
535please_set_SHELL_PATH_to_a_more_modern_shell: 537please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -660,12 +662,12 @@ $(OUTPUT)perf-%: %.o $(PERFLIBS)
660 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) 662 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
661 663
662ifndef NO_PERF_READ_VDSO32 664ifndef NO_PERF_READ_VDSO32
663$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-vdso-map.c 665$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
664 $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c 666 $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
665endif 667endif
666 668
667ifndef NO_PERF_READ_VDSOX32 669ifndef NO_PERF_READ_VDSOX32
668$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c 670$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
669 $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c 671 $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
670endif 672endif
671 673
diff --git a/tools/perf/arch/arm/tests/Build b/tools/perf/arch/arm/tests/Build
index 883c57ff0c08..d9ae2733f9cc 100644
--- a/tools/perf/arch/arm/tests/Build
+++ b/tools/perf/arch/arm/tests/Build
@@ -1,4 +1,5 @@
1libperf-y += regs_load.o 1libperf-y += regs_load.o
2libperf-y += dwarf-unwind.o 2libperf-y += dwarf-unwind.o
3libperf-y += vectors-page.o
3 4
4libperf-y += arch-tests.o 5libperf-y += arch-tests.o
diff --git a/tools/perf/arch/arm/tests/arch-tests.c b/tools/perf/arch/arm/tests/arch-tests.c
index 5b1543c98022..6848101a855f 100644
--- a/tools/perf/arch/arm/tests/arch-tests.c
+++ b/tools/perf/arch/arm/tests/arch-tests.c
@@ -11,6 +11,10 @@ struct test arch_tests[] = {
11 }, 11 },
12#endif 12#endif
13 { 13 {
14 .desc = "Vectors page",
15 .func = test__vectors_page,
16 },
17 {
14 .func = NULL, 18 .func = NULL,
15 }, 19 },
16}; 20};
diff --git a/tools/perf/arch/arm/tests/vectors-page.c b/tools/perf/arch/arm/tests/vectors-page.c
new file mode 100644
index 000000000000..7ffdd79971c8
--- /dev/null
+++ b/tools/perf/arch/arm/tests/vectors-page.c
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <stdio.h>
3#include <string.h>
4#include <linux/compiler.h>
5
6#include "debug.h"
7#include "tests/tests.h"
8#include "util/find-map.c"
9
10#define VECTORS__MAP_NAME "[vectors]"
11
12int test__vectors_page(struct test *test __maybe_unused,
13 int subtest __maybe_unused)
14{
15 void *start, *end;
16
17 if (find_map(&start, &end, VECTORS__MAP_NAME)) {
18 pr_err("%s not found, is CONFIG_KUSER_HELPERS enabled?\n",
19 VECTORS__MAP_NAME);
20 return TEST_FAIL;
21 }
22
23 return TEST_OK;
24}
diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index a111239df182..e58d00d62f02 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -14,18 +14,25 @@ PERF_HAVE_JITDUMP := 1
14out := $(OUTPUT)arch/powerpc/include/generated/asm 14out := $(OUTPUT)arch/powerpc/include/generated/asm
15header32 := $(out)/syscalls_32.c 15header32 := $(out)/syscalls_32.c
16header64 := $(out)/syscalls_64.c 16header64 := $(out)/syscalls_64.c
17sysdef := $(srctree)/tools/arch/powerpc/include/uapi/asm/unistd.h 17syskrn := $(srctree)/arch/powerpc/kernel/syscalls/syscall.tbl
18sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls/ 18sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls
19sysdef := $(sysprf)/syscall.tbl
19systbl := $(sysprf)/mksyscalltbl 20systbl := $(sysprf)/mksyscalltbl
20 21
21# Create output directory if not already present 22# Create output directory if not already present
22_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') 23_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
23 24
24$(header64): $(sysdef) $(systbl) 25$(header64): $(sysdef) $(systbl)
25 $(Q)$(SHELL) '$(systbl)' '64' '$(CC)' $(sysdef) > $@ 26 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
27 (diff -B $(sysdef) $(syskrn) >/dev/null) \
28 || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true
29 $(Q)$(SHELL) '$(systbl)' '64' $(sysdef) > $@
26 30
27$(header32): $(sysdef) $(systbl) 31$(header32): $(sysdef) $(systbl)
28 $(Q)$(SHELL) '$(systbl)' '32' '$(CC)' $(sysdef) > $@ 32 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
33 (diff -B $(sysdef) $(syskrn) >/dev/null) \
34 || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true
35 $(Q)$(SHELL) '$(systbl)' '32' $(sysdef) > $@
29 36
30clean:: 37clean::
31 $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64) 38 $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64)
diff --git a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
index ef52e1dd694b..6c58060aa03b 100755
--- a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
@@ -9,10 +9,9 @@
9# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> 9# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
10 10
11wordsize=$1 11wordsize=$1
12gcc=$2 12SYSCALL_TBL=$2
13input=$3
14 13
15if ! test -r $input; then 14if ! test -r $SYSCALL_TBL; then
16 echo "Could not read input file" >&2 15 echo "Could not read input file" >&2
17 exit 1 16 exit 1
18fi 17fi
@@ -20,18 +19,21 @@ fi
20create_table() 19create_table()
21{ 20{
22 local wordsize=$1 21 local wordsize=$1
23 local max_nr 22 local max_nr nr abi sc discard
23 max_nr=-1
24 nr=0
24 25
25 echo "static const char *syscalltbl_powerpc_${wordsize}[] = {" 26 echo "static const char *syscalltbl_powerpc_${wordsize}[] = {"
26 while read sc nr; do 27 while read nr abi sc discard; do
27 printf '\t[%d] = "%s",\n' $nr $sc 28 if [ "$max_nr" -lt "$nr" ]; then
28 max_nr=$nr 29 printf '\t[%d] = "%s",\n' $nr $sc
30 max_nr=$nr
31 fi
29 done 32 done
30 echo '};' 33 echo '};'
31 echo "#define SYSCALLTBL_POWERPC_${wordsize}_MAX_ID $max_nr" 34 echo "#define SYSCALLTBL_POWERPC_${wordsize}_MAX_ID $max_nr"
32} 35}
33 36
34$gcc -m${wordsize} -E -dM -x c $input \ 37grep -E "^[[:digit:]]+[[:space:]]+(common|spu|nospu|${wordsize})" $SYSCALL_TBL \
35 |sed -ne 's/^#define __NR_//p' \ 38 |sort -k1 -n \
36 |sort -t' ' -k2 -nu \
37 |create_table ${wordsize} 39 |create_table ${wordsize}
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
new file mode 100644
index 000000000000..db3bbb8744af
--- /dev/null
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -0,0 +1,427 @@
1# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2#
3# system call numbers and entry vectors for powerpc
4#
5# The format is:
6# <number> <abi> <name> <entry point> <compat entry point>
7#
8# The <abi> can be common, spu, nospu, 64, or 32 for this file.
9#
100 nospu restart_syscall sys_restart_syscall
111 nospu exit sys_exit
122 nospu fork ppc_fork
133 common read sys_read
144 common write sys_write
155 common open sys_open compat_sys_open
166 common close sys_close
177 common waitpid sys_waitpid
188 common creat sys_creat
199 common link sys_link
2010 common unlink sys_unlink
2111 nospu execve sys_execve compat_sys_execve
2212 common chdir sys_chdir
2313 common time sys_time compat_sys_time
2414 common mknod sys_mknod
2515 common chmod sys_chmod
2616 common lchown sys_lchown
2717 common break sys_ni_syscall
2818 32 oldstat sys_stat sys_ni_syscall
2918 64 oldstat sys_ni_syscall
3018 spu oldstat sys_ni_syscall
3119 common lseek sys_lseek compat_sys_lseek
3220 common getpid sys_getpid
3321 nospu mount sys_mount compat_sys_mount
3422 32 umount sys_oldumount
3522 64 umount sys_ni_syscall
3622 spu umount sys_ni_syscall
3723 common setuid sys_setuid
3824 common getuid sys_getuid
3925 common stime sys_stime compat_sys_stime
4026 nospu ptrace sys_ptrace compat_sys_ptrace
4127 common alarm sys_alarm
4228 32 oldfstat sys_fstat sys_ni_syscall
4328 64 oldfstat sys_ni_syscall
4428 spu oldfstat sys_ni_syscall
4529 nospu pause sys_pause
4630 nospu utime sys_utime compat_sys_utime
4731 common stty sys_ni_syscall
4832 common gtty sys_ni_syscall
4933 common access sys_access
5034 common nice sys_nice
5135 common ftime sys_ni_syscall
5236 common sync sys_sync
5337 common kill sys_kill
5438 common rename sys_rename
5539 common mkdir sys_mkdir
5640 common rmdir sys_rmdir
5741 common dup sys_dup
5842 common pipe sys_pipe
5943 common times sys_times compat_sys_times
6044 common prof sys_ni_syscall
6145 common brk sys_brk
6246 common setgid sys_setgid
6347 common getgid sys_getgid
6448 nospu signal sys_signal
6549 common geteuid sys_geteuid
6650 common getegid sys_getegid
6751 nospu acct sys_acct
6852 nospu umount2 sys_umount
6953 common lock sys_ni_syscall
7054 common ioctl sys_ioctl compat_sys_ioctl
7155 common fcntl sys_fcntl compat_sys_fcntl
7256 common mpx sys_ni_syscall
7357 common setpgid sys_setpgid
7458 common ulimit sys_ni_syscall
7559 32 oldolduname sys_olduname
7659 64 oldolduname sys_ni_syscall
7759 spu oldolduname sys_ni_syscall
7860 common umask sys_umask
7961 common chroot sys_chroot
8062 nospu ustat sys_ustat compat_sys_ustat
8163 common dup2 sys_dup2
8264 common getppid sys_getppid
8365 common getpgrp sys_getpgrp
8466 common setsid sys_setsid
8567 32 sigaction sys_sigaction compat_sys_sigaction
8667 64 sigaction sys_ni_syscall
8767 spu sigaction sys_ni_syscall
8868 common sgetmask sys_sgetmask
8969 common ssetmask sys_ssetmask
9070 common setreuid sys_setreuid
9171 common setregid sys_setregid
9272 32 sigsuspend sys_sigsuspend
9372 64 sigsuspend sys_ni_syscall
9472 spu sigsuspend sys_ni_syscall
9573 32 sigpending sys_sigpending compat_sys_sigpending
9673 64 sigpending sys_ni_syscall
9773 spu sigpending sys_ni_syscall
9874 common sethostname sys_sethostname
9975 common setrlimit sys_setrlimit compat_sys_setrlimit
10076 32 getrlimit sys_old_getrlimit compat_sys_old_getrlimit
10176 64 getrlimit sys_ni_syscall
10276 spu getrlimit sys_ni_syscall
10377 common getrusage sys_getrusage compat_sys_getrusage
10478 common gettimeofday sys_gettimeofday compat_sys_gettimeofday
10579 common settimeofday sys_settimeofday compat_sys_settimeofday
10680 common getgroups sys_getgroups
10781 common setgroups sys_setgroups
10882 32 select ppc_select sys_ni_syscall
10982 64 select sys_ni_syscall
11082 spu select sys_ni_syscall
11183 common symlink sys_symlink
11284 32 oldlstat sys_lstat sys_ni_syscall
11384 64 oldlstat sys_ni_syscall
11484 spu oldlstat sys_ni_syscall
11585 common readlink sys_readlink
11686 nospu uselib sys_uselib
11787 nospu swapon sys_swapon
11888 nospu reboot sys_reboot
11989 32 readdir sys_old_readdir compat_sys_old_readdir
12089 64 readdir sys_ni_syscall
12189 spu readdir sys_ni_syscall
12290 common mmap sys_mmap
12391 common munmap sys_munmap
12492 common truncate sys_truncate compat_sys_truncate
12593 common ftruncate sys_ftruncate compat_sys_ftruncate
12694 common fchmod sys_fchmod
12795 common fchown sys_fchown
12896 common getpriority sys_getpriority
12997 common setpriority sys_setpriority
13098 common profil sys_ni_syscall
13199 nospu statfs sys_statfs compat_sys_statfs
132100 nospu fstatfs sys_fstatfs compat_sys_fstatfs
133101 common ioperm sys_ni_syscall
134102 common socketcall sys_socketcall compat_sys_socketcall
135103 common syslog sys_syslog
136104 common setitimer sys_setitimer compat_sys_setitimer
137105 common getitimer sys_getitimer compat_sys_getitimer
138106 common stat sys_newstat compat_sys_newstat
139107 common lstat sys_newlstat compat_sys_newlstat
140108 common fstat sys_newfstat compat_sys_newfstat
141109 32 olduname sys_uname
142109 64 olduname sys_ni_syscall
143109 spu olduname sys_ni_syscall
144110 common iopl sys_ni_syscall
145111 common vhangup sys_vhangup
146112 common idle sys_ni_syscall
147113 common vm86 sys_ni_syscall
148114 common wait4 sys_wait4 compat_sys_wait4
149115 nospu swapoff sys_swapoff
150116 common sysinfo sys_sysinfo compat_sys_sysinfo
151117 nospu ipc sys_ipc compat_sys_ipc
152118 common fsync sys_fsync
153119 32 sigreturn sys_sigreturn compat_sys_sigreturn
154119 64 sigreturn sys_ni_syscall
155119 spu sigreturn sys_ni_syscall
156120 nospu clone ppc_clone
157121 common setdomainname sys_setdomainname
158122 common uname sys_newuname
159123 common modify_ldt sys_ni_syscall
160124 common adjtimex sys_adjtimex compat_sys_adjtimex
161125 common mprotect sys_mprotect
162126 32 sigprocmask sys_sigprocmask compat_sys_sigprocmask
163126 64 sigprocmask sys_ni_syscall
164126 spu sigprocmask sys_ni_syscall
165127 common create_module sys_ni_syscall
166128 nospu init_module sys_init_module
167129 nospu delete_module sys_delete_module
168130 common get_kernel_syms sys_ni_syscall
169131 nospu quotactl sys_quotactl
170132 common getpgid sys_getpgid
171133 common fchdir sys_fchdir
172134 common bdflush sys_bdflush
173135 common sysfs sys_sysfs
174136 32 personality sys_personality ppc64_personality
175136 64 personality ppc64_personality
176136 spu personality ppc64_personality
177137 common afs_syscall sys_ni_syscall
178138 common setfsuid sys_setfsuid
179139 common setfsgid sys_setfsgid
180140 common _llseek sys_llseek
181141 common getdents sys_getdents compat_sys_getdents
182142 common _newselect sys_select compat_sys_select
183143 common flock sys_flock
184144 common msync sys_msync
185145 common readv sys_readv compat_sys_readv
186146 common writev sys_writev compat_sys_writev
187147 common getsid sys_getsid
188148 common fdatasync sys_fdatasync
189149 nospu _sysctl sys_sysctl compat_sys_sysctl
190150 common mlock sys_mlock
191151 common munlock sys_munlock
192152 common mlockall sys_mlockall
193153 common munlockall sys_munlockall
194154 common sched_setparam sys_sched_setparam
195155 common sched_getparam sys_sched_getparam
196156 common sched_setscheduler sys_sched_setscheduler
197157 common sched_getscheduler sys_sched_getscheduler
198158 common sched_yield sys_sched_yield
199159 common sched_get_priority_max sys_sched_get_priority_max
200160 common sched_get_priority_min sys_sched_get_priority_min
201161 common sched_rr_get_interval sys_sched_rr_get_interval compat_sys_sched_rr_get_interval
202162 common nanosleep sys_nanosleep compat_sys_nanosleep
203163 common mremap sys_mremap
204164 common setresuid sys_setresuid
205165 common getresuid sys_getresuid
206166 common query_module sys_ni_syscall
207167 common poll sys_poll
208168 common nfsservctl sys_ni_syscall
209169 common setresgid sys_setresgid
210170 common getresgid sys_getresgid
211171 common prctl sys_prctl
212172 nospu rt_sigreturn sys_rt_sigreturn compat_sys_rt_sigreturn
213173 nospu rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction
214174 nospu rt_sigprocmask sys_rt_sigprocmask compat_sys_rt_sigprocmask
215175 nospu rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending
216176 nospu rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
217177 nospu rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
218178 nospu rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend
219179 common pread64 sys_pread64 compat_sys_pread64
220180 common pwrite64 sys_pwrite64 compat_sys_pwrite64
221181 common chown sys_chown
222182 common getcwd sys_getcwd
223183 common capget sys_capget
224184 common capset sys_capset
225185 nospu sigaltstack sys_sigaltstack compat_sys_sigaltstack
226186 32 sendfile sys_sendfile compat_sys_sendfile
227186 64 sendfile sys_sendfile64
228186 spu sendfile sys_sendfile64
229187 common getpmsg sys_ni_syscall
230188 common putpmsg sys_ni_syscall
231189 nospu vfork ppc_vfork
232190 common ugetrlimit sys_getrlimit compat_sys_getrlimit
233191 common readahead sys_readahead compat_sys_readahead
234192 32 mmap2 sys_mmap2 compat_sys_mmap2
235193 32 truncate64 sys_truncate64 compat_sys_truncate64
236194 32 ftruncate64 sys_ftruncate64 compat_sys_ftruncate64
237195 32 stat64 sys_stat64
238196 32 lstat64 sys_lstat64
239197 32 fstat64 sys_fstat64
240198 nospu pciconfig_read sys_pciconfig_read
241199 nospu pciconfig_write sys_pciconfig_write
242200 nospu pciconfig_iobase sys_pciconfig_iobase
243201 common multiplexer sys_ni_syscall
244202 common getdents64 sys_getdents64
245203 common pivot_root sys_pivot_root
246204 32 fcntl64 sys_fcntl64 compat_sys_fcntl64
247205 common madvise sys_madvise
248206 common mincore sys_mincore
249207 common gettid sys_gettid
250208 common tkill sys_tkill
251209 common setxattr sys_setxattr
252210 common lsetxattr sys_lsetxattr
253211 common fsetxattr sys_fsetxattr
254212 common getxattr sys_getxattr
255213 common lgetxattr sys_lgetxattr
256214 common fgetxattr sys_fgetxattr
257215 common listxattr sys_listxattr
258216 common llistxattr sys_llistxattr
259217 common flistxattr sys_flistxattr
260218 common removexattr sys_removexattr
261219 common lremovexattr sys_lremovexattr
262220 common fremovexattr sys_fremovexattr
263221 common futex sys_futex compat_sys_futex
264222 common sched_setaffinity sys_sched_setaffinity compat_sys_sched_setaffinity
265223 common sched_getaffinity sys_sched_getaffinity compat_sys_sched_getaffinity
266# 224 unused
267225 common tuxcall sys_ni_syscall
268226 32 sendfile64 sys_sendfile64 compat_sys_sendfile64
269227 common io_setup sys_io_setup compat_sys_io_setup
270228 common io_destroy sys_io_destroy
271229 common io_getevents sys_io_getevents compat_sys_io_getevents
272230 common io_submit sys_io_submit compat_sys_io_submit
273231 common io_cancel sys_io_cancel
274232 nospu set_tid_address sys_set_tid_address
275233 common fadvise64 sys_fadvise64 ppc32_fadvise64
276234 nospu exit_group sys_exit_group
277235 nospu lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie
278236 common epoll_create sys_epoll_create
279237 common epoll_ctl sys_epoll_ctl
280238 common epoll_wait sys_epoll_wait
281239 common remap_file_pages sys_remap_file_pages
282240 common timer_create sys_timer_create compat_sys_timer_create
283241 common timer_settime sys_timer_settime compat_sys_timer_settime
284242 common timer_gettime sys_timer_gettime compat_sys_timer_gettime
285243 common timer_getoverrun sys_timer_getoverrun
286244 common timer_delete sys_timer_delete
287245 common clock_settime sys_clock_settime compat_sys_clock_settime
288246 common clock_gettime sys_clock_gettime compat_sys_clock_gettime
289247 common clock_getres sys_clock_getres compat_sys_clock_getres
290248 common clock_nanosleep sys_clock_nanosleep compat_sys_clock_nanosleep
291249 32 swapcontext ppc_swapcontext ppc32_swapcontext
292249 64 swapcontext ppc64_swapcontext
293249 spu swapcontext sys_ni_syscall
294250 common tgkill sys_tgkill
295251 common utimes sys_utimes compat_sys_utimes
296252 common statfs64 sys_statfs64 compat_sys_statfs64
297253 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64
298254 32 fadvise64_64 ppc_fadvise64_64
299254 spu fadvise64_64 sys_ni_syscall
300255 common rtas sys_rtas
301256 32 sys_debug_setcontext sys_debug_setcontext sys_ni_syscall
302256 64 sys_debug_setcontext sys_ni_syscall
303256 spu sys_debug_setcontext sys_ni_syscall
304# 257 reserved for vserver
305258 nospu migrate_pages sys_migrate_pages compat_sys_migrate_pages
306259 nospu mbind sys_mbind compat_sys_mbind
307260 nospu get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
308261 nospu set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy
309262 nospu mq_open sys_mq_open compat_sys_mq_open
310263 nospu mq_unlink sys_mq_unlink
311264 nospu mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend
312265 nospu mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive
313266 nospu mq_notify sys_mq_notify compat_sys_mq_notify
314267 nospu mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr
315268 nospu kexec_load sys_kexec_load compat_sys_kexec_load
316269 nospu add_key sys_add_key
317270 nospu request_key sys_request_key
318271 nospu keyctl sys_keyctl compat_sys_keyctl
319272 nospu waitid sys_waitid compat_sys_waitid
320273 nospu ioprio_set sys_ioprio_set
321274 nospu ioprio_get sys_ioprio_get
322275 nospu inotify_init sys_inotify_init
323276 nospu inotify_add_watch sys_inotify_add_watch
324277 nospu inotify_rm_watch sys_inotify_rm_watch
325278 nospu spu_run sys_spu_run
326279 nospu spu_create sys_spu_create
327280 nospu pselect6 sys_pselect6 compat_sys_pselect6
328281 nospu ppoll sys_ppoll compat_sys_ppoll
329282 common unshare sys_unshare
330283 common splice sys_splice
331284 common tee sys_tee
332285 common vmsplice sys_vmsplice compat_sys_vmsplice
333286 common openat sys_openat compat_sys_openat
334287 common mkdirat sys_mkdirat
335288 common mknodat sys_mknodat
336289 common fchownat sys_fchownat
337290 common futimesat sys_futimesat compat_sys_futimesat
338291 32 fstatat64 sys_fstatat64
339291 64 newfstatat sys_newfstatat
340291 spu newfstatat sys_newfstatat
341292 common unlinkat sys_unlinkat
342293 common renameat sys_renameat
343294 common linkat sys_linkat
344295 common symlinkat sys_symlinkat
345296 common readlinkat sys_readlinkat
346297 common fchmodat sys_fchmodat
347298 common faccessat sys_faccessat
348299 common get_robust_list sys_get_robust_list compat_sys_get_robust_list
349300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list
350301 common move_pages sys_move_pages compat_sys_move_pages
351302 common getcpu sys_getcpu
352303 nospu epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
353304 common utimensat sys_utimensat compat_sys_utimensat
354305 common signalfd sys_signalfd compat_sys_signalfd
355306 common timerfd_create sys_timerfd_create
356307 common eventfd sys_eventfd
357308 common sync_file_range2 sys_sync_file_range2 compat_sys_sync_file_range2
358309 nospu fallocate sys_fallocate compat_sys_fallocate
359310 nospu subpage_prot sys_subpage_prot
360311 common timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime
361312 common timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime
362313 common signalfd4 sys_signalfd4 compat_sys_signalfd4
363314 common eventfd2 sys_eventfd2
364315 common epoll_create1 sys_epoll_create1
365316 common dup3 sys_dup3
366317 common pipe2 sys_pipe2
367318 nospu inotify_init1 sys_inotify_init1
368319 common perf_event_open sys_perf_event_open
369320 common preadv sys_preadv compat_sys_preadv
370321 common pwritev sys_pwritev compat_sys_pwritev
371322 nospu rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
372323 nospu fanotify_init sys_fanotify_init
373324 nospu fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark
374325 common prlimit64 sys_prlimit64
375326 common socket sys_socket
376327 common bind sys_bind
377328 common connect sys_connect
378329 common listen sys_listen
379330 common accept sys_accept
380331 common getsockname sys_getsockname
381332 common getpeername sys_getpeername
382333 common socketpair sys_socketpair
383334 common send sys_send
384335 common sendto sys_sendto
385336 common recv sys_recv compat_sys_recv
386337 common recvfrom sys_recvfrom compat_sys_recvfrom
387338 common shutdown sys_shutdown
388339 common setsockopt sys_setsockopt compat_sys_setsockopt
389340 common getsockopt sys_getsockopt compat_sys_getsockopt
390341 common sendmsg sys_sendmsg compat_sys_sendmsg
391342 common recvmsg sys_recvmsg compat_sys_recvmsg
392343 common recvmmsg sys_recvmmsg compat_sys_recvmmsg
393344 common accept4 sys_accept4
394345 common name_to_handle_at sys_name_to_handle_at
395346 common open_by_handle_at sys_open_by_handle_at compat_sys_open_by_handle_at
396347 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime
397348 common syncfs sys_syncfs
398349 common sendmmsg sys_sendmmsg compat_sys_sendmmsg
399350 common setns sys_setns
400351 nospu process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv
401352 nospu process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev
402353 nospu finit_module sys_finit_module
403354 nospu kcmp sys_kcmp
404355 common sched_setattr sys_sched_setattr
405356 common sched_getattr sys_sched_getattr
406357 common renameat2 sys_renameat2
407358 common seccomp sys_seccomp
408359 common getrandom sys_getrandom
409360 common memfd_create sys_memfd_create
410361 common bpf sys_bpf
411362 nospu execveat sys_execveat compat_sys_execveat
412363 32 switch_endian sys_ni_syscall
413363 64 switch_endian ppc_switch_endian
414363 spu switch_endian sys_ni_syscall
415364 common userfaultfd sys_userfaultfd
416365 common membarrier sys_membarrier
417378 nospu mlock2 sys_mlock2
418379 nospu copy_file_range sys_copy_file_range
419380 common preadv2 sys_preadv2 compat_sys_preadv2
420381 common pwritev2 sys_pwritev2 compat_sys_pwritev2
421382 nospu kexec_file_load sys_kexec_file_load
422383 nospu statx sys_statx
423384 nospu pkey_alloc sys_pkey_alloc
424385 nospu pkey_free sys_pkey_free
425386 nospu pkey_mprotect sys_pkey_mprotect
426387 nospu rseq sys_rseq
427388 nospu io_pgetevents sys_io_pgetevents compat_sys_io_pgetevents
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1410d66192f7..63a3afc7f32b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -561,7 +561,8 @@ try_again:
561 break; 561 break;
562 } 562 }
563 } 563 }
564 wait4(child_pid, &status, 0, &stat_config.ru_data); 564 if (child_pid != -1)
565 wait4(child_pid, &status, 0, &stat_config.ru_data);
565 566
566 if (workload_exec_errno) { 567 if (workload_exec_errno) {
567 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); 568 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index fe3ecfb2e64b..f64e312db787 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1028,12 +1028,7 @@ out_err:
1028 1028
1029static int callchain_param__setup_sample_type(struct callchain_param *callchain) 1029static int callchain_param__setup_sample_type(struct callchain_param *callchain)
1030{ 1030{
1031 if (!perf_hpp_list.sym) { 1031 if (callchain->mode != CHAIN_NONE) {
1032 if (callchain->enabled) {
1033 ui__error("Selected -g but \"sym\" not present in --sort/-s.");
1034 return -EINVAL;
1035 }
1036 } else if (callchain->mode != CHAIN_NONE) {
1037 if (callchain_register_param(callchain) < 0) { 1032 if (callchain_register_param(callchain) < 0) {
1038 ui__error("Can't register callchain params.\n"); 1033 ui__error("Can't register callchain params.\n");
1039 return -EINVAL; 1034 return -EINVAL;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index adbf28183560..ed4583128b9c 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1758,6 +1758,7 @@ static int trace__printf_interrupted_entry(struct trace *trace)
1758{ 1758{
1759 struct thread_trace *ttrace; 1759 struct thread_trace *ttrace;
1760 size_t printed; 1760 size_t printed;
1761 int len;
1761 1762
1762 if (trace->failure_only || trace->current == NULL) 1763 if (trace->failure_only || trace->current == NULL)
1763 return 0; 1764 return 0;
@@ -1768,9 +1769,14 @@ static int trace__printf_interrupted_entry(struct trace *trace)
1768 return 0; 1769 return 0;
1769 1770
1770 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output); 1771 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output);
1771 printed += fprintf(trace->output, ")%-*s ...\n", trace->args_alignment, ttrace->entry_str); 1772 printed += len = fprintf(trace->output, "%s)", ttrace->entry_str);
1772 ttrace->entry_pending = false; 1773
1774 if (len < trace->args_alignment - 4)
1775 printed += fprintf(trace->output, "%-*s", trace->args_alignment - 4 - len, " ");
1773 1776
1777 printed += fprintf(trace->output, " ...\n");
1778
1779 ttrace->entry_pending = false;
1774 ++trace->nr_events_printed; 1780 ++trace->nr_events_printed;
1775 1781
1776 return printed; 1782 return printed;
@@ -2026,9 +2032,10 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
2026 if (ttrace->entry_pending) { 2032 if (ttrace->entry_pending) {
2027 printed = fprintf(trace->output, "%s", ttrace->entry_str); 2033 printed = fprintf(trace->output, "%s", ttrace->entry_str);
2028 } else { 2034 } else {
2029 fprintf(trace->output, " ... ["); 2035 printed += fprintf(trace->output, " ... [");
2030 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued"); 2036 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued");
2031 fprintf(trace->output, "]: %s()", sc->name); 2037 printed += 9;
2038 printed += fprintf(trace->output, "]: %s()", sc->name);
2032 } 2039 }
2033 2040
2034 printed++; /* the closing ')' */ 2041 printed++; /* the closing ')' */
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 6cb98f8570a2..7b55613924de 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -10,6 +10,7 @@ include/uapi/linux/fs.h
10include/uapi/linux/kcmp.h 10include/uapi/linux/kcmp.h
11include/uapi/linux/kvm.h 11include/uapi/linux/kvm.h
12include/uapi/linux/in.h 12include/uapi/linux/in.h
13include/uapi/linux/mount.h
13include/uapi/linux/perf_event.h 14include/uapi/linux/perf_event.h
14include/uapi/linux/prctl.h 15include/uapi/linux/prctl.h
15include/uapi/linux/sched.h 16include/uapi/linux/sched.h
@@ -49,7 +50,6 @@ arch/parisc/include/uapi/asm/errno.h
49arch/powerpc/include/uapi/asm/errno.h 50arch/powerpc/include/uapi/asm/errno.h
50arch/sparc/include/uapi/asm/errno.h 51arch/sparc/include/uapi/asm/errno.h
51arch/x86/include/uapi/asm/errno.h 52arch/x86/include/uapi/asm/errno.h
52arch/powerpc/include/uapi/asm/unistd.h
53include/asm-generic/bitops/arch_hweight.h 53include/asm-generic/bitops/arch_hweight.h
54include/asm-generic/bitops/const_hweight.h 54include/asm-generic/bitops/const_hweight.h
55include/asm-generic/bitops/__fls.h 55include/asm-generic/bitops/__fls.h
diff --git a/tools/perf/perf-read-vdso.c b/tools/perf/perf-read-vdso.c
index 8c0ca0cc428f..aaa5210ea84a 100644
--- a/tools/perf/perf-read-vdso.c
+++ b/tools/perf/perf-read-vdso.c
@@ -5,17 +5,17 @@
5#define VDSO__MAP_NAME "[vdso]" 5#define VDSO__MAP_NAME "[vdso]"
6 6
7/* 7/*
8 * Include definition of find_vdso_map() also used in util/vdso.c for 8 * Include definition of find_map() also used in util/vdso.c for
9 * building perf. 9 * building perf.
10 */ 10 */
11#include "util/find-vdso-map.c" 11#include "util/find-map.c"
12 12
13int main(void) 13int main(void)
14{ 14{
15 void *start, *end; 15 void *start, *end;
16 size_t size, written; 16 size_t size, written;
17 17
18 if (find_vdso_map(&start, &end)) 18 if (find_map(&start, &end, VDSO__MAP_NAME))
19 return 1; 19 return 1;
20 20
21 size = end - start; 21 size = end - start;
diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
index 1c16e56cd93e..7cb99b433888 100644
--- a/tools/perf/tests/shell/lib/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
@@ -13,7 +13,8 @@ add_probe_vfs_getname() {
13 local verbose=$1 13 local verbose=$1
14 if [ $had_vfs_getname -eq 1 ] ; then 14 if [ $had_vfs_getname -eq 1 ] ; then
15 line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') 15 line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/')
16 perf probe $verbose "vfs_getname=getname_flags:${line} pathname=result->name:string" 16 perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \
17 perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string"
17 fi 18 fi
18} 19}
19 20
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index b82f55fcc294..399f18ca71a3 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -119,4 +119,9 @@ int test__arch_unwind_sample(struct perf_sample *sample,
119 struct thread *thread); 119 struct thread *thread);
120#endif 120#endif
121#endif 121#endif
122
123#if defined(__arm__)
124int test__vectors_page(struct test *test, int subtest);
125#endif
126
122#endif /* TESTS_H */ 127#endif /* TESTS_H */
diff --git a/tools/perf/trace/beauty/mount_flags.sh b/tools/perf/trace/beauty/mount_flags.sh
index 45547573a1db..847850b2ef6c 100755
--- a/tools/perf/trace/beauty/mount_flags.sh
+++ b/tools/perf/trace/beauty/mount_flags.sh
@@ -5,11 +5,11 @@
5 5
6printf "static const char *mount_flags[] = {\n" 6printf "static const char *mount_flags[] = {\n"
7regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*' 7regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*'
8egrep $regex ${header_dir}/fs.h | egrep -v '(MSK|VERBOSE|MGC_VAL)\>' | \ 8egrep $regex ${header_dir}/mount.h | egrep -v '(MSK|VERBOSE|MGC_VAL)\>' | \
9 sed -r "s/$regex/\2 \2 \1/g" | sort -n | \ 9 sed -r "s/$regex/\2 \2 \1/g" | sort -n | \
10 xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n" 10 xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n"
11regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*' 11regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*'
12egrep $regex ${header_dir}/fs.h | \ 12egrep $regex ${header_dir}/mount.h | \
13 sed -r "s/$regex/\2 \1/g" | \ 13 sed -r "s/$regex/\2 \1/g" | \
14 xargs printf "\t[%s + 1] = \"%s\",\n" 14 xargs printf "\t[%s + 1] = \"%s\",\n"
15printf "};\n" 15printf "};\n"
diff --git a/tools/perf/trace/beauty/prctl_option.sh b/tools/perf/trace/beauty/prctl_option.sh
index d32f8f1124af..3109d7b05e11 100755
--- a/tools/perf/trace/beauty/prctl_option.sh
+++ b/tools/perf/trace/beauty/prctl_option.sh
@@ -4,7 +4,7 @@
4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/ 4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
5 5
6printf "static const char *prctl_options[] = {\n" 6printf "static const char *prctl_options[] = {\n"
7regex='^#define[[:space:]]+PR_([GS]ET\w+)[[:space:]]*([[:xdigit:]]+).*' 7regex='^#define[[:space:]]+PR_(\w+)[[:space:]]*([[:xdigit:]]+).*'
8egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \ 8egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \
9 sed -r "s/$regex/\2 \1/g" | \ 9 sed -r "s/$regex/\2 \1/g" | \
10 sort -n | xargs printf "\t[%s] = \"%s\",\n" 10 sort -n | xargs printf "\t[%s] = \"%s\",\n"
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ac9805e0bc76..70de8f6b3aee 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1723,15 +1723,14 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1723 err = asprintf(&command, 1723 err = asprintf(&command,
1724 "%s %s%s --start-address=0x%016" PRIx64 1724 "%s %s%s --start-address=0x%016" PRIx64
1725 " --stop-address=0x%016" PRIx64 1725 " --stop-address=0x%016" PRIx64
1726 " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand", 1726 " -l -d %s %s -C \"$1\" 2>/dev/null|grep -v \"$1:\"|expand",
1727 opts->objdump_path ?: "objdump", 1727 opts->objdump_path ?: "objdump",
1728 opts->disassembler_style ? "-M " : "", 1728 opts->disassembler_style ? "-M " : "",
1729 opts->disassembler_style ?: "", 1729 opts->disassembler_style ?: "",
1730 map__rip_2objdump(map, sym->start), 1730 map__rip_2objdump(map, sym->start),
1731 map__rip_2objdump(map, sym->end), 1731 map__rip_2objdump(map, sym->end),
1732 opts->show_asm_raw ? "" : "--no-show-raw", 1732 opts->show_asm_raw ? "" : "--no-show-raw",
1733 opts->annotate_src ? "-S" : "", 1733 opts->annotate_src ? "-S" : "");
1734 symfs_filename, symfs_filename);
1735 1734
1736 if (err < 0) { 1735 if (err < 0) {
1737 pr_err("Failure allocating memory for the command to run\n"); 1736 pr_err("Failure allocating memory for the command to run\n");
@@ -1756,7 +1755,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1756 close(stdout_fd[0]); 1755 close(stdout_fd[0]);
1757 dup2(stdout_fd[1], 1); 1756 dup2(stdout_fd[1], 1);
1758 close(stdout_fd[1]); 1757 close(stdout_fd[1]);
1759 execl("/bin/sh", "sh", "-c", command, NULL); 1758 execl("/bin/sh", "sh", "-c", command, "--", symfs_filename,
1759 NULL);
1760 perror(command); 1760 perror(command);
1761 exit(-1); 1761 exit(-1);
1762 } 1762 }
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 32ef7bdca1cf..dc2212e12184 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -766,6 +766,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
766 cnode->cycles_count += node->branch_flags.cycles; 766 cnode->cycles_count += node->branch_flags.cycles;
767 cnode->iter_count += node->nr_loop_iter; 767 cnode->iter_count += node->nr_loop_iter;
768 cnode->iter_cycles += node->iter_cycles; 768 cnode->iter_cycles += node->iter_cycles;
769 cnode->from_count++;
769 } 770 }
770 } 771 }
771 772
@@ -1345,10 +1346,10 @@ static int branch_to_str(char *bf, int bfsize,
1345static int branch_from_str(char *bf, int bfsize, 1346static int branch_from_str(char *bf, int bfsize,
1346 u64 branch_count, 1347 u64 branch_count,
1347 u64 cycles_count, u64 iter_count, 1348 u64 cycles_count, u64 iter_count,
1348 u64 iter_cycles) 1349 u64 iter_cycles, u64 from_count)
1349{ 1350{
1350 int printed = 0, i = 0; 1351 int printed = 0, i = 0;
1351 u64 cycles; 1352 u64 cycles, v = 0;
1352 1353
1353 cycles = cycles_count / branch_count; 1354 cycles = cycles_count / branch_count;
1354 if (cycles) { 1355 if (cycles) {
@@ -1357,14 +1358,16 @@ static int branch_from_str(char *bf, int bfsize,
1357 bf + printed, bfsize - printed); 1358 bf + printed, bfsize - printed);
1358 } 1359 }
1359 1360
1360 if (iter_count) { 1361 if (iter_count && from_count) {
1361 printed += count_pri64_printf(i++, "iter", 1362 v = iter_count / from_count;
1362 iter_count, 1363 if (v) {
1363 bf + printed, bfsize - printed); 1364 printed += count_pri64_printf(i++, "iter",
1365 v, bf + printed, bfsize - printed);
1364 1366
1365 printed += count_pri64_printf(i++, "avg_cycles", 1367 printed += count_pri64_printf(i++, "avg_cycles",
1366 iter_cycles / iter_count, 1368 iter_cycles / iter_count,
1367 bf + printed, bfsize - printed); 1369 bf + printed, bfsize - printed);
1370 }
1368 } 1371 }
1369 1372
1370 if (i) 1373 if (i)
@@ -1377,6 +1380,7 @@ static int counts_str_build(char *bf, int bfsize,
1377 u64 branch_count, u64 predicted_count, 1380 u64 branch_count, u64 predicted_count,
1378 u64 abort_count, u64 cycles_count, 1381 u64 abort_count, u64 cycles_count,
1379 u64 iter_count, u64 iter_cycles, 1382 u64 iter_count, u64 iter_cycles,
1383 u64 from_count,
1380 struct branch_type_stat *brtype_stat) 1384 struct branch_type_stat *brtype_stat)
1381{ 1385{
1382 int printed; 1386 int printed;
@@ -1389,7 +1393,8 @@ static int counts_str_build(char *bf, int bfsize,
1389 predicted_count, abort_count, brtype_stat); 1393 predicted_count, abort_count, brtype_stat);
1390 } else { 1394 } else {
1391 printed = branch_from_str(bf, bfsize, branch_count, 1395 printed = branch_from_str(bf, bfsize, branch_count,
1392 cycles_count, iter_count, iter_cycles); 1396 cycles_count, iter_count, iter_cycles,
1397 from_count);
1393 } 1398 }
1394 1399
1395 if (!printed) 1400 if (!printed)
@@ -1402,13 +1407,14 @@ static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
1402 u64 branch_count, u64 predicted_count, 1407 u64 branch_count, u64 predicted_count,
1403 u64 abort_count, u64 cycles_count, 1408 u64 abort_count, u64 cycles_count,
1404 u64 iter_count, u64 iter_cycles, 1409 u64 iter_count, u64 iter_cycles,
1410 u64 from_count,
1405 struct branch_type_stat *brtype_stat) 1411 struct branch_type_stat *brtype_stat)
1406{ 1412{
1407 char str[256]; 1413 char str[256];
1408 1414
1409 counts_str_build(str, sizeof(str), branch_count, 1415 counts_str_build(str, sizeof(str), branch_count,
1410 predicted_count, abort_count, cycles_count, 1416 predicted_count, abort_count, cycles_count,
1411 iter_count, iter_cycles, brtype_stat); 1417 iter_count, iter_cycles, from_count, brtype_stat);
1412 1418
1413 if (fp) 1419 if (fp)
1414 return fprintf(fp, "%s", str); 1420 return fprintf(fp, "%s", str);
@@ -1422,6 +1428,7 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
1422 u64 branch_count, predicted_count; 1428 u64 branch_count, predicted_count;
1423 u64 abort_count, cycles_count; 1429 u64 abort_count, cycles_count;
1424 u64 iter_count, iter_cycles; 1430 u64 iter_count, iter_cycles;
1431 u64 from_count;
1425 1432
1426 branch_count = clist->branch_count; 1433 branch_count = clist->branch_count;
1427 predicted_count = clist->predicted_count; 1434 predicted_count = clist->predicted_count;
@@ -1429,11 +1436,12 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
1429 cycles_count = clist->cycles_count; 1436 cycles_count = clist->cycles_count;
1430 iter_count = clist->iter_count; 1437 iter_count = clist->iter_count;
1431 iter_cycles = clist->iter_cycles; 1438 iter_cycles = clist->iter_cycles;
1439 from_count = clist->from_count;
1432 1440
1433 return callchain_counts_printf(fp, bf, bfsize, branch_count, 1441 return callchain_counts_printf(fp, bf, bfsize, branch_count,
1434 predicted_count, abort_count, 1442 predicted_count, abort_count,
1435 cycles_count, iter_count, iter_cycles, 1443 cycles_count, iter_count, iter_cycles,
1436 &clist->brtype_stat); 1444 from_count, &clist->brtype_stat);
1437} 1445}
1438 1446
1439static void free_callchain_node(struct callchain_node *node) 1447static void free_callchain_node(struct callchain_node *node)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 154560b1eb65..99d38ac019b8 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -118,6 +118,7 @@ struct callchain_list {
118 bool has_children; 118 bool has_children;
119 }; 119 };
120 u64 branch_count; 120 u64 branch_count;
121 u64 from_count;
121 u64 predicted_count; 122 u64 predicted_count;
122 u64 abort_count; 123 u64 abort_count;
123 u64 cycles_count; 124 u64 cycles_count;
diff --git a/tools/perf/util/find-vdso-map.c b/tools/perf/util/find-map.c
index d7823e3508fc..7b2300588ece 100644
--- a/tools/perf/util/find-vdso-map.c
+++ b/tools/perf/util/find-map.c
@@ -1,5 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2static int find_vdso_map(void **start, void **end) 2static int find_map(void **start, void **end, const char *name)
3{ 3{
4 FILE *maps; 4 FILE *maps;
5 char line[128]; 5 char line[128];
@@ -7,7 +7,7 @@ static int find_vdso_map(void **start, void **end)
7 7
8 maps = fopen("/proc/self/maps", "r"); 8 maps = fopen("/proc/self/maps", "r");
9 if (!maps) { 9 if (!maps) {
10 fprintf(stderr, "vdso: cannot open maps\n"); 10 fprintf(stderr, "cannot open maps\n");
11 return -1; 11 return -1;
12 } 12 }
13 13
@@ -21,8 +21,7 @@ static int find_vdso_map(void **start, void **end)
21 if (m < 0) 21 if (m < 0)
22 continue; 22 continue;
23 23
24 if (!strncmp(&line[m], VDSO__MAP_NAME, 24 if (!strncmp(&line[m], name, strlen(name)))
25 sizeof(VDSO__MAP_NAME) - 1))
26 found = 1; 25 found = 1;
27 } 26 }
28 27
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 6fcb3bce0442..143f7057d581 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2005,7 +2005,7 @@ static void save_iterations(struct iterations *iter,
2005{ 2005{
2006 int i; 2006 int i;
2007 2007
2008 iter->nr_loop_iter = nr; 2008 iter->nr_loop_iter++;
2009 iter->cycles = 0; 2009 iter->cycles = 0;
2010 2010
2011 for (i = 0; i < nr; i++) 2011 for (i = 0; i < nr; i++)
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 9005fbe0780e..23092fd6451d 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -109,7 +109,6 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
109 return ret; 109 return ret;
110 } 110 }
111 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved); 111 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
112 va_end(ap_saved);
113 if (len > strbuf_avail(sb)) { 112 if (len > strbuf_avail(sb)) {
114 pr_debug("this should not happen, your vsnprintf is broken"); 113 pr_debug("this should not happen, your vsnprintf is broken");
115 va_end(ap_saved); 114 va_end(ap_saved);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 01f2c7385e38..48efad6d0f90 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -614,6 +614,7 @@ out:
614static bool symbol__is_idle(const char *name) 614static bool symbol__is_idle(const char *name)
615{ 615{
616 const char * const idle_symbols[] = { 616 const char * const idle_symbols[] = {
617 "arch_cpu_idle",
617 "cpu_idle", 618 "cpu_idle",
618 "cpu_startup_entry", 619 "cpu_startup_entry",
619 "intel_idle", 620 "intel_idle",
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 741af209b19d..3702cba11d7d 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -18,10 +18,10 @@
18#include "debug.h" 18#include "debug.h"
19 19
20/* 20/*
21 * Include definition of find_vdso_map() also used in perf-read-vdso.c for 21 * Include definition of find_map() also used in perf-read-vdso.c for
22 * building perf-read-vdso32 and perf-read-vdsox32. 22 * building perf-read-vdso32 and perf-read-vdsox32.
23 */ 23 */
24#include "find-vdso-map.c" 24#include "find-map.c"
25 25
26#define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX" 26#define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX"
27 27
@@ -76,7 +76,7 @@ static char *get_file(struct vdso_file *vdso_file)
76 if (vdso_file->found) 76 if (vdso_file->found)
77 return vdso_file->temp_file_name; 77 return vdso_file->temp_file_name;
78 78
79 if (vdso_file->error || find_vdso_map(&start, &end)) 79 if (vdso_file->error || find_map(&start, &end, VDSO__MAP_NAME))
80 return NULL; 80 return NULL;
81 81
82 size = end - start; 82 size = end - start;
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
index 89a2444c1df2..59e417ec3e13 100644
--- a/tools/thermal/tmon/Makefile
+++ b/tools/thermal/tmon/Makefile
@@ -6,7 +6,7 @@ VERSION = 1.0
6 6
7BINDIR=usr/bin 7BINDIR=usr/bin
8WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 8WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
9override CFLAGS+= -O1 ${WARNFLAGS} 9override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
10# Add "-fstack-protector" only if toolchain supports it. 10# Add "-fstack-protector" only if toolchain supports it.
11override CFLAGS+= $(call cc-option,-fstack-protector-strong) 11override CFLAGS+= $(call cc-option,-fstack-protector-strong)
12CC?= $(CROSS_COMPILE)gcc 12CC?= $(CROSS_COMPILE)gcc
diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 18fc112b65cd..d3a8755c039c 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -5,7 +5,9 @@
5 * Example use: 5 * Example use:
6 * cat /sys/kernel/debug/page_owner > page_owner_full.txt 6 * cat /sys/kernel/debug/page_owner > page_owner_full.txt
7 * grep -v ^PFN page_owner_full.txt > page_owner.txt 7 * grep -v ^PFN page_owner_full.txt > page_owner.txt
8 * ./sort page_owner.txt sorted_page_owner.txt 8 * ./page_owner_sort page_owner.txt sorted_page_owner.txt
9 *
10 * See Documentation/vm/page_owner.rst
9*/ 11*/
10 12
11#include <stdio.h> 13#include <stdio.h>
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1f888a103f78..5ecea812cb6a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1227,9 +1227,9 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm,
1227{ 1227{
1228 struct kvm_memslots *slots; 1228 struct kvm_memslots *slots;
1229 struct kvm_memory_slot *memslot; 1229 struct kvm_memory_slot *memslot;
1230 int as_id, id, n; 1230 int as_id, id;
1231 gfn_t offset; 1231 gfn_t offset;
1232 unsigned long i; 1232 unsigned long i, n;
1233 unsigned long *dirty_bitmap; 1233 unsigned long *dirty_bitmap;
1234 unsigned long *dirty_bitmap_buffer; 1234 unsigned long *dirty_bitmap_buffer;
1235 1235
@@ -1249,6 +1249,11 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm,
1249 return -ENOENT; 1249 return -ENOENT;
1250 1250
1251 n = kvm_dirty_bitmap_bytes(memslot); 1251 n = kvm_dirty_bitmap_bytes(memslot);
1252
1253 if (log->first_page > memslot->npages ||
1254 log->num_pages > memslot->npages - log->first_page)
1255 return -EINVAL;
1256
1252 *flush = false; 1257 *flush = false;
1253 dirty_bitmap_buffer = kvm_second_dirty_bitmap(memslot); 1258 dirty_bitmap_buffer = kvm_second_dirty_bitmap(memslot);
1254 if (copy_from_user(dirty_bitmap_buffer, log->dirty_bitmap, n)) 1259 if (copy_from_user(dirty_bitmap_buffer, log->dirty_bitmap, n))