mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
RDMA/core: Do not compile ib_core_uverbs without USER_ACCESS
Remove the entire ib_core_uverbs.c from the build if CONFIG_INFINIBAND_USER_ACCESS is not set. These functions are only used to support uverbs and are never callable even if they happen to get linked in. Provide inlines for the missing ones to return errors to further push code elimination in drivers. Link: https://patch.msgid.link/r/1-v3-43aba1969751+1988-ib_uverbs_support_ko_jgg@nvidia.com Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
e312f0ff9e
commit
33d1117eb5
|
|
@ -37,6 +37,10 @@ config INFINIBAND_USER_ACCESS
|
|||
libibverbs, libibcm and a hardware driver library from
|
||||
rdma-core <https://github.com/linux-rdma/rdma-core>.
|
||||
|
||||
config INFINIBAND_USER_ACCESS_CORE
|
||||
bool
|
||||
default y if INFINIBAND_USER_ACCESS != n
|
||||
|
||||
config INFINIBAND_USER_MEM
|
||||
bool
|
||||
depends on INFINIBAND_USER_ACCESS != n
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
|
|||
device.o cache.o netlink.o \
|
||||
roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
|
||||
multicast.o mad.o smi.o agent.o mad_rmpp.o \
|
||||
nldev.o restrack.o counters.o ib_core_uverbs.o \
|
||||
nldev.o restrack.o counters.o \
|
||||
trace.o lag.o iter.o frmr_pools.o
|
||||
|
||||
ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o
|
||||
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
|
||||
ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o umem_dmabuf.o
|
||||
ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o
|
||||
ib_core-$(CONFIG_INFINIBAND_USER_ACCESS_CORE) += ib_core_uverbs.o
|
||||
|
||||
ib_cm-y := cm.o cm_trace.o
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ EXPORT_SYMBOL(rdma_user_mmap_entry_insert);
|
|||
* The struct ib_device that is handling the uverbs call. Must not be called if
|
||||
* udata is NULL. The result can be NULL.
|
||||
*/
|
||||
struct ib_device *rdma_udata_to_dev(struct ib_udata *udata)
|
||||
static struct ib_device *rdma_udata_to_dev(struct ib_udata *udata)
|
||||
{
|
||||
struct uverbs_attr_bundle *bundle =
|
||||
rdma_udata_to_uverbs_attr_bundle(udata);
|
||||
|
|
@ -415,10 +415,9 @@ struct ib_device *rdma_udata_to_dev(struct ib_udata *udata)
|
|||
return srcu_dereference(bundle->ufile->device->ib_dev,
|
||||
&bundle->ufile->device->disassociate_srcu);
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_udata_to_dev);
|
||||
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
uverbs_api_ioctl_handler_fn uverbs_get_handler_fn(struct ib_udata *udata)
|
||||
typedef int (*uverbs_api_ioctl_handler_fn)(struct uverbs_attr_bundle *attrs);
|
||||
static uverbs_api_ioctl_handler_fn uverbs_get_handler_fn(struct ib_udata *udata)
|
||||
{
|
||||
struct uverbs_attr_bundle *bundle =
|
||||
rdma_udata_to_uverbs_attr_bundle(udata);
|
||||
|
|
@ -502,4 +501,3 @@ int _ib_respond_udata(struct ib_udata *udata, const void *src, size_t len)
|
|||
return -EFAULT;
|
||||
}
|
||||
EXPORT_SYMBOL(_ib_respond_udata);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -151,9 +151,6 @@ void uapi_compute_bundle_size(struct uverbs_api_ioctl_method *method_elm,
|
|||
unsigned int num_attrs);
|
||||
void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile);
|
||||
|
||||
typedef int (*uverbs_api_ioctl_handler_fn)(struct uverbs_attr_bundle *attrs);
|
||||
uverbs_api_ioctl_handler_fn uverbs_get_handler_fn(struct ib_udata *udata);
|
||||
|
||||
extern const struct uapi_definition uverbs_def_obj_async_fd[];
|
||||
extern const struct uapi_definition uverbs_def_obj_counters[];
|
||||
extern const struct uapi_definition uverbs_def_obj_cq[];
|
||||
|
|
|
|||
|
|
@ -3101,6 +3101,7 @@ void ib_set_client_data(struct ib_device *device, struct ib_client *client,
|
|||
void ib_set_device_ops(struct ib_device *device,
|
||||
const struct ib_device_ops *ops);
|
||||
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
int rdma_user_mmap_io(struct ib_ucontext *ucontext, struct vm_area_struct *vma,
|
||||
unsigned long pfn, unsigned long size, pgprot_t prot,
|
||||
struct rdma_user_mmap_entry *entry);
|
||||
|
|
@ -3112,13 +3113,7 @@ int rdma_user_mmap_entry_insert_range(struct ib_ucontext *ucontext,
|
|||
size_t length, u32 min_pgoff,
|
||||
u32 max_pgoff);
|
||||
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
void rdma_user_mmap_disassociate(struct ib_device *device);
|
||||
#else
|
||||
static inline void rdma_user_mmap_disassociate(struct ib_device *device)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
rdma_user_mmap_entry_insert_exact(struct ib_ucontext *ucontext,
|
||||
|
|
@ -3138,6 +3133,66 @@ rdma_user_mmap_entry_get(struct ib_ucontext *ucontext,
|
|||
void rdma_user_mmap_entry_put(struct rdma_user_mmap_entry *entry);
|
||||
|
||||
void rdma_user_mmap_entry_remove(struct rdma_user_mmap_entry *entry);
|
||||
#else
|
||||
static inline int rdma_user_mmap_io(struct ib_ucontext *ucontext,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long pfn, unsigned long size,
|
||||
pgprot_t prot,
|
||||
struct rdma_user_mmap_entry *entry)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rdma_user_mmap_entry_insert(struct ib_ucontext *ucontext,
|
||||
struct rdma_user_mmap_entry *entry, size_t length)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rdma_user_mmap_entry_insert_range(struct ib_ucontext *ucontext,
|
||||
struct rdma_user_mmap_entry *entry,
|
||||
size_t length, u32 min_pgoff, u32 max_pgoff)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline void rdma_user_mmap_disassociate(struct ib_device *device)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int
|
||||
rdma_user_mmap_entry_insert_exact(struct ib_ucontext *ucontext,
|
||||
struct rdma_user_mmap_entry *entry,
|
||||
size_t length, u32 pgoff)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline struct rdma_user_mmap_entry *
|
||||
rdma_user_mmap_entry_get_pgoff(struct ib_ucontext *ucontext,
|
||||
unsigned long pgoff)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct rdma_user_mmap_entry *
|
||||
rdma_user_mmap_entry_get(struct ib_ucontext *ucontext,
|
||||
struct vm_area_struct *vma)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void rdma_user_mmap_entry_put(struct rdma_user_mmap_entry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
rdma_user_mmap_entry_remove(struct rdma_user_mmap_entry *entry)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -668,8 +668,6 @@ rdma_udata_to_uverbs_attr_bundle(struct ib_udata *udata)
|
|||
(udata ? container_of(rdma_udata_to_uverbs_attr_bundle(udata)->context, \
|
||||
drv_dev_struct, member) : (drv_dev_struct *)NULL)
|
||||
|
||||
struct ib_device *rdma_udata_to_dev(struct ib_udata *udata);
|
||||
|
||||
#define IS_UVERBS_COPY_ERR(_ret) ((_ret) && (_ret) != -ENOENT)
|
||||
|
||||
static inline const struct uverbs_attr *uverbs_attr_get(const struct uverbs_attr_bundle *attrs_bundle,
|
||||
|
|
@ -902,6 +900,8 @@ int uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle,
|
|||
int _ib_copy_validate_udata_in(struct ib_udata *udata, void *req,
|
||||
size_t kernel_size, size_t minimum_size);
|
||||
int _ib_respond_udata(struct ib_udata *udata, const void *src, size_t len);
|
||||
int _ib_copy_validate_udata_cm_fail(struct ib_udata *udata, u64 req_cm,
|
||||
u64 valid_cm);
|
||||
#else
|
||||
static inline int
|
||||
uverbs_get_flags64(u64 *to, const struct uverbs_attr_bundle *attrs_bundle,
|
||||
|
|
@ -971,6 +971,12 @@ static inline int _ib_respond_udata(struct ib_udata *udata, const void *src,
|
|||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int _ib_copy_validate_udata_cm_fail(struct ib_udata *udata,
|
||||
u64 req_cm, u64 valid_cm)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define uverbs_get_const_signed(_to, _attrs_bundle, _idx) \
|
||||
|
|
@ -1051,9 +1057,6 @@ uverbs_get_raw_fd(int *to, const struct uverbs_attr_bundle *attrs_bundle,
|
|||
_ib_copy_validate_udata_in(_udata, &(_req), sizeof(_req), \
|
||||
offsetofend(typeof(_req), _end_member))
|
||||
|
||||
int _ib_copy_validate_udata_cm_fail(struct ib_udata *udata, u64 req_cm,
|
||||
u64 valid_cm);
|
||||
|
||||
/**
|
||||
* ib_copy_validate_udata_in_cm - Copy the req structure and check the comp_mask
|
||||
* @_udata: The system calls ib_udata struct
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user