From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeAPWuC (ORCPT + 1 other); Tue, 16 Jan 2018 17:50:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42332 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbeAPWuA (ORCPT ); Tue, 16 Jan 2018 17:50:00 -0500 Date: Tue, 16 Jan 2018 16:49:55 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: David Woodhouse , linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Thomas Gleixner , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Borislav Petkov Subject: Re: [PATCH v2 03/10] x86: Add a type field to alt_instr Message-ID: <20180116224955.zwfqr74agcy6qymw@treble> References: <20180116142825.376986833@infradead.org> <20180116143241.063773295@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180116143241.063773295@infradead.org> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 16 Jan 2018 22:50:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 16, 2018 at 03:28:28PM +0100, Peter Zijlstra wrote: > 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; Should we put a comment above the struct with a reminder to also update objtool ALT_ENTRY_SIZE (and possibly the ALT_*_OFFSET macros) when they change the struct? Unfortunately it's against policy to include kernel headers from the tools subdirectory, so we generally have to either hard code things like this, or have a duplicated header file which needs to be kept in sync. -- Josh