mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	jump_label, x86: Emit short JMP
Now that we can patch short JMP/NOP, allow the compiler/assembler to emit short JMP instructions. There is no way to have the assembler emit short NOPs based on the potential displacement, so leave those long for now. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20210506194157.967034497@infradead.org
This commit is contained in:
		
							parent
							
								
									5af0ea293d
								
							
						
					
					
						commit
						e7bf1ba97a
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		|  | @ -35,8 +35,7 @@ static __always_inline bool arch_static_branch(struct static_key * const key, co | ||||||
| static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) | static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) | ||||||
| { | { | ||||||
| 	asm_volatile_goto("1:" | 	asm_volatile_goto("1:" | ||||||
| 		".byte 0xe9 \n\t" | 		"jmp %l[l_yes]\n\t" | ||||||
| 		".long %l[l_yes] - (. + 4) \n\t" |  | ||||||
| 		JUMP_TABLE_ENTRY | 		JUMP_TABLE_ENTRY | ||||||
| 		: :  "i" (key), "i" (branch) : : l_yes); | 		: :  "i" (key), "i" (branch) : : l_yes); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,12 +15,18 @@ | ||||||
| #include <asm/kprobes.h> | #include <asm/kprobes.h> | ||||||
| #include <asm/alternative.h> | #include <asm/alternative.h> | ||||||
| #include <asm/text-patching.h> | #include <asm/text-patching.h> | ||||||
|  | #include <asm/insn.h> | ||||||
| 
 | 
 | ||||||
| #define JUMP_LABEL_NOP_SIZE	JMP32_INSN_SIZE | #define JUMP_LABEL_NOP_SIZE	JMP32_INSN_SIZE | ||||||
| 
 | 
 | ||||||
| int arch_jump_entry_size(struct jump_entry *entry) | int arch_jump_entry_size(struct jump_entry *entry) | ||||||
| { | { | ||||||
| 	return JMP32_INSN_SIZE; | 	struct insn insn = {}; | ||||||
|  | 
 | ||||||
|  | 	insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); | ||||||
|  | 	BUG_ON(insn.length != 2 && insn.length != 5); | ||||||
|  | 
 | ||||||
|  | 	return insn.length; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct jump_label_patch { | struct jump_label_patch { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Peter Zijlstra
						Peter Zijlstra