Skip to contentSkip to conversation

kexec-tools: Tweak run-time handling of libxenctrl.so

PATCH Applied Eric DeVolder 3 participants 9 messages Jan 23, 2018 – Jan 24, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover kexec-tools: Tweak run-time handling of libxenctrl.so

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper concerning the lack of a dlclose() and the desire to make xc_dlhandle static, rather than extern.

---
v1: 23jan2018
- Implemented feedback from Daniel Kiper

v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two

Eric DeVolder (2):
kexec-tools: Call dlclose() from within __xc_interface_close()
kexec-tools: Make xc_dlhandle static

 kexec/kexec-xen.c | 10 +++++++++-
 kexec/kexec-xen.h |  9 ++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH v2 1/2 kexec-tools: Call dlclose() from within __xc_interface_close()

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

In the original patch, the call to dlclose() was omitted, in contrast to the description in the commit message. This patch inserts the call. Note that this dynamic linking feature is dependent upon the proper operation of the RTLD_NODELETE flag to dlopen(), which does work as advertised on Linux (otherwise the call to dlclose() should be omitted).

---
v1: 23jan2018
- Implemented feedback from Daniel Kiper

v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two

---
 kexec/kexec-xen.c | 1 +
 1 file changed, 1 insertion(+)
kexec/kexec-xen.c +1 -0
index d42a45a..75f8758 100644
@@ -47,6 +47,7 @@ int __xc_interface_close(xc_interface *xch)
 
 		func_t func = (func_t)dlsym(xc_dlhandle, "xc_interface_close");
 		rc = func(xch);
+		dlclose(xc_dlhandle);
 		xc_dlhandle = NULL;
 	}
 
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] kexec-tools: Call dlclose() from within __xc_interface_close()

Quoted 11 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

In the original patch, the call to dlclose() was omitted, in contrast to the description in the commit message. This patch inserts the call. Note that this dynamic linking feature is dependent upon the proper operation of the RTLD_NODELETE flag to dlopen(), which does work as advertised on Linux (otherwise the call to dlclose() should be omitted).

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Applied
#3 lore raw

Re: [PATCH v2 1/2] kexec-tools: Call dlclose() from within __xc_interface_close()

Quoted 11 lines · Daniel Kiper
Quoted 10 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

In the original patch, the call to dlclose() was omitted, in contrast to the description in the commit message. This patch inserts the call. Note that this dynamic linking feature is dependent upon the proper operation of the RTLD_NODELETE flag to dlopen(), which does work as advertised on Linux (otherwise the call to dlclose() should be omitted).

Quoted 3 lines
Quoted 1 line

Thanks, applied.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

PATCH v2 2/2 kexec-tools: Make xc_dlhandle static

In reply to Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

This patch implements Daniel's suggestion to make the xc_dlhandle variable static.

---
v1: 23jan2018
- Implemented feedback from Daniel Kiper

v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two

---
 kexec/kexec-xen.c | 9 ++++++++-
 kexec/kexec-xen.h | 9 ++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
kexec/kexec-xen.c +8 -1
index 75f8758..960fa16 100644
@@ -15,8 +15,15 @@
 #include "crashdump.h"
 
 #ifdef CONFIG_LIBXENCTRL_DL
-void *xc_dlhandle;
+/* The handle from dlopen(), needed by dlsym(), dlclose() */
+static void *xc_dlhandle;
 xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL);
+
+void *__xc_dlsym(const char *symbol)
+{
+	return dlsym(xc_dlhandle, symbol);
+}
+
 xc_interface *__xc_interface_open(xentoollog_logger *logger,
 				  xentoollog_logger *dombuild_logger,
 				  unsigned open_flags)
kexec/kexec-xen.h +4 -5
index ffb8743..8955334 100644
@@ -6,9 +6,8 @@
 
 #ifdef CONFIG_LIBXENCTRL_DL
 #include <dlfcn.h>
