From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750916AbeAOTIs (ORCPT + 1 other); Mon, 15 Jan 2018 14:08:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28053 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbeAOTIr (ORCPT ); Mon, 15 Jan 2018 14:08:47 -0500 Date: Mon, 15 Jan 2018 13:08:19 -0600 From: Josh Poimboeuf To: Borislav Petkov Cc: Peter Zijlstra , 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 Subject: Re: [PATCH 2/4] objtool: Implement jump_assert for _static_cpu_has() Message-ID: <20180115190819.3pxrnikuqoddxt4b@treble> References: <20180115164428.498966552@infradead.org> <20180115164909.836510626@infradead.org> <20180115180405.cdzdgw6tocbsmbrf@treble> <20180115181230.GD2228@hirez.programming.kicks-ass.net> <20180115183417.myyorkvsbte3tnrw@treble> <20180115185937.icl32kzpwov3pu64@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180115185937.icl32kzpwov3pu64@pd.tnic> 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.25]); Mon, 15 Jan 2018 19:08:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 15, 2018 at 07:59:37PM +0100, Borislav Petkov wrote: > Right, > > I've been putting away extending struct alt_instr for a long time now, > trying to be conservative about it but I guess this might be the right > time to change that. How about: > > struct alt_instr { > s32 instr_offset; /* original instruction */ > s32 repl_offset; /* offset to replacement instruction */ > u16 cpuid; /* cpuid bit set for replacement */ > u8 instrlen; /* length of original instruction */ > u8 replacementlen; /* length of new instruction */ > u8 padlen; /* length of build-time padding */ > u64 flags; /* alternative flags, see */ > } __packed; > > This way we have 64 settings. So we could do: > > ... > .flags = ALT_FLAGS_STATIC_CPU_HAS, > > or something like that and then we can do additional processing/matching > for the alternatives. > > Or, we can do > > struct alt_instr { > s32 instr_offset; /* original instruction */ > s32 repl_offset; /* offset to replacement instruction */ > u16 cpuid; /* cpuid bit set for replacement */ > u8 instrlen; /* length of original instruction */ > u8 replacementlen; /* length of new instruction */ > u8 padlen; /* length of build-time padding */ > u8 type; /* types */ > } __packed; > > and have 256 types but that would be limiting as we won't be able to set > more than one. > > Hmmm? That might be a good idea, but here we also need to annotate jump labels. So unless you want to make alternatives broad enough to encompass jump labels, I don't think it solves this particular problem. -- Josh