Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Leon Romanovsky
Mon, 16 Nov 2026 08:57
Re: [PATCH V1 rdma-next 08/24] RDMA/mlx5: Derive mlx5_ib_adversarial_mode global from mlx5_core adversarial API
Author: Leon Romanovsky
Date: Mon, 16 Nov 2026 08:57
Date: Mon, 16 Nov 2026 08:57
59 lines
9818 bytes
9818 bytes
On Tue, Nov 10, 2026 at 03:43:04PM +0200, Yishai Hadas wrote:
> Cache mlx5_is_adversarial() in a driver-wide mlx5_ib_adversarial_mode
> in mlx5_ib_init(), shared through mlx5_ib.h. The mode is the same for
> all devices, so a global avoids reading it through every mlx5_ib_dev
> and keeps the checks at the call sites simple.
This patch and description makes no sense. The mlx5_is_adversarial() is
simple static pre-compiled branch "cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)".
>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/infiniband/hw/mlx5/main.c | 3 +++
> drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 +
> 2 files changed, 4 insertions(+)
>
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index 65455aedd559..f4f2ad80e76c 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -76,6 +76,7 @@ enum {
> MLX5_ATOMIC_SIZE_QP_8BYTES = 1 << 3,
> };
>
> +bool mlx5_ib_adversarial_mode;
It is not kernel style to throw random global values to cache existing
in-kernel API functions.
Thanks
> static struct workqueue_struct *mlx5_ib_event_wq;
> static LIST_HEAD(mlx5_ib_unaffiliated_port_list);
> static LIST_HEAD(mlx5_ib_dev_list);
> @@ -5431,6 +5432,8 @@ static int __init mlx5_ib_init(void)
> return -ENOMEM;
> }
>
> + mlx5_ib_adversarial_mode = mlx5_is_adversarial();
> +
> ret = mlx5_ib_qp_event_init();
> if (ret)
> goto qp_event_err;
> diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> index 4a6ee14ffd7d..0f81b8aa487e 100644
> --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
> +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> @@ -1582,6 +1582,7 @@ static inline int get_uars_per_sys_page(struct mlx5_ib_dev *dev, bool lib_suppor
> }
>
> extern void *xlt_emergency_page;
> +extern bool mlx5_ib_adversarial_mode;
>
> int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
> struct mlx5_bfreg_info *bfregi, u32 bfregn,
> --
> 2.18.1
>
Re: [PATCH V1 rdma-next 08/24] RDMA/mlx5: Derive mlx5_ib_adversarial_mode global from mlx5_core adversarial API
Author: Leon Romanovsky
Date: Mon, 16 Nov 2026 14:21
Date: Mon, 16 Nov 2026 14:21
50 lines
9851 bytes
9851 bytes
On Mon, Nov 16, 2026 at 04:12:55PM +0200, Yishai Hadas wrote:
> On 16/11/2026 10:57, Leon Romanovsky wrote:
> > On Tue, Nov 10, 2026 at 03:43:04PM +0200, Yishai Hadas wrote:
> > > Cache mlx5_is_adversarial() in a driver-wide mlx5_ib_adversarial_mode
> > > in mlx5_ib_init(), shared through mlx5_ib.h. The mode is the same for
> > > all devices, so a global avoids reading it through every mlx5_ib_dev
> > > and keeps the checks at the call sites simple.
> >
> > This patch and description makes no sense. The mlx5_is_adversarial() is
> > simple static pre-compiled branch "cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)".
> >
>
> cc_platform_has() is a function call, not a static branch.
Please check how it is implemented.
> The wrapper keeps the policy of when mlx5 runs in adversarial mode in one place,
> used by both mlx5_core and mlx5_ib. Anyway, in V2 mlx5_ib calls it once
> per device at init, see below.
>
> > >
> > > Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> > > ---
> > > drivers/infiniband/hw/mlx5/main.c | 3 +++
> > > drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 +
> > > 2 files changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> > > index 65455aedd559..f4f2ad80e76c 100644
> > > --- a/drivers/infiniband/hw/mlx5/main.c
> > > +++ b/drivers/infiniband/hw/mlx5/main.c
> > > @@ -76,6 +76,7 @@ enum {
> > > MLX5_ATOMIC_SIZE_QP_8BYTES = 1 << 3,
> > > };
> > > +bool mlx5_ib_adversarial_mode;
> >
> > It is not kernel style to throw random global values to cache existing
> > in-kernel API functions.
> >
>
> OK. In V2 there is no global flag in mlx5_ib anymore. This patch is
> replaced by one that sets ib_device::adversarial_mode once per device,
> and the checks read that field. Patch #24, which set it at the end of
> the series, is folded into it.
You shouldn't cache simple function call to an existing API.
>
> Yishai
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads