Add mlx5_is_adversarial() to report whether the driver treats the NIC as untrusted. In a confidential computing guest, the hypervisor and any passthrough device are outside the guest's trust boundary, so the mode is derived from cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT). This turns adversarial mode on automatically in such guests, without any administrator configuration. Reviewed-by: Tariq Toukan Signed-off-by: Yishai Hadas --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 7 +++++++ include/linux/mlx5/driver.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 1a45474ce03d..f9e10464a71b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -31,6 +31,7 @@ */ #include +#include #include #include #include @@ -484,6 +485,12 @@ bool mlx5_is_roce_on(struct mlx5_core_dev *dev) } EXPORT_SYMBOL(mlx5_is_roce_on); +bool mlx5_is_adversarial(void) +{ + return cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT); +} +EXPORT_SYMBOL_GPL(mlx5_is_adversarial); + static int handle_hca_cap_2(struct mlx5_core_dev *dev, void *set_ctx) { bool do_set = false; diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index a1275e6aa6c1..3d3bc16e581d 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -1328,6 +1328,7 @@ enum { }; bool mlx5_is_roce_on(struct mlx5_core_dev *dev); +bool mlx5_is_adversarial(void); static inline bool mlx5_get_roce_state(struct mlx5_core_dev *dev) { -- 2.18.1