Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1543968 > unrolled thread
| Started by | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> |
|---|---|
| First post | 2016-12-17 14:20 +0100 |
| Last post | 2016-12-19 15:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH] livepatch: fixup klp-convert tool integration Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2016-12-17 14:20 +0100
Re: [PATCH] livepatch: fixup klp-convert tool integration Miroslav Benes <mbenes@suse.cz> - 2016-12-19 15:40 +0100
| From | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> |
|---|---|
| Date | 2016-12-17 14:20 +0100 |
| Subject | [PATCH] livepatch: fixup klp-convert tool integration |
| Message-ID | <sPn45-1Ge-3@gated-at.bofh.it> |
I've found some minor problems, this patch fixes:
* save cmd_ld_ko_o into .module.cmd, if_changed_rule doesn't do that
* fix bashisms for debian where /bin/sh is a symlink to /bin/dash
* rename rule_link_module to rule_ld_ko_o, otherwise arg-check inside
if_changed_rule compares cmd_link_module and cmd_ld_ko_o
* use HOSTLOADLIBES_$module instead of HOSTLDFLAGS: -lelf must be at the end
* check modinfo -F livepatch only if CONFIG_LIVEPATCH is true
I think "modinfo -F" could be replaced with explicit mark in makefile,
for example: LIVEPATCH_module.ko := y (like KASAN_SANITIZE_obj.o := n).
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
scripts/Kbuild.include | 4 +++-
scripts/Makefile.modpost | 24 +++++++++++-------------
scripts/livepatch/Makefile | 2 +-
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 179219845dfc..e299fde3423b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -247,6 +247,8 @@ endif
# (needed for the shell)
make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
+save-cmd = printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd
+
# Find any prerequisites that is newer than target or that does not exist.
# PHONY targets skipped in both cases.
any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
@@ -256,7 +258,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
@set -e; \
$(echo-cmd) $(cmd_$(1)); \
- printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
+ $(save-cmd), @:)
# Execute the command and also postprocess generated .d dependencies file.
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 916dd347e8f6..5d149d0b05c2 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -123,24 +123,22 @@ quiet_cmd_ld_ko_o = LD [M] $@
$(LD) -r $(LDFLAGS) \
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
-o $@ $(filter-out FORCE,$^) ; \
- $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) ;
+ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
-ifdef CONFIG_LIVEPATCH
KLP_CONVERT = scripts/livepatch/klp-convert
- cmd_klp_convert = \
- if [[ -n "`modinfo -F livepatch $@`" ]]; then \
- mv $@ $(@:.ko=.klp.o); \
- $(KLP_CONVERT) $(@:.ko=.klp.o) $@; \
- fi ;
-endif
-
-define rule_link_module
- $(call echo-cmd,ld_ko_o) $(cmd_ld_ko_o) \
- $(cmd_klp_convert)
+quiet_cmd_klp_convert = LIVEPATCH $@
+ cmd_klp_convert = mv $@ $(@:.ko=.klp.o); $(KLP_CONVERT) $(@:.ko=.klp.o) $@
+
+define rule_ld_ko_o
+ $(call echo-cmd,ld_ko_o) $(cmd_ld_ko_o) ; \
+ $(call save-cmd,ld_ko_o) ; \
+ $(if $(CONFIG_LIVEPATCH), \
+ if [ -n "`modinfo -F livepatch $@`" ] ; then \
+ $(call echo-cmd,klp_convert) $(cmd_klp_convert) ; fi)
endef
$(modules): %.ko :%.o %.mod.o FORCE
- +$(call if_changed_rule,link_module)
+ +$(call if_changed_rule,ld_ko_o)
targets += $(modules)
diff --git a/scripts/livepatch/Makefile b/scripts/livepatch/Makefile
index 221829bb34c7..bd5c1ae553ab 100644
--- a/scripts/livepatch/Makefile
+++ b/scripts/livepatch/Makefile
@@ -4,4 +4,4 @@ always := $(hostprogs-y)
klp-convert-objs := klp-convert.o elf.o
HOSTCFLAGS := -g -I$(INSTALL_HDR_PATH)/include -Wall
-HOSTLDFLAGS := -lelf
+HOSTLOADLIBES_klp-convert := -lelf
[toc] | [next] | [standalone]
| From | Miroslav Benes <mbenes@suse.cz> |
|---|---|
| Date | 2016-12-19 15:40 +0100 |
| Message-ID | <sQ7gC-Ek-25@gated-at.bofh.it> |
| In reply to | #1543968 |
On Sat, 17 Dec 2016, Konstantin Khlebnikov wrote: > I've found some minor problems, this patch fixes: > > * save cmd_ld_ko_o into .module.cmd, if_changed_rule doesn't do that > * fix bashisms for debian where /bin/sh is a symlink to /bin/dash > * rename rule_link_module to rule_ld_ko_o, otherwise arg-check inside > if_changed_rule compares cmd_link_module and cmd_ld_ko_o > * use HOSTLOADLIBES_$module instead of HOSTLDFLAGS: -lelf must be at the end Ok, why not. I'll incorporate these changes to the patch set, if you're ok with it. > * check modinfo -F livepatch only if CONFIG_LIVEPATCH is true Right, this was the case with Josh's changes too if I understand modpost correctly (still causing me headaches). > I think "modinfo -F" could be replaced with explicit mark in makefile, > for example: LIVEPATCH_module.ko := y (like KASAN_SANITIZE_obj.o := n). Yes, replacing modinfo is definitely something I plan to do and explicit mark in Makefile is one option how to deal with it. I also though about a mark somewhere in a source code, but it does not matter much, I guess. Thanks, Miroslav > Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> > --- > scripts/Kbuild.include | 4 +++- > scripts/Makefile.modpost | 24 +++++++++++------------- > scripts/livepatch/Makefile | 2 +- > 3 files changed, 15 insertions(+), 15 deletions(-) > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include > index 179219845dfc..e299fde3423b 100644 > --- a/scripts/Kbuild.include > +++ b/scripts/Kbuild.include > @@ -247,6 +247,8 @@ endif > # (needed for the shell) > make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) > > +save-cmd = printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd > + > # Find any prerequisites that is newer than target or that does not exist. > # PHONY targets skipped in both cases. > any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) > @@ -256,7 +258,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) > if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ > @set -e; \ > $(echo-cmd) $(cmd_$(1)); \ > - printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) > + $(save-cmd), @:) > > # Execute the command and also postprocess generated .d dependencies file. > if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost > index 916dd347e8f6..5d149d0b05c2 100644 > --- a/scripts/Makefile.modpost > +++ b/scripts/Makefile.modpost > @@ -123,24 +123,22 @@ quiet_cmd_ld_ko_o = LD [M] $@ > $(LD) -r $(LDFLAGS) \ > $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ > -o $@ $(filter-out FORCE,$^) ; \ > - $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) ; > + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) > > -ifdef CONFIG_LIVEPATCH > KLP_CONVERT = scripts/livepatch/klp-convert > - cmd_klp_convert = \ > - if [[ -n "`modinfo -F livepatch $@`" ]]; then \ > - mv $@ $(@:.ko=.klp.o); \ > - $(KLP_CONVERT) $(@:.ko=.klp.o) $@; \ > - fi ; > -endif > - > -define rule_link_module > - $(call echo-cmd,ld_ko_o) $(cmd_ld_ko_o) \ > - $(cmd_klp_convert) > +quiet_cmd_klp_convert = LIVEPATCH $@ > + cmd_klp_convert = mv $@ $(@:.ko=.klp.o); $(KLP_CONVERT) $(@:.ko=.klp.o) $@ > + > +define rule_ld_ko_o > + $(call echo-cmd,ld_ko_o) $(cmd_ld_ko_o) ; \ > + $(call save-cmd,ld_ko_o) ; \ > + $(if $(CONFIG_LIVEPATCH), \ > + if [ -n "`modinfo -F livepatch $@`" ] ; then \ > + $(call echo-cmd,klp_convert) $(cmd_klp_convert) ; fi) > endef > > $(modules): %.ko :%.o %.mod.o FORCE > - +$(call if_changed_rule,link_module) > + +$(call if_changed_rule,ld_ko_o) > > targets += $(modules) > > diff --git a/scripts/livepatch/Makefile b/scripts/livepatch/Makefile > index 221829bb34c7..bd5c1ae553ab 100644 > --- a/scripts/livepatch/Makefile > +++ b/scripts/livepatch/Makefile > @@ -4,4 +4,4 @@ always := $(hostprogs-y) > klp-convert-objs := klp-convert.o elf.o > > HOSTCFLAGS := -g -I$(INSTALL_HDR_PATH)/include -Wall > -HOSTLDFLAGS := -lelf > +HOSTLOADLIBES_klp-convert := -lelf > > -- > To unsubscribe from this list: send the line "unsubscribe live-patching" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web