-
-/* The handle from dlopen(), needed by dlsym(), dlclose() */
-extern void *xc_dlhandle;
+/* Lookup symbols in libxenctrl.so */
+void *__xc_dlsym(const char *symbol);
 
 /* Wrappers around xc_interface_open/close() to insert dlopen/dlclose() */
 xc_interface *__xc_interface_open(xentoollog_logger *logger,
@@ -21,13 +20,13 @@ int __xc_interface_close(xc_interface *xch);
 ( \
 	{ dtype value; \
 	typedef dtype (*func_t)(xc_interface *, ...); \
-	func_t func = dlsym(xc_dlhandle, #name); \
+	func_t func = __xc_dlsym(#name); \
 	value = func(args); \
 	value; } \
 )
 #define __xc_data(dtype, name) \
 ( \
-	{ dtype *value = (dtype *)dlsym(xc_dlhandle, #name); value; } \
+	{ dtype *value = (dtype *)__xc_dlsym(#name); value; } \
 )
 
 /* The wrappers around utilized xenctrl.h functions */
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] kexec-tools: Make xc_dlhandle static

Quoted 8 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

This patch implements Daniel's suggestion to make the xc_dlhandle variable static.

Just two nitpicks... Otherwise you can add

Quoted 38 lines

---
v1: 23jan2018
- Implemented feedback from Daniel Kiper

v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two

---
 kexec/kexec-xen.c | 9 ++++++++-
 kexec/kexec-xen.h | 9 ++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
kexec/kexec-xen.c +8 -1
index 75f8758..960fa16 100644
@@ -15,8 +15,15 @@
 #include "crashdump.h"
 
 #ifdef CONFIG_LIBXENCTRL_DL
-void *xc_dlhandle;
+/* The handle from dlopen(), needed by dlsym(), dlclose() */
+static void *xc_dlhandle;
 xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL);
+
+void *__xc_dlsym(const char *symbol)
+{
+	return dlsym(xc_dlhandle, symbol);
+}
+
 xc_interface *__xc_interface_open(xentoollog_logger *logger,
 				  xentoollog_logger *dombuild_logger,
 				  unsigned open_flags)
kexec/kexec-xen.h +0 -0
index ffb8743..8955334 100644

kexec/kexec-xen.h line 8

Quoted 3 lines
kexec/kexec-xen.h +0 -0
@@ -6,9 +6,8 @@
 
 #ifdef CONFIG_LIBXENCTRL_DL
 #include <dlfcn.h>

I think that you can drop this include too.

kexec/kexec-xen.h line 10

Quoted 5 lines
kexec/kexec-xen.h +2 -3
-
-/* The handle from dlopen(), needed by dlsym(), dlclose() */
-extern void *xc_dlhandle;
+/* Lookup symbols in libxenctrl.so */
+void *__xc_dlsym(const char *symbol);

extern void *__xc_dlsym(const char *symbol);?

But then, IMO, you should put extern for __xc_interface_open() and __xc_interface_close() below too. You can do it in separate patch with Reviewed-by: Daniel Kiper <[email protected]>

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Re: [PATCH v2 2/2] kexec-tools: Make xc_dlhandle static

Quoted 5 lines · Daniel Kiper
Quoted 4 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

Quoted 8 lines
Quoted 4 lines

This patch implements Daniel's suggestion to make the xc_dlhandle variable static.

Just two nitpicks... Otherwise you can add

Eric, please address Daniel's review and repost this patch as appropriate. There is no need to repost patch 1/2 as I've applied it.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw

Re: [PATCH v2 2/2] kexec-tools: Make xc_dlhandle static

Quoted 9 lines · Simon Horman
Quoted 8 lines · Daniel Kiper
Quoted 7 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

This patch implements Daniel's suggestion to make the xc_dlhandle variable static.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Just two nitpicks... Otherwise you can add

Eric, please address Daniel's review and repost this patch as appropriate. There is no need to repost patch 1/2 as I've applied it.

Simon, I've incorporated Daniel's feedback and posted v3 of this patch. Regards,
eric

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw

Re: [PATCH v2 2/2] kexec-tools: Make xc_dlhandle static

In reply to Daniel Kiper

Daniel, thanks for the review, inline responses below. eric

Quoted 53 lines · Daniel Kiper
Quoted 8 lines · Eric DeVolder

This patch is a follow-on to commit 43d3932e "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.

This patch implements Daniel's suggestion to make the xc_dlhandle variable static.

Just two nitpicks... Otherwise you can add

Quoted 39 lines

---
v1: 23jan2018
- Implemented feedback from Daniel Kiper

v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two

---
  kexec/kexec-xen.c | 9 ++++++++-
  kexec/kexec-xen.h | 9 ++++-----
  2 files changed, 12 insertions(+), 6 deletions(-)
kexec/kexec-xen.c +8 -1
index 75f8758..960fa16 100644
@@ -15,8 +15,15 @@
  #include "crashdump.h"
 
  #ifdef CONFIG_LIBXENCTRL_DL
-void *xc_dlhandle;
+/* The handle from dlopen(), needed by dlsym(), dlclose() */
+static void *xc_dlhandle;
  xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL);
+
+void *__xc_dlsym(const char *symbol)
+{
+	return dlsym(xc_dlhandle, symbol);
+}
+
  xc_interface *__xc_interface_open(xentoollog_logger *logger,
  				  xentoollog_logger *dombuild_logger,
  				  unsigned open_flags)
kexec/kexec-xen.h +0 -0
index ffb8743..8955334 100644
@@ -6,9 +6,8 @@
 
Quoted 4 lines

kexec/kexec-xen.h line 8

Quoted 2 lines
kexec/kexec-xen.h +0 -0
  #ifdef CONFIG_LIBXENCTRL_DL
  #include <dlfcn.h>

I think that you can drop this include too.

I did check and this is the only place in kexec-tools that includes this header file (it has the prototypes for dlopen/close/sym()). Without this header file included, compilation fails. Thus I've left it in.

Quoted 8 lines

kexec/kexec-xen.h line 10

Quoted 6 lines
kexec/kexec-xen.h +2 -3
-
-/* The handle from dlopen(), needed by dlsym(), dlclose() */
-extern void *xc_dlhandle;
+/* Lookup symbols in libxenctrl.so */
+void *__xc_dlsym(const char *symbol);

extern void *__xc_dlsym(const char *symbol);?

Done for this and the others.

Quoted 6 lines

But then, IMO, you should put extern for __xc_interface_open() and __xc_interface_close() below too. You can do it in separate patch with Reviewed-by: Daniel Kiper <[email protected]>

Daniel

Thanks, I've posted v3 of this patch, including your RB.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec