From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756542AbeARPHG (ORCPT ); Thu, 18 Jan 2018 10:07:06 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:42691 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754836AbeARO56 (ORCPT ); Thu, 18 Jan 2018 09:57:58 -0500 Message-Id: <20180118140151.744090514@infradead.org> User-Agent: quilt/0.63-1 Date: Thu, 18 Jan 2018 14:48:05 +0100 From: Peter Zijlstra From: Peter Zijlstra To: David Woodhouse , Thomas Gleixner , Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Jason Baron , Peter Zijlstra , Borislav Petkov Subject: [PATCH 05/35] x86: Add a type field to alt_instr References: <20180118134800.711245485@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-alternative-type.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a type field to the alternative description. For now this will be used to annotate static_cpu_has() but possible future uses include using it to implement alternative alignment and special NOP handling. Suggested-by: Borislav Petkov Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/alternative-asm.h | 3 ++- arch/x86/include/asm/alternative.h | 6 +++++- arch/x86/include/asm/cpufeature.h | 2 ++ tools/objtool/special.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) --- a/arch/x86/include/asm/alternative-asm.h +++ b/arch/x86/include/asm/alternative-asm.h @@ -25,13 +25,14 @@ * enough information for the alternatives patching code to patch an * instruction. See apply_alternatives(). */ -.macro altinstruction_entry orig alt feature orig_len alt_len pad_len +.macro altinstruction_entry orig alt feature orig_len alt_len pad_len type=0 .long \orig - . .long \alt - . .word \feature .byte \orig_len .byte \alt_len .byte \pad_len + .byte \type .endm /* --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -45,6 +45,8 @@ #define LOCK_PREFIX "" #endif +#define ALT_TYPE_DEFAULT 0 + struct alt_instr { s32 instr_offset; /* original instruction */ s32 repl_offset; /* offset to replacement instruction */ @@ -52,6 +54,7 @@ struct alt_instr { u8 instrlen; /* length of original instruction */ u8 replacementlen; /* length of new instruction */ u8 padlen; /* length of build-time padding */ + u8 type; /* type of alternative */ } __packed; /* @@ -127,7 +130,8 @@ static inline int alternatives_text_rese " .word " __stringify(feature) "\n" /* feature bit */ \ " .byte " alt_total_slen "\n" /* source len */ \ " .byte " alt_rlen(num) "\n" /* replacement len */ \ - " .byte " alt_pad_len "\n" /* pad len */ + " .byte " alt_pad_len "\n" /* pad len */ \ + " .byte 0 \n" /* type */ #define ALTINSTR_REPLACEMENT(newinstr, feature, num) /* replacement */ \ b_replacement(num)":\n\t" newinstr "\n" e_replacement(num) ":\n\t" --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -157,6 +157,7 @@ static __always_inline __pure bool _stat " .byte 3b - 1b\n" /* src len */ " .byte 5f - 4f\n" /* repl len */ " .byte 3b - 2b\n" /* pad len */ + " .byte 0\n" /* type */ ".previous\n" ".section .altinstr_replacement,\"ax\"\n" "4: jmp %l[t_no]\n" @@ -169,6 +170,7 @@ static __always_inline __pure bool _stat " .byte 3b - 1b\n" /* src len */ " .byte 0\n" /* repl len */ " .byte 0\n" /* pad len */ + " .byte 0\n" /* type */ ".previous\n" ".section .altinstr_aux,\"ax\"\n" "6:\n" --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -34,7 +34,7 @@ #define JUMP_ORIG_OFFSET 0 #define JUMP_NEW_OFFSET 8 -#define ALT_ENTRY_SIZE 13 +#define ALT_ENTRY_SIZE 14 #define ALT_ORIG_OFFSET 0 #define ALT_NEW_OFFSET 4 #define ALT_FEATURE_OFFSET 8