All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*()
@ 2018-08-28  6:55 Jiri Kosina
  2018-08-28  7:56 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiri Kosina @ 2018-08-28  6:55 UTC (permalink / raw)
  To: x86, Thomas Gleixner, Ingo Molnar
  Cc: Peter Zijlstra, Andy Lutomirski, Masami Hiramatsu, linux-kernel

From: Jiri Kosina <jkosina@suse.cz>

text_poke() and text_poke_bp() must be called with text_mutex held.
Let's put proper lockdep anotation in place instead of just mentioning
the requirement in comment.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 arch/x86/kernel/alternative.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 014f214da581..b9d5e7c9ef43 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -684,8 +684,6 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
  * It means the size must be writable atomically and the address must be aligned
  * in a way that permits an atomic write. It also makes sure we fit on a single
  * page.
- *
- * Note: Must be called under text_mutex.
  */
 void *text_poke(void *addr, const void *opcode, size_t len)
 {
@@ -700,6 +698,8 @@ void *text_poke(void *addr, const void *opcode, size_t len)
 	 */
 	BUG_ON(!after_bootmem);
 
+	lockdep_assert_held(&text_mutex);
+
 	if (!core_kernel_text((unsigned long)addr)) {
 		pages[0] = vmalloc_to_page(addr);
 		pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
@@ -782,8 +782,6 @@ int poke_int3_handler(struct pt_regs *regs)
  *	- replace the first byte (int3) by the first byte of
  *	  replacing opcode
  *	- sync cores
- *
- * Note: must be called under text_mutex.
  */
 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
 {
@@ -792,6 +790,9 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
 	bp_int3_handler = handler;
 	bp_int3_addr = (u8 *)addr + sizeof(int3);
 	bp_patching_in_progress = true;
+
+	lockdep_assert_held(&text_mutex);
+
 	/*
 	 * Corresponding read barrier in int3 notifier for making sure the
 	 * in_progress and handler are correctly ordered wrt. patching.

-- 
Jiri Kosina
SUSE Labs


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

* Re: [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*()
  2018-08-28  6:55 [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*() Jiri Kosina
@ 2018-08-28  7:56 ` Peter Zijlstra
  2018-08-28  8:49 ` Masami Hiramatsu
  2018-08-30 11:06 ` [tip:x86/urgent] x86/alternatives: Lockdep-enforce " tip-bot for Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2018-08-28  7:56 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: x86, Thomas Gleixner, Ingo Molnar, Andy Lutomirski,
	Masami Hiramatsu, linux-kernel

On Tue, Aug 28, 2018 at 08:55:14AM +0200, Jiri Kosina wrote:
> From: Jiri Kosina <jkosina@suse.cz>
> 
> text_poke() and text_poke_bp() must be called with text_mutex held.
> Let's put proper lockdep anotation in place instead of just mentioning
> the requirement in comment.

Thanks Jiri!

> Reported-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*()
  2018-08-28  6:55 [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*() Jiri Kosina
  2018-08-28  7:56 ` Peter Zijlstra
@ 2018-08-28  8:49 ` Masami Hiramatsu
  2018-08-30 11:06 ` [tip:x86/urgent] x86/alternatives: Lockdep-enforce " tip-bot for Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2018-08-28  8:49 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: x86, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Andy Lutomirski, Masami Hiramatsu, linux-kernel

On Tue, 28 Aug 2018 08:55:14 +0200 (CEST)
Jiri Kosina <jikos@kernel.org> wrote:

> From: Jiri Kosina <jkosina@suse.cz>
> 
> text_poke() and text_poke_bp() must be called with text_mutex held.
> Let's put proper lockdep anotation in place instead of just mentioning
> the requirement in comment.

Thank you!

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

> 
> Reported-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
>  arch/x86/kernel/alternative.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 014f214da581..b9d5e7c9ef43 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -684,8 +684,6 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
>   * It means the size must be writable atomically and the address must be aligned
>   * in a way that permits an atomic write. It also makes sure we fit on a single
>   * page.
> - *
> - * Note: Must be called under text_mutex.
>   */
>  void *text_poke(void *addr, const void *opcode, size_t len)
>  {
> @@ -700,6 +698,8 @@ void *text_poke(void *addr, const void *opcode, size_t len)
>  	 */
>  	BUG_ON(!after_bootmem);
>  
> +	lockdep_assert_held(&text_mutex);
> +
>  	if (!core_kernel_text((unsigned long)addr)) {
>  		pages[0] = vmalloc_to_page(addr);
>  		pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
> @@ -782,8 +782,6 @@ int poke_int3_handler(struct pt_regs *regs)
>   *	- replace the first byte (int3) by the first byte of
>   *	  replacing opcode
>   *	- sync cores
> - *
> - * Note: must be called under text_mutex.
>   */
>  void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  {
> @@ -792,6 +790,9 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  	bp_int3_handler = handler;
>  	bp_int3_addr = (u8 *)addr + sizeof(int3);
>  	bp_patching_in_progress = true;
> +
> +	lockdep_assert_held(&text_mutex);
> +
>  	/*
>  	 * Corresponding read barrier in int3 notifier for making sure the
>  	 * in_progress and handler are correctly ordered wrt. patching.
> 
> -- 
> Jiri Kosina
> SUSE Labs
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* [tip:x86/urgent] x86/alternatives: Lockdep-enforce text_mutex in text_poke*()
  2018-08-28  6:55 [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*() Jiri Kosina
  2018-08-28  7:56 ` Peter Zijlstra
  2018-08-28  8:49 ` Masami Hiramatsu
@ 2018-08-30 11:06 ` tip-bot for Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Kosina @ 2018-08-30 11:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jkosina, hpa, mingo, linux-kernel, peterz, mhiramat, luto, tglx

Commit-ID:  9222f606506c5f8ca2c8b8c939d59ed3e6ac4148
Gitweb:     https://git.kernel.org/tip/9222f606506c5f8ca2c8b8c939d59ed3e6ac4148
Author:     Jiri Kosina <jkosina@suse.cz>
AuthorDate: Tue, 28 Aug 2018 08:55:14 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Aug 2018 13:02:30 +0200

x86/alternatives: Lockdep-enforce text_mutex in text_poke*()

text_poke() and text_poke_bp() must be called with text_mutex held.

Put proper lockdep anotation in place instead of just mentioning the
requirement in a comment.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/nycvar.YFH.7.76.1808280853520.25787@cbobk.fhfr.pm

---
 arch/x86/kernel/alternative.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 014f214da581..b9d5e7c9ef43 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -684,8 +684,6 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
  * It means the size must be writable atomically and the address must be aligned
  * in a way that permits an atomic write. It also makes sure we fit on a single
  * page.
- *
- * Note: Must be called under text_mutex.
  */
 void *text_poke(void *addr, const void *opcode, size_t len)
 {
@@ -700,6 +698,8 @@ void *text_poke(void *addr, const void *opcode, size_t len)
 	 */
 	BUG_ON(!after_bootmem);
 
+	lockdep_assert_held(&text_mutex);
+
 	if (!core_kernel_text((unsigned long)addr)) {
 		pages[0] = vmalloc_to_page(addr);
 		pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
@@ -782,8 +782,6 @@ int poke_int3_handler(struct pt_regs *regs)
  *	- replace the first byte (int3) by the first byte of
  *	  replacing opcode
  *	- sync cores
- *
- * Note: must be called under text_mutex.
  */
 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
 {
@@ -792,6 +790,9 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
 	bp_int3_handler = handler;
 	bp_int3_addr = (u8 *)addr + sizeof(int3);
 	bp_patching_in_progress = true;
+
+	lockdep_assert_held(&text_mutex);
+
 	/*
 	 * Corresponding read barrier in int3 notifier for making sure the
 	 * in_progress and handler are correctly ordered wrt. patching.

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

end of thread, other threads:[~2018-08-30 11:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28  6:55 [PATCH] x86/alternatives: lockdep-enforce text_mutex in text_poke*() Jiri Kosina
2018-08-28  7:56 ` Peter Zijlstra
2018-08-28  8:49 ` Masami Hiramatsu
2018-08-30 11:06 ` [tip:x86/urgent] x86/alternatives: Lockdep-enforce " tip-bot for Jiri Kosina

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.