Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4012866ybv; Mon, 10 Feb 2020 10:35:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwFTL+xe/ANkvei06ZsepH/aEJ2evDyNH2H5QzlHivkUXt5fM+YGcdf0kIFHvlBxq1MiNTi X-Received: by 2002:aca:534f:: with SMTP id h76mr265873oib.23.1581359705779; Mon, 10 Feb 2020 10:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581359705; cv=none; d=google.com; s=arc-20160816; b=AswtWloUgkanVW6NsKE0lucVQ5zDGk7JWxl14NkORESHI3/WoqOH254frI4jeB0Ahw NNXZPHD/9OlB4e8WkOgMy5Lw0gvHGHzk0t2ev3PZqR5wWaGq8ZuTohThMRV6TWL37ltm YIQRCUx9vbtZedjUGg5OGcC3GiO0fI146ZiHDIAiJbY8buUCMm75ciQ2AYRDilf/bb+h kKKrEYoNvQxvqaEonpbnxRvHEcbcnECW/0/Gt+CDaJA34f+AQeKzExiCDoHAjp4bGnUM bEmg0D81YALcQ6V8fwSnxFSSav2Y5/C5fPaBq/ieyndHcRDspyV8yBJ4l83YODoyK3tS O9hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i8fRUGFIHBnfJGjUZdlQ+TJpifnArFyNjaK/G+n3xX4=; b=Aoq/hWg6Qbu5++4yciMnHolCqtwynsFxcRktlJMHpAj9NFexKM4faGg35n+AQ30YbY S4LvrcTGaMVvZyDQlf96fkGdIftQnT6WjjfJUDLsIs/F00ggxpIPAwhl6nRkT08rDXm1 2XmtNLhDmf5ESfNvt7SnDm+T4hFQewGSh0aPC5d9v8r418tORwkrFhafEky62Jhyy0zK 2tnt/tmUbpBOZy7UuhXbPCqrnBy7v56P2l+x+XSrto5TmXGEvRRySF5TxyaLFA9Rx41E OhkFtM6KpAA7KhP+o4BN8XcGRIpiLBQMlqU3dOTCo8dqtbEW75RQQp8mW3W0InkDQeFq 3L2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K58RblsK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k19si558634otp.33.2020.02.10.10.34.53; Mon, 10 Feb 2020 10:35:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K58RblsK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbgBJSdZ (ORCPT + 99 others); Mon, 10 Feb 2020 13:33:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54273 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727671AbgBJSdY (ORCPT ); Mon, 10 Feb 2020 13:33:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581359603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i8fRUGFIHBnfJGjUZdlQ+TJpifnArFyNjaK/G+n3xX4=; b=K58RblsKSUpMBpVZM7uwgHM3e90ubLEKYOyV7TW/XGEuIx+/eF14cry8B8ou3zxSXjci9O qqq/rHPfZa2Qhsr0kXfO17JFhQB1/rW+8W/oscBFGa1Gi5df41q8vqIS6avfRrkAFAcMMj ieJkaqGXhlT4jUZZBIsibXZUqVk4hcg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-2mSjX6BaMkaeu-PE7fAcpw-1; Mon, 10 Feb 2020 13:33:21 -0500 X-MC-Unique: 2mSjX6BaMkaeu-PE7fAcpw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 366291005514; Mon, 10 Feb 2020 18:33:20 +0000 (UTC) Received: from treble.redhat.com (ovpn-122-45.rdu2.redhat.com [10.10.122.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12F2910013A7; Mon, 10 Feb 2020 18:33:18 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Julien Thierry , Peter Zijlstra Subject: [PATCH 2/3] objtool: Add is_static_jump() helper Date: Mon, 10 Feb 2020 12:32:39 -0600 Message-Id: <9b8b438df918276315e4765c60d2587f3c7ad698.1581359535.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are several places where objtool tests for a non-dynamic (aka direct) jump. Move the check to a helper function. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 61d2d1877fd2..5ea2ce7ed8a3 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -97,14 +97,19 @@ static struct instruction *next_insn_same_func(struct= objtool_file *file, for (insn =3D next_insn_same_sec(file, insn); insn; \ insn =3D next_insn_same_sec(file, insn)) =20 +static bool is_static_jump(struct instruction *insn) +{ + return insn->type =3D=3D INSN_JUMP_CONDITIONAL || + insn->type =3D=3D INSN_JUMP_UNCONDITIONAL; +} + static bool is_sibling_call(struct instruction *insn) { /* An indirect jump is either a sibling call or a jump to a table. */ if (insn->type =3D=3D INSN_JUMP_DYNAMIC) return list_empty(&insn->alts); =20 - if (insn->type !=3D INSN_JUMP_CONDITIONAL && - insn->type !=3D INSN_JUMP_UNCONDITIONAL) + if (!is_static_jump(insn)) return false; =20 /* add_jump_destinations() sets insn->call_dest for sibling calls. */ @@ -571,8 +576,7 @@ static int add_jump_destinations(struct objtool_file = *file) unsigned long dest_off; =20 for_each_insn(file, insn) { - if (insn->type !=3D INSN_JUMP_CONDITIONAL && - insn->type !=3D INSN_JUMP_UNCONDITIONAL) + if (!is_static_jump(insn)) continue; =20 if (insn->ignore || insn->offset =3D=3D FAKE_JUMP_OFFSET) @@ -782,8 +786,7 @@ static int handle_group_alt(struct objtool_file *file= , insn->ignore =3D orig_insn->ignore_alts; insn->func =3D orig_insn->func; =20 - if (insn->type !=3D INSN_JUMP_CONDITIONAL && - insn->type !=3D INSN_JUMP_UNCONDITIONAL) + if (!is_static_jump(insn)) continue; =20 if (!insn->immediate) --=20 2.21.1