42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 0279e7aded382011be52a2ad340fbfdbf15e75be Mon Sep 17 00:00:00 2001
 | |
| From: Thomas Gleixner <tglx@linutronix.de>
 | |
| Date: Thu, 3 Sep 2015 12:41:47 +0200
 | |
| Subject: [PATCH] x86/alternatives: Make optimize_nops() interrupt safe and
 | |
|  synced
 | |
| 
 | |
| optimize_nops() is buggy in two aspects:
 | |
| 
 | |
| - It's not disabling interrupts across the modification
 | |
| - It's lacking a sync_core() call
 | |
| 
 | |
| Fixes: 4fd4b6e5537c 'x86/alternatives: Use optimized NOPs for padding'
 | |
| Reported-by: "Richard W.M. Jones" <rjones@redhat.com>
 | |
| Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
 | |
| ---
 | |
|  arch/x86/kernel/alternative.c | 5 +++++
 | |
|  1 file changed, 5 insertions(+)
 | |
| 
 | |
| diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
 | |
| index c42827eb86cf..25f909362b7a 100644
 | |
| --- a/arch/x86/kernel/alternative.c
 | |
| +++ b/arch/x86/kernel/alternative.c
 | |
| @@ -338,10 +338,15 @@ done:
 | |
|  
 | |
|  static void __init_or_module optimize_nops(struct alt_instr *a, u8 *instr)
 | |
|  {
 | |
| +	unsigned long flags;
 | |
| +
 | |
|  	if (instr[0] != 0x90)
 | |
|  		return;
 | |
|  
 | |
| +	local_irq_save(flags);
 | |
|  	add_nops(instr + (a->instrlen - a->padlen), a->padlen);
 | |
| +	sync_core();
 | |
| +	local_irq_restore(flags);
 | |
|  
 | |
|  	DUMP_BYTES(instr, a->instrlen, "%p: [%d:%d) optimized NOPs: ",
 | |
|  		   instr, a->instrlen - a->padlen, a->padlen);
 | |
| -- 
 | |
| 2.4.3
 | |
| 
 |