History

Merge 5.15-rc4 into char-misc-next

We need the char-misc fixes in here as well.

Greg Kroah-Hartman committed 5 years ago

Commit 8bf7a122 parents 20ac422 9e1ff30349 files · +4142 −2311Browse files

Unified · Split

349 files
  1. Documentation/devicetree/bindings/interconnect/qcom,sdm660.yaml +42 −4
  2. Documentation/hwmon/k10temp.rst +0 −17
  3. MAINTAINERS +16 −12
  4. Makefile +1 −1
  5. arch/arm64/kvm/hyp/nvhe/Makefile +1 −1
  6. arch/arm64/kvm/perf.c +0 −3
  7. arch/arm64/kvm/pmu-emul.c +8 −1
  8. arch/m68k/68000/entry.S +0 −4
  9. arch/m68k/Kconfig +0 −1
  10. arch/m68k/coldfire/entry.S +0 −4
  11. arch/m68k/include/asm/processor.h +28 −3
  12. arch/m68k/include/asm/segment.h +0 −59
  13. arch/m68k/include/asm/thread_info.h +0 −3
  14. arch/m68k/include/asm/tlbflush.h +3 −8
  15. arch/m68k/include/asm/traps.h +4 −0
  16. arch/m68k/include/asm/uaccess.h +141 −74
  17. arch/m68k/kernel/asm-offsets.c +1 −1
  18. arch/m68k/kernel/entry.S +28 −30
  19. arch/m68k/kernel/process.c +2 −2
  20. arch/m68k/kernel/signal.c +83 −116
  21. arch/m68k/kernel/traps.c +4 −9
  22. arch/m68k/mac/misc.c +0 −1
  23. arch/m68k/mm/cache.c +3 −22
  24. arch/m68k/mm/init.c +0 −6
  25. arch/m68k/mm/kmap.c +0 −1
  26. arch/m68k/mm/memory.c +0 −1
  27. arch/m68k/mm/motorola.c +1 −1
  28. arch/m68k/sun3/config.c +1 −2
  29. arch/m68k/sun3/mmu_emu.c +2 −4
  30. arch/m68k/sun3/sun3ints.c +0 −1
  31. arch/m68k/sun3x/prom.c +0 −1
  32. arch/mips/net/bpf_jit.c +43 −14
  33. arch/nios2/Kconfig.debug +2 −1
  34. arch/nios2/kernel/setup.c +0 −2
  35. arch/s390/kvm/interrupt.c +2 −2
  36. arch/s390/kvm/kvm-s390.c +1 −1
  37. arch/s390/kvm/kvm-s390.h +1 −1
  38. arch/x86/crypto/sm4-aesni-avx-asm_64.S +3 −2
  39. arch/x86/events/core.c +1 −0
  40. arch/x86/events/intel/core.c +1 −0
  41. arch/x86/include/asm/kvm_page_track.h +1 −1
  42. arch/x86/include/asm/kvmclock.h +14 −0
  43. arch/x86/kernel/kvmclock.c +2 −11
  44. arch/x86/kvm/cpuid.c +2 −2
  45. arch/x86/kvm/emulate.c +1 −2
  46. arch/x86/kvm/hyperv.c +3 −4
  47. arch/x86/kvm/hyperv.h +1 −1
  48. arch/x86/kvm/ioapic.c +5 −5
  49. arch/x86/kvm/mmu/mmu.c +10 −7
  50. arch/x86/kvm/mmu/page_track.c +2 −2
  51. arch/x86/kvm/mmu/paging_tmpl.h +23 −23
  52. arch/x86/kvm/svm/nested.c +6 −4
  53. arch/x86/kvm/svm/sev.c +62 −30
  54. arch/x86/kvm/svm/svm.c +74 −63
  55. arch/x86/kvm/svm/svm.h +2 −1
  56. arch/x86/kvm/vmx/evmcs.c +9 −3
  57. arch/x86/kvm/vmx/nested.c +15 −9
  58. arch/x86/kvm/vmx/vmx.c +27 −12
  59. arch/x86/kvm/vmx/vmx.h +1 −4
  60. arch/x86/kvm/x86.c +26 −2
  61. arch/x86/net/bpf_jit_comp.c +48 −18
  62. block/bfq-iosched.c +3 −13
  63. drivers/acpi/nfit/core.c +12 −0
  64. drivers/base/core.c +63 −27
  65. drivers/block/nbd.c +17 −12
  66. drivers/crypto/ccp/ccp-ops.c +8 −6
  67. drivers/gpio/gpio-pca953x.c +2 −9
  68. drivers/gpio/gpio-rockchip.c +22 −0
  69. drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +31 −0
  70. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 −1
  71. drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2 −1
  72. drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 −1
  73. drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +8 −0
  74. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 −0
  75. drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +7 −8
  76. drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 −3
  77. drivers/gpu/drm/exynos/exynos_drm_dsi.c +1 −3
  78. drivers/gpu/drm/exynos/exynos_drm_fimc.c +1 −4
  79. drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 −3
  80. drivers/gpu/drm/exynos/exynos_drm_g2d.c +1 −4
  81. drivers/gpu/drm/exynos/exynos_drm_gsc.c +1 −5
  82. drivers/gpu/drm/exynos/exynos_drm_rotator.c +1 −3
  83. drivers/gpu/drm/exynos/exynos_drm_scaler.c +1 −3
  84. drivers/gpu/drm/exynos/exynos_hdmi.c +1 −3
  85. drivers/gpu/drm/i915/gt/intel_context.c +3 −2
  86. drivers/gpu/drm/i915/gt/intel_rps.c +0 −2
  87. drivers/gpu/drm/i915/gt/uc/abi/guc_communication_ctb_abi.h +5 −5
  88. drivers/gpu/drm/i915/gt/uc/abi/guc_communication_mmio_abi.h +5 −5
  89. drivers/gpu/drm/i915/gvt/scheduler.c +2 −2
  90. drivers/gpu/drm/i915/i915_request.c +2 −9
  91. drivers/gpu/drm/tegra/dc.c +0 −3
  92. drivers/gpu/drm/tegra/dc.h +0 −6
  93. drivers/gpu/drm/tegra/uapi.c +1 −1
  94. drivers/gpu/host1x/fence.c +4 −2
  95. drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +4 −4
  96. drivers/hid/hid-apple.c +7 −0
  97. drivers/hid/hid-betopff.c +10 −3
  98. drivers/hid/hid-u2fzero.c +3 −1
  99. drivers/hid/wacom_wac.c +8 −0
  100. drivers/hwmon/k10temp.c +0 −6
  101. drivers/hwmon/ltc2947-core.c +6 −2
  102. drivers/hwmon/mlxreg-fan.c +9 −3
  103. drivers/hwmon/occ/common.c +5 −12
  104. drivers/hwmon/pmbus/ibm-cffps.c +8 −2
  105. drivers/hwmon/pmbus/mp2975.c +1 −1
  106. drivers/hwmon/tmp421.c +39 −32
  107. drivers/hwmon/w83791d.c +11 −18
  108. drivers/hwmon/w83792d.c +11 −17
  109. drivers/hwmon/w83793.c +11 −15
  110. drivers/infiniband/core/cma.c +45 −6
  111. drivers/infiniband/core/cma_priv.h +1 −0
  112. drivers/infiniband/hw/hfi1/ipoib_tx.c +4 −4
  113. drivers/infiniband/hw/hns/hns_roce_cq.c +22 −9
  114. drivers/infiniband/hw/hns/hns_roce_hw_v2.c +7 −6
  115. drivers/infiniband/hw/irdma/cm.c +2 −2
  116. drivers/infiniband/hw/irdma/hw.c +11 −3
  117. drivers/infiniband/hw/irdma/i40iw_if.c +1 −1
  118. drivers/infiniband/hw/irdma/main.h +0 −1
  119. drivers/infiniband/hw/irdma/user.h +2 −0
  120. drivers/infiniband/hw/irdma/utils.c +1 −1
  121. drivers/infiniband/hw/irdma/verbs.c +6 −3
  122. drivers/infiniband/hw/qib/qib_sysfs.c +1 −1
  123. drivers/infiniband/hw/usnic/usnic_ib.h +1 −1
  124. drivers/infiniband/hw/usnic/usnic_ib_main.c +1 −1
  125. drivers/infiniband/hw/usnic/usnic_ib_verbs.c +8 −8
  126. drivers/interconnect/qcom/sdm660.c +19 −6
  127. drivers/iommu/apple-dart.c +35 −21
  128. drivers/iommu/intel/dmar.c +3 −3
  129. drivers/ipack/devices/ipoctal.c +47 −16
  130. drivers/media/platform/s5p-jpeg/jpeg-core.c +9 −9
  131. drivers/media/platform/s5p-jpeg/jpeg-core.h +14 −14
  132. drivers/media/rc/ir_toy.c +20 −1
  133. drivers/mmc/host/dw_mmc.c +12 −3
  134. drivers/mmc/host/renesas_sdhi_core.c +2 −0
  135. drivers/net/dsa/mv88e6xxx/chip.c +10 −7
  136. drivers/net/dsa/mv88e6xxx/chip.h +1 −0
  137. drivers/net/dsa/mv88e6xxx/global1.c +2 −0
  138. drivers/net/dsa/mv88e6xxx/port.c +2 −0
  139. drivers/net/ethernet/broadcom/bgmac-platform.c +3 −0
  140. drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 −2
  141. drivers/net/ethernet/hisilicon/hns3/hnae3.h +0 −1
  142. drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +7 −9
  143. drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +4 −2
  144. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +13 −8
  145. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +16 −13
  146. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +24 −4
  147. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +15 −12
  148. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +5 −28
  149. drivers/net/ethernet/hisilicon/hns_mdio.c +1 −1
  150. drivers/net/ethernet/ibm/ibmvnic.c +0 −8
  151. drivers/net/ethernet/intel/e100.c +15 −7
  152. drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +1 −1
  153. drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 −2
  154. drivers/net/ethernet/micrel/Makefile +2 −4
  155. drivers/net/ethernet/micrel/ks8851_common.c +8 −0
  156. drivers/net/ethernet/pensando/ionic/ionic_stats.c +0 −9
  157. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 −0
  158. drivers/net/ethernet/sun/Kconfig +1 −0
  159. drivers/net/hamradio/Kconfig +1 −0
  160. drivers/net/mdio/mdio-ipq4019.c +5 −1
  161. drivers/net/mdio/mdio-mscc-miim.c +10 −5
  162. drivers/net/mhi_net.c +1 −5
  163. drivers/net/phy/bcm7xxx.c +110 −4
  164. drivers/net/phy/mdio_bus.c +5 −0
  165. drivers/net/phy/mxl-gpy.c +21 −2
  166. drivers/net/usb/smsc95xx.c +3 −0
  167. drivers/net/wireless/mac80211_hwsim.c +2 −2
  168. drivers/nvdimm/pmem.c +1 −4
  169. drivers/nvme/host/core.c +3 −1
  170. drivers/nvme/host/nvme.h +6 −0
  171. drivers/nvme/host/pci.c +2 −1
  172. drivers/perf/arm_pmu.c +2 −0
  173. drivers/pinctrl/core.c +1 −1
  174. drivers/pinctrl/pinctrl-amd.c +14 −5
  175. drivers/pinctrl/pinctrl-amd.h +1 −0
  176. drivers/pinctrl/pinctrl-rockchip.c +67 −0
  177. drivers/pinctrl/pinctrl-rockchip.h +10 −0
  178. drivers/pinctrl/qcom/pinctrl-sc7280.c +1 −0
  179. drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +34 −3
  180. drivers/ptp/ptp_kvm_x86.c +2 −7
  181. drivers/s390/cio/blacklist.c +5 −3
  182. drivers/s390/cio/css.c +31 −9
  183. drivers/s390/cio/css.h +9 −1
  184. drivers/s390/crypto/vfio_ap_ops.c +3 −1
  185. drivers/scsi/csiostor/csio_init.c +1 −0
  186. drivers/scsi/qla2xxx/qla_isr.c +2 −2
  187. drivers/scsi/ses.c +1 −1
  188. drivers/scsi/ufs/ufshcd.c +1 −2
  189. drivers/scsi/virtio_scsi.c +2 −2
  190. drivers/staging/media/hantro/hantro_drv.c +1 −1
  191. drivers/staging/media/sunxi/cedrus/cedrus_video.c +1 −1
  192. drivers/vdpa/mlx5/net/mlx5_vnet.c +5 −0
  193. drivers/vdpa/vdpa_user/vduse_dev.c +5 −5
  194. drivers/vfio/pci/vfio_pci_core.c +1 −1
  195. drivers/vhost/vdpa.c +1 −1
  196. drivers/virtio/virtio.c +6 −1
  197. drivers/watchdog/Kconfig +1 −1
  198. fs/binfmt_elf.c +1 −1
  199. fs/debugfs/inode.c +1 −1
  200. fs/ext4/dir.c +3 −3
  201. fs/ext4/ext4.h +0 −3
  202. fs/ext4/extents.c +14 −5
  203. fs/ext4/fast_commit.c +6 −0
  204. fs/ext4/inline.c +85 −65
  205. fs/ext4/inode.c +59 −117
  206. fs/ext4/super.c +15 −6
  207. fs/io-wq.c +1 −4
  208. fs/io_uring.c +2 −15
  209. fs/kernfs/dir.c +7 −2
  210. fs/ksmbd/auth.c +0 −205
  211. fs/ksmbd/crypto_ctx.c +0 −16
  212. fs/ksmbd/crypto_ctx.h +0 −8
  213. fs/ksmbd/misc.c +7 −10
  214. fs/ksmbd/oplock.c +31 −10
  215. fs/ksmbd/smb2pdu.c +196 −60
  216. fs/ksmbd/smb2pdu.h +9 −0
  217. fs/ksmbd/smb_common.c +28 −19
  218. fs/ksmbd/smb_common.h +0 −8
  219. fs/ksmbd/smbacl.c +19 −2
  220. fs/ksmbd/transport_tcp.c +2 −2
  221. fs/vboxsf/super.c +2 −10
  222. fs/verity/enable.c +1 −1
  223. fs/verity/open.c +1 −1
  224. include/kvm/arm_pmu.h +0 −3
  225. include/linux/bpf.h +2 −1
  226. include/linux/cpumask.h +4 −3
  227. include/linux/fwnode.h +8 −3
  228. include/linux/kvm_host.h +0 −6
  229. include/linux/perf/arm_pmu.h +6 −0
  230. include/linux/perf_event.h +3 −1
  231. include/linux/sched.h +1 −1
  232. include/net/ip_fib.h +1 −1
  233. include/net/mac80211.h +4 −4
  234. include/net/nexthop.h +1 −1
  235. include/net/pkt_sched.h +1 −0
  236. include/net/sock.h +32 −1
  237. include/sound/rawmidi.h +1 −0
  238. include/trace/events/cachefiles.h +1 −1
  239. include/uapi/sound/asound.h +1 −0
  240. kernel/bpf/bpf_struct_ops.c +5 −2
  241. kernel/bpf/core.c +1 −1
  242. kernel/cgroup/cgroup.c +12 −5
  243. kernel/events/core.c +30 −4
  244. kernel/sched/debug.c +7 −1
  245. kernel/sched/fair.c +5 −1
  246. net/bpf/test_run.c +9 −5
  247. net/bridge/br_multicast.c +2 −4
  248. net/bridge/br_private.h +1 −1
  249. net/core/dev_addr_lists.c +6 −0
  250. net/core/sock.c +28 −24
  251. net/ipv4/fib_semantics.c +9 −7
  252. net/ipv4/netfilter/iptable_raw.c +1 −1
  253. net/ipv4/udp.c +5 −5
  254. net/ipv6/netfilter/ip6_tables.c +1 −0
  255. net/ipv6/route.c +3 −2
  256. net/ipv6/udp.c +1 −1
  257. net/mac80211/mesh_pathtbl.c +4 −1
  258. net/mac80211/mesh_ps.c +2 −1
  259. net/mac80211/rate.c +0 −4
  260. net/mac80211/rx.c +2 −1
  261. net/mac80211/tx.c +12 −0
  262. net/mac80211/wpa.c +6 −0
  263. net/mptcp/mptcp_diag.c +1 −1
  264. net/mptcp/pm_netlink.c +1 −3
  265. net/mptcp/protocol.c +1 −1
  266. net/mptcp/protocol.h +1 −1
  267. net/mptcp/subflow.c +1 −1
  268. net/mptcp/syncookies.c +1 −12
  269. net/mptcp/token.c +8 −3
  270. net/mptcp/token_test.c +8 −6
  271. net/netfilter/ipset/ip_set_hash_gen.h +2 −2
  272. net/netfilter/ipvs/ip_vs_conn.c +4 −0
  273. net/netfilter/nf_conntrack_core.c +100 −54
  274. net/netfilter/nf_nat_core.c +12 −5
  275. net/netfilter/nf_nat_masquerade.c +97 −71
  276. net/netfilter/nf_tables_api.c +19 −11
  277. net/netfilter/nft_compat.c +16 −1
  278. net/netfilter/xt_LOG.c +9 −1
  279. net/netfilter/xt_NFLOG.c +9 −1
  280. net/sched/cls_flower.c +6 −0
  281. net/sched/sch_api.c +6 −0
  282. net/sctp/input.c +1 −1
  283. net/unix/af_unix.c +60 −23
  284. sound/core/rawmidi.c +9 −0
  285. sound/drivers/pcsp/pcsp_lib.c +1 −1
  286. sound/firewire/motu/amdtp-motu.c +4 −3
  287. sound/firewire/oxfw/oxfw.c +8 −5
  288. sound/pci/hda/hda_intel.c +9 −3
  289. sound/pci/hda/patch_cs8409.c +3 −0
  290. sound/pci/hda/patch_realtek.c +129 −0
  291. sound/pci/pcxhr/pcxhr_core.c +1 −1
  292. sound/soc/fsl/fsl_esai.c +10 −6
  293. sound/soc/fsl/fsl_micfil.c +10 −5
  294. sound/soc/fsl/fsl_sai.c +9 −5
  295. sound/soc/fsl/fsl_spdif.c +9 −5
  296. sound/soc/fsl/fsl_xcvr.c +10 −5
  297. sound/soc/intel/boards/sof_sdw.c +5 −0
  298. sound/soc/mediatek/Kconfig +3 −0
  299. sound/soc/mediatek/common/mtk-afe-fe-dai.c +11 −8
  300. sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c +3 −4
  301. sound/soc/sof/core.c +1 −3
  302. sound/soc/sof/imx/imx8.c +8 −1
  303. sound/soc/sof/imx/imx8m.c +8 −1
  304. sound/soc/sof/loader.c +5 −3
  305. sound/soc/sof/trace.c +0 −1
  306. sound/soc/sof/xtensa/core.c +2 −2
  307. sound/usb/card.c +4 −14
  308. sound/usb/mixer.c +4 −22
  309. sound/usb/mixer.h +1 −2
  310. sound/usb/mixer_quirks.c +1 −1
  311. tools/lib/bpf/linker.c +7 −1
  312. tools/objtool/special.c +30 −8
  313. tools/perf/Documentation/jitdump-specification.txt +1 −1
  314. tools/perf/Documentation/perf-c2c.txt +1 −1
  315. tools/perf/Documentation/perf-intel-pt.txt +1 −1
  316. tools/perf/Documentation/perf-lock.txt +1 −1
  317. tools/perf/Documentation/perf-script-perl.txt +1 −1
  318. tools/perf/Documentation/perf-script-python.txt +1 −1
  319. tools/perf/Documentation/perf-stat.txt +1 −1
  320. tools/perf/Documentation/topdown.txt +1 −1
  321. tools/perf/arch/arm/util/auxtrace.c +4 −4
  322. tools/perf/arch/arm/util/cs-etm.c +12 −12
  323. tools/perf/arch/arm/util/perf_regs.c +1 −1
  324. tools/perf/arch/arm/util/pmu.c +1 −1
  325. tools/perf/arch/arm/util/unwind-libdw.c +3 −3
  326. tools/perf/arch/arm/util/unwind-libunwind.c +2 −2
  327. tools/perf/arch/x86/util/iostat.c +1 −1
  328. tools/perf/builtin-stat.c +2 −0
  329. tools/perf/pmu-events/arch/powerpc/power8/other.json +1 −1
  330. tools/perf/tests/code-reading.c +2 −2
  331. tools/perf/tests/dwarf-unwind.c +32 −7
  332. tools/perf/util/config.c +1 −1
  333. tools/testing/selftests/bpf/Makefile +2 −1
  334. tools/testing/selftests/bpf/test_lwt_ip_encap.sh +8 −5
  335. tools/testing/selftests/kvm/.gitignore +1 −0
  336. tools/testing/selftests/kvm/Makefile +1 −0
  337. tools/testing/selftests/kvm/access_tracking_perf_test.c +2 −4
  338. tools/testing/selftests/kvm/demand_paging_test.c +7 −8
  339. tools/testing/selftests/kvm/dirty_log_perf_test.c +42 −20
  340. tools/testing/selftests/kvm/include/test_util.h +3 −1
  341. tools/testing/selftests/kvm/include/x86_64/processor.h +17 −17
  342. tools/testing/selftests/kvm/kvm_page_table_test.c +2 −5
  343. tools/testing/selftests/kvm/lib/test_util.c +13 −4
  344. tools/testing/selftests/kvm/rseq_test.c +60 −10
  345. tools/testing/selftests/kvm/steal_time.c +2 −2
  346. tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c +128 −0
  347. tools/testing/selftests/netfilter/nft_nat_zones.sh +309 −0
  348. tools/testing/selftests/netfilter/nft_zones_many.sh +156 −0
  349. virt/kvm/kvm_main.c +49 −19
Documentation/devicetree/bindings/interconnect/qcom,sdm660.yaml+42−4
@@ -31,11 +31,11 @@ properties: · 30 unmodified lines
3131
3232 clocks:
3333 minItems: 1
34− maxItems: 3
34+ maxItems: 7
3535
3636 clock-names:
3737 minItems: 1
38− maxItems: 3
38+ maxItems: 7
3939
4040 required:
4141 - compatible
@@ -72,6 +72,32 @@ allOf: · 30 unmodified lines
7272 contains:
7373 enum:
7474 - qcom,sdm660-a2noc
75+ then:
76+ properties:
77+ clocks:
78+ items:
79+ - description: Bus Clock.
80+ - description: Bus A Clock.
81+ - description: IPA Clock.
82+ - description: UFS AXI Clock.
83+ - description: Aggregate2 UFS AXI Clock.
84+ - description: Aggregate2 USB3 AXI Clock.
85+ - description: Config NoC USB2 AXI Clock.
86+ clock-names:
87+ items:
88+ - const: bus
89+ - const: bus_a
90+ - const: ipa
91+ - const: ufs_axi
92+ - const: aggre2_ufs_axi
93+ - const: aggre2_usb3_axi
94+ - const: cfg_noc_usb2_axi
95+
96+ - if:
97+ properties:
98+ compatible:
99+ contains:
100+ enum:
75101 - qcom,sdm660-bimc
76102 - qcom,sdm660-cnoc
77103 - qcom,sdm660-gnoc
@@ -91,6 +117,7 @@ examples: · 13 unmodified lines
91117 - |
92118 #include <dt-bindings/clock/qcom,rpmcc.h>
93119 #include <dt-bindings/clock/qcom,mmcc-sdm660.h>
120+ #include <dt-bindings/clock/qcom,gcc-sdm660.h>
94121
95122 bimc: interconnect@1008000 {
96123 compatible = "qcom,sdm660-bimc";
@@ -123,9 +150,20 @@ examples: · 26 unmodified lines
123150 compatible = "qcom,sdm660-a2noc";
124151 reg = <0x01704000 0xc100>;
125152 #interconnect-cells = <1>;
126− clock-names = "bus", "bus_a";
153+ clock-names = "bus",
154+ "bus_a",
155+ "ipa",
156+ "ufs_axi",
157+ "aggre2_ufs_axi",
158+ "aggre2_usb3_axi",
159+ "cfg_noc_usb2_axi";
127160 clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>,
128− <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>;
161+ <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>,
162+ <&rpmcc RPM_SMD_IPA_CLK>,
163+ <&gcc GCC_UFS_AXI_CLK>,
164+ <&gcc GCC_AGGRE2_UFS_AXI_CLK>,
165+ <&gcc GCC_AGGRE2_USB3_AXI_CLK>,
166+ <&gcc GCC_CFG_NOC_USB2_AXI_CLK>;
129167 };
130168
131169 mnoc: interconnect@1745000 {
Documentation/hwmon/k10temp.rst+0−17
@@ -132,20 +132,3 @@ On Family 17h and Family 18h CPUs, additional temperature sensors may report · 131 unmodified lines
132132 Core Complex Die (CCD) temperatures. Up to 8 such temperatures are reported
133133 as temp{3..10}_input, labeled Tccd{1..8}. Actual support depends on the CPU
134134 variant.
135−
136−Various Family 17h and 18h CPUs report voltage and current telemetry
137−information. The following attributes may be reported.
138−
139−Attribute Label Description
140−=============== ======= ================
141−in0_input Vcore Core voltage
142−in1_input Vsoc SoC voltage
143−curr1_input Icore Core current
144−curr2_input Isoc SoC current
145−=============== ======= ================
146−
147−Current values are raw (unscaled) as reported by the CPU. Core current is
148−reported as multiples of 1A / LSB. SoC is reported as multiples of 0.25A
149−/ LSB. The real current is board specific. Reported currents should be seen
150−as rough guidance, and should be scaled using sensors3.conf as appropriate
151−for a given board.
MAINTAINERS+16−12
@@ -414,7 +414,8 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 413 unmodified lines
414414 F: drivers/acpi/pmic/
415415
416416 ACPI THERMAL DRIVER
417−M: Zhang Rui <rui.zhang@intel.com>
417+M: Rafael J. Wysocki <rafael@kernel.org>
418+R: Zhang Rui <rui.zhang@intel.com>
418419 L: linux-acpi@vger.kernel.org
419420 S: Supported
420421 W: https://01.org/linux-acpi
@@ -810,7 +811,7 @@ F: Documentation/devicetree/bindings/dma/altr,msgdma.yaml · 389 unmodified lines
810811 F: drivers/dma/altera-msgdma.c
811812
812813 ALTERA PIO DRIVER
813−M: Joyce Ooi <joyce.ooi@intel.com>
814+M: Mun Yew Tham <mun.yew.tham@intel.com>
814815 L: linux-gpio@vger.kernel.org
815816 S: Maintained
816817 F: drivers/gpio/gpio-altera.c
@@ -2961,7 +2962,7 @@ F: crypto/async_tx/ · 2144 unmodified lines
29612962 F: include/linux/async_tx.h
29622963
29632964 AT24 EEPROM DRIVER
2964−M: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2965+M: Bartosz Golaszewski <brgl@bgdev.pl>
29652966 L: linux-i2c@vger.kernel.org
29662967 S: Maintained
29672968 T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
@@ -3384,9 +3385,11 @@ F: Documentation/networking/filter.rst · 416 unmodified lines
33843385 F: Documentation/userspace-api/ebpf/
33853386 F: arch/*/net/*
33863387 F: include/linux/bpf*
3388+F: include/linux/btf*
33873389 F: include/linux/filter.h
33883390 F: include/trace/events/xdp.h
33893391 F: include/uapi/linux/bpf*
3392+F: include/uapi/linux/btf*
33903393 F: include/uapi/linux/filter.h
33913394 F: kernel/bpf/
33923395 F: kernel/trace/bpf_trace.c
@@ -3820,7 +3823,6 @@ F: drivers/scsi/mpi3mr/ · 427 unmodified lines
38203823
38213824 BROADCOM NETXTREME-E ROCE DRIVER
38223825 M: Selvin Xavier <selvin.xavier@broadcom.com>
3823−M: Naresh Kumar PBS <nareshkumar.pbs@broadcom.com>
38243826 L: linux-rdma@vger.kernel.org
38253827 S: Supported
38263828 W: http://www.broadcom.com
@@ -4655,7 +4657,7 @@ W: http://linux-cifs.samba.org/ · 828 unmodified lines
46554657 T: git git://git.samba.org/sfrench/cifs-2.6.git
46564658 F: Documentation/admin-guide/cifs/
46574659 F: fs/cifs/
4658−F: fs/cifs_common/
4660+F: fs/smbfs_common/
46594661
46604662 COMPACTPCI HOTPLUG CORE
46614663 M: Scott Murray <scott@spiteful.org>
@@ -7985,7 +7987,7 @@ F: include/linux/gpio/regmap.h · 3323 unmodified lines
79857987
79867988 GPIO SUBSYSTEM
79877989 M: Linus Walleij <linus.walleij@linaro.org>
7988−M: Bartosz Golaszewski <bgolaszewski@baylibre.com>
7990+M: Bartosz Golaszewski <brgl@bgdev.pl>
79897991 L: linux-gpio@vger.kernel.org
79907992 S: Maintained
79917993 T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git
@@ -10193,8 +10195,8 @@ M: Hyunchul Lee <hyc.lee@gmail.com> · 2201 unmodified lines
1019310195 L: linux-cifs@vger.kernel.org
1019410196 S: Maintained
1019510197 T: git git://git.samba.org/ksmbd.git
10196−F: fs/cifs_common/
1019710198 F: fs/ksmbd/
10199+F: fs/smbfs_common/
1019810200
1019910201 KERNEL UNIT TESTING FRAMEWORK (KUnit)
1020010202 M: Brendan Higgins <brendanhiggins@google.com>
@@ -11366,7 +11368,7 @@ F: Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.yaml · 1165 unmodified lines
1136611368 F: drivers/iio/proximity/mb1232.c
1136711369
1136811370 MAXIM MAX77650 PMIC MFD DRIVER
11369−M: Bartosz Golaszewski <bgolaszewski@baylibre.com>
11371+M: Bartosz Golaszewski <brgl@bgdev.pl>
1137011372 L: linux-kernel@vger.kernel.org
1137111373 S: Maintained
1137211374 F: Documentation/devicetree/bindings/*/*max77650.yaml
@@ -17883,7 +17885,8 @@ M: Olivier Moysan <olivier.moysan@foss.st.com> · 6510 unmodified lines
1788317885 M: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
1788417886 L: alsa-devel@alsa-project.org (moderated for non-subscribers)
1788517887 S: Maintained
17886−F: Documentation/devicetree/bindings/iio/adc/st,stm32-*.yaml
17888+F: Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml
17889+F: Documentation/devicetree/bindings/sound/st,stm32-*.yaml
1788717890 F: sound/soc/stm/
1788817891
1788917892 STM32 TIMER/LPTIMER DRIVERS
@@ -18547,13 +18550,14 @@ T: git git://linuxtv.org/media_tree.git · 657 unmodified lines
1854718550 F: drivers/media/radio/radio-raremono.c
1854818551
1854918552 THERMAL
18550−M: Zhang Rui <rui.zhang@intel.com>
18553+M: Rafael J. Wysocki <rafael@kernel.org>
1855118554 M: Daniel Lezcano <daniel.lezcano@linaro.org>
1855218555 R: Amit Kucheria <amitk@kernel.org>
18556+R: Zhang Rui <rui.zhang@intel.com>
1855318557 L: linux-pm@vger.kernel.org
1855418558 S: Supported
1855518559 Q: https://patchwork.kernel.org/project/linux-pm/list/
18556−T: git git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git
18560+T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
1855718561 F: Documentation/devicetree/bindings/thermal/
1855818562 F: drivers/thermal/
1855918563 F: include/linux/cpu_cooling.h
@@ -18682,7 +18686,7 @@ F: include/linux/clk/ti.h · 122 unmodified lines
1868218686
1868318687 TI DAVINCI MACHINE SUPPORT
1868418688 M: Sekhar Nori <nsekhar@ti.com>
18685−R: Bartosz Golaszewski <bgolaszewski@baylibre.com>
18689+R: Bartosz Golaszewski <brgl@bgdev.pl>
1868618690 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1868718691 S: Supported
1868818692 T: git git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci.git
Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 5
33 PATCHLEVEL = 15
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc3
5+EXTRAVERSION = -rc4
66 NAME = Opossums on Parade
77
88 # *DOCUMENTATION*
arch/arm64/kvm/hyp/nvhe/Makefile+1−1
@@ -54,7 +54,7 @@ $(obj)/kvm_nvhe.tmp.o: $(obj)/hyp.lds $(addprefix $(obj)/,$(hyp-obj)) FORCE · 53 unmodified lines
5454 # runtime. Because the hypervisor is part of the kernel binary, relocations
5555 # produce a kernel VA. We enumerate relocations targeting hyp at build time
5656 # and convert the kernel VAs at those positions to hyp VAs.
57−$(obj)/hyp-reloc.S: $(obj)/kvm_nvhe.tmp.o $(obj)/gen-hyprel
57+$(obj)/hyp-reloc.S: $(obj)/kvm_nvhe.tmp.o $(obj)/gen-hyprel FORCE
5858 $(call if_changed,hyprel)
5959
6060 # 5) Compile hyp-reloc.S and link it into the existing partially linked object.
arch/arm64/kvm/perf.c+0−3
@@ -50,9 +50,6 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = { · 49 unmodified lines
5050
5151 int kvm_perf_init(void)
5252 {
53− if (kvm_pmu_probe_pmuver() != ID_AA64DFR0_PMUVER_IMP_DEF && !is_protected_kvm_enabled())
54− static_branch_enable(&kvm_arm_pmu_available);
55−
5653 return perf_register_guest_info_callbacks(&kvm_guest_cbs);
5754 }
5855
arch/arm64/kvm/pmu-emul.c+8−1
@@ -740,7 +740,14 @@ void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data, · 739 unmodified lines
740740 kvm_pmu_create_perf_event(vcpu, select_idx);
741741 }
742742
743−int kvm_pmu_probe_pmuver(void)
743+void kvm_host_pmu_init(struct arm_pmu *pmu)
744+{
745+ if (pmu->pmuver != 0 && pmu->pmuver != ID_AA64DFR0_PMUVER_IMP_DEF &&
746+ !kvm_arm_support_pmu_v3() && !is_protected_kvm_enabled())
747+ static_branch_enable(&kvm_arm_pmu_available);
748+}
749+
750+static int kvm_pmu_probe_pmuver(void)
744751 {
745752 struct perf_event_attr attr = { };
746753 struct perf_event *event;
arch/m68k/68000/entry.S+0−4
@@ -15,7 +15,6 @@ · 14 unmodified lines
1515 #include <asm/unistd.h>
1616 #include <asm/errno.h>
1717 #include <asm/setup.h>
18−#include <asm/segment.h>
1918 #include <asm/traps.h>
2019 #include <asm/asm-offsets.h>
2120 #include <asm/entry.h>
@@ -25,7 +24,6 @@ · 3 unmodified lines
2524 .globl system_call
2625 .globl resume
2726 .globl ret_from_exception
28−.globl ret_from_signal
2927 .globl sys_call_table
3028 .globl bad_interrupt
3129 .globl inthandler1
@@ -59,8 +57,6 @@ do_trace: · 27 unmodified lines
5957 subql #4,%sp /* dummy return address */
6058 SAVE_SWITCH_STACK
6159 jbsr syscall_trace_leave
62−
63−ret_from_signal:
6460 RESTORE_SWITCH_STACK
6561 addql #4,%sp
6662 jra ret_from_exception
arch/m68k/Kconfig+0−1
@@ -29,7 +29,6 @@ config M68K · 28 unmodified lines
2929 select NO_DMA if !MMU && !COLDFIRE
3030 select OLD_SIGACTION
3131 select OLD_SIGSUSPEND3
32− select SET_FS
3332 select UACCESS_MEMCPY if !MMU
3433 select VIRT_TO_BUS
3534 select ZONE_DMA
arch/m68k/coldfire/entry.S+0−4
@@ -31,7 +31,6 @@ · 30 unmodified lines
3131 #include <asm/thread_info.h>
3232 #include <asm/errno.h>
3333 #include <asm/setup.h>
34−#include <asm/segment.h>
3534 #include <asm/asm-offsets.h>
3635 #include <asm/entry.h>
3736
@@ -51,7 +50,6 @@ sw_usp: · 13 unmodified lines
5150 .globl system_call
5251 .globl resume
5352 .globl ret_from_exception
54−.globl ret_from_signal
5553 .globl sys_call_table
5654 .globl inthandler
5755
@@ -98,8 +96,6 @@ ENTRY(system_call) · 40 unmodified lines
9896 subql #4,%sp /* dummy return address */
9997 SAVE_SWITCH_STACK
10098 jbsr syscall_trace_leave
101−
102−ret_from_signal:
10399 RESTORE_SWITCH_STACK
104100 addql #4,%sp
105101
arch/m68k/include/asm/processor.h+28−3
@@ -9,7 +9,6 @@ · 8 unmodified lines
99 #define __ASM_M68K_PROCESSOR_H
1010
1111 #include <linux/thread_info.h>
12−#include <asm/segment.h>
1312 #include <asm/fpu.h>
1413 #include <asm/ptrace.h>
1514
@@ -75,11 +74,37 @@ static inline void wrusp(unsigned long usp) · 59 unmodified lines
7574 #define TASK_UNMAPPED_BASE 0
7675 #endif
7776
77+/* Address spaces (or Function Codes in Motorola lingo) */
78+#define USER_DATA 1
79+#define USER_PROGRAM 2
80+#define SUPER_DATA 5
81+#define SUPER_PROGRAM 6
82+#define CPU_SPACE 7
83+
84+#ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
85+/*
86+ * Set the SFC/DFC registers for special MM operations. For most normal
87+ * operation these remain set to USER_DATA for the uaccess routines.
88+ */
89+static inline void set_fc(unsigned long val)
90+{
91+ WARN_ON_ONCE(in_interrupt());
92+
93+ __asm__ __volatile__ ("movec %0,%/sfc\n\t"
94+ "movec %0,%/dfc\n\t"
95+ : /* no outputs */ : "r" (val) : "memory");
96+}
97+#else
98+static inline void set_fc(unsigned long val)
99+{
100+}
101+#endif /* CONFIG_CPU_HAS_ADDRESS_SPACES */
102+
78103 struct thread_struct {
79104 unsigned long ksp; /* kernel stack pointer */
80105 unsigned long usp; /* user stack pointer */
81106 unsigned short sr; /* saved status register */
82− unsigned short fs; /* saved fs (sfc, dfc) */
107+ unsigned short fc; /* saved fc (sfc, dfc) */
83108 unsigned long crp[2]; /* cpu root pointer */
84109 unsigned long esp0; /* points to SR of stack frame */
85110 unsigned long faddr; /* info about last fault */
@@ -92,7 +117,7 @@ struct thread_struct { · 6 unmodified lines
92117 #define INIT_THREAD { \
93118 .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
94119 .sr = PS_S, \
95− .fs = __KERNEL_DS, \
120+ .fc = USER_DATA, \
96121 }
97122
98123 /*
arch/m68k/include/asm/segment.h+0−59
@@ -1,59 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _M68K_SEGMENT_H
3−#define _M68K_SEGMENT_H
4−
5−/* define constants */
6−/* Address spaces (FC0-FC2) */
7−#define USER_DATA (1)
8−#ifndef __USER_DS
9−#define __USER_DS (USER_DATA)
10−#endif
11−#define USER_PROGRAM (2)
12−#define SUPER_DATA (5)
13−#ifndef __KERNEL_DS
14−#define __KERNEL_DS (SUPER_DATA)
15−#endif
16−#define SUPER_PROGRAM (6)
17−#define CPU_SPACE (7)
18−
19−#ifndef __ASSEMBLY__
20−
21−typedef struct {
22− unsigned long seg;
23−} mm_segment_t;
24−
25−#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
26−
27−#ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
28−/*
29− * Get/set the SFC/DFC registers for MOVES instructions
30− */
31−#define USER_DS MAKE_MM_SEG(__USER_DS)
32−#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
33−
34−static inline mm_segment_t get_fs(void)
35−{
36− mm_segment_t _v;
37− __asm__ ("movec %/dfc,%0":"=r" (_v.seg):);
38− return _v;
39−}
40−
41−static inline void set_fs(mm_segment_t val)
42−{
43− __asm__ __volatile__ ("movec %0,%/sfc\n\t"
44− "movec %0,%/dfc\n\t"
45− : /* no outputs */ : "r" (val.seg) : "memory");
46−}
47−
48−#else
49−#define USER_DS MAKE_MM_SEG(TASK_SIZE)
50−#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
51−#define get_fs() (current_thread_info()->addr_limit)
52−#define set_fs(x) (current_thread_info()->addr_limit = (x))
53−#endif
54−
55−#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
56−
57−#endif /* __ASSEMBLY__ */
58−
59−#endif /* _M68K_SEGMENT_H */
arch/m68k/include/asm/thread_info.h+0−3
@@ -4,7 +4,6 @@ · 3 unmodified lines
44
55 #include <asm/types.h>
66 #include <asm/page.h>
7−#include <asm/segment.h>
87
98 /*
109 * On machines with 4k pages we default to an 8k thread size, though we
@@ -27,7 +26,6 @@ · 16 unmodified lines
2726 struct thread_info {
2827 struct task_struct *task; /* main task structure */
2928 unsigned long flags;
30− mm_segment_t addr_limit; /* thread address space */
3129 int preempt_count; /* 0 => preemptable, <0 => BUG */
3230 __u32 cpu; /* should always be 0 on m68k */
3331 unsigned long tp_value; /* thread pointer */
@@ -37,7 +35,6 @@ struct thread_info { · 3 unmodified lines
3735 #define INIT_THREAD_INFO(tsk) \
3836 { \
3937 .task = &tsk, \
40− .addr_limit = KERNEL_DS, \
4138 .preempt_count = INIT_PREEMPT_COUNT, \
4239 }
4340
arch/m68k/include/asm/tlbflush.h+3−8
@@ -13,13 +13,12 @@ static inline void flush_tlb_kernel_page(void *addr) · 12 unmodified lines
1313 if (CPU_IS_COLDFIRE) {
1414 mmu_write(MMUOR, MMUOR_CNL);
1515 } else if (CPU_IS_040_OR_060) {
16− mm_segment_t old_fs = get_fs();
17− set_fs(KERNEL_DS);
16+ set_fc(SUPER_DATA);
1817 __asm__ __volatile__(".chip 68040\n\t"
1918 "pflush (%0)\n\t"
2019 ".chip 68k"
2120 : : "a" (addr));
22− set_fs(old_fs);
21+ set_fc(USER_DATA);
2322 } else if (CPU_IS_020_OR_030)
2423 __asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr));
2524 }
@@ -84,12 +83,8 @@ static inline void flush_tlb_mm(struct mm_struct *mm) · 58 unmodified lines
8483
8584 static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
8685 {
87− if (vma->vm_mm == current->active_mm) {
88− mm_segment_t old_fs = force_uaccess_begin();
89−
86+ if (vma->vm_mm == current->active_mm)
9087 __flush_tlb_one(addr);
91− force_uaccess_end(old_fs);
92− }
9388 }
9489
9590 static inline void flush_tlb_range(struct vm_area_struct *vma,
arch/m68k/include/asm/traps.h+4−0
@@ -267,6 +267,10 @@ struct frame { · 266 unmodified lines
267267 } un;
268268 };
269269
270+#ifdef CONFIG_M68040
271+asmlinkage void berr_040cleanup(struct frame *fp);
272+#endif
273+
270274 #endif /* __ASSEMBLY__ */
271275
272276 #endif /* _M68K_TRAPS_H */
arch/m68k/include/asm/uaccess.h+141−74
@@ -9,13 +9,16 @@ · 8 unmodified lines
99 */
1010 #include <linux/compiler.h>
1111 #include <linux/types.h>
12−#include <asm/segment.h>
1312 #include <asm/extable.h>
1413
1514 /* We let the MMU do all checking */
1615 static inline int access_ok(const void __user *addr,
1716 unsigned long size)
1817 {
18+ /*
19+ * XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check
20+ * for TASK_SIZE!
21+ */
1922 return 1;
2023 }
2124
@@ -35,12 +38,9 @@ static inline int access_ok(const void __user *addr, · 13 unmodified lines
3538 #define MOVES "move"
3639 #endif
3740
38−extern int __put_user_bad(void);
39−extern int __get_user_bad(void);
40−
41−#define __put_user_asm(res, x, ptr, bwl, reg, err) \
41+#define __put_user_asm(inst, res, x, ptr, bwl, reg, err) \
4242 asm volatile ("\n" \
43− "1: "MOVES"."#bwl" %2,%1\n" \
43+ "1: "inst"."#bwl" %2,%1\n" \
4444 "2:\n" \
4545 " .section .fixup,\"ax\"\n" \
4646 " .even\n" \
@@ -56,6 +56,31 @@ asm volatile ("\n" \ · 9 unmodified lines
5656 : "+d" (res), "=m" (*(ptr)) \
5757 : #reg (x), "i" (err))
5858
59+#define __put_user_asm8(inst, res, x, ptr) \
60+do { \
61+ const void *__pu_ptr = (const void __force *)(ptr); \
62+ \
63+ asm volatile ("\n" \
64+ "1: "inst".l %2,(%1)+\n" \
65+ "2: "inst".l %R2,(%1)\n" \
66+ "3:\n" \
67+ " .section .fixup,\"ax\"\n" \
68+ " .even\n" \
69+ "10: movel %3,%0\n" \
70+ " jra 3b\n" \
71+ " .previous\n" \
72+ "\n" \
73+ " .section __ex_table,\"a\"\n" \
74+ " .align 4\n" \
75+ " .long 1b,10b\n" \
76+ " .long 2b,10b\n" \
77+ " .long 3b,10b\n" \
78+ " .previous" \
79+ : "+d" (res), "+a" (__pu_ptr) \
80+ : "r" (x), "i" (-EFAULT) \
81+ : "memory"); \
82+} while (0)
83+
5984 /*
6085 * These are the main single-value transfer routines. They automatically
6186 * use the right size if we just have the right pointer type.
@@ -68,51 +93,29 @@ asm volatile ("\n" \ · 6 unmodified lines
6893 __chk_user_ptr(ptr); \
6994 switch (sizeof (*(ptr))) { \
7095 case 1: \
71− __put_user_asm(__pu_err, __pu_val, ptr, b, d, -EFAULT); \
96+ __put_user_asm(MOVES, __pu_err, __pu_val, ptr, b, d, -EFAULT); \
7297 break; \
7398 case 2: \
74− __put_user_asm(__pu_err, __pu_val, ptr, w, r, -EFAULT); \
99+ __put_user_asm(MOVES, __pu_err, __pu_val, ptr, w, r, -EFAULT); \
75100 break; \
76101 case 4: \
77− __put_user_asm(__pu_err, __pu_val, ptr, l, r, -EFAULT); \
102+ __put_user_asm(MOVES, __pu_err, __pu_val, ptr, l, r, -EFAULT); \
78103 break; \
79104 case 8: \
80− { \
81− const void __user *__pu_ptr = (ptr); \
82− asm volatile ("\n" \
83− "1: "MOVES".l %2,(%1)+\n" \
84− "2: "MOVES".l %R2,(%1)\n" \
85− "3:\n" \
86− " .section .fixup,\"ax\"\n" \
87− " .even\n" \
88− "10: movel %3,%0\n" \
89− " jra 3b\n" \
90− " .previous\n" \
91− "\n" \
92− " .section __ex_table,\"a\"\n" \
93− " .align 4\n" \
94− " .long 1b,10b\n" \
95− " .long 2b,10b\n" \
96− " .long 3b,10b\n" \
97− " .previous" \
98− : "+d" (__pu_err), "+a" (__pu_ptr) \
99− : "r" (__pu_val), "i" (-EFAULT) \
100− : "memory"); \
105+ __put_user_asm8(MOVES, __pu_err, __pu_val, ptr); \
101106 break; \
102− } \
103107 default: \
104− __pu_err = __put_user_bad(); \
105− break; \
108+ BUILD_BUG(); \
106109 } \
107110 __pu_err; \
108111 })
109112 #define put_user(x, ptr) __put_user(x, ptr)
110113
111114
112−#define __get_user_asm(res, x, ptr, type, bwl, reg, err) ({ \
115+#define __get_user_asm(inst, res, x, ptr, type, bwl, reg, err) ({ \
113116 type __gu_val; \
114117 asm volatile ("\n" \
115− "1: "MOVES"."#bwl" %2,%1\n" \
118+ "1: "inst"."#bwl" %2,%1\n" \
116119 "2:\n" \
117120 " .section .fixup,\"ax\"\n" \
118121 " .even\n" \
@@ -130,53 +133,57 @@ asm volatile ("\n" \ · 11 unmodified lines
130133 (x) = (__force typeof(*(ptr)))(__force unsigned long)__gu_val; \
131134 })
132135
136+#define __get_user_asm8(inst, res, x, ptr) \
137+do { \
138+ const void *__gu_ptr = (const void __force *)(ptr); \
139+ union { \
140+ u64 l; \
141+ __typeof__(*(ptr)) t; \
142+ } __gu_val; \
143+ \
144+ asm volatile ("\n" \
145+ "1: "inst".l (%2)+,%1\n" \
146+ "2: "inst".l (%2),%R1\n" \
147+ "3:\n" \
148+ " .section .fixup,\"ax\"\n" \
149+ " .even\n" \
150+ "10: move.l %3,%0\n" \
151+ " sub.l %1,%1\n" \
152+ " sub.l %R1,%R1\n" \
153+ " jra 3b\n" \
154+ " .previous\n" \
155+ "\n" \
156+ " .section __ex_table,\"a\"\n" \
157+ " .align 4\n" \
158+ " .long 1b,10b\n" \
159+ " .long 2b,10b\n" \
160+ " .previous" \
161+ : "+d" (res), "=&r" (__gu_val.l), \
162+ "+a" (__gu_ptr) \
163+ : "i" (-EFAULT) \
164+ : "memory"); \
165+ (x) = __gu_val.t; \
166+} while (0)
167+
133168 #define __get_user(x, ptr) \
134169 ({ \
135170 int __gu_err = 0; \
136171 __chk_user_ptr(ptr); \
137172 switch (sizeof(*(ptr))) { \
138173 case 1: \
139− __get_user_asm(__gu_err, x, ptr, u8, b, d, -EFAULT); \
174+ __get_user_asm(MOVES, __gu_err, x, ptr, u8, b, d, -EFAULT); \
140175 break; \
141176 case 2: \
142− __get_user_asm(__gu_err, x, ptr, u16, w, r, -EFAULT); \
177+ __get_user_asm(MOVES, __gu_err, x, ptr, u16, w, r, -EFAULT); \
143178 break; \
144179 case 4: \
145− __get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT); \
180+ __get_user_asm(MOVES, __gu_err, x, ptr, u32, l, r, -EFAULT); \
146181 break; \
147− case 8: { \
148− const void __user *__gu_ptr = (ptr); \
149− union { \
150− u64 l; \
151− __typeof__(*(ptr)) t; \
152− } __gu_val; \
153− asm volatile ("\n" \
154− "1: "MOVES".l (%2)+,%1\n" \
155− "2: "MOVES".l (%2),%R1\n" \
156− "3:\n" \
157− " .section .fixup,\"ax\"\n" \
158− " .even\n" \
159− "10: move.l %3,%0\n" \
160− " sub.l %1,%1\n" \
161− " sub.l %R1,%R1\n" \
162− " jra 3b\n" \
163− " .previous\n" \
164− "\n" \
165− " .section __ex_table,\"a\"\n" \
166− " .align 4\n" \
167− " .long 1b,10b\n" \
168− " .long 2b,10b\n" \
169− " .previous" \
170− : "+d" (__gu_err), "=&r" (__gu_val.l), \
171− "+a" (__gu_ptr) \
172− : "i" (-EFAULT) \
173− : "memory"); \
174− (x) = __gu_val.t; \
182+ case 8: \
183+ __get_user_asm8(MOVES, __gu_err, x, ptr); \
175184 break; \
176− } \
177185 default: \
178− __gu_err = __get_user_bad(); \
179− break; \
186+ BUILD_BUG(); \
180187 } \
181188 __gu_err; \
182189 })
@@ -322,16 +329,19 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n) · 139 unmodified lines
322329
323330 switch (n) {
324331 case 1:
325− __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1);
332+ __put_user_asm(MOVES, res, *(u8 *)from, (u8 __user *)to,
333+ b, d, 1);
326334 break;
327335 case 2:
328− __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, r, 2);
336+ __put_user_asm(MOVES, res, *(u16 *)from, (u16 __user *)to,
337+ w, r, 2);
329338 break;
330339 case 3:
331340 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
332341 break;
333342 case 4:
334− __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4);
343+ __put_user_asm(MOVES, res, *(u32 *)from, (u32 __user *)to,
344+ l, r, 4);
335345 break;
336346 case 5:
337347 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,);
@@ -380,8 +390,65 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n) · 42 unmodified lines
380390 #define INLINE_COPY_FROM_USER
381391 #define INLINE_COPY_TO_USER
382392
383−#define user_addr_max() \
384− (uaccess_kernel() ? ~0UL : TASK_SIZE)
393+#define HAVE_GET_KERNEL_NOFAULT
394+
395+#define __get_kernel_nofault(dst, src, type, err_label) \
396+do { \
397+ type *__gk_dst = (type *)(dst); \
398+ type *__gk_src = (type *)(src); \
399+ int __gk_err = 0; \
400+ \
401+ switch (sizeof(type)) { \
402+ case 1: \
403+ __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \
404+ u8, b, d, -EFAULT); \
405+ break; \
406+ case 2: \
407+ __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \
408+ u16, w, r, -EFAULT); \
409+ break; \
410+ case 4: \
411+ __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \
412+ u32, l, r, -EFAULT); \
413+ break; \
414+ case 8: \
415+ __get_user_asm8("move", __gk_err, *__gk_dst, __gk_src); \
416+ break; \
417+ default: \
418+ BUILD_BUG(); \
419+ } \
420+ if (unlikely(__gk_err)) \
421+ goto err_label; \
422+} while (0)
423+
424+#define __put_kernel_nofault(dst, src, type, err_label) \
425+do { \
426+ type __pk_src = *(type *)(src); \
427+ type *__pk_dst = (type *)(dst); \
428+ int __pk_err = 0; \
429+ \
430+ switch (sizeof(type)) { \
431+ case 1: \
432+ __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \
433+ b, d, -EFAULT); \
434+ break; \
435+ case 2: \
436+ __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \
437+ w, r, -EFAULT); \
438+ break; \
439+ case 4: \
440+ __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \
441+ l, r, -EFAULT); \
442+ break; \
443+ case 8: \
444+ __put_user_asm8("move", __pk_err, __pk_src, __pk_dst); \
445+ break; \
446+ default: \
447+ BUILD_BUG(); \
448+ } \
449+ if (unlikely(__pk_err)) \
450+ goto err_label; \
451+} while (0)
385452
386453 extern long strncpy_from_user(char *dst, const char __user *src, long count);
387454 extern __must_check long strnlen_user(const char __user *str, long n);
arch/m68k/kernel/asm-offsets.c+1−1
@@ -31,7 +31,7 @@ int main(void) · 30 unmodified lines
3131 DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
3232 DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
3333 DEFINE(THREAD_SR, offsetof(struct thread_struct, sr));
34− DEFINE(THREAD_FS, offsetof(struct thread_struct, fs));
34+ DEFINE(THREAD_FC, offsetof(struct thread_struct, fc));
3535 DEFINE(THREAD_CRP, offsetof(struct thread_struct, crp));
3636 DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
3737 DEFINE(THREAD_FPREG, offsetof(struct thread_struct, fp));
arch/m68k/kernel/entry.S+28−30
@@ -36,7 +36,6 @@ · 35 unmodified lines
3636 #include <linux/linkage.h>
3737 #include <asm/errno.h>
3838 #include <asm/setup.h>
39−#include <asm/segment.h>
4039 #include <asm/traps.h>
4140 #include <asm/unistd.h>
4241 #include <asm/asm-offsets.h>
@@ -78,20 +77,38 @@ ENTRY(__sys_clone3) · 35 unmodified lines
7877
7978 ENTRY(sys_sigreturn)
8079 SAVE_SWITCH_STACK
81− movel %sp,%sp@- | switch_stack pointer
82− pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
80+ movel %sp,%a1 | switch_stack pointer
81+ lea %sp@(SWITCH_STACK_SIZE),%a0 | pt_regs pointer
82+ lea %sp@(-84),%sp | leave a gap
83+ movel %a1,%sp@-
84+ movel %a0,%sp@-
8385 jbsr do_sigreturn
84− addql #8,%sp
85− RESTORE_SWITCH_STACK
86− rts
86+ jra 1f | shared with rt_sigreturn()
8787
8888 ENTRY(sys_rt_sigreturn)
8989 SAVE_SWITCH_STACK
90− movel %sp,%sp@- | switch_stack pointer
91− pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
90+ movel %sp,%a1 | switch_stack pointer
91+ lea %sp@(SWITCH_STACK_SIZE),%a0 | pt_regs pointer
92+ lea %sp@(-84),%sp | leave a gap
93+ movel %a1,%sp@-
94+ movel %a0,%sp@-
95+ | stack contents:
96+ | [original pt_regs address] [original switch_stack address]
97+ | [gap] [switch_stack] [pt_regs] [exception frame]
9298 jbsr do_rt_sigreturn
93− addql #8,%sp
99+
100+1:
101+ | stack contents now:
102+ | [original pt_regs address] [original switch_stack address]
103+ | [unused part of the gap] [moved switch_stack] [moved pt_regs]
104+ | [replacement exception frame]
105+ | return value of do_{rt_,}sigreturn() points to moved switch_stack.
106+
107+ movel %d0,%sp | discard the leftover junk
94108 RESTORE_SWITCH_STACK
109+ | stack contents now is just [syscall return address] [pt_regs] [frame]
110+ | return pt_regs.d0
111+ movel %sp@(PT_OFF_D0+4),%d0
95112 rts
96113
97114 ENTRY(buserr)
@@ -182,25 +199,6 @@ do_trace_exit: · 84 unmodified lines
182199 addql #4,%sp
183200 jra .Lret_from_exception
184201
185−ENTRY(ret_from_signal)
186− movel %curptr@(TASK_STACK),%a1
187− tstb %a1@(TINFO_FLAGS+2)
188− jge 1f
189− jbsr syscall_trace
190−1: RESTORE_SWITCH_STACK
191− addql #4,%sp
192−/* on 68040 complete pending writebacks if any */
193−#ifdef CONFIG_M68040
194− bfextu %sp@(PT_OFF_FORMATVEC){#0,#4},%d0
195− subql #7,%d0 | bus error frame ?
196− jbne 1f
197− movel %sp,%sp@-
198− jbsr berr_040cleanup
199− addql #4,%sp
200−1:
201−#endif
202− jra .Lret_from_exception
203−
204202 ENTRY(system_call)
205203 SAVE_ALL_SYS
206204
@@ -338,7 +336,7 @@ resume: · 131 unmodified lines
338336
339337 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
340338 movec %sfc,%d0
341− movew %d0,%a0@(TASK_THREAD+THREAD_FS)
339+ movew %d0,%a0@(TASK_THREAD+THREAD_FC)
342340
343341 /* save usp */
344342 /* it is better to use a movel here instead of a movew 8*) */
@@ -424,7 +422,7 @@ resume: · 79 unmodified lines
424422 movel %a0,%usp
425423
426424 /* restore fs (sfc,%dfc) */
427− movew %a1@(TASK_THREAD+THREAD_FS),%a0
425+ movew %a1@(TASK_THREAD+THREAD_FC),%a0
428426 movec %a0,%sfc
429427 movec %a0,%dfc
430428
arch/m68k/kernel/process.c+2−2
@@ -92,7 +92,7 @@ void show_regs(struct pt_regs * regs) · 91 unmodified lines
9292
9393 void flush_thread(void)
9494 {
95− current->thread.fs = __USER_DS;
95+ current->thread.fc = USER_DATA;
9696 #ifdef CONFIG_FPU
9797 if (!FPU_IS_EMU) {
9898 unsigned long zero = 0;
@@ -155,7 +155,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg, · 56 unmodified lines
155155 * Must save the current SFC/DFC value, NOT the value when
156156 * the parent was last descheduled - RGH 10-08-96
157157 */
158− p->thread.fs = get_fs().seg;
158+ p->thread.fc = USER_DATA;
159159
160160 if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
161161 /* kernel thread */
arch/m68k/kernel/signal.c+83−116
@@ -447,7 +447,7 @@ static inline void save_fpu_state(struct sigcontext *sc, struct pt_regs *regs) · 446 unmodified lines
447447
448448 if (CPU_IS_060 ? sc->sc_fpstate[2] : sc->sc_fpstate[0]) {
449449 fpu_version = sc->sc_fpstate[0];
450− if (CPU_IS_020_OR_030 &&
450+ if (CPU_IS_020_OR_030 && !regs->stkadj &&
451451 regs->vector >= (VEC_FPBRUC * 4) &&
452452 regs->vector <= (VEC_FPNAN * 4)) {
453453 /* Clear pending exception in 68882 idle frame */
@@ -510,7 +510,7 @@ static inline int rt_save_fpu_state(struct ucontext __user *uc, struct pt_regs * · 56 unmodified lines
510510 if (!(CPU_IS_060 || CPU_IS_COLDFIRE))
511511 context_size = fpstate[1];
512512 fpu_version = fpstate[0];
513− if (CPU_IS_020_OR_030 &&
513+ if (CPU_IS_020_OR_030 && !regs->stkadj &&
514514 regs->vector >= (VEC_FPBRUC * 4) &&
515515 regs->vector <= (VEC_FPNAN * 4)) {
516516 /* Clear pending exception in 68882 idle frame */
@@ -641,56 +641,35 @@ static inline void siginfo_build_tests(void) · 124 unmodified lines
641641 static int mangle_kernel_stack(struct pt_regs *regs, int formatvec,
642642 void __user *fp)
643643 {
644− int fsize = frame_extra_sizes(formatvec >> 12);
645− if (fsize < 0) {
644+ int extra = frame_extra_sizes(formatvec >> 12);
645+ char buf[sizeof_field(struct frame, un)];
646+
647+ if (extra < 0) {
646648 /*
647649 * user process trying to return with weird frame format
648650 */
649651 pr_debug("user process returning with weird frame format\n");
650− return 1;
652+ return -1;
651653 }
652− if (!fsize) {
653− regs->format = formatvec >> 12;
654− regs->vector = formatvec & 0xfff;
655− } else {
656− struct switch_stack *sw = (struct switch_stack *)regs - 1;
657− /* yes, twice as much as max(sizeof(frame.un.fmt<x>)) */
658− unsigned long buf[sizeof_field(struct frame, un) / 2];
659−
660− /* that'll make sure that expansion won't crap over data */
661− if (copy_from_user(buf + fsize / 4, fp, fsize))
662− return 1;
663−
664− /* point of no return */
665− regs->format = formatvec >> 12;
666− regs->vector = formatvec & 0xfff;
667−#define frame_offset (sizeof(struct pt_regs)+sizeof(struct switch_stack))
668− __asm__ __volatile__ (
669−#ifdef CONFIG_COLDFIRE
670− " movel %0,%/sp\n\t"
671− " bra ret_from_signal\n"
672−#else
673− " movel %0,%/a0\n\t"
674− " subl %1,%/a0\n\t" /* make room on stack */
675− " movel %/a0,%/sp\n\t" /* set stack pointer */
676− /* move switch_stack and pt_regs */
677− "1: movel %0@+,%/a0@+\n\t"
678− " dbra %2,1b\n\t"
679− " lea %/sp@(%c3),%/a0\n\t" /* add offset of fmt */
680− " lsrl #2,%1\n\t"
681− " subql #1,%1\n\t"
682− /* copy to the gap we'd made */
683− "2: movel %4@+,%/a0@+\n\t"
684− " dbra %1,2b\n\t"
685− " bral ret_from_signal\n"
654+ if (extra && copy_from_user(buf, fp, extra))
655+ return -1;
656+ regs->format = formatvec >> 12;
657+ regs->vector = formatvec & 0xfff;
658+ if (extra) {
659+ void *p = (struct switch_stack *)regs - 1;
660+ struct frame *new = (void *)regs - extra;
661+ int size = sizeof(struct pt_regs)+sizeof(struct switch_stack);
662+
663+ memmove(p - extra, p, size);
664+ memcpy(p - extra + size, buf, extra);
665+ current->thread.esp0 = (unsigned long)&new->ptregs;
666+#ifdef CONFIG_M68040
667+ /* on 68040 complete pending writebacks if any */
668+ if (new->ptregs.format == 7) // bus error frame
669+ berr_040cleanup(new);
686670 #endif
687− : /* no outputs, it doesn't ever return */
688− : "a" (sw), "d" (fsize), "d" (frame_offset/4-1),
689− "n" (frame_offset), "a" (buf + fsize/4)
690− : "a0");
691−#undef frame_offset
692671 }
693− return 0;
672+ return extra;
694673 }
695674
696675 static inline int
@@ -698,7 +677,6 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *usc, void __u · 1 unmodified line
698677 {
699678 int formatvec;
700679 struct sigcontext context;
701− int err = 0;
702680
703681 siginfo_build_tests();
704682
@@ -707,7 +685,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *usc, void __u · 2 unmodified lines
707685
708686 /* get previous context */
709687 if (copy_from_user(&context, usc, sizeof(context)))
710− goto badframe;
688+ return -1;
711689
712690 /* restore passed registers */
713691 regs->d0 = context.sc_d0;
@@ -720,15 +698,10 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *usc, void __u · 6 unmodified lines
720698 wrusp(context.sc_usp);
721699 formatvec = context.sc_formatvec;
722700
723− err = restore_fpu_state(&context);
701+ if (restore_fpu_state(&context))
702+ return -1;
724703
725− if (err || mangle_kernel_stack(regs, formatvec, fp))
726− goto badframe;
727−
728− return 0;
729−
730−badframe:
731− return 1;
704+ return mangle_kernel_stack(regs, formatvec, fp);
732705 }
733706
734707 static inline int
@@ -745,7 +718,7 @@ rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw, · 10 unmodified lines
745718
746719 err = __get_user(temp, &uc->uc_mcontext.version);
747720 if (temp != MCONTEXT_VERSION)
748− goto badframe;
721+ return -1;
749722 /* restore passed registers */
750723 err |= __get_user(regs->d0, &gregs[0]);
751724 err |= __get_user(regs->d1, &gregs[1]);
@@ -774,22 +747,17 @@ rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw, · 22 unmodified lines
774747 err |= restore_altstack(&uc->uc_stack);
775748
776749 if (err)
777− goto badframe;
750+ return -1;
778751
779− if (mangle_kernel_stack(regs, temp, &uc->uc_extra))
780− goto badframe;
781−
782− return 0;
783−
784−badframe:
785− return 1;
752+ return mangle_kernel_stack(regs, temp, &uc->uc_extra);
786753 }
787754
788−asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
755+asmlinkage void *do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
789756 {
790757 unsigned long usp = rdusp();
791758 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
792759 sigset_t set;
760+ int size;
793761
794762 if (!access_ok(frame, sizeof(*frame)))
795763 goto badframe;
@@ -801,20 +769,22 @@ asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw) · 5 unmodified lines
801769
802770 set_current_blocked(&set);
803771
804− if (restore_sigcontext(regs, &frame->sc, frame + 1))
772+ size = restore_sigcontext(regs, &frame->sc, frame + 1);
773+ if (size < 0)
805774 goto badframe;
806− return regs->d0;
775+ return (void *)sw - size;
807776
808777 badframe:
809778 force_sig(SIGSEGV);
810− return 0;
779+ return sw;
811780 }
812781
813−asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
782+asmlinkage void *do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
814783 {
815784 unsigned long usp = rdusp();
816785 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
817786 sigset_t set;
787+ int size;
818788
819789 if (!access_ok(frame, sizeof(*frame)))
820790 goto badframe;
@@ -823,27 +793,34 @@ asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw) · 2 unmodified lines
823793
824794 set_current_blocked(&set);
825795
826− if (rt_restore_ucontext(regs, sw, &frame->uc))
796+ size = rt_restore_ucontext(regs, sw, &frame->uc);
797+ if (size < 0)
827798 goto badframe;
828− return regs->d0;
799+ return (void *)sw - size;
829800
830801 badframe:
831802 force_sig(SIGSEGV);
832− return 0;
803+ return sw;
804+}
805+
806+static inline struct pt_regs *rte_regs(struct pt_regs *regs)
807+{
808+ return (void *)regs + regs->stkadj;
833809 }
834810
835811 static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
836812 unsigned long mask)
837813 {
814+ struct pt_regs *tregs = rte_regs(regs);
838815 sc->sc_mask = mask;
839816 sc->sc_usp = rdusp();
840817 sc->sc_d0 = regs->d0;
841818 sc->sc_d1 = regs->d1;
842819 sc->sc_a0 = regs->a0;
843820 sc->sc_a1 = regs->a1;
844− sc->sc_sr = regs->sr;
845− sc->sc_pc = regs->pc;
846− sc->sc_formatvec = regs->format << 12 | regs->vector;
821+ sc->sc_sr = tregs->sr;
822+ sc->sc_pc = tregs->pc;
823+ sc->sc_formatvec = tregs->format << 12 | tregs->vector;
847824 save_a5_state(sc, regs);
848825 save_fpu_state(sc, regs);
849826 }
@@ -851,6 +828,7 @@ static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, · 1 unmodified line
851828 static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs *regs)
852829 {
853830 struct switch_stack *sw = (struct switch_stack *)regs - 1;
831+ struct pt_regs *tregs = rte_regs(regs);
854832 greg_t __user *gregs = uc->uc_mcontext.gregs;
855833 int err = 0;
856834
@@ -871,9 +849,9 @@ static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs * · 14 unmodified lines
871849 err |= __put_user(sw->a5, &gregs[13]);
872850 err |= __put_user(sw->a6, &gregs[14]);
873851 err |= __put_user(rdusp(), &gregs[15]);
874− err |= __put_user(regs->pc, &gregs[16]);
875− err |= __put_user(regs->sr, &gregs[17]);
876− err |= __put_user((regs->format << 12) | regs->vector, &uc->uc_formatvec);
852+ err |= __put_user(tregs->pc, &gregs[16]);
853+ err |= __put_user(tregs->sr, &gregs[17]);
854+ err |= __put_user((tregs->format << 12) | tregs->vector, &uc->uc_formatvec);
877855 err |= rt_save_fpu_state(uc, regs);
878856 return err;
879857 }
@@ -890,13 +868,14 @@ static int setup_frame(struct ksignal *ksig, sigset_t *set, · 10 unmodified lines
890868 struct pt_regs *regs)
891869 {
892870 struct sigframe __user *frame;
893− int fsize = frame_extra_sizes(regs->format);
871+ struct pt_regs *tregs = rte_regs(regs);
872+ int fsize = frame_extra_sizes(tregs->format);
894873 struct sigcontext context;
895874 int err = 0, sig = ksig->sig;
896875
897876 if (fsize < 0) {
898877 pr_debug("setup_frame: Unknown frame format %#x\n",
899− regs->format);
878+ tregs->format);
900879 return -EFAULT;
901880 }
902881
@@ -907,7 +886,7 @@ static int setup_frame(struct ksignal *ksig, sigset_t *set, · 4 unmodified lines
907886
908887 err |= __put_user(sig, &frame->sig);
909888
910− err |= __put_user(regs->vector, &frame->code);
889+ err |= __put_user(tregs->vector, &frame->code);
911890 err |= __put_user(&frame->sc, &frame->psc);
912891
913892 if (_NSIG_WORDS > 1)
@@ -933,34 +912,28 @@ static int setup_frame(struct ksignal *ksig, sigset_t *set, · 19 unmodified lines
933912
934913 push_cache ((unsigned long) &frame->retcode);
935914
936− /*
937− * Set up registers for signal handler. All the state we are about
938− * to destroy is successfully copied to sigframe.
939− */
940− wrusp ((unsigned long) frame);
941− regs->pc = (unsigned long) ksig->ka.sa.sa_handler;
942− adjustformat(regs);
943−
944915 /*
945916 * This is subtle; if we build more than one sigframe, all but the
946917 * first one will see frame format 0 and have fsize == 0, so we won't
947918 * screw stkadj.
948919 */
949− if (fsize)
920+ if (fsize) {
950921 regs->stkadj = fsize;
951−
952− /* Prepare to skip over the extra stuff in the exception frame. */
953− if (regs->stkadj) {
954− struct pt_regs *tregs =
955− (struct pt_regs *)((ulong)regs + regs->stkadj);
922+ tregs = rte_regs(regs);
956923 pr_debug("Performing stackadjust=%04lx\n", regs->stkadj);
957− /* This must be copied with decreasing addresses to
958− handle overlaps. */
959924 tregs->vector = 0;
960925 tregs->format = 0;
961− tregs->pc = regs->pc;
962926 tregs->sr = regs->sr;
963927 }
928+
929+ /*
930+ * Set up registers for signal handler. All the state we are about
931+ * to destroy is successfully copied to sigframe.
932+ */
933+ wrusp ((unsigned long) frame);
934+ tregs->pc = (unsigned long) ksig->ka.sa.sa_handler;
935+ adjustformat(regs);
936+
964937 return 0;
965938 }
966939
@@ -968,7 +941,8 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 1 unmodified line
968941 struct pt_regs *regs)
969942 {
970943 struct rt_sigframe __user *frame;
971− int fsize = frame_extra_sizes(regs->format);
944+ struct pt_regs *tregs = rte_regs(regs);
945+ int fsize = frame_extra_sizes(tregs->format);
972946 int err = 0, sig = ksig->sig;
973947
974948 if (fsize < 0) {
@@ -1018,34 +992,27 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 43 unmodified lines
1018992
1019993 push_cache ((unsigned long) &frame->retcode);
1020994
1021− /*
1022− * Set up registers for signal handler. All the state we are about
1023− * to destroy is successfully copied to sigframe.
1024− */
1025− wrusp ((unsigned long) frame);
1026− regs->pc = (unsigned long) ksig->ka.sa.sa_handler;
1027− adjustformat(regs);
1028−
1029995 /*
1030996 * This is subtle; if we build more than one sigframe, all but the
1031997 * first one will see frame format 0 and have fsize == 0, so we won't
1032998 * screw stkadj.
1033999 */
1034− if (fsize)
1000+ if (fsize) {
10351001 regs->stkadj = fsize;
1036−
1037− /* Prepare to skip over the extra stuff in the exception frame. */
1038− if (regs->stkadj) {
1039− struct pt_regs *tregs =
1040− (struct pt_regs *)((ulong)regs + regs->stkadj);
1002+ tregs = rte_regs(regs);
10411003 pr_debug("Performing stackadjust=%04lx\n", regs->stkadj);
1042− /* This must be copied with decreasing addresses to
1043− handle overlaps. */
10441004 tregs->vector = 0;
10451005 tregs->format = 0;
1046− tregs->pc = regs->pc;
10471006 tregs->sr = regs->sr;
10481007 }
1008+
1009+ /*
1010+ * Set up registers for signal handler. All the state we are about
1011+ * to destroy is successfully copied to sigframe.
1012+ */
1013+ wrusp ((unsigned long) frame);
1014+ tregs->pc = (unsigned long) ksig->ka.sa.sa_handler;
1015+ adjustformat(regs);
10491016 return 0;
10501017 }
10511018
arch/m68k/kernel/traps.c+4−9
@@ -181,9 +181,8 @@ static inline void access_error060 (struct frame *fp) · 180 unmodified lines
181181 static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
182182 {
183183 unsigned long mmusr;
184− mm_segment_t old_fs = get_fs();
185184
186− set_fs(MAKE_MM_SEG(wbs));
185+ set_fc(wbs);
187186
188187 if (iswrite)
189188 asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
@@ -192,7 +191,7 @@ static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs) · 2 unmodified lines
192191
193192 asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
194193
195− set_fs(old_fs);
194+ set_fc(USER_DATA);
196195
197196 return mmusr;
198197 }
@@ -201,10 +200,8 @@ static inline int do_040writeback1(unsigned short wbs, unsigned long wba, · 2 unmodified lines
201200 unsigned long wbd)
202201 {
203202 int res = 0;
204− mm_segment_t old_fs = get_fs();
205203
206− /* set_fs can not be moved, otherwise put_user() may oops */
207− set_fs(MAKE_MM_SEG(wbs));
204+ set_fc(wbs);
208205
209206 switch (wbs & WBSIZ_040) {
210207 case BA_SIZE_BYTE:
@@ -218,9 +215,7 @@ static inline int do_040writeback1(unsigned short wbs, unsigned long wba, · 7 unmodified lines
218215 break;
219216 }
220217
221− /* set_fs can not be moved, otherwise put_user() may oops */
222− set_fs(old_fs);
223−
218+ set_fc(USER_DATA);
224219
225220 pr_debug("do_040writeback1, res=%d\n", res);
226221
arch/m68k/mac/misc.c+0−1
@@ -18,7 +18,6 @@ · 17 unmodified lines
1818
1919 #include <linux/uaccess.h>
2020 #include <asm/io.h>
21−#include <asm/segment.h>
2221 #include <asm/setup.h>
2322 #include <asm/macintosh.h>
2423 #include <asm/mac_via.h>
arch/m68k/mm/cache.c+3−22
@@ -49,24 +49,7 @@ static unsigned long virt_to_phys_slow(unsigned long vaddr) · 48 unmodified lines
4949 if (mmusr & MMU_R_040)
5050 return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
5151 } else {
52− unsigned short mmusr;
53− unsigned long *descaddr;
54−
55− asm volatile ("ptestr %3,%2@,#7,%0\n\t"
56− "pmove %%psr,%1"
57− : "=a&" (descaddr), "=m" (mmusr)
58− : "a" (vaddr), "d" (get_fs().seg));
59− if (mmusr & (MMU_I|MMU_B|MMU_L))
60− return 0;
61− descaddr = phys_to_virt((unsigned long)descaddr);
62− switch (mmusr & MMU_NUM) {
63− case 1:
64− return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff);
65− case 2:
66− return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff);
67− case 3:
68− return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
69− }
52+ WARN_ON_ONCE(!CPU_IS_040_OR_060);
7053 }
7154 return 0;
7255 }
@@ -107,11 +90,9 @@ void flush_icache_user_range(unsigned long address, unsigned long endaddr) · 34 unmodified lines
10790
10891 void flush_icache_range(unsigned long address, unsigned long endaddr)
10992 {
110− mm_segment_t old_fs = get_fs();
111−
112− set_fs(KERNEL_DS);
93+ set_fc(SUPER_DATA);
11394 flush_icache_user_range(address, endaddr);
114− set_fs(old_fs);
95+ set_fc(USER_DATA);
11596 }
11697 EXPORT_SYMBOL(flush_icache_range);
11798
arch/m68k/mm/init.c+0−6
@@ -72,12 +72,6 @@ void __init paging_init(void) · 71 unmodified lines
7272 if (!empty_zero_page)
7373 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
7474 __func__, PAGE_SIZE, PAGE_SIZE);
75−
76− /*
77− * Set up SFC/DFC registers (user data space).
78− */
79− set_fs (USER_DS);
80−
8175 max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
8276 free_area_init(max_zone_pfn);
8377 }
arch/m68k/mm/kmap.c+0−1
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 #include <linux/vmalloc.h>
1818
1919 #include <asm/setup.h>
20−#include <asm/segment.h>
2120 #include <asm/page.h>
2221 #include <asm/io.h>
2322 #include <asm/tlbflush.h>
arch/m68k/mm/memory.c+0−1
@@ -15,7 +15,6 @@ · 14 unmodified lines
1515 #include <linux/gfp.h>
1616
1717 #include <asm/setup.h>
18−#include <asm/segment.h>
1918 #include <asm/page.h>
2019 #include <asm/traps.h>
2120 #include <asm/machdep.h>
arch/m68k/mm/motorola.c+1−1
@@ -467,7 +467,7 @@ void __init paging_init(void) · 466 unmodified lines
467467 /*
468468 * Set up SFC/DFC registers
469469 */
470− set_fs(KERNEL_DS);
470+ set_fc(USER_DATA);
471471
472472 #ifdef DEBUG
473473 printk ("before free_area_init\n");
arch/m68k/sun3/config.c+1−2
@@ -31,7 +31,6 @@ · 30 unmodified lines
3131 #include <asm/intersil.h>
3232 #include <asm/irq.h>
3333 #include <asm/sections.h>
34−#include <asm/segment.h>
3534 #include <asm/sun3ints.h>
3635
3736 char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
@@ -89,7 +88,7 @@ void __init sun3_init(void) · 51 unmodified lines
8988 sun3_reserved_pmeg[249] = 1;
9089 sun3_reserved_pmeg[252] = 1;
9190 sun3_reserved_pmeg[253] = 1;
92− set_fs(KERNEL_DS);
91+ set_fc(USER_DATA);
9392 }
9493
9594 /* Without this, Bad Things happen when something calls arch_reset. */
arch/m68k/sun3/mmu_emu.c+2−4
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/uaccess.h>
2424 #include <asm/page.h>
2525 #include <asm/sun3mmu.h>
26−#include <asm/segment.h>
2726 #include <asm/oplib.h>
2827 #include <asm/mmu_context.h>
2928 #include <asm/dvma.h>
@@ -191,14 +190,13 @@ void __init mmu_emu_init(unsigned long bootmem_end) · 161 unmodified lines
191190 for(seg = 0; seg < PAGE_OFFSET; seg += SUN3_PMEG_SIZE)
192191 sun3_put_segmap(seg, SUN3_INVALID_PMEG);
193192
194− set_fs(MAKE_MM_SEG(3));
193+ set_fc(3);
195194 for(seg = 0; seg < 0x10000000; seg += SUN3_PMEG_SIZE) {
196195 i = sun3_get_segmap(seg);
197196 for(j = 1; j < CONTEXTS_NUM; j++)
198197 (*(romvec->pv_setctxt))(j, (void *)seg, i);
199198 }
200− set_fs(KERNEL_DS);
201−
199+ set_fc(USER_DATA);
202200 }
203201
204202 /* erase the mappings for a dead context. Uses the pg_dir for hints
arch/m68k/sun3/sun3ints.c+0−1
@@ -11,7 +11,6 @@ · 10 unmodified lines
1111 #include <linux/sched.h>
1212 #include <linux/kernel_stat.h>
1313 #include <linux/interrupt.h>
14−#include <asm/segment.h>
1514 #include <asm/intersil.h>
1615 #include <asm/oplib.h>
1716 #include <asm/sun3ints.h>
arch/m68k/sun3x/prom.c+0−1
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414 #include <asm/traps.h>
1515 #include <asm/sun3xprom.h>
1616 #include <asm/idprom.h>
17−#include <asm/segment.h>
1817 #include <asm/sun3ints.h>
1918 #include <asm/openprom.h>
2019 #include <asm/machines.h>
arch/mips/net/bpf_jit.c+43−14
@@ -662,6 +662,11 @@ static void build_epilogue(struct jit_ctx *ctx) · 661 unmodified lines
662662 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative : func) : \
663663 func##_positive)
664664
665+static bool is_bad_offset(int b_off)
666+{
667+ return b_off > 0x1ffff || b_off < -0x20000;
668+}
669+
665670 static int build_body(struct jit_ctx *ctx)
666671 {
667672 const struct bpf_prog *prog = ctx->skf;
@@ -728,7 +733,10 @@ load_common: · 60 unmodified lines
728733 /* Load return register on DS for failures */
729734 emit_reg_move(r_ret, r_zero, ctx);
730735 /* Return with error */
731− emit_b(b_imm(prog->len, ctx), ctx);
736+ b_off = b_imm(prog->len, ctx);
737+ if (is_bad_offset(b_off))
738+ return -E2BIG;
739+ emit_b(b_off, ctx);
732740 emit_nop(ctx);
733741 break;
734742 case BPF_LD | BPF_W | BPF_IND:
@@ -775,8 +783,10 @@ load_ind: · 40 unmodified lines
775783 emit_jalr(MIPS_R_RA, r_s0, ctx);
776784 emit_reg_move(MIPS_R_A0, r_skb, ctx); /* delay slot */
777785 /* Check the error value */
778− emit_bcond(MIPS_COND_NE, r_ret, 0,
779− b_imm(prog->len, ctx), ctx);
786+ b_off = b_imm(prog->len, ctx);
787+ if (is_bad_offset(b_off))
788+ return -E2BIG;
789+ emit_bcond(MIPS_COND_NE, r_ret, 0, b_off, ctx);
780790 emit_reg_move(r_ret, r_zero, ctx);
781791 /* We are good */
782792 /* X <- P[1:K] & 0xf */
@@ -855,8 +865,10 @@ load_ind: · 72 unmodified lines
855865 /* A /= X */
856866 ctx->flags |= SEEN_X | SEEN_A;
857867 /* Check if r_X is zero */
858− emit_bcond(MIPS_COND_EQ, r_X, r_zero,
859− b_imm(prog->len, ctx), ctx);
868+ b_off = b_imm(prog->len, ctx);
869+ if (is_bad_offset(b_off))
870+ return -E2BIG;
871+ emit_bcond(MIPS_COND_EQ, r_X, r_zero, b_off, ctx);
860872 emit_load_imm(r_ret, 0, ctx); /* delay slot */
861873 emit_div(r_A, r_X, ctx);
862874 break;
@@ -864,8 +876,10 @@ load_ind: · 1 unmodified line
864876 /* A %= X */
865877 ctx->flags |= SEEN_X | SEEN_A;
866878 /* Check if r_X is zero */
867− emit_bcond(MIPS_COND_EQ, r_X, r_zero,
868− b_imm(prog->len, ctx), ctx);
879+ b_off = b_imm(prog->len, ctx);
880+ if (is_bad_offset(b_off))
881+ return -E2BIG;
882+ emit_bcond(MIPS_COND_EQ, r_X, r_zero, b_off, ctx);
869883 emit_load_imm(r_ret, 0, ctx); /* delay slot */
870884 emit_mod(r_A, r_X, ctx);
871885 break;
@@ -926,7 +940,10 @@ load_ind: · 54 unmodified lines
926940 break;
927941 case BPF_JMP | BPF_JA:
928942 /* pc += K */
929− emit_b(b_imm(i + k + 1, ctx), ctx);
943+ b_off = b_imm(i + k + 1, ctx);
944+ if (is_bad_offset(b_off))
945+ return -E2BIG;
946+ emit_b(b_off, ctx);
930947 emit_nop(ctx);
931948 break;
932949 case BPF_JMP | BPF_JEQ | BPF_K:
@@ -1056,12 +1073,16 @@ jmp_cmp: · 123 unmodified lines
10561073 break;
10571074 case BPF_RET | BPF_A:
10581075 ctx->flags |= SEEN_A;
1059− if (i != prog->len - 1)
1076+ if (i != prog->len - 1) {
10601077 /*
10611078 * If this is not the last instruction
10621079 * then jump to the epilogue
10631080 */
1064− emit_b(b_imm(prog->len, ctx), ctx);
1081+ b_off = b_imm(prog->len, ctx);
1082+ if (is_bad_offset(b_off))
1083+ return -E2BIG;
1084+ emit_b(b_off, ctx);
1085+ }
10651086 emit_reg_move(r_ret, r_A, ctx); /* delay slot */
10661087 break;
10671088 case BPF_RET | BPF_K:
@@ -1075,7 +1096,10 @@ jmp_cmp: · 7 unmodified lines
10751096 * If this is not the last instruction
10761097 * then jump to the epilogue
10771098 */
1078− emit_b(b_imm(prog->len, ctx), ctx);
1099+ b_off = b_imm(prog->len, ctx);
1100+ if (is_bad_offset(b_off))
1101+ return -E2BIG;
1102+ emit_b(b_off, ctx);
10791103 emit_nop(ctx);
10801104 }
10811105 break;
@@ -1133,8 +1157,10 @@ jmp_cmp: · 51 unmodified lines
11331157 /* Load *dev pointer */
11341158 emit_load_ptr(r_s0, r_skb, off, ctx);
11351159 /* error (0) in the delay slot */
1136− emit_bcond(MIPS_COND_EQ, r_s0, r_zero,
1137− b_imm(prog->len, ctx), ctx);
1160+ b_off = b_imm(prog->len, ctx);
1161+ if (is_bad_offset(b_off))
1162+ return -E2BIG;
1163+ emit_bcond(MIPS_COND_EQ, r_s0, r_zero, b_off, ctx);
11381164 emit_reg_move(r_ret, r_zero, ctx);
11391165 if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
11401166 BUILD_BUG_ON(sizeof_field(struct net_device, ifindex) != 4);
@@ -1244,7 +1270,10 @@ void bpf_jit_compile(struct bpf_prog *fp) · 103 unmodified lines
12441270
12451271 /* Generate the actual JIT code */
12461272 build_prologue(&ctx);
1247− build_body(&ctx);
1273+ if (build_body(&ctx)) {
1274+ module_memfree(ctx.target);
1275+ goto out;
1276+ }
12481277 build_epilogue(&ctx);
12491278
12501279 /* Update the icache */
arch/nios2/Kconfig.debug+2−1
@@ -3,9 +3,10 @@ · 2 unmodified lines
33 config EARLY_PRINTK
44 bool "Activate early kernel debugging"
55 default y
6+ depends on TTY
67 select SERIAL_CORE_CONSOLE
78 help
8− Enable early printk on console
9+ Enable early printk on console.
910 This is useful for kernel debugging when your machine crashes very
1011 early before the console code is initialized.
1112 You should normally say N here, unless you want to debug such a crash.
arch/nios2/kernel/setup.c+0−2
@@ -149,8 +149,6 @@ static void __init find_limits(unsigned long *min, unsigned long *max_low, · 148 unmodified lines
149149
150150 void __init setup_arch(char **cmdline_p)
151151 {
152− int dram_start;
153−
154152 console_verbose();
155153
156154 memory_start = memblock_start_of_DRAM();
arch/s390/kvm/interrupt.c+2−2
@@ -419,13 +419,13 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu) · 418 unmodified lines
419419 static void __set_cpu_idle(struct kvm_vcpu *vcpu)
420420 {
421421 kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
422− set_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
422+ set_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask);
423423 }
424424
425425 static void __unset_cpu_idle(struct kvm_vcpu *vcpu)
426426 {
427427 kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT);
428− clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
428+ clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask);
429429 }
430430
431431 static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
arch/s390/kvm/kvm-s390.c+1−1
@@ -4066,7 +4066,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu) · 4065 unmodified lines
40664066 kvm_s390_patch_guest_per_regs(vcpu);
40674067 }
40684068
4069− clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.gisa_int.kicked_mask);
4069+ clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask);
40704070
40714071 vcpu->arch.sie_block->icptcode = 0;
40724072 cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
arch/s390/kvm/kvm-s390.h+1−1
@@ -79,7 +79,7 @@ static inline int is_vcpu_stopped(struct kvm_vcpu *vcpu) · 78 unmodified lines
7979
8080 static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
8181 {
82− return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
82+ return test_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask);
8383 }
8484
8585 static inline int kvm_is_ucontrol(struct kvm *kvm)
arch/x86/crypto/sm4-aesni-avx-asm_64.S+3−2
@@ -367,10 +367,11 @@ SYM_FUNC_START(sm4_aesni_avx_crypt8) · 366 unmodified lines
367367 * %rdx: src (1..8 blocks)
368368 * %rcx: num blocks (1..8)
369369 */
370− FRAME_BEGIN
371−
372370 cmpq $5, %rcx;
373371 jb sm4_aesni_avx_crypt4;
372+
373+ FRAME_BEGIN
374+
374375 vmovdqu (0 * 16)(%rdx), RA0;
375376 vmovdqu (1 * 16)(%rdx), RA1;
376377 vmovdqu (2 * 16)(%rdx), RA2;
arch/x86/events/core.c+1−0
@@ -2465,6 +2465,7 @@ static int x86_pmu_event_init(struct perf_event *event) · 2464 unmodified lines
24652465 if (err) {
24662466 if (event->destroy)
24672467 event->destroy(event);
2468+ event->destroy = NULL;
24682469 }
24692470
24702471 if (READ_ONCE(x86_pmu.attr_rdpmc) &&
arch/x86/events/intel/core.c+1−0
@@ -263,6 +263,7 @@ static struct event_constraint intel_icl_event_constraints[] = { · 262 unmodified lines
263263 INTEL_EVENT_CONSTRAINT_RANGE(0xa8, 0xb0, 0xf),
264264 INTEL_EVENT_CONSTRAINT_RANGE(0xb7, 0xbd, 0xf),
265265 INTEL_EVENT_CONSTRAINT_RANGE(0xd0, 0xe6, 0xf),
266+ INTEL_EVENT_CONSTRAINT(0xef, 0xf),
266267 INTEL_EVENT_CONSTRAINT_RANGE(0xf0, 0xf4, 0xf),
267268 EVENT_CONSTRAINT_END
268269 };
arch/x86/include/asm/kvm_page_track.h+1−1
@@ -46,7 +46,7 @@ struct kvm_page_track_notifier_node { · 45 unmodified lines
4646 struct kvm_page_track_notifier_node *node);
4747 };
4848
49−void kvm_page_track_init(struct kvm *kvm);
49+int kvm_page_track_init(struct kvm *kvm);
5050 void kvm_page_track_cleanup(struct kvm *kvm);
5151
5252 void kvm_page_track_free_memslot(struct kvm_memory_slot *slot);
arch/x86/include/asm/kvmclock.h+14−0
@@ -2,6 +2,20 @@ · 1 unmodified line
22 #ifndef _ASM_X86_KVM_CLOCK_H
33 #define _ASM_X86_KVM_CLOCK_H
44
5+#include <linux/percpu.h>
6+
57 extern struct clocksource kvm_clock;
68
9+DECLARE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu);
10+
11+static inline struct pvclock_vcpu_time_info *this_cpu_pvti(void)
12+{
13+ return &this_cpu_read(hv_clock_per_cpu)->pvti;
14+}
15+
16+static inline struct pvclock_vsyscall_time_info *this_cpu_hvclock(void)
17+{
18+ return this_cpu_read(hv_clock_per_cpu);
19+}
20+
721 #endif /* _ASM_X86_KVM_CLOCK_H */
arch/x86/kernel/kvmclock.c+2−11
@@ -49,18 +49,9 @@ early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall); · 48 unmodified lines
4949 static struct pvclock_vsyscall_time_info
5050 hv_clock_boot[HVC_BOOT_ARRAY_SIZE] __bss_decrypted __aligned(PAGE_SIZE);
5151 static struct pvclock_wall_clock wall_clock __bss_decrypted;
52−static DEFINE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu);
5352 static struct pvclock_vsyscall_time_info *hvclock_mem;
54−
55−static inline struct pvclock_vcpu_time_info *this_cpu_pvti(void)
56−{
57− return &this_cpu_read(hv_clock_per_cpu)->pvti;
58−}
59−
60−static inline struct pvclock_vsyscall_time_info *this_cpu_hvclock(void)
61−{
62− return this_cpu_read(hv_clock_per_cpu);
63−}
53+DEFINE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu);
54+EXPORT_PER_CPU_SYMBOL_GPL(hv_clock_per_cpu);
6455
6556 /*
6657 * The wallclock is the time of day when we booted. Since then, some time may
arch/x86/kvm/cpuid.c+2−2
@@ -65,8 +65,8 @@ static inline struct kvm_cpuid_entry2 *cpuid_entry2_find( · 64 unmodified lines
6565 for (i = 0; i < nent; i++) {
6666 e = &entries[i];
6767
68− if (e->function == function && (e->index == index ||
69− !(e->flags & KVM_CPUID_FLAG_SIGNIFCANT_INDEX)))
68+ if (e->function == function &&
69+ (!(e->flags & KVM_CPUID_FLAG_SIGNIFCANT_INDEX) || e->index == index))
7070 return e;
7171 }
7272
arch/x86/kvm/emulate.c+1−2
@@ -435,7 +435,6 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); · 434 unmodified lines
435435 __FOP_RET(#op)
436436
437437 asm(".pushsection .fixup, \"ax\"\n"
438− ".global kvm_fastop_exception \n"
439438 "kvm_fastop_exception: xor %esi, %esi; ret\n"
440439 ".popsection");
441440
@@ -4206,7 +4205,7 @@ static int check_rdtsc(struct x86_emulate_ctxt *ctxt) · 3764 unmodified lines
42064205 u64 cr4 = ctxt->ops->get_cr(ctxt, 4);
42074206
42084207 if (cr4 & X86_CR4_TSD && ctxt->ops->cpl(ctxt))
4209− return emulate_ud(ctxt);
4208+ return emulate_gp(ctxt, 0);
42104209
42114210 return X86EMUL_CONTINUE;
42124211 }
arch/x86/kvm/hyperv.c+3−4
@@ -939,7 +939,7 @@ static int kvm_hv_vcpu_init(struct kvm_vcpu *vcpu) · 938 unmodified lines
939939 for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++)
940940 stimer_init(&hv_vcpu->stimer[i], i);
941941
942− hv_vcpu->vp_index = kvm_vcpu_get_idx(vcpu);
942+ hv_vcpu->vp_index = vcpu->vcpu_idx;
943943
944944 return 0;
945945 }
@@ -1444,7 +1444,6 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host) · 498 unmodified lines
14441444 switch (msr) {
14451445 case HV_X64_MSR_VP_INDEX: {
14461446 struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
1447− int vcpu_idx = kvm_vcpu_get_idx(vcpu);
14481447 u32 new_vp_index = (u32)data;
14491448
14501449 if (!host || new_vp_index >= KVM_MAX_VCPUS)
@@ -1459,9 +1458,9 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host) · 8 unmodified lines
14591458 * VP index is changing, adjust num_mismatched_vp_indexes if
14601459 * it now matches or no longer matches vcpu_idx.
14611460 */
1462− if (hv_vcpu->vp_index == vcpu_idx)
1461+ if (hv_vcpu->vp_index == vcpu->vcpu_idx)
14631462 atomic_inc(&hv->num_mismatched_vp_indexes);
1464− else if (new_vp_index == vcpu_idx)
1463+ else if (new_vp_index == vcpu->vcpu_idx)
14651464 atomic_dec(&hv->num_mismatched_vp_indexes);
14661465
14671466 hv_vcpu->vp_index = new_vp_index;
arch/x86/kvm/hyperv.h+1−1
@@ -83,7 +83,7 @@ static inline u32 kvm_hv_get_vpindex(struct kvm_vcpu *vcpu) · 82 unmodified lines
8383 {
8484 struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
8585
86− return hv_vcpu ? hv_vcpu->vp_index : kvm_vcpu_get_idx(vcpu);
86+ return hv_vcpu ? hv_vcpu->vp_index : vcpu->vcpu_idx;
8787 }
8888
8989 int kvm_hv_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host);
arch/x86/kvm/ioapic.c+5−5
@@ -319,8 +319,8 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · 318 unmodified lines
319319 unsigned index;
320320 bool mask_before, mask_after;
321321 union kvm_ioapic_redirect_entry *e;
322− unsigned long vcpu_bitmap;
323322 int old_remote_irr, old_delivery_status, old_dest_id, old_dest_mode;
323+ DECLARE_BITMAP(vcpu_bitmap, KVM_MAX_VCPUS);
324324
325325 switch (ioapic->ioregsel) {
326326 case IOAPIC_REG_VERSION:
@@ -384,9 +384,9 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · 57 unmodified lines
384384 irq.shorthand = APIC_DEST_NOSHORT;
385385 irq.dest_id = e->fields.dest_id;
386386 irq.msi_redir_hint = false;
387− bitmap_zero(&vcpu_bitmap, 16);
387+ bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS);
388388 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
389− &vcpu_bitmap);
389+ vcpu_bitmap);
390390 if (old_dest_mode != e->fields.dest_mode ||
391391 old_dest_id != e->fields.dest_id) {
392392 /*
@@ -399,10 +399,10 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · 6 unmodified lines
399399 kvm_lapic_irq_dest_mode(
400400 !!e->fields.dest_mode);
401401 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
402− &vcpu_bitmap);
402+ vcpu_bitmap);
403403 }
404404 kvm_make_scan_ioapic_request_mask(ioapic->kvm,
405− &vcpu_bitmap);
405+ vcpu_bitmap);
406406 } else {
407407 kvm_make_scan_ioapic_request(ioapic->kvm);
408408 }
arch/x86/kvm/mmu/mmu.c+10−7
@@ -2027,8 +2027,8 @@ static void mmu_pages_clear_parents(struct mmu_page_path *parents) · 2026 unmodified lines
20272027 } while (!sp->unsync_children);
20282028 }
20292029
2030−static void mmu_sync_children(struct kvm_vcpu *vcpu,
2031− struct kvm_mmu_page *parent)
2030+static int mmu_sync_children(struct kvm_vcpu *vcpu,
2031+ struct kvm_mmu_page *parent, bool can_yield)
20322032 {
20332033 int i;
20342034 struct kvm_mmu_page *sp;
@@ -2055,12 +2055,18 @@ static void mmu_sync_children(struct kvm_vcpu *vcpu, · 20 unmodified lines
20552055 }
20562056 if (need_resched() || rwlock_needbreak(&vcpu->kvm->mmu_lock)) {
20572057 kvm_mmu_flush_or_zap(vcpu, &invalid_list, false, flush);
2058+ if (!can_yield) {
2059+ kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);
2060+ return -EINTR;
2061+ }
2062+
20582063 cond_resched_rwlock_write(&vcpu->kvm->mmu_lock);
20592064 flush = false;
20602065 }
20612066 }
20622067
20632068 kvm_mmu_flush_or_zap(vcpu, &invalid_list, false, flush);
2069+ return 0;
20642070 }
20652071
20662072 static void __clear_sp_write_flooding_count(struct kvm_mmu_page *sp)
@@ -2146,9 +2152,6 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, · 79 unmodified lines
21462152 kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu);
21472153 }
21482154
2149− if (sp->unsync_children)
2150− kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);
2151−
21522155 __clear_sp_write_flooding_count(sp);
21532156
21542157 trace_get_page:
@@ -3684,7 +3687,7 @@ void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) · 1529 unmodified lines
36843687 write_lock(&vcpu->kvm->mmu_lock);
36853688 kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC);
36863689
3687− mmu_sync_children(vcpu, sp);
3690+ mmu_sync_children(vcpu, sp, true);
36883691
36893692 kvm_mmu_audit(vcpu, AUDIT_POST_SYNC);
36903693 write_unlock(&vcpu->kvm->mmu_lock);
@@ -3700,7 +3703,7 @@ void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) · 9 unmodified lines
37003703 if (IS_VALID_PAE_ROOT(root)) {
37013704 root &= PT64_BASE_ADDR_MASK;
37023705 sp = to_shadow_page(root);
3703− mmu_sync_children(vcpu, sp);
3706+ mmu_sync_children(vcpu, sp, true);
37043707 }
37053708 }
37063709
arch/x86/kvm/mmu/page_track.c+2−2
@@ -164,13 +164,13 @@ void kvm_page_track_cleanup(struct kvm *kvm) · 163 unmodified lines
164164 cleanup_srcu_struct(&head->track_srcu);
165165 }
166166
167−void kvm_page_track_init(struct kvm *kvm)
167+int kvm_page_track_init(struct kvm *kvm)
168168 {
169169 struct kvm_page_track_notifier_head *head;
170170
171171 head = &kvm->arch.track_notifier_head;
172− init_srcu_struct(&head->track_srcu);
173172 INIT_HLIST_HEAD(&head->track_notifier_list);
173+ return init_srcu_struct(&head->track_srcu);
174174 }
175175
176176 /*
arch/x86/kvm/mmu/paging_tmpl.h+23−23
@@ -707,8 +707,27 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, · 706 unmodified lines
707707 if (!is_shadow_present_pte(*it.sptep)) {
708708 table_gfn = gw->table_gfn[it.level - 2];
709709 access = gw->pt_access[it.level - 2];
710− sp = kvm_mmu_get_page(vcpu, table_gfn, addr, it.level-1,
711− false, access);
710+ sp = kvm_mmu_get_page(vcpu, table_gfn, addr,
711+ it.level-1, false, access);
712+ /*
713+ * We must synchronize the pagetable before linking it
714+ * because the guest doesn't need to flush tlb when
715+ * the gpte is changed from non-present to present.
716+ * Otherwise, the guest may use the wrong mapping.
717+ *
718+ * For PG_LEVEL_4K, kvm_mmu_get_page() has already
719+ * synchronized it transiently via kvm_sync_page().
720+ *
721+ * For higher level pagetable, we synchronize it via
722+ * the slower mmu_sync_children(). If it needs to
723+ * break, some progress has been made; return
724+ * RET_PF_RETRY and retry on the next #PF.
725+ * KVM_REQ_MMU_SYNC is not necessary but it
726+ * expedites the process.
727+ */
728+ if (sp->unsync_children &&
729+ mmu_sync_children(vcpu, sp, false))
730+ return RET_PF_RETRY;
712731 }
713732
714733 /*
@@ -1047,14 +1066,6 @@ static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gpa_t vaddr, · 332 unmodified lines
10471066 * Using the cached information from sp->gfns is safe because:
10481067 * - The spte has a reference to the struct page, so the pfn for a given gfn
10491068 * can't change unless all sptes pointing to it are nuked first.
1050− *
1051− * Note:
1052− * We should flush all tlbs if spte is dropped even though guest is
1053− * responsible for it. Since if we don't, kvm_mmu_notifier_invalidate_page
1054− * and kvm_mmu_notifier_invalidate_range_start detect the mapping page isn't
1055− * used by guest then tlbs are not flushed, so guest is allowed to access the
1056− * freed pages.
1057− * And we increase kvm->tlbs_dirty to delay tlbs flush in this case.
10581069 */
10591070 static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
10601071 {
@@ -1107,13 +1118,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) · 46 unmodified lines
11071118 return 0;
11081119
11091120 if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) {
1110− /*
1111− * Update spte before increasing tlbs_dirty to make
1112− * sure no tlb flush is lost after spte is zapped; see
1113− * the comments in kvm_flush_remote_tlbs().
1114− */
1115− smp_wmb();
1116− vcpu->kvm->tlbs_dirty++;
1121+ set_spte_ret |= SET_SPTE_NEED_REMOTE_TLB_FLUSH;
11171122 continue;
11181123 }
11191124
@@ -1128,12 +1133,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) · 8 unmodified lines
11281133
11291134 if (gfn != sp->gfns[i]) {
11301135 drop_spte(vcpu->kvm, &sp->spt[i]);
1131− /*
1132− * The same as above where we are doing
1133− * prefetch_invalid_gpte().
1134− */
1135− smp_wmb();
1136− vcpu->kvm->tlbs_dirty++;
1136+ set_spte_ret |= SET_SPTE_NEED_REMOTE_TLB_FLUSH;
11371137 continue;
11381138 }
11391139
arch/x86/kvm/svm/nested.c+6−4
@@ -545,7 +545,6 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) · 544 unmodified lines
545545 (svm->nested.ctl.int_ctl & int_ctl_vmcb12_bits) |
546546 (svm->vmcb01.ptr->control.int_ctl & int_ctl_vmcb01_bits);
547547
548− svm->vmcb->control.virt_ext = svm->nested.ctl.virt_ext;
549548 svm->vmcb->control.int_vector = svm->nested.ctl.int_vector;
550549 svm->vmcb->control.int_state = svm->nested.ctl.int_state;
551550 svm->vmcb->control.event_inj = svm->nested.ctl.event_inj;
@@ -579,7 +578,7 @@ static void nested_svm_copy_common_state(struct vmcb *from_vmcb, struct vmcb *to · 27 unmodified lines
579578 }
580579
581580 int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa,
582− struct vmcb *vmcb12)
581+ struct vmcb *vmcb12, bool from_vmrun)
583582 {
584583 struct vcpu_svm *svm = to_svm(vcpu);
585584 int ret;
@@ -609,13 +608,16 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, · 23 unmodified lines
609608 nested_vmcb02_prepare_save(svm, vmcb12);
610609
611610 ret = nested_svm_load_cr3(&svm->vcpu, vmcb12->save.cr3,
612− nested_npt_enabled(svm), true);
611+ nested_npt_enabled(svm), from_vmrun);
613612 if (ret)
614613 return ret;
615614
616615 if (!npt_enabled)
617616 vcpu->arch.mmu->inject_page_fault = svm_inject_page_fault_nested;
618617
618+ if (!from_vmrun)
619+ kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
620+
619621 svm_set_gif(svm, true);
620622
621623 return 0;
@@ -681,7 +683,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) · 59 unmodified lines
681683
682684 svm->nested.nested_run_pending = 1;
683685
684− if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12))
686+ if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true))
685687 goto out_exit_err;
686688
687689 if (nested_svm_vmrun_msrpm(svm))
arch/x86/kvm/svm/sev.c+62−30
@@ -595,43 +595,50 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm) · 594 unmodified lines
595595 return 0;
596596 }
597597
598−static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)
598+static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu,
599+ int *error)
599600 {
600− struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
601601 struct sev_data_launch_update_vmsa vmsa;
602+ struct vcpu_svm *svm = to_svm(vcpu);
603+ int ret;
604+
605+ /* Perform some pre-encryption checks against the VMSA */
606+ ret = sev_es_sync_vmsa(svm);
607+ if (ret)
608+ return ret;
609+
610+ /*
611+ * The LAUNCH_UPDATE_VMSA command will perform in-place encryption of
612+ * the VMSA memory content (i.e it will write the same memory region
613+ * with the guest's key), so invalidate it first.
614+ */
615+ clflush_cache_range(svm->vmsa, PAGE_SIZE);
616+
617+ vmsa.reserved = 0;
618+ vmsa.handle = to_kvm_svm(kvm)->sev_info.handle;
619+ vmsa.address = __sme_pa(svm->vmsa);
620+ vmsa.len = PAGE_SIZE;
621+ return sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error);
622+}
623+
624+static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)
625+{
602626 struct kvm_vcpu *vcpu;
603627 int i, ret;
604628
605629 if (!sev_es_guest(kvm))
606630 return -ENOTTY;
607631
608− vmsa.reserved = 0;
609−
610632 kvm_for_each_vcpu(i, vcpu, kvm) {
611− struct vcpu_svm *svm = to_svm(vcpu);
612−
613− /* Perform some pre-encryption checks against the VMSA */
614− ret = sev_es_sync_vmsa(svm);
633+ ret = mutex_lock_killable(&vcpu->mutex);
615634 if (ret)
616635 return ret;
617636
618− /*
619− * The LAUNCH_UPDATE_VMSA command will perform in-place
620− * encryption of the VMSA memory content (i.e it will write
621− * the same memory region with the guest's key), so invalidate
622− * it first.
623− */
624− clflush_cache_range(svm->vmsa, PAGE_SIZE);
637+ ret = __sev_launch_update_vmsa(kvm, vcpu, &argp->error);
625638
626− vmsa.handle = sev->handle;
627− vmsa.address = __sme_pa(svm->vmsa);
628− vmsa.len = PAGE_SIZE;
629− ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa,
630− &argp->error);
639+ mutex_unlock(&vcpu->mutex);
631640 if (ret)
632641 return ret;
633−
634− svm->vcpu.arch.guest_state_protected = true;
635642 }
636643
637644 return 0;
@@ -1397,8 +1404,10 @@ static int sev_receive_start(struct kvm *kvm, struct kvm_sev_cmd *argp) · 759 unmodified lines
13971404
13981405 /* Bind ASID to this guest */
13991406 ret = sev_bind_asid(kvm, start.handle, error);
1400− if (ret)
1407+ if (ret) {
1408+ sev_decommission(start.handle);
14011409 goto e_free_session;
1410+ }
14021411
14031412 params.handle = start.handle;
14041413 if (copy_to_user((void __user *)(uintptr_t)argp->data,
@@ -1464,7 +1473,7 @@ static int sev_receive_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) · 59 unmodified lines
14641473
14651474 /* Pin guest memory */
14661475 guest_page = sev_pin_memory(kvm, params.guest_uaddr & PAGE_MASK,
1467− PAGE_SIZE, &n, 0);
1476+ PAGE_SIZE, &n, 1);
14681477 if (IS_ERR(guest_page)) {
14691478 ret = PTR_ERR(guest_page);
14701479 goto e_free_trans;
@@ -1501,6 +1510,20 @@ static int sev_receive_finish(struct kvm *kvm, struct kvm_sev_cmd *argp) · 30 unmodified lines
15011510 return sev_issue_cmd(kvm, SEV_CMD_RECEIVE_FINISH, &data, &argp->error);
15021511 }
15031512
1513+static bool cmd_allowed_from_miror(u32 cmd_id)
1514+{
1515+ /*
1516+ * Allow mirrors VM to call KVM_SEV_LAUNCH_UPDATE_VMSA to enable SEV-ES
1517+ * active mirror VMs. Also allow the debugging and status commands.
1518+ */
1519+ if (cmd_id == KVM_SEV_LAUNCH_UPDATE_VMSA ||
1520+ cmd_id == KVM_SEV_GUEST_STATUS || cmd_id == KVM_SEV_DBG_DECRYPT ||
1521+ cmd_id == KVM_SEV_DBG_ENCRYPT)
1522+ return true;
1523+
1524+ return false;
1525+}
1526+
15041527 int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
15051528 {
15061529 struct kvm_sev_cmd sev_cmd;
@@ -1517,8 +1540,9 @@ int svm_mem_enc_op(struct kvm *kvm, void __user *argp) · 10 unmodified lines
15171540
15181541 mutex_lock(&kvm->lock);
15191542
1520− /* enc_context_owner handles all memory enc operations */
1521− if (is_mirroring_enc_context(kvm)) {
1543+ /* Only the enc_context_owner handles some memory enc operations. */
1544+ if (is_mirroring_enc_context(kvm) &&
1545+ !cmd_allowed_from_miror(sev_cmd.id)) {
15221546 r = -EINVAL;
15231547 goto out;
15241548 }
@@ -1715,8 +1739,7 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) · 190 unmodified lines
17151739 {
17161740 struct file *source_kvm_file;
17171741 struct kvm *source_kvm;
1718− struct kvm_sev_info *mirror_sev;
1719− unsigned int asid;
1742+ struct kvm_sev_info source_sev, *mirror_sev;
17201743 int ret;
17211744
17221745 source_kvm_file = fget(source_fd);
@@ -1739,7 +1762,8 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) · 16 unmodified lines
17391762 goto e_source_unlock;
17401763 }
17411764
1742− asid = to_kvm_svm(source_kvm)->sev_info.asid;
1765+ memcpy(&source_sev, &to_kvm_svm(source_kvm)->sev_info,
1766+ sizeof(source_sev));
17431767
17441768 /*
17451769 * The mirror kvm holds an enc_context_owner ref so its asid can't
@@ -1759,8 +1783,16 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) · 13 unmodified lines
17591783 /* Set enc_context_owner and copy its encryption context over */
17601784 mirror_sev = &to_kvm_svm(kvm)->sev_info;
17611785 mirror_sev->enc_context_owner = source_kvm;
1762− mirror_sev->asid = asid;
17631786 mirror_sev->active = true;
1787+ mirror_sev->asid = source_sev.asid;
1788+ mirror_sev->fd = source_sev.fd;
1789+ mirror_sev->es_active = source_sev.es_active;
1790+ mirror_sev->handle = source_sev.handle;
1791+ /*
1792+ * Do not copy ap_jump_table. Since the mirror does not share the same
1793+ * KVM contexts as the original, and they may have different
1794+ * memory-views.
1795+ */
17641796
17651797 mutex_unlock(&kvm->lock);
17661798 return 0;
arch/x86/kvm/svm/svm.c+74−63
@@ -1566,6 +1566,8 @@ static void svm_clear_vintr(struct vcpu_svm *svm) · 1565 unmodified lines
15661566
15671567 svm->vmcb->control.int_ctl |= svm->nested.ctl.int_ctl &
15681568 V_IRQ_INJECTION_BITS_MASK;
1569+
1570+ svm->vmcb->control.int_vector = svm->nested.ctl.int_vector;
15691571 }
15701572
15711573 vmcb_mark_dirty(svm->vmcb, VMCB_INTR);
@@ -2222,6 +2224,10 @@ static int gp_interception(struct kvm_vcpu *vcpu) · 650 unmodified lines
22222224 if (error_code)
22232225 goto reinject;
22242226
2227+ /* All SVM instructions expect page aligned RAX */
2228+ if (svm->vmcb->save.rax & ~PAGE_MASK)
2229+ goto reinject;
2230+
22252231 /* Decode the instruction for usage later */
22262232 if (x86_decode_emulated_instruction(vcpu, 0, NULL, 0) != EMULATION_OK)
22272233 goto reinject;
@@ -4285,43 +4291,44 @@ static int svm_enter_smm(struct kvm_vcpu *vcpu, char *smstate) · 2057 unmodified lines
42854291 struct kvm_host_map map_save;
42864292 int ret;
42874293
4288− if (is_guest_mode(vcpu)) {
4289− /* FED8h - SVM Guest */
4290− put_smstate(u64, smstate, 0x7ed8, 1);
4291− /* FEE0h - SVM Guest VMCB Physical Address */
4292− put_smstate(u64, smstate, 0x7ee0, svm->nested.vmcb12_gpa);
4294+ if (!is_guest_mode(vcpu))
4295+ return 0;
42934296
4294− svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX];
4295− svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP];
4296− svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP];
4297+ /* FED8h - SVM Guest */
4298+ put_smstate(u64, smstate, 0x7ed8, 1);
4299+ /* FEE0h - SVM Guest VMCB Physical Address */
4300+ put_smstate(u64, smstate, 0x7ee0, svm->nested.vmcb12_gpa);
42974301
4298− ret = nested_svm_vmexit(svm);
4299− if (ret)
4300− return ret;
4302+ svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX];
4303+ svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP];
4304+ svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP];
43014305
4302− /*
4303− * KVM uses VMCB01 to store L1 host state while L2 runs but
4304− * VMCB01 is going to be used during SMM and thus the state will
4305− * be lost. Temporary save non-VMLOAD/VMSAVE state to the host save
4306− * area pointed to by MSR_VM_HSAVE_PA. APM guarantees that the
4307− * format of the area is identical to guest save area offsetted
4308− * by 0x400 (matches the offset of 'struct vmcb_save_area'
4309− * within 'struct vmcb'). Note: HSAVE area may also be used by
4310− * L1 hypervisor to save additional host context (e.g. KVM does
4311− * that, see svm_prepare_guest_switch()) which must be
4312− * preserved.
4313− */
4314− if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr),
4315− &map_save) == -EINVAL)
4316− return 1;
4306+ ret = nested_svm_vmexit(svm);
4307+ if (ret)
4308+ return ret;
43174309
4318− BUILD_BUG_ON(offsetof(struct vmcb, save) != 0x400);
4310+ /*
4311+ * KVM uses VMCB01 to store L1 host state while L2 runs but
4312+ * VMCB01 is going to be used during SMM and thus the state will
4313+ * be lost. Temporary save non-VMLOAD/VMSAVE state to the host save
4314+ * area pointed to by MSR_VM_HSAVE_PA. APM guarantees that the
4315+ * format of the area is identical to guest save area offsetted
4316+ * by 0x400 (matches the offset of 'struct vmcb_save_area'
4317+ * within 'struct vmcb'). Note: HSAVE area may also be used by
4318+ * L1 hypervisor to save additional host context (e.g. KVM does
4319+ * that, see svm_prepare_guest_switch()) which must be
4320+ * preserved.
4321+ */
4322+ if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr),
4323+ &map_save) == -EINVAL)
4324+ return 1;
43194325
4320− svm_copy_vmrun_state(map_save.hva + 0x400,
4321− &svm->vmcb01.ptr->save);
4326+ BUILD_BUG_ON(offsetof(struct vmcb, save) != 0x400);
43224327
4323− kvm_vcpu_unmap(vcpu, &map_save, true);
4324− }
4328+ svm_copy_vmrun_state(map_save.hva + 0x400,
4329+ &svm->vmcb01.ptr->save);
4330+
4331+ kvm_vcpu_unmap(vcpu, &map_save, true);
43254332 return 0;
43264333 }
43274334
@@ -4329,50 +4336,54 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate) · 1 unmodified line
43294336 {
43304337 struct vcpu_svm *svm = to_svm(vcpu);
43314338 struct kvm_host_map map, map_save;
4332− int ret = 0;
4339+ u64 saved_efer, vmcb12_gpa;
4340+ struct vmcb *vmcb12;
4341+ int ret;
43334342
4334− if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) {
4335− u64 saved_efer = GET_SMSTATE(u64, smstate, 0x7ed0);
4336− u64 guest = GET_SMSTATE(u64, smstate, 0x7ed8);
4337− u64 vmcb12_gpa = GET_SMSTATE(u64, smstate, 0x7ee0);
4338− struct vmcb *vmcb12;
4343+ if (!guest_cpuid_has(vcpu, X86_FEATURE_LM))
4344+ return 0;
43394345
4340− if (guest) {
4341− if (!guest_cpuid_has(vcpu, X86_FEATURE_SVM))
4342− return 1;
4346+ /* Non-zero if SMI arrived while vCPU was in guest mode. */
4347+ if (!GET_SMSTATE(u64, smstate, 0x7ed8))
4348+ return 0;
43434349
4344− if (!(saved_efer & EFER_SVME))
4345− return 1;
4350+ if (!guest_cpuid_has(vcpu, X86_FEATURE_SVM))
4351+ return 1;
43464352
4347− if (kvm_vcpu_map(vcpu,
4348− gpa_to_gfn(vmcb12_gpa), &map) == -EINVAL)
4349− return 1;
4353+ saved_efer = GET_SMSTATE(u64, smstate, 0x7ed0);
4354+ if (!(saved_efer & EFER_SVME))
4355+ return 1;
43504356
4351− if (svm_allocate_nested(svm))
4352− return 1;
4357+ vmcb12_gpa = GET_SMSTATE(u64, smstate, 0x7ee0);
4358+ if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map) == -EINVAL)
4359+ return 1;
43534360
4354− vmcb12 = map.hva;
4361+ ret = 1;
4362+ if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), &map_save) == -EINVAL)
4363+ goto unmap_map;
43554364
4356− nested_load_control_from_vmcb12(svm, &vmcb12->control);
4365+ if (svm_allocate_nested(svm))
4366+ goto unmap_save;
43574367
4358− ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12);
4359− kvm_vcpu_unmap(vcpu, &map, true);
4368+ /*
4369+ * Restore L1 host state from L1 HSAVE area as VMCB01 was
4370+ * used during SMM (see svm_enter_smm())
4371+ */
43604372
4361− /*
4362− * Restore L1 host state from L1 HSAVE area as VMCB01 was
4363− * used during SMM (see svm_enter_smm())
4364− */
4365− if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr),
4366− &map_save) == -EINVAL)
4367− return 1;
4373+ svm_copy_vmrun_state(&svm->vmcb01.ptr->save, map_save.hva + 0x400);
43684374
4369− svm_copy_vmrun_state(&svm->vmcb01.ptr->save,
4370− map_save.hva + 0x400);
4375+ /*
4376+ * Enter the nested guest now
4377+ */
43714378
4372− kvm_vcpu_unmap(vcpu, &map_save, true);
4373− }
4374− }
4379+ vmcb12 = map.hva;
4380+ nested_load_control_from_vmcb12(svm, &vmcb12->control);
4381+ ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, false);
43754382
4383+unmap_save:
4384+ kvm_vcpu_unmap(vcpu, &map_save, true);
4385+unmap_map:
4386+ kvm_vcpu_unmap(vcpu, &map, true);
43764387 return ret;
43774388 }
43784389
arch/x86/kvm/svm/svm.h+2−1
@@ -459,7 +459,8 @@ static inline bool nested_exit_on_nmi(struct vcpu_svm *svm) · 458 unmodified lines
459459 return vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_NMI);
460460 }
461461
462−int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb_gpa, struct vmcb *vmcb12);
462+int enter_svm_guest_mode(struct kvm_vcpu *vcpu,
463+ u64 vmcb_gpa, struct vmcb *vmcb12, bool from_vmrun);
463464 void svm_leave_nested(struct vcpu_svm *svm);
464465 void svm_free_nested(struct vcpu_svm *svm);
465466 int svm_allocate_nested(struct vcpu_svm *svm);
arch/x86/kvm/vmx/evmcs.c+9−3
@@ -353,14 +353,20 @@ void nested_evmcs_filter_control_msr(u32 msr_index, u64 *pdata) · 352 unmodified lines
353353 switch (msr_index) {
354354 case MSR_IA32_VMX_EXIT_CTLS:
355355 case MSR_IA32_VMX_TRUE_EXIT_CTLS:
356− ctl_high &= ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
356+ ctl_high &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL;
357357 break;
358358 case MSR_IA32_VMX_ENTRY_CTLS:
359359 case MSR_IA32_VMX_TRUE_ENTRY_CTLS:
360− ctl_high &= ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
360+ ctl_high &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL;
361361 break;
362362 case MSR_IA32_VMX_PROCBASED_CTLS2:
363− ctl_high &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
363+ ctl_high &= ~EVMCS1_UNSUPPORTED_2NDEXEC;
364+ break;
365+ case MSR_IA32_VMX_PINBASED_CTLS:
366+ ctl_high &= ~EVMCS1_UNSUPPORTED_PINCTRL;
367+ break;
368+ case MSR_IA32_VMX_VMFUNC:
369+ ctl_low &= ~EVMCS1_UNSUPPORTED_VMFUNC;
364370 break;
365371 }
366372
arch/x86/kvm/vmx/nested.c+15−9
@@ -2583,8 +2583,13 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, · 2582 unmodified lines
25832583 * Guest state is invalid and unrestricted guest is disabled,
25842584 * which means L1 attempted VMEntry to L2 with invalid state.
25852585 * Fail the VMEntry.
2586+ *
2587+ * However when force loading the guest state (SMM exit or
2588+ * loading nested state after migration, it is possible to
2589+ * have invalid guest state now, which will be later fixed by
2590+ * restoring L2 register state
25862591 */
2587− if (CC(!vmx_guest_state_valid(vcpu))) {
2592+ if (CC(from_vmentry && !vmx_guest_state_valid(vcpu))) {
25882593 *entry_failure_code = ENTRY_FAIL_DEFAULT;
25892594 return -EINVAL;
25902595 }
@@ -4351,6 +4356,8 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, · 1760 unmodified lines
43514356 if (nested_vmx_load_msr(vcpu, vmcs12->vm_exit_msr_load_addr,
43524357 vmcs12->vm_exit_msr_load_count))
43534358 nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_MSR_FAIL);
4359+
4360+ to_vmx(vcpu)->emulation_required = vmx_emulation_required(vcpu);
43544361 }
43554362
43564363 static inline u64 nested_vmx_get_vmcs01_guest_efer(struct vcpu_vmx *vmx)
@@ -4899,14 +4906,7 @@ out_vmcs02: · 542 unmodified lines
48994906 return -ENOMEM;
49004907 }
49014908
4902−/*
4903− * Emulate the VMXON instruction.
4904− * Currently, we just remember that VMX is active, and do not save or even
4905− * inspect the argument to VMXON (the so-called "VMXON pointer") because we
4906− * do not currently need to store anything in that guest-allocated memory
4907− * region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their
4908− * argument is different from the VMXON pointer (which the spec says they do).
4909− */
4909+/* Emulate the VMXON instruction. */
49104910 static int handle_vmon(struct kvm_vcpu *vcpu)
49114911 {
49124912 int ret;
@@ -5903,6 +5903,12 @@ static bool nested_vmx_l0_wants_exit(struct kvm_vcpu *vcpu, · 990 unmodified lines
59035903 case EXIT_REASON_VMFUNC:
59045904 /* VM functions are emulated through L2->L0 vmexits. */
59055905 return true;
5906+ case EXIT_REASON_BUS_LOCK:
5907+ /*
5908+ * At present, bus lock VM exit is never exposed to L1.
5909+ * Handle L2's bus locks in L0 directly.
5910+ */
5911+ return true;
59065912 default:
59075913 break;
59085914 }
arch/x86/kvm/vmx/vmx.c+27−12
@@ -1323,7 +1323,7 @@ static void vmx_vcpu_put(struct kvm_vcpu *vcpu) · 1322 unmodified lines
13231323 vmx_prepare_switch_to_host(to_vmx(vcpu));
13241324 }
13251325
1326−static bool emulation_required(struct kvm_vcpu *vcpu)
1326+bool vmx_emulation_required(struct kvm_vcpu *vcpu)
13271327 {
13281328 return emulate_invalid_guest_state && !vmx_guest_state_valid(vcpu);
13291329 }
@@ -1367,7 +1367,7 @@ void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) · 37 unmodified lines
13671367 vmcs_writel(GUEST_RFLAGS, rflags);
13681368
13691369 if ((old_rflags ^ vmx->rflags) & X86_EFLAGS_VM)
1370− vmx->emulation_required = emulation_required(vcpu);
1370+ vmx->emulation_required = vmx_emulation_required(vcpu);
13711371 }
13721372
13731373 u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu)
@@ -1837,10 +1837,11 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · 463 unmodified lines
18371837 &msr_info->data))
18381838 return 1;
18391839 /*
1840− * Enlightened VMCS v1 doesn't have certain fields, but buggy
1841− * Hyper-V versions are still trying to use corresponding
1842− * features when they are exposed. Filter out the essential
1843− * minimum.
1840+ * Enlightened VMCS v1 doesn't have certain VMCS fields but
1841+ * instead of just ignoring the features, different Hyper-V
1842+ * versions are either trying to use them and fail or do some
1843+ * sanity checking and refuse to boot. Filter all unsupported
1844+ * features out.
18441845 */
18451846 if (!msr_info->host_initiated &&
18461847 vmx->nested.enlightened_vmcs_enabled)
@@ -3077,7 +3078,7 @@ void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) · 1230 unmodified lines
30773078 }
30783079
30793080 /* depends on vcpu->arch.cr0 to be set to a new value */
3080− vmx->emulation_required = emulation_required(vcpu);
3081+ vmx->emulation_required = vmx_emulation_required(vcpu);
30813082 }
30823083
30833084 static int vmx_get_max_tdp_level(void)
@@ -3330,7 +3331,7 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int · 246 unmodified lines
33303331 {
33313332 __vmx_set_segment(vcpu, var, seg);
33323333
3333− to_vmx(vcpu)->emulation_required = emulation_required(vcpu);
3334+ to_vmx(vcpu)->emulation_required = vmx_emulation_required(vcpu);
33343335 }
33353336
33363337 static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
@@ -6621,10 +6622,24 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) · 3284 unmodified lines
66216622 vmx->loaded_vmcs->soft_vnmi_blocked))
66226623 vmx->loaded_vmcs->entry_time = ktime_get();
66236624
6624− /* Don't enter VMX if guest state is invalid, let the exit handler
6625− start emulation until we arrive back to a valid state */
6626− if (vmx->emulation_required)
6625+ /*
6626+ * Don't enter VMX if guest state is invalid, let the exit handler
6627+ * start emulation until we arrive back to a valid state. Synthesize a
6628+ * consistency check VM-Exit due to invalid guest state and bail.
6629+ */
6630+ if (unlikely(vmx->emulation_required)) {
6631+
6632+ /* We don't emulate invalid state of a nested guest */
6633+ vmx->fail = is_guest_mode(vcpu);
6634+
6635+ vmx->exit_reason.full = EXIT_REASON_INVALID_STATE;
6636+ vmx->exit_reason.failed_vmentry = 1;
6637+ kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_1);
6638+ vmx->exit_qualification = ENTRY_FAIL_DEFAULT;
6639+ kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_2);
6640+ vmx->exit_intr_info = 0;
66276641 return EXIT_FASTPATH_NONE;
6642+ }
66286643
66296644 trace_kvm_entry(vcpu);
66306645
@@ -6833,7 +6848,7 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu) · 202 unmodified lines
68336848 */
68346849 tsx_ctrl = vmx_find_uret_msr(vmx, MSR_IA32_TSX_CTRL);
68356850 if (tsx_ctrl)
6836− vmx->guest_uret_msrs[i].mask = ~(u64)TSX_CTRL_CPUID_CLEAR;
6851+ tsx_ctrl->mask = ~(u64)TSX_CTRL_CPUID_CLEAR;
68376852 }
68386853
68396854 err = alloc_loaded_vmcs(&vmx->vmcs01);
arch/x86/kvm/vmx/vmx.h+1−4
@@ -248,12 +248,8 @@ struct vcpu_vmx { · 247 unmodified lines
248248 * only loaded into hardware when necessary, e.g. SYSCALL #UDs outside
249249 * of 64-bit mode or if EFER.SCE=1, thus the SYSCALL MSRs don't need to
250250 * be loaded into hardware if those conditions aren't met.
251− * nr_active_uret_msrs tracks the number of MSRs that need to be loaded
252− * into hardware when running the guest. guest_uret_msrs[] is resorted
253− * whenever the number of "active" uret MSRs is modified.
254251 */
255252 struct vmx_uret_msr guest_uret_msrs[MAX_NR_USER_RETURN_MSRS];
256− int nr_active_uret_msrs;
257253 bool guest_uret_msrs_loaded;
258254 #ifdef CONFIG_X86_64
259255 u64 msr_host_kernel_gs_base;
@@ -359,6 +355,7 @@ void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu); · 99 unmodified lines
359355 void vmx_set_host_fs_gs(struct vmcs_host_state *host, u16 fs_sel, u16 gs_sel,
360356 unsigned long fs_base, unsigned long gs_base);
361357 int vmx_get_cpl(struct kvm_vcpu *vcpu);
358+bool vmx_emulation_required(struct kvm_vcpu *vcpu);
362359 unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu);
363360 void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags);
364361 u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu);
arch/x86/kvm/x86.c+26−2
@@ -1332,6 +1332,13 @@ static const u32 msrs_to_save_all[] = { · 1331 unmodified lines
13321332 MSR_ARCH_PERFMON_EVENTSEL0 + 12, MSR_ARCH_PERFMON_EVENTSEL0 + 13,
13331333 MSR_ARCH_PERFMON_EVENTSEL0 + 14, MSR_ARCH_PERFMON_EVENTSEL0 + 15,
13341334 MSR_ARCH_PERFMON_EVENTSEL0 + 16, MSR_ARCH_PERFMON_EVENTSEL0 + 17,
1335+
1336+ MSR_K7_EVNTSEL0, MSR_K7_EVNTSEL1, MSR_K7_EVNTSEL2, MSR_K7_EVNTSEL3,
1337+ MSR_K7_PERFCTR0, MSR_K7_PERFCTR1, MSR_K7_PERFCTR2, MSR_K7_PERFCTR3,
1338+ MSR_F15H_PERF_CTL0, MSR_F15H_PERF_CTL1, MSR_F15H_PERF_CTL2,
1339+ MSR_F15H_PERF_CTL3, MSR_F15H_PERF_CTL4, MSR_F15H_PERF_CTL5,
1340+ MSR_F15H_PERF_CTR0, MSR_F15H_PERF_CTR1, MSR_F15H_PERF_CTR2,
1341+ MSR_F15H_PERF_CTR3, MSR_F15H_PERF_CTR4, MSR_F15H_PERF_CTR5,
13351342 };
13361343
13371344 static u32 msrs_to_save[ARRAY_SIZE(msrs_to_save_all)];
@@ -2969,7 +2976,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) · 1631 unmodified lines
29692976 offsetof(struct compat_vcpu_info, time));
29702977 if (vcpu->xen.vcpu_time_info_set)
29712978 kvm_setup_pvclock_page(v, &vcpu->xen.vcpu_time_info_cache, 0);
2972− if (v == kvm_get_vcpu(v->kvm, 0))
2979+ if (!v->vcpu_idx)
29732980 kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock);
29742981 return 0;
29752982 }
@@ -7658,6 +7665,13 @@ static void kvm_smm_changed(struct kvm_vcpu *vcpu, bool entering_smm) · 4682 unmodified lines
76587665
76597666 /* Process a latched INIT or SMI, if any. */
76607667 kvm_make_request(KVM_REQ_EVENT, vcpu);
7668+
7669+ /*
7670+ * Even if KVM_SET_SREGS2 loaded PDPTRs out of band,
7671+ * on SMM exit we still need to reload them from
7672+ * guest memory
7673+ */
7674+ vcpu->arch.pdptrs_from_userspace = false;
76617675 }
76627676
76637677 kvm_mmu_reset_context(vcpu);
@@ -10652,6 +10666,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) · 2988 unmodified lines
1065210666 int r;
1065310667
1065410668 vcpu->arch.last_vmentry_cpu = -1;
10669+ vcpu->arch.regs_avail = ~0;
10670+ vcpu->arch.regs_dirty = ~0;
1065510671
1065610672 if (!irqchip_in_kernel(vcpu->kvm) || kvm_vcpu_is_reset_bsp(vcpu))
1065710673 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
@@ -10893,6 +10909,9 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) · 235 unmodified lines
1089310909 kvm_set_rflags(vcpu, X86_EFLAGS_FIXED);
1089410910 kvm_rip_write(vcpu, 0xfff0);
1089510911
10912+ vcpu->arch.cr3 = 0;
10913+ kvm_register_mark_dirty(vcpu, VCPU_EXREG_CR3);
10914+
1089610915 /*
1089710916 * CR0.CD/NW are set on RESET, preserved on INIT. Note, some versions
1089810917 * of Intel's SDM list CD/NW as being set on INIT, but they contradict
@@ -11139,9 +11158,15 @@ void kvm_arch_free_vm(struct kvm *kvm) · 240 unmodified lines
1113911158
1114011159 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
1114111160 {
11161+ int ret;
11162+
1114211163 if (type)
1114311164 return -EINVAL;
1114411165
11166+ ret = kvm_page_track_init(kvm);
11167+ if (ret)
11168+ return ret;
11169+
1114511170 INIT_HLIST_HEAD(&kvm->arch.mask_notifier_list);
1114611171 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages);
1114711172 INIT_LIST_HEAD(&kvm->arch.zapped_obsolete_pages);
@@ -11174,7 +11199,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) · 26 unmodified lines
1117411199
1117511200 kvm_apicv_init(kvm);
1117611201 kvm_hv_init_vm(kvm);
11177− kvm_page_track_init(kvm);
1117811202 kvm_mmu_init_vm(kvm);
1117911203 kvm_xen_init_vm(kvm);
1118011204
arch/x86/net/bpf_jit_comp.c+48−18
@@ -1341,9 +1341,10 @@ st: if (is_imm8(insn->off)) · 1340 unmodified lines
13411341 if (insn->imm == (BPF_AND | BPF_FETCH) ||
13421342 insn->imm == (BPF_OR | BPF_FETCH) ||
13431343 insn->imm == (BPF_XOR | BPF_FETCH)) {
1344− u8 *branch_target;
13451344 bool is64 = BPF_SIZE(insn->code) == BPF_DW;
13461345 u32 real_src_reg = src_reg;
1346+ u32 real_dst_reg = dst_reg;
1347+ u8 *branch_target;
13471348
13481349 /*
13491350 * Can't be implemented with a single x86 insn.
@@ -1354,11 +1355,13 @@ st: if (is_imm8(insn->off)) · 4 unmodified lines
13541355 emit_mov_reg(&prog, true, BPF_REG_AX, BPF_REG_0);
13551356 if (src_reg == BPF_REG_0)
13561357 real_src_reg = BPF_REG_AX;
1358+ if (dst_reg == BPF_REG_0)
1359+ real_dst_reg = BPF_REG_AX;
13571360
13581361 branch_target = prog;
13591362 /* Load old value */
13601363 emit_ldx(&prog, BPF_SIZE(insn->code),
1361− BPF_REG_0, dst_reg, insn->off);
1364+ BPF_REG_0, real_dst_reg, insn->off);
13621365 /*
13631366 * Perform the (commutative) operation locally,
13641367 * put the result in the AUX_REG.
@@ -1369,7 +1372,8 @@ st: if (is_imm8(insn->off)) · 4 unmodified lines
13691372 add_2reg(0xC0, AUX_REG, real_src_reg));
13701373 /* Attempt to swap in new value */
13711374 err = emit_atomic(&prog, BPF_CMPXCHG,
1372− dst_reg, AUX_REG, insn->off,
1375+ real_dst_reg, AUX_REG,
1376+ insn->off,
13731377 BPF_SIZE(insn->code));
13741378 if (WARN_ON(err))
13751379 return err;
@@ -1383,11 +1387,10 @@ st: if (is_imm8(insn->off)) · 7 unmodified lines
13831387 /* Restore R0 after clobbering RAX */
13841388 emit_mov_reg(&prog, true, BPF_REG_0, BPF_REG_AX);
13851389 break;
1386−
13871390 }
13881391
13891392 err = emit_atomic(&prog, insn->imm, dst_reg, src_reg,
1390− insn->off, BPF_SIZE(insn->code));
1393+ insn->off, BPF_SIZE(insn->code));
13911394 if (err)
13921395 return err;
13931396 break;
@@ -1744,7 +1747,7 @@ static void restore_regs(const struct btf_func_model *m, u8 **prog, int nr_args, · 350 unmodified lines
17441747 }
17451748
17461749 static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog,
1747− struct bpf_prog *p, int stack_size, bool mod_ret)
1750+ struct bpf_prog *p, int stack_size, bool save_ret)
17481751 {
17491752 u8 *prog = *pprog;
17501753 u8 *jmp_insn;
@@ -1777,11 +1780,15 @@ static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, · 26 unmodified lines
17771780 if (emit_call(&prog, p->bpf_func, prog))
17781781 return -EINVAL;
17791782
1780− /* BPF_TRAMP_MODIFY_RETURN trampolines can modify the return
1783+ /*
1784+ * BPF_TRAMP_MODIFY_RETURN trampolines can modify the return
17811785 * of the previous call which is then passed on the stack to
17821786 * the next BPF program.
1787+ *
1788+ * BPF_TRAMP_FENTRY trampoline may need to return the return
1789+ * value of BPF_PROG_TYPE_STRUCT_OPS prog.
17831790 */
1784− if (mod_ret)
1791+ if (save_ret)
17851792 emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8);
17861793
17871794 /* replace 2 nops with JE insn, since jmp target is known */
@@ -1828,13 +1835,15 @@ static int emit_cond_near_jump(u8 **pprog, void *func, void *ip, u8 jmp_cond) · 40 unmodified lines
18281835 }
18291836
18301837 static int invoke_bpf(const struct btf_func_model *m, u8 **pprog,
1831− struct bpf_tramp_progs *tp, int stack_size)
1838+ struct bpf_tramp_progs *tp, int stack_size,
1839+ bool save_ret)
18321840 {
18331841 int i;
18341842 u8 *prog = *pprog;
18351843
18361844 for (i = 0; i < tp->nr_progs; i++) {
1837− if (invoke_bpf_prog(m, &prog, tp->progs[i], stack_size, false))
1845+ if (invoke_bpf_prog(m, &prog, tp->progs[i], stack_size,
1846+ save_ret))
18381847 return -EINVAL;
18391848 }
18401849 *pprog = prog;
@@ -1877,6 +1886,23 @@ static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog, · 36 unmodified lines
18771886 return 0;
18781887 }
18791888
1889+static bool is_valid_bpf_tramp_flags(unsigned int flags)
1890+{
1891+ if ((flags & BPF_TRAMP_F_RESTORE_REGS) &&
1892+ (flags & BPF_TRAMP_F_SKIP_FRAME))
1893+ return false;
1894+
1895+ /*
1896+ * BPF_TRAMP_F_RET_FENTRY_RET is only used by bpf_struct_ops,
1897+ * and it must be used alone.
1898+ */
1899+ if ((flags & BPF_TRAMP_F_RET_FENTRY_RET) &&
1900+ (flags & ~BPF_TRAMP_F_RET_FENTRY_RET))
1901+ return false;
1902+
1903+ return true;
1904+}
1905+
18801906 /* Example:
18811907 * __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
18821908 * its 'struct btf_func_model' will be nr_args=2
@@ -1949,17 +1975,19 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i · 66 unmodified lines
19491975 struct bpf_tramp_progs *fmod_ret = &tprogs[BPF_TRAMP_MODIFY_RETURN];
19501976 u8 **branches = NULL;
19511977 u8 *prog;
1978+ bool save_ret;
19521979
19531980 /* x86-64 supports up to 6 arguments. 7+ can be added in the future */
19541981 if (nr_args > 6)
19551982 return -ENOTSUPP;
19561983
1957− if ((flags & BPF_TRAMP_F_RESTORE_REGS) &&
1958− (flags & BPF_TRAMP_F_SKIP_FRAME))
1984+ if (!is_valid_bpf_tramp_flags(flags))
19591985 return -EINVAL;
19601986
1961− if (flags & BPF_TRAMP_F_CALL_ORIG)
1962− stack_size += 8; /* room for return value of orig_call */
1987+ /* room for return value of orig_call or fentry prog */
1988+ save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET);
1989+ if (save_ret)
1990+ stack_size += 8;
19631991
19641992 if (flags & BPF_TRAMP_F_IP_ARG)
19651993 stack_size += 8; /* room for IP address argument */
@@ -2005,7 +2033,8 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i · 39 unmodified lines
20052033 }
20062034
20072035 if (fentry->nr_progs)
2008− if (invoke_bpf(m, &prog, fentry, stack_size))
2036+ if (invoke_bpf(m, &prog, fentry, stack_size,
2037+ flags & BPF_TRAMP_F_RET_FENTRY_RET))
20092038 return -EINVAL;
20102039
20112040 if (fmod_ret->nr_progs) {
@@ -2052,7 +2081,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i · 40 unmodified lines
20522081 }
20532082
20542083 if (fexit->nr_progs)
2055− if (invoke_bpf(m, &prog, fexit, stack_size)) {
2084+ if (invoke_bpf(m, &prog, fexit, stack_size, false)) {
20562085 ret = -EINVAL;
20572086 goto cleanup;
20582087 }
@@ -2072,9 +2101,10 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i · 13 unmodified lines
20722101 ret = -EINVAL;
20732102 goto cleanup;
20742103 }
2075− /* restore original return value back into RAX */
2076− emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8);
20772104 }
2105+ /* restore return value of orig_call or fentry prog back into RAX */
2106+ if (save_ret)
2107+ emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8);
20782108
20792109 EMIT1(0x5B); /* pop rbx */
20802110 EMIT1(0xC9); /* leave */
block/bfq-iosched.c+3−13
@@ -2662,15 +2662,6 @@ bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) · 2661 unmodified lines
26622662 * are likely to increase the throughput.
26632663 */
26642664 bfqq->new_bfqq = new_bfqq;
2665− /*
2666− * The above assignment schedules the following redirections:
2667− * each time some I/O for bfqq arrives, the process that
2668− * generated that I/O is disassociated from bfqq and
2669− * associated with new_bfqq. Here we increases new_bfqq->ref
2670− * in advance, adding the number of processes that are
2671− * expected to be associated with new_bfqq as they happen to
2672− * issue I/O.
2673− */
26742665 new_bfqq->ref += process_refs;
26752666 return new_bfqq;
26762667 }
@@ -2733,10 +2724,6 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, · 56 unmodified lines
27332724 {
27342725 struct bfq_queue *in_service_bfqq, *new_bfqq;
27352726
2736− /* if a merge has already been setup, then proceed with that first */
2737− if (bfqq->new_bfqq)
2738− return bfqq->new_bfqq;
2739−
27402727 /*
27412728 * Check delayed stable merge for rotational or non-queueing
27422729 * devs. For this branch to be executed, bfqq must not be
@@ -2838,6 +2825,9 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, · 95 unmodified lines
28382825 if (bfq_too_late_for_merging(bfqq))
28392826 return NULL;
28402827
2828+ if (bfqq->new_bfqq)
2829+ return bfqq->new_bfqq;
2830+
28412831 if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq))
28422832 return NULL;
28432833
drivers/acpi/nfit/core.c+12−0
@@ -3007,6 +3007,18 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, · 3006 unmodified lines
30073007 ndr_desc->target_node = NUMA_NO_NODE;
30083008 }
30093009
3010+ /* Fallback to address based numa information if node lookup failed */
3011+ if (ndr_desc->numa_node == NUMA_NO_NODE) {
3012+ ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address);
3013+ dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]",
3014+ NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
3015+ }
3016+ if (ndr_desc->target_node == NUMA_NO_NODE) {
3017+ ndr_desc->target_node = phys_to_target_node(spa->address);
3018+ dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]",
3019+ NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
3020+ }
3021+
30103022 /*
30113023 * Persistence domain bits are hierarchical, if
30123024 * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
drivers/base/core.c+63−27
@@ -95,12 +95,29 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) · 94 unmodified lines
9595
9696 list_add(&link->s_hook, &sup->consumers);
9797 list_add(&link->c_hook, &con->suppliers);
98+ pr_debug("%pfwP Linked as a fwnode consumer to %pfwP\n",
99+ con, sup);
98100 out:
99101 mutex_unlock(&fwnode_link_lock);
100102
101103 return ret;
102104 }
103105
106+/**
107+ * __fwnode_link_del - Delete a link between two fwnode_handles.
108+ * @link: the fwnode_link to be deleted
109+ *
110+ * The fwnode_link_lock needs to be held when this function is called.
111+ */
112+static void __fwnode_link_del(struct fwnode_link *link)
113+{
114+ pr_debug("%pfwP Dropping the fwnode link to %pfwP\n",
115+ link->consumer, link->supplier);
116+ list_del(&link->s_hook);
117+ list_del(&link->c_hook);
118+ kfree(link);
119+}
120+
104121 /**
105122 * fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle.
106123 * @fwnode: fwnode whose supplier links need to be deleted
@@ -112,11 +129,8 @@ static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode) · 5 unmodified lines
112129 struct fwnode_link *link, *tmp;
113130
114131 mutex_lock(&fwnode_link_lock);
115− list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) {
116− list_del(&link->s_hook);
117− list_del(&link->c_hook);
118− kfree(link);
119− }
132+ list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook)
133+ __fwnode_link_del(link);
120134 mutex_unlock(&fwnode_link_lock);
121135 }
122136
@@ -131,11 +145,8 @@ static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode) · 8 unmodified lines
131145 struct fwnode_link *link, *tmp;
132146
133147 mutex_lock(&fwnode_link_lock);
134− list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) {
135− list_del(&link->s_hook);
136− list_del(&link->c_hook);
137− kfree(link);
138− }
148+ list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook)
149+ __fwnode_link_del(link);
139150 mutex_unlock(&fwnode_link_lock);
140151 }
141152
@@ -975,6 +986,7 @@ int device_links_check_suppliers(struct device *dev) · 833 unmodified lines
975986 {
976987 struct device_link *link;
977988 int ret = 0;
989+ struct fwnode_handle *sup_fw;
978990
979991 /*
980992 * Device waiting for supplier to become available is not allowed to
@@ -983,10 +995,11 @@ int device_links_check_suppliers(struct device *dev) · 2 unmodified lines
983995 mutex_lock(&fwnode_link_lock);
984996 if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
985997 !fw_devlink_is_permissive()) {
986− dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n",
987− list_first_entry(&dev->fwnode->suppliers,
988− struct fwnode_link,
989− c_hook)->supplier);
998+ sup_fw = list_first_entry(&dev->fwnode->suppliers,
999+ struct fwnode_link,
1000+ c_hook)->supplier;
1001+ dev_err_probe(dev, -EPROBE_DEFER, "wait for supplier %pfwP\n",
1002+ sup_fw);
9901003 mutex_unlock(&fwnode_link_lock);
9911004 return -EPROBE_DEFER;
9921005 }
@@ -1001,8 +1014,9 @@ int device_links_check_suppliers(struct device *dev) · 8 unmodified lines
10011014 if (link->status != DL_STATE_AVAILABLE &&
10021015 !(link->flags & DL_FLAG_SYNC_STATE_ONLY)) {
10031016 device_links_missing_supplier(dev);
1004− dev_dbg(dev, "probe deferral - supplier %s not ready\n",
1005− dev_name(link->supplier));
1017+ dev_err_probe(dev, -EPROBE_DEFER,
1018+ "supplier %s not ready\n",
1019+ dev_name(link->supplier));
10061020 ret = -EPROBE_DEFER;
10071021 break;
10081022 }
@@ -1722,6 +1736,25 @@ static int fw_devlink_create_devlink(struct device *con, · 713 unmodified lines
17221736 struct device *sup_dev;
17231737 int ret = 0;
17241738
1739+ /*
1740+ * In some cases, a device P might also be a supplier to its child node
1741+ * C. However, this would defer the probe of C until the probe of P
1742+ * completes successfully. This is perfectly fine in the device driver
1743+ * model. device_add() doesn't guarantee probe completion of the device
1744+ * by the time it returns.
1745+ *
1746+ * However, there are a few drivers that assume C will finish probing
1747+ * as soon as it's added and before P finishes probing. So, we provide
1748+ * a flag to let fw_devlink know not to delay the probe of C until the
1749+ * probe of P completes successfully.
1750+ *
1751+ * When such a flag is set, we can't create device links where P is the
1752+ * supplier of C as that would delay the probe of C.
1753+ */
1754+ if (sup_handle->flags & FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD &&
1755+ fwnode_is_ancestor_of(sup_handle, con->fwnode))
1756+ return -EINVAL;
1757+
17251758 sup_dev = get_dev_from_fwnode(sup_handle);
17261759 if (sup_dev) {
17271760 /*
@@ -1772,14 +1805,21 @@ static int fw_devlink_create_devlink(struct device *con, · 44 unmodified lines
17721805 * be broken by applying logic. Check for these types of cycles and
17731806 * break them so that devices in the cycle probe properly.
17741807 *
1775− * If the supplier's parent is dependent on the consumer, then
1776− * the consumer-supplier dependency is a false dependency. So,
1777− * treat it as an invalid link.
1808+ * If the supplier's parent is dependent on the consumer, then the
1809+ * consumer and supplier have a cyclic dependency. Since fw_devlink
1810+ * can't tell which of the inferred dependencies are incorrect, don't
1811+ * enforce probe ordering between any of the devices in this cyclic
1812+ * dependency. Do this by relaxing all the fw_devlink device links in
1813+ * this cycle and by treating the fwnode link between the consumer and
1814+ * the supplier as an invalid dependency.
17781815 */
17791816 sup_dev = fwnode_get_next_parent_dev(sup_handle);
17801817 if (sup_dev && device_is_dependent(con, sup_dev)) {
1781− dev_dbg(con, "Not linking to %pfwP - False link\n",
1782− sup_handle);
1818+ dev_info(con, "Fixing up cyclic dependency with %pfwP (%s)\n",
1819+ sup_handle, dev_name(sup_dev));
1820+ device_links_write_lock();
1821+ fw_devlink_relax_cycle(con, sup_dev);
1822+ device_links_write_unlock();
17831823 ret = -EINVAL;
17841824 } else {
17851825 /*
@@ -1858,9 +1898,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev) · 72 unmodified lines
18581898 if (!own_link || ret == -EAGAIN)
18591899 continue;
18601900
1861− list_del(&link->s_hook);
1862− list_del(&link->c_hook);
1863− kfree(link);
1901+ __fwnode_link_del(link);
18641902 }
18651903 }
18661904
@@ -1912,9 +1950,7 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, · 45 unmodified lines
19121950 if (!own_link || ret == -EAGAIN)
19131951 continue;
19141952
1915− list_del(&link->s_hook);
1916− list_del(&link->c_hook);
1917− kfree(link);
1953+ __fwnode_link_del(link);
19181954
19191955 /* If no device link was created, nothing more to do. */
19201956 if (ret)
drivers/block/nbd.c+17−12
@@ -97,13 +97,18 @@ struct nbd_config { · 96 unmodified lines
9797
9898 atomic_t recv_threads;
9999 wait_queue_head_t recv_wq;
100− loff_t blksize;
100+ unsigned int blksize_bits;
101101 loff_t bytesize;
102102 #if IS_ENABLED(CONFIG_DEBUG_FS)
103103 struct dentry *dbg_dir;
104104 #endif
105105 };
106106
107+static inline unsigned int nbd_blksize(struct nbd_config *config)
108+{
109+ return 1u << config->blksize_bits;
110+}
111+
107112 struct nbd_device {
108113 struct blk_mq_tag_set tag_set;
109114
@@ -146,7 +151,7 @@ static struct dentry *nbd_dbg_dir; · 36 unmodified lines
146151
147152 #define NBD_MAGIC 0x68797548
148153
149−#define NBD_DEF_BLKSIZE 1024
154+#define NBD_DEF_BLKSIZE_BITS 10
150155
151156 static unsigned int nbds_max = 16;
152157 static int max_part = 16;
@@ -317,12 +322,12 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, · 164 unmodified lines
317322 loff_t blksize)
318323 {
319324 if (!blksize)
320− blksize = NBD_DEF_BLKSIZE;
325+ blksize = 1u << NBD_DEF_BLKSIZE_BITS;
321326 if (blksize < 512 || blksize > PAGE_SIZE || !is_power_of_2(blksize))
322327 return -EINVAL;
323328
324329 nbd->config->bytesize = bytesize;
325− nbd->config->blksize = blksize;
330+ nbd->config->blksize_bits = __ffs(blksize);
326331
327332 if (!nbd->task_recv)
328333 return 0;
@@ -1337,7 +1342,7 @@ static int nbd_start_device(struct nbd_device *nbd) · 1008 unmodified lines
13371342 args->index = i;
13381343 queue_work(nbd->recv_workq, &args->work);
13391344 }
1340− return nbd_set_size(nbd, config->bytesize, config->blksize);
1345+ return nbd_set_size(nbd, config->bytesize, nbd_blksize(config));
13411346 }
13421347
13431348 static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev)
@@ -1406,11 +1411,11 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, · 62 unmodified lines
14061411 case NBD_SET_BLKSIZE:
14071412 return nbd_set_size(nbd, config->bytesize, arg);
14081413 case NBD_SET_SIZE:
1409− return nbd_set_size(nbd, arg, config->blksize);
1414+ return nbd_set_size(nbd, arg, nbd_blksize(config));
14101415 case NBD_SET_SIZE_BLOCKS:
1411− if (check_mul_overflow((loff_t)arg, config->blksize, &bytesize))
1416+ if (check_shl_overflow(arg, config->blksize_bits, &bytesize))
14121417 return -EINVAL;
1413− return nbd_set_size(nbd, bytesize, config->blksize);
1418+ return nbd_set_size(nbd, bytesize, nbd_blksize(config));
14141419 case NBD_SET_TIMEOUT:
14151420 nbd_set_cmd_timeout(nbd, arg);
14161421 return 0;
@@ -1476,7 +1481,7 @@ static struct nbd_config *nbd_alloc_config(void) · 59 unmodified lines
14761481 atomic_set(&config->recv_threads, 0);
14771482 init_waitqueue_head(&config->recv_wq);
14781483 init_waitqueue_head(&config->conn_wait);
1479− config->blksize = NBD_DEF_BLKSIZE;
1484+ config->blksize_bits = NBD_DEF_BLKSIZE_BITS;
14801485 atomic_set(&config->live_connections, 0);
14811486 try_module_get(THIS_MODULE);
14821487 return config;
@@ -1604,7 +1609,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd) · 121 unmodified lines
16041609 debugfs_create_file("tasks", 0444, dir, nbd, &nbd_dbg_tasks_fops);
16051610 debugfs_create_u64("size_bytes", 0444, dir, &config->bytesize);
16061611 debugfs_create_u32("timeout", 0444, dir, &nbd->tag_set.timeout);
1607− debugfs_create_u64("blocksize", 0444, dir, &config->blksize);
1612+ debugfs_create_u32("blocksize_bits", 0444, dir, &config->blksize_bits);
16081613 debugfs_create_file("flags", 0444, dir, nbd, &nbd_dbg_flags_fops);
16091614
16101615 return 0;
@@ -1826,7 +1831,7 @@ nbd_device_policy[NBD_DEVICE_ATTR_MAX + 1] = { · 215 unmodified lines
18261831 static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd)
18271832 {
18281833 struct nbd_config *config = nbd->config;
1829− u64 bsize = config->blksize;
1834+ u64 bsize = nbd_blksize(config);
18301835 u64 bytes = config->bytesize;
18311836
18321837 if (info->attrs[NBD_ATTR_SIZE_BYTES])
@@ -1835,7 +1840,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd) · 2 unmodified lines
18351840 if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES])
18361841 bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
18371842
1838− if (bytes != config->bytesize || bsize != config->blksize)
1843+ if (bytes != config->bytesize || bsize != nbd_blksize(config))
18391844 return nbd_set_size(nbd, bytes, bsize);
18401845 return 0;
18411846 }
drivers/crypto/ccp/ccp-ops.c+8−6
@@ -778,7 +778,7 @@ ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · 777 unmodified lines
778778 in_place ? DMA_BIDIRECTIONAL
779779 : DMA_TO_DEVICE);
780780 if (ret)
781− goto e_ctx;
781+ goto e_aad;
782782
783783 if (in_place) {
784784 dst = src;
@@ -863,7 +863,7 @@ ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · 78 unmodified lines
863863 op.u.aes.size = 0;
864864 ret = cmd_q->ccp->vdata->perform->aes(&op);
865865 if (ret)
866− goto e_dst;
866+ goto e_final_wa;
867867
868868 if (aes->action == CCP_AES_ACTION_ENCRYPT) {
869869 /* Put the ciphered tag after the ciphertext. */
@@ -873,17 +873,19 @@ ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · 3 unmodified lines
873873 ret = ccp_init_dm_workarea(&tag, cmd_q, authsize,
874874 DMA_BIDIRECTIONAL);
875875 if (ret)
876− goto e_tag;
876+ goto e_final_wa;
877877 ret = ccp_set_dm_area(&tag, 0, p_tag, 0, authsize);
878− if (ret)
879− goto e_tag;
878+ if (ret) {
879+ ccp_dm_free(&tag);
880+ goto e_final_wa;
881+ }
880882
881883 ret = crypto_memneq(tag.address, final_wa.address,
882884 authsize) ? -EBADMSG : 0;
883885 ccp_dm_free(&tag);
884886 }
885887
886−e_tag:
888+e_final_wa:
887889 ccp_dm_free(&final_wa);
888890
889891 e_dst:
drivers/gpio/gpio-pca953x.c+2−9
@@ -468,15 +468,8 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) · 467 unmodified lines
468468 mutex_lock(&chip->i2c_lock);
469469 ret = regmap_read(chip->regmap, inreg, &reg_val);
470470 mutex_unlock(&chip->i2c_lock);
471− if (ret < 0) {
472− /*
473− * NOTE:
474− * diagnostic already emitted; that's all we should
475− * do unless gpio_*_value_cansleep() calls become different
476− * from their nonsleeping siblings (and report faults).
477− */
478− return 0;
479− }
471+ if (ret < 0)
472+ return ret;
480473
481474 return !!(reg_val & bit);
482475 }
drivers/gpio/gpio-rockchip.c+22−0
@@ -689,6 +689,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev) · 688 unmodified lines
689689 struct device_node *pctlnp = of_get_parent(np);
690690 struct pinctrl_dev *pctldev = NULL;
691691 struct rockchip_pin_bank *bank = NULL;
692+ struct rockchip_pin_output_deferred *cfg;
692693 static int gpio;
693694 int id, ret;
694695
@@ -716,12 +717,33 @@ static int rockchip_gpio_probe(struct platform_device *pdev) · 21 unmodified lines
716717 if (ret)
717718 return ret;
718719
720+ /*
721+ * Prevent clashes with a deferred output setting
722+ * being added right at this moment.
723+ */
724+ mutex_lock(&bank->deferred_lock);
725+
719726 ret = rockchip_gpiolib_register(bank);
720727 if (ret) {
721728 clk_disable_unprepare(bank->clk);
729+ mutex_unlock(&bank->deferred_lock);
722730 return ret;
723731 }
724732
733+ while (!list_empty(&bank->deferred_output)) {
734+ cfg = list_first_entry(&bank->deferred_output,
735+ struct rockchip_pin_output_deferred, head);
736+ list_del(&cfg->head);
737+
738+ ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg);
739+ if (ret)
740+ dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin, cfg->arg);
741+
742+ kfree(cfg);
743+ }
744+
745+ mutex_unlock(&bank->deferred_lock);
746+
725747 platform_set_drvdata(pdev, bank);
726748 dev_info(dev, "probed %pOF\n", np);
727749
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c+31−0
@@ -837,6 +837,28 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) · 836 unmodified lines
837837 return 0;
838838 }
839839
840+/* Mirrors the is_displayable check in radeonsi's gfx6_compute_surface */
841+static int check_tiling_flags_gfx6(struct amdgpu_framebuffer *afb)
842+{
843+ u64 micro_tile_mode;
844+
845+ /* Zero swizzle mode means linear */
846+ if (AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE) == 0)
847+ return 0;
848+
849+ micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE);
850+ switch (micro_tile_mode) {
851+ case 0: /* DISPLAY */
852+ case 3: /* RENDER */
853+ return 0;
854+ default:
855+ drm_dbg_kms(afb->base.dev,
856+ "Micro tile mode %llu not supported for scanout\n",
857+ micro_tile_mode);
858+ return -EINVAL;
859+ }
860+}
861+
840862 static void get_block_dimensions(unsigned int block_log2, unsigned int cpp,
841863 unsigned int *width, unsigned int *height)
842864 {
@@ -1103,6 +1125,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev, · 260 unmodified lines
11031125 const struct drm_mode_fb_cmd2 *mode_cmd,
11041126 struct drm_gem_object *obj)
11051127 {
1128+ struct amdgpu_device *adev = drm_to_adev(dev);
11061129 int ret, i;
11071130
11081131 /*
@@ -1122,6 +1145,14 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev, · 13 unmodified lines
11221145 if (ret)
11231146 return ret;
11241147
1148+ if (!dev->mode_config.allow_fb_modifiers) {
1149+ drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
1150+ "GFX9+ requires FB check based on format modifier\n");
1151+ ret = check_tiling_flags_gfx6(rfb);
1152+ if (ret)
1153+ return ret;
1154+ }
1155+
11251156 if (dev->mode_config.allow_fb_modifiers &&
11261157 !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
11271158 ret = convert_tiling_flags_to_modifier(rfb);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c+1−1
@@ -3599,7 +3599,7 @@ static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring) · 3598 unmodified lines
35993599
36003600 /* set static priority for a queue/ring */
36013601 gfx_v9_0_mqd_set_priority(ring, mqd);
3602− mqd->cp_hqd_quantum = RREG32(mmCP_HQD_QUANTUM);
3602+ mqd->cp_hqd_quantum = RREG32_SOC15(GC, 0, mmCP_HQD_QUANTUM);
36033603
36043604 /* map_queues packet doesn't need activate the queue,
36053605 * so only kiq need set this field.
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c+2−1
@@ -1098,6 +1098,8 @@ static int gmc_v10_0_hw_fini(void *handle) · 1097 unmodified lines
10981098 {
10991099 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
11001100
1101+ gmc_v10_0_gart_disable(adev);
1102+
11011103 if (amdgpu_sriov_vf(adev)) {
11021104 /* full access mode, so don't touch any GMC register */
11031105 DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1106,7 +1108,6 @@ static int gmc_v10_0_hw_fini(void *handle) · 2 unmodified lines
11061108
11071109 amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
11081110 amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
1109− gmc_v10_0_gart_disable(adev);
11101111
11111112 return 0;
11121113 }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c+2−1
@@ -1794,6 +1794,8 @@ static int gmc_v9_0_hw_fini(void *handle) · 1793 unmodified lines
17941794 {
17951795 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
17961796
1797+ gmc_v9_0_gart_disable(adev);
1798+
17971799 if (amdgpu_sriov_vf(adev)) {
17981800 /* full access mode, so don't touch any GMC register */
17991801 DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1802,7 +1804,6 @@ static int gmc_v9_0_hw_fini(void *handle) · 2 unmodified lines
18021804
18031805 amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
18041806 amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
1805− gmc_v9_0_gart_disable(adev);
18061807
18071808 return 0;
18081809 }
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c+8−0
@@ -868,6 +868,12 @@ static int sdma_v5_2_start(struct amdgpu_device *adev) · 867 unmodified lines
868868 msleep(1000);
869869 }
870870
871+ /* TODO: check whether can submit a doorbell request to raise
872+ * a doorbell fence to exit gfxoff.
873+ */
874+ if (adev->in_s0ix)
875+ amdgpu_gfx_off_ctrl(adev, false);
876+
871877 sdma_v5_2_soft_reset(adev);
872878 /* unhalt the MEs */
873879 sdma_v5_2_enable(adev, true);
@@ -876,6 +882,8 @@ static int sdma_v5_2_start(struct amdgpu_device *adev) · 2 unmodified lines
876882
877883 /* start the gfx rings and rlc compute queues */
878884 r = sdma_v5_2_gfx_resume(adev);
885+ if (adev->in_s0ix)
886+ amdgpu_gfx_off_ctrl(adev, true);
879887 if (r)
880888 return r;
881889 r = sdma_v5_2_rlc_resume(adev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c+2−0
@@ -1115,6 +1115,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) · 1114 unmodified lines
11151115
11161116 init_data.asic_id.pci_revision_id = adev->pdev->revision;
11171117 init_data.asic_id.hw_internal_rev = adev->external_rev_id;
1118+ init_data.asic_id.chip_id = adev->pdev->device;
11181119
11191120 init_data.asic_id.vram_width = adev->gmc.vram_width;
11201121 /* TODO: initialize init_data.asic_id.vram_type here!!!! */
@@ -1719,6 +1720,7 @@ static int dm_late_init(void *handle) · 598 unmodified lines
17191720 linear_lut[i] = 0xFFFF * i / 15;
17201721
17211722 params.set = 0;
1723+ params.backlight_ramping_override = false;
17221724 params.backlight_ramping_start = 0xCCCC;
17231725 params.backlight_ramping_reduction = 0xCCCCCCCC;
17241726 params.backlight_lut_array_size = 16;
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c+7−8
@@ -1826,14 +1826,13 @@ bool perform_link_training_with_retries( · 1825 unmodified lines
18261826 if (panel_mode == DP_PANEL_MODE_EDP) {
18271827 struct cp_psp *cp_psp = &stream->ctx->cp_psp;
18281828
1829− if (cp_psp && cp_psp->funcs.enable_assr) {
1830− if (!cp_psp->funcs.enable_assr(cp_psp->handle, link)) {
1831− /* since eDP implies ASSR on, change panel
1832− * mode to disable ASSR
1833− */
1834− panel_mode = DP_PANEL_MODE_DEFAULT;
1835− }
1836− }
1829+ if (cp_psp && cp_psp->funcs.enable_assr)
1830+ /* ASSR is bound to fail with unsigned PSP
1831+ * verstage used during devlopment phase.
1832+ * Report and continue with eDP panel mode to
1833+ * perform eDP link training with right settings
1834+ */
1835+ cp_psp->funcs.enable_assr(cp_psp->handle, link);
18371836 }
18381837 #endif
18391838
drivers/gpu/drm/exynos/exynos5433_drm_decon.c+1−3
@@ -793,7 +793,6 @@ static int exynos5433_decon_probe(struct platform_device *pdev) · 792 unmodified lines
793793 {
794794 struct device *dev = &pdev->dev;
795795 struct decon_context *ctx;
796− struct resource *res;
797796 int ret;
798797 int i;
799798
@@ -818,8 +817,7 @@ static int exynos5433_decon_probe(struct platform_device *pdev) · 18 unmodified lines
818817 ctx->clks[i] = clk;
819818 }
820819
821− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
822− ctx->addr = devm_ioremap_resource(dev, res);
820+ ctx->addr = devm_platform_ioremap_resource(pdev, 0);
823821 if (IS_ERR(ctx->addr))
824822 return PTR_ERR(ctx->addr);
825823
drivers/gpu/drm/exynos/exynos_drm_dsi.c+1−3
@@ -1738,7 +1738,6 @@ static const struct component_ops exynos_dsi_component_ops = { · 1737 unmodified lines
17381738 static int exynos_dsi_probe(struct platform_device *pdev)
17391739 {
17401740 struct device *dev = &pdev->dev;
1741− struct resource *res;
17421741 struct exynos_dsi *dsi;
17431742 int ret, i;
17441743
@@ -1789,8 +1788,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) · 44 unmodified lines
17891788 }
17901789 }
17911790
1792− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1793− dsi->reg_base = devm_ioremap_resource(dev, res);
1791+ dsi->reg_base = devm_platform_ioremap_resource(pdev, 0);
17941792 if (IS_ERR(dsi->reg_base))
17951793 return PTR_ERR(dsi->reg_base);
17961794
drivers/gpu/drm/exynos/exynos_drm_fimc.c+1−4
@@ -85,7 +85,6 @@ struct fimc_scaler { · 84 unmodified lines
8585 /*
8686 * A structure of fimc context.
8787 *
88− * @regs_res: register resources.
8988 * @regs: memory mapped io registers.
9089 * @lock: locking of operations.
9190 * @clocks: fimc clocks.
@@ -103,7 +102,6 @@ struct fimc_context { · 11 unmodified lines
103102 struct exynos_drm_ipp_formats *formats;
104103 unsigned int num_formats;
105104
106− struct resource *regs_res;
107105 void __iomem *regs;
108106 spinlock_t lock;
109107 struct clk *clocks[FIMC_CLKS_MAX];
@@ -1327,8 +1325,7 @@ static int fimc_probe(struct platform_device *pdev) · 1217 unmodified lines
13271325 ctx->num_formats = num_formats;
13281326
13291327 /* resource memory */
1330− ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1331− ctx->regs = devm_ioremap_resource(dev, ctx->regs_res);
1328+ ctx->regs = devm_platform_ioremap_resource(pdev, 0);
13321329 if (IS_ERR(ctx->regs))
13331330 return PTR_ERR(ctx->regs);
13341331
drivers/gpu/drm/exynos/exynos_drm_fimd.c+1−3
@@ -1202,9 +1202,7 @@ static int fimd_probe(struct platform_device *pdev) · 1201 unmodified lines
12021202 return PTR_ERR(ctx->lcd_clk);
12031203 }
12041204
1205− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1206−
1207− ctx->regs = devm_ioremap_resource(dev, res);
1205+ ctx->regs = devm_platform_ioremap_resource(pdev, 0);
12081206 if (IS_ERR(ctx->regs))
12091207 return PTR_ERR(ctx->regs);
12101208
drivers/gpu/drm/exynos/exynos_drm_g2d.c+1−4
@@ -1449,7 +1449,6 @@ static const struct component_ops g2d_component_ops = { · 1448 unmodified lines
14491449 static int g2d_probe(struct platform_device *pdev)
14501450 {
14511451 struct device *dev = &pdev->dev;
1452− struct resource *res;
14531452 struct g2d_data *g2d;
14541453 int ret;
14551454
@@ -1491,9 +1490,7 @@ static int g2d_probe(struct platform_device *pdev) · 35 unmodified lines
14911490 clear_bit(G2D_BIT_SUSPEND_RUNQUEUE, &g2d->flags);
14921491 clear_bit(G2D_BIT_ENGINE_BUSY, &g2d->flags);
14931492
1494− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1495−
1496− g2d->regs = devm_ioremap_resource(dev, res);
1493+ g2d->regs = devm_platform_ioremap_resource(pdev, 0);
14971494 if (IS_ERR(g2d->regs)) {
14981495 ret = PTR_ERR(g2d->regs);
14991496 goto err_put_clk;
drivers/gpu/drm/exynos/exynos_drm_gsc.c+1−5
@@ -86,7 +86,6 @@ struct gsc_scaler { · 85 unmodified lines
8686 /*
8787 * A structure of gsc context.
8888 *
89− * @regs_res: register resources.
9089 * @regs: memory mapped io registers.
9190 * @gsc_clk: gsc gate clock.
9291 * @sc: scaler infomations.
@@ -103,7 +102,6 @@ struct gsc_context { · 10 unmodified lines
103102 struct exynos_drm_ipp_formats *formats;
104103 unsigned int num_formats;
105104
106− struct resource *regs_res;
107105 void __iomem *regs;
108106 const char **clk_names;
109107 struct clk *clocks[GSC_MAX_CLOCKS];
@@ -1272,9 +1270,7 @@ static int gsc_probe(struct platform_device *pdev) · 1162 unmodified lines
12721270 }
12731271 }
12741272
1275− /* resource memory */
1276− ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1277− ctx->regs = devm_ioremap_resource(dev, ctx->regs_res);
1273+ ctx->regs = devm_platform_ioremap_resource(pdev, 0);
12781274 if (IS_ERR(ctx->regs))
12791275 return PTR_ERR(ctx->regs);
12801276
drivers/gpu/drm/exynos/exynos_drm_rotator.c+1−3
@@ -278,7 +278,6 @@ static const struct component_ops rotator_component_ops = { · 277 unmodified lines
278278 static int rotator_probe(struct platform_device *pdev)
279279 {
280280 struct device *dev = &pdev->dev;
281− struct resource *regs_res;
282281 struct rot_context *rot;
283282 const struct rot_variant *variant;
284283 int irq;
@@ -292,8 +291,7 @@ static int rotator_probe(struct platform_device *pdev) · 7 unmodified lines
292291 rot->formats = variant->formats;
293292 rot->num_formats = variant->num_formats;
294293 rot->dev = dev;
295− regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
296− rot->regs = devm_ioremap_resource(dev, regs_res);
294+ rot->regs = devm_platform_ioremap_resource(pdev, 0);
297295 if (IS_ERR(rot->regs))
298296 return PTR_ERR(rot->regs);
299297
drivers/gpu/drm/exynos/exynos_drm_scaler.c+1−3
@@ -485,7 +485,6 @@ static const struct component_ops scaler_component_ops = { · 484 unmodified lines
485485 static int scaler_probe(struct platform_device *pdev)
486486 {
487487 struct device *dev = &pdev->dev;
488− struct resource *regs_res;
489488 struct scaler_context *scaler;
490489 int irq;
491490 int ret, i;
@@ -498,8 +497,7 @@ static int scaler_probe(struct platform_device *pdev) · 6 unmodified lines
498497 (struct scaler_data *)of_device_get_match_data(dev);
499498
500499 scaler->dev = dev;
501− regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
502− scaler->regs = devm_ioremap_resource(dev, regs_res);
500+ scaler->regs = devm_platform_ioremap_resource(pdev, 0);
503501 if (IS_ERR(scaler->regs))
504502 return PTR_ERR(scaler->regs);
505503
drivers/gpu/drm/exynos/exynos_hdmi.c+1−3
@@ -1957,7 +1957,6 @@ static int hdmi_probe(struct platform_device *pdev) · 1956 unmodified lines
19571957 struct hdmi_audio_infoframe *audio_infoframe;
19581958 struct device *dev = &pdev->dev;
19591959 struct hdmi_context *hdata;
1960− struct resource *res;
19611960 int ret;
19621961
19631962 hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL);
@@ -1979,8 +1978,7 @@ static int hdmi_probe(struct platform_device *pdev) · 15 unmodified lines
19791978 return ret;
19801979 }
19811980
1982− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1983− hdata->regs = devm_ioremap_resource(dev, res);
1981+ hdata->regs = devm_platform_ioremap_resource(pdev, 0);
19841982 if (IS_ERR(hdata->regs)) {
19851983 ret = PTR_ERR(hdata->regs);
19861984 return ret;
drivers/gpu/drm/i915/gt/intel_context.c+3−2
@@ -362,8 +362,9 @@ static int __intel_context_active(struct i915_active *active) · 361 unmodified lines
362362 return 0;
363363 }
364364
365−static int sw_fence_dummy_notify(struct i915_sw_fence *sf,
366− enum i915_sw_fence_notify state)
365+static int __i915_sw_fence_call
366+sw_fence_dummy_notify(struct i915_sw_fence *sf,
367+ enum i915_sw_fence_notify state)
367368 {
368369 return NOTIFY_DONE;
369370 }
drivers/gpu/drm/i915/gt/intel_rps.c+0−2
@@ -882,8 +882,6 @@ void intel_rps_park(struct intel_rps *rps) · 881 unmodified lines
882882 if (!intel_rps_is_enabled(rps))
883883 return;
884884
885− GEM_BUG_ON(atomic_read(&rps->num_waiters));
886−
887885 if (!intel_rps_clear_active(rps))
888886 return;
889887
drivers/gpu/drm/i915/gt/uc/abi/guc_communication_ctb_abi.h+5−5
@@ -102,11 +102,11 @@ static_assert(sizeof(struct guc_ct_buffer_desc) == 64); · 101 unmodified lines
102102 * | +-------+--------------------------------------------------------------+
103103 * | | 7:0 | NUM_DWORDS = length (in dwords) of the embedded HXG message |
104104 * +---+-------+--------------------------------------------------------------+
105− * | 1 | 31:0 | +--------------------------------------------------------+ |
106− * +---+-------+ | | |
107− * |...| | | Embedded `HXG Message`_ | |
108− * +---+-------+ | | |
109− * | n | 31:0 | +--------------------------------------------------------+ |
105+ * | 1 | 31:0 | |
106+ * +---+-------+ |
107+ * |...| | [Embedded `HXG Message`_] |
108+ * +---+-------+ |
109+ * | n | 31:0 | |
110110 * +---+-------+--------------------------------------------------------------+
111111 */
112112
drivers/gpu/drm/i915/gt/uc/abi/guc_communication_mmio_abi.h+5−5
@@ -38,11 +38,11 @@ · 37 unmodified lines
3838 * +---+-------+--------------------------------------------------------------+
3939 * | | Bits | Description |
4040 * +===+=======+==============================================================+
41− * | 0 | 31:0 | +--------------------------------------------------------+ |
42− * +---+-------+ | | |
43− * |...| | | Embedded `HXG Message`_ | |
44− * +---+-------+ | | |
45− * | n | 31:0 | +--------------------------------------------------------+ |
41+ * | 0 | 31:0 | |
42+ * +---+-------+ |
43+ * |...| | [Embedded `HXG Message`_] |
44+ * +---+-------+ |
45+ * | n | 31:0 | |
4646 * +---+-------+--------------------------------------------------------------+
4747 */
4848
drivers/gpu/drm/i915/gvt/scheduler.c+2−2
@@ -576,7 +576,7 @@ retry: · 575 unmodified lines
576576
577577 /* No one is going to touch shadow bb from now on. */
578578 i915_gem_object_flush_map(bb->obj);
579− i915_gem_object_unlock(bb->obj);
579+ i915_gem_ww_ctx_fini(&ww);
580580 }
581581 }
582582 return 0;
@@ -630,7 +630,7 @@ retry: · 47 unmodified lines
630630 return ret;
631631 }
632632
633− i915_gem_object_unlock(wa_ctx->indirect_ctx.obj);
633+ i915_gem_ww_ctx_fini(&ww);
634634
635635 /* FIXME: we are not tracking our pinned VMA leaving it
636636 * up to the core to fix up the stray pin_count upon
drivers/gpu/drm/i915/i915_request.c+2−9
@@ -829,8 +829,6 @@ static void __i915_request_ctor(void *arg) · 828 unmodified lines
829829 i915_sw_fence_init(&rq->submit, submit_notify);
830830 i915_sw_fence_init(&rq->semaphore, semaphore_notify);
831831
832− dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock, 0, 0);
833−
834832 rq->capture_list = NULL;
835833
836834 init_llist_head(&rq->execute_cb);
@@ -905,17 +903,12 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp) · 68 unmodified lines
905903 rq->ring = ce->ring;
906904 rq->execution_mask = ce->engine->mask;
907905
908− kref_init(&rq->fence.refcount);
909− rq->fence.flags = 0;
910− rq->fence.error = 0;
911− INIT_LIST_HEAD(&rq->fence.cb_list);
912−
913906 ret = intel_timeline_get_seqno(tl, rq, &seqno);
914907 if (ret)
915908 goto err_free;
916909
917− rq->fence.context = tl->fence_context;
918− rq->fence.seqno = seqno;
910+ dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
911+ tl->fence_context, seqno);
919912
920913 RCU_INIT_POINTER(rq->timeline, tl);
921914 rq->hwsp_seqno = tl->hwsp_seqno;
drivers/gpu/drm/tegra/dc.c+0−3
@@ -1845,7 +1845,6 @@ tegra_crtc_update_memory_bandwidth(struct drm_crtc *crtc, · 1844 unmodified lines
18451845 bool prepare_bandwidth_transition)
18461846 {
18471847 const struct tegra_plane_state *old_tegra_state, *new_tegra_state;
1848− const struct tegra_dc_state *old_dc_state, *new_dc_state;
18491848 u32 i, new_avg_bw, old_avg_bw, new_peak_bw, old_peak_bw;
18501849 const struct drm_plane_state *old_plane_state;
18511850 const struct drm_crtc_state *old_crtc_state;
@@ -1858,8 +1857,6 @@ tegra_crtc_update_memory_bandwidth(struct drm_crtc *crtc, · 6 unmodified lines
18581857 return;
18591858
18601859 old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc);
1861− old_dc_state = to_const_dc_state(old_crtc_state);
1862− new_dc_state = to_const_dc_state(crtc->state);
18631860
18641861 if (!crtc->state->active) {
18651862 if (!old_crtc_state->active)
drivers/gpu/drm/tegra/dc.h+0−6
@@ -35,12 +35,6 @@ static inline struct tegra_dc_state *to_dc_state(struct drm_crtc_state *state) · 34 unmodified lines
3535 return NULL;
3636 }
3737
38−static inline const struct tegra_dc_state *
39−to_const_dc_state(const struct drm_crtc_state *state)
40−{
41− return to_dc_state((struct drm_crtc_state *)state);
42−}
43−
4438 struct tegra_dc_stats {
4539 unsigned long frames;
4640 unsigned long vblank;
drivers/gpu/drm/tegra/uapi.c+1−1
@@ -222,7 +222,7 @@ int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data, struct drm_f · 221 unmodified lines
222222 mapping->iova = sg_dma_address(mapping->sgt->sgl);
223223 }
224224
225− mapping->iova_end = mapping->iova + host1x_to_tegra_bo(mapping->bo)->size;
225+ mapping->iova_end = mapping->iova + host1x_to_tegra_bo(mapping->bo)->gem.size;
226226
227227 err = xa_alloc(&context->mappings, &args->mapping, mapping, XA_LIMIT(1, U32_MAX),
228228 GFP_KERNEL);
drivers/gpu/host1x/fence.c+4−2
@@ -15,7 +15,7 @@ · 14 unmodified lines
1515 #include "intr.h"
1616 #include "syncpt.h"
1717
18−DEFINE_SPINLOCK(lock);
18+static DEFINE_SPINLOCK(lock);
1919
2020 struct host1x_syncpt_fence {
2121 struct dma_fence base;
@@ -152,8 +152,10 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold) · 130 unmodified lines
152152 return ERR_PTR(-ENOMEM);
153153
154154 fence->waiter = kzalloc(sizeof(*fence->waiter), GFP_KERNEL);
155− if (!fence->waiter)
155+ if (!fence->waiter) {
156+ kfree(fence);
156157 return ERR_PTR(-ENOMEM);
158+ }
157159
158160 fence->sp = sp;
159161 fence->threshold = threshold;
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c+4−4
@@ -255,13 +255,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i · 254 unmodified lines
255255 if (!privdata->cl_data)
256256 return -ENOMEM;
257257
258− rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
258+ mp2_select_ops(privdata);
259+
260+ rc = amd_sfh_hid_client_init(privdata);
259261 if (rc)
260262 return rc;
261263
262− mp2_select_ops(privdata);
263−
264− return amd_sfh_hid_client_init(privdata);
264+ return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
265265 }
266266
267267 static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
drivers/hid/hid-apple.c+7−0
@@ -336,12 +336,19 @@ static int apple_event(struct hid_device *hdev, struct hid_field *field, · 335 unmodified lines
336336
337337 /*
338338 * MacBook JIS keyboard has wrong logical maximum
339+ * Magic Keyboard JIS has wrong logical maximum
339340 */
340341 static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
341342 unsigned int *rsize)
342343 {
343344 struct apple_sc *asc = hid_get_drvdata(hdev);
344345
346+ if(*rsize >=71 && rdesc[70] == 0x65 && rdesc[64] == 0x65) {
347+ hid_info(hdev,
348+ "fixing up Magic Keyboard JIS report descriptor\n");
349+ rdesc[64] = rdesc[70] = 0xe7;
350+ }
351+
345352 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
346353 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
347354 hid_info(hdev,
drivers/hid/hid-betopff.c+10−3
@@ -56,15 +56,22 @@ static int betopff_init(struct hid_device *hid) · 55 unmodified lines
5656 {
5757 struct betopff_device *betopff;
5858 struct hid_report *report;
59− struct hid_input *hidinput =
60− list_first_entry(&hid->inputs, struct hid_input, list);
59+ struct hid_input *hidinput;
6160 struct list_head *report_list =
6261 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
63− struct input_dev *dev = hidinput->input;
62+ struct input_dev *dev;
6463 int field_count = 0;
6564 int error;
6665 int i, j;
6766
67+ if (list_empty(&hid->inputs)) {
68+ hid_err(hid, "no inputs found\n");
69+ return -ENODEV;
70+ }
71+
72+ hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
73+ dev = hidinput->input;
74+
6875 if (list_empty(report_list)) {
6976 hid_err(hid, "no output reports found\n");
7077 return -ENODEV;
drivers/hid/hid-u2fzero.c+3−1
@@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data, · 197 unmodified lines
198198 }
199199
200200 ret = u2fzero_recv(dev, &req, &resp);
201− if (ret < 0)
201+
202+ /* ignore errors or packets without data */
203+ if (ret < offsetof(struct u2f_hid_msg, init.data))
202204 return 0;
203205
204206 /* only take the minimum amount of data it is safe to take */
drivers/hid/wacom_wac.c+8−0
@@ -4746,6 +4746,12 @@ static const struct wacom_features wacom_features_0x393 = · 4745 unmodified lines
47464746 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
47474747 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
47484748 .touch_max = 10 };
4749+static const struct wacom_features wacom_features_0x3c6 =
4750+ { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4751+ INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4752+static const struct wacom_features wacom_features_0x3c8 =
4753+ { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4754+ INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
47494755
47504756 static const struct wacom_features wacom_features_HID_ANY_ID =
47514757 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
@@ -4919,6 +4925,8 @@ const struct hid_device_id wacom_ids[] = { · 167 unmodified lines
49194925 { USB_DEVICE_WACOM(0x37A) },
49204926 { USB_DEVICE_WACOM(0x37B) },
49214927 { BT_DEVICE_WACOM(0x393) },
4928+ { BT_DEVICE_WACOM(0x3c6) },
4929+ { BT_DEVICE_WACOM(0x3c8) },
49224930 { USB_DEVICE_WACOM(0x4001) },
49234931 { USB_DEVICE_WACOM(0x4004) },
49244932 { USB_DEVICE_WACOM(0x5000) },
drivers/hwmon/k10temp.c+0−6
@@ -362,12 +362,6 @@ static const struct hwmon_channel_info *k10temp_info[] = { · 361 unmodified lines
362362 HWMON_T_INPUT | HWMON_T_LABEL,
363363 HWMON_T_INPUT | HWMON_T_LABEL,
364364 HWMON_T_INPUT | HWMON_T_LABEL),
365− HWMON_CHANNEL_INFO(in,
366− HWMON_I_INPUT | HWMON_I_LABEL,
367− HWMON_I_INPUT | HWMON_I_LABEL),
368− HWMON_CHANNEL_INFO(curr,
369− HWMON_C_INPUT | HWMON_C_LABEL,
370− HWMON_C_INPUT | HWMON_C_LABEL),
371365 NULL
372366 };
373367
drivers/hwmon/ltc2947-core.c+6−2
@@ -989,8 +989,12 @@ static int ltc2947_setup(struct ltc2947_data *st) · 988 unmodified lines
989989 return ret;
990990
991991 /* check external clock presence */
992− extclk = devm_clk_get(st->dev, NULL);
993− if (!IS_ERR(extclk)) {
992+ extclk = devm_clk_get_optional(st->dev, NULL);
993+ if (IS_ERR(extclk))
994+ return dev_err_probe(st->dev, PTR_ERR(extclk),
995+ "Failed to get external clock\n");
996+
997+ if (extclk) {
994998 unsigned long rate_hz;
995999 u8 pre = 0, div, tbctl;
9961000 u64 aux;
drivers/hwmon/mlxreg-fan.c+9−3
@@ -315,8 +315,8 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev, · 314 unmodified lines
315315 {
316316 struct mlxreg_fan *fan = cdev->devdata;
317317 unsigned long cur_state;
318+ int i, config = 0;
318319 u32 regval;
319− int i;
320320 int err;
321321
322322 /*
@@ -329,6 +329,12 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev, · 6 unmodified lines
329329 * overwritten.
330330 */
331331 if (state >= MLXREG_FAN_SPEED_MIN && state <= MLXREG_FAN_SPEED_MAX) {
332+ /*
333+ * This is configuration change, which is only supported through sysfs.
334+ * For configuration non-zero value is to be returned to avoid thermal
335+ * statistics update.
336+ */
337+ config = 1;
332338 state -= MLXREG_FAN_MAX_STATE;
333339 for (i = 0; i < state; i++)
334340 fan->cooling_levels[i] = state;
@@ -343,7 +349,7 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev, · 8 unmodified lines
343349
344350 cur_state = MLXREG_FAN_PWM_DUTY2STATE(regval);
345351 if (state < cur_state)
346− return 0;
352+ return config;
347353
348354 state = cur_state;
349355 }
@@ -359,7 +365,7 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev, · 9 unmodified lines
359365 dev_err(fan->dev, "Failed to write PWM duty\n");
360366 return err;
361367 }
362− return 0;
368+ return config;
363369 }
364370
365371 static const struct thermal_cooling_device_ops mlxreg_fan_cooling_ops = {
drivers/hwmon/occ/common.c+5−12
@@ -340,18 +340,11 @@ static ssize_t occ_show_temp_10(struct device *dev, · 339 unmodified lines
340340 if (val == OCC_TEMP_SENSOR_FAULT)
341341 return -EREMOTEIO;
342342
343− /*
344− * VRM doesn't return temperature, only alarm bit. This
345− * attribute maps to tempX_alarm instead of tempX_input for
346− * VRM
347− */
348− if (temp->fru_type != OCC_FRU_TYPE_VRM) {
349− /* sensor not ready */
350− if (val == 0)
351− return -EAGAIN;
343+ /* sensor not ready */
344+ if (val == 0)
345+ return -EAGAIN;
352346
353− val *= 1000;
354− }
347+ val *= 1000;
355348 break;
356349 case 2:
357350 val = temp->fru_type;
@@ -886,7 +879,7 @@ static int occ_setup_sensor_attrs(struct occ *occ) · 528 unmodified lines
886879 0, i);
887880 attr++;
888881
889− if (sensors->temp.version > 1 &&
882+ if (sensors->temp.version == 2 &&
890883 temp->fru_type == OCC_FRU_TYPE_VRM) {
891884 snprintf(attr->name, sizeof(attr->name),
892885 "temp%d_alarm", s);
drivers/hwmon/pmbus/ibm-cffps.c+8−2
@@ -171,8 +171,14 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, · 170 unmodified lines
171171 cmd = CFFPS_SN_CMD;
172172 break;
173173 case CFFPS_DEBUGFS_MAX_POWER_OUT:
174− rc = i2c_smbus_read_word_swapped(psu->client,
175− CFFPS_MAX_POWER_OUT_CMD);
174+ if (psu->version == cffps1) {
175+ rc = i2c_smbus_read_word_swapped(psu->client,
176+ CFFPS_MAX_POWER_OUT_CMD);
177+ } else {
178+ rc = i2c_smbus_read_word_data(psu->client,
179+ CFFPS_MAX_POWER_OUT_CMD);
180+ }
181+
176182 if (rc < 0)
177183 return rc;
178184
drivers/hwmon/pmbus/mp2975.c+1−1
@@ -54,7 +54,7 @@ · 53 unmodified lines
5454
5555 #define MP2975_RAIL2_FUNC (PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \
5656 PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \
57− PMBUS_PHASE_VIRTUAL)
57+ PMBUS_HAVE_POUT | PMBUS_PHASE_VIRTUAL)
5858
5959 struct mp2975_data {
6060 struct pmbus_driver_info info;
drivers/hwmon/tmp421.c+39−32
@@ -100,71 +100,81 @@ struct tmp421_data { · 99 unmodified lines
100100 s16 temp[4];
101101 };
102102
103−static int temp_from_s16(s16 reg)
103+static int temp_from_raw(u16 reg, bool extended)
104104 {
105105 /* Mask out status bits */
106106 int temp = reg & ~0xf;
107107
108− return (temp * 1000 + 128) / 256;
109−}
110−
111−static int temp_from_u16(u16 reg)
112−{
113− /* Mask out status bits */
114− int temp = reg & ~0xf;
115−
116− /* Add offset for extended temperature range. */
117− temp -= 64 * 256;
108+ if (extended)
109+ temp = temp - 64 * 256;
110+ else
111+ temp = (s16)temp;
118112
119− return (temp * 1000 + 128) / 256;
113+ return DIV_ROUND_CLOSEST(temp * 1000, 256);
120114 }
121115
122−static struct tmp421_data *tmp421_update_device(struct device *dev)
116+static int tmp421_update_device(struct tmp421_data *data)
123117 {
124− struct tmp421_data *data = dev_get_drvdata(dev);
125118 struct i2c_client *client = data->client;
119+ int ret = 0;
126120 int i;
127121
128122 mutex_lock(&data->update_lock);
129123
130124 if (time_after(jiffies, data->last_updated + (HZ / 2)) ||
131125 !data->valid) {
132− data->config = i2c_smbus_read_byte_data(client,
133− TMP421_CONFIG_REG_1);
126+ ret = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1);
127+ if (ret < 0)
128+ goto exit;
129+ data->config = ret;
134130
135131 for (i = 0; i < data->channels; i++) {
136− data->temp[i] = i2c_smbus_read_byte_data(client,
137− TMP421_TEMP_MSB[i]) << 8;
138− data->temp[i] |= i2c_smbus_read_byte_data(client,
139− TMP421_TEMP_LSB[i]);
132+ ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]);
133+ if (ret < 0)
134+ goto exit;
135+ data->temp[i] = ret << 8;
136+
137+ ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]);
138+ if (ret < 0)
139+ goto exit;
140+ data->temp[i] |= ret;
140141 }
141142 data->last_updated = jiffies;
142143 data->valid = 1;
143144 }
144145
146+exit:
145147 mutex_unlock(&data->update_lock);
146148
147− return data;
149+ if (ret < 0) {
150+ data->valid = 0;
151+ return ret;
152+ }
153+
154+ return 0;
148155 }
149156
150157 static int tmp421_read(struct device *dev, enum hwmon_sensor_types type,
151158 u32 attr, int channel, long *val)
152159 {
153− struct tmp421_data *tmp421 = tmp421_update_device(dev);
160+ struct tmp421_data *tmp421 = dev_get_drvdata(dev);
161+ int ret = 0;
162+
163+ ret = tmp421_update_device(tmp421);
164+ if (ret)
165+ return ret;
154166
155167 switch (attr) {
156168 case hwmon_temp_input:
157− if (tmp421->config & TMP421_CONFIG_RANGE)
158− *val = temp_from_u16(tmp421->temp[channel]);
159− else
160− *val = temp_from_s16(tmp421->temp[channel]);
169+ *val = temp_from_raw(tmp421->temp[channel],
170+ tmp421->config & TMP421_CONFIG_RANGE);
161171 return 0;
162172 case hwmon_temp_fault:
163173 /*
164− * The OPEN bit signals a fault. This is bit 0 of the temperature
165− * register (low byte).
174+ * Any of OPEN or /PVLD bits indicate a hardware mulfunction
175+ * and the conversion result may be incorrect
166176 */
167− *val = tmp421->temp[channel] & 0x01;
177+ *val = !!(tmp421->temp[channel] & 0x03);
168178 return 0;
169179 default:
170180 return -EOPNOTSUPP;
@@ -177,9 +187,6 @@ static umode_t tmp421_is_visible(const void *data, enum hwmon_sensor_types type, · 6 unmodified lines
177187 {
178188 switch (attr) {
179189 case hwmon_temp_fault:
180− if (channel == 0)
181− return 0;
182− return 0444;
183190 case hwmon_temp_input:
184191 return 0444;
185192 default:
drivers/hwmon/w83791d.c+11−18
@@ -273,9 +273,6 @@ struct w83791d_data { · 272 unmodified lines
273273 char valid; /* !=0 if following fields are valid */
274274 unsigned long last_updated; /* In jiffies */
275275
276− /* array of 2 pointers to subclients */
277− struct i2c_client *lm75[2];
278−
279276 /* volts */
280277 u8 in[NUMBER_OF_VIN]; /* Register value */
281278 u8 in_max[NUMBER_OF_VIN]; /* Register value */
@@ -1257,7 +1254,6 @@ static const struct attribute_group w83791d_group_fanpwm45 = { · 975 unmodified lines
12571254 static int w83791d_detect_subclients(struct i2c_client *client)
12581255 {
12591256 struct i2c_adapter *adapter = client->adapter;
1260− struct w83791d_data *data = i2c_get_clientdata(client);
12611257 int address = client->addr;
12621258 int i, id;
12631259 u8 val;
@@ -1280,22 +1276,19 @@ static int w83791d_detect_subclients(struct i2c_client *client) · 16 unmodified lines
12801276 }
12811277
12821278 val = w83791d_read(client, W83791D_REG_I2C_SUBADDR);
1283− if (!(val & 0x08))
1284− data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
1285− 0x48 + (val & 0x7));
1286− if (!(val & 0x80)) {
1287− if (!IS_ERR(data->lm75[0]) &&
1288− ((val & 0x7) == ((val >> 4) & 0x7))) {
1289− dev_err(&client->dev,
1290− "duplicate addresses 0x%x, "
1291− "use force_subclient\n",
1292− data->lm75[0]->addr);
1293− return -ENODEV;
1294− }
1295− data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
1296− 0x48 + ((val >> 4) & 0x7));
1279+
1280+ if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) {
1281+ dev_err(&client->dev,
1282+ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7));
1283+ return -ENODEV;
12971284 }
12981285
1286+ if (!(val & 0x08))
1287+ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (val & 0x7));
1288+
1289+ if (!(val & 0x80))
1290+ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((val >> 4) & 0x7));
1291+
12991292 return 0;
13001293 }
13011294
drivers/hwmon/w83792d.c+11−17
@@ -264,9 +264,6 @@ struct w83792d_data { · 263 unmodified lines
264264 char valid; /* !=0 if following fields are valid */
265265 unsigned long last_updated; /* In jiffies */
266266
267− /* array of 2 pointers to subclients */
268− struct i2c_client *lm75[2];
269−
270267 u8 in[9]; /* Register value */
271268 u8 in_max[9]; /* Register value */
272269 u8 in_min[9]; /* Register value */
@@ -927,7 +924,6 @@ w83792d_detect_subclients(struct i2c_client *new_client) · 654 unmodified lines
927924 int address = new_client->addr;
928925 u8 val;
929926 struct i2c_adapter *adapter = new_client->adapter;
930− struct w83792d_data *data = i2c_get_clientdata(new_client);
931927
932928 id = i2c_adapter_id(adapter);
933929 if (force_subclients[0] == id && force_subclients[1] == address) {
@@ -946,21 +942,19 @@ w83792d_detect_subclients(struct i2c_client *new_client) · 12 unmodified lines
946942 }
947943
948944 val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
949− if (!(val & 0x08))
950− data->lm75[0] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
951− 0x48 + (val & 0x7));
952− if (!(val & 0x80)) {
953− if (!IS_ERR(data->lm75[0]) &&
954− ((val & 0x7) == ((val >> 4) & 0x7))) {
955− dev_err(&new_client->dev,
956− "duplicate addresses 0x%x, use force_subclient\n",
957− data->lm75[0]->addr);
958− return -ENODEV;
959− }
960− data->lm75[1] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
961− 0x48 + ((val >> 4) & 0x7));
945+
946+ if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) {
947+ dev_err(&new_client->dev,
948+ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7));
949+ return -ENODEV;
962950 }
963951
952+ if (!(val & 0x08))
953+ devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + (val & 0x7));
954+
955+ if (!(val & 0x80))
956+ devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + ((val >> 4) & 0x7));
957+
964958 return 0;
965959 }
966960
drivers/hwmon/w83793.c+11−15
@@ -202,7 +202,6 @@ static inline s8 TEMP_TO_REG(long val, s8 min, s8 max) · 201 unmodified lines
202202 }
203203
204204 struct w83793_data {
205− struct i2c_client *lm75[2];
206205 struct device *hwmon_dev;
207206 struct mutex update_lock;
208207 char valid; /* !=0 if following fields are valid */
@@ -1566,7 +1565,6 @@ w83793_detect_subclients(struct i2c_client *client) · 1357 unmodified lines
15661565 int address = client->addr;
15671566 u8 tmp;
15681567 struct i2c_adapter *adapter = client->adapter;
1569− struct w83793_data *data = i2c_get_clientdata(client);
15701568
15711569 id = i2c_adapter_id(adapter);
15721570 if (force_subclients[0] == id && force_subclients[1] == address) {
@@ -1586,21 +1584,19 @@ w83793_detect_subclients(struct i2c_client *client) · 13 unmodified lines
15861584 }
15871585
15881586 tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR);
1589− if (!(tmp & 0x08))
1590− data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
1591− 0x48 + (tmp & 0x7));
1592− if (!(tmp & 0x80)) {
1593− if (!IS_ERR(data->lm75[0])
1594− && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) {
1595− dev_err(&client->dev,
1596− "duplicate addresses 0x%x, "
1597− "use force_subclients\n", data->lm75[0]->addr);
1598− return -ENODEV;
1599− }
1600− data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
1601− 0x48 + ((tmp >> 4) & 0x7));
1587+
1588+ if (!(tmp & 0x88) && (tmp & 0x7) == ((tmp >> 4) & 0x7)) {
1589+ dev_err(&client->dev,
1590+ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (tmp & 0x7));
1591+ return -ENODEV;
16021592 }
16031593
1594+ if (!(tmp & 0x08))
1595+ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (tmp & 0x7));
1596+
1597+ if (!(tmp & 0x80))
1598+ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((tmp >> 4) & 0x7));
1599+
16041600 return 0;
16051601 }
16061602
drivers/infiniband/core/cma.c+45−6
@@ -1746,15 +1746,16 @@ static void cma_cancel_route(struct rdma_id_private *id_priv) · 1745 unmodified lines
17461746 }
17471747 }
17481748
1749−static void cma_cancel_listens(struct rdma_id_private *id_priv)
1749+static void _cma_cancel_listens(struct rdma_id_private *id_priv)
17501750 {
17511751 struct rdma_id_private *dev_id_priv;
17521752
1753+ lockdep_assert_held(&lock);
1754+
17531755 /*
17541756 * Remove from listen_any_list to prevent added devices from spawning
17551757 * additional listen requests.
17561758 */
1757− mutex_lock(&lock);
17581759 list_del(&id_priv->list);
17591760
17601761 while (!list_empty(&id_priv->listen_list)) {
@@ -1768,6 +1769,12 @@ static void cma_cancel_listens(struct rdma_id_private *id_priv) · 7 unmodified lines
17681769 rdma_destroy_id(&dev_id_priv->id);
17691770 mutex_lock(&lock);
17701771 }
1772+}
1773+
1774+static void cma_cancel_listens(struct rdma_id_private *id_priv)
1775+{
1776+ mutex_lock(&lock);
1777+ _cma_cancel_listens(id_priv);
17711778 mutex_unlock(&lock);
17721779 }
17731780
@@ -1776,6 +1783,14 @@ static void cma_cancel_operation(struct rdma_id_private *id_priv, · 2 unmodified lines
17761783 {
17771784 switch (state) {
17781785 case RDMA_CM_ADDR_QUERY:
1786+ /*
1787+ * We can avoid doing the rdma_addr_cancel() based on state,
1788+ * only RDMA_CM_ADDR_QUERY has a work that could still execute.
1789+ * Notice that the addr_handler work could still be exiting
1790+ * outside this state, however due to the interaction with the
1791+ * handler_mutex the work is guaranteed not to touch id_priv
1792+ * during exit.
1793+ */
17791794 rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
17801795 break;
17811796 case RDMA_CM_ROUTE_QUERY:
@@ -1810,6 +1825,8 @@ static void cma_release_port(struct rdma_id_private *id_priv) · 28 unmodified lines
18101825 static void destroy_mc(struct rdma_id_private *id_priv,
18111826 struct cma_multicast *mc)
18121827 {
1828+ bool send_only = mc->join_state == BIT(SENDONLY_FULLMEMBER_JOIN);
1829+
18131830 if (rdma_cap_ib_mcast(id_priv->id.device, id_priv->id.port_num))
18141831 ib_sa_free_multicast(mc->sa_mc);
18151832
@@ -1826,7 +1843,10 @@ static void destroy_mc(struct rdma_id_private *id_priv, · 10 unmodified lines
18261843
18271844 cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr,
18281845 &mgid);
1829− cma_igmp_send(ndev, &mgid, false);
1846+
1847+ if (!send_only)
1848+ cma_igmp_send(ndev, &mgid, false);
1849+
18301850 dev_put(ndev);
18311851 }
18321852
@@ -2574,7 +2594,7 @@ static int cma_listen_on_all(struct rdma_id_private *id_priv) · 741 unmodified lines
25742594 return 0;
25752595
25762596 err_listen:
2577− list_del(&id_priv->list);
2597+ _cma_cancel_listens(id_priv);
25782598 mutex_unlock(&lock);
25792599 if (to_destroy)
25802600 rdma_destroy_id(&to_destroy->id);
@@ -3413,6 +3433,21 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, · 832 unmodified lines
34133433 if (dst_addr->sa_family == AF_IB) {
34143434 ret = cma_resolve_ib_addr(id_priv);
34153435 } else {
3436+ /*
3437+ * The FSM can return back to RDMA_CM_ADDR_BOUND after
3438+ * rdma_resolve_ip() is called, eg through the error
3439+ * path in addr_handler(). If this happens the existing
3440+ * request must be canceled before issuing a new one.
3441+ * Since canceling a request is a bit slow and this
3442+ * oddball path is rare, keep track once a request has
3443+ * been issued. The track turns out to be a permanent
3444+ * state since this is the only cancel as it is
3445+ * immediately before rdma_resolve_ip().
3446+ */
3447+ if (id_priv->used_resolve_ip)
3448+ rdma_addr_cancel(&id->route.addr.dev_addr);
3449+ else
3450+ id_priv->used_resolve_ip = 1;
34163451 ret = rdma_resolve_ip(cma_src_addr(id_priv), dst_addr,
34173452 &id->route.addr.dev_addr,
34183453 timeout_ms, addr_handler,
@@ -3771,9 +3806,13 @@ int rdma_listen(struct rdma_cm_id *id, int backlog) · 352 unmodified lines
37713806 int ret;
37723807
37733808 if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN)) {
3809+ struct sockaddr_in any_in = {
3810+ .sin_family = AF_INET,
3811+ .sin_addr.s_addr = htonl(INADDR_ANY),
3812+ };
3813+
37743814 /* For a well behaved ULP state will be RDMA_CM_IDLE */
3775− id->route.addr.src_addr.ss_family = AF_INET;
3776− ret = rdma_bind_addr(id, cma_src_addr(id_priv));
3815+ ret = rdma_bind_addr(id, (struct sockaddr *)&any_in);
37773816 if (ret)
37783817 return ret;
37793818 if (WARN_ON(!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND,
drivers/infiniband/core/cma_priv.h+1−0
@@ -91,6 +91,7 @@ struct rdma_id_private { · 90 unmodified lines
9191 u8 afonly;
9292 u8 timeout;
9393 u8 min_rnr_timer;
94+ u8 used_resolve_ip;
9495 enum ib_gid_type gid_type;
9596
9697 /*
drivers/infiniband/hw/hfi1/ipoib_tx.c+4−4
@@ -876,14 +876,14 @@ void hfi1_ipoib_tx_timeout(struct net_device *dev, unsigned int q) · 875 unmodified lines
876876 struct hfi1_ipoib_txq *txq = &priv->txqs[q];
877877 u64 completed = atomic64_read(&txq->complete_txreqs);
878878
879− dd_dev_info(priv->dd, "timeout txq %llx q %u stopped %u stops %d no_desc %d ring_full %d\n",
880− (unsigned long long)txq, q,
879+ dd_dev_info(priv->dd, "timeout txq %p q %u stopped %u stops %d no_desc %d ring_full %d\n",
880+ txq, q,
881881 __netif_subqueue_stopped(dev, txq->q_idx),
882882 atomic_read(&txq->stops),
883883 atomic_read(&txq->no_desc),
884884 atomic_read(&txq->ring_full));
885− dd_dev_info(priv->dd, "sde %llx engine %u\n",
886− (unsigned long long)txq->sde,
885+ dd_dev_info(priv->dd, "sde %p engine %u\n",
886+ txq->sde,
887887 txq->sde ? txq->sde->this_idx : 0);
888888 dd_dev_info(priv->dd, "flow %x\n", txq->flow.as_int);
889889 dd_dev_info(priv->dd, "sent %llu completed %llu used %llu\n",
drivers/infiniband/hw/hns/hns_roce_cq.c+22−9
@@ -326,19 +326,30 @@ static void set_cq_param(struct hns_roce_cq *hr_cq, u32 cq_entries, int vector, · 325 unmodified lines
326326 INIT_LIST_HEAD(&hr_cq->rq_list);
327327 }
328328
329−static void set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata,
330− struct hns_roce_ib_create_cq *ucmd)
329+static int set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata,
330+ struct hns_roce_ib_create_cq *ucmd)
331331 {
332332 struct hns_roce_dev *hr_dev = to_hr_dev(hr_cq->ib_cq.device);
333333
334− if (udata) {
335− if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size))
336− hr_cq->cqe_size = ucmd->cqe_size;
337− else
338− hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE;
339− } else {
334+ if (!udata) {
340335 hr_cq->cqe_size = hr_dev->caps.cqe_sz;
336+ return 0;
337+ }
338+
339+ if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size)) {
340+ if (ucmd->cqe_size != HNS_ROCE_V2_CQE_SIZE &&
341+ ucmd->cqe_size != HNS_ROCE_V3_CQE_SIZE) {
342+ ibdev_err(&hr_dev->ib_dev,
343+ "invalid cqe size %u.\n", ucmd->cqe_size);
344+ return -EINVAL;
345+ }
346+
347+ hr_cq->cqe_size = ucmd->cqe_size;
348+ } else {
349+ hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE;
341350 }
351+
352+ return 0;
342353 }
343354
344355 int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
@@ -366,7 +377,9 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr, · 21 unmodified lines
366377
367378 set_cq_param(hr_cq, attr->cqe, attr->comp_vector, &ucmd);
368379
369− set_cqe_size(hr_cq, udata, &ucmd);
380+ ret = set_cqe_size(hr_cq, udata, &ucmd);
381+ if (ret)
382+ return ret;
370383
371384 ret = alloc_cq_buf(hr_dev, hr_cq, udata, ucmd.buf_addr);
372385 if (ret) {
drivers/infiniband/hw/hns/hns_roce_hw_v2.c+7−6
@@ -3299,7 +3299,7 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn, · 3298 unmodified lines
32993299 dest = get_cqe_v2(hr_cq, (prod_index + nfreed) &
33003300 hr_cq->ib_cq.cqe);
33013301 owner_bit = hr_reg_read(dest, CQE_OWNER);
3302− memcpy(dest, cqe, sizeof(*cqe));
3302+ memcpy(dest, cqe, hr_cq->cqe_size);
33033303 hr_reg_write(dest, CQE_OWNER, owner_bit);
33043304 }
33053305 }
@@ -4397,7 +4397,12 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, · 1091 unmodified lines
43974397 hr_qp->path_mtu = ib_mtu;
43984398
43994399 mtu = ib_mtu_enum_to_int(ib_mtu);
4400− if (WARN_ON(mtu < 0))
4400+ if (WARN_ON(mtu <= 0))
4401+ return -EINVAL;
4402+#define MAX_LP_MSG_LEN 65536
4403+ /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */
4404+ lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu);
4405+ if (WARN_ON(lp_pktn_ini >= 0xF))
44014406 return -EINVAL;
44024407
44034408 if (attr_mask & IB_QP_PATH_MTU) {
@@ -4405,10 +4410,6 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, · 1 unmodified line
44054410 hr_reg_clear(qpc_mask, QPC_MTU);
44064411 }
44074412
4408−#define MAX_LP_MSG_LEN 65536
4409− /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */
4410− lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu);
4411−
44124413 hr_reg_write(context, QPC_LP_PKTN_INI, lp_pktn_ini);
44134414 hr_reg_clear(qpc_mask, QPC_LP_PKTN_INI);
44144415
drivers/infiniband/hw/irdma/cm.c+2−2
@@ -3496,7 +3496,7 @@ static void irdma_cm_disconn_true(struct irdma_qp *iwqp) · 3495 unmodified lines
34963496 original_hw_tcp_state == IRDMA_TCP_STATE_TIME_WAIT ||
34973497 last_ae == IRDMA_AE_RDMAP_ROE_BAD_LLP_CLOSE ||
34983498 last_ae == IRDMA_AE_BAD_CLOSE ||
3499− last_ae == IRDMA_AE_LLP_CONNECTION_RESET || iwdev->reset)) {
3499+ last_ae == IRDMA_AE_LLP_CONNECTION_RESET || iwdev->rf->reset)) {
35003500 issue_close = 1;
35013501 iwqp->cm_id = NULL;
35023502 qp->term_flags = 0;
@@ -4250,7 +4250,7 @@ void irdma_cm_teardown_connections(struct irdma_device *iwdev, u32 *ipaddr, · 747 unmodified lines
42504250 teardown_entry);
42514251 attr.qp_state = IB_QPS_ERR;
42524252 irdma_modify_qp(&cm_node->iwqp->ibqp, &attr, IB_QP_STATE, NULL);
4253− if (iwdev->reset)
4253+ if (iwdev->rf->reset)
42544254 irdma_cm_disconn(cm_node->iwqp);
42554255 irdma_rem_ref_cm_node(cm_node);
42564256 }
drivers/infiniband/hw/irdma/hw.c+11−3
@@ -176,6 +176,14 @@ static void irdma_set_flush_fields(struct irdma_sc_qp *qp, · 175 unmodified lines
176176 case IRDMA_AE_LLP_RECEIVED_MPA_CRC_ERROR:
177177 qp->flush_code = FLUSH_GENERAL_ERR;
178178 break;
179+ case IRDMA_AE_LLP_TOO_MANY_RETRIES:
180+ qp->flush_code = FLUSH_RETRY_EXC_ERR;
181+ break;
182+ case IRDMA_AE_AMP_MWBIND_INVALID_RIGHTS:
183+ case IRDMA_AE_AMP_MWBIND_BIND_DISABLED:
184+ case IRDMA_AE_AMP_MWBIND_INVALID_BOUNDS:
185+ qp->flush_code = FLUSH_MW_BIND_ERR;
186+ break;
179187 default:
180188 qp->flush_code = FLUSH_FATAL_ERR;
181189 break;
@@ -1489,7 +1497,7 @@ void irdma_reinitialize_ieq(struct irdma_sc_vsi *vsi) · 1307 unmodified lines
14891497
14901498 irdma_puda_dele_rsrc(vsi, IRDMA_PUDA_RSRC_TYPE_IEQ, false);
14911499 if (irdma_initialize_ieq(iwdev)) {
1492− iwdev->reset = true;
1500+ iwdev->rf->reset = true;
14931501 rf->gen_ops.request_reset(rf);
14941502 }
14951503 }
@@ -1632,13 +1640,13 @@ void irdma_rt_deinit_hw(struct irdma_device *iwdev) · 136 unmodified lines
16321640 case IEQ_CREATED:
16331641 if (!iwdev->roce_mode)
16341642 irdma_puda_dele_rsrc(&iwdev->vsi, IRDMA_PUDA_RSRC_TYPE_IEQ,
1635− iwdev->reset);
1643+ iwdev->rf->reset);
16361644 fallthrough;
16371645 case ILQ_CREATED:
16381646 if (!iwdev->roce_mode)
16391647 irdma_puda_dele_rsrc(&iwdev->vsi,
16401648 IRDMA_PUDA_RSRC_TYPE_ILQ,
1641− iwdev->reset);
1649+ iwdev->rf->reset);
16421650 break;
16431651 default:
16441652 ibdev_warn(&iwdev->ibdev, "bad init_state = %d\n", iwdev->init_state);
drivers/infiniband/hw/irdma/i40iw_if.c+1−1
@@ -55,7 +55,7 @@ static void i40iw_close(struct i40e_info *cdev_info, struct i40e_client *client, · 54 unmodified lines
5555
5656 iwdev = to_iwdev(ibdev);
5757 if (reset)
58− iwdev->reset = true;
58+ iwdev->rf->reset = true;
5959
6060 iwdev->iw_status = 0;
6161 irdma_port_ibevent(iwdev);
drivers/infiniband/hw/irdma/main.h+0−1
@@ -346,7 +346,6 @@ struct irdma_device { · 345 unmodified lines
346346 bool roce_mode:1;
347347 bool roce_dcqcn_en:1;
348348 bool dcb:1;
349− bool reset:1;
350349 bool iw_ooo:1;
351350 enum init_completion_state init_state;
352351
drivers/infiniband/hw/irdma/user.h+2−0
@@ -102,6 +102,8 @@ enum irdma_flush_opcode { · 101 unmodified lines
102102 FLUSH_REM_OP_ERR,
103103 FLUSH_LOC_LEN_ERR,
104104 FLUSH_FATAL_ERR,
105+ FLUSH_RETRY_EXC_ERR,
106+ FLUSH_MW_BIND_ERR,
105107 };
106108
107109 enum irdma_cmpl_status {
drivers/infiniband/hw/irdma/utils.c+1−1
@@ -2507,7 +2507,7 @@ void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp) · 2506 unmodified lines
25072507 struct irdma_qp *qp = sc_qp->qp_uk.back_qp;
25082508 struct ib_qp_attr attr;
25092509
2510− if (qp->iwdev->reset)
2510+ if (qp->iwdev->rf->reset)
25112511 return;
25122512 attr.qp_state = IB_QPS_ERR;
25132513
drivers/infiniband/hw/irdma/verbs.c+6−3
@@ -535,8 +535,7 @@ static int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) · 534 unmodified lines
535535 irdma_qp_rem_ref(&iwqp->ibqp);
536536 wait_for_completion(&iwqp->free_qp);
537537 irdma_free_lsmm_rsrc(iwqp);
538− if (!iwdev->reset)
539− irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp);
538+ irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp);
540539
541540 if (!iwqp->user_mode) {
542541 if (iwqp->iwscq) {
@@ -2035,7 +2034,7 @@ static int irdma_create_cq(struct ib_cq *ibcq, · 1492 unmodified lines
20352034 /* Kmode allocations */
20362035 int rsize;
20372036
2038− if (entries > rf->max_cqe) {
2037+ if (entries < 1 || entries > rf->max_cqe) {
20392038 err_code = -EINVAL;
20402039 goto cq_free_rsrc;
20412040 }
@@ -3353,6 +3352,10 @@ static enum ib_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcode · 1311 unmodified lines
33533352 return IB_WC_LOC_LEN_ERR;
33543353 case FLUSH_GENERAL_ERR:
33553354 return IB_WC_WR_FLUSH_ERR;
3355+ case FLUSH_RETRY_EXC_ERR:
3356+ return IB_WC_RETRY_EXC_ERR;
3357+ case FLUSH_MW_BIND_ERR:
3358+ return IB_WC_MW_BIND_ERR;
33563359 case FLUSH_FATAL_ERR:
33573360 default:
33583361 return IB_WC_FATAL_ERR;
drivers/infiniband/hw/qib/qib_sysfs.c+1−1
@@ -403,7 +403,7 @@ static ssize_t diagc_attr_store(struct ib_device *ibdev, u32 port_num, · 402 unmodified lines
403403 }
404404
405405 #define QIB_DIAGC_ATTR(N) \
406− static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \
406+ static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \
407407 static struct qib_diagc_attr qib_diagc_attr_##N = { \
408408 .attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \
409409 .counter = \
drivers/infiniband/hw/usnic/usnic_ib.h+1−1
@@ -90,7 +90,7 @@ struct usnic_ib_dev { · 89 unmodified lines
9090
9191 struct usnic_ib_vf {
9292 struct usnic_ib_dev *pf;
93− spinlock_t lock;
93+ struct mutex lock;
9494 struct usnic_vnic *vnic;
9595 unsigned int qp_grp_ref_cnt;
9696 struct usnic_ib_pd *pd;
drivers/infiniband/hw/usnic/usnic_ib_main.c+1−1
@@ -572,7 +572,7 @@ static int usnic_ib_pci_probe(struct pci_dev *pdev, · 571 unmodified lines
572572 }
573573
574574 vf->pf = pf;
575− spin_lock_init(&vf->lock);
575+ mutex_init(&vf->lock);
576576 mutex_lock(&pf->usdev_lock);
577577 list_add_tail(&vf->link, &pf->vf_dev_list);
578578 /*
drivers/infiniband/hw/usnic/usnic_ib_verbs.c+8−8
@@ -196,7 +196,7 @@ find_free_vf_and_create_qp_grp(struct ib_qp *qp, · 195 unmodified lines
196196 for (i = 0; dev_list[i]; i++) {
197197 dev = dev_list[i];
198198 vf = dev_get_drvdata(dev);
199− spin_lock(&vf->lock);
199+ mutex_lock(&vf->lock);
200200 vnic = vf->vnic;
201201 if (!usnic_vnic_check_room(vnic, res_spec)) {
202202 usnic_dbg("Found used vnic %s from %s\n",
@@ -208,10 +208,10 @@ find_free_vf_and_create_qp_grp(struct ib_qp *qp, · 5 unmodified lines
208208 vf, pd, res_spec,
209209 trans_spec);
210210
211− spin_unlock(&vf->lock);
211+ mutex_unlock(&vf->lock);
212212 goto qp_grp_check;
213213 }
214− spin_unlock(&vf->lock);
214+ mutex_unlock(&vf->lock);
215215
216216 }
217217 usnic_uiom_free_dev_list(dev_list);
@@ -220,7 +220,7 @@ find_free_vf_and_create_qp_grp(struct ib_qp *qp, · 2 unmodified lines
220220
221221 /* Try to find resources on an unused vf */
222222 list_for_each_entry(vf, &us_ibdev->vf_dev_list, link) {
223− spin_lock(&vf->lock);
223+ mutex_lock(&vf->lock);
224224 vnic = vf->vnic;
225225 if (vf->qp_grp_ref_cnt == 0 &&
226226 usnic_vnic_check_room(vnic, res_spec) == 0) {
@@ -228,10 +228,10 @@ find_free_vf_and_create_qp_grp(struct ib_qp *qp, · 1 unmodified line
228228 vf, pd, res_spec,
229229 trans_spec);
230230
231− spin_unlock(&vf->lock);
231+ mutex_unlock(&vf->lock);
232232 goto qp_grp_check;
233233 }
234− spin_unlock(&vf->lock);
234+ mutex_unlock(&vf->lock);
235235 }
236236
237237 usnic_info("No free qp grp found on %s\n",
@@ -253,9 +253,9 @@ static void qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp) · 15 unmodified lines
253253
254254 WARN_ON(qp_grp->state != IB_QPS_RESET);
255255
256− spin_lock(&vf->lock);
256+ mutex_lock(&vf->lock);
257257 usnic_ib_qp_grp_destroy(qp_grp);
258− spin_unlock(&vf->lock);
258+ mutex_unlock(&vf->lock);
259259 }
260260
261261 static int create_qp_validate_user_data(struct usnic_ib_create_qp_cmd cmd)
drivers/interconnect/qcom/sdm660.c+19−6
@@ -44,9 +44,9 @@ · 43 unmodified lines
4444 #define NOC_PERM_MODE_BYPASS (1 << NOC_QOS_MODE_BYPASS)
4545
4646 #define NOC_QOS_PRIORITYn_ADDR(n) (0x8 + (n * 0x1000))
47−#define NOC_QOS_PRIORITY_MASK 0xf
47+#define NOC_QOS_PRIORITY_P1_MASK 0xc
48+#define NOC_QOS_PRIORITY_P0_MASK 0x3
4849 #define NOC_QOS_PRIORITY_P1_SHIFT 0x2
49−#define NOC_QOS_PRIORITY_P0_SHIFT 0x3
5050
5151 #define NOC_QOS_MODEn_ADDR(n) (0xc + (n * 0x1000))
5252 #define NOC_QOS_MODEn_MASK 0x3
@@ -173,6 +173,16 @@ static const struct clk_bulk_data bus_mm_clocks[] = { · 120 unmodified lines
173173 { .id = "iface" },
174174 };
175175
176+static const struct clk_bulk_data bus_a2noc_clocks[] = {
177+ { .id = "bus" },
178+ { .id = "bus_a" },
179+ { .id = "ipa" },
180+ { .id = "ufs_axi" },
181+ { .id = "aggre2_ufs_axi" },
182+ { .id = "aggre2_usb3_axi" },
183+ { .id = "cfg_noc_usb2_axi" },
184+};
185+
176186 /**
177187 * struct qcom_icc_provider - Qualcomm specific interconnect provider
178188 * @provider: generic interconnect provider
@@ -307,7 +317,7 @@ DEFINE_QNODE(slv_bimc_cfg, SDM660_SLAVE_BIMC_CFG, 4, -1, 56, true, -1, 0, -1, 0) · 128 unmodified lines
307317 DEFINE_QNODE(slv_prng, SDM660_SLAVE_PRNG, 4, -1, 44, true, -1, 0, -1, 0);
308318 DEFINE_QNODE(slv_spdm, SDM660_SLAVE_SPDM, 4, -1, 60, true, -1, 0, -1, 0);
309319 DEFINE_QNODE(slv_qdss_cfg, SDM660_SLAVE_QDSS_CFG, 4, -1, 63, true, -1, 0, -1, 0);
310−DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_BLSP_1, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG);
320+DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_CNOC_MNOC_CFG, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG);
311321 DEFINE_QNODE(slv_snoc_cfg, SDM660_SLAVE_SNOC_CFG, 4, -1, 70, true, -1, 0, -1, 0);
312322 DEFINE_QNODE(slv_qm_cfg, SDM660_SLAVE_QM_CFG, 4, -1, 212, true, -1, 0, -1, 0);
313323 DEFINE_QNODE(slv_clk_ctl, SDM660_SLAVE_CLK_CTL, 4, -1, 47, true, -1, 0, -1, 0);
@@ -624,13 +634,12 @@ static int qcom_icc_noc_set_qos_priority(struct regmap *rmap, · 310 unmodified lines
624634 /* Must be updated one at a time, P1 first, P0 last */
625635 val = qos->areq_prio << NOC_QOS_PRIORITY_P1_SHIFT;
626636 rc = regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port),
627− NOC_QOS_PRIORITY_MASK, val);
637+ NOC_QOS_PRIORITY_P1_MASK, val);
628638 if (rc)
629639 return rc;
630640
631− val = qos->prio_level << NOC_QOS_PRIORITY_P0_SHIFT;
632641 return regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port),
633− NOC_QOS_PRIORITY_MASK, val);
642+ NOC_QOS_PRIORITY_P0_MASK, qos->prio_level);
634643 }
635644
636645 static int qcom_icc_set_noc_qos(struct icc_node *src, u64 max_bw)
@@ -810,6 +819,10 @@ static int qnoc_probe(struct platform_device *pdev) · 173 unmodified lines
810819 qp->bus_clks = devm_kmemdup(dev, bus_mm_clocks,
811820 sizeof(bus_mm_clocks), GFP_KERNEL);
812821 qp->num_clks = ARRAY_SIZE(bus_mm_clocks);
822+ } else if (of_device_is_compatible(dev->of_node, "qcom,sdm660-a2noc")) {
823+ qp->bus_clks = devm_kmemdup(dev, bus_a2noc_clocks,
824+ sizeof(bus_a2noc_clocks), GFP_KERNEL);
825+ qp->num_clks = ARRAY_SIZE(bus_a2noc_clocks);
813826 } else {
814827 if (of_device_is_compatible(dev->of_node, "qcom,sdm660-bimc"))
815828 qp->is_bimc_node = true;
drivers/iommu/apple-dart.c+35−21
@@ -183,7 +183,6 @@ struct apple_dart_master_cfg { · 182 unmodified lines
183183
184184 static struct platform_driver apple_dart_driver;
185185 static const struct iommu_ops apple_dart_iommu_ops;
186−static const struct iommu_flush_ops apple_dart_tlb_ops;
187186
188187 static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom)
189188 {
@@ -338,22 +337,6 @@ static void apple_dart_iotlb_sync_map(struct iommu_domain *domain, · 148 unmodified lines
338337 apple_dart_domain_flush_tlb(to_dart_domain(domain));
339338 }
340339
341−static void apple_dart_tlb_flush_all(void *cookie)
342−{
343− apple_dart_domain_flush_tlb(cookie);
344−}
345−
346−static void apple_dart_tlb_flush_walk(unsigned long iova, size_t size,
347− size_t granule, void *cookie)
348−{
349− apple_dart_domain_flush_tlb(cookie);
350−}
351−
352−static const struct iommu_flush_ops apple_dart_tlb_ops = {
353− .tlb_flush_all = apple_dart_tlb_flush_all,
354− .tlb_flush_walk = apple_dart_tlb_flush_walk,
355−};
356−
357340 static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain,
358341 dma_addr_t iova)
359342 {
@@ -435,7 +418,6 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain, · 75 unmodified lines
435418 .ias = 32,
436419 .oas = 36,
437420 .coherent_walk = 1,
438− .tlb = &apple_dart_tlb_ops,
439421 .iommu_dev = dart->dev,
440422 };
441423
@@ -661,16 +643,34 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args) · 219 unmodified lines
661643 return -EINVAL;
662644 }
663645
646+static DEFINE_MUTEX(apple_dart_groups_lock);
647+
648+static void apple_dart_release_group(void *iommu_data)
649+{
650+ int i, sid;
651+ struct apple_dart_stream_map *stream_map;
652+ struct apple_dart_master_cfg *group_master_cfg = iommu_data;
653+
654+ mutex_lock(&apple_dart_groups_lock);
655+
656+ for_each_stream_map(i, group_master_cfg, stream_map)
657+ for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS)
658+ stream_map->dart->sid2group[sid] = NULL;
659+
660+ kfree(iommu_data);
661+ mutex_unlock(&apple_dart_groups_lock);
662+}
663+
664664 static struct iommu_group *apple_dart_device_group(struct device *dev)
665665 {
666− static DEFINE_MUTEX(lock);
667666 int i, sid;
668667 struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
669668 struct apple_dart_stream_map *stream_map;
669+ struct apple_dart_master_cfg *group_master_cfg;
670670 struct iommu_group *group = NULL;
671671 struct iommu_group *res = ERR_PTR(-EINVAL);
672672
673− mutex_lock(&lock);
673+ mutex_lock(&apple_dart_groups_lock);
674674
675675 for_each_stream_map(i, cfg, stream_map) {
676676 for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS) {
@@ -698,6 +698,20 @@ static struct iommu_group *apple_dart_device_group(struct device *dev) · 21 unmodified lines
698698 #endif
699699 group = generic_device_group(dev);
700700
701+ res = ERR_PTR(-ENOMEM);
702+ if (!group)
703+ goto out;
704+
705+ group_master_cfg = kzalloc(sizeof(*group_master_cfg), GFP_KERNEL);
706+ if (!group_master_cfg) {
707+ iommu_group_put(group);
708+ goto out;
709+ }
710+
711+ memcpy(group_master_cfg, cfg, sizeof(*group_master_cfg));
712+ iommu_group_set_iommudata(group, group_master_cfg,
713+ apple_dart_release_group);
714+
701715 for_each_stream_map(i, cfg, stream_map)
702716 for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS)
703717 stream_map->dart->sid2group[sid] = group;
@@ -705,7 +719,7 @@ static struct iommu_group *apple_dart_device_group(struct device *dev) · 1 unmodified line
705719 res = group;
706720
707721 out:
708− mutex_unlock(&lock);
722+ mutex_unlock(&apple_dart_groups_lock);
709723 return res;
710724 }
711725
drivers/iommu/intel/dmar.c+3−3
@@ -1942,18 +1942,18 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type, · 1941 unmodified lines
19421942 reason = dmar_get_fault_reason(fault_reason, &fault_type);
19431943
19441944 if (fault_type == INTR_REMAP)
1945− pr_err("[INTR-REMAP] Request device [0x%02x:0x%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
1945+ pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
19461946 source_id >> 8, PCI_SLOT(source_id & 0xFF),
19471947 PCI_FUNC(source_id & 0xFF), addr >> 48,
19481948 fault_reason, reason);
19491949 else if (pasid == INVALID_IOASID)
1950− pr_err("[%s NO_PASID] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
1950+ pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
19511951 type ? "DMA Read" : "DMA Write",
19521952 source_id >> 8, PCI_SLOT(source_id & 0xFF),
19531953 PCI_FUNC(source_id & 0xFF), addr,
19541954 fault_reason, reason);
19551955 else
1956− pr_err("[%s PASID 0x%x] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
1956+ pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
19571957 type ? "DMA Read" : "DMA Write", pasid,
19581958 source_id >> 8, PCI_SLOT(source_id & 0xFF),
19591959 PCI_FUNC(source_id & 0xFF), addr,
drivers/ipack/devices/ipoctal.c+47−16
@@ -33,6 +33,7 @@ struct ipoctal_channel { · 32 unmodified lines
3333 unsigned int pointer_read;
3434 unsigned int pointer_write;
3535 struct tty_port tty_port;
36+ bool tty_registered;
3637 union scc2698_channel __iomem *regs;
3738 union scc2698_block __iomem *block_regs;
3839 unsigned int board_id;
@@ -81,22 +82,34 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty) · 42 unmodified lines
8182 return 0;
8283 }
8384
84−static int ipoctal_open(struct tty_struct *tty, struct file *file)
85+static int ipoctal_install(struct tty_driver *driver, struct tty_struct *tty)
8586 {
8687 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
8788 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
88− int err;
89−
90− tty->driver_data = channel;
89+ int res;
9190
9291 if (!ipack_get_carrier(ipoctal->dev))
9392 return -EBUSY;
9493
95− err = tty_port_open(&channel->tty_port, tty, file);
96− if (err)
97− ipack_put_carrier(ipoctal->dev);
94+ res = tty_standard_install(driver, tty);
95+ if (res)
96+ goto err_put_carrier;
97+
98+ tty->driver_data = channel;
99+
100+ return 0;
101+
102+err_put_carrier:
103+ ipack_put_carrier(ipoctal->dev);
104+
105+ return res;
106+}
107+
108+static int ipoctal_open(struct tty_struct *tty, struct file *file)
109+{
110+ struct ipoctal_channel *channel = tty->driver_data;
98111
99− return err;
112+ return tty_port_open(&channel->tty_port, tty, file);
100113 }
101114
102115 static void ipoctal_reset_stats(struct ipoctal_stats *stats)
@@ -264,7 +277,6 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 161 unmodified lines
264277 int res;
265278 int i;
266279 struct tty_driver *tty;
267− char name[20];
268280 struct ipoctal_channel *channel;
269281 struct ipack_region *region;
270282 void __iomem *addr;
@@ -355,8 +367,11 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 84 unmodified lines
355367 /* Fill struct tty_driver with ipoctal data */
356368 tty->owner = THIS_MODULE;
357369 tty->driver_name = KBUILD_MODNAME;
358− sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
359− tty->name = name;
370+ tty->name = kasprintf(GFP_KERNEL, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
371+ if (!tty->name) {
372+ res = -ENOMEM;
373+ goto err_put_driver;
374+ }
360375 tty->major = 0;
361376
362377 tty->minor_start = 0;
@@ -371,8 +386,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 8 unmodified lines
371386 res = tty_register_driver(tty);
372387 if (res) {
373388 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
374− tty_driver_kref_put(tty);
375− return res;
389+ goto err_free_name;
376390 }
377391
378392 /* Save struct tty_driver for use it when uninstalling the device */
@@ -383,7 +397,9 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 4 unmodified lines
383397
384398 channel = &ipoctal->channel[i];
385399 tty_port_init(&channel->tty_port);
386− tty_port_alloc_xmit_buf(&channel->tty_port);
400+ res = tty_port_alloc_xmit_buf(&channel->tty_port);
401+ if (res)
402+ continue;
387403 channel->tty_port.ops = &ipoctal_tty_port_ops;
388404
389405 ipoctal_reset_stats(&channel->stats);
@@ -391,13 +407,15 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 1 unmodified line
391407 spin_lock_init(&channel->lock);
392408 channel->pointer_read = 0;
393409 channel->pointer_write = 0;
394− tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL);
410+ tty_dev = tty_port_register_device_attr(&channel->tty_port, tty,
411+ i, NULL, channel, NULL);
395412 if (IS_ERR(tty_dev)) {
396413 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
414+ tty_port_free_xmit_buf(&channel->tty_port);
397415 tty_port_destroy(&channel->tty_port);
398416 continue;
399417 }
400− dev_set_drvdata(tty_dev, channel);
418+ channel->tty_registered = true;
401419 }
402420
403421 /*
@@ -409,6 +427,13 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, · 5 unmodified lines
409427 ipoctal_irq_handler, ipoctal);
410428
411429 return 0;
430+
431+err_free_name:
432+ kfree(tty->name);
433+err_put_driver:
434+ tty_driver_kref_put(tty);
435+
436+ return res;
412437 }
413438
414439 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
@@ -648,6 +673,7 @@ static void ipoctal_cleanup(struct tty_struct *tty) · 233 unmodified lines
648673
649674 static const struct tty_operations ipoctal_fops = {
650675 .ioctl = NULL,
676+ .install = ipoctal_install,
651677 .open = ipoctal_open,
652678 .close = ipoctal_close,
653679 .write = ipoctal_write_tty,
@@ -690,12 +716,17 @@ static void __ipoctal_remove(struct ipoctal *ipoctal) · 36 unmodified lines
690716
691717 for (i = 0; i < NR_CHANNELS; i++) {
692718 struct ipoctal_channel *channel = &ipoctal->channel[i];
719+
720+ if (!channel->tty_registered)
721+ continue;
722+
693723 tty_unregister_device(ipoctal->tty_drv, i);
694724 tty_port_free_xmit_buf(&channel->tty_port);
695725 tty_port_destroy(&channel->tty_port);
696726 }
697727
698728 tty_unregister_driver(ipoctal->tty_drv);
729+ kfree(ipoctal->tty_drv->name);
699730 tty_driver_kref_put(ipoctal->tty_drv);
700731 kfree(ipoctal);
701732 }
drivers/media/platform/s5p-jpeg/jpeg-core.c+9−9
@@ -1140,8 +1140,8 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, · 1139 unmodified lines
11401140 continue;
11411141 length = 0;
11421142 switch (c) {
1143− /* SOF0: baseline JPEG */
1144− case SOF0:
1143+ /* JPEG_MARKER_SOF0: baseline JPEG */
1144+ case JPEG_MARKER_SOF0:
11451145 if (get_word_be(&jpeg_buffer, &word))
11461146 break;
11471147 length = (long)word - 2;
@@ -1172,7 +1172,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, · 24 unmodified lines
11721172 notfound = 0;
11731173 break;
11741174
1175− case DQT:
1175+ case JPEG_MARKER_DQT:
11761176 if (get_word_be(&jpeg_buffer, &word))
11771177 break;
11781178 length = (long)word - 2;
@@ -1185,7 +1185,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, · 6 unmodified lines
11851185 skip(&jpeg_buffer, length);
11861186 break;
11871187
1188− case DHT:
1188+ case JPEG_MARKER_DHT:
11891189 if (get_word_be(&jpeg_buffer, &word))
11901190 break;
11911191 length = (long)word - 2;
@@ -1198,15 +1198,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, · 6 unmodified lines
11981198 skip(&jpeg_buffer, length);
11991199 break;
12001200
1201− case SOS:
1201+ case JPEG_MARKER_SOS:
12021202 sos = jpeg_buffer.curr - 2; /* 0xffda */
12031203 break;
12041204
12051205 /* skip payload-less markers */
1206− case RST ... RST + 7:
1207− case SOI:
1208− case EOI:
1209− case TEM:
1206+ case JPEG_MARKER_RST ... JPEG_MARKER_RST + 7:
1207+ case JPEG_MARKER_SOI:
1208+ case JPEG_MARKER_EOI:
1209+ case JPEG_MARKER_TEM:
12101210 break;
12111211
12121212 /* skip uninteresting payload markers */
drivers/media/platform/s5p-jpeg/jpeg-core.h+14−14
@@ -37,15 +37,15 @@ · 36 unmodified lines
3737 #define EXYNOS3250_IRQ_TIMEOUT 0x10000000
3838
3939 /* a selection of JPEG markers */
40−#define TEM 0x01
41−#define SOF0 0xc0
42−#define DHT 0xc4
43−#define RST 0xd0
44−#define SOI 0xd8
45−#define EOI 0xd9
46−#define SOS 0xda
47−#define DQT 0xdb
48−#define DHP 0xde
40+#define JPEG_MARKER_TEM 0x01
41+#define JPEG_MARKER_SOF0 0xc0
42+#define JPEG_MARKER_DHT 0xc4
43+#define JPEG_MARKER_RST 0xd0
44+#define JPEG_MARKER_SOI 0xd8
45+#define JPEG_MARKER_EOI 0xd9
46+#define JPEG_MARKER_SOS 0xda
47+#define JPEG_MARKER_DQT 0xdb
48+#define JPEG_MARKER_DHP 0xde
4949
5050 /* Flags that indicate a format can be used for capture/output */
5151 #define SJPEG_FMT_FLAG_ENC_CAPTURE (1 << 0)
@@ -187,11 +187,11 @@ struct s5p_jpeg_marker { · 135 unmodified lines
187187 * @fmt: driver-specific format of this queue
188188 * @w: image width
189189 * @h: image height
190− * @sos: SOS marker's position relative to the buffer beginning
191− * @dht: DHT markers' positions relative to the buffer beginning
192− * @dqt: DQT markers' positions relative to the buffer beginning
193− * @sof: SOF0 marker's position relative to the buffer beginning
194− * @sof_len: SOF0 marker's payload length (without length field itself)
190+ * @sos: JPEG_MARKER_SOS's position relative to the buffer beginning
191+ * @dht: JPEG_MARKER_DHT' positions relative to the buffer beginning
192+ * @dqt: JPEG_MARKER_DQT' positions relative to the buffer beginning
193+ * @sof: JPEG_MARKER_SOF0's position relative to the buffer beginning
194+ * @sof_len: JPEG_MARKER_SOF0's payload length (without length field itself)
195195 * @size: image buffer size in bytes
196196 */
197197 struct s5p_jpeg_q_data {
drivers/media/rc/ir_toy.c+20−1
@@ -24,6 +24,7 @@ static const u8 COMMAND_VERSION[] = { 'v' }; · 23 unmodified lines
2424 // End transmit and repeat reset command so we exit sump mode
2525 static const u8 COMMAND_RESET[] = { 0xff, 0xff, 0, 0, 0, 0, 0 };
2626 static const u8 COMMAND_SMODE_ENTER[] = { 's' };
27+static const u8 COMMAND_SMODE_EXIT[] = { 0 };
2728 static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 };
2829
2930 #define REPLY_XMITCOUNT 't'
@@ -309,12 +310,30 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count) · 279 unmodified lines
309310 buf[i] = cpu_to_be16(v);
310311 }
311312
312− buf[count] = cpu_to_be16(0xffff);
313+ buf[count] = 0xffff;
313314
314315 irtoy->tx_buf = buf;
315316 irtoy->tx_len = size;
316317 irtoy->emitted = 0;
317318
319+ // There is an issue where if the unit is receiving IR while the
320+ // first TXSTART command is sent, the device might end up hanging
321+ // with its led on. It does not respond to any command when this
322+ // happens. To work around this, re-enter sample mode.
323+ err = irtoy_command(irtoy, COMMAND_SMODE_EXIT,
324+ sizeof(COMMAND_SMODE_EXIT), STATE_RESET);
325+ if (err) {
326+ dev_err(irtoy->dev, "exit sample mode: %d\n", err);
327+ return err;
328+ }
329+
330+ err = irtoy_command(irtoy, COMMAND_SMODE_ENTER,
331+ sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND);
332+ if (err) {
333+ dev_err(irtoy->dev, "enter sample mode: %d\n", err);
334+ return err;
335+ }
336+
318337 err = irtoy_command(irtoy, COMMAND_TXSTART, sizeof(COMMAND_TXSTART),
319338 STATE_TX);
320339 kfree(buf);
drivers/mmc/host/dw_mmc.c+12−3
@@ -1802,10 +1802,15 @@ static enum hrtimer_restart dw_mci_fault_timer(struct hrtimer *t) · 1801 unmodified lines
18021802
18031803 spin_lock_irqsave(&host->irq_lock, flags);
18041804
1805− if (!host->data_status)
1805+ /*
1806+ * Only inject an error if we haven't already got an error or data over
1807+ * interrupt.
1808+ */
1809+ if (!host->data_status) {
18061810 host->data_status = SDMMC_INT_DCRC;
1807− set_bit(EVENT_DATA_ERROR, &host->pending_events);
1808− tasklet_schedule(&host->tasklet);
1811+ set_bit(EVENT_DATA_ERROR, &host->pending_events);
1812+ tasklet_schedule(&host->tasklet);
1813+ }
18091814
18101815 spin_unlock_irqrestore(&host->irq_lock, flags);
18111816
@@ -2721,12 +2726,16 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) · 909 unmodified lines
27212726 }
27222727
27232728 if (pending & DW_MCI_DATA_ERROR_FLAGS) {
2729+ spin_lock(&host->irq_lock);
2730+
27242731 /* if there is an error report DATA_ERROR */
27252732 mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS);
27262733 host->data_status = pending;
27272734 smp_wmb(); /* drain writebuffer */
27282735 set_bit(EVENT_DATA_ERROR, &host->pending_events);
27292736 tasklet_schedule(&host->tasklet);
2737+
2738+ spin_unlock(&host->irq_lock);
27302739 }
27312740
27322741 if (pending & SDMMC_INT_DATA_OVER) {
drivers/mmc/host/renesas_sdhi_core.c+2−0
@@ -561,6 +561,8 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host) · 560 unmodified lines
561561 /* Unknown why but without polling reset status, it will hang */
562562 read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100,
563563 false, priv->rstc);
564+ /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */
565+ sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
564566 priv->needs_adjust_hs400 = false;
565567 renesas_sdhi_set_clock(host, host->clk_cache);
566568 } else if (priv->scc_ctl) {
drivers/net/dsa/mv88e6xxx/chip.c+10−7
@@ -2834,8 +2834,8 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) · 2833 unmodified lines
28342834 if (err)
28352835 return err;
28362836
2837− /* Port Control 2: don't force a good FCS, set the maximum frame size to
2838− * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
2837+ /* Port Control 2: don't force a good FCS, set the MTU size to
2838+ * 10222 bytes, disable 802.1q tags checking, don't discard tagged or
28392839 * untagged frames on this port, do a destination address lookup on all
28402840 * received packets as usual, disable ARP mirroring and don't send a
28412841 * copy of all transmitted/received frames on this port to the CPU.
@@ -2854,7 +2854,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) · 12 unmodified lines
28542854 return err;
28552855
28562856 if (chip->info->ops->port_set_jumbo_size) {
2857− err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
2857+ err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
28582858 if (err)
28592859 return err;
28602860 }
@@ -2944,10 +2944,10 @@ static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) · 83 unmodified lines
29442944 struct mv88e6xxx_chip *chip = ds->priv;
29452945
29462946 if (chip->info->ops->port_set_jumbo_size)
2947− return 10240;
2947+ return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
29482948 else if (chip->info->ops->set_max_frame_size)
2949− return 1632;
2950− return 1522;
2949+ return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
2950+ return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
29512951 }
29522952
29532953 static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
@@ -2955,6 +2955,9 @@ static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) · 1 unmodified line
29552955 struct mv88e6xxx_chip *chip = ds->priv;
29562956 int ret = 0;
29572957
2958+ if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
2959+ new_mtu += EDSA_HLEN;
2960+
29582961 mv88e6xxx_reg_lock(chip);
29592962 if (chip->info->ops->port_set_jumbo_size)
29602963 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
@@ -3725,7 +3728,6 @@ static const struct mv88e6xxx_ops mv88e6161_ops = { · 764 unmodified lines
37253728 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
37263729 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
37273730 .port_set_ether_type = mv88e6351_port_set_ether_type,
3728− .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
37293731 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
37303732 .port_pause_limit = mv88e6097_port_pause_limit,
37313733 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
@@ -3750,6 +3752,7 @@ static const struct mv88e6xxx_ops mv88e6161_ops = { · 18 unmodified lines
37503752 .avb_ops = &mv88e6165_avb_ops,
37513753 .ptp_ops = &mv88e6165_ptp_ops,
37523754 .phylink_validate = mv88e6185_phylink_validate,
3755+ .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
37533756 };
37543757
37553758 static const struct mv88e6xxx_ops mv88e6165_ops = {
drivers/net/dsa/mv88e6xxx/chip.h+1−0
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/timecounter.h>
1919 #include <net/dsa.h>
2020
21+#define EDSA_HLEN 8
2122 #define MV88E6XXX_N_FID 4096
2223
2324 /* PVT limits for 4-bit port and 5-bit switch */
drivers/net/dsa/mv88e6xxx/global1.c+2−0
@@ -232,6 +232,8 @@ int mv88e6185_g1_set_max_frame_size(struct mv88e6xxx_chip *chip, int mtu) · 231 unmodified lines
232232 u16 val;
233233 int err;
234234
235+ mtu += ETH_HLEN + ETH_FCS_LEN;
236+
235237 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &val);
236238 if (err)
237239 return err;
drivers/net/dsa/mv88e6xxx/port.c+2−0
@@ -1277,6 +1277,8 @@ int mv88e6165_port_set_jumbo_size(struct mv88e6xxx_chip *chip, int port, · 1276 unmodified lines
12771277 u16 reg;
12781278 int err;
12791279
1280+ size += VLAN_ETH_HLEN + ETH_FCS_LEN;
1281+
12801282 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, &reg);
12811283 if (err)
12821284 return err;
drivers/net/ethernet/broadcom/bgmac-platform.c+3−0
@@ -192,6 +192,9 @@ static int bgmac_probe(struct platform_device *pdev) · 191 unmodified lines
192192 bgmac->dma_dev = &pdev->dev;
193193
194194 ret = of_get_mac_address(np, bgmac->net_dev->dev_addr);
195+ if (ret == -EPROBE_DEFER)
196+ return ret;
197+
195198 if (ret)
196199 dev_warn(&pdev->dev,
197200 "MAC address not present in device tree\n");
drivers/net/ethernet/freescale/enetc/enetc_pf.c+1−2
@@ -541,8 +541,7 @@ static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode) · 540 unmodified lines
541541
542542 if (phy_interface_mode_is_rgmii(phy_mode)) {
543543 val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
544− val &= ~ENETC_PM0_IFM_EN_AUTO;
545− val &= ENETC_PM0_IFM_IFMODE_MASK;
544+ val &= ~(ENETC_PM0_IFM_EN_AUTO | ENETC_PM0_IFM_IFMODE_MASK);
546545 val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG;
547546 enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
548547 }
drivers/net/ethernet/hisilicon/hns3/hnae3.h+0−1
@@ -752,7 +752,6 @@ struct hnae3_tc_info { · 751 unmodified lines
752752 u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
753753 u16 tqp_count[HNAE3_MAX_TC];
754754 u16 tqp_offset[HNAE3_MAX_TC];
755− unsigned long tc_en; /* bitmap of TC enabled */
756755 u8 num_tc; /* Total number of enabled TCs */
757756 bool mqprio_active;
758757 };
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c+7−9
@@ -623,13 +623,9 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev) · 622 unmodified lines
623623 return ret;
624624 }
625625
626− for (i = 0; i < HNAE3_MAX_TC; i++) {
627− if (!test_bit(i, &tc_info->tc_en))
628− continue;
629−
626+ for (i = 0; i < tc_info->num_tc; i++)
630627 netdev_set_tc_queue(netdev, i, tc_info->tqp_count[i],
631628 tc_info->tqp_offset[i]);
632− }
633629 }
634630
635631 ret = netif_set_real_num_tx_queues(netdev, queue_size);
@@ -779,6 +775,11 @@ static int hns3_nic_net_open(struct net_device *netdev) · 143 unmodified lines
779775 if (hns3_nic_resetting(netdev))
780776 return -EBUSY;
781777
778+ if (!test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
779+ netdev_warn(netdev, "net open repeatedly!\n");
780+ return 0;
781+ }
782+
782783 netif_carrier_off(netdev);
783784
784785 ret = hns3_nic_set_real_num_queue(netdev);
@@ -4865,12 +4866,9 @@ static void hns3_init_tx_ring_tc(struct hns3_nic_priv *priv) · 4080 unmodified lines
48654866 struct hnae3_tc_info *tc_info = &kinfo->tc_info;
48664867 int i;
48674868
4868− for (i = 0; i < HNAE3_MAX_TC; i++) {
4869+ for (i = 0; i < tc_info->num_tc; i++) {
48694870 int j;
48704871
4871− if (!test_bit(i, &tc_info->tc_en))
4872− continue;
4873−
48744872 for (j = 0; j < tc_info->tqp_count[i]; j++) {
48754873 struct hnae3_queue *q;
48764874
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c+4−2
@@ -334,7 +334,8 @@ static void hns3_selftest_prepare(struct net_device *ndev, · 333 unmodified lines
334334
335335 #if IS_ENABLED(CONFIG_VLAN_8021Q)
336336 /* Disable the vlan filter for selftest does not support it */
337− if (h->ae_algo->ops->enable_vlan_filter)
337+ if (h->ae_algo->ops->enable_vlan_filter &&
338+ ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
338339 h->ae_algo->ops->enable_vlan_filter(h, false);
339340 #endif
340341
@@ -359,7 +360,8 @@ static void hns3_selftest_restore(struct net_device *ndev, bool if_running) · 18 unmodified lines
359360 h->ae_algo->ops->halt_autoneg(h, false);
360361
361362 #if IS_ENABLED(CONFIG_VLAN_8021Q)
362− if (h->ae_algo->ops->enable_vlan_filter)
363+ if (h->ae_algo->ops->enable_vlan_filter &&
364+ ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
363365 h->ae_algo->ops->enable_vlan_filter(h, true);
364366 #endif
365367
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c+13−8
@@ -467,7 +467,7 @@ err_csq: · 466 unmodified lines
467467 return ret;
468468 }
469469
470−static int hclge_firmware_compat_config(struct hclge_dev *hdev)
470+static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en)
471471 {
472472 struct hclge_firmware_compat_cmd *req;
473473 struct hclge_desc desc;
@@ -475,13 +475,16 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev) · 1 unmodified line
475475
476476 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_IMP_COMPAT_CFG, false);
477477
478− req = (struct hclge_firmware_compat_cmd *)desc.data;
478+ if (en) {
479+ req = (struct hclge_firmware_compat_cmd *)desc.data;
479480
480− hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1);
481− hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1);
482− if (hnae3_dev_phy_imp_supported(hdev))
483− hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1);
484− req->compat = cpu_to_le32(compat);
481+ hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1);
482+ hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1);
483+ if (hnae3_dev_phy_imp_supported(hdev))
484+ hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1);
485+
486+ req->compat = cpu_to_le32(compat);
487+ }
485488
486489 return hclge_cmd_send(&hdev->hw, &desc, 1);
487490 }
@@ -538,7 +541,7 @@ int hclge_cmd_init(struct hclge_dev *hdev) · 50 unmodified lines
538541 /* ask the firmware to enable some features, driver can work without
539542 * it.
540543 */
541− ret = hclge_firmware_compat_config(hdev);
544+ ret = hclge_firmware_compat_config(hdev, true);
542545 if (ret)
543546 dev_warn(&hdev->pdev->dev,
544547 "Firmware compatible features not enabled(%d).\n",
@@ -568,6 +571,8 @@ static void hclge_cmd_uninit_regs(struct hclge_hw *hw) · 23 unmodified lines
568571
569572 void hclge_cmd_uninit(struct hclge_dev *hdev)
570573 {
574+ hclge_firmware_compat_config(hdev, false);
575+
571576 set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
572577 /* wait to ensure that the firmware completes the possible left
573578 * over commands.
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c+16−13
@@ -247,6 +247,10 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) · 246 unmodified lines
247247 }
248248
249249 hclge_tm_schd_info_update(hdev, num_tc);
250+ if (num_tc > 1)
251+ hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
252+ else
253+ hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
250254
251255 ret = hclge_ieee_ets_to_tm_info(hdev, ets);
252256 if (ret)
@@ -306,8 +310,7 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc) · 53 unmodified lines
306310 u8 i, j, pfc_map, *prio_tc;
307311 int ret;
308312
309− if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) ||
310− hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
313+ if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
311314 return -EINVAL;
312315
313316 if (pfc->pfc_en == hdev->tm_info.pfc_en)
@@ -441,8 +444,6 @@ static int hclge_mqprio_qopt_check(struct hclge_dev *hdev, · 127 unmodified lines
441444 static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info,
442445 struct tc_mqprio_qopt_offload *mqprio_qopt)
443446 {
444− int i;
445−
446447 memset(tc_info, 0, sizeof(*tc_info));
447448 tc_info->num_tc = mqprio_qopt->qopt.num_tc;
448449 memcpy(tc_info->prio_tc, mqprio_qopt->qopt.prio_tc_map,
@@ -451,9 +452,6 @@ static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info, · 2 unmodified lines
451452 sizeof_field(struct hnae3_tc_info, tqp_count));
452453 memcpy(tc_info->tqp_offset, mqprio_qopt->qopt.offset,
453454 sizeof_field(struct hnae3_tc_info, tqp_offset));
454−
455− for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
456− set_bit(tc_info->prio_tc[i], &tc_info->tc_en);
457455 }
458456
459457 static int hclge_config_tc(struct hclge_dev *hdev,
@@ -519,12 +517,17 @@ static int hclge_setup_tc(struct hnae3_handle *h, · 59 unmodified lines
519517 return hclge_notify_init_up(hdev);
520518
521519 err_out:
522− /* roll-back */
523− memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info));
524− if (hclge_config_tc(hdev, &kinfo->tc_info))
525− dev_err(&hdev->pdev->dev,
526− "failed to roll back tc configuration\n");
527−
520+ if (!tc) {
521+ dev_warn(&hdev->pdev->dev,
522+ "failed to destroy mqprio, will active after reset, ret = %d\n",
523+ ret);
524+ } else {
525+ /* roll-back */
526+ memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info));
527+ if (hclge_config_tc(hdev, &kinfo->tc_info))
528+ dev_err(&hdev->pdev->dev,
529+ "failed to roll back tc configuration\n");
530+ }
528531 hclge_notify_init_up(hdev);
529532
530533 return ret;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c+24−4
@@ -719,9 +719,9 @@ static void hclge_dbg_fill_shaper_content(struct hclge_tm_shaper_para *para, · 718 unmodified lines
719719 sprintf(result[(*index)++], "%6u", para->rate);
720720 }
721721
722−static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len)
722+static int __hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *data_str,
723+ char *buf, int len)
723724 {
724− char data_str[ARRAY_SIZE(tm_pg_items)][HCLGE_DBG_DATA_STR_LEN];
725725 struct hclge_tm_shaper_para c_shaper_para, p_shaper_para;
726726 char *result[ARRAY_SIZE(tm_pg_items)], *sch_mode_str;
727727 u8 pg_id, sch_mode, weight, pri_bit_map, i, j;
@@ -729,8 +729,10 @@ static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) · 1 unmodified line
729729 int pos = 0;
730730 int ret;
731731
732− for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++)
733− result[i] = &data_str[i][0];
732+ for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++) {
733+ result[i] = data_str;
734+ data_str += HCLGE_DBG_DATA_STR_LEN;
735+ }
734736
735737 hclge_dbg_fill_content(content, sizeof(content), tm_pg_items,
736738 NULL, ARRAY_SIZE(tm_pg_items));
@@ -781,6 +783,24 @@ static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) · 44 unmodified lines
781783 return 0;
782784 }
783785
786+static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len)
787+{
788+ char *data_str;
789+ int ret;
790+
791+ data_str = kcalloc(ARRAY_SIZE(tm_pg_items),
792+ HCLGE_DBG_DATA_STR_LEN, GFP_KERNEL);
793+
794+ if (!data_str)
795+ return -ENOMEM;
796+
797+ ret = __hclge_dbg_dump_tm_pg(hdev, data_str, buf, len);
798+
799+ kfree(data_str);
800+
801+ return ret;
802+}
803+
784804 static int hclge_dbg_dump_tm_port(struct hclge_dev *hdev, char *buf, int len)
785805 {
786806 struct hclge_tm_shaper_para shaper_para;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c+15−12
@@ -8708,15 +8708,8 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport, · 8707 unmodified lines
87088708 }
87098709
87108710 /* check if we just hit the duplicate */
8711− if (!ret) {
8712− dev_warn(&hdev->pdev->dev, "VF %u mac(%pM) exists\n",
8713− vport->vport_id, addr);
8714− return 0;
8715− }
8716−
8717− dev_err(&hdev->pdev->dev,
8718− "PF failed to add unicast entry(%pM) in the MAC table\n",
8719− addr);
8711+ if (!ret)
8712+ return -EEXIST;
87208713
87218714 return ret;
87228715 }
@@ -8868,7 +8861,13 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, · 145 unmodified lines
88688861 } else {
88698862 set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE,
88708863 &vport->state);
8871− break;
8864+
8865+ /* If one unicast mac address is existing in hardware,
8866+ * we need to try whether other unicast mac addresses
8867+ * are new addresses that can be added.
8868+ */
8869+ if (ret != -EEXIST)
8870+ break;
88728871 }
88738872 }
88748873 }
@@ -12797,8 +12796,12 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev) · 3922 unmodified lines
1279712796 continue;
1279812797
1279912798 if (vport->vf_info.trusted) {
12800− uc_en = vport->vf_info.request_uc_en > 0;
12801− mc_en = vport->vf_info.request_mc_en > 0;
12799+ uc_en = vport->vf_info.request_uc_en > 0 ||
12800+ vport->overflow_promisc_flags &
12801+ HNAE3_OVERFLOW_UPE;
12802+ mc_en = vport->vf_info.request_mc_en > 0 ||
12803+ vport->overflow_promisc_flags &
12804+ HNAE3_OVERFLOW_MPE;
1280212805 }
1280312806 bc_en = vport->vf_info.request_bc_en > 0;
1280412807
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c+5−28
@@ -687,12 +687,10 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport) · 686 unmodified lines
687687
688688 for (i = 0; i < HNAE3_MAX_TC; i++) {
689689 if (hdev->hw_tc_map & BIT(i) && i < kinfo->tc_info.num_tc) {
690− set_bit(i, &kinfo->tc_info.tc_en);
691690 kinfo->tc_info.tqp_offset[i] = i * kinfo->rss_size;
692691 kinfo->tc_info.tqp_count[i] = kinfo->rss_size;
693692 } else {
694693 /* Set to default queue if TC is disable */
695− clear_bit(i, &kinfo->tc_info.tc_en);
696694 kinfo->tc_info.tqp_offset[i] = 0;
697695 kinfo->tc_info.tqp_count[i] = 1;
698696 }
@@ -729,14 +727,6 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev) · 30 unmodified lines
729727 for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
730728 hdev->tm_info.prio_tc[i] =
731729 (i >= hdev->tm_info.num_tc) ? 0 : i;
732−
733− /* DCB is enabled if we have more than 1 TC or pfc_en is
734− * non-zero.
735− */
736− if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en)
737− hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
738− else
739− hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
740730 }
741731
742732 static void hclge_tm_pg_info_init(struct hclge_dev *hdev)
@@ -767,10 +757,10 @@ static void hclge_tm_pg_info_init(struct hclge_dev *hdev) · 24 unmodified lines
767757
768758 static void hclge_update_fc_mode_by_dcb_flag(struct hclge_dev *hdev)
769759 {
770− if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE)) {
760+ if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en) {
771761 if (hdev->fc_mode_last_time == HCLGE_FC_PFC)
772762 dev_warn(&hdev->pdev->dev,
773− "DCB is disable, but last mode is FC_PFC\n");
763+ "Only 1 tc used, but last mode is FC_PFC\n");
774764
775765 hdev->tm_info.fc_mode = hdev->fc_mode_last_time;
776766 } else if (hdev->tm_info.fc_mode != HCLGE_FC_PFC) {
@@ -796,7 +786,7 @@ static void hclge_update_fc_mode(struct hclge_dev *hdev) · 19 unmodified lines
796786 }
797787 }
798788
799−static void hclge_pfc_info_init(struct hclge_dev *hdev)
789+void hclge_tm_pfc_info_update(struct hclge_dev *hdev)
800790 {
801791 if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
802792 hclge_update_fc_mode(hdev);
@@ -812,7 +802,7 @@ static void hclge_tm_schd_info_init(struct hclge_dev *hdev) · 9 unmodified lines
812802
813803 hclge_tm_vport_info_update(hdev);
814804
815− hclge_pfc_info_init(hdev);
805+ hclge_tm_pfc_info_update(hdev);
816806 }
817807
818808 static int hclge_tm_pg_to_pri_map(struct hclge_dev *hdev)
@@ -1558,19 +1548,6 @@ void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc) · 739 unmodified lines
15581548 hclge_tm_schd_info_init(hdev);
15591549 }
15601550
1561−void hclge_tm_pfc_info_update(struct hclge_dev *hdev)
1562−{
1563− /* DCB is enabled if we have more than 1 TC or pfc_en is
1564− * non-zero.
1565− */
1566− if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en)
1567− hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
1568− else
1569− hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
1570−
1571− hclge_pfc_info_init(hdev);
1572−}
1573−
15741551 int hclge_tm_init_hw(struct hclge_dev *hdev, bool init)
15751552 {
15761553 int ret;
@@ -1616,7 +1593,7 @@ int hclge_tm_vport_map_update(struct hclge_dev *hdev) · 39 unmodified lines
16161593 if (ret)
16171594 return ret;
16181595
1619− if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE))
1596+ if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en)
16201597 return 0;
16211598
16221599 return hclge_tm_bp_setup(hdev);
drivers/net/ethernet/hisilicon/hns_mdio.c+1−1
@@ -354,7 +354,7 @@ static int hns_mdio_reset(struct mii_bus *bus) · 353 unmodified lines
354354
355355 if (dev_of_node(bus->parent)) {
356356 if (!mdio_dev->subctrl_vbase) {
357− dev_err(&bus->dev, "mdio sys ctl reg has not maped\n");
357+ dev_err(&bus->dev, "mdio sys ctl reg has not mapped\n");
358358 return -ENODEV;
359359 }
360360
drivers/net/ethernet/ibm/ibmvnic.c+0−8
@@ -4708,14 +4708,6 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq, · 4707 unmodified lines
47084708 return 0;
47094709 }
47104710
4711− if (adapter->failover_pending) {
4712− adapter->init_done_rc = -EAGAIN;
4713− netdev_dbg(netdev, "Failover pending, ignoring login response\n");
4714− complete(&adapter->init_done);
4715− /* login response buffer will be released on reset */
4716− return 0;
4717− }
4718−
47194711 netdev->mtu = adapter->req_mtu - ETH_HLEN;
47204712
47214713 netdev_dbg(adapter->netdev, "Login Response Buffer:\n");
drivers/net/ethernet/intel/e100.c+15−7
@@ -2437,11 +2437,15 @@ static void e100_get_drvinfo(struct net_device *netdev, · 2436 unmodified lines
24372437 sizeof(info->bus_info));
24382438 }
24392439
2440−#define E100_PHY_REGS 0x1C
2440+#define E100_PHY_REGS 0x1D
24412441 static int e100_get_regs_len(struct net_device *netdev)
24422442 {
24432443 struct nic *nic = netdev_priv(netdev);
2444− return 1 + E100_PHY_REGS + sizeof(nic->mem->dump_buf);
2444+
2445+ /* We know the number of registers, and the size of the dump buffer.
2446+ * Calculate the total size in bytes.
2447+ */
2448+ return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf);
24452449 }
24462450
24472451 static void e100_get_regs(struct net_device *netdev,
@@ -2455,14 +2459,18 @@ static void e100_get_regs(struct net_device *netdev, · 7 unmodified lines
24552459 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 |
24562460 ioread8(&nic->csr->scb.cmd_lo) << 16 |
24572461 ioread16(&nic->csr->scb.status);
2458− for (i = E100_PHY_REGS; i >= 0; i--)
2459− buff[1 + E100_PHY_REGS - i] =
2460− mdio_read(netdev, nic->mii.phy_id, i);
2462+ for (i = 0; i < E100_PHY_REGS; i++)
2463+ /* Note that we read the registers in reverse order. This
2464+ * ordering is the ABI apparently used by ethtool and other
2465+ * applications.
2466+ */
2467+ buff[1 + i] = mdio_read(netdev, nic->mii.phy_id,
2468+ E100_PHY_REGS - 1 - i);
24612469 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf));
24622470 e100_exec_cb(nic, NULL, e100_dump);
24632471 msleep(10);
2464− memcpy(&buff[2 + E100_PHY_REGS], nic->mem->dump_buf,
2465− sizeof(nic->mem->dump_buf));
2472+ memcpy(&buff[1 + E100_PHY_REGS], nic->mem->dump_buf,
2473+ sizeof(nic->mem->dump_buf));
24662474 }
24672475
24682476 static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c+1−1
@@ -3208,7 +3208,7 @@ static unsigned int ixgbe_max_channels(struct ixgbe_adapter *adapter) · 3207 unmodified lines
32083208 max_combined = ixgbe_max_rss_indices(adapter);
32093209 }
32103210
3211− return max_combined;
3211+ return min_t(int, max_combined, num_online_cpus());
32123212 }
32133213
32143214 static void ixgbe_get_channels(struct net_device *dev,
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+6−2
@@ -10112,6 +10112,7 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) · 10111 unmodified lines
1011210112 struct ixgbe_adapter *adapter = netdev_priv(dev);
1011310113 struct bpf_prog *old_prog;
1011410114 bool need_reset;
10115+ int num_queues;
1011510116
1011610117 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
1011710118 return -EINVAL;
@@ -10161,11 +10162,14 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) · 43 unmodified lines
1016110162 /* Kick start the NAPI context if there is an AF_XDP socket open
1016210163 * on that queue id. This so that receiving will start.
1016310164 */
10164− if (need_reset && prog)
10165− for (i = 0; i < adapter->num_rx_queues; i++)
10165+ if (need_reset && prog) {
10166+ num_queues = min_t(int, adapter->num_rx_queues,
10167+ adapter->num_xdp_queues);
10168+ for (i = 0; i < num_queues; i++)
1016610169 if (adapter->xdp_ring[i]->xsk_pool)
1016710170 (void)ixgbe_xsk_wakeup(adapter->netdev, i,
1016810171 XDP_WAKEUP_RX);
10172+ }
1016910173
1017010174 return 0;
1017110175 }
drivers/net/ethernet/micrel/Makefile+2−4
@@ -4,8 +4,6 @@ · 3 unmodified lines
44 #
55
66 obj-$(CONFIG_KS8842) += ks8842.o
7−obj-$(CONFIG_KS8851) += ks8851.o
8−ks8851-objs = ks8851_common.o ks8851_spi.o
9−obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o
10−ks8851_mll-objs = ks8851_common.o ks8851_par.o
7+obj-$(CONFIG_KS8851) += ks8851_common.o ks8851_spi.o
8+obj-$(CONFIG_KS8851_MLL) += ks8851_common.o ks8851_par.o
119 obj-$(CONFIG_KSZ884X_PCI) += ksz884x.o
drivers/net/ethernet/micrel/ks8851_common.c+8−0
@@ -1057,6 +1057,7 @@ int ks8851_suspend(struct device *dev) · 1056 unmodified lines
10571057
10581058 return 0;
10591059 }
1060+EXPORT_SYMBOL_GPL(ks8851_suspend);
10601061
10611062 int ks8851_resume(struct device *dev)
10621063 {
@@ -1070,6 +1071,7 @@ int ks8851_resume(struct device *dev) · 7 unmodified lines
10701071
10711072 return 0;
10721073 }
1074+EXPORT_SYMBOL_GPL(ks8851_resume);
10731075 #endif
10741076
10751077 static int ks8851_register_mdiobus(struct ks8851_net *ks, struct device *dev)
@@ -1243,6 +1245,7 @@ err_reg: · 167 unmodified lines
12431245 err_reg_io:
12441246 return ret;
12451247 }
1248+EXPORT_SYMBOL_GPL(ks8851_probe_common);
12461249
12471250 int ks8851_remove_common(struct device *dev)
12481251 {
@@ -1261,3 +1264,8 @@ int ks8851_remove_common(struct device *dev) · 12 unmodified lines
12611264
12621265 return 0;
12631266 }
1267+EXPORT_SYMBOL_GPL(ks8851_remove_common);
1268+
1269+MODULE_DESCRIPTION("KS8851 Network driver");
1270+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
1271+MODULE_LICENSE("GPL");
drivers/net/ethernet/pensando/ionic/ionic_stats.c+0−9
@@ -380,15 +380,6 @@ static void ionic_sw_stats_get_txq_values(struct ionic_lif *lif, u64 **buf, · 379 unmodified lines
380380 &ionic_dbg_intr_stats_desc[i]);
381381 (*buf)++;
382382 }
383− for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) {
384− **buf = IONIC_READ_STAT64(&txqcq->napi_stats,
385− &ionic_dbg_napi_stats_desc[i]);
386− (*buf)++;
387− }
388− for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) {
389− **buf = txqcq->napi_stats.work_done_cntr[i];
390− (*buf)++;
391− }
392383 for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) {
393384 **buf = txstats->sg_cntr[i];
394385 (*buf)++;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+4−0
@@ -486,6 +486,10 @@ bool stmmac_eee_init(struct stmmac_priv *priv) · 485 unmodified lines
486486 timer_setup(&priv->eee_ctrl_timer, stmmac_eee_ctrl_timer, 0);
487487 stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS,
488488 eee_tw_timer);
489+ if (priv->hw->xpcs)
490+ xpcs_config_eee(priv->hw->xpcs,
491+ priv->plat->mult_fact_100ns,
492+ true);
489493 }
490494
491495 if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) {
drivers/net/ethernet/sun/Kconfig+1−0
@@ -73,6 +73,7 @@ config CASSINI · 72 unmodified lines
7373 config SUNVNET_COMMON
7474 tristate "Common routines to support Sun Virtual Networking"
7575 depends on SUN_LDOMS
76+ depends on INET
7677 default m
7778
7879 config SUNVNET
drivers/net/hamradio/Kconfig+1−0
@@ -48,6 +48,7 @@ config BPQETHER · 47 unmodified lines
4848 config DMASCC
4949 tristate "High-speed (DMA) SCC driver for AX.25"
5050 depends on ISA && AX25 && BROKEN_ON_SMP && ISA_DMA_API
51+ depends on VIRT_TO_BUS
5152 help
5253 This is a driver for high-speed SCC boards, i.e. those supporting
5354 DMA on one port. You usually use those boards to connect your
drivers/net/mdio/mdio-ipq4019.c+5−1
@@ -207,6 +207,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) · 206 unmodified lines
207207 {
208208 struct ipq4019_mdio_data *priv;
209209 struct mii_bus *bus;
210+ struct resource *res;
210211 int ret;
211212
212213 bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -224,7 +225,10 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) · 11 unmodified lines
224225 return PTR_ERR(priv->mdio_clk);
225226
226227 /* The platform resource is provided on the chipset IPQ5018 */
227− priv->eth_ldo_rdy = devm_platform_ioremap_resource(pdev, 1);
228+ /* This resource is optional */
229+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
230+ if (res)
231+ priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
228232
229233 bus->name = "ipq4019_mdio";
230234 bus->read = ipq4019_mdio_read;
drivers/net/mdio/mdio-mscc-miim.c+10−5
@@ -134,8 +134,9 @@ static int mscc_miim_reset(struct mii_bus *bus) · 133 unmodified lines
134134
135135 static int mscc_miim_probe(struct platform_device *pdev)
136136 {
137− struct mii_bus *bus;
138137 struct mscc_miim_dev *dev;
138+ struct resource *res;
139+ struct mii_bus *bus;
139140 int ret;
140141
141142 bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*dev));
@@ -156,10 +157,14 @@ static int mscc_miim_probe(struct platform_device *pdev) · 14 unmodified lines
156157 return PTR_ERR(dev->regs);
157158 }
158159
159− dev->phy_regs = devm_platform_ioremap_resource(pdev, 1);
160− if (IS_ERR(dev->phy_regs)) {
161− dev_err(&pdev->dev, "Unable to map internal phy registers\n");
162− return PTR_ERR(dev->phy_regs);
160+ /* This resource is optional */
161+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
162+ if (res) {
163+ dev->phy_regs = devm_ioremap_resource(&pdev->dev, res);
164+ if (IS_ERR(dev->phy_regs)) {
165+ dev_err(&pdev->dev, "Unable to map internal phy registers\n");
166+ return PTR_ERR(dev->phy_regs);
167+ }
163168 }
164169
165170 ret = of_mdiobus_register(bus, pdev->dev.of_node);
drivers/net/mhi_net.c+1−5
@@ -321,7 +321,7 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev) · 320 unmodified lines
321321 /* Start MHI channels */
322322 err = mhi_prepare_for_transfer(mhi_dev);
323323 if (err)
324− goto out_err;
324+ return err;
325325
326326 /* Number of transfer descriptors determines size of the queue */
327327 mhi_netdev->rx_queue_sz = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE);
@@ -331,10 +331,6 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev) · 3 unmodified lines
331331 return err;
332332
333333 return 0;
334−
335−out_err:
336− free_netdev(ndev);
337− return err;
338334 }
339335
340336 static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev)
drivers/net/phy/bcm7xxx.c+110−4
@@ -27,7 +27,12 @@ · 26 unmodified lines
2727 #define MII_BCM7XXX_SHD_2_ADDR_CTRL 0xe
2828 #define MII_BCM7XXX_SHD_2_CTRL_STAT 0xf
2929 #define MII_BCM7XXX_SHD_2_BIAS_TRIM 0x1a
30+#define MII_BCM7XXX_SHD_3_PCS_CTRL 0x0
31+#define MII_BCM7XXX_SHD_3_PCS_STATUS 0x1
32+#define MII_BCM7XXX_SHD_3_EEE_CAP 0x2
3033 #define MII_BCM7XXX_SHD_3_AN_EEE_ADV 0x3
34+#define MII_BCM7XXX_SHD_3_EEE_LP 0x4
35+#define MII_BCM7XXX_SHD_3_EEE_WK_ERR 0x5
3136 #define MII_BCM7XXX_SHD_3_PCS_CTRL_2 0x6
3237 #define MII_BCM7XXX_PCS_CTRL_2_DEF 0x4400
3338 #define MII_BCM7XXX_SHD_3_AN_STAT 0xb
@@ -216,25 +221,37 @@ static int bcm7xxx_28nm_resume(struct phy_device *phydev) · 182 unmodified lines
216221 return genphy_config_aneg(phydev);
217222 }
218223
219−static int phy_set_clr_bits(struct phy_device *dev, int location,
220− int set_mask, int clr_mask)
224+static int __phy_set_clr_bits(struct phy_device *dev, int location,
225+ int set_mask, int clr_mask)
221226 {
222227 int v, ret;
223228
224− v = phy_read(dev, location);
229+ v = __phy_read(dev, location);
225230 if (v < 0)
226231 return v;
227232
228233 v &= ~clr_mask;
229234 v |= set_mask;
230235
231− ret = phy_write(dev, location, v);
236+ ret = __phy_write(dev, location, v);
232237 if (ret < 0)
233238 return ret;
234239
235240 return v;
236241 }
237242
243+static int phy_set_clr_bits(struct phy_device *dev, int location,
244+ int set_mask, int clr_mask)
245+{
246+ int ret;
247+
248+ mutex_lock(&dev->mdio.bus->mdio_lock);
249+ ret = __phy_set_clr_bits(dev, location, set_mask, clr_mask);
250+ mutex_unlock(&dev->mdio.bus->mdio_lock);
251+
252+ return ret;
253+}
254+
238255 static int bcm7xxx_28nm_ephy_01_afe_config_init(struct phy_device *phydev)
239256 {
240257 int ret;
@@ -398,6 +415,93 @@ static int bcm7xxx_28nm_ephy_config_init(struct phy_device *phydev) · 157 unmodified lines
398415 return bcm7xxx_28nm_ephy_apd_enable(phydev);
399416 }
400417
418+#define MII_BCM7XXX_REG_INVALID 0xff
419+
420+static u8 bcm7xxx_28nm_ephy_regnum_to_shd(u16 regnum)
421+{
422+ switch (regnum) {
423+ case MDIO_CTRL1:
424+ return MII_BCM7XXX_SHD_3_PCS_CTRL;
425+ case MDIO_STAT1:
426+ return MII_BCM7XXX_SHD_3_PCS_STATUS;
427+ case MDIO_PCS_EEE_ABLE:
428+ return MII_BCM7XXX_SHD_3_EEE_CAP;
429+ case MDIO_AN_EEE_ADV:
430+ return MII_BCM7XXX_SHD_3_AN_EEE_ADV;
431+ case MDIO_AN_EEE_LPABLE:
432+ return MII_BCM7XXX_SHD_3_EEE_LP;
433+ case MDIO_PCS_EEE_WK_ERR:
434+ return MII_BCM7XXX_SHD_3_EEE_WK_ERR;
435+ default:
436+ return MII_BCM7XXX_REG_INVALID;
437+ }
438+}
439+
440+static bool bcm7xxx_28nm_ephy_dev_valid(int devnum)
441+{
442+ return devnum == MDIO_MMD_AN || devnum == MDIO_MMD_PCS;
443+}
444+
445+static int bcm7xxx_28nm_ephy_read_mmd(struct phy_device *phydev,
446+ int devnum, u16 regnum)
447+{
448+ u8 shd = bcm7xxx_28nm_ephy_regnum_to_shd(regnum);
449+ int ret;
450+
451+ if (!bcm7xxx_28nm_ephy_dev_valid(devnum) ||
452+ shd == MII_BCM7XXX_REG_INVALID)
453+ return -EOPNOTSUPP;
454+
455+ /* set shadow mode 2 */
456+ ret = __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST,
457+ MII_BCM7XXX_SHD_MODE_2, 0);
458+ if (ret < 0)
459+ return ret;
460+
461+ /* Access the desired shadow register address */
462+ ret = __phy_write(phydev, MII_BCM7XXX_SHD_2_ADDR_CTRL, shd);
463+ if (ret < 0)
464+ goto reset_shadow_mode;
465+
466+ ret = __phy_read(phydev, MII_BCM7XXX_SHD_2_CTRL_STAT);
467+
468+reset_shadow_mode:
469+ /* reset shadow mode 2 */
470+ __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0,
471+ MII_BCM7XXX_SHD_MODE_2);
472+ return ret;
473+}
474+
475+static int bcm7xxx_28nm_ephy_write_mmd(struct phy_device *phydev,
476+ int devnum, u16 regnum, u16 val)
477+{
478+ u8 shd = bcm7xxx_28nm_ephy_regnum_to_shd(regnum);
479+ int ret;
480+
481+ if (!bcm7xxx_28nm_ephy_dev_valid(devnum) ||
482+ shd == MII_BCM7XXX_REG_INVALID)
483+ return -EOPNOTSUPP;
484+
485+ /* set shadow mode 2 */
486+ ret = __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST,
487+ MII_BCM7XXX_SHD_MODE_2, 0);
488+ if (ret < 0)
489+ return ret;
490+
491+ /* Access the desired shadow register address */
492+ ret = __phy_write(phydev, MII_BCM7XXX_SHD_2_ADDR_CTRL, shd);
493+ if (ret < 0)
494+ goto reset_shadow_mode;
495+
496+ /* Write the desired value in the shadow register */
497+ __phy_write(phydev, MII_BCM7XXX_SHD_2_CTRL_STAT, val);
498+
499+reset_shadow_mode:
500+ /* reset shadow mode 2 */
501+ return __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0,
502+ MII_BCM7XXX_SHD_MODE_2);
503+}
504+
401505 static int bcm7xxx_28nm_ephy_resume(struct phy_device *phydev)
402506 {
403507 int ret;
@@ -595,6 +699,8 @@ static void bcm7xxx_28nm_remove(struct phy_device *phydev) · 191 unmodified lines
595699 .get_stats = bcm7xxx_28nm_get_phy_stats, \
596700 .probe = bcm7xxx_28nm_probe, \
597701 .remove = bcm7xxx_28nm_remove, \
702+ .read_mmd = bcm7xxx_28nm_ephy_read_mmd, \
703+ .write_mmd = bcm7xxx_28nm_ephy_write_mmd, \
598704 }
599705
600706 #define BCM7XXX_40NM_EPHY(_oui, _name) \
drivers/net/phy/mdio_bus.c+5−0
@@ -525,6 +525,10 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) · 524 unmodified lines
525525 NULL == bus->read || NULL == bus->write)
526526 return -EINVAL;
527527
528+ if (bus->parent && bus->parent->of_node)
529+ bus->parent->of_node->fwnode.flags |=
530+ FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD;
531+
528532 BUG_ON(bus->state != MDIOBUS_ALLOCATED &&
529533 bus->state != MDIOBUS_UNREGISTERED);
530534
@@ -537,6 +541,7 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) · 6 unmodified lines
537541 err = device_register(&bus->dev);
538542 if (err) {
539543 pr_err("mii_bus %s failed to register\n", bus->id);
544+ put_device(&bus->dev);
540545 return -EINVAL;
541546 }
542547
drivers/net/phy/mxl-gpy.c+21−2
@@ -493,6 +493,25 @@ static int gpy_loopback(struct phy_device *phydev, bool enable) · 492 unmodified lines
493493 return ret;
494494 }
495495
496+static int gpy115_loopback(struct phy_device *phydev, bool enable)
497+{
498+ int ret;
499+ int fw_minor;
500+
501+ if (enable)
502+ return gpy_loopback(phydev, enable);
503+
504+ ret = phy_read(phydev, PHY_FWV);
505+ if (ret < 0)
506+ return ret;
507+
508+ fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret);
509+ if (fw_minor > 0x0076)
510+ return gpy_loopback(phydev, 0);
511+
512+ return genphy_soft_reset(phydev);
513+}
514+
496515 static struct phy_driver gpy_drivers[] = {
497516 {
498517 PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx),
@@ -527,7 +546,7 @@ static struct phy_driver gpy_drivers[] = { · 28 unmodified lines
527546 .handle_interrupt = gpy_handle_interrupt,
528547 .set_wol = gpy_set_wol,
529548 .get_wol = gpy_get_wol,
530− .set_loopback = gpy_loopback,
549+ .set_loopback = gpy115_loopback,
531550 },
532551 {
533552 PHY_ID_MATCH_MODEL(PHY_ID_GPY115C),
@@ -544,7 +563,7 @@ static struct phy_driver gpy_drivers[] = { · 10 unmodified lines
544563 .handle_interrupt = gpy_handle_interrupt,
545564 .set_wol = gpy_set_wol,
546565 .get_wol = gpy_get_wol,
547− .set_loopback = gpy_loopback,
566+ .set_loopback = gpy115_loopback,
548567 },
549568 {
550569 .phy_id = PHY_ID_GPY211B,
drivers/net/usb/smsc95xx.c+3−0
@@ -1178,7 +1178,10 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) · 1177 unmodified lines
11781178
11791179 static void smsc95xx_handle_link_change(struct net_device *net)
11801180 {
1181+ struct usbnet *dev = netdev_priv(net);
1182+
11811183 phy_print_status(net->phydev);
1184+ usbnet_defer_kevent(dev, EVENT_LINK_CHANGE);
11821185 }
11831186
11841187 static int smsc95xx_start_phy(struct usbnet *dev)
drivers/net/wireless/mac80211_hwsim.c+2−2
@@ -1867,8 +1867,8 @@ mac80211_hwsim_beacon(struct hrtimer *timer) · 1866 unmodified lines
18671867 bcn_int -= data->bcn_delta;
18681868 data->bcn_delta = 0;
18691869 }
1870− hrtimer_forward(&data->beacon_timer, hrtimer_get_expires(timer),
1871− ns_to_ktime(bcn_int * NSEC_PER_USEC));
1870+ hrtimer_forward_now(&data->beacon_timer,
1871+ ns_to_ktime(bcn_int * NSEC_PER_USEC));
18721872 return HRTIMER_RESTART;
18731873 }
18741874
drivers/nvdimm/pmem.c+1−4
@@ -380,7 +380,6 @@ static int pmem_attach_disk(struct device *dev, · 379 unmodified lines
380380 struct nd_pfn_sb *pfn_sb;
381381 struct pmem_device *pmem;
382382 struct request_queue *q;
383− struct device *gendev;
384383 struct gendisk *disk;
385384 void *addr;
386385 int rc;
@@ -489,10 +488,8 @@ static int pmem_attach_disk(struct device *dev, · 102 unmodified lines
489488 }
490489 dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
491490 pmem->dax_dev = dax_dev;
492− gendev = disk_to_dev(disk);
493− gendev->groups = pmem_attribute_groups;
494491
495− device_add_disk(dev, disk, NULL);
492+ device_add_disk(dev, disk, pmem_attribute_groups);
496493 if (devm_add_action_or_reset(dev, pmem_release_disk, pmem))
497494 return -ENOMEM;
498495
drivers/nvme/host/core.c+3−1
@@ -978,6 +978,7 @@ EXPORT_SYMBOL_GPL(nvme_cleanup_cmd); · 977 unmodified lines
978978 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
979979 {
980980 struct nvme_command *cmd = nvme_req(req)->cmd;
981+ struct nvme_ctrl *ctrl = nvme_req(req)->ctrl;
981982 blk_status_t ret = BLK_STS_OK;
982983
983984 if (!(req->rq_flags & RQF_DONTPREP)) {
@@ -1026,7 +1027,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) · 42 unmodified lines
10261027 return BLK_STS_IOERR;
10271028 }
10281029
1029− nvme_req(req)->genctr++;
1030+ if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN))
1031+ nvme_req(req)->genctr++;
10301032 cmd->common.command_id = nvme_cid(req);
10311033 trace_nvme_setup_cmd(req, cmd);
10321034 return ret;
drivers/nvme/host/nvme.h+6−0
@@ -138,6 +138,12 @@ enum nvme_quirks { · 137 unmodified lines
138138 * 48 bits.
139139 */
140140 NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16),
141+
142+ /*
143+ * The controller requires the command_id value be be limited, so skip
144+ * encoding the generation sequence number.
145+ */
146+ NVME_QUIRK_SKIP_CID_GEN = (1 << 17),
141147 };
142148
143149 /*
drivers/nvme/host/pci.c+2−1
@@ -3369,7 +3369,8 @@ static const struct pci_device_id nvme_id_table[] = { · 3368 unmodified lines
33693369 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005),
33703370 .driver_data = NVME_QUIRK_SINGLE_VECTOR |
33713371 NVME_QUIRK_128_BYTES_SQES |
3372− NVME_QUIRK_SHARED_TAGS },
3372+ NVME_QUIRK_SHARED_TAGS |
3373+ NVME_QUIRK_SKIP_CID_GEN },
33733374
33743375 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
33753376 { 0, }
drivers/perf/arm_pmu.c+2−0
@@ -952,6 +952,8 @@ int armpmu_register(struct arm_pmu *pmu) · 951 unmodified lines
952952 pmu->name, pmu->num_events,
953953 has_nmi ? ", using NMIs" : "");
954954
955+ kvm_host_pmu_init(pmu);
956+
955957 return 0;
956958
957959 out_destroy:
drivers/pinctrl/core.c+1−1
@@ -2306,7 +2306,7 @@ EXPORT_SYMBOL_GPL(devm_pinctrl_register_and_init); · 2305 unmodified lines
23062306
23072307 /**
23082308 * devm_pinctrl_unregister() - Resource managed version of pinctrl_unregister().
2309− * @dev: device for which which resource was allocated
2309+ * @dev: device for which resource was allocated
23102310 * @pctldev: the pinctrl device to unregister.
23112311 */
23122312 void devm_pinctrl_unregister(struct device *dev, struct pinctrl_dev *pctldev)
drivers/pinctrl/pinctrl-amd.c+14−5
@@ -445,6 +445,7 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on) · 444 unmodified lines
445445 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
446446 struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
447447 u32 wake_mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3);
448+ int err;
448449
449450 raw_spin_lock_irqsave(&gpio_dev->lock, flags);
450451 pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
@@ -457,6 +458,15 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on) · 6 unmodified lines
457458 writel(pin_reg, gpio_dev->base + (d->hwirq)*4);
458459 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
459460
461+ if (on)
462+ err = enable_irq_wake(gpio_dev->irq);
463+ else
464+ err = disable_irq_wake(gpio_dev->irq);
465+
466+ if (err)
467+ dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n",
468+ on ? "enable" : "disable");
469+
460470 return 0;
461471 }
462472
@@ -902,7 +912,6 @@ static struct pinctrl_desc amd_pinctrl_desc = { · 439 unmodified lines
902912 static int amd_gpio_probe(struct platform_device *pdev)
903913 {
904914 int ret = 0;
905− int irq_base;
906915 struct resource *res;
907916 struct amd_gpio *gpio_dev;
908917 struct gpio_irq_chip *girq;
@@ -925,9 +934,9 @@ static int amd_gpio_probe(struct platform_device *pdev) · 16 unmodified lines
925934 if (!gpio_dev->base)
926935 return -ENOMEM;
927936
928− irq_base = platform_get_irq(pdev, 0);
929− if (irq_base < 0)
930− return irq_base;
937+ gpio_dev->irq = platform_get_irq(pdev, 0);
938+ if (gpio_dev->irq < 0)
939+ return gpio_dev->irq;
931940
932941 #ifdef CONFIG_PM_SLEEP
933942 gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins,
@@ -987,7 +996,7 @@ static int amd_gpio_probe(struct platform_device *pdev) · 53 unmodified lines
987996 goto out2;
988997 }
989998
990− ret = devm_request_irq(&pdev->dev, irq_base, amd_gpio_irq_handler,
999+ ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler,
9911000 IRQF_SHARED, KBUILD_MODNAME, gpio_dev);
9921001 if (ret)
9931002 goto out2;
drivers/pinctrl/pinctrl-amd.h+1−0
@@ -98,6 +98,7 @@ struct amd_gpio { · 97 unmodified lines
9898 struct resource *res;
9999 struct platform_device *pdev;
100100 u32 *saved_regs;
101+ int irq;
101102 };
102103
103104 /* KERNCZ configuration*/
drivers/pinctrl/pinctrl-rockchip.c+67−0
@@ -2092,6 +2092,23 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, · 2091 unmodified lines
20922092 return false;
20932093 }
20942094
2095+static int rockchip_pinconf_defer_output(struct rockchip_pin_bank *bank,
2096+ unsigned int pin, u32 arg)
2097+{
2098+ struct rockchip_pin_output_deferred *cfg;
2099+
2100+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
2101+ if (!cfg)
2102+ return -ENOMEM;
2103+
2104+ cfg->pin = pin;
2105+ cfg->arg = arg;
2106+
2107+ list_add_tail(&cfg->head, &bank->deferred_output);
2108+
2109+ return 0;
2110+}
2111+
20952112 /* set the pin config settings for a specified pin */
20962113 static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
20972114 unsigned long *configs, unsigned num_configs)
@@ -2136,6 +2153,22 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, · 38 unmodified lines
21362153 if (rc != RK_FUNC_GPIO)
21372154 return -EINVAL;
21382155
2156+ /*
2157+ * Check for gpio driver not being probed yet.
2158+ * The lock makes sure that either gpio-probe has completed
2159+ * or the gpio driver hasn't probed yet.
2160+ */
2161+ mutex_lock(&bank->deferred_lock);
2162+ if (!gpio || !gpio->direction_output) {
2163+ rc = rockchip_pinconf_defer_output(bank, pin - bank->pin_base, arg);
2164+ mutex_unlock(&bank->deferred_lock);
2165+ if (rc)
2166+ return rc;
2167+
2168+ break;
2169+ }
2170+ mutex_unlock(&bank->deferred_lock);
2171+
21392172 rc = gpio->direction_output(gpio, pin - bank->pin_base,
21402173 arg);
21412174 if (rc)
@@ -2204,6 +2237,11 @@ static int rockchip_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, · 62 unmodified lines
22042237 if (rc != RK_FUNC_GPIO)
22052238 return -EINVAL;
22062239
2240+ if (!gpio || !gpio->get) {
2241+ arg = 0;
2242+ break;
2243+ }
2244+
22072245 rc = gpio->get(gpio, pin - bank->pin_base);
22082246 if (rc < 0)
22092247 return rc;
@@ -2450,6 +2488,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, · 240 unmodified lines
24502488 pin_bank->name, pin);
24512489 pdesc++;
24522490 }
2491+
2492+ INIT_LIST_HEAD(&pin_bank->deferred_output);
2493+ mutex_init(&pin_bank->deferred_lock);
24532494 }
24542495
24552496 ret = rockchip_pinctrl_parse_dt(pdev, info);
@@ -2716,6 +2757,31 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) · 260 unmodified lines
27162757 return 0;
27172758 }
27182759
2760+static int rockchip_pinctrl_remove(struct platform_device *pdev)
2761+{
2762+ struct rockchip_pinctrl *info = platform_get_drvdata(pdev);
2763+ struct rockchip_pin_bank *bank;
2764+ struct rockchip_pin_output_deferred *cfg;
2765+ int i;
2766+
2767+ of_platform_depopulate(&pdev->dev);
2768+
2769+ for (i = 0; i < info->ctrl->nr_banks; i++) {
2770+ bank = &info->ctrl->pin_banks[i];
2771+
2772+ mutex_lock(&bank->deferred_lock);
2773+ while (!list_empty(&bank->deferred_output)) {
2774+ cfg = list_first_entry(&bank->deferred_output,
2775+ struct rockchip_pin_output_deferred, head);
2776+ list_del(&cfg->head);
2777+ kfree(cfg);
2778+ }
2779+ mutex_unlock(&bank->deferred_lock);
2780+ }
2781+
2782+ return 0;
2783+}
2784+
27192785 static struct rockchip_pin_bank px30_pin_banks[] = {
27202786 PIN_BANK_IOMUX_FLAGS(0, 32, "gpio0", IOMUX_SOURCE_PMU,
27212787 IOMUX_SOURCE_PMU,
@@ -3175,6 +3241,7 @@ static const struct of_device_id rockchip_pinctrl_dt_match[] = { · 453 unmodified lines
31753241
31763242 static struct platform_driver rockchip_pinctrl_driver = {
31773243 .probe = rockchip_pinctrl_probe,
3244+ .remove = rockchip_pinctrl_remove,
31783245 .driver = {
31793246 .name = "rockchip-pinctrl",
31803247 .pm = &rockchip_pinctrl_dev_pm_ops,
drivers/pinctrl/pinctrl-rockchip.h+10−0
@@ -141,6 +141,8 @@ struct rockchip_drv { · 140 unmodified lines
141141 * @toggle_edge_mode: bit mask to toggle (falling/rising) edge mode
142142 * @recalced_mask: bit mask to indicate a need to recalulate the mask
143143 * @route_mask: bits describing the routing pins of per bank
144+ * @deferred_output: gpio output settings to be done after gpio bank probed
145+ * @deferred_lock: mutex for the deferred_output shared btw gpio and pinctrl
144146 */
145147 struct rockchip_pin_bank {
146148 struct device *dev;
@@ -169,6 +171,8 @@ struct rockchip_pin_bank { · 22 unmodified lines
169171 u32 toggle_edge_mode;
170172 u32 recalced_mask;
171173 u32 route_mask;
174+ struct list_head deferred_output;
175+ struct mutex deferred_lock;
172176 };
173177
174178 /**
@@ -243,6 +247,12 @@ struct rockchip_pin_config { · 68 unmodified lines
243247 unsigned int nconfigs;
244248 };
245249
250+struct rockchip_pin_output_deferred {
251+ struct list_head head;
252+ unsigned int pin;
253+ u32 arg;
254+};
255+
246256 /**
247257 * struct rockchip_pin_group: represent group of pins of a pinmux function.
248258 * @name: name of the pin group, used to lookup the group.
drivers/pinctrl/qcom/pinctrl-sc7280.c+1−0
@@ -1496,6 +1496,7 @@ static const struct of_device_id sc7280_pinctrl_of_match[] = { · 1495 unmodified lines
14961496 static struct platform_driver sc7280_pinctrl_driver = {
14971497 .driver = {
14981498 .name = "sc7280-pinctrl",
1499+ .pm = &msm_pinctrl_dev_pm_ops,
14991500 .of_match_table = sc7280_pinctrl_of_match,
15001501 },
15011502 .probe = sc7280_pinctrl_probe,
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c+34−3
@@ -1,6 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0-only
22 /*
3− * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
3+ * Copyright (c) 2012-2014, 2016-2021 The Linux Foundation. All rights reserved.
44 */
55
66 #include <linux/gpio/driver.h>
@@ -14,6 +14,7 @@ · 7 unmodified lines
1414 #include <linux/platform_device.h>
1515 #include <linux/regmap.h>
1616 #include <linux/slab.h>
17+#include <linux/spmi.h>
1718 #include <linux/types.h>
1819
1920 #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
@@ -171,6 +172,8 @@ struct pmic_gpio_state { · 151 unmodified lines
171172 struct pinctrl_dev *ctrl;
172173 struct gpio_chip chip;
173174 struct irq_chip irq;
175+ u8 usid;
176+ u8 pid_base;
174177 };
175178
176179 static const struct pinconf_generic_params pmic_gpio_bindings[] = {
@@ -949,12 +952,36 @@ static int pmic_gpio_child_to_parent_hwirq(struct gpio_chip *chip, · 772 unmodified lines
949952 unsigned int *parent_hwirq,
950953 unsigned int *parent_type)
951954 {
952− *parent_hwirq = child_hwirq + 0xc0;
955+ struct pmic_gpio_state *state = gpiochip_get_data(chip);
956+
957+ *parent_hwirq = child_hwirq + state->pid_base;
953958 *parent_type = child_type;
954959
955960 return 0;
956961 }
957962
963+static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
964+ unsigned int parent_hwirq,
965+ unsigned int parent_type)
966+{
967+ struct pmic_gpio_state *state = gpiochip_get_data(chip);
968+ struct irq_fwspec *fwspec;
969+
970+ fwspec = kzalloc(sizeof(*fwspec), GFP_KERNEL);
971+ if (!fwspec)
972+ return NULL;
973+
974+ fwspec->fwnode = chip->irq.parent_domain->fwnode;
975+
976+ fwspec->param_count = 4;
977+ fwspec->param[0] = state->usid;
978+ fwspec->param[1] = parent_hwirq;
979+ /* param[2] must be left as 0 */
980+ fwspec->param[3] = parent_type;
981+
982+ return fwspec;
983+}
984+
958985 static int pmic_gpio_probe(struct platform_device *pdev)
959986 {
960987 struct irq_domain *parent_domain;
@@ -965,6 +992,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 4 unmodified lines
965992 struct pmic_gpio_pad *pad, *pads;
966993 struct pmic_gpio_state *state;
967994 struct gpio_irq_chip *girq;
995+ const struct spmi_device *parent_spmi_dev;
968996 int ret, npins, i;
969997 u32 reg;
970998
@@ -984,6 +1012,9 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 13 unmodified lines
9841012
9851013 state->dev = &pdev->dev;
9861014 state->map = dev_get_regmap(dev->parent, NULL);
1015+ parent_spmi_dev = to_spmi_device(dev->parent);
1016+ state->usid = parent_spmi_dev->usid;
1017+ state->pid_base = reg >> 8;
9871018
9881019 pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL);
9891020 if (!pindesc)
@@ -1059,7 +1090,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 69 unmodified lines
10591090 girq->fwnode = of_node_to_fwnode(state->dev->of_node);
10601091 girq->parent_domain = parent_domain;
10611092 girq->child_to_parent_hwirq = pmic_gpio_child_to_parent_hwirq;
1062− girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell;
1093+ girq->populate_parent_alloc_arg = pmic_gpio_populate_parent_fwspec;
10631094 girq->child_offset_to_irq = pmic_gpio_child_offset_to_irq;
10641095 girq->child_irq_domain_ops.translate = pmic_gpio_domain_translate;
10651096
drivers/ptp/ptp_kvm_x86.c+2−7
@@ -15,8 +15,6 @@ · 14 unmodified lines
1515 #include <linux/ptp_clock_kernel.h>
1616 #include <linux/ptp_kvm.h>
1717
18−struct pvclock_vsyscall_time_info *hv_clock;
19−
2018 static phys_addr_t clock_pair_gpa;
2119 static struct kvm_clock_pairing clock_pair;
2220
@@ -28,8 +26,7 @@ int kvm_arch_ptp_init(void) · 5 unmodified lines
2826 return -ENODEV;
2927
3028 clock_pair_gpa = slow_virt_to_phys(&clock_pair);
31− hv_clock = pvclock_get_pvti_cpu0_va();
32− if (!hv_clock)
29+ if (!pvclock_get_pvti_cpu0_va())
3330 return -ENODEV;
3431
3532 ret = kvm_hypercall2(KVM_HC_CLOCK_PAIRING, clock_pair_gpa,
@@ -64,10 +61,8 @@ int kvm_arch_ptp_get_crosststamp(u64 *cycle, struct timespec64 *tspec, · 28 unmodified lines
6461 struct pvclock_vcpu_time_info *src;
6562 unsigned int version;
6663 long ret;
67− int cpu;
6864
69− cpu = smp_processor_id();
70− src = &hv_clock[cpu].pvti;
65+ src = this_cpu_pvti();
7166
7267 do {
7368 /*
drivers/s390/cio/blacklist.c+5−3
@@ -262,10 +262,12 @@ static int blacklist_parse_proc_parameters(char *buf) · 261 unmodified lines
262262
263263 if (strcmp("free", parm) == 0) {
264264 rc = blacklist_parse_parameters(buf, free, 0);
265− /* There could be subchannels without proper devices connected.
266− * evaluate all the entries
265+ /*
266+ * Evaluate the subchannels without an online device. This way,
267+ * no path-verification will be triggered on those subchannels
268+ * and it avoids unnecessary delays.
267269 */
268− css_schedule_eval_all();
270+ css_schedule_eval_cond(CSS_EVAL_NOT_ONLINE, 0);
269271 } else if (strcmp("add", parm) == 0)
270272 rc = blacklist_parse_parameters(buf, add, 0);
271273 else if (strcmp("purge", parm) == 0)
drivers/s390/cio/css.c+31−9
@@ -788,27 +788,49 @@ static int __unset_registered(struct device *dev, void *data) · 787 unmodified lines
788788 return 0;
789789 }
790790
791−void css_schedule_eval_all_unreg(unsigned long delay)
791+static int __unset_online(struct device *dev, void *data)
792+{
793+ struct idset *set = data;
794+ struct subchannel *sch = to_subchannel(dev);
795+ struct ccw_device *cdev = sch_get_cdev(sch);
796+
797+ if (cdev && cdev->online)
798+ idset_sch_del(set, sch->schid);
799+
800+ return 0;
801+}
802+
803+void css_schedule_eval_cond(enum css_eval_cond cond, unsigned long delay)
792804 {
793805 unsigned long flags;
794− struct idset *unreg_set;
806+ struct idset *set;
795807
796808 /* Find unregistered subchannels. */
797− unreg_set = idset_sch_new();
798− if (!unreg_set) {
809+ set = idset_sch_new();
810+ if (!set) {
799811 /* Fallback. */
800812 css_schedule_eval_all();
801813 return;
802814 }
803− idset_fill(unreg_set);
804− bus_for_each_dev(&css_bus_type, NULL, unreg_set, __unset_registered);
815+ idset_fill(set);
816+ switch (cond) {
817+ case CSS_EVAL_UNREG:
818+ bus_for_each_dev(&css_bus_type, NULL, set, __unset_registered);
819+ break;
820+ case CSS_EVAL_NOT_ONLINE:
821+ bus_for_each_dev(&css_bus_type, NULL, set, __unset_online);
822+ break;
823+ default:
824+ break;
825+ }
826+
805827 /* Apply to slow_subchannel_set. */
806828 spin_lock_irqsave(&slow_subchannel_lock, flags);
807− idset_add_set(slow_subchannel_set, unreg_set);
829+ idset_add_set(slow_subchannel_set, set);
808830 atomic_set(&css_eval_scheduled, 1);
809831 queue_delayed_work(cio_work_q, &slow_path_work, delay);
810832 spin_unlock_irqrestore(&slow_subchannel_lock, flags);
811− idset_free(unreg_set);
833+ idset_free(set);
812834 }
813835
814836 void css_wait_for_slow_path(void)
@@ -820,7 +842,7 @@ void css_wait_for_slow_path(void) · 5 unmodified lines
820842 void css_schedule_reprobe(void)
821843 {
822844 /* Schedule with a delay to allow merging of subsequent calls. */
823− css_schedule_eval_all_unreg(1 * HZ);
845+ css_schedule_eval_cond(CSS_EVAL_UNREG, 1 * HZ);
824846 }
825847 EXPORT_SYMBOL_GPL(css_schedule_reprobe);
826848
drivers/s390/cio/css.h+9−1
@@ -34,6 +34,14 @@ · 33 unmodified lines
3434 #define SNID_STATE3_MULTI_PATH 1
3535 #define SNID_STATE3_SINGLE_PATH 0
3636
37+/*
38+ * Conditions used to specify which subchannels need evaluation
39+ */
40+enum css_eval_cond {
41+ CSS_EVAL_UNREG, /* unregistered subchannels */
42+ CSS_EVAL_NOT_ONLINE /* sch without an online-device */
43+};
44+
3745 struct path_state {
3846 __u8 state1 : 2; /* path state value 1 */
3947 __u8 state2 : 2; /* path state value 2 */
@@ -136,7 +144,7 @@ static inline struct channel_subsystem *css_by_id(u8 cssid) · 96 unmodified lines
136144 /* Helper functions to build lists for the slow path. */
137145 void css_schedule_eval(struct subchannel_id schid);
138146 void css_schedule_eval_all(void);
139−void css_schedule_eval_all_unreg(unsigned long delay);
147+void css_schedule_eval_cond(enum css_eval_cond, unsigned long delay);
140148 int css_complete_work(void);
141149
142150 int sch_is_pseudo_sch(struct subchannel *);
drivers/s390/crypto/vfio_ap_ops.c+3−1
@@ -361,6 +361,7 @@ err_list: · 360 unmodified lines
361361 mutex_lock(&matrix_dev->lock);
362362 list_del(&matrix_mdev->node);
363363 mutex_unlock(&matrix_dev->lock);
364+ vfio_uninit_group_dev(&matrix_mdev->vdev);
364365 kfree(matrix_mdev);
365366 err_dec_available:
366367 atomic_inc(&matrix_dev->available_instances);
@@ -376,9 +377,10 @@ static void vfio_ap_mdev_remove(struct mdev_device *mdev) · 9 unmodified lines
376377 mutex_lock(&matrix_dev->lock);
377378 vfio_ap_mdev_reset_queues(matrix_mdev);
378379 list_del(&matrix_mdev->node);
380+ mutex_unlock(&matrix_dev->lock);
381+ vfio_uninit_group_dev(&matrix_mdev->vdev);
379382 kfree(matrix_mdev);
380383 atomic_inc(&matrix_dev->available_instances);
381− mutex_unlock(&matrix_dev->lock);
382384 }
383385
384386 static ssize_t name_show(struct mdev_type *mtype,
drivers/scsi/csiostor/csio_init.c+1−0
@@ -1254,3 +1254,4 @@ MODULE_DEVICE_TABLE(pci, csio_pci_tbl); · 1253 unmodified lines
12541254 MODULE_VERSION(CSIO_DRV_VERSION);
12551255 MODULE_FIRMWARE(FW_FNAME_T5);
12561256 MODULE_FIRMWARE(FW_FNAME_T6);
1257+MODULE_SOFTDEP("pre: cxgb4");
drivers/scsi/qla2xxx/qla_isr.c+2−2
@@ -2634,7 +2634,7 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, · 2633 unmodified lines
26342634 }
26352635
26362636 if (unlikely(logit))
2637− ql_log(ql_log_warn, fcport->vha, 0x5060,
2637+ ql_log(ql_dbg_io, fcport->vha, 0x5060,
26382638 "NVME-%s ERR Handling - hdl=%x status(%x) tr_len:%x resid=%x ox_id=%x\n",
26392639 sp->name, sp->handle, comp_status,
26402640 fd->transferred_length, le32_to_cpu(sts->residual_len),
@@ -3491,7 +3491,7 @@ check_scsi_status: · 850 unmodified lines
34913491
34923492 out:
34933493 if (logit)
3494− ql_log(ql_log_warn, fcport->vha, 0x3022,
3494+ ql_log(ql_dbg_io, fcport->vha, 0x3022,
34953495 "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n",
34963496 comp_status, scsi_status, res, vha->host_no,
34973497 cp->device->id, cp->device->lun, fcport->d_id.b.domain,
drivers/scsi/ses.c+1−1
@@ -118,7 +118,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code, · 117 unmodified lines
118118 static int ses_send_diag(struct scsi_device *sdev, int page_code,
119119 void *buf, int bufflen)
120120 {
121− u32 result;
121+ int result;
122122
123123 unsigned char cmd[] = {
124124 SEND_DIAGNOSTIC,
drivers/scsi/ufs/ufshcd.c+1−2
@@ -318,8 +318,7 @@ static void ufshcd_add_query_upiu_trace(struct ufs_hba *hba, · 317 unmodified lines
318318 static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag,
319319 enum ufs_trace_str_t str_t)
320320 {
321− int off = (int)tag - hba->nutrs;
322− struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[off];
321+ struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[tag];
323322
324323 if (!trace_ufshcd_upiu_enabled())
325324 return;
drivers/scsi/virtio_scsi.c+2−2
@@ -300,7 +300,7 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi, · 299 unmodified lines
300300 }
301301 break;
302302 default:
303− pr_info("Unsupport virtio scsi event reason %x\n", event->reason);
303+ pr_info("Unsupported virtio scsi event reason %x\n", event->reason);
304304 }
305305 }
306306
@@ -392,7 +392,7 @@ static void virtscsi_handle_event(struct work_struct *work) · 85 unmodified lines
392392 virtscsi_handle_param_change(vscsi, event);
393393 break;
394394 default:
395− pr_err("Unsupport virtio scsi event %x\n", event->event);
395+ pr_err("Unsupported virtio scsi event %x\n", event->event);
396396 }
397397 virtscsi_kick_event(vscsi, event_node);
398398 }
drivers/staging/media/hantro/hantro_drv.c+1−1
@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev) · 918 unmodified lines
919919 if (!vpu->variant->irqs[i].handler)
920920 continue;
921921
922− if (vpu->variant->num_clocks > 1) {
922+ if (vpu->variant->num_irqs > 1) {
923923 irq_name = vpu->variant->irqs[i].name;
924924 irq = platform_get_irq_byname(vpu->pdev, irq_name);
925925 } else {
drivers/staging/media/sunxi/cedrus/cedrus_video.c+1−1
@@ -135,7 +135,7 @@ void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt) · 134 unmodified lines
135135 sizeimage = bytesperline * height;
136136
137137 /* Chroma plane size. */
138− sizeimage += bytesperline * height / 2;
138+ sizeimage += bytesperline * ALIGN(height, 64) / 2;
139139
140140 break;
141141
drivers/vdpa/mlx5/net/mlx5_vnet.c+5−0
@@ -1714,6 +1714,9 @@ static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready · 1713 unmodified lines
17141714 struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
17151715 struct mlx5_vdpa_virtqueue *mvq;
17161716
1717+ if (!mvdev->actual_features)
1718+ return;
1719+
17171720 if (!is_index_valid(mvdev, idx))
17181721 return;
17191722
@@ -2145,6 +2148,8 @@ static void clear_vqs_ready(struct mlx5_vdpa_net *ndev) · 425 unmodified lines
21452148
21462149 for (i = 0; i < ndev->mvdev.max_vqs; i++)
21472150 ndev->vqs[i].ready = false;
2151+
2152+ ndev->mvdev.cvq.ready = false;
21482153 }
21492154
21502155 static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
drivers/vdpa/vdpa_user/vduse_dev.c+5−5
@@ -665,13 +665,11 @@ static void vduse_vdpa_set_config(struct vdpa_device *vdpa, unsigned int offset, · 664 unmodified lines
665665 static int vduse_vdpa_reset(struct vdpa_device *vdpa)
666666 {
667667 struct vduse_dev *dev = vdpa_to_vduse(vdpa);
668−
669− if (vduse_dev_set_status(dev, 0))
670− return -EIO;
668+ int ret = vduse_dev_set_status(dev, 0);
671669
672670 vduse_dev_reset(dev);
673671
674− return 0;
672+ return ret;
675673 }
676674
677675 static u32 vduse_vdpa_get_generation(struct vdpa_device *vdpa)
@@ -1593,8 +1591,10 @@ static int vduse_init(void) · 915 unmodified lines
15931591
15941592 vduse_irq_wq = alloc_workqueue("vduse-irq",
15951593 WQ_HIGHPRI | WQ_SYSFS | WQ_UNBOUND, 0);
1596− if (!vduse_irq_wq)
1594+ if (!vduse_irq_wq) {
1595+ ret = -ENOMEM;
15971596 goto err_wq;
1597+ }
15981598
15991599 ret = vduse_domain_init();
16001600 if (ret)
drivers/vfio/pci/vfio_pci_core.c+1−1
@@ -565,7 +565,7 @@ static bool vfio_pci_dev_below_slot(struct pci_dev *pdev, struct pci_slot *slot) · 564 unmodified lines
565565 }
566566
567567 struct vfio_pci_walk_info {
568− int (*fn)(struct pci_dev *, void *data);
568+ int (*fn)(struct pci_dev *pdev, void *data);
569569 void *data;
570570 struct pci_dev *pdev;
571571 bool slot;
drivers/vhost/vdpa.c+1−1
@@ -640,7 +640,7 @@ static int vhost_vdpa_va_map(struct vhost_vdpa *v, · 639 unmodified lines
640640 u64 offset, map_size, map_iova = iova;
641641 struct vdpa_map_file *map_file;
642642 struct vm_area_struct *vma;
643− int ret;
643+ int ret = 0;
644644
645645 mmap_read_lock(dev->mm);
646646
drivers/virtio/virtio.c+6−1
@@ -345,8 +345,13 @@ static int virtio_device_of_init(struct virtio_device *dev) · 344 unmodified lines
345345 ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
346346 BUG_ON(ret >= sizeof(compat));
347347
348+ /*
349+ * On powerpc/pseries virtio devices are PCI devices so PCI
350+ * vendor/device ids play the role of the "compatible" property.
351+ * Simply don't init of_node in this case.
352+ */
348353 if (!of_device_is_compatible(np, compat)) {
349− ret = -EINVAL;
354+ ret = 0;
350355 goto out;
351356 }
352357
drivers/watchdog/Kconfig+1−1
@@ -1666,7 +1666,7 @@ config WDT_MTX1 · 1665 unmodified lines
16661666
16671667 config SIBYTE_WDOG
16681668 tristate "Sibyte SoC hardware watchdog"
1669− depends on CPU_SB1 || (MIPS && COMPILE_TEST)
1669+ depends on CPU_SB1
16701670 help
16711671 Watchdog driver for the built in watchdog hardware in Sibyte
16721672 SoC processors. There are apparently two watchdog timers
fs/binfmt_elf.c+1−1
@@ -630,7 +630,7 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex, · 629 unmodified lines
630630
631631 vaddr = eppnt->p_vaddr;
632632 if (interp_elf_ex->e_type == ET_EXEC || load_addr_set)
633− elf_type |= MAP_FIXED_NOREPLACE;
633+ elf_type |= MAP_FIXED;
634634 else if (no_base && interp_elf_ex->e_type == ET_DYN)
635635 load_addr = -vaddr;
636636
fs/debugfs/inode.c+1−1
@@ -528,7 +528,7 @@ void debugfs_create_file_size(const char *name, umode_t mode, · 527 unmodified lines
528528 {
529529 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops);
530530
531− if (de)
531+ if (!IS_ERR(de))
532532 d_inode(de)->i_size = file_size;
533533 }
534534 EXPORT_SYMBOL_GPL(debugfs_create_file_size);
fs/ext4/dir.c+3−3
@@ -551,7 +551,7 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx) · 550 unmodified lines
551551 struct dir_private_info *info = file->private_data;
552552 struct inode *inode = file_inode(file);
553553 struct fname *fname;
554− int ret;
554+ int ret = 0;
555555
556556 if (!info) {
557557 info = ext4_htree_create_dir_info(file, ctx->pos);
@@ -599,7 +599,7 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx) · 41 unmodified lines
599599 info->curr_minor_hash,
600600 &info->next_hash);
601601 if (ret < 0)
602− return ret;
602+ goto finished;
603603 if (ret == 0) {
604604 ctx->pos = ext4_get_htree_eof(file);
605605 break;
@@ -630,7 +630,7 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx) · 24 unmodified lines
630630 }
631631 finished:
632632 info->last_pos = ctx->pos;
633− return 0;
633+ return ret < 0 ? ret : 0;
634634 }
635635
636636 static int ext4_release_dir(struct inode *inode, struct file *filp)
fs/ext4/ext4.h+0−3
@@ -3593,9 +3593,6 @@ extern int ext4_da_write_inline_data_begin(struct address_space *mapping, · 3592 unmodified lines
35933593 unsigned flags,
35943594 struct page **pagep,
35953595 void **fsdata);
3596−extern int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
3597− unsigned len, unsigned copied,
3598− struct page *page);
35993596 extern int ext4_try_add_inline_entry(handle_t *handle,
36003597 struct ext4_filename *fname,
36013598 struct inode *dir, struct inode *inode);
fs/ext4/extents.c+14−5
@@ -5916,7 +5916,7 @@ void ext4_ext_replay_shrink_inode(struct inode *inode, ext4_lblk_t end) · 5915 unmodified lines
59165916 }
59175917
59185918 /* Check if *cur is a hole and if it is, skip it */
5919−static void skip_hole(struct inode *inode, ext4_lblk_t *cur)
5919+static int skip_hole(struct inode *inode, ext4_lblk_t *cur)
59205920 {
59215921 int ret;
59225922 struct ext4_map_blocks map;
@@ -5925,9 +5925,12 @@ static void skip_hole(struct inode *inode, ext4_lblk_t *cur) · 2 unmodified lines
59255925 map.m_len = ((inode->i_size) >> inode->i_sb->s_blocksize_bits) - *cur;
59265926
59275927 ret = ext4_map_blocks(NULL, inode, &map, 0);
5928+ if (ret < 0)
5929+ return ret;
59285930 if (ret != 0)
5929− return;
5931+ return 0;
59305932 *cur = *cur + map.m_len;
5933+ return 0;
59315934 }
59325935
59335936 /* Count number of blocks used by this inode and update i_blocks */
@@ -5976,7 +5979,9 @@ int ext4_ext_replay_set_iblocks(struct inode *inode) · 42 unmodified lines
59765979 * iblocks by total number of differences found.
59775980 */
59785981 cur = 0;
5979− skip_hole(inode, &cur);
5982+ ret = skip_hole(inode, &cur);
5983+ if (ret < 0)
5984+ goto out;
59805985 path = ext4_find_extent(inode, cur, NULL, 0);
59815986 if (IS_ERR(path))
59825987 goto out;
@@ -5995,8 +6000,12 @@ int ext4_ext_replay_set_iblocks(struct inode *inode) · 12 unmodified lines
59956000 }
59966001 cur = max(cur + 1, le32_to_cpu(ex->ee_block) +
59976002 ext4_ext_get_actual_len(ex));
5998− skip_hole(inode, &cur);
5999−
6003+ ret = skip_hole(inode, &cur);
6004+ if (ret < 0) {
6005+ ext4_ext_drop_refs(path);
6006+ kfree(path);
6007+ break;
6008+ }
60006009 path2 = ext4_find_extent(inode, cur, NULL, 0);
60016010 if (IS_ERR(path2)) {
60026011 ext4_ext_drop_refs(path);
fs/ext4/fast_commit.c+6−0
@@ -892,6 +892,12 @@ static int ext4_fc_write_inode_data(struct inode *inode, u32 *crc) · 891 unmodified lines
892892 sizeof(lrange), (u8 *)&lrange, crc))
893893 return -ENOSPC;
894894 } else {
895+ unsigned int max = (map.m_flags & EXT4_MAP_UNWRITTEN) ?
896+ EXT_UNWRITTEN_MAX_LEN : EXT_INIT_MAX_LEN;
897+
898+ /* Limit the number of blocks in one extent */
899+ map.m_len = min(max, map.m_len);
900+
895901 fc_ext.fc_ino = cpu_to_le32(inode->i_ino);
896902 ex = (struct ext4_extent *)&fc_ext.fc_ex;
897903 ex->ee_block = cpu_to_le32(map.m_lblk);
fs/ext4/inline.c+85−65
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #include <linux/iomap.h>
88 #include <linux/fiemap.h>
99 #include <linux/iversion.h>
10+#include <linux/backing-dev.h>
1011
1112 #include "ext4_jbd2.h"
1213 #include "ext4.h"
@@ -733,45 +734,83 @@ convert: · 720 unmodified lines
733734 int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
734735 unsigned copied, struct page *page)
735736 {
736− int ret, no_expand;
737+ handle_t *handle = ext4_journal_current_handle();
738+ int no_expand;
737739 void *kaddr;
738740 struct ext4_iloc iloc;
741+ int ret = 0, ret2;
742+
743+ if (unlikely(copied < len) && !PageUptodate(page))
744+ copied = 0;
739745
740− if (unlikely(copied < len)) {
741− if (!PageUptodate(page)) {
742− copied = 0;
746+ if (likely(copied)) {
747+ ret = ext4_get_inode_loc(inode, &iloc);
748+ if (ret) {
749+ unlock_page(page);
750+ put_page(page);
751+ ext4_std_error(inode->i_sb, ret);
743752 goto out;
744753 }
745− }
754+ ext4_write_lock_xattr(inode, &no_expand);
755+ BUG_ON(!ext4_has_inline_data(inode));
746756
747− ret = ext4_get_inode_loc(inode, &iloc);
748− if (ret) {
749− ext4_std_error(inode->i_sb, ret);
750− copied = 0;
751− goto out;
752− }
757+ /*
758+ * ei->i_inline_off may have changed since
759+ * ext4_write_begin() called
760+ * ext4_try_to_write_inline_data()
761+ */
762+ (void) ext4_find_inline_data_nolock(inode);
753763
754− ext4_write_lock_xattr(inode, &no_expand);
755− BUG_ON(!ext4_has_inline_data(inode));
764+ kaddr = kmap_atomic(page);
765+ ext4_write_inline_data(inode, &iloc, kaddr, pos, copied);
766+ kunmap_atomic(kaddr);
767+ SetPageUptodate(page);
768+ /* clear page dirty so that writepages wouldn't work for us. */
769+ ClearPageDirty(page);
756770
757− /*
758− * ei->i_inline_off may have changed since ext4_write_begin()
759− * called ext4_try_to_write_inline_data()
760− */
761− (void) ext4_find_inline_data_nolock(inode);
771+ ext4_write_unlock_xattr(inode, &no_expand);
772+ brelse(iloc.bh);
762773
763− kaddr = kmap_atomic(page);
764− ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
765− kunmap_atomic(kaddr);
766− SetPageUptodate(page);
767− /* clear page dirty so that writepages wouldn't work for us. */
768− ClearPageDirty(page);
774+ /*
775+ * It's important to update i_size while still holding page
776+ * lock: page writeout could otherwise come in and zero
777+ * beyond i_size.
778+ */
779+ ext4_update_inode_size(inode, pos + copied);
780+ }
781+ unlock_page(page);
782+ put_page(page);
769783
770− ext4_write_unlock_xattr(inode, &no_expand);
771− brelse(iloc.bh);
772− mark_inode_dirty(inode);
784+ /*
785+ * Don't mark the inode dirty under page lock. First, it unnecessarily
786+ * makes the holding time of page lock longer. Second, it forces lock
787+ * ordering of page lock and transaction start for journaling
788+ * filesystems.
789+ */
790+ if (likely(copied))
791+ mark_inode_dirty(inode);
773792 out:
774− return copied;
793+ /*
794+ * If we didn't copy as much data as expected, we need to trim back
795+ * size of xattr containing inline data.
796+ */
797+ if (pos + len > inode->i_size && ext4_can_truncate(inode))
798+ ext4_orphan_add(handle, inode);
799+
800+ ret2 = ext4_journal_stop(handle);
801+ if (!ret)
802+ ret = ret2;
803+ if (pos + len > inode->i_size) {
804+ ext4_truncate_failed_write(inode);
805+ /*
806+ * If truncate failed early the inode might still be
807+ * on the orphan list; we need to make sure the inode
808+ * is removed from the orphan list in that case.
809+ */
810+ if (inode->i_nlink)
811+ ext4_orphan_del(NULL, inode);
812+ }
813+ return ret ? ret : copied;
775814 }
776815
777816 struct buffer_head *
@@ -953,43 +992,6 @@ out: · 175 unmodified lines
953992 return ret;
954993 }
955994
956−int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
957− unsigned len, unsigned copied,
958− struct page *page)
959−{
960− int ret;
961−
962− ret = ext4_write_inline_data_end(inode, pos, len, copied, page);
963− if (ret < 0) {
964− unlock_page(page);
965− put_page(page);
966− return ret;
967− }
968− copied = ret;
969−
970− /*
971− * No need to use i_size_read() here, the i_size
972− * cannot change under us because we hold i_mutex.
973− *
974− * But it's important to update i_size while still holding page lock:
975− * page writeout could otherwise come in and zero beyond i_size.
976− */
977− if (pos+copied > inode->i_size)
978− i_size_write(inode, pos+copied);
979− unlock_page(page);
980− put_page(page);
981−
982− /*
983− * Don't mark the inode dirty under page lock. First, it unnecessarily
984− * makes the holding time of page lock longer. Second, it forces lock
985− * ordering of page lock and transaction start for journaling
986− * filesystems.
987− */
988− mark_inode_dirty(inode);
989−
990− return copied;
991−}
992−
993995 #ifdef INLINE_DIR_DEBUG
994996 void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
995997 void *inline_start, int inline_size)
@@ -1917,6 +1919,24 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline) · 921 unmodified lines
19171919 EXT4_I(inode)->i_disksize = i_size;
19181920
19191921 if (i_size < inline_size) {
1922+ /*
1923+ * if there's inline data to truncate and this file was
1924+ * converted to extents after that inline data was written,
1925+ * the extent status cache must be cleared to avoid leaving
1926+ * behind stale delayed allocated extent entries
1927+ */
1928+ if (!ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
1929+retry:
1930+ err = ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
1931+ if (err == -ENOMEM) {
1932+ cond_resched();
1933+ congestion_wait(BLK_RW_ASYNC, HZ/50);
1934+ goto retry;
1935+ }
1936+ if (err)
1937+ goto out_error;
1938+ }
1939+
19201940 /* Clear the content in the xattr space. */
19211941 if (inline_size > EXT4_MIN_INLINE_DATA_SIZE) {
19221942 if ((err = ext4_xattr_ibody_find(inode, &i, &is)) != 0)
fs/ext4/inode.c+59−117
@@ -1284,22 +1284,14 @@ static int ext4_write_end(struct file *file, · 1283 unmodified lines
12841284 loff_t old_size = inode->i_size;
12851285 int ret = 0, ret2;
12861286 int i_size_changed = 0;
1287− int inline_data = ext4_has_inline_data(inode);
12881287 bool verity = ext4_verity_in_progress(inode);
12891288
12901289 trace_ext4_write_end(inode, pos, len, copied);
1291− if (inline_data) {
1292− ret = ext4_write_inline_data_end(inode, pos, len,
1293− copied, page);
1294− if (ret < 0) {
1295− unlock_page(page);
1296− put_page(page);
1297− goto errout;
1298− }
1299− copied = ret;
1300− } else
1301− copied = block_write_end(file, mapping, pos,
1302− len, copied, page, fsdata);
1290+
1291+ if (ext4_has_inline_data(inode))
1292+ return ext4_write_inline_data_end(inode, pos, len, copied, page);
1293+
1294+ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
13031295 /*
13041296 * it's important to update i_size while still holding page lock:
13051297 * page writeout could otherwise come in and zero beyond i_size.
@@ -1320,7 +1312,7 @@ static int ext4_write_end(struct file *file, · 14 unmodified lines
13201312 * ordering of page lock and transaction start for journaling
13211313 * filesystems.
13221314 */
1323− if (i_size_changed || inline_data)
1315+ if (i_size_changed)
13241316 ret = ext4_mark_inode_dirty(handle, inode);
13251317
13261318 if (pos + len > inode->i_size && !verity && ext4_can_truncate(inode))
@@ -1329,7 +1321,7 @@ static int ext4_write_end(struct file *file, · 2 unmodified lines
13291321 * inode->i_size. So truncate them
13301322 */
13311323 ext4_orphan_add(handle, inode);
1332−errout:
1324+
13331325 ret2 = ext4_journal_stop(handle);
13341326 if (!ret)
13351327 ret = ret2;
@@ -1395,7 +1387,6 @@ static int ext4_journalled_write_end(struct file *file, · 59 unmodified lines
13951387 int partial = 0;
13961388 unsigned from, to;
13971389 int size_changed = 0;
1398− int inline_data = ext4_has_inline_data(inode);
13991390 bool verity = ext4_verity_in_progress(inode);
14001391
14011392 trace_ext4_journalled_write_end(inode, pos, len, copied);
@@ -1404,16 +1395,10 @@ static int ext4_journalled_write_end(struct file *file, · 2 unmodified lines
14041395
14051396 BUG_ON(!ext4_handle_valid(handle));
14061397
1407− if (inline_data) {
1408− ret = ext4_write_inline_data_end(inode, pos, len,
1409− copied, page);
1410− if (ret < 0) {
1411− unlock_page(page);
1412− put_page(page);
1413− goto errout;
1414− }
1415− copied = ret;
1416− } else if (unlikely(copied < len) && !PageUptodate(page)) {
1398+ if (ext4_has_inline_data(inode))
1399+ return ext4_write_inline_data_end(inode, pos, len, copied, page);
1400+
1401+ if (unlikely(copied < len) && !PageUptodate(page)) {
14171402 copied = 0;
14181403 ext4_journalled_zero_new_buffers(handle, inode, page, from, to);
14191404 } else {
@@ -1436,7 +1421,7 @@ static int ext4_journalled_write_end(struct file *file, · 16 unmodified lines
14361421 if (old_size < pos && !verity)
14371422 pagecache_isize_extended(inode, old_size, pos);
14381423
1439− if (size_changed || inline_data) {
1424+ if (size_changed) {
14401425 ret2 = ext4_mark_inode_dirty(handle, inode);
14411426 if (!ret)
14421427 ret = ret2;
@@ -1449,7 +1434,6 @@ static int ext4_journalled_write_end(struct file *file, · 6 unmodified lines
14491434 */
14501435 ext4_orphan_add(handle, inode);
14511436
1452−errout:
14531437 ret2 = ext4_journal_stop(handle);
14541438 if (!ret)
14551439 ret = ret2;
@@ -1644,6 +1628,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk) · 188 unmodified lines
16441628 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
16451629 int ret;
16461630 bool allocated = false;
1631+ bool reserved = false;
16471632
16481633 /*
16491634 * If the cluster containing lblk is shared with a delayed,
@@ -1660,6 +1645,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk) · 10 unmodified lines
16601645 ret = ext4_da_reserve_space(inode);
16611646 if (ret != 0) /* ENOSPC */
16621647 goto errout;
1648+ reserved = true;
16631649 } else { /* bigalloc */
16641650 if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
16651651 if (!ext4_es_scan_clu(inode,
@@ -1672,6 +1658,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk) · 6 unmodified lines
16721658 ret = ext4_da_reserve_space(inode);
16731659 if (ret != 0) /* ENOSPC */
16741660 goto errout;
1661+ reserved = true;
16751662 } else {
16761663 allocated = true;
16771664 }
@@ -1682,6 +1669,8 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk) · 4 unmodified lines
16821669 }
16831670
16841671 ret = ext4_es_insert_delayed_block(inode, lblk, allocated);
1672+ if (ret && reserved)
1673+ ext4_da_release_space(inode, 1);
16851674
16861675 errout:
16871676 return ret;
@@ -1722,13 +1711,16 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, · 34 unmodified lines
17221711 }
17231712
17241713 /*
1725− * Delayed extent could be allocated by fallocate.
1726− * So we need to check it.
1714+ * the buffer head associated with a delayed and not unwritten
1715+ * block found in the extent status cache must contain an
1716+ * invalid block number and have its BH_New and BH_Delay bits
1717+ * set, reflecting the state assigned when the block was
1718+ * initially delayed allocated
17271719 */
1728− if (ext4_es_is_delayed(&es) && !ext4_es_is_unwritten(&es)) {
1729− map_bh(bh, inode->i_sb, invalid_block);
1730− set_buffer_new(bh);
1731− set_buffer_delay(bh);
1720+ if (ext4_es_is_delonly(&es)) {
1721+ BUG_ON(bh->b_blocknr != invalid_block);
1722+ BUG_ON(!buffer_new(bh));
1723+ BUG_ON(!buffer_delay(bh));
17321724 return 0;
17331725 }
17341726
@@ -2932,19 +2924,6 @@ static int ext4_nonda_switch(struct super_block *sb) · 1197 unmodified lines
29322924 return 0;
29332925 }
29342926
2935−/* We always reserve for an inode update; the superblock could be there too */
2936−static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
2937−{
2938− if (likely(ext4_has_feature_large_file(inode->i_sb)))
2939− return 1;
2940−
2941− if (pos + len <= 0x7fffffffULL)
2942− return 1;
2943−
2944− /* We might need to update the superblock to set LARGE_FILE */
2945− return 2;
2946−}
2947−
29482927 static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
29492928 loff_t pos, unsigned len, unsigned flags,
29502929 struct page **pagep, void **fsdata)
@@ -2953,7 +2932,6 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, · 2 unmodified lines
29532932 struct page *page;
29542933 pgoff_t index;
29552934 struct inode *inode = mapping->host;
2956− handle_t *handle;
29572935
29582936 if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
29592937 return -EIO;
@@ -2979,41 +2957,11 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, · 19 unmodified lines
29792957 return 0;
29802958 }
29812959
2982− /*
2983− * grab_cache_page_write_begin() can take a long time if the
2984− * system is thrashing due to memory pressure, or if the page
2985− * is being written back. So grab it first before we start
2986− * the transaction handle. This also allows us to allocate
2987− * the page (if needed) without using GFP_NOFS.
2988− */
2989−retry_grab:
2960+retry:
29902961 page = grab_cache_page_write_begin(mapping, index, flags);
29912962 if (!page)
29922963 return -ENOMEM;
2993− unlock_page(page);
29942964
2995− /*
2996− * With delayed allocation, we don't log the i_disksize update
2997− * if there is delayed block allocation. But we still need
2998− * to journalling the i_disksize update if writes to the end
2999− * of file which has an already mapped buffer.
3000− */
3001−retry_journal:
3002− handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
3003− ext4_da_write_credits(inode, pos, len));
3004− if (IS_ERR(handle)) {
3005− put_page(page);
3006− return PTR_ERR(handle);
3007− }
3008−
3009− lock_page(page);
3010− if (page->mapping != mapping) {
3011− /* The page got truncated from under us */
3012− unlock_page(page);
3013− put_page(page);
3014− ext4_journal_stop(handle);
3015− goto retry_grab;
3016− }
30172965 /* In case writeback began while the page was unlocked */
30182966 wait_for_stable_page(page);
30192967
@@ -3025,20 +2973,18 @@ retry_journal: · 5 unmodified lines
30252973 #endif
30262974 if (ret < 0) {
30272975 unlock_page(page);
3028− ext4_journal_stop(handle);
2976+ put_page(page);
30292977 /*
30302978 * block_write_begin may have instantiated a few blocks
30312979 * outside i_size. Trim these off again. Don't need
3032− * i_size_read because we hold i_mutex.
2980+ * i_size_read because we hold inode lock.
30332981 */
30342982 if (pos + len > inode->i_size)
30352983 ext4_truncate_failed_write(inode);
30362984
30372985 if (ret == -ENOSPC &&
30382986 ext4_should_retry_alloc(inode->i_sb, &retries))
3039− goto retry_journal;
3040−
3041− put_page(page);
2987+ goto retry;
30422988 return ret;
30432989 }
30442990
@@ -3075,8 +3021,6 @@ static int ext4_da_write_end(struct file *file, · 30 unmodified lines
30753021 struct page *page, void *fsdata)
30763022 {
30773023 struct inode *inode = mapping->host;
3078− int ret = 0, ret2;
3079− handle_t *handle = ext4_journal_current_handle();
30803024 loff_t new_i_size;
30813025 unsigned long start, end;
30823026 int write_mode = (int)(unsigned long)fsdata;
@@ -3086,44 +3030,36 @@ static int ext4_da_write_end(struct file *file, · 3 unmodified lines
30863030 len, copied, page, fsdata);
30873031
30883032 trace_ext4_da_write_end(inode, pos, len, copied);
3033+
3034+ if (write_mode != CONVERT_INLINE_DATA &&
3035+ ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA) &&
3036+ ext4_has_inline_data(inode))
3037+ return ext4_write_inline_data_end(inode, pos, len, copied, page);
3038+
30893039 start = pos & (PAGE_SIZE - 1);
30903040 end = start + copied - 1;
30913041
30923042 /*
3093− * generic_write_end() will run mark_inode_dirty() if i_size
3094− * changes. So let's piggyback the i_disksize mark_inode_dirty
3095− * into that.
3043+ * Since we are holding inode lock, we are sure i_disksize <=
3044+ * i_size. We also know that if i_disksize < i_size, there are
3045+ * delalloc writes pending in the range upto i_size. If the end of
3046+ * the current write is <= i_size, there's no need to touch
3047+ * i_disksize since writeback will push i_disksize upto i_size
3048+ * eventually. If the end of the current write is > i_size and
3049+ * inside an allocated block (ext4_da_should_update_i_disksize()
3050+ * check), we need to update i_disksize here as neither
3051+ * ext4_writepage() nor certain ext4_writepages() paths not
3052+ * allocating blocks update i_disksize.
3053+ *
3054+ * Note that we defer inode dirtying to generic_write_end() /
3055+ * ext4_da_write_inline_data_end().
30963056 */
30973057 new_i_size = pos + copied;
3098− if (copied && new_i_size > EXT4_I(inode)->i_disksize) {
3099− if (ext4_has_inline_data(inode) ||
3100− ext4_da_should_update_i_disksize(page, end)) {
3101− ext4_update_i_disksize(inode, new_i_size);
3102− /* We need to mark inode dirty even if
3103− * new_i_size is less that inode->i_size
3104− * bu greater than i_disksize.(hint delalloc)
3105− */
3106− ret = ext4_mark_inode_dirty(handle, inode);
3107− }
3108− }
3058+ if (copied && new_i_size > inode->i_size &&
3059+ ext4_da_should_update_i_disksize(page, end))
3060+ ext4_update_i_disksize(inode, new_i_size);
31093061
3110− if (write_mode != CONVERT_INLINE_DATA &&
3111− ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA) &&
3112− ext4_has_inline_data(inode))
3113− ret2 = ext4_da_write_inline_data_end(inode, pos, len, copied,
3114− page);
3115− else
3116− ret2 = generic_write_end(file, mapping, pos, len, copied,
3117− page, fsdata);
3118−
3119− copied = ret2;
3120− if (ret2 < 0)
3121− ret = ret2;
3122− ret2 = ext4_journal_stop(handle);
3123− if (unlikely(ret2 && !ret))
3124− ret = ret2;
3125−
3126− return ret ? ret : copied;
3062+ return generic_write_end(file, mapping, pos, len, copied, page, fsdata);
31273063 }
31283064
31293065 /*
@@ -4340,6 +4276,12 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino, · 1210 unmodified lines
43404276 goto has_buffer;
43414277
43424278 lock_buffer(bh);
4279+ if (ext4_buffer_uptodate(bh)) {
4280+ /* Someone brought it uptodate while we waited */
4281+ unlock_buffer(bh);
4282+ goto has_buffer;
4283+ }
4284+
43434285 /*
43444286 * If we have all information of the inode in memory and this
43454287 * is the only valid inode in the block, we need not read the
fs/ext4/super.c+15−6
@@ -658,7 +658,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error, · 657 unmodified lines
658658 * constraints, it may not be safe to do it right here so we
659659 * defer superblock flushing to a workqueue.
660660 */
661− if (continue_fs)
661+ if (continue_fs && journal)
662662 schedule_work(&EXT4_SB(sb)->s_error_work);
663663 else
664664 ext4_commit_super(sb);
@@ -1350,6 +1350,12 @@ static void ext4_destroy_inode(struct inode *inode) · 685 unmodified lines
13501350 true);
13511351 dump_stack();
13521352 }
1353+
1354+ if (EXT4_I(inode)->i_reserved_data_blocks)
1355+ ext4_msg(inode->i_sb, KERN_ERR,
1356+ "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!",
1357+ inode->i_ino, EXT4_I(inode),
1358+ EXT4_I(inode)->i_reserved_data_blocks);
13531359 }
13541360
13551361 static void init_once(void *foo)
@@ -3021,17 +3027,17 @@ static loff_t ext4_max_size(int blkbits, int has_huge_files) · 1665 unmodified lines
30213027 */
30223028 static loff_t ext4_max_bitmap_size(int bits, int has_huge_files)
30233029 {
3024− loff_t res = EXT4_NDIR_BLOCKS;
3030+ unsigned long long upper_limit, res = EXT4_NDIR_BLOCKS;
30253031 int meta_blocks;
3026− loff_t upper_limit;
3027− /* This is calculated to be the largest file size for a dense, block
3032+
3033+ /*
3034+ * This is calculated to be the largest file size for a dense, block
30283035 * mapped file such that the file's total number of 512-byte sectors,
30293036 * including data and all indirect blocks, does not exceed (2^48 - 1).
30303037 *
30313038 * __u32 i_blocks_lo and _u16 i_blocks_high represent the total
30323039 * number of 512-byte sectors of the file.
30333040 */
3034−
30353041 if (!has_huge_files) {
30363042 /*
30373043 * !has_huge_files or implies that the inode i_block field
@@ -3074,7 +3080,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) · 36 unmodified lines
30743080 if (res > MAX_LFS_FILESIZE)
30753081 res = MAX_LFS_FILESIZE;
30763082
3077− return res;
3083+ return (loff_t)res;
30783084 }
30793085
30803086 static ext4_fsblk_t descriptor_loc(struct super_block *sb,
@@ -5042,12 +5048,15 @@ failed_mount_wq: · 1961 unmodified lines
50425048 sbi->s_ea_block_cache = NULL;
50435049
50445050 if (sbi->s_journal) {
5051+ /* flush s_error_work before journal destroy. */
5052+ flush_work(&sbi->s_error_work);
50455053 jbd2_journal_destroy(sbi->s_journal);
50465054 sbi->s_journal = NULL;
50475055 }
50485056 failed_mount3a:
50495057 ext4_es_unregister_shrinker(sbi);
50505058 failed_mount3:
5059+ /* flush s_error_work before sbi destroy */
50515060 flush_work(&sbi->s_error_work);
50525061 del_timer_sync(&sbi->s_err_report);
50535062 ext4_stop_mmpd(sbi);
fs/io-wq.c+1−4
@@ -584,10 +584,7 @@ loop: · 583 unmodified lines
584584
585585 if (!get_signal(&ksig))
586586 continue;
587− if (fatal_signal_pending(current) ||
588− signal_group_exit(current->signal))
589− break;
590− continue;
587+ break;
591588 }
592589 last_timeout = !ret;
593590 }
fs/io_uring.c+2−15
@@ -403,7 +403,6 @@ struct io_ring_ctx { · 402 unmodified lines
403403 struct wait_queue_head cq_wait;
404404 unsigned cq_extra;
405405 atomic_t cq_timeouts;
406− struct fasync_struct *cq_fasync;
407406 unsigned cq_last_tm_flush;
408407 } ____cacheline_aligned_in_smp;
409408
@@ -1614,10 +1613,8 @@ static void io_cqring_ev_posted(struct io_ring_ctx *ctx) · 1204 unmodified lines
16141613 wake_up(&ctx->sq_data->wait);
16151614 if (io_should_trigger_evfd(ctx))
16161615 eventfd_signal(ctx->cq_ev_fd, 1);
1617− if (waitqueue_active(&ctx->poll_wait)) {
1616+ if (waitqueue_active(&ctx->poll_wait))
16181617 wake_up_interruptible(&ctx->poll_wait);
1619− kill_fasync(&ctx->cq_fasync, SIGIO, POLL_IN);
1620− }
16211618 }
16221619
16231620 static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx)
@@ -1631,10 +1628,8 @@ static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx) · 7 unmodified lines
16311628 }
16321629 if (io_should_trigger_evfd(ctx))
16331630 eventfd_signal(ctx->cq_ev_fd, 1);
1634− if (waitqueue_active(&ctx->poll_wait)) {
1631+ if (waitqueue_active(&ctx->poll_wait))
16351632 wake_up_interruptible(&ctx->poll_wait);
1636− kill_fasync(&ctx->cq_fasync, SIGIO, POLL_IN);
1637− }
16381633 }
16391634
16401635 /* Returns true if there are no backlogged entries after the flush */
@@ -9345,13 +9340,6 @@ static __poll_t io_uring_poll(struct file *file, poll_table *wait) · 7704 unmodified lines
93459340 return mask;
93469341 }
93479342
9348−static int io_uring_fasync(int fd, struct file *file, int on)
9349−{
9350− struct io_ring_ctx *ctx = file->private_data;
9351−
9352− return fasync_helper(fd, file, on, &ctx->cq_fasync);
9353−}
9354−
93559343 static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id)
93569344 {
93579345 const struct cred *creds;
@@ -10145,7 +10133,6 @@ static const struct file_operations io_uring_fops = { · 787 unmodified lines
1014510133 .mmap_capabilities = io_uring_nommu_mmap_capabilities,
1014610134 #endif
1014710135 .poll = io_uring_poll,
10148− .fasync = io_uring_fasync,
1014910136 #ifdef CONFIG_PROC_FS
1015010137 .show_fdinfo = io_uring_show_fdinfo,
1015110138 #endif
fs/kernfs/dir.c+7−2
@@ -1116,8 +1116,13 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir, · 1115 unmodified lines
11161116 if (!inode)
11171117 inode = ERR_PTR(-ENOMEM);
11181118 }
1119− /* Needed only for negative dentry validation */
1120− if (!inode)
1119+ /*
1120+ * Needed for negative dentry validation.
1121+ * The negative dentry can be created in kernfs_iop_lookup()
1122+ * or transforms from positive dentry in dentry_unlink_inode()
1123+ * called from vfs_rmdir().
1124+ */
1125+ if (!IS_ERR(inode))
11211126 kernfs_set_rev(parent, dentry);
11221127 up_read(&kernfs_rwsem);
11231128
fs/ksmbd/auth.c+0−205
@@ -68,125 +68,6 @@ void ksmbd_copy_gss_neg_header(void *buf) · 67 unmodified lines
6868 memcpy(buf, NEGOTIATE_GSS_HEADER, AUTH_GSS_LENGTH);
6969 }
7070
71−static void
72−str_to_key(unsigned char *str, unsigned char *key)
73−{
74− int i;
75−
76− key[0] = str[0] >> 1;
77− key[1] = ((str[0] & 0x01) << 6) | (str[1] >> 2);
78− key[2] = ((str[1] & 0x03) << 5) | (str[2] >> 3);
79− key[3] = ((str[2] & 0x07) << 4) | (str[3] >> 4);
80− key[4] = ((str[3] & 0x0F) << 3) | (str[4] >> 5);
81− key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
82− key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
83− key[7] = str[6] & 0x7F;
84− for (i = 0; i < 8; i++)
85− key[i] = (key[i] << 1);
86−}
87−
88−static int
89−smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)
90−{
91− unsigned char key2[8];
92− struct des_ctx ctx;
93−
94− if (fips_enabled) {
95− ksmbd_debug(AUTH, "FIPS compliance enabled: DES not permitted\n");
96− return -ENOENT;
97− }
98−
99− str_to_key(key, key2);
100− des_expand_key(&ctx, key2, DES_KEY_SIZE);
101− des_encrypt(&ctx, out, in);
102− memzero_explicit(&ctx, sizeof(ctx));
103− return 0;
104−}
105−
106−static int ksmbd_enc_p24(unsigned char *p21, const unsigned char *c8, unsigned char *p24)
107−{
108− int rc;
109−
110− rc = smbhash(p24, c8, p21);
111− if (rc)
112− return rc;
113− rc = smbhash(p24 + 8, c8, p21 + 7);
114− if (rc)
115− return rc;
116− return smbhash(p24 + 16, c8, p21 + 14);
117−}
118−
119−/* produce a md4 message digest from data of length n bytes */
120−static int ksmbd_enc_md4(unsigned char *md4_hash, unsigned char *link_str,
121− int link_len)
122−{
123− int rc;
124− struct ksmbd_crypto_ctx *ctx;
125−
126− ctx = ksmbd_crypto_ctx_find_md4();
127− if (!ctx) {
128− ksmbd_debug(AUTH, "Crypto md4 allocation error\n");
129− return -ENOMEM;
130− }
131−
132− rc = crypto_shash_init(CRYPTO_MD4(ctx));
133− if (rc) {
134− ksmbd_debug(AUTH, "Could not init md4 shash\n");
135− goto out;
136− }
137−
138− rc = crypto_shash_update(CRYPTO_MD4(ctx), link_str, link_len);
139− if (rc) {
140− ksmbd_debug(AUTH, "Could not update with link_str\n");
141− goto out;
142− }
143−
144− rc = crypto_shash_final(CRYPTO_MD4(ctx), md4_hash);
145− if (rc)
146− ksmbd_debug(AUTH, "Could not generate md4 hash\n");
147−out:
148− ksmbd_release_crypto_ctx(ctx);
149− return rc;
150−}
151−
152−static int ksmbd_enc_update_sess_key(unsigned char *md5_hash, char *nonce,
153− char *server_challenge, int len)
154−{
155− int rc;
156− struct ksmbd_crypto_ctx *ctx;
157−
158− ctx = ksmbd_crypto_ctx_find_md5();
159− if (!ctx) {
160− ksmbd_debug(AUTH, "Crypto md5 allocation error\n");
161− return -ENOMEM;
162− }
163−
164− rc = crypto_shash_init(CRYPTO_MD5(ctx));
165− if (rc) {
166− ksmbd_debug(AUTH, "Could not init md5 shash\n");
167− goto out;
168− }
169−
170− rc = crypto_shash_update(CRYPTO_MD5(ctx), server_challenge, len);
171− if (rc) {
172− ksmbd_debug(AUTH, "Could not update with challenge\n");
173− goto out;
174− }
175−
176− rc = crypto_shash_update(CRYPTO_MD5(ctx), nonce, len);
177− if (rc) {
178− ksmbd_debug(AUTH, "Could not update with nonce\n");
179− goto out;
180− }
181−
182− rc = crypto_shash_final(CRYPTO_MD5(ctx), md5_hash);
183− if (rc)
184− ksmbd_debug(AUTH, "Could not generate md5 hash\n");
185−out:
186− ksmbd_release_crypto_ctx(ctx);
187− return rc;
188−}
189−
19071 /**
19172 * ksmbd_gen_sess_key() - function to generate session key
19273 * @sess: session of connection
@@ -324,43 +205,6 @@ out: · 131 unmodified lines
324205 return ret;
325206 }
326207
327−/**
328− * ksmbd_auth_ntlm() - NTLM authentication handler
329− * @sess: session of connection
330− * @pw_buf: NTLM challenge response
331− * @passkey: user password
332− *
333− * Return: 0 on success, error number on error
334− */
335−int ksmbd_auth_ntlm(struct ksmbd_session *sess, char *pw_buf)
336−{
337− int rc;
338− unsigned char p21[21];
339− char key[CIFS_AUTH_RESP_SIZE];
340−
341− memset(p21, '\0', 21);
342− memcpy(p21, user_passkey(sess->user), CIFS_NTHASH_SIZE);
343− rc = ksmbd_enc_p24(p21, sess->ntlmssp.cryptkey, key);
344− if (rc) {
345− pr_err("password processing failed\n");
346− return rc;
347− }
348−
349− ksmbd_enc_md4(sess->sess_key, user_passkey(sess->user),
350− CIFS_SMB1_SESSKEY_SIZE);
351− memcpy(sess->sess_key + CIFS_SMB1_SESSKEY_SIZE, key,
352− CIFS_AUTH_RESP_SIZE);
353− sess->sequence_number = 1;
354−
355− if (strncmp(pw_buf, key, CIFS_AUTH_RESP_SIZE) != 0) {
356− ksmbd_debug(AUTH, "ntlmv1 authentication failed\n");
357− return -EINVAL;
358− }
359−
360− ksmbd_debug(AUTH, "ntlmv1 authentication pass\n");
361− return 0;
362−}
363−
364208 /**
365209 * ksmbd_auth_ntlmv2() - NTLMv2 authentication handler
366210 * @sess: session of connection
@@ -441,44 +285,6 @@ out: · 74 unmodified lines
441285 return rc;
442286 }
443287
444−/**
445− * __ksmbd_auth_ntlmv2() - NTLM2(extended security) authentication handler
446− * @sess: session of connection
447− * @client_nonce: client nonce from LM response.
448− * @ntlm_resp: ntlm response data from client.
449− *
450− * Return: 0 on success, error number on error
451− */
452−static int __ksmbd_auth_ntlmv2(struct ksmbd_session *sess, char *client_nonce,
453− char *ntlm_resp)
454−{
455− char sess_key[CIFS_SMB1_SESSKEY_SIZE] = {0};
456− int rc;
457− unsigned char p21[21];
458− char key[CIFS_AUTH_RESP_SIZE];
459−
460− rc = ksmbd_enc_update_sess_key(sess_key,
461− client_nonce,
462− (char *)sess->ntlmssp.cryptkey, 8);
463− if (rc) {
464− pr_err("password processing failed\n");
465− goto out;
466− }
467−
468− memset(p21, '\0', 21);
469− memcpy(p21, user_passkey(sess->user), CIFS_NTHASH_SIZE);
470− rc = ksmbd_enc_p24(p21, sess_key, key);
471− if (rc) {
472− pr_err("password processing failed\n");
473− goto out;
474− }
475−
476− if (memcmp(ntlm_resp, key, CIFS_AUTH_RESP_SIZE) != 0)
477− rc = -EINVAL;
478−out:
479− return rc;
480−}
481−
482288 /**
483289 * ksmbd_decode_ntlmssp_auth_blob() - helper function to construct
484290 * authenticate blob
@@ -512,17 +318,6 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, · 27 unmodified lines
512318 nt_off = le32_to_cpu(authblob->NtChallengeResponse.BufferOffset);
513319 nt_len = le16_to_cpu(authblob->NtChallengeResponse.Length);
514320
515− /* process NTLM authentication */
516− if (nt_len == CIFS_AUTH_RESP_SIZE) {
517− if (le32_to_cpu(authblob->NegotiateFlags) &
518− NTLMSSP_NEGOTIATE_EXTENDED_SEC)
519− return __ksmbd_auth_ntlmv2(sess, (char *)authblob +
520− lm_off, (char *)authblob + nt_off);
521− else
522− return ksmbd_auth_ntlm(sess, (char *)authblob +
523− nt_off);
524− }
525−
526321 /* TODO : use domain name that imported from configuration file */
527322 domain_name = smb_strndup_from_utf16((const char *)authblob +
528323 le32_to_cpu(authblob->DomainName.BufferOffset),
fs/ksmbd/crypto_ctx.c+0−16
@@ -81,12 +81,6 @@ static struct shash_desc *alloc_shash_desc(int id) · 80 unmodified lines
8181 case CRYPTO_SHASH_SHA512:
8282 tfm = crypto_alloc_shash("sha512", 0, 0);
8383 break;
84− case CRYPTO_SHASH_MD4:
85− tfm = crypto_alloc_shash("md4", 0, 0);
86− break;
87− case CRYPTO_SHASH_MD5:
88− tfm = crypto_alloc_shash("md5", 0, 0);
89− break;
9084 default:
9185 return NULL;
9286 }
@@ -214,16 +208,6 @@ struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void) · 121 unmodified lines
214208 return ____crypto_shash_ctx_find(CRYPTO_SHASH_SHA512);
215209 }
216210
217−struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4(void)
218−{
219− return ____crypto_shash_ctx_find(CRYPTO_SHASH_MD4);
220−}
221−
222−struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5(void)
223−{
224− return ____crypto_shash_ctx_find(CRYPTO_SHASH_MD5);
225−}
226−
227211 static struct ksmbd_crypto_ctx *____crypto_aead_ctx_find(int id)
228212 {
229213 struct ksmbd_crypto_ctx *ctx;
fs/ksmbd/crypto_ctx.h+0−8
@@ -15,8 +15,6 @@ enum { · 14 unmodified lines
1515 CRYPTO_SHASH_CMACAES,
1616 CRYPTO_SHASH_SHA256,
1717 CRYPTO_SHASH_SHA512,
18− CRYPTO_SHASH_MD4,
19− CRYPTO_SHASH_MD5,
2018 CRYPTO_SHASH_MAX,
2119 };
2220
@@ -43,8 +41,6 @@ struct ksmbd_crypto_ctx { · 20 unmodified lines
4341 #define CRYPTO_CMACAES(c) ((c)->desc[CRYPTO_SHASH_CMACAES])
4442 #define CRYPTO_SHA256(c) ((c)->desc[CRYPTO_SHASH_SHA256])
4543 #define CRYPTO_SHA512(c) ((c)->desc[CRYPTO_SHASH_SHA512])
46−#define CRYPTO_MD4(c) ((c)->desc[CRYPTO_SHASH_MD4])
47−#define CRYPTO_MD5(c) ((c)->desc[CRYPTO_SHASH_MD5])
4844
4945 #define CRYPTO_HMACMD5_TFM(c) ((c)->desc[CRYPTO_SHASH_HMACMD5]->tfm)
5046 #define CRYPTO_HMACSHA256_TFM(c)\
@@ -52,8 +48,6 @@ struct ksmbd_crypto_ctx { · 1 unmodified line
5248 #define CRYPTO_CMACAES_TFM(c) ((c)->desc[CRYPTO_SHASH_CMACAES]->tfm)
5349 #define CRYPTO_SHA256_TFM(c) ((c)->desc[CRYPTO_SHASH_SHA256]->tfm)
5450 #define CRYPTO_SHA512_TFM(c) ((c)->desc[CRYPTO_SHASH_SHA512]->tfm)
55−#define CRYPTO_MD4_TFM(c) ((c)->desc[CRYPTO_SHASH_MD4]->tfm)
56−#define CRYPTO_MD5_TFM(c) ((c)->desc[CRYPTO_SHASH_MD5]->tfm)
5751
5852 #define CRYPTO_GCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_GCM])
5953 #define CRYPTO_CCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_CCM])
@@ -64,8 +58,6 @@ struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacsha256(void); · 4 unmodified lines
6458 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_cmacaes(void);
6559 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void);
6660 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha256(void);
67−struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4(void);
68−struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5(void);
6961 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_gcm(void);
7062 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_ccm(void);
7163 void ksmbd_crypto_destroy(void);
fs/ksmbd/misc.c+7−10
@@ -162,17 +162,14 @@ char *convert_to_nt_pathname(char *filename) · 161 unmodified lines
162162 {
163163 char *ab_pathname;
164164
165− if (strlen(filename) == 0) {
166− ab_pathname = kmalloc(2, GFP_KERNEL);
167− ab_pathname[0] = '\\';
168− ab_pathname[1] = '\0';
169− } else {
170− ab_pathname = kstrdup(filename, GFP_KERNEL);
171− if (!ab_pathname)
172− return NULL;
165+ if (strlen(filename) == 0)
166+ filename = "\\";
173167
174− ksmbd_conv_path_to_windows(ab_pathname);
175− }
168+ ab_pathname = kstrdup(filename, GFP_KERNEL);
169+ if (!ab_pathname)
170+ return NULL;
171+
172+ ksmbd_conv_path_to_windows(ab_pathname);
176173 return ab_pathname;
177174 }
178175
fs/ksmbd/oplock.c+31−10
@@ -1451,26 +1451,47 @@ struct lease_ctx_info *parse_lease_state(void *open_req) · 1450 unmodified lines
14511451 */
14521452 struct create_context *smb2_find_context_vals(void *open_req, const char *tag)
14531453 {
1454− char *data_offset;
14551454 struct create_context *cc;
14561455 unsigned int next = 0;
14571456 char *name;
14581457 struct smb2_create_req *req = (struct smb2_create_req *)open_req;
1458+ unsigned int remain_len, name_off, name_len, value_off, value_len,
1459+ cc_len;
14591460
1460− data_offset = (char *)req + 4 + le32_to_cpu(req->CreateContextsOffset);
1461− cc = (struct create_context *)data_offset;
1461+ /*
1462+ * CreateContextsOffset and CreateContextsLength are guaranteed to
1463+ * be valid because of ksmbd_smb2_check_message().
1464+ */
1465+ cc = (struct create_context *)((char *)req + 4 +
1466+ le32_to_cpu(req->CreateContextsOffset));
1467+ remain_len = le32_to_cpu(req->CreateContextsLength);
14621468 do {
1463− int val;
1464−
14651469 cc = (struct create_context *)((char *)cc + next);
1466− name = le16_to_cpu(cc->NameOffset) + (char *)cc;
1467− val = le16_to_cpu(cc->NameLength);
1468− if (val < 4)
1470+ if (remain_len < offsetof(struct create_context, Buffer))
14691471 return ERR_PTR(-EINVAL);
14701472
1471− if (memcmp(name, tag, val) == 0)
1472− return cc;
14731473 next = le32_to_cpu(cc->Next);
1474+ name_off = le16_to_cpu(cc->NameOffset);
1475+ name_len = le16_to_cpu(cc->NameLength);
1476+ value_off = le16_to_cpu(cc->DataOffset);
1477+ value_len = le32_to_cpu(cc->DataLength);
1478+ cc_len = next ? next : remain_len;
1479+
1480+ if ((next & 0x7) != 0 ||
1481+ next > remain_len ||
1482+ name_off != offsetof(struct create_context, Buffer) ||
1483+ name_len < 4 ||
1484+ name_off + name_len > cc_len ||
1485+ (value_off & 0x7) != 0 ||
1486+ (value_off && (value_off < name_off + name_len)) ||
1487+ ((u64)value_off + value_len > cc_len))
1488+ return ERR_PTR(-EINVAL);
1489+
1490+ name = (char *)cc + name_off;
1491+ if (memcmp(name, tag, name_len) == 0)
1492+ return cc;
1493+
1494+ remain_len -= next;
14741495 } while (next != 0);
14751496
14761497 return NULL;
fs/ksmbd/smb2pdu.c+196−60
@@ -459,13 +459,22 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work) · 458 unmodified lines
459459 bool is_chained_smb2_message(struct ksmbd_work *work)
460460 {
461461 struct smb2_hdr *hdr = work->request_buf;
462− unsigned int len;
462+ unsigned int len, next_cmd;
463463
464464 if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
465465 return false;
466466
467467 hdr = ksmbd_req_buf_next(work);
468− if (le32_to_cpu(hdr->NextCommand) > 0) {
468+ next_cmd = le32_to_cpu(hdr->NextCommand);
469+ if (next_cmd > 0) {
470+ if ((u64)work->next_smb2_rcv_hdr_off + next_cmd +
471+ __SMB2_HEADER_STRUCTURE_SIZE >
472+ get_rfc1002_len(work->request_buf)) {
473+ pr_err("next command(%u) offset exceeds smb msg size\n",
474+ next_cmd);
475+ return false;
476+ }
477+
469478 ksmbd_debug(SMB, "got SMB2 chained command\n");
470479 init_chained_smb2_rsp(work);
471480 return true;
@@ -1058,6 +1067,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work) · 586 unmodified lines
10581067 struct smb2_negotiate_req *req = work->request_buf;
10591068 struct smb2_negotiate_rsp *rsp = work->response_buf;
10601069 int rc = 0;
1070+ unsigned int smb2_buf_len, smb2_neg_size;
10611071 __le32 status;
10621072
10631073 ksmbd_debug(SMB, "Received negotiate request\n");
@@ -1075,6 +1085,44 @@ int smb2_handle_negotiate(struct ksmbd_work *work) · 11 unmodified lines
10751085 goto err_out;
10761086 }
10771087
1088+ smb2_buf_len = get_rfc1002_len(work->request_buf);
1089+ smb2_neg_size = offsetof(struct smb2_negotiate_req, Dialects) - 4;
1090+ if (smb2_neg_size > smb2_buf_len) {
1091+ rsp->hdr.Status = STATUS_INVALID_PARAMETER;
1092+ rc = -EINVAL;
1093+ goto err_out;
1094+ }
1095+
1096+ if (conn->dialect == SMB311_PROT_ID) {
1097+ unsigned int nego_ctxt_off = le32_to_cpu(req->NegotiateContextOffset);
1098+
1099+ if (smb2_buf_len < nego_ctxt_off) {
1100+ rsp->hdr.Status = STATUS_INVALID_PARAMETER;
1101+ rc = -EINVAL;
1102+ goto err_out;
1103+ }
1104+
1105+ if (smb2_neg_size > nego_ctxt_off) {
1106+ rsp->hdr.Status = STATUS_INVALID_PARAMETER;
1107+ rc = -EINVAL;
1108+ goto err_out;
1109+ }
1110+
1111+ if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) >
1112+ nego_ctxt_off) {
1113+ rsp->hdr.Status = STATUS_INVALID_PARAMETER;
1114+ rc = -EINVAL;
1115+ goto err_out;
1116+ }
1117+ } else {
1118+ if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) >
1119+ smb2_buf_len) {
1120+ rsp->hdr.Status = STATUS_INVALID_PARAMETER;
1121+ rc = -EINVAL;
1122+ goto err_out;
1123+ }
1124+ }
1125+
10781126 conn->cli_cap = le32_to_cpu(req->Capabilities);
10791127 switch (conn->dialect) {
10801128 case SMB311_PROT_ID:
@@ -2093,16 +2141,22 @@ out: · 1012 unmodified lines
20932141 * smb2_set_ea() - handler for setting extended attributes using set
20942142 * info command
20952143 * @eabuf: set info command buffer
2144+ * @buf_len: set info command buffer length
20962145 * @path: dentry path for get ea
20972146 *
20982147 * Return: 0 on success, otherwise error
20992148 */
2100−static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path)
2149+static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
2150+ struct path *path)
21012151 {
21022152 struct user_namespace *user_ns = mnt_user_ns(path->mnt);
21032153 char *attr_name = NULL, *value;
21042154 int rc = 0;
2105− int next = 0;
2155+ unsigned int next = 0;
2156+
2157+ if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength +
2158+ le16_to_cpu(eabuf->EaValueLength))
2159+ return -EINVAL;
21062160
21072161 attr_name = kmalloc(XATTR_NAME_MAX + 1, GFP_KERNEL);
21082162 if (!attr_name)
@@ -2167,7 +2221,13 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path) · 58 unmodified lines
21672221
21682222 next:
21692223 next = le32_to_cpu(eabuf->NextEntryOffset);
2224+ if (next == 0 || buf_len < next)
2225+ break;
2226+ buf_len -= next;
21702227 eabuf = (struct smb2_ea_info *)((char *)eabuf + next);
2228+ if (next < (u32)eabuf->EaNameLength + le16_to_cpu(eabuf->EaValueLength))
2229+ break;
2230+
21712231 } while (next != 0);
21722232
21732233 kfree(attr_name);
@@ -2367,6 +2427,10 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, · 193 unmodified lines
23672427 ksmbd_debug(SMB,
23682428 "Set ACLs using SMB2_CREATE_SD_BUFFER context\n");
23692429 sd_buf = (struct create_sd_buf_req *)context;
2430+ if (le16_to_cpu(context->DataOffset) +
2431+ le32_to_cpu(context->DataLength) <
2432+ sizeof(struct create_sd_buf_req))
2433+ return -EINVAL;
23702434 return set_info_sec(work->conn, work->tcon, path, &sd_buf->ntsd,
23712435 le32_to_cpu(sd_buf->ccontext.DataLength), true);
23722436 }
@@ -2561,6 +2625,12 @@ int smb2_open(struct ksmbd_work *work) · 188 unmodified lines
25612625 goto err_out1;
25622626 } else if (context) {
25632627 ea_buf = (struct create_ea_buf_req *)context;
2628+ if (le16_to_cpu(context->DataOffset) +
2629+ le32_to_cpu(context->DataLength) <
2630+ sizeof(struct create_ea_buf_req)) {
2631+ rc = -EINVAL;
2632+ goto err_out1;
2633+ }
25642634 if (req->CreateOptions & FILE_NO_EA_KNOWLEDGE_LE) {
25652635 rsp->hdr.Status = STATUS_ACCESS_DENIED;
25662636 rc = -EACCES;
@@ -2599,6 +2669,12 @@ int smb2_open(struct ksmbd_work *work) · 32 unmodified lines
25992669 } else if (context) {
26002670 struct create_posix *posix =
26012671 (struct create_posix *)context;
2672+ if (le16_to_cpu(context->DataOffset) +
2673+ le32_to_cpu(context->DataLength) <
2674+ sizeof(struct create_posix)) {
2675+ rc = -EINVAL;
2676+ goto err_out1;
2677+ }
26022678 ksmbd_debug(SMB, "get posix context\n");
26032679
26042680 posix_mode = le32_to_cpu(posix->Mode);
@@ -2748,7 +2824,15 @@ int smb2_open(struct ksmbd_work *work) · 143 unmodified lines
27482824 created = true;
27492825 user_ns = mnt_user_ns(path.mnt);
27502826 if (ea_buf) {
2751− rc = smb2_set_ea(&ea_buf->ea, &path);
2827+ if (le32_to_cpu(ea_buf->ccontext.DataLength) <
2828+ sizeof(struct smb2_ea_info)) {
2829+ rc = -EINVAL;
2830+ goto err_out;
2831+ }
2832+
2833+ rc = smb2_set_ea(&ea_buf->ea,
2834+ le32_to_cpu(ea_buf->ccontext.DataLength),
2835+ &path);
27522836 if (rc == -EOPNOTSUPP)
27532837 rc = 0;
27542838 else if (rc)
@@ -2981,9 +3065,16 @@ int smb2_open(struct ksmbd_work *work) · 226 unmodified lines
29813065 rc = PTR_ERR(az_req);
29823066 goto err_out;
29833067 } else if (az_req) {
2984− loff_t alloc_size = le64_to_cpu(az_req->AllocationSize);
3068+ loff_t alloc_size;
29853069 int err;
29863070
3071+ if (le16_to_cpu(az_req->ccontext.DataOffset) +
3072+ le32_to_cpu(az_req->ccontext.DataLength) <
3073+ sizeof(struct create_alloc_size_req)) {
3074+ rc = -EINVAL;
3075+ goto err_out;
3076+ }
3077+ alloc_size = le64_to_cpu(az_req->AllocationSize);
29873078 ksmbd_debug(SMB,
29883079 "request smb2 create allocate size : %llu\n",
29893080 alloc_size);
@@ -4152,7 +4243,7 @@ static void get_file_access_info(struct smb2_query_info_rsp *rsp, · 1162 unmodified lines
41524243 static int get_file_basic_info(struct smb2_query_info_rsp *rsp,
41534244 struct ksmbd_file *fp, void *rsp_org)
41544245 {
4155− struct smb2_file_all_info *basic_info;
4246+ struct smb2_file_basic_info *basic_info;
41564247 struct kstat stat;
41574248 u64 time;
41584249
@@ -4162,7 +4253,7 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, · 3 unmodified lines
41624253 return -EACCES;
41634254 }
41644255
4165− basic_info = (struct smb2_file_all_info *)rsp->Buffer;
4256+ basic_info = (struct smb2_file_basic_info *)rsp->Buffer;
41664257 generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp),
41674258 &stat);
41684259 basic_info->CreationTime = cpu_to_le64(fp->create_time);
@@ -4175,9 +4266,8 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, · 6 unmodified lines
41754266 basic_info->Attributes = fp->f_ci->m_fattr;
41764267 basic_info->Pad1 = 0;
41774268 rsp->OutputBufferLength =
4178− cpu_to_le32(offsetof(struct smb2_file_all_info, AllocationSize));
4179− inc_rfc1001_len(rsp_org, offsetof(struct smb2_file_all_info,
4180− AllocationSize));
4269+ cpu_to_le32(sizeof(struct smb2_file_basic_info));
4270+ inc_rfc1001_len(rsp_org, sizeof(struct smb2_file_basic_info));
41814271 return 0;
41824272 }
41834273
@@ -5333,7 +5423,7 @@ out: · 1149 unmodified lines
53335423 static int smb2_create_link(struct ksmbd_work *work,
53345424 struct ksmbd_share_config *share,
53355425 struct smb2_file_link_info *file_info,
5336− struct file *filp,
5426+ unsigned int buf_len, struct file *filp,
53375427 struct nls_table *local_nls)
53385428 {
53395429 char *link_name = NULL, *target_name = NULL, *pathname = NULL;
@@ -5341,6 +5431,10 @@ static int smb2_create_link(struct ksmbd_work *work, · 1 unmodified line
53415431 bool file_present = true;
53425432 int rc;
53435433
5434+ if (buf_len < (u64)sizeof(struct smb2_file_link_info) +
5435+ le32_to_cpu(file_info->FileNameLength))
5436+ return -EINVAL;
5437+
53445438 ksmbd_debug(SMB, "setting FILE_LINK_INFORMATION\n");
53455439 pathname = kmalloc(PATH_MAX, GFP_KERNEL);
53465440 if (!pathname)
@@ -5400,10 +5494,10 @@ out: · 53 unmodified lines
54005494 return rc;
54015495 }
54025496
5403−static int set_file_basic_info(struct ksmbd_file *fp, char *buf,
5497+static int set_file_basic_info(struct ksmbd_file *fp,
5498+ struct smb2_file_basic_info *file_info,
54045499 struct ksmbd_share_config *share)
54055500 {
5406− struct smb2_file_all_info *file_info;
54075501 struct iattr attrs;
54085502 struct timespec64 ctime;
54095503 struct file *filp;
@@ -5414,7 +5508,6 @@ static int set_file_basic_info(struct ksmbd_file *fp, char *buf, · 4 unmodified lines
54145508 if (!(fp->daccess & FILE_WRITE_ATTRIBUTES_LE))
54155509 return -EACCES;
54165510
5417− file_info = (struct smb2_file_all_info *)buf;
54185511 attrs.ia_valid = 0;
54195512 filp = fp->filp;
54205513 inode = file_inode(filp);
@@ -5491,7 +5584,8 @@ static int set_file_basic_info(struct ksmbd_file *fp, char *buf, · 70 unmodified lines
54915584 }
54925585
54935586 static int set_file_allocation_info(struct ksmbd_work *work,
5494− struct ksmbd_file *fp, char *buf)
5587+ struct ksmbd_file *fp,
5588+ struct smb2_file_alloc_info *file_alloc_info)
54955589 {
54965590 /*
54975591 * TODO : It's working fine only when store dos attributes
@@ -5499,7 +5593,6 @@ static int set_file_allocation_info(struct ksmbd_work *work, · 1 unmodified line
54995593 * properly with any smb.conf option
55005594 */
55015595
5502− struct smb2_file_alloc_info *file_alloc_info;
55035596 loff_t alloc_blks;
55045597 struct inode *inode;
55055598 int rc;
@@ -5507,7 +5600,6 @@ static int set_file_allocation_info(struct ksmbd_work *work, · 1 unmodified line
55075600 if (!(fp->daccess & FILE_WRITE_DATA_LE))
55085601 return -EACCES;
55095602
5510− file_alloc_info = (struct smb2_file_alloc_info *)buf;
55115603 alloc_blks = (le64_to_cpu(file_alloc_info->AllocationSize) + 511) >> 9;
55125604 inode = file_inode(fp->filp);
55135605
@@ -5543,9 +5635,8 @@ static int set_file_allocation_info(struct ksmbd_work *work, · 29 unmodified lines
55435635 }
55445636
55455637 static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,
5546− char *buf)
5638+ struct smb2_file_eof_info *file_eof_info)
55475639 {
5548− struct smb2_file_eof_info *file_eof_info;
55495640 loff_t newsize;
55505641 struct inode *inode;
55515642 int rc;
@@ -5553,7 +5644,6 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, · 1 unmodified line
55535644 if (!(fp->daccess & FILE_WRITE_DATA_LE))
55545645 return -EACCES;
55555646
5556− file_eof_info = (struct smb2_file_eof_info *)buf;
55575647 newsize = le64_to_cpu(file_eof_info->EndOfFile);
55585648 inode = file_inode(fp->filp);
55595649
@@ -5580,7 +5670,8 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, · 20 unmodified lines
55805670 }
55815671
55825672 static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp,
5583− char *buf)
5673+ struct smb2_file_rename_info *rename_info,
5674+ unsigned int buf_len)
55845675 {
55855676 struct user_namespace *user_ns;
55865677 struct ksmbd_file *parent_fp;
@@ -5593,6 +5684,10 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, · 6 unmodified lines
55935684 return -EACCES;
55945685 }
55955686
5687+ if (buf_len < (u64)sizeof(struct smb2_file_rename_info) +
5688+ le32_to_cpu(rename_info->FileNameLength))
5689+ return -EINVAL;
5690+
55965691 user_ns = file_mnt_user_ns(fp->filp);
55975692 if (ksmbd_stream_fd(fp))
55985693 goto next;
@@ -5615,14 +5710,13 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, · 16 unmodified lines
56155710 }
56165711 }
56175712 next:
5618− return smb2_rename(work, fp, user_ns,
5619− (struct smb2_file_rename_info *)buf,
5713+ return smb2_rename(work, fp, user_ns, rename_info,
56205714 work->sess->conn->local_nls);
56215715 }
56225716
5623−static int set_file_disposition_info(struct ksmbd_file *fp, char *buf)
5717+static int set_file_disposition_info(struct ksmbd_file *fp,
5718+ struct smb2_file_disposition_info *file_info)
56245719 {
5625− struct smb2_file_disposition_info *file_info;
56265720 struct inode *inode;
56275721
56285722 if (!(fp->daccess & FILE_DELETE_LE)) {
@@ -5631,7 +5725,6 @@ static int set_file_disposition_info(struct ksmbd_file *fp, char *buf) · 2 unmodified lines
56315725 }
56325726
56335727 inode = file_inode(fp->filp);
5634− file_info = (struct smb2_file_disposition_info *)buf;
56355728 if (file_info->DeletePending) {
56365729 if (S_ISDIR(inode->i_mode) &&
56375730 ksmbd_vfs_empty_dir(fp) == -ENOTEMPTY)
@@ -5643,15 +5736,14 @@ static int set_file_disposition_info(struct ksmbd_file *fp, char *buf) · 5 unmodified lines
56435736 return 0;
56445737 }
56455738
5646−static int set_file_position_info(struct ksmbd_file *fp, char *buf)
5739+static int set_file_position_info(struct ksmbd_file *fp,
5740+ struct smb2_file_pos_info *file_info)
56475741 {
5648− struct smb2_file_pos_info *file_info;
56495742 loff_t current_byte_offset;
56505743 unsigned long sector_size;
56515744 struct inode *inode;
56525745
56535746 inode = file_inode(fp->filp);
5654− file_info = (struct smb2_file_pos_info *)buf;
56555747 current_byte_offset = le64_to_cpu(file_info->CurrentByteOffset);
56565748 sector_size = inode->i_sb->s_blocksize;
56575749
@@ -5667,12 +5759,11 @@ static int set_file_position_info(struct ksmbd_file *fp, char *buf) · 9 unmodified lines
56675759 return 0;
56685760 }
56695761
5670−static int set_file_mode_info(struct ksmbd_file *fp, char *buf)
5762+static int set_file_mode_info(struct ksmbd_file *fp,
5763+ struct smb2_file_mode_info *file_info)
56715764 {
5672− struct smb2_file_mode_info *file_info;
56735765 __le32 mode;
56745766
5675− file_info = (struct smb2_file_mode_info *)buf;
56765767 mode = file_info->Mode;
56775768
56785769 if ((mode & ~FILE_MODE_INFO_MASK) ||
@@ -5702,40 +5793,74 @@ static int set_file_mode_info(struct ksmbd_file *fp, char *buf) · 23 unmodified lines
57025793 * TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH
57035794 */
57045795 static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
5705− int info_class, char *buf,
5796+ struct smb2_set_info_req *req,
57065797 struct ksmbd_share_config *share)
57075798 {
5708− switch (info_class) {
5799+ unsigned int buf_len = le32_to_cpu(req->BufferLength);
5800+
5801+ switch (req->FileInfoClass) {
57095802 case FILE_BASIC_INFORMATION:
5710− return set_file_basic_info(fp, buf, share);
5803+ {
5804+ if (buf_len < sizeof(struct smb2_file_basic_info))
5805+ return -EINVAL;
57115806
5807+ return set_file_basic_info(fp, (struct smb2_file_basic_info *)req->Buffer, share);
5808+ }
57125809 case FILE_ALLOCATION_INFORMATION:
5713− return set_file_allocation_info(work, fp, buf);
5810+ {
5811+ if (buf_len < sizeof(struct smb2_file_alloc_info))
5812+ return -EINVAL;
57145813
5814+ return set_file_allocation_info(work, fp,
5815+ (struct smb2_file_alloc_info *)req->Buffer);
5816+ }
57155817 case FILE_END_OF_FILE_INFORMATION:
5716− return set_end_of_file_info(work, fp, buf);
5818+ {
5819+ if (buf_len < sizeof(struct smb2_file_eof_info))
5820+ return -EINVAL;
57175821
5822+ return set_end_of_file_info(work, fp,
5823+ (struct smb2_file_eof_info *)req->Buffer);
5824+ }
57185825 case FILE_RENAME_INFORMATION:
5826+ {
57195827 if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) {
57205828 ksmbd_debug(SMB,
57215829 "User does not have write permission\n");
57225830 return -EACCES;
57235831 }
5724− return set_rename_info(work, fp, buf);
57255832
5833+ if (buf_len < sizeof(struct smb2_file_rename_info))
5834+ return -EINVAL;
5835+
5836+ return set_rename_info(work, fp,
5837+ (struct smb2_file_rename_info *)req->Buffer,
5838+ buf_len);
5839+ }
57265840 case FILE_LINK_INFORMATION:
5841+ {
5842+ if (buf_len < sizeof(struct smb2_file_link_info))
5843+ return -EINVAL;
5844+
57275845 return smb2_create_link(work, work->tcon->share_conf,
5728− (struct smb2_file_link_info *)buf, fp->filp,
5846+ (struct smb2_file_link_info *)req->Buffer,
5847+ buf_len, fp->filp,
57295848 work->sess->conn->local_nls);
5730−
5849+ }
57315850 case FILE_DISPOSITION_INFORMATION:
5851+ {
57325852 if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) {
57335853 ksmbd_debug(SMB,
57345854 "User does not have write permission\n");
57355855 return -EACCES;
57365856 }
5737− return set_file_disposition_info(fp, buf);
57385857
5858+ if (buf_len < sizeof(struct smb2_file_disposition_info))
5859+ return -EINVAL;
5860+
5861+ return set_file_disposition_info(fp,
5862+ (struct smb2_file_disposition_info *)req->Buffer);
5863+ }
57395864 case FILE_FULL_EA_INFORMATION:
57405865 {
57415866 if (!(fp->daccess & FILE_WRITE_EA_LE)) {
@@ -5744,18 +5869,29 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp, · 2 unmodified lines
57445869 return -EACCES;
57455870 }
57465871
5747− return smb2_set_ea((struct smb2_ea_info *)buf,
5748− &fp->filp->f_path);
5749− }
5872+ if (buf_len < sizeof(struct smb2_ea_info))
5873+ return -EINVAL;
57505874
5875+ return smb2_set_ea((struct smb2_ea_info *)req->Buffer,
5876+ buf_len, &fp->filp->f_path);
5877+ }
57515878 case FILE_POSITION_INFORMATION:
5752− return set_file_position_info(fp, buf);
5879+ {
5880+ if (buf_len < sizeof(struct smb2_file_pos_info))
5881+ return -EINVAL;
57535882
5883+ return set_file_position_info(fp, (struct smb2_file_pos_info *)req->Buffer);
5884+ }
57545885 case FILE_MODE_INFORMATION:
5755− return set_file_mode_info(fp, buf);
5886+ {
5887+ if (buf_len < sizeof(struct smb2_file_mode_info))
5888+ return -EINVAL;
5889+
5890+ return set_file_mode_info(fp, (struct smb2_file_mode_info *)req->Buffer);
5891+ }
57565892 }
57575893
5758− pr_err("Unimplemented Fileinfoclass :%d\n", info_class);
5894+ pr_err("Unimplemented Fileinfoclass :%d\n", req->FileInfoClass);
57595895 return -EOPNOTSUPP;
57605896 }
57615897
@@ -5816,8 +5952,7 @@ int smb2_set_info(struct ksmbd_work *work) · 54 unmodified lines
58165952 switch (req->InfoType) {
58175953 case SMB2_O_INFO_FILE:
58185954 ksmbd_debug(SMB, "GOT SMB2_O_INFO_FILE\n");
5819− rc = smb2_set_info_file(work, fp, req->FileInfoClass,
5820− req->Buffer, work->tcon->share_conf);
5955+ rc = smb2_set_info_file(work, fp, req, work->tcon->share_conf);
58215956 break;
58225957 case SMB2_O_INFO_SECURITY:
58235958 ksmbd_debug(SMB, "GOT SMB2_O_INFO_SECURITY\n");
@@ -8171,7 +8306,8 @@ void smb3_preauth_hash_rsp(struct ksmbd_work *work) · 2347 unmodified lines
81718306
81728307 WORK_BUFFERS(work, req, rsp);
81738308
8174− if (le16_to_cpu(req->Command) == SMB2_NEGOTIATE_HE)
8309+ if (le16_to_cpu(req->Command) == SMB2_NEGOTIATE_HE &&
8310+ conn->preauth_info)
81758311 ksmbd_gen_preauth_integrity_hash(conn, (char *)rsp,
81768312 conn->preauth_info->Preauth_HashValue);
81778313
@@ -8278,16 +8414,8 @@ int smb3_decrypt_req(struct ksmbd_work *work) · 100 unmodified lines
82788414 unsigned int buf_data_size = pdu_length + 4 -
82798415 sizeof(struct smb2_transform_hdr);
82808416 struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf;
8281− unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize);
82828417 int rc = 0;
82838418
8284− sess = ksmbd_session_lookup_all(conn, le64_to_cpu(tr_hdr->SessionId));
8285− if (!sess) {
8286− pr_err("invalid session id(%llx) in transform header\n",
8287− le64_to_cpu(tr_hdr->SessionId));
8288− return -ECONNABORTED;
8289− }
8290−
82918419 if (pdu_length + 4 <
82928420 sizeof(struct smb2_transform_hdr) + sizeof(struct smb2_hdr)) {
82938421 pr_err("Transform message is too small (%u)\n",
@@ -8295,11 +8423,19 @@ int smb3_decrypt_req(struct ksmbd_work *work) · 1 unmodified line
82958423 return -ECONNABORTED;
82968424 }
82978425
8298− if (pdu_length + 4 < orig_len + sizeof(struct smb2_transform_hdr)) {
8426+ if (pdu_length + 4 <
8427+ le32_to_cpu(tr_hdr->OriginalMessageSize) + sizeof(struct smb2_transform_hdr)) {
82998428 pr_err("Transform message is broken\n");
83008429 return -ECONNABORTED;
83018430 }
83028431
8432+ sess = ksmbd_session_lookup_all(conn, le64_to_cpu(tr_hdr->SessionId));
8433+ if (!sess) {
8434+ pr_err("invalid session id(%llx) in transform header\n",
8435+ le64_to_cpu(tr_hdr->SessionId));
8436+ return -ECONNABORTED;
8437+ }
8438+
83038439 iov[0].iov_base = buf;
83048440 iov[0].iov_len = sizeof(struct smb2_transform_hdr);
83058441 iov[1].iov_base = buf + sizeof(struct smb2_transform_hdr);
fs/ksmbd/smb2pdu.h+9−0
@@ -1464,6 +1464,15 @@ struct smb2_file_all_info { /* data block encoding of response to level 18 */ · 1463 unmodified lines
14641464 char FileName[1];
14651465 } __packed; /* level 18 Query */
14661466
1467+struct smb2_file_basic_info { /* data block encoding of response to level 18 */
1468+ __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1469+ __le64 LastAccessTime;
1470+ __le64 LastWriteTime;
1471+ __le64 ChangeTime;
1472+ __le32 Attributes;
1473+ __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1474+} __packed;
1475+
14671476 struct smb2_file_alt_name_info {
14681477 __le32 FileNameLength;
14691478 char FileName[0];
fs/ksmbd/smb_common.c+28−19
@@ -155,20 +155,7 @@ int ksmbd_verify_smb_message(struct ksmbd_work *work) · 154 unmodified lines
155155 */
156156 bool ksmbd_smb_request(struct ksmbd_conn *conn)
157157 {
158− int type = *(char *)conn->request_buf;
159−
160− switch (type) {
161− case RFC1002_SESSION_MESSAGE:
162− /* Regular SMB request */
163− return true;
164− case RFC1002_SESSION_KEEP_ALIVE:
165− ksmbd_debug(SMB, "RFC 1002 session keep alive\n");
166− break;
167− default:
168− ksmbd_debug(SMB, "RFC 1002 unknown request type 0x%x\n", type);
169− }
170−
171− return false;
158+ return conn->request_buf[0] == 0;
172159 }
173160
174161 static bool supported_protocol(int idx)
@@ -182,10 +169,12 @@ static bool supported_protocol(int idx) · 7 unmodified lines
182169 idx <= server_conf.max_protocol);
183170 }
184171
185−static char *next_dialect(char *dialect, int *next_off)
172+static char *next_dialect(char *dialect, int *next_off, int bcount)
186173 {
187174 dialect = dialect + *next_off;
188− *next_off = strlen(dialect);
175+ *next_off = strnlen(dialect, bcount);
176+ if (dialect[*next_off] != '\0')
177+ return NULL;
189178 return dialect;
190179 }
191180
@@ -200,7 +189,9 @@ static int ksmbd_lookup_dialect_by_name(char *cli_dialects, __le16 byte_count) · 8 unmodified lines
200189 dialect = cli_dialects;
201190 bcount = le16_to_cpu(byte_count);
202191 do {
203− dialect = next_dialect(dialect, &next);
192+ dialect = next_dialect(dialect, &next, bcount);
193+ if (!dialect)
194+ break;
204195 ksmbd_debug(SMB, "client requested dialect %s\n",
205196 dialect);
206197 if (!strcmp(dialect, smb1_protos[i].name)) {
@@ -248,13 +239,22 @@ int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count) · 41 unmodified lines
248239
249240 static int ksmbd_negotiate_smb_dialect(void *buf)
250241 {
251− __le32 proto;
242+ int smb_buf_length = get_rfc1002_len(buf);
243+ __le32 proto = ((struct smb2_hdr *)buf)->ProtocolId;
252244
253− proto = ((struct smb2_hdr *)buf)->ProtocolId;
254245 if (proto == SMB2_PROTO_NUMBER) {
255246 struct smb2_negotiate_req *req;
247+ int smb2_neg_size =
248+ offsetof(struct smb2_negotiate_req, Dialects) - 4;
256249
257250 req = (struct smb2_negotiate_req *)buf;
251+ if (smb2_neg_size > smb_buf_length)
252+ goto err_out;
253+
254+ if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) >
255+ smb_buf_length)
256+ goto err_out;
257+
258258 return ksmbd_lookup_dialect_by_id(req->Dialects,
259259 req->DialectCount);
260260 }
@@ -264,10 +264,19 @@ static int ksmbd_negotiate_smb_dialect(void *buf) · 3 unmodified lines
264264 struct smb_negotiate_req *req;
265265
266266 req = (struct smb_negotiate_req *)buf;
267+ if (le16_to_cpu(req->ByteCount) < 2)
268+ goto err_out;
269+
270+ if (offsetof(struct smb_negotiate_req, DialectsArray) - 4 +
271+ le16_to_cpu(req->ByteCount) > smb_buf_length) {
272+ goto err_out;
273+ }
274+
267275 return ksmbd_lookup_dialect_by_name(req->DialectsArray,
268276 req->ByteCount);
269277 }
270278
279+err_out:
271280 return BAD_PROT_ID;
272281 }
273282
fs/ksmbd/smb_common.h+0−8
@@ -48,14 +48,6 @@ · 47 unmodified lines
4848 #define CIFS_DEFAULT_IOSIZE (64 * 1024)
4949 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
5050
51−/* RFC 1002 session packet types */
52−#define RFC1002_SESSION_MESSAGE 0x00
53−#define RFC1002_SESSION_REQUEST 0x81
54−#define RFC1002_POSITIVE_SESSION_RESPONSE 0x82
55−#define RFC1002_NEGATIVE_SESSION_RESPONSE 0x83
56−#define RFC1002_RETARGET_SESSION_RESPONSE 0x84
57−#define RFC1002_SESSION_KEEP_ALIVE 0x85
58−
5951 /* Responses when opening a file. */
6052 #define F_SUPERSEDED 0
6153 #define F_OPENED 1
fs/ksmbd/smbacl.c+19−2
@@ -380,7 +380,7 @@ static void parse_dacl(struct user_namespace *user_ns, · 379 unmodified lines
380380 {
381381 int i, ret;
382382 int num_aces = 0;
383− int acl_size;
383+ unsigned int acl_size;
384384 char *acl_base;
385385 struct smb_ace **ppace;
386386 struct posix_acl_entry *cf_pace, *cf_pdace;
@@ -392,7 +392,7 @@ static void parse_dacl(struct user_namespace *user_ns, · 5 unmodified lines
392392 return;
393393
394394 /* validate that we do not go past end of acl */
395− if (end_of_acl <= (char *)pdacl ||
395+ if (end_of_acl < (char *)pdacl + sizeof(struct smb_acl) ||
396396 end_of_acl < (char *)pdacl + le16_to_cpu(pdacl->size)) {
397397 pr_err("ACL too small to parse DACL\n");
398398 return;
@@ -431,8 +431,22 @@ static void parse_dacl(struct user_namespace *user_ns, · 32 unmodified lines
431431 * user/group/other have no permissions
432432 */
433433 for (i = 0; i < num_aces; ++i) {
434+ if (end_of_acl - acl_base < acl_size)
435+ break;
436+
434437 ppace[i] = (struct smb_ace *)(acl_base + acl_size);
435438 acl_base = (char *)ppace[i];
439+ acl_size = offsetof(struct smb_ace, sid) +
440+ offsetof(struct smb_sid, sub_auth);
441+
442+ if (end_of_acl - acl_base < acl_size ||
443+ ppace[i]->sid.num_subauth > SID_MAX_SUB_AUTHORITIES ||
444+ (end_of_acl - acl_base <
445+ acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) ||
446+ (le16_to_cpu(ppace[i]->size) <
447+ acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth))
448+ break;
449+
436450 acl_size = le16_to_cpu(ppace[i]->size);
437451 ppace[i]->access_req =
438452 smb_map_generic_desired_access(ppace[i]->access_req);
@@ -807,6 +821,9 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, · 368 unmodified lines
807821 if (!pntsd)
808822 return -EIO;
809823
824+ if (acl_len < sizeof(struct smb_ntsd))
825+ return -EINVAL;
826+
810827 owner_sid_ptr = (struct smb_sid *)((char *)pntsd +
811828 le32_to_cpu(pntsd->osidoffset));
812829 group_sid_ptr = (struct smb_sid *)((char *)pntsd +
fs/ksmbd/transport_tcp.c+2−2
@@ -215,7 +215,7 @@ out_error: · 214 unmodified lines
215215 * ksmbd_kthread_fn() - listen to new SMB connections and callback server
216216 * @p: arguments to forker thread
217217 *
218− * Return: Returns a task_struct or ERR_PTR
218+ * Return: 0 on success, error number otherwise
219219 */
220220 static int ksmbd_kthread_fn(void *p)
221221 {
@@ -387,7 +387,7 @@ static void tcp_destroy_socket(struct socket *ksmbd_socket) · 165 unmodified lines
387387 /**
388388 * create_socket - create socket for ksmbd/0
389389 *
390− * Return: Returns a task_struct or ERR_PTR
390+ * Return: 0 on success, error number otherwise
391391 */
392392 static int create_socket(struct interface *iface)
393393 {
fs/vboxsf/super.c+2−10
@@ -21,10 +21,7 @@ · 20 unmodified lines
2121
2222 #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
2323
24−#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000')
25−#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377')
26−#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376')
27−#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375')
24+static const unsigned char VBSF_MOUNT_SIGNATURE[4] = "\000\377\376\375";
2825
2926 static int follow_symlinks;
3027 module_param(follow_symlinks, int, 0444);
@@ -386,12 +383,7 @@ fail_nomem: · 355 unmodified lines
386383
387384 static int vboxsf_parse_monolithic(struct fs_context *fc, void *data)
388385 {
389− unsigned char *options = data;
390−
391− if (options && options[0] == VBSF_MOUNT_SIGNATURE_BYTE_0 &&
392− options[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 &&
393− options[2] == VBSF_MOUNT_SIGNATURE_BYTE_2 &&
394− options[3] == VBSF_MOUNT_SIGNATURE_BYTE_3) {
386+ if (data && !memcmp(data, VBSF_MOUNT_SIGNATURE, 4)) {
395387 vbg_err("vboxsf: Old binary mount data not supported, remove obsolete mount.vboxsf and/or update your VBoxService.\n");
396388 return -EINVAL;
397389 }
fs/verity/enable.c+1−1
@@ -177,7 +177,7 @@ static int build_merkle_tree(struct file *filp, · 176 unmodified lines
177177 * (level 0) and ascending to the root node (level 'num_levels - 1').
178178 * Then at the end (level 'num_levels'), calculate the root hash.
179179 */
180− blocks = (inode->i_size + params->block_size - 1) >>
180+ blocks = ((u64)inode->i_size + params->block_size - 1) >>
181181 params->log_blocksize;
182182 for (level = 0; level <= params->num_levels; level++) {
183183 err = build_merkle_tree_level(filp, level, blocks, params,
fs/verity/open.c+1−1
@@ -89,7 +89,7 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, · 88 unmodified lines
8989 */
9090
9191 /* Compute number of levels and the number of blocks in each level */
92− blocks = (inode->i_size + params->block_size - 1) >> log_blocksize;
92+ blocks = ((u64)inode->i_size + params->block_size - 1) >> log_blocksize;
9393 pr_debug("Data is %lld bytes (%llu blocks)\n", inode->i_size, blocks);
9494 while (blocks > 1) {
9595 if (params->num_levels >= FS_VERITY_MAX_LEVELS) {
include/kvm/arm_pmu.h+0−3
@@ -61,7 +61,6 @@ int kvm_arm_pmu_v3_get_attr(struct kvm_vcpu *vcpu, · 60 unmodified lines
6161 int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu,
6262 struct kvm_device_attr *attr);
6363 int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu);
64−int kvm_pmu_probe_pmuver(void);
6564 #else
6665 struct kvm_pmu {
6766 };
@@ -118,8 +117,6 @@ static inline u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1) · 50 unmodified lines
118117 return 0;
119118 }
120119
121−static inline int kvm_pmu_probe_pmuver(void) { return 0xf; }
122−
123120 #endif
124121
125122 #endif
include/linux/bpf.h+2−1
@@ -578,11 +578,12 @@ struct btf_func_model { · 577 unmodified lines
578578 * programs only. Should not be used with normal calls and indirect calls.
579579 */
580580 #define BPF_TRAMP_F_SKIP_FRAME BIT(2)
581−
582581 /* Store IP address of the caller on the trampoline stack,
583582 * so it's available for trampoline's programs.
584583 */
585584 #define BPF_TRAMP_F_IP_ARG BIT(3)
585+/* Return the return value of fentry prog. Only used by bpf_struct_ops. */
586+#define BPF_TRAMP_F_RET_FENTRY_RET BIT(4)
586587
587588 /* Each call __bpf_prog_enter + call bpf_func + call __bpf_prog_exit is ~50
588589 * bytes on x86. Pick a number to fit into BPF_IMAGE_SIZE / 2
include/linux/cpumask.h+4−3
@@ -996,14 +996,15 @@ cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) · 995 unmodified lines
996996 * cpumask; Typically used by bin_attribute to export cpumask bitmask
997997 * ABI.
998998 *
999− * Returns the length of how many bytes have been copied.
999+ * Returns the length of how many bytes have been copied, excluding
1000+ * terminating '\0'.
10001001 */
10011002 static inline ssize_t
10021003 cpumap_print_bitmask_to_buf(char *buf, const struct cpumask *mask,
10031004 loff_t off, size_t count)
10041005 {
10051006 return bitmap_print_bitmask_to_buf(buf, cpumask_bits(mask),
1006− nr_cpu_ids, off, count);
1007+ nr_cpu_ids, off, count) - 1;
10071008 }
10081009
10091010 /**
@@ -1018,7 +1019,7 @@ cpumap_print_list_to_buf(char *buf, const struct cpumask *mask, · 8 unmodified lines
10181019 loff_t off, size_t count)
10191020 {
10201021 return bitmap_print_list_to_buf(buf, cpumask_bits(mask),
1021− nr_cpu_ids, off, count);
1022+ nr_cpu_ids, off, count) - 1;
10221023 }
10231024
10241025 #if NR_CPUS <= BITS_PER_LONG
include/linux/fwnode.h+8−3
@@ -22,10 +22,15 @@ struct device; · 21 unmodified lines
2222 * LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
2323 * NOT_DEVICE: The fwnode will never be populated as a struct device.
2424 * INITIALIZED: The hardware corresponding to fwnode has been initialized.
25+ * NEEDS_CHILD_BOUND_ON_ADD: For this fwnode/device to probe successfully, its
26+ * driver needs its child devices to be bound with
27+ * their respective drivers as soon as they are
28+ * added.
2529 */
26−#define FWNODE_FLAG_LINKS_ADDED BIT(0)
27−#define FWNODE_FLAG_NOT_DEVICE BIT(1)
28−#define FWNODE_FLAG_INITIALIZED BIT(2)
30+#define FWNODE_FLAG_LINKS_ADDED BIT(0)
31+#define FWNODE_FLAG_NOT_DEVICE BIT(1)
32+#define FWNODE_FLAG_INITIALIZED BIT(2)
33+#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3)
2934
3035 struct fwnode_handle {
3136 struct fwnode_handle *secondary;
include/linux/kvm_host.h+0−6
@@ -608,7 +608,6 @@ struct kvm { · 607 unmodified lines
608608 unsigned long mmu_notifier_range_start;
609609 unsigned long mmu_notifier_range_end;
610610 #endif
611− long tlbs_dirty;
612611 struct list_head devices;
613612 u64 manual_dirty_log_protect;
614613 struct dentry *debugfs_dentry;
@@ -721,11 +720,6 @@ static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id) · 106 unmodified lines
721720 return NULL;
722721 }
723722
724−static inline int kvm_vcpu_get_idx(struct kvm_vcpu *vcpu)
725−{
726− return vcpu->vcpu_idx;
727−}
728−
729723 #define kvm_for_each_memslot(memslot, slots) \
730724 for (memslot = &slots->memslots[0]; \
731725 memslot < slots->memslots + slots->used_slots; memslot++) \
include/linux/perf/arm_pmu.h+6−0
@@ -163,6 +163,12 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn); · 162 unmodified lines
163163 static inline int arm_pmu_acpi_probe(armpmu_init_fn init_fn) { return 0; }
164164 #endif
165165
166+#ifdef CONFIG_KVM
167+void kvm_host_pmu_init(struct arm_pmu *pmu);
168+#else
169+#define kvm_host_pmu_init(x) do { } while(0)
170+#endif
171+
166172 /* Internal functions only for core arm_pmu code */
167173 struct arm_pmu *armpmu_alloc(void);
168174 struct arm_pmu *armpmu_alloc_atomic(void);
include/linux/perf_event.h+3−1
@@ -683,7 +683,9 @@ struct perf_event { · 682 unmodified lines
683683 /*
684684 * timestamp shadows the actual context timing but it can
685685 * be safely used in NMI interrupt context. It reflects the
686− * context time as it was when the event was last scheduled in.
686+ * context time as it was when the event was last scheduled in,
687+ * or when ctx_sched_in failed to schedule the event because we
688+ * run out of PMC.
687689 *
688690 * ctx_time already accounts for ctx->timestamp. Therefore to
689691 * compute ctx_time for a sample, simply add perf_clock().
include/linux/sched.h+1−1
@@ -1720,7 +1720,7 @@ extern struct pid *cad_pid; · 1719 unmodified lines
17201720 #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
17211721 #define used_math() tsk_used_math(current)
17221722
1723−static inline bool is_percpu_thread(void)
1723+static __always_inline bool is_percpu_thread(void)
17241724 {
17251725 #ifdef CONFIG_SMP
17261726 return (current->flags & PF_NO_SETAFFINITY) &&
include/net/ip_fib.h+1−1
@@ -597,5 +597,5 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh, · 596 unmodified lines
597597 int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh,
598598 u8 rt_family, unsigned char *flags, bool skip_oif);
599599 int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh,
600− int nh_weight, u8 rt_family);
600+ int nh_weight, u8 rt_family, u32 nh_tclassid);
601601 #endif /* _NET_FIB_H */
include/net/mac80211.h+4−4
@@ -2818,13 +2818,13 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); · 2817 unmodified lines
28182818 * Mac80211 drivers should set the @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 flag
28192819 * when they are able to replace in-use PTK keys according to the following
28202820 * requirements:
2821− * 1) They do not hand over frames decrypted with the old key to
2822− mac80211 once the call to set_key() with command %DISABLE_KEY has been
2823− completed when also setting @IEEE80211_KEY_FLAG_GENERATE_IV for any key,
2821+ * 1) They do not hand over frames decrypted with the old key to mac80211
2822+ once the call to set_key() with command %DISABLE_KEY has been completed,
28242823 2) either drop or continue to use the old key for any outgoing frames queued
28252824 at the time of the key deletion (including re-transmits),
28262825 3) never send out a frame queued prior to the set_key() %SET_KEY command
2827− encrypted with the new key and
2826+ encrypted with the new key when also needing
2827+ @IEEE80211_KEY_FLAG_GENERATE_IV and
28282828 4) never send out a frame unencrypted when it should be encrypted.
28292829 Mac80211 will not queue any new frames for a deleted key to the driver.
28302830 */
include/net/nexthop.h+1−1
@@ -325,7 +325,7 @@ int nexthop_mpath_fill_node(struct sk_buff *skb, struct nexthop *nh, · 324 unmodified lines
325325 struct fib_nh_common *nhc = &nhi->fib_nhc;
326326 int weight = nhg->nh_entries[i].weight;
327327
328− if (fib_add_nexthop(skb, nhc, weight, rt_family) < 0)
328+ if (fib_add_nexthop(skb, nhc, weight, rt_family, 0) < 0)
329329 return -EMSGSIZE;
330330 }
331331
include/net/pkt_sched.h+1−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <uapi/linux/pkt_sched.h>
1212
1313 #define DEFAULT_TX_QUEUE_LEN 1000
14+#define STAB_SIZE_LOG_MAX 30
1415
1516 struct qdisc_walker {
1617 int stop;
include/net/sock.h+32−1
@@ -488,8 +488,10 @@ struct sock { · 487 unmodified lines
488488 u8 sk_prefer_busy_poll;
489489 u16 sk_busy_poll_budget;
490490 #endif
491+ spinlock_t sk_peer_lock;
491492 struct pid *sk_peer_pid;
492493 const struct cred *sk_peer_cred;
494+
493495 long sk_rcvtimeo;
494496 ktime_t sk_stamp;
495497 #if BITS_PER_LONG==32
@@ -1623,7 +1625,36 @@ void release_sock(struct sock *sk); · 1127 unmodified lines
16231625 SINGLE_DEPTH_NESTING)
16241626 #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock))
16251627
1626−bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock);
1628+bool __lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock);
1629+
1630+/**
1631+ * lock_sock_fast - fast version of lock_sock
1632+ * @sk: socket
1633+ *
1634+ * This version should be used for very small section, where process wont block
1635+ * return false if fast path is taken:
1636+ *
1637+ * sk_lock.slock locked, owned = 0, BH disabled
1638+ *
1639+ * return true if slow path is taken:
1640+ *
1641+ * sk_lock.slock unlocked, owned = 1, BH enabled
1642+ */
1643+static inline bool lock_sock_fast(struct sock *sk)
1644+{
1645+ /* The sk_lock has mutex_lock() semantics here. */
1646+ mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_);
1647+
1648+ return __lock_sock_fast(sk);
1649+}
1650+
1651+/* fast socket lock variant for caller already holding a [different] socket lock */
1652+static inline bool lock_sock_fast_nested(struct sock *sk)
1653+{
1654+ mutex_acquire(&sk->sk_lock.dep_map, SINGLE_DEPTH_NESTING, 0, _RET_IP_);
1655+
1656+ return __lock_sock_fast(sk);
1657+}
16271658
16281659 /**
16291660 * unlock_sock_fast - complement of lock_sock_fast
include/sound/rawmidi.h+1−0
@@ -98,6 +98,7 @@ struct snd_rawmidi_file { · 97 unmodified lines
9898 struct snd_rawmidi *rmidi;
9999 struct snd_rawmidi_substream *input;
100100 struct snd_rawmidi_substream *output;
101+ unsigned int user_pversion; /* supported protocol version */
101102 };
102103
103104 struct snd_rawmidi_str {
include/trace/events/cachefiles.h+1−1
@@ -305,7 +305,7 @@ TRACE_EVENT(cachefiles_mark_buried, · 304 unmodified lines
305305 ),
306306
307307 TP_fast_assign(
308− __entry->obj = obj->fscache.debug_id;
308+ __entry->obj = obj ? obj->fscache.debug_id : UINT_MAX;
309309 __entry->de = de;
310310 __entry->why = why;
311311 ),
include/uapi/sound/asound.h+1−0
@@ -784,6 +784,7 @@ struct snd_rawmidi_status { · 783 unmodified lines
784784
785785 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
786786 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
787+#define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int)
787788 #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params)
788789 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status)
789790 #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
kernel/bpf/bpf_struct_ops.c+5−2
@@ -368,6 +368,7 @@ static int bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, · 367 unmodified lines
368368 const struct btf_type *mtype, *ptype;
369369 struct bpf_prog *prog;
370370 u32 moff;
371+ u32 flags;
371372
372373 moff = btf_member_bit_offset(t, member) / 8;
373374 ptype = btf_type_resolve_ptr(btf_vmlinux, member->type, NULL);
@@ -431,10 +432,12 @@ static int bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, · 57 unmodified lines
431432
432433 tprogs[BPF_TRAMP_FENTRY].progs[0] = prog;
433434 tprogs[BPF_TRAMP_FENTRY].nr_progs = 1;
435+ flags = st_ops->func_models[i].ret_size > 0 ?
436+ BPF_TRAMP_F_RET_FENTRY_RET : 0;
434437 err = arch_prepare_bpf_trampoline(NULL, image,
435438 st_map->image + PAGE_SIZE,
436− &st_ops->func_models[i], 0,
437− tprogs, NULL);
439+ &st_ops->func_models[i],
440+ flags, tprogs, NULL);
438441 if (err < 0)
439442 goto reset_unlock;
440443
kernel/bpf/core.c+1−1
@@ -827,7 +827,7 @@ int bpf_jit_charge_modmem(u32 pages) · 826 unmodified lines
827827 {
828828 if (atomic_long_add_return(pages, &bpf_jit_current) >
829829 (bpf_jit_limit >> PAGE_SHIFT)) {
830− if (!capable(CAP_SYS_ADMIN)) {
830+ if (!bpf_capable()) {
831831 atomic_long_sub(pages, &bpf_jit_current);
832832 return -EPERM;
833833 }
kernel/cgroup/cgroup.c+12−5
@@ -6574,22 +6574,29 @@ int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v) · 6573 unmodified lines
65746574
65756575 void cgroup_sk_alloc(struct sock_cgroup_data *skcd)
65766576 {
6577− /* Don't associate the sock with unrelated interrupted task's cgroup. */
6578− if (in_interrupt())
6579− return;
6577+ struct cgroup *cgroup;
65806578
65816579 rcu_read_lock();
6580+ /* Don't associate the sock with unrelated interrupted task's cgroup. */
6581+ if (in_interrupt()) {
6582+ cgroup = &cgrp_dfl_root.cgrp;
6583+ cgroup_get(cgroup);
6584+ goto out;
6585+ }
6586+
65826587 while (true) {
65836588 struct css_set *cset;
65846589
65856590 cset = task_css_set(current);
65866591 if (likely(cgroup_tryget(cset->dfl_cgrp))) {
6587− skcd->cgroup = cset->dfl_cgrp;
6588− cgroup_bpf_get(cset->dfl_cgrp);
6592+ cgroup = cset->dfl_cgrp;
65896593 break;
65906594 }
65916595 cpu_relax();
65926596 }
6597+out:
6598+ skcd->cgroup = cgroup;
6599+ cgroup_bpf_get(cgroup);
65936600 rcu_read_unlock();
65946601 }
65956602
kernel/events/core.c+30−4
@@ -3707,6 +3707,29 @@ static noinline int visit_groups_merge(struct perf_cpu_context *cpuctx, · 3706 unmodified lines
37073707 return 0;
37083708 }
37093709
3710+static inline bool event_update_userpage(struct perf_event *event)
3711+{
3712+ if (likely(!atomic_read(&event->mmap_count)))
3713+ return false;
3714+
3715+ perf_event_update_time(event);
3716+ perf_set_shadow_time(event, event->ctx);
3717+ perf_event_update_userpage(event);
3718+
3719+ return true;
3720+}
3721+
3722+static inline void group_update_userpage(struct perf_event *group_event)
3723+{
3724+ struct perf_event *event;
3725+
3726+ if (!event_update_userpage(group_event))
3727+ return;
3728+
3729+ for_each_sibling_event(event, group_event)
3730+ event_update_userpage(event);
3731+}
3732+
37103733 static int merge_sched_in(struct perf_event *event, void *data)
37113734 {
37123735 struct perf_event_context *ctx = event->ctx;
@@ -3725,14 +3748,15 @@ static int merge_sched_in(struct perf_event *event, void *data) · 12 unmodified lines
37253748 }
37263749
37273750 if (event->state == PERF_EVENT_STATE_INACTIVE) {
3751+ *can_add_hw = 0;
37283752 if (event->attr.pinned) {
37293753 perf_cgroup_event_disable(event, ctx);
37303754 perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
3755+ } else {
3756+ ctx->rotate_necessary = 1;
3757+ perf_mux_hrtimer_restart(cpuctx);
3758+ group_update_userpage(event);
37313759 }
3732−
3733− *can_add_hw = 0;
3734− ctx->rotate_necessary = 1;
3735− perf_mux_hrtimer_restart(cpuctx);
37363760 }
37373761
37383762 return 0;
@@ -6324,6 +6348,8 @@ accounting: · 2585 unmodified lines
63246348
63256349 ring_buffer_attach(event, rb);
63266350
6351+ perf_event_update_time(event);
6352+ perf_set_shadow_time(event, event->ctx);
63276353 perf_event_init_userpage(event);
63286354 perf_event_update_userpage(event);
63296355 } else {
kernel/sched/debug.c+7−1
@@ -173,16 +173,22 @@ static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf, · 172 unmodified lines
173173 size_t cnt, loff_t *ppos)
174174 {
175175 char buf[16];
176+ unsigned int scaling;
176177
177178 if (cnt > 15)
178179 cnt = 15;
179180
180181 if (copy_from_user(&buf, ubuf, cnt))
181182 return -EFAULT;
183+ buf[cnt] = '\0';
182184
183− if (kstrtouint(buf, 10, &sysctl_sched_tunable_scaling))
185+ if (kstrtouint(buf, 10, &scaling))
184186 return -EINVAL;
185187
188+ if (scaling >= SCHED_TUNABLESCALING_END)
189+ return -EINVAL;
190+
191+ sysctl_sched_tunable_scaling = scaling;
186192 if (sched_update_scaling())
187193 return -EINVAL;
188194
kernel/sched/fair.c+5−1
@@ -4936,8 +4936,12 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) · 4935 unmodified lines
49364936 /* update hierarchical throttle state */
49374937 walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq);
49384938
4939− if (!cfs_rq->load.weight)
4939+ /* Nothing to run but something to decay (on_list)? Complete the branch */
4940+ if (!cfs_rq->load.weight) {
4941+ if (cfs_rq->on_list)
4942+ goto unthrottle_throttle;
49404943 return;
4944+ }
49414945
49424946 task_delta = cfs_rq->h_nr_running;
49434947 idle_task_delta = cfs_rq->idle_h_nr_running;
net/bpf/test_run.c+9−5
@@ -552,6 +552,12 @@ static void convert_skb_to___skb(struct sk_buff *skb, struct __sk_buff *__skb) · 551 unmodified lines
552552 __skb->gso_segs = skb_shinfo(skb)->gso_segs;
553553 }
554554
555+static struct proto bpf_dummy_proto = {
556+ .name = "bpf_dummy",
557+ .owner = THIS_MODULE,
558+ .obj_size = sizeof(struct sock),
559+};
560+
555561 int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
556562 union bpf_attr __user *uattr)
557563 {
@@ -596,20 +602,19 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr, · 38 unmodified lines
596602 break;
597603 }
598604
599− sk = kzalloc(sizeof(struct sock), GFP_USER);
605+ sk = sk_alloc(net, AF_UNSPEC, GFP_USER, &bpf_dummy_proto, 1);
600606 if (!sk) {
601607 kfree(data);
602608 kfree(ctx);
603609 return -ENOMEM;
604610 }
605− sock_net_set(sk, net);
606611 sock_init_data(NULL, sk);
607612
608613 skb = build_skb(data, 0);
609614 if (!skb) {
610615 kfree(data);
611616 kfree(ctx);
612− kfree(sk);
617+ sk_free(sk);
613618 return -ENOMEM;
614619 }
615620 skb->sk = sk;
@@ -682,8 +687,7 @@ out: · 66 unmodified lines
682687 if (dev && dev != net->loopback_dev)
683688 dev_put(dev);
684689 kfree_skb(skb);
685− bpf_sk_storage_free(sk);
686− kfree(sk);
690+ sk_free(sk);
687691 kfree(ctx);
688692 return ret;
689693 }
net/bridge/br_multicast.c+2−4
@@ -1677,8 +1677,6 @@ static void br_multicast_update_querier(struct net_bridge_mcast *brmctx, · 1676 unmodified lines
16771677 int ifindex,
16781678 struct br_ip *saddr)
16791679 {
1680− lockdep_assert_held_once(&brmctx->br->multicast_lock);
1681−
16821680 write_seqcount_begin(&querier->seq);
16831681 querier->port_ifidx = ifindex;
16841682 memcpy(&querier->addr, saddr, sizeof(*saddr));
@@ -3867,13 +3865,13 @@ void br_multicast_ctx_init(struct net_bridge *br, · 2182 unmodified lines
38673865
38683866 brmctx->ip4_other_query.delay_time = 0;
38693867 brmctx->ip4_querier.port_ifidx = 0;
3870− seqcount_init(&brmctx->ip4_querier.seq);
3868+ seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock);
38713869 brmctx->multicast_igmp_version = 2;
38723870 #if IS_ENABLED(CONFIG_IPV6)
38733871 brmctx->multicast_mld_version = 1;
38743872 brmctx->ip6_other_query.delay_time = 0;
38753873 brmctx->ip6_querier.port_ifidx = 0;
3876− seqcount_init(&brmctx->ip6_querier.seq);
3874+ seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock);
38773875 #endif
38783876
38793877 timer_setup(&brmctx->ip4_mc_router_timer,
net/bridge/br_private.h+1−1
@@ -82,7 +82,7 @@ struct bridge_mcast_other_query { · 81 unmodified lines
8282 struct bridge_mcast_querier {
8383 struct br_ip addr;
8484 int port_ifidx;
85− seqcount_t seq;
85+ seqcount_spinlock_t seq;
8686 };
8787
8888 /* IGMP/MLD statistics */
net/core/dev_addr_lists.c+6−0
@@ -50,6 +50,11 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list, · 49 unmodified lines
5050 if (addr_len > MAX_ADDR_LEN)
5151 return -EINVAL;
5252
53+ ha = list_first_entry(&list->list, struct netdev_hw_addr, list);
54+ if (ha && !memcmp(addr, ha->addr, addr_len) &&
55+ (!addr_type || addr_type == ha->type))
56+ goto found_it;
57+
5358 while (*ins_point) {
5459 int diff;
5560
@@ -64,6 +69,7 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list, · 8 unmodified lines
6469 } else if (diff > 0) {
6570 ins_point = &parent->rb_right;
6671 } else {
72+found_it:
6773 if (exclusive)
6874 return -EEXIST;
6975 if (global) {
net/core/sock.c+28−24
@@ -1376,6 +1376,16 @@ set_sndbuf: · 1375 unmodified lines
13761376 }
13771377 EXPORT_SYMBOL(sock_setsockopt);
13781378
1379+static const struct cred *sk_get_peer_cred(struct sock *sk)
1380+{
1381+ const struct cred *cred;
1382+
1383+ spin_lock(&sk->sk_peer_lock);
1384+ cred = get_cred(sk->sk_peer_cred);
1385+ spin_unlock(&sk->sk_peer_lock);
1386+
1387+ return cred;
1388+}
13791389
13801390 static void cred_to_ucred(struct pid *pid, const struct cred *cred,
13811391 struct ucred *ucred)
@@ -1552,7 +1562,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 170 unmodified lines
15521562 struct ucred peercred;
15531563 if (len > sizeof(peercred))
15541564 len = sizeof(peercred);
1565+
1566+ spin_lock(&sk->sk_peer_lock);
15551567 cred_to_ucred(sk->sk_peer_pid, sk->sk_peer_cred, &peercred);
1568+ spin_unlock(&sk->sk_peer_lock);
1569+
15561570 if (copy_to_user(optval, &peercred, len))
15571571 return -EFAULT;
15581572 goto lenout;
@@ -1560,20 +1574,23 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 1 unmodified line
15601574
15611575 case SO_PEERGROUPS:
15621576 {
1577+ const struct cred *cred;
15631578 int ret, n;
15641579
1565− if (!sk->sk_peer_cred)
1580+ cred = sk_get_peer_cred(sk);
1581+ if (!cred)
15661582 return -ENODATA;
15671583
1568− n = sk->sk_peer_cred->group_info->ngroups;
1584+ n = cred->group_info->ngroups;
15691585 if (len < n * sizeof(gid_t)) {
15701586 len = n * sizeof(gid_t);
1587+ put_cred(cred);
15711588 return put_user(len, optlen) ? -EFAULT : -ERANGE;
15721589 }
15731590 len = n * sizeof(gid_t);
15741591
1575− ret = groups_to_user((gid_t __user *)optval,
1576− sk->sk_peer_cred->group_info);
1592+ ret = groups_to_user((gid_t __user *)optval, cred->group_info);
1593+ put_cred(cred);
15771594 if (ret)
15781595 return ret;
15791596 goto lenout;
@@ -1935,9 +1952,10 @@ static void __sk_destruct(struct rcu_head *head) · 355 unmodified lines
19351952 sk->sk_frag.page = NULL;
19361953 }
19371954
1938− if (sk->sk_peer_cred)
1939− put_cred(sk->sk_peer_cred);
1955+ /* We do not need to acquire sk->sk_peer_lock, we are the last user. */
1956+ put_cred(sk->sk_peer_cred);
19401957 put_pid(sk->sk_peer_pid);
1958+
19411959 if (likely(sk->sk_net_refcnt))
19421960 put_net(sock_net(sk));
19431961 sk_prot_free(sk->sk_prot_creator, sk);
@@ -3145,6 +3163,8 @@ void sock_init_data(struct socket *sock, struct sock *sk) · 1201 unmodified lines
31453163
31463164 sk->sk_peer_pid = NULL;
31473165 sk->sk_peer_cred = NULL;
3166+ spin_lock_init(&sk->sk_peer_lock);
3167+
31483168 sk->sk_write_pending = 0;
31493169 sk->sk_rcvlowat = 1;
31503170 sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
@@ -3210,24 +3230,8 @@ void release_sock(struct sock *sk) · 59 unmodified lines
32103230 }
32113231 EXPORT_SYMBOL(release_sock);
32123232
3213−/**
3214− * lock_sock_fast - fast version of lock_sock
3215− * @sk: socket
3216− *
3217− * This version should be used for very small section, where process wont block
3218− * return false if fast path is taken:
3219− *
3220− * sk_lock.slock locked, owned = 0, BH disabled
3221− *
3222− * return true if slow path is taken:
3223− *
3224− * sk_lock.slock unlocked, owned = 1, BH enabled
3225− */
3226−bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock)
3233+bool __lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock)
32273234 {
3228− /* The sk_lock has mutex_lock() semantics here. */
3229− mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_);
3230−
32313235 might_sleep();
32323236 spin_lock_bh(&sk->sk_lock.slock);
32333237
@@ -3256,7 +3260,7 @@ bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock) · 22 unmodified lines
32563260 spin_unlock_bh(&sk->sk_lock.slock);
32573261 return true;
32583262 }
3259−EXPORT_SYMBOL(lock_sock_fast);
3263+EXPORT_SYMBOL(__lock_sock_fast);
32603264
32613265 int sock_gettstamp(struct socket *sock, void __user *userstamp,
32623266 bool timeval, bool time32)
net/ipv4/fib_semantics.c+9−7
@@ -1661,7 +1661,7 @@ EXPORT_SYMBOL_GPL(fib_nexthop_info); · 1660 unmodified lines
16611661
16621662 #if IS_ENABLED(CONFIG_IP_ROUTE_MULTIPATH) || IS_ENABLED(CONFIG_IPV6)
16631663 int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc,
1664− int nh_weight, u8 rt_family)
1664+ int nh_weight, u8 rt_family, u32 nh_tclassid)
16651665 {
16661666 const struct net_device *dev = nhc->nhc_dev;
16671667 struct rtnexthop *rtnh;
@@ -1679,6 +1679,9 @@ int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc, · 11 unmodified lines
16791679
16801680 rtnh->rtnh_flags = flags;
16811681
1682+ if (nh_tclassid && nla_put_u32(skb, RTA_FLOW, nh_tclassid))
1683+ goto nla_put_failure;
1684+
16821685 /* length of rtnetlink header + attributes */
16831686 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *)rtnh;
16841687
@@ -1706,14 +1709,13 @@ static int fib_add_multipath(struct sk_buff *skb, struct fib_info *fi) · 21 unmodified lines
17061709 }
17071710
17081711 for_nexthops(fi) {
1709− if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight,
1710− AF_INET) < 0)
1711− goto nla_put_failure;
1712+ u32 nh_tclassid = 0;
17121713 #ifdef CONFIG_IP_ROUTE_CLASSID
1713− if (nh->nh_tclassid &&
1714− nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
1715− goto nla_put_failure;
1714+ nh_tclassid = nh->nh_tclassid;
17161715 #endif
1716+ if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight,
1717+ AF_INET, nh_tclassid) < 0)
1718+ goto nla_put_failure;
17171719 } endfor_nexthops(fi);
17181720
17191721 mp_end:
net/ipv4/netfilter/iptable_raw.c+1−1
@@ -42,7 +42,7 @@ iptable_raw_hook(void *priv, struct sk_buff *skb, · 41 unmodified lines
4242
4343 static struct nf_hook_ops *rawtable_ops __read_mostly;
4444
45−static int __net_init iptable_raw_table_init(struct net *net)
45+static int iptable_raw_table_init(struct net *net)
4646 {
4747 struct ipt_replace *repl;
4848 const struct xt_table *table = &packet_raw;
net/ipv4/udp.c+5−5
@@ -1053,7 +1053,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · 1052 unmodified lines
10531053 __be16 dport;
10541054 u8 tos;
10551055 int err, is_udplite = IS_UDPLITE(sk);
1056− int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
1056+ int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE;
10571057 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
10581058 struct sk_buff *skb;
10591059 struct ip_options_data opt_copy;
@@ -1361,7 +1361,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, · 301 unmodified lines
13611361 }
13621362
13631363 up->len += size;
1364− if (!(up->corkflag || (flags&MSG_MORE)))
1364+ if (!(READ_ONCE(up->corkflag) || (flags&MSG_MORE)))
13651365 ret = udp_push_pending_frames(sk);
13661366 if (!ret)
13671367 ret = size;
@@ -2662,9 +2662,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, · 1294 unmodified lines
26622662 switch (optname) {
26632663 case UDP_CORK:
26642664 if (val != 0) {
2665− up->corkflag = 1;
2665+ WRITE_ONCE(up->corkflag, 1);
26662666 } else {
2667− up->corkflag = 0;
2667+ WRITE_ONCE(up->corkflag, 0);
26682668 lock_sock(sk);
26692669 push_pending_frames(sk);
26702670 release_sock(sk);
@@ -2787,7 +2787,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname, · 116 unmodified lines
27872787
27882788 switch (optname) {
27892789 case UDP_CORK:
2790− val = up->corkflag;
2790+ val = READ_ONCE(up->corkflag);
27912791 break;
27922792
27932793 case UDP_ENCAP:
net/ipv6/netfilter/ip6_tables.c+1−0
@@ -273,6 +273,7 @@ ip6t_do_table(struct sk_buff *skb, · 272 unmodified lines
273273 * things we don't know, ie. tcp syn flag or ports). If the
274274 * rule is also a fragment-specific rule, non-fragments won't
275275 * match it. */
276+ acpar.fragoff = 0;
276277 acpar.hotdrop = false;
277278 acpar.state = state;
278279
net/ipv6/route.c+3−2
@@ -5681,14 +5681,15 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, · 5680 unmodified lines
56815681 goto nla_put_failure;
56825682
56835683 if (fib_add_nexthop(skb, &rt->fib6_nh->nh_common,
5684− rt->fib6_nh->fib_nh_weight, AF_INET6) < 0)
5684+ rt->fib6_nh->fib_nh_weight, AF_INET6,
5685+ 0) < 0)
56855686 goto nla_put_failure;
56865687
56875688 list_for_each_entry_safe(sibling, next_sibling,
56885689 &rt->fib6_siblings, fib6_siblings) {
56895690 if (fib_add_nexthop(skb, &sibling->fib6_nh->nh_common,
56905691 sibling->fib6_nh->fib_nh_weight,
5691− AF_INET6) < 0)
5692+ AF_INET6, 0) < 0)
56925693 goto nla_put_failure;
56935694 }
56945695
net/ipv6/udp.c+1−1
@@ -1303,7 +1303,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · 1302 unmodified lines
13031303 int addr_len = msg->msg_namelen;
13041304 bool connected = false;
13051305 int ulen = len;
1306− int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
1306+ int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE;
13071307 int err;
13081308 int is_udplite = IS_UDPLITE(sk);
13091309 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
net/mac80211/mesh_pathtbl.c+4−1
@@ -60,7 +60,10 @@ static struct mesh_table *mesh_table_alloc(void) · 59 unmodified lines
6060 atomic_set(&newtbl->entries, 0);
6161 spin_lock_init(&newtbl->gates_lock);
6262 spin_lock_init(&newtbl->walk_lock);
63− rhashtable_init(&newtbl->rhead, &mesh_rht_params);
63+ if (rhashtable_init(&newtbl->rhead, &mesh_rht_params)) {
64+ kfree(newtbl);
65+ return NULL;
66+ }
6467
6568 return newtbl;
6669 }
net/mac80211/mesh_ps.c+2−1
@@ -2,6 +2,7 @@ · 1 unmodified line
22 /*
33 * Copyright 2012-2013, Marco Porsch <marco.porsch@s2005.tu-chemnitz.de>
44 * Copyright 2012-2013, cozybit Inc.
5+ * Copyright (C) 2021 Intel Corporation
56 */
67
78 #include "mesh.h"
@@ -588,7 +589,7 @@ void ieee80211_mps_frame_release(struct sta_info *sta, · 580 unmodified lines
588589
589590 /* only transmit to PS STA with announced, non-zero awake window */
590591 if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
591− (!elems->awake_window || !le16_to_cpu(*elems->awake_window)))
592+ (!elems->awake_window || !get_unaligned_le16(elems->awake_window)))
592593 return;
593594
594595 if (!test_sta_flag(sta, WLAN_STA_MPSP_OWNER))
net/mac80211/rate.c+0−4
@@ -392,10 +392,6 @@ static bool rate_control_send_low(struct ieee80211_sta *pubsta, · 391 unmodified lines
392392 int mcast_rate;
393393 bool use_basicrate = false;
394394
395− if (ieee80211_is_tx_data(txrc->skb) &&
396− info->flags & IEEE80211_TX_CTL_NO_ACK)
397− return false;
398−
399395 if (!pubsta || rc_no_data_or_no_ack_use_min(txrc)) {
400396 __rate_control_send_low(txrc->hw, sband, pubsta, info,
401397 txrc->rate_idx_mask);
net/mac80211/rx.c+2−1
@@ -4131,7 +4131,8 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) · 4130 unmodified lines
41314131 if (!bssid)
41324132 return false;
41334133 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
4134− ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
4134+ ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2) ||
4135+ !is_valid_ether_addr(hdr->addr2))
41354136 return false;
41364137 if (ieee80211_is_beacon(hdr->frame_control))
41374138 return true;
net/mac80211/tx.c+12−0
@@ -2209,7 +2209,11 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, · 2208 unmodified lines
22092209 }
22102210
22112211 vht_mcs = iterator.this_arg[4] >> 4;
2212+ if (vht_mcs > 11)
2213+ vht_mcs = 0;
22122214 vht_nss = iterator.this_arg[4] & 0xF;
2215+ if (!vht_nss || vht_nss > 8)
2216+ vht_nss = 1;
22132217 break;
22142218
22152219 /*
@@ -3380,6 +3384,14 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, · 1164 unmodified lines
33803384 if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head))
33813385 goto out;
33823386
3387+ /* If n == 2, the "while (*frag_tail)" loop above didn't execute
3388+ * and frag_tail should be &skb_shinfo(head)->frag_list.
3389+ * However, ieee80211_amsdu_prepare_head() can reallocate it.
3390+ * Reload frag_tail to have it pointing to the correct place.
3391+ */
3392+ if (n == 2)
3393+ frag_tail = &skb_shinfo(head)->frag_list;
3394+
33833395 /*
33843396 * Pad out the previous subframe to a multiple of 4 by adding the
33853397 * padding to the next one, that's being added. Note that head->len
net/mac80211/wpa.c+6−0
@@ -520,6 +520,9 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx, · 519 unmodified lines
520520 return RX_DROP_UNUSABLE;
521521 }
522522
523+ /* reload hdr - skb might have been reallocated */
524+ hdr = (void *)rx->skb->data;
525+
523526 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
524527 if (!rx->sta || data_len < 0)
525528 return RX_DROP_UNUSABLE;
@@ -749,6 +752,9 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx) · 223 unmodified lines
749752 return RX_DROP_UNUSABLE;
750753 }
751754
755+ /* reload hdr - skb might have been reallocated */
756+ hdr = (void *)rx->skb->data;
757+
752758 data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len;
753759 if (!rx->sta || data_len < 0)
754760 return RX_DROP_UNUSABLE;
net/mptcp/mptcp_diag.c+1−1
@@ -36,7 +36,7 @@ static int mptcp_diag_dump_one(struct netlink_callback *cb, · 35 unmodified lines
3636 struct sock *sk;
3737
3838 net = sock_net(in_skb->sk);
39− msk = mptcp_token_get_sock(req->id.idiag_cookie[0]);
39+ msk = mptcp_token_get_sock(net, req->id.idiag_cookie[0]);
4040 if (!msk)
4141 goto out_nosk;
4242
net/mptcp/pm_netlink.c+1−3
@@ -1718,9 +1718,7 @@ static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · 1717 unmodified lines
17181718
17191719 list_for_each_entry(entry, &pernet->local_addr_list, list) {
17201720 if (addresses_equal(&entry->addr, &addr.addr, true)) {
1721− ret = mptcp_nl_addr_backup(net, &entry->addr, bkup);
1722− if (ret)
1723− return ret;
1721+ mptcp_nl_addr_backup(net, &entry->addr, bkup);
17241722
17251723 if (bkup)
17261724 entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
net/mptcp/protocol.c+1−1
@@ -2735,7 +2735,7 @@ cleanup: · 2734 unmodified lines
27352735 inet_csk(sk)->icsk_mtup.probe_timestamp = tcp_jiffies32;
27362736 mptcp_for_each_subflow(mptcp_sk(sk), subflow) {
27372737 struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
2738− bool slow = lock_sock_fast(ssk);
2738+ bool slow = lock_sock_fast_nested(ssk);
27392739
27402740 sock_orphan(ssk);
27412741 unlock_sock_fast(ssk, slow);
net/mptcp/protocol.h+1−1
@@ -709,7 +709,7 @@ int mptcp_token_new_connect(struct sock *sk); · 708 unmodified lines
709709 void mptcp_token_accept(struct mptcp_subflow_request_sock *r,
710710 struct mptcp_sock *msk);
711711 bool mptcp_token_exists(u32 token);
712−struct mptcp_sock *mptcp_token_get_sock(u32 token);
712+struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token);
713713 struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot,
714714 long *s_num);
715715 void mptcp_token_destroy(struct mptcp_sock *msk);
net/mptcp/subflow.c+1−1
@@ -86,7 +86,7 @@ static struct mptcp_sock *subflow_token_join_request(struct request_sock *req) · 85 unmodified lines
8686 struct mptcp_sock *msk;
8787 int local_id;
8888
89− msk = mptcp_token_get_sock(subflow_req->token);
89+ msk = mptcp_token_get_sock(sock_net(req_to_sk(req)), subflow_req->token);
9090 if (!msk) {
9191 SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINNOTOKEN);
9292 return NULL;
net/mptcp/syncookies.c+1−12
@@ -108,18 +108,12 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl · 107 unmodified lines
108108
109109 e->valid = 0;
110110
111− msk = mptcp_token_get_sock(e->token);
111+ msk = mptcp_token_get_sock(net, e->token);
112112 if (!msk) {
113113 spin_unlock_bh(&join_entry_locks[i]);
114114 return false;
115115 }
116116
117− /* If this fails, the token got re-used in the mean time by another
118− * mptcp socket in a different netns, i.e. entry is outdated.
119− */
120− if (!net_eq(sock_net((struct sock *)msk), net))
121− goto err_put;
122−
123117 subflow_req->remote_nonce = e->remote_nonce;
124118 subflow_req->local_nonce = e->local_nonce;
125119 subflow_req->backup = e->backup;
@@ -128,11 +122,6 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl · 2 unmodified lines
128122 subflow_req->msk = msk;
129123 spin_unlock_bh(&join_entry_locks[i]);
130124 return true;
131−
132−err_put:
133− spin_unlock_bh(&join_entry_locks[i]);
134− sock_put((struct sock *)msk);
135− return false;
136125 }
137126
138127 void __init mptcp_join_cookie_init(void)
net/mptcp/token.c+8−3
@@ -231,6 +231,7 @@ found: · 230 unmodified lines
231231
232232 /**
233233 * mptcp_token_get_sock - retrieve mptcp connection sock using its token
234+ * @net: restrict to this namespace
234235 * @token: token of the mptcp connection to retrieve
235236 *
236237 * This function returns the mptcp connection structure with the given token.
@@ -238,7 +239,7 @@ found: · 1 unmodified line
238239 *
239240 * returns NULL if no connection with the given token value exists.
240241 */
241−struct mptcp_sock *mptcp_token_get_sock(u32 token)
242+struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token)
242243 {
243244 struct hlist_nulls_node *pos;
244245 struct token_bucket *bucket;
@@ -251,11 +252,15 @@ struct mptcp_sock *mptcp_token_get_sock(u32 token) · 6 unmodified lines
251252 again:
252253 sk_nulls_for_each_rcu(sk, pos, &bucket->msk_chain) {
253254 msk = mptcp_sk(sk);
254− if (READ_ONCE(msk->token) != token)
255+ if (READ_ONCE(msk->token) != token ||
256+ !net_eq(sock_net(sk), net))
255257 continue;
258+
256259 if (!refcount_inc_not_zero(&sk->sk_refcnt))
257260 goto not_found;
258− if (READ_ONCE(msk->token) != token) {
261+
262+ if (READ_ONCE(msk->token) != token ||
263+ !net_eq(sock_net(sk), net)) {
259264 sock_put(sk);
260265 goto again;
261266 }
net/mptcp/token_test.c+8−6
@@ -11,6 +11,7 @@ static struct mptcp_subflow_request_sock *build_req_sock(struct kunit *test) · 10 unmodified lines
1111 GFP_USER);
1212 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, req);
1313 mptcp_token_init_request((struct request_sock *)req);
14+ sock_net_set((struct sock *)req, &init_net);
1415 return req;
1516 }
1617
@@ -22,7 +23,7 @@ static void mptcp_token_test_req_basic(struct kunit *test) · 5 unmodified lines
2223 KUNIT_ASSERT_EQ(test, 0,
2324 mptcp_token_new_request((struct request_sock *)req));
2425 KUNIT_EXPECT_NE(test, 0, (int)req->token);
25− KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(req->token));
26+ KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, req->token));
2627
2728 /* cleanup */
2829 mptcp_token_destroy_request((struct request_sock *)req);
@@ -55,6 +56,7 @@ static struct mptcp_sock *build_msk(struct kunit *test) · 26 unmodified lines
5556 msk = kunit_kzalloc(test, sizeof(struct mptcp_sock), GFP_USER);
5657 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, msk);
5758 refcount_set(&((struct sock *)msk)->sk_refcnt, 1);
59+ sock_net_set((struct sock *)msk, &init_net);
5860 return msk;
5961 }
6062
@@ -74,11 +76,11 @@ static void mptcp_token_test_msk_basic(struct kunit *test) · 13 unmodified lines
7476 mptcp_token_new_connect((struct sock *)icsk));
7577 KUNIT_EXPECT_NE(test, 0, (int)ctx->token);
7678 KUNIT_EXPECT_EQ(test, ctx->token, msk->token);
77− KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(ctx->token));
79+ KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, ctx->token));
7880 KUNIT_EXPECT_EQ(test, 2, (int)refcount_read(&sk->sk_refcnt));
7981
8082 mptcp_token_destroy(msk);
81− KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(ctx->token));
83+ KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, ctx->token));
8284 }
8385
8486 static void mptcp_token_test_accept(struct kunit *test)
@@ -90,11 +92,11 @@ static void mptcp_token_test_accept(struct kunit *test) · 5 unmodified lines
9092 mptcp_token_new_request((struct request_sock *)req));
9193 msk->token = req->token;
9294 mptcp_token_accept(req, msk);
93− KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(msk->token));
95+ KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, msk->token));
9496
9597 /* this is now a no-op */
9698 mptcp_token_destroy_request((struct request_sock *)req);
97− KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(msk->token));
99+ KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, msk->token));
98100
99101 /* cleanup */
100102 mptcp_token_destroy(msk);
@@ -116,7 +118,7 @@ static void mptcp_token_test_destroyed(struct kunit *test) · 15 unmodified lines
116118
117119 /* simulate race on removal */
118120 refcount_set(&sk->sk_refcnt, 0);
119− KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(msk->token));
121+ KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, msk->token));
120122
121123 /* cleanup */
122124 mptcp_token_destroy(msk);
net/netfilter/ipset/ip_set_hash_gen.h+2−2
@@ -130,11 +130,11 @@ htable_size(u8 hbits) · 129 unmodified lines
130130 {
131131 size_t hsize;
132132
133− /* We must fit both into u32 in jhash and size_t */
133+ /* We must fit both into u32 in jhash and INT_MAX in kvmalloc_node() */
134134 if (hbits > 31)
135135 return 0;
136136 hsize = jhash_size(hbits);
137− if ((((size_t)-1) - sizeof(struct htable)) / sizeof(struct hbucket *)
137+ if ((INT_MAX - sizeof(struct htable)) / sizeof(struct hbucket *)
138138 < hsize)
139139 return 0;
140140
net/netfilter/ipvs/ip_vs_conn.c+4−0
@@ -1468,6 +1468,10 @@ int __init ip_vs_conn_init(void) · 1467 unmodified lines
14681468 int idx;
14691469
14701470 /* Compute size and mask */
1471+ if (ip_vs_conn_tab_bits < 8 || ip_vs_conn_tab_bits > 20) {
1472+ pr_info("conn_tab_bits not in [8, 20]. Using default value\n");
1473+ ip_vs_conn_tab_bits = CONFIG_IP_VS_TAB_BITS;
1474+ }
14711475 ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits;
14721476 ip_vs_conn_tab_mask = ip_vs_conn_tab_size - 1;
14731477
net/netfilter/nf_conntrack_core.c+100−54
@@ -74,10 +74,14 @@ static __read_mostly struct kmem_cache *nf_conntrack_cachep; · 73 unmodified lines
7474 static DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);
7575 static __read_mostly bool nf_conntrack_locks_all;
7676
77+/* serialize hash resizes and nf_ct_iterate_cleanup */
78+static DEFINE_MUTEX(nf_conntrack_mutex);
79+
7780 #define GC_SCAN_INTERVAL (120u * HZ)
7881 #define GC_SCAN_MAX_DURATION msecs_to_jiffies(10)
7982
80−#define MAX_CHAINLEN 64u
83+#define MIN_CHAINLEN 8u
84+#define MAX_CHAINLEN (32u - MIN_CHAINLEN)
8185
8286 static struct conntrack_gc_work conntrack_gc_work;
8387
@@ -188,11 +192,13 @@ seqcount_spinlock_t nf_conntrack_generation __read_mostly; · 104 unmodified lines
188192 static siphash_key_t nf_conntrack_hash_rnd __read_mostly;
189193
190194 static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple,
195+ unsigned int zoneid,
191196 const struct net *net)
192197 {
193198 struct {
194199 struct nf_conntrack_man src;
195200 union nf_inet_addr dst_addr;
201+ unsigned int zone;
196202 u32 net_mix;
197203 u16 dport;
198204 u16 proto;
@@ -205,6 +211,7 @@ static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple, · 6 unmodified lines
205211 /* The direction must be ignored, so handle usable members manually. */
206212 combined.src = tuple->src;
207213 combined.dst_addr = tuple->dst.u3;
214+ combined.zone = zoneid;
208215 combined.net_mix = net_hash_mix(net);
209216 combined.dport = (__force __u16)tuple->dst.u.all;
210217 combined.proto = tuple->dst.protonum;
@@ -219,15 +226,17 @@ static u32 scale_hash(u32 hash) · 8 unmodified lines
219226
220227 static u32 __hash_conntrack(const struct net *net,
221228 const struct nf_conntrack_tuple *tuple,
229+ unsigned int zoneid,
222230 unsigned int size)
223231 {
224− return reciprocal_scale(hash_conntrack_raw(tuple, net), size);
232+ return reciprocal_scale(hash_conntrack_raw(tuple, zoneid, net), size);
225233 }
226234
227235 static u32 hash_conntrack(const struct net *net,
228− const struct nf_conntrack_tuple *tuple)
236+ const struct nf_conntrack_tuple *tuple,
237+ unsigned int zoneid)
229238 {
230− return scale_hash(hash_conntrack_raw(tuple, net));
239+ return scale_hash(hash_conntrack_raw(tuple, zoneid, net));
231240 }
232241
233242 static bool nf_ct_get_tuple_ports(const struct sk_buff *skb,
@@ -650,9 +659,11 @@ static void nf_ct_delete_from_lists(struct nf_conn *ct) · 416 unmodified lines
650659 do {
651660 sequence = read_seqcount_begin(&nf_conntrack_generation);
652661 hash = hash_conntrack(net,
653− &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
662+ &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
663+ nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_ORIGINAL));
654664 reply_hash = hash_conntrack(net,
655− &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
665+ &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
666+ nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY));
656667 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence));
657668
658669 clean_from_lists(ct);
@@ -819,8 +830,20 @@ struct nf_conntrack_tuple_hash * · 160 unmodified lines
819830 nf_conntrack_find_get(struct net *net, const struct nf_conntrack_zone *zone,
820831 const struct nf_conntrack_tuple *tuple)
821832 {
822− return __nf_conntrack_find_get(net, zone, tuple,
823− hash_conntrack_raw(tuple, net));
833+ unsigned int rid, zone_id = nf_ct_zone_id(zone, IP_CT_DIR_ORIGINAL);
834+ struct nf_conntrack_tuple_hash *thash;
835+
836+ thash = __nf_conntrack_find_get(net, zone, tuple,
837+ hash_conntrack_raw(tuple, zone_id, net));
838+
839+ if (thash)
840+ return thash;
841+
842+ rid = nf_ct_zone_id(zone, IP_CT_DIR_REPLY);
843+ if (rid != zone_id)
844+ return __nf_conntrack_find_get(net, zone, tuple,
845+ hash_conntrack_raw(tuple, rid, net));
846+ return thash;
824847 }
825848 EXPORT_SYMBOL_GPL(nf_conntrack_find_get);
826849
@@ -842,6 +865,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) · 15 unmodified lines
842865 unsigned int hash, reply_hash;
843866 struct nf_conntrack_tuple_hash *h;
844867 struct hlist_nulls_node *n;
868+ unsigned int max_chainlen;
845869 unsigned int chainlen = 0;
846870 unsigned int sequence;
847871 int err = -EEXIST;
@@ -852,18 +876,22 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) · 4 unmodified lines
852876 do {
853877 sequence = read_seqcount_begin(&nf_conntrack_generation);
854878 hash = hash_conntrack(net,
855− &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
879+ &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
880+ nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_ORIGINAL));
856881 reply_hash = hash_conntrack(net,
857− &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
882+ &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
883+ nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY));
858884 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence));
859885
886+ max_chainlen = MIN_CHAINLEN + prandom_u32_max(MAX_CHAINLEN);
887+
860888 /* See if there's one in the list already, including reverse */
861889 hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[hash], hnnode) {
862890 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
863891 zone, net))
864892 goto out;
865893
866− if (chainlen++ > MAX_CHAINLEN)
894+ if (chainlen++ > max_chainlen)
867895 goto chaintoolong;
868896 }
869897
@@ -873,7 +901,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) · 3 unmodified lines
873901 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
874902 zone, net))
875903 goto out;
876− if (chainlen++ > MAX_CHAINLEN)
904+ if (chainlen++ > max_chainlen)
877905 goto chaintoolong;
878906 }
879907
@@ -1103,8 +1131,8 @@ drop: · 223 unmodified lines
11031131 int
11041132 __nf_conntrack_confirm(struct sk_buff *skb)
11051133 {
1134+ unsigned int chainlen = 0, sequence, max_chainlen;
11061135 const struct nf_conntrack_zone *zone;
1107− unsigned int chainlen = 0, sequence;
11081136 unsigned int hash, reply_hash;
11091137 struct nf_conntrack_tuple_hash *h;
11101138 struct nf_conn *ct;
@@ -1133,8 +1161,8 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 22 unmodified lines
11331161 hash = *(unsigned long *)&ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev;
11341162 hash = scale_hash(hash);
11351163 reply_hash = hash_conntrack(net,
1136− &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
1137−
1164+ &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
1165+ nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY));
11381166 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence));
11391167
11401168 /* We're not in hash table, and we refuse to set up related
@@ -1168,6 +1196,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 27 unmodified lines
11681196 goto dying;
11691197 }
11701198
1199+ max_chainlen = MIN_CHAINLEN + prandom_u32_max(MAX_CHAINLEN);
11711200 /* See if there's one in the list already, including reverse:
11721201 NAT could have grabbed it without realizing, since we're
11731202 not in the hash. If there is, we lost race. */
@@ -1175,7 +1204,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 1 unmodified line
11751204 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
11761205 zone, net))
11771206 goto out;
1178− if (chainlen++ > MAX_CHAINLEN)
1207+ if (chainlen++ > max_chainlen)
11791208 goto chaintoolong;
11801209 }
11811210
@@ -1184,7 +1213,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) · 2 unmodified lines
11841213 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
11851214 zone, net))
11861215 goto out;
1187− if (chainlen++ > MAX_CHAINLEN) {
1216+ if (chainlen++ > max_chainlen) {
11881217 chaintoolong:
11891218 nf_ct_add_to_dying_list(ct);
11901219 NF_CT_STAT_INC(net, chaintoolong);
@@ -1246,7 +1275,7 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, · 55 unmodified lines
12461275 rcu_read_lock();
12471276 begin:
12481277 nf_conntrack_get_ht(&ct_hash, &hsize);
1249− hash = __hash_conntrack(net, tuple, hsize);
1278+ hash = __hash_conntrack(net, tuple, nf_ct_zone_id(zone, IP_CT_DIR_REPLY), hsize);
12501279
12511280 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[hash], hnnode) {
12521281 ct = nf_ct_tuplehash_to_ctrack(h);
@@ -1687,8 +1716,8 @@ resolve_normal_ct(struct nf_conn *tmpl, · 434 unmodified lines
16871716 struct nf_conntrack_tuple_hash *h;
16881717 enum ip_conntrack_info ctinfo;
16891718 struct nf_conntrack_zone tmp;
1719+ u32 hash, zone_id, rid;
16901720 struct nf_conn *ct;
1691− u32 hash;
16921721
16931722 if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
16941723 dataoff, state->pf, protonum, state->net,
@@ -1699,8 +1728,20 @@ resolve_normal_ct(struct nf_conn *tmpl, · 4 unmodified lines
16991728
17001729 /* look for tuple match */
17011730 zone = nf_ct_zone_tmpl(tmpl, skb, &tmp);
1702− hash = hash_conntrack_raw(&tuple, state->net);
1731+
1732+ zone_id = nf_ct_zone_id(zone, IP_CT_DIR_ORIGINAL);
1733+ hash = hash_conntrack_raw(&tuple, zone_id, state->net);
17031734 h = __nf_conntrack_find_get(state->net, zone, &tuple, hash);
1735+
1736+ if (!h) {
1737+ rid = nf_ct_zone_id(zone, IP_CT_DIR_REPLY);
1738+ if (zone_id != rid) {
1739+ u32 tmp = hash_conntrack_raw(&tuple, rid, state->net);
1740+
1741+ h = __nf_conntrack_find_get(state->net, zone, &tuple, tmp);
1742+ }
1743+ }
1744+
17041745 if (!h) {
17051746 h = init_conntrack(state->net, tmpl, &tuple,
17061747 skb, dataoff, hash);
@@ -2225,28 +2266,31 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data), · 518 unmodified lines
22252266 spinlock_t *lockp;
22262267
22272268 for (; *bucket < nf_conntrack_htable_size; (*bucket)++) {
2269+ struct hlist_nulls_head *hslot = &nf_conntrack_hash[*bucket];
2270+
2271+ if (hlist_nulls_empty(hslot))
2272+ continue;
2273+
22282274 lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
22292275 local_bh_disable();
22302276 nf_conntrack_lock(lockp);
2231− if (*bucket < nf_conntrack_htable_size) {
2232− hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[*bucket], hnnode) {
2233− if (NF_CT_DIRECTION(h) != IP_CT_DIR_REPLY)
2234− continue;
2235− /* All nf_conn objects are added to hash table twice, one
2236− * for original direction tuple, once for the reply tuple.
2237− *
2238− * Exception: In the IPS_NAT_CLASH case, only the reply
2239− * tuple is added (the original tuple already existed for
2240− * a different object).
2241− *
2242− * We only need to call the iterator once for each
2243− * conntrack, so we just use the 'reply' direction
2244− * tuple while iterating.
2245− */
2246− ct = nf_ct_tuplehash_to_ctrack(h);
2247− if (iter(ct, data))
2248− goto found;
2249− }
2277+ hlist_nulls_for_each_entry(h, n, hslot, hnnode) {
2278+ if (NF_CT_DIRECTION(h) != IP_CT_DIR_REPLY)
2279+ continue;
2280+ /* All nf_conn objects are added to hash table twice, one
2281+ * for original direction tuple, once for the reply tuple.
2282+ *
2283+ * Exception: In the IPS_NAT_CLASH case, only the reply
2284+ * tuple is added (the original tuple already existed for
2285+ * a different object).
2286+ *
2287+ * We only need to call the iterator once for each
2288+ * conntrack, so we just use the 'reply' direction
2289+ * tuple while iterating.
2290+ */
2291+ ct = nf_ct_tuplehash_to_ctrack(h);
2292+ if (iter(ct, data))
2293+ goto found;
22502294 }
22512295 spin_unlock(lockp);
22522296 local_bh_enable();
@@ -2264,26 +2308,20 @@ found: · 11 unmodified lines
22642308 static void nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data),
22652309 void *data, u32 portid, int report)
22662310 {
2267− unsigned int bucket = 0, sequence;
2311+ unsigned int bucket = 0;
22682312 struct nf_conn *ct;
22692313
22702314 might_sleep();
22712315
2272− for (;;) {
2273− sequence = read_seqcount_begin(&nf_conntrack_generation);
2274−
2275− while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) {
2276− /* Time to push up daises... */
2316+ mutex_lock(&nf_conntrack_mutex);
2317+ while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) {
2318+ /* Time to push up daises... */
22772319
2278− nf_ct_delete(ct, portid, report);
2279− nf_ct_put(ct);
2280− cond_resched();
2281− }
2282−
2283− if (!read_seqcount_retry(&nf_conntrack_generation, sequence))
2284− break;
2285− bucket = 0;
2320+ nf_ct_delete(ct, portid, report);
2321+ nf_ct_put(ct);
2322+ cond_resched();
22862323 }
2324+ mutex_unlock(&nf_conntrack_mutex);
22872325 }
22882326
22892327 struct iter_data {
@@ -2519,8 +2557,10 @@ int nf_conntrack_hash_resize(unsigned int hashsize) · 229 unmodified lines
25192557 if (!hash)
25202558 return -ENOMEM;
25212559
2560+ mutex_lock(&nf_conntrack_mutex);
25222561 old_size = nf_conntrack_htable_size;
25232562 if (old_size == hashsize) {
2563+ mutex_unlock(&nf_conntrack_mutex);
25242564 kvfree(hash);
25252565 return 0;
25262566 }
@@ -2537,12 +2577,16 @@ int nf_conntrack_hash_resize(unsigned int hashsize) · 10 unmodified lines
25372577
25382578 for (i = 0; i < nf_conntrack_htable_size; i++) {
25392579 while (!hlist_nulls_empty(&nf_conntrack_hash[i])) {
2580+ unsigned int zone_id;
2581+
25402582 h = hlist_nulls_entry(nf_conntrack_hash[i].first,
25412583 struct nf_conntrack_tuple_hash, hnnode);
25422584 ct = nf_ct_tuplehash_to_ctrack(h);
25432585 hlist_nulls_del_rcu(&h->hnnode);
2586+
2587+ zone_id = nf_ct_zone_id(nf_ct_zone(ct), NF_CT_DIRECTION(h));
25442588 bucket = __hash_conntrack(nf_ct_net(ct),
2545− &h->tuple, hashsize);
2589+ &h->tuple, zone_id, hashsize);
25462590 hlist_nulls_add_head_rcu(&h->hnnode, &hash[bucket]);
25472591 }
25482592 }
@@ -2556,6 +2600,8 @@ int nf_conntrack_hash_resize(unsigned int hashsize) · 7 unmodified lines
25562600 nf_conntrack_all_unlock();
25572601 local_bh_enable();
25582602
2603+ mutex_unlock(&nf_conntrack_mutex);
2604+
25592605 synchronize_net();
25602606 kvfree(old_hash);
25612607 return 0;
net/netfilter/nf_nat_core.c+12−5
@@ -150,13 +150,16 @@ static void __nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl) · 149 unmodified lines
150150
151151 /* We keep an extra hash for each conntrack, for fast searching. */
152152 static unsigned int
153−hash_by_src(const struct net *n, const struct nf_conntrack_tuple *tuple)
153+hash_by_src(const struct net *net,
154+ const struct nf_conntrack_zone *zone,
155+ const struct nf_conntrack_tuple *tuple)
154156 {
155157 unsigned int hash;
156158 struct {
157159 struct nf_conntrack_man src;
158160 u32 net_mix;
159161 u32 protonum;
162+ u32 zone;
160163 } __aligned(SIPHASH_ALIGNMENT) combined;
161164
162165 get_random_once(&nf_nat_hash_rnd, sizeof(nf_nat_hash_rnd));
@@ -165,9 +168,13 @@ hash_by_src(const struct net *n, const struct nf_conntrack_tuple *tuple) · 2 unmodified lines
165168
166169 /* Original src, to ensure we map it consistently if poss. */
167170 combined.src = tuple->src;
168− combined.net_mix = net_hash_mix(n);
171+ combined.net_mix = net_hash_mix(net);
169172 combined.protonum = tuple->dst.protonum;
170173
174+ /* Zone ID can be used provided its valid for both directions */
175+ if (zone->dir == NF_CT_DEFAULT_ZONE_DIR)
176+ combined.zone = zone->id;
177+
171178 hash = siphash(&combined, sizeof(combined), &nf_nat_hash_rnd);
172179
173180 return reciprocal_scale(hash, nf_nat_htable_size);
@@ -272,7 +279,7 @@ find_appropriate_src(struct net *net, · 98 unmodified lines
272279 struct nf_conntrack_tuple *result,
273280 const struct nf_nat_range2 *range)
274281 {
275− unsigned int h = hash_by_src(net, tuple);
282+ unsigned int h = hash_by_src(net, zone, tuple);
276283 const struct nf_conn *ct;
277284
278285 hlist_for_each_entry_rcu(ct, &nf_nat_bysource[h], nat_bysource) {
@@ -619,7 +626,7 @@ nf_nat_setup_info(struct nf_conn *ct, · 340 unmodified lines
619626 unsigned int srchash;
620627 spinlock_t *lock;
621628
622− srchash = hash_by_src(net,
629+ srchash = hash_by_src(net, nf_ct_zone(ct),
623630 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
624631 lock = &nf_nat_locks[srchash % CONNTRACK_LOCKS];
625632 spin_lock_bh(lock);
@@ -788,7 +795,7 @@ static void __nf_nat_cleanup_conntrack(struct nf_conn *ct) · 162 unmodified lines
788795 {
789796 unsigned int h;
790797
791− h = hash_by_src(nf_ct_net(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
798+ h = hash_by_src(nf_ct_net(ct), nf_ct_zone(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
792799 spin_lock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]);
793800 hlist_del_rcu(&ct->nat_bysource);
794801 spin_unlock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]);
net/netfilter/nf_nat_masquerade.c+97−71
@@ -9,8 +9,19 @@ · 8 unmodified lines
99
1010 #include <net/netfilter/nf_nat_masquerade.h>
1111
12+struct masq_dev_work {
13+ struct work_struct work;
14+ struct net *net;
15+ union nf_inet_addr addr;
16+ int ifindex;
17+ int (*iter)(struct nf_conn *i, void *data);
18+};
19+
20+#define MAX_MASQ_WORKER_COUNT 16
21+
1222 static DEFINE_MUTEX(masq_mutex);
1323 static unsigned int masq_refcnt __read_mostly;
24+static atomic_t masq_worker_count __read_mostly;
1425
1526 unsigned int
1627 nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum,
@@ -63,13 +74,71 @@ nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum, · 46 unmodified lines
6374 }
6475 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv4);
6576
66−static int device_cmp(struct nf_conn *i, void *ifindex)
77+static void iterate_cleanup_work(struct work_struct *work)
78+{
79+ struct masq_dev_work *w;
80+
81+ w = container_of(work, struct masq_dev_work, work);
82+
83+ nf_ct_iterate_cleanup_net(w->net, w->iter, (void *)w, 0, 0);
84+
85+ put_net(w->net);
86+ kfree(w);
87+ atomic_dec(&masq_worker_count);
88+ module_put(THIS_MODULE);
89+}
90+
91+/* Iterate conntrack table in the background and remove conntrack entries
92+ * that use the device/address being removed.
93+ *
94+ * In case too many work items have been queued already or memory allocation
95+ * fails iteration is skipped, conntrack entries will time out eventually.
96+ */
97+static void nf_nat_masq_schedule(struct net *net, union nf_inet_addr *addr,
98+ int ifindex,
99+ int (*iter)(struct nf_conn *i, void *data),
100+ gfp_t gfp_flags)
101+{
102+ struct masq_dev_work *w;
103+
104+ if (atomic_read(&masq_worker_count) > MAX_MASQ_WORKER_COUNT)
105+ return;
106+
107+ net = maybe_get_net(net);
108+ if (!net)
109+ return;
110+
111+ if (!try_module_get(THIS_MODULE))
112+ goto err_module;
113+
114+ w = kzalloc(sizeof(*w), gfp_flags);
115+ if (w) {
116+ /* We can overshoot MAX_MASQ_WORKER_COUNT, no big deal */
117+ atomic_inc(&masq_worker_count);
118+
119+ INIT_WORK(&w->work, iterate_cleanup_work);
120+ w->ifindex = ifindex;
121+ w->net = net;
122+ w->iter = iter;
123+ if (addr)
124+ w->addr = *addr;
125+ schedule_work(&w->work);
126+ return;
127+ }
128+
129+ module_put(THIS_MODULE);
130+ err_module:
131+ put_net(net);
132+}
133+
134+static int device_cmp(struct nf_conn *i, void *arg)
67135 {
68136 const struct nf_conn_nat *nat = nfct_nat(i);
137+ const struct masq_dev_work *w = arg;
69138
70139 if (!nat)
71140 return 0;
72− return nat->masq_index == (int)(long)ifindex;
141+ return nat->masq_index == w->ifindex;
73142 }
74143
75144 static int masq_device_event(struct notifier_block *this,
@@ -85,8 +154,8 @@ static int masq_device_event(struct notifier_block *this, · 9 unmodified lines
85154 * and forget them.
86155 */
87156
88− nf_ct_iterate_cleanup_net(net, device_cmp,
89− (void *)(long)dev->ifindex, 0, 0);
157+ nf_nat_masq_schedule(net, NULL, dev->ifindex,
158+ device_cmp, GFP_KERNEL);
90159 }
91160
92161 return NOTIFY_DONE;
@@ -94,35 +163,45 @@ static int masq_device_event(struct notifier_block *this, · 1 unmodified line
94163
95164 static int inet_cmp(struct nf_conn *ct, void *ptr)
96165 {
97− struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
98− struct net_device *dev = ifa->ifa_dev->dev;
99166 struct nf_conntrack_tuple *tuple;
167+ struct masq_dev_work *w = ptr;
100168
101− if (!device_cmp(ct, (void *)(long)dev->ifindex))
169+ if (!device_cmp(ct, ptr))
102170 return 0;
103171
104172 tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
105173
106− return ifa->ifa_address == tuple->dst.u3.ip;
174+ return nf_inet_addr_cmp(&w->addr, &tuple->dst.u3);
107175 }
108176
109177 static int masq_inet_event(struct notifier_block *this,
110178 unsigned long event,
111179 void *ptr)
112180 {
113− struct in_device *idev = ((struct in_ifaddr *)ptr)->ifa_dev;
114− struct net *net = dev_net(idev->dev);
181+ const struct in_ifaddr *ifa = ptr;
182+ const struct in_device *idev;
183+ const struct net_device *dev;
184+ union nf_inet_addr addr;
185+
186+ if (event != NETDEV_DOWN)
187+ return NOTIFY_DONE;
115188
116189 /* The masq_dev_notifier will catch the case of the device going
117190 * down. So if the inetdev is dead and being destroyed we have
118191 * no work to do. Otherwise this is an individual address removal
119192 * and we have to perform the flush.
120193 */
194+ idev = ifa->ifa_dev;
121195 if (idev->dead)
122196 return NOTIFY_DONE;
123197
124− if (event == NETDEV_DOWN)
125− nf_ct_iterate_cleanup_net(net, inet_cmp, ptr, 0, 0);
198+ memset(&addr, 0, sizeof(addr));
199+
200+ addr.ip = ifa->ifa_address;
201+
202+ dev = idev->dev;
203+ nf_nat_masq_schedule(dev_net(idev->dev), &addr, dev->ifindex,
204+ inet_cmp, GFP_KERNEL);
126205
127206 return NOTIFY_DONE;
128207 }
@@ -136,8 +215,6 @@ static struct notifier_block masq_inet_notifier = { · 7 unmodified lines
136215 };
137216
138217 #if IS_ENABLED(CONFIG_IPV6)
139−static atomic_t v6_worker_count __read_mostly;
140−
141218 static int
142219 nat_ipv6_dev_get_saddr(struct net *net, const struct net_device *dev,
143220 const struct in6_addr *daddr, unsigned int srcprefs,
@@ -187,40 +264,6 @@ nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range, · 43 unmodified lines
187264 }
188265 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv6);
189266
190−struct masq_dev_work {
191− struct work_struct work;
192− struct net *net;
193− struct in6_addr addr;
194− int ifindex;
195−};
196−
197−static int inet6_cmp(struct nf_conn *ct, void *work)
198−{
199− struct masq_dev_work *w = (struct masq_dev_work *)work;
200− struct nf_conntrack_tuple *tuple;
201−
202− if (!device_cmp(ct, (void *)(long)w->ifindex))
203− return 0;
204−
205− tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
206−
207− return ipv6_addr_equal(&w->addr, &tuple->dst.u3.in6);
208−}
209−
210−static void iterate_cleanup_work(struct work_struct *work)
211−{
212− struct masq_dev_work *w;
213−
214− w = container_of(work, struct masq_dev_work, work);
215−
216− nf_ct_iterate_cleanup_net(w->net, inet6_cmp, (void *)w, 0, 0);
217−
218− put_net(w->net);
219− kfree(w);
220− atomic_dec(&v6_worker_count);
221− module_put(THIS_MODULE);
222−}
223−
224267 /* atomic notifier; can't call nf_ct_iterate_cleanup_net (it can sleep).
225268 *
226269 * Defer it to the system workqueue.
@@ -233,36 +276,19 @@ static int masq_inet6_event(struct notifier_block *this, · 6 unmodified lines
233276 {
234277 struct inet6_ifaddr *ifa = ptr;
235278 const struct net_device *dev;
236− struct masq_dev_work *w;
237− struct net *net;
279+ union nf_inet_addr addr;
238280
239− if (event != NETDEV_DOWN || atomic_read(&v6_worker_count) >= 16)
281+ if (event != NETDEV_DOWN)
240282 return NOTIFY_DONE;
241283
242284 dev = ifa->idev->dev;
243− net = maybe_get_net(dev_net(dev));
244− if (!net)
245− return NOTIFY_DONE;
246285
247− if (!try_module_get(THIS_MODULE))
248− goto err_module;
286+ memset(&addr, 0, sizeof(addr));
249287
250− w = kmalloc(sizeof(*w), GFP_ATOMIC);
251− if (w) {
252− atomic_inc(&v6_worker_count);
253−
254− INIT_WORK(&w->work, iterate_cleanup_work);
255− w->ifindex = dev->ifindex;
256− w->net = net;
257− w->addr = ifa->addr;
258− schedule_work(&w->work);
288+ addr.in6 = ifa->addr;
259289
260− return NOTIFY_DONE;
261− }
262−
263− module_put(THIS_MODULE);
264− err_module:
265− put_net(net);
290+ nf_nat_masq_schedule(dev_net(dev), &addr, dev->ifindex, inet_cmp,
291+ GFP_ATOMIC);
266292 return NOTIFY_DONE;
267293 }
268294
net/netfilter/nf_tables_api.c+19−11
@@ -4336,7 +4336,7 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info, · 4335 unmodified lines
43364336 if (ops->privsize != NULL)
43374337 size = ops->privsize(nla, &desc);
43384338 alloc_size = sizeof(*set) + size + udlen;
4339− if (alloc_size < size)
4339+ if (alloc_size < size || alloc_size > INT_MAX)
43404340 return -ENOMEM;
43414341 set = kvzalloc(alloc_size, GFP_KERNEL);
43424342 if (!set)
@@ -9599,7 +9599,6 @@ static void __nft_release_table(struct net *net, struct nft_table *table) · 5256 unmodified lines
95999599 table->use--;
96009600 nf_tables_chain_destroy(&ctx);
96019601 }
9602− list_del(&table->list);
96039602 nf_tables_table_destroy(&ctx);
96049603 }
96059604
@@ -9612,6 +9611,8 @@ static void __nft_release_tables(struct net *net) · 6 unmodified lines
96129611 if (nft_table_has_owner(table))
96139612 continue;
96149613
9614+ list_del(&table->list);
9615+
96159616 __nft_release_table(net, table);
96169617 }
96179618 }
@@ -9619,31 +9620,38 @@ static void __nft_release_tables(struct net *net) · 1 unmodified line
96199620 static int nft_rcv_nl_event(struct notifier_block *this, unsigned long event,
96209621 void *ptr)
96219622 {
9623+ struct nft_table *table, *to_delete[8];
96229624 struct nftables_pernet *nft_net;
96239625 struct netlink_notify *n = ptr;
9624− struct nft_table *table, *nt;
96259626 struct net *net = n->net;
9626− bool release = false;
9627+ unsigned int deleted;
9628+ bool restart = false;
96279629
96289630 if (event != NETLINK_URELEASE || n->protocol != NETLINK_NETFILTER)
96299631 return NOTIFY_DONE;
96309632
96319633 nft_net = nft_pernet(net);
9634+ deleted = 0;
96329635 mutex_lock(&nft_net->commit_mutex);
9636+again:
96339637 list_for_each_entry(table, &nft_net->tables, list) {
96349638 if (nft_table_has_owner(table) &&
96359639 n->portid == table->nlpid) {
96369640 __nft_release_hook(net, table);
9637− release = true;
9641+ list_del_rcu(&table->list);
9642+ to_delete[deleted++] = table;
9643+ if (deleted >= ARRAY_SIZE(to_delete))
9644+ break;
96389645 }
96399646 }
9640− if (release) {
9647+ if (deleted) {
9648+ restart = deleted >= ARRAY_SIZE(to_delete);
96419649 synchronize_rcu();
9642− list_for_each_entry_safe(table, nt, &nft_net->tables, list) {
9643− if (nft_table_has_owner(table) &&
9644− n->portid == table->nlpid)
9645− __nft_release_table(net, table);
9646− }
9650+ while (deleted)
9651+ __nft_release_table(net, to_delete[--deleted]);
9652+
9653+ if (restart)
9654+ goto again;
96479655 }
96489656 mutex_unlock(&nft_net->commit_mutex);
96499657
net/netfilter/nft_compat.c+16−1
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/netfilter_bridge/ebtables.h>
2020 #include <linux/netfilter_arp/arp_tables.h>
2121 #include <net/netfilter/nf_tables.h>
22+#include <net/netfilter/nf_log.h>
2223
2324 /* Used for matches where *info is larger than X byte */
2425 #define NFT_MATCH_LARGE_THRESH 192
@@ -257,8 +258,22 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr, · 232 unmodified lines
257258 nft_compat_wait_for_destructors();
258259
259260 ret = xt_check_target(&par, size, proto, inv);
260− if (ret < 0)
261+ if (ret < 0) {
262+ if (ret == -ENOENT) {
263+ const char *modname = NULL;
264+
265+ if (strcmp(target->name, "LOG") == 0)
266+ modname = "nf_log_syslog";
267+ else if (strcmp(target->name, "NFLOG") == 0)
268+ modname = "nfnetlink_log";
269+
270+ if (modname &&
271+ nft_request_module(ctx->net, "%s", modname) == -EAGAIN)
272+ return -EAGAIN;
273+ }
274+
261275 return ret;
276+ }
262277
263278 /* The standard target cannot be used */
264279 if (!target->target)
net/netfilter/xt_LOG.c+9−1
@@ -44,6 +44,7 @@ log_tg(struct sk_buff *skb, const struct xt_action_param *par) · 43 unmodified lines
4444 static int log_tg_check(const struct xt_tgchk_param *par)
4545 {
4646 const struct xt_log_info *loginfo = par->targinfo;
47+ int ret;
4748
4849 if (par->family != NFPROTO_IPV4 && par->family != NFPROTO_IPV6)
4950 return -EINVAL;
@@ -58,7 +59,14 @@ static int log_tg_check(const struct xt_tgchk_param *par) · 8 unmodified lines
5859 return -EINVAL;
5960 }
6061
61− return nf_logger_find_get(par->family, NF_LOG_TYPE_LOG);
62+ ret = nf_logger_find_get(par->family, NF_LOG_TYPE_LOG);
63+ if (ret != 0 && !par->nft_compat) {
64+ request_module("%s", "nf_log_syslog");
65+
66+ ret = nf_logger_find_get(par->family, NF_LOG_TYPE_LOG);
67+ }
68+
69+ return ret;
6270 }
6371
6472 static void log_tg_destroy(const struct xt_tgdtor_param *par)
net/netfilter/xt_NFLOG.c+9−1
@@ -42,13 +42,21 @@ nflog_tg(struct sk_buff *skb, const struct xt_action_param *par) · 41 unmodified lines
4242 static int nflog_tg_check(const struct xt_tgchk_param *par)
4343 {
4444 const struct xt_nflog_info *info = par->targinfo;
45+ int ret;
4546
4647 if (info->flags & ~XT_NFLOG_MASK)
4748 return -EINVAL;
4849 if (info->prefix[sizeof(info->prefix) - 1] != '\0')
4950 return -EINVAL;
5051
51− return nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG);
52+ ret = nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG);
53+ if (ret != 0 && !par->nft_compat) {
54+ request_module("%s", "nfnetlink_log");
55+
56+ ret = nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG);
57+ }
58+
59+ return ret;
5260 }
5361
5462 static void nflog_tg_destroy(const struct xt_tgdtor_param *par)
net/sched/cls_flower.c+6−0
@@ -2188,18 +2188,24 @@ static void fl_walk(struct tcf_proto *tp, struct tcf_walker *arg, · 2187 unmodified lines
21882188
21892189 arg->count = arg->skip;
21902190
2191+ rcu_read_lock();
21912192 idr_for_each_entry_continue_ul(&head->handle_idr, f, tmp, id) {
21922193 /* don't return filters that are being deleted */
21932194 if (!refcount_inc_not_zero(&f->refcnt))
21942195 continue;
2196+ rcu_read_unlock();
2197+
21952198 if (arg->fn(tp, f, arg) < 0) {
21962199 __fl_put(f);
21972200 arg->stop = 1;
2201+ rcu_read_lock();
21982202 break;
21992203 }
22002204 __fl_put(f);
22012205 arg->count++;
2206+ rcu_read_lock();
22022207 }
2208+ rcu_read_unlock();
22032209 arg->cookie = id;
22042210 }
22052211
net/sched/sch_api.c+6−0
@@ -513,6 +513,12 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt, · 512 unmodified lines
513513 return stab;
514514 }
515515
516+ if (s->size_log > STAB_SIZE_LOG_MAX ||
517+ s->cell_log > STAB_SIZE_LOG_MAX) {
518+ NL_SET_ERR_MSG(extack, "Invalid logarithmic size of size table");
519+ return ERR_PTR(-EINVAL);
520+ }
521+
516522 stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL);
517523 if (!stab)
518524 return ERR_PTR(-ENOMEM);
net/sctp/input.c+1−1
@@ -702,7 +702,7 @@ static int sctp_rcv_ootb(struct sk_buff *skb) · 701 unmodified lines
702702 ch = skb_header_pointer(skb, offset, sizeof(*ch), &_ch);
703703
704704 /* Break out if chunk length is less then minimal. */
705− if (ntohs(ch->length) < sizeof(_ch))
705+ if (!ch || ntohs(ch->length) < sizeof(_ch))
706706 break;
707707
708708 ch_end = offset + SCTP_PAD4(ntohs(ch->length));
net/unix/af_unix.c+60−23
@@ -608,20 +608,42 @@ static void unix_release_sock(struct sock *sk, int embrion) · 607 unmodified lines
608608
609609 static void init_peercred(struct sock *sk)
610610 {
611− put_pid(sk->sk_peer_pid);
612− if (sk->sk_peer_cred)
613− put_cred(sk->sk_peer_cred);
611+ const struct cred *old_cred;
612+ struct pid *old_pid;
613+
614+ spin_lock(&sk->sk_peer_lock);
615+ old_pid = sk->sk_peer_pid;
616+ old_cred = sk->sk_peer_cred;
614617 sk->sk_peer_pid = get_pid(task_tgid(current));
615618 sk->sk_peer_cred = get_current_cred();
619+ spin_unlock(&sk->sk_peer_lock);
620+
621+ put_pid(old_pid);
622+ put_cred(old_cred);
616623 }
617624
618625 static void copy_peercred(struct sock *sk, struct sock *peersk)
619626 {
620− put_pid(sk->sk_peer_pid);
621− if (sk->sk_peer_cred)
622− put_cred(sk->sk_peer_cred);
627+ const struct cred *old_cred;
628+ struct pid *old_pid;
629+
630+ if (sk < peersk) {
631+ spin_lock(&sk->sk_peer_lock);
632+ spin_lock_nested(&peersk->sk_peer_lock, SINGLE_DEPTH_NESTING);
633+ } else {
634+ spin_lock(&peersk->sk_peer_lock);
635+ spin_lock_nested(&sk->sk_peer_lock, SINGLE_DEPTH_NESTING);
636+ }
637+ old_pid = sk->sk_peer_pid;
638+ old_cred = sk->sk_peer_cred;
623639 sk->sk_peer_pid = get_pid(peersk->sk_peer_pid);
624640 sk->sk_peer_cred = get_cred(peersk->sk_peer_cred);
641+
642+ spin_unlock(&sk->sk_peer_lock);
643+ spin_unlock(&peersk->sk_peer_lock);
644+
645+ put_pid(old_pid);
646+ put_cred(old_cred);
625647 }
626648
627649 static int unix_listen(struct socket *sock, int backlog)
@@ -828,20 +850,25 @@ struct proto unix_stream_proto = { · 200 unmodified lines
828850
829851 static struct sock *unix_create1(struct net *net, struct socket *sock, int kern, int type)
830852 {
831− struct sock *sk = NULL;
832853 struct unix_sock *u;
854+ struct sock *sk;
855+ int err;
833856
834857 atomic_long_inc(&unix_nr_socks);
835− if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files())
836− goto out;
858+ if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files()) {
859+ err = -ENFILE;
860+ goto err;
861+ }
837862
838863 if (type == SOCK_STREAM)
839864 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_stream_proto, kern);
840865 else /*dgram and seqpacket */
841866 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_dgram_proto, kern);
842867
843− if (!sk)
844− goto out;
868+ if (!sk) {
869+ err = -ENOMEM;
870+ goto err;
871+ }
845872
846873 sock_init_data(sock, sk);
847874
@@ -861,20 +888,23 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern, · 13 unmodified lines
861888 init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay);
862889 memset(&u->scm_stat, 0, sizeof(struct scm_stat));
863890 unix_insert_socket(unix_sockets_unbound(sk), sk);
864−out:
865− if (sk == NULL)
866− atomic_long_dec(&unix_nr_socks);
867− else {
868− local_bh_disable();
869− sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
870− local_bh_enable();
871− }
891+
892+ local_bh_disable();
893+ sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
894+ local_bh_enable();
895+
872896 return sk;
897+
898+err:
899+ atomic_long_dec(&unix_nr_socks);
900+ return ERR_PTR(err);
873901 }
874902
875903 static int unix_create(struct net *net, struct socket *sock, int protocol,
876904 int kern)
877905 {
906+ struct sock *sk;
907+
878908 if (protocol && protocol != PF_UNIX)
879909 return -EPROTONOSUPPORT;
880910
@@ -901,7 +931,11 @@ static int unix_create(struct net *net, struct socket *sock, int protocol, · 20 unmodified lines
901931 return -ESOCKTNOSUPPORT;
902932 }
903933
904− return unix_create1(net, sock, kern, sock->type) ? 0 : -ENOMEM;
934+ sk = unix_create1(net, sock, kern, sock->type);
935+ if (IS_ERR(sk))
936+ return PTR_ERR(sk);
937+
938+ return 0;
905939 }
906940
907941 static int unix_release(struct socket *sock)
@@ -1314,12 +1348,15 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, · 406 unmodified lines
13141348 we will have to recheck all again in any case.
13151349 */
13161350
1317− err = -ENOMEM;
1318−
13191351 /* create new sock for complete connection */
13201352 newsk = unix_create1(sock_net(sk), NULL, 0, sock->type);
1321− if (newsk == NULL)
1353+ if (IS_ERR(newsk)) {
1354+ err = PTR_ERR(newsk);
1355+ newsk = NULL;
13221356 goto out;
1357+ }
1358+
1359+ err = -ENOMEM;
13231360
13241361 /* Allocate skb for sending to listening sock */
13251362 skb = sock_wmalloc(newsk, 1, 0, GFP_KERNEL);
sound/core/rawmidi.c+9−0
@@ -873,12 +873,21 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long · 872 unmodified lines
873873 return -EINVAL;
874874 }
875875 }
876+ case SNDRV_RAWMIDI_IOCTL_USER_PVERSION:
877+ if (get_user(rfile->user_pversion, (unsigned int __user *)arg))
878+ return -EFAULT;
879+ return 0;
880+
876881 case SNDRV_RAWMIDI_IOCTL_PARAMS:
877882 {
878883 struct snd_rawmidi_params params;
879884
880885 if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params)))
881886 return -EFAULT;
887+ if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) {
888+ params.mode = 0;
889+ memset(params.reserved, 0, sizeof(params.reserved));
890+ }
882891 switch (params.stream) {
883892 case SNDRV_RAWMIDI_STREAM_OUTPUT:
884893 if (rfile->output == NULL)
sound/drivers/pcsp/pcsp_lib.c+1−1
@@ -143,7 +143,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) · 142 unmodified lines
143143 if (pointer_update)
144144 pcsp_pointer_update(chip);
145145
146− hrtimer_forward(handle, hrtimer_get_expires(handle), ns_to_ktime(ns));
146+ hrtimer_forward_now(handle, ns_to_ktime(ns));
147147
148148 return HRTIMER_RESTART;
149149 }
sound/firewire/motu/amdtp-motu.c+4−3
@@ -276,10 +276,11 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer, · 275 unmodified lines
276276
277277 /* This is just for v2/v3 protocol. */
278278 for (i = 0; i < data_blocks; ++i) {
279− *frames = (be32_to_cpu(buffer[1]) << 16) |
280− (be32_to_cpu(buffer[2]) >> 16);
279+ *frames = be32_to_cpu(buffer[1]);
280+ *frames <<= 16;
281+ *frames |= be32_to_cpu(buffer[2]) >> 16;
282+ ++frames;
281283 buffer += data_block_quadlets;
282− frames++;
283284 }
284285 }
285286
sound/firewire/oxfw/oxfw.c+8−5
@@ -184,13 +184,16 @@ static int detect_quirks(struct snd_oxfw *oxfw, const struct ieee1394_device_id · 183 unmodified lines
184184 model = val;
185185 }
186186
187− /*
188− * Mackie Onyx Satellite with base station has a quirk to report a wrong
189− * value in 'dbs' field of CIP header against its format information.
190− */
191− if (vendor == VENDOR_LOUD && model == MODEL_SATELLITE)
187+ if (vendor == VENDOR_LOUD) {
188+ // Mackie Onyx Satellite with base station has a quirk to report a wrong
189+ // value in 'dbs' field of CIP header against its format information.
192190 oxfw->quirks |= SND_OXFW_QUIRK_WRONG_DBS;
193191
192+ // OXFW971-based models may transfer events by blocking method.
193+ if (!(oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD))
194+ oxfw->quirks |= SND_OXFW_QUIRK_BLOCKING_TRANSMISSION;
195+ }
196+
194197 return 0;
195198 }
196199
sound/pci/hda/hda_intel.c+9−3
@@ -883,10 +883,11 @@ static unsigned int azx_get_pos_skl(struct azx *chip, struct azx_dev *azx_dev) · 882 unmodified lines
883883 return azx_get_pos_posbuf(chip, azx_dev);
884884 }
885885
886−static void azx_shutdown_chip(struct azx *chip)
886+static void __azx_shutdown_chip(struct azx *chip, bool skip_link_reset)
887887 {
888888 azx_stop_chip(chip);
889− azx_enter_link_reset(chip);
889+ if (!skip_link_reset)
890+ azx_enter_link_reset(chip);
890891 azx_clear_irq_pending(chip);
891892 display_power(chip, false);
892893 }
@@ -895,6 +896,11 @@ static void azx_shutdown_chip(struct azx *chip) · 2 unmodified lines
895896 static DEFINE_MUTEX(card_list_lock);
896897 static LIST_HEAD(card_list);
897898
899+static void azx_shutdown_chip(struct azx *chip)
900+{
901+ __azx_shutdown_chip(chip, false);
902+}
903+
898904 static void azx_add_card_list(struct azx *chip)
899905 {
900906 struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
@@ -2357,7 +2363,7 @@ static void azx_shutdown(struct pci_dev *pci) · 1456 unmodified lines
23572363 return;
23582364 chip = card->private_data;
23592365 if (chip && chip->running)
2360− azx_shutdown_chip(chip);
2366+ __azx_shutdown_chip(chip, true);
23612367 }
23622368
23632369 /* PCI IDs */
sound/pci/hda/patch_cs8409.c+3−0
@@ -1207,6 +1207,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac · 1206 unmodified lines
12071207 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true,
12081208 SND_JACK_HEADPHONE, NULL);
12091209
1210+ snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true,
1211+ SND_JACK_MICROPHONE, NULL);
1212+
12101213 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID);
12111214 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID);
12121215 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID);
sound/pci/hda/patch_realtek.c+129−0
@@ -6429,6 +6429,20 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, · 6428 unmodified lines
64296429 hda_fixup_thinkpad_acpi(codec, fix, action);
64306430 }
64316431
6432+/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
6433+static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6434+ const struct hda_fixup *fix,
6435+ int action)
6436+{
6437+ struct alc_spec *spec = codec->spec;
6438+
6439+ switch (action) {
6440+ case HDA_FIXUP_ACT_PRE_PROBE:
6441+ spec->gen.suppress_auto_mute = 1;
6442+ break;
6443+ }
6444+}
6445+
64326446 /* for alc295_fixup_hp_top_speakers */
64336447 #include "hp_x360_helper.c"
64346448
@@ -6646,6 +6660,10 @@ enum { · 211 unmodified lines
66466660 ALC623_FIXUP_LENOVO_THINKSTATION_P340,
66476661 ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
66486662 ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
6663+ ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
6664+ ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
6665+ ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
6666+ ALC287_FIXUP_13S_GEN2_SPEAKERS
66496667 };
66506668
66516669 static const struct hda_fixup alc269_fixups[] = {
@@ -8236,6 +8254,113 @@ static const struct hda_fixup alc269_fixups[] = { · 1584 unmodified lines
82368254 .chained = true,
82378255 .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
82388256 },
8257+ [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
8258+ .type = HDA_FIXUP_VERBS,
8259+ //.v.verbs = legion_15imhg05_coefs,
8260+ .v.verbs = (const struct hda_verb[]) {
8261+ // set left speaker Legion 7i.
8262+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8263+ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8264+
8265+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8266+ { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8267+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8268+ { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8269+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8270+
8271+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8272+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8273+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8274+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8275+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8276+
8277+ // set right speaker Legion 7i.
8278+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8279+ { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8280+
8281+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8282+ { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8283+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8284+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8285+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8286+
8287+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8288+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8289+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8290+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8291+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8292+ {}
8293+ },
8294+ .chained = true,
8295+ .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
8296+ },
8297+ [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
8298+ .type = HDA_FIXUP_FUNC,
8299+ .v.func = alc287_fixup_legion_15imhg05_speakers,
8300+ .chained = true,
8301+ .chain_id = ALC269_FIXUP_HEADSET_MODE,
8302+ },
8303+ [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
8304+ .type = HDA_FIXUP_VERBS,
8305+ .v.verbs = (const struct hda_verb[]) {
8306+ // set left speaker Yoga 7i.
8307+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8308+ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8309+
8310+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8311+ { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8312+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8313+ { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8314+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8315+
8316+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8317+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8318+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8319+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8320+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8321+
8322+ // set right speaker Yoga 7i.
8323+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8324+ { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
8325+
8326+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8327+ { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8328+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8329+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8330+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8331+
8332+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8333+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8334+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8335+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8336+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8337+ {}
8338+ },
8339+ .chained = true,
8340+ .chain_id = ALC269_FIXUP_HEADSET_MODE,
8341+ },
8342+ [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
8343+ .type = HDA_FIXUP_VERBS,
8344+ .v.verbs = (const struct hda_verb[]) {
8345+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8346+ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8347+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8348+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8349+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8350+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8351+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8352+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8353+ { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8354+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8355+ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8356+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8357+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8358+ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8359+ {}
8360+ },
8361+ .chained = true,
8362+ .chain_id = ALC269_FIXUP_HEADSET_MODE,
8363+ },
82398364 };
82408365
82418366 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -8630,6 +8755,10 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 388 unmodified lines
86308755 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
86318756 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
86328757 SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
8758+ SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
8759+ SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
8760+ SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
8761+ SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
86338762 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
86348763 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
86358764 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
sound/pci/pcxhr/pcxhr_core.c+1−1
@@ -52,7 +52,7 @@ · 51 unmodified lines
5252 #define PCXHR_DSP 2
5353
5454 #if (PCXHR_DSP_OFFSET_MAX > PCXHR_PLX_OFFSET_MIN)
55−#undef PCXHR_REG_TO_PORT(x)
55+#error PCXHR_REG_TO_PORT(x)
5656 #else
5757 #define PCXHR_REG_TO_PORT(x) ((x)>PCXHR_DSP_OFFSET_MAX ? PCXHR_PLX : PCXHR_DSP)
5858 #endif
sound/soc/fsl/fsl_esai.c+10−6
@@ -1073,6 +1073,16 @@ static int fsl_esai_probe(struct platform_device *pdev) · 1072 unmodified lines
10731073 if (ret < 0)
10741074 goto err_pm_get_sync;
10751075
1076+ /*
1077+ * Register platform component before registering cpu dai for there
1078+ * is not defer probe for platform component in snd_soc_add_pcm_runtime().
1079+ */
1080+ ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE);
1081+ if (ret) {
1082+ dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret);
1083+ goto err_pm_get_sync;
1084+ }
1085+
10761086 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component,
10771087 &fsl_esai_dai, 1);
10781088 if (ret) {
@@ -1082,12 +1092,6 @@ static int fsl_esai_probe(struct platform_device *pdev) · 3 unmodified lines
10821092
10831093 INIT_WORK(&esai_priv->work, fsl_esai_hw_reset);
10841094
1085− ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE);
1086− if (ret) {
1087− dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret);
1088− goto err_pm_get_sync;
1089− }
1090−
10911095 return ret;
10921096
10931097 err_pm_get_sync:
sound/soc/fsl/fsl_micfil.c+10−5
@@ -737,18 +737,23 @@ static int fsl_micfil_probe(struct platform_device *pdev) · 736 unmodified lines
737737 pm_runtime_enable(&pdev->dev);
738738 regcache_cache_only(micfil->regmap, true);
739739
740+ /*
741+ * Register platform component before registering cpu dai for there
742+ * is not defer probe for platform component in snd_soc_add_pcm_runtime().
743+ */
744+ ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
745+ if (ret) {
746+ dev_err(&pdev->dev, "failed to pcm register\n");
747+ return ret;
748+ }
749+
740750 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_micfil_component,
741751 &fsl_micfil_dai, 1);
742752 if (ret) {
743753 dev_err(&pdev->dev, "failed to register component %s\n",
744754 fsl_micfil_component.name);
745− return ret;
746755 }
747756
748− ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
749− if (ret)
750− dev_err(&pdev->dev, "failed to pcm register\n");
751−
752757 return ret;
753758 }
754759
sound/soc/fsl/fsl_sai.c+9−5
@@ -1152,11 +1152,10 @@ static int fsl_sai_probe(struct platform_device *pdev) · 1151 unmodified lines
11521152 if (ret < 0)
11531153 goto err_pm_get_sync;
11541154
1155− ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
1156− &sai->cpu_dai_drv, 1);
1157− if (ret)
1158− goto err_pm_get_sync;
1159−
1155+ /*
1156+ * Register platform component before registering cpu dai for there
1157+ * is not defer probe for platform component in snd_soc_add_pcm_runtime().
1158+ */
11601159 if (sai->soc_data->use_imx_pcm) {
11611160 ret = imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE);
11621161 if (ret)
@@ -1167,6 +1166,11 @@ static int fsl_sai_probe(struct platform_device *pdev) · 4 unmodified lines
11671166 goto err_pm_get_sync;
11681167 }
11691168
1169+ ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
1170+ &sai->cpu_dai_drv, 1);
1171+ if (ret)
1172+ goto err_pm_get_sync;
1173+
11701174 return ret;
11711175
11721176 err_pm_get_sync:
sound/soc/fsl/fsl_spdif.c+9−5
@@ -1434,16 +1434,20 @@ static int fsl_spdif_probe(struct platform_device *pdev) · 1433 unmodified lines
14341434 pm_runtime_enable(&pdev->dev);
14351435 regcache_cache_only(spdif_priv->regmap, true);
14361436
1437− ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
1438− &spdif_priv->cpu_dai_drv, 1);
1437+ /*
1438+ * Register platform component before registering cpu dai for there
1439+ * is not defer probe for platform component in snd_soc_add_pcm_runtime().
1440+ */
1441+ ret = imx_pcm_dma_init(pdev, IMX_SPDIF_DMABUF_SIZE);
14391442 if (ret) {
1440− dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
1443+ dev_err_probe(&pdev->dev, ret, "imx_pcm_dma_init failed\n");
14411444 goto err_pm_disable;
14421445 }
14431446
1444− ret = imx_pcm_dma_init(pdev, IMX_SPDIF_DMABUF_SIZE);
1447+ ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
1448+ &spdif_priv->cpu_dai_drv, 1);
14451449 if (ret) {
1446− dev_err_probe(&pdev->dev, ret, "imx_pcm_dma_init failed\n");
1450+ dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
14471451 goto err_pm_disable;
14481452 }
14491453
sound/soc/fsl/fsl_xcvr.c+10−5
@@ -1215,18 +1215,23 @@ static int fsl_xcvr_probe(struct platform_device *pdev) · 1214 unmodified lines
12151215 pm_runtime_enable(dev);
12161216 regcache_cache_only(xcvr->regmap, true);
12171217
1218+ /*
1219+ * Register platform component before registering cpu dai for there
1220+ * is not defer probe for platform component in snd_soc_add_pcm_runtime().
1221+ */
1222+ ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0);
1223+ if (ret) {
1224+ dev_err(dev, "failed to pcm register\n");
1225+ return ret;
1226+ }
1227+
12181228 ret = devm_snd_soc_register_component(dev, &fsl_xcvr_comp,
12191229 &fsl_xcvr_dai, 1);
12201230 if (ret) {
12211231 dev_err(dev, "failed to register component %s\n",
12221232 fsl_xcvr_comp.name);
1223− return ret;
12241233 }
12251234
1226− ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0);
1227− if (ret)
1228− dev_err(dev, "failed to pcm register\n");
1229−
12301235 return ret;
12311236 }
12321237
sound/soc/intel/boards/sof_sdw.c+5−0
@@ -929,6 +929,11 @@ static int create_sdw_dailink(struct snd_soc_card *card, · 928 unmodified lines
929929 cpus + *cpu_id, cpu_dai_num,
930930 codecs, codec_num,
931931 NULL, &sdw_ops);
932+ /*
933+ * SoundWire DAILINKs use 'stream' functions and Bank Switch operations
934+ * based on wait_for_completion(), tag them as 'nonatomic'.
935+ */
936+ dai_links[*be_index].nonatomic = true;
932937
933938 ret = set_codec_init_func(card, link, dai_links + (*be_index)++,
934939 playback, group_id);
sound/soc/mediatek/Kconfig+3−0
@@ -1,6 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0-only
22 config SND_SOC_MEDIATEK
33 tristate
4+ select REGMAP_MMIO
45
56 config SND_SOC_MT2701
67 tristate "ASoC support for Mediatek MT2701 chip"
@@ -188,7 +189,9 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682 · 181 unmodified lines
188189 config SND_SOC_MT8195
189190 tristate "ASoC support for Mediatek MT8195 chip"
190191 depends on ARCH_MEDIATEK || COMPILE_TEST
192+ depends on COMMON_CLK
191193 select SND_SOC_MEDIATEK
194+ select MFD_SYSCON if SND_SOC_MT6359
192195 help
193196 This adds ASoC platform driver support for Mediatek MT8195 chip
194197 that can be used with other codecs.
sound/soc/mediatek/common/mtk-afe-fe-dai.c+11−8
@@ -334,9 +334,11 @@ int mtk_afe_suspend(struct snd_soc_component *component) · 333 unmodified lines
334334 devm_kcalloc(dev, afe->reg_back_up_list_num,
335335 sizeof(unsigned int), GFP_KERNEL);
336336
337− for (i = 0; i < afe->reg_back_up_list_num; i++)
338− regmap_read(regmap, afe->reg_back_up_list[i],
339− &afe->reg_back_up[i]);
337+ if (afe->reg_back_up) {
338+ for (i = 0; i < afe->reg_back_up_list_num; i++)
339+ regmap_read(regmap, afe->reg_back_up_list[i],
340+ &afe->reg_back_up[i]);
341+ }
340342
341343 afe->suspended = true;
342344 afe->runtime_suspend(dev);
@@ -356,12 +358,13 @@ int mtk_afe_resume(struct snd_soc_component *component) · 13 unmodified lines
356358
357359 afe->runtime_resume(dev);
358360
359− if (!afe->reg_back_up)
361+ if (!afe->reg_back_up) {
360362 dev_dbg(dev, "%s no reg_backup\n", __func__);
361−
362− for (i = 0; i < afe->reg_back_up_list_num; i++)
363− mtk_regmap_write(regmap, afe->reg_back_up_list[i],
364− afe->reg_back_up[i]);
363+ } else {
364+ for (i = 0; i < afe->reg_back_up_list_num; i++)
365+ mtk_regmap_write(regmap, afe->reg_back_up_list[i],
366+ afe->reg_back_up[i]);
367+ }
365368
366369 afe->suspended = false;
367370 return 0;
sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c+3−4
@@ -424,8 +424,8 @@ static int mt8195_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) · 423 unmodified lines
424424 return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL);
425425 }
426426
427−static int mt8195_hdmitx_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
428− struct snd_pcm_hw_params *params)
427+static int mt8195_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
428+ struct snd_pcm_hw_params *params)
429429
430430 {
431431 /* fix BE i2s format to 32bit, clean param mask first */
@@ -902,7 +902,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = { · 470 unmodified lines
902902 .no_pcm = 1,
903903 .dpcm_playback = 1,
904904 .ops = &mt8195_dptx_ops,
905− .be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup,
905+ .be_hw_params_fixup = mt8195_dptx_hw_params_fixup,
906906 SND_SOC_DAILINK_REG(DPTX_BE),
907907 },
908908 [DAI_LINK_ETDM1_IN_BE] = {
@@ -953,7 +953,6 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = { · 44 unmodified lines
953953 SND_SOC_DAIFMT_NB_NF |
954954 SND_SOC_DAIFMT_CBS_CFS,
955955 .dpcm_playback = 1,
956− .be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup,
957956 SND_SOC_DAILINK_REG(ETDM3_OUT_BE),
958957 },
959958 [DAI_LINK_PCM1_BE] = {
sound/soc/sof/core.c+1−3
@@ -371,7 +371,6 @@ int snd_sof_device_remove(struct device *dev) · 370 unmodified lines
371371 dev_warn(dev, "error: %d failed to prepare DSP for device removal",
372372 ret);
373373
374− snd_sof_fw_unload(sdev);
375374 snd_sof_ipc_free(sdev);
376375 snd_sof_free_debug(sdev);
377376 snd_sof_free_trace(sdev);
@@ -394,8 +393,7 @@ int snd_sof_device_remove(struct device *dev) · 16 unmodified lines
394393 snd_sof_remove(sdev);
395394
396395 /* release firmware */
397− release_firmware(pdata->fw);
398− pdata->fw = NULL;
396+ snd_sof_fw_unload(sdev);
399397
400398 return 0;
401399 }
sound/soc/sof/imx/imx8.c+8−1
@@ -365,7 +365,14 @@ static int imx8_remove(struct snd_sof_dev *sdev) · 364 unmodified lines
365365 /* on i.MX8 there is 1 to 1 match between type and BAR idx */
366366 static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type)
367367 {
368− return type;
368+ /* Only IRAM and SRAM bars are valid */
369+ switch (type) {
370+ case SOF_FW_BLK_TYPE_IRAM:
371+ case SOF_FW_BLK_TYPE_SRAM:
372+ return type;
373+ default:
374+ return -EINVAL;
375+ }
369376 }
370377
371378 static void imx8_ipc_msg_data(struct snd_sof_dev *sdev,
sound/soc/sof/imx/imx8m.c+8−1
@@ -228,7 +228,14 @@ static int imx8m_remove(struct snd_sof_dev *sdev) · 227 unmodified lines
228228 /* on i.MX8 there is 1 to 1 match between type and BAR idx */
229229 static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type)
230230 {
231− return type;
231+ /* Only IRAM and SRAM bars are valid */
232+ switch (type) {
233+ case SOF_FW_BLK_TYPE_IRAM:
234+ case SOF_FW_BLK_TYPE_SRAM:
235+ return type;
236+ default:
237+ return -EINVAL;
238+ }
232239 }
233240
234241 static void imx8m_ipc_msg_data(struct snd_sof_dev *sdev,
sound/soc/sof/loader.c+5−3
@@ -729,10 +729,10 @@ int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev) · 728 unmodified lines
729729 ret = request_firmware(&plat_data->fw, fw_filename, sdev->dev);
730730
731731 if (ret < 0) {
732− dev_err(sdev->dev, "error: request firmware %s failed err: %d\n",
733− fw_filename, ret);
734732 dev_err(sdev->dev,
735− "you may need to download the firmware from https://github.com/thesofproject/sof-bin/\n");
733+ "error: sof firmware file is missing, you might need to\n");
734+ dev_err(sdev->dev,
735+ " download it from https://github.com/thesofproject/sof-bin/\n");
736736 goto err;
737737 } else {
738738 dev_dbg(sdev->dev, "request_firmware %s successful\n",
@@ -880,5 +880,7 @@ EXPORT_SYMBOL(snd_sof_run_firmware); · 141 unmodified lines
880880 void snd_sof_fw_unload(struct snd_sof_dev *sdev)
881881 {
882882 /* TODO: support module unloading at runtime */
883+ release_firmware(sdev->pdata->fw);
884+ sdev->pdata->fw = NULL;
883885 }
884886 EXPORT_SYMBOL(snd_sof_fw_unload);
sound/soc/sof/trace.c+0−1
@@ -530,7 +530,6 @@ void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev) · 529 unmodified lines
530530 return;
531531
532532 if (sdev->dtrace_is_enabled) {
533− dev_err(sdev->dev, "error: waking up any trace sleepers\n");
534533 sdev->dtrace_error = true;
535534 wake_up(&sdev->trace_sleep);
536535 }
sound/soc/sof/xtensa/core.c+2−2
@@ -122,9 +122,9 @@ static void xtensa_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack, · 121 unmodified lines
122122 * 0x0049fbb0: 8000f2d0 0049fc00 6f6c6c61 00632e63
123123 */
124124 for (i = 0; i < stack_words; i += 4) {
125− hex_dump_to_buffer(stack + i * 4, 16, 16, 4,
125+ hex_dump_to_buffer(stack + i, 16, 16, 4,
126126 buf, sizeof(buf), false);
127− dev_err(sdev->dev, "0x%08x: %s\n", stack_ptr + i, buf);
127+ dev_err(sdev->dev, "0x%08x: %s\n", stack_ptr + i * 4, buf);
128128 }
129129 }
130130
sound/usb/card.c+4−14
@@ -1054,7 +1054,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) · 1053 unmodified lines
10541054 return 0;
10551055 }
10561056
1057−static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
1057+static int usb_audio_resume(struct usb_interface *intf)
10581058 {
10591059 struct snd_usb_audio *chip = usb_get_intfdata(intf);
10601060 struct snd_usb_stream *as;
@@ -1080,7 +1080,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) · 19 unmodified lines
10801080 * we just notify and restart the mixers
10811081 */
10821082 list_for_each_entry(mixer, &chip->mixer_list, list) {
1083− err = snd_usb_mixer_resume(mixer, reset_resume);
1083+ err = snd_usb_mixer_resume(mixer);
10841084 if (err < 0)
10851085 goto err_out;
10861086 }
@@ -1100,20 +1100,10 @@ err_out: · 13 unmodified lines
11001100 atomic_dec(&chip->active); /* allow autopm after this point */
11011101 return err;
11021102 }
1103−
1104−static int usb_audio_resume(struct usb_interface *intf)
1105−{
1106− return __usb_audio_resume(intf, false);
1107−}
1108−
1109−static int usb_audio_reset_resume(struct usb_interface *intf)
1110−{
1111− return __usb_audio_resume(intf, true);
1112−}
11131103 #else
11141104 #define usb_audio_suspend NULL
11151105 #define usb_audio_resume NULL
1116−#define usb_audio_reset_resume NULL
1106+#define usb_audio_resume NULL
11171107 #endif /* CONFIG_PM */
11181108
11191109 static const struct usb_device_id usb_audio_ids [] = {
@@ -1135,7 +1125,7 @@ static struct usb_driver usb_audio_driver = { · 15 unmodified lines
11351125 .disconnect = usb_audio_disconnect,
11361126 .suspend = usb_audio_suspend,
11371127 .resume = usb_audio_resume,
1138− .reset_resume = usb_audio_reset_resume,
1128+ .reset_resume = usb_audio_resume,
11391129 .id_table = usb_audio_ids,
11401130 .supports_autosuspend = 1,
11411131 };
sound/usb/mixer.c+4−22
@@ -3653,33 +3653,16 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list) · 3652 unmodified lines
36533653 return 0;
36543654 }
36553655
3656−static int default_mixer_reset_resume(struct usb_mixer_elem_list *list)
3657−{
3658− int err;
3659−
3660− if (list->resume) {
3661− err = list->resume(list);
3662− if (err < 0)
3663− return err;
3664− }
3665− return restore_mixer_value(list);
3666−}
3667−
3668−int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume)
3656+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer)
36693657 {
36703658 struct usb_mixer_elem_list *list;
3671− usb_mixer_elem_resume_func_t f;
36723659 int id, err;
36733660
36743661 /* restore cached mixer values */
36753662 for (id = 0; id < MAX_ID_ELEMS; id++) {
36763663 for_each_mixer_elem(list, mixer, id) {
3677− if (reset_resume)
3678− f = list->reset_resume;
3679− else
3680− f = list->resume;
3681− if (f) {
3682− err = f(list);
3664+ if (list->resume) {
3665+ err = list->resume(list);
36833666 if (err < 0)
36843667 return err;
36853668 }
@@ -3700,7 +3683,6 @@ void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, · 14 unmodified lines
37003683 list->id = unitid;
37013684 list->dump = snd_usb_mixer_dump_cval;
37023685 #ifdef CONFIG_PM
3703− list->resume = NULL;
3704− list->reset_resume = default_mixer_reset_resume;
3686+ list->resume = restore_mixer_value;
37053687 #endif
37063688 }
sound/usb/mixer.h+1−2
@@ -70,7 +70,6 @@ struct usb_mixer_elem_list { · 69 unmodified lines
7070 bool is_std_info;
7171 usb_mixer_elem_dump_func_t dump;
7272 usb_mixer_elem_resume_func_t resume;
73− usb_mixer_elem_resume_func_t reset_resume;
7473 };
7574
7675 /* iterate over mixer element list of the given unit id */
@@ -121,7 +120,7 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, · 44 unmodified lines
121120
122121 #ifdef CONFIG_PM
123122 int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
124−int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume);
123+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer);
125124 #endif
126125
127126 int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
sound/usb/mixer_quirks.c+1−1
@@ -151,7 +151,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, · 150 unmodified lines
151151 *listp = list;
152152 list->mixer = mixer;
153153 list->id = id;
154− list->reset_resume = resume;
154+ list->resume = resume;
155155 kctl = snd_ctl_new1(knew, list);
156156 if (!kctl) {
157157 kfree(list);
tools/lib/bpf/linker.c+7−1
@@ -1649,11 +1649,17 @@ static bool btf_is_non_static(const struct btf_type *t) · 1648 unmodified lines
16491649 static int find_glob_sym_btf(struct src_obj *obj, Elf64_Sym *sym, const char *sym_name,
16501650 int *out_btf_sec_id, int *out_btf_id)
16511651 {
1652− int i, j, n = btf__get_nr_types(obj->btf), m, btf_id = 0;
1652+ int i, j, n, m, btf_id = 0;
16531653 const struct btf_type *t;
16541654 const struct btf_var_secinfo *vi;
16551655 const char *name;
16561656
1657+ if (!obj->btf) {
1658+ pr_warn("failed to find BTF info for object '%s'\n", obj->filename);
1659+ return -EINVAL;
1660+ }
1661+
1662+ n = btf__get_nr_types(obj->btf);
16571663 for (i = 1; i <= n; i++) {
16581664 t = btf__type_by_id(obj->btf, i);
16591665
tools/objtool/special.c+30−8
@@ -58,6 +58,24 @@ void __weak arch_handle_alternative(unsigned short feature, struct special_alt * · 57 unmodified lines
5858 {
5959 }
6060
61+static bool reloc2sec_off(struct reloc *reloc, struct section **sec, unsigned long *off)
62+{
63+ switch (reloc->sym->type) {
64+ case STT_FUNC:
65+ *sec = reloc->sym->sec;
66+ *off = reloc->sym->offset + reloc->addend;
67+ return true;
68+
69+ case STT_SECTION:
70+ *sec = reloc->sym->sec;
71+ *off = reloc->addend;
72+ return true;
73+
74+ default:
75+ return false;
76+ }
77+}
78+
6179 static int get_alt_entry(struct elf *elf, struct special_entry *entry,
6280 struct section *sec, int idx,
6381 struct special_alt *alt)
@@ -91,15 +109,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, · 27 unmodified lines
91109 WARN_FUNC("can't find orig reloc", sec, offset + entry->orig);
92110 return -1;
93111 }
94− if (orig_reloc->sym->type != STT_SECTION) {
95− WARN_FUNC("don't know how to handle non-section reloc symbol %s",
96− sec, offset + entry->orig, orig_reloc->sym->name);
112+ if (!reloc2sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off)) {
113+ WARN_FUNC("don't know how to handle reloc symbol type %d: %s",
114+ sec, offset + entry->orig,
115+ orig_reloc->sym->type,
116+ orig_reloc->sym->name);
97117 return -1;
98118 }
99119
100− alt->orig_sec = orig_reloc->sym->sec;
101− alt->orig_off = orig_reloc->addend;
102−
103120 if (!entry->group || alt->new_len) {
104121 new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new);
105122 if (!new_reloc) {
@@ -116,8 +133,13 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, · 10 unmodified lines
116133 if (arch_is_retpoline(new_reloc->sym))
117134 return 1;
118135
119− alt->new_sec = new_reloc->sym->sec;
120− alt->new_off = (unsigned int)new_reloc->addend;
136+ if (!reloc2sec_off(new_reloc, &alt->new_sec, &alt->new_off)) {
137+ WARN_FUNC("don't know how to handle reloc symbol type %d: %s",
138+ sec, offset + entry->new,
139+ new_reloc->sym->type,
140+ new_reloc->sym->name);
141+ return -1;
142+ }
121143
122144 /* _ASM_EXTABLE_EX hack */
123145 if (alt->new_off >= 0x7ffffff0)
tools/perf/Documentation/jitdump-specification.txt+1−1
@@ -164,7 +164,7 @@ const char unwinding_data[n]: an array of unwinding data, consisting of the EH F · 163 unmodified lines
164164 The EH Frame header follows the Linux Standard Base (LSB) specification as described in the document at https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html
165165
166166
167−The EH Frame follows the LSB specicfication as described in the document at https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html
167+The EH Frame follows the LSB specification as described in the document at https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html
168168
169169
170170 NOTE: The mapped_size is generally either the same as unwind_data_size (if the unwinding data was mapped in memory by the running process) or zero (if the unwinding data is not mapped by the process). If the unwinding data was not mapped, then only the EH Frame Header will be read, which can be used to specify FP based unwinding for a function which does not have unwinding information.
tools/perf/Documentation/perf-c2c.txt+1−1
@@ -261,7 +261,7 @@ COALESCE · 260 unmodified lines
261261 User can specify how to sort offsets for cacheline.
262262
263263 Following fields are available and governs the final
264−output fields set for caheline offsets output:
264+output fields set for cacheline offsets output:
265265
266266 tid - coalesced by process TIDs
267267 pid - coalesced by process PIDs
tools/perf/Documentation/perf-intel-pt.txt+1−1
@@ -883,7 +883,7 @@ and "r" can be combined to get calls and returns. · 882 unmodified lines
883883
884884 "Transactions" events correspond to the start or end of transactions. The
885885 'flags' field can be used in perf script to determine whether the event is a
886−tranasaction start, commit or abort.
886+transaction start, commit or abort.
887887
888888 Note that "instructions", "branches" and "transactions" events depend on code
889889 flow packets which can be disabled by using the config term "branch=0". Refer
tools/perf/Documentation/perf-lock.txt+1−1
@@ -44,7 +44,7 @@ COMMON OPTIONS · 43 unmodified lines
4444
4545 -f::
4646 --force::
47− Don't complan, do it.
47+ Don't complain, do it.
4848
4949 REPORT OPTIONS
5050 --------------
tools/perf/Documentation/perf-script-perl.txt+1−1
@@ -54,7 +54,7 @@ all sched_wakeup events in the system: · 53 unmodified lines
5454 Traces meant to be processed using a script should be recorded with
5555 the above option: -a to enable system-wide collection.
5656
57−The format file for the sched_wakep event defines the following fields
57+The format file for the sched_wakeup event defines the following fields
5858 (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
5959
6060 ----
tools/perf/Documentation/perf-script-python.txt+1−1
@@ -448,7 +448,7 @@ all sched_wakeup events in the system: · 447 unmodified lines
448448 Traces meant to be processed using a script should be recorded with
449449 the above option: -a to enable system-wide collection.
450450
451−The format file for the sched_wakep event defines the following fields
451+The format file for the sched_wakeup event defines the following fields
452452 (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
453453
454454 ----
tools/perf/Documentation/perf-stat.txt+1−1
@@ -385,7 +385,7 @@ Aggregate counts per physical processor for system-wide mode measurements. · 384 unmodified lines
385385 Print metrics or metricgroups specified in a comma separated list.
386386 For a group all metrics from the group are added.
387387 The events from the metrics are automatically measured.
388−See perf list output for the possble metrics and metricgroups.
388+See perf list output for the possible metrics and metricgroups.
389389
390390 -A::
391391 --no-aggr::
tools/perf/Documentation/topdown.txt+1−1
@@ -2,7 +2,7 @@ Using TopDown metrics in user space · 1 unmodified line
22 -----------------------------------
33
44 Intel CPUs (since Sandy Bridge and Silvermont) support a TopDown
5−methology to break down CPU pipeline execution into 4 bottlenecks:
5+methodology to break down CPU pipeline execution into 4 bottlenecks:
66 frontend bound, backend bound, bad speculation, retiring.
77
88 For more details on Topdown see [1][5]
tools/perf/arch/arm/util/auxtrace.c+4−4
@@ -8,10 +8,10 @@ · 7 unmodified lines
88 #include <linux/coresight-pmu.h>
99 #include <linux/zalloc.h>
1010
11−#include "../../util/auxtrace.h"
12−#include "../../util/debug.h"
13−#include "../../util/evlist.h"
14−#include "../../util/pmu.h"
11+#include "../../../util/auxtrace.h"
12+#include "../../../util/debug.h"
13+#include "../../../util/evlist.h"
14+#include "../../../util/pmu.h"
1515 #include "cs-etm.h"
1616 #include "arm-spe.h"
1717
tools/perf/arch/arm/util/cs-etm.c+12−12
@@ -16,19 +16,19 @@ · 15 unmodified lines
1616 #include <linux/zalloc.h>
1717
1818 #include "cs-etm.h"
19−#include "../../util/debug.h"
20−#include "../../util/record.h"
21−#include "../../util/auxtrace.h"
22−#include "../../util/cpumap.h"
23−#include "../../util/event.h"
24−#include "../../util/evlist.h"
25−#include "../../util/evsel.h"
26−#include "../../util/perf_api_probe.h"
27−#include "../../util/evsel_config.h"
28−#include "../../util/pmu.h"
29−#include "../../util/cs-etm.h"
19+#include "../../../util/debug.h"
20+#include "../../../util/record.h"
21+#include "../../../util/auxtrace.h"
22+#include "../../../util/cpumap.h"
23+#include "../../../util/event.h"
24+#include "../../../util/evlist.h"
25+#include "../../../util/evsel.h"
26+#include "../../../util/perf_api_probe.h"
27+#include "../../../util/evsel_config.h"
28+#include "../../../util/pmu.h"
29+#include "../../../util/cs-etm.h"
3030 #include <internal/lib.h> // page_size
31−#include "../../util/session.h"
31+#include "../../../util/session.h"
3232
3333 #include <errno.h>
3434 #include <stdlib.h>
tools/perf/arch/arm/util/perf_regs.c+1−1
@@ -1,5 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2−#include "../../util/perf_regs.h"
2+#include "../../../util/perf_regs.h"
33
44 const struct sample_reg sample_reg_masks[] = {
55 SMPL_REG_END
tools/perf/arch/arm/util/pmu.c+1−1
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 #include <linux/string.h>
1111
1212 #include "arm-spe.h"
13−#include "../../util/pmu.h"
13+#include "../../../util/pmu.h"
1414
1515 struct perf_event_attr
1616 *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
tools/perf/arch/arm/util/unwind-libdw.c+3−3
@@ -1,8 +1,8 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <elfutils/libdwfl.h>
3−#include "../../util/unwind-libdw.h"
4−#include "../../util/perf_regs.h"
5−#include "../../util/event.h"
3+#include "../../../util/unwind-libdw.h"
4+#include "../../../util/perf_regs.h"
5+#include "../../../util/event.h"
66
77 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
88 {
tools/perf/arch/arm/util/unwind-libunwind.c+2−2
@@ -3,8 +3,8 @@ · 2 unmodified lines
33 #include <errno.h>
44 #include <libunwind.h>
55 #include "perf_regs.h"
6−#include "../../util/unwind.h"
7−#include "../../util/debug.h"
6+#include "../../../util/unwind.h"
7+#include "../../../util/debug.h"
88
99 int libunwind__arch_reg_id(int regnum)
1010 {
tools/perf/arch/x86/util/iostat.c+1−1
@@ -432,7 +432,7 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel, · 431 unmodified lines
432432 u8 die = ((struct iio_root_port *)evsel->priv)->die;
433433 struct perf_counts_values *count = perf_counts(evsel->counts, die, 0);
434434
435− if (count->run && count->ena) {
435+ if (count && count->run && count->ena) {
436436 if (evsel->prev_raw_counts && !out->force_header) {
437437 struct perf_counts_values *prev_count =
438438 perf_counts(evsel->prev_raw_counts, die, 0);
tools/perf/builtin-stat.c+2−0
@@ -2408,6 +2408,8 @@ int cmd_stat(int argc, const char **argv) · 2407 unmodified lines
24082408 goto out;
24092409 } else if (verbose)
24102410 iostat_list(evsel_list, &stat_config);
2411+ if (iostat_mode == IOSTAT_RUN && !target__has_cpu(&target))
2412+ target.system_wide = true;
24112413 }
24122414
24132415 if (add_default_attributes())
tools/perf/pmu-events/arch/powerpc/power8/other.json+1−1
@@ -1046,7 +1046,7 @@ · 1045 unmodified lines
10461046 {
10471047 "EventCode": "0x4e010",
10481048 "EventName": "PM_GCT_NOSLOT_IC_L3MISS",
1049− "BriefDescription": "Gct empty for this thread due to icach l3 miss",
1049+ "BriefDescription": "Gct empty for this thread due to icache l3 miss",
10501050 "PublicDescription": ""
10511051 },
10521052 {
tools/perf/tests/code-reading.c+2−2
@@ -229,8 +229,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, · 228 unmodified lines
229229 struct thread *thread, struct state *state)
230230 {
231231 struct addr_location al;
232− unsigned char buf1[BUFSZ];
233− unsigned char buf2[BUFSZ];
232+ unsigned char buf1[BUFSZ] = {0};
233+ unsigned char buf2[BUFSZ] = {0};
234234 size_t ret_len;
235235 u64 objdump_addr;
236236 const char *objdump_name;
tools/perf/tests/dwarf-unwind.c+32−7
@@ -20,6 +20,23 @@ · 19 unmodified lines
2020 /* For bsearch. We try to unwind functions in shared object. */
2121 #include <stdlib.h>
2222
23+/*
24+ * The test will assert frames are on the stack but tail call optimizations lose
25+ * the frame of the caller. Clang can disable this optimization on a called
26+ * function but GCC currently (11/2020) lacks this attribute. The barrier is
27+ * used to inhibit tail calls in these cases.
28+ */
29+#ifdef __has_attribute
30+#if __has_attribute(disable_tail_calls)
31+#define NO_TAIL_CALL_ATTRIBUTE __attribute__((disable_tail_calls))
32+#define NO_TAIL_CALL_BARRIER
33+#endif
34+#endif
35+#ifndef NO_TAIL_CALL_ATTRIBUTE
36+#define NO_TAIL_CALL_ATTRIBUTE
37+#define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory");
38+#endif
39+
2340 static int mmap_handler(struct perf_tool *tool __maybe_unused,
2441 union perf_event *event,
2542 struct perf_sample *sample,
@@ -91,7 +108,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg) · 65 unmodified lines
91108 return strcmp((const char *) symbol, funcs[idx]);
92109 }
93110
94−noinline int test_dwarf_unwind__thread(struct thread *thread)
111+NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thread)
95112 {
96113 struct perf_sample sample;
97114 unsigned long cnt = 0;
@@ -122,7 +139,7 @@ noinline int test_dwarf_unwind__thread(struct thread *thread) · 24 unmodified lines
122139
123140 static int global_unwind_retval = -INT_MAX;
124141
125−noinline int test_dwarf_unwind__compare(void *p1, void *p2)
142+NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *p2)
126143 {
127144 /* Any possible value should be 'thread' */
128145 struct thread *thread = *(struct thread **)p1;
@@ -141,7 +158,7 @@ noinline int test_dwarf_unwind__compare(void *p1, void *p2) · 12 unmodified lines
141158 return p1 - p2;
142159 }
143160
144−noinline int test_dwarf_unwind__krava_3(struct thread *thread)
161+NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *thread)
145162 {
146163 struct thread *array[2] = {thread, thread};
147164 void *fp = &bsearch;
@@ -160,14 +177,22 @@ noinline int test_dwarf_unwind__krava_3(struct thread *thread) · 12 unmodified lines
160177 return global_unwind_retval;
161178 }
162179
163−noinline int test_dwarf_unwind__krava_2(struct thread *thread)
180+NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *thread)
164181 {
165− return test_dwarf_unwind__krava_3(thread);
182+ int ret;
183+
184+ ret = test_dwarf_unwind__krava_3(thread);
185+ NO_TAIL_CALL_BARRIER;
186+ return ret;
166187 }
167188
168−noinline int test_dwarf_unwind__krava_1(struct thread *thread)
189+NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *thread)
169190 {
170− return test_dwarf_unwind__krava_2(thread);
191+ int ret;
192+
193+ ret = test_dwarf_unwind__krava_2(thread);
194+ NO_TAIL_CALL_BARRIER;
195+ return ret;
171196 }
172197
173198 int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
tools/perf/util/config.c+1−1
@@ -801,7 +801,7 @@ int perf_config_set(struct perf_config_set *set, · 800 unmodified lines
801801 section->name, item->name);
802802 ret = fn(key, value, data);
803803 if (ret < 0) {
804− pr_err("Error: wrong config key-value pair %s=%s\n",
804+ pr_err("Error in the given config file: wrong config key-value pair %s=%s\n",
805805 key, value);
806806 /*
807807 * Can't be just a 'break', as perf_config_set__for_each_entry()
tools/testing/selftests/bpf/Makefile+2−1
@@ -375,7 +375,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o: \ · 374 unmodified lines
375375 $(TRUNNER_BPF_PROGS_DIR)/%.c \
376376 $(TRUNNER_BPF_PROGS_DIR)/*.h \
377377 $$(INCLUDE_DIR)/vmlinux.h \
378− $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
378+ $(wildcard $(BPFDIR)/bpf_*.h) \
379+ | $(TRUNNER_OUTPUT) $$(BPFOBJ)
379380 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
380381 $(TRUNNER_BPF_CFLAGS))
381382
tools/testing/selftests/bpf/test_lwt_ip_encap.sh+8−5
@@ -112,6 +112,14 @@ setup() · 111 unmodified lines
112112 ip netns add "${NS2}"
113113 ip netns add "${NS3}"
114114
115+ # rp_filter gets confused by what these tests are doing, so disable it
116+ ip netns exec ${NS1} sysctl -wq net.ipv4.conf.all.rp_filter=0
117+ ip netns exec ${NS2} sysctl -wq net.ipv4.conf.all.rp_filter=0
118+ ip netns exec ${NS3} sysctl -wq net.ipv4.conf.all.rp_filter=0
119+ ip netns exec ${NS1} sysctl -wq net.ipv4.conf.default.rp_filter=0
120+ ip netns exec ${NS2} sysctl -wq net.ipv4.conf.default.rp_filter=0
121+ ip netns exec ${NS3} sysctl -wq net.ipv4.conf.default.rp_filter=0
122+
115123 ip link add veth1 type veth peer name veth2
116124 ip link add veth3 type veth peer name veth4
117125 ip link add veth5 type veth peer name veth6
@@ -236,11 +244,6 @@ setup() · 118 unmodified lines
236244 ip -netns ${NS1} -6 route add ${IPv6_GRE}/128 dev veth5 via ${IPv6_6} ${VRF}
237245 ip -netns ${NS2} -6 route add ${IPv6_GRE}/128 dev veth7 via ${IPv6_8} ${VRF}
238246
239− # rp_filter gets confused by what these tests are doing, so disable it
240− ip netns exec ${NS1} sysctl -wq net.ipv4.conf.all.rp_filter=0
241− ip netns exec ${NS2} sysctl -wq net.ipv4.conf.all.rp_filter=0
242− ip netns exec ${NS3} sysctl -wq net.ipv4.conf.all.rp_filter=0
243−
244247 TMPFILE=$(mktemp /tmp/test_lwt_ip_encap.XXXXXX)
245248
246249 sleep 1 # reduce flakiness
tools/testing/selftests/kvm/.gitignore+1−0
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 /x86_64/smm_test
2525 /x86_64/state_test
2626 /x86_64/svm_vmcall_test
27+/x86_64/svm_int_ctl_test
2728 /x86_64/sync_regs_test
2829 /x86_64/tsc_msrs_test
2930 /x86_64/userspace_msr_exit_test
tools/testing/selftests/kvm/Makefile+1−0
@@ -56,6 +56,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/smm_test · 55 unmodified lines
5656 TEST_GEN_PROGS_x86_64 += x86_64/state_test
5757 TEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test
5858 TEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test
59+TEST_GEN_PROGS_x86_64 += x86_64/svm_int_ctl_test
5960 TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
6061 TEST_GEN_PROGS_x86_64 += x86_64/userspace_msr_exit_test
6162 TEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
tools/testing/selftests/kvm/access_tracking_perf_test.c+2−4
@@ -371,9 +371,7 @@ static void help(char *name) · 370 unmodified lines
371371 printf(" -v: specify the number of vCPUs to run.\n");
372372 printf(" -o: Overlap guest memory accesses instead of partitioning\n"
373373 " them into a separate region of memory for each vCPU.\n");
374− printf(" -s: specify the type of memory that should be used to\n"
375− " back the guest data region.\n\n");
376− backing_src_help();
374+ backing_src_help("-s");
377375 puts("");
378376 exit(0);
379377 }
@@ -381,7 +379,7 @@ static void help(char *name) · 1 unmodified line
381379 int main(int argc, char *argv[])
382380 {
383381 struct test_params params = {
384− .backing_src = VM_MEM_SRC_ANONYMOUS,
382+ .backing_src = DEFAULT_VM_MEM_SRC,
385383 .vcpu_memory_bytes = DEFAULT_PER_VCPU_MEM_SIZE,
386384 .vcpus = 1,
387385 };
tools/testing/selftests/kvm/demand_paging_test.c+7−8
@@ -179,7 +179,7 @@ static void *uffd_handler_thread_fn(void *arg) · 178 unmodified lines
179179 return NULL;
180180 }
181181
182− if (!pollfd[0].revents & POLLIN)
182+ if (!(pollfd[0].revents & POLLIN))
183183 continue;
184184
185185 r = read(uffd, &msg, sizeof(msg));
@@ -416,7 +416,7 @@ static void help(char *name) · 230 unmodified lines
416416 {
417417 puts("");
418418 printf("usage: %s [-h] [-m vm_mode] [-u uffd_mode] [-d uffd_delay_usec]\n"
419− " [-b memory] [-t type] [-v vcpus] [-o]\n", name);
419+ " [-b memory] [-s type] [-v vcpus] [-o]\n", name);
420420 guest_modes_help();
421421 printf(" -u: use userfaultfd to handle vCPU page faults. Mode is a\n"
422422 " UFFD registration mode: 'MISSING' or 'MINOR'.\n");
@@ -426,8 +426,7 @@ static void help(char *name) · 3 unmodified lines
426426 printf(" -b: specify the size of the memory region which should be\n"
427427 " demand paged by each vCPU. e.g. 10M or 3G.\n"
428428 " Default: 1G\n");
429− printf(" -t: The type of backing memory to use. Default: anonymous\n");
430− backing_src_help();
429+ backing_src_help("-s");
431430 printf(" -v: specify the number of vCPUs to run.\n");
432431 printf(" -o: Overlap guest memory accesses instead of partitioning\n"
433432 " them into a separate region of memory for each vCPU.\n");
@@ -439,14 +438,14 @@ int main(int argc, char *argv[]) · 5 unmodified lines
439438 {
440439 int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
441440 struct test_params p = {
442− .src_type = VM_MEM_SRC_ANONYMOUS,
441+ .src_type = DEFAULT_VM_MEM_SRC,
443442 .partition_vcpu_memory_access = true,
444443 };
445444 int opt;
446445
447446 guest_modes_append_default();
448447
449− while ((opt = getopt(argc, argv, "hm:u:d:b:t:v:o")) != -1) {
448+ while ((opt = getopt(argc, argv, "hm:u:d:b:s:v:o")) != -1) {
450449 switch (opt) {
451450 case 'm':
452451 guest_modes_cmdline(optarg);
@@ -465,7 +464,7 @@ int main(int argc, char *argv[]) · 12 unmodified lines
465464 case 'b':
466465 guest_percpu_mem_size = parse_size(optarg);
467466 break;
468− case 't':
467+ case 's':
469468 p.src_type = parse_backing_src_type(optarg);
470469 break;
471470 case 'v':
@@ -485,7 +484,7 @@ int main(int argc, char *argv[]) · 13 unmodified lines
485484
486485 if (p.uffd_mode == UFFDIO_REGISTER_MODE_MINOR &&
487486 !backing_src_is_shared(p.src_type)) {
488− TEST_FAIL("userfaultfd MINOR mode requires shared memory; pick a different -t");
487+ TEST_FAIL("userfaultfd MINOR mode requires shared memory; pick a different -s");
489488 }
490489
491490 for_each_guest_mode(run_test, &p);
tools/testing/selftests/kvm/dirty_log_perf_test.c+42−20
@@ -118,42 +118,64 @@ static inline void disable_dirty_logging(struct kvm_vm *vm, int slots) · 117 unmodified lines
118118 toggle_dirty_logging(vm, slots, false);
119119 }
120120
121−static void get_dirty_log(struct kvm_vm *vm, int slots, unsigned long *bitmap,
122− uint64_t nr_pages)
121+static void get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots)
123122 {
124− uint64_t slot_pages = nr_pages / slots;
125123 int i;
126124
127125 for (i = 0; i < slots; i++) {
128126 int slot = PERF_TEST_MEM_SLOT_INDEX + i;
129− unsigned long *slot_bitmap = bitmap + i * slot_pages;
130127
131− kvm_vm_get_dirty_log(vm, slot, slot_bitmap);
128+ kvm_vm_get_dirty_log(vm, slot, bitmaps[i]);
132129 }
133130 }
134131
135−static void clear_dirty_log(struct kvm_vm *vm, int slots, unsigned long *bitmap,
136− uint64_t nr_pages)
132+static void clear_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[],
133+ int slots, uint64_t pages_per_slot)
137134 {
138− uint64_t slot_pages = nr_pages / slots;
139135 int i;
140136
141137 for (i = 0; i < slots; i++) {
142138 int slot = PERF_TEST_MEM_SLOT_INDEX + i;
143− unsigned long *slot_bitmap = bitmap + i * slot_pages;
144139
145− kvm_vm_clear_dirty_log(vm, slot, slot_bitmap, 0, slot_pages);
140+ kvm_vm_clear_dirty_log(vm, slot, bitmaps[i], 0, pages_per_slot);
146141 }
147142 }
148143
144+static unsigned long **alloc_bitmaps(int slots, uint64_t pages_per_slot)
145+{
146+ unsigned long **bitmaps;
147+ int i;
148+
149+ bitmaps = malloc(slots * sizeof(bitmaps[0]));
150+ TEST_ASSERT(bitmaps, "Failed to allocate bitmaps array.");
151+
152+ for (i = 0; i < slots; i++) {
153+ bitmaps[i] = bitmap_zalloc(pages_per_slot);
154+ TEST_ASSERT(bitmaps[i], "Failed to allocate slot bitmap.");
155+ }
156+
157+ return bitmaps;
158+}
159+
160+static void free_bitmaps(unsigned long *bitmaps[], int slots)
161+{
162+ int i;
163+
164+ for (i = 0; i < slots; i++)
165+ free(bitmaps[i]);
166+
167+ free(bitmaps);
168+}
169+
149170 static void run_test(enum vm_guest_mode mode, void *arg)
150171 {
151172 struct test_params *p = arg;
152173 pthread_t *vcpu_threads;
153174 struct kvm_vm *vm;
154− unsigned long *bmap;
175+ unsigned long **bitmaps;
155176 uint64_t guest_num_pages;
156177 uint64_t host_num_pages;
178+ uint64_t pages_per_slot;
157179 int vcpu_id;
158180 struct timespec start;
159181 struct timespec ts_diff;
@@ -171,7 +193,9 @@ static void run_test(enum vm_guest_mode mode, void *arg) · 11 unmodified lines
171193 guest_num_pages = (nr_vcpus * guest_percpu_mem_size) >> vm_get_page_shift(vm);
172194 guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages);
173195 host_num_pages = vm_num_host_pages(mode, guest_num_pages);
174− bmap = bitmap_zalloc(host_num_pages);
196+ pages_per_slot = host_num_pages / p->slots;
197+
198+ bitmaps = alloc_bitmaps(p->slots, pages_per_slot);
175199
176200 if (dirty_log_manual_caps) {
177201 cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2;
@@ -239,7 +263,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) · 61 unmodified lines
239263 iteration, ts_diff.tv_sec, ts_diff.tv_nsec);
240264
241265 clock_gettime(CLOCK_MONOTONIC, &start);
242− get_dirty_log(vm, p->slots, bmap, host_num_pages);
266+ get_dirty_log(vm, bitmaps, p->slots);
243267 ts_diff = timespec_elapsed(start);
244268 get_dirty_log_total = timespec_add(get_dirty_log_total,
245269 ts_diff);
@@ -248,7 +272,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) · 2 unmodified lines
248272
249273 if (dirty_log_manual_caps) {
250274 clock_gettime(CLOCK_MONOTONIC, &start);
251− clear_dirty_log(vm, p->slots, bmap, host_num_pages);
275+ clear_dirty_log(vm, bitmaps, p->slots, pages_per_slot);
252276 ts_diff = timespec_elapsed(start);
253277 clear_dirty_log_total = timespec_add(clear_dirty_log_total,
254278 ts_diff);
@@ -281,7 +305,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) · 26 unmodified lines
281305 clear_dirty_log_total.tv_nsec, avg.tv_sec, avg.tv_nsec);
282306 }
283307
284− free(bmap);
308+ free_bitmaps(bitmaps, p->slots);
285309 free(vcpu_threads);
286310 perf_test_destroy_vm(vm);
287311 }
@@ -308,11 +332,9 @@ static void help(char *name) · 20 unmodified lines
308332 printf(" -v: specify the number of vCPUs to run.\n");
309333 printf(" -o: Overlap guest memory accesses instead of partitioning\n"
310334 " them into a separate region of memory for each vCPU.\n");
311− printf(" -s: specify the type of memory that should be used to\n"
312− " back the guest data region.\n\n");
335+ backing_src_help("-s");
313336 printf(" -x: Split the memory region into this number of memslots.\n"
314− " (default: 1)");
315− backing_src_help();
337+ " (default: 1)\n");
316338 puts("");
317339 exit(0);
318340 }
@@ -324,7 +346,7 @@ int main(int argc, char *argv[]) · 5 unmodified lines
324346 .iterations = TEST_HOST_LOOP_N,
325347 .wr_fract = 1,
326348 .partition_vcpu_memory_access = true,
327− .backing_src = VM_MEM_SRC_ANONYMOUS,
349+ .backing_src = DEFAULT_VM_MEM_SRC,
328350 .slots = 1,
329351 };
330352 int opt;
tools/testing/selftests/kvm/include/test_util.h+3−1
@@ -90,6 +90,8 @@ enum vm_mem_backing_src_type { · 89 unmodified lines
9090 NUM_SRC_TYPES,
9191 };
9292
93+#define DEFAULT_VM_MEM_SRC VM_MEM_SRC_ANONYMOUS
94+
9395 struct vm_mem_backing_src_alias {
9496 const char *name;
9597 uint32_t flag;
@@ -102,7 +104,7 @@ size_t get_trans_hugepagesz(void); · 6 unmodified lines
102104 size_t get_def_hugetlb_pagesz(void);
103105 const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i);
104106 size_t get_backing_src_pagesz(uint32_t i);
105−void backing_src_help(void);
107+void backing_src_help(const char *flag);
106108 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);
107109 long get_run_delay(void);
108110
tools/testing/selftests/kvm/include/x86_64/processor.h+17−17
@@ -312,37 +312,37 @@ static inline void set_xmm(int n, unsigned long val) · 311 unmodified lines
312312 }
313313 }
314314
315−typedef unsigned long v1di __attribute__ ((vector_size (8)));
315+#define GET_XMM(__xmm) \
316+({ \
317+ unsigned long __val; \
318+ asm volatile("movq %%"#__xmm", %0" : "=r"(__val)); \
319+ __val; \
320+})
321+
316322 static inline unsigned long get_xmm(int n)
317323 {
318324 assert(n >= 0 && n <= 7);
319325
320− register v1di xmm0 __asm__("%xmm0");
321− register v1di xmm1 __asm__("%xmm1");
322− register v1di xmm2 __asm__("%xmm2");
323− register v1di xmm3 __asm__("%xmm3");
324− register v1di xmm4 __asm__("%xmm4");
325− register v1di xmm5 __asm__("%xmm5");
326− register v1di xmm6 __asm__("%xmm6");
327− register v1di xmm7 __asm__("%xmm7");
328326 switch (n) {
329327 case 0:
330− return (unsigned long)xmm0;
328+ return GET_XMM(xmm0);
331329 case 1:
332− return (unsigned long)xmm1;
330+ return GET_XMM(xmm1);
333331 case 2:
334− return (unsigned long)xmm2;
332+ return GET_XMM(xmm2);
335333 case 3:
336− return (unsigned long)xmm3;
334+ return GET_XMM(xmm3);
337335 case 4:
338− return (unsigned long)xmm4;
336+ return GET_XMM(xmm4);
339337 case 5:
340− return (unsigned long)xmm5;
338+ return GET_XMM(xmm5);
341339 case 6:
342− return (unsigned long)xmm6;
340+ return GET_XMM(xmm6);
343341 case 7:
344− return (unsigned long)xmm7;
342+ return GET_XMM(xmm7);
345343 }
344+
345+ /* never reached */
346346 return 0;
347347 }
348348
tools/testing/selftests/kvm/kvm_page_table_test.c+2−5
@@ -456,10 +456,7 @@ static void help(char *name) · 455 unmodified lines
456456 " (default: 1G)\n");
457457 printf(" -v: specify the number of vCPUs to run\n"
458458 " (default: 1)\n");
459− printf(" -s: specify the type of memory that should be used to\n"
460− " back the guest data region.\n"
461− " (default: anonymous)\n\n");
462− backing_src_help();
459+ backing_src_help("-s");
463460 puts("");
464461 }
465462
@@ -468,7 +465,7 @@ int main(int argc, char *argv[]) · 2 unmodified lines
468465 int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
469466 struct test_params p = {
470467 .test_mem_size = DEFAULT_TEST_MEM_SIZE,
471− .src_type = VM_MEM_SRC_ANONYMOUS,
468+ .src_type = DEFAULT_VM_MEM_SRC,
472469 };
473470 int opt;
474471
tools/testing/selftests/kvm/lib/test_util.c+13−4
@@ -283,13 +283,22 @@ size_t get_backing_src_pagesz(uint32_t i) · 282 unmodified lines
283283 }
284284 }
285285
286−void backing_src_help(void)
286+static void print_available_backing_src_types(const char *prefix)
287287 {
288288 int i;
289289
290− printf("Available backing src types:\n");
290+ printf("%sAvailable backing src types:\n", prefix);
291+
291292 for (i = 0; i < NUM_SRC_TYPES; i++)
292− printf("\t%s\n", vm_mem_backing_src_alias(i)->name);
293+ printf("%s %s\n", prefix, vm_mem_backing_src_alias(i)->name);
294+}
295+
296+void backing_src_help(const char *flag)
297+{
298+ printf(" %s: specify the type of memory that should be used to\n"
299+ " back the guest data region. (default: %s)\n",
300+ flag, vm_mem_backing_src_alias(DEFAULT_VM_MEM_SRC)->name);
301+ print_available_backing_src_types(" ");
293302 }
294303
295304 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name)
@@ -300,7 +309,7 @@ enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name) · 4 unmodified lines
300309 if (!strcmp(type_name, vm_mem_backing_src_alias(i)->name))
301310 return i;
302311
303− backing_src_help();
312+ print_available_backing_src_types("");
304313 TEST_FAIL("Unknown backing src type: %s", type_name);
305314 return -1;
306315 }
tools/testing/selftests/kvm/rseq_test.c+60−10
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <signal.h>
1111 #include <syscall.h>
1212 #include <sys/ioctl.h>
13+#include <sys/sysinfo.h>
1314 #include <asm/barrier.h>
1415 #include <linux/atomic.h>
1516 #include <linux/rseq.h>
@@ -39,6 +40,7 @@ static __thread volatile struct rseq __rseq = { · 23 unmodified lines
3940
4041 static pthread_t migration_thread;
4142 static cpu_set_t possible_mask;
43+static int min_cpu, max_cpu;
4244 static bool done;
4345
4446 static atomic_t seq_cnt;
@@ -57,20 +59,37 @@ static void sys_rseq(int flags) · 12 unmodified lines
5759 TEST_ASSERT(!r, "rseq failed, errno = %d (%s)", errno, strerror(errno));
5860 }
5961
62+static int next_cpu(int cpu)
63+{
64+ /*
65+ * Advance to the next CPU, skipping those that weren't in the original
66+ * affinity set. Sadly, there is no CPU_SET_FOR_EACH, and cpu_set_t's
67+ * data storage is considered as opaque. Note, if this task is pinned
68+ * to a small set of discontigous CPUs, e.g. 2 and 1023, this loop will
69+ * burn a lot cycles and the test will take longer than normal to
70+ * complete.
71+ */
72+ do {
73+ cpu++;
74+ if (cpu > max_cpu) {
75+ cpu = min_cpu;
76+ TEST_ASSERT(CPU_ISSET(cpu, &possible_mask),
77+ "Min CPU = %d must always be usable", cpu);
78+ break;
79+ }
80+ } while (!CPU_ISSET(cpu, &possible_mask));
81+
82+ return cpu;
83+}
84+
6085 static void *migration_worker(void *ign)
6186 {
6287 cpu_set_t allowed_mask;
63− int r, i, nr_cpus, cpu;
88+ int r, i, cpu;
6489
6590 CPU_ZERO(&allowed_mask);
6691
67− nr_cpus = CPU_COUNT(&possible_mask);
68−
69− for (i = 0; i < NR_TASK_MIGRATIONS; i++) {
70− cpu = i % nr_cpus;
71− if (!CPU_ISSET(cpu, &possible_mask))
72− continue;
73−
92+ for (i = 0, cpu = min_cpu; i < NR_TASK_MIGRATIONS; i++, cpu = next_cpu(cpu)) {
7493 CPU_SET(cpu, &allowed_mask);
7594
7695 /*
@@ -154,6 +173,36 @@ static void *migration_worker(void *ign) · 77 unmodified lines
154173 return NULL;
155174 }
156175
176+static int calc_min_max_cpu(void)
177+{
178+ int i, cnt, nproc;
179+
180+ if (CPU_COUNT(&possible_mask) < 2)
181+ return -EINVAL;
182+
183+ /*
184+ * CPU_SET doesn't provide a FOR_EACH helper, get the min/max CPU that
185+ * this task is affined to in order to reduce the time spent querying
186+ * unusable CPUs, e.g. if this task is pinned to a small percentage of
187+ * total CPUs.
188+ */
189+ nproc = get_nprocs_conf();
190+ min_cpu = -1;
191+ max_cpu = -1;
192+ cnt = 0;
193+
194+ for (i = 0; i < nproc; i++) {
195+ if (!CPU_ISSET(i, &possible_mask))
196+ continue;
197+ if (min_cpu == -1)
198+ min_cpu = i;
199+ max_cpu = i;
200+ cnt++;
201+ }
202+
203+ return (cnt < 2) ? -EINVAL : 0;
204+}
205+
157206 int main(int argc, char *argv[])
158207 {
159208 int r, i, snapshot;
@@ -167,8 +216,8 @@ int main(int argc, char *argv[]) · 7 unmodified lines
167216 TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)", errno,
168217 strerror(errno));
169218
170− if (CPU_COUNT(&possible_mask) < 2) {
171− print_skip("Only one CPU, task migration not possible\n");
219+ if (calc_min_max_cpu()) {
220+ print_skip("Only one usable CPU, task migration not possible");
172221 exit(KSFT_SKIP);
173222 }
174223
@@ -180,6 +229,7 @@ int main(int argc, char *argv[]) · 5 unmodified lines
180229 * CPU affinity.
181230 */
182231 vm = vm_create_default(VCPU_ID, 0, guest_code);
232+ ucall_init(vm, NULL);
183233
184234 pthread_create(&migration_thread, NULL, migration_worker, 0);
185235
tools/testing/selftests/kvm/steal_time.c+2−2
@@ -116,12 +116,12 @@ struct st_time { · 115 unmodified lines
116116 uint64_t st_time;
117117 };
118118
119−static int64_t smccc(uint32_t func, uint32_t arg)
119+static int64_t smccc(uint32_t func, uint64_t arg)
120120 {
121121 unsigned long ret;
122122
123123 asm volatile(
124− "mov x0, %1\n"
124+ "mov w0, %w1\n"
125125 "mov x1, %2\n"
126126 "hvc #0\n"
127127 "mov %0, x0\n"
tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c+128−0
@@ -0,0 +1,128 @@
1+// SPDX-License-Identifier: GPL-2.0-only
2+/*
3+ * svm_int_ctl_test
4+ *
5+ * Copyright (C) 2021, Red Hat, Inc.
6+ *
7+ * Nested SVM testing: test simultaneous use of V_IRQ from L1 and L0.
8+ */
9+
10+#include "test_util.h"
11+#include "kvm_util.h"
12+#include "processor.h"
13+#include "svm_util.h"
14+#include "apic.h"
15+
16+#define VCPU_ID 0
17+
18+static struct kvm_vm *vm;
19+
20+bool vintr_irq_called;
21+bool intr_irq_called;
22+
23+#define VINTR_IRQ_NUMBER 0x20
24+#define INTR_IRQ_NUMBER 0x30
25+
26+static void vintr_irq_handler(struct ex_regs *regs)
27+{
28+ vintr_irq_called = true;
29+}
30+
31+static void intr_irq_handler(struct ex_regs *regs)
32+{
33+ x2apic_write_reg(APIC_EOI, 0x00);
34+ intr_irq_called = true;
35+}
36+
37+static void l2_guest_code(struct svm_test_data *svm)
38+{
39+ /* This code raises interrupt INTR_IRQ_NUMBER in the L1's LAPIC,
40+ * and since L1 didn't enable virtual interrupt masking,
41+ * L2 should receive it and not L1.
42+ *
43+ * L2 also has virtual interrupt 'VINTR_IRQ_NUMBER' pending in V_IRQ
44+ * so it should also receive it after the following 'sti'.
45+ */
46+ x2apic_write_reg(APIC_ICR,
47+ APIC_DEST_SELF | APIC_INT_ASSERT | INTR_IRQ_NUMBER);
48+
49+ __asm__ __volatile__(
50+ "sti\n"
51+ "nop\n"
52+ );
53+
54+ GUEST_ASSERT(vintr_irq_called);
55+ GUEST_ASSERT(intr_irq_called);
56+
57+ __asm__ __volatile__(
58+ "vmcall\n"
59+ );
60+}
61+
62+static void l1_guest_code(struct svm_test_data *svm)
63+{
64+ #define L2_GUEST_STACK_SIZE 64
65+ unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
66+ struct vmcb *vmcb = svm->vmcb;
67+
68+ x2apic_enable();
69+
70+ /* Prepare for L2 execution. */
71+ generic_svm_setup(svm, l2_guest_code,
72+ &l2_guest_stack[L2_GUEST_STACK_SIZE]);
73+
74+ /* No virtual interrupt masking */
75+ vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK;
76+
77+ /* No intercepts for real and virtual interrupts */
78+ vmcb->control.intercept &= ~(1ULL << INTERCEPT_INTR | INTERCEPT_VINTR);
79+
80+ /* Make a virtual interrupt VINTR_IRQ_NUMBER pending */
81+ vmcb->control.int_ctl |= V_IRQ_MASK | (0x1 << V_INTR_PRIO_SHIFT);
82+ vmcb->control.int_vector = VINTR_IRQ_NUMBER;
83+
84+ run_guest(vmcb, svm->vmcb_gpa);
85+ GUEST_ASSERT(vmcb->control.exit_code == SVM_EXIT_VMMCALL);
86+ GUEST_DONE();
87+}
88+
89+int main(int argc, char *argv[])
90+{
91+ vm_vaddr_t svm_gva;
92+
93+ nested_svm_check_supported();
94+
95+ vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code);
96+
97+ vm_init_descriptor_tables(vm);
98+ vcpu_init_descriptor_tables(vm, VCPU_ID);
99+
100+ vm_install_exception_handler(vm, VINTR_IRQ_NUMBER, vintr_irq_handler);
101+ vm_install_exception_handler(vm, INTR_IRQ_NUMBER, intr_irq_handler);
102+
103+ vcpu_alloc_svm(vm, &svm_gva);
104+ vcpu_args_set(vm, VCPU_ID, 1, svm_gva);
105+
106+ struct kvm_run *run = vcpu_state(vm, VCPU_ID);
107+ struct ucall uc;
108+
109+ vcpu_run(vm, VCPU_ID);
110+ TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
111+ "Got exit_reason other than KVM_EXIT_IO: %u (%s)\n",
112+ run->exit_reason,
113+ exit_reason_str(run->exit_reason));
114+
115+ switch (get_ucall(vm, VCPU_ID, &uc)) {
116+ case UCALL_ABORT:
117+ TEST_FAIL("%s", (const char *)uc.args[0]);
118+ break;
119+ /* NOT REACHED */
120+ case UCALL_DONE:
121+ goto done;
122+ default:
123+ TEST_FAIL("Unknown ucall 0x%lx.", uc.cmd);
124+ }
125+done:
126+ kvm_vm_free(vm);
127+ return 0;
128+}
tools/testing/selftests/netfilter/nft_nat_zones.sh+309−0
@@ -0,0 +1,309 @@
1+#!/bin/bash
2+#
3+# Test connection tracking zone and NAT source port reallocation support.
4+#
5+
6+# Kselftest framework requirement - SKIP code is 4.
7+ksft_skip=4
8+
9+# Don't increase too much, 2000 clients should work
10+# just fine but script can then take several minutes with
11+# KASAN/debug builds.
12+maxclients=100
13+
14+have_iperf=1
15+ret=0
16+
17+# client1---.
18+# veth1-.
19+# |
20+# NAT Gateway --veth0--> Server
21+# | |
22+# veth2-' |
23+# client2---' |
24+# .... |
25+# clientX----vethX---'
26+
27+# All clients share identical IP address.
28+# NAT Gateway uses policy routing and conntrack zones to isolate client
29+# namespaces. Each client connects to Server, each with colliding tuples:
30+# clientsaddr:10000 -> serveraddr:dport
31+# NAT Gateway is supposed to do port reallocation for each of the
32+# connections.
33+
34+sfx=$(mktemp -u "XXXXXXXX")
35+gw="ns-gw-$sfx"
36+cl1="ns-cl1-$sfx"
37+cl2="ns-cl2-$sfx"
38+srv="ns-srv-$sfx"
39+
40+v4gc1=$(sysctl -n net.ipv4.neigh.default.gc_thresh1 2>/dev/null)
41+v4gc2=$(sysctl -n net.ipv4.neigh.default.gc_thresh2 2>/dev/null)
42+v4gc3=$(sysctl -n net.ipv4.neigh.default.gc_thresh3 2>/dev/null)
43+v6gc1=$(sysctl -n net.ipv6.neigh.default.gc_thresh1 2>/dev/null)
44+v6gc2=$(sysctl -n net.ipv6.neigh.default.gc_thresh2 2>/dev/null)
45+v6gc3=$(sysctl -n net.ipv6.neigh.default.gc_thresh3 2>/dev/null)
46+
47+cleanup()
48+{
49+ ip netns del $gw
50+ ip netns del $srv
51+ for i in $(seq 1 $maxclients); do
52+ ip netns del ns-cl$i-$sfx 2>/dev/null
53+ done
54+
55+ sysctl -q net.ipv4.neigh.default.gc_thresh1=$v4gc1 2>/dev/null
56+ sysctl -q net.ipv4.neigh.default.gc_thresh2=$v4gc2 2>/dev/null
57+ sysctl -q net.ipv4.neigh.default.gc_thresh3=$v4gc3 2>/dev/null
58+ sysctl -q net.ipv6.neigh.default.gc_thresh1=$v6gc1 2>/dev/null
59+ sysctl -q net.ipv6.neigh.default.gc_thresh2=$v6gc2 2>/dev/null
60+ sysctl -q net.ipv6.neigh.default.gc_thresh3=$v6gc3 2>/dev/null
61+}
62+
63+nft --version > /dev/null 2>&1
64+if [ $? -ne 0 ];then
65+ echo "SKIP: Could not run test without nft tool"
66+ exit $ksft_skip
67+fi
68+
69+ip -Version > /dev/null 2>&1
70+if [ $? -ne 0 ];then
71+ echo "SKIP: Could not run test without ip tool"
72+ exit $ksft_skip
73+fi
74+
75+conntrack -V > /dev/null 2>&1
76+if [ $? -ne 0 ];then
77+ echo "SKIP: Could not run test without conntrack tool"
78+ exit $ksft_skip
79+fi
80+
81+iperf3 -v >/dev/null 2>&1
82+if [ $? -ne 0 ];then
83+ have_iperf=0
84+fi
85+
86+ip netns add "$gw"
87+if [ $? -ne 0 ];then
88+ echo "SKIP: Could not create net namespace $gw"
89+ exit $ksft_skip
90+fi
91+ip -net "$gw" link set lo up
92+
93+trap cleanup EXIT
94+
95+ip netns add "$srv"
96+if [ $? -ne 0 ];then
97+ echo "SKIP: Could not create server netns $srv"
98+ exit $ksft_skip
99+fi
100+
101+ip link add veth0 netns "$gw" type veth peer name eth0 netns "$srv"
102+ip -net "$gw" link set veth0 up
103+ip -net "$srv" link set lo up
104+ip -net "$srv" link set eth0 up
105+
106+sysctl -q net.ipv6.neigh.default.gc_thresh1=512 2>/dev/null
107+sysctl -q net.ipv6.neigh.default.gc_thresh2=1024 2>/dev/null
108+sysctl -q net.ipv6.neigh.default.gc_thresh3=4096 2>/dev/null
109+sysctl -q net.ipv4.neigh.default.gc_thresh1=512 2>/dev/null
110+sysctl -q net.ipv4.neigh.default.gc_thresh2=1024 2>/dev/null
111+sysctl -q net.ipv4.neigh.default.gc_thresh3=4096 2>/dev/null
112+
113+for i in $(seq 1 $maxclients);do
114+ cl="ns-cl$i-$sfx"
115+
116+ ip netns add "$cl"
117+ if [ $? -ne 0 ];then
118+ echo "SKIP: Could not create client netns $cl"
119+ exit $ksft_skip
120+ fi
121+ ip link add veth$i netns "$gw" type veth peer name eth0 netns "$cl" > /dev/null 2>&1
122+ if [ $? -ne 0 ];then
123+ echo "SKIP: No virtual ethernet pair device support in kernel"
124+ exit $ksft_skip
125+ fi
126+done
127+
128+for i in $(seq 1 $maxclients);do
129+ cl="ns-cl$i-$sfx"
130+ echo netns exec "$cl" ip link set lo up
131+ echo netns exec "$cl" ip link set eth0 up
132+ echo netns exec "$cl" sysctl -q net.ipv4.tcp_syn_retries=2
133+ echo netns exec "$gw" ip link set veth$i up
134+ echo netns exec "$gw" sysctl -q net.ipv4.conf.veth$i.arp_ignore=2
135+ echo netns exec "$gw" sysctl -q net.ipv4.conf.veth$i.rp_filter=0
136+
137+ # clients have same IP addresses.
138+ echo netns exec "$cl" ip addr add 10.1.0.3/24 dev eth0
139+ echo netns exec "$cl" ip addr add dead:1::3/64 dev eth0
140+ echo netns exec "$cl" ip route add default via 10.1.0.2 dev eth0
141+ echo netns exec "$cl" ip route add default via dead:1::2 dev eth0
142+
143+ # NB: same addresses on client-facing interfaces.
144+ echo netns exec "$gw" ip addr add 10.1.0.2/24 dev veth$i
145+ echo netns exec "$gw" ip addr add dead:1::2/64 dev veth$i
146+
147+ # gw: policy routing
148+ echo netns exec "$gw" ip route add 10.1.0.0/24 dev veth$i table $((1000+i))
149+ echo netns exec "$gw" ip route add dead:1::0/64 dev veth$i table $((1000+i))
150+ echo netns exec "$gw" ip route add 10.3.0.0/24 dev veth0 table $((1000+i))
151+ echo netns exec "$gw" ip route add dead:3::0/64 dev veth0 table $((1000+i))
152+ echo netns exec "$gw" ip rule add fwmark $i lookup $((1000+i))
153+done | ip -batch /dev/stdin
154+
155+ip -net "$gw" addr add 10.3.0.1/24 dev veth0
156+ip -net "$gw" addr add dead:3::1/64 dev veth0
157+
158+ip -net "$srv" addr add 10.3.0.99/24 dev eth0
159+ip -net "$srv" addr add dead:3::99/64 dev eth0
160+
161+ip netns exec $gw nft -f /dev/stdin<<EOF
162+table inet raw {
163+ map iiftomark {
164+ type ifname : mark
165+ }
166+
167+ map iiftozone {
168+ typeof iifname : ct zone
169+ }
170+
171+ set inicmp {
172+ flags dynamic
173+ type ipv4_addr . ifname . ipv4_addr
174+ }
175+ set inflows {
176+ flags dynamic
177+ type ipv4_addr . inet_service . ifname . ipv4_addr . inet_service
178+ }
179+
180+ set inflows6 {
181+ flags dynamic
182+ type ipv6_addr . inet_service . ifname . ipv6_addr . inet_service
183+ }
184+
185+ chain prerouting {
186+ type filter hook prerouting priority -64000; policy accept;
187+ ct original zone set meta iifname map @iiftozone
188+ meta mark set meta iifname map @iiftomark
189+
190+ tcp flags & (syn|ack) == ack add @inflows { ip saddr . tcp sport . meta iifname . ip daddr . tcp dport counter }
191+ add @inflows6 { ip6 saddr . tcp sport . meta iifname . ip6 daddr . tcp dport counter }
192+ ip protocol icmp add @inicmp { ip saddr . meta iifname . ip daddr counter }
193+ }
194+
195+ chain nat_postrouting {
196+ type nat hook postrouting priority 0; policy accept;
197+ ct mark set meta mark meta oifname veth0 masquerade
198+ }
199+
200+ chain mangle_prerouting {
201+ type filter hook prerouting priority -100; policy accept;
202+ ct direction reply meta mark set ct mark
203+ }
204+}
205+EOF
206+
207+( echo add element inet raw iiftomark \{
208+ for i in $(seq 1 $((maxclients-1))); do
209+ echo \"veth$i\" : $i,
210+ done
211+ echo \"veth$maxclients\" : $maxclients \}
212+ echo add element inet raw iiftozone \{
213+ for i in $(seq 1 $((maxclients-1))); do
214+ echo \"veth$i\" : $i,
215+ done
216+ echo \"veth$maxclients\" : $maxclients \}
217+) | ip netns exec $gw nft -f /dev/stdin
218+
219+ip netns exec "$gw" sysctl -q net.ipv4.conf.all.forwarding=1 > /dev/null
220+ip netns exec "$gw" sysctl -q net.ipv6.conf.all.forwarding=1 > /dev/null
221+ip netns exec "$gw" sysctl -q net.ipv4.conf.all.rp_filter=0 >/dev/null
222+
223+# useful for debugging: allows to use 'ping' from clients to gateway.
224+ip netns exec "$gw" sysctl -q net.ipv4.fwmark_reflect=1 > /dev/null
225+ip netns exec "$gw" sysctl -q net.ipv6.fwmark_reflect=1 > /dev/null
226+
227+for i in $(seq 1 $maxclients); do
228+ cl="ns-cl$i-$sfx"
229+ ip netns exec $cl ping -i 0.5 -q -c 3 10.3.0.99 > /dev/null 2>&1 &
230+ if [ $? -ne 0 ]; then
231+ echo FAIL: Ping failure from $cl 1>&2
232+ ret=1
233+ break
234+ fi
235+done
236+
237+wait
238+
239+for i in $(seq 1 $maxclients); do
240+ ip netns exec $gw nft get element inet raw inicmp "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 }" | grep -q "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 counter packets 3 bytes 252 }"
241+ if [ $? -ne 0 ];then
242+ ret=1
243+ echo "FAIL: counter icmp mismatch for veth$i" 1>&2
244+ ip netns exec $gw nft get element inet raw inicmp "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 }" 1>&2
245+ break
246+ fi
247+done
248+
249+ip netns exec $gw nft get element inet raw inicmp "{ 10.3.0.99 . \"veth0\" . 10.3.0.1 }" | grep -q "{ 10.3.0.99 . \"veth0\" . 10.3.0.1 counter packets $((3 * $maxclients)) bytes $((252 * $maxclients)) }"
250+if [ $? -ne 0 ];then
251+ ret=1
252+ echo "FAIL: counter icmp mismatch for veth0: { 10.3.0.99 . \"veth0\" . 10.3.0.1 counter packets $((3 * $maxclients)) bytes $((252 * $maxclients)) }"
253+ ip netns exec $gw nft get element inet raw inicmp "{ 10.3.99 . \"veth0\" . 10.3.0.1 }" 1>&2
254+fi
255+
256+if [ $ret -eq 0 ]; then
257+ echo "PASS: ping test from all $maxclients namespaces"
258+fi
259+
260+if [ $have_iperf -eq 0 ];then
261+ echo "SKIP: iperf3 not installed"
262+ if [ $ret -ne 0 ];then
263+ exit $ret
264+ fi
265+ exit $ksft_skip
266+fi
267+
268+ip netns exec $srv iperf3 -s > /dev/null 2>&1 &
269+iperfpid=$!
270+sleep 1
271+
272+for i in $(seq 1 $maxclients); do
273+ if [ $ret -ne 0 ]; then
274+ break
275+ fi
276+ cl="ns-cl$i-$sfx"
277+ ip netns exec $cl iperf3 -c 10.3.0.99 --cport 10000 -n 1 > /dev/null
278+ if [ $? -ne 0 ]; then
279+ echo FAIL: Failure to connect for $cl 1>&2
280+ ip netns exec $gw conntrack -S 1>&2
281+ ret=1
282+ fi
283+done
284+if [ $ret -eq 0 ];then
285+ echo "PASS: iperf3 connections for all $maxclients net namespaces"
286+fi
287+
288+kill $iperfpid
289+wait
290+
291+for i in $(seq 1 $maxclients); do
292+ ip netns exec $gw nft get element inet raw inflows "{ 10.1.0.3 . 10000 . \"veth$i\" . 10.3.0.99 . 5201 }" > /dev/null
293+ if [ $? -ne 0 ];then
294+ ret=1
295+ echo "FAIL: can't find expected tcp entry for veth$i" 1>&2
296+ break
297+ fi
298+done
299+if [ $ret -eq 0 ];then
300+ echo "PASS: Found client connection for all $maxclients net namespaces"
301+fi
302+
303+ip netns exec $gw nft get element inet raw inflows "{ 10.3.0.99 . 5201 . \"veth0\" . 10.3.0.1 . 10000 }" > /dev/null
304+if [ $? -ne 0 ];then
305+ ret=1
306+ echo "FAIL: cannot find return entry on veth0" 1>&2
307+fi
308+
309+exit $ret
tools/testing/selftests/netfilter/nft_zones_many.sh+156−0
@@ -0,0 +1,156 @@
1+#!/bin/bash
2+
3+# Test insertion speed for packets with identical addresses/ports
4+# that are all placed in distinct conntrack zones.
5+
6+sfx=$(mktemp -u "XXXXXXXX")
7+ns="ns-$sfx"
8+
9+# Kselftest framework requirement - SKIP code is 4.
10+ksft_skip=4
11+
12+zones=20000
13+have_ct_tool=0
14+ret=0
15+
16+cleanup()
17+{
18+ ip netns del $ns
19+}
20+
21+ip netns add $ns
22+if [ $? -ne 0 ];then
23+ echo "SKIP: Could not create net namespace $gw"
24+ exit $ksft_skip
25+fi
26+
27+trap cleanup EXIT
28+
29+conntrack -V > /dev/null 2>&1
30+if [ $? -eq 0 ];then
31+ have_ct_tool=1
32+fi
33+
34+ip -net "$ns" link set lo up
35+
36+test_zones() {
37+ local max_zones=$1
38+
39+ip netns exec $ns sysctl -q net.netfilter.nf_conntrack_udp_timeout=3600
40+ip netns exec $ns nft -f /dev/stdin<<EOF
41+flush ruleset
42+table inet raw {
43+ map rndzone {
44+ typeof numgen inc mod $max_zones : ct zone
45+ }
46+
47+ chain output {
48+ type filter hook output priority -64000; policy accept;
49+ udp dport 12345 ct zone set numgen inc mod 65536 map @rndzone
50+ }
51+}
52+EOF
53+ (
54+ echo "add element inet raw rndzone {"
55+ for i in $(seq 1 $max_zones);do
56+ echo -n "$i : $i"
57+ if [ $i -lt $max_zones ]; then
58+ echo ","
59+ else
60+ echo "}"
61+ fi
62+ done
63+ ) | ip netns exec $ns nft -f /dev/stdin
64+
65+ local i=0
66+ local j=0
67+ local outerstart=$(date +%s%3N)
68+ local stop=$outerstart
69+
70+ while [ $i -lt $max_zones ]; do
71+ local start=$(date +%s%3N)
72+ i=$((i + 10000))
73+ j=$((j + 1))
74+ dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" nc -w 1 -q 1 -u -p 12345 127.0.0.1 12345 > /dev/null
75+ if [ $? -ne 0 ] ;then
76+ ret=1
77+ break
78+ fi
79+
80+ stop=$(date +%s%3N)
81+ local duration=$((stop-start))
82+ echo "PASS: added 10000 entries in $duration ms (now $i total, loop $j)"
83+ done
84+
85+ if [ $have_ct_tool -eq 1 ]; then
86+ local count=$(ip netns exec "$ns" conntrack -C)
87+ local duration=$((stop-outerstart))
88+
89+ if [ $count -eq $max_zones ]; then
90+ echo "PASS: inserted $count entries from packet path in $duration ms total"
91+ else
92+ ip netns exec $ns conntrack -S 1>&2
93+ echo "FAIL: inserted $count entries from packet path in $duration ms total, expected $max_zones entries"
94+ ret=1
95+ fi
96+ fi
97+
98+ if [ $ret -ne 0 ];then
99+ echo "FAIL: insert $max_zones entries from packet path" 1>&2
100+ fi
101+}
102+
103+test_conntrack_tool() {
104+ local max_zones=$1
105+
106+ ip netns exec $ns conntrack -F >/dev/null 2>/dev/null
107+
108+ local outerstart=$(date +%s%3N)
109+ local start=$(date +%s%3N)
110+ local stop=$start
111+ local i=0
112+ while [ $i -lt $max_zones ]; do
113+ i=$((i + 1))
114+ ip netns exec "$ns" conntrack -I -s 1.1.1.1 -d 2.2.2.2 --protonum 6 \
115+ --timeout 3600 --state ESTABLISHED --sport 12345 --dport 1000 --zone $i >/dev/null 2>&1
116+ if [ $? -ne 0 ];then
117+ ip netns exec "$ns" conntrack -I -s 1.1.1.1 -d 2.2.2.2 --protonum 6 \
118+ --timeout 3600 --state ESTABLISHED --sport 12345 --dport 1000 --zone $i > /dev/null
119+ echo "FAIL: conntrack -I returned an error"
120+ ret=1
121+ break
122+ fi
123+
124+ if [ $((i%10000)) -eq 0 ];then
125+ stop=$(date +%s%3N)
126+
127+ local duration=$((stop-start))
128+ echo "PASS: added 10000 entries in $duration ms (now $i total)"
129+ start=$stop
130+ fi
131+ done
132+
133+ local count=$(ip netns exec "$ns" conntrack -C)
134+ local duration=$((stop-outerstart))
135+
136+ if [ $count -eq $max_zones ]; then
137+ echo "PASS: inserted $count entries via ctnetlink in $duration ms"
138+ else
139+ ip netns exec $ns conntrack -S 1>&2
140+ echo "FAIL: inserted $count entries via ctnetlink in $duration ms, expected $max_zones entries ($duration ms)"
141+ ret=1
142+ fi
143+}
144+
145+test_zones $zones
146+
147+if [ $have_ct_tool -eq 1 ];then
148+ test_conntrack_tool $zones
149+else
150+ echo "SKIP: Could not run ctnetlink insertion test without conntrack tool"
151+ if [ $ret -eq 0 ];then
152+ exit $ksft_skip
153+ fi
154+fi
155+
156+exit $ret
virt/kvm/kvm_main.c+49−19
@@ -235,9 +235,13 @@ static void ack_flush(void *_completed) · 234 unmodified lines
235235 {
236236 }
237237
238−static inline bool kvm_kick_many_cpus(const struct cpumask *cpus, bool wait)
238+static inline bool kvm_kick_many_cpus(cpumask_var_t tmp, bool wait)
239239 {
240− if (unlikely(!cpus))
240+ const struct cpumask *cpus;
241+
242+ if (likely(cpumask_available(tmp)))
243+ cpus = tmp;
244+ else
241245 cpus = cpu_online_mask;
242246
243247 if (cpumask_empty(cpus))
@@ -263,14 +267,34 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req, · 19 unmodified lines
263267 continue;
264268
265269 kvm_make_request(req, vcpu);
266− cpu = vcpu->cpu;
267270
268271 if (!(req & KVM_REQUEST_NO_WAKEUP) && kvm_vcpu_wake_up(vcpu))
269272 continue;
270273
271− if (tmp != NULL && cpu != -1 && cpu != me &&
272− kvm_request_needs_ipi(vcpu, req))
273− __cpumask_set_cpu(cpu, tmp);
274+ /*
275+ * tmp can be "unavailable" if cpumasks are allocated off stack
276+ * as allocation of the mask is deliberately not fatal and is
277+ * handled by falling back to kicking all online CPUs.
278+ */
279+ if (!cpumask_available(tmp))
280+ continue;
281+
282+ /*
283+ * Note, the vCPU could get migrated to a different pCPU at any
284+ * point after kvm_request_needs_ipi(), which could result in
285+ * sending an IPI to the previous pCPU. But, that's ok because
286+ * the purpose of the IPI is to ensure the vCPU returns to
287+ * OUTSIDE_GUEST_MODE, which is satisfied if the vCPU migrates.
288+ * Entering READING_SHADOW_PAGE_TABLES after this point is also
289+ * ok, as the requirement is only that KVM wait for vCPUs that
290+ * were reading SPTEs _before_ any changes were finalized. See
291+ * kvm_vcpu_kick() for more details on handling requests.
292+ */
293+ if (kvm_request_needs_ipi(vcpu, req)) {
294+ cpu = READ_ONCE(vcpu->cpu);
295+ if (cpu != -1 && cpu != me)
296+ __cpumask_set_cpu(cpu, tmp);
297+ }
274298 }
275299
276300 called = kvm_kick_many_cpus(tmp, !!(req & KVM_REQUEST_WAIT));
@@ -302,13 +326,8 @@ EXPORT_SYMBOL_GPL(kvm_make_all_cpus_request); · 25 unmodified lines
302326 #ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
303327 void kvm_flush_remote_tlbs(struct kvm *kvm)
304328 {
305− /*
306− * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in
307− * kvm_make_all_cpus_request.
308− */
309− long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
310−
311329 ++kvm->stat.generic.remote_tlb_flush_requests;
330+
312331 /*
313332 * We want to publish modifications to the page tables before reading
314333 * mode. Pairs with a memory barrier in arch-specific code.
@@ -323,7 +342,6 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) · 8 unmodified lines
323342 if (!kvm_arch_flush_remote_tlb(kvm)
324343 || kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
325344 ++kvm->stat.generic.remote_tlb_flush;
326− cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
327345 }
328346 EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs);
329347 #endif
@@ -528,7 +546,7 @@ static __always_inline int __kvm_handle_hva_range(struct kvm *kvm, · 198 unmodified lines
528546 }
529547 }
530548
531− if (range->flush_on_ret && (ret || kvm->tlbs_dirty))
549+ if (range->flush_on_ret && ret)
532550 kvm_flush_remote_tlbs(kvm);
533551
534552 if (locked)
@@ -3134,15 +3152,19 @@ out: · 2599 unmodified lines
31343152
31353153 static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
31363154 {
3137− unsigned int old, val, shrink;
3155+ unsigned int old, val, shrink, grow_start;
31383156
31393157 old = val = vcpu->halt_poll_ns;
31403158 shrink = READ_ONCE(halt_poll_ns_shrink);
3159+ grow_start = READ_ONCE(halt_poll_ns_grow_start);
31413160 if (shrink == 0)
31423161 val = 0;
31433162 else
31443163 val /= shrink;
31453164
3165+ if (val < grow_start)
3166+ val = 0;
3167+
31463168 vcpu->halt_poll_ns = val;
31473169 trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old);
31483170 }
@@ -3290,16 +3312,24 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_wake_up); · 141 unmodified lines
32903312 */
32913313 void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
32923314 {
3293− int me;
3294− int cpu = vcpu->cpu;
3315+ int me, cpu;
32953316
32963317 if (kvm_vcpu_wake_up(vcpu))
32973318 return;
32983319
3320+ /*
3321+ * Note, the vCPU could get migrated to a different pCPU at any point
3322+ * after kvm_arch_vcpu_should_kick(), which could result in sending an
3323+ * IPI to the previous pCPU. But, that's ok because the purpose of the
3324+ * IPI is to force the vCPU to leave IN_GUEST_MODE, and migrating the
3325+ * vCPU also requires it to leave IN_GUEST_MODE.
3326+ */
32993327 me = get_cpu();
3300− if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu))
3301− if (kvm_arch_vcpu_should_kick(vcpu))
3328+ if (kvm_arch_vcpu_should_kick(vcpu)) {
3329+ cpu = READ_ONCE(vcpu->cpu);
3330+ if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu))
33023331 smp_send_reschedule(cpu);
3332+ }
33033333 put_cpu();
33043334 }
33053335 EXPORT_SYMBOL_GPL(kvm_vcpu_kick);