aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2019-05-28 17:16:22 -0400
committerIngo Molnar <mingo@kernel.org>2019-05-28 17:16:22 -0400
commit849e96f30068d4f6f8352715e02a10533a46deba (patch)
treedef395835d94b580b1b6225b4441b8b820bcba87
parent5322ea58a06da2e69c5ef36a9b4d4b9255edd423 (diff)
parenta7350998a25ac10cdca5b33dee1d343a74debbfe (diff)
Merge tag 'perf-urgent-for-mingo-5.2-20190528' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes: BPF: Jiri Olsa: - Fixup determination of end of kernel map, to avoid having BPF programs, that are after the kernel headers and just before module texts mixed up in the kernel map. tools UAPI header copies: Arnaldo Carvalho de Melo: - Update copy of files related to new fspick, fsmount, fsconfig, fsopen, move_mount and open_tree syscalls. - Sync cpufeatures.h, sched.h, fs.h, drm.h, i915_drm.h and kvm.h headers. Namespaces: Namhyung Kim: - Add missing byte swap ops for namespace events when processing records from perf.data files that could have been recorded in a arch with a different endianness. - Fix access to the thread namespaces list by using the namespaces_lock. perf data: Shawn Landden: - Fix 'strncat may truncate' build failure with recent gcc. s/390 Thomas Richter: - Fix s390 missing module symbol and warning for non-root users in 'perf record'. arm64: Vitaly Chikunov: - Fix mksyscalltbl when system kernel headers are ahead of the kernel. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--Documentation/bpf/btf.rst2
-rw-r--r--Documentation/kbuild/makefiles.txt14
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/atm/iphase.c6
-rw-r--r--drivers/infiniband/hw/mlx5/ib_rep.c13
-rw-r--r--drivers/infiniband/hw/mlx5/ib_rep.h12
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c16
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc.c4
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_ethtool.c2
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_pf.c2
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_vf.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ecpf.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c19
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c29
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c20
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c20
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_env.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_thermal.c6
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c17
-rw-r--r--drivers/net/phy/aquantia_main.c1
-rw-r--r--drivers/net/ppp/ppp_deflate.c20
-rw-r--r--drivers/net/usb/aqc111.c35
-rw-r--r--drivers/net/usb/qmi_wwan.c2
-rw-r--r--fs/btrfs/compression.c1
-rw-r--r--fs/btrfs/extent-tree.c15
-rw-r--r--fs/btrfs/file.c16
-rw-r--r--fs/btrfs/props.c30
-rw-r--r--fs/btrfs/root-tree.c4
-rw-r--r--fs/btrfs/sysfs.c7
-rw-r--r--fs/btrfs/tree-checker.c49
-rw-r--r--fs/btrfs/tree-log.c1
-rw-r--r--include/linux/bpf.h1
-rw-r--r--include/linux/mlx5/eswitch.h6
-rw-r--r--include/linux/of_net.h2
-rw-r--r--include/linux/rhashtable.h58
-rw-r--r--include/linux/skbuff.h9
-rw-r--r--include/net/flow_offload.h2
-rw-r--r--include/net/ip6_fib.h3
-rw-r--r--include/net/sock.h2
-rw-r--r--include/uapi/linux/btf.h2
-rw-r--r--kernel/bpf/devmap.c3
-rw-r--r--kernel/bpf/hashtab.c23
-rw-r--r--kernel/bpf/inode.c2
-rw-r--r--kernel/bpf/syscall.c5
-rw-r--r--kernel/trace/bpf_trace.c5
-rw-r--r--lib/random32.c4
-rw-r--r--lib/rhashtable.c33
-rw-r--r--net/caif/cfdbgl.c2
-rw-r--r--net/caif/cfdgml.c3
-rw-r--r--net/caif/cfutill.c2
-rw-r--r--net/caif/cfveil.c2
-rw-r--r--net/caif/cfvidl.c2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/flow_offload.c7
-rw-r--r--net/core/rtnetlink.c16
-rw-r--r--net/core/skmsg.c7
-rw-r--r--net/ipv4/bpfilter/sockopt.c6
-rw-r--r--net/ipv4/ping.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_bpf.c7
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/datagram.c2
-rw-r--r--net/ipv6/ip6_fib.c12
-rw-r--r--net/ipv6/route.c58
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/phonet/socket.c2
-rw-r--r--net/socket.c34
-rw-r--r--net/tipc/core.c14
-rw-r--r--net/vmw_vsock/hyperv_transport.c108
-rw-r--r--net/vmw_vsock/virtio_transport.c13
-rw-r--r--net/vmw_vsock/virtio_transport_common.c7
-rw-r--r--net/xfrm/xfrm_policy.c24
-rw-r--r--scripts/Kbuild.include5
-rwxr-xr-xscripts/modules-check.sh6
-rw-r--r--tools/arch/arm64/include/uapi/asm/kvm.h43
-rw-r--r--tools/arch/powerpc/include/uapi/asm/kvm.h46
-rw-r--r--tools/arch/s390/include/uapi/asm/kvm.h4
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h3
-rw-r--r--tools/bpf/bpftool/btf.c4
-rw-r--r--tools/bpf/bpftool/prog.c4
-rw-r--r--tools/include/uapi/asm-generic/unistd.h14
-rw-r--r--tools/include/uapi/drm/drm.h37
-rw-r--r--tools/include/uapi/drm/i915_drm.h254
-rw-r--r--tools/include/uapi/linux/btf.h2
-rw-r--r--tools/include/uapi/linux/fcntl.h2
-rw-r--r--tools/include/uapi/linux/fs.h3
-rw-r--r--tools/include/uapi/linux/kvm.h15
-rw-r--r--tools/include/uapi/linux/mount.h62
-rw-r--r--tools/include/uapi/linux/sched.h1
-rw-r--r--tools/lib/bpf/btf.c2
-rw-r--r--tools/lib/bpf/libbpf.c3
-rw-r--r--tools/lib/bpf/libbpf_internal.h13
-rw-r--r--tools/lib/bpf/libbpf_util.h13
-rw-r--r--tools/lib/bpf/xsk.c2
-rwxr-xr-xtools/perf/arch/arm64/entry/syscalls/mksyscalltbl2
-rw-r--r--tools/perf/arch/s390/util/machine.c9
-rw-r--r--tools/perf/arch/x86/entry/syscalls/syscall_64.tbl6
-rw-r--r--tools/perf/tests/vmlinux-kallsyms.c9
-rw-r--r--tools/perf/util/data-convert-bt.c2
-rw-r--r--tools/perf/util/machine.c27
-rw-r--r--tools/perf/util/session.c21
-rw-r--r--tools/perf/util/thread.c15
-rw-r--r--tools/testing/selftests/bpf/.gitignore1
-rw-r--r--tools/testing/selftests/bpf/bpf_helpers.h2
-rw-r--r--tools/testing/selftests/bpf/map_tests/.gitignore1
-rw-r--r--tools/testing/selftests/bpf/prog_tests/flow_dissector.c9
-rw-r--r--tools/testing/selftests/bpf/test_lru_map.c288
-rwxr-xr-xtools/testing/selftests/net/pmtu.sh18
-rwxr-xr-xtools/testing/selftests/netfilter/nft_nat.sh77
124 files changed, 1455 insertions, 558 deletions
diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
index 8820360d00da..35d83e24dbdb 100644
--- a/Documentation/bpf/btf.rst
+++ b/Documentation/bpf/btf.rst
@@ -131,7 +131,7 @@ The following sections detail encoding of each kind.
131``btf_type`` is followed by a ``u32`` with the following bits arrangement:: 131``btf_type`` is followed by a ``u32`` with the following bits arrangement::
132 132
133 #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 133 #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
134 #define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 134 #define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
135 #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 135 #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
136 136
137The ``BTF_INT_ENCODING`` has the following attributes:: 137The ``BTF_INT_ENCODING`` has the following attributes::
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 03c065855eaf..d65ad5746f94 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -437,20 +437,6 @@ more details, with real examples.
437 The second argument is optional, and if supplied will be used 437 The second argument is optional, and if supplied will be used
438 if first argument is not supported. 438 if first argument is not supported.
439 439
440 cc-ldoption
441 cc-ldoption is used to check if $(CC) when used to link object files
442 supports the given option. An optional second option may be
443 specified if first option are not supported.
444
445 Example:
446 #arch/x86/kernel/Makefile
447 vsyscall-flags += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
448
449 In the above example, vsyscall-flags will be assigned the option
450 -Wl$(comma)--hash-style=sysv if it is supported by $(CC).
451 The second argument is optional, and if supplied will be used
452 if first argument is not supported.
453
454 as-instr 440 as-instr
455 as-instr checks if the assembler reports a specific instruction 441 as-instr checks if the assembler reports a specific instruction
456 and then outputs either option1 or option2 442 and then outputs either option1 or option2
diff --git a/MAINTAINERS b/MAINTAINERS
index 5cfbea4ce575..0c55b0fedbe2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11068,10 +11068,8 @@ S: Supported
11068F: drivers/net/ethernet/qlogic/netxen/ 11068F: drivers/net/ethernet/qlogic/netxen/
11069 11069
11070NFC SUBSYSTEM 11070NFC SUBSYSTEM
11071M: Samuel Ortiz <sameo@linux.intel.com> 11071L: netdev@vger.kernel.org
11072L: linux-wireless@vger.kernel.org 11072S: Orphan
11073L: linux-nfc@lists.01.org (subscribers-only)
11074S: Supported
11075F: net/nfc/ 11073F: net/nfc/
11076F: include/net/nfc/ 11074F: include/net/nfc/
11077F: include/uapi/linux/nfc.h 11075F: include/uapi/linux/nfc.h
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 5278c57dce73..302cf0ba1600 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -2767,12 +2767,6 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2767 case MEMDUMP: 2767 case MEMDUMP:
2768 { 2768 {
2769 switch (ia_cmds.sub_cmd) { 2769 switch (ia_cmds.sub_cmd) {
2770 case MEMDUMP_DEV:
2771 if (!capable(CAP_NET_ADMIN)) return -EPERM;
2772 if (copy_to_user(ia_cmds.buf, iadev, sizeof(IADEV)))
2773 return -EFAULT;
2774 ia_cmds.status = 0;
2775 break;
2776 case MEMDUMP_SEGREG: 2770 case MEMDUMP_SEGREG:
2777 if (!capable(CAP_NET_ADMIN)) return -EPERM; 2771 if (!capable(CAP_NET_ADMIN)) return -EPERM;
2778 tmps = (u16 __user *)ia_cmds.buf; 2772 tmps = (u16 __user *)ia_cmds.buf;
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
index cbcc40d776b9..269b24a3baa1 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.c
+++ b/drivers/infiniband/hw/mlx5/ib_rep.c
@@ -109,15 +109,15 @@ u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
109} 109}
110 110
111struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 111struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
112 int vport_index) 112 u16 vport_num)
113{ 113{
114 return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_IB); 114 return mlx5_eswitch_get_proto_dev(esw, vport_num, REP_IB);
115} 115}
116 116
117struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 117struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
118 int vport_index) 118 u16 vport_num)
119{ 119{
120 return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_ETH); 120 return mlx5_eswitch_get_proto_dev(esw, vport_num, REP_ETH);
121} 121}
122 122
123struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw) 123struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
@@ -125,9 +125,10 @@ struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
125 return mlx5_eswitch_uplink_get_proto_dev(esw, REP_IB); 125 return mlx5_eswitch_uplink_get_proto_dev(esw, REP_IB);
126} 126}
127 127
128struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport) 128struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
129 u16 vport_num)
129{ 130{
130 return mlx5_eswitch_vport_rep(esw, vport); 131 return mlx5_eswitch_vport_rep(esw, vport_num);
131} 132}
132 133
133struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 134struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.h b/drivers/infiniband/hw/mlx5/ib_rep.h
index 1d9778da8a50..8336e0517a5c 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.h
+++ b/drivers/infiniband/hw/mlx5/ib_rep.h
@@ -14,17 +14,17 @@ extern const struct mlx5_ib_profile uplink_rep_profile;
14 14
15u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw); 15u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
16struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 16struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
17 int vport_index); 17 u16 vport_num);
18struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw); 18struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);
19struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 19struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
20 int vport_index); 20 u16 vport_num);
21void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev); 21void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev);
22void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev); 22void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev);
23struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 23struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
24 struct mlx5_ib_sq *sq, 24 struct mlx5_ib_sq *sq,
25 u16 port); 25 u16 port);
26struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 26struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
27 int vport_index); 27 u16 vport_num);
28#else /* CONFIG_MLX5_ESWITCH */ 28#else /* CONFIG_MLX5_ESWITCH */
29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) 29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
30{ 30{
@@ -33,7 +33,7 @@ static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
33 33
34static inline 34static inline
35struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 35struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
36 int vport_index) 36 u16 vport_num)
37{ 37{
38 return NULL; 38 return NULL;
39} 39}
@@ -46,7 +46,7 @@ struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
46 46
47static inline 47static inline
48struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 48struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
49 int vport_index) 49 u16 vport_num)
50{ 50{
51 return NULL; 51 return NULL;
52} 52}
@@ -63,7 +63,7 @@ struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
63 63
64static inline 64static inline
65struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 65struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
66 int vport_index) 66 u16 vport_num)
67{ 67{
68 return NULL; 68 return NULL;
69} 69}
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 21cde7e78621..0d3ba056cda3 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -40,7 +40,7 @@ obj-$(CONFIG_ARCNET) += arcnet/
40obj-$(CONFIG_DEV_APPLETALK) += appletalk/ 40obj-$(CONFIG_DEV_APPLETALK) += appletalk/
41obj-$(CONFIG_CAIF) += caif/ 41obj-$(CONFIG_CAIF) += caif/
42obj-$(CONFIG_CAN) += can/ 42obj-$(CONFIG_CAN) += can/
43obj-$(CONFIG_NET_DSA) += dsa/ 43obj-y += dsa/
44obj-$(CONFIG_ETHERNET) += ethernet/ 44obj-$(CONFIG_ETHERNET) += ethernet/
45obj-$(CONFIG_FDDI) += fddi/ 45obj-$(CONFIG_FDDI) += fddi/
46obj-$(CONFIG_HIPPI) += hippi/ 46obj-$(CONFIG_HIPPI) += hippi/
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index c049410bc888..bebd9b1aeb64 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3343,7 +3343,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3343 if (!err) 3343 if (!err)
3344 err = -ENODEV; 3344 err = -ENODEV;
3345 3345
3346 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); 3346 dev_err(&pdev->dev, "failed to get macb_clk (%d)\n", err);
3347 return err; 3347 return err;
3348 } 3348 }
3349 3349
@@ -3352,7 +3352,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3352 if (!err) 3352 if (!err)
3353 err = -ENODEV; 3353 err = -ENODEV;
3354 3354
3355 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); 3355 dev_err(&pdev->dev, "failed to get hclk (%d)\n", err);
3356 return err; 3356 return err;
3357 } 3357 }
3358 3358
@@ -3370,31 +3370,31 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3370 3370
3371 err = clk_prepare_enable(*pclk); 3371 err = clk_prepare_enable(*pclk);
3372 if (err) { 3372 if (err) {
3373 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); 3373 dev_err(&pdev->dev, "failed to enable pclk (%d)\n", err);
3374 return err; 3374 return err;
3375 } 3375 }
3376 3376
3377 err = clk_prepare_enable(*hclk); 3377 err = clk_prepare_enable(*hclk);
3378 if (err) { 3378 if (err) {
3379 dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err); 3379 dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err);
3380 goto err_disable_pclk; 3380 goto err_disable_pclk;
3381 } 3381 }
3382 3382
3383 err = clk_prepare_enable(*tx_clk); 3383 err = clk_prepare_enable(*tx_clk);
3384 if (err) { 3384 if (err) {
3385 dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err); 3385 dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err);
3386 goto err_disable_hclk; 3386 goto err_disable_hclk;
3387 } 3387 }
3388 3388
3389 err = clk_prepare_enable(*rx_clk); 3389 err = clk_prepare_enable(*rx_clk);
3390 if (err) { 3390 if (err) {
3391 dev_err(&pdev->dev, "failed to enable rx_clk (%u)\n", err); 3391 dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err);
3392 goto err_disable_txclk; 3392 goto err_disable_txclk;
3393 } 3393 }
3394 3394
3395 err = clk_prepare_enable(*tsu_clk); 3395 err = clk_prepare_enable(*tsu_clk);
3396 if (err) { 3396 if (err) {
3397 dev_err(&pdev->dev, "failed to enable tsu_clk (%u)\n", err); 3397 dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err);
3398 goto err_disable_rxclk; 3398 goto err_disable_rxclk;
3399 } 3399 }
3400 3400
@@ -3868,7 +3868,7 @@ static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
3868 3868
3869 err = clk_prepare_enable(*pclk); 3869 err = clk_prepare_enable(*pclk);
3870 if (err) { 3870 if (err) {
3871 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); 3871 dev_err(&pdev->dev, "failed to enable pclk (%d)\n", err);
3872 return err; 3872 return err;
3873 } 3873 }
3874 3874
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 5bb9eb35d76d..491475d87736 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -313,7 +313,9 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
313 while (bds_to_clean && tx_frm_cnt < ENETC_DEFAULT_TX_WORK) { 313 while (bds_to_clean && tx_frm_cnt < ENETC_DEFAULT_TX_WORK) {
314 bool is_eof = !!tx_swbd->skb; 314 bool is_eof = !!tx_swbd->skb;
315 315
316 enetc_unmap_tx_buff(tx_ring, tx_swbd); 316 if (likely(tx_swbd->dma))
317 enetc_unmap_tx_buff(tx_ring, tx_swbd);
318
317 if (is_eof) { 319 if (is_eof) {
318 napi_consume_skb(tx_swbd->skb, napi_budget); 320 napi_consume_skb(tx_swbd->skb, napi_budget);
319 tx_swbd->skb = NULL; 321 tx_swbd->skb = NULL;
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index 1ecad9ffabae..b9519b6ad727 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -570,6 +570,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = {
570 .get_ringparam = enetc_get_ringparam, 570 .get_ringparam = enetc_get_ringparam,
571 .get_link_ksettings = phy_ethtool_get_link_ksettings, 571 .get_link_ksettings = phy_ethtool_get_link_ksettings,
572 .set_link_ksettings = phy_ethtool_set_link_ksettings, 572 .set_link_ksettings = phy_ethtool_set_link_ksettings,
573 .get_link = ethtool_op_get_link,
573}; 574};
574 575
575static const struct ethtool_ops enetc_vf_ethtool_ops = { 576static const struct ethtool_ops enetc_vf_ethtool_ops = {
@@ -584,6 +585,7 @@ static const struct ethtool_ops enetc_vf_ethtool_ops = {
584 .get_rxfh = enetc_get_rxfh, 585 .get_rxfh = enetc_get_rxfh,
585 .set_rxfh = enetc_set_rxfh, 586 .set_rxfh = enetc_set_rxfh,
586 .get_ringparam = enetc_get_ringparam, 587 .get_ringparam = enetc_get_ringparam,
588 .get_link = ethtool_op_get_link,
587}; 589};
588 590
589void enetc_set_ethtool_ops(struct net_device *ndev) 591void enetc_set_ethtool_ops(struct net_device *ndev)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 15876a6e7598..78287c517095 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -721,7 +721,7 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
721 ndev->watchdog_timeo = 5 * HZ; 721 ndev->watchdog_timeo = 5 * HZ;
722 ndev->max_mtu = ENETC_MAX_MTU; 722 ndev->max_mtu = ENETC_MAX_MTU;
723 723
724 ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM | 724 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
725 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | 725 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
726 NETIF_F_LOOPBACK; 726 NETIF_F_LOOPBACK;
727 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | 727 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index 64bebee9f52a..72c3ea887bcf 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -130,7 +130,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
130 ndev->watchdog_timeo = 5 * HZ; 130 ndev->watchdog_timeo = 5 * HZ;
131 ndev->max_mtu = ENETC_MAX_MTU; 131 ndev->max_mtu = ENETC_MAX_MTU;
132 132
133 ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM | 133 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
134 NETIF_F_HW_VLAN_CTAG_TX | 134 NETIF_F_HW_VLAN_CTAG_TX |
135 NETIF_F_HW_VLAN_CTAG_RX; 135 NETIF_F_HW_VLAN_CTAG_RX;
136 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | 136 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index ffed2d4c9403..9c481823b3e8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -1492,7 +1492,7 @@ int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port,
1492 rule.port = port; 1492 rule.port = port;
1493 rule.qpn = qpn; 1493 rule.qpn = qpn;
1494 INIT_LIST_HEAD(&rule.list); 1494 INIT_LIST_HEAD(&rule.list);
1495 mlx4_err(dev, "going promisc on %x\n", port); 1495 mlx4_info(dev, "going promisc on %x\n", port);
1496 1496
1497 return mlx4_flow_attach(dev, &rule, regid_p); 1497 return mlx4_flow_attach(dev, &rule, regid_p);
1498} 1498}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index 9aca8086ee01..88ccfcfcd128 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -8,6 +8,7 @@ config MLX5_CORE
8 select NET_DEVLINK 8 select NET_DEVLINK
9 imply PTP_1588_CLOCK 9 imply PTP_1588_CLOCK
10 imply VXLAN 10 imply VXLAN
11 imply MLXFW
11 default n 12 default n
12 ---help--- 13 ---help---
13 Core driver for low level functionality of the ConnectX-4 and 14 Core driver for low level functionality of the ConnectX-4 and
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 937ba4bcb056..d2ab8cd8ad9f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1604,7 +1604,27 @@ void mlx5_cmd_flush(struct mlx5_core_dev *dev)
1604 1604
1605static int status_to_err(u8 status) 1605static int status_to_err(u8 status)
1606{ 1606{
1607 return status ? -1 : 0; /* TBD more meaningful codes */ 1607 switch (status) {
1608 case MLX5_CMD_DELIVERY_STAT_OK:
1609 case MLX5_DRIVER_STATUS_ABORTED:
1610 return 0;
1611 case MLX5_CMD_DELIVERY_STAT_SIGNAT_ERR:
1612 case MLX5_CMD_DELIVERY_STAT_TOK_ERR:
1613 return -EBADR;
1614 case MLX5_CMD_DELIVERY_STAT_BAD_BLK_NUM_ERR:
1615 case MLX5_CMD_DELIVERY_STAT_OUT_PTR_ALIGN_ERR:
1616 case MLX5_CMD_DELIVERY_STAT_IN_PTR_ALIGN_ERR:
1617 return -EFAULT; /* Bad address */
1618 case MLX5_CMD_DELIVERY_STAT_IN_LENGTH_ERR:
1619 case MLX5_CMD_DELIVERY_STAT_OUT_LENGTH_ERR:
1620 case MLX5_CMD_DELIVERY_STAT_CMD_DESCR_ERR:
1621 case MLX5_CMD_DELIVERY_STAT_RES_FLD_NOT_CLR_ERR:
1622 return -ENOMSG;
1623 case MLX5_CMD_DELIVERY_STAT_FW_ERR:
1624 return -EIO;
1625 default:
1626 return -EINVAL;
1627 }
1608} 1628}
1609 1629
1610static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size, 1630static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
index 4746f2d28fb6..0ccd6d40baf7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
@@ -26,7 +26,7 @@ static int mlx5_peer_pf_disable_hca(struct mlx5_core_dev *dev)
26 26
27 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA); 27 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
28 MLX5_SET(disable_hca_in, in, function_id, 0); 28 MLX5_SET(disable_hca_in, in, function_id, 0);
29 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0); 29 MLX5_SET(disable_hca_in, in, embedded_cpu_function, 0);
30 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); 30 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
31} 31}
32 32
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 7efaa58ae034..dd764e0471f2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1901,6 +1901,22 @@ static int mlx5e_flash_device(struct net_device *dev,
1901 return mlx5e_ethtool_flash_device(priv, flash); 1901 return mlx5e_ethtool_flash_device(priv, flash);
1902} 1902}
1903 1903
1904#ifndef CONFIG_MLX5_EN_RXNFC
1905/* When CONFIG_MLX5_EN_RXNFC=n we only support ETHTOOL_GRXRINGS
1906 * otherwise this function will be defined from en_fs_ethtool.c
1907 */
1908static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, u32 *rule_locs)
1909{
1910 struct mlx5e_priv *priv = netdev_priv(dev);
1911
1912 if (info->cmd != ETHTOOL_GRXRINGS)
1913 return -EOPNOTSUPP;
1914 /* ring_count is needed by ethtool -x */
1915 info->data = priv->channels.params.num_channels;
1916 return 0;
1917}
1918#endif
1919
1904const struct ethtool_ops mlx5e_ethtool_ops = { 1920const struct ethtool_ops mlx5e_ethtool_ops = {
1905 .get_drvinfo = mlx5e_get_drvinfo, 1921 .get_drvinfo = mlx5e_get_drvinfo,
1906 .get_link = ethtool_op_get_link, 1922 .get_link = ethtool_op_get_link,
@@ -1919,8 +1935,8 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
1919 .get_rxfh_indir_size = mlx5e_get_rxfh_indir_size, 1935 .get_rxfh_indir_size = mlx5e_get_rxfh_indir_size,
1920 .get_rxfh = mlx5e_get_rxfh, 1936 .get_rxfh = mlx5e_get_rxfh,
1921 .set_rxfh = mlx5e_set_rxfh, 1937 .set_rxfh = mlx5e_set_rxfh,
1922#ifdef CONFIG_MLX5_EN_RXNFC
1923 .get_rxnfc = mlx5e_get_rxnfc, 1938 .get_rxnfc = mlx5e_get_rxnfc,
1939#ifdef CONFIG_MLX5_EN_RXNFC
1924 .set_rxnfc = mlx5e_set_rxnfc, 1940 .set_rxnfc = mlx5e_set_rxnfc,
1925#endif 1941#endif
1926 .flash_device = mlx5e_flash_device, 1942 .flash_device = mlx5e_flash_device,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 91e24f1cead8..5283e16c69e4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -65,9 +65,26 @@ static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
65static void mlx5e_rep_get_drvinfo(struct net_device *dev, 65static void mlx5e_rep_get_drvinfo(struct net_device *dev,
66 struct ethtool_drvinfo *drvinfo) 66 struct ethtool_drvinfo *drvinfo)
67{ 67{
68 struct mlx5e_priv *priv = netdev_priv(dev);
69 struct mlx5_core_dev *mdev = priv->mdev;
70
68 strlcpy(drvinfo->driver, mlx5e_rep_driver_name, 71 strlcpy(drvinfo->driver, mlx5e_rep_driver_name,
69 sizeof(drvinfo->driver)); 72 sizeof(drvinfo->driver));
70 strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version)); 73 strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
74 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
75 "%d.%d.%04d (%.16s)",
76 fw_rev_maj(mdev), fw_rev_min(mdev),
77 fw_rev_sub(mdev), mdev->board_id);
78}
79
80static void mlx5e_uplink_rep_get_drvinfo(struct net_device *dev,
81 struct ethtool_drvinfo *drvinfo)
82{
83 struct mlx5e_priv *priv = netdev_priv(dev);
84
85 mlx5e_rep_get_drvinfo(dev, drvinfo);
86 strlcpy(drvinfo->bus_info, pci_name(priv->mdev->pdev),
87 sizeof(drvinfo->bus_info));
71} 88}
72 89
73static const struct counter_desc sw_rep_stats_desc[] = { 90static const struct counter_desc sw_rep_stats_desc[] = {
@@ -363,7 +380,7 @@ static const struct ethtool_ops mlx5e_vf_rep_ethtool_ops = {
363}; 380};
364 381
365static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = { 382static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = {
366 .get_drvinfo = mlx5e_rep_get_drvinfo, 383 .get_drvinfo = mlx5e_uplink_rep_get_drvinfo,
367 .get_link = ethtool_op_get_link, 384 .get_link = ethtool_op_get_link,
368 .get_strings = mlx5e_rep_get_strings, 385 .get_strings = mlx5e_rep_get_strings,
369 .get_sset_count = mlx5e_rep_get_sset_count, 386 .get_sset_count = mlx5e_rep_get_sset_count,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 122f457091a2..31cd02f11499 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1595,7 +1595,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
1595 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) { 1595 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) {
1596 struct flow_match_vlan match; 1596 struct flow_match_vlan match;
1597 1597
1598 flow_rule_match_vlan(rule, &match); 1598 flow_rule_match_cvlan(rule, &match);
1599 if (match.mask->vlan_id || 1599 if (match.mask->vlan_id ||
1600 match.mask->vlan_priority || 1600 match.mask->vlan_priority ||
1601 match.mask->vlan_tpid) { 1601 match.mask->vlan_tpid) {
@@ -1916,6 +1916,19 @@ struct mlx5_fields {
1916 offsetof(struct pedit_headers, field) + (off), \ 1916 offsetof(struct pedit_headers, field) + (off), \
1917 MLX5_BYTE_OFF(fte_match_set_lyr_2_4, match_field)} 1917 MLX5_BYTE_OFF(fte_match_set_lyr_2_4, match_field)}
1918 1918
1919/* masked values are the same and there are no rewrites that do not have a
1920 * match.
1921 */
1922#define SAME_VAL_MASK(type, valp, maskp, matchvalp, matchmaskp) ({ \
1923 type matchmaskx = *(type *)(matchmaskp); \
1924 type matchvalx = *(type *)(matchvalp); \
1925 type maskx = *(type *)(maskp); \
1926 type valx = *(type *)(valp); \
1927 \
1928 (valx & maskx) == (matchvalx & matchmaskx) && !(maskx & (maskx ^ \
1929 matchmaskx)); \
1930})
1931
1919static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp, 1932static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp,
1920 void *matchmaskp, int size) 1933 void *matchmaskp, int size)
1921{ 1934{
@@ -1923,16 +1936,13 @@ static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp,
1923 1936
1924 switch (size) { 1937 switch (size) {
1925 case sizeof(u8): 1938 case sizeof(u8):
1926 same = ((*(u8 *)valp) & (*(u8 *)maskp)) == 1939 same = SAME_VAL_MASK(u8, valp, maskp, matchvalp, matchmaskp);
1927 ((*(u8 *)matchvalp) & (*(u8 *)matchmaskp));
1928 break; 1940 break;
1929 case sizeof(u16): 1941 case sizeof(u16):
1930 same = ((*(u16 *)valp) & (*(u16 *)maskp)) == 1942 same = SAME_VAL_MASK(u16, valp, maskp, matchvalp, matchmaskp);
1931 ((*(u16 *)matchvalp) & (*(u16 *)matchmaskp));
1932 break; 1943 break;
1933 case sizeof(u32): 1944 case sizeof(u32):
1934 same = ((*(u32 *)valp) & (*(u32 *)maskp)) == 1945 same = SAME_VAL_MASK(u32, valp, maskp, matchvalp, matchmaskp);
1935 ((*(u32 *)matchvalp) & (*(u32 *)matchmaskp));
1936 break; 1946 break;
1937 } 1947 }
1938 1948
@@ -2557,8 +2567,10 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
2557 /* in case all pedit actions are skipped, remove the MOD_HDR 2567 /* in case all pedit actions are skipped, remove the MOD_HDR
2558 * flag. 2568 * flag.
2559 */ 2569 */
2560 if (parse_attr->num_mod_hdr_actions == 0) 2570 if (parse_attr->num_mod_hdr_actions == 0) {
2561 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; 2571 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
2572 kfree(parse_attr->mod_hdr_actions);
2573 }
2562 } 2574 }
2563 2575
2564 attr->action = action; 2576 attr->action = action;
@@ -2995,6 +3007,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
2995 */ 3007 */
2996 if (parse_attr->num_mod_hdr_actions == 0) { 3008 if (parse_attr->num_mod_hdr_actions == 0) {
2997 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; 3009 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
3010 kfree(parse_attr->mod_hdr_actions);
2998 if (!((action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) || 3011 if (!((action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) ||
2999 (action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH))) 3012 (action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH)))
3000 attr->split_count = 0; 3013 attr->split_count = 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 7b61126fcec9..195a7d903cec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -361,7 +361,7 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
361 } 361 }
362 362
363 stats->bytes += num_bytes; 363 stats->bytes += num_bytes;
364 stats->xmit_more += netdev_xmit_more(); 364 stats->xmit_more += xmit_more;
365 365
366 headlen = skb->len - ihs - skb->data_len; 366 headlen = skb->len - ihs - skb->data_len;
367 ds_cnt += !!headlen; 367 ds_cnt += !!headlen;
@@ -624,7 +624,8 @@ mlx5i_txwqe_build_datagram(struct mlx5_av *av, u32 dqpn, u32 dqkey,
624} 624}
625 625
626netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, 626netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
627 struct mlx5_av *av, u32 dqpn, u32 dqkey) 627 struct mlx5_av *av, u32 dqpn, u32 dqkey,
628 bool xmit_more)
628{ 629{
629 struct mlx5_wq_cyc *wq = &sq->wq; 630 struct mlx5_wq_cyc *wq = &sq->wq;
630 struct mlx5i_tx_wqe *wqe; 631 struct mlx5i_tx_wqe *wqe;
@@ -660,7 +661,7 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
660 } 661 }
661 662
662 stats->bytes += num_bytes; 663 stats->bytes += num_bytes;
663 stats->xmit_more += netdev_xmit_more(); 664 stats->xmit_more += xmit_more;
664 665
665 headlen = skb->len - ihs - skb->data_len; 666 headlen = skb->len - ihs - skb->data_len;
666 ds_cnt += !!headlen; 667 ds_cnt += !!headlen;
@@ -705,7 +706,7 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
705 goto err_drop; 706 goto err_drop;
706 707
707 mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt, num_wqebbs, num_bytes, 708 mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt, num_wqebbs, num_bytes,
708 num_dma, wi, cseg, false); 709 num_dma, wi, cseg, xmit_more);
709 710
710 return NETDEV_TX_OK; 711 return NETDEV_TX_OK;
711 712
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 9ea0ccfe5ef5..6a921e24cd5e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1526,7 +1526,7 @@ static void node_guid_gen_from_mac(u64 *node_guid, u8 mac[ETH_ALEN])
1526static void esw_apply_vport_conf(struct mlx5_eswitch *esw, 1526static void esw_apply_vport_conf(struct mlx5_eswitch *esw,
1527 struct mlx5_vport *vport) 1527 struct mlx5_vport *vport)
1528{ 1528{
1529 int vport_num = vport->vport; 1529 u16 vport_num = vport->vport;
1530 1530
1531 if (esw->manager_vport == vport_num) 1531 if (esw->manager_vport == vport_num)
1532 return; 1532 return;
@@ -1915,7 +1915,7 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
1915 1915
1916/* Vport Administration */ 1916/* Vport Administration */
1917int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, 1917int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
1918 int vport, u8 mac[ETH_ALEN]) 1918 u16 vport, u8 mac[ETH_ALEN])
1919{ 1919{
1920 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1920 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1921 u64 node_guid; 1921 u64 node_guid;
@@ -1959,7 +1959,7 @@ unlock:
1959} 1959}
1960 1960
1961int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, 1961int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
1962 int vport, int link_state) 1962 u16 vport, int link_state)
1963{ 1963{
1964 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1964 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1965 int err = 0; 1965 int err = 0;
@@ -1989,7 +1989,7 @@ unlock:
1989} 1989}
1990 1990
1991int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, 1991int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
1992 int vport, struct ifla_vf_info *ivi) 1992 u16 vport, struct ifla_vf_info *ivi)
1993{ 1993{
1994 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1994 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1995 1995
@@ -2014,7 +2014,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
2014} 2014}
2015 2015
2016int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 2016int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2017 int vport, u16 vlan, u8 qos, u8 set_flags) 2017 u16 vport, u16 vlan, u8 qos, u8 set_flags)
2018{ 2018{
2019 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2019 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2020 int err = 0; 2020 int err = 0;
@@ -2047,7 +2047,7 @@ unlock:
2047} 2047}
2048 2048
2049int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 2049int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2050 int vport, u16 vlan, u8 qos) 2050 u16 vport, u16 vlan, u8 qos)
2051{ 2051{
2052 u8 set_flags = 0; 2052 u8 set_flags = 0;
2053 2053
@@ -2058,7 +2058,7 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2058} 2058}
2059 2059
2060int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, 2060int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
2061 int vport, bool spoofchk) 2061 u16 vport, bool spoofchk)
2062{ 2062{
2063 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2063 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2064 bool pschk; 2064 bool pschk;
@@ -2208,7 +2208,7 @@ out:
2208} 2208}
2209 2209
2210int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, 2210int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
2211 int vport, bool setting) 2211 u16 vport, bool setting)
2212{ 2212{
2213 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2213 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2214 2214
@@ -2278,7 +2278,7 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
2278 return 0; 2278 return 0;
2279} 2279}
2280 2280
2281int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, 2281int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
2282 u32 max_rate, u32 min_rate) 2282 u32 max_rate, u32 min_rate)
2283{ 2283{
2284 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2284 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
@@ -2368,7 +2368,7 @@ static int mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev,
2368} 2368}
2369 2369
2370int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, 2370int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
2371 int vport_num, 2371 u16 vport_num,
2372 struct ifla_vf_stats *vf_stats) 2372 struct ifla_vf_stats *vf_stats)
2373{ 2373{
2374 struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num); 2374 struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index ed3fad689ec9..d043d6f9797d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -246,23 +246,23 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
246int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode); 246int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode);
247void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw); 247void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw);
248int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, 248int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
249 int vport, u8 mac[ETH_ALEN]); 249 u16 vport, u8 mac[ETH_ALEN]);
250int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, 250int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
251 int vport, int link_state); 251 u16 vport, int link_state);
252int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 252int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
253 int vport, u16 vlan, u8 qos); 253 u16 vport, u16 vlan, u8 qos);
254int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, 254int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
255 int vport, bool spoofchk); 255 u16 vport, bool spoofchk);
256int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, 256int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
257 int vport_num, bool setting); 257 u16 vport_num, bool setting);
258int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, 258int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
259 u32 max_rate, u32 min_rate); 259 u32 max_rate, u32 min_rate);
260int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting); 260int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting);
261int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting); 261int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting);
262int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, 262int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
263 int vport, struct ifla_vf_info *ivi); 263 u16 vport, struct ifla_vf_info *ivi);
264int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, 264int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
265 int vport, 265 u16 vport,
266 struct ifla_vf_stats *vf_stats); 266 struct ifla_vf_stats *vf_stats);
267void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule); 267void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule);
268 268
@@ -296,7 +296,7 @@ u32
296mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw); 296mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw);
297 297
298struct mlx5_flow_handle * 298struct mlx5_flow_handle *
299mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, 299mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, u16 vport,
300 struct mlx5_flow_destination *dest); 300 struct mlx5_flow_destination *dest);
301 301
302enum { 302enum {
@@ -366,7 +366,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
366int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw, 366int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,
367 struct mlx5_esw_flow_attr *attr); 367 struct mlx5_esw_flow_attr *attr);
368int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 368int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
369 int vport, u16 vlan, u8 qos, u8 set_flags); 369 u16 vport, u16 vlan, u8 qos, u8 set_flags);
370 370
371static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev, 371static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev,
372 u8 vlan_depth) 372 u8 vlan_depth)
@@ -430,7 +430,7 @@ static inline int mlx5_eswitch_vport_num_to_index(struct mlx5_eswitch *esw,
430 return vport_num; 430 return vport_num;
431} 431}
432 432
433static inline int mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw, 433static inline u16 mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw,
434 int index) 434 int index)
435{ 435{
436 if (index == mlx5_eswitch_ecpf_idx(esw) && 436 if (index == mlx5_eswitch_ecpf_idx(esw) &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index e09ae27485ee..47b446d30f71 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -57,7 +57,7 @@
57static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw, 57static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw,
58 u16 vport_num) 58 u16 vport_num)
59{ 59{
60 u16 idx = mlx5_eswitch_vport_num_to_index(esw, vport_num); 60 int idx = mlx5_eswitch_vport_num_to_index(esw, vport_num);
61 61
62 WARN_ON(idx > esw->total_vports - 1); 62 WARN_ON(idx > esw->total_vports - 1);
63 return &esw->offloads.vport_reps[idx]; 63 return &esw->offloads.vport_reps[idx];
@@ -515,7 +515,8 @@ out:
515} 515}
516 516
517struct mlx5_flow_handle * 517struct mlx5_flow_handle *
518mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, int vport, u32 sqn) 518mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, u16 vport,
519 u32 sqn)
519{ 520{
520 struct mlx5_flow_act flow_act = {0}; 521 struct mlx5_flow_act flow_act = {0};
521 struct mlx5_flow_destination dest = {}; 522 struct mlx5_flow_destination dest = {};
@@ -1181,7 +1182,7 @@ static void esw_destroy_vport_rx_group(struct mlx5_eswitch *esw)
1181} 1182}
1182 1183
1183struct mlx5_flow_handle * 1184struct mlx5_flow_handle *
1184mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, 1185mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, u16 vport,
1185 struct mlx5_flow_destination *dest) 1186 struct mlx5_flow_destination *dest)
1186{ 1187{
1187 struct mlx5_flow_act flow_act = {0}; 1188 struct mlx5_flow_act flow_act = {0};
@@ -1731,13 +1732,14 @@ static void esw_prio_tag_acls_cleanup(struct mlx5_eswitch *esw)
1731 struct mlx5_vport *vport; 1732 struct mlx5_vport *vport;
1732 int i; 1733 int i;
1733 1734
1734 mlx5_esw_for_each_vf_vport(esw, i, vport, esw->nvports) { 1735 mlx5_esw_for_each_vf_vport(esw, i, vport, esw->dev->priv.sriov.num_vfs) {
1735 esw_vport_disable_egress_acl(esw, vport); 1736 esw_vport_disable_egress_acl(esw, vport);
1736 esw_vport_disable_ingress_acl(esw, vport); 1737 esw_vport_disable_ingress_acl(esw, vport);
1737 } 1738 }
1738} 1739}
1739 1740
1740static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports) 1741static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int vf_nvports,
1742 int nvports)
1741{ 1743{
1742 int err; 1744 int err;
1743 1745
@@ -1745,7 +1747,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports)
1745 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); 1747 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);
1746 1748
1747 if (MLX5_CAP_GEN(esw->dev, prio_tag_required)) { 1749 if (MLX5_CAP_GEN(esw->dev, prio_tag_required)) {
1748 err = esw_prio_tag_acls_config(esw, nvports); 1750 err = esw_prio_tag_acls_config(esw, vf_nvports);
1749 if (err) 1751 if (err)
1750 return err; 1752 return err;
1751 } 1753 }
@@ -1838,7 +1840,7 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
1838{ 1840{
1839 int err; 1841 int err;
1840 1842
1841 err = esw_offloads_steering_init(esw, total_nvports); 1843 err = esw_offloads_steering_init(esw, vf_nvports, total_nvports);
1842 if (err) 1844 if (err)
1843 return err; 1845 return err;
1844 1846
@@ -2243,7 +2245,7 @@ void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)
2243} 2245}
2244 2246
2245void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, 2247void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
2246 int vport, 2248 u16 vport,
2247 u8 rep_type) 2249 u8 rep_type)
2248{ 2250{
2249 struct mlx5_eswitch_rep *rep; 2251 struct mlx5_eswitch_rep *rep;
@@ -2264,7 +2266,7 @@ void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type)
2264EXPORT_SYMBOL(mlx5_eswitch_uplink_get_proto_dev); 2266EXPORT_SYMBOL(mlx5_eswitch_uplink_get_proto_dev);
2265 2267
2266struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw, 2268struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw,
2267 int vport) 2269 u16 vport)
2268{ 2270{
2269 return mlx5_eswitch_get_rep(esw, vport); 2271 return mlx5_eswitch_get_rep(esw, vport);
2270} 2272}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index fb5b61727ee7..d7ca7e82a832 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1380,6 +1380,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
1380 if ((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT && 1380 if ((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
1381 d1->vport.num == d2->vport.num && 1381 d1->vport.num == d2->vport.num &&
1382 d1->vport.flags == d2->vport.flags && 1382 d1->vport.flags == d2->vport.flags &&
1383 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ?
1384 (d1->vport.vhca_id == d2->vport.vhca_id) : true) &&
1383 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ? 1385 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ?
1384 (d1->vport.reformat_id == d2->vport.reformat_id) : true)) || 1386 (d1->vport.reformat_id == d2->vport.reformat_id) : true)) ||
1385 (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && 1387 (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index ada1b7c0e0b8..9ca492b430d8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -619,7 +619,7 @@ static int mlx5i_xmit(struct net_device *dev, struct sk_buff *skb,
619 struct mlx5_ib_ah *mah = to_mah(address); 619 struct mlx5_ib_ah *mah = to_mah(address);
620 struct mlx5i_priv *ipriv = epriv->ppriv; 620 struct mlx5i_priv *ipriv = epriv->ppriv;
621 621
622 return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey); 622 return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey, netdev_xmit_more());
623} 623}
624 624
625static void mlx5i_set_pkey_index(struct net_device *netdev, int id) 625static void mlx5i_set_pkey_index(struct net_device *netdev, int id)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
index 9165ca567047..e19ba3fcd1b7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
@@ -119,7 +119,8 @@ static inline void mlx5i_sq_fetch_wqe(struct mlx5e_txqsq *sq,
119} 119}
120 120
121netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, 121netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
122 struct mlx5_av *av, u32 dqpn, u32 dqkey); 122 struct mlx5_av *av, u32 dqpn, u32 dqkey,
123 bool xmit_more);
123void mlx5i_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 124void mlx5i_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
124void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats); 125void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
125 126
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index bcbe07ec22be..6ee6de7f0160 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
122} 122}
123EXPORT_SYMBOL(mlxsw_core_driver_priv); 123EXPORT_SYMBOL(mlxsw_core_driver_priv);
124 124
125bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
126{
127 return mlxsw_core->driver->res_query_enabled;
128}
129EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
130
125struct mlxsw_rx_listener_item { 131struct mlxsw_rx_listener_item {
126 struct list_head list; 132 struct list_head list;
127 struct mlxsw_rx_listener rxl; 133 struct mlxsw_rx_listener rxl;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index 917be621c904..e3832cb5bdda 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
28 28
29void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); 29void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
30 30
31bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
32
31int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); 33int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
32void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); 34void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
33 35
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index c1c1965d7acc..72539a9a3847 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -3,6 +3,7 @@
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/err.h> 5#include <linux/err.h>
6#include <linux/sfp.h>
6 7
7#include "core.h" 8#include "core.h"
8#include "core_env.h" 9#include "core_env.h"
@@ -162,7 +163,7 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
162{ 163{
163 u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; 164 u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
164 u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; 165 u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE;
165 u8 module_rev_id, module_id; 166 u8 module_rev_id, module_id, diag_mon;
166 unsigned int read_size; 167 unsigned int read_size;
167 int err; 168 int err;
168 169
@@ -195,8 +196,21 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
195 } 196 }
196 break; 197 break;
197 case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: 198 case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
199 /* Verify if transceiver provides diagnostic monitoring page */
200 err = mlxsw_env_query_module_eeprom(mlxsw_core, module,
201 SFP_DIAGMON, 1, &diag_mon,
202 &read_size);
203 if (err)
204 return err;
205
206 if (read_size < 1)
207 return -EIO;
208
198 modinfo->type = ETH_MODULE_SFF_8472; 209 modinfo->type = ETH_MODULE_SFF_8472;
199 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; 210 if (diag_mon)
211 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
212 else
213 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
200 break; 214 break;
201 default: 215 default:
202 return -EINVAL; 216 return -EINVAL;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index 6956bbebe2f1..496dc904c5ed 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
518 u8 width; 518 u8 width;
519 int err; 519 int err;
520 520
521 if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
522 return 0;
523
521 /* Add extra attributes for module temperature. Sensor index is 524 /* Add extra attributes for module temperature. Sensor index is
522 * assigned to sensor_count value, while all indexed before 525 * assigned to sensor_count value, while all indexed before
523 * sensor_count are already utilized by the sensors connected through 526 * sensor_count are already utilized by the sensors connected through
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 472f63f9fac5..d3e851e7ca72 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
740 struct mlxsw_thermal_module *module_tz; 740 struct mlxsw_thermal_module *module_tz;
741 int i, err; 741 int i, err;
742 742
743 if (!mlxsw_core_res_query_enabled(core))
744 return 0;
745
743 thermal->tz_module_arr = kcalloc(module_count, 746 thermal->tz_module_arr = kcalloc(module_count,
744 sizeof(*thermal->tz_module_arr), 747 sizeof(*thermal->tz_module_arr),
745 GFP_KERNEL); 748 GFP_KERNEL);
@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
776 unsigned int module_count = mlxsw_core_max_ports(thermal->core); 779 unsigned int module_count = mlxsw_core_max_ports(thermal->core);
777 int i; 780 int i;
778 781
782 if (!mlxsw_core_res_query_enabled(thermal->core))
783 return;
784
779 for (i = module_count - 1; i >= 0; i--) 785 for (i = module_count - 1; i >= 0; i--)
780 mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); 786 mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
781 kfree(thermal->tz_module_arr); 787 kfree(thermal->tz_module_arr);
diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
index faa06edf95ac..8c67505865a4 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
@@ -168,6 +168,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
168 return; 168 return;
169 } 169 }
170 170
171 rcu_read_lock();
171 for (i = 0; i < count; i++) { 172 for (i = 0; i < count; i++) {
172 ipv4_addr = payload->tun_info[i].ipv4; 173 ipv4_addr = payload->tun_info[i].ipv4;
173 port = be32_to_cpu(payload->tun_info[i].egress_port); 174 port = be32_to_cpu(payload->tun_info[i].egress_port);
@@ -183,6 +184,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
183 neigh_event_send(n, NULL); 184 neigh_event_send(n, NULL);
184 neigh_release(n); 185 neigh_release(n);
185 } 186 }
187 rcu_read_unlock();
186} 188}
187 189
188static int 190static int
@@ -367,9 +369,10 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
367 369
368 payload = nfp_flower_cmsg_get_data(skb); 370 payload = nfp_flower_cmsg_get_data(skb);
369 371
372 rcu_read_lock();
370 netdev = nfp_app_dev_get(app, be32_to_cpu(payload->ingress_port), NULL); 373 netdev = nfp_app_dev_get(app, be32_to_cpu(payload->ingress_port), NULL);
371 if (!netdev) 374 if (!netdev)
372 goto route_fail_warning; 375 goto fail_rcu_unlock;
373 376
374 flow.daddr = payload->ipv4_addr; 377 flow.daddr = payload->ipv4_addr;
375 flow.flowi4_proto = IPPROTO_UDP; 378 flow.flowi4_proto = IPPROTO_UDP;
@@ -379,21 +382,23 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
379 rt = ip_route_output_key(dev_net(netdev), &flow); 382 rt = ip_route_output_key(dev_net(netdev), &flow);
380 err = PTR_ERR_OR_ZERO(rt); 383 err = PTR_ERR_OR_ZERO(rt);
381 if (err) 384 if (err)
382 goto route_fail_warning; 385 goto fail_rcu_unlock;
383#else 386#else
384 goto route_fail_warning; 387 goto fail_rcu_unlock;
385#endif 388#endif
386 389
387 /* Get the neighbour entry for the lookup */ 390 /* Get the neighbour entry for the lookup */
388 n = dst_neigh_lookup(&rt->dst, &flow.daddr); 391 n = dst_neigh_lookup(&rt->dst, &flow.daddr);
389 ip_rt_put(rt); 392 ip_rt_put(rt);
390 if (!n) 393 if (!n)
391 goto route_fail_warning; 394 goto fail_rcu_unlock;
392 nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_KERNEL); 395 nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_ATOMIC);
393 neigh_release(n); 396 neigh_release(n);
397 rcu_read_unlock();
394 return; 398 return;
395 399
396route_fail_warning: 400fail_rcu_unlock:
401 rcu_read_unlock();
397 nfp_flower_cmsg_warn(app, "Requested route not found.\n"); 402 nfp_flower_cmsg_warn(app, "Requested route not found.\n");
398} 403}
399 404
diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c
index eed4fe3d871f..0fedd28fdb6e 100644
--- a/drivers/net/phy/aquantia_main.c
+++ b/drivers/net/phy/aquantia_main.c
@@ -487,6 +487,7 @@ static int aqr107_config_init(struct phy_device *phydev)
487 /* Check that the PHY interface type is compatible */ 487 /* Check that the PHY interface type is compatible */
488 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && 488 if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
489 phydev->interface != PHY_INTERFACE_MODE_2500BASEX && 489 phydev->interface != PHY_INTERFACE_MODE_2500BASEX &&
490 phydev->interface != PHY_INTERFACE_MODE_XGMII &&
490 phydev->interface != PHY_INTERFACE_MODE_10GKR) 491 phydev->interface != PHY_INTERFACE_MODE_10GKR)
491 return -ENODEV; 492 return -ENODEV;
492 493
diff --git a/drivers/net/ppp/ppp_deflate.c b/drivers/net/ppp/ppp_deflate.c
index b5edc7f96a39..685e875f5164 100644
--- a/drivers/net/ppp/ppp_deflate.c
+++ b/drivers/net/ppp/ppp_deflate.c
@@ -610,12 +610,20 @@ static struct compressor ppp_deflate_draft = {
610 610
611static int __init deflate_init(void) 611static int __init deflate_init(void)
612{ 612{
613 int answer = ppp_register_compressor(&ppp_deflate); 613 int rc;
614 if (answer == 0) 614
615 printk(KERN_INFO 615 rc = ppp_register_compressor(&ppp_deflate);
616 "PPP Deflate Compression module registered\n"); 616 if (rc)
617 ppp_register_compressor(&ppp_deflate_draft); 617 return rc;
618 return answer; 618
619 rc = ppp_register_compressor(&ppp_deflate_draft);
620 if (rc) {
621 ppp_unregister_compressor(&ppp_deflate);
622 return rc;
623 }
624
625 pr_info("PPP Deflate Compression module registered\n");
626 return 0;
619} 627}
620 628
621static void __exit deflate_cleanup(void) 629static void __exit deflate_cleanup(void)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index b86c5ce9a92a..7e44110746dd 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -320,7 +320,6 @@ static int aqc111_get_link_ksettings(struct net_device *net,
320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) 320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
321{ 321{
322 struct aqc111_data *aqc111_data = dev->driver_priv; 322 struct aqc111_data *aqc111_data = dev->driver_priv;
323 u32 phy_on_the_wire;
324 323
325 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 324 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
326 aqc111_data->phy_cfg |= AQ_PAUSE; 325 aqc111_data->phy_cfg |= AQ_PAUSE;
@@ -362,8 +361,7 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
362 } 361 }
363 } 362 }
364 363
365 phy_on_the_wire = aqc111_data->phy_cfg; 364 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg);
366 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &phy_on_the_wire);
367} 365}
368 366
369static int aqc111_set_link_ksettings(struct net_device *net, 367static int aqc111_set_link_ksettings(struct net_device *net,
@@ -439,7 +437,7 @@ static int aqc111_change_mtu(struct net_device *net, int new_mtu)
439 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 437 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
440 2, &reg16); 438 2, &reg16);
441 439
442 if (dev->net->mtu > 12500 && dev->net->mtu <= 16334) { 440 if (dev->net->mtu > 12500) {
443 memcpy(buf, &AQC111_BULKIN_SIZE[2], 5); 441 memcpy(buf, &AQC111_BULKIN_SIZE[2], 5);
444 /* RX bulk configuration */ 442 /* RX bulk configuration */
445 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, 443 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL,
@@ -453,10 +451,8 @@ static int aqc111_change_mtu(struct net_device *net, int new_mtu)
453 reg16 = 0x1020; 451 reg16 = 0x1020;
454 else if (dev->net->mtu <= 12500) 452 else if (dev->net->mtu <= 12500)
455 reg16 = 0x1420; 453 reg16 = 0x1420;
456 else if (dev->net->mtu <= 16334)
457 reg16 = 0x1A20;
458 else 454 else
459 return 0; 455 reg16 = 0x1A20;
460 456
461 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, 457 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW,
462 2, &reg16); 458 2, &reg16);
@@ -757,7 +753,6 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
757{ 753{
758 struct aqc111_data *aqc111_data = dev->driver_priv; 754 struct aqc111_data *aqc111_data = dev->driver_priv;
759 u16 reg16; 755 u16 reg16;
760 u32 phy_on_the_wire;
761 756
762 /* Force bz */ 757 /* Force bz */
763 reg16 = SFR_PHYPWR_RSTCTL_BZ; 758 reg16 = SFR_PHYPWR_RSTCTL_BZ;
@@ -771,9 +766,8 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
771 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 766 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
772 aqc111_data->phy_cfg |= AQ_LOW_POWER; 767 aqc111_data->phy_cfg |= AQ_LOW_POWER;
773 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; 768 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN;
774 phy_on_the_wire = aqc111_data->phy_cfg;
775 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, 769 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0,
776 &phy_on_the_wire); 770 &aqc111_data->phy_cfg);
777 771
778 kfree(aqc111_data); 772 kfree(aqc111_data);
779} 773}
@@ -996,7 +990,6 @@ static int aqc111_reset(struct usbnet *dev)
996{ 990{
997 struct aqc111_data *aqc111_data = dev->driver_priv; 991 struct aqc111_data *aqc111_data = dev->driver_priv;
998 u8 reg8 = 0; 992 u8 reg8 = 0;
999 u32 phy_on_the_wire;
1000 993
1001 dev->rx_urb_size = URB_SIZE; 994 dev->rx_urb_size = URB_SIZE;
1002 995
@@ -1009,9 +1002,8 @@ static int aqc111_reset(struct usbnet *dev)
1009 1002
1010 /* Power up ethernet PHY */ 1003 /* Power up ethernet PHY */
1011 aqc111_data->phy_cfg = AQ_PHY_POWER_EN; 1004 aqc111_data->phy_cfg = AQ_PHY_POWER_EN;
1012 phy_on_the_wire = aqc111_data->phy_cfg;
1013 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1005 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1014 &phy_on_the_wire); 1006 &aqc111_data->phy_cfg);
1015 1007
1016 /* Set the MAC address */ 1008 /* Set the MAC address */
1017 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, 1009 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN,
@@ -1042,7 +1034,6 @@ static int aqc111_stop(struct usbnet *dev)
1042{ 1034{
1043 struct aqc111_data *aqc111_data = dev->driver_priv; 1035 struct aqc111_data *aqc111_data = dev->driver_priv;
1044 u16 reg16 = 0; 1036 u16 reg16 = 0;
1045 u32 phy_on_the_wire;
1046 1037
1047 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 1038 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
1048 2, &reg16); 1039 2, &reg16);
@@ -1054,9 +1045,8 @@ static int aqc111_stop(struct usbnet *dev)
1054 1045
1055 /* Put PHY to low power*/ 1046 /* Put PHY to low power*/
1056 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1047 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1057 phy_on_the_wire = aqc111_data->phy_cfg;
1058 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1048 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1059 &phy_on_the_wire); 1049 &aqc111_data->phy_cfg);
1060 1050
1061 netif_carrier_off(dev->net); 1051 netif_carrier_off(dev->net);
1062 1052
@@ -1332,7 +1322,6 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1332 u16 temp_rx_ctrl = 0x00; 1322 u16 temp_rx_ctrl = 0x00;
1333 u16 reg16; 1323 u16 reg16;
1334 u8 reg8; 1324 u8 reg8;
1335 u32 phy_on_the_wire;
1336 1325
1337 usbnet_suspend(intf, message); 1326 usbnet_suspend(intf, message);
1338 1327
@@ -1404,14 +1393,12 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1404 1393
1405 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0, 1394 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0,
1406 WOL_CFG_SIZE, &wol_cfg); 1395 WOL_CFG_SIZE, &wol_cfg);
1407 phy_on_the_wire = aqc111_data->phy_cfg;
1408 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1396 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1409 &phy_on_the_wire); 1397 &aqc111_data->phy_cfg);
1410 } else { 1398 } else {
1411 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1399 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1412 phy_on_the_wire = aqc111_data->phy_cfg;
1413 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1400 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1414 &phy_on_the_wire); 1401 &aqc111_data->phy_cfg);
1415 1402
1416 /* Disable RX path */ 1403 /* Disable RX path */
1417 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, 1404 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC,
@@ -1428,7 +1415,7 @@ static int aqc111_resume(struct usb_interface *intf)
1428{ 1415{
1429 struct usbnet *dev = usb_get_intfdata(intf); 1416 struct usbnet *dev = usb_get_intfdata(intf);
1430 struct aqc111_data *aqc111_data = dev->driver_priv; 1417 struct aqc111_data *aqc111_data = dev->driver_priv;
1431 u16 reg16, oldreg16; 1418 u16 reg16;
1432 u8 reg8; 1419 u8 reg8;
1433 1420
1434 netif_carrier_off(dev->net); 1421 netif_carrier_off(dev->net);
@@ -1444,11 +1431,9 @@ static int aqc111_resume(struct usb_interface *intf)
1444 /* Configure RX control register => start operation */ 1431 /* Configure RX control register => start operation */
1445 reg16 = aqc111_data->rxctl; 1432 reg16 = aqc111_data->rxctl;
1446 reg16 &= ~SFR_RX_CTL_START; 1433 reg16 &= ~SFR_RX_CTL_START;
1447 /* needs to be saved in case endianness is swapped */
1448 oldreg16 = reg16;
1449 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16); 1434 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16);
1450 1435
1451 reg16 = oldreg16 | SFR_RX_CTL_START; 1436 reg16 |= SFR_RX_CTL_START;
1452 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16); 1437 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16);
1453 1438
1454 aqc111_set_phy_speed(dev, aqc111_data->autoneg, 1439 aqc111_set_phy_speed(dev, aqc111_data->autoneg,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 5c3ac97519b7..d9a6699abe59 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -1259,6 +1259,8 @@ static const struct usb_device_id products[] = {
1259 {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)}, /* Telit ME910 dual modem */ 1259 {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)}, /* Telit ME910 dual modem */
1260 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 1260 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
1261 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ 1261 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */
1262 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1260, 2)}, /* Telit LE910Cx */
1263 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1261, 2)}, /* Telit LE910Cx */
1262 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1900, 1)}, /* Telit LN940 series */ 1264 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1900, 1)}, /* Telit LN940 series */
1263 {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */ 1265 {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */
1264 {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */ 1266 {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index daf7908d1e35..84dd4a8980c5 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1008,6 +1008,7 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
1008 struct list_head *workspace; 1008 struct list_head *workspace;
1009 int ret; 1009 int ret;
1010 1010
1011 level = btrfs_compress_op[type]->set_level(level);
1011 workspace = get_workspace(type, level); 1012 workspace = get_workspace(type, level);
1012 ret = btrfs_compress_op[type]->compress_pages(workspace, mapping, 1013 ret = btrfs_compress_op[type]->compress_pages(workspace, mapping,
1013 start, pages, 1014 start, pages,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index f79e477a378e..1aee51a9f3bf 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -757,12 +757,14 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
757} 757}
758 758
759static void add_pinned_bytes(struct btrfs_fs_info *fs_info, 759static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
760 struct btrfs_ref *ref) 760 struct btrfs_ref *ref, int sign)
761{ 761{
762 struct btrfs_space_info *space_info; 762 struct btrfs_space_info *space_info;
763 s64 num_bytes = -ref->len; 763 s64 num_bytes;
764 u64 flags; 764 u64 flags;
765 765
766 ASSERT(sign == 1 || sign == -1);
767 num_bytes = sign * ref->len;
766 if (ref->type == BTRFS_REF_METADATA) { 768 if (ref->type == BTRFS_REF_METADATA) {
767 if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID) 769 if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
768 flags = BTRFS_BLOCK_GROUP_SYSTEM; 770 flags = BTRFS_BLOCK_GROUP_SYSTEM;
@@ -2063,7 +2065,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
2063 btrfs_ref_tree_mod(fs_info, generic_ref); 2065 btrfs_ref_tree_mod(fs_info, generic_ref);
2064 2066
2065 if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0) 2067 if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
2066 add_pinned_bytes(fs_info, generic_ref); 2068 add_pinned_bytes(fs_info, generic_ref, -1);
2067 2069
2068 return ret; 2070 return ret;
2069} 2071}
@@ -3882,8 +3884,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
3882 info->space_info_kobj, "%s", 3884 info->space_info_kobj, "%s",
3883 alloc_name(space_info->flags)); 3885 alloc_name(space_info->flags));
3884 if (ret) { 3886 if (ret) {
3885 percpu_counter_destroy(&space_info->total_bytes_pinned); 3887 kobject_put(&space_info->kobj);
3886 kfree(space_info);
3887 return ret; 3888 return ret;
3888 } 3889 }
3889 3890
@@ -7190,7 +7191,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
7190 } 7191 }
7191out: 7192out:
7192 if (pin) 7193 if (pin)
7193 add_pinned_bytes(fs_info, &generic_ref); 7194 add_pinned_bytes(fs_info, &generic_ref, 1);
7194 7195
7195 if (last_ref) { 7196 if (last_ref) {
7196 /* 7197 /*
@@ -7238,7 +7239,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
7238 btrfs_ref_tree_mod(fs_info, ref); 7239 btrfs_ref_tree_mod(fs_info, ref);
7239 7240
7240 if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0) 7241 if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
7241 add_pinned_bytes(fs_info, ref); 7242 add_pinned_bytes(fs_info, ref, 1);
7242 7243
7243 return ret; 7244 return ret;
7244} 7245}
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 7e85dca0e6f2..89f5be2bfb43 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2068,6 +2068,18 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
2068 u64 len; 2068 u64 len;
2069 2069
2070 /* 2070 /*
2071 * If the inode needs a full sync, make sure we use a full range to
2072 * avoid log tree corruption, due to hole detection racing with ordered
2073 * extent completion for adjacent ranges, and assertion failures during
2074 * hole detection.
2075 */
2076 if (test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
2077 &BTRFS_I(inode)->runtime_flags)) {
2078 start = 0;
2079 end = LLONG_MAX;
2080 }
2081
2082 /*
2071 * The range length can be represented by u64, we have to do the typecasts 2083 * The range length can be represented by u64, we have to do the typecasts
2072 * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync() 2084 * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync()
2073 */ 2085 */
@@ -2554,10 +2566,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2554 2566
2555 ret = btrfs_punch_hole_lock_range(inode, lockstart, lockend, 2567 ret = btrfs_punch_hole_lock_range(inode, lockstart, lockend,
2556 &cached_state); 2568 &cached_state);
2557 if (ret) { 2569 if (ret)
2558 inode_unlock(inode);
2559 goto out_only_mutex; 2570 goto out_only_mutex;
2560 }
2561 2571
2562 path = btrfs_alloc_path(); 2572 path = btrfs_alloc_path();
2563 if (!path) { 2573 if (!path) {
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index ca2716917e37..a9e2e66152ee 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -332,6 +332,7 @@ static int inherit_props(struct btrfs_trans_handle *trans,
332 struct btrfs_fs_info *fs_info = root->fs_info; 332 struct btrfs_fs_info *fs_info = root->fs_info;
333 int ret; 333 int ret;
334 int i; 334 int i;
335 bool need_reserve = false;
335 336
336 if (!test_bit(BTRFS_INODE_HAS_PROPS, 337 if (!test_bit(BTRFS_INODE_HAS_PROPS,
337 &BTRFS_I(parent)->runtime_flags)) 338 &BTRFS_I(parent)->runtime_flags))
@@ -357,11 +358,20 @@ static int inherit_props(struct btrfs_trans_handle *trans,
357 if (ret) 358 if (ret)
358 continue; 359 continue;
359 360
360 num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1); 361 /*
361 ret = btrfs_block_rsv_add(root, trans->block_rsv, 362 * Currently callers should be reserving 1 item for properties,
362 num_bytes, BTRFS_RESERVE_NO_FLUSH); 363 * since we only have 1 property that we currently support. If
363 if (ret) 364 * we add more in the future we need to try and reserve more
364 return ret; 365 * space for them. But we should also revisit how we do space
366 * reservations if we do add more properties in the future.
367 */
368 if (need_reserve) {
369 num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1);
370 ret = btrfs_block_rsv_add(root, trans->block_rsv,
371 num_bytes, BTRFS_RESERVE_NO_FLUSH);
372 if (ret)
373 return ret;
374 }
365 375
366 ret = btrfs_setxattr(trans, inode, h->xattr_name, value, 376 ret = btrfs_setxattr(trans, inode, h->xattr_name, value,
367 strlen(value), 0); 377 strlen(value), 0);
@@ -375,9 +385,13 @@ static int inherit_props(struct btrfs_trans_handle *trans,
375 &BTRFS_I(inode)->runtime_flags); 385 &BTRFS_I(inode)->runtime_flags);
376 } 386 }
377 387
378 btrfs_block_rsv_release(fs_info, trans->block_rsv, num_bytes); 388 if (need_reserve) {
379 if (ret) 389 btrfs_block_rsv_release(fs_info, trans->block_rsv,
380 return ret; 390 num_bytes);
391 if (ret)
392 return ret;
393 }
394 need_reserve = true;
381 } 395 }
382 396
383 return 0; 397 return 0;
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 1b9a5d0de139..22124122728c 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -132,10 +132,8 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
132 return -ENOMEM; 132 return -ENOMEM;
133 133
134 ret = btrfs_search_slot(trans, root, key, path, 0, 1); 134 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
135 if (ret < 0) { 135 if (ret < 0)
136 btrfs_abort_transaction(trans, ret);
137 goto out; 136 goto out;
138 }
139 137
140 if (ret > 0) { 138 if (ret > 0) {
141 btrfs_crit(fs_info, 139 btrfs_crit(fs_info,
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 5a5930e3d32b..2f078b77fe14 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -825,7 +825,12 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
825 fs_devs->fsid_kobj.kset = btrfs_kset; 825 fs_devs->fsid_kobj.kset = btrfs_kset;
826 error = kobject_init_and_add(&fs_devs->fsid_kobj, 826 error = kobject_init_and_add(&fs_devs->fsid_kobj,
827 &btrfs_ktype, parent, "%pU", fs_devs->fsid); 827 &btrfs_ktype, parent, "%pU", fs_devs->fsid);
828 return error; 828 if (error) {
829 kobject_put(&fs_devs->fsid_kobj);
830 return error;
831 }
832
833 return 0;
829} 834}
830 835
831int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) 836int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 748cd1598255..96fce4bef4e7 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -107,8 +107,26 @@ static void file_extent_err(const struct extent_buffer *eb, int slot,
107 (!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment))); \ 107 (!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment))); \
108}) 108})
109 109
110static u64 file_extent_end(struct extent_buffer *leaf,
111 struct btrfs_key *key,
112 struct btrfs_file_extent_item *extent)
113{
114 u64 end;
115 u64 len;
116
117 if (btrfs_file_extent_type(leaf, extent) == BTRFS_FILE_EXTENT_INLINE) {
118 len = btrfs_file_extent_ram_bytes(leaf, extent);
119 end = ALIGN(key->offset + len, leaf->fs_info->sectorsize);
120 } else {
121 len = btrfs_file_extent_num_bytes(leaf, extent);
122 end = key->offset + len;
123 }
124 return end;
125}
126
110static int check_extent_data_item(struct extent_buffer *leaf, 127static int check_extent_data_item(struct extent_buffer *leaf,
111 struct btrfs_key *key, int slot) 128 struct btrfs_key *key, int slot,
129 struct btrfs_key *prev_key)
112{ 130{
113 struct btrfs_fs_info *fs_info = leaf->fs_info; 131 struct btrfs_fs_info *fs_info = leaf->fs_info;
114 struct btrfs_file_extent_item *fi; 132 struct btrfs_file_extent_item *fi;
@@ -188,6 +206,28 @@ static int check_extent_data_item(struct extent_buffer *leaf,
188 CHECK_FE_ALIGNED(leaf, slot, fi, offset, sectorsize) || 206 CHECK_FE_ALIGNED(leaf, slot, fi, offset, sectorsize) ||
189 CHECK_FE_ALIGNED(leaf, slot, fi, num_bytes, sectorsize)) 207 CHECK_FE_ALIGNED(leaf, slot, fi, num_bytes, sectorsize))
190 return -EUCLEAN; 208 return -EUCLEAN;
209
210 /*
211 * Check that no two consecutive file extent items, in the same leaf,
212 * present ranges that overlap each other.
213 */
214 if (slot > 0 &&
215 prev_key->objectid == key->objectid &&
216 prev_key->type == BTRFS_EXTENT_DATA_KEY) {
217 struct btrfs_file_extent_item *prev_fi;
218 u64 prev_end;
219
220 prev_fi = btrfs_item_ptr(leaf, slot - 1,
221 struct btrfs_file_extent_item);
222 prev_end = file_extent_end(leaf, prev_key, prev_fi);
223 if (prev_end > key->offset) {
224 file_extent_err(leaf, slot - 1,
225"file extent end range (%llu) goes beyond start offset (%llu) of the next file extent",
226 prev_end, key->offset);
227 return -EUCLEAN;
228 }
229 }
230
191 return 0; 231 return 0;
192} 232}
193 233
@@ -774,14 +814,15 @@ static int check_inode_item(struct extent_buffer *leaf,
774 * Common point to switch the item-specific validation. 814 * Common point to switch the item-specific validation.
775 */ 815 */
776static int check_leaf_item(struct extent_buffer *leaf, 816static int check_leaf_item(struct extent_buffer *leaf,
777 struct btrfs_key *key, int slot) 817 struct btrfs_key *key, int slot,
818 struct btrfs_key *prev_key)
778{ 819{
779 int ret = 0; 820 int ret = 0;
780 struct btrfs_chunk *chunk; 821 struct btrfs_chunk *chunk;
781 822
782 switch (key->type) { 823 switch (key->type) {
783 case BTRFS_EXTENT_DATA_KEY: 824 case BTRFS_EXTENT_DATA_KEY:
784 ret = check_extent_data_item(leaf, key, slot); 825 ret = check_extent_data_item(leaf, key, slot, prev_key);
785 break; 826 break;
786 case BTRFS_EXTENT_CSUM_KEY: 827 case BTRFS_EXTENT_CSUM_KEY:
787 ret = check_csum_item(leaf, key, slot); 828 ret = check_csum_item(leaf, key, slot);
@@ -928,7 +969,7 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
928 * Check if the item size and content meet other 969 * Check if the item size and content meet other
929 * criteria 970 * criteria
930 */ 971 */
931 ret = check_leaf_item(leaf, &key, slot); 972 ret = check_leaf_item(leaf, &key, slot, &prev_key);
932 if (ret < 0) 973 if (ret < 0)
933 return ret; 974 return ret;
934 } 975 }
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 6adcd8a2c5c7..6c47f6ed3e94 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4182,6 +4182,7 @@ fill_holes:
4182 *last_extent, 0, 4182 *last_extent, 0,
4183 0, len, 0, len, 4183 0, len, 0, len,
4184 0, 0, 0); 4184 0, 0, 0);
4185 *last_extent += len;
4185 } 4186 }
4186 } 4187 }
4187 } 4188 }
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 59631dd0777c..4fb3aa2dc975 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -36,6 +36,7 @@ struct bpf_map_ops {
36 void (*map_free)(struct bpf_map *map); 36 void (*map_free)(struct bpf_map *map);
37 int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key); 37 int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key);
38 void (*map_release_uref)(struct bpf_map *map); 38 void (*map_release_uref)(struct bpf_map *map);
39 void *(*map_lookup_elem_sys_only)(struct bpf_map *map, void *key);
39 40
40 /* funcs callable from userspace and from eBPF programs */ 41 /* funcs callable from userspace and from eBPF programs */
41 void *(*map_lookup_elem)(struct bpf_map *map, void *key); 42 void *(*map_lookup_elem)(struct bpf_map *map, void *key);
diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h
index 0ca77dd1429c..cf226c190329 100644
--- a/include/linux/mlx5/eswitch.h
+++ b/include/linux/mlx5/eswitch.h
@@ -51,13 +51,13 @@ void mlx5_eswitch_register_vport_reps(struct mlx5_eswitch *esw,
51 u8 rep_type); 51 u8 rep_type);
52void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type); 52void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type);
53void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, 53void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
54 int vport, 54 u16 vport_num,
55 u8 rep_type); 55 u8 rep_type);
56struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw, 56struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw,
57 int vport); 57 u16 vport_num);
58void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type); 58void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type);
59u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw); 59u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw);
60struct mlx5_flow_handle * 60struct mlx5_flow_handle *
61mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, 61mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw,
62 int vport, u32 sqn); 62 u16 vport_num, u32 sqn);
63#endif 63#endif
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aab76fe..0f0346e6829c 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -22,7 +22,7 @@ static inline int of_get_phy_mode(struct device_node *np)
22 22
23static inline const void *of_get_mac_address(struct device_node *np) 23static inline const void *of_get_mac_address(struct device_node *np)
24{ 24{
25 return NULL; 25 return ERR_PTR(-ENODEV);
26} 26}
27 27
28static inline struct net_device *of_find_net_device_by_node(struct device_node *np) 28static inline struct net_device *of_find_net_device_by_node(struct device_node *np)
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index f7714d3b46bd..9f8bc06d4136 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -84,7 +84,7 @@ struct bucket_table {
84 84
85 struct lockdep_map dep_map; 85 struct lockdep_map dep_map;
86 86
87 struct rhash_lock_head __rcu *buckets[] ____cacheline_aligned_in_smp; 87 struct rhash_lock_head *buckets[] ____cacheline_aligned_in_smp;
88}; 88};
89 89
90/* 90/*
@@ -261,13 +261,13 @@ void rhashtable_free_and_destroy(struct rhashtable *ht,
261 void *arg); 261 void *arg);
262void rhashtable_destroy(struct rhashtable *ht); 262void rhashtable_destroy(struct rhashtable *ht);
263 263
264struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, 264struct rhash_lock_head **rht_bucket_nested(const struct bucket_table *tbl,
265 unsigned int hash); 265 unsigned int hash);
266struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tbl, 266struct rhash_lock_head **__rht_bucket_nested(const struct bucket_table *tbl,
267 unsigned int hash); 267 unsigned int hash);
268struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht, 268struct rhash_lock_head **rht_bucket_nested_insert(struct rhashtable *ht,
269 struct bucket_table *tbl, 269 struct bucket_table *tbl,
270 unsigned int hash); 270 unsigned int hash);
271 271
272#define rht_dereference(p, ht) \ 272#define rht_dereference(p, ht) \
273 rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht)) 273 rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht))
@@ -284,21 +284,21 @@ struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht,
284#define rht_entry(tpos, pos, member) \ 284#define rht_entry(tpos, pos, member) \
285 ({ tpos = container_of(pos, typeof(*tpos), member); 1; }) 285 ({ tpos = container_of(pos, typeof(*tpos), member); 1; })
286 286
287static inline struct rhash_lock_head __rcu *const *rht_bucket( 287static inline struct rhash_lock_head *const *rht_bucket(
288 const struct bucket_table *tbl, unsigned int hash) 288 const struct bucket_table *tbl, unsigned int hash)
289{ 289{
290 return unlikely(tbl->nest) ? rht_bucket_nested(tbl, hash) : 290 return unlikely(tbl->nest) ? rht_bucket_nested(tbl, hash) :
291 &tbl->buckets[hash]; 291 &tbl->buckets[hash];
292} 292}
293 293
294static inline struct rhash_lock_head __rcu **rht_bucket_var( 294static inline struct rhash_lock_head **rht_bucket_var(
295 struct bucket_table *tbl, unsigned int hash) 295 struct bucket_table *tbl, unsigned int hash)
296{ 296{
297 return unlikely(tbl->nest) ? __rht_bucket_nested(tbl, hash) : 297 return unlikely(tbl->nest) ? __rht_bucket_nested(tbl, hash) :
298 &tbl->buckets[hash]; 298 &tbl->buckets[hash];
299} 299}
300 300
301static inline struct rhash_lock_head __rcu **rht_bucket_insert( 301static inline struct rhash_lock_head **rht_bucket_insert(
302 struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash) 302 struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash)
303{ 303{
304 return unlikely(tbl->nest) ? rht_bucket_nested_insert(ht, tbl, hash) : 304 return unlikely(tbl->nest) ? rht_bucket_nested_insert(ht, tbl, hash) :
@@ -349,6 +349,12 @@ static inline void rht_unlock(struct bucket_table *tbl,
349 local_bh_enable(); 349 local_bh_enable();
350} 350}
351 351
352static inline struct rhash_head __rcu *__rht_ptr(
353 struct rhash_lock_head *const *bkt)
354{
355 return (struct rhash_head __rcu *)((unsigned long)*bkt & ~BIT(0));
356}
357
352/* 358/*
353 * Where 'bkt' is a bucket and might be locked: 359 * Where 'bkt' is a bucket and might be locked:
354 * rht_ptr() dereferences that pointer and clears the lock bit. 360 * rht_ptr() dereferences that pointer and clears the lock bit.
@@ -356,30 +362,30 @@ static inline void rht_unlock(struct bucket_table *tbl,
356 * access is guaranteed, such as when destroying the table. 362 * access is guaranteed, such as when destroying the table.
357 */ 363 */
358static inline struct rhash_head *rht_ptr( 364static inline struct rhash_head *rht_ptr(
359 struct rhash_lock_head __rcu * const *bkt, 365 struct rhash_lock_head *const *bkt,
360 struct bucket_table *tbl, 366 struct bucket_table *tbl,
361 unsigned int hash) 367 unsigned int hash)
362{ 368{
363 const struct rhash_lock_head *p = 369 struct rhash_head __rcu *p = __rht_ptr(bkt);
364 rht_dereference_bucket_rcu(*bkt, tbl, hash);
365 370
366 if ((((unsigned long)p) & ~BIT(0)) == 0) 371 if (!p)
367 return RHT_NULLS_MARKER(bkt); 372 return RHT_NULLS_MARKER(bkt);
368 return (void *)(((unsigned long)p) & ~BIT(0)); 373
374 return rht_dereference_bucket_rcu(p, tbl, hash);
369} 375}
370 376
371static inline struct rhash_head *rht_ptr_exclusive( 377static inline struct rhash_head *rht_ptr_exclusive(
372 struct rhash_lock_head __rcu * const *bkt) 378 struct rhash_lock_head *const *bkt)
373{ 379{
374 const struct rhash_lock_head *p = 380 struct rhash_head __rcu *p = __rht_ptr(bkt);
375 rcu_dereference_protected(*bkt, 1);
376 381
377 if (!p) 382 if (!p)
378 return RHT_NULLS_MARKER(bkt); 383 return RHT_NULLS_MARKER(bkt);
379 return (void *)(((unsigned long)p) & ~BIT(0)); 384
385 return rcu_dereference_protected(p, 1);
380} 386}
381 387
382static inline void rht_assign_locked(struct rhash_lock_head __rcu **bkt, 388static inline void rht_assign_locked(struct rhash_lock_head **bkt,
383 struct rhash_head *obj) 389 struct rhash_head *obj)
384{ 390{
385 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt; 391 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt;
@@ -390,7 +396,7 @@ static inline void rht_assign_locked(struct rhash_lock_head __rcu **bkt,
390} 396}
391 397
392static inline void rht_assign_unlock(struct bucket_table *tbl, 398static inline void rht_assign_unlock(struct bucket_table *tbl,
393 struct rhash_lock_head __rcu **bkt, 399 struct rhash_lock_head **bkt,
394 struct rhash_head *obj) 400 struct rhash_head *obj)
395{ 401{
396 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt; 402 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt;
@@ -587,7 +593,7 @@ static inline struct rhash_head *__rhashtable_lookup(
587 .ht = ht, 593 .ht = ht,
588 .key = key, 594 .key = key,
589 }; 595 };
590 struct rhash_lock_head __rcu * const *bkt; 596 struct rhash_lock_head *const *bkt;
591 struct bucket_table *tbl; 597 struct bucket_table *tbl;
592 struct rhash_head *he; 598 struct rhash_head *he;
593 unsigned int hash; 599 unsigned int hash;
@@ -703,7 +709,7 @@ static inline void *__rhashtable_insert_fast(
703 .ht = ht, 709 .ht = ht,
704 .key = key, 710 .key = key,
705 }; 711 };
706 struct rhash_lock_head __rcu **bkt; 712 struct rhash_lock_head **bkt;
707 struct rhash_head __rcu **pprev; 713 struct rhash_head __rcu **pprev;
708 struct bucket_table *tbl; 714 struct bucket_table *tbl;
709 struct rhash_head *head; 715 struct rhash_head *head;
@@ -989,7 +995,7 @@ static inline int __rhashtable_remove_fast_one(
989 struct rhash_head *obj, const struct rhashtable_params params, 995 struct rhash_head *obj, const struct rhashtable_params params,
990 bool rhlist) 996 bool rhlist)
991{ 997{
992 struct rhash_lock_head __rcu **bkt; 998 struct rhash_lock_head **bkt;
993 struct rhash_head __rcu **pprev; 999 struct rhash_head __rcu **pprev;
994 struct rhash_head *he; 1000 struct rhash_head *he;
995 unsigned int hash; 1001 unsigned int hash;
@@ -1141,7 +1147,7 @@ static inline int __rhashtable_replace_fast(
1141 struct rhash_head *obj_old, struct rhash_head *obj_new, 1147 struct rhash_head *obj_old, struct rhash_head *obj_new,
1142 const struct rhashtable_params params) 1148 const struct rhashtable_params params)
1143{ 1149{
1144 struct rhash_lock_head __rcu **bkt; 1150 struct rhash_lock_head **bkt;
1145 struct rhash_head __rcu **pprev; 1151 struct rhash_head __rcu **pprev;
1146 struct rhash_head *he; 1152 struct rhash_head *he;
1147 unsigned int hash; 1153 unsigned int hash;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6d58fa8a65fd..2ee5e63195c0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1434,10 +1434,12 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy)
1434 struct ubuf_info *uarg = skb_zcopy(skb); 1434 struct ubuf_info *uarg = skb_zcopy(skb);
1435 1435
1436 if (uarg) { 1436 if (uarg) {
1437 if (uarg->callback == sock_zerocopy_callback) { 1437 if (skb_zcopy_is_nouarg(skb)) {
1438 /* no notification callback */
1439 } else if (uarg->callback == sock_zerocopy_callback) {
1438 uarg->zerocopy = uarg->zerocopy && zerocopy; 1440 uarg->zerocopy = uarg->zerocopy && zerocopy;
1439 sock_zerocopy_put(uarg); 1441 sock_zerocopy_put(uarg);
1440 } else if (!skb_zcopy_is_nouarg(skb)) { 1442 } else {
1441 uarg->callback(uarg, zerocopy); 1443 uarg->callback(uarg, zerocopy);
1442 } 1444 }
1443 1445
@@ -2691,7 +2693,8 @@ static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
2691{ 2693{
2692 if (likely(!skb_zcopy(skb))) 2694 if (likely(!skb_zcopy(skb)))
2693 return 0; 2695 return 0;
2694 if (skb_uarg(skb)->callback == sock_zerocopy_callback) 2696 if (!skb_zcopy_is_nouarg(skb) &&
2697 skb_uarg(skb)->callback == sock_zerocopy_callback)
2695 return 0; 2698 return 0;
2696 return skb_copy_ubufs(skb, gfp_mask); 2699 return skb_copy_ubufs(skb, gfp_mask);
2697} 2700}
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 6200900434e1..a2df99f9b196 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -71,6 +71,8 @@ void flow_rule_match_eth_addrs(const struct flow_rule *rule,
71 struct flow_match_eth_addrs *out); 71 struct flow_match_eth_addrs *out);
72void flow_rule_match_vlan(const struct flow_rule *rule, 72void flow_rule_match_vlan(const struct flow_rule *rule,
73 struct flow_match_vlan *out); 73 struct flow_match_vlan *out);
74void flow_rule_match_cvlan(const struct flow_rule *rule,
75 struct flow_match_vlan *out);
74void flow_rule_match_ipv4_addrs(const struct flow_rule *rule, 76void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
75 struct flow_match_ipv4_addrs *out); 77 struct flow_match_ipv4_addrs *out);
76void flow_rule_match_ipv6_addrs(const struct flow_rule *rule, 78void flow_rule_match_ipv6_addrs(const struct flow_rule *rule,
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 40105738e2f6..525f701653ca 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -167,7 +167,8 @@ struct fib6_info {
167 dst_nocount:1, 167 dst_nocount:1,
168 dst_nopolicy:1, 168 dst_nopolicy:1,
169 dst_host:1, 169 dst_host:1,
170 unused:3; 170 fib6_destroying:1,
171 unused:2;
171 172
172 struct fib6_nh fib6_nh; 173 struct fib6_nh fib6_nh;
173 struct rcu_head rcu; 174 struct rcu_head rcu;
diff --git a/include/net/sock.h b/include/net/sock.h
index 4d208c0f9c14..0680fa988497 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1473,7 +1473,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
1473 sock_set_flag(sk, SOCK_QUEUE_SHRUNK); 1473 sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
1474 sk->sk_wmem_queued -= skb->truesize; 1474 sk->sk_wmem_queued -= skb->truesize;
1475 sk_mem_uncharge(sk, skb->truesize); 1475 sk_mem_uncharge(sk, skb->truesize);
1476 if (!sk->sk_tx_skb_cache) { 1476 if (!sk->sk_tx_skb_cache && !skb_cloned(skb)) {
1477 skb_zcopy_clear(skb, true); 1477 skb_zcopy_clear(skb, true);
1478 sk->sk_tx_skb_cache = skb; 1478 sk->sk_tx_skb_cache = skb;
1479 return; 1479 return;
diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
index 9310652ca4f9..63ae4a39e58b 100644
--- a/include/uapi/linux/btf.h
+++ b/include/uapi/linux/btf.h
@@ -83,7 +83,7 @@ struct btf_type {
83 * is the 32 bits arrangement: 83 * is the 32 bits arrangement:
84 */ 84 */
85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
86#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 86#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
88 88
89/* Attributes stored in the BTF_INT_ENCODING */ 89/* Attributes stored in the BTF_INT_ENCODING */
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 191b79948424..1e525d70f833 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -164,6 +164,9 @@ static void dev_map_free(struct bpf_map *map)
164 bpf_clear_redirect_map(map); 164 bpf_clear_redirect_map(map);
165 synchronize_rcu(); 165 synchronize_rcu();
166 166
167 /* Make sure prior __dev_map_entry_free() have completed. */
168 rcu_barrier();
169
167 /* To ensure all pending flush operations have completed wait for flush 170 /* To ensure all pending flush operations have completed wait for flush
168 * bitmap to indicate all flush_needed bits to be zero on _all_ cpus. 171 * bitmap to indicate all flush_needed bits to be zero on _all_ cpus.
169 * Because the above synchronize_rcu() ensures the map is disconnected 172 * Because the above synchronize_rcu() ensures the map is disconnected
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 192d32e77db3..0f2708fde5f7 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -527,18 +527,30 @@ static u32 htab_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
527 return insn - insn_buf; 527 return insn - insn_buf;
528} 528}
529 529
530static void *htab_lru_map_lookup_elem(struct bpf_map *map, void *key) 530static __always_inline void *__htab_lru_map_lookup_elem(struct bpf_map *map,
531 void *key, const bool mark)
531{ 532{
532 struct htab_elem *l = __htab_map_lookup_elem(map, key); 533 struct htab_elem *l = __htab_map_lookup_elem(map, key);
533 534
534 if (l) { 535 if (l) {
535 bpf_lru_node_set_ref(&l->lru_node); 536 if (mark)
537 bpf_lru_node_set_ref(&l->lru_node);
536 return l->key + round_up(map->key_size, 8); 538 return l->key + round_up(map->key_size, 8);
537 } 539 }
538 540
539 return NULL; 541 return NULL;
540} 542}
541 543
544static void *htab_lru_map_lookup_elem(struct bpf_map *map, void *key)
545{
546 return __htab_lru_map_lookup_elem(map, key, true);
547}
548
549static void *htab_lru_map_lookup_elem_sys(struct bpf_map *map, void *key)
550{
551 return __htab_lru_map_lookup_elem(map, key, false);
552}
553
542static u32 htab_lru_map_gen_lookup(struct bpf_map *map, 554static u32 htab_lru_map_gen_lookup(struct bpf_map *map,
543 struct bpf_insn *insn_buf) 555 struct bpf_insn *insn_buf)
544{ 556{
@@ -1250,6 +1262,7 @@ const struct bpf_map_ops htab_lru_map_ops = {
1250 .map_free = htab_map_free, 1262 .map_free = htab_map_free,
1251 .map_get_next_key = htab_map_get_next_key, 1263 .map_get_next_key = htab_map_get_next_key,
1252 .map_lookup_elem = htab_lru_map_lookup_elem, 1264 .map_lookup_elem = htab_lru_map_lookup_elem,
1265 .map_lookup_elem_sys_only = htab_lru_map_lookup_elem_sys,
1253 .map_update_elem = htab_lru_map_update_elem, 1266 .map_update_elem = htab_lru_map_update_elem,
1254 .map_delete_elem = htab_lru_map_delete_elem, 1267 .map_delete_elem = htab_lru_map_delete_elem,
1255 .map_gen_lookup = htab_lru_map_gen_lookup, 1268 .map_gen_lookup = htab_lru_map_gen_lookup,
@@ -1281,7 +1294,6 @@ static void *htab_lru_percpu_map_lookup_elem(struct bpf_map *map, void *key)
1281 1294
1282int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value) 1295int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value)
1283{ 1296{
1284 struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
1285 struct htab_elem *l; 1297 struct htab_elem *l;
1286 void __percpu *pptr; 1298 void __percpu *pptr;
1287 int ret = -ENOENT; 1299 int ret = -ENOENT;
@@ -1297,8 +1309,9 @@ int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value)
1297 l = __htab_map_lookup_elem(map, key); 1309 l = __htab_map_lookup_elem(map, key);
1298 if (!l) 1310 if (!l)
1299 goto out; 1311 goto out;
1300 if (htab_is_lru(htab)) 1312 /* We do not mark LRU map element here in order to not mess up
1301 bpf_lru_node_set_ref(&l->lru_node); 1313 * eviction heuristics when user space does a map walk.
1314 */
1302 pptr = htab_elem_get_ptr(l, map->key_size); 1315 pptr = htab_elem_get_ptr(l, map->key_size);
1303 for_each_possible_cpu(cpu) { 1316 for_each_possible_cpu(cpu) {
1304 bpf_long_memcpy(value + off, 1317 bpf_long_memcpy(value + off,
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index bc53e5b20ddc..84a80b02db99 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -518,7 +518,7 @@ out:
518static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type) 518static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type)
519{ 519{
520 struct bpf_prog *prog; 520 struct bpf_prog *prog;
521 int ret = inode_permission(inode, MAY_READ | MAY_WRITE); 521 int ret = inode_permission(inode, MAY_READ);
522 if (ret) 522 if (ret)
523 return ERR_PTR(ret); 523 return ERR_PTR(ret);
524 524
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ad3ccf82f31d..cb5440b02e82 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -808,7 +808,10 @@ static int map_lookup_elem(union bpf_attr *attr)
808 err = map->ops->map_peek_elem(map, value); 808 err = map->ops->map_peek_elem(map, value);
809 } else { 809 } else {
810 rcu_read_lock(); 810 rcu_read_lock();
811 ptr = map->ops->map_lookup_elem(map, key); 811 if (map->ops->map_lookup_elem_sys_only)
812 ptr = map->ops->map_lookup_elem_sys_only(map, key);
813 else
814 ptr = map->ops->map_lookup_elem(map, key);
812 if (IS_ERR(ptr)) { 815 if (IS_ERR(ptr)) {
813 err = PTR_ERR(ptr); 816 err = PTR_ERR(ptr);
814 } else if (!ptr) { 817 } else if (!ptr) {
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index b496ffdf5f36..f92d6ad5e080 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1297,7 +1297,8 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
1297} 1297}
1298 1298
1299#ifdef CONFIG_MODULES 1299#ifdef CONFIG_MODULES
1300int bpf_event_notify(struct notifier_block *nb, unsigned long op, void *module) 1300static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
1301 void *module)
1301{ 1302{
1302 struct bpf_trace_module *btm, *tmp; 1303 struct bpf_trace_module *btm, *tmp;
1303 struct module *mod = module; 1304 struct module *mod = module;
@@ -1336,7 +1337,7 @@ static struct notifier_block bpf_module_nb = {
1336 .notifier_call = bpf_event_notify, 1337 .notifier_call = bpf_event_notify,
1337}; 1338};
1338 1339
1339int __init bpf_event_init(void) 1340static int __init bpf_event_init(void)
1340{ 1341{
1341 register_module_notifier(&bpf_module_nb); 1342 register_module_notifier(&bpf_module_nb);
1342 return 0; 1343 return 0;
diff --git a/lib/random32.c b/lib/random32.c
index 4aaa76404d56..763b920a6206 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -171,9 +171,9 @@ static void prandom_seed_early(struct rnd_state *state, u32 seed,
171 171
172/** 172/**
173 * prandom_seed - add entropy to pseudo random number generator 173 * prandom_seed - add entropy to pseudo random number generator
174 * @seed: seed value 174 * @entropy: entropy value
175 * 175 *
176 * Add some additional seeding to the prandom pool. 176 * Add some additional entropy to the prandom pool.
177 */ 177 */
178void prandom_seed(u32 entropy) 178void prandom_seed(u32 entropy)
179{ 179{
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 6529fe1b45c1..935ec80f213f 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -34,7 +34,7 @@
34 34
35union nested_table { 35union nested_table {
36 union nested_table __rcu *table; 36 union nested_table __rcu *table;
37 struct rhash_lock_head __rcu *bucket; 37 struct rhash_lock_head *bucket;
38}; 38};
39 39
40static u32 head_hashfn(struct rhashtable *ht, 40static u32 head_hashfn(struct rhashtable *ht,
@@ -131,7 +131,7 @@ static union nested_table *nested_table_alloc(struct rhashtable *ht,
131 INIT_RHT_NULLS_HEAD(ntbl[i].bucket); 131 INIT_RHT_NULLS_HEAD(ntbl[i].bucket);
132 } 132 }
133 133
134 if (cmpxchg(prev, NULL, ntbl) == NULL) 134 if (cmpxchg((union nested_table **)prev, NULL, ntbl) == NULL)
135 return ntbl; 135 return ntbl;
136 /* Raced with another thread. */ 136 /* Raced with another thread. */
137 kfree(ntbl); 137 kfree(ntbl);
@@ -216,7 +216,7 @@ static struct bucket_table *rhashtable_last_table(struct rhashtable *ht,
216} 216}
217 217
218static int rhashtable_rehash_one(struct rhashtable *ht, 218static int rhashtable_rehash_one(struct rhashtable *ht,
219 struct rhash_lock_head __rcu **bkt, 219 struct rhash_lock_head **bkt,
220 unsigned int old_hash) 220 unsigned int old_hash)
221{ 221{
222 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); 222 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht);
@@ -269,7 +269,7 @@ static int rhashtable_rehash_chain(struct rhashtable *ht,
269 unsigned int old_hash) 269 unsigned int old_hash)
270{ 270{
271 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); 271 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht);
272 struct rhash_lock_head __rcu **bkt = rht_bucket_var(old_tbl, old_hash); 272 struct rhash_lock_head **bkt = rht_bucket_var(old_tbl, old_hash);
273 int err; 273 int err;
274 274
275 if (!bkt) 275 if (!bkt)
@@ -296,7 +296,8 @@ static int rhashtable_rehash_attach(struct rhashtable *ht,
296 * rcu_assign_pointer(). 296 * rcu_assign_pointer().
297 */ 297 */
298 298
299 if (cmpxchg(&old_tbl->future_tbl, NULL, new_tbl) != NULL) 299 if (cmpxchg((struct bucket_table **)&old_tbl->future_tbl, NULL,
300 new_tbl) != NULL)
300 return -EEXIST; 301 return -EEXIST;
301 302
302 return 0; 303 return 0;
@@ -478,7 +479,7 @@ fail:
478} 479}
479 480
480static void *rhashtable_lookup_one(struct rhashtable *ht, 481static void *rhashtable_lookup_one(struct rhashtable *ht,
481 struct rhash_lock_head __rcu **bkt, 482 struct rhash_lock_head **bkt,
482 struct bucket_table *tbl, unsigned int hash, 483 struct bucket_table *tbl, unsigned int hash,
483 const void *key, struct rhash_head *obj) 484 const void *key, struct rhash_head *obj)
484{ 485{
@@ -529,7 +530,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht,
529} 530}
530 531
531static struct bucket_table *rhashtable_insert_one(struct rhashtable *ht, 532static struct bucket_table *rhashtable_insert_one(struct rhashtable *ht,
532 struct rhash_lock_head __rcu **bkt, 533 struct rhash_lock_head **bkt,
533 struct bucket_table *tbl, 534 struct bucket_table *tbl,
534 unsigned int hash, 535 unsigned int hash,
535 struct rhash_head *obj, 536 struct rhash_head *obj,
@@ -584,7 +585,7 @@ static void *rhashtable_try_insert(struct rhashtable *ht, const void *key,
584{ 585{
585 struct bucket_table *new_tbl; 586 struct bucket_table *new_tbl;
586 struct bucket_table *tbl; 587 struct bucket_table *tbl;
587 struct rhash_lock_head __rcu **bkt; 588 struct rhash_lock_head **bkt;
588 unsigned int hash; 589 unsigned int hash;
589 void *data; 590 void *data;
590 591
@@ -1166,8 +1167,8 @@ void rhashtable_destroy(struct rhashtable *ht)
1166} 1167}
1167EXPORT_SYMBOL_GPL(rhashtable_destroy); 1168EXPORT_SYMBOL_GPL(rhashtable_destroy);
1168 1169
1169struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tbl, 1170struct rhash_lock_head **__rht_bucket_nested(const struct bucket_table *tbl,
1170 unsigned int hash) 1171 unsigned int hash)
1171{ 1172{
1172 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); 1173 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *));
1173 unsigned int index = hash & ((1 << tbl->nest) - 1); 1174 unsigned int index = hash & ((1 << tbl->nest) - 1);
@@ -1195,10 +1196,10 @@ struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tb
1195} 1196}
1196EXPORT_SYMBOL_GPL(__rht_bucket_nested); 1197EXPORT_SYMBOL_GPL(__rht_bucket_nested);
1197 1198
1198struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, 1199struct rhash_lock_head **rht_bucket_nested(const struct bucket_table *tbl,
1199 unsigned int hash) 1200 unsigned int hash)
1200{ 1201{
1201 static struct rhash_lock_head __rcu *rhnull; 1202 static struct rhash_lock_head *rhnull;
1202 1203
1203 if (!rhnull) 1204 if (!rhnull)
1204 INIT_RHT_NULLS_HEAD(rhnull); 1205 INIT_RHT_NULLS_HEAD(rhnull);
@@ -1206,9 +1207,9 @@ struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl,
1206} 1207}
1207EXPORT_SYMBOL_GPL(rht_bucket_nested); 1208EXPORT_SYMBOL_GPL(rht_bucket_nested);
1208 1209
1209struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht, 1210struct rhash_lock_head **rht_bucket_nested_insert(struct rhashtable *ht,
1210 struct bucket_table *tbl, 1211 struct bucket_table *tbl,
1211 unsigned int hash) 1212 unsigned int hash)
1212{ 1213{
1213 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); 1214 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *));
1214 unsigned int index = hash & ((1 << tbl->nest) - 1); 1215 unsigned int index = hash & ((1 << tbl->nest) - 1);
diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c
index 7aae0b56829e..cce839bf49f7 100644
--- a/net/caif/cfdbgl.c
+++ b/net/caif/cfdbgl.c
@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
26 cfsrvl_init(dbg, channel_id, dev_info, false); 26 cfsrvl_init(dbg, channel_id, dev_info, false);
27 dbg->layer.receive = cfdbgl_receive; 27 dbg->layer.receive = cfdbgl_receive;
28 dbg->layer.transmit = cfdbgl_transmit; 28 dbg->layer.transmit = cfdbgl_transmit;
29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); 29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ, "dbg%d", channel_id);
30 return &dbg->layer; 30 return &dbg->layer;
31} 31}
32 32
diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c
index 3bdddb32d55a..58fdb99a390f 100644
--- a/net/caif/cfdgml.c
+++ b/net/caif/cfdgml.c
@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(dgm, channel_id, dev_info, true); 33 cfsrvl_init(dgm, channel_id, dev_info, true);
34 dgm->layer.receive = cfdgml_receive; 34 dgm->layer.receive = cfdgml_receive;
35 dgm->layer.transmit = cfdgml_transmit; 35 dgm->layer.transmit = cfdgml_transmit;
36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id); 36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ, "dgm%d", channel_id);
37 dgm->layer.name[CAIF_LAYER_NAME_SZ - 1] = '\0';
38 return &dgm->layer; 37 return &dgm->layer;
39} 38}
40 39
diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c
index 1728fa4471cf..be7c43a92ead 100644
--- a/net/caif/cfutill.c
+++ b/net/caif/cfutill.c
@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(util, channel_id, dev_info, true); 33 cfsrvl_init(util, channel_id, dev_info, true);
34 util->layer.receive = cfutill_receive; 34 util->layer.receive = cfutill_receive;
35 util->layer.transmit = cfutill_transmit; 35 util->layer.transmit = cfutill_transmit;
36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); 36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
37 return &util->layer; 37 return &util->layer;
38} 38}
39 39
diff --git a/net/caif/cfveil.c b/net/caif/cfveil.c
index 262224581efa..35dd3a600dd1 100644
--- a/net/caif/cfveil.c
+++ b/net/caif/cfveil.c
@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
32 cfsrvl_init(vei, channel_id, dev_info, true); 32 cfsrvl_init(vei, channel_id, dev_info, true);
33 vei->layer.receive = cfvei_receive; 33 vei->layer.receive = cfvei_receive;
34 vei->layer.transmit = cfvei_transmit; 34 vei->layer.transmit = cfvei_transmit;
35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id); 35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
36 return &vei->layer; 36 return &vei->layer;
37} 37}
38 38
diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c
index b3b110e8a350..73615e3b3b58 100644
--- a/net/caif/cfvidl.c
+++ b/net/caif/cfvidl.c
@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
29 cfsrvl_init(vid, channel_id, dev_info, false); 29 cfsrvl_init(vid, channel_id, dev_info, false);
30 vid->layer.receive = cfvidl_receive; 30 vid->layer.receive = cfvidl_receive;
31 vid->layer.transmit = cfvidl_transmit; 31 vid->layer.transmit = cfvidl_transmit;
32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); 32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ, "vid1");
33 return &vid->layer; 33 return &vid->layer;
34} 34}
35 35
diff --git a/net/core/dev.c b/net/core/dev.c
index 108ac8137b9b..b6b8505cfb3e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8927,7 +8927,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
8927 8927
8928 refcnt = netdev_refcnt_read(dev); 8928 refcnt = netdev_refcnt_read(dev);
8929 8929
8930 if (time_after(jiffies, warning_time + 10 * HZ)) { 8930 if (refcnt && time_after(jiffies, warning_time + 10 * HZ)) {
8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n", 8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
8932 dev->name, refcnt); 8932 dev->name, refcnt);
8933 warning_time = jiffies; 8933 warning_time = jiffies;
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index c3a00eac4804..5ce7d47a960e 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -54,6 +54,13 @@ void flow_rule_match_vlan(const struct flow_rule *rule,
54} 54}
55EXPORT_SYMBOL(flow_rule_match_vlan); 55EXPORT_SYMBOL(flow_rule_match_vlan);
56 56
57void flow_rule_match_cvlan(const struct flow_rule *rule,
58 struct flow_match_vlan *out)
59{
60 FLOW_DISSECTOR_MATCH(rule, FLOW_DISSECTOR_KEY_CVLAN, out);
61}
62EXPORT_SYMBOL(flow_rule_match_cvlan);
63
57void flow_rule_match_ipv4_addrs(const struct flow_rule *rule, 64void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
58 struct flow_match_ipv4_addrs *out) 65 struct flow_match_ipv4_addrs *out)
59{ 66{
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2bd12afb9297..adcc045952c2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1496,14 +1496,15 @@ static int put_master_ifindex(struct sk_buff *skb, struct net_device *dev)
1496 return ret; 1496 return ret;
1497} 1497}
1498 1498
1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev) 1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev,
1500 bool force)
1500{ 1501{
1501 int ifindex = dev_get_iflink(dev); 1502 int ifindex = dev_get_iflink(dev);
1502 1503
1503 if (dev->ifindex == ifindex) 1504 if (force || dev->ifindex != ifindex)
1504 return 0; 1505 return nla_put_u32(skb, IFLA_LINK, ifindex);
1505 1506
1506 return nla_put_u32(skb, IFLA_LINK, ifindex); 1507 return 0;
1507} 1508}
1508 1509
1509static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb, 1510static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb,
@@ -1520,6 +1521,8 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1520 const struct net_device *dev, 1521 const struct net_device *dev,
1521 struct net *src_net) 1522 struct net *src_net)
1522{ 1523{
1524 bool put_iflink = false;
1525
1523 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) { 1526 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) {
1524 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev); 1527 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
1525 1528
@@ -1528,10 +1531,12 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1528 1531
1529 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id)) 1532 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
1530 return -EMSGSIZE; 1533 return -EMSGSIZE;
1534
1535 put_iflink = true;
1531 } 1536 }
1532 } 1537 }
1533 1538
1534 return 0; 1539 return nla_put_iflink(skb, dev, put_iflink);
1535} 1540}
1536 1541
1537static int rtnl_fill_link_af(struct sk_buff *skb, 1542static int rtnl_fill_link_af(struct sk_buff *skb,
@@ -1617,7 +1622,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
1617#ifdef CONFIG_RPS 1622#ifdef CONFIG_RPS
1618 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1623 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
1619#endif 1624#endif
1620 nla_put_iflink(skb, dev) ||
1621 put_master_ifindex(skb, dev) || 1625 put_master_ifindex(skb, dev) ||
1622 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1626 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
1623 (dev->qdisc && 1627 (dev->qdisc &&
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index cc94d921476c..93bffaad2135 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -411,6 +411,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb)
411 sk_mem_charge(sk, skb->len); 411 sk_mem_charge(sk, skb->len);
412 copied = skb->len; 412 copied = skb->len;
413 msg->sg.start = 0; 413 msg->sg.start = 0;
414 msg->sg.size = copied;
414 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge; 415 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge;
415 msg->skb = skb; 416 msg->skb = skb;
416 417
@@ -554,8 +555,10 @@ static void sk_psock_destroy_deferred(struct work_struct *gc)
554 struct sk_psock *psock = container_of(gc, struct sk_psock, gc); 555 struct sk_psock *psock = container_of(gc, struct sk_psock, gc);
555 556
556 /* No sk_callback_lock since already detached. */ 557 /* No sk_callback_lock since already detached. */
557 strp_stop(&psock->parser.strp); 558
558 strp_done(&psock->parser.strp); 559 /* Parser has been stopped */
560 if (psock->progs.skb_parser)
561 strp_done(&psock->parser.strp);
559 562
560 cancel_work_sync(&psock->work); 563 cancel_work_sync(&psock->work);
561 564
diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c
index 15427163a041..0480918bfc7c 100644
--- a/net/ipv4/bpfilter/sockopt.c
+++ b/net/ipv4/bpfilter/sockopt.c
@@ -30,13 +30,11 @@ static int bpfilter_mbox_request(struct sock *sk, int optname,
30 mutex_lock(&bpfilter_ops.lock); 30 mutex_lock(&bpfilter_ops.lock);
31 if (!bpfilter_ops.sockopt) { 31 if (!bpfilter_ops.sockopt) {
32 mutex_unlock(&bpfilter_ops.lock); 32 mutex_unlock(&bpfilter_ops.lock);
33 err = request_module("bpfilter"); 33 request_module("bpfilter");
34 mutex_lock(&bpfilter_ops.lock); 34 mutex_lock(&bpfilter_ops.lock);
35 35
36 if (err)
37 goto out;
38 if (!bpfilter_ops.sockopt) { 36 if (!bpfilter_ops.sockopt) {
39 err = -ECHILD; 37 err = -ENOPROTOOPT;
40 goto out; 38 goto out;
41 } 39 }
42 } 40 }
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 7ccb5f87f70b..834be7daeb32 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1113,7 +1113,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1113 __u16 srcp = ntohs(inet->inet_sport); 1113 __u16 srcp = ntohs(inet->inet_sport);
1114 1114
1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
1117 bucket, src, srcp, dest, destp, sp->sk_state, 1117 bucket, src, srcp, dest, destp, sp->sk_state,
1118 sk_wmem_alloc_get(sp), 1118 sk_wmem_alloc_get(sp),
1119 sk_rmem_alloc_get(sp), 1119 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index dc91c27bb788..0e482f07b37f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1076,7 +1076,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
1076 srcp = inet->inet_num; 1076 srcp = inet->inet_num;
1077 1077
1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X" 1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1080 i, src, srcp, dest, destp, sp->sk_state, 1080 i, src, srcp, dest, destp, sp->sk_state,
1081 sk_wmem_alloc_get(sp), 1081 sk_wmem_alloc_get(sp),
1082 sk_rmem_alloc_get(sp), 1082 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1fa15beb8380..53d61ca3ac4b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -855,7 +855,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
855 855
856 if (likely(!size)) { 856 if (likely(!size)) {
857 skb = sk->sk_tx_skb_cache; 857 skb = sk->sk_tx_skb_cache;
858 if (skb && !skb_cloned(skb)) { 858 if (skb) {
859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); 859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
860 sk->sk_tx_skb_cache = NULL; 860 sk->sk_tx_skb_cache = NULL;
861 pskb_trim(skb, 0); 861 pskb_trim(skb, 0);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 1bb7321a256d..3d1e15401384 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -27,7 +27,10 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
27 int flags, long timeo, int *err) 27 int flags, long timeo, int *err)
28{ 28{
29 DEFINE_WAIT_FUNC(wait, woken_wake_function); 29 DEFINE_WAIT_FUNC(wait, woken_wake_function);
30 int ret; 30 int ret = 0;
31
32 if (!timeo)
33 return ret;
31 34
32 add_wait_queue(sk_sleep(sk), &wait); 35 add_wait_queue(sk_sleep(sk), &wait);
33 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 36 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
@@ -528,8 +531,6 @@ static void tcp_bpf_remove(struct sock *sk, struct sk_psock *psock)
528{ 531{
529 struct sk_psock_link *link; 532 struct sk_psock_link *link;
530 533
531 sk_psock_cork_free(psock);
532 __sk_psock_purge_ingress_msg(psock);
533 while ((link = sk_psock_link_pop(psock))) { 534 while ((link = sk_psock_link_pop(psock))) {
534 sk_psock_unlink(sk, link); 535 sk_psock_unlink(sk, link);
535 sk_psock_free_link(link); 536 sk_psock_free_link(link);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 20f6fac5882e..c61edd023b35 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6024,6 +6024,9 @@ reset_and_undo:
6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) 6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)
6025{ 6025{
6026 tcp_try_undo_loss(sk, false); 6026 tcp_try_undo_loss(sk, false);
6027
6028 /* Reset rtx states to prevent spurious retransmits_timed_out() */
6029 tcp_sk(sk)->retrans_stamp = 0;
6027 inet_csk(sk)->icsk_retransmits = 0; 6030 inet_csk(sk)->icsk_retransmits = 0;
6028 6031
6029 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1, 6032 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3c58ba02af7d..8fb250ed53d4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2883,7 +2883,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2883 __u16 srcp = ntohs(inet->inet_sport); 2883 __u16 srcp = ntohs(inet->inet_sport);
2884 2884
2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
2887 bucket, src, srcp, dest, destp, sp->sk_state, 2887 bucket, src, srcp, dest, destp, sp->sk_state,
2888 sk_wmem_alloc_get(sp), 2888 sk_wmem_alloc_get(sp),
2889 udp_rqueue_get(sp), 2889 udp_rqueue_get(sp),
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index ee4a4e54d016..f07fb24f4ba1 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -1034,7 +1034,7 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
1034 src = &sp->sk_v6_rcv_saddr; 1034 src = &sp->sk_v6_rcv_saddr;
1035 seq_printf(seq, 1035 seq_printf(seq,
1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " 1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1038 bucket, 1038 bucket,
1039 src->s6_addr32[0], src->s6_addr32[1], 1039 src->s6_addr32[0], src->s6_addr32[1],
1040 src->s6_addr32[2], src->s6_addr32[3], srcp, 1040 src->s6_addr32[2], src->s6_addr32[3], srcp,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 08e0390e001c..008421b550c6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -904,6 +904,12 @@ static void fib6_drop_pcpu_from(struct fib6_info *f6i,
904{ 904{
905 int cpu; 905 int cpu;
906 906
907 /* Make sure rt6_make_pcpu_route() wont add other percpu routes
908 * while we are cleaning them here.
909 */
910 f6i->fib6_destroying = 1;
911 mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
912
907 /* release the reference to this fib entry from 913 /* release the reference to this fib entry from
908 * all of its cached pcpu routes 914 * all of its cached pcpu routes
909 */ 915 */
@@ -927,6 +933,9 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
927{ 933{
928 struct fib6_table *table = rt->fib6_table; 934 struct fib6_table *table = rt->fib6_table;
929 935
936 if (rt->rt6i_pcpu)
937 fib6_drop_pcpu_from(rt, table);
938
930 if (refcount_read(&rt->fib6_ref) != 1) { 939 if (refcount_read(&rt->fib6_ref) != 1) {
931 /* This route is used as dummy address holder in some split 940 /* This route is used as dummy address holder in some split
932 * nodes. It is not leaked, but it still holds other resources, 941 * nodes. It is not leaked, but it still holds other resources,
@@ -948,9 +957,6 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
948 fn = rcu_dereference_protected(fn->parent, 957 fn = rcu_dereference_protected(fn->parent,
949 lockdep_is_held(&table->tb6_lock)); 958 lockdep_is_held(&table->tb6_lock));
950 } 959 }
951
952 if (rt->rt6i_pcpu)
953 fib6_drop_pcpu_from(rt, table);
954 } 960 }
955} 961}
956 962
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 23a20d62daac..7a014ca877ed 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -111,8 +111,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
111 int iif, int type, u32 portid, u32 seq, 111 int iif, int type, u32 portid, u32 seq,
112 unsigned int flags); 112 unsigned int flags);
113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
114 struct in6_addr *daddr, 114 const struct in6_addr *daddr,
115 struct in6_addr *saddr); 115 const struct in6_addr *saddr);
116 116
117#ifdef CONFIG_IPV6_ROUTE_INFO 117#ifdef CONFIG_IPV6_ROUTE_INFO
118static struct fib6_info *rt6_add_route_info(struct net *net, 118static struct fib6_info *rt6_add_route_info(struct net *net,
@@ -1295,6 +1295,13 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,
1295 prev = cmpxchg(p, NULL, pcpu_rt); 1295 prev = cmpxchg(p, NULL, pcpu_rt);
1296 BUG_ON(prev); 1296 BUG_ON(prev);
1297 1297
1298 if (res->f6i->fib6_destroying) {
1299 struct fib6_info *from;
1300
1301 from = xchg((__force struct fib6_info **)&pcpu_rt->from, NULL);
1302 fib6_info_release(from);
1303 }
1304
1298 return pcpu_rt; 1305 return pcpu_rt;
1299} 1306}
1300 1307
@@ -1566,31 +1573,44 @@ out:
1566 * Caller has to hold rcu_read_lock() 1573 * Caller has to hold rcu_read_lock()
1567 */ 1574 */
1568static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 1575static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
1569 struct in6_addr *daddr, 1576 const struct in6_addr *daddr,
1570 struct in6_addr *saddr) 1577 const struct in6_addr *saddr)
1571{ 1578{
1579 const struct in6_addr *src_key = NULL;
1572 struct rt6_exception_bucket *bucket; 1580 struct rt6_exception_bucket *bucket;
1573 struct in6_addr *src_key = NULL;
1574 struct rt6_exception *rt6_ex; 1581 struct rt6_exception *rt6_ex;
1575 struct rt6_info *ret = NULL; 1582 struct rt6_info *ret = NULL;
1576 1583
1577 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1578
1579#ifdef CONFIG_IPV6_SUBTREES 1584#ifdef CONFIG_IPV6_SUBTREES
1580 /* fib6i_src.plen != 0 indicates f6i is in subtree 1585 /* fib6i_src.plen != 0 indicates f6i is in subtree
1581 * and exception table is indexed by a hash of 1586 * and exception table is indexed by a hash of
1582 * both fib6_dst and fib6_src. 1587 * both fib6_dst and fib6_src.
1583 * Otherwise, the exception table is indexed by 1588 * However, the src addr used to create the hash
1584 * a hash of only fib6_dst. 1589 * might not be exactly the passed in saddr which
1590 * is a /128 addr from the flow.
1591 * So we need to use f6i->fib6_src to redo lookup
1592 * if the passed in saddr does not find anything.
1593 * (See the logic in ip6_rt_cache_alloc() on how
1594 * rt->rt6i_src is updated.)
1585 */ 1595 */
1586 if (res->f6i->fib6_src.plen) 1596 if (res->f6i->fib6_src.plen)
1587 src_key = saddr; 1597 src_key = saddr;
1598find_ex:
1588#endif 1599#endif
1600 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1589 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key); 1601 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
1590 1602
1591 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i)) 1603 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
1592 ret = rt6_ex->rt6i; 1604 ret = rt6_ex->rt6i;
1593 1605
1606#ifdef CONFIG_IPV6_SUBTREES
1607 /* Use fib6_src as src_key and redo lookup */
1608 if (!ret && src_key && src_key != &res->f6i->fib6_src.addr) {
1609 src_key = &res->f6i->fib6_src.addr;
1610 goto find_ex;
1611 }
1612#endif
1613
1594 return ret; 1614 return ret;
1595} 1615}
1596 1616
@@ -2665,12 +2685,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2665 const struct in6_addr *daddr, 2685 const struct in6_addr *daddr,
2666 const struct in6_addr *saddr) 2686 const struct in6_addr *saddr)
2667{ 2687{
2668 struct rt6_exception_bucket *bucket;
2669 const struct fib6_nh *nh = res->nh; 2688 const struct fib6_nh *nh = res->nh;
2670 struct fib6_info *f6i = res->f6i; 2689 struct fib6_info *f6i = res->f6i;
2671 const struct in6_addr *src_key;
2672 struct rt6_exception *rt6_ex;
2673 struct inet6_dev *idev; 2690 struct inet6_dev *idev;
2691 struct rt6_info *rt;
2674 u32 mtu = 0; 2692 u32 mtu = 0;
2675 2693
2676 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) { 2694 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) {
@@ -2679,18 +2697,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2679 goto out; 2697 goto out;
2680 } 2698 }
2681 2699
2682 src_key = NULL; 2700 rt = rt6_find_cached_rt(res, daddr, saddr);
2683#ifdef CONFIG_IPV6_SUBTREES 2701 if (unlikely(rt)) {
2684 if (f6i->fib6_src.plen) 2702 mtu = dst_metric_raw(&rt->dst, RTAX_MTU);
2685 src_key = saddr; 2703 } else {
2686#endif
2687
2688 bucket = rcu_dereference(f6i->rt6i_exception_bucket);
2689 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
2690 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
2691 mtu = dst_metric_raw(&rt6_ex->rt6i->dst, RTAX_MTU);
2692
2693 if (likely(!mtu)) {
2694 struct net_device *dev = nh->fib_nh_dev; 2704 struct net_device *dev = nh->fib_nh_dev;
2695 2705
2696 mtu = IPV6_MIN_MTU; 2706 mtu = IPV6_MIN_MTU;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 216ab915dd54..718a97d5f1fd 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2642,7 +2642,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
2642 struct sock *s = v; 2642 struct sock *s = v;
2643 struct netlink_sock *nlk = nlk_sk(s); 2643 struct netlink_sock *nlk = nlk_sk(s);
2644 2644
2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n", 2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8u %-8lu\n",
2646 s, 2646 s,
2647 s->sk_protocol, 2647 s->sk_protocol,
2648 nlk->portid, 2648 nlk->portid,
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 30187990257f..2567af2fbd6f 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -607,7 +607,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
607 struct pn_sock *pn = pn_sk(sk); 607 struct pn_sock *pn = pn_sk(sk);
608 608
609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu " 609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
610 "%d %pK %d", 610 "%d %pK %u",
611 sk->sk_protocol, pn->sobject, pn->dobject, 611 sk->sk_protocol, pn->sobject, pn->dobject,
612 pn->resource, sk->sk_state, 612 pn->resource, sk->sk_state,
613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), 613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
diff --git a/net/socket.c b/net/socket.c
index 472fbefa5d9b..72372dc5dd70 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -645,14 +645,6 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags)
645} 645}
646EXPORT_SYMBOL(__sock_tx_timestamp); 646EXPORT_SYMBOL(__sock_tx_timestamp);
647 647
648/**
649 * sock_sendmsg - send a message through @sock
650 * @sock: socket
651 * @msg: message to send
652 *
653 * Sends @msg through @sock, passing through LSM.
654 * Returns the number of bytes sent, or an error code.
655 */
656INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *, 648INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *,
657 size_t)); 649 size_t));
658static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) 650static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
@@ -663,6 +655,14 @@ static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
663 return ret; 655 return ret;
664} 656}
665 657
658/**
659 * sock_sendmsg - send a message through @sock
660 * @sock: socket
661 * @msg: message to send
662 *
663 * Sends @msg through @sock, passing through LSM.
664 * Returns the number of bytes sent, or an error code.
665 */
666int sock_sendmsg(struct socket *sock, struct msghdr *msg) 666int sock_sendmsg(struct socket *sock, struct msghdr *msg)
667{ 667{
668 int err = security_socket_sendmsg(sock, msg, 668 int err = security_socket_sendmsg(sock, msg,
@@ -875,15 +875,6 @@ void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
875} 875}
876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); 876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops);
877 877
878/**
879 * sock_recvmsg - receive a message from @sock
880 * @sock: socket
881 * @msg: message to receive
882 * @flags: message flags
883 *
884 * Receives @msg from @sock, passing through LSM. Returns the total number
885 * of bytes received, or an error.
886 */
887INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *, 878INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *,
888 size_t , int )); 879 size_t , int ));
889static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, 880static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
@@ -893,6 +884,15 @@ static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
893 msg_data_left(msg), flags); 884 msg_data_left(msg), flags);
894} 885}
895 886
887/**
888 * sock_recvmsg - receive a message from @sock
889 * @sock: socket
890 * @msg: message to receive
891 * @flags: message flags
892 *
893 * Receives @msg from @sock, passing through LSM. Returns the total number
894 * of bytes received, or an error.
895 */
896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) 896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags)
897{ 897{
898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags); 898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 27cccd101ef6..ddd2e0f67c07 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -131,10 +131,6 @@ static int __init tipc_init(void)
131 if (err) 131 if (err)
132 goto out_netlink_compat; 132 goto out_netlink_compat;
133 133
134 err = tipc_socket_init();
135 if (err)
136 goto out_socket;
137
138 err = tipc_register_sysctl(); 134 err = tipc_register_sysctl();
139 if (err) 135 if (err)
140 goto out_sysctl; 136 goto out_sysctl;
@@ -143,6 +139,10 @@ static int __init tipc_init(void)
143 if (err) 139 if (err)
144 goto out_pernet; 140 goto out_pernet;
145 141
142 err = tipc_socket_init();
143 if (err)
144 goto out_socket;
145
146 err = tipc_bearer_setup(); 146 err = tipc_bearer_setup();
147 if (err) 147 if (err)
148 goto out_bearer; 148 goto out_bearer;
@@ -150,12 +150,12 @@ static int __init tipc_init(void)
150 pr_info("Started in single node mode\n"); 150 pr_info("Started in single node mode\n");
151 return 0; 151 return 0;
152out_bearer: 152out_bearer:
153 tipc_socket_stop();
154out_socket:
153 unregister_pernet_subsys(&tipc_net_ops); 155 unregister_pernet_subsys(&tipc_net_ops);
154out_pernet: 156out_pernet:
155 tipc_unregister_sysctl(); 157 tipc_unregister_sysctl();
156out_sysctl: 158out_sysctl:
157 tipc_socket_stop();
158out_socket:
159 tipc_netlink_compat_stop(); 159 tipc_netlink_compat_stop();
160out_netlink_compat: 160out_netlink_compat:
161 tipc_netlink_stop(); 161 tipc_netlink_stop();
@@ -167,10 +167,10 @@ out_netlink:
167static void __exit tipc_exit(void) 167static void __exit tipc_exit(void)
168{ 168{
169 tipc_bearer_cleanup(); 169 tipc_bearer_cleanup();
170 tipc_socket_stop();
170 unregister_pernet_subsys(&tipc_net_ops); 171 unregister_pernet_subsys(&tipc_net_ops);
171 tipc_netlink_stop(); 172 tipc_netlink_stop();
172 tipc_netlink_compat_stop(); 173 tipc_netlink_compat_stop();
173 tipc_socket_stop();
174 tipc_unregister_sysctl(); 174 tipc_unregister_sysctl();
175 175
176 pr_info("Deactivated\n"); 176 pr_info("Deactivated\n");
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index a827547aa102..982a8dc49e03 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -35,6 +35,9 @@
35/* The MTU is 16KB per the host side's design */ 35/* The MTU is 16KB per the host side's design */
36#define HVS_MTU_SIZE (1024 * 16) 36#define HVS_MTU_SIZE (1024 * 16)
37 37
38/* How long to wait for graceful shutdown of a connection */
39#define HVS_CLOSE_TIMEOUT (8 * HZ)
40
38struct vmpipe_proto_header { 41struct vmpipe_proto_header {
39 u32 pkt_type; 42 u32 pkt_type;
40 u32 data_size; 43 u32 data_size;
@@ -305,19 +308,32 @@ static void hvs_channel_cb(void *ctx)
305 sk->sk_write_space(sk); 308 sk->sk_write_space(sk);
306} 309}
307 310
308static void hvs_close_connection(struct vmbus_channel *chan) 311static void hvs_do_close_lock_held(struct vsock_sock *vsk,
312 bool cancel_timeout)
309{ 313{
310 struct sock *sk = get_per_channel_state(chan); 314 struct sock *sk = sk_vsock(vsk);
311 struct vsock_sock *vsk = vsock_sk(sk);
312
313 lock_sock(sk);
314 315
315 sk->sk_state = TCP_CLOSE;
316 sock_set_flag(sk, SOCK_DONE); 316 sock_set_flag(sk, SOCK_DONE);
317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN; 317 vsk->peer_shutdown = SHUTDOWN_MASK;
318 318 if (vsock_stream_has_data(vsk) <= 0)
319 sk->sk_state = TCP_CLOSING;
319 sk->sk_state_change(sk); 320 sk->sk_state_change(sk);
321 if (vsk->close_work_scheduled &&
322 (!cancel_timeout || cancel_delayed_work(&vsk->close_work))) {
323 vsk->close_work_scheduled = false;
324 vsock_remove_sock(vsk);
320 325
326 /* Release the reference taken while scheduling the timeout */
327 sock_put(sk);
328 }
329}
330
331static void hvs_close_connection(struct vmbus_channel *chan)
332{
333 struct sock *sk = get_per_channel_state(chan);
334
335 lock_sock(sk);
336 hvs_do_close_lock_held(vsock_sk(sk), true);
321 release_sock(sk); 337 release_sock(sk);
322} 338}
323 339
@@ -452,50 +468,80 @@ static int hvs_connect(struct vsock_sock *vsk)
452 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id); 468 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id);
453} 469}
454 470
471static void hvs_shutdown_lock_held(struct hvsock *hvs, int mode)
472{
473 struct vmpipe_proto_header hdr;
474
475 if (hvs->fin_sent || !hvs->chan)
476 return;
477
478 /* It can't fail: see hvs_channel_writable_bytes(). */
479 (void)hvs_send_data(hvs->chan, (struct hvs_send_buf *)&hdr, 0);
480 hvs->fin_sent = true;
481}
482
455static int hvs_shutdown(struct vsock_sock *vsk, int mode) 483static int hvs_shutdown(struct vsock_sock *vsk, int mode)
456{ 484{
457 struct sock *sk = sk_vsock(vsk); 485 struct sock *sk = sk_vsock(vsk);
458 struct vmpipe_proto_header hdr;
459 struct hvs_send_buf *send_buf;
460 struct hvsock *hvs;
461 486
462 if (!(mode & SEND_SHUTDOWN)) 487 if (!(mode & SEND_SHUTDOWN))
463 return 0; 488 return 0;
464 489
465 lock_sock(sk); 490 lock_sock(sk);
491 hvs_shutdown_lock_held(vsk->trans, mode);
492 release_sock(sk);
493 return 0;
494}
466 495
467 hvs = vsk->trans; 496static void hvs_close_timeout(struct work_struct *work)
468 if (hvs->fin_sent) 497{
469 goto out; 498 struct vsock_sock *vsk =
470 499 container_of(work, struct vsock_sock, close_work.work);
471 send_buf = (struct hvs_send_buf *)&hdr; 500 struct sock *sk = sk_vsock(vsk);
472 501
473 /* It can't fail: see hvs_channel_writable_bytes(). */ 502 sock_hold(sk);
474 (void)hvs_send_data(hvs->chan, send_buf, 0); 503 lock_sock(sk);
504 if (!sock_flag(sk, SOCK_DONE))
505 hvs_do_close_lock_held(vsk, false);
475 506
476 hvs->fin_sent = true; 507 vsk->close_work_scheduled = false;
477out:
478 release_sock(sk); 508 release_sock(sk);
479 return 0; 509 sock_put(sk);
480} 510}
481 511
482static void hvs_release(struct vsock_sock *vsk) 512/* Returns true, if it is safe to remove socket; false otherwise */
513static bool hvs_close_lock_held(struct vsock_sock *vsk)
483{ 514{
484 struct sock *sk = sk_vsock(vsk); 515 struct sock *sk = sk_vsock(vsk);
485 struct hvsock *hvs = vsk->trans;
486 struct vmbus_channel *chan;
487 516
488 lock_sock(sk); 517 if (!(sk->sk_state == TCP_ESTABLISHED ||
518 sk->sk_state == TCP_CLOSING))
519 return true;
489 520
490 sk->sk_state = TCP_CLOSING; 521 if ((sk->sk_shutdown & SHUTDOWN_MASK) != SHUTDOWN_MASK)
491 vsock_remove_sock(vsk); 522 hvs_shutdown_lock_held(vsk->trans, SHUTDOWN_MASK);
492 523
493 release_sock(sk); 524 if (sock_flag(sk, SOCK_DONE))
525 return true;
494 526
495 chan = hvs->chan; 527 /* This reference will be dropped by the delayed close routine */
496 if (chan) 528 sock_hold(sk);
497 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN); 529 INIT_DELAYED_WORK(&vsk->close_work, hvs_close_timeout);
530 vsk->close_work_scheduled = true;
531 schedule_delayed_work(&vsk->close_work, HVS_CLOSE_TIMEOUT);
532 return false;
533}
498 534
535static void hvs_release(struct vsock_sock *vsk)
536{
537 struct sock *sk = sk_vsock(vsk);
538 bool remove_sock;
539
540 lock_sock(sk);
541 remove_sock = hvs_close_lock_held(vsk);
542 release_sock(sk);
543 if (remove_sock)
544 vsock_remove_sock(vsk);
499} 545}
500 546
501static void hvs_destruct(struct vsock_sock *vsk) 547static void hvs_destruct(struct vsock_sock *vsk)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 15eb5d3d4750..96ab344f17bb 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -702,28 +702,27 @@ static int __init virtio_vsock_init(void)
702 if (!virtio_vsock_workqueue) 702 if (!virtio_vsock_workqueue)
703 return -ENOMEM; 703 return -ENOMEM;
704 704
705 ret = register_virtio_driver(&virtio_vsock_driver); 705 ret = vsock_core_init(&virtio_transport.transport);
706 if (ret) 706 if (ret)
707 goto out_wq; 707 goto out_wq;
708 708
709 ret = vsock_core_init(&virtio_transport.transport); 709 ret = register_virtio_driver(&virtio_vsock_driver);
710 if (ret) 710 if (ret)
711 goto out_vdr; 711 goto out_vci;
712 712
713 return 0; 713 return 0;
714 714
715out_vdr: 715out_vci:
716 unregister_virtio_driver(&virtio_vsock_driver); 716 vsock_core_exit();
717out_wq: 717out_wq:
718 destroy_workqueue(virtio_vsock_workqueue); 718 destroy_workqueue(virtio_vsock_workqueue);
719 return ret; 719 return ret;
720
721} 720}
722 721
723static void __exit virtio_vsock_exit(void) 722static void __exit virtio_vsock_exit(void)
724{ 723{
725 vsock_core_exit();
726 unregister_virtio_driver(&virtio_vsock_driver); 724 unregister_virtio_driver(&virtio_vsock_driver);
725 vsock_core_exit();
727 destroy_workqueue(virtio_vsock_workqueue); 726 destroy_workqueue(virtio_vsock_workqueue);
728} 727}
729 728
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 602715fc9a75..f3f3d06cb6d8 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk)
786 786
787void virtio_transport_release(struct vsock_sock *vsk) 787void virtio_transport_release(struct vsock_sock *vsk)
788{ 788{
789 struct virtio_vsock_sock *vvs = vsk->trans;
790 struct virtio_vsock_pkt *pkt, *tmp;
789 struct sock *sk = &vsk->sk; 791 struct sock *sk = &vsk->sk;
790 bool remove_sock = true; 792 bool remove_sock = true;
791 793
792 lock_sock(sk); 794 lock_sock(sk);
793 if (sk->sk_type == SOCK_STREAM) 795 if (sk->sk_type == SOCK_STREAM)
794 remove_sock = virtio_transport_close(vsk); 796 remove_sock = virtio_transport_close(vsk);
797
798 list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) {
799 list_del(&pkt->list);
800 virtio_transport_free_pkt(pkt);
801 }
795 release_sock(sk); 802 release_sock(sk);
796 803
797 if (remove_sock) 804 if (remove_sock)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 410233c5681e..7a43ae6b2a44 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3264,7 +3264,8 @@ static void
3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse) 3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3265{ 3265{
3266 const struct iphdr *iph = ip_hdr(skb); 3266 const struct iphdr *iph = ip_hdr(skb);
3267 u8 *xprth = skb_network_header(skb) + iph->ihl * 4; 3267 int ihl = iph->ihl;
3268 u8 *xprth = skb_network_header(skb) + ihl * 4;
3268 struct flowi4 *fl4 = &fl->u.ip4; 3269 struct flowi4 *fl4 = &fl->u.ip4;
3269 int oif = 0; 3270 int oif = 0;
3270 3271
@@ -3275,6 +3276,11 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3275 fl4->flowi4_mark = skb->mark; 3276 fl4->flowi4_mark = skb->mark;
3276 fl4->flowi4_oif = reverse ? skb->skb_iif : oif; 3277 fl4->flowi4_oif = reverse ? skb->skb_iif : oif;
3277 3278
3279 fl4->flowi4_proto = iph->protocol;
3280 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3281 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3282 fl4->flowi4_tos = iph->tos;
3283
3278 if (!ip_is_fragment(iph)) { 3284 if (!ip_is_fragment(iph)) {
3279 switch (iph->protocol) { 3285 switch (iph->protocol) {
3280 case IPPROTO_UDP: 3286 case IPPROTO_UDP:
@@ -3286,7 +3292,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3286 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3292 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3287 __be16 *ports; 3293 __be16 *ports;
3288 3294
3289 xprth = skb_network_header(skb) + iph->ihl * 4; 3295 xprth = skb_network_header(skb) + ihl * 4;
3290 ports = (__be16 *)xprth; 3296 ports = (__be16 *)xprth;
3291 3297
3292 fl4->fl4_sport = ports[!!reverse]; 3298 fl4->fl4_sport = ports[!!reverse];
@@ -3298,7 +3304,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3298 pskb_may_pull(skb, xprth + 2 - skb->data)) { 3304 pskb_may_pull(skb, xprth + 2 - skb->data)) {
3299 u8 *icmp; 3305 u8 *icmp;
3300 3306
3301 xprth = skb_network_header(skb) + iph->ihl * 4; 3307 xprth = skb_network_header(skb) + ihl * 4;
3302 icmp = xprth; 3308 icmp = xprth;
3303 3309
3304 fl4->fl4_icmp_type = icmp[0]; 3310 fl4->fl4_icmp_type = icmp[0];
@@ -3310,7 +3316,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3310 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3316 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3311 __be32 *ehdr; 3317 __be32 *ehdr;
3312 3318
3313 xprth = skb_network_header(skb) + iph->ihl * 4; 3319 xprth = skb_network_header(skb) + ihl * 4;
3314 ehdr = (__be32 *)xprth; 3320 ehdr = (__be32 *)xprth;
3315 3321
3316 fl4->fl4_ipsec_spi = ehdr[0]; 3322 fl4->fl4_ipsec_spi = ehdr[0];
@@ -3321,7 +3327,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3321 pskb_may_pull(skb, xprth + 8 - skb->data)) { 3327 pskb_may_pull(skb, xprth + 8 - skb->data)) {
3322 __be32 *ah_hdr; 3328 __be32 *ah_hdr;
3323 3329
3324 xprth = skb_network_header(skb) + iph->ihl * 4; 3330 xprth = skb_network_header(skb) + ihl * 4;
3325 ah_hdr = (__be32 *)xprth; 3331 ah_hdr = (__be32 *)xprth;
3326 3332
3327 fl4->fl4_ipsec_spi = ah_hdr[1]; 3333 fl4->fl4_ipsec_spi = ah_hdr[1];
@@ -3332,7 +3338,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3332 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3338 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3333 __be16 *ipcomp_hdr; 3339 __be16 *ipcomp_hdr;
3334 3340
3335 xprth = skb_network_header(skb) + iph->ihl * 4; 3341 xprth = skb_network_header(skb) + ihl * 4;
3336 ipcomp_hdr = (__be16 *)xprth; 3342 ipcomp_hdr = (__be16 *)xprth;
3337 3343
3338 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1])); 3344 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
@@ -3344,7 +3350,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3344 __be16 *greflags; 3350 __be16 *greflags;
3345 __be32 *gre_hdr; 3351 __be32 *gre_hdr;
3346 3352
3347 xprth = skb_network_header(skb) + iph->ihl * 4; 3353 xprth = skb_network_header(skb) + ihl * 4;
3348 greflags = (__be16 *)xprth; 3354 greflags = (__be16 *)xprth;
3349 gre_hdr = (__be32 *)xprth; 3355 gre_hdr = (__be32 *)xprth;
3350 3356
@@ -3360,10 +3366,6 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3360 break; 3366 break;
3361 } 3367 }
3362 } 3368 }
3363 fl4->flowi4_proto = iph->protocol;
3364 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3365 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3366 fl4->flowi4_tos = iph->tos;
3367} 3369}
3368 3370
3369#if IS_ENABLED(CONFIG_IPV6) 3371#if IS_ENABLED(CONFIG_IPV6)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index a675ce11a573..e2de6c4dce90 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -138,11 +138,6 @@ cc-disable-warning = $(call try-run,\
138# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 138# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
139cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) 139cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
140 140
141# cc-ldoption
142# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
143cc-ldoption = $(call try-run,\
144 $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
145
146# ld-option 141# ld-option
147# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) 142# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
148ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) 143ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh
index 2f659530e1ec..39e8cb36ba19 100755
--- a/scripts/modules-check.sh
+++ b/scripts/modules-check.sh
@@ -6,10 +6,10 @@ set -e
6# Check uniqueness of module names 6# Check uniqueness of module names
7check_same_name_modules() 7check_same_name_modules()
8{ 8{
9 for m in $(sed 's:.*/::' modules.order modules.builtin | sort | uniq -d) 9 for m in $(sed 's:.*/::' modules.order | sort | uniq -d)
10 do 10 do
11 echo "warning: same basename if the following are built as modules:" >&2 11 echo "warning: same module names found:" >&2
12 sed "/\/$m/!d;s:^kernel/: :" modules.order modules.builtin >&2 12 sed -n "/\/$m/s:^kernel/: :p" modules.order >&2
13 done 13 done
14} 14}
15 15
diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h b/tools/arch/arm64/include/uapi/asm/kvm.h
index 97c3478ee6e7..7b7ac0f6cec9 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -35,6 +35,7 @@
35#include <linux/psci.h> 35#include <linux/psci.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <asm/ptrace.h> 37#include <asm/ptrace.h>
38#include <asm/sve_context.h>
38 39
39#define __KVM_HAVE_GUEST_DEBUG 40#define __KVM_HAVE_GUEST_DEBUG
40#define __KVM_HAVE_IRQ_LINE 41#define __KVM_HAVE_IRQ_LINE
@@ -102,6 +103,9 @@ struct kvm_regs {
102#define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ 103#define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */
103#define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */ 104#define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */
104#define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */ 105#define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */
106#define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */
107#define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */
108#define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */
105 109
106struct kvm_vcpu_init { 110struct kvm_vcpu_init {
107 __u32 target; 111 __u32 target;
@@ -226,6 +230,45 @@ struct kvm_vcpu_events {
226 KVM_REG_ARM_FW | ((r) & 0xffff)) 230 KVM_REG_ARM_FW | ((r) & 0xffff))
227#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) 231#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0)
228 232
233/* SVE registers */
234#define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT)
235
236/* Z- and P-regs occupy blocks at the following offsets within this range: */
237#define KVM_REG_ARM64_SVE_ZREG_BASE 0
238#define KVM_REG_ARM64_SVE_PREG_BASE 0x400
239#define KVM_REG_ARM64_SVE_FFR_BASE 0x600
240
241#define KVM_ARM64_SVE_NUM_ZREGS __SVE_NUM_ZREGS
242#define KVM_ARM64_SVE_NUM_PREGS __SVE_NUM_PREGS
243
244#define KVM_ARM64_SVE_MAX_SLICES 32
245
246#define KVM_REG_ARM64_SVE_ZREG(n, i) \
247 (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_ZREG_BASE | \
248 KVM_REG_SIZE_U2048 | \
249 (((n) & (KVM_ARM64_SVE_NUM_ZREGS - 1)) << 5) | \
250 ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1)))
251
252#define KVM_REG_ARM64_SVE_PREG(n, i) \
253 (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_PREG_BASE | \
254 KVM_REG_SIZE_U256 | \
255 (((n) & (KVM_ARM64_SVE_NUM_PREGS - 1)) << 5) | \
256 ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1)))
257
258#define KVM_REG_ARM64_SVE_FFR(i) \
259 (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_FFR_BASE | \
260 KVM_REG_SIZE_U256 | \
261 ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1)))
262
263#define KVM_ARM64_SVE_VQ_MIN __SVE_VQ_MIN
264#define KVM_ARM64_SVE_VQ_MAX __SVE_VQ_MAX
265
266/* Vector lengths pseudo-register: */
267#define KVM_REG_ARM64_SVE_VLS (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | \
268 KVM_REG_SIZE_U512 | 0xffff)
269#define KVM_ARM64_SVE_VLS_WORDS \
270 ((KVM_ARM64_SVE_VQ_MAX - KVM_ARM64_SVE_VQ_MIN) / 64 + 1)
271
229/* Device Control API: ARM VGIC */ 272/* Device Control API: ARM VGIC */
230#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 273#define KVM_DEV_ARM_VGIC_GRP_ADDR 0
231#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 274#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
index 26ca425f4c2c..b0f72dea8b11 100644
--- a/tools/arch/powerpc/include/uapi/asm/kvm.h
+++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
@@ -482,6 +482,8 @@ struct kvm_ppc_cpu_char {
482#define KVM_REG_PPC_ICP_PPRI_SHIFT 16 /* pending irq priority */ 482#define KVM_REG_PPC_ICP_PPRI_SHIFT 16 /* pending irq priority */
483#define KVM_REG_PPC_ICP_PPRI_MASK 0xff 483#define KVM_REG_PPC_ICP_PPRI_MASK 0xff
484 484
485#define KVM_REG_PPC_VP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x8d)
486
485/* Device control API: PPC-specific devices */ 487/* Device control API: PPC-specific devices */
486#define KVM_DEV_MPIC_GRP_MISC 1 488#define KVM_DEV_MPIC_GRP_MISC 1
487#define KVM_DEV_MPIC_BASE_ADDR 0 /* 64-bit */ 489#define KVM_DEV_MPIC_BASE_ADDR 0 /* 64-bit */
@@ -677,4 +679,48 @@ struct kvm_ppc_cpu_char {
677#define KVM_XICS_PRESENTED (1ULL << 43) 679#define KVM_XICS_PRESENTED (1ULL << 43)
678#define KVM_XICS_QUEUED (1ULL << 44) 680#define KVM_XICS_QUEUED (1ULL << 44)
679 681
682/* POWER9 XIVE Native Interrupt Controller */
683#define KVM_DEV_XIVE_GRP_CTRL 1
684#define KVM_DEV_XIVE_RESET 1
685#define KVM_DEV_XIVE_EQ_SYNC 2
686#define KVM_DEV_XIVE_GRP_SOURCE 2 /* 64-bit source identifier */
687#define KVM_DEV_XIVE_GRP_SOURCE_CONFIG 3 /* 64-bit source identifier */
688#define KVM_DEV_XIVE_GRP_EQ_CONFIG 4 /* 64-bit EQ identifier */
689#define KVM_DEV_XIVE_GRP_SOURCE_SYNC 5 /* 64-bit source identifier */
690
691/* Layout of 64-bit XIVE source attribute values */
692#define KVM_XIVE_LEVEL_SENSITIVE (1ULL << 0)
693#define KVM_XIVE_LEVEL_ASSERTED (1ULL << 1)
694
695/* Layout of 64-bit XIVE source configuration attribute values */
696#define KVM_XIVE_SOURCE_PRIORITY_SHIFT 0
697#define KVM_XIVE_SOURCE_PRIORITY_MASK 0x7
698#define KVM_XIVE_SOURCE_SERVER_SHIFT 3
699#define KVM_XIVE_SOURCE_SERVER_MASK 0xfffffff8ULL
700#define KVM_XIVE_SOURCE_MASKED_SHIFT 32
701#define KVM_XIVE_SOURCE_MASKED_MASK 0x100000000ULL
702#define KVM_XIVE_SOURCE_EISN_SHIFT 33
703#define KVM_XIVE_SOURCE_EISN_MASK 0xfffffffe00000000ULL
704
705/* Layout of 64-bit EQ identifier */
706#define KVM_XIVE_EQ_PRIORITY_SHIFT 0
707#define KVM_XIVE_EQ_PRIORITY_MASK 0x7
708#define KVM_XIVE_EQ_SERVER_SHIFT 3
709#define KVM_XIVE_EQ_SERVER_MASK 0xfffffff8ULL
710
711/* Layout of EQ configuration values (64 bytes) */
712struct kvm_ppc_xive_eq {
713 __u32 flags;
714 __u32 qshift;
715 __u64 qaddr;
716 __u32 qtoggle;
717 __u32 qindex;
718 __u8 pad[40];
719};
720
721#define KVM_XIVE_EQ_ALWAYS_NOTIFY 0x00000001
722
723#define KVM_XIVE_TIMA_PAGE_OFFSET 0
724#define KVM_XIVE_ESB_PAGE_OFFSET 4
725
680#endif /* __LINUX_KVM_POWERPC_H */ 726#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/tools/arch/s390/include/uapi/asm/kvm.h b/tools/arch/s390/include/uapi/asm/kvm.h
index 09652eabe769..47104e5b47fd 100644
--- a/tools/arch/s390/include/uapi/asm/kvm.h
+++ b/tools/arch/s390/include/uapi/asm/kvm.h
@@ -153,7 +153,9 @@ struct kvm_s390_vm_cpu_subfunc {
153 __u8 ppno[16]; /* with MSA5 */ 153 __u8 ppno[16]; /* with MSA5 */
154 __u8 kma[16]; /* with MSA8 */ 154 __u8 kma[16]; /* with MSA8 */
155 __u8 kdsa[16]; /* with MSA9 */ 155 __u8 kdsa[16]; /* with MSA9 */
156 __u8 reserved[1792]; 156 __u8 sortl[32]; /* with STFLE.150 */
157 __u8 dfltcc[32]; /* with STFLE.151 */
158 __u8 reserved[1728];
157}; 159};
158 160
159/* kvm attributes for crypto */ 161/* kvm attributes for crypto */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 981ff9479648..75f27ee2c263 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -344,6 +344,7 @@
344/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ 344/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
345#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ 345#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
346#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ 346#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
347#define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */
347#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */ 348#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
348#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ 349#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
349#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */ 350#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
@@ -382,5 +383,7 @@
382#define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */ 383#define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
383#define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */ 384#define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */
384#define X86_BUG_L1TF X86_BUG(18) /* CPU is affected by L1 Terminal Fault */ 385#define X86_BUG_L1TF X86_BUG(18) /* CPU is affected by L1 Terminal Fault */
386#define X86_BUG_MDS X86_BUG(19) /* CPU is affected by Microarchitectural data sampling */
387#define X86_BUG_MSBDS_ONLY X86_BUG(20) /* CPU is only affected by the MSDBS variant of BUG_MDS */
385 388
386#endif /* _ASM_X86_CPUFEATURES_H */ 389#endif /* _ASM_X86_CPUFEATURES_H */
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index 58a2cd002a4b..7317438ecd9e 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -208,8 +208,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
208 break; 208 break;
209 } 209 }
210 case BTF_KIND_FWD: { 210 case BTF_KIND_FWD: {
211 const char *fwd_kind = BTF_INFO_KIND(t->info) ? "union" 211 const char *fwd_kind = BTF_INFO_KFLAG(t->info) ? "union"
212 : "struct"; 212 : "struct";
213 213
214 if (json_output) 214 if (json_output)
215 jsonw_string_field(w, "fwd_kind", fwd_kind); 215 jsonw_string_field(w, "fwd_kind", fwd_kind);
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index fc495b27f0fc..26336bad0442 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -879,6 +879,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
879 } 879 }
880 } 880 }
881 881
882 set_max_rlimit();
883
882 obj = __bpf_object__open_xattr(&attr, bpf_flags); 884 obj = __bpf_object__open_xattr(&attr, bpf_flags);
883 if (IS_ERR_OR_NULL(obj)) { 885 if (IS_ERR_OR_NULL(obj)) {
884 p_err("failed to open object file"); 886 p_err("failed to open object file");
@@ -958,8 +960,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
958 goto err_close_obj; 960 goto err_close_obj;
959 } 961 }
960 962
961 set_max_rlimit();
962
963 err = bpf_object__load(obj); 963 err = bpf_object__load(obj);
964 if (err) { 964 if (err) {
965 p_err("failed to load object file"); 965 p_err("failed to load object file");
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index dee7292e1df6..a87904daf103 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -832,9 +832,21 @@ __SYSCALL(__NR_io_uring_setup, sys_io_uring_setup)
832__SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) 832__SYSCALL(__NR_io_uring_enter, sys_io_uring_enter)
833#define __NR_io_uring_register 427 833#define __NR_io_uring_register 427
834__SYSCALL(__NR_io_uring_register, sys_io_uring_register) 834__SYSCALL(__NR_io_uring_register, sys_io_uring_register)
835#define __NR_open_tree 428
836__SYSCALL(__NR_open_tree, sys_open_tree)
837#define __NR_move_mount 429
838__SYSCALL(__NR_move_mount, sys_move_mount)
839#define __NR_fsopen 430
840__SYSCALL(__NR_fsopen, sys_fsopen)
841#define __NR_fsconfig 431
842__SYSCALL(__NR_fsconfig, sys_fsconfig)
843#define __NR_fsmount 432
844__SYSCALL(__NR_fsmount, sys_fsmount)
845#define __NR_fspick 433
846__SYSCALL(__NR_fspick, sys_fspick)
835 847
836#undef __NR_syscalls 848#undef __NR_syscalls
837#define __NR_syscalls 428 849#define __NR_syscalls 434
838 850
839/* 851/*
840 * 32 bit systems traditionally used different 852 * 32 bit systems traditionally used different
diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h
index 300f336633f2..661d73f9a919 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -649,6 +649,7 @@ struct drm_gem_open {
649#define DRM_CAP_PAGE_FLIP_TARGET 0x11 649#define DRM_CAP_PAGE_FLIP_TARGET 0x11
650#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12 650#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
651#define DRM_CAP_SYNCOBJ 0x13 651#define DRM_CAP_SYNCOBJ 0x13
652#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
652 653
653/** DRM_IOCTL_GET_CAP ioctl argument type */ 654/** DRM_IOCTL_GET_CAP ioctl argument type */
654struct drm_get_cap { 655struct drm_get_cap {
@@ -735,8 +736,18 @@ struct drm_syncobj_handle {
735 __u32 pad; 736 __u32 pad;
736}; 737};
737 738
739struct drm_syncobj_transfer {
740 __u32 src_handle;
741 __u32 dst_handle;
742 __u64 src_point;
743 __u64 dst_point;
744 __u32 flags;
745 __u32 pad;
746};
747
738#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) 748#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
739#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) 749#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
750#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) /* wait for time point to become available */
740struct drm_syncobj_wait { 751struct drm_syncobj_wait {
741 __u64 handles; 752 __u64 handles;
742 /* absolute timeout */ 753 /* absolute timeout */
@@ -747,12 +758,33 @@ struct drm_syncobj_wait {
747 __u32 pad; 758 __u32 pad;
748}; 759};
749 760
761struct drm_syncobj_timeline_wait {
762 __u64 handles;
763 /* wait on specific timeline point for every handles*/
764 __u64 points;
765 /* absolute timeout */
766 __s64 timeout_nsec;
767 __u32 count_handles;
768 __u32 flags;
769 __u32 first_signaled; /* only valid when not waiting all */
770 __u32 pad;
771};
772
773
750struct drm_syncobj_array { 774struct drm_syncobj_array {
751 __u64 handles; 775 __u64 handles;
752 __u32 count_handles; 776 __u32 count_handles;
753 __u32 pad; 777 __u32 pad;
754}; 778};
755 779
780struct drm_syncobj_timeline_array {
781 __u64 handles;
782 __u64 points;
783 __u32 count_handles;
784 __u32 pad;
785};
786
787
756/* Query current scanout sequence number */ 788/* Query current scanout sequence number */
757struct drm_crtc_get_sequence { 789struct drm_crtc_get_sequence {
758 __u32 crtc_id; /* requested crtc_id */ 790 __u32 crtc_id; /* requested crtc_id */
@@ -909,6 +941,11 @@ extern "C" {
909#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease) 941#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease)
910#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) 942#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease)
911 943
944#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)
945#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array)
946#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
947#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
948
912/** 949/**
913 * Device specific ioctls should only be in their respective headers 950 * Device specific ioctls should only be in their respective headers
914 * The device specific ioctl range is from 0x40 to 0x9f. 951 * The device specific ioctl range is from 0x40 to 0x9f.
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index 397810fa2d33..3a73f5316766 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -63,6 +63,28 @@ extern "C" {
63#define I915_RESET_UEVENT "RESET" 63#define I915_RESET_UEVENT "RESET"
64 64
65/* 65/*
66 * i915_user_extension: Base class for defining a chain of extensions
67 *
68 * Many interfaces need to grow over time. In most cases we can simply
69 * extend the struct and have userspace pass in more data. Another option,
70 * as demonstrated by Vulkan's approach to providing extensions for forward
71 * and backward compatibility, is to use a list of optional structs to
72 * provide those extra details.
73 *
74 * The key advantage to using an extension chain is that it allows us to
75 * redefine the interface more easily than an ever growing struct of
76 * increasing complexity, and for large parts of that interface to be
77 * entirely optional. The downside is more pointer chasing; chasing across
78 * the __user boundary with pointers encapsulated inside u64.
79 */
80struct i915_user_extension {
81 __u64 next_extension;
82 __u32 name;
83 __u32 flags; /* All undefined bits must be zero. */
84 __u32 rsvd[4]; /* Reserved for future use; must be zero. */
85};
86
87/*
66 * MOCS indexes used for GPU surfaces, defining the cacheability of the 88 * MOCS indexes used for GPU surfaces, defining the cacheability of the
67 * surface data and the coherency for this data wrt. CPU vs. GPU accesses. 89 * surface data and the coherency for this data wrt. CPU vs. GPU accesses.
68 */ 90 */
@@ -99,9 +121,23 @@ enum drm_i915_gem_engine_class {
99 I915_ENGINE_CLASS_VIDEO = 2, 121 I915_ENGINE_CLASS_VIDEO = 2,
100 I915_ENGINE_CLASS_VIDEO_ENHANCE = 3, 122 I915_ENGINE_CLASS_VIDEO_ENHANCE = 3,
101 123
124 /* should be kept compact */
125
102 I915_ENGINE_CLASS_INVALID = -1 126 I915_ENGINE_CLASS_INVALID = -1
103}; 127};
104 128
129/*
130 * There may be more than one engine fulfilling any role within the system.
131 * Each engine of a class is given a unique instance number and therefore
132 * any engine can be specified by its class:instance tuplet. APIs that allow
133 * access to any engine in the system will use struct i915_engine_class_instance
134 * for this identification.
135 */
136struct i915_engine_class_instance {
137 __u16 engine_class; /* see enum drm_i915_gem_engine_class */
138 __u16 engine_instance;
139};
140
105/** 141/**
106 * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915 142 * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915
107 * 143 *
@@ -319,6 +355,7 @@ typedef struct _drm_i915_sarea {
319#define DRM_I915_PERF_ADD_CONFIG 0x37 355#define DRM_I915_PERF_ADD_CONFIG 0x37
320#define DRM_I915_PERF_REMOVE_CONFIG 0x38 356#define DRM_I915_PERF_REMOVE_CONFIG 0x38
321#define DRM_I915_QUERY 0x39 357#define DRM_I915_QUERY 0x39
358/* Must be kept compact -- no holes */
322 359
323#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 360#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
324#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 361#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -367,6 +404,7 @@ typedef struct _drm_i915_sarea {
367#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) 404#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
368#define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait) 405#define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
369#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create) 406#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
407#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create_ext)
370#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy) 408#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
371#define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read) 409#define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
372#define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats) 410#define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
@@ -476,6 +514,7 @@ typedef struct drm_i915_irq_wait {
476#define I915_SCHEDULER_CAP_ENABLED (1ul << 0) 514#define I915_SCHEDULER_CAP_ENABLED (1ul << 0)
477#define I915_SCHEDULER_CAP_PRIORITY (1ul << 1) 515#define I915_SCHEDULER_CAP_PRIORITY (1ul << 1)
478#define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2) 516#define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)
517#define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3)
479 518
480#define I915_PARAM_HUC_STATUS 42 519#define I915_PARAM_HUC_STATUS 42
481 520
@@ -559,6 +598,8 @@ typedef struct drm_i915_irq_wait {
559 */ 598 */
560#define I915_PARAM_MMAP_GTT_COHERENT 52 599#define I915_PARAM_MMAP_GTT_COHERENT 52
561 600
601/* Must be kept compact -- no holes and well documented */
602
562typedef struct drm_i915_getparam { 603typedef struct drm_i915_getparam {
563 __s32 param; 604 __s32 param;
564 /* 605 /*
@@ -574,6 +615,7 @@ typedef struct drm_i915_getparam {
574#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2 615#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
575#define I915_SETPARAM_ALLOW_BATCHBUFFER 3 616#define I915_SETPARAM_ALLOW_BATCHBUFFER 3
576#define I915_SETPARAM_NUM_USED_FENCES 4 617#define I915_SETPARAM_NUM_USED_FENCES 4
618/* Must be kept compact -- no holes */
577 619
578typedef struct drm_i915_setparam { 620typedef struct drm_i915_setparam {
579 int param; 621 int param;
@@ -972,7 +1014,7 @@ struct drm_i915_gem_execbuffer2 {
972 * struct drm_i915_gem_exec_fence *fences. 1014 * struct drm_i915_gem_exec_fence *fences.
973 */ 1015 */
974 __u64 cliprects_ptr; 1016 __u64 cliprects_ptr;
975#define I915_EXEC_RING_MASK (7<<0) 1017#define I915_EXEC_RING_MASK (0x3f)
976#define I915_EXEC_DEFAULT (0<<0) 1018#define I915_EXEC_DEFAULT (0<<0)
977#define I915_EXEC_RENDER (1<<0) 1019#define I915_EXEC_RENDER (1<<0)
978#define I915_EXEC_BSD (2<<0) 1020#define I915_EXEC_BSD (2<<0)
@@ -1120,32 +1162,34 @@ struct drm_i915_gem_busy {
1120 * as busy may become idle before the ioctl is completed. 1162 * as busy may become idle before the ioctl is completed.
1121 * 1163 *
1122 * Furthermore, if the object is busy, which engine is busy is only 1164 * Furthermore, if the object is busy, which engine is busy is only
1123 * provided as a guide. There are race conditions which prevent the 1165 * provided as a guide and only indirectly by reporting its class
1124 * report of which engines are busy from being always accurate. 1166 * (there may be more than one engine in each class). There are race
1125 * However, the converse is not true. If the object is idle, the 1167 * conditions which prevent the report of which engines are busy from
1126 * result of the ioctl, that all engines are idle, is accurate. 1168 * being always accurate. However, the converse is not true. If the
1169 * object is idle, the result of the ioctl, that all engines are idle,
1170 * is accurate.
1127 * 1171 *
1128 * The returned dword is split into two fields to indicate both 1172 * The returned dword is split into two fields to indicate both
1129 * the engines on which the object is being read, and the 1173 * the engine classess on which the object is being read, and the
1130 * engine on which it is currently being written (if any). 1174 * engine class on which it is currently being written (if any).
1131 * 1175 *
1132 * The low word (bits 0:15) indicate if the object is being written 1176 * The low word (bits 0:15) indicate if the object is being written
1133 * to by any engine (there can only be one, as the GEM implicit 1177 * to by any engine (there can only be one, as the GEM implicit
1134 * synchronisation rules force writes to be serialised). Only the 1178 * synchronisation rules force writes to be serialised). Only the
1135 * engine for the last write is reported. 1179 * engine class (offset by 1, I915_ENGINE_CLASS_RENDER is reported as
1180 * 1 not 0 etc) for the last write is reported.
1136 * 1181 *
1137 * The high word (bits 16:31) are a bitmask of which engines are 1182 * The high word (bits 16:31) are a bitmask of which engines classes
1138 * currently reading from the object. Multiple engines may be 1183 * are currently reading from the object. Multiple engines may be
1139 * reading from the object simultaneously. 1184 * reading from the object simultaneously.
1140 * 1185 *
1141 * The value of each engine is the same as specified in the 1186 * The value of each engine class is the same as specified in the
1142 * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc. 1187 * I915_CONTEXT_SET_ENGINES parameter and via perf, i.e.
1143 * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to 1188 * I915_ENGINE_CLASS_RENDER, I915_ENGINE_CLASS_COPY, etc.
1144 * the I915_EXEC_RENDER engine for execution, and so it is never
1145 * reported as active itself. Some hardware may have parallel 1189 * reported as active itself. Some hardware may have parallel
1146 * execution engines, e.g. multiple media engines, which are 1190 * execution engines, e.g. multiple media engines, which are
1147 * mapped to the same identifier in the EXECBUFFER2 ioctl and 1191 * mapped to the same class identifier and so are not separately
1148 * so are not separately reported for busyness. 1192 * reported for busyness.
1149 * 1193 *
1150 * Caveat emptor: 1194 * Caveat emptor:
1151 * Only the boolean result of this query is reliable; that is whether 1195 * Only the boolean result of this query is reliable; that is whether
@@ -1412,65 +1456,17 @@ struct drm_i915_gem_wait {
1412}; 1456};
1413 1457
1414struct drm_i915_gem_context_create { 1458struct drm_i915_gem_context_create {
1415 /* output: id of new context*/ 1459 __u32 ctx_id; /* output: id of new context*/
1416 __u32 ctx_id;
1417 __u32 pad;
1418};
1419
1420struct drm_i915_gem_context_destroy {
1421 __u32 ctx_id;
1422 __u32 pad; 1460 __u32 pad;
1423}; 1461};
1424 1462
1425struct drm_i915_reg_read { 1463struct drm_i915_gem_context_create_ext {
1426 /* 1464 __u32 ctx_id; /* output: id of new context*/
1427 * Register offset.
1428 * For 64bit wide registers where the upper 32bits don't immediately
1429 * follow the lower 32bits, the offset of the lower 32bits must
1430 * be specified
1431 */
1432 __u64 offset;
1433#define I915_REG_READ_8B_WA (1ul << 0)
1434
1435 __u64 val; /* Return value */
1436};
1437/* Known registers:
1438 *
1439 * Render engine timestamp - 0x2358 + 64bit - gen7+
1440 * - Note this register returns an invalid value if using the default
1441 * single instruction 8byte read, in order to workaround that pass
1442 * flag I915_REG_READ_8B_WA in offset field.
1443 *
1444 */
1445
1446struct drm_i915_reset_stats {
1447 __u32 ctx_id;
1448 __u32 flags;
1449
1450 /* All resets since boot/module reload, for all contexts */
1451 __u32 reset_count;
1452
1453 /* Number of batches lost when active in GPU, for this context */
1454 __u32 batch_active;
1455
1456 /* Number of batches lost pending for execution, for this context */
1457 __u32 batch_pending;
1458
1459 __u32 pad;
1460};
1461
1462struct drm_i915_gem_userptr {
1463 __u64 user_ptr;
1464 __u64 user_size;
1465 __u32 flags; 1465 __u32 flags;
1466#define I915_USERPTR_READ_ONLY 0x1 1466#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0)
1467#define I915_USERPTR_UNSYNCHRONIZED 0x80000000 1467#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \
1468 /** 1468 (-(I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS << 1))
1469 * Returned handle for the object. 1469 __u64 extensions;
1470 *
1471 * Object handles are nonzero.
1472 */
1473 __u32 handle;
1474}; 1470};
1475 1471
1476struct drm_i915_gem_context_param { 1472struct drm_i915_gem_context_param {
@@ -1491,6 +1487,28 @@ struct drm_i915_gem_context_param {
1491 * drm_i915_gem_context_param_sseu. 1487 * drm_i915_gem_context_param_sseu.
1492 */ 1488 */
1493#define I915_CONTEXT_PARAM_SSEU 0x7 1489#define I915_CONTEXT_PARAM_SSEU 0x7
1490
1491/*
1492 * Not all clients may want to attempt automatic recover of a context after
1493 * a hang (for example, some clients may only submit very small incremental
1494 * batches relying on known logical state of previous batches which will never
1495 * recover correctly and each attempt will hang), and so would prefer that
1496 * the context is forever banned instead.
1497 *
1498 * If set to false (0), after a reset, subsequent (and in flight) rendering
1499 * from this context is discarded, and the client will need to create a new
1500 * context to use instead.
1501 *
1502 * If set to true (1), the kernel will automatically attempt to recover the
1503 * context by skipping the hanging batch and executing the next batch starting
1504 * from the default context state (discarding the incomplete logical context
1505 * state lost due to the reset).
1506 *
1507 * On creation, all new contexts are marked as recoverable.
1508 */
1509#define I915_CONTEXT_PARAM_RECOVERABLE 0x8
1510/* Must be kept compact -- no holes and well documented */
1511
1494 __u64 value; 1512 __u64 value;
1495}; 1513};
1496 1514
@@ -1519,8 +1537,7 @@ struct drm_i915_gem_context_param_sseu {
1519 /* 1537 /*
1520 * Engine class & instance to be configured or queried. 1538 * Engine class & instance to be configured or queried.
1521 */ 1539 */
1522 __u16 engine_class; 1540 struct i915_engine_class_instance engine;
1523 __u16 engine_instance;
1524 1541
1525 /* 1542 /*
1526 * Unused for now. Must be cleared to zero. 1543 * Unused for now. Must be cleared to zero.
@@ -1553,6 +1570,96 @@ struct drm_i915_gem_context_param_sseu {
1553 __u32 rsvd; 1570 __u32 rsvd;
1554}; 1571};
1555 1572
1573struct drm_i915_gem_context_create_ext_setparam {
1574#define I915_CONTEXT_CREATE_EXT_SETPARAM 0
1575 struct i915_user_extension base;
1576 struct drm_i915_gem_context_param param;
1577};
1578
1579struct drm_i915_gem_context_destroy {
1580 __u32 ctx_id;
1581 __u32 pad;
1582};
1583
1584/*
1585 * DRM_I915_GEM_VM_CREATE -
1586 *
1587 * Create a new virtual memory address space (ppGTT) for use within a context
1588 * on the same file. Extensions can be provided to configure exactly how the
1589 * address space is setup upon creation.
1590 *
1591 * The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is
1592 * returned in the outparam @id.
1593 *
1594 * No flags are defined, with all bits reserved and must be zero.
1595 *
1596 * An extension chain maybe provided, starting with @extensions, and terminated
1597 * by the @next_extension being 0. Currently, no extensions are defined.
1598 *
1599 * DRM_I915_GEM_VM_DESTROY -
1600 *
1601 * Destroys a previously created VM id, specified in @id.
1602 *
1603 * No extensions or flags are allowed currently, and so must be zero.
1604 */
1605struct drm_i915_gem_vm_control {
1606 __u64 extensions;
1607 __u32 flags;
1608 __u32 vm_id;
1609};
1610
1611struct drm_i915_reg_read {
1612 /*
1613 * Register offset.
1614 * For 64bit wide registers where the upper 32bits don't immediately
1615 * follow the lower 32bits, the offset of the lower 32bits must
1616 * be specified
1617 */
1618 __u64 offset;
1619#define I915_REG_READ_8B_WA (1ul << 0)
1620
1621 __u64 val; /* Return value */
1622};
1623
1624/* Known registers:
1625 *
1626 * Render engine timestamp - 0x2358 + 64bit - gen7+
1627 * - Note this register returns an invalid value if using the default
1628 * single instruction 8byte read, in order to workaround that pass
1629 * flag I915_REG_READ_8B_WA in offset field.
1630 *
1631 */
1632
1633struct drm_i915_reset_stats {
1634 __u32 ctx_id;
1635 __u32 flags;
1636
1637 /* All resets since boot/module reload, for all contexts */
1638 __u32 reset_count;
1639
1640 /* Number of batches lost when active in GPU, for this context */
1641 __u32 batch_active;
1642
1643 /* Number of batches lost pending for execution, for this context */
1644 __u32 batch_pending;
1645
1646 __u32 pad;
1647};
1648
1649struct drm_i915_gem_userptr {
1650 __u64 user_ptr;
1651 __u64 user_size;
1652 __u32 flags;
1653#define I915_USERPTR_READ_ONLY 0x1
1654#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
1655 /**
1656 * Returned handle for the object.
1657 *
1658 * Object handles are nonzero.
1659 */
1660 __u32 handle;
1661};
1662
1556enum drm_i915_oa_format { 1663enum drm_i915_oa_format {
1557 I915_OA_FORMAT_A13 = 1, /* HSW only */ 1664 I915_OA_FORMAT_A13 = 1, /* HSW only */
1558 I915_OA_FORMAT_A29, /* HSW only */ 1665 I915_OA_FORMAT_A29, /* HSW only */
@@ -1714,6 +1821,7 @@ struct drm_i915_perf_oa_config {
1714struct drm_i915_query_item { 1821struct drm_i915_query_item {
1715 __u64 query_id; 1822 __u64 query_id;
1716#define DRM_I915_QUERY_TOPOLOGY_INFO 1 1823#define DRM_I915_QUERY_TOPOLOGY_INFO 1
1824/* Must be kept compact -- no holes and well documented */
1717 1825
1718 /* 1826 /*
1719 * When set to zero by userspace, this is filled with the size of the 1827 * When set to zero by userspace, this is filled with the size of the
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index 9310652ca4f9..63ae4a39e58b 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -83,7 +83,7 @@ struct btf_type {
83 * is the 32 bits arrangement: 83 * is the 32 bits arrangement:
84 */ 84 */
85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
86#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 86#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
88 88
89/* Attributes stored in the BTF_INT_ENCODING */ 89/* Attributes stored in the BTF_INT_ENCODING */
diff --git a/tools/include/uapi/linux/fcntl.h b/tools/include/uapi/linux/fcntl.h
index a2f8658f1c55..1d338357df8a 100644
--- a/tools/include/uapi/linux/fcntl.h
+++ b/tools/include/uapi/linux/fcntl.h
@@ -91,5 +91,7 @@
91#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ 91#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */
92#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ 92#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */
93 93
94#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
95
94 96
95#endif /* _UAPI_LINUX_FCNTL_H */ 97#endif /* _UAPI_LINUX_FCNTL_H */
diff --git a/tools/include/uapi/linux/fs.h b/tools/include/uapi/linux/fs.h
index 121e82ce296b..59c71fa8c553 100644
--- a/tools/include/uapi/linux/fs.h
+++ b/tools/include/uapi/linux/fs.h
@@ -320,6 +320,9 @@ struct fscrypt_key {
320#define SYNC_FILE_RANGE_WAIT_BEFORE 1 320#define SYNC_FILE_RANGE_WAIT_BEFORE 1
321#define SYNC_FILE_RANGE_WRITE 2 321#define SYNC_FILE_RANGE_WRITE 2
322#define SYNC_FILE_RANGE_WAIT_AFTER 4 322#define SYNC_FILE_RANGE_WAIT_AFTER 4
323#define SYNC_FILE_RANGE_WRITE_AND_WAIT (SYNC_FILE_RANGE_WRITE | \
324 SYNC_FILE_RANGE_WAIT_BEFORE | \
325 SYNC_FILE_RANGE_WAIT_AFTER)
323 326
324/* 327/*
325 * Flags for preadv2/pwritev2: 328 * Flags for preadv2/pwritev2:
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 6d4ea4b6c922..2fe12b40d503 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -986,8 +986,13 @@ struct kvm_ppc_resize_hpt {
986#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 986#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
987#define KVM_CAP_EXCEPTION_PAYLOAD 164 987#define KVM_CAP_EXCEPTION_PAYLOAD 164
988#define KVM_CAP_ARM_VM_IPA_SIZE 165 988#define KVM_CAP_ARM_VM_IPA_SIZE 165
989#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 989#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */
990#define KVM_CAP_HYPERV_CPUID 167 990#define KVM_CAP_HYPERV_CPUID 167
991#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
992#define KVM_CAP_PPC_IRQ_XIVE 169
993#define KVM_CAP_ARM_SVE 170
994#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
995#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
991 996
992#ifdef KVM_CAP_IRQ_ROUTING 997#ifdef KVM_CAP_IRQ_ROUTING
993 998
@@ -1145,6 +1150,7 @@ struct kvm_dirty_tlb {
1145#define KVM_REG_SIZE_U256 0x0050000000000000ULL 1150#define KVM_REG_SIZE_U256 0x0050000000000000ULL
1146#define KVM_REG_SIZE_U512 0x0060000000000000ULL 1151#define KVM_REG_SIZE_U512 0x0060000000000000ULL
1147#define KVM_REG_SIZE_U1024 0x0070000000000000ULL 1152#define KVM_REG_SIZE_U1024 0x0070000000000000ULL
1153#define KVM_REG_SIZE_U2048 0x0080000000000000ULL
1148 1154
1149struct kvm_reg_list { 1155struct kvm_reg_list {
1150 __u64 n; /* number of regs */ 1156 __u64 n; /* number of regs */
@@ -1211,6 +1217,8 @@ enum kvm_device_type {
1211#define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1217#define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3
1212 KVM_DEV_TYPE_ARM_VGIC_ITS, 1218 KVM_DEV_TYPE_ARM_VGIC_ITS,
1213#define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1219#define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS
1220 KVM_DEV_TYPE_XIVE,
1221#define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE
1214 KVM_DEV_TYPE_MAX, 1222 KVM_DEV_TYPE_MAX,
1215}; 1223};
1216 1224
@@ -1434,12 +1442,15 @@ struct kvm_enc_region {
1434#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1442#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1435#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 1443#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state)
1436 1444
1437/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT */ 1445/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */
1438#define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) 1446#define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1439 1447
1440/* Available with KVM_CAP_HYPERV_CPUID */ 1448/* Available with KVM_CAP_HYPERV_CPUID */
1441#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) 1449#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1442 1450
1451/* Available with KVM_CAP_ARM_SVE */
1452#define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int)
1453
1443/* Secure Encrypted Virtualization command */ 1454/* Secure Encrypted Virtualization command */
1444enum sev_cmd_id { 1455enum sev_cmd_id {
1445 /* Guest initialization commands */ 1456 /* Guest initialization commands */
diff --git a/tools/include/uapi/linux/mount.h b/tools/include/uapi/linux/mount.h
index 3f9ec42510b0..96a0240f23fe 100644
--- a/tools/include/uapi/linux/mount.h
+++ b/tools/include/uapi/linux/mount.h
@@ -55,4 +55,66 @@
55#define MS_MGC_VAL 0xC0ED0000 55#define MS_MGC_VAL 0xC0ED0000
56#define MS_MGC_MSK 0xffff0000 56#define MS_MGC_MSK 0xffff0000
57 57
58/*
59 * open_tree() flags.
60 */
61#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
62#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
63
64/*
65 * move_mount() flags.
66 */
67#define MOVE_MOUNT_F_SYMLINKS 0x00000001 /* Follow symlinks on from path */
68#define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
69#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
70#define MOVE_MOUNT_T_SYMLINKS 0x00000010 /* Follow symlinks on to path */
71#define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */
72#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
73#define MOVE_MOUNT__MASK 0x00000077
74
75/*
76 * fsopen() flags.
77 */
78#define FSOPEN_CLOEXEC 0x00000001
79
80/*
81 * fspick() flags.
82 */
83#define FSPICK_CLOEXEC 0x00000001
84#define FSPICK_SYMLINK_NOFOLLOW 0x00000002
85#define FSPICK_NO_AUTOMOUNT 0x00000004
86#define FSPICK_EMPTY_PATH 0x00000008
87
88/*
89 * The type of fsconfig() call made.
90 */
91enum fsconfig_command {
92 FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
93 FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */
94 FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */
95 FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */
96 FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */
97 FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */
98 FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */
99 FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */
100};
101
102/*
103 * fsmount() flags.
104 */
105#define FSMOUNT_CLOEXEC 0x00000001
106
107/*
108 * Mount attributes.
109 */
110#define MOUNT_ATTR_RDONLY 0x00000001 /* Mount read-only */
111#define MOUNT_ATTR_NOSUID 0x00000002 /* Ignore suid and sgid bits */
112#define MOUNT_ATTR_NODEV 0x00000004 /* Disallow access to device special files */
113#define MOUNT_ATTR_NOEXEC 0x00000008 /* Disallow program execution */
114#define MOUNT_ATTR__ATIME 0x00000070 /* Setting on how atime should be updated */
115#define MOUNT_ATTR_RELATIME 0x00000000 /* - Update atime relative to mtime/ctime. */
116#define MOUNT_ATTR_NOATIME 0x00000010 /* - Do not update access times. */
117#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
118#define MOUNT_ATTR_NODIRATIME 0x00000080 /* Do not update directory access times */
119
58#endif /* _UAPI_LINUX_MOUNT_H */ 120#endif /* _UAPI_LINUX_MOUNT_H */
diff --git a/tools/include/uapi/linux/sched.h b/tools/include/uapi/linux/sched.h
index 22627f80063e..ed4ee170bee2 100644
--- a/tools/include/uapi/linux/sched.h
+++ b/tools/include/uapi/linux/sched.h
@@ -10,6 +10,7 @@
10#define CLONE_FS 0x00000200 /* set if fs info shared between processes */ 10#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
11#define CLONE_FILES 0x00000400 /* set if open files shared between processes */ 11#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
12#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ 12#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
13#define CLONE_PIDFD 0x00001000 /* set if a pidfd should be placed in parent */
13#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ 14#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
14#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ 15#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
15#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ 16#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 75eaf10b9e1a..03348c4d6bd4 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -11,7 +11,7 @@
11#include "btf.h" 11#include "btf.h"
12#include "bpf.h" 12#include "bpf.h"
13#include "libbpf.h" 13#include "libbpf.h"
14#include "libbpf_util.h" 14#include "libbpf_internal.h"
15 15
16#define max(a, b) ((a) > (b) ? (a) : (b)) 16#define max(a, b) ((a) > (b) ? (a) : (b))
17#define min(a, b) ((a) < (b) ? (a) : (b)) 17#define min(a, b) ((a) < (b) ? (a) : (b))
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7e3b79d7c25f..197b574406b3 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -43,7 +43,6 @@
43#include "bpf.h" 43#include "bpf.h"
44#include "btf.h" 44#include "btf.h"
45#include "str_error.h" 45#include "str_error.h"
46#include "libbpf_util.h"
47#include "libbpf_internal.h" 46#include "libbpf_internal.h"
48 47
49#ifndef EM_BPF 48#ifndef EM_BPF
@@ -1696,7 +1695,7 @@ bpf_object__probe_caps(struct bpf_object *obj)
1696 for (i = 0; i < ARRAY_SIZE(probe_fn); i++) { 1695 for (i = 0; i < ARRAY_SIZE(probe_fn); i++) {
1697 ret = probe_fn[i](obj); 1696 ret = probe_fn[i](obj);
1698 if (ret < 0) 1697 if (ret < 0)
1699 return ret; 1698 pr_debug("Probe #%d failed with %d.\n", i, ret);
1700 } 1699 }
1701 1700
1702 return 0; 1701 return 0;
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 789e435b5900..f3025b4d90e1 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -21,6 +21,19 @@
21#define BTF_PARAM_ENC(name, type) (name), (type) 21#define BTF_PARAM_ENC(name, type) (name), (type)
22#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size) 22#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size)
23 23
24extern void libbpf_print(enum libbpf_print_level level,
25 const char *format, ...)
26 __attribute__((format(printf, 2, 3)));
27
28#define __pr(level, fmt, ...) \
29do { \
30 libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
31} while (0)
32
33#define pr_warning(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
34#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
35#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
36
24int libbpf__probe_raw_btf(const char *raw_types, size_t types_len, 37int libbpf__probe_raw_btf(const char *raw_types, size_t types_len,
25 const char *str_sec, size_t str_len); 38 const char *str_sec, size_t str_len);
26 39
diff --git a/tools/lib/bpf/libbpf_util.h b/tools/lib/bpf/libbpf_util.h
index da94c4cb2e4d..59c779c5790c 100644
--- a/tools/lib/bpf/libbpf_util.h
+++ b/tools/lib/bpf/libbpf_util.h
@@ -10,19 +10,6 @@
10extern "C" { 10extern "C" {
11#endif 11#endif
12 12
13extern void libbpf_print(enum libbpf_print_level level,
14 const char *format, ...)
15 __attribute__((format(printf, 2, 3)));
16
17#define __pr(level, fmt, ...) \
18do { \
19 libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
20} while (0)
21
22#define pr_warning(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
23#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
24#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
25
26/* Use these barrier functions instead of smp_[rw]mb() when they are 13/* Use these barrier functions instead of smp_[rw]mb() when they are
27 * used in a libbpf header file. That way they can be built into the 14 * used in a libbpf header file. That way they can be built into the
28 * application that uses libbpf. 15 * application that uses libbpf.
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index a3d1a302bc9c..38667b62f1fe 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -29,7 +29,7 @@
29 29
30#include "bpf.h" 30#include "bpf.h"
31#include "libbpf.h" 31#include "libbpf.h"
32#include "libbpf_util.h" 32#include "libbpf_internal.h"
33#include "xsk.h" 33#include "xsk.h"
34 34
35#ifndef SOL_XDP 35#ifndef SOL_XDP
diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
index c88fd32563eb..459469b7222c 100755
--- a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
@@ -56,7 +56,7 @@ create_table()
56 echo "};" 56 echo "};"
57} 57}
58 58
59$gcc -E -dM -x c $input \ 59$gcc -E -dM -x c -I $incpath/include/uapi $input \
60 |sed -ne 's/^#define __NR_//p' \ 60 |sed -ne 's/^#define __NR_//p' \
61 |sort -t' ' -k2 -nu \ 61 |sort -t' ' -k2 -nu \
62 |create_table 62 |create_table
diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
index 0b2054007314..a19690a17291 100644
--- a/tools/perf/arch/s390/util/machine.c
+++ b/tools/perf/arch/s390/util/machine.c
@@ -5,16 +5,19 @@
5#include "util.h" 5#include "util.h"
6#include "machine.h" 6#include "machine.h"
7#include "api/fs/fs.h" 7#include "api/fs/fs.h"
8#include "debug.h"
8 9
9int arch__fix_module_text_start(u64 *start, const char *name) 10int arch__fix_module_text_start(u64 *start, const char *name)
10{ 11{
12 u64 m_start = *start;
11 char path[PATH_MAX]; 13 char path[PATH_MAX];
12 14
13 snprintf(path, PATH_MAX, "module/%.*s/sections/.text", 15 snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
14 (int)strlen(name) - 2, name + 1); 16 (int)strlen(name) - 2, name + 1);
15 17 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
16 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) 18 pr_debug2("Using module %s start:%#lx\n", path, m_start);
17 return -1; 19 *start = m_start;
20 }
18 21
19 return 0; 22 return 0;
20} 23}
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index 92ee0b4378d4..b4e6f9e6204a 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -349,6 +349,12 @@
349425 common io_uring_setup __x64_sys_io_uring_setup 349425 common io_uring_setup __x64_sys_io_uring_setup
350426 common io_uring_enter __x64_sys_io_uring_enter 350426 common io_uring_enter __x64_sys_io_uring_enter
351427 common io_uring_register __x64_sys_io_uring_register 351427 common io_uring_register __x64_sys_io_uring_register
352428 common open_tree __x64_sys_open_tree
353429 common move_mount __x64_sys_move_mount
354430 common fsopen __x64_sys_fsopen
355431 common fsconfig __x64_sys_fsconfig
356432 common fsmount __x64_sys_fsmount
357433 common fspick __x64_sys_fspick
352 358
353# 359#
354# x32-specific system call numbers start at 512 to avoid cache impact 360# x32-specific system call numbers start at 512 to avoid cache impact
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 7691980b7df1..f101576d1c72 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -161,9 +161,16 @@ next_pair:
161 161
162 continue; 162 continue;
163 } 163 }
164 } else 164 } else if (mem_start == kallsyms.vmlinux_map->end) {
165 /*
166 * Ignore aliases to _etext, i.e. to the end of the kernel text area,
167 * such as __indirect_thunk_end.
168 */
169 continue;
170 } else {
165 pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n", 171 pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n",
166 mem_start, sym->name); 172 mem_start, sym->name);
173 }
167 174
168 err = -1; 175 err = -1;
169 } 176 }
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index e0311c9750ad..9097543a818b 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string)
271 if (i > 0) 271 if (i > 0)
272 strncpy(buffer, string, i); 272 strncpy(buffer, string, i);
273 } 273 }
274 strncat(buffer + p, numstr, 4); 274 memcpy(buffer + p, numstr, 4);
275 p += 3; 275 p += 3;
276 } 276 }
277 } 277 }
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 28a9541c4835..dc7aafe45a2b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL};
924 * symbol_name if it's not that important. 924 * symbol_name if it's not that important.
925 */ 925 */
926static int machine__get_running_kernel_start(struct machine *machine, 926static int machine__get_running_kernel_start(struct machine *machine,
927 const char **symbol_name, u64 *start) 927 const char **symbol_name,
928 u64 *start, u64 *end)
928{ 929{
929 char filename[PATH_MAX]; 930 char filename[PATH_MAX];
930 int i, err = -1; 931 int i, err = -1;
@@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct machine *machine,
949 *symbol_name = name; 950 *symbol_name = name;
950 951
951 *start = addr; 952 *start = addr;
953
954 err = kallsyms__get_function_start(filename, "_etext", &addr);
955 if (!err)
956 *end = addr;
957
952 return 0; 958 return 0;
953} 959}
954 960
@@ -1441,7 +1447,7 @@ int machine__create_kernel_maps(struct machine *machine)
1441 struct dso *kernel = machine__get_kernel(machine); 1447 struct dso *kernel = machine__get_kernel(machine);
1442 const char *name = NULL; 1448 const char *name = NULL;
1443 struct map *map; 1449 struct map *map;
1444 u64 addr = 0; 1450 u64 start = 0, end = ~0ULL;
1445 int ret; 1451 int ret;
1446 1452
1447 if (kernel == NULL) 1453 if (kernel == NULL)
@@ -1460,9 +1466,9 @@ int machine__create_kernel_maps(struct machine *machine)
1460 "continuing anyway...\n", machine->pid); 1466 "continuing anyway...\n", machine->pid);
1461 } 1467 }
1462 1468
1463 if (!machine__get_running_kernel_start(machine, &name, &addr)) { 1469 if (!machine__get_running_kernel_start(machine, &name, &start, &end)) {
1464 if (name && 1470 if (name &&
1465 map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { 1471 map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) {
1466 machine__destroy_kernel_maps(machine); 1472 machine__destroy_kernel_maps(machine);
1467 ret = -1; 1473 ret = -1;
1468 goto out_put; 1474 goto out_put;
@@ -1472,16 +1478,19 @@ int machine__create_kernel_maps(struct machine *machine)
1472 * we have a real start address now, so re-order the kmaps 1478 * we have a real start address now, so re-order the kmaps
1473 * assume it's the last in the kmaps 1479 * assume it's the last in the kmaps
1474 */ 1480 */
1475 machine__update_kernel_mmap(machine, addr, ~0ULL); 1481 machine__update_kernel_mmap(machine, start, end);
1476 } 1482 }
1477 1483
1478 if (machine__create_extra_kernel_maps(machine, kernel)) 1484 if (machine__create_extra_kernel_maps(machine, kernel))
1479 pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); 1485 pr_debug("Problems creating extra kernel maps, continuing anyway...\n");
1480 1486
1481 /* update end address of the kernel map using adjacent module address */ 1487 if (end == ~0ULL) {
1482 map = map__next(machine__kernel_map(machine)); 1488 /* update end address of the kernel map using adjacent module address */
1483 if (map) 1489 map = map__next(machine__kernel_map(machine));
1484 machine__set_kernel_mmap(machine, addr, map->start); 1490 if (map)
1491 machine__set_kernel_mmap(machine, start, map->start);
1492 }
1493
1485out_put: 1494out_put:
1486 dso__put(kernel); 1495 dso__put(kernel);
1487 return ret; 1496 return ret;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 2310a1752983..54cf163347f7 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -647,6 +647,26 @@ static void perf_event__throttle_swap(union perf_event *event,
647 swap_sample_id_all(event, &event->throttle + 1); 647 swap_sample_id_all(event, &event->throttle + 1);
648} 648}
649 649
650static void perf_event__namespaces_swap(union perf_event *event,
651 bool sample_id_all)
652{
653 u64 i;
654
655 event->namespaces.pid = bswap_32(event->namespaces.pid);
656 event->namespaces.tid = bswap_32(event->namespaces.tid);
657 event->namespaces.nr_namespaces = bswap_64(event->namespaces.nr_namespaces);
658
659 for (i = 0; i < event->namespaces.nr_namespaces; i++) {
660 struct perf_ns_link_info *ns = &event->namespaces.link_info[i];
661
662 ns->dev = bswap_64(ns->dev);
663 ns->ino = bswap_64(ns->ino);
664 }
665
666 if (sample_id_all)
667 swap_sample_id_all(event, &event->namespaces.link_info[i]);
668}
669
650static u8 revbyte(u8 b) 670static u8 revbyte(u8 b)
651{ 671{
652 int rev = (b >> 4) | ((b & 0xf) << 4); 672 int rev = (b >> 4) | ((b & 0xf) << 4);
@@ -887,6 +907,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
887 [PERF_RECORD_LOST_SAMPLES] = perf_event__all64_swap, 907 [PERF_RECORD_LOST_SAMPLES] = perf_event__all64_swap,
888 [PERF_RECORD_SWITCH] = perf_event__switch_swap, 908 [PERF_RECORD_SWITCH] = perf_event__switch_swap,
889 [PERF_RECORD_SWITCH_CPU_WIDE] = perf_event__switch_swap, 909 [PERF_RECORD_SWITCH_CPU_WIDE] = perf_event__switch_swap,
910 [PERF_RECORD_NAMESPACES] = perf_event__namespaces_swap,
890 [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap, 911 [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap,
891 [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap, 912 [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
892 [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap, 913 [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 403045a2bbea..b413ba5b9835 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -133,7 +133,7 @@ void thread__put(struct thread *thread)
133 } 133 }
134} 134}
135 135
136struct namespaces *thread__namespaces(const struct thread *thread) 136static struct namespaces *__thread__namespaces(const struct thread *thread)
137{ 137{
138 if (list_empty(&thread->namespaces_list)) 138 if (list_empty(&thread->namespaces_list))
139 return NULL; 139 return NULL;
@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread)
141 return list_first_entry(&thread->namespaces_list, struct namespaces, list); 141 return list_first_entry(&thread->namespaces_list, struct namespaces, list);
142} 142}
143 143
144struct namespaces *thread__namespaces(const struct thread *thread)
145{
146 struct namespaces *ns;
147
148 down_read((struct rw_semaphore *)&thread->namespaces_lock);
149 ns = __thread__namespaces(thread);
150 up_read((struct rw_semaphore *)&thread->namespaces_lock);
151
152 return ns;
153}
154
144static int __thread__set_namespaces(struct thread *thread, u64 timestamp, 155static int __thread__set_namespaces(struct thread *thread, u64 timestamp,
145 struct namespaces_event *event) 156 struct namespaces_event *event)
146{ 157{
147 struct namespaces *new, *curr = thread__namespaces(thread); 158 struct namespaces *new, *curr = __thread__namespaces(thread);
148 159
149 new = namespaces__new(event); 160 new = namespaces__new(event);
150 if (!new) 161 if (!new)
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
index a877803e4ba8..dd5d69529382 100644
--- a/tools/testing/selftests/bpf/.gitignore
+++ b/tools/testing/selftests/bpf/.gitignore
@@ -31,6 +31,7 @@ test_section_names
31test_tcpnotify_user 31test_tcpnotify_user
32test_libbpf 32test_libbpf
33test_tcp_check_syncookie_user 33test_tcp_check_syncookie_user
34test_sysctl
34alu32 35alu32
35libbpf.pc 36libbpf.pc
36libbpf.so.* 37libbpf.so.*
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index 6e80b66d7fb1..5f6f9e7aba2a 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -278,7 +278,7 @@ static int (*bpf_skb_change_type)(void *ctx, __u32 type) =
278 (void *) BPF_FUNC_skb_change_type; 278 (void *) BPF_FUNC_skb_change_type;
279static unsigned int (*bpf_get_hash_recalc)(void *ctx) = 279static unsigned int (*bpf_get_hash_recalc)(void *ctx) =
280 (void *) BPF_FUNC_get_hash_recalc; 280 (void *) BPF_FUNC_get_hash_recalc;
281static unsigned long long (*bpf_get_current_task)(void *ctx) = 281static unsigned long long (*bpf_get_current_task)(void) =
282 (void *) BPF_FUNC_get_current_task; 282 (void *) BPF_FUNC_get_current_task;
283static int (*bpf_skb_change_tail)(void *ctx, __u32 len, __u64 flags) = 283static int (*bpf_skb_change_tail)(void *ctx, __u32 len, __u64 flags) =
284 (void *) BPF_FUNC_skb_change_tail; 284 (void *) BPF_FUNC_skb_change_tail;
diff --git a/tools/testing/selftests/bpf/map_tests/.gitignore b/tools/testing/selftests/bpf/map_tests/.gitignore
new file mode 100644
index 000000000000..45984a364647
--- /dev/null
+++ b/tools/testing/selftests/bpf/map_tests/.gitignore
@@ -0,0 +1 @@
tests.h
diff --git a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
index 8b54adfd6264..fbd1d88a6095 100644
--- a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
+++ b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
@@ -242,12 +242,12 @@ void test_flow_dissector(void)
242 */ 242 */
243 243
244 err = bpf_prog_attach(prog_fd, 0, BPF_FLOW_DISSECTOR, 0); 244 err = bpf_prog_attach(prog_fd, 0, BPF_FLOW_DISSECTOR, 0);
245 CHECK(err, "bpf_prog_attach", "err %d errno %d", err, errno); 245 CHECK(err, "bpf_prog_attach", "err %d errno %d\n", err, errno);
246 246
247 tap_fd = create_tap("tap0"); 247 tap_fd = create_tap("tap0");
248 CHECK(tap_fd < 0, "create_tap", "tap_fd %d errno %d", tap_fd, errno); 248 CHECK(tap_fd < 0, "create_tap", "tap_fd %d errno %d\n", tap_fd, errno);
249 err = ifup("tap0"); 249 err = ifup("tap0");
250 CHECK(err, "ifup", "err %d errno %d", err, errno); 250 CHECK(err, "ifup", "err %d errno %d\n", err, errno);
251 251
252 for (i = 0; i < ARRAY_SIZE(tests); i++) { 252 for (i = 0; i < ARRAY_SIZE(tests); i++) {
253 struct bpf_flow_keys flow_keys = {}; 253 struct bpf_flow_keys flow_keys = {};
@@ -255,7 +255,7 @@ void test_flow_dissector(void)
255 __u32 key = 0; 255 __u32 key = 0;
256 256
257 err = tx_tap(tap_fd, &tests[i].pkt, sizeof(tests[i].pkt)); 257 err = tx_tap(tap_fd, &tests[i].pkt, sizeof(tests[i].pkt));
258 CHECK(err < 0, "tx_tap", "err %d errno %d", err, errno); 258 CHECK(err < 0, "tx_tap", "err %d errno %d\n", err, errno);
259 259
260 err = bpf_map_lookup_elem(keys_fd, &key, &flow_keys); 260 err = bpf_map_lookup_elem(keys_fd, &key, &flow_keys);
261 CHECK_ATTR(err, tests[i].name, "bpf_map_lookup_elem %d\n", err); 261 CHECK_ATTR(err, tests[i].name, "bpf_map_lookup_elem %d\n", err);
@@ -264,5 +264,6 @@ void test_flow_dissector(void)
264 CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys); 264 CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys);
265 } 265 }
266 266
267 bpf_prog_detach(prog_fd, BPF_FLOW_DISSECTOR);
267 bpf_object__close(obj); 268 bpf_object__close(obj);
268} 269}
diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c
index 781c7de343be..1b25a7e348dc 100644
--- a/tools/testing/selftests/bpf/test_lru_map.c
+++ b/tools/testing/selftests/bpf/test_lru_map.c
@@ -18,9 +18,11 @@
18#include <sys/wait.h> 18#include <sys/wait.h>
19 19
20#include <bpf/bpf.h> 20#include <bpf/bpf.h>
21#include <bpf/libbpf.h>
21 22
22#include "bpf_util.h" 23#include "bpf_util.h"
23#include "bpf_rlimit.h" 24#include "bpf_rlimit.h"
25#include "../../../include/linux/filter.h"
24 26
25#define LOCAL_FREE_TARGET (128) 27#define LOCAL_FREE_TARGET (128)
26#define PERCPU_FREE_TARGET (4) 28#define PERCPU_FREE_TARGET (4)
@@ -40,6 +42,68 @@ static int create_map(int map_type, int map_flags, unsigned int size)
40 return map_fd; 42 return map_fd;
41} 43}
42 44
45static int bpf_map_lookup_elem_with_ref_bit(int fd, unsigned long long key,
46 void *value)
47{
48 struct bpf_load_program_attr prog;
49 struct bpf_create_map_attr map;
50 struct bpf_insn insns[] = {
51 BPF_LD_MAP_VALUE(BPF_REG_9, 0, 0),
52 BPF_LD_MAP_FD(BPF_REG_1, fd),
53 BPF_LD_IMM64(BPF_REG_3, key),
54 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
55 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
56 BPF_STX_MEM(BPF_DW, BPF_REG_2, BPF_REG_3, 0),
57 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
58 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
59 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0),
60 BPF_STX_MEM(BPF_DW, BPF_REG_9, BPF_REG_1, 0),
61 BPF_MOV64_IMM(BPF_REG_0, 42),
62 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
63 BPF_MOV64_IMM(BPF_REG_0, 1),
64 BPF_EXIT_INSN(),
65 };
66 __u8 data[64] = {};
67 int mfd, pfd, ret, zero = 0;
68 __u32 retval = 0;
69
70 memset(&map, 0, sizeof(map));
71 map.map_type = BPF_MAP_TYPE_ARRAY;
72 map.key_size = sizeof(int);
73 map.value_size = sizeof(unsigned long long);
74 map.max_entries = 1;
75
76 mfd = bpf_create_map_xattr(&map);
77 if (mfd < 0)
78 return -1;
79
80 insns[0].imm = mfd;
81
82 memset(&prog, 0, sizeof(prog));
83 prog.prog_type = BPF_PROG_TYPE_SCHED_CLS;
84 prog.insns = insns;
85 prog.insns_cnt = ARRAY_SIZE(insns);
86 prog.license = "GPL";
87
88 pfd = bpf_load_program_xattr(&prog, NULL, 0);
89 if (pfd < 0) {
90 close(mfd);
91 return -1;
92 }
93
94 ret = bpf_prog_test_run(pfd, 1, data, sizeof(data),
95 NULL, NULL, &retval, NULL);
96 if (ret < 0 || retval != 42) {
97 ret = -1;
98 } else {
99 assert(!bpf_map_lookup_elem(mfd, &zero, value));
100 ret = 0;
101 }
102 close(pfd);
103 close(mfd);
104 return ret;
105}
106
43static int map_subset(int map0, int map1) 107static int map_subset(int map0, int map1)
44{ 108{
45 unsigned long long next_key = 0; 109 unsigned long long next_key = 0;
@@ -87,7 +151,7 @@ static int sched_next_online(int pid, int *next_to_try)
87 return ret; 151 return ret;
88} 152}
89 153
90/* Size of the LRU amp is 2 154/* Size of the LRU map is 2
91 * Add key=1 (+1 key) 155 * Add key=1 (+1 key)
92 * Add key=2 (+1 key) 156 * Add key=2 (+1 key)
93 * Lookup Key=1 157 * Lookup Key=1
@@ -157,7 +221,7 @@ static void test_lru_sanity0(int map_type, int map_flags)
157 * stop LRU from removing key=1 221 * stop LRU from removing key=1
158 */ 222 */
159 key = 1; 223 key = 1;
160 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 224 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
161 assert(value[0] == 1234); 225 assert(value[0] == 1234);
162 226
163 key = 3; 227 key = 3;
@@ -167,7 +231,8 @@ static void test_lru_sanity0(int map_type, int map_flags)
167 231
168 /* key=2 has been removed from the LRU */ 232 /* key=2 has been removed from the LRU */
169 key = 2; 233 key = 2;
170 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1); 234 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
235 errno == ENOENT);
171 236
172 assert(map_equal(lru_map_fd, expected_map_fd)); 237 assert(map_equal(lru_map_fd, expected_map_fd));
173 238
@@ -221,7 +286,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
221 /* Lookup 1 to tgt_free/2 */ 286 /* Lookup 1 to tgt_free/2 */
222 end_key = 1 + batch_size; 287 end_key = 1 + batch_size;
223 for (key = 1; key < end_key; key++) { 288 for (key = 1; key < end_key; key++) {
224 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 289 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
225 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 290 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
226 BPF_NOEXIST)); 291 BPF_NOEXIST));
227 } 292 }
@@ -322,10 +387,11 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
322 end_key = 1 + batch_size; 387 end_key = 1 + batch_size;
323 value[0] = 4321; 388 value[0] = 4321;
324 for (key = 1; key < end_key; key++) { 389 for (key = 1; key < end_key; key++) {
325 assert(bpf_map_lookup_elem(lru_map_fd, &key, value)); 390 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
391 errno == ENOENT);
326 assert(!bpf_map_update_elem(lru_map_fd, &key, value, 392 assert(!bpf_map_update_elem(lru_map_fd, &key, value,
327 BPF_NOEXIST)); 393 BPF_NOEXIST));
328 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 394 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
329 assert(value[0] == 4321); 395 assert(value[0] == 4321);
330 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 396 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
331 BPF_NOEXIST)); 397 BPF_NOEXIST));
@@ -404,7 +470,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
404 /* Lookup key 1 to tgt_free*3/2 */ 470 /* Lookup key 1 to tgt_free*3/2 */
405 end_key = tgt_free + batch_size; 471 end_key = tgt_free + batch_size;
406 for (key = 1; key < end_key; key++) { 472 for (key = 1; key < end_key; key++) {
407 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 473 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
408 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 474 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
409 BPF_NOEXIST)); 475 BPF_NOEXIST));
410 } 476 }
@@ -463,7 +529,7 @@ static void test_lru_sanity4(int map_type, int map_flags, unsigned int tgt_free)
463 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); 529 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
464 530
465 for (key = 1; key <= tgt_free; key++) { 531 for (key = 1; key <= tgt_free; key++) {
466 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 532 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
467 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 533 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
468 BPF_NOEXIST)); 534 BPF_NOEXIST));
469 } 535 }
@@ -494,16 +560,16 @@ static void do_test_lru_sanity5(unsigned long long last_key, int map_fd)
494 unsigned long long key, value[nr_cpus]; 560 unsigned long long key, value[nr_cpus];
495 561
496 /* Ensure the last key inserted by previous CPU can be found */ 562 /* Ensure the last key inserted by previous CPU can be found */
497 assert(!bpf_map_lookup_elem(map_fd, &last_key, value)); 563 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, last_key, value));
498
499 value[0] = 1234; 564 value[0] = 1234;
500 565
501 key = last_key + 1; 566 key = last_key + 1;
502 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); 567 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST));
503 assert(!bpf_map_lookup_elem(map_fd, &key, value)); 568 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, key, value));
504 569
505 /* Cannot find the last key because it was removed by LRU */ 570 /* Cannot find the last key because it was removed by LRU */
506 assert(bpf_map_lookup_elem(map_fd, &last_key, value)); 571 assert(bpf_map_lookup_elem(map_fd, &last_key, value) == -1 &&
572 errno == ENOENT);
507} 573}
508 574
509/* Test map with only one element */ 575/* Test map with only one element */
@@ -590,8 +656,8 @@ static void test_lru_sanity6(int map_type, int map_flags, int tgt_free)
590 /* Make ref bit sticky for key: [1, tgt_free] */ 656 /* Make ref bit sticky for key: [1, tgt_free] */
591 for (stable_key = 1; stable_key <= tgt_free; stable_key++) { 657 for (stable_key = 1; stable_key <= tgt_free; stable_key++) {
592 /* Mark the ref bit */ 658 /* Mark the ref bit */
593 assert(!bpf_map_lookup_elem(lru_map_fd, &stable_key, 659 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd,
594 value)); 660 stable_key, value));
595 } 661 }
596 assert(!bpf_map_update_elem(lru_map_fd, &key, value, 662 assert(!bpf_map_update_elem(lru_map_fd, &key, value,
597 BPF_NOEXIST)); 663 BPF_NOEXIST));
@@ -612,6 +678,198 @@ static void test_lru_sanity6(int map_type, int map_flags, int tgt_free)
612 printf("Pass\n"); 678 printf("Pass\n");
613} 679}
614 680
681/* Size of the LRU map is 2
682 * Add key=1 (+1 key)
683 * Add key=2 (+1 key)
684 * Lookup Key=1 (datapath)
685 * Lookup Key=2 (syscall)
686 * Add Key=3
687 * => Key=2 will be removed by LRU
688 * Iterate map. Only found key=1 and key=3
689 */
690static void test_lru_sanity7(int map_type, int map_flags)
691{
692 unsigned long long key, value[nr_cpus];
693 int lru_map_fd, expected_map_fd;
694 int next_cpu = 0;
695
696 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
697 map_flags);
698
699 assert(sched_next_online(0, &next_cpu) != -1);
700
701 if (map_flags & BPF_F_NO_COMMON_LRU)
702 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus);
703 else
704 lru_map_fd = create_map(map_type, map_flags, 2);
705 assert(lru_map_fd != -1);
706
707 expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, 2);
708 assert(expected_map_fd != -1);
709
710 value[0] = 1234;
711
712 /* insert key=1 element */
713
714 key = 1;
715 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
716 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
717 BPF_NOEXIST));
718
719 /* BPF_NOEXIST means: add new element if it doesn't exist */
720 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1
721 /* key=1 already exists */
722 && errno == EEXIST);
723
724 /* insert key=2 element */
725
726 /* check that key=2 is not found */
727 key = 2;
728 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
729 errno == ENOENT);
730
731 /* BPF_EXIST means: update existing element */
732 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 &&
733 /* key=2 is not there */
734 errno == ENOENT);
735
736 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
737
738 /* insert key=3 element */
739
740 /* check that key=3 is not found */
741 key = 3;
742 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
743 errno == ENOENT);
744
745 /* check that key=1 can be found and mark the ref bit to
746 * stop LRU from removing key=1
747 */
748 key = 1;
749 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
750 assert(value[0] == 1234);
751
752 /* check that key=2 can be found and do _not_ mark ref bit.
753 * this will be evicted on next update.
754 */
755 key = 2;
756 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
757 assert(value[0] == 1234);
758
759 key = 3;
760 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
761 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
762 BPF_NOEXIST));
763
764 /* key=2 has been removed from the LRU */
765 key = 2;
766 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
767 errno == ENOENT);
768
769 assert(map_equal(lru_map_fd, expected_map_fd));
770
771 close(expected_map_fd);
772 close(lru_map_fd);
773
774 printf("Pass\n");
775}
776
777/* Size of the LRU map is 2
778 * Add key=1 (+1 key)
779 * Add key=2 (+1 key)
780 * Lookup Key=1 (syscall)
781 * Lookup Key=2 (datapath)
782 * Add Key=3
783 * => Key=1 will be removed by LRU
784 * Iterate map. Only found key=2 and key=3
785 */
786static void test_lru_sanity8(int map_type, int map_flags)
787{
788 unsigned long long key, value[nr_cpus];
789 int lru_map_fd, expected_map_fd;
790 int next_cpu = 0;
791
792 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
793 map_flags);
794
795 assert(sched_next_online(0, &next_cpu) != -1);
796
797 if (map_flags & BPF_F_NO_COMMON_LRU)
798 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus);
799 else
800 lru_map_fd = create_map(map_type, map_flags, 2);
801 assert(lru_map_fd != -1);
802
803 expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, 2);
804 assert(expected_map_fd != -1);
805
806 value[0] = 1234;
807
808 /* insert key=1 element */
809
810 key = 1;
811 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
812
813 /* BPF_NOEXIST means: add new element if it doesn't exist */
814 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1
815 /* key=1 already exists */
816 && errno == EEXIST);
817
818 /* insert key=2 element */
819
820 /* check that key=2 is not found */
821 key = 2;
822 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
823 errno == ENOENT);
824
825 /* BPF_EXIST means: update existing element */
826 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 &&
827 /* key=2 is not there */
828 errno == ENOENT);
829
830 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
831 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
832 BPF_NOEXIST));
833
834 /* insert key=3 element */
835
836 /* check that key=3 is not found */
837 key = 3;
838 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
839 errno == ENOENT);
840
841 /* check that key=1 can be found and do _not_ mark ref bit.
842 * this will be evicted on next update.
843 */
844 key = 1;
845 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
846 assert(value[0] == 1234);
847
848 /* check that key=2 can be found and mark the ref bit to
849 * stop LRU from removing key=2
850 */
851 key = 2;
852 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
853 assert(value[0] == 1234);
854
855 key = 3;
856 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
857 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
858 BPF_NOEXIST));
859
860 /* key=1 has been removed from the LRU */
861 key = 1;
862 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
863 errno == ENOENT);
864
865 assert(map_equal(lru_map_fd, expected_map_fd));
866
867 close(expected_map_fd);
868 close(lru_map_fd);
869
870 printf("Pass\n");
871}
872
615int main(int argc, char **argv) 873int main(int argc, char **argv)
616{ 874{
617 int map_types[] = {BPF_MAP_TYPE_LRU_HASH, 875 int map_types[] = {BPF_MAP_TYPE_LRU_HASH,
@@ -637,6 +895,8 @@ int main(int argc, char **argv)
637 test_lru_sanity4(map_types[t], map_flags[f], tgt_free); 895 test_lru_sanity4(map_types[t], map_flags[f], tgt_free);
638 test_lru_sanity5(map_types[t], map_flags[f]); 896 test_lru_sanity5(map_types[t], map_flags[f]);
639 test_lru_sanity6(map_types[t], map_flags[f], tgt_free); 897 test_lru_sanity6(map_types[t], map_flags[f], tgt_free);
898 test_lru_sanity7(map_types[t], map_flags[f]);
899 test_lru_sanity8(map_types[t], map_flags[f]);
640 900
641 printf("\n"); 901 printf("\n");
642 } 902 }
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index 524b15dabb3c..b9171a7b3aaa 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -430,15 +430,15 @@ setup_xfrm() {
430 veth_a_addr="${2}" 430 veth_a_addr="${2}"
431 veth_b_addr="${3}" 431 veth_b_addr="${3}"
432 432
433 run_cmd "${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" || return 1 433 run_cmd ${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 1
434 run_cmd "${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 434 run_cmd ${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
435 run_cmd "${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel" 435 run_cmd ${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
436 run_cmd "${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel" 436 run_cmd ${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
437 437
438 run_cmd "${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 438 run_cmd ${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
439 run_cmd "${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 439 run_cmd ${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
440 run_cmd "${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel" 440 run_cmd ${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
441 run_cmd "${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel" 441 run_cmd ${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
442} 442}
443 443
444setup_xfrm4() { 444setup_xfrm4() {
diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
index 21159f5f3362..14fcf3104c77 100755
--- a/tools/testing/selftests/netfilter/nft_nat.sh
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -8,6 +8,11 @@ ksft_skip=4
8ret=0 8ret=0
9test_inet_nat=true 9test_inet_nat=true
10 10
11cleanup()
12{
13 for i in 0 1 2; do ip netns del ns$i;done
14}
15
11nft --version > /dev/null 2>&1 16nft --version > /dev/null 2>&1
12if [ $? -ne 0 ];then 17if [ $? -ne 0 ];then
13 echo "SKIP: Could not run test without nft tool" 18 echo "SKIP: Could not run test without nft tool"
@@ -21,6 +26,13 @@ if [ $? -ne 0 ];then
21fi 26fi
22 27
23ip netns add ns0 28ip netns add ns0
29if [ $? -ne 0 ];then
30 echo "SKIP: Could not create net namespace"
31 exit $ksft_skip
32fi
33
34trap cleanup EXIT
35
24ip netns add ns1 36ip netns add ns1
25ip netns add ns2 37ip netns add ns2
26 38
@@ -347,7 +359,7 @@ EOF
347test_masquerade6() 359test_masquerade6()
348{ 360{
349 local family=$1 361 local family=$1
350 local natflags=$1 362 local natflags=$2
351 local lret=0 363 local lret=0
352 364
353 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null 365 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
@@ -392,18 +404,13 @@ EOF
392 404
393 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 405 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
394 if [ $? -ne 0 ] ; then 406 if [ $? -ne 0 ] ; then
395<<<<<<< HEAD 407 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
396 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
397=======
398 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags"
399>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
400 lret=1 408 lret=1
401 fi 409 fi
402 410
403 # ns1 should have seen packets from ns0, due to masquerade 411 # ns1 should have seen packets from ns0, due to masquerade
404 expect="packets 1 bytes 104" 412 expect="packets 1 bytes 104"
405 for dir in "in6" "out6" ; do 413 for dir in "in6" "out6" ; do
406
407 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect") 414 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
408 if [ $? -ne 0 ]; then 415 if [ $? -ne 0 ]; then
409 bad_counter ns1 ns0$dir "$expect" 416 bad_counter ns1 ns0$dir "$expect"
@@ -433,38 +440,27 @@ EOF
433 fi 440 fi
434 done 441 done
435 442
436<<<<<<< HEAD
437 ip netns exec ns0 nft flush chain $family nat postrouting
438=======
439 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 443 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
440 if [ $? -ne 0 ] ; then 444 if [ $? -ne 0 ] ; then
441 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)" 445 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)"
442 lret=1 446 lret=1
443 fi 447 fi
444 448
445 ip netns exec ns0 nft flush chain ip6 nat postrouting 449 ip netns exec ns0 nft flush chain $family nat postrouting
446>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
447 if [ $? -ne 0 ]; then 450 if [ $? -ne 0 ]; then
448 echo "ERROR: Could not flush $family nat postrouting" 1>&2 451 echo "ERROR: Could not flush $family nat postrouting" 1>&2
449 lret=1 452 lret=1
450 fi 453 fi
451 454
452<<<<<<< HEAD 455 test $lret -eq 0 && echo "PASS: $family IPv6 masquerade $natflags for ns2"
453 test $lret -eq 0 && echo "PASS: $family IPv6 masquerade for ns2"
454=======
455 test $lret -eq 0 && echo "PASS: IPv6 masquerade $natflags for ns2"
456>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
457 456
458 return $lret 457 return $lret
459} 458}
460 459
461test_masquerade() 460test_masquerade()
462{ 461{
463<<<<<<< HEAD
464 local family=$1 462 local family=$1
465======= 463 local natflags=$2
466 local natflags=$1
467>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
468 local lret=0 464 local lret=0
469 465
470 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null 466 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
@@ -509,11 +505,7 @@ EOF
509 505
510 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 506 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
511 if [ $? -ne 0 ] ; then 507 if [ $? -ne 0 ] ; then
512<<<<<<< HEAD 508 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
513 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
514=======
515 echo "ERROR: cannot ping ns1 from ns2 with active ip masquere $natflags"
516>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
517 lret=1 509 lret=1
518 fi 510 fi
519 511
@@ -549,27 +541,19 @@ EOF
549 fi 541 fi
550 done 542 done
551 543
552<<<<<<< HEAD
553 ip netns exec ns0 nft flush chain $family nat postrouting
554=======
555 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 544 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
556 if [ $? -ne 0 ] ; then 545 if [ $? -ne 0 ] ; then
557 echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)" 546 echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)"
558 lret=1 547 lret=1
559 fi 548 fi
560 549
561 ip netns exec ns0 nft flush chain ip nat postrouting 550 ip netns exec ns0 nft flush chain $family nat postrouting
562>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
563 if [ $? -ne 0 ]; then 551 if [ $? -ne 0 ]; then
564 echo "ERROR: Could not flush $family nat postrouting" 1>&2 552 echo "ERROR: Could not flush $family nat postrouting" 1>&2
565 lret=1 553 lret=1
566 fi 554 fi
567 555
568<<<<<<< HEAD 556 test $lret -eq 0 && echo "PASS: $family IP masquerade $natflags for ns2"
569 test $lret -eq 0 && echo "PASS: $family IP masquerade for ns2"
570=======
571 test $lret -eq 0 && echo "PASS: IP masquerade $natflags for ns2"
572>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
573 557
574 return $lret 558 return $lret
575} 559}
@@ -842,21 +826,14 @@ reset_counters
842$test_inet_nat && test_local_dnat inet 826$test_inet_nat && test_local_dnat inet
843$test_inet_nat && test_local_dnat6 inet 827$test_inet_nat && test_local_dnat6 inet
844 828
829for flags in "" "fully-random"; do
845reset_counters 830reset_counters
846<<<<<<< HEAD 831test_masquerade ip $flags
847test_masquerade ip 832test_masquerade6 ip6 $flags
848test_masquerade6 ip6
849reset_counters 833reset_counters
850$test_inet_nat && test_masquerade inet 834$test_inet_nat && test_masquerade inet $flags
851$test_inet_nat && test_masquerade6 inet 835$test_inet_nat && test_masquerade6 inet $flags
852======= 836done
853test_masquerade ""
854test_masquerade6 ""
855
856reset_counters
857test_masquerade "fully-random"
858test_masquerade6 "fully-random"
859>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
860 837
861reset_counters 838reset_counters
862test_redirect ip 839test_redirect ip
@@ -865,6 +842,4 @@ reset_counters
865$test_inet_nat && test_redirect inet 842$test_inet_nat && test_redirect inet
866$test_inet_nat && test_redirect6 inet 843$test_inet_nat && test_redirect6 inet
867 844
868for i in 0 1 2; do ip netns del ns$i;done
869
870exit $ret 845exit $ret