Skip to content

Commit 8921965

Browse files
committed
Merge: [s390] Upgrade the SMC driver to latest from upstream
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6875 JIRA: https://issues.redhat.com/browse/RHEL-73484 Conflicts: Code changes necessary to adapt to existing differences to upstream - no functional change CVE: CVE-2024-57791 Ark-kernel MR: [3874](https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3874) Commits: ``` e40b801 79a2223 407db47 9744d2b 3511227 b24aa14 71c6aa0 c308e9e 1e70094 7290178 6ac1e65 7f0620b 69b888e bbed596 6912e72 f5146e3 c68681a 4abbd2e 5211c97 c5bf605 aa96fbd f8e80fc 1f2c9dd e7bed88 c5a1039 ac053a1 5205ac4 9505450 ece60db 00e006a 8dd512d b40584d 01fd161 c6b8b8e b3bf760 9dbe086 c3dfcdb b27696c af398bd 9748dbc 784c46f 46ac644 45783ee f7a2207 d1d8d0b c8df2d4 0479134 4398888 cc0ab80 c3a910f 3ac14b9 2f4b101 d0e3565 13543d0 d25a92c 2b33eb8 679e9dd a29e220 7863c9f 9ab332d c5b8ee5 ``` Omitted-fix: 2fe5273 ("net/smc: prevent UAF in inet_create()") Omitted-fix: 98d4435 ("net/smc: prevent NULL pointer dereference in txopt_get") Omitted-fix: 6fd27ea ("net/smc: fix lacks of icsk_syn_mss with IPPROTO_SMC") Omitted-fix: d293958 ("net/smc: do not leave a dangling sk pointer in __smc_create()") Omitted-fix: 752e221 ("smc: Fix lockdep false-positive for IPPROTO_SMC.") Omitted-fix: d27a835 ("net/smc: add the max value of fallback reason count") Omitted-fix: 25c12b4 ("net/smc: Fix memory leak when using percpu refs") Omitted-fix: ed86525 ("tools/include: Sync network socket headers with the kernel sources") Omitted-fix: 0a3e693 ("net/smc: Use static_assert() to check struct sizes") Omitted-fix: b013b81 ("nvme-tcp: fix use-after-free of netns by kernel TCP socket.") Signed-off-by: Mete Durlu <mdurlu@redhat.com> Approved-by: Marcelo Ricardo Leitner <mleitner@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 58db71a + dda5e87 commit 8921965

File tree

37 files changed

+1885
-497
lines changed

37 files changed

+1885
-497
lines changed

Documentation/networking/smc-sysctl.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ smcr_testlink_time - INTEGER
4141
disabling TEST_LINK.
4242

4343
Default: 30 seconds.
44+
45+
smcr_max_links_per_lgr - INTEGER
46+
Controls the max number of links can be added to a SMC-R link group. Notice that
47+
the actual number of the links added to a SMC-R link group depends on the number
48+
of RDMA devices exist in the system. The acceptable value ranges from 1 to 2. Only
49+
for SMC-R v2.1 and later.
50+
51+
Default: 2
52+
53+
smcr_max_conns_per_lgr - INTEGER
54+
Controls the max number of connections can be added to a SMC-R link group. The
55+
acceptable value ranges from 16 to 255. Only for SMC-R v2.1 and later.
56+
57+
Default: 255

drivers/s390/net/ism.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
#define ISM_DMB_WORD_OFFSET 1
1818
#define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32)
19-
#define ISM_IDENT_MASK 0x00FFFF
2019

2120
#define ISM_REG_SBA 0x1
2221
#define ISM_REG_IEQ 0x2
@@ -192,12 +191,6 @@ struct ism_sba {
192191
#define ISM_CREATE_REQ(dmb, idx, sf, offset) \
193192
((dmb) | (idx) << 24 | (sf) << 23 | (offset))
194193

195-
struct ism_systemeid {
196-
u8 seid_string[24];
197-
u8 serial_number[4];
198-
u8 type[4];
199-
};
200-
201194
static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
202195
unsigned long offset, unsigned long len)
203196
{

drivers/s390/net/ism_drv.c

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static struct ism_client *clients[MAX_CLIENTS]; /* use an array rather than */
3636
/* a list for fast mapping */
3737
static u8 max_client;
3838
static DEFINE_MUTEX(clients_lock);
39+
static bool ism_v2_capable;
3940
struct ism_dev_list {
4041
struct list_head list;
4142
struct mutex mutex; /* protects ism device list */
@@ -462,32 +463,6 @@ int ism_move(struct ism_dev *ism, u64 dmb_tok, unsigned int idx, bool sf,
462463
}
463464
EXPORT_SYMBOL_GPL(ism_move);
464465

465-
static struct ism_systemeid SYSTEM_EID = {
466-
.seid_string = "IBM-SYSZ-ISMSEID00000000",
467-
.serial_number = "0000",
468-
.type = "0000",
469-
};
470-
471-
static void ism_create_system_eid(void)
472-
{
473-
struct cpuid id;
474-
u16 ident_tail;
475-
char tmp[5];
476-
477-
get_cpu_id(&id);
478-
ident_tail = (u16)(id.ident & ISM_IDENT_MASK);
479-
snprintf(tmp, 5, "%04X", ident_tail);
480-
memcpy(&SYSTEM_EID.serial_number, tmp, 4);
481-
snprintf(tmp, 5, "%04X", id.machine);
482-
memcpy(&SYSTEM_EID.type, tmp, 4);
483-
}
484-
485-
u8 *ism_get_seid(void)
486-
{
487-
return SYSTEM_EID.seid_string;
488-
}
489-
EXPORT_SYMBOL_GPL(ism_get_seid);
490-
491466
static void ism_handle_event(struct ism_dev *ism)
492467
{
493468
struct ism_event *entry;
@@ -579,7 +554,9 @@ static int ism_dev_init(struct ism_dev *ism)
579554

580555
if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID))
581556
/* hardware is V2 capable */
582-
ism_create_system_eid();
557+
ism_v2_capable = true;
558+
else
559+
ism_v2_capable = false;
583560

584561
mutex_lock(&ism_dev_list.mutex);
585562
mutex_lock(&clients_lock);
@@ -684,8 +661,7 @@ static void ism_dev_exit(struct ism_dev *ism)
684661
}
685662
mutex_unlock(&clients_lock);
686663

687-
if (SYSTEM_EID.serial_number[0] != '0' ||
688-
SYSTEM_EID.type[0] != '0')
664+
if (ism_v2_capable)
689665
ism_del_vlan_id(ism, ISM_RESERVED_VLANID);
690666
unregister_ieq(ism);
691667
unregister_sba(ism);
@@ -762,14 +738,14 @@ static int ism_query_rgid(struct ism_dev *ism, u64 rgid, u32 vid_valid,
762738
return ism_cmd(ism, &cmd);
763739
}
764740

765-
static int smcd_query_rgid(struct smcd_dev *smcd, u64 rgid, u32 vid_valid,
766-
u32 vid)
741+
static int smcd_query_rgid(struct smcd_dev *smcd, struct smcd_gid *rgid,
742+
u32 vid_valid, u32 vid)
767743
{
768-
return ism_query_rgid(smcd->priv, rgid, vid_valid, vid);
744+
return ism_query_rgid(smcd->priv, rgid->gid, vid_valid, vid);
769745
}
770746

771747
static int smcd_register_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb,
772-
struct ism_client *client)
748+
void *client)
773749
{
774750
return ism_register_dmb(smcd->priv, (struct ism_dmb *)dmb, client);
775751
}
@@ -816,10 +792,11 @@ static int ism_signal_ieq(struct ism_dev *ism, u64 rgid, u32 trigger_irq,
816792
return ism_cmd(ism, &cmd);
817793
}
818794

819-
static int smcd_signal_ieq(struct smcd_dev *smcd, u64 rgid, u32 trigger_irq,
820-
u32 event_code, u64 info)
795+
static int smcd_signal_ieq(struct smcd_dev *smcd, struct smcd_gid *rgid,
796+
u32 trigger_irq, u32 event_code, u64 info)
821797
{
822-
return ism_signal_ieq(smcd->priv, rgid, trigger_irq, event_code, info);
798+
return ism_signal_ieq(smcd->priv, rgid->gid,
799+
trigger_irq, event_code, info);
823800
}
824801

825802
static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
@@ -831,18 +808,19 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
831808

832809
static int smcd_supports_v2(void)
833810
{
834-
return SYSTEM_EID.serial_number[0] != '0' ||
835-
SYSTEM_EID.type[0] != '0';
811+
return ism_v2_capable;
836812
}
837813

838814
static u64 ism_get_local_gid(struct ism_dev *ism)
839815
{
840816
return ism->local_gid;
841817
}
842818

843-
static u64 smcd_get_local_gid(struct smcd_dev *smcd)
819+
static void smcd_get_local_gid(struct smcd_dev *smcd,
820+
struct smcd_gid *smcd_gid)
844821
{
845-
return ism_get_local_gid(smcd->priv);
822+
smcd_gid->gid = ism_get_local_gid(smcd->priv);
823+
smcd_gid->gid_ext = 0;
846824
}
847825

848826
static u16 ism_get_chid(struct ism_dev *ism)
@@ -876,7 +854,6 @@ static const struct smcd_ops ism_ops = {
876854
.signal_event = smcd_signal_ieq,
877855
.move_data = smcd_move,
878856
.supports_v2 = smcd_supports_v2,
879-
.get_system_eid = ism_get_seid,
880857
.get_local_gid = smcd_get_local_gid,
881858
.get_chid = smcd_get_chid,
882859
.get_dev = smcd_get_dev,

include/linux/ism.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ int ism_register_dmb(struct ism_dev *dev, struct ism_dmb *dmb,
8686
int ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb);
8787
int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf,
8888
unsigned int offset, void *data, unsigned int size);
89-
u8 *ism_get_seid(void);
9089

9190
const struct smcd_ops *ism_get_smcd_ops(void);
9291

include/net/netns/smc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ struct netns_smc {
2020
unsigned int sysctl_autocorking_size;
2121
unsigned int sysctl_smcr_buf_type;
2222
int sysctl_smcr_testlink_time;
23+
int sysctl_max_links_per_lgr;
24+
int sysctl_max_conns_per_lgr;
2325
};
2426
#endif

include/net/smc.h

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ struct smc_hashinfo {
2626
struct hlist_head ht;
2727
};
2828

29-
int smc_hash_sk(struct sock *sk);
30-
void smc_unhash_sk(struct sock *sk);
31-
3229
/* SMCD/ISM device driver interface */
3330
struct smcd_dmb {
3431
u64 dmb_tok;
@@ -50,33 +47,42 @@ struct smcd_dmb {
5047
#define ISM_ERROR 0xFFFF
5148

5249
struct smcd_dev;
53-
struct ism_client;
50+
51+
struct smcd_gid {
52+
u64 gid;
53+
u64 gid_ext;
54+
};
5455

5556
struct smcd_ops {
56-
int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
57-
u32 vid);
57+
int (*query_remote_gid)(struct smcd_dev *dev, struct smcd_gid *rgid,
58+
u32 vid_valid, u32 vid);
5859
int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb,
59-
struct ism_client *client);
60+
void *client);
6061
int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
61-
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
62-
int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
63-
int (*set_vlan_required)(struct smcd_dev *dev);
64-
int (*reset_vlan_required)(struct smcd_dev *dev);
65-
int (*signal_event)(struct smcd_dev *dev, u64 rgid, u32 trigger_irq,
66-
u32 event_code, u64 info);
6762
int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
6863
bool sf, unsigned int offset, void *data,
6964
unsigned int size);
7065
int (*supports_v2)(void);
71-
u8* (*get_system_eid)(void);
72-
u64 (*get_local_gid)(struct smcd_dev *dev);
66+
void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
7367
u16 (*get_chid)(struct smcd_dev *dev);
7468
struct device* (*get_dev)(struct smcd_dev *dev);
69+
70+
/* optional operations */
71+
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
72+
int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
73+
int (*set_vlan_required)(struct smcd_dev *dev);
74+
int (*reset_vlan_required)(struct smcd_dev *dev);
75+
int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid,
76+
u32 trigger_irq, u32 event_code, u64 info);
77+
int (*support_dmb_nocopy)(struct smcd_dev *dev);
78+
int (*attach_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
79+
int (*detach_dmb)(struct smcd_dev *dev, u64 token);
7580
};
7681

7782
struct smcd_dev {
7883
const struct smcd_ops *ops;
7984
void *priv;
85+
void *client;
8086
struct list_head list;
8187
spinlock_t lock;
8288
struct smc_connection **conn;

include/uapi/linux/in.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ enum {
8181
#define IPPROTO_ETHERNET IPPROTO_ETHERNET
8282
IPPROTO_RAW = 255, /* Raw IP packets */
8383
#define IPPROTO_RAW IPPROTO_RAW
84+
IPPROTO_SMC = 256, /* Shared Memory Communications */
85+
#define IPPROTO_SMC IPPROTO_SMC
8486
IPPROTO_MPTCP = 262, /* Multipath TCP connection */
8587
#define IPPROTO_MPTCP IPPROTO_MPTCP
8688
IPPROTO_MAX

include/uapi/linux/smc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ enum {
107107
enum {
108108
SMC_NLA_LGR_R_V2_UNSPEC,
109109
SMC_NLA_LGR_R_V2_DIRECT, /* u8 */
110+
SMC_NLA_LGR_R_V2_MAX_CONNS, /* u8 */
111+
SMC_NLA_LGR_R_V2_MAX_LINKS, /* u8 */
110112
__SMC_NLA_LGR_R_V2_MAX,
111113
SMC_NLA_LGR_R_V2_MAX = __SMC_NLA_LGR_R_V2_MAX - 1
112114
};
@@ -158,6 +160,8 @@ enum {
158160
SMC_NLA_LGR_D_CHID, /* u16 */
159161
SMC_NLA_LGR_D_PAD, /* flag */
160162
SMC_NLA_LGR_D_V2_COMMON, /* nest */
163+
SMC_NLA_LGR_D_EXT_GID, /* u64 */
164+
SMC_NLA_LGR_D_PEER_EXT_GID, /* u64 */
161165
__SMC_NLA_LGR_D_MAX,
162166
SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX - 1
163167
};

include/uapi/linux/smc_diag.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ struct smcd_diag_dmbinfo { /* SMC-D Socket internals */
107107
__aligned_u64 my_gid; /* My GID */
108108
__aligned_u64 token; /* Token of DMB */
109109
__aligned_u64 peer_token; /* Token of remote DMBE */
110+
__aligned_u64 peer_gid_ext; /* Peer GID (extended part) */
111+
__aligned_u64 my_gid_ext; /* My GID (extended part) */
110112
};
111113

112114
#endif /* _UAPI_SMC_DIAG_H_ */

net/smc/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,16 @@ config SMC_DIAG
2020
smcss.
2121

2222
if unsure, say Y.
23+
24+
config SMC_LO
25+
bool "SMC intra-OS shortcut with loopback-ism"
26+
depends on SMC
27+
default n
28+
help
29+
SMC_LO enables the creation of an Emulated-ISM device named
30+
loopback-ism in SMC and makes use of it for transferring data
31+
when communication occurs within the same OS. This helps in
32+
convenient testing of SMC-D since loopback-ism is independent
33+
of architecture or hardware.
34+
35+
if unsure, say N.

0 commit comments

Comments
 (0)