Skip to contentSkip to conversation

klp: remove superfluous errors in asm/livepatch.h

PATCH In review Miroslav Benes 5 participants 9 messages Mar 4, 2016 – Mar 15, 2016

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

PATCH 1/1 klp: remove superfluous errors in asm/livepatch.h

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

---
 arch/s390/include/asm/livepatch.h | 2 --
 arch/x86/include/asm/livepatch.h  | 2 --
 2 files changed, 4 deletions(-)
arch/s390/include/asm/livepatch.h +0 -2
index a52b6cca873d..105074582d86 100644
@@ -36,8 +36,6 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
 {
 	regs->psw.addr = ip;
 }
-#else
-#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif
arch/x86/include/asm/livepatch.h +0 -2
index e795f5274217..8acfe798625b 100644
@@ -40,8 +40,6 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
 {
 	regs->ip = ip;
 }
-#else
-#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif /* _ASM_X86_LIVEPATCH_H */
Signature · 1 line
2.7.2
#1 lore raw
Quoted 7 lines · Miroslav Benes

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

Looks fine to me. While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

Quoted 34 lines
---
 arch/s390/include/asm/livepatch.h | 2 --
 arch/x86/include/asm/livepatch.h  | 2 --
 2 files changed, 4 deletions(-)
arch/s390/include/asm/livepatch.h +0 -2
index a52b6cca873d..105074582d86 100644
@@ -36,8 +36,6 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
 {
 	regs->psw.addr = ip;
 }
-#else
-#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif
arch/x86/include/asm/livepatch.h +0 -2
index e795f5274217..8acfe798625b 100644
@@ -40,8 +40,6 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
 {
 	regs->ip = ip;
 }
-#else
-#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif /* _ASM_X86_LIVEPATCH_H */
Signature · 1 line
2.7.2
Signature · 1 line
Josh
#2 lore raw
Quoted 9 lines · Josh Poimboeuf
Quoted 7 lines

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

Looks fine to me.

Thanks. I consider this to be your Ack then :) (if you disagree, please shout loudly).

Quoted 2 lines

While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

You are right, this seems indeed completely unnecessary. I'll remove it for 4.6 as well, if noone has any objections.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw
Quoted 7 lines · Jiri Kosina
Quoted 5 lines · Josh Poimboeuf
Quoted 5 lines

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Looks fine to me.

Thanks. I consider this to be your Ack then :) (if you disagree, please shout loudly).

:-)

Quoted 6 lines
Quoted 3 lines

While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

You are right, this seems indeed completely unnecessary. I'll remove it for 4.6 as well, if noone has any objections.

Signature · 1 line
Josh
#4 lore raw
In reply to Jiri Kosina

+++ Jiri Kosina [06/03/16 22:13 +0100]:

Quoted 12 lines · Josh Poimboeuf
Quoted 10 lines
Quoted 8 lines

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

Looks fine to me.

Quoted 8 lines

Thanks. I consider this to be your Ack then :) (if you disagree, please shout loudly).

Quoted 2 lines

While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

You are right, this seems indeed completely unnecessary. I'll remove it for 4.6 as well, if noone has any objections.

Hm, I should've caught this earlier, but the notifier cleanup patch that removes the livepatch module notifier had kernel/module.c include livepatch.h for the klp_module_{coming,going} function stubs in the !CONFIG_LIVEPATCH case. See here: https://lkml.org/lkml/2016/2/8/1182

Looking back, I now don't think it makes sense for module.c to include all those livepatch definitions in the first place, since all it needed was the klp_module_{coming,going} declarations. I guess my question is, since we've removed the #ifdef CONFIG_LIVEPATCH blocks from livepatch.h, where might be a better place for the klp_module_{coming,going} stubs? Perhaps they could go in module.h instead?

Jessica

#5 lore raw
Quoted 11 lines · Jessica Yu
Quoted 6 lines · Josh Poimboeuf
Quoted 2 lines

While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

You are right, this seems indeed completely unnecessary. I'll remove it for 4.6 as well, if noone has any objections.

Hm, I should've caught this earlier, but the notifier cleanup patch that removes the livepatch module notifier had kernel/module.c include livepatch.h for the klp_module_{coming,going} function stubs in the !CONFIG_LIVEPATCH case. See here: https://lkml.org/lkml/2016/2/8/1182

Great catch! And you are in time because Mirek has vacation this week :-)

Quoted 7 lines

Looking back, I now don't think it makes sense for module.c to include all those livepatch definitions in the first place, since all it needed was the klp_module_{coming,going} declarations. I guess my question is, since we've removed the #ifdef CONFIG_LIVEPATCH blocks from livepatch.h, where might be a better place for the klp_module_{coming,going} stubs? Perhaps they could go in module.h instead?

I personally prefer to keep the klp_module_{coming,going} declarations in livepatch.h. It means to keep the '#ifdef CONFIG_LIVEPATCH' there as well. It is a standard solution. It helps to find things where one would expect them.

Best Regards,
Petr

#6 lore raw
In reply to Jessica Yu
Quoted 5 lines · Jessica Yu

Hm, I should've caught this earlier, but the notifier cleanup patch that removes the livepatch module notifier had kernel/module.c include livepatch.h for the klp_module_{coming,going} function stubs in the !CONFIG_LIVEPATCH case. See here: https://lkml.org/lkml/2016/2/8/1182

Quoted 7 lines

Looking back, I now don't think it makes sense for module.c to include all those livepatch definitions in the first place, since all it needed was the klp_module_{coming,going} declarations. I guess my question is, since we've removed the #ifdef CONFIG_LIVEPATCH blocks from livepatch.h, where might be a better place for the klp_module_{coming,going} stubs? Perhaps they could go in module.h instead?

Well, once there actually are alternate stubs to be included through the header file (like in the proposed notifier removal), it indeed makes sense to reintroduce the #ifdef. And once it's there, it probably doesn't make too much sense to have it guard only portion of the file.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#7 lore raw
Quoted 15 lines · Jiri Kosina
Quoted 5 lines · Jessica Yu

Hm, I should've caught this earlier, but the notifier cleanup patch that removes the livepatch module notifier had kernel/module.c include livepatch.h for the klp_module_{coming,going} function stubs in the !CONFIG_LIVEPATCH case. See here: https://lkml.org/lkml/2016/2/8/1182

Quoted 7 lines

Looking back, I now don't think it makes sense for module.c to include all those livepatch definitions in the first place, since all it needed was the klp_module_{coming,going} declarations. I guess my question is, since we've removed the #ifdef CONFIG_LIVEPATCH blocks from livepatch.h, where might be a better place for the klp_module_{coming,going} stubs? Perhaps they could go in module.h instead?

Quoted 4 lines

Well, once there actually are alternate stubs to be included through the header file (like in the proposed notifier removal), it indeed makes sense to reintroduce the #ifdef. And once it's there, it probably doesn't make too much sense to have it guard only portion of the file.

It's a minor issue but I think it would be cleaner if we only guard the parts of the file which need to be guarded.

Signature · 1 line
Josh
#8 lore raw
In reply to Josh Poimboeuf
Quoted 11 lines · Josh Poimboeuf
Quoted 7 lines · Miroslav Benes

There is an #error in asm/livepatch.h for both x86 and s390 in !CONFIG_LIVEPATCH cases. It does not make much sense as pointed out by Michael Ellerman. One can happily include asm/livepatch.h with CONFIG_LIVEPATCH. Remove it as useless.

Looks fine to me. While we're at it, do we even need the '#ifdef CONFIG_LIVEPATCH' in these files? And in include/linux/livepatch.h?

IIRC there was a reason to this. If you build a patch module on (against) the kernel with CONFIG_LIVEPATCH=n the build fails immediately with those ifdefs, because there is no declaration of needed symbols present (klp_register_patch(), data structures and such). Without ifdefs the build succeeds and modprobe/insmod fails. The former could be advantageous in some scenarios.

But since the guard in include/linux/livepatch.h (which is the only important header file in fact) returns with Jessica's patches for better reason there is no point to discuss this further :)

Miroslav