All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-core] verbs: Encode the private ABI version number in verbs_register_driver
@ 2017-08-24 21:56 Jason Gunthorpe
       [not found] ` <20170824215601.GA19717-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2017-08-24 21:56 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky

This causes the symbol table to look like:

   208: 000000000000c000   142 FUNC    GLOBAL DEFAULT   13 verbs_register_driver_15@@IBVERBS_PRIVATE_15

Which encodes the expected private ABI version inside the symbol name
as well as with the symbol version.

This ensures that the ABI version is checked even if the linking
environment does not include symbol versions, for instance if an
end user is linking a provider static library to the system dynamic
libibverbs.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 buildlib/config.h.in         |  1 +
 libibverbs/driver.h          | 11 +++++++++++
 libibverbs/libibverbs.map.in |  2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

Since Leon says people are using static provider libraries we should
do more to make sure they work right.

diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index b879bc9034d328..f477559aeac6d2 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -25,6 +25,7 @@
 
 #define VERBS_PROVIDER_DIR "@VERBS_PROVIDER_DIR@"
 #define VERBS_PROVIDER_SUFFIX "@IBVERBS_PROVIDER_SUFFIX@"
+#define IBVERBS_PABI_VERSION @IBVERBS_PABI_VERSION@
 
 // FIXME This has been supported in compilers forever, we should just fail to build on such old systems.
 #cmakedefine HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE 1
diff --git a/libibverbs/driver.h b/libibverbs/driver.h
index 8ece40e28629b9..887412de6327c3 100644
--- a/libibverbs/driver.h
+++ b/libibverbs/driver.h
@@ -39,6 +39,7 @@
 #include <infiniband/verbs.h>
 #include <infiniband/kern-abi.h>
 #include <ccan/list.h>
+#include <config.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -128,6 +129,16 @@ verbs_get_device(const struct ibv_device *dev)
 
 typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_path,
 						       int abi_version);
+
+/* Wire the IBVERBS_PRIVATE version number into the verbs_register_driver
+ * symbol name.  This guarentees we link to the correct set of symbols even if
+ * statically linking or using a dynmic linker with symbol versioning turned
+ * off.
+ */
+#define ___make_verbs_register_driver(x) verbs_register_driver_ ## x
+#define __make_verbs_register_driver(x)  ___make_verbs_register_driver(x)
+#define verbs_register_driver __make_verbs_register_driver(IBVERBS_PABI_VERSION)
+
 void verbs_register_driver(const char *name, verbs_driver_init_func init_func);
 void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context,
 		       struct ibv_comp_channel *channel,
diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in
index a1124421bf364d..39d9d05100a5f9 100644
--- a/libibverbs/libibverbs.map.in
+++ b/libibverbs/libibverbs.map.in
@@ -137,6 +137,6 @@ IBVERBS_PRIVATE_@IBVERBS_PABI_VERSION@ {
 		ibv_cmd_resize_cq;
 		ibv_query_gid_type;
 		ibv_register_driver;
-		verbs_register_driver;
+		verbs_register_driver_@IBVERBS_PABI_VERSION@;
 		verbs_init_cq;
 };
-- 
2.7.4


-- 
Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>        (780)4406067x832
Chief Technology Officer, Obsidian Research Corp         Edmonton, Canada
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-core] verbs: Encode the private ABI version number in verbs_register_driver
       [not found] ` <20170824215601.GA19717-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-08-27 12:12   ` Leon Romanovsky
  2017-09-01 20:30   ` Chien Tin Tung
  1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2017-08-27 12:12 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

On Thu, Aug 24, 2017 at 03:56:01PM -0600, Jason Gunthorpe wrote:
> This causes the symbol table to look like:
>
>    208: 000000000000c000   142 FUNC    GLOBAL DEFAULT   13 verbs_register_driver_15@@IBVERBS_PRIVATE_15
>
> Which encodes the expected private ABI version inside the symbol name
> as well as with the symbol version.
>
> This ensures that the ABI version is checked even if the linking
> environment does not include symbol versions, for instance if an
> end user is linking a provider static library to the system dynamic
> libibverbs.
>
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---
>  buildlib/config.h.in         |  1 +
>  libibverbs/driver.h          | 11 +++++++++++
>  libibverbs/libibverbs.map.in |  2 +-
>  3 files changed, 13 insertions(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-core] verbs: Encode the private ABI version number in verbs_register_driver
       [not found] ` <20170824215601.GA19717-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2017-08-27 12:12   ` Leon Romanovsky
@ 2017-09-01 20:30   ` Chien Tin Tung
       [not found]     ` <20170901203021.GA5832-TZeIlv3TuzOfrEmaQUPKxl95YUYmaKo1UNDiOz3kqAs@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Chien Tin Tung @ 2017-09-01 20:30 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky

On Thu, Aug 24, 2017 at 04:56:01PM -0500, Jason Gunthorpe wrote:
> This causes the symbol table to look like:
> 
>    208: 000000000000c000   142 FUNC    GLOBAL DEFAULT   13 verbs_register_driver_15@@IBVERBS_PRIVATE_15
> 
> Which encodes the expected private ABI version inside the symbol name
> as well as with the symbol version.
> 
> This ensures that the ABI version is checked even if the linking
> environment does not include symbol versions, for instance if an
> end user is linking a provider static library to the system dynamic
> libibverbs.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---
>  buildlib/config.h.in         |  1 +
>  libibverbs/driver.h          | 11 +++++++++++
>  libibverbs/libibverbs.map.in |  2 +-
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> Since Leon says people are using static provider libraries we should
> do more to make sure they work right.

Jason,

Can you dumb this down for me?  I don't understand the provider static library part.
Do you mean an application statically linking in a provider library and dynamically
to libibverbs?  Why would someone do this?  Are there examples of this?

Thanks,

Chien
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-core] verbs: Encode the private ABI version number in verbs_register_driver
       [not found]     ` <20170901203021.GA5832-TZeIlv3TuzOfrEmaQUPKxl95YUYmaKo1UNDiOz3kqAs@public.gmane.org>
@ 2017-09-01 21:29       ` Jason Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2017-09-01 21:29 UTC (permalink / raw)
  To: Chien Tin Tung; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky

On Fri, Sep 01, 2017 at 03:30:21PM -0500, Chien Tin Tung wrote:
> On Thu, Aug 24, 2017 at 04:56:01PM -0500, Jason Gunthorpe wrote:
> > This causes the symbol table to look like:
> > 
> >    208: 000000000000c000   142 FUNC    GLOBAL DEFAULT   13 verbs_register_driver_15@@IBVERBS_PRIVATE_15
> > 
> > Which encodes the expected private ABI version inside the symbol name
> > as well as with the symbol version.
> > 
> > This ensures that the ABI version is checked even if the linking
> > environment does not include symbol versions, for instance if an
> > end user is linking a provider static library to the system dynamic
> > libibverbs.
> > 
> > Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> >  buildlib/config.h.in         |  1 +
> >  libibverbs/driver.h          | 11 +++++++++++
> >  libibverbs/libibverbs.map.in |  2 +-
> >  3 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > Since Leon says people are using static provider libraries we should
> > do more to make sure they work right.
> 
> Jason,
> 
> Can you dumb this down for me?  I don't understand the provider static library part.
> Do you mean an application statically linking in a provider library and dynamically
> to libibverbs?

Yes.

> Why would someone do this?

Not sure. Leon said there was interest and the patch is simple.

Perhaps it makes sense when combined with libmlx5dv. Eg you could
build a middleware library that embeds the 'dv' library. Maybe turn on
LTO to gain some speed.

> Are there examples of this?

Compile rdma-core with -DENABLE_STATIC

>From memory, untested:
  $ gcc -o foo foo.o -Wl,--whole-archive -lmlx5dv

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-01 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24 21:56 [PATCH rdma-core] verbs: Encode the private ABI version number in verbs_register_driver Jason Gunthorpe
     [not found] ` <20170824215601.GA19717-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-08-27 12:12   ` Leon Romanovsky
2017-09-01 20:30   ` Chien Tin Tung
     [not found]     ` <20170901203021.GA5832-TZeIlv3TuzOfrEmaQUPKxl95YUYmaKo1UNDiOz3kqAs@public.gmane.org>
2017-09-01 21:29       ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.