Flags sent down from user might not be supported by running driver. This might lead to unwanted bugs. To solve this, added macro to test for unsupported flags.
Unified · Split
| @@ -1728,6 +1728,11 @@ static void configure_requester_scat_cqe(struct mlx5_ib_dev *dev, · 1727 unmodified lines | |||
| 1728 | MLX5_SET(qpc, qpc, cs_req, MLX5_REQ_SCAT_DATA32_CQE); | 1728 | MLX5_SET(qpc, qpc, cs_req, MLX5_REQ_SCAT_DATA32_CQE); |
| 1729 | } | 1729 | } |
| 1730 | 1730 | ||
| 1731 | static inline bool check_flags_mask(uint64_t input, uint64_t supported) | ||
| 1732 | { | ||
| 1733 | return (input & ~supported) == 0; | ||
| 1734 | } | ||
| 1735 | |||
| 1731 | static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, | 1736 | static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, |
| 1732 | struct ib_qp_init_attr *init_attr, | 1737 | struct ib_qp_init_attr *init_attr, |
| 1733 | struct ib_udata *udata, struct mlx5_ib_qp *qp) | 1738 | struct ib_udata *udata, struct mlx5_ib_qp *qp) |
| @@ -1825,6 +1830,15 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, · 91 unmodified lines | |||
| 1825 | return -EFAULT; | 1830 | return -EFAULT; |
| 1826 | } | 1831 | } |
| 1827 | 1832 | ||
| 1833 | if (!check_flags_mask(ucmd.flags, | ||
| 1834 | MLX5_QP_FLAG_SIGNATURE | | ||
| 1835 | MLX5_QP_FLAG_SCATTER_CQE | | ||
| 1836 | MLX5_QP_FLAG_TUNNEL_OFFLOADS | | ||
| 1837 | MLX5_QP_FLAG_BFREG_INDEX | | ||
| 1838 | MLX5_QP_FLAG_TYPE_DCT | | ||
| 1839 | MLX5_QP_FLAG_TYPE_DCI)) | ||
| 1840 | return -EINVAL; | ||
| 1841 | |||
| 1828 | err = get_qp_user_index(to_mucontext(pd->uobject->context), | 1842 | err = get_qp_user_index(to_mucontext(pd->uobject->context), |
| 1829 | &ucmd, udata->inlen, &uidx); | 1843 | &ucmd, udata->inlen, &uidx); |
| 1830 | if (err) | 1844 | if (err) |