Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp758820ybz; Wed, 29 Apr 2020 08:53:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJlv85m9XUFLhE0Tc+8H0xneZkBQF6CiqEOYWeTxzTYc9L/IuO92dCNZUbx6/IWrXVE3aXa X-Received: by 2002:aa7:ca45:: with SMTP id j5mr2961710edt.268.1588175589686; Wed, 29 Apr 2020 08:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588175589; cv=none; d=google.com; s=arc-20160816; b=0teJj0JhOK95oZ5cerXzSLLP7HWpKSe/rDu0CSbhvTfV1Pv8ggWyrCsYrNjyRklYB1 DxvAyqoTHLq6fVY2l4wE5ZSdVi1zi+qNi3xVCPAHu5ZptsV0/7OYpNm13aR5QZUb4efK QTKgV1wQSMVPYss/3aeZaVlRehjZhRooCVteLFxikQuariY/ZyUpbQv1p9bYGrr958Ea W8CiFdJ2HM9X1k5396awydgG3vep1YpZVh0TDr5PJouV6UG59PV/I7hbJHKqipb/WwGe VZ3VwwvujFXyUADFh+434EN12T/b2lrJtP2+Qvs8vvQg4JRcUhcnqcZizT0Rv+rMS++d qXPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NxBBFFm6MtwCSdPcYTRckA3NQsUn3OiyYrVi4AMqwnQ=; b=OepBLgQ/IW6jGZB7BUz3j53MC5qzuUOA8938WbS6z23aQ/9qGiLp7E4JTpXoZomvLt Wp7V5Du05rnYhCfLl+mzxIMJpwbh5N0EWUz1FN5188aN5afBojK7la3HP1sUOWseL/9u e2R5hIPFRpL/Skrp3kaS76T73iIJUcKTfciFQQCs8FY6kQ57R16oegM9INf7dl3nbPAh tlcdnLT7gQz0lA43Rywwt9QRm5YGa0je6dDUB6lpj4D4sXhEdplc2a2KairsCmfIhaL4 gXfzfsbM0oAwuX5DQymfZrxeXGhyxADselF0sQlIU6O5IPRF6VNFfjbRi9EQVv94PnHZ zXiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=F5ul1L8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si3494229edb.262.2020.04.29.08.52.45; Wed, 29 Apr 2020 08:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=F5ul1L8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgD2PvR (ORCPT + 99 others); Wed, 29 Apr 2020 11:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbgD2PvQ (ORCPT ); Wed, 29 Apr 2020 11:51:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AABF5C03C1AD for ; Wed, 29 Apr 2020 08:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NxBBFFm6MtwCSdPcYTRckA3NQsUn3OiyYrVi4AMqwnQ=; b=F5ul1L8C/XskogCvKJ7LlCJhxO aEbtYahfIeSU21RzUMsl9uZ5r10KqANOnR1jsEOW9tK4Cq3MBhpGKSBrSQVB9phdebLADYTGKOlH4 VgStoiCqApU9zqGEWPJ7rcdX9WjI02fLZ8JdcW1pGCOWLIXve1N6yUg6hr5AkrADB3tcgk1GveKxO 9VO5ndtowBnBFjzkofqJ2rF3jPSmRsmCrtIIfyURzmKfGZ98AH1F0M6gcOjUe+6bLPuPbXqLVzzvD xZmfy8U5d7ZgssyrtyGXEbUzpWW4AiifAGHsyzhDjCuW9PoLrICqF0sl+6Ky+umNJ/XoeVLQRfkN2 pCIWfZbw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jTozP-0000df-GE; Wed, 29 Apr 2020 15:51:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DC0143011E8; Wed, 29 Apr 2020 17:51:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C378620BD9729; Wed, 29 Apr 2020 17:51:09 +0200 (CEST) Date: Wed, 29 Apr 2020 17:51:09 +0200 From: Peter Zijlstra To: Miroslav Benes Cc: jpoimboe@redhat.com, alexandre.chartre@oracle.com, linux-kernel@vger.kernel.org, jthierry@redhat.com, tglx@linutronix.de, x86@kernel.org, Jann Horn Subject: Re: [PATCH v2 02/14] objtool: Fix ORC vs alternatives Message-ID: <20200429155109.GN13592@hirez.programming.kicks-ass.net> References: <20200428191101.886208539@infradead.org> <20200428191659.499074346@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 29, 2020 at 04:33:31PM +0200, Miroslav Benes wrote: > On Tue, 28 Apr 2020, Peter Zijlstra wrote: > > /* > > + * Alternatives should not contain any ORC entries, this in turn means they > > + * should not contain any CFI ops, which implies all instructions should have > > + * the same same CFI state. > > + * > > + * It is possible to constuct alternatives that have unreachable holes that go > > + * unreported (because they're NOPs), such holes would result in CFI_UNDEFINED > > + * states which then results in ORC entries, which we just said we didn't want. > > + * > > + * Avoid them by copying the CFI entry of the first instruction into the whole > > + * alternative. > > + */ > > +static void fill_alternative_cfi(struct objtool_file *file, struct instruction *insn) > > +{ > > + struct instruction *first_insn = insn; > > + int alt_group = insn->alt_group; > > + > > + sec_for_each_insn_continue(file, insn) { > > + if (insn->alt_group != alt_group) > > + break; > > + insn->cfi = first_insn->cfi; > > + } > > +} > > If I am reading this and previous patch correctly... > > The function would copy cfi only to "orig" alternative (its insn->alts is > non-empty, orig_insn->alt_group differs from new_insn->alt_group), right? Yes. > Would it make sense to do the same for "new" alternative, because of the > invariant? It seems to me it is not processed anywhere that way. No. > Am I missing something? Whenever I try to read all this alternatives > handling in objtool, I get lost pretty soon. We only care about the ORC covering the original range, because that is the range we execute code from. The memory where we store the alternative instructions (.altinstruction section) is never executed, that is, RIP should never point there, so we don't need ORC data covering it.