From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AFFAC433DB for ; Wed, 20 Jan 2021 18:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 326B3233EB for ; Wed, 20 Jan 2021 18:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392398AbhATS4b (ORCPT ); Wed, 20 Jan 2021 13:56:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21400 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387699AbhATRjs (ORCPT ); Wed, 20 Jan 2021 12:39:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611164301; 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=ybADuVVj33zXJpBTN6zXgGLfnzshZUI1ojUuRxuiGxo=; b=IRoiuwMiNY+QQxnVSMo7/6CPPzufqAPivop7ams7efCwxaQDMr8fYjEaskDWgRJmOe8Gvg 0I4R75lsO2csRkzMLfdFN2i9mm4ALYTTCWRjC8RNWuZqKtX3mgafOmnjoQwR15emi4M5p5 ths8w+XJ3f1FEp35NYBzq6O3eWNKqtg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-wVmZokurMpWF-tX7VxFNrg-1; Wed, 20 Jan 2021 12:38:20 -0500 X-MC-Unique: wVmZokurMpWF-tX7VxFNrg-1 Received: by mail-wr1-f70.google.com with SMTP id r8so11923075wro.22 for ; Wed, 20 Jan 2021 09:38:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ybADuVVj33zXJpBTN6zXgGLfnzshZUI1ojUuRxuiGxo=; b=KphlFN/PI+oCTTlaiOposiWJxhiZ50+x9msSlMFX06C5swcZsJxkFcx916NCYMSFzt Jgh1HbUvtFsOqaP0o1iO3DlY54zJNjMRHm5O1MKGB9Tmf624pQMBtXqcxuaQgFk07IAT 2pexiC+u+HiFDU9TW63XbWzIhlMM+duVm5Vi/noJMsEX6T67YIbR2KEiTaGYVNYNzYpW oJJN93YMfGndtFRGvLGki7rX6KeRv0JgUUtFBTZdM4/DHCZTRm9v872EGhcnsZo6sMh0 NkQE0r/9cOVpdVrthqsjlOZFtUEdoW3R7G0NLIGDWv8Gke5aou3oFET5AnO5dr7WfFD4 wRbA== X-Gm-Message-State: AOAM530z23bU/GProutrIeSyguHVyaxOa66j4TKzQOumemQK6TlglYEb ckPZNgJBoIWBE7nPNNKUw+JS+YENEWossSQ2JViXjLWucuqDTLijvHRqfR78Wo34szqGVzsddsM HfmV+RgYXGwwyq/HR3FPTTc7SYkIlGzN0tnA9/EEe3QnpVNygtiTAR0tnsPzVE66VHPoRRs188H W0 X-Received: by 2002:a5d:5917:: with SMTP id v23mr10790338wrd.308.1611164298857; Wed, 20 Jan 2021 09:38:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCWhKh32IYPGwQ7eOyS6NFprZttJ5fMUAm09DXGKOoX6f0LQRibhfxka+az9xnCWXYUtnyTw== X-Received: by 2002:a5d:5917:: with SMTP id v23mr10790318wrd.308.1611164298719; Wed, 20 Jan 2021 09:38:18 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id x11sm4948325wmi.4.2021.01.20.09.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 09:38:18 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, masahiroy@kernel.org, keescook@chromium.org, michal.lkml@markovi.net, jpoimboe@redhat.com, peterz@infradead.org, mark.rutland@arm.com, broonie@kernel.org, linux-efi@vger.kernel.org, linux-hardening@vger.kernel.org, Julien Thierry Subject: [RFC PATCH 06/17] objtool: arm64: Decode jump and call related instructions Date: Wed, 20 Jan 2021 18:37:49 +0100 Message-Id: <20210120173800.1660730-7-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210120173800.1660730-1-jthierry@redhat.com> References: <20210120173800.1660730-1-jthierry@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Decode branch, branch and link (aarch64's call) and return instructions. Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 0f312dd1b146..924121b4b466 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -205,6 +205,28 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec, } *type = INSN_OTHER; break; + case AARCH64_INSN_CLS_BR_SYS: + if (aarch64_insn_is_ret(insn) && + aarch64_insn_decode_register(AARCH64_INSN_REGTYPE_RN, insn) == AARCH64_INSN_REG_LR) { + *type = INSN_RETURN; + } else if (aarch64_insn_is_bl(insn)) { + *type = INSN_CALL; + *immediate = aarch64_get_branch_offset(insn); + } else if (aarch64_insn_is_blr(insn)) { + *type = INSN_CALL_DYNAMIC; + } else if (aarch64_insn_is_b(insn)) { + *type = INSN_JUMP_UNCONDITIONAL; + *immediate = aarch64_get_branch_offset(insn); + } else if (aarch64_insn_is_br(insn)) { + *type = INSN_JUMP_DYNAMIC; + } else if (aarch64_insn_is_branch_imm(insn)) { + /* Remaining branch opcodes are conditional */ + *type = INSN_JUMP_CONDITIONAL; + *immediate = aarch64_get_branch_offset(insn); + } else { + *type = INSN_OTHER; + } + break; default: *type = INSN_OTHER; break; -- 2.25.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABAB4C433DB for ; Wed, 20 Jan 2021 17:44:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BD0B2070A for ; Wed, 20 Jan 2021 17:44:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BD0B2070A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=o7D/xT5UpF3Rx1MPJQjtT8tNta5/O0Zm9Xu5F+b3lH8=; b=LQ7mrUQ0zfEbVyt4VeNDT/jOZ /sMzTxKPrrNXFnqafPoCY9AjlQukcaTgkuRI1mNWJO6yl9QJ0DYuRnGOVzHXnCfWnfh5bBOJm1rOa hYv88JrmIEzMflf26JJNCNc7rTCjA6GthfNFCEytOet7VHZjNqa9/0eLXurdfUo+j1tpU5i8XyG3d ZInFowsQLxTQHS44YR4ix+C/Zwp94lRdPBSH5BmCkkknnAnBzGgf1UIz6+WDf4IxtALiNBibX63Zm 1j2i3V9ii7o7+DhqhjyK3PH75CB2YxpcO6HBrxh0VKM6oppLNc08x5L/VZi5ytu/R+rCzpQhDcJZ3 z0X3qzQ7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HU2-0004ST-Da; Wed, 20 Jan 2021 17:41:30 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HR2-0002q5-Se for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2021 17:38:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611164301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ybADuVVj33zXJpBTN6zXgGLfnzshZUI1ojUuRxuiGxo=; b=CvlhGPSilL2M4xf/bzvy2s8xp83o5ym05ToX3jmd1GcywNCAMVHkNpnnIrGrLX/6udOJyw X2fR9d7x3f5/FI6G8BURY2Dh1e1lsr5QnnshDDX/XZ22v3nS8mGZs/cntxfjeVsz8fwmX3 3bQK2ujM87BzG2U4H6XTnb/S/JQ9C4Q= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-514-Xdvjy4HAOr-bidsfmL49Fg-1; Wed, 20 Jan 2021 12:38:20 -0500 X-MC-Unique: Xdvjy4HAOr-bidsfmL49Fg-1 Received: by mail-wr1-f70.google.com with SMTP id q2so11965430wrp.4 for ; Wed, 20 Jan 2021 09:38:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ybADuVVj33zXJpBTN6zXgGLfnzshZUI1ojUuRxuiGxo=; b=AgJ36cAVa2RTwj6bnePzmFbnodocRqg8uml4aTVuj7Mx9ypNapIPfssl5KocOY7cQi GQcGnLpb+7XaHws7dVK+DY89I8ZQfoY6g7B+cjHE8YQ9AhenNpisosxEZbM/gk9x0lF9 /GX/TmoXWpjkp5deksDxEFYk6dUnOGtAHEYc87IL5dUHaruPE/W5neMVHKnam+rPhF86 GKjtzf8UC0CY+DFlwJDPoc4xPkDWKP6Erhqee1uOOBM6docb0gshH7cK29HT+7b8efV+ raeagXKEFe21KW4zO0ErK0nArLRpTkAxA/CBNpi9Kb1mcmU7dB/sd0Lc3hRF3vLFQ0xF vA/Q== X-Gm-Message-State: AOAM5307MU/8XJALfJcKXliUFfFj83BLFIer0+6i5o2Rj1bOHQLaS4Yq 8+BmuA1o4glp/4mMNzCfKJqK3/t7h+ogMKL2BJ/x+B52ZbhueEJc+YYRU9+94kXSy6mvRNbIxtm IRdzxgU629WjVPRVVbdm1Tdb7V3z/W3QabjY= X-Received: by 2002:a5d:5917:: with SMTP id v23mr10790325wrd.308.1611164298825; Wed, 20 Jan 2021 09:38:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCWhKh32IYPGwQ7eOyS6NFprZttJ5fMUAm09DXGKOoX6f0LQRibhfxka+az9xnCWXYUtnyTw== X-Received: by 2002:a5d:5917:: with SMTP id v23mr10790318wrd.308.1611164298719; Wed, 20 Jan 2021 09:38:18 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id x11sm4948325wmi.4.2021.01.20.09.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 09:38:18 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 06/17] objtool: arm64: Decode jump and call related instructions Date: Wed, 20 Jan 2021 18:37:49 +0100 Message-Id: <20210120173800.1660730-7-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210120173800.1660730-1-jthierry@redhat.com> References: <20210120173800.1660730-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_123825_162158_43BF5869 X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-efi@vger.kernel.org, michal.lkml@markovi.net, keescook@chromium.org, peterz@infradead.org, catalin.marinas@arm.com, masahiroy@kernel.org, broonie@kernel.org, linux-hardening@vger.kernel.org, jpoimboe@redhat.com, will@kernel.org, ardb@kernel.org, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Decode branch, branch and link (aarch64's call) and return instructions. Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 0f312dd1b146..924121b4b466 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -205,6 +205,28 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec, } *type = INSN_OTHER; break; + case AARCH64_INSN_CLS_BR_SYS: + if (aarch64_insn_is_ret(insn) && + aarch64_insn_decode_register(AARCH64_INSN_REGTYPE_RN, insn) == AARCH64_INSN_REG_LR) { + *type = INSN_RETURN; + } else if (aarch64_insn_is_bl(insn)) { + *type = INSN_CALL; + *immediate = aarch64_get_branch_offset(insn); + } else if (aarch64_insn_is_blr(insn)) { + *type = INSN_CALL_DYNAMIC; + } else if (aarch64_insn_is_b(insn)) { + *type = INSN_JUMP_UNCONDITIONAL; + *immediate = aarch64_get_branch_offset(insn); + } else if (aarch64_insn_is_br(insn)) { + *type = INSN_JUMP_DYNAMIC; + } else if (aarch64_insn_is_branch_imm(insn)) { + /* Remaining branch opcodes are conditional */ + *type = INSN_JUMP_CONDITIONAL; + *immediate = aarch64_get_branch_offset(insn); + } else { + *type = INSN_OTHER; + } + break; default: *type = INSN_OTHER; break; -- 2.25.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel