From patchwork Thu Jan 9 16:02:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EE3C930 for ; Thu, 9 Jan 2020 16:09:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E4F2320661 for ; Thu, 9 Jan 2020 16:09:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Pz+nL7pX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Cn5rSfgU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4F2320661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=yHyoMhsSXiX7Z7HMt8iqBWUXbdY9IZ6LxGd7K4Ym4AY=; b=Pz+nL7pXDyYsad U2Hv7SRK6xzsLYmuolVuWsaTZakk5w6yoPwzKl9kY2pNulvmKK1WqnUy+kTF6+u6RIl49owL/KMkp Eza3IbVfo/8lf1Uc24G012aIy7eGe88CeMoNwpvYAJQaXtKBVLy5qVYI79WOiMfMSAITYExC5orl1 zfT/c50EjtUZm5TxA574vZ0P6q7JOaGhLin13lpkj/ZPeF0NrAfT5hCS4K212BSbDqY/z/DFpJWfW m1GwYWxVnKl7F17dmuau+qcB3kvpzPXU0rCHGG8qUSf+l1XUBCm5BkekjSKUZG0YVlryJZ99rTLgp vZfSKY7Hj65yLe/Pee4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMs-0001xC-Ee; Thu, 09 Jan 2020 16:09:06 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJH-0006z8-Jn for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585921; 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=VoZqCBetiwAvEoR5ECNM7m4hScz5XF9PJmd6ARWzq0s=; b=Cn5rSfgUnnWLfOsVOxMsu39BmrzDySdlVO1poiY1xjplUVUwrkgcTjc2/KfGmE7/YOT5jB SxKFlBbfWjMZuZQMUCCZ3wExEg5S1Rc4KqEa1tKlhITXKRcWwyf/th7ivyMf49QTdLP0Fr rnloymuUNix1qYW573KuAElulSeXlRM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-IXc5Bs9cPf2Y7zy5SX28Ug-1; Thu, 09 Jan 2020 11:03:13 -0500 Received: by mail-wr1-f71.google.com with SMTP id c6so3023590wrm.18 for ; Thu, 09 Jan 2020 08:03:13 -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=cv9OEnoxm5jqEof6Q4MR3S73IbKofEk1lKfADeLvzKM=; b=Z+rYcbNI3uRgcezKwIohRTbVNQcU2VxUHTiMURpe8j1c+UTxOnxbmLvVmVh+tU7gum Uu5irsW3Mob5Swl9GLOVrgWpyHHLXf5CC2Dy3F2pqnR+vEB+fa7oK6akdgpW72IJ1iqa Ili8tXX21d5upfDVxm19XMVyUs+r8qru4rX+1ky3bcb3F6+VBypY7ua9dh5zhQ7JslsM HMHjhkzc+rN1CtkZIpRMEv9474zlM4Rk2RgBHFQ9AfTNexVVHTWHgAIEVQZYroicx5iz ukWzrqzI9FqRNW7ZMwITdJQX38wHsrMJTq6q9xgF99v19X3Ws05XK0Cl6vprgg5nnIiQ 6IkA== X-Gm-Message-State: APjAAAXEkCDDhfz0n8S3VtJy6LnPgbFgtKj+CkxTjDGZ+bDz+NfrJdH5 D9CFrlZOookIwrN5GtB8Te6+lQlhv0y89P6mf+j97Nh0KDy5n6uFMUN36On/FyrYlrVpa/kWA8A e+PPd5CUS8rFS48xUgbe3j4XiQxnEoD4Fafw= X-Received: by 2002:a5d:538e:: with SMTP id d14mr11942318wrv.358.1578585792181; Thu, 09 Jan 2020 08:03:12 -0800 (PST) X-Google-Smtp-Source: APXvYqywPwV2UvQwN4s2qv+/dJ9GOKMz9Upk2KnoXLCCN9ETrzeZJVoqAGjRgbLtFMAu3XU2NN4UVw== X-Received: by 2002:a5d:538e:: with SMTP id d14mr11942292wrv.358.1578585791962; Thu, 09 Jan 2020 08:03:11 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id z21sm3258969wml.5.2020.01.09.08.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:11 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 01/57] objtool: check: Remove redundant checks on operand type Date: Thu, 9 Jan 2020 16:02:04 +0000 Message-Id: <20200109160300.26150-2-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: IXc5Bs9cPf2Y7zy5SX28Ug-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080523_866437_F39BC7F6 X-CRM114-Status: GOOD ( 10.97 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org POP operations are already in code path where destination operand is OP_DEST_REG. There is no need to check the operand type again. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.21.0 diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4768d91c6d68..a04778421144 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1672,15 +1672,13 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) case OP_SRC_POP: case OP_SRC_POPF: - if (!state->drap && op->dest.type == OP_DEST_REG && - op->dest.reg == cfa->base) { + if (!state->drap && op->dest.reg == cfa->base) { /* pop %rbp */ cfa->base = CFI_SP; } if (state->drap && cfa->base == CFI_BP_INDIRECT && - op->dest.type == OP_DEST_REG && op->dest.reg == state->drap_reg && state->drap_offset == -state->stack_size) { From patchwork Thu Jan 9 16:02:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22AAD1395 for ; Thu, 9 Jan 2020 16:11:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F3DD320661 for ; Thu, 9 Jan 2020 16:11:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OykNLmMI"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R1LLK4JB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3DD320661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=9Trxk/GJ1GOzQ7Bxk51xYuMdUpKBGI9YefkUNeV/hEE=; b=OykNLmMIki9ive PcnEPxNSjIB1NiqdlH+6JW2mKM3SY8D/X1ty+6vlEw89VIeOGAKNU6IgMqEF6+Z6K5uqvltiHGX+k iQWdX84pFcgfxzJ8yfceBShcrNL0+6Tnjyu/bvDHqw6VCg677waee5K+KMYHhgIl/ayHLR76Xslai QJCSOQ+jpnIAFuiD7+eYyTFc84SIsHrz3lowb4Mtr6XkLTg9ZG/EZLGraWDfnascoSQV37pbTnPKR qVr6NxupdCR348CPbhkHfxJhyv+OD2faoQf3Na5z0CGe3S7072z61FU8iDzDyyqYH9O89QQloCPRV UEMCLWUkcau4Fug7rb+g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaPJ-0005cX-CQ; Thu, 09 Jan 2020 16:11:37 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJv-0007eB-L8 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585961; 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=0uuxcpkn5JFDgE+lOpghWftUHEKd37cfHOyYmtcckKY=; b=R1LLK4JBWtp8bXARd6Bo/AaGg5Pr6XPvDy/7c+v3F3gRjRuwsqpP+X13yFPm7HQgci/+yG SYX5yvJSrWdZrq48AgXw8gaK9xBAxOCoIE46thIH8aoxnzBdm4uzQ2Z9UnbJF5DQqALEXX 8PElYy+1eCMRKF3tP9q8MrMKdwukAnw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-W9StxrtnMWCYEZ9R-uBqXQ-1; Thu, 09 Jan 2020 11:03:14 -0500 Received: by mail-wm1-f71.google.com with SMTP id y125so882917wmg.1 for ; Thu, 09 Jan 2020 08:03:14 -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=2TbvKMt2I2jso1SowXcHnsxCi6YkVVHUp/mczZ9qxkU=; b=txD/3p8LulNWoQBYGgRfPFZ23ekglyYa9Ahncsd95+hqBRlOSAIgqHJX3mCrvbglLD lh+v8l8uhDB8qrmRTkwvEleWsHRlinWvf7TVgXIhDCXKSCZuxdGaRz1PwaahFH0oV+kk kBlNwSKddFBeh6OjWs5KlDEMvA/mXJ7VWQz6cyzU56dFctib72J77paHkG/MjKCHivDz TRTsLQgM7Fbjb/PsrVhAM9Np/4W39gejRl12BgiUbaFzwKbc+1NhvedwhZ0DP3lH5u9G oW1Ps45Ykj9vwDfQGhoM8PHB9gNG+yIPNUY48vtnEDs6mrGJaLxVs+NXvMGCnBrE17RM cmjA== X-Gm-Message-State: APjAAAXvxpMJoifGDVoT9mOynCRdLR4tmc9iTCqgxf45kcvJtk/IqvLG v5KXh2GJgFkESXTFONMaGCXyXWYx4Ki6aJjgGB8Lz+BERl0Jk26LcOb4L367qLXnY5+NSeNcXX4 2WFl1rZznkx6VZnZ2y3LXQ4HZzVFCqoz9JpY= X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr5903399wmj.90.1578585793360; Thu, 09 Jan 2020 08:03:13 -0800 (PST) X-Google-Smtp-Source: APXvYqx1i6RTYzKo5WMbgBgJvZ21maBSBOwlzW/NH2DdpXZf53ZMSa43jR/D3EBbhqlU18Cm4YAYbg== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr5903384wmj.90.1578585793218; Thu, 09 Jan 2020 08:03:13 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id z21sm3258969wml.5.2020.01.09.08.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:12 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 02/57] objtool: check: Clean instruction state before each function validation Date: Thu, 9 Jan 2020 16:02:05 +0000 Message-Id: <20200109160300.26150-3-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: W9StxrtnMWCYEZ9R-uBqXQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080603_783456_DD063E2E X-CRM114-Status: GOOD ( 10.82 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When a function fails its validation, it might leave a stale state that will be used for the validation of other functions. That would cause false warnings on potentially valid functions. Reset the instruction state before the validation of each individual function. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) -- 2.21.0 diff --git a/tools/objtool/check.c b/tools/objtool/check.c index a04778421144..4784f0f6a3ae 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2348,13 +2348,6 @@ static int validate_functions(struct objtool_file *file) struct insn_state state; int ret, warnings = 0; - clear_insn_state(&state); - - state.cfa = initial_func_cfi.cfa; - memcpy(&state.regs, &initial_func_cfi.regs, - CFI_NUM_REGS * sizeof(struct cfi_reg)); - state.stack_size = initial_func_cfi.cfa.offset; - for_each_sec(file, sec) { list_for_each_entry(func, &sec->symbol_list, list) { if (func->type != STT_FUNC) @@ -2373,6 +2366,12 @@ static int validate_functions(struct objtool_file *file) if (!insn || insn->ignore || insn->visited) continue; + clear_insn_state(&state); + state.cfa = initial_func_cfi.cfa; + memcpy(&state.regs, &initial_func_cfi.regs, + CFI_NUM_REGS * sizeof(struct cfi_reg)); + state.stack_size = initial_func_cfi.cfa.offset; + state.uaccess = func->uaccess_safe; ret = validate_branch(file, func, insn, state); From patchwork Thu Jan 9 16:02:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9CD2930 for ; Thu, 9 Jan 2020 16:07:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 879EE20661 for ; Thu, 9 Jan 2020 16:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="t+AFPPkw"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ax3v47pu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 879EE20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=J+uOSgDDroPtEJxcOJ40IWdwj05hXFzaEy8MfyZI6ww=; b=t+AFPPkwGQNw+G MjyTxi9QVpSGrK0jx6WNjKxMwZtm2kYeIIOBHMrt54UHlC+cAv7Tst6QFvGjTi7+XmbgNzeoq/ffF n5Ac7d21nx3pinPZJLV4ZXNmri2tiStBX8X2NEdKDdQAsRYUBhDGMTehb2DC/+nryasYtkbOT4mpS WpjeRBw77NV+6Dt8nVrJvbU4R5cAUnANVw4LjZBGwVpaQjaQ/Yrl4mLC08gV2gc2/QSDgZbPbnNEX C1K/q6qt1jE4n9/1vA4sxDsdo3oJNkRdjtwK7Utc+EFVFzVxn3G4KlHMI2yEXltBQL1QQ/6m1kWI0 AteYyTZ0/8EkUT3RAgrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLK-0000VU-Nf; Thu, 09 Jan 2020 16:07:30 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJ6-00065h-3W for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585907; 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=nrmsztAj2poxJxg6fxmu2Z7SI2LPSgd3Nzrj9Xbra3A=; b=Ax3v47puuIJgFDm0PqPs4xp6S2l/nZWqyjrz6MOezjoWMbGoUL6qQHMJYSu+jZIpGEssHH dH/H/yBHM8wMA25JWjZkjBTC2NeU8tX2yqhW9a1H+DRabxClXrbpJW+GqZ7P73kYxMNPjD vivjhIQPBvKK9jqXYK/D5TXUmAj3naQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-mnJq83umP9WKXcwPF7dSvw-1; Thu, 09 Jan 2020 11:03:18 -0500 Received: by mail-wm1-f71.google.com with SMTP id p2so1097984wma.3 for ; Thu, 09 Jan 2020 08:03:18 -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=IEmOZ+3NX8EHnBrXs7JpcZGqiWky8RDzrGpjGW3JhOk=; b=SPc4QwZaXZlwMzVzKOu8bzJGBXDJRiT5hC0zY6RLs/NoHGI44XwK/qjw5O/xtp/UIk zOntZNKrgyGrKhA8n7USdOZpjbrBJ1UKUUcy63C5CObzRVyAFmmSvQUS1nMu6m0x+v+X nCluN9pcTVrWIU+tEM1oHovQoE3MT9wHIcOMF+SNz0kUEVYqmGyYqQ07EAU5wfNOOJ/j KCtyozEXsD9M6C8ub6+cB2jGLdEgEGzW1cO+0DpRv4n0TZHG5QQttaW8fG9G6wIihM99 DmY3iiJFABYi3UpmcngfUlMHd0CpNGcujbZNV1HCD0OL11Cmq7GlD/U4qB/HilIwy7wO JsUQ== X-Gm-Message-State: APjAAAX7VJbrPcvSZ/TZZH0/sHkfXaWFD3l0uyxYV/H0jXyInINfTnYg JkMuQqzmpbnIubRiQLxBp5HBM5NfaNGOoUkjOF5p2rrIo8uFrivvvbbu8CjSvKqGtgyyMKpqjGy pKUqNjlVbqIGbCa2uOHkxjdbqg1TcoSXDh/Q= X-Received: by 2002:adf:806e:: with SMTP id 101mr12284644wrk.300.1578585795605; Thu, 09 Jan 2020 08:03:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxhJw7oN3KdrwJWeebHQd7OtKE/MeC5SWWnNta8sWE9upFVwuTQwP5gOrTZf1dc7nb4l3igCQ== X-Received: by 2002:adf:806e:: with SMTP id 101mr12284536wrk.300.1578585794619; Thu, 09 Jan 2020 08:03:14 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id z21sm3258969wml.5.2020.01.09.08.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:14 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 03/57] objtool: check: Use arch specific values in restore_reg() Date: Thu, 9 Jan 2020 16:02:06 +0000 Message-Id: <20200109160300.26150-4-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: mnJq83umP9WKXcwPF7dSvw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080512_357652_086179F7 X-CRM114-Status: GOOD ( 11.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Initial register state is set up by arch specific code. Use the value the arch code has set when restoring registers from the stack. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4784f0f6a3ae..5968e6f08891 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1437,8 +1437,8 @@ static void save_reg(struct insn_state *state, unsigned char reg, int base, static void restore_reg(struct insn_state *state, unsigned char reg) { - state->regs[reg].base = CFI_UNDEFINED; - state->regs[reg].offset = 0; + state->regs[reg].base = initial_func_cfi.regs[reg].base; + state->regs[reg].offset = initial_func_cfi.regs[reg].offset; } /* From patchwork Thu Jan 9 16:02:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1247139A for ; Thu, 9 Jan 2020 16:11:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 82CE620661 for ; Thu, 9 Jan 2020 16:11:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QOvGqpV4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CLGPBPtk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82CE620661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=XEqzvQf30r4JARQaXK28iTqGcm4yqGwq3zNfojiER4U=; b=QOvGqpV4ZMBQc8 3tyVeDH2j/65lLu8dd00WVXfMJvFEV9cIwqg4PxNMnQdZZHhDNgI3BISeObbHpSsobAn7eXgg4cOr RNrQyJo5v6BbecqGP/pacLl6LomtcdPrUA0uEEr/0kA3EZBC4fiFLHajnCkARQ2RR/A1DZ3jnKC2F T74hFMe4l4EZIk7LC3i6H3tba0Q9ML69amhm19/7gWoIsf0jttaQ8VxXs50/4RMIWgF6VACHq3cXC nR6VRz/06LFLmU04rsSQx309W98Mqwjctcl57a6zpjpwUQOG0ReBcsgstoqd7AIZEekc0EkWgUa6h X6WBXq3BvHOhHa7mQxtw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaP4-0005Pt-Ck; Thu, 09 Jan 2020 16:11:22 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJv-0007dt-2Q for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585961; 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=GmC2xKL3e4Fy+ZDst+0UU0XDQE8Eej6nqhT+4DhHses=; b=CLGPBPtk2J6QSwl9lg+p5d37F0TmcAIHaFVhqGFgRTHR7c8Eo6ZzvyXnwAkO/qn0xn8QYg 0jEtSkvvEm0KcFOPoOY/3MVjY40bOvh4AmPJFAjVt30QWTpq4DLwCZ3yPkTlWjbS/zujjE fTyRJqFvRNolJKdNm5Npyh6ZXJOHd2Q= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-if02yHJiP_yebAd8U360Og-1; Thu, 09 Jan 2020 11:03:17 -0500 Received: by mail-wm1-f72.google.com with SMTP id w205so1092799wmb.5 for ; Thu, 09 Jan 2020 08:03:17 -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=+U+nGKdjMx0B4G/fm6acyvjMMXdjwiUkB11cChVUwvw=; b=YZdTp+56By7Q4U+zpQrMPNzDvCgrfuMxQQB4Gc2uFrByywV1v7W2+lehj/7p5Uwxcc DWP0KwoX0Q0oeoBeQmjAw8LeiCRNVAP3SNOYJC7515G/Vl2P5cCLBIaJWNyfqx7xlZoJ i9CH6EfQMGbI/Nfb0lyNBEnfl8oKXewfFy5tbUki6QqWOUpBd1ffZhJ3U3J8cdgY+/D+ cZG6Sev0UaBYyrzkmjbidCPH1BQ1U2sKkFC+ZbhcYPGanl8rfqIQ8KD2psyzcGbS3nzN ktJ2zfjHWqNFRIRH4N8IiwWzr6tOze+4eUyibEmloNu0hVAWVF74pRqccDK1h0HHy3wp 4toQ== X-Gm-Message-State: APjAAAVHp1r7lK3kE41qvXJtRCLTH1iF3nXNwLbRJ2fopqSMWiyz/OH4 pEmh9mCuHG3WDbqNvafIhzejs41mjv9+tPf3oBM8zQowRcMQtHAtj1QVGMR46OI7i93D7ipBYqK sBYMPMif1omWflCf1ad6XRbI2nzpKFchodfA= X-Received: by 2002:adf:ef0b:: with SMTP id e11mr11689563wro.128.1578585796272; Thu, 09 Jan 2020 08:03:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxcaCDsW9bbAJtdhxvEAdTTp7rkMopW6pzF8N23b9naHbPtWUffbUGHw5DVwkRvjunTIXO26A== X-Received: by 2002:adf:ef0b:: with SMTP id e11mr11689532wro.128.1578585796043; Thu, 09 Jan 2020 08:03:16 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id z21sm3258969wml.5.2020.01.09.08.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:15 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 04/57] objtool: check: Ignore empty alternative groups Date: Thu, 9 Jan 2020 16:02:07 +0000 Message-Id: <20200109160300.26150-5-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: if02yHJiP_yebAd8U360Og-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080603_243981_4BA6FF12 X-CRM114-Status: UNSURE ( 9.37 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Atlernative section can contain entries for alternatives with no instructions. Objtool will currently crash when handling such an entry. Just skip that entry, but still give a warning to discourage useless entries. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 5968e6f08891..27e5380e0e0b 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -866,6 +866,13 @@ static int add_special_section_alts(struct objtool_file *file) } if (special_alt->group) { + if (!special_alt->orig_len) { + WARN("empty alternative entry at %s+0x%lx", + orig_insn->sec->name, + orig_insn->offset); + continue; + } + ret = handle_group_alt(file, special_alt, orig_insn, &new_insn); if (ret) From patchwork Thu Jan 9 16:02:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12C6F930 for ; Thu, 9 Jan 2020 16:04:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DC4312072A for ; Thu, 9 Jan 2020 16:04:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pOuUxwjp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jWTe7t1r"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ekhvse7v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC4312072A 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=ukKVY2HQx4Jsooy/1ebxgFfjh9Xo9QagM9l0AzmDUgo=; b=pOuUxwjp0+o0hA z8o2EgnAJ5eopKwgpDjVT2xgGbuIqgS66Nt7YjOWDf3Ci4wpoeKUp8l4rvf+1B/3jbGA8BHFiDK1J 3BF032+Ekgnyztygq8I22ggb5J9lox/p6I8GGL8qRopEejWHfIscPKMxKyxgVxErixXFjk5Nd7piI gZpml0vODrF+TYekvbsjgYg/Ip/b9kdPY7KAe2zgSQfAuqtEaUWJHPuQV8GIezueapEHWe94sDHkw LhgYMDqBbxICNiLcewG1h6RuIwaTsBZgD30yjMlIUC3Y/KjOZ4xpPubgfqgUZmrBEy85nFzqbWeOg vb+uKYJYxiC8GebflXSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIi-0005Mh-2Y; Thu, 09 Jan 2020 16:04:48 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaII-0004w1-9L for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Jan 2020 16:04:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AropSZgrnAEaybp2t3tDQYTQE6YkovgWTRMsWVpUkJE=; b=jWTe7t1r3IrLm11dzJZR9EQpuC 6yQkii2/mFRPSaDZ45xl7hZfkanEto19M8+ytcWFl9Zvt/0sbaefYiO1yWsEehxXqk+PIjBWKxnV2 uAVm1/mhZDVyk656slBr2U/IEa9tAM0P/wArVLWR5vX0i/PzYn3gjQlmYSMpAaAlHuCa4X0hXEZgU rhZz9jWt5UbJ4PiPeKQnf8B9lZBqnCeYH/UegqQSTdRIdT3bQGJ/RNIwIIOH4nbAIBB0UX41OXO90 UPr3s/FlG1YNxCq4duyuZv3wonmKSLfcUeLNhQg1zAnt6BaReLv0Fy4NWGbWt6SfloS6NGkFDSONs sBFEOXbg==; Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIf-0007jk-NP for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585833; 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=AropSZgrnAEaybp2t3tDQYTQE6YkovgWTRMsWVpUkJE=; b=Ekhvse7vDm5ggHO0z7bNaPRw1kbC971v4tC/fWZ6u1Qr3zMj4k9egil4umctKvunWK9Ls4 PpXH5hdKtB8oeKpu3NP1+Edp47Bc8utiQyHUNn5UKXbWAJqY+cMDHBtg300KJd2j5Y3WJs /F0fyeEZbIQqRHiVK75amrVoi7nuX7g= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-R5YR1PMuPB6i_-kDqOtq6w-1; Thu, 09 Jan 2020 11:03:49 -0500 Received: by mail-wr1-f71.google.com with SMTP id j4so158917wrs.13 for ; Thu, 09 Jan 2020 08:03:49 -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=XyxUQFf/o75wh5gN7bTB2ZufiMygHr9oF7Ozqff3HFc=; b=OeilERwyUCU2LSFUDdYva/afX9/YWx8zhzVmgo/zwOFoTP5+QD3LuY1eiX5OnDsMWG YsYQjstCO6STB3S9oU7TtkkNsYiauO6JmZYANNy2kwvUAN1hIIZpcltPeP417Uj+QYc3 x4mfJcQfWt2d37McDrKSlsvNTEwwzW/eUaS1f07zPXY0WOAKHPoL7MgzoIKEc7b3vgSG Km6N9F3ifw2ls6X/2p/uIkTtzXlxmZJE4O6J+wwhMenBl36Gq/lSy7CO5IrlSyvvs5aM iunVy0ngPHOfFdGP1zbVqvQwftjKt5snVSUbNWyR3yQpLfzF2YBSuUgiB0wbZFcjlTvZ C2bA== X-Gm-Message-State: APjAAAU9pZ57+SrqdIMJH1OF+t2n+dzkUmFJQQnkNRQf/EmCB00+JWpz I1PiroMBagYrN3xoSGyXVmVK3hUxfLQtH3u8CAHnH3Ampmzv5HBqGQja+BB/aeE43lVPCw68t1s CfhmwfY+J1+MPDUCZDo31NESzdDbJpH10d5A= X-Received: by 2002:a05:6000:cb:: with SMTP id q11mr11357633wrx.14.1578585828640; Thu, 09 Jan 2020 08:03:48 -0800 (PST) X-Google-Smtp-Source: APXvYqywh+nDZSYkZ7FzASPCFOYxPUVilYHzJUKHcQ0MT1oOqlc7tokvdArdaYIoBR2/85jfNJvqig== X-Received: by 2002:a05:6000:cb:: with SMTP id q11mr11357604wrx.14.1578585828381; Thu, 09 Jan 2020 08:03:48 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m126sm3321546wmf.7.2020.01.09.08.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:47 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 05/57] objtool: Add abstraction for computation of symbols offsets Date: Thu, 9 Jan 2020 16:02:08 +0000 Message-Id: <20200109160300.26150-6-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: R5YR1PMuPB6i_-kDqOtq6w-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_160445_856044_5E834332 X-CRM114-Status: GOOD ( 13.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 0.0 T_FILL_THIS_FORM_SHORT Fill in a short form with personal information 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault The jump destination and relocation offset used previously are only reliable on x86_64 architecture. We abstract these computations by calling arch-dependent implementations. Signed-off-by: Raphael Gault [J.T. Remove superfluous comment, replace other addend offsets with arch_dest_rela_offset] Signed-off-by: Julien Thierry --- tools/objtool/arch.h | 6 ++++++ tools/objtool/arch/x86/decode.c | 11 +++++++++++ tools/objtool/check.c | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index ced3765c4f44..a9a50a25ca66 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -66,6 +66,8 @@ struct stack_op { struct op_src src; }; +struct instruction; + void arch_initial_func_cfi_state(struct cfi_state *state); int arch_decode_instruction(struct elf *elf, struct section *sec, @@ -75,4 +77,8 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, bool arch_callee_saved_reg(unsigned char reg); +unsigned long arch_jump_destination(struct instruction *insn); + +unsigned long arch_dest_rela_offset(int addend); + #endif /* _ARCH_H */ diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index a62e032863a8..79ff33ffa6e0 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -11,6 +11,7 @@ #include "../../../arch/x86/lib/inat.c" #include "../../../arch/x86/lib/insn.c" +#include "../../check.h" #include "../../elf.h" #include "../../arch.h" #include "../../warn.h" @@ -66,6 +67,11 @@ bool arch_callee_saved_reg(unsigned char reg) } } +unsigned long arch_dest_rela_offset(int addend) +{ + return addend + 4; +} + int arch_decode_instruction(struct elf *elf, struct section *sec, unsigned long offset, unsigned int maxlen, unsigned int *len, enum insn_type *type, @@ -497,3 +503,8 @@ void arch_initial_func_cfi_state(struct cfi_state *state) state->regs[16].base = CFI_CFA; state->regs[16].offset = -8; } + +unsigned long arch_jump_destination(struct instruction *insn) +{ + return insn->offset + insn->len + insn->immediate; +} diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 27e5380e0e0b..6a5f78cca27c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -564,13 +564,14 @@ static int add_jump_destinations(struct objtool_file *file) insn->len); if (!rela) { dest_sec = insn->sec; - dest_off = insn->offset + insn->len + insn->immediate; + dest_off = arch_jump_destination(insn); } else if (rela->sym->type == STT_SECTION) { dest_sec = rela->sym->sec; - dest_off = rela->addend + 4; + dest_off = arch_dest_rela_offset(rela->addend); } else if (rela->sym->sec->idx) { dest_sec = rela->sym->sec; - dest_off = rela->sym->sym.st_value + rela->addend + 4; + dest_off = rela->sym->sym.st_value + + arch_dest_rela_offset(rela->addend); } else if (strstr(rela->sym->name, "_indirect_thunk_")) { /* * Retpoline jumps are really dynamic jumps in @@ -660,7 +661,7 @@ static int add_call_destinations(struct objtool_file *file) rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); if (!rela) { - dest_off = insn->offset + insn->len + insn->immediate; + dest_off = arch_jump_destination(insn); insn->call_dest = find_symbol_by_offset(insn->sec, dest_off); @@ -673,14 +674,15 @@ static int add_call_destinations(struct objtool_file *file) } } else if (rela->sym->type == STT_SECTION) { + dest_off = arch_dest_rela_offset(rela->addend); insn->call_dest = find_symbol_by_offset(rela->sym->sec, - rela->addend+4); + dest_off); if (!insn->call_dest || insn->call_dest->type != STT_FUNC) { - WARN_FUNC("can't find call dest symbol at %s+0x%x", + WARN_FUNC("can't find call dest symbol at %s+0x%lx", insn->sec, insn->offset, rela->sym->sec->name, - rela->addend + 4); + dest_off); return -1; } } else @@ -771,7 +773,7 @@ static int handle_group_alt(struct objtool_file *file, if (!insn->immediate) continue; - dest_off = insn->offset + insn->len + insn->immediate; + dest_off = arch_jump_destination(insn); if (dest_off == special_alt->new_off + special_alt->new_len) { if (!fake_jump) { WARN("%s: alternative jump to end of section", From patchwork Thu Jan 9 16:02:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E32B2930 for ; Thu, 9 Jan 2020 16:04:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 90593206ED for ; Thu, 9 Jan 2020 16:04:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mmH1IeF0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="j2ROrZtb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RNyfQEzA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90593206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=gZPhUCOEwdUssxIMKrJMaU0pKF+PSGCgNYR8bgoOafM=; b=mmH1IeF0bQsn5c YokFL8AEq2VmrIvPePSNC5T8gYDLkU1GIKqtHLVNAoprjZke9V3qKJ7tKlTCxoLQ3BmPPRBuaSFk5 X70vlsQix9dE65sb73lLT3tf1581x1DGJ6+WQBLrqmtuP5KGVRoiryOy+acbsmZWG6xVWeBl78b/e hZ/E4FKfw3xL9M8Kqn5rkoOtqAKzVi6FRImxOiaOrQ7UFcmX+abqcAzUyB6KguIypUVQFcHfcn6oY XDVzV6uYk/TxgTIgDVEjhE3urFyxDKYiHq8gIQMQXl3vrFXxb9iRvLg5l2DUMskXxFSeBTF+im9dz RrTeatBMV318gU7xBOzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIP-00053w-Ct; Thu, 09 Jan 2020 16:04:29 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaII-0004w0-46 for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Jan 2020 16:04:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kjViSquLhswyraCUEAkO3I/bte+UooXKuYBTgJ9Qqac=; b=j2ROrZtbH5qhsZVrL798tr8QpI kFlgsCOEXP8oLzWLVh678TbSWJfmySJ81EOtfSA0oJmhCL8JFgHOfiyAn+lBG89j49AwVhqEdJ+P0 eH+OQKl9UhZonTvnRNN0NT0TUphdRVpIb8ZeNde89SBh4jtO0fM3TYLDFOG0W8sSphBNGsVvoyIM6 xVIy2dqqQA82Sk/g8SDzub4XBpvj20yl/qhdwMuVXSHGFRwRXX+P8yiEmexLCr8vBLKA1z8X21VEZ JAwD2sZTwdtcdQlIpwjvcbqKD8HCBnyfFKI3q5e9eD+/i9khFLtUO57r2b+ajiXRDzj9xJM0XEIMA 9GsZGZrA==; Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIf-0007ji-H6 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585835; 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=kjViSquLhswyraCUEAkO3I/bte+UooXKuYBTgJ9Qqac=; b=RNyfQEzA6HQQSUMZjUB9UMQ2TQ2ZuDarn7J/WixjSY060U+l5Edd2xmmzvXqlBCp1BhC00 BW0AnxCNQeQye0ApYIOg5AEOM98lr6AdQpNU8o4QHr20iAnEkyzODDeCmgxpZzkO7R1qWx RF1WxflJCIsYlwOuRNS7rf4FAjA4X50= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-OGQ3uRGaPRqT4muXbKuOcg-1; Thu, 09 Jan 2020 11:03:51 -0500 Received: by mail-wr1-f69.google.com with SMTP id u12so3042924wrt.15 for ; Thu, 09 Jan 2020 08:03:51 -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=aRwsZXslrF8qlI5MyK0VLDbXIL7BVk96fwOyF4VyYbw=; b=qbiUb0rni2NvAZ1jWKQS658dqJcu1ULSOUeJuigi7r4mjzPnVRdD5CfZFdBOp+lwmk v5tXOTDxstgwTkueuPMLqXGRfBV9OTXoLwfDP2o/AlFxHGRILALIOdI1GLZlVEHjJFZn dVS2f2x7IETK0Y7x4wh3aJZ4D5qcPenCbO8s3YFQqagbNXSI7sK/8aw4UdT+/SjyhpkW k/00rG8q1TXZfOPsNhV9BV2H7Id0XY/8t8lGcnux2bDhDBXrPwzOMefI1/CHR3b9nxS8 vOIVWN6o6/50NaOstjtXFuIrjRlCh+JIBKtzAVBWcy+4Zaxn/104koQVjKzXpTPBk/pD BPMQ== X-Gm-Message-State: APjAAAW9XiM5WRF4umI10y2fEYuhTsna51Qq/TweWvZkzo6wyO0AieRg 3N6RG+MAVgFTqD/Ln4jIDqdTfZwtz9vuAQJ0Fa4yqz4YAYSiwOxCgU9lgSnlHgf2YlGHuT/SyM2 Gg0i7KZAOdM5ZO9RBV6ChmOchV2WaR10EVpo= X-Received: by 2002:a5d:6a0f:: with SMTP id m15mr11697761wru.40.1578585830109; Thu, 09 Jan 2020 08:03:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwdTwKmwk+TMSvNrwowSzjOiXNj+qkJd4Gz4AqQII7UyixaAnIcNddNNeu3UQ7anmhP/LotHQ== X-Received: by 2002:a5d:6a0f:: with SMTP id m15mr11697736wru.40.1578585829847; Thu, 09 Jan 2020 08:03:49 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m126sm3321546wmf.7.2020.01.09.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:49 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 06/57] objtool: Give ORC functions consistent name Date: Thu, 9 Jan 2020 16:02:09 +0000 Message-Id: <20200109160300.26150-7-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: OGQ3uRGaPRqT4muXbKuOcg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_160445_673895_28C27EC5 X-CRM114-Status: GOOD ( 11.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Rename ORC manipulating functions to have more consistent name. Have "orc_" as a prefix for all of them. No functionality change. Suggested-by: Josh Poimboeuf Signed-off-by: Julien Thierry --- tools/objtool/check.c | 4 ++-- tools/objtool/orc.h | 4 ++-- tools/objtool/orc_gen.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6a5f78cca27c..dd155095251c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2481,11 +2481,11 @@ int check(const char *_objname, bool orc) } if (orc) { - ret = create_orc(&file); + ret = orc_init(&file); if (ret < 0) goto out; - ret = create_orc_sections(&file); + ret = orc_create_sections(&file); if (ret < 0) goto out; diff --git a/tools/objtool/orc.h b/tools/objtool/orc.h index ee2832221e62..cd44417487e4 100644 --- a/tools/objtool/orc.h +++ b/tools/objtool/orc.h @@ -10,8 +10,8 @@ struct objtool_file; -int create_orc(struct objtool_file *file); -int create_orc_sections(struct objtool_file *file); +int orc_init(struct objtool_file *file); +int orc_create_sections(struct objtool_file *file); int orc_dump(const char *objname); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 27a4112848c2..29bee7bd212a 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -10,7 +10,7 @@ #include "check.h" #include "warn.h" -int create_orc(struct objtool_file *file) +int orc_init(struct objtool_file *file) { struct instruction *insn; @@ -81,9 +81,9 @@ int create_orc(struct objtool_file *file) return 0; } -static int create_orc_entry(struct section *u_sec, struct section *ip_relasec, - unsigned int idx, struct section *insn_sec, - unsigned long insn_off, struct orc_entry *o) +static int orc_create_entry(struct section *u_sec, struct section *ip_relasec, + unsigned int idx, struct section *insn_sec, + unsigned long insn_off, struct orc_entry *o) { struct orc_entry *orc; struct rela *rela; @@ -116,7 +116,7 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec, return 0; } -int create_orc_sections(struct objtool_file *file) +int orc_create_sections(struct objtool_file *file) { struct instruction *insn, *prev_insn; struct section *sec, *u_sec, *ip_relasec; @@ -182,7 +182,7 @@ int create_orc_sections(struct objtool_file *file) if (!prev_insn || memcmp(&insn->orc, &prev_insn->orc, sizeof(struct orc_entry))) { - if (create_orc_entry(u_sec, ip_relasec, idx, + if (orc_create_entry(u_sec, ip_relasec, idx, insn->sec, insn->offset, &insn->orc)) return -1; @@ -194,7 +194,7 @@ int create_orc_sections(struct objtool_file *file) /* section terminator */ if (prev_insn) { - if (create_orc_entry(u_sec, ip_relasec, idx, + if (orc_create_entry(u_sec, ip_relasec, idx, prev_insn->sec, prev_insn->offset + prev_insn->len, &empty)) From patchwork Thu Jan 9 16:02:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CFA7930 for ; Thu, 9 Jan 2020 16:04:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 27C58206ED for ; Thu, 9 Jan 2020 16:04:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="osSddVkX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N4NzKcJF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27C58206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=2DPYRDaMgIdK4FPLN2+k9Uravftvo4RVhmYfdQ5SKMo=; b=osSddVkXxIywbP 68oUE2UUZJ7380ZLvghzRnY+BgygEvY9DYmTpghufHKieh+h0q9ZhJurf4XSKP2DOwfwpGQz1WqZn unkiweA6OKz9+D100hXkVPRIEtYKRDe1DdBAT8arf+U3svtu5uTCse8TFRqG8CO3PQd0pj60QVbG8 2DM02UsM40irDT6DG9yvlPrSMYxgKbz9ocFBlOuG1S9fEkRXaDxbOgT0GdP1QL6E8VcGuiTwIR/et I1RR1UUb9oDOYouZ4/5dzwYHeQYqqdBm9FwTBzjjoZdwZMMJ14TX7dWBG067hSUXhIjl3Vu12TAuW LXLY+QGrPMLQO4B8iqVA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaII-0004wM-R2; Thu, 09 Jan 2020 16:04:22 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaID-0004rl-PI for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585834; 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=oRbC/g6ssOZ1j6q/GsrbqDwzai6KH95AMo3rMRqU9sY=; b=N4NzKcJF27QWsuR4HtPYI97muUIyQ5YWQSn9w7aEsnf0UIR6JF41H+dr8DHQLeQSPqvA5H giE+tpIyu5XQnt3twnznq/T++defioD9cb7eqkNZdnz7s4/ThMGmfxcCbZMEt6ufZJffSC 6t/cGIXKcXVlhlIByK8pvzzEm3i3WAM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-eMcsJ1JUM8CwNfwLTj_npA-1; Thu, 09 Jan 2020 11:03:53 -0500 Received: by mail-wm1-f72.google.com with SMTP id p5so616354wmc.4 for ; Thu, 09 Jan 2020 08:03:53 -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=PUQsxLHZdxOzSqZcrip37lVsIDHbyPZSVWhfrajhS7w=; b=bNkemZ3LE4stZLnnUb2fGFNytJHuTDxpp2dZy0zvMK2ZhuOJhRsJHp0JJm+0knZICR aKNoIqxJlDNnIBJAEiRYkGduzR06jPA1uTWyd2xvHMInLVuiTbxNEwouKLXqggtbknYR 0L7W8S48ZHIWVBaADywdpIB+NVvhlGgXxI5FCt8oQRnaacver5zrbIrJUH/pJmPsKrmH KuxjduFkgr+iUreJJJimpx1c+ybxLh5aUfUa7rX1fqq6Y7g3o4HnQuvz/91YCYVC1Wn5 NmcjPpkWKjP7gF2vJ0wANTAT0yYN4mSusKOgLXhR/Ogdmlrmb5OZVoGRxbluX15foLDQ T0/Q== X-Gm-Message-State: APjAAAWFTQQHdeimQ0tIRWSWfCyyLv7MSd+r2Xy7o8pZeCafIjhQ3q5M I3hub3qecRVDdJoE7Q3lhnB2YJmE/mHb58I3POPefCBh/2BBtFas/zdnX15aL68UjqQ/gS3Rda6 P4As+dH4xaqg9klnTwr5pFH29tIz2SdqRA1k= X-Received: by 2002:a1c:730d:: with SMTP id d13mr5646585wmb.126.1578585832062; Thu, 09 Jan 2020 08:03:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy3yDnYzwz4QZqxuPmNwe/gs/CcDoWlTDjZeGXTzwLU8hTdjO+MTW0olGHnh14bqNw8fn6M5w== X-Received: by 2002:a1c:730d:: with SMTP id d13mr5646471wmb.126.1578585831111; Thu, 09 Jan 2020 08:03:51 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m126sm3321546wmf.7.2020.01.09.08.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:50 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 07/57] objtool: orc: Refactor ORC API for other architectures to implement. Date: Thu, 9 Jan 2020 16:02:10 +0000 Message-Id: <20200109160300.26150-8-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: eMcsJ1JUM8CwNfwLTj_npA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080417_892763_9CC1F371 X-CRM114-Status: GOOD ( 12.64 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault The ORC unwinder is only supported on x86 at the moment and should thus be in the x86 architecture code. In order not to break the whole structure in case another architecture decides to support the ORC unwinder via objtool, move the implementation be done in the architecture dependent code. Signed-off-by: Raphael Gault [J.T. Rebase on orc name changes, Move arch_orc_read_unwind_hints() to orc.h, Reword commit message to use imperative language] Signed-off-by: Julien Thierry --- tools/objtool/Build | 2 - tools/objtool/arch/x86/Build | 2 + tools/objtool/{ => arch/x86}/orc_dump.c | 4 +- tools/objtool/{ => arch/x86}/orc_gen.c | 104 ++++++++++++++++++++++-- tools/objtool/check.c | 99 +--------------------- tools/objtool/orc.h | 5 +- 6 files changed, 109 insertions(+), 107 deletions(-) rename tools/objtool/{ => arch/x86}/orc_dump.c (98%) rename tools/objtool/{ => arch/x86}/orc_gen.c (66%) diff --git a/tools/objtool/Build b/tools/objtool/Build index 8dc4f0848362..d069d26d97fa 100644 --- a/tools/objtool/Build +++ b/tools/objtool/Build @@ -2,8 +2,6 @@ objtool-y += arch/$(SRCARCH)/ objtool-y += builtin-check.o objtool-y += builtin-orc.o objtool-y += check.o -objtool-y += orc_gen.o -objtool-y += orc_dump.o objtool-y += elf.o objtool-y += special.o objtool-y += objtool.o diff --git a/tools/objtool/arch/x86/Build b/tools/objtool/arch/x86/Build index 7c5004008e97..e43fd6fa0ee1 100644 --- a/tools/objtool/arch/x86/Build +++ b/tools/objtool/arch/x86/Build @@ -1,4 +1,6 @@ objtool-y += decode.o +objtool-y += orc_dump.o +objtool-y += orc_gen.o inat_tables_script = ../arch/x86/tools/gen-insn-attr-x86.awk inat_tables_maps = ../arch/x86/lib/x86-opcode-map.txt diff --git a/tools/objtool/orc_dump.c b/tools/objtool/arch/x86/orc_dump.c similarity index 98% rename from tools/objtool/orc_dump.c rename to tools/objtool/arch/x86/orc_dump.c index 13ccf775a83a..cfe8f96bdd68 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/arch/x86/orc_dump.c @@ -4,8 +4,8 @@ */ #include -#include "orc.h" -#include "warn.h" +#include "../../orc.h" +#include "../../warn.h" static const char *reg_name(unsigned int reg) { diff --git a/tools/objtool/orc_gen.c b/tools/objtool/arch/x86/orc_gen.c similarity index 66% rename from tools/objtool/orc_gen.c rename to tools/objtool/arch/x86/orc_gen.c index 29bee7bd212a..e8be41a1bf94 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/arch/x86/orc_gen.c @@ -6,11 +6,11 @@ #include #include -#include "orc.h" -#include "check.h" -#include "warn.h" +#include "../../orc.h" +#include "../../check.h" +#include "../../warn.h" -int orc_init(struct objtool_file *file) +int arch_orc_init(struct objtool_file *file) { struct instruction *insn; @@ -116,7 +116,7 @@ static int orc_create_entry(struct section *u_sec, struct section *ip_relasec, return 0; } -int orc_create_sections(struct objtool_file *file) +int arch_orc_create_sections(struct objtool_file *file) { struct instruction *insn, *prev_insn; struct section *sec, *u_sec, *ip_relasec; @@ -209,3 +209,97 @@ int orc_create_sections(struct objtool_file *file) return 0; } + +int arch_orc_read_unwind_hints(struct objtool_file *file) +{ + struct section *sec, *relasec; + struct rela *rela; + struct unwind_hint *hint; + struct instruction *insn; + struct cfi_reg *cfa; + int i; + + sec = find_section_by_name(file->elf, ".discard.unwind_hints"); + if (!sec) + return 0; + + relasec = sec->rela; + if (!relasec) { + WARN("missing .rela.discard.unwind_hints section"); + return -1; + } + + if (sec->len % sizeof(struct unwind_hint)) { + WARN("struct unwind_hint size mismatch"); + return -1; + } + + file->hints = true; + + for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { + hint = (struct unwind_hint *)sec->data->d_buf + i; + + rela = find_rela_by_dest(sec, i * sizeof(*hint)); + if (!rela) { + WARN("can't find rela for unwind_hints[%d]", i); + return -1; + } + + insn = find_insn(file, rela->sym->sec, rela->addend); + if (!insn) { + WARN("can't find insn for unwind_hints[%d]", i); + return -1; + } + + cfa = &insn->state.cfa; + + if (hint->type == UNWIND_HINT_TYPE_SAVE) { + insn->save = true; + continue; + + } else if (hint->type == UNWIND_HINT_TYPE_RESTORE) { + insn->restore = true; + insn->hint = true; + continue; + } + + insn->hint = true; + + switch (hint->sp_reg) { + case ORC_REG_UNDEFINED: + cfa->base = CFI_UNDEFINED; + break; + case ORC_REG_SP: + cfa->base = CFI_SP; + break; + case ORC_REG_BP: + cfa->base = CFI_BP; + break; + case ORC_REG_SP_INDIRECT: + cfa->base = CFI_SP_INDIRECT; + break; + case ORC_REG_R10: + cfa->base = CFI_R10; + break; + case ORC_REG_R13: + cfa->base = CFI_R13; + break; + case ORC_REG_DI: + cfa->base = CFI_DI; + break; + case ORC_REG_DX: + cfa->base = CFI_DX; + break; + default: + WARN_FUNC("unsupported unwind_hint sp base reg %d", + insn->sec, insn->offset, hint->sp_reg); + return -1; + } + + cfa->offset = hint->sp_offset; + insn->state.type = hint->type; + insn->state.end = hint->end; + } + + return 0; +} diff --git a/tools/objtool/check.c b/tools/objtool/check.c index dd155095251c..2c5ccf61510a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1167,99 +1167,6 @@ static int add_jump_table_alts(struct objtool_file *file) return 0; } -static int read_unwind_hints(struct objtool_file *file) -{ - struct section *sec, *relasec; - struct rela *rela; - struct unwind_hint *hint; - struct instruction *insn; - struct cfi_reg *cfa; - int i; - - sec = find_section_by_name(file->elf, ".discard.unwind_hints"); - if (!sec) - return 0; - - relasec = sec->rela; - if (!relasec) { - WARN("missing .rela.discard.unwind_hints section"); - return -1; - } - - if (sec->len % sizeof(struct unwind_hint)) { - WARN("struct unwind_hint size mismatch"); - return -1; - } - - file->hints = true; - - for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { - hint = (struct unwind_hint *)sec->data->d_buf + i; - - rela = find_rela_by_dest(sec, i * sizeof(*hint)); - if (!rela) { - WARN("can't find rela for unwind_hints[%d]", i); - return -1; - } - - insn = find_insn(file, rela->sym->sec, rela->addend); - if (!insn) { - WARN("can't find insn for unwind_hints[%d]", i); - return -1; - } - - cfa = &insn->state.cfa; - - if (hint->type == UNWIND_HINT_TYPE_SAVE) { - insn->save = true; - continue; - - } else if (hint->type == UNWIND_HINT_TYPE_RESTORE) { - insn->restore = true; - insn->hint = true; - continue; - } - - insn->hint = true; - - switch (hint->sp_reg) { - case ORC_REG_UNDEFINED: - cfa->base = CFI_UNDEFINED; - break; - case ORC_REG_SP: - cfa->base = CFI_SP; - break; - case ORC_REG_BP: - cfa->base = CFI_BP; - break; - case ORC_REG_SP_INDIRECT: - cfa->base = CFI_SP_INDIRECT; - break; - case ORC_REG_R10: - cfa->base = CFI_R10; - break; - case ORC_REG_R13: - cfa->base = CFI_R13; - break; - case ORC_REG_DI: - cfa->base = CFI_DI; - break; - case ORC_REG_DX: - cfa->base = CFI_DX; - break; - default: - WARN_FUNC("unsupported unwind_hint sp base reg %d", - insn->sec, insn->offset, hint->sp_reg); - return -1; - } - - cfa->offset = hint->sp_offset; - insn->state.type = hint->type; - insn->state.end = hint->end; - } - - return 0; -} static int read_retpoline_hints(struct objtool_file *file) { @@ -1359,7 +1266,7 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; - ret = read_unwind_hints(file); + ret = arch_orc_read_unwind_hints(file); if (ret) return ret; @@ -2481,11 +2388,11 @@ int check(const char *_objname, bool orc) } if (orc) { - ret = orc_init(&file); + ret = arch_orc_init(&file); if (ret < 0) goto out; - ret = orc_create_sections(&file); + ret = arch_orc_create_sections(&file); if (ret < 0) goto out; diff --git a/tools/objtool/orc.h b/tools/objtool/orc.h index cd44417487e4..ffda072cf4ad 100644 --- a/tools/objtool/orc.h +++ b/tools/objtool/orc.h @@ -10,8 +10,9 @@ struct objtool_file; -int orc_init(struct objtool_file *file); -int orc_create_sections(struct objtool_file *file); +int arch_orc_init(struct objtool_file *file); +int arch_orc_create_sections(struct objtool_file *file); +int arch_orc_read_unwind_hints(struct objtool_file *file); int orc_dump(const char *objname); From patchwork Thu Jan 9 16:02:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EF95930 for ; Thu, 9 Jan 2020 16:05:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4E06620721 for ; Thu, 9 Jan 2020 16:05:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CCd3+qzC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Pt8HAPnA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Athg2/mf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E06620721 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Tv+xpmvarkmzIKCxcqjj6IJ3HGy92bgZ7KNUkSgY6kg=; b=CCd3+qzCSaAqek uOVzwaah42KLWZLdG5XLDCkqQkQamuN9QkgMj8HDU7TmQv+pWpGUtv/IvtA/h+g2zS9PS//myW3TR yli5N5RwHNSi8rSf6PVc2n4ah0jl/CKDVzVMM4qt97HeowzUXPOHtMzve2lDcoUtsb2t0mDo3RGgU ULyUIajieXgsNKZGqskxlkG/ovLnEUnE77B/QnWkoKrzKvwyz7GK3qEO99kbKeOAr1Pl1l8H+qOsE IDzbR4gyxaUsSs9Vzc87BtcKciuHzQI+LM5er5c3aj7Il1sVnqOG/y9goLns4XqhEqIETNqRbCc5u 8Bwq43PY6CKxZeDdOmiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJR-0007BW-Qw; Thu, 09 Jan 2020 16:05:33 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIN-00051S-P3 for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Jan 2020 16:04:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=h7WOWw3CmbI4FYhjgRf2tNAW2ZSsJGxLjWzDUCTQoZ0=; b=Pt8HAPnAMYctA1AuihAsu9G0AO xUXq9whZ3IfrXBu7Oh4Z2us+ipf6tL4S4YQovybFVJD9+CnJ+myyxoxz6tmJiOl3nyJBNaS4Kbw3g 53hZhLQLQv/JNty2SDUKKBanNL2fChekHrMKAuZ1Kmj/sx1vsSJV6coSCKG60LnTlhbeGOk023MPZ s935VLv1JYgSkPhF4TEAtvp9wQB9/YlzNsbmV7AVKLG8/cyPFSgHxRp/5plv+XeUSN2B0OueKaNQ5 IAjI4uLu+zV4gkqpr4BM/Be91A2lbTmEVDLeTDvgnBMqyOecijFmN0Tei0tX8qBTJzbt7Cxaj1QPv +T5t4V1A==; Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIl-0007ku-D7 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585838; 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=h7WOWw3CmbI4FYhjgRf2tNAW2ZSsJGxLjWzDUCTQoZ0=; b=Athg2/mf0NuxDCp217uDtUtlifae1WQeu3Sqdy4wmgAvcg3g3KCywTFDO2LLfbSifmUjvX peLBOBT2aRfhjyG8+KY9sHO0zNzFIm8L62423YZp5NiKpvv+Y1WFusxz4TLekG18VzR7qJ qZHzJ5vu8fO66GbiGgCa3FAY3Hrj8Nk= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-Bk6daoRpN1K9gEjcx6DA8Q-1; Thu, 09 Jan 2020 11:03:54 -0500 Received: by mail-wr1-f72.google.com with SMTP id u12so3042999wrt.15 for ; Thu, 09 Jan 2020 08:03:53 -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=+ZWC3NYwPtgLE6SG36C3VaKcOwxxIR92Oe8t166+ozo=; b=WMqM/zYqvCsHcPxD6+WwavdyPdNdtF0dw1tsVcpzRTaDuI8kjVmSzTCjzQVfH9dpEx tQOV/WV8tgeQj9iTtL7s8EUy2qN/v9DRDuoTsSZXpZpTaJzwPPPywYp0zJXBXA+4G4+e 1hWeR7n0O1GTHmeGdaGzJPr2ukJI3Wf3s3ShhSn0/KLB/ocU9SiNWylDVGbgatL06c4r BV9ZXw5UaWjbHiOyck53Fsy4Ea/5sKj6QbC4lqSViVDS1AqVZISdhciVJGYyMVpe8Jvu V/XiUEaf4nBEAEEL7VHioNTY5X+bvOhdHrkiQrKgxRucBBLHp1zNpNpbKgnZb6rMotym yBzQ== X-Gm-Message-State: APjAAAWLDbRbhSgcownqJr04UHZ0cD5HnlpIN72ugBnvON7xWSsKSAH5 5YU9WwkjkwwM28usE3HG4tYNItToLArcd8JyMaaRjkTljhDIH0VQuRYVMgQcDjhDLs+Z2bxo2Ot O8No0jlLfompBP388wLG8fMl4+ee4yYMVRNE= X-Received: by 2002:a1c:4d18:: with SMTP id o24mr5714903wmh.35.1578585832545; Thu, 09 Jan 2020 08:03:52 -0800 (PST) X-Google-Smtp-Source: APXvYqz3K422AcRc43kA+7KXUEORNfUwnc+dzxIyEmAHwHDVmV1yK+mA2HEhXQ9YIN/yRwLx6UmfRA== X-Received: by 2002:a1c:4d18:: with SMTP id o24mr5714878wmh.35.1578585832351; Thu, 09 Jan 2020 08:03:52 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m126sm3321546wmf.7.2020.01.09.08.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:51 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 08/57] objtool: Make ORC support optional Date: Thu, 9 Jan 2020 16:02:11 +0000 Message-Id: <20200109160300.26150-9-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: Bk6daoRpN1K9gEjcx6DA8Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_160451_527823_9F7230E7 X-CRM114-Status: GOOD ( 13.62 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently, only x86 supports ORC. To simplify the addition of other supported architectures to objtool 'check' command, make the 'orc' objtool command optional to implement for a given architecture. Signed-off-by: Julien Thierry --- tools/objtool/Build | 2 +- tools/objtool/Makefile | 10 +++++++++- tools/objtool/check.c | 4 ++++ tools/objtool/objtool.c | 2 ++ tools/objtool/orc.h | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/tools/objtool/Build b/tools/objtool/Build index d069d26d97fa..6e7163f9522a 100644 --- a/tools/objtool/Build +++ b/tools/objtool/Build @@ -1,6 +1,6 @@ objtool-y += arch/$(SRCARCH)/ objtool-y += builtin-check.o -objtool-y += builtin-orc.o +objtool-$(OBJTOOL_ORC) += builtin-orc.o objtool-y += check.o objtool-y += elf.o objtool-y += special.o diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index d2a19b0bc05a..24d653e0b6ec 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -6,6 +6,10 @@ ifeq ($(ARCH),x86_64) ARCH := x86 endif +ifeq ($(ARCH),x86) +OBJTOOL_ORC := y +endif + # always use the host compiler HOSTAR ?= ar HOSTCC ?= gcc @@ -42,8 +46,12 @@ LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) +ifeq ($(OBJTOOL_ORC),y) +CFLAGS += -DOBJTOOL_ORC +endif + AWK = awk -export srctree OUTPUT CFLAGS SRCARCH AWK +export srctree OUTPUT CFLAGS SRCARCH AWK OBJTOOL_ORC include $(srctree)/tools/build/Makefile.include $(OBJTOOL_IN): fixdep FORCE diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 2c5ccf61510a..8f2ff030936d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1317,6 +1317,7 @@ static bool has_valid_stack_frame(struct insn_state *state) return false; } +#ifdef OBJTOOL_ORC static int update_insn_state_regs(struct instruction *insn, struct insn_state *state) { struct cfi_reg *cfa = &state->cfa; @@ -1340,6 +1341,7 @@ static int update_insn_state_regs(struct instruction *insn, struct insn_state *s return 0; } +#endif static void save_reg(struct insn_state *state, unsigned char reg, int base, int offset) @@ -1425,8 +1427,10 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) return 0; } +#ifdef OBJTOOL_ORC if (state->type == ORC_TYPE_REGS || state->type == ORC_TYPE_REGS_IRET) return update_insn_state_regs(insn, state); +#endif switch (op->dest.type) { diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c index 0b3528f05053..8db7139b72cd 100644 --- a/tools/objtool/objtool.c +++ b/tools/objtool/objtool.c @@ -34,7 +34,9 @@ static const char objtool_usage_string[] = static struct cmd_struct objtool_cmds[] = { {"check", cmd_check, "Perform stack metadata validation on an object file" }, +#ifdef OBJTOOL_ORC {"orc", cmd_orc, "Generate in-place ORC unwind tables for an object file" }, +#endif }; bool help; diff --git a/tools/objtool/orc.h b/tools/objtool/orc.h index ffda072cf4ad..f5303b8264e3 100644 --- a/tools/objtool/orc.h +++ b/tools/objtool/orc.h @@ -6,14 +6,43 @@ #ifndef _ORC_H #define _ORC_H -#include - struct objtool_file; +#ifdef OBJTOOL_ORC + +#include + int arch_orc_init(struct objtool_file *file); int arch_orc_create_sections(struct objtool_file *file); int arch_orc_read_unwind_hints(struct objtool_file *file); int orc_dump(const char *objname); +#else + +struct orc_entry { +}; + +static inline int arch_orc_init(struct objtool_file *file) +{ + return 0; +} + +static inline int arch_orc_create_sections(struct objtool_file *file) +{ + return 0; +} + +static inline int arch_orc_read_unwind_hints(struct objtool_file *file) +{ + return 0; +} + +static inline int orc_dump(const char *objname) +{ + return 0; +} + +#endif /* OBJTOOL_ORC */ + #endif /* _ORC_H */ From patchwork Thu Jan 9 16:02:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D37BD930 for ; Thu, 9 Jan 2020 16:05:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6F6D920721 for ; Thu, 9 Jan 2020 16:05:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HYwr1VeE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Q88wb/td"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N+kdxI3l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F6D920721 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=059XBshiyFRPDEZxOBR0D36HXUZI4CFs0qgM9JVhDrs=; b=HYwr1VeEF0LTTe OC1YPfE1Eymy0UvV3zFeMUJ4RPj3k0oMXlnPNhsTF0LTwc7nWovNhkaE/aeemwrJPyV7utA2jhXUm VtSKQ0JRwy4u0JWHDrH+k2y1ACrrspGmRqApJF1yXrM1f444CmL2tcIxiZ4iqRO59Gd+SdehS+xFc U2+WH6Ge+9jsQJy2pQEwlKCO1Dw328q0VRbnK/j3eAVj6LZ6gDPrrt47+CxFr13maOMmBhILapwyo cjhUr57S70di4LcuVtSSc97ERUFUFg5A0WgEodTLMwL/bdJADNwlWKJFyvAFAKVLJFKufl68jnV90 xWQSTtRtsZyR+dCt5CDw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJC-0006vk-Pd; Thu, 09 Jan 2020 16:05:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIK-0004xG-6T for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Jan 2020 16:04:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iD5ekURTlh+pgwRxx2gUCDMyCmbRJV+KeqCXMr7mSSA=; b=Q88wb/tdghmRb3o6onb/tCcdyw letOvP18Kv0U6o7S/TxnWIJ3s/Jn/009yxJUXTA4zhKL3m82WF2ZuxWHbNAwG9i87iskmEZZ68aDU s9dBd1HitVTyjF8C6eiwc+e5A8w6uDd0Hzx96CwPrdYmWZV9uCbRoQoEO/XjqkIjJm5IG+dXZxKr5 j0+OeC3/2yZmU8q3773EmThA/DqsIMNc3qMz9rsrR5KiGE+7uGqYAlJWu4IDPcKE3M4Jia3jPhaup xnYoK2a2fn/byoFUbkNrcbqxDzasczGgXxZ1kTxZBVoFe1ORUZFP48dpWFLVlUlI4Fj8JMaH6lfyi 8Fap4WPg==; Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIg-0007jj-0i for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585836; 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=iD5ekURTlh+pgwRxx2gUCDMyCmbRJV+KeqCXMr7mSSA=; b=N+kdxI3lFheoMVufTRdjeBiWSvyP95c1y5SQn58CyTwlyNAsKRyVbVz++l0t8QReNgegIs 6zpzaBaAFeH69BY+2jMGunc8rL7nXqpDntV8RiMDJpvTEs/aiQhMiM9G4wzElsOrbv3fFJ oDmm9y064Fhmr/+4FGGs5L/P/A6M2tY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-y8BQ9QgKNkOGWfkfx6KPNA-1; Thu, 09 Jan 2020 11:03:55 -0500 Received: by mail-wr1-f71.google.com with SMTP id o6so3035909wrp.8 for ; Thu, 09 Jan 2020 08:03:55 -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=Qr2r3mp7rftEmxfhLDidcKbFbCYdpKuq3T+a5+/CCqE=; b=i8e+go1WE/dwKNt+8xSx1uNtejo4DkNRAp8o2c0GDhPZLoSm1EyOTjtCaUKJa7mSlI H7hbBAvvRA2Dmq0boG1ad7KxDjA9VA/BgGHaDdkTpYabaDytMVfYrlCZ5d7awmuv64uQ 9lxeBODiB8XgL2VD+JeAGCYDFW/GSzw93Bz/aX8qQoqbPpEKL8XLq7k6R+i/3CtFGWGK wkwr8y31LH5rtKGISpmM4RuZZlKvKGP0edvHwmfKzjS/pHTX4PETJVI6trCSvFLQvVoF VfhwudoS0KGI0ZWtgpzDb/+3mDuFpAETMjHGOEhNRrcL+qZ0F4VWxm8PkyhpsuOUJuoF 7iFQ== X-Gm-Message-State: APjAAAVs5rIRPmftmVKsnEVS/kt6PcRPrXGC0QpA8mFegqWDusyJi2// KQ1xbCIONlp8I5pcF4w9un26ybxugLvpXqvs/ez8va323izj9TXLpk/aYGhfwkDm7XZwVgxje1w RGF3JZ7tWpdF5kzt3GHduR6AuZ+cyy+TEFv0= X-Received: by 2002:a7b:cb0a:: with SMTP id u10mr5598165wmj.165.1578585834089; Thu, 09 Jan 2020 08:03:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxxPpfZ8umi6fB7ZYKrURHzWQS31pfkUOU6pTbSf04Fo9JFmyXHY0aoMxvY+j4DAs5z8sDE5A== X-Received: by 2002:a7b:cb0a:: with SMTP id u10mr5598133wmj.165.1578585833874; Thu, 09 Jan 2020 08:03:53 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m126sm3321546wmf.7.2020.01.09.08.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:03:53 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 09/57] objtool: Move registers and control flow to arch-dependent code Date: Thu, 9 Jan 2020 16:02:12 +0000 Message-Id: <20200109160300.26150-10-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: y8BQ9QgKNkOGWfkfx6KPNA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_160446_173104_9596004B X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on casper.infradead.org summary: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault The control flow information and register macro definitions were based on the x86_64 architecture but should be abstract so that each architecture can define the correct values for the registers, especially the registers related to the stack frame (Frame Pointer, Stack Pointer and possibly Return Address). Signed-off-by: Raphael Gault [J.T. : Added objtool arch specific include to build flags, Use SPDX identifier for new header] Signed-off-by: Julien Thierry --- tools/objtool/Makefile | 3 ++- tools/objtool/arch/x86/include/arch_special.h | 23 +++++++++++++++++++ tools/objtool/{ => arch/x86/include}/cfi.h | 0 tools/objtool/check.h | 1 + tools/objtool/special.c | 19 +-------------- 5 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 tools/objtool/arch/x86/include/arch_special.h rename tools/objtool/{ => arch/x86/include}/cfi.h (100%) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 24d653e0b6ec..be735e4f27f5 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -37,7 +37,8 @@ all: $(OBJTOOL) INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ - -I$(srctree)/tools/arch/$(ARCH)/include + -I$(srctree)/tools/arch/$(ARCH)/include \ + -I$(srctree)/tools/objtool/arch/$(ARCH)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) diff --git a/tools/objtool/arch/x86/include/arch_special.h b/tools/objtool/arch/x86/include/arch_special.h new file mode 100644 index 000000000000..426178d504a8 --- /dev/null +++ b/tools/objtool/arch/x86/include/arch_special.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _X86_ARCH_SPECIAL_H +#define _X86_ARCH_SPECIAL_H + +#define EX_ENTRY_SIZE 12 +#define EX_ORIG_OFFSET 0 +#define EX_NEW_OFFSET 4 + +#define JUMP_ENTRY_SIZE 16 +#define JUMP_ORIG_OFFSET 0 +#define JUMP_NEW_OFFSET 4 + +#define ALT_ENTRY_SIZE 13 +#define ALT_ORIG_OFFSET 0 +#define ALT_NEW_OFFSET 4 +#define ALT_FEATURE_OFFSET 8 +#define ALT_ORIG_LEN_OFFSET 10 +#define ALT_NEW_LEN_OFFSET 11 + +#define X86_FEATURE_POPCNT (4 * 32 + 23) +#define X86_FEATURE_SMAP (9 * 32 + 20) + +#endif /* _X86_ARCH_SPECIAL_H */ diff --git a/tools/objtool/cfi.h b/tools/objtool/arch/x86/include/cfi.h similarity index 100% rename from tools/objtool/cfi.h rename to tools/objtool/arch/x86/include/cfi.h diff --git a/tools/objtool/check.h b/tools/objtool/check.h index 6d875ca6fce0..af87b55db454 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -11,6 +11,7 @@ #include "cfi.h" #include "arch.h" #include "orc.h" +#include "arch_special.h" #include struct insn_state { diff --git a/tools/objtool/special.c b/tools/objtool/special.c index fdbaa611146d..b8ccee1b5382 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -14,24 +14,7 @@ #include "builtin.h" #include "special.h" #include "warn.h" - -#define EX_ENTRY_SIZE 12 -#define EX_ORIG_OFFSET 0 -#define EX_NEW_OFFSET 4 - -#define JUMP_ENTRY_SIZE 16 -#define JUMP_ORIG_OFFSET 0 -#define JUMP_NEW_OFFSET 4 - -#define ALT_ENTRY_SIZE 13 -#define ALT_ORIG_OFFSET 0 -#define ALT_NEW_OFFSET 4 -#define ALT_FEATURE_OFFSET 8 -#define ALT_ORIG_LEN_OFFSET 10 -#define ALT_NEW_LEN_OFFSET 11 - -#define X86_FEATURE_POPCNT (4*32+23) -#define X86_FEATURE_SMAP (9*32+20) +#include "arch_special.h" struct special_entry { const char *sec; From patchwork Thu Jan 9 16:02:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37F46139A for ; Thu, 9 Jan 2020 16:06:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C4DBF20661 for ; Thu, 9 Jan 2020 16:06:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AITCu1aX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eiKgAzHw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4DBF20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=c3YPFJeBw9FyRktMafsBRPmwFtgJmUX/l4e0+NPfg3o=; b=AITCu1aXu+wQkN 3YPvYgHU9/eYB97H4rvyeDgpkHWwV9ge1KhMnyswk1X0mW8+foSCaUJodaPmt9zvhCnPGNMh2Wzlt gpiM/HR5Ud6NHk38peejj8DDMYctrs8YfYDIowusuJDvK9b6IIV3Ry1CtSlpOFA8/6x8m4w1n0Mq+ qqhC5M5F2PZyWYfIuu+BamJOqNHaNa3Mm2cb3O2IVWZNwVL1Y0+nyKJVkkeCHsb9+die5WpvpOWub GY7HobB5/xJfC7XKMdvo9v45oMZp/Jgw5lYsXVFS7x5B8pCHYT6OTh27BOCQ0hL45R94gB4uypJhx An74pOho7Q5Hjb4hXgZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKQ-00085r-Tu; Thu, 09 Jan 2020 16:06:34 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIP-00053o-Nn for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585868; 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=3LYqgzhBPGm06NyErpqYh7YUMX1S4FFE51j/nLN5Etk=; b=eiKgAzHwopkdLjoneXMJYye4PjBvbmV2rwpr6hE3Ux/GpQ6q771JqdgkitC0y76iB+OkIQ 1UNQKXQpVyzoSLS7s1RZRTm+GdZqrlRny6ZdLquc1raFx5Suaj6DkYXzjdxx0t31plix5f zg0rbhzzzoB7uVjbV9cgxQx8mYt+jiw= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-uxxWnmz2ObKoRlQnCKS6XA-1; Thu, 09 Jan 2020 11:04:27 -0500 Received: by mail-wr1-f69.google.com with SMTP id u18so3041765wrn.11 for ; Thu, 09 Jan 2020 08:04:27 -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=bWQrA7VCFyRmkR4P5YmsvhynTE3rA5d5XHSqEPaJkPo=; b=Gj8eGxLRW2SMxbsJL0xBzLNea352HDqXOAoyds+K6Zd/pOKTLkHwsN0/ARF36/NKPd XwBj4LAKG/UDpPg/6UF0MbiDLKL1AO6MUQyOtQGLuEX8zAQkC6thVNc7pOfuwoLOVnmB +LB2ippLxD457jIvcfGGTNBdnfIF7KonFq/fH5AqrlaYm/VeFPW85Qa+9Sn+0mb0uX2e QY6xhnq5tG78BY4l/UUhlkZt4vyePAElmDH/C0B8EgXkKjQYpkiPwuykscJ6iHZKNnd/ sIKZNzO2MUX3W7aNcsGGqcP9Lh+rqhAY9gq3O4GEJ8kdMGm/ACTEP571MTggbPilb/DF L0aA== X-Gm-Message-State: APjAAAVRtzrOSYIzWThdEBK0h8cmyq5RYdI81UEAqVuOYgMQln5x7SH2 y4UhtJL7bFUd5ePH7hyo1Fp5rNUPXVhVUjZ62eMcMJcJxaiuyfNNWzvA2N4j86ehQLuq4/svd7g fOSkhLu12dOwCt1W6t/2n+ahMR2QiiCkeTc0= X-Received: by 2002:adf:8b4f:: with SMTP id v15mr11990368wra.231.1578585866198; Thu, 09 Jan 2020 08:04:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyRBNHddmXJHExrgBfiG3rOVNGpjzR688ErWpsppuCbMLL/G6HOJYCSxBlJEZgOnpRtPnxIbA== X-Received: by 2002:adf:8b4f:: with SMTP id v15mr11990334wra.231.1578585865969; Thu, 09 Jan 2020 08:04:25 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id b17sm8615898wrp.49.2020.01.09.08.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:04:25 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 10/57] objtool: Split generic and arch specific CFI definitions Date: Thu, 9 Jan 2020 16:02:13 +0000 Message-Id: <20200109160300.26150-11-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: uxxWnmz2ObKoRlQnCKS6XA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080429_852917_E81B9D61 X-CRM114-Status: GOOD ( 11.01 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some CFI definitions used by generic objtool code have no reason to vary from one architecture to another. Move those definition to generic code and keep a separate per arch header to provide architecture specific CFI definitions. Signed-off-by: Julien Thierry --- tools/objtool/arch/x86/include/cfi_regs.h | 25 ++++++++++++++++++++++ tools/objtool/{arch/x86/include => }/cfi.h | 21 ++---------------- 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 tools/objtool/arch/x86/include/cfi_regs.h rename tools/objtool/{arch/x86/include => }/cfi.h (54%) diff --git a/tools/objtool/arch/x86/include/cfi_regs.h b/tools/objtool/arch/x86/include/cfi_regs.h new file mode 100644 index 000000000000..79bc517efba8 --- /dev/null +++ b/tools/objtool/arch/x86/include/cfi_regs.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _OBJTOOL_CFI_REGS_H +#define _OBJTOOL_CFI_REGS_H + +#define CFI_AX 0 +#define CFI_DX 1 +#define CFI_CX 2 +#define CFI_BX 3 +#define CFI_SI 4 +#define CFI_DI 5 +#define CFI_BP 6 +#define CFI_SP 7 +#define CFI_R8 8 +#define CFI_R9 9 +#define CFI_R10 10 +#define CFI_R11 11 +#define CFI_R12 12 +#define CFI_R13 13 +#define CFI_R14 14 +#define CFI_R15 15 +#define CFI_RA 16 +#define CFI_NUM_REGS 17 + +#endif /* _OBJTOOL_CFI_REGS_H */ diff --git a/tools/objtool/arch/x86/include/cfi.h b/tools/objtool/cfi.h similarity index 54% rename from tools/objtool/arch/x86/include/cfi.h rename to tools/objtool/cfi.h index 4427bf8ed686..1a3e7b807994 100644 --- a/tools/objtool/arch/x86/include/cfi.h +++ b/tools/objtool/cfi.h @@ -6,30 +6,13 @@ #ifndef _OBJTOOL_CFI_H #define _OBJTOOL_CFI_H +#include "cfi_regs.h" + #define CFI_UNDEFINED -1 #define CFI_CFA -2 #define CFI_SP_INDIRECT -3 #define CFI_BP_INDIRECT -4 -#define CFI_AX 0 -#define CFI_DX 1 -#define CFI_CX 2 -#define CFI_BX 3 -#define CFI_SI 4 -#define CFI_DI 5 -#define CFI_BP 6 -#define CFI_SP 7 -#define CFI_R8 8 -#define CFI_R9 9 -#define CFI_R10 10 -#define CFI_R11 11 -#define CFI_R12 12 -#define CFI_R13 13 -#define CFI_R14 14 -#define CFI_R15 15 -#define CFI_RA 16 -#define CFI_NUM_REGS 17 - struct cfi_reg { int base; int offset; From patchwork Thu Jan 9 16:02:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C030E139A for ; Thu, 9 Jan 2020 16:06:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9E1D7206ED for ; Thu, 9 Jan 2020 16:06:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CkTabWD7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fUVxxrcC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E1D7206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=3P9MAzqiCyxNvu+8B7kgQIBObrs4lVnaqLSY9jJsQ5c=; b=CkTabWD7FUxfuG 68w/DFgNaOD3+dk7fpMnAlMS0fSAc0IXLiHYHsMyUuJS3vcXTFjJzdLRklXBAYl4z1lr+phojMjbq FtJAfK5FWQnZgT6e6pGvw4t9v5woaM4v7RJe+H2YMpaIdtVJljIljNcMuYZW5+QTUvke5hX5tAPkq Xx1LBDhOeQBf2SoIHn3ifmIiXksIlefzQhu3UHJoXN86A7wc8LoFiL+V0PNtHyy7n7pgyxl03PdeG cS1dUgNGjnQIe34qEMxnjvUc0Xaqs9nzYcN54fTDaMeY3Avh5oql2Qm09JsCKrzIm6r8ov+JTkPAp 4YdZNtaQBTo50ohNrlzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJq-0007Yu-Gu; Thu, 09 Jan 2020 16:05:58 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIS-00057R-Q0 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585871; 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=85A3jXho/OiEn29VGhQa36f2B6U6e4WqdxbgEUrqO6w=; b=fUVxxrcCgcz2xz/NsGBHtBdcgX2atWiRxpoZbjnVKg/KCjRrv8P4LLwnUZiYS2QyttvKSg EBTf75PSGMDKKgqRKcrHBuXIk+ruHXoZ9D3l9SjfoAoh0bD9lhpjdbkr666nFOo0p3FCtx fPA1Fh9JwQDVH1lo9Rngzeqkd1KP6O0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-i2OAVtuCO5uLd393UWjt1Q-1; Thu, 09 Jan 2020 11:04:29 -0500 Received: by mail-wr1-f69.google.com with SMTP id f15so3075165wrr.2 for ; Thu, 09 Jan 2020 08:04:28 -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=LKRV6Dbt/iehaVr8Oe5+bZly0BQdm7b+eiiMLnIM3KI=; b=oS6LoY19l9iraUJnlQ+cFaV9iCdvqRzOlbMlAjW/hyiegoMlww9xtXaun+homdos/x TPriJuuc26sZnHqA3GtYSjvhukulPyLzrUwEbRvQ9rZxYTtPx+HBh8ZCYt6UmWXI3yO+ FRkGzYaitQ5e/al30py5n3i4ifzgRX2VHNIXWwVnGkdhH6T371Hctzb6o+j/j6MhpZPj Eeeuqz1xqUG/pk4LHT+QTfcsIq6aveO79U9POlLE43npPuGeLJ1FqBYaiWlQJcFz/oBr fA3a/N9gbzOhUWidFKDD0qJA6MSEGUHxf7rNKEuJPofgkNc4ev1+CaPycaij5pw9OeqM iGhw== X-Gm-Message-State: APjAAAUYF5QD13oi6FalchGEgpZstDS4sLd68FE+LvpGrQEUMT9Ybs3x LiQg1xL31bSgX7wJvsjYLris6hWH5bIfVnXCmXYH4rQ69Hsilzo5uajDnaEmo0f8DkiIn1GYzbz 1Py5VWxOzWuFqyloozlUnHvty0H0sXO9B8Ws= X-Received: by 2002:a05:6000:149:: with SMTP id r9mr11718060wrx.147.1578585867816; Thu, 09 Jan 2020 08:04:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwE3TyBDC9AqG/yX8Wr+TMrqckkMWTYZH3Gv26HTZhn0fYryvFxFkZBJQubZ1op9IAokDJnzw== X-Received: by 2002:a05:6000:149:: with SMTP id r9mr11718025wrx.147.1578585867532; Thu, 09 Jan 2020 08:04:27 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id b17sm8615898wrp.49.2020.01.09.08.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:04:27 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 11/57] objtool: Abstract alternative special case handling Date: Thu, 9 Jan 2020 16:02:14 +0000 Message-Id: <20200109160300.26150-12-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: i2OAVtuCO5uLd393UWjt1Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080432_949897_273FD079 X-CRM114-Status: GOOD ( 16.35 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some alternatives associated with a specific feature need to be treated in a special way. Since the features and how to treat them vary from one architecture to another, move the special case handling to arch specific code. Signed-off-by: Julien Thierry --- tools/objtool/arch/x86/Build | 1 + tools/objtool/arch/x86/arch_special.c | 34 +++++++++++++++++++ tools/objtool/arch/x86/include/arch_special.h | 5 +++ tools/objtool/special.c | 25 +------------- tools/objtool/special.h | 8 +++++ 5 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 tools/objtool/arch/x86/arch_special.c diff --git a/tools/objtool/arch/x86/Build b/tools/objtool/arch/x86/Build index e43fd6fa0ee1..971f9fa90a3c 100644 --- a/tools/objtool/arch/x86/Build +++ b/tools/objtool/arch/x86/Build @@ -1,3 +1,4 @@ +objtool-y += arch_special.o objtool-y += decode.o objtool-y += orc_dump.o objtool-y += orc_gen.o diff --git a/tools/objtool/arch/x86/arch_special.c b/tools/objtool/arch/x86/arch_special.c new file mode 100644 index 000000000000..6dba31f419d0 --- /dev/null +++ b/tools/objtool/arch/x86/arch_special.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include "../../special.h" +#include "../../builtin.h" + +void arch_handle_alternative(unsigned short feature, struct special_alt *alt) +{ + /* + * If UACCESS validation is enabled; force that alternative; + * otherwise force it the other way. + * + * What we want to avoid is having both the original and the + * alternative code flow at the same time, in that case we can + * find paths that see the STAC but take the NOP instead of + * CLAC and the other way around. + */ + switch (feature) { + case X86_FEATURE_SMAP: + if (uaccess) + alt->skip_orig = true; + else + alt->skip_alt = true; + break; + case X86_FEATURE_POPCNT: + /* + * It has been requested that we don't validate the !POPCNT + * feature path which is a "very very small percentage of + * machines". + */ + alt->skip_orig = true; + break; + default: + break; + } +} diff --git a/tools/objtool/arch/x86/include/arch_special.h b/tools/objtool/arch/x86/include/arch_special.h index 426178d504a8..3ab2dc32424b 100644 --- a/tools/objtool/arch/x86/include/arch_special.h +++ b/tools/objtool/arch/x86/include/arch_special.h @@ -20,4 +20,9 @@ #define X86_FEATURE_POPCNT (4 * 32 + 23) #define X86_FEATURE_SMAP (9 * 32 + 20) +struct special_alt; + +#define arch_handle_alternative arch_handle_alternative +void arch_handle_alternative(unsigned short feature, struct special_alt *alt); + #endif /* _X86_ARCH_SPECIAL_H */ diff --git a/tools/objtool/special.c b/tools/objtool/special.c index b8ccee1b5382..67461b25e649 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -75,30 +75,7 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, feature = *(unsigned short *)(sec->data->d_buf + offset + entry->feature); - - /* - * It has been requested that we don't validate the !POPCNT - * feature path which is a "very very small percentage of - * machines". - */ - if (feature == X86_FEATURE_POPCNT) - alt->skip_orig = true; - - /* - * If UACCESS validation is enabled; force that alternative; - * otherwise force it the other way. - * - * What we want to avoid is having both the original and the - * alternative code flow at the same time, in that case we can - * find paths that see the STAC but take the NOP instead of - * CLAC and the other way around. - */ - if (feature == X86_FEATURE_SMAP) { - if (uaccess) - alt->skip_orig = true; - else - alt->skip_alt = true; - } + arch_handle_alternative(feature, alt); } orig_rela = find_rela_by_dest(sec, offset + entry->orig); diff --git a/tools/objtool/special.h b/tools/objtool/special.h index 35061530e46e..738a05bc6d3a 100644 --- a/tools/objtool/special.h +++ b/tools/objtool/special.h @@ -8,6 +8,7 @@ #include #include "elf.h" +#include "arch_special.h" struct special_alt { struct list_head list; @@ -28,4 +29,11 @@ struct special_alt { int special_get_alts(struct elf *elf, struct list_head *alts); +#ifndef arch_handle_alternative +static inline void arch_handle_alternative(unsigned short feature, + struct special_alt *alt) +{ +} +#endif + #endif /* _SPECIAL_H */ From patchwork Thu Jan 9 16:02:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0395A930 for ; Thu, 9 Jan 2020 16:06:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D05B3206ED for ; Thu, 9 Jan 2020 16:06:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MbOt5IiS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IcXVAPng" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D05B3206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=9f3m5C0vcOkkKHNafu8ERsungF4YtgvpRi6kYQBHoTA=; b=MbOt5IiSfcbBLb xDOXSlTJVJUVDMD8UP7wnsdSqJaySUcHM2llhJ8x3/N4u1ByLUyvDPmZDmKbiHv5W2ReoDmrS3qoF xExJwMDkN43F6Rr/FjvsNV9kbyqJnorWY0pAyiUVYYhzAMt+/GZBkKve62Vxe+E6fstMHoWxHzRH4 zti3VPMosg5M1XxFBL5XqOBABwtPMTqNJIBmb+4+257fBqEEvpvfc3ySocfJe+vlZ1hIKEuQfHD7Z I7mTHuPwmDTJ45wnHwMl2oCTkO12zs21rH21YD9TQ+KmNRBx3AmtUEQUsrkQN1rMx2at635aK3HI3 qBEy8p/2pC9VI2kogXbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaK9-0007oZ-Ph; Thu, 09 Jan 2020 16:06:17 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIT-00058B-4B for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585871; 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=FXQxfKCa95iVhzNUh/d4s107aoEQ/uGIdoZfuhqnFqc=; b=IcXVAPng4dB+tFbFODawYi3UH+k4AP0HQ2x5QT94/7ZzUk0GfjK1ahZscXu7sIbc9l9cxp ZM8JxkCCfYHKBhFxeLIi/dmso3Qd8vYnw8NRPoM8c65HyIZlUNEpdxWNscFkHjqy7vmurK 7jlSPHmHK+0gjR34aIzLjz8tBnh+FwA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-ZpcPUJn-NpObNV3EmD4eFg-1; Thu, 09 Jan 2020 11:04:30 -0500 Received: by mail-wr1-f71.google.com with SMTP id j13so3033875wrr.20 for ; Thu, 09 Jan 2020 08:04:29 -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=xt5DbHzH/EVOyMc37NjjTNOfxPGZdHy+R4yzKk2QEI0=; b=pgky8o7P/lyk/Q/+1SdnB9VpLJ0ArlMWwKuuyWdoeI8AcebU7mAJE0mWHHxz2ZeQc1 /Wllltnr1dUmivqxFezfNaWzkdJid05MgkgPd64JTUVez1hrij/wAdagVc/x7b42MJ9W nGSyxur7N2u4hciNxrFvBIQOA2Eao/pUhOQpcrvLkuOH5hVSqwirEBNxV+dcLLcTWKU/ o4uu9OS8ZewlrIBWF0iGDDwaLbwAdVoQZl2RV0lcZrfVCjO5PkgL7lVwtbRm1pcWQSQ0 nVDnVMD0O6Q8/iM8uFylxPbeqWaNvox7tOCglBCMvsMRZ7SZGybpR/QLdSMH1DEKYvrG DEHA== X-Gm-Message-State: APjAAAV5xk0T/euS3zlYHnf9mzagLnm3lUliwxWU4AOqH2+L+AMq34UC oe+1T3ya4xP7fyIgh3d8MXX5tcDupC2PTIPxCsJUHxRP5u1Lnr5xq32JRx1TkkzXQq9Yo65BvfF vgj15bpC563hCpLZiVVlcj8nRzDqqkBDJ9Xw= X-Received: by 2002:a05:600c:294:: with SMTP id 20mr5609171wmk.97.1578585868940; Thu, 09 Jan 2020 08:04:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzq/Alj0h2G/J2VQULJA01MqEGedUbxb2oF0V48iKffuNbHJbUHRhKAG5KbZl3knGLHvbjRuw== X-Received: by 2002:a05:600c:294:: with SMTP id 20mr5609151wmk.97.1578585868751; Thu, 09 Jan 2020 08:04:28 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id b17sm8615898wrp.49.2020.01.09.08.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:04:28 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 12/57] objtool: check: Allow jumps from an alternative group to itself Date: Thu, 9 Jan 2020 16:02:15 +0000 Message-Id: <20200109160300.26150-13-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: ZpcPUJn-NpObNV3EmD4eFg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080433_270180_B938613D X-CRM114-Status: GOOD ( 13.19 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Alternatives can contain instructions that jump to another instruction in the same alternative group. This is actually a common pattern on arm64. Keep track of instructions jumping within their own alternative group and carry on validating such branches. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 48 ++++++++++++++++++++++++++++++++++--------- tools/objtool/check.h | 1 + 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8f2ff030936d..c7b3f1e2a628 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -722,6 +722,14 @@ static int handle_group_alt(struct objtool_file *file, sec_for_each_insn_from(file, insn) { if (insn->offset >= special_alt->orig_off + special_alt->orig_len) break; + /* Is insn a jump to an instruction within the alt_group */ + if (insn->jump_dest && insn->sec == insn->jump_dest->sec && + (insn->type == INSN_JUMP_CONDITIONAL || + insn->type == INSN_JUMP_UNCONDITIONAL)) { + dest_off = insn->jump_dest->offset; + insn->intra_group_jump = special_alt->orig_off <= dest_off && + dest_off < special_alt->orig_off + special_alt->orig_len; + } insn->alt_group = true; last_orig_insn = insn; @@ -1853,14 +1861,33 @@ static int validate_sibling_call(struct instruction *insn, struct insn_state *st return validate_call(insn, state); } +static int validate_branch_alt_safe(struct objtool_file *file, + struct symbol *func, + struct instruction *first, + struct insn_state state); + +static int validate_branch(struct objtool_file *file, struct symbol *func, + struct instruction *first, struct insn_state state) +{ + if (first->alt_group && list_empty(&first->alts)) { + WARN_FUNC("don't know how to handle branch to middle of alternative instruction group", + first->sec, first->offset); + return 1; + } + + return validate_branch_alt_safe(file, func, first, state); +} + /* * Follow the branch starting at the given instruction, and recursively follow * any other branches (jumps). Meanwhile, track the frame pointer state at * each instruction and validate all the rules described in * tools/objtool/Documentation/stack-validation.txt. */ -static int validate_branch(struct objtool_file *file, struct symbol *func, - struct instruction *first, struct insn_state state) +static int validate_branch_alt_safe(struct objtool_file *file, + struct symbol *func, + struct instruction *first, + struct insn_state state) { struct alternative *alt; struct instruction *insn, *next_insn; @@ -1871,12 +1898,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, insn = first; sec = insn->sec; - if (insn->alt_group && list_empty(&insn->alts)) { - WARN_FUNC("don't know how to handle branch to middle of alternative instruction group", - sec, insn->offset); - return 1; - } - while (1) { next_insn = next_insn_same_sec(file, insn); @@ -2023,8 +2044,15 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, return ret; } else if (insn->jump_dest) { - ret = validate_branch(file, func, - insn->jump_dest, state); + if (insn->intra_group_jump) + ret = validate_branch_alt_safe(file, + func, + insn->jump_dest, + state); + else + ret = validate_branch(file, func, + insn->jump_dest, + state); if (ret) { if (backtrace) BT_FUNC("(branch)", insn); diff --git a/tools/objtool/check.h b/tools/objtool/check.h index af87b55db454..d13ee02f28a4 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -46,6 +46,7 @@ struct instruction { struct stack_op stack_op; struct insn_state state; struct orc_entry orc; + bool intra_group_jump; }; struct objtool_file { From patchwork Thu Jan 9 16:02:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94DF3930 for ; Thu, 9 Jan 2020 16:06:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6D51920661 for ; Thu, 9 Jan 2020 16:06:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QxRio1Y8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bfBkcwcj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D51920661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=yIRN7cutCnJWRNas581k5P/5J827qYpXdtzyp63pfks=; b=QxRio1Y8X74Qfu 9U6n2tIbXeiUJfBU67LkAZAmAlW7HuaXYTZlKy7dFO2DViM8poZbBe5MZ5XUncKzZykkucsCe87Lx eYhQHOmYMrTHvzIPWM2eQg8K5wu9q1Sx4pGmI3tvaQBCC1kiv8HXyyVqFR+UpSicpzzMVWGc7kqKu OwOZFxPAYyJIuSgB9GxIdN4lUI5Wc3G0v0+JNmzi2cRxc+j73SmBj0GeoKCja2WJKgb5zbr7dmBZV yDYSy9X4ixbZWE3vmrz8ktNEFnpYdbUaqBHIfqyACcQnTSQNpFoJ/hTvpmJA4RJs177lak720KiV0 gX/ZMnsAM2q0bGgfgduw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKg-0008LD-0K; Thu, 09 Jan 2020 16:06:50 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIW-0005AV-Iv for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585874; 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=cc/ZFBwn+owAUC3q/3LPd+YhZAW6KEWcDpWP6mVsy7U=; b=bfBkcwcjwLs65AOVuCd8fphcZRDV6M8z01q9F5LBYJbVY40zoXT1CY2W39HwaNXnNkCk/f Ne6bSdT3CUw6TOWV/Yxol6Gu6C/dT3p6ulIOPIQox7BaWF86EPuMTesS3KlgHTOPmPLTSr pS5e/j2L8jCsDUpkaONlbBESfNG32ak= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-TTJ-PL7HPMiezzgRy2J3TA-1; Thu, 09 Jan 2020 11:04:32 -0500 Received: by mail-wm1-f72.google.com with SMTP id 18so1103950wmp.0 for ; Thu, 09 Jan 2020 08:04:32 -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=bcJsi6poG6rW7I+2z+ATXTC2LDR+mpWWn+1cZrFZsLM=; b=nC3xMt2BNoQ6iJEXCkQTIqLn1kwR7QJQSGbNSmM/EsKIZ9ihV5CaDQ9kWoRRdW5exB HKM5MMdubUCQSLG+EwBIyWWK6E+Lmpi/DB9exIzdw21w1urBUEgsj5DtS0NXdsO2Rkmv Nnx8ijsCASrBD85fl4PwigweaCAlmEh+Qwz0GfI4RAAmSEbEiFLc1/pjXfq3OahpdZ+I PCo8OGpKGJ0ezyAeSZnRuKRFU186QBAhGEOJ0wgYWSWnipXs8dzXN3AB/Jq57jJiuOfW kzWohb5vfhOWUJJ0eUtEkxKObl3qjkZbG4m6KPfgxf903dAKjOBrrdJCAbokkMqYPYEN PUSw== X-Gm-Message-State: APjAAAW4igLoVuhZXXAhTgzlsItuW789jD5TW3s91Sih+H1iL3bAz5U0 4E8qEicyp61eMdltK37PEdb6UFSLHwZ5nssU7JoyDl8H9o44O8RCfsYmZJOvAdG+rFbFl+CDLjL pUSdLmXU/4ym14do4zdvkjPZyJXu7A4Ih5bA= X-Received: by 2002:adf:cf06:: with SMTP id o6mr11621112wrj.349.1578585871350; Thu, 09 Jan 2020 08:04:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyo7qWerLrxda8DnRcqwsDd2dtjVq+e+ucigRp3KhQquOz5uAl0/8Qk6EgqebE1radeABodUQ== X-Received: by 2002:adf:cf06:: with SMTP id o6mr11621067wrj.349.1578585870839; Thu, 09 Jan 2020 08:04:30 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id b17sm8615898wrp.49.2020.01.09.08.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:04:29 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 13/57] objtool: Refactor switch-tables code to support other architectures Date: Thu, 9 Jan 2020 16:02:16 +0000 Message-Id: <20200109160300.26150-14-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: TTJ-PL7HPMiezzgRy2J3TA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080436_838727_3E4ED2B5 X-CRM114-Status: GOOD ( 24.83 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault The way to identify switch-tables and retrieves all the data necessary to handle the different execution branches is not the same on all architecture. In order to be able to add other architecture support, this patch defines arch-dependent functions to process jump-tables. Signed-off-by: Raphael Gault [J.T.: Move arm64 bits out of this patch, rename arch_add_jump_table to arch_add_jump_table_dests, remove redundant/unused arguments] Signed-off-by: Julien Thierry --- tools/objtool/arch/x86/arch_special.c | 148 ++++++++++++++++++++++++++ tools/objtool/check.c | 148 +------------------------- tools/objtool/check.h | 7 ++ tools/objtool/special.h | 5 + 4 files changed, 164 insertions(+), 144 deletions(-) diff --git a/tools/objtool/arch/x86/arch_special.c b/tools/objtool/arch/x86/arch_special.c index 6dba31f419d0..9e382155298b 100644 --- a/tools/objtool/arch/x86/arch_special.c +++ b/tools/objtool/arch/x86/arch_special.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#include + #include "../../special.h" #include "../../builtin.h" +#include "../../warn.h" void arch_handle_alternative(unsigned short feature, struct special_alt *alt) { @@ -32,3 +35,148 @@ void arch_handle_alternative(unsigned short feature, struct special_alt *alt) break; } } + +int arch_add_jump_table_dests(struct objtool_file *file, + struct instruction *insn) +{ + struct rela *table = insn->jump_table; + struct rela *rela = table; + struct instruction *dest_insn; + struct alternative *alt; + struct symbol *pfunc = insn->func->pfunc; + unsigned int prev_offset = 0; + + /* + * Each @rela is a switch table relocation which points to the target + * instruction. + */ + list_for_each_entry_from(rela, &table->sec->rela_list, list) { + + /* Check for the end of the table: */ + if (rela != table && rela->jump_table_start) + break; + + /* Make sure the table entries are consecutive: */ + if (prev_offset && rela->offset != prev_offset + 8) + break; + + /* Detect function pointers from contiguous objects: */ + if (rela->sym->sec == pfunc->sec && + rela->addend == pfunc->offset) + break; + + dest_insn = find_insn(file, rela->sym->sec, rela->addend); + if (!dest_insn) + break; + + /* Make sure the destination is in the same function: */ + if (!dest_insn->func || dest_insn->func->pfunc != pfunc) + break; + + alt = malloc(sizeof(*alt)); + if (!alt) { + WARN("malloc failed"); + return -1; + } + + alt->insn = dest_insn; + list_add_tail(&alt->list, &insn->alts); + prev_offset = rela->offset; + } + + if (!prev_offset) { + WARN_FUNC("can't find switch jump table", + insn->sec, insn->offset); + return -1; + } + + return 0; +} + +/* + * There are 3 basic jump table patterns: + * + * 1. jmpq *[rodata addr](,%reg,8) + * + * This is the most common case by far. It jumps to an address in a simple + * jump table which is stored in .rodata. + * + * 2. jmpq *[rodata addr](%rip) + * + * This is caused by a rare GCC quirk, currently only seen in three driver + * functions in the kernel, only with certain obscure non-distro configs. + * + * As part of an optimization, GCC makes a copy of an existing switch jump + * table, modifies it, and then hard-codes the jump (albeit with an indirect + * jump) to use a single entry in the table. The rest of the jump table and + * some of its jump targets remain as dead code. + * + * In such a case we can just crudely ignore all unreachable instruction + * warnings for the entire object file. Ideally we would just ignore them + * for the function, but that would require redesigning the code quite a + * bit. And honestly that's just not worth doing: unreachable instruction + * warnings are of questionable value anyway, and this is such a rare issue. + * + * 3. mov [rodata addr],%reg1 + * ... some instructions ... + * jmpq *(%reg1,%reg2,8) + * + * This is a fairly uncommon pattern which is new for GCC 6. As of this + * writing, there are 11 occurrences of it in the allmodconfig kernel. + * + * As of GCC 7 there are quite a few more of these and the 'in between' code + * is significant. Esp. with KASAN enabled some of the code between the mov + * and jmpq uses .rodata itself, which can confuse things. + * + * TODO: Once we have DWARF CFI and smarter instruction decoding logic, + * ensure the same register is used in the mov and jump instructions. + * + * NOTE: RETPOLINE made it harder still to decode dynamic jumps. + */ +struct rela *arch_find_switch_table(struct objtool_file *file, + struct instruction *insn) +{ + struct rela *text_rela, *rodata_rela; + struct section *table_sec; + unsigned long table_offset; + + /* look for a relocation which references .rodata */ + text_rela = find_rela_by_dest_range(insn->sec, insn->offset, + insn->len); + if (!text_rela || text_rela->sym->type != STT_SECTION || + !text_rela->sym->sec->rodata) + return NULL; + table_offset = text_rela->addend; + table_sec = text_rela->sym->sec; + + if (text_rela->type == R_X86_64_PC32) + table_offset += 4; + + /* + * Make sure the .rodata address isn't associated with a + * symbol. GCC jump tables are anonymous data. + * + * Also support C jump tables which are in the same format as + * switch jump tables. For objtool to recognize them, they + * need to be placed in the C_JUMP_TABLE_SECTION section. They + * have symbols associated with them. + */ + if (find_symbol_containing(table_sec, table_offset) && + strcmp(table_sec->name, C_JUMP_TABLE_SECTION)) + return NULL; + + rodata_rela = find_rela_by_dest(table_sec, table_offset); + if (rodata_rela) { + /* + * Use of RIP-relative switch jumps is quite rare, and + * indicates a rare GCC quirk/bug which can leave dead + * code behind. + */ + if (text_rela->type == R_X86_64_PC32) + file->ignore_unreachables = true; + + return rodata_rela; + } + + return NULL; +} diff --git a/tools/objtool/check.c b/tools/objtool/check.c index c7b3f1e2a628..19e96c4ad0a3 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -18,14 +18,6 @@ #define FAKE_JUMP_OFFSET -1 -#define C_JUMP_TABLE_SECTION ".rodata..c_jump_table" - -struct alternative { - struct list_head list; - struct instruction *insn; - bool skip_orig; -}; - const char *objname; struct cfi_state initial_func_cfi; @@ -914,113 +906,16 @@ static int add_special_section_alts(struct objtool_file *file) return ret; } -static int add_jump_table(struct objtool_file *file, struct instruction *insn, - struct rela *table) -{ - struct rela *rela = table; - struct instruction *dest_insn; - struct alternative *alt; - struct symbol *pfunc = insn->func->pfunc; - unsigned int prev_offset = 0; - - /* - * Each @rela is a switch table relocation which points to the target - * instruction. - */ - list_for_each_entry_from(rela, &table->sec->rela_list, list) { - - /* Check for the end of the table: */ - if (rela != table && rela->jump_table_start) - break; - - /* Make sure the table entries are consecutive: */ - if (prev_offset && rela->offset != prev_offset + 8) - break; - - /* Detect function pointers from contiguous objects: */ - if (rela->sym->sec == pfunc->sec && - rela->addend == pfunc->offset) - break; - - dest_insn = find_insn(file, rela->sym->sec, rela->addend); - if (!dest_insn) - break; - - /* Make sure the destination is in the same function: */ - if (!dest_insn->func || dest_insn->func->pfunc != pfunc) - break; - - alt = malloc(sizeof(*alt)); - if (!alt) { - WARN("malloc failed"); - return -1; - } - - alt->insn = dest_insn; - list_add_tail(&alt->list, &insn->alts); - prev_offset = rela->offset; - } - - if (!prev_offset) { - WARN_FUNC("can't find switch jump table", - insn->sec, insn->offset); - return -1; - } - - return 0; -} - /* * find_jump_table() - Given a dynamic jump, find the switch jump table in - * .rodata associated with it. - * - * There are 3 basic patterns: - * - * 1. jmpq *[rodata addr](,%reg,8) - * - * This is the most common case by far. It jumps to an address in a simple - * jump table which is stored in .rodata. - * - * 2. jmpq *[rodata addr](%rip) - * - * This is caused by a rare GCC quirk, currently only seen in three driver - * functions in the kernel, only with certain obscure non-distro configs. - * - * As part of an optimization, GCC makes a copy of an existing switch jump - * table, modifies it, and then hard-codes the jump (albeit with an indirect - * jump) to use a single entry in the table. The rest of the jump table and - * some of its jump targets remain as dead code. - * - * In such a case we can just crudely ignore all unreachable instruction - * warnings for the entire object file. Ideally we would just ignore them - * for the function, but that would require redesigning the code quite a - * bit. And honestly that's just not worth doing: unreachable instruction - * warnings are of questionable value anyway, and this is such a rare issue. - * - * 3. mov [rodata addr],%reg1 - * ... some instructions ... - * jmpq *(%reg1,%reg2,8) - * - * This is a fairly uncommon pattern which is new for GCC 6. As of this - * writing, there are 11 occurrences of it in the allmodconfig kernel. - * - * As of GCC 7 there are quite a few more of these and the 'in between' code - * is significant. Esp. with KASAN enabled some of the code between the mov - * and jmpq uses .rodata itself, which can confuse things. - * - * TODO: Once we have DWARF CFI and smarter instruction decoding logic, - * ensure the same register is used in the mov and jump instructions. - * - * NOTE: RETPOLINE made it harder still to decode dynamic jumps. + * associated with it. */ static struct rela *find_jump_table(struct objtool_file *file, struct symbol *func, struct instruction *insn) { - struct rela *text_rela, *table_rela; + struct rela *table_rela; struct instruction *orig_insn = insn; - struct section *table_sec; - unsigned long table_offset; /* * Backward search using the @first_jump_src links, these help avoid @@ -1044,45 +939,10 @@ static struct rela *find_jump_table(struct objtool_file *file, insn->jump_dest->offset > orig_insn->offset)) break; - /* look for a relocation which references .rodata */ - text_rela = find_rela_by_dest_range(insn->sec, insn->offset, - insn->len); - if (!text_rela || text_rela->sym->type != STT_SECTION || - !text_rela->sym->sec->rodata) - continue; - - table_offset = text_rela->addend; - table_sec = text_rela->sym->sec; - - if (text_rela->type == R_X86_64_PC32) - table_offset += 4; - - /* - * Make sure the .rodata address isn't associated with a - * symbol. GCC jump tables are anonymous data. - * - * Also support C jump tables which are in the same format as - * switch jump tables. For objtool to recognize them, they - * need to be placed in the C_JUMP_TABLE_SECTION section. They - * have symbols associated with them. - */ - if (find_symbol_containing(table_sec, table_offset) && - strcmp(table_sec->name, C_JUMP_TABLE_SECTION)) - continue; - - /* Each table entry has a rela associated with it. */ - table_rela = find_rela_by_dest(table_sec, table_offset); + table_rela = arch_find_switch_table(file, insn); if (!table_rela) continue; - /* - * Use of RIP-relative switch jumps is quite rare, and - * indicates a rare GCC quirk/bug which can leave dead code - * behind. - */ - if (text_rela->type == R_X86_64_PC32) - file->ignore_unreachables = true; - return table_rela; } @@ -1138,7 +998,7 @@ static int add_func_jump_tables(struct objtool_file *file, if (!insn->jump_table) continue; - ret = add_jump_table(file, insn, insn->jump_table); + ret = arch_add_jump_table_dests(file, insn); if (ret) return ret; } diff --git a/tools/objtool/check.h b/tools/objtool/check.h index d13ee02f28a4..843094cbae87 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -49,6 +49,12 @@ struct instruction { bool intra_group_jump; }; +struct alternative { + struct list_head list; + struct instruction *insn; + bool skip_orig; +}; + struct objtool_file { struct elf *elf; struct list_head insn_list; @@ -70,5 +76,6 @@ struct instruction *find_insn(struct objtool_file *file, insn->sec == sec; \ insn = list_next_entry(insn, list)) +#define C_JUMP_TABLE_SECTION ".rodata..c_jump_table" #endif /* _CHECK_H */ diff --git a/tools/objtool/special.h b/tools/objtool/special.h index 738a05bc6d3a..7f258d87e9f8 100644 --- a/tools/objtool/special.h +++ b/tools/objtool/special.h @@ -7,6 +7,7 @@ #define _SPECIAL_H #include +#include "check.h" #include "elf.h" #include "arch_special.h" @@ -36,4 +37,8 @@ static inline void arch_handle_alternative(unsigned short feature, } #endif +int arch_add_jump_table_dests(struct objtool_file *file, + struct instruction *insn); +struct rela *arch_find_switch_table(struct objtool_file *file, + struct instruction *insn); #endif /* _SPECIAL_H */ From patchwork Thu Jan 9 16:02:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326061 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3029C930 for ; Thu, 9 Jan 2020 16:07:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B7EC420661 for ; Thu, 9 Jan 2020 16:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rnO4GJlf"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dJrJERVa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7EC420661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Gt2/6ijDyV+0UoaBWtPr4Z7gc/2qGZzTSgrKnDqv1d0=; b=rnO4GJlfnO79n+ B/ZGiO5QHVyWUoSc4LaFTVXbSUXvE4BB4QanpZvJICK6fip1v+5gl0ed6B7u2AkX80umwn+dLvEfZ Dczb6BlFBbfCsTVTou2KkWHzUlvs0jKqbW4hqoX42zihSmKtzeYGr+BJzKS1eYlsgWXFBZ+JtC2Zg fFXDn+DliknB4n9J6Se6PTgfQC+EPU6wFaKGWIQNe92CPgc7Be+b9nQkXhYqJ5adgv6V7q9coOhE3 saGpm4iRLTu/950A8pNC6fM32DPD4jqaXAoRg7JNTLQo50akIYw73sPErGURRCPukLKLPSfw0vYwo QCcDnrybQNJaGxb2GPGg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKw-0000AW-9P; Thu, 09 Jan 2020 16:07:06 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaIX-0005C4-MP for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:04:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585876; 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=HYifaCqC83E9quo0AQzzkcM5RVW6YOnxLGeWgN1jEgE=; b=dJrJERVaQtAMhhQ+p8XBGYf4k3Ho3Y033ijMvS97ECniZTZGN/wOaduB9PgtDdA90iqNJq wcmOh/jEbholLcDuQWE1J0VjGaYvXwn1iR9xo2andBeaArb5oQh78vp/EQJw9hNPWLrqdd o4cyvABit8TPVMNScY46XUSjLIKXAq0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-JZk1l24UNHqyWjmq9OkZ5Q-1; Thu, 09 Jan 2020 11:04:34 -0500 Received: by mail-wr1-f69.google.com with SMTP id c17so3034309wrp.10 for ; Thu, 09 Jan 2020 08:04:34 -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=OPBxE4c44VnYWt99R79o8GTHiHVeNVwB4++Qy9Ykboc=; b=iptJkwd7WjBzFv2BUxH7WyHNfxc/MbjDizP+NcEMvj6l/zr9nyj8n2TfNibnqRY427 vREcdeFbogZWTOxELQWA9pT06OKQ8Dzf7HEPd10wvBNUM6h3jdGGwCB0hi0ZCU2wyeOj o0pgm/+kxID0ZZ+jbTCfmbCiUzdeiaFhs3XYdEMTAlftxtDpH2LcEaLZtFvR2fcb08Et 2blHpDuaL2KePgQ2JYH9lODsO0hvGXBRuQJdnX0QFWXDsrTU4N/cADjFymGLhSwXuDlN xRdSTsIBEdrrG6oXxEyBhZFeO02hXW+5e9Zkime+Uy15GwDr9ncL6GQphm3FgrtMYfS4 n6mA== X-Gm-Message-State: APjAAAVK7wV9AR7snblKicLaUvjaYLScrvOgIMsqU+yCsnVIRoY2LBdR cqW3q4oWTvgCASlhPOhllbRxOIcNCWINdAjdT09KJRl5j6BFSlxKparovcCbP2Ht6GnQelXsgCp Qc5SI4a6eTsKVuH9lm4F2vAEEC/MQ5NVvB0o= X-Received: by 2002:adf:d848:: with SMTP id k8mr11316226wrl.328.1578585872138; Thu, 09 Jan 2020 08:04:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyqcNbetrnQcSOK2+QlGeBEYrCj6Gyr3pvipf9Hu3BWAwzBGYNpp4vh/6MRtMDYbRKorqQdHw== X-Received: by 2002:adf:d848:: with SMTP id k8mr11316210wrl.328.1578585871917; Thu, 09 Jan 2020 08:04:31 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id b17sm8615898wrp.49.2020.01.09.08.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:04:31 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 14/57] objtool: Do not look for STT_NOTYPE symbols Date: Thu, 9 Jan 2020 16:02:17 +0000 Message-Id: <20200109160300.26150-15-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: JZk1l24UNHqyWjmq9OkZ5Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080437_821490_EB3827DC X-CRM114-Status: GOOD ( 11.32 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ELF symbols can have type STT_NOTYPE which have no standard semantics. Arm64 objects will contain STT_NOTYPE symbols at the beginning of each section which aren't of any use to generic objtool code. Those symbols unfortunately overlap with the first function of the section. Skip symbols with type STT_NOTYPE when looking up symbols. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/elf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index edba4745f25a..c6ac0b771b73 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -62,7 +62,8 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) struct symbol *sym; list_for_each_entry(sym, &sec->symbol_list, list) - if (sym->type != STT_SECTION && + if (sym->type != STT_NOTYPE && + sym->type != STT_SECTION && sym->offset == offset) return sym; From patchwork Thu Jan 9 16:02:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42AA5930 for ; Thu, 9 Jan 2020 16:07:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 19DF920661 for ; Thu, 9 Jan 2020 16:07:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GGQ1KToM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="epAv4O5i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19DF920661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=/B1YYGUHm13PiPA3scJeNwOymwYpmMJXqtQ55NrT540=; b=GGQ1KToMUjN7C0 2jzB7eqmic3Jsq9XIpBJuux9CxqXEbjS+rJLg2Fs0b/K5ZK7mXGy6NEA0Bid+AD4Lv/4zvu/5EjYj EQRJsBvKYf2fhhkzG5k1+PHLRJW4j43+i3+XvcSgRR44wZEk0v/J6gpBJWYhHVx4MlQVpTNpw1qBv PAcqZzoQxi97G2ruThsbT7EsvI2T8BN/EWwiS4sRfkXzhJnShTmtsu4EqI61pNzfFoBFNNTqWsrqq IRF8v5La3eo/vBOqWPIEG4PxrSlGBCbg8X/F0Ec/Y/ovhZhj8kVcBpfi8eEPpz/rJxaJrZHsONY8/ VWMQ0x3xv689ZRreoOMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLg-0000sZ-Go; Thu, 09 Jan 2020 16:07:52 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJ6-00068I-25 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585907; 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=maOW8A5/u0J925rSRYzcXOzsHtn4QK4E4IRMZP251q4=; b=epAv4O5iq+Nfod40PmBGnaR3l6U6X6wvI3KWm9DHUDdNvquQRSSy2I9nNtvm2AN+bxamm6 A70Dgxg1LceOxRdRWbiE3R96X2aWfNAp/CUEmosacKD+IBqMyOcVeATC17CqCNMQq7Ex1j WZwP4ypn6MEQuZmiWTRndFSkk7a0X2w= 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-388-Vj63JLtPPeKn8v6ygpc7Wg-1; Thu, 09 Jan 2020 11:05:06 -0500 Received: by mail-wr1-f70.google.com with SMTP id f10so3058316wro.14 for ; Thu, 09 Jan 2020 08:05:05 -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=KfRYv85TKcvAOdoeytsotoDBeN5NjVxxna+B8zLHPVA=; b=W2eTo3yunOT1JMgehvrvnzgUHRzS6HRrevw8vpZXXEE9feg2xSUb0BsbA9T4TYOUgu BXe5J3ttZlHG8KsUhT3gzUP9Sea1kRPPvUAWH93sOXX2zzlHqGFyHu2t5Apv3fVep8xa PgOiEhZJg+v8r2yriGZd7z+YMeAAteJPjBqvnL6QEAkoaqToVzIwsubZ4OHsZn8UFmGi an2e68IAj5FmEI9N2MVyuNJ5v6WqqmlttZrY6gPsnWOjK1ZSl4f7QWsu2y7yIXe8ahZ+ g9ZCxNptx53lG1AkTtE/zEyEpqmisf0YT6b2UudQSLj7Kjnmp8FzF+KT0DriWW9UYlSk ivuA== X-Gm-Message-State: APjAAAXQPDxU+ogkfxJ0I0UujAeFZStYVsQziaBzT/DKQqtYhTN2B3wE FVifBKu/w9GiXs4JHGjPobIEuNSSxi5p3qK3tx8D20NkuiGoT3YRMUnBR24Ouu48Er3hFbsONXl f7t5c66C97/4tMGyXyYYNOXniEiO7pDLm5Tc= X-Received: by 2002:adf:f2c1:: with SMTP id d1mr11478789wrp.111.1578585904835; Thu, 09 Jan 2020 08:05:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyPEXxUZBqvxm0pvveTyPQvZPZhyqo90SAmgLADCLxa+3+kAarj0a6aRfYAABQykiNl2ucrZw== X-Received: by 2002:adf:f2c1:: with SMTP id d1mr11478765wrp.111.1578585904635; Thu, 09 Jan 2020 08:05:04 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id d16sm9285303wrg.27.2020.01.09.08.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:03 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 15/57] objtool: Support addition to set frame pointer Date: Thu, 9 Jan 2020 16:02:18 +0000 Message-Id: <20200109160300.26150-16-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: Vj63JLtPPeKn8v6ygpc7Wg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080512_282655_8C4584B8 X-CRM114-Status: UNSURE ( 9.34 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Support updating the frame pointer by adding an immediate value to the stack pointer in the CFA tracking code. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 19e96c4ad0a3..5b2539eaccba 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1394,6 +1394,18 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) break; } + if (op->src.reg == CFI_SP && cfa->base == CFI_SP && + op->dest.reg == CFI_BP && + regs[CFI_BP].base == CFI_CFA && + regs[CFI_BP].offset == -cfa->offset + op->src.offset) { + + /* lea disp(%rsp), %rbp */ + cfa->base = CFI_BP; + cfa->offset -= op->src.offset; + state->bp_scratch = false; + break; + } + if (op->src.reg == CFI_SP && cfa->base == CFI_SP) { /* drap: lea disp(%rsp), %drap */ From patchwork Thu Jan 9 16:02:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13190139A for ; Thu, 9 Jan 2020 16:08:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DF24720661 for ; Thu, 9 Jan 2020 16:08:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fu7zjsHP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WtzoRuNd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF24720661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=IRMKW1BUsLKZhhODLoyzDaFxZ3lvZwTzvEKx50GP55E=; b=fu7zjsHP9iT+cW aYGAnKTkkyzWQPsXOHwXxaLklhiA+qF2L1itMJt5RFr2ZckHmoF8xmHkgeQaY+egxbiiVGBPtCITQ MDBAU5fVYJuY778HlNScoq4g3ja3rZZTxUBTo5JItRF9fN7Lyn+sFXTvv4XUXubt2QFGDmXyszSGi YRR/n5Mk3OLaE7CU0pyxfH0XvGAA2VLGrLToTIl6jIA+/K0OF6SUgUU0prXYizTgojxuai41Ghh7b lCvnhn9cVUH8dE6xSuATcFZGO47DyR6dPMi0kI+Zegmk70Vet//ilWZaskH9jUsR0FmMLKeEA29kO tIRaQyoDka/yv3jjTzXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLt-00015k-DC; Thu, 09 Jan 2020 16:08:05 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJ6-0006D3-GB for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585908; 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=Fu7bYN5srVl+qXZI7cFZSY77PyhyER4eVK7tyh3waH4=; b=WtzoRuNdc8FieuAKjMd0MnSUS/rKsm/tW4si0+T2kDLPYykTFxmEMNr4azbyv200jkMoBz VywGy+J62CMZOjX84+ZZGKULQGDyWlMq54esZ4FKiDVpV7kw6CmnTlxlSUB7hGEjE8McsY 6GPwwuVVjc+ZuYB26lffKICKk4nJkt8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-EJ2EYDwGOu-LsDudC3h-zg-1; Thu, 09 Jan 2020 11:05:07 -0500 Received: by mail-wr1-f72.google.com with SMTP id 90so3037480wrq.6 for ; Thu, 09 Jan 2020 08:05:07 -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=RN81Hr2F3scNb0RyFSSlR24ibWGqr/jAb3l0nXd6mwk=; b=d0nk5XAJG1MDjRTv5xWI3KoBzGCdSxKPtEdVKEo7obv2/lWlaIqJvKVdbr4Mwqumqp NgRpJFdW6yhE+1lrcjq1A/fwT0PASts2O5oodaLN2t2qZFdifHxMVABXGYIIdDPG4ChC QR8iPTEUnrrSFlr/+ui1U++jYgr8AM+vsukH1mrXnUKoDB6gNPQePfAre84Ae8mo3vrA i9KYPnG7RLZD9tfiYNlpvZVUxvpJ4t7wgj1x6BPKybUq427ahyhkp7KCAYQJdi1SeLmy 6LVKqCoeTuBOxbMOsdGkZWXcuxnqvBcAwrp2klpzdNkP802Y8ENEfVpHdGIK3i5HsijQ kZbg== X-Gm-Message-State: APjAAAUBmcniwVPwI/nTeae3QtGAk/CdJiyYpgz4HtJkJguRdn2c/H7i 6GsU+r8k46ln94lrVk7tTYBdRDGMfT0n9Ygytnzn1+L5e27pL6sftYhCfeIlZHFb4M4jD6ttXZq 5rWU3mjaT2VP/+qq0C1OLAIPSIyKlUPNKIzY= X-Received: by 2002:a5d:608e:: with SMTP id w14mr12212472wrt.256.1578585906279; Thu, 09 Jan 2020 08:05:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzelCxqz+HY+vptIAIaeoW/L/+6jX9Gnq+tDYYFZlPnGBvNBZJ14bHw1aP3g+H7x8mUB7kekA== X-Received: by 2002:a5d:608e:: with SMTP id w14mr12212440wrt.256.1578585905967; Thu, 09 Jan 2020 08:05:05 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id d16sm9285303wrg.27.2020.01.09.08.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:05 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 16/57] objtool: Support restoring BP from the stack without POP Date: Thu, 9 Jan 2020 16:02:19 +0000 Message-Id: <20200109160300.26150-17-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: EJ2EYDwGOu-LsDudC3h-zg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080512_723059_486A6D9F X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Support instruction that set BP to its previous value (base on the current CFA state) from the stack without modifying the stack pointer. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 5b2539eaccba..0a5c51e4e24c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1507,6 +1507,12 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) cfa->base = state->drap_reg; cfa->offset = 0; state->drap_offset = -1; + } else if (!state->drap && op->src.reg == CFI_SP && + op->dest.reg == cfa->base) { + + /* mov disp(%rsp), %rbp */ + cfa->base = CFI_SP; + cfa->offset += op->src.offset; } if (state->drap && op->src.reg == CFI_BP && From patchwork Thu Jan 9 16:02:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F7CD139A for ; Thu, 9 Jan 2020 16:08:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 343AE20661 for ; Thu, 9 Jan 2020 16:08:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LQq2E6Wk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Jk7T4DT4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 343AE20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=4TKsZQ162PzjQCBkRgV9ROgh8fZS+2lfcOtjxGKpzlU=; b=LQq2E6WkZAIuLE 2WxXc+eScB/woppINfhZf5B8ga7VIgt0fi2C5HMcldtknSAR5TCZiz2TsDGsyd0XM4e15fukLZGwk /YkNBJ3nGenCuFbjTmnx5FyuHMszB1uXf6hcqLgjDDqHjRuWGjPQ/2t8hPRK264aqyj5VqxFpcQxB KVTE0YAB/jsJpaPTdLHsRb8c5pgje3zdziI7pVDFdlcarQZDGDLdoKGbFk1BBuBaZuWk96dWSRaHu be7jyeFdUxzxdYvWTSEnPJMv25KlRA6/CrjtfKHSu6NCIzcdLZhs7sLIeEJfph5+t/LhcW6caRBfT ENYve2BNCjME/iD9mdag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaME-0001OR-2S; Thu, 09 Jan 2020 16:08:26 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJ7-0006O5-A3 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585910; 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=0eGQcEDML0Y79i4e+/1ghIKGwGfPNRaPsrp8gxp/WLc=; b=Jk7T4DT4uHJjdAcwijFb8CyIrQI1Q6kdnKGGB7KlKfqTwlw7NOyzOlWEIkzZny1IjcCrZG aQiXnZNWpYuAd6+1KiDPkVDrEQvnTCx2CI6oJTDdi50nVoyjplRB2ret6f8V6ky30TFfXm Fj8SbbDBiodH1/RdLzfwTNXAIstSkC4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-On0pbphPMAG_qo7dhASz9g-1; Thu, 09 Jan 2020 11:05:09 -0500 Received: by mail-wr1-f71.google.com with SMTP id z14so3074172wrs.4 for ; Thu, 09 Jan 2020 08:05:09 -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=GLC9hNezWUeQVArYqnoEaqxCV4y5v31FOWiE9b3pIzA=; b=By3456pmNxGeTw11wR2ky6sppMU9R/J8E4xHTwY9YQEmTWPHgsNz81cou3GnUFXe3i An75ZnAmBnACgPaWIPBWV7vleeDzNShaFepG+4Gd4rvLJeswPGjkoFATismgdjZ9vSTe D0tCxdmCUIaIWXbz5nH1gA7VN7422NSW3ahc7G/vvduRg5cklrDiyPUzXK991ZRDJEoY +blz+hhZwMfDv0o6ia3j8Nh4gBGxnpGT3yixSaC2lZfhmxXYtHuuzOG3W2YWidGe9/a/ t11g317nU8dnjThIHlkf/SrFAM0ZpiwofpS1L9zEP4/L412gxw8N+L0AXcJwuSwv8Ecd 56Sw== X-Gm-Message-State: APjAAAWAk/pE8tlpVQ/9dP4S3MZ9Memm4QIOtXBDDRk9Goo/pcxnYLNH rCXhJtOL6AkzsorO2bf3VCN05i8XyAhHE8vlJ2HGH+oB13OG4Pm/pC0Z1TOK0LSHLW2DDKxyove GdJHh4MiwM+Hd8cVadCnmzpcaV+73rejRSNQ= X-Received: by 2002:a5d:6652:: with SMTP id f18mr12130809wrw.246.1578585907737; Thu, 09 Jan 2020 08:05:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxcuGHLY97/ieBCy+A431B2pbzBsFD5NdBbjJV9wyCtGKMcOfTDY33FxJb8HaIZjLm8Wp/zNA== X-Received: by 2002:a5d:6652:: with SMTP id f18mr12130779wrw.246.1578585907516; Thu, 09 Jan 2020 08:05:07 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id d16sm9285303wrg.27.2020.01.09.08.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:06 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 17/57] objtool: Make stack validation more generic Date: Thu, 9 Jan 2020 16:02:20 +0000 Message-Id: <20200109160300.26150-18-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: On0pbphPMAG_qo7dhASz9g-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080513_605907_9B4EF32D X-CRM114-Status: GOOD ( 13.98 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On x86, when calling a function, the new call frame is alway placed at the start of the stack space this function can freely use. So the frame pointer is always saved at - 16. This is not true for the calling convention of all architecture. When validating the call frame before a call instruction, all that can be done is check that a frame was created by the current function and that the frame pointer is correctly pointing to it. Signed-off-by: Julien Thierry --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 0a5c51e4e24c..04434cdbdab6 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1176,7 +1176,7 @@ static bool has_modified_stack_frame(struct insn_state *state) static bool has_valid_stack_frame(struct insn_state *state) { if (state->cfa.base == CFI_BP && state->regs[CFI_BP].base == CFI_CFA && - state->regs[CFI_BP].offset == -16) + state->regs[CFI_BP].offset == -state->cfa.offset) return true; if (state->drap && state->regs[CFI_BP].base == CFI_BP) From patchwork Thu Jan 9 16:02:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE2CB930 for ; Thu, 9 Jan 2020 16:08:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A4D8020661 for ; Thu, 9 Jan 2020 16:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uqRibiU2"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RsD1kbO5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4D8020661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=9EDvzbzlkrqZ5SZWd+NIlCBHiWy5GwCZKPCy8XNY6fQ=; b=uqRibiU2MZrqf3 eLvjyBzSinrrcULyYWx6kFH6fOfA5zpsGPJgcu6tPoZ3FFJB5pqtpVOtkDvXRRjjl8hXoJhk3TAbl gk8HqIVjERWh+YKe3JlgUry7Qa78ZX3pknIdkWatDt1l0AxTcbyUhc9RwLoBG4Qq6LeHF2xEaT//z v4Nueiz9ChrjhXAXC3vziZKwlsGcAqjqgeJJO+NIcH1Y2URbap4hGMdPGERfxx2LqnEeJ+AZrPoQ9 d9mbiWArcNZYHUTZicqQwVW27+buQffX7WG8JsXj++wflHs2WMc0I9dy6uaxhozLWxRJcGe9Tkt03 Dp9Fd7PdTShq6UPN7k4A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMd-0001jw-2Y; Thu, 09 Jan 2020 16:08:51 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJ8-0006Xt-Bb for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585912; 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=rqhdowMksK6zee7nOWNFlCyOp/jFquOjYNm+6gMRECs=; b=RsD1kbO5ruvhHX7Ff30J7RDJMP+qtbv58GcgLy4KqLkQl78ODeB8YGZvUnfVQh9hXehcDf q0eNvLvF9ETEPk9z3/Egn1sL8/VDx06Lcd+a+IjXzQZ+aNTXQ+qJQ6fSXODRMarSTJC9TS lEyId4uZRUX7fEYfMVqBDBH01GfW2yc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-aVfcn17MNGq7adq_4N792Q-1; Thu, 09 Jan 2020 11:05:11 -0500 Received: by mail-wm1-f71.google.com with SMTP id b131so1090561wmd.9 for ; Thu, 09 Jan 2020 08:05:10 -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=rUZyYTZTlt6xExXoiyGlyEW363t3TFsZHEPKNeEJgoc=; b=egSXDSQg26pQQFb1p1+zIiD+Q26cfqUKLwvyQghGm2HnUxowOEyz/XfBY/ebcNoySI aFo7aTL950V3atHYHN7gtXHjRyyJdtTnKPHiK8ZYSkV656XE8et5jJTHgrVRlVH8/PxC 2HCYb6A4alxaip/FvRwe8EY70BTg541wS/AzQ/l3K+dqtCjcgfdWx3laMgeKw/Gp5Bie 2La48vKwxlVO8G26vQNVqBUZ5SYi7OW3IGFxYj6Y0mhAWa+ckTnApyuN+jn87wnTv64q njVK5bnVV6tzJ8nlDXssS6/d9+3vGyaeUCvk8nGi1MKg9JawGcv4Lke1kzKLpA2oqbRY kVCw== X-Gm-Message-State: APjAAAVpD3WIuEI59IS4YKPNEX8GT9OBACm7LipZxHEvCgjyXCu7bnmw 764VADhrhT6EGS3RRvIrd2oqX2XTyCextTUYJ74wDllZvDAoSxf3M/51ifipD789KbfG7nJh4nw Vm5iGXfjw5/FMLGj9hdL7XkdQ7cKXGg2TiBA= X-Received: by 2002:a1c:8086:: with SMTP id b128mr5785195wmd.80.1578585909224; Thu, 09 Jan 2020 08:05:09 -0800 (PST) X-Google-Smtp-Source: APXvYqy4QksIyxHYuyEaR7ATKTXxSgLBn8h9jbGh1vFZzsTsxowKxTbQnjsGE4vrFPLbQBd2CXwocg== X-Received: by 2002:a1c:8086:: with SMTP id b128mr5785151wmd.80.1578585908897; Thu, 09 Jan 2020 08:05:08 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id d16sm9285303wrg.27.2020.01.09.08.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:08 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 18/57] objtool: Support multiple stack_op per instruction Date: Thu, 9 Jan 2020 16:02:21 +0000 Message-Id: <20200109160300.26150-19-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: aVfcn17MNGq7adq_4N792Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080514_525811_1F9D17C6 X-CRM114-Status: GOOD ( 12.15 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Instruction sets can include more or less complex operations which might not fit the currently defined set of stack_ops. Combining more than one stack_op provides more flexibility to describe the behaviour of an instruction. This also reduces the need to define new stack_ops specific to a single instruction set. Allow instruction decoders to generate multiple stack_op per instruction. Signed-off-by: Julien Thierry --- tools/objtool/arch.h | 4 +- tools/objtool/arch/x86/decode.c | 13 +++++- tools/objtool/check.c | 79 +++++++++++++++++++++------------ tools/objtool/check.h | 2 +- 4 files changed, 67 insertions(+), 31 deletions(-) diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index a9a50a25ca66..f9883c431949 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -64,6 +64,7 @@ struct op_src { struct stack_op { struct op_dest dest; struct op_src src; + struct list_head list; }; struct instruction; @@ -73,7 +74,8 @@ void arch_initial_func_cfi_state(struct cfi_state *state); int arch_decode_instruction(struct elf *elf, struct section *sec, unsigned long offset, unsigned int maxlen, unsigned int *len, enum insn_type *type, - unsigned long *immediate, struct stack_op *op); + unsigned long *immediate, + struct list_head *ops_list); bool arch_callee_saved_reg(unsigned char reg); diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 79ff33ffa6e0..650e5d021486 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -75,13 +75,15 @@ unsigned long arch_dest_rela_offset(int addend) int arch_decode_instruction(struct elf *elf, struct section *sec, unsigned long offset, unsigned int maxlen, unsigned int *len, enum insn_type *type, - unsigned long *immediate, struct stack_op *op) + unsigned long *immediate, + struct list_head *ops_list) { struct insn insn; int x86_64, sign; unsigned char op1, op2, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0, rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0, modrm_reg = 0, sib = 0; + struct stack_op *op; x86_64 = is_x86_64(elf); if (x86_64 == -1) @@ -122,6 +124,10 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, if (insn.sib.nbytes) sib = insn.sib.bytes[0]; + op = calloc(1, sizeof(*op)); + if (!op) + return -1; + switch (op1) { case 0x1: @@ -483,6 +489,11 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, *immediate = insn.immediate.nbytes ? insn.immediate.value : 0; + if (*type == INSN_STACK) + list_add_tail(&op->list, ops_list); + else + free(op); + return 0; } diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 04434cdbdab6..48aec56a7760 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -246,6 +246,7 @@ static int decode_instructions(struct objtool_file *file) } memset(insn, 0, sizeof(*insn)); INIT_LIST_HEAD(&insn->alts); + INIT_LIST_HEAD(&insn->stack_ops); clear_insn_state(&insn->state); insn->sec = sec; @@ -255,7 +256,7 @@ static int decode_instructions(struct objtool_file *file) sec->len - offset, &insn->len, &insn->type, &insn->immediate, - &insn->stack_op); + &insn->stack_ops); if (ret) goto err; @@ -735,6 +736,7 @@ static int handle_group_alt(struct objtool_file *file, } memset(fake_jump, 0, sizeof(*fake_jump)); INIT_LIST_HEAD(&fake_jump->alts); + INIT_LIST_HEAD(&fake_jump->stack_ops); clear_insn_state(&fake_jump->state); fake_jump->sec = special_alt->new_sec; @@ -1186,10 +1188,11 @@ static bool has_valid_stack_frame(struct insn_state *state) } #ifdef OBJTOOL_ORC -static int update_insn_state_regs(struct instruction *insn, struct insn_state *state) +static int update_insn_state_regs(struct instruction *insn, + struct insn_state *state, + struct stack_op *op) { struct cfi_reg *cfa = &state->cfa; - struct stack_op *op = &insn->stack_op; if (cfa->base != CFI_SP) return 0; @@ -1280,9 +1283,9 @@ static void restore_reg(struct insn_state *state, unsigned char reg) * 41 5d pop %r13 * c3 retq */ -static int update_insn_state(struct instruction *insn, struct insn_state *state) +static int update_insn_state(struct instruction *insn, struct insn_state *state, + struct stack_op *op) { - struct stack_op *op = &insn->stack_op; struct cfi_reg *cfa = &state->cfa; struct cfi_reg *regs = state->regs; @@ -1297,7 +1300,7 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) #ifdef OBJTOOL_ORC if (state->type == ORC_TYPE_REGS || state->type == ORC_TYPE_REGS_IRET) - return update_insn_state_regs(insn, state); + return update_insn_state_regs(insn, state, op); #endif switch (op->dest.type) { @@ -1653,6 +1656,42 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state) return 0; } +static int handle_insn_ops(struct instruction *insn, struct insn_state *state) +{ + struct stack_op *op; + + list_for_each_entry(op, &insn->stack_ops, list) { + int res; + + res = update_insn_state(insn, state, op); + if (res) + return res; + + if (op->dest.type == OP_DEST_PUSHF) { + if (!state->uaccess_stack) { + state->uaccess_stack = 1; + } else if (state->uaccess_stack >> 31) { + WARN_FUNC("PUSHF stack exhausted", + insn->sec, insn->offset); + return 1; + } + state->uaccess_stack <<= 1; + state->uaccess_stack |= state->uaccess; + } + + if (op->src.type == OP_SRC_POPF) { + if (state->uaccess_stack) { + state->uaccess = state->uaccess_stack & 1; + state->uaccess_stack >>= 1; + if (state->uaccess_stack == 1) + state->uaccess_stack = 0; + } + } + } + + return 0; +} + static bool insn_state_match(struct instruction *insn, struct insn_state *state) { struct insn_state *state1 = &insn->state, *state2 = state; @@ -1965,29 +2004,8 @@ static int validate_branch_alt_safe(struct objtool_file *file, return 0; case INSN_STACK: - if (update_insn_state(insn, &state)) + if (handle_insn_ops(insn, &state)) return 1; - - if (insn->stack_op.dest.type == OP_DEST_PUSHF) { - if (!state.uaccess_stack) { - state.uaccess_stack = 1; - } else if (state.uaccess_stack >> 31) { - WARN_FUNC("PUSHF stack exhausted", sec, insn->offset); - return 1; - } - state.uaccess_stack <<= 1; - state.uaccess_stack |= state.uaccess; - } - - if (insn->stack_op.src.type == OP_SRC_POPF) { - if (state.uaccess_stack) { - state.uaccess = state.uaccess_stack & 1; - state.uaccess_stack >>= 1; - if (state.uaccess_stack == 1) - state.uaccess_stack = 0; - } - } - break; case INSN_STAC: @@ -2232,12 +2250,17 @@ static void cleanup(struct objtool_file *file) { struct instruction *insn, *tmpinsn; struct alternative *alt, *tmpalt; + struct stack_op *op, *tmpop; list_for_each_entry_safe(insn, tmpinsn, &file->insn_list, list) { list_for_each_entry_safe(alt, tmpalt, &insn->alts, list) { list_del(&alt->list); free(alt); } + list_for_each_entry_safe(op, tmpop, &insn->stack_ops, list) { + list_del(&op->list); + free(op); + } list_del(&insn->list); hash_del(&insn->hash); free(insn); diff --git a/tools/objtool/check.h b/tools/objtool/check.h index 843094cbae87..91adec42782c 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -43,7 +43,7 @@ struct instruction { struct rela *jump_table; struct list_head alts; struct symbol *func; - struct stack_op stack_op; + struct list_head stack_ops; struct insn_state state; struct orc_entry orc; bool intra_group_jump; From patchwork Thu Jan 9 16:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 773C917EE for ; Thu, 9 Jan 2020 16:09:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5008320661 for ; Thu, 9 Jan 2020 16:09:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pG8PjXbM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E/YApsBB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5008320661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=xfLzeQtVJCQ92ImfWYyeuMQHaiybNxMY3DJ4gx+Ox5Y=; b=pG8PjXbMRivDyA KIefDtgkBOLguh02AsG4V+3KCahnwypkI0cLJfZ7Vb8GKznsHL/eTPqKuXv0FRllWk6BcB3CbEcjH ZI4q0BnnR40QGe0JFnvDrNqFm6IE9wW7hsadVaTxDy+Iv33ZcKHnUX0yE99+m+fYzqrNq00lEZgpX dY5/9SYsdZEvydxYo7wNBiKT0A+6iiIcs1hVjoSMYbu1VgkvsiVEkk06KjAySTcYQRYiEsTvkrpr4 c3Oc9czl/G0+nP32g3MiaRK/4dYssib/+TiEFM33n77hiI7DisuSvFyfktGqVGMvWTk/Zp/jF89Xe J0OgjtbeYHHqthaZM62A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaN4-0002Er-UA; Thu, 09 Jan 2020 16:09:19 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJB-0006v2-4P for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585916; 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=liqkySHLKIz0uoBGXHlsMeQRRl9gvCVdhNGv8Wwep9Q=; b=E/YApsBBFPFS/ZZ8nkui51bEEaF9wDmlAD5ZTKYorkSyOgXwHFU7x3zVvOklXV4EsqUtYP PF6RXqOtfygMn8dcqlWsZylTB+MKQ+897/UDHl5IGDJeyPJviYFBd/aYxe9XwncplJAsfB g+y088Z6aWUbqgjAbum15qFoMO3IfjY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-054Wb59wNp6VWhLbo3EKSQ-1; Thu, 09 Jan 2020 11:05:12 -0500 Received: by mail-wm1-f71.google.com with SMTP id b9so1093753wmj.6 for ; Thu, 09 Jan 2020 08:05:12 -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=paPYD98fP2vtMtxm6JwVilmzUTcQhBJ0i4er0etHTlI=; b=cqlhQSoBFz2L28lwlgAQqhSri6f35ZeaZmvpWR7RU7epn6sx044+u0r5J3XLliQ3tj zQC7y9GGQEwdhLcUeiLA7NojOOqYzax6uKGBJAGVxM8iiAA1vq2Zw+py1mRrXCQMI6ls mJPGJzV3QHCWJgXMCHq6pddqH8b5mJDnHRl6oWHyV4oOY1CVYb17hyJtxXsYFhbl6UZX nR7mfDAlu7uiMFms67400G5oKzRRDywdy8SKokJ85BXHHMzsn/G07zjcRbpfuCyIZlVn 0Y0rSLQGKUjJ17bjXkXueDnFvHWYLktUo500oIbJF/hC7jaAoA1gwGb4oBA8pxYMoRTN chfA== X-Gm-Message-State: APjAAAXMbarDszbG2+BLznJiyNIlCnKWVtj3Acf6TlMWEQZ+tD81MQ2O ii7HuVKbNm0pVrsXa3qAcMboVGyewbALEMGL9FTS8su4HEjNjw+BlKyRbEdS0GOa3E6EyKnxKLU /Zjt/657Uu76dw4rEVIkaGOqevBkQcyNGO08= X-Received: by 2002:adf:d4ca:: with SMTP id w10mr11107408wrk.53.1578585911063; Thu, 09 Jan 2020 08:05:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwGtV8Ry02kUzdgkMc5mjIbvbd8qI1FNNyDK/gxNDOK9K/FQSxV7d/la71ePxNsc07Fc7+xbg== X-Received: by 2002:adf:d4ca:: with SMTP id w10mr11107372wrk.53.1578585910720; Thu, 09 Jan 2020 08:05:10 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id d16sm9285303wrg.27.2020.01.09.08.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:09 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 19/57] objtool: arm64: Add required implementation for supporting the aarch64 architecture in objtool. Date: Thu, 9 Jan 2020 16:02:22 +0000 Message-Id: <20200109160300.26150-20-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 054Wb59wNp6VWhLbo3EKSQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080517_439212_509B1192 X-CRM114-Status: GOOD ( 16.22 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Provide implementation for the arch-dependent functions that are called by the main check function of objtool. Provide an empty squeleton for the aarch64 decoder that shall be completed in later patches. Signed-off-by: Raphael Gault [J.T.: Use enum for instruction type, Remove orc functions, Remove x86 feature macros from arm64 header, Split decoder over multiple patches, Use SPDX identifiers] Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/Build | 5 + tools/objtool/arch/arm64/arch_special.c | 15 +++ tools/objtool/arch/arm64/bit_operations.c | 69 ++++++++++ tools/objtool/arch/arm64/decode.c | 127 ++++++++++++++++++ .../objtool/arch/arm64/include/arch_special.h | 21 +++ .../arch/arm64/include/bit_operations.h | 31 +++++ tools/objtool/arch/arm64/include/cfi_regs.h | 44 ++++++ .../objtool/arch/arm64/include/insn_decode.h | 15 +++ 8 files changed, 327 insertions(+) create mode 100644 tools/objtool/arch/arm64/Build create mode 100644 tools/objtool/arch/arm64/arch_special.c create mode 100644 tools/objtool/arch/arm64/bit_operations.c create mode 100644 tools/objtool/arch/arm64/decode.c create mode 100644 tools/objtool/arch/arm64/include/arch_special.h create mode 100644 tools/objtool/arch/arm64/include/bit_operations.h create mode 100644 tools/objtool/arch/arm64/include/cfi_regs.h create mode 100644 tools/objtool/arch/arm64/include/insn_decode.h diff --git a/tools/objtool/arch/arm64/Build b/tools/objtool/arch/arm64/Build new file mode 100644 index 000000000000..2a554af43e96 --- /dev/null +++ b/tools/objtool/arch/arm64/Build @@ -0,0 +1,5 @@ +objtool-y += arch_special.o +objtool-y += bit_operations.o +objtool-y += decode.o + +CFLAGS_decode.o += -I$(OUTPUT)arch/arm64/lib diff --git a/tools/objtool/arch/arm64/arch_special.c b/tools/objtool/arch/arm64/arch_special.c new file mode 100644 index 000000000000..5239489c9c57 --- /dev/null +++ b/tools/objtool/arch/arm64/arch_special.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "../../special.h" + +int arch_add_jump_table_dests(struct objtool_file *file, + struct instruction *insn) +{ + return 0; +} + +struct rela *arch_find_switch_table(struct objtool_file *file, + struct instruction *insn) +{ + return NULL; +} diff --git a/tools/objtool/arch/arm64/bit_operations.c b/tools/objtool/arch/arm64/bit_operations.c new file mode 100644 index 000000000000..cd44138956bb --- /dev/null +++ b/tools/objtool/arch/arm64/bit_operations.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include "bit_operations.h" + +#include "../../warn.h" + +u64 replicate(u64 x, int size, int n) +{ + u64 ret = 0; + + while (n >= 0) { + ret = (ret | x) << size; + n--; + } + return ret | x; +} + +u64 ror(u64 x, int size, int shift) +{ + int m = shift % size; + + if (shift == 0) + return x; + return ZERO_EXTEND((x >> m) | (x << (size - m)), size); +} + +int highest_set_bit(u32 x) +{ + int i; + + for (i = 31; i >= 0; i--, x <<= 1) + if (x & 0x80000000) + return i; + return 0; +} + +/* imms and immr are both 6 bit long */ +__uint128_t decode_bit_masks(unsigned char N, unsigned char imms, + unsigned char immr, bool immediate) +{ + u64 tmask, wmask; + u32 diff, S, R, esize, welem, telem; + unsigned char levels = 0, len = 0; + + len = highest_set_bit((N << 6) | ((~imms) & ONES(6))); + levels = ZERO_EXTEND(ONES(len), 6); + + if (immediate && ((imms & levels) == levels)) { + WARN("unknown instruction"); + return -1; + } + + S = imms & levels; + R = immr & levels; + diff = ZERO_EXTEND(S - R, 6); + + esize = 1 << len; + diff = diff & ONES(len); + + welem = ZERO_EXTEND(ONES(S + 1), esize); + telem = ZERO_EXTEND(ONES(diff + 1), esize); + + wmask = replicate(ror(welem, esize, R), esize, 64 / esize); + tmask = replicate(telem, esize, 64 / esize); + + return ((__uint128_t)wmask << 64) | tmask; +} diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c new file mode 100644 index 000000000000..4d0ab2acca27 --- /dev/null +++ b/tools/objtool/arch/arm64/decode.c @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include + +#include "insn_decode.h" +#include "cfi_regs.h" +#include "bit_operations.h" + +#include "../../check.h" +#include "../../arch.h" +#include "../../elf.h" +#include "../../warn.h" + +bool arch_callee_saved_reg(unsigned char reg) +{ + switch (reg) { + case CFI_R19: + case CFI_R20: + case CFI_R21: + case CFI_R22: + case CFI_R23: + case CFI_R24: + case CFI_R25: + case CFI_R26: + case CFI_R27: + case CFI_R28: + case CFI_FP: + case CFI_R30: + return true; + default: + return false; + } +} + +void arch_initial_func_cfi_state(struct cfi_state *state) +{ + int i; + + for (i = 0; i < CFI_NUM_REGS; i++) { + state->regs[i].base = CFI_UNDEFINED; + state->regs[i].offset = 0; + } + + /* initial CFA (call frame address) */ + state->cfa.base = CFI_SP; + state->cfa.offset = 0; +} + +unsigned long arch_dest_rela_offset(int addend) +{ + return addend; +} + +unsigned long arch_jump_destination(struct instruction *insn) +{ + return insn->offset + insn->immediate; +} + +static int is_arm64(struct elf *elf) +{ + switch (elf->ehdr.e_machine) { + case EM_AARCH64: //0xB7 + return 1; + default: + WARN("unexpected ELF machine type %x", + elf->ehdr.e_machine); + return 0; + } +} + +/* + * static int (*arm_decode_class)(u32 instr, + * unsigned int *len, + * enum insn_type *type, + * unsigned long *immediate, + * struct list_head *ops_list); + */ +static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { + NULL, +}; + +/* + * Arm A64 Instruction set' decode groups (based on op0 bits[28:25]): + * Ob0000 - Reserved + * 0b0001/0b001x - Unallocated + * 0b100x - Data Processing -- Immediate + * 0b101x - Branch, Exception Gen., System Instructions. + * 0bx1x0 - Loads and Stores + * 0bx101 - Data Processing -- Registers + * 0bx111 - Data Processing -- Scalar Floating-Points, Advanced SIMD + */ + +int arch_decode_instruction(struct elf *elf, struct section *sec, + unsigned long offset, unsigned int maxlen, + unsigned int *len, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + arm_decode_class decode_fun; + int arm64 = 0; + u32 insn = 0; + int res; + + *len = 4; + *immediate = 0; + + //test architucture (make sure it is arm64) + arm64 = is_arm64(elf); + if (arm64 != 1) + return -1; + + //retrieve instruction (from sec->data->offset) + insn = *(u32 *)(sec->data->d_buf + offset); + + //dispatch according to encoding classes + decode_fun = aarch64_insn_class_decode_table[INSN_CLASS(insn)]; + if (decode_fun) + res = decode_fun(insn, type, immediate, ops_list); + else + res = -1; + + if (res) + WARN_FUNC("Unsupported instruction", sec, offset); + return res; +} diff --git a/tools/objtool/arch/arm64/include/arch_special.h b/tools/objtool/arch/arm64/include/arch_special.h new file mode 100644 index 000000000000..a82a9b3e51df --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch_special.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _ARM64_ARCH_SPECIAL_H +#define _ARM64_ARCH_SPECIAL_H + +#define EX_ENTRY_SIZE 8 +#define EX_ORIG_OFFSET 0 +#define EX_NEW_OFFSET 4 + +#define JUMP_ENTRY_SIZE 16 +#define JUMP_ORIG_OFFSET 0 +#define JUMP_NEW_OFFSET 4 + +#define ALT_ENTRY_SIZE 12 +#define ALT_ORIG_OFFSET 0 +#define ALT_NEW_OFFSET 4 +#define ALT_FEATURE_OFFSET 8 +#define ALT_ORIG_LEN_OFFSET 10 +#define ALT_NEW_LEN_OFFSET 11 + +#endif /* _ARM64_ARCH_SPECIAL_H */ diff --git a/tools/objtool/arch/arm64/include/bit_operations.h b/tools/objtool/arch/arm64/include/bit_operations.h new file mode 100644 index 000000000000..8554adb0df70 --- /dev/null +++ b/tools/objtool/arch/arm64/include/bit_operations.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _BIT_OPERATIONS_H +#define _BIT_OPERATIONS_H + +#include +#include +#include + +#define ONES(N) (((__uint128_t)1 << (N)) - 1) +#define ZERO_EXTEND(X, N) ((X) & ONES(N)) +#define EXTRACT_BIT(X, N) (((X) >> (N)) & ONES(1)) +#define SIGN_EXTEND(X, N) sign_extend((X), (N)) + +static inline unsigned long sign_extend(unsigned long x, int nbits) +{ + return ((~0UL + (EXTRACT_BIT(x, nbits - 1) ^ 1)) << nbits) | x; +} + +u64 replicate(u64 x, int size, int n); + +u64 ror(u64 x, int size, int shift); + +int highest_set_bit(u32 x); + +__uint128_t decode_bit_masks(unsigned char N, + unsigned char imms, + unsigned char immr, + bool immediate); + +#endif /* _BIT_OPERATIONS_H */ diff --git a/tools/objtool/arch/arm64/include/cfi_regs.h b/tools/objtool/arch/arm64/include/cfi_regs.h new file mode 100644 index 000000000000..d48f41e7890b --- /dev/null +++ b/tools/objtool/arch/arm64/include/cfi_regs.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _OBJTOOL_CFI_REGS_H +#define _OBJTOOL_CFI_REGS_H + +#define CFI_R0 0 +#define CFI_R1 1 +#define CFI_R2 2 +#define CFI_R3 3 +#define CFI_R4 4 +#define CFI_R5 5 +#define CFI_R6 6 +#define CFI_R7 7 +#define CFI_R8 8 +#define CFI_R9 9 +#define CFI_R10 10 +#define CFI_R11 11 +#define CFI_R12 12 +#define CFI_R13 13 +#define CFI_R14 14 +#define CFI_R15 15 +#define CFI_R16 16 +#define CFI_R17 17 +#define CFI_R18 18 +#define CFI_R19 19 +#define CFI_R20 20 +#define CFI_R21 21 +#define CFI_R22 22 +#define CFI_R23 23 +#define CFI_R24 24 +#define CFI_R25 25 +#define CFI_R26 26 +#define CFI_R27 27 +#define CFI_R28 28 +#define CFI_R29 29 +#define CFI_FP CFI_R29 +#define CFI_BP CFI_FP +#define CFI_R30 30 +#define CFI_LR CFI_R30 +#define CFI_SP 31 + +#define CFI_NUM_REGS 32 + +#endif /* _OBJTOOL_CFI_REGS_H */ diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h new file mode 100644 index 000000000000..c56b72ac4633 --- /dev/null +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _ARM_INSN_DECODE_H +#define _ARM_INSN_DECODE_H + +#include "../../../arch.h" + +#define NR_INSN_CLASS 16 +#define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) + +typedef int (*arm_decode_class)(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); + +#endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD9FC17EE for ; Thu, 9 Jan 2020 16:09:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A4D0F2072A for ; Thu, 9 Jan 2020 16:09:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oKRCoB0u"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N+Gu22da" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4D0F2072A 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=X3eiD49MmNov9sCwgzTe6qIX2JEorHsY8yTiyoisLRg=; b=oKRCoB0uIggeTS JsDSGd4tORGDMTpZNt98sKtVvItwFjbpgURyBeTptNi3+lgcPvZFnfLN+S1Nk3lfRuz2jtS8FtQ41 lMp9sVubhgboLH/lAoM9xad32yv9EcmC3x2o0ignWDXbRNc7fY7ydiqwJaQEOYhUDqgru8G9Va5nV pgI6GX+KPeTSuiGybsCZwKTZqFeJX9rJ0FIbnL2G0joyaNi/pDL7BR+pG8ga/48akKtGwmCuBvOCf 4LHirs+TkspB39Gf9DtWLOERq2WHa5yy1cPuW3Ei5sqU7CGnj0uNFiB8q4XfntY6KZh0riLVBJg36 EAPCD1SrvKmehxk1nifw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNQ-0002cw-W2; Thu, 09 Jan 2020 16:09:40 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJe-0007Nr-OD for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585945; 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=uShC0TzvILfcSqwBAvApf38hhifFMlGiqOYN9FsIsRQ=; b=N+Gu22daIO8XtatQUJC+XzDb55vyTl0ypzXjANWqYAHryxBobu/JPx75W7HcDkje9u760e FFsTU0Vu5XODYkD7xNq/v+GKRs5MqH27k52NXSIAKCrTwtVVW6pKG7oMnm4twsA6+huWvu UjXHGoqRmsKStkcP3ydebMOMArlty2U= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-rPg8Z3-UMoOcS4N5SVcghg-1; Thu, 09 Jan 2020 11:05:44 -0500 Received: by mail-wr1-f69.google.com with SMTP id t3so3021212wrm.23 for ; Thu, 09 Jan 2020 08:05:43 -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=Mml1mzhjK5wtC17nLrEN5fR+Z9py7ETGWVYItyxd8Hw=; b=FZcvbUu4+3ZVWPP75aiO/N5e5FIZITYfglxczQ75xJ4v4FW/57KXCoDdkSkqrVBoaQ OiB/ZP5B1+PJxJ8szyKLcTR0qDoiywV5On1XqwPnnbgUkghXr9NPI2CuDyCw95lFU3+Z CKsDIcfk0GWR60thIa+0b0h5n8aV/m5eHP/wRo+Mv2aL/AezMXGkheBntxQiTtOnHEto d6PPKfmvNjNvZPTp/Ng7X5Mp99wwgz2H6smkwQQyVWgGdZqY9BF0T51siSsNCOYaVKg1 yOePtqbvsNmE06dRhlzXVmz78SYcRqRkKa3uKZzZqk3JKtkynxi9I2i5ttwi/ClURxKf 31Xw== X-Gm-Message-State: APjAAAUtKCFQDkrs5xpoyM1fCabqUYfueUaU2Rxa3bC/Cp1cvutNpWtM kWPxKrjA4PNRUFjUz6PcgB6X4XVI/Ba/2QJjsdjIBeDa+eGuezixTVQkqWao6M3bWoIrNmDvJGt hufjP2QmqRCSM/nTGSzr66fQH+D8d2WeSCrA= X-Received: by 2002:a1c:2089:: with SMTP id g131mr5957477wmg.63.1578585943126; Thu, 09 Jan 2020 08:05:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyw4kwWJhsfey2tGM6eLUUWESwCEkAPg51xba9MD4w398rYCfFbg3NiYZBgdd7WT6pDYqRluw== X-Received: by 2002:a1c:2089:: with SMTP id g131mr5957442wmg.63.1578585942891; Thu, 09 Jan 2020 08:05:42 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id a16sm8545544wrt.37.2020.01.09.08.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:42 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 20/57] objtool: arm64: Decode unknown instructions Date: Thu, 9 Jan 2020 16:02:23 +0000 Message-Id: <20200109160300.26150-21-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: rPg8Z3-UMoOcS4N5SVcghg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080546_905141_F3188191 X-CRM114-Status: GOOD ( 12.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For aarch64, it is possible to have byte sequences that aren't valid opcodes in the code sections. Do not report an error when the decoder finds such a sequence, but make sure that those bytes cannot be reached in the execution flow. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch.h | 1 + tools/objtool/arch/arm64/decode.c | 22 ++++++++++++++++++- .../objtool/arch/arm64/include/insn_decode.h | 7 ++++++ tools/objtool/check.c | 10 ++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index f9883c431949..0336efecb9d9 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -28,6 +28,7 @@ enum insn_type { INSN_STD, INSN_CLD, INSN_OTHER, + INSN_INVALID, }; enum op_dest_type { diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 4d0ab2acca27..04358f41ef1d 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -78,7 +78,9 @@ static int is_arm64(struct elf *elf) * struct list_head *ops_list); */ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { - NULL, + [INSN_RESERVED] = arm_decode_unknown, + [INSN_UNKNOWN] = arm_decode_unknown, + [INSN_UNALLOC] = arm_decode_unknown, }; /* @@ -125,3 +127,21 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, WARN_FUNC("Unsupported instruction", sec, offset); return res; } + +int arm_decode_unknown(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + /* + * There are a few reasons we might have non-valid opcodes in + * code sections: + * - For load literal, assembler can generate the data to be loaded in + * the code section + * - Compiler/assembler can generate zeroes to pad function that do not + * end on 8-byte alignment + * - Hand written assembly code might contain constants in the code + * section + */ + *type = INSN_INVALID; + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index c56b72ac4633..16066f8fca0d 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -5,6 +5,10 @@ #include "../../../arch.h" +#define INSN_RESERVED 0b0000 +#define INSN_UNKNOWN 0b0001 +#define INSN_UNALLOC 0b0011 + #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) @@ -12,4 +16,7 @@ typedef int (*arm_decode_class)(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +/* arm64 instruction classes */ +int arm_decode_unknown(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 48aec56a7760..52a8e64e15ca 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1818,6 +1818,13 @@ static int validate_branch_alt_safe(struct objtool_file *file, while (1) { next_insn = next_insn_same_sec(file, insn); + if (insn->type == INSN_INVALID) { + WARN("%s+0x%lx non-executable instruction, should never be reached", + insn->sec->name, + insn->offset); + return 1; + } + if (file->c_file && func && insn->func && func != insn->func->pfunc) { WARN("%s() falls through to next function %s()", func->name, insn->func->name); @@ -2137,7 +2144,8 @@ static bool ignore_unreachable_insn(struct instruction *insn) { int i; - if (insn->ignore || insn->type == INSN_NOP) + if (insn->ignore || insn->type == INSN_NOP || + insn->type == INSN_INVALID) return true; /* From patchwork Thu Jan 9 16:02:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C86AA930 for ; Thu, 9 Jan 2020 16:10:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A1ED520661 for ; Thu, 9 Jan 2020 16:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Iqv5zs+O"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VhhpwX7i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1ED520661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=QJwvbOcFi2iOOsgKPfggBVX7FKiCiYrKrmWr+doXXs0=; b=Iqv5zs+OAxLmte JlBVPVkPHehoufK5wN+iWH2+jrmnMXvoeDzfZg5RsesDXetxO5uIH7/LLVGgyuvZFF5sDBbW2CWYx +kmIdfVlF2FEzS8Qygxn4eacI10TJsQOs/RdW6fWCLtlABqFL41GZOlQ1ETzTwDMaVP1JiREXTj43 RXuYaf7O8gEBPWsPS6QdoYjm5e1TtndInSmrUaiausIVYqoVfGW6a3NOW11tGjDR1i0Kh5TSmLQB5 eFAvRUjOGphkgY/8f0bCqkdZrJdgXb0EkMW2bAhRJuOshhW2VQzyitJ++2+1k+t30h9mkwsIS1+KR SEVESuSS9/f0UaCDMyqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaOQ-0004pe-Bi; Thu, 09 Jan 2020 16:10:42 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJh-0007Q3-Be for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585947; 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=SK6heBwfqxiTCLT9bS4AgsWzBnwRSJTG6nXoFuN+nRY=; b=VhhpwX7icNHDqE75pTuFbxwrfgw9zUaX90gXtIoTS6UXuLESY1FC1LuhRd/MKtgHw9sxPw 3W5Ctk72TqATaQXfd5IJUviT0uE4nNCCq/2XqFmFqpSAYDxZxuGyeDpsp9a+ZSI+j7e/ko 3Po7Up3eH6ilJvx34bV2yh+aEsMc3VQ= 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-146-w4X6DTFePiq_DRXfqcc6mA-1; Thu, 09 Jan 2020 11:05:45 -0500 Received: by mail-wr1-f70.google.com with SMTP id z10so3023107wrt.21 for ; Thu, 09 Jan 2020 08:05:45 -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=5AHYV2UMb6QFH2KrZdQF90S4dwnJAUXmqxV2bgFAoj4=; b=mSOc/877dWao8zHRkzKqyCuH0I3Z1lGQ4BOA77FZ3t6WOMZfeix0C3AFJWf9RDZMe/ e+grXzwi+hN7UiTVpT5+EeTKbv9ntlEOttbV6/8U7E4n435rzK6NpamEebF521FQvUVk I1tx7K+9V9gXyBYl1dNMjIEloqp+cd5kDxssA1WwBtM8g7wzqcpjXqeCzc5cKQw/42qi 2RdUwOSDOB/LD3h8UDfPbGEc1SpaJutIMe7OswmiP7lhm3weiWgSodvGzda37Bv+3nvi o4NmHTfV8KSUkpNJR2iiViWy/yOA5h5p3LWQjcAxbYfKOxdmxLiDBrr9mnDxb7oODAV/ 3rCw== X-Gm-Message-State: APjAAAVMSVhKY7O67j98+E/q97J90qfbiWnOPjfswhaGt7Ml064D60ir 3MUUeL82GN4LbbZHQ24PVYYvoxvgc8IJnt5RKx3uW8jxpEIF7tfRhQWZ0EfzC1qrk6ZbIWcM7QO okswlThv9X0TM1+ffvY6Y2E0fVZysfTnMLGI= X-Received: by 2002:adf:ee88:: with SMTP id b8mr12352660wro.249.1578585944487; Thu, 09 Jan 2020 08:05:44 -0800 (PST) X-Google-Smtp-Source: APXvYqziyrPjjwc6jFBPwhewcMunWuDhPtWfMzeeejSLNUTdBAiUMf1lRurJ4PQYCUI/+LBPOsBfYw== X-Received: by 2002:adf:ee88:: with SMTP id b8mr12352633wro.249.1578585944225; Thu, 09 Jan 2020 08:05:44 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id a16sm8545544wrt.37.2020.01.09.08.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:43 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 21/57] objtool: arm64: Decode simple data processing instructions Date: Thu, 9 Jan 2020 16:02:24 +0000 Message-Id: <20200109160300.26150-22-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: w4X6DTFePiq_DRXfqcc6mA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080549_480342_D169290B X-CRM114-Status: GOOD ( 10.20 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode data processing instructions that do not constitute stack operations. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 104 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 18 +++ 2 files changed, 122 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 04358f41ef1d..6c8db9335fc9 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -81,6 +81,7 @@ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_RESERVED] = arm_decode_unknown, [INSN_UNKNOWN] = arm_decode_unknown, [INSN_UNALLOC] = arm_decode_unknown, + [0b1000 ... INSN_DP_IMM] = arm_decode_dp_imm, }; /* @@ -145,3 +146,106 @@ int arm_decode_unknown(u32 instr, enum insn_type *type, return 0; } + +#define NR_DP_IMM_SUBCLASS 8 +#define INSN_DP_IMM_SUBCLASS(opcode) \ + (((opcode) >> 23) & (NR_DP_IMM_SUBCLASS - 1)) + +static arm_decode_class aarch64_insn_dp_imm_decode_table[NR_DP_IMM_SUBCLASS] = { + [0 ... INSN_PCREL] = arm_decode_pcrel, + [INSN_MOVE_WIDE] = arm_decode_move_wide, + [INSN_BITFIELD] = arm_decode_bitfield, + [INSN_EXTRACT] = arm_decode_extract, +}; + +int arm_decode_dp_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + arm_decode_class decode_fun; + + decode_fun = aarch64_insn_dp_imm_decode_table[INSN_DP_IMM_SUBCLASS(instr)]; + if (!decode_fun) + return -1; + return decode_fun(instr, type, immediate, ops_list); +} + +int arm_decode_pcrel(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char page = 0; + u32 immhi = 0, immlo = 0; + + page = EXTRACT_BIT(instr, 31); + immhi = (instr >> 5) & ONES(19); + immlo = (instr >> 29) & ONES(2); + + *immediate = SIGN_EXTEND((immhi << 2) | immlo, 21); + + if (page) + *immediate = SIGN_EXTEND(*immediate << 12, 33); + + *type = INSN_OTHER; + + return 0; +} + +int arm_decode_move_wide(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 imm16 = 0; + unsigned char hw = 0, opc = 0, sf = 0; + + sf = EXTRACT_BIT(instr, 31); + opc = (instr >> 29) & ONES(2); + hw = (instr >> 21) & ONES(2); + imm16 = (instr >> 5) & ONES(16); + + if ((sf == 0 && (hw & 0x2)) || opc == 0x1) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + *immediate = imm16; + + return 0; +} + +int arm_decode_bitfield(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, opc = 0, N = 0; + + sf = EXTRACT_BIT(instr, 31); + opc = (instr >> 29) & ONES(2); + N = EXTRACT_BIT(instr, 22); + + if (opc == 0x3 || sf != N) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + + return 0; +} + +int arm_decode_extract(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, op21 = 0, N = 0, o0 = 0; + unsigned char imms = 0; + unsigned char decode_field = 0; + + sf = EXTRACT_BIT(instr, 31); + op21 = (instr >> 29) & ONES(2); + N = EXTRACT_BIT(instr, 22); + o0 = EXTRACT_BIT(instr, 21); + imms = (instr >> 10) & ONES(6); + + decode_field = (sf << 4) | (op21 << 2) | (N << 1) | o0; + *type = INSN_OTHER; + *immediate = imms; + + if ((decode_field == 0 && !EXTRACT_BIT(imms, 5)) || + decode_field == 0b10010) + return 0; + + return arm_decode_unknown(instr, type, immediate, ops_list); +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 16066f8fca0d..06235d81300c 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -8,15 +8,33 @@ #define INSN_RESERVED 0b0000 #define INSN_UNKNOWN 0b0001 #define INSN_UNALLOC 0b0011 +#define INSN_DP_IMM 0b1001 //0x100x #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) +#define INSN_PCREL 0b001 //0b00x +#define INSN_MOVE_WIDE 0b101 +#define INSN_BITFIELD 0b110 +#define INSN_EXTRACT 0b111 + typedef int (*arm_decode_class)(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); /* arm64 instruction classes */ +int arm_decode_dp_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_unknown(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); + +/* arm64 data processing -- immediate subclasses */ +int arm_decode_pcrel(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_move_wide(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_bitfield(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_extract(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72300139A for ; Thu, 9 Jan 2020 16:10:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 13BEE206ED for ; Thu, 9 Jan 2020 16:10:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aZNmzKfY"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JGuMHDsS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13BEE206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=N47q+7ScfY6PzdDZi1JFAi6LCHbDCZgAArvE8akYjUc=; b=aZNmzKfYc+6yh7 GjSnA088QCJedC5OD1YxwKZlbliXAr89rAy9Od+do/vzSUY9J7OW3UrPNSSd5/c1Wo/K85pMTBE2v u9seh5Sw5yLsDifyCLPZcmXcTi311pGAFnl7LrFyzpb75dxFX8Scy9qSdZkXqIouDUJOMaxTsN7Cz n7QBVCboq0mm6s8PWbjydAWm0uLctvEwmrpjrQdBvfXb8K49ZBchVlYVGn7L1stCzs9aANhMgog0i gbtJFHBOYASrUZPYJDHVT00q8b6mSnlnUtezJgTjdg4+LDg+gaEYwRCEkI35Ht6pfe5maiWxjtFMJ MQrHAbPC89+HeMOMvUiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNj-0002wo-1z; Thu, 09 Jan 2020 16:09:59 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJh-0007QV-9O for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585948; 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=fwhd4eMW5xT1uOj12IsTbmrRU4eJvKckHGPYXpmJi9M=; b=JGuMHDsSklT0F+ECo5L4uDtcHhkGmRgB5B8vtziTcP+aQ7iiSRV7fPAiuhEEAyXl0QwNJF VMRZ6Qn/48w1g5yMa/pgfXnpP5WBOcs7p6Wkg0IwEgDPec4KYLEdJrdb4yt6c2MY9gERTJ /0A32mNKBVNM084ZUvGhVk0S3B5ioqs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-MnW3eAR1MZ6ldr5I44v7uw-1; Thu, 09 Jan 2020 11:05:46 -0500 Received: by mail-wm1-f71.google.com with SMTP id t16so1099222wmt.4 for ; Thu, 09 Jan 2020 08:05:46 -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=XV84s1d1LXARfGRI5XvwgmL153zgl5bEcSpec4trBAU=; b=O+upgnFmYGV4xfpxBnaBDYCuzD3QRuWzaNx7Wv2MigZNgk9djn7pIajJh1eTKayJeb Gik3jC4z+0z5vM4UWaylEixDoGrBughlBY+X/smidDFRdWq0BCo2R8aH9pAktElnHWfG MljDWoC+uD8KRNBqiuV0qAFY5/t7yxUAR7HDRp9rVxk5flQMPlBWTEBSCJSg64T4o0R4 vQ4k5uUb1K01nsih8UiVnL7AEJVH16OKhNpL27rosq2jkK/0YDI/siM78hMeo+0ARkZy kUUALe/igAFZncIuCxRJH5Ope1GU7htG2gKa1+kr3Iyp420e6indQzLtcEw3QhXbvlW1 1moA== X-Gm-Message-State: APjAAAWhqZXJPDPguSA3oSElwJoWT6XmVYG+hqybsV5g/eNvfwjgFJDr H9ANRyw5/1QWp2YM/y06N0n859VYl3b9MYSQyvPEoZa3Hah3arJAK9vv7viC5E0pwhEegV9oMRU WA8ApGFDMMQTwfRvkvRP90au9frcLmPKTWvg= X-Received: by 2002:adf:ef92:: with SMTP id d18mr11387507wro.234.1578585945685; Thu, 09 Jan 2020 08:05:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyzfegkeI1UxER55TgVqDuAMftZI6GF0dVFGZz86ZmeW75YjI/CiYezeaVwYmkistCPIOFlkQ== X-Received: by 2002:adf:ef92:: with SMTP id d18mr11387478wro.234.1578585945448; Thu, 09 Jan 2020 08:05:45 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id a16sm8545544wrt.37.2020.01.09.08.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:44 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 22/57] objtool: arm64: Decode add/sub immediate instructions Date: Thu, 9 Jan 2020 16:02:25 +0000 Message-Id: <20200109160300.26150-23-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: MnW3eAR1MZ6ldr5I44v7uw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080549_411464_BA409952 X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instruction adding immediates to registers. Create stack operation for instructions interacting with the stack pointer or the frame pointer. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 84 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 7 ++ 2 files changed, 91 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 6c8db9335fc9..d240f29a2390 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -13,6 +13,11 @@ #include "../../elf.h" #include "../../warn.h" +static bool stack_related_reg(int reg) +{ + return reg == CFI_SP || reg == CFI_BP; +} + bool arch_callee_saved_reg(unsigned char reg) { switch (reg) { @@ -153,6 +158,8 @@ int arm_decode_unknown(u32 instr, enum insn_type *type, static arm_decode_class aarch64_insn_dp_imm_decode_table[NR_DP_IMM_SUBCLASS] = { [0 ... INSN_PCREL] = arm_decode_pcrel, + [INSN_ADD_SUB] = arm_decode_add_sub, + [INSN_ADD_TAG] = arm_decode_add_sub_tags, [INSN_MOVE_WIDE] = arm_decode_move_wide, [INSN_BITFIELD] = arm_decode_bitfield, [INSN_EXTRACT] = arm_decode_extract, @@ -189,6 +196,83 @@ int arm_decode_pcrel(u32 instr, enum insn_type *type, return 0; } +int arm_decode_add_sub(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned long imm12 = 0, imm = 0; + unsigned char sf = 0, sh = 0, S = 0, op_bit = 0; + unsigned char rn = 0, rd = 0; + + S = EXTRACT_BIT(instr, 29); + op_bit = EXTRACT_BIT(instr, 30); + sf = EXTRACT_BIT(instr, 31); + sh = EXTRACT_BIT(instr, 22); + rd = instr & ONES(5); + rn = (instr >> 5) & ONES(5); + imm12 = (instr >> 10) & ONES(12); + imm = ZERO_EXTEND(imm12 << (sh * 12), (sf + 1) * 32); + + *type = INSN_OTHER; + + if (rd == CFI_BP || (!S && rd == CFI_SP) || stack_related_reg(rn)) { + struct stack_op *op; + + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + op->dest.reg = rd; + op->src.type = OP_SRC_ADD; + op->src.offset = op_bit ? -1 * imm : imm; + op->src.reg = rn; + } + return 0; +} + +int arm_decode_add_sub_tags(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char decode_field = 0, rn = 0, rd = 0, uimm6 = 0; + + decode_field = (instr >> 29) & ONES(3); + rd = instr & ONES(5); + rn = (instr >> 5) & ONES(5); + uimm6 = (instr >> 16) & ONES(6); + + *immediate = uimm6; + *type = INSN_OTHER; + +#define ADDG_DECODE 4 +#define SUBG_DECODE 5 + if (decode_field != ADDG_DECODE && decode_field != SUBG_DECODE) + return arm_decode_unknown(instr, type, immediate, ops_list); + +#undef ADDG_DECODE +#undef SUBG_DECODE + + if (stack_related_reg(rd)) { + struct stack_op *op; + + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + op->dest.reg = rd; + op->src.type = OP_SRC_ADD; + op->src.offset = 0; + op->src.reg = rn; + } + + return 0; +} + int arm_decode_move_wide(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) { diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 06235d81300c..65e60b293a07 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -14,6 +14,8 @@ #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) #define INSN_PCREL 0b001 //0b00x +#define INSN_ADD_SUB 0b010 +#define INSN_ADD_TAG 0b011 #define INSN_MOVE_WIDE 0b101 #define INSN_BITFIELD 0b110 #define INSN_EXTRACT 0b111 @@ -31,6 +33,11 @@ int arm_decode_unknown(u32 instr, enum insn_type *type, /* arm64 data processing -- immediate subclasses */ int arm_decode_pcrel(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_add_sub(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_add_sub_tags(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_move_wide(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_bitfield(u32 instr, enum insn_type *type, From patchwork Thu Jan 9 16:02:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70093930 for ; Thu, 9 Jan 2020 16:10:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3919420661 for ; Thu, 9 Jan 2020 16:10:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fjnLo0ji"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d6+JTYnZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3919420661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=1qwDwLSBBCvOxsJZ4IwcMRhoPHSMinb0dfIKuf5fE2Q=; b=fjnLo0jivkyJ3M urCzWXi/euElLBa4JWmno6bF7aRBF29Ip2AsK9HN4qb8P3EYqbUpMYX1iTTjYVNosYaFbsOvBbgmj OxZxWwUO4nB/+x+72wnjqHnPbx1sOgn0R5gMgbeWL9pR1JknBI4RaxmO3W5OKDXPi8z3vUi2WFLpv Ta/CGkgTZ2O8biP9tbpGFhr+Ga8LUsdQTTTLAXR+kmICHKEH/cJCutX1Mtel9dYNxxvvE+rylQ6XP RO+qVCfIUOvJPPbOoCceHf/ErYO5Kc8kcVNuOzXRIocnqN1pGZv+vPvBGJwAXu+3G0V48tv1emItp ofX8exqYs4/yqXqikBQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaOG-0004e6-RE; Thu, 09 Jan 2020 16:10:32 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJi-0007SO-FV for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:05:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585949; 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=bOnboSSDhCNbDvDrRcBVcUTor/1d2iJyZ3x1lH8gG70=; b=d6+JTYnZIT1JCXYMcHGDIoszTCvOpFTYnQAPvSMsR2pumptUDaWTk1/imHVY4YvLsElca/ /qipxJ2ldNJhDe10auPDsUQt3EkONs1HoHSPT66+zgO2eE1sSWZQu0fieBtdkMpPVCiu6n FRzy7nE182bkMigqP4H8ard3MFZi4XU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-K22vHRlePwea3mPZL3Jo_Q-1; Thu, 09 Jan 2020 11:05:48 -0500 Received: by mail-wm1-f71.google.com with SMTP id t16so1099251wmt.4 for ; Thu, 09 Jan 2020 08:05:47 -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=Dq52D+PjqCb5lmkvaEi43/GUeI+ylqf3UQ4Yjnbg3l0=; b=Bw3u4P+SUq/3nhmjH8UJ06+2/kwmJnOfqricNu4o24xfyAXbZlCwNIhrqoEDYoZ+Xs dpg2dsgZsF5uHEtHYnDm62WQMvuZxRV40aG4geYBjhRKqXAJ0zVxwLCBPymmw7bcD4c9 +ixK2TNIaQ0PM+YiJM0TXCeOm7maSBkpW5u59KVZqpZnZXmxv88Y7gJuLe4USMaFNWMc zPSvMQ9AwCf6KSRcaorgEMtDFOGdV5DQ4B5eqHa+8TxhEV+UxFa8N2jHN0eDlFuNZE+P GA/P0RcM5nN6dJ1m1uwHHnoJ7e6R20KSVjsqe/ST+wHFvOvkDQFFHTnm0fxl1AB7NnDr Wkaw== X-Gm-Message-State: APjAAAW5maIt/fYv4QR2W0N/0DHocmsheipZE//j2MOfJOx6oVzfmfrL nTDQM2zIJZT1QG0WC+uEKFM7u8/kEmpqnM0x6wjP07MJLgP6UFkJweRHtzed6ieCh85+v+5dIIR /RYoYRh/QbSYq0J4Mlk8C3YGrNp4YRYTmAdU= X-Received: by 2002:a5d:6b03:: with SMTP id v3mr11849276wrw.289.1578585947048; Thu, 09 Jan 2020 08:05:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwP9x68/cDeC19G8Csd5FQdYjLlYnXYaw7fp3/2NsvZJnBVV02K8nlocIVVAnRTR5wkU2nCEA== X-Received: by 2002:a5d:6b03:: with SMTP id v3mr11849244wrw.289.1578585946797; Thu, 09 Jan 2020 08:05:46 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id a16sm8545544wrt.37.2020.01.09.08.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:46 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 23/57] objtool: arm64: Decode logical data processing instructions Date: Thu, 9 Jan 2020 16:02:26 +0000 Message-Id: <20200109160300.26150-24-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: K22vHRlePwea3mPZL3Jo_Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080550_622103_2D610A18 X-CRM114-Status: GOOD ( 12.03 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions performing logical operations with immediate values. Create a stack operation for and operation targeting the stack pointer. Since OP_SRC_AND assumes the source and destination register are the same, add a register assignment operation when the source operand of the logical instruction is not the stack pointer. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 58 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + 2 files changed, 61 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index d240f29a2390..a30c3294cc21 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -160,6 +160,7 @@ static arm_decode_class aarch64_insn_dp_imm_decode_table[NR_DP_IMM_SUBCLASS] = { [0 ... INSN_PCREL] = arm_decode_pcrel, [INSN_ADD_SUB] = arm_decode_add_sub, [INSN_ADD_TAG] = arm_decode_add_sub_tags, + [INSN_LOGICAL] = arm_decode_logical, [INSN_MOVE_WIDE] = arm_decode_move_wide, [INSN_BITFIELD] = arm_decode_bitfield, [INSN_EXTRACT] = arm_decode_extract, @@ -273,6 +274,63 @@ int arm_decode_add_sub_tags(u32 instr, enum insn_type *type, return 0; } +int arm_decode_logical(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, opc = 0, N = 0; + unsigned char imms = 0, immr = 0, rn = 0, rd = 0; + struct stack_op *op; + + rd = instr & ONES(5); + rn = (instr >> 5) & ONES(5); + + imms = (instr >> 10) & ONES(6); + immr = (instr >> 16) & ONES(6); + + N = EXTRACT_BIT(instr, 22); + opc = (instr >> 29) & ONES(2); + sf = EXTRACT_BIT(instr, 31); + + if (N == 1 && sf == 0) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + *immediate = (decode_bit_masks(N, imms, immr, true) >> 64); + + if (opc & 1) + return 0; + + if (rd != CFI_SP) + return 0; + + *type = INSN_STACK; + + if (rn != CFI_SP) { + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + op->dest.reg = rd; + op->src.type = OP_SRC_REG; + op->src.offset = 0; + op->src.reg = rn; + } + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + op->dest.reg = rd; + + op->src.type = OP_SRC_AND; + op->src.offset = 0; + op->src.reg = rd; + + return 0; +} + int arm_decode_move_wide(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) { diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 65e60b293a07..6f68e8887cdb 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -16,6 +16,7 @@ #define INSN_PCREL 0b001 //0b00x #define INSN_ADD_SUB 0b010 #define INSN_ADD_TAG 0b011 +#define INSN_LOGICAL 0b100 #define INSN_MOVE_WIDE 0b101 #define INSN_BITFIELD 0b110 #define INSN_EXTRACT 0b111 @@ -38,6 +39,8 @@ int arm_decode_add_sub(u32 instr, enum insn_type *type, int arm_decode_add_sub_tags(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_logical(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_move_wide(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_bitfield(u32 instr, enum insn_type *type, From patchwork Thu Jan 9 16:02:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5FF3139A for ; Thu, 9 Jan 2020 16:11:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8395E20661 for ; Thu, 9 Jan 2020 16:11:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pPMgwz4t"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ak9Cvc9Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8395E20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=OGCMVRL8vAacCeCSASerl+LhloFb0ySx/5yCEicv5TA=; b=pPMgwz4tnJyVzv hipVJaL4e2/PwWmtL0Yh2VNYgNaKV3TXiXS62UuuZLVJmJoZYq30AhisyoTR2hRMTuuA8xnP+CnmQ kRu527MsRZ4fX2SYoIgnoP5RzpBCaaICi6ZxrrdBVoqQVBPs4BXgL75jXvoC/fwFGG1+XgvLqaP5R iNYY9rqvEctOnXEaghYpKtJcDw+GYGfm9+tOz1o+YNSg3vHnfEo1qY6PVk89CF8R8rx0wcjsgnVlK dFgoUck2+vD9oYBomNgGq9OwVQKeYJLStOLHHzXQpd0nwb1mGLj0Jb4CmVOMUmTqdRJvTyDMO+yNm /KYgCpeH/LY7b6JQuXJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaOl-00057s-ME; Thu, 09 Jan 2020 16:11:03 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaJk-0007UT-Rc for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585951; 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=3+FheDq2ZplLWH7Hscjh46HZP3eUOL/7yenw4GWEIA8=; b=ak9Cvc9Qp1WYhNAZNziScwJfCFiAWdGntUttazsik8LVSyAxZB0kQ1sINtG9ee3/V2zwCA RnZC6jamYOVKC3MAlF56ufERQzw3oJcDeX+RzZsjDALD9o/STWKel1RFImiOeIlIaEZB1n rl3VvpBXQ8WvrtAzonbN7d6jFbEnPIk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-NEEQEME-Ou6gzzIReLDJEA-1; Thu, 09 Jan 2020 11:05:49 -0500 Received: by mail-wm1-f72.google.com with SMTP id g26so618819wmk.6 for ; Thu, 09 Jan 2020 08:05:49 -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=yq+5KLGG8C3/es7UmF0OP8vHzerZYbNFdNiyqCT1ebc=; b=TVO0ouBb/g+LMxiCRzfmr3FFOKvuzzq/df4TVMntvGSfJUQ9KeCSbsmQFDm6b6prEz ylApNXCWyuF4PhN0jmIFIMoo08yvBXXA7lSVLCfDo0q9mdf1oZYRo586RoOJMjP1LqDX nxCtmNW871Fd1FTO3fy6MwnuJrj3eLCglwA0XUPVQftS5Bjt+O9MNghxxPgoBapSLmSL j3Kox1KE50arCSGgRmed5T7+Kji5/zkMglc34LSI02cB1yXyTSob2JlxWzXDfv1XgY1R GK63bttk0Y03vAkINfh9Rq+Hn1YuOAANF+8vyig02TgcjyXpWpJMeec6XtoljcggcE3j zAJA== X-Gm-Message-State: APjAAAVnzy5Y7yFR1TpJwsTXMLokzfrffpIKoo5BmHofkdM8abS97GB+ 2aIp/aFGCuFovuX3LKh6rgDx9rTtxcNJQ6wx5us8Q5zQAfGPLo8U5y85NRssOnqFnOa0IDmeBpP W0/PGpjkXhsC6wrvG46xQlC3KiZeoDx1c5ow= X-Received: by 2002:a5d:4e0a:: with SMTP id p10mr11575566wrt.229.1578585948471; Thu, 09 Jan 2020 08:05:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwLZVgpVj1PcTS0z5J40QUs6nyfbe/27huXPUr91QfNm91o6qPV2F2jQlHKmgq8A7M+M38/7A== X-Received: by 2002:a5d:4e0a:: with SMTP id p10mr11575528wrt.229.1578585948045; Thu, 09 Jan 2020 08:05:48 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id a16sm8545544wrt.37.2020.01.09.08.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:05:47 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 24/57] objtool: arm64: Decode system instructions not affecting the flow Date: Thu, 9 Jan 2020 16:02:27 +0000 Message-Id: <20200109160300.26150-25-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: NEEQEME-Ou6gzzIReLDJEA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080552_999312_7D019244 X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode basic system instructions that do not cause jumps or stack pointer modifications. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 95 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 23 +++++ 2 files changed, 118 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index a30c3294cc21..c38d73fb57e1 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -87,6 +87,7 @@ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_UNKNOWN] = arm_decode_unknown, [INSN_UNALLOC] = arm_decode_unknown, [0b1000 ... INSN_DP_IMM] = arm_decode_dp_imm, + [0b1010 ... INSN_SYS_BRANCH] = arm_decode_br_sys, }; /* @@ -391,3 +392,97 @@ int arm_decode_extract(u32 instr, enum insn_type *type, return arm_decode_unknown(instr, type, immediate, ops_list); } + +static struct aarch64_insn_decoder br_sys_decoder[] = { + { + .mask = 0b1111111111111111111111, + .value = 0b1100100000011001011111, + .decode_func = arm_decode_hints, + }, + { + .mask = 0b1111111111111111100000, + .value = 0b1100100000011001100000, + .decode_func = arm_decode_barriers, + }, + { + .mask = 0b1111111111000111100000, + .value = 0b1100100000000010000000, + .decode_func = arm_decode_pstate, + }, + { + .mask = 0b1111111011000000000000, + .value = 0b1100100001000000000000, + .decode_func = arm_decode_system_insn, + }, + { + .mask = 0b1111111010000000000000, + .value = 0b1100100010000000000000, + .decode_func = arm_decode_system_regs, + }, +}; + +int arm_decode_br_sys(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 decode_field = 0, op1 = 0; + unsigned char op0 = 0, op2 = 0; + int i = 0; + + op0 = (instr >> 29) & ONES(3); + op1 = (instr >> 12) & ONES(14); + op2 = instr & ONES(5); + + decode_field = op0; + decode_field = (decode_field << 19) | (op1 << 5) | op2; + + for (i = 0; i < ARRAY_SIZE(br_sys_decoder); i++) { + if ((decode_field & br_sys_decoder[i].mask) == + br_sys_decoder[i].value) { + return br_sys_decoder[i].decode_func(instr, + type, + immediate, + ops_list); + } + } + + return arm_decode_unknown(instr, type, immediate, ops_list); +} + +int arm_decode_hints(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + *type = INSN_NOP; + return 0; +} + +int arm_decode_barriers(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + /* TODO:check unallocated */ + *type = INSN_OTHER; + return 0; +} + +int arm_decode_pstate(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + /* TODO:check unallocated */ + *type = INSN_OTHER; + return 0; +} + +int arm_decode_system_insn(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + /* TODO:check unallocated */ + *type = INSN_OTHER; + return 0; +} + +int arm_decode_system_regs(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + /* TODO:check unallocated */ + *type = INSN_OTHER; + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 6f68e8887cdb..777a62f1a141 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -9,6 +9,7 @@ #define INSN_UNKNOWN 0b0001 #define INSN_UNALLOC 0b0011 #define INSN_DP_IMM 0b1001 //0x100x +#define INSN_SYS_BRANCH 0b1011 //0x101x #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) @@ -25,9 +26,17 @@ typedef int (*arm_decode_class)(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +struct aarch64_insn_decoder { + u32 mask; + u32 value; + arm_decode_class decode_func; +}; + /* arm64 instruction classes */ int arm_decode_dp_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_br_sys(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_unknown(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); @@ -47,4 +56,18 @@ int arm_decode_bitfield(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_extract(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); + +/* arm64 branch, exception generation, system insn subclasses */ +int arm_decode_hints(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_barriers(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_pstate(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_system_insn(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_system_regs(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91A6A139A for ; Thu, 9 Jan 2020 16:12:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5FEBD20661 for ; Thu, 9 Jan 2020 16:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="t0hVokNL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ehiFB4gO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FEBD20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=jVScanfkJi5WidFh/jwqVBW+BtZDTOF/xtgdZ7mSs4Q=; b=t0hVokNLbuVOiz s8yOJSWVgxqPizEqqYDSMcPrSIg7MdYrXnD+krpc3Mf1u3+LyYl22vBsuesV2AuCnxifJtyMTu1Ke sbo43+HKoUQkCfjo1pTAzFjN3EHyJJD3fGg+1kXuaxjTa6VBO4EskDGzUNFipXFnSUE2We37KPPzM 6YU5KlmZthaLgUjXTCywZPaJYW3C8zMm6N/3ieDxnbqb3MR/UxXmFKHvHkqYzWK6iQ0ZhoP8zt3IK aiY/FfoTu1OOzDJUuZF4jcV3HFS6avSBeozSKEEe0oDOIzR4Of3DOzHcjz/JHVUr07w9VEqD9uDuH 6bZE9PPCvfFCZJar9mMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaPr-00064T-1P; Thu, 09 Jan 2020 16:12:11 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKG-0007uE-85 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585982; 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=Cg04LeivDqCyzx2mah0zKMuO/OHMVXi2xzNv/WSk8HU=; b=ehiFB4gOSXsWS8SLZoH9PG9Mrcehow47fAx1iQP6mtC7vvLATn3Eojwrev7ZrAcIMeRfus PWUZrFzdhla/D0JwUA5YokO8vagtbXQ7rlUn5fTXuSovkODJ+eLbIKHS1/TUX1kgcMPBkN eq8sqxPFgnKbWycq3gye+g3Qa+u4zNY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-XT7vV1PiNzK6TgT5WZy-PQ-1; Thu, 09 Jan 2020 11:06:21 -0500 Received: by mail-wm1-f71.google.com with SMTP id p2so1102488wma.3 for ; Thu, 09 Jan 2020 08:06:21 -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=59aS99No1krrXfIWCRAYZAAd//TqWaD8qP5fyW3sdMg=; b=Ny83KpQ6hnAIR/zp1rR53dlBi1GKlTZAm3bOYJZTIUDvAl+NCO1v8rWhENBZWQJajM /UtArNMzORstkK+4+OBXJTf1FS2DWaWg9LvNnFJBCFiMI7zIjiRRiwvEZojxHli9fJU2 YMabZDzHWcuyBtaOPjGJkPeYbyehmgH0pQmzwzV8vq0JwkMly5wQzc0yqt90DAB3YV+E UZ5zvgvDdty65AVSdO1xtD1sJEr5LIhtalMAEjCmPCTLu7UJM9+8mQM9AsDhHlUgs4b1 K9dwv8jaBpRI2+Q8WX9cFq7E+/K8GpOiu4wGukvgT8CAeFQRQxNxGb0LINpT/V7EFuMa nkhg== X-Gm-Message-State: APjAAAWu8CdlgPFtPGDN8ADFwINKYnH9SGx7Ky2idLxfloVKvIwb+MUb RWpG52u3ZxpCLZ56TDkVlugaDGSnqUucMTeNgn7bDRZu3rI5/bQT3i4S+F8WA6wjZ22p/zMW9eU 16ZPb4NPmr8o3BKhQRD2QralVGWnvEdMuqXM= X-Received: by 2002:a1c:4e10:: with SMTP id g16mr5663402wmh.94.1578585980288; Thu, 09 Jan 2020 08:06:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyjRFkbMIepr4wXf1QqLfVFyAf3vdn/APW9YXTZqFn1HcPM1Jr3zmviIV97H+YUovcevsWwVA== X-Received: by 2002:a1c:4e10:: with SMTP id g16mr5663373wmh.94.1578585980101; Thu, 09 Jan 2020 08:06:20 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e18sm8643101wrr.95.2020.01.09.08.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:19 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 25/57] objtool: arm64: Decode calls to higher EL Date: Thu, 9 Jan 2020 16:02:28 +0000 Message-Id: <20200109160300.26150-26-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: XT7vV1PiNzK6TgT5WZy-PQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080624_412875_5D03DCEF X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions that volontarily trigger exceptions to a higher exception level. It is assumed that the higher exception level should service the request in a sane maner, returning to the caller exception level without altering its context too much (e.g. not modifying the PC, the stack pointer or the frame pointer). Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 45 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 2 + 2 files changed, 47 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index c38d73fb57e1..aa00de725686 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -419,6 +419,11 @@ static struct aarch64_insn_decoder br_sys_decoder[] = { .value = 0b1100100010000000000000, .decode_func = arm_decode_system_regs, }, + { + .mask = 0b1111100000000000000000, + .value = 0b1100000000000000000000, + .decode_func = arm_decode_except_gen, + }, }; int arm_decode_br_sys(u32 instr, enum insn_type *type, @@ -486,3 +491,43 @@ int arm_decode_system_regs(u32 instr, enum insn_type *type, *type = INSN_OTHER; return 0; } + +int arm_decode_except_gen(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 imm16 = 0; + unsigned char opc = 0, op2 = 0, LL = 0, decode_field = 0; + + imm16 = (instr >> 5) & ONES(16); + opc = (instr >> 21) & ONES(3); + op2 = (instr >> 2) & ONES(3); + LL = instr & ONES(2); + decode_field = (opc << 5) | (op2 << 2) | LL; + +#define INSN_SVC 0b00000001 +#define INSN_HVC 0b00000010 +#define INSN_SMC 0b00000011 + + switch (decode_field) { + case INSN_SVC: + case INSN_HVC: + case INSN_SMC: + /* + * We consider that the context will be restored correctly + * with an unchanged sp and the same general registers + */ + *type = INSN_NOP; + return 0; + default: + return arm_decode_unknown(instr, type, immediate, ops_list); + } + +#undef INSN_SVC +#undef INSN_HVC +#undef INSN_SMC +#undef INSN_BRK +#undef INSN_HLT +#undef INSN_DCPS1 +#undef INSN_DCPS2 +#undef INSN_DCPS3 +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 777a62f1a141..a55dcbfcfed2 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -70,4 +70,6 @@ int arm_decode_system_insn(u32 instr, enum insn_type *type, int arm_decode_system_regs(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_except_gen(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 832A71395 for ; Thu, 9 Jan 2020 16:12:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5304220661 for ; Thu, 9 Jan 2020 16:12:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o8zSs4Yp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IMYWAiSm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5304220661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=JESEaEzzliC3dMj6EWj6FuiiGwgfF7I3zbOvhFgVj/4=; b=o8zSs4Ypf5xgVT Pdg9QXFJ/KbUlaPUJGFZAbKvBVZqE99L+K7pvBGITxYfdyIs2Y6pfNRJfwi3YtrgCo8hwsCiinDph 6XuJhhSv18dTK0kwQ09yOLLubtZMiiFTqRaetBQxMYPOBD3oF6t+EFhKASoWibJ8EQUiA/9qkIBD2 d2NajBmNOPj7F53vysL+Hw+1BaO/bLlI11UPnS1PE+WW7NsC5N23teQDUQWJaoZBtENzENtSPHv4W mdzuwfo7Lf3IEeXJYa2IG2wc93wSdl+g9Ga5uAxdE+5MUcZHDwbhS3Rd266PWbPHjvm2MiZxM/BzC 0xJrrzbT0y8XRpetQURw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaQV-0006d5-LX; Thu, 09 Jan 2020 16:12:51 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKK-0007vH-8T for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585983; 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=2G/c7GPowFok5ALwyk1F5fUboM78XmAHyRYoMCK7uzU=; b=IMYWAiSmiQ/pLNRxU5Cbw3UAiesWuaU7dShSYrdwWyk0JgPBojt7bydNpCoFL7irJm9uUx DwWGdKPE4WoCQvP1S3mBGg7QR4V1Mc+LKgAezYH/wKPy3yiY80oYWl0qbDDWbL0wVhpClV sgDANf69XBVMLdgChVCwtDWNBi+BdFg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-6WttVQ6AM5WnQAll9BTE1Q-1; Thu, 09 Jan 2020 11:06:22 -0500 Received: by mail-wr1-f71.google.com with SMTP id d8so3035573wrq.12 for ; Thu, 09 Jan 2020 08:06:22 -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=FgwSNSqS6px8jp3jNYPpBzj7QjkDMZcWf7jBSHIJiCU=; b=M/FCv35MF4zG7XJMKl9S1WJffWIVvcfNrTGlyCvtkEIhifl15B5O9m0SKy2PCVnGL5 Qr+lD4VYBG+hUbUHdUOgM4i8pgc5LZUDHzjGPF+TmIXidxkUokgBy3AXRMK4fl/HF6bV wBpooY3o1zV4FR0uLDmN5A/y5zo0dNSOqH07/P9zDI8OeVfpZVMysRFtCHfmeJyuW7Fj ZSXyoVVmj+Dgyg7qkBPTn+3UW1pXDx8b8f2UCluYDZw2uxQDLlEZNClX+XDHWsawo/PB IKUQ+xvoivz08V5FLcCw7E4ed4SNV8JIeZHQ88V0kUN7PCaiH/eFFnmk0Yov395eyjpr egWw== X-Gm-Message-State: APjAAAXvrJ56PvfeT22PP9gJTT0zoT3cR+BHCkDxaO3arvMaLKRGpSHt eFHA+ubB7q8Kfp5qA6zd7zH0IIo8JmMxL/d7lLkEHtYwqfLgOvza7BueLWcPnSSHimAAEJ4nC2v P4mHn+JAdKimMWRnm2JKcfx3rHy7vRNOM0cQ= X-Received: by 2002:a7b:cd07:: with SMTP id f7mr5555833wmj.37.1578585981649; Thu, 09 Jan 2020 08:06:21 -0800 (PST) X-Google-Smtp-Source: APXvYqz3pweoOYbsv4OP48X37FSBCDstfv+4OYIDJH8H8/t6Mr+whcukViSF0ZLbVNz5xhoyBsMETg== X-Received: by 2002:a7b:cd07:: with SMTP id f7mr5555817wmj.37.1578585981473; Thu, 09 Jan 2020 08:06:21 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e18sm8643101wrr.95.2020.01.09.08.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:20 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 26/57] objtool: arm64: Decode brk instruction Date: Thu, 9 Jan 2020 16:02:29 +0000 Message-Id: <20200109160300.26150-27-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 6WttVQ6AM5WnQAll9BTE1Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080628_381306_ABAF363B X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add decoding brk instructions. Associate known immediate values with their kernel/compiler semantics. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index aa00de725686..1609750cc4b9 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -507,6 +507,7 @@ int arm_decode_except_gen(u32 instr, enum insn_type *type, #define INSN_SVC 0b00000001 #define INSN_HVC 0b00000010 #define INSN_SMC 0b00000011 +#define INSN_BRK 0b00100000 switch (decode_field) { case INSN_SVC: @@ -518,6 +519,38 @@ int arm_decode_except_gen(u32 instr, enum insn_type *type, */ *type = INSN_NOP; return 0; + case INSN_BRK: + /* Based on arch/arm64/include/asm/brk-imm.h */ + switch (imm16) { + case 0x004: /* KPROBES_BRK_IMM */ + case 0x005: /* UPROBES_BRK_IMM */ + case 0x400: /* KGDB_DYN_DBG_BRK_IMM */ + case 0x401: /* KGDB_COMPILED_DBG_BRK_IMM */ + *type = INSN_OTHER; + break; + case 0x800: /* BUG_BRK_IMM */ + /* + * brk #0x800 is generated by the BUG()/WARN() linux API + * and is thus a particular case. Since those are not + * necessarily compiled in, the surrounding code should + * work properly without it. We thus consider it as a + * nop. + */ + *type = INSN_NOP; + break; + case 0x3e8: + /* + * Similar to the use of "ud2" on x86, GCC inserts + * "brk #0x38e" instructions for certain divide-by-zero + * cases. + */ + *type = INSN_BUG; + break; + default: + *type = INSN_CONTEXT_SWITCH; + break; + } + return 0; default: return arm_decode_unknown(instr, type, immediate, ops_list); } From patchwork Thu Jan 9 16:02:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A183139A for ; Thu, 9 Jan 2020 16:12:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EACDA20661 for ; Thu, 9 Jan 2020 16:12:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HmMs+RIa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="espufZzu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EACDA20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=HjanM//+zgpRXeGnXUpMmap32m1qdMiQS0b7zLQorVI=; b=HmMs+RIaFi/MMW 4WOZcqJNcfuH/fwQPs8yMNRyPuHO9bmGLotIJBfdDUSsKqdb26f8KABEtXtIzpWgbn11uexs214TU 7lBiBDgwJ1rNPwqXkowMrGiF6jxXY4JFYwd8VSQAgOfBGr8Gom/RYnE0ee3GMIzEc6oWnfmyZZ4/C amHMmscapPGnZFh4hc4foyrD/ETcNtAS/TFqkabH7opjZ1NbO10/q0D+UJWGviQ2RDywuELWZNbCC Y59rC1HkDwV2Da/UPgd9xm981aMO6WCbHM6fZJ8f6cn0Mrz1aleVK+NFXNPMNc96vGIVLq55p12Na +vG39TuSxOPkg2vv7Agg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaQF-0006P5-40; Thu, 09 Jan 2020 16:12:35 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKJ-0007xw-1Y for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585985; 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=2idOYVbFUu8UYWjig8IIHjgpdBbgTVkfK7tIeXEZk8w=; b=espufZzuc/NsM4Efm6qptHC8sj8P/YQRxLsbWAuHagCsviRaVglFV6Dt0unsAY3X9Ffqni Wd4iKgDykN7fPSQHmZm3Drwgso0hl2uMd3tyDvotEys81TQuSGMheYNcodamlp64M/FYFs eJD8yenfUHCHCygC952eIHcCScJdd6c= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-KuzAGEg_N_KCJu7e_3AtrQ-1; Thu, 09 Jan 2020 11:06:24 -0500 Received: by mail-wm1-f69.google.com with SMTP id h130so1094331wme.7 for ; Thu, 09 Jan 2020 08:06:24 -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=HNhyss2u9SsGVYYccTk/iU0pIIQIcXT3bxVXb0UyHWg=; b=RXJd+KAqdhAOEA4QHYMu8R5xZtv1tIf7NFNrcGEplRIDZsOSd+bYKNa4cmS1ODE0xc goq+X8s5yOSWu8CO8Ay1LnpYx3UZBi3FV4LdF0+/hm5DBQMhXzPxYB4TFVA3Ylu2V4Le V98ow8KurFGWqXu0dW3WyX9cL5TlaJVtDcxRyBek5dKeZFj24NcgIJw52W/0OMzDVuE6 vSegijSjvAIyJWCAfMoQoHyB0V8DdpdFVYocqWPBpkaZE16quFrjOKewCYUm7K4M1hWB 5X0P14PdP8Oa9GvdSA+aJvk+eVaCuaGyHCguEAKeuW+9dV9bpoq3QZJbUPOaw3nQYui5 0kyA== X-Gm-Message-State: APjAAAUO2I6xhSWK2qiGU/S6NqFWJkwSlHt0JUwP/If1jADF565+6DWk L7pEAfTWz+IQ0q6b2iWzc8+YW+UQqnUDFLWa0UH9YtsVrAcCNB7GdYk+iDEIncvYdgxZyV/SjKf Sv+dGCo+UvfmpxCYFKavaIDFDnEH8it/5pp8= X-Received: by 2002:adf:f10a:: with SMTP id r10mr11698854wro.202.1578585983152; Thu, 09 Jan 2020 08:06:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwfuKPzYnuaQfyIgBEkCdvvo1v0X3eOw5Mldms4E6Ry3uTgyBQ8xNyJC89tB0eee772rraRfA== X-Received: by 2002:adf:f10a:: with SMTP id r10mr11698826wro.202.1578585982936; Thu, 09 Jan 2020 08:06:22 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e18sm8643101wrr.95.2020.01.09.08.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:22 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 27/57] objtool: arm64: Decode instruction triggering context switch Date: Thu, 9 Jan 2020 16:02:30 +0000 Message-Id: <20200109160300.26150-28-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: KuzAGEg_N_KCJu7e_3AtrQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080627_170118_229314CE X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions that volutarily trigger an exception to change the context of execution. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 1609750cc4b9..5eba83c5d5bc 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -508,6 +508,10 @@ int arm_decode_except_gen(u32 instr, enum insn_type *type, #define INSN_HVC 0b00000010 #define INSN_SMC 0b00000011 #define INSN_BRK 0b00100000 +#define INSN_HLT 0b01000000 +#define INSN_DCPS1 0b10100001 +#define INSN_DCPS2 0b10100010 +#define INSN_DCPS3 0b10100011 switch (decode_field) { case INSN_SVC: @@ -551,6 +555,13 @@ int arm_decode_except_gen(u32 instr, enum insn_type *type, break; } return 0; + case INSN_HLT: + case INSN_DCPS1: + case INSN_DCPS2: + case INSN_DCPS3: + *immediate = imm16; + *type = INSN_CONTEXT_SWITCH; + return 0; default: return arm_decode_unknown(instr, type, immediate, ops_list); } From patchwork Thu Jan 9 16:02:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DAE91395 for ; Thu, 9 Jan 2020 16:13:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0B12F206ED for ; Thu, 9 Jan 2020 16:13:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ipvVO8+W"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="egMSxT1o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B12F206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=et7yWr5LfG4Te29SAXMdkxdMoVROdRWD7TciuO1zGTY=; b=ipvVO8+WYIoVBg LT+57jDesldjFDu+so3lXowAmBGdWU1UowAdVFxWmVfk6qKxcY2UcJABPtAiDtZvkMKJksyJich3j hmDhpP0ZnG79akSzJB83wmSk8UFLQWlGswjU52odKQ1Meg9CxVEvQAKKvQe7+fjGYvfN5MFsJWYJg B++9MS+sSacmDfjjdbBdo0mZK5zIoAWynFSg/HQ8gI4T3BdJBLndky4TCOkSR+WG3yXWVR1yRT2xE IWJbXcaOboBPcEFHhRQzxdwuaCG+ysMLX6XHxzLOcqyC70cvMddgaYkohcqEKlSPE20A8+DKgdihl Y9azpPOY6YIF1aLeH6Wg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaQk-0006sL-Py; Thu, 09 Jan 2020 16:13:06 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKO-00082N-6S for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585990; 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=tlQRkFiwtOzDsnF1EvmrQl/6BVM4mJGyHhan4vNK2JU=; b=egMSxT1ojSXQOE3UzrJdRBqE21wPBts+Q0HOZJ4hyw1NfabaCJ3oSjciCj3DmfPnV5+yfY q8dmapjLEyvlAjpUt412CwDqwlf84RD22pA4FDK8+fiLjT+u/fsxFd/JLpIzYyR4NBCY2R LEq00RwSiJrRhLYK/jRgF5N1FkHfyOY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-vdmisrpVM3qaXn4RHFGepA-1; Thu, 09 Jan 2020 11:06:26 -0500 Received: by mail-wm1-f71.google.com with SMTP id t17so618165wmi.7 for ; Thu, 09 Jan 2020 08:06:26 -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=J63NkwzczmrLcPGsOIe2c0tfTD5HWt1z/wmViklA3es=; b=p+Ss6gTSwwJpM6a15njb7ihs7euNFFPvkPDQa4w64ES9oRfhxuwy1fZ27npF0+bVfP 9hkL5/UjLAZVrtgFwxAY7bik4Usy9aS7C7DPHUEOBmbRXGTDcwbZV3NkUqc3c9UFYjR9 6+UOoqmC3ynSGNJtK9On2znZ0jOVeJ12IGFIHdxHLZLzKR5E9Lb3MxSJfqURSXP/Kz1e zvaueClzG9TK6go1hsCTlISHyj2Mk35hrbpVmIUDVTlayIKSnGWf/0ZbKXOfVi4EqTEy QunAPPi4sWC8P0aldA8G2vTx7sUHtnSrzqgLVZ8u5Fu3Zv4RUGuE2KGzzuOtoQS41eo0 Vx0Q== X-Gm-Message-State: APjAAAUAbBBifD3NOcyhPi9RGVEzcCyW2O9/sC42vkjNwwWWY8HX5fqi q491Wfoket5MXFh/J35YK5c3etMJUw2omQL2f85htjDmD2P7LsCvLT2U9nLO9RUE8dZNRPzEiFm XcqGHy6S04LbCYl459IX4b6jXop+hFwo8lms= X-Received: by 2002:a5d:4ed0:: with SMTP id s16mr11380323wrv.144.1578585985410; Thu, 09 Jan 2020 08:06:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxG3LuVTogmg7FJSWlNc329KhrNkP0B6SiHOu3F08s0s+2V12EeNGQmM0ARlcnccvAJXUA4Ew== X-Received: by 2002:a5d:4ed0:: with SMTP id s16mr11380293wrv.144.1578585985185; Thu, 09 Jan 2020 08:06:25 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e18sm8643101wrr.95.2020.01.09.08.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:24 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 28/57] objtool: arm64: Decode branch instructions with PC relative immediates Date: Thu, 9 Jan 2020 16:02:31 +0000 Message-Id: <20200109160300.26150-29-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: vdmisrpVM3qaXn4RHFGepA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080632_425352_4A514D43 X-CRM114-Status: GOOD ( 10.50 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions that cause a jump in the execution flow, adding an immediate value to the current instruction counter. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 79 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 11 +++ 2 files changed, 90 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 5eba83c5d5bc..7986ded8b622 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -424,6 +424,26 @@ static struct aarch64_insn_decoder br_sys_decoder[] = { .value = 0b1100000000000000000000, .decode_func = arm_decode_except_gen, }, + { + .mask = 0b1111000000000000000000, + .value = 0b0100000000000000000000, + .decode_func = arm_decode_br_cond_imm, + }, + { + .mask = 0b0110000000000000000000, + .value = 0b0000000000000000000000, + .decode_func = arm_decode_br_uncond_imm, + }, + { + .mask = 0b0111000000000000000000, + .value = 0b0010000000000000000000, + .decode_func = arm_decode_br_comp_imm, + }, + { + .mask = 0b0111000000000000000000, + .value = 0b0011000000000000000000, + .decode_func = arm_decode_br_tst_imm, + }, }; int arm_decode_br_sys(u32 instr, enum insn_type *type, @@ -575,3 +595,62 @@ int arm_decode_except_gen(u32 instr, enum insn_type *type, #undef INSN_DCPS2 #undef INSN_DCPS3 } + +int arm_decode_br_cond_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char o0 = 0, o1 = 0; + u32 imm19; + + o0 = EXTRACT_BIT(instr, 4); + o1 = EXTRACT_BIT(instr, 24); + imm19 = (instr >> 5) & ONES(19); + + *immediate = SIGN_EXTEND(imm19 << 2, 19); + + if ((o1 << 1) | o0) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_JUMP_CONDITIONAL; + + return 0; +} + +int arm_decode_br_uncond_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char decode_field = 0; + u32 imm26 = 0; + + decode_field = EXTRACT_BIT(instr, 31); + imm26 = instr & ONES(26); + + *immediate = SIGN_EXTEND(imm26 << 2, 28); + if (decode_field == 0) + *type = INSN_JUMP_UNCONDITIONAL; + else + *type = INSN_CALL; + + return 0; +} + +int arm_decode_br_comp_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 imm19 = (instr >> 5) & ONES(19); + + *immediate = SIGN_EXTEND(imm19 << 2, 21); + *type = INSN_JUMP_CONDITIONAL; + return 0; +} + +int arm_decode_br_tst_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 imm14 = (instr >> 5) & ONES(14); + + *immediate = SIGN_EXTEND(imm14 << 2, 16); + *type = INSN_JUMP_CONDITIONAL; + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index a55dcbfcfed2..ceb80a58c548 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -72,4 +72,15 @@ int arm_decode_system_regs(u32 instr, enum insn_type *type, struct list_head *ops_list); int arm_decode_except_gen(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_br_uncond_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_br_comp_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_br_tst_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); +int arm_decode_br_cond_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28265139A for ; Thu, 9 Jan 2020 16:13:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EBA18206ED for ; Thu, 9 Jan 2020 16:13:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hLHD18u/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f86zNbuf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBA18206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=8oFYADSbb8kC+0j3algdgjAq9/vbur+wqd4gRDYxirc=; b=hLHD18u/bO4Rg3 tK5f0y52A6JfqwNCcdf15wumvRHHXBrBbVJTyZu1TkrTgipQPLWt8FHfZzIY6AqsLKUy391NNyYLn wAyu7tDoQ5JWls4WUqqYIDbuPqBDW9mrPy/B2DbxeEc/akx4HmswgPUI0xK8Ct1XDWsHaF/FtaSja k+32twIkZQmv/MaS3wfzE7bPdGPQ9Bwt7uWKkCprElv8fX/P1w1NUGKIe6tJSxiObgtv/cSk7w7oT bhS4USXtfyk0ux9TXY/YbY8iC7Lhci/r4/uzhgZmxmFXb9oQ3QcdduE4xAEx0AnbKSzNZImPw3W5I 8nriFZq6RXxjzEjItXZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaR1-0007DZ-5N; Thu, 09 Jan 2020 16:13:23 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKP-00083F-CL for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:06:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578585991; 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=lff3/TR6Gb5NqDs05d1xwkpfdI5PSaFFzDQEvi96bk0=; b=f86zNbuftjnQ5oPhOj5L4DMnvRdzfrfJ0WqP4XAr2qzXADxmt47oafjW0njFnbDPNlCrfA zg4XbNKMuEdYjprqD9X/l1CzliE6OZqOTMg3tlUEgHeCel1AIwfXwh0pd/V/HVuVgiEXMJ 1C7u0pWQFNTn9zeymP6UAvc+7deYXxM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-6IxzOp-7MhqiRXpXkx24ZQ-1; Thu, 09 Jan 2020 11:06:27 -0500 Received: by mail-wr1-f69.google.com with SMTP id f15so3077491wrr.2 for ; Thu, 09 Jan 2020 08:06:27 -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=tp6JL9rGP8VcGeIdUkesp1xLP6ts4YGw1IAU9COITC4=; b=kEucIgWkzTd8sO5wmHSXR9uEWAmwTP2VGwIh+ssK2cmSj0uVrKpKkoUVEcsuW4yxp1 ilV3aNpEDp5LZw0KOUa0u/uNDDKPeyL90pSBsItWLV9eRWO2jARJA6E6IMqbpOMxmGLS 0kiXki7EPonGf33kmyzux65iWLDpvVNOjcqfbaYTI2dQzIpK8oDSbM+tRU1c0kFYQwBh CHfoqNlhNbXvAvjqwMcBKwzycLsLa8V3WPq7xk+7KgQpPGUjOASWLOyUIAmt5Jb0JPOK hGDUEEhbmWxpsTHX2G9AULaccCf5xPf1FX+d2Rd+3rCOxBxyiJ0gh1I3obWpbPdKjU5Q 51SA== X-Gm-Message-State: APjAAAW0vclqf32ne22wG9vKNB9Kz4pntTzcBI5laSlsstfsoaS5Jv10 UBWi/twNjzh1eLhJHy58xTMdSQhE9rQi7q/7XCdQwkIsU93INiEeaPX8ruiH7QtQPeEx6zzMkHD s0szlYSQD8rpfreE9wmxGH3G9pRX9n5Cuius= X-Received: by 2002:a05:600c:2215:: with SMTP id z21mr5990741wml.55.1578585986754; Thu, 09 Jan 2020 08:06:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxEYx+b+ZCp2ZXGZSAYjmTHkSxr4PiMHPsV7FrExWj8/adU6yZ5L8AF6L4WgU01bYY7ltzeEg== X-Received: by 2002:a05:600c:2215:: with SMTP id z21mr5990707wml.55.1578585986501; Thu, 09 Jan 2020 08:06:26 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e18sm8643101wrr.95.2020.01.09.08.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:25 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 29/57] objtool: arm64: Decode branch to register instruction Date: Thu, 9 Jan 2020 16:02:32 +0000 Message-Id: <20200109160300.26150-30-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 6IxzOp-7MhqiRXpXkx24ZQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080633_509339_337D2EB7 X-CRM114-Status: GOOD ( 11.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions producing jumps in the execution flow, taking the value of their operand register as the target address. Return instructions are just branch to register instruction with the link register (x31) as implicit operand. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 150 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + 2 files changed, 153 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 7986ded8b622..bf9334451b40 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -444,6 +444,11 @@ static struct aarch64_insn_decoder br_sys_decoder[] = { .value = 0b0011000000000000000000, .decode_func = arm_decode_br_tst_imm, }, + { + .mask = 0b1111000000000000000000, + .value = 0b1101000000000000000000, + .decode_func = arm_decode_br_uncond_reg, + }, }; int arm_decode_br_sys(u32 instr, enum insn_type *type, @@ -654,3 +659,148 @@ int arm_decode_br_tst_imm(u32 instr, enum insn_type *type, *type = INSN_JUMP_CONDITIONAL; return 0; } + +static struct aarch64_insn_decoder ret_decoder[] = { + /* + * RET, RETAA, RETAB + */ + { + .mask = 0b1111111111111110000011111, + .value = 0b0010111110000000000000000, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111111111111111, + .value = 0b0010111110000101111111111, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111111111111111, + .value = 0b0010111110000111111111111, + .decode_func = NULL, + }, +}; + +static struct aarch64_insn_decoder br_decoder[] = { + /* + * BR, BRAA, BRAAZ, BRAB, BRABZ + */ + { + .mask = 0b1111111111111110000011111, + .value = 0b0000111110000000000000000, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000011111, + .value = 0b0000111110000100000011111, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000011111, + .value = 0b0000111110000110000011111, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000000000, + .value = 0b1000111110000100000000000, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000000000, + .value = 0b1000111110000110000000000, + .decode_func = NULL, + }, +}; + +#define INSN_DRPS_FIELD 0b0101111110000001111100000 +#define INSN_DRPS_MASK 0b1111111111111111111111111 + +static struct aarch64_insn_decoder ct_sw_decoder[] = { + /* + * ERET, ERETAA, ERETAB + */ + { + .mask = INSN_DRPS_MASK, + .value = 0b0100111110000001111100000, + .decode_func = NULL, + }, + { + .mask = INSN_DRPS_MASK, + .value = 0b0100111110000101111111111, + .decode_func = NULL, + }, + { + .mask = INSN_DRPS_MASK, + .value = 0b0100111110000111111111111, + .decode_func = NULL, + }, +}; + +static struct aarch64_insn_decoder call_decoder[] = { + /* + * BLR, BLRAA, BLRAAZ, BLRAB, BLRABZ + */ + { + .mask = 0b1111111111111110000011111, + .value = 0b0001111110000000000000000, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000011111, + .value = 0b0001111110000100000011111, + .decode_func = NULL, + }, + { + 0b1111111111111110000011111, + 0b0001111110000110000011111, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000000000, + .value = 0b1001111110000100000000000, + .decode_func = NULL, + }, + { + .mask = 0b1111111111111110000000000, + .value = 0b1001111110000110000000000, + .decode_func = NULL, + }, +}; + +int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + u32 decode_field = 0; + int i = 0; + + decode_field = instr & ONES(25); + *type = 0; + for (i = 0; i < ARRAY_SIZE(br_decoder); i++) { + if ((decode_field & br_decoder[i].mask) == br_decoder[i].value) + *type = INSN_JUMP_DYNAMIC; + } + for (i = 0; i < ARRAY_SIZE(call_decoder); i++) { + if ((decode_field & call_decoder[i].value) == + call_decoder[i].value) + *type = INSN_CALL_DYNAMIC; + } + for (i = 0; i < ARRAY_SIZE(ret_decoder); i++) { + if ((decode_field & ret_decoder[i].mask) == + ret_decoder[i].value) + *type = INSN_RETURN; + } + for (i = 0; i < ARRAY_SIZE(ct_sw_decoder); i++) { + if ((decode_field & ct_sw_decoder[i].mask) == + ct_sw_decoder[i].value) + *type = INSN_CONTEXT_SWITCH; + } + if ((decode_field & INSN_DRPS_MASK) == INSN_DRPS_FIELD) + *type = INSN_OTHER; + if (*type == 0) + return arm_decode_unknown(instr, type, immediate, ops_list); + return 0; +} + +#undef INSN_DRPS_FIELD +#undef INSN_DRPS_MASK diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index ceb80a58c548..6e600f408bea 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -83,4 +83,7 @@ int arm_decode_br_tst_imm(u32 instr, enum insn_type *type, int arm_decode_br_cond_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D43D139A for ; Thu, 9 Jan 2020 16:13:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5B0DA20661 for ; Thu, 9 Jan 2020 16:13:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ql1bcxks"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KhR32D/U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B0DA20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=JtPwCswLEjTHLSlWXXl+gjx7s4ZtUE2+0ir8FhEcVco=; b=Ql1bcxksxQONtF Yg1t2kGqSVV7wmnfNmJvfb1JvauP2xvAZboAcK5ZTo8yoh3BGJP50CvYsTCdq+LJ8uGNuhVKMGtva LMu8/lOGzd5Jg9VpmdBagi1D+4mVh5YHruKNdFNdISyKkdl6CZQ4r3O447GzkbX7oY0H4USrMf0pJ 5iFy8j0+d6GKLWmxF6pAM2JcBixzS00v/Xs4+yzEkngqz+/xde3bsiZdwbKtJb7CiersSwMk8o0bW 9Bkcfs4thObmjlCRlcCY8FpRarQFied/8hJPXA08mH3szI+epRmC1Ag6XEwaPr+sOpxHzACAhlGiQ 0JbM8lHUux9Witkzvsyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaRU-0007ff-NA; Thu, 09 Jan 2020 16:13:52 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKt-00008t-V7 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586022; 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=wyTEMibBQu6x8w66/pYMCbRPxuRIPN3y9kqxG5xMsdw=; b=KhR32D/Uw/HObKXWpbuQxgZiJaFRhWA9dUd9xRJHnxnKs4cah5RpS2Nr+giR5NxC0gemSJ J2LuajUaihLwMGQAOhRNimc/o8Pz3DyCKkfUotT09XVTSMFP52Jo9+2oTPQ+UrKfjmoj9w G/Nm1rbAPUx28NMeJtqjcxLPu+YuIDc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-139-XqXaCSoGMa6ge_OkwIyVIA-1; Thu, 09 Jan 2020 11:07:00 -0500 Received: by mail-wr1-f69.google.com with SMTP id f10so3060450wro.14 for ; Thu, 09 Jan 2020 08:07:00 -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=/Xq2TYaoyKIaoZWWIj0lFf3WygPVLaBw/8+8QDSMChc=; b=QOzHNrHZZ6AbEoBFQmKHQPyeYDHvUIU/IZTOONlHr0sSf3OIq3uFZgJ4b7hGii+bQA TqlAj/YpVEmpvc5goY+64b2/NI7eM5lxY48t6i4KyeAauC5e7a3a/05xrtz9UJSNtSLL 49GLHCrke8H8eiOi5s7TtJtQg7AdWDUrq+iS1rICsD519aU4RwN4b3XfjZUEiFOWiSIr 7/O/vpBiHNcTLtXx9Q5ACCFJsZpAzHwhIlamvW/C6Ch/AGz7QbrkELnn2OnFnGvVKKUy tLe+T6b4HqTLzaiJpr2x0AG6ZhboTJXXIzEAwJNq1dcAy1OaplHhPTOML7YkZZDRxviZ x1ng== X-Gm-Message-State: APjAAAUkwoDmPKm/urR9c4euBwIaKVVD5C7nc77iaVoOloaZ3EF9RUbH uE5qkVCMK/d85+YQJDHYwbBqkGnCY0/QXUOqObsn6WJYhy4wHsttwEGS4R1blddp4i7tXJ6BFmT NzcJsEtz9nyLGQnERBvwe+WO9NpunH6u62b0= X-Received: by 2002:a1c:28d4:: with SMTP id o203mr5725788wmo.123.1578586019456; Thu, 09 Jan 2020 08:06:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzLoKJ+701qFfHV+IuL6JMCP1wXVIvF4aCLPHBdRsPum7P4wPgdei+sohgHerHSdwvNMk0qxA== X-Received: by 2002:a1c:28d4:: with SMTP id o203mr5725754wmo.123.1578586019116; Thu, 09 Jan 2020 08:06:59 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id q3sm9123252wrn.33.2020.01.09.08.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:58 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 30/57] objtool: arm64: Decode basic load/stores Date: Thu, 9 Jan 2020 16:02:33 +0000 Message-Id: <20200109160300.26150-31-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: XqXaCSoGMa6ge_OkwIyVIA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080704_201315_A81FC269 X-CRM114-Status: GOOD ( 10.98 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instructions for single register, using an immediate offset for the target address. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 396 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 23 + 2 files changed, 419 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index bf9334451b40..7064302416f4 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -86,8 +86,12 @@ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_RESERVED] = arm_decode_unknown, [INSN_UNKNOWN] = arm_decode_unknown, [INSN_UNALLOC] = arm_decode_unknown, + [INSN_LD_ST_4] = arm_decode_ld_st, + [INSN_LD_ST_6] = arm_decode_ld_st, [0b1000 ... INSN_DP_IMM] = arm_decode_dp_imm, [0b1010 ... INSN_SYS_BRANCH] = arm_decode_br_sys, + [INSN_LD_ST_C] = arm_decode_ld_st, + [INSN_LD_ST_E] = arm_decode_ld_st, }; /* @@ -804,3 +808,395 @@ int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, #undef INSN_DRPS_FIELD #undef INSN_DRPS_MASK + +static struct aarch64_insn_decoder ld_st_decoder[] = { + { + .mask = 0b001101010000011, + .value = 0b001100000000000, + .decode_func = arm_decode_ld_st_regs_unsc_imm, + }, + { + .mask = 0b001101010000011, + .value = 0b001100000000001, + .decode_func = arm_decode_ld_st_imm_post, + }, + { + .mask = 0b001101010000011, + .value = 0b001100000000010, + .decode_func = arm_decode_ld_st_imm_unpriv, + }, + { + .mask = 0b001101010000011, + .value = 0b001100000000011, + .decode_func = arm_decode_ld_st_imm_pre, + }, + { + .mask = 0b001101000000000, + .value = 0b001101000000000, + .decode_func = arm_decode_ld_st_regs_unsigned, + }, +}; + +int arm_decode_ld_st(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + u32 decode_field = 0; + int i = 0; + unsigned char op0 = 0, op1 = 0, op2 = 0, op3 = 0, op4 = 0; + + op0 = (instr >> 28) & ONES(4); + op1 = EXTRACT_BIT(instr, 26); + op2 = (instr >> 23) & ONES(2); + op3 = (instr >> 16) & ONES(6); + op4 = (instr >> 10) & ONES(2); + decode_field = (op0 << 3) | (op1 << 2) | op2; + decode_field = (decode_field << 8) | (op3 << 2) | op4; + + for (i = 0; i < ARRAY_SIZE(ld_st_decoder); i++) { + if ((decode_field & ld_st_decoder[i].mask) == + ld_st_decoder[i].value) { + return ld_st_decoder[i].decode_func(instr, + type, + immediate, + ops_list); + } + } + return arm_decode_unknown(instr, type, immediate, ops_list); +} + +int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + u32 imm9 = 0; + unsigned char size = 0, V = 0, opc = 0, rn = 0, rt = 0; + unsigned char decode_field = 0; + struct stack_op *op; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + + imm9 = (instr >> 12) & ONES(9); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + + decode_field = (size << 2) | (V << 2) | opc; + + switch (decode_field) { + case 0b01110: + case 0b01111: + case 0b11110: + case 0b11111: + case 0b10011: + case 0b11011: + case 0b10110: + case 0b10111: + return arm_decode_unknown(instr, type, immediate, ops_list); + case 26: + /* prefetch */ + *type = INSN_OTHER; + return 0; + case 1: + case 2: + case 3: + case 5: + case 7: + case 9: + case 10: + case 11: + case 13: + case 17: + case 18: + case 21: + case 25: + case 29: + /* load */ + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = SIGN_EXTEND(imm9, 9); + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + break; + default: + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = SIGN_EXTEND(imm9, 9); + op->src.type = OP_DEST_REG; + op->src.reg = rt; + op->src.offset = 0; + break; + } + + *type = INSN_STACK; + return 0; +} + +static struct aarch64_insn_decoder ld_unsig_unalloc_decoder[] = { + { + .mask = 0b01110, + .value = 0b01110, + }, + { + .mask = 0b10111, + .value = 0b10011, + }, + { + .mask = 0b10110, + .value = 0b10110, + }, +}; + +int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, opc = 0, rn = 0, rt = 0; + unsigned char decode_field = 0; + struct stack_op *op; + u32 imm12 = 0; + int i = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + + decode_field = (size << 3) | (V << 2) | opc; + for (i = 0; i < ARRAY_SIZE(ld_unsig_unalloc_decoder); i++) { + if ((decode_field & ld_unsig_unalloc_decoder[i].mask) == + ld_unsig_unalloc_decoder[i].value) { + return arm_decode_unknown(instr, type, + immediate, ops_list); + } + } + + imm12 = (instr >> 10) & ONES(12); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + + if (!stack_related_reg(rn) || decode_field == 26) { + *type = INSN_OTHER; + return 0; + } + + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + switch (decode_field) { + case 1: + case 2: + case 3: + case 5: + case 7: + case 9: + case 10: + case 11: + case 13: + case 17: + case 18: + case 21: + case 25: + /* load */ + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = imm12; + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + break; + default: /* store */ + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = imm12; + op->src.type = OP_DEST_REG; + op->src.reg = rt; + op->src.offset = 0; + } + + return 0; +} + +int arm_decode_ld_st_imm_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, opc = 0; + unsigned char decode_field = 0; + struct stack_op *op; + struct stack_op *post_inc; + int base_reg; + u32 imm9 = 0; + int ret = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + + imm9 = (instr >> 12) & ONES(9); + + decode_field = (size << 2) | (V << 2) | opc; + + if (decode_field == 0b11010) + return arm_decode_unknown(instr, type, immediate, ops_list); + + ret = arm_decode_ld_st_regs_unsigned(instr, type, immediate, ops_list); + if (ret < 0 || *type == INSN_OTHER) + return ret; + + op = list_first_entry(ops_list, typeof(*op), list); + if (op->dest.type == OP_DEST_REG_INDIRECT) { + base_reg = op->dest.reg; + op->dest.offset = 0; + } else if (op->src.type == OP_SRC_REG_INDIRECT) { + base_reg = op->src.reg; + op->src.offset = 0; + } else { + WARN("Cannot find stack op base"); + return -1; + } + + post_inc = malloc(sizeof(*post_inc)); + post_inc->dest.type = OP_DEST_REG; + post_inc->dest.reg = base_reg; + post_inc->src.reg = base_reg; + post_inc->src.type = OP_SRC_ADD; + post_inc->src.offset = SIGN_EXTEND(imm9, 9); + + list_add_tail(&post_inc->list, ops_list); + + return 0; +} + +int arm_decode_ld_st_imm_pre(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, opc = 0; + unsigned char decode_field = 0; + struct stack_op *op; + struct stack_op *pre_inc; + int base_reg; + u32 imm9 = 0; + int ret = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + + imm9 = (instr >> 12) & ONES(9); + + decode_field = (size << 2) | (V << 2) | opc; + + if (decode_field == 0b11010) + return arm_decode_unknown(instr, type, immediate, ops_list); + + ret = arm_decode_ld_st_regs_unsigned(instr, type, immediate, ops_list); + if (ret < 0 || *type == INSN_OTHER) + return ret; + + op = list_first_entry(ops_list, typeof(*op), list); + if (op->dest.type == OP_DEST_REG_INDIRECT) { + base_reg = op->dest.reg; + op->dest.offset = 0; + } else if (op->src.type == OP_SRC_REG_INDIRECT) { + base_reg = op->src.reg; + op->src.offset = 0; + } else { + WARN("Cannot find stack op base"); + return -1; + } + + pre_inc = malloc(sizeof(*pre_inc)); + pre_inc->dest.type = OP_DEST_REG; + pre_inc->dest.reg = base_reg; + pre_inc->src.reg = base_reg; + pre_inc->src.type = OP_SRC_ADD; + pre_inc->src.offset = SIGN_EXTEND(imm9, 9); + + list_add(&pre_inc->list, ops_list); + + return 0; +} + +#define LD_UNPR_UNALLOC_1 0b10011 +#define LD_UNPR_UNALLOC_2 0b11010 +int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, opc = 0, rn = 0, rt = 0; + unsigned char decode_field = 0; + struct stack_op *op; + u32 imm9 = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + + imm9 = (instr >> 12) & ONES(9); + + decode_field = (size << 3) | (V << 2) | opc; + if (V == 1 || + (decode_field & 0b10111) == LD_UNPR_UNALLOC_1 || + (decode_field & 0b11111) == LD_UNPR_UNALLOC_2) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } +#undef LD_UNPR_UNALLOC_1 +#undef LD_UNPR_UNALLOC_2 + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + *type = INSN_STACK; + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + switch (decode_field) { + case 1: + case 2: + case 3: + case 9: + case 10: + case 11: + case 17: + case 18: + case 25: + /* load */ + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = SIGN_EXTEND(imm9, 9); + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + break; + default: + /* store */ + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = SIGN_EXTEND(imm9, 9); + op->src.type = OP_DEST_REG; + op->src.reg = rt; + op->src.offset = 0; + break; + } + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 6e600f408bea..1e031b12cf69 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -10,6 +10,10 @@ #define INSN_UNALLOC 0b0011 #define INSN_DP_IMM 0b1001 //0x100x #define INSN_SYS_BRANCH 0b1011 //0x101x +#define INSN_LD_ST_4 0b0100 //0bx1x0 +#define INSN_LD_ST_6 0b0110 //0bx1x0 +#define INSN_LD_ST_C 0b1100 //0bx1x0 +#define INSN_LD_ST_E 0b1110 //0bx1x0 #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) @@ -37,6 +41,8 @@ int arm_decode_dp_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_br_sys(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_st(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_unknown(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); @@ -86,4 +92,21 @@ int arm_decode_br_cond_imm(u32 instr, enum insn_type *type, int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); + +/* arm64 load/store instructions */ +int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_imm_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_imm_pre(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6112139A for ; Thu, 9 Jan 2020 16:14:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 60F2020661 for ; Thu, 9 Jan 2020 16:14:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WUE4t35U"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c1mS/1/U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60F2020661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=HjQKkAZeLZ5QVfwOmef7hmqp3IVCx5w3L2TZZcwGWSw=; b=WUE4t35UrUR0Ft VFiaEu1fRmH9K1iJ8BbYQSqUf383szbaC2gC1g9ebq0Lj4RoHgrnl8JdnsMjNLi2AZypnADB/as8T x8gqzzXB8G4hUDWOdFR9dCL3870YcUjwQpwUYoTopGCobLsTpUfeApmv8EPzL8B1cW/FePrttSaIE GlYbxJaYZVKMdbrcpStGTrN9SgVLbOjGLXEpndk3uHqGXQrtLB4B0cVVN3XsHua0aZvvQts3J3C9F 4rKHEfSc3X//Sdrqi1fcJYqqJgtbz7zFfTR2/qewkN81q3y7OzqRON9942QuVfU7+wxrsz8fhsa+u i/xxxElpV8PwFZpOoTSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaRj-0007wF-Nm; Thu, 09 Jan 2020 16:14:07 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKw-0000A2-3e for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586023; 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=buj5zxwQmq+EgC9+pqBGy/R4fCPRVRg23/mLLDHCY/0=; b=c1mS/1/UIuRzSYMHWM1bzqO/KbgiSxNlvh+0IjthwSekfddNFXKm1dWL2jVJGuwuSY1zot JFZCnneAtMHKXlbRoNfLkHHj9Zwv4zkJVS2K0px6XK983OrDD8cUPBRXbeQk5NM53Wq7LM Rj7ZXvFY+er9vTKDBtgIkhaW8on/68Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-O3H-sbF5MyGkaWslaHvolA-1; Thu, 09 Jan 2020 11:07:01 -0500 Received: by mail-wm1-f70.google.com with SMTP id l11so888458wmi.0 for ; Thu, 09 Jan 2020 08:07:01 -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=C242X53zcOHATp6nW8wanAXybHBsTs8xiHcl5AgRRKM=; b=LdrJCEovz2F3sgiH00AvD73167YhInHooKV1ECeuzDFpicNPdSJCzhBad8Iw7xN3jO qMPquEgNhHRYk6/N0gea2aFOLvWGpWUNiWFvb9t0u9YFoFL52aYEFwXYxOx+iwKVULO1 kg6dwlKVVSl9Ulm99yN9ujS9ydyeUOhLhyhjtXPLuyjcvuE0ovsigHyVHW0lTpRgs+Gg zbaR8yBC7DBQDLHmh/47ItudjcyAbV0FPNe9+bcDR2ar9ue6kVLiCi2yE8vwIIQGOKog AfXTJ+HZolnO1QZ924rqN1se1yakHqQ2kgnZcSSrOZQt4BGGmFflGj/42+BauhHt6TlU MuKA== X-Gm-Message-State: APjAAAWzXAlOoDOpJnk6eEBYaeIuzaS7QbLs4VE5dRh2T+qMDYwD4BW+ q9pFHqz9sxqSCYunDrIpdifJTRCX4NRuYOWiIdQ+ElNc8vF1Rxne5aO0EfOiPYvbm04baFBrjOg ks5rdZhOVYJJtXfrTmDf+NDE8OG90z7FV48s= X-Received: by 2002:a7b:c4cc:: with SMTP id g12mr5945679wmk.68.1578586020594; Thu, 09 Jan 2020 08:07:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxHOfR4JB2i4uBDVB7MQ9mxgnZen75IkCm90k8Leliq2qj5mXFDzoMI/euFvStxlxW9fbs8Jw== X-Received: by 2002:a7b:c4cc:: with SMTP id g12mr5945652wmk.68.1578586020371; Thu, 09 Jan 2020 08:07:00 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id q3sm9123252wrn.33.2020.01.09.08.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:06:59 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 31/57] objtool: arm64: Decode load/store with register offset Date: Thu, 9 Jan 2020 16:02:34 +0000 Message-Id: <20200109160300.26150-32-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: O3H-sbF5MyGkaWslaHvolA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080706_280434_E230C457 X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instruction using the value of a register as offset for the target address. Since objtool can't keep track of the possible values of this offset, it is not possible to take this instructions into account for stack frame validation. Luckily, the compiler does not tend to generate these instructions for stack/frame pointer manipulation. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 34 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 ++ 2 files changed, 37 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 7064302416f4..00d5d627af08 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -830,6 +830,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b001100000000011, .decode_func = arm_decode_ld_st_imm_pre, }, + { + .mask = 0b001101010000011, + .value = 0b001100010000010, + .decode_func = arm_decode_ld_st_regs_off, + }, { .mask = 0b001101000000000, .value = 0b001101000000000, @@ -1200,3 +1205,32 @@ int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, } return 0; } + +int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, opc = 0, option = 0; + unsigned char decode_field = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + opc = (instr >> 22) & ONES(2); + option = (instr >> 13) & ONES(3); + +#define LD_ROFF_UNALLOC_1 0b01110 +#define LD_ROFF_UNALLOC_2 0b10110 +#define LD_ROFF_UNALLOC_3 0b10011 + decode_field = (size << 3) | (V << 2) | opc; + if (!EXTRACT_BIT(option, 1) || + (decode_field & LD_ROFF_UNALLOC_1) == LD_ROFF_UNALLOC_1 || + (decode_field & LD_ROFF_UNALLOC_2) == LD_ROFF_UNALLOC_2 || + (decode_field & 0b10111) == LD_ROFF_UNALLOC_3) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } +#undef LD_ROFF_UNALLOC_1 +#undef LD_ROFF_UNALLOC_2 +#undef LD_ROFF_UNALLOC_3 + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 1e031b12cf69..9043ca6f6708 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -106,6 +106,9 @@ int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, int arm_decode_ld_st_imm_pre(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2721B139A for ; Thu, 9 Jan 2020 16:14:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EBBAA20661 for ; Thu, 9 Jan 2020 16:14:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qiG1py+S"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O7TFNl0L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBBAA20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=FXx8Aa/NKl61sOj6FREYWGlZWth9bGrork5vSg4QKD4=; b=qiG1py+SqcA2Gf zIrzTwEKOxPTPcn14rRQW7JawZFDnwyRCY8pcg8wz5EIPHG+pOo1hR+65TRNQEbY6GjMbn7UFdxzz vXh0S8xyMEMdHNMz7hVbcnzwq44ZfNIBteOWsg2ibA2iGbNUv62yiYfx5yiStOMn1gwSjWdXK68UX Gg5GHb1s072vRu9oUs81+eqjXw8Z+HgLydr01x8nzxP92o02DhItowp0ZfTezAOjsvJr2/PHwctxR xrx1QvTa2GDTQtbHMSv8BbIuw4tZjgs3poYv2ltCY3fvmIBDE+tDDU3GId9Ddcr2u+QC1xlphYF21 NxtPeFMS0gGn5qvs7ILg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaS3-0008Fv-LJ; Thu, 09 Jan 2020 16:14:27 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKx-0000Bj-3u for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586025; 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=RM6BLLMvC70E0rK1309LlWSUO6CZiBbuWyXdyHITSkQ=; b=O7TFNl0LdMNGfw0+ZZfUIRdL+mfTA2EfYCsUxOD5zQM++mh7J0CP5S8Td8IZqx7PLOP+R3 gBREXi2ZhPsff5FW6DrYC6CiYdwps3/no+bC5HYKjkU1hokLhVYWLRCAl8n1Fy/HiJl53F tyZYCNtnfFlKT8+g4e43e6CZUylgg2k= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-ORe9dzEZPeWW_gp44l0jxQ-1; Thu, 09 Jan 2020 11:07:03 -0500 Received: by mail-wr1-f72.google.com with SMTP id 90so3039554wrq.6 for ; Thu, 09 Jan 2020 08:07:03 -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=y8iVqwlPqx8D0v6wn+sNinncmvzZmA9bOrVw84GrFXg=; b=A3jBSCnexzQwgyaPpDJ6YNX6Y3aWs3D/3Ga9Oe4pCBm118FhN2UVKv91Ox1s6WkEOI 1es5AcDvJHANwK10iUWZLZ2IOlxGNS2zalD01zb8sAmhdXl6997XI/gsFaykdnYlO+2P 8sIbrI+ez+eS9UW0nqCgyrS2a2j04+WLc3BW+zJToMZkDDS0o3ynq0AEdIhCYg3f03d4 i7i8hm6DD5E7O3Sv/w3CjRVMfJUdG11y182lIpsYi85TQTmKPav1D8P6swETcNF15o7X aMYoDurIb3EbUD221z8zhopycD4ahMlnppxiWtTAUbbk5gW1v4TB3WZ6RoOj6tbr8Xh4 8oTA== X-Gm-Message-State: APjAAAV8IBo568q3VIYf/C1qoVHx483XNlF7o4vUH28NbtTVyIwDQrHN YvikekV4E+MvrNr4iecTWyEDSOyv+3mZ288UmUgryvVg9GEGKKFICZsdnYT0ZmyZfogwe10rxyX K+DyE1B469EO1GsXGD3ZEXH59kbrUpymOGTM= X-Received: by 2002:adf:fd43:: with SMTP id h3mr11468142wrs.169.1578586022090; Thu, 09 Jan 2020 08:07:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwUxQHjrf4FRdDbNfOTNXug87kNQAURNGlHTw3u5DPgWcuL7CdH67/0NDbY/vvhci1xsXh2QA== X-Received: by 2002:adf:fd43:: with SMTP id h3mr11468101wrs.169.1578586021736; Thu, 09 Jan 2020 08:07:01 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id q3sm9123252wrn.33.2020.01.09.08.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:01 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 32/57] objtool: arm64: Decode load/store register pair instructions Date: Thu, 9 Jan 2020 16:02:35 +0000 Message-Id: <20200109160300.26150-33-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: ORe9dzEZPeWW_gp44l0jxQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080707_257437_5BF29913 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instruction to a pair of registers. Split the instruction into two stack operations, one for each register. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 220 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 12 + 2 files changed, 232 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 00d5d627af08..2aaac4e3786c 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -810,6 +810,26 @@ int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, #undef INSN_DRPS_MASK static struct aarch64_insn_decoder ld_st_decoder[] = { + { + .mask = 0b001101100000000, + .value = 0b001000000000000, + .decode_func = arm_decode_ld_st_noalloc_pair_off, + }, + { + .mask = 0b001101100000000, + .value = 0b001000100000000, + .decode_func = arm_decode_ld_st_regs_pair_post, + }, + { + .mask = 0b001101100000000, + .value = 0b001001000000000, + .decode_func = arm_decode_ld_st_regs_pair_off, + }, + { + .mask = 0b001101100000000, + .value = 0b001001100000000, + .decode_func = arm_decode_ld_st_regs_pair_pre, + }, { .mask = 0b001101010000011, .value = 0b001100000000000, @@ -1234,3 +1254,203 @@ int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, return 0; } + +int arm_decode_ld_st_noalloc_pair_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char opc = 0, V = 0, L = 0; + unsigned char decode_field = 0; + + opc = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + L = EXTRACT_BIT(instr, 22); + + decode_field = (opc << 2) | (V << 1) | L; + + if (decode_field == 0x4 || + decode_field == 0x5 || + decode_field >= 12) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } + return arm_decode_ld_st_regs_pair_off(instr, type, immediate, ops_list); +} + +int arm_decode_ld_st_regs_pair_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char opc = 0, V = 0, L = 0, bit = 0; + unsigned char imm7 = 0, rt2 = 0, rt = 0, rn = 0; + unsigned char decode_field = 0; + struct stack_op *op; + int scale = 0; + + opc = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + L = EXTRACT_BIT(instr, 22); + imm7 = (instr >> 15) & ONES(7); + rt2 = (instr >> 10) & ONES(5); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + bit = EXTRACT_BIT(opc, 1); + scale = 2 + bit; + + decode_field = (opc << 2) | (V << 1) | L; + + if (decode_field >= 0xC) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *immediate = (SIGN_EXTEND(imm7, 7)) << scale; + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + switch (decode_field) { + case 1: + case 3: + case 5: + case 7: + case 9: + case 11: + /* load */ + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = *immediate; + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + { + struct stack_op *extra; + + extra = malloc(sizeof(*extra)); + extra->src.type = OP_SRC_REG_INDIRECT; + extra->src.reg = rn; + extra->src.offset = (int)*immediate + 8; + extra->dest.type = OP_DEST_REG; + extra->dest.reg = rt2; + extra->dest.offset = 0; + + list_add_tail(&extra->list, ops_list); + } + break; + default: + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = (int)*immediate + 8; + op->src.type = OP_SRC_REG; + op->src.reg = rt2; + op->src.offset = 0; + { + struct stack_op *extra; + + extra = malloc(sizeof(*extra)); + extra->dest.type = OP_DEST_REG_INDIRECT; + extra->dest.reg = rn; + extra->dest.offset = *immediate; + extra->src.type = OP_SRC_REG; + extra->src.reg = rt; + extra->src.offset = 0; + + list_add_tail(&extra->list, ops_list); + } + /* store */ + } + return 0; +} + +int arm_decode_ld_st_regs_pair_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + int ret = 0; + unsigned int base_reg; + bool base_is_src; + struct stack_op *op; + struct stack_op *post_inc; + + ret = arm_decode_ld_st_regs_pair_off(instr, type, immediate, ops_list); + if (ret < 0 || *type == INSN_OTHER) + return ret; + + op = list_first_entry(ops_list, typeof(*op), list); + if (op->dest.type == OP_DEST_REG_INDIRECT) { + base_reg = op->dest.reg; + base_is_src = false; + } else if (op->src.type == OP_SRC_REG_INDIRECT) { + base_reg = op->src.reg; + base_is_src = true; + } else { + WARN("Unexpected base type"); + return -1; + } + + post_inc = malloc(sizeof(*post_inc)); + post_inc->dest.type = OP_DEST_REG; + post_inc->dest.reg = base_reg; + post_inc->src.reg = base_reg; + post_inc->src.type = OP_SRC_ADD; + post_inc->src.offset = (int)*immediate; + + /* Adapt offsets */ + list_for_each_entry(op, ops_list, list) { + if (!base_is_src) + op->dest.offset -= post_inc->src.offset; + else + op->src.offset -= post_inc->src.offset; + } + list_add_tail(&post_inc->list, ops_list); + + return ret; +} + +int arm_decode_ld_st_regs_pair_pre(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + int ret = 0; + unsigned int base_reg; + bool base_is_src; + struct stack_op *op; + struct stack_op *pre_inc; + + ret = arm_decode_ld_st_regs_pair_off(instr, type, immediate, ops_list); + if (ret < 0 || *type == INSN_OTHER) + return ret; + + op = list_first_entry(ops_list, typeof(*op), list); + if (op->dest.type == OP_DEST_REG_INDIRECT) { + base_reg = op->dest.reg; + base_is_src = false; + } else if (op->src.type == OP_SRC_REG_INDIRECT) { + base_reg = op->src.reg; + base_is_src = true; + } else { + WARN("Unexpected base type"); + return -1; + } + + pre_inc = malloc(sizeof(*pre_inc)); + pre_inc->dest.type = OP_DEST_REG; + pre_inc->dest.reg = base_reg; + pre_inc->src.type = OP_SRC_ADD; + pre_inc->src.reg = base_reg; + pre_inc->src.offset = (int)*immediate; + + /* Adapt offsets */ + list_for_each_entry(op, ops_list, list) { + if (!base_is_src) + op->dest.offset -= pre_inc->src.offset; + else + op->src.offset -= pre_inc->src.offset; + } + list_add(&pre_inc->list, ops_list); + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 9043ca6f6708..caeb40942b18 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -94,6 +94,18 @@ int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, struct list_head *ops_list); /* arm64 load/store instructions */ +int arm_decode_ld_st_noalloc_pair_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_regs_pair_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_regs_pair_off(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_ld_st_regs_pair_pre(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8656A1395 for ; Thu, 9 Jan 2020 16:14:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1A9CC20661 for ; Thu, 9 Jan 2020 16:14:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tW2pkMdn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PBKIZFPB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A9CC20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=gRcO5rjY9e897WoH5WTrSGboqT+4b03HZATSOU9TW+A=; b=tW2pkMdnTRtXt+ lCfgZ84habzD/XE8axGbAW/38SIMbIQlXl/yLjJgm32aQspWCLB/n4A+WpsYP3Ucyg0RSm+Lc3zbR MUhY4GLV8bKQzReLlGVpHYRYWZV+mDG2HXIZ3RCcD3Q5J+blsFJroyFQ5Lvsonesy6nbpYDH/MGPj Q8eWtmQbxzf4j4U7lKbwa003xsEsA++uolPxPY/ecQhCk+x2asZO6Y2FF2SCchJpnZxXm5pKDA0ab PJduwvpcdt6lxJTHfjQ6UnSqI6fiPQ0xKsl7lQkvpne9XIEYSfLJl7Wvthbwg6ab7YGC/bJy4DET+ UUpFlsk88upTjRRH3uYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaSL-00007a-9y; Thu, 09 Jan 2020 16:14:45 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKx-0000D7-OE for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586026; 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=ZrHIGMfa1ezX1wLKOejBrnNEGuBrWXKv+McP9/MFns4=; b=PBKIZFPBNqnh0nJ4tadqJgv9F0qaaR+3rEHJFt8PkCREstJSOQ8hSSUrla2MJYiHLKx5Yq XAV4WbMcoaVD9uxwo/s6ElkAm0MiLjrAaC03U3teiCA7Sc0q4mpytY7JrQ+7nfNf+Rd+DB NRfprbpzjBQQ+SGmdun5sJm2LB/bJyk= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-VfZw8porNpexTRH4-_cr5g-1; Thu, 09 Jan 2020 11:07:05 -0500 Received: by mail-wr1-f71.google.com with SMTP id c6so3028623wrm.18 for ; Thu, 09 Jan 2020 08:07:04 -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=674vedoaHlOK+sohBzVeKsD1bt4H4p7wzQDNyJHcuUU=; b=UletLu8ZxcBvppRzXmLgPr6R9Xe2UjoyQ5XmRYDiaB4vQEGR96bYQpVuPUA9spkKal ZOu7aAskd7Nv/5rq6yE94MDbPtNAk/1Hf5tnQAKgExOiuGRrd3gPxHWAiAh/W/Aq76Nk iVME5qdIN0TWL1AQM45pIPYXLXtOyu1frjajgXNDAgr34mgVzRvTFIaOgWvissng2z1v 8HAKl8Yga+wisDkFZXfot50CBvB/W14z0BtiruYYnyO6bRvw4wwq8an4D2jXaEyWCJZu 7N6VKAmwPoFqX5vybRzk6cBfK4hes2dmFDoWoicO3sWIeBkDV3vNF/rPYTR7f2B+ZBnX GEWQ== X-Gm-Message-State: APjAAAUyMX0xalT/dFOuDoYh2mjIHJZ3CXz/5tdYR0Ql/AFAJi7rd9lG y8ekCMJGWM6n7X+yUO3tYWrrNPc4QPf7xG30a4HvYd+F+m8vyMkuZWzh4XvozNK14VyrNB/qLHq +TDr0Nk+b2eqp8Pe3SczKsbdu+f4qsTb+r6U= X-Received: by 2002:a7b:cbcd:: with SMTP id n13mr5750920wmi.104.1578586023795; Thu, 09 Jan 2020 08:07:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyYyTRISBUXfTdMjMVF0DyWCzXa8gRzRagckK39rZstNu1/RnqpteCWutzTgpkE45cGgf1BEw== X-Received: by 2002:a7b:cbcd:: with SMTP id n13mr5750895wmi.104.1578586023548; Thu, 09 Jan 2020 08:07:03 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id q3sm9123252wrn.33.2020.01.09.08.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:03 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 33/57] objtool: arm64: Decode FP/SIMD load/store instructions Date: Thu, 9 Jan 2020 16:02:36 +0000 Message-Id: <20200109160300.26150-34-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: VfZw8porNpexTRH4-_cr5g-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080707_925771_A09CB705 X-CRM114-Status: GOOD ( 11.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instruction acting on floating point and SIMD registers. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 301 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 12 + 2 files changed, 313 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 2aaac4e3786c..7d480efe0bc2 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -810,6 +810,26 @@ int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, #undef INSN_DRPS_MASK static struct aarch64_insn_decoder ld_st_decoder[] = { + { + .mask = 0b101111111111100, + .value = 0b000010000000000, + .decode_func = arm_decode_adv_simd_mult, + }, + { + .mask = 0b101111110000000, + .value = 0b000010100000000, + .decode_func = arm_decode_adv_simd_mult_post, + }, + { + .mask = 0b101111101111100, + .value = 0b000011000000000, + .decode_func = arm_decode_adv_simd_single, + }, + { + .mask = 0b101111100000000, + .value = 0b000011100000000, + .decode_func = arm_decode_adv_simd_single_post, + }, { .mask = 0b001101100000000, .value = 0b001000000000000, @@ -889,6 +909,287 @@ int arm_decode_ld_st(u32 instr, enum insn_type *type, return arm_decode_unknown(instr, type, immediate, ops_list); } +static int adv_simd_mult_fields[] = { + 0b00000, + 0b00010, + 0b00100, + 0b00110, + 0b00111, + 0b01000, + 0b01010, + 0b10000, + 0b10010, + 0b10100, + 0b10110, + 0b10111, + 0b11000, + 0b11010, +}; + +int arm_decode_adv_simd_mult(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char L = 0, opcode = 0, rn = 0; + unsigned char decode_field = 0; + int i = 0; + + L = EXTRACT_BIT(instr, 22); + opcode = (instr >> 12) & ONES(4); + + decode_field = (L << 4) | opcode; + rn = (instr >> 5) & ONES(5); + *type = INSN_OTHER; + + for (i = 0; i < ARRAY_SIZE(adv_simd_mult_fields); i++) { + if ((decode_field & 0b11111) == adv_simd_mult_fields[i]) { + if (!stack_related_reg(rn)) + return 0; + } + } + + return arm_decode_unknown(instr, type, immediate, ops_list); +} + +int arm_decode_adv_simd_mult_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + /* same opcode as for the no offset variant */ + int ret = 0; + + ret = arm_decode_adv_simd_mult(instr, type, immediate, ops_list); + + /* TODO: Create stack_op for post increment with immediate */ + return ret; +} + +static struct aarch64_insn_decoder simd_single_decoder[] = { + { + .mask = 0b11111000, + .value = 0b00000000, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b00001000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b00010000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b00011000, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b00100000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b00100001, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b00101000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b00101001, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b01000000, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b01001000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b01010000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b01011000, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b01100000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b01100001, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b01101000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b01101001, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b10000000, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b10001000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b10010000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b10011000, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b10100000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b10100001, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b10101000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b10101001, + .decode_func = NULL, + }, + { + .mask = 0b11111100, + .value = 0b10110000, + .decode_func = NULL, + }, + { + .mask = 0b11111100, + .value = 0b10111000, + .decode_func = NULL, + }, + { + .mask = 0b11000000, + .value = 0b11111000, + .decode_func = NULL, + }, + { + .mask = 0b11111000, + .value = 0b11001000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b11010000, + .decode_func = NULL, + }, + { + .mask = 0b11111001, + .value = 0b11011000, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b11100000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b11100001, + .decode_func = NULL, + }, + { + .mask = 0b11111011, + .value = 0b11101000, + .decode_func = NULL, + }, + { + .mask = 0b11111111, + .value = 0b11101001, + .decode_func = NULL, + }, + { + .mask = 0b11111100, + .value = 0b11110000, + .decode_func = NULL, + }, + { + .mask = 0b11111100, + .value = 0b11111000, + .decode_func = NULL, + }, +}; + +int arm_decode_adv_simd_single(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char L = 0, R = 0, S = 0, opcode = 0, size = 0; + unsigned char rn = 0, dfield = 0; + int i = 0; + + L = EXTRACT_BIT(instr, 22); + R = EXTRACT_BIT(instr, 21); + S = EXTRACT_BIT(instr, 12); + opcode = (instr >> 13) & ONES(3); + size = (instr >> 10) & ONES(2); + + dfield = (L << 7) | (R << 6) | (opcode << 3) | (S << 2) | size; + + *type = INSN_OTHER; + rn = (instr << 5) & ONES(5); + + for (i = 0; i < ARRAY_SIZE(simd_single_decoder); i++) { + if ((dfield & simd_single_decoder[i].mask) == + simd_single_decoder[i].value) { + if (!stack_related_reg(rn)) + return 0; + } + } + + return arm_decode_unknown(instr, type, immediate, ops_list); +} + +int arm_decode_adv_simd_single_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + /* same opcode as for the no offset variant */ + int ret = 0; + + ret = arm_decode_adv_simd_single(instr, type, immediate, ops_list); + + /* TODO: Create stack_op for post increment with immediate */ + return ret; +} + int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index caeb40942b18..7fd333f88612 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -94,6 +94,18 @@ int arm_decode_br_uncond_reg(u32 instr, enum insn_type *type, struct list_head *ops_list); /* arm64 load/store instructions */ +int arm_decode_adv_simd_mult(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_adv_simd_mult_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_adv_simd_single(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_adv_simd_single_post(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_noalloc_pair_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C626921 for ; Thu, 9 Jan 2020 16:15:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 385D620661 for ; Thu, 9 Jan 2020 16:15:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sk5ETX7Q"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AvSHZEUy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 385D620661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=VV1gYYPmZ4Hd77h3Y0ZxlUnJ6Dp2x2qK0N50DnY1wdo=; b=sk5ETX7QPmKy5f 64WXApEtcDEGE4N6YS5jfHDEYouG7OukG8Je/4Th5XEanN3oiDKTTOrSecmim63aOU4PxTLSDg3XP nB9LCgjPqjuy3UPixvCQRwE1/Rx9jSjMJvpiHKRMkQBfqx7X/B0DjG6lLTk3tK/Y0PTX7n76PCbc4 hiLjIxI9hsqKgtRwq7FIwOM54wZQtFGqujW/JYVe/+bpui6ajsa2t4nvwPDlAggsDlc46/uPVyQ5G FFk+2ON4aaz1+8CABKWiNbBLq7gqLyyYurhhtbgglwOx2WsyGsNMmhGRRKnxJNDH941Px3x4XqVAB JNZ1voC9VvyAajXEpXfA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaSa-0000Lf-05; Thu, 09 Jan 2020 16:15:00 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaKz-0000F9-FQ for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586028; 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=mL32uzZtS4A4WxOY9naPKxSGCWugpIBuatEE3CXVbYc=; b=AvSHZEUyn5C4i33XWzqADuIj6Upln0mn+jukacjxXvR/mrHzg9BbwR9B8yI1y3wYFhNMHd NClAg3TzIq3LoTWueX5FZyjBBHEq8ufQikpLK2oBllokYzKCEgM8pgHQn/MaWj4umWgmAu g/36K6ozYYxhp6jpTw0D8VWIst+y1YI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-pDVe2TogPXyv4TYlsnqgVA-1; Thu, 09 Jan 2020 11:07:06 -0500 Received: by mail-wm1-f72.google.com with SMTP id c4so1094283wmb.8 for ; Thu, 09 Jan 2020 08:07:06 -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=Io3pe+yXhkH0XtVt81FPsOl3c54xtZQ9M8pNFcB3Jec=; b=T/GcxlfzPLyxZZXXR1DciDrtSeEVri5F9o2jlSmD2I2htiIv8gvTeKyEbqQUWfkp9d xGXGX+ihtDksfqJ6wGXn5qrZ+ChrurdWfsoC0KQXjYw8AFcOu71Eo7fqiCH2K4FBnkn1 cIU2nF/TQIa1eX+H/mJxw2pvbEkXQ83VfDbkrYkfOMWjoFMD8ZLlu2QNo2W9DKfi9j0A ZtCMRWpcMdochkOdw/o0nqextJLBiyou6KWJ6cnGblOfh48t3lBVBSn1cUlRaEEsSVpT 4OKq5D85SYmPjUGzondM2IAap/4of+xJ2wJiy7Grj0+YabMWbc0BiT0tZk9WNnnw8STq h7jQ== X-Gm-Message-State: APjAAAWuyPx41g8nN3DCyGkMTuDl8lTPDDYmZ/U+MQhHgjpvZ1/Lfo+O BkBRZ5hXCkyBbfHFTsnoMB51kGtbip5+Diytk+/eq5IeTFablTfKUckZOznP/H1tDQ7V581HSlj bVpW9yW/eRL262F78BKvBNCj5CZ4CZjPQGOA= X-Received: by 2002:a5d:5273:: with SMTP id l19mr12042235wrc.175.1578586024905; Thu, 09 Jan 2020 08:07:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyhV2DNPneDJ3INZRmEMT5LfpnDkTy4hQ+cTQKOs/UrhpfRFlyh+43dh8pZyrUb2ibu33ow8w== X-Received: by 2002:a5d:5273:: with SMTP id l19mr12042205wrc.175.1578586024671; Thu, 09 Jan 2020 08:07:04 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id q3sm9123252wrn.33.2020.01.09.08.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:04 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 34/57] objtool: arm64: Decode load/store exclusive Date: Thu, 9 Jan 2020 16:02:37 +0000 Message-Id: <20200109160300.26150-35-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: pDVe2TogPXyv4TYlsnqgVA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080709_624058_A60612D6 X-CRM114-Status: GOOD ( 10.88 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store exclusive instructions. From objtool's point of view there aren't particular semantics to these operations. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 140 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + 2 files changed, 143 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 7d480efe0bc2..e3f77d68b282 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -830,6 +830,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b000011100000000, .decode_func = arm_decode_adv_simd_single_post, }, + { + .mask = 0b001111000000000, + .value = 0b000000000000000, + .decode_func = arm_decode_ld_st_exclusive, + }, { .mask = 0b001101100000000, .value = 0b001000000000000, @@ -1190,6 +1195,141 @@ int arm_decode_adv_simd_single_post(u32 instr, enum insn_type *type, return ret; } +#define ST_EXCL_UNALLOC_1 0b001010 +#define ST_EXCL_UNALLOC_2 0b000010 + +#define LDXRB 0b000100 +#define LDAXRB 0b000101 +#define LDLARB 0b001100 +#define LDARB 0b001101 +#define LDXRH 0b010100 +#define LDAXRH 0b010101 +#define LDLARH 0b011100 +#define LDARH 0b011101 +#define LDXR 0b100100 +#define LDAXR 0b100101 +#define LDXP 0b100110 +#define LDAXP 0b100111 +#define LDLAR 0b101100 +#define LDAR 0b101101 +#define LDXR_64 0b110100 +#define LDAXR_64 0b110101 +#define LDXP_64 0b110110 +#define LDAXP_64 0b110111 +#define LDLAR_64 0b111100 +#define LDAR_64 0b111101 + +#define LD_EXCL_NUMBER 20 + +static int ld_excl_masks[] = { + LDXRB, + LDAXRB, + LDLARB, + LDARB, + LDXRH, + LDAXRH, + LDLARH, + LDARH, + LDXR, + LDAXR, + LDXP, + LDAXP, + LDLAR, + LDAR, + LDXR_64, + LDAXR_64, + LDXP_64, + LDAXP_64, + LDLAR_64, + LDAR_64, +}; + +int arm_decode_ld_st_exclusive(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, o2 = 0, L = 0, o1 = 0, o0 = 0; + unsigned char rt = 0, rt2 = 0, rn = 0; + unsigned char decode_field = 0; + struct stack_op *op; + int i = 0; + + size = (instr >> 30) & ONES(2); + o2 = EXTRACT_BIT(instr, 23); + L = EXTRACT_BIT(instr, 22); + o1 = EXTRACT_BIT(instr, 21); + o0 = EXTRACT_BIT(instr, 15); + + rt2 = (instr >> 10) & ONES(5); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + + decode_field = (size << 4) | (o2 << 3) | (L << 2) | (o1 << 1) | o0; + + if ((decode_field & ST_EXCL_UNALLOC_1) == ST_EXCL_UNALLOC_1 || + (decode_field & 0b101010) == ST_EXCL_UNALLOC_2) { + if (rt2 != 31) + return arm_decode_unknown(instr, type, immediate, + ops_list); + } + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + + *type = INSN_STACK; + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + for (i = 0; i < LD_EXCL_NUMBER; i++) { + if ((decode_field & 0b111111) == ld_excl_masks[i]) { + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = 0; + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + return 0; + } + } + + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = 0; + op->src.type = OP_SRC_REG; + op->src.reg = rt; + op->src.offset = 0; + + return 0; +} + +#undef ST_EXCL_UNALLOC_1 +#undef ST_EXCL_UNALLOC_2 + +#undef LD_EXCL_NUMBER + +#undef LDXRB +#undef LDAXRB +#undef LDLARB +#undef LDARB +#undef LDXRH +#undef LDAXRH +#undef LDLARH +#undef LDARH +#undef LDXR +#undef LDAXR +#undef LDXP +#undef LDAXP +#undef LDLAR +#undef LDAR +#undef LDXR_64 +#undef LDAXR_64 +#undef LDXP_64 +#undef LDAXP_64 +#undef LDLAR_64 +#undef LDAR_64 + int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 7fd333f88612..61152b4aa42a 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -136,4 +136,7 @@ int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_st_exclusive(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52D27139A for ; Thu, 9 Jan 2020 16:16:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2273F20661 for ; Thu, 9 Jan 2020 16:16:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WgpHjCnU"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S3Cy4SAQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2273F20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Qmk/KcI3wKmF0UBGPuADPjdBDr+lkaQlg4McuC2sTEk=; b=WgpHjCnU/KlJvC wySzpw0JTHgFkS7pVD1LzcfWjGvg50nAGiOpqE6YRKhcoqdddeDUChqzAD+lx13WkOzcSNmWBLTqC vyPogM1/HSzixNN7sCydiN5aASXW8vrOXUeXU7Vrndt7HtkpXwLusSHSijT6B86FLBhf1Dlklpbfw QV9gbDvxCUxqJ6XsZepqLaS/rEz1CDLUu+EP1muOSVVZ6ju+lSnKh+hkJt/H2/Jic/puCcefC+EkP 0VpgRIXIuSLYcJu7Mibr4qAKWZPw8f3upSdvSJxSmCb58+CnHZUklx3v8tgFMT4n46i/Ul46bUqiH kVVJOPumNH3LmVl1F4PA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaTa-0002Ta-Rm; Thu, 09 Jan 2020 16:16:02 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLW-0000ge-8C for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586060; 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=gF5zGccN6XPj4wdads+TYexD8DaIE0r9gJyUAoloV6U=; b=S3Cy4SAQuRJswpJ8VZkMuuoAKy1zTJcXwjZPCi7DSVdiWhlyMNrDs2GpDuiKosB3sFDYzC e7vCpNrspdosrugio+vtthe0cKZE6O6UHgOYB7w+ds1lg3stUY8to5wrr/Pz+FHYjuUNMD iXZkkNLprp6JgGdOQrGlm6O4dZ6Hb8o= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-8N3DI3L_P_mhEDdTqTfHwA-1; Thu, 09 Jan 2020 11:07:39 -0500 Received: by mail-wm1-f70.google.com with SMTP id t4so1104313wmf.2 for ; Thu, 09 Jan 2020 08:07:39 -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=V80sKnfPgpuJ2PN6PlqMSnAckHTRWhZvUDB6P0wLWgc=; b=kBUti04q8BUjHzMFJRXyC4zbKHC6Lhe3B0lXO3nVPNzvdHNJzqqmOtnkXpticOKWuJ OwD/BlKf3STJKI24devQdDv+t35Fv4yQtf6O5IJsDyGRUjuj/eU04gMtDefnxnufnJW5 dOZeuaCndczey/ZyV72TtVrd7SPnc1V3VKOedVIpOLQsy5JFAWDYjg9CBmZkuDujAJmR jM04+eEmMqSpVxdioFG19nLztPKCrJeMhk61zkOB/0NSn4DZsbh3lfrJ0f85Bqtr6nnm ceF/W9VgxYl9I6b4yEnM0k2n9n1o8zBiddjDr7dxGtbRXVeVxucl2SOC1kbwb4WPC/7W 3mtg== X-Gm-Message-State: APjAAAW5Spatg+t+bBi0DhDhicOkXbN8B38M/6E8OXCV/YemK5D7ZKhD 9cU6+peeJgrh7aPZTSUcyzpAlH6dxLcY9lafqy3tcYbfe5ZtuPt+k6DiRcfx3817ugSTdAfpPBQ YM0bvyrquHpcmAEKH/UQ5ImQ2w4WE/NMYoTE= X-Received: by 2002:a1c:96c4:: with SMTP id y187mr5972340wmd.112.1578586057203; Thu, 09 Jan 2020 08:07:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwc4TaEWjCmUkmfkOmwGRLIgB1O+Rz/bvnkIEzkSOYGeyv8HJLRBacELGQ/7+dBBu8TEZebjw== X-Received: by 2002:a1c:96c4:: with SMTP id y187mr5972312wmd.112.1578586057002; Thu, 09 Jan 2020 08:07:37 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id h2sm8591413wrv.66.2020.01.09.08.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:36 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 35/57] objtool: arm64: Decode atomic load/store Date: Thu, 9 Jan 2020 16:02:38 +0000 Message-Id: <20200109160300.26150-36-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 8N3DI3L_P_mhEDdTqTfHwA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080742_408313_89F8D5F5 X-CRM114-Status: GOOD ( 10.64 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode v8.1 atomic load/store instructions. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 86 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 2 + 2 files changed, 88 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index e3f77d68b282..1897f62987fa 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -875,6 +875,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b001100000000011, .decode_func = arm_decode_ld_st_imm_pre, }, + { + .mask = 0b001101010000011, + .value = 0b001100010000000, + .decode_func = arm_decode_atomic, + }, { .mask = 0b001101010000011, .value = 0b001100010000010, @@ -1667,6 +1672,87 @@ int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, return 0; } +static struct aarch64_insn_decoder atom_unallocs_decoder[] = { + { + .mask = 0b1001111, + .value = 0b0001001, + }, + { + .mask = 0b1001110, + .value = 0b0001010, + }, + { + .mask = 0b1001111, + .value = 0b0001101, + }, + { + .mask = 0b1001110, + .value = 0b0001110, + }, + { + .mask = 0b1101111, + .value = 0b0001100, + }, + { + .mask = 0b1111111, + .value = 0b0111100, + }, + { + .mask = 0b1000000, + .value = 0b1000000, + }, +}; + +int arm_decode_atomic(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char V = 0, A = 0, R = 0, o3 = 0, opc = 0; + unsigned char rn = 0, rt = 0; + unsigned char decode_field = 0; + struct stack_op *op; + int i = 0; + + V = EXTRACT_BIT(instr, 26); + A = EXTRACT_BIT(instr, 23); + R = EXTRACT_BIT(instr, 22); + o3 = EXTRACT_BIT(instr, 15); + opc = (instr >> 12) & ONES(3); + + decode_field = (V << 6) | (A << 5) | (R << 4) | (o3 << 3) | opc; + + for (i = 0; i < ARRAY_SIZE(atom_unallocs_decoder); i++) { + if ((decode_field & atom_unallocs_decoder[i].mask) == + atom_unallocs_decoder[i].value) { + return arm_decode_unknown(instr, + type, + immediate, + ops_list); + } + } + + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->src.reg = rn; + op->src.type = OP_DEST_REG_INDIRECT; + op->src.offset = 0; + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + + return 0; +} + int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 61152b4aa42a..89488c5df5e9 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -130,6 +130,8 @@ int arm_decode_ld_st_imm_unpriv(u32 instr, enum insn_type *type, int arm_decode_ld_st_imm_pre(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_atomic(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326115 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FB35139A for ; Thu, 9 Jan 2020 16:15:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7862520661 for ; Thu, 9 Jan 2020 16:15:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OOcbx7Ex"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XReg23jx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7862520661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=0mkoMjpifis8nbNY7lHYnxpUQZpnXD/8Zj0W81uJgsc=; b=OOcbx7ExdvSzRV Wu3pKrzV8o+XD72fMkWO+a2w4ALU4QlbLIHpXWJGpyT8+5rcmdp52oIQyF88CAxxeXFbFJOxKOPog GnAJvirXKbgaD1X6soHRATTDUPVokamCUD0sqBV5LnvCOE+IF30+phjEVATf1qlHRenNyokGj42cR j11kGVtceWiWpFYdd1agV6QRAvaC6g+o6b5Oc6DLplsz7L6P1oepKoGCDKbsG70X2iiy8DWPXe5XX DuL/EgAYn56ET734q6I14o4Gto4wMeQj/af1DT9wqywY0EAjRAE7zKK1Er8UuPKQKMSjr9XySkHU/ YeKL2B4HMkaipaGlo8aw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaTI-0002Dj-Fa; Thu, 09 Jan 2020 16:15:44 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLW-0000gj-1q for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586060; 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=093JoFjWWkSe13bupL/8/jGT/P9IkM6eHbU8krItibg=; b=XReg23jxsIKBR8sicjh2C3qO7w//T/J6mSRzmOBpVVOYt7uI7b4b1rCJYXkCZYHfoAStkW 4cX3tfSQxIzK+ADy3bqXh8h8Oh1kERggscUicYPJ5c/CLc3TGtCwIlJDyP6DKgiqjOa7LV 19SINWxJ5UvKwaacCgxHhZs+tUhJr5s= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-NrE9aRtIPJK_A7FMZetIjQ-1; Thu, 09 Jan 2020 11:07:39 -0500 Received: by mail-wr1-f71.google.com with SMTP id 90so3040115wrq.6 for ; Thu, 09 Jan 2020 08:07:39 -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=gehBuZsWTyS5GusQuL5RiDnS9qnv2i+e7pvi+x7gJHA=; b=nZs1S8ckVYxv3y0CjaChY9cjLOh1PBBK90WPDiuB1219ye+HNJeWPaH1bJc41O94v9 WOwiZ+rUCV2CHIddfj9eOgCQgq8knVRP7oe3chv/JhuCFyn1FrliEd+TBzSlDMIQnhHl y4jjcSp+bbR0170iEg5BHIHNI1L0lzV1QaFXT2zjGyj+CLcIKMwC+CguKiqYoStTJ8pI fgAc2/m3rAnU05uwJBLoMeDXz5gfy4U5I+U/K0Ehe7MIIRmynpWc84iQu8dlS4JB40SV nn3sFHSq3YO9YO0PlD1bp2QhpCyuQcOY3FxM5lNKGhGQdSEfhl3o+kdUoKL22DCCNJa7 ulWw== X-Gm-Message-State: APjAAAXln2FYv17Jyr0J9EdjHnLbbOzvZqTqsj0xMhCQ4RnpU7ma+V5x nAT7EQXa1Tipt/ekLUyYJMv5/k9nfNalglrmyhFE2CD7dF+4rNkYJsGPyEpGVAVqW+jS+6+a9/n 7BS7aYwwV++q519TrLCLPB0L0Rtw7qeOMJfc= X-Received: by 2002:a1c:f001:: with SMTP id a1mr5483533wmb.76.1578586058550; Thu, 09 Jan 2020 08:07:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwjD64xWcH+OF87TPinIqmOaTnoguN09GymLeZun31rI/KZftrppzQP03Apb2IWiqX3F1kkTA== X-Received: by 2002:a1c:f001:: with SMTP id a1mr5483512wmb.76.1578586058385; Thu, 09 Jan 2020 08:07:38 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id h2sm8591413wrv.66.2020.01.09.08.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:37 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 36/57] objtool: arm64: Decode pointer auth load instructions Date: Thu, 9 Jan 2020 16:02:39 +0000 Message-Id: <20200109160300.26150-37-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: NrE9aRtIPJK_A7FMZetIjQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080742_202460_517DC811 X-CRM114-Status: GOOD ( 10.14 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instruction provided by the v8.3 pointer authentication architecture extension. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 51 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 ++ 2 files changed, 54 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 1897f62987fa..0bbbacd74e48 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -885,6 +885,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b001100010000010, .decode_func = arm_decode_ld_st_regs_off, }, + { + .mask = 0b001101010000001, + .value = 0b001100010000001, + .decode_func = arm_decode_ld_st_regs_pac, + }, { .mask = 0b001101000000000, .value = 0b001101000000000, @@ -1981,3 +1986,49 @@ int arm_decode_ld_st_regs_pair_pre(u32 instr, enum insn_type *type, return 0; } + +int arm_decode_ld_st_regs_pac(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char size = 0, V = 0, W = 0, S = 0; + unsigned char rn = 0, rt = 0; + struct stack_op *op; + u32 imm9 = 0, s10 = 0; + + size = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + W = EXTRACT_BIT(instr, 11); + + if (size != 3 || V == 1) + return arm_decode_unknown(instr, type, immediate, ops_list); + + rn = (instr >> 5) & ONES(5); + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + + S = EXTRACT_BIT(instr, 22); + s10 = (S << 9) | imm9; + + *type = INSN_STACK; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + op->dest.reg = rt; + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + op->src.offset = (SIGN_EXTEND(s10, 9) << 3); + if (W) { /* pre-indexed/writeback */ + op->src.type = OP_SRC_POP; + op->src.reg = rn; + } else { + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + } + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 89488c5df5e9..d819d2e795a3 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -135,6 +135,9 @@ int arm_decode_atomic(u32 instr, enum insn_type *type, int arm_decode_ld_st_regs_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_st_regs_pac(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02771921 for ; Thu, 9 Jan 2020 16:16:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D450420661 for ; Thu, 9 Jan 2020 16:16:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XHfy/hbL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vw48jusC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D450420661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=pzT9VLArV2t3Z5q1AY+dqpxd+MKvwTZpDptFBVo1OAc=; b=XHfy/hbL+qPuwf sO8lt7+BM3jWgY5MnRaA28enE5ishlIFtfrNbE8jQYIfbQlStRZK7nltRBxAH24Og0BEn3rSi+ch4 xxhllzBiXS0joOwGfZGzxknamVjmkBD73DbK2RZjSr+/URlnZ8PWietgjNE/GPU1/h+ZCROJA8EyX AN6hv9G+eHI5WKkqb2BWoYzFgQy7Q0yeLLSyeWc5PsirhICSEMRUmHCF1OSXAwAqv81RFDIU3K7x7 sAbgvHBre/y0vtjrJUOK26NMisU8XvrZsMYnyIjZFnon9Wj4G2LHrv9hehHCTuPGEw4pQp9OR/pqs C9fUSwXonXe4Fgel8jzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaUJ-00032I-0r; Thu, 09 Jan 2020 16:16:47 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLa-0000k8-Nt for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586064; 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=IeEJuhyOdraSaiW7XLYyhApDC86GgE1TadUQ1aO6tfU=; b=Vw48jusCgThln4w6Sh4LiPA8PL5rE0sy7RJ+3nu/Ix78yzyoLrdL4bt3ydCi/eXCC7vTm2 N8yNS+DHgveJ8Wxm535DnLoLGoDaM3IfbtuFYVEZ//flHhY+D3wbJRAajylJzQleY6BFcH ABZr2PuH5Da47wII2KJ4QGzcY9UYYQg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-WTBlUoB5NDOm-E4fvwTmVQ-1; Thu, 09 Jan 2020 11:07:41 -0500 Received: by mail-wr1-f71.google.com with SMTP id f17so3052314wrt.19 for ; Thu, 09 Jan 2020 08:07:40 -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=6MXSkudn70UtEbMzCHfdquKWnGc9F4q7hjxMMx1IdM8=; b=YXrjcQ5w+5YLOveYs/hgLAkjdwxbDo8KBuT+nY66gUuRW5ihJ4EdIM5n3hJMOtNIPF hKfiJR1qC7NTztetT0rnW0CVjUz13SiD2sjZsC3ZY1URVmpCrJ/8+lURCeiWBRMHMH+M C3kEg2qK9Cl98sCs+brVD0VTG9e49UEpYwne+bK1Cc2uoHrQcvl2/pGEZWo07wpttr1u YQp32ZcBZC5fmFi+HTSaHba6Dv5Nd3OsxGEkhjehiy6t+RwUTIu3UKLt7IDKHdWkp//X ccdT68pBG5CMQzUHVGQtqU3whBUJOZVM0najciKuH6p17qy4am3qYA+EJaiYNI+PYVFF vL4g== X-Gm-Message-State: APjAAAW0oJ00+jJuL9PIiQgNFjoCMjXxOpUrnTLatzQjmBNg5RUzXUe+ Cn12xS2Y3I304ADZAdmAn3aNlN6NljfDwJTNeFadgk/nGJQ0HLU7z/zdfCLj/K9aIjfdFZsNu8F FVJ6azaENyZhPmkWI9hMkcPWEdHqGfKc3tmY= X-Received: by 2002:a1c:7d92:: with SMTP id y140mr5326756wmc.145.1578586059937; Thu, 09 Jan 2020 08:07:39 -0800 (PST) X-Google-Smtp-Source: APXvYqwO98wUDEIRDRIYLKdIbYyjOEf2GJMH63VpDj9P6FrGkNnf7bEr0cdtCq9CGHTRBKqwcrGGfw== X-Received: by 2002:a1c:7d92:: with SMTP id y140mr5326736wmc.145.1578586059741; Thu, 09 Jan 2020 08:07:39 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id h2sm8591413wrv.66.2020.01.09.08.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:39 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 37/57] objtool: arm64: Decode load acquire/store release Date: Thu, 9 Jan 2020 16:02:40 +0000 Message-Id: <20200109160300.26150-38-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: WTBlUoB5NDOm-E4fvwTmVQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080746_909527_2E0FA88A X-CRM114-Status: GOOD ( 10.50 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instructions provided by the v8.4 RCPC architecture extension. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 68 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + 2 files changed, 71 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 0bbbacd74e48..becc563345dd 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -835,6 +835,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b000000000000000, .decode_func = arm_decode_ld_st_exclusive, }, + { + .mask = 0b001111010000011, + .value = 0b000101000000000, + .decode_func = arm_decode_ldapr_stlr_unsc_imm, + }, { .mask = 0b001101100000000, .value = 0b001000000000000, @@ -2032,3 +2037,66 @@ int arm_decode_ld_st_regs_pac(u32 instr, enum insn_type *type, return 0; } + +int arm_decode_ldapr_stlr_unsc_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + u32 imm9 = 0; + unsigned char size = 0, opc = 0, rn = 0, rt = 0, decode_field = 0; + struct stack_op *op; + + imm9 = (instr >> 12) & ONES(9); + size = (instr >> 30) & ONES(2); + opc = (instr >> 22) & ONES(2); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(5); + + decode_field = (size << 2) | opc; + if (decode_field == 0xB || + decode_field == 0xE || + decode_field == 0xF) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + *type = INSN_STACK; + *immediate = imm9; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + switch (decode_field) { + case 1: + case 2: + case 3: + case 5: + case 6: + case 7: + case 9: + case 10: + case 13: + /* load */ + op->src.type = OP_SRC_REG_INDIRECT; + op->src.reg = rn; + op->src.offset = SIGN_EXTEND(imm9, 9); + op->dest.type = OP_DEST_REG; + op->dest.reg = rt; + op->dest.offset = 0; + break; + default: + /* store */ + op->dest.type = OP_SRC_REG_INDIRECT; + op->dest.reg = rn; + op->dest.offset = SIGN_EXTEND(imm9, 9); + op->src.type = OP_SRC_REG; + op->src.reg = rt; + op->src.offset = 0; + break; + } + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index d819d2e795a3..1721d9c487d0 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -106,6 +106,9 @@ int arm_decode_adv_simd_single(u32 instr, enum insn_type *type, int arm_decode_adv_simd_single_post(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ldapr_stlr_unsc_imm(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_noalloc_pair_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326119 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C48D6921 for ; Thu, 9 Jan 2020 16:16:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9FCAF20661 for ; Thu, 9 Jan 2020 16:16:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uRkXIRLG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EdBGelac" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FCAF20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=iscGxTjNmnE9rUzirZS8JGB58WG2+5c2MU+JtDiAink=; b=uRkXIRLG9mDTRx +MIfJp61nxYbOwPn8e0pHi5VvtcJIOtHpkM96nJLwymvNfd7lP7+NCziM2Lco72mi/fxJXN0RUUhz PNShSgeZykr1lV81WK94wy04uSXQpj7eF6n6jNSXv1bXN2Eu7BGaRqNg+fvjQYWgvRP1nokeJBlfM Bsr27wi5J0Qx6aLiQHzD/pzTWuwU3de3lLGlfQboaFAhFBb9GM3w5gHhQG9/xe4NRnh+OqbWH9k7H s8EGHPt9Cjl4ztnVQ97BZ1pVdfVnf1/8Bpf11LZRXJR8GrLCZQboWfhstQadjr1/JNOBkvMfjNDMd 21ZpsyK3c4DcnjwG6NzQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaU0-0002m9-Rs; Thu, 09 Jan 2020 16:16:28 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLa-0000ji-Mq for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586064; 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=x6lOb3lmB+zuso09zwhfVFsGQAh043Ip/hnDkUCWcy0=; b=EdBGelacP3aloKvTx9KfiYcQnslrbubpQERCfKDtzlAKRAByiTe+R2woOzlWV4f1CbpTIS GVK1Qd4d1WV7du/8Lx0OAUa0GspJ/Q36QN7m+Jj4Z0xgephmTBiMsoGfEmUG1jyoAsGpUV eFKfBcUkSHoXD3Tv1+4rdB03VpJQ3m8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-drUov8bPNRecLXgXu-NaUQ-1; Thu, 09 Jan 2020 11:07:43 -0500 Received: by mail-wr1-f69.google.com with SMTP id t3so3023203wrm.23 for ; Thu, 09 Jan 2020 08:07:42 -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=YSzXbc/iliStE7cNjDlAGjV3g1ZUU8qfPQMgIaRdVVc=; b=ArhoBErdZcY8J38w/tjGAF6ZdqSKvV0xztLXwZveYqMGKMf8KSdq6PkGMq27lfVagS sP6ARFFO/xWl8EnTtPuDXiyJbGjuDlT48/ovAwaVrjWQCS2iGLyjxtZDth9fyAM4wsh3 QPotppBIQPXXXM7UotH9Tq1s0SCR+Da+YEmS3NObk9VDn7sD45nCWWOLHxjn35ZMzV55 HfLyYIDAyiOfNjHxgGCIW0Uiz20NsJ22B1Qq/Enq7navXfZWwkfJAT0UGpcHSFK/lSqe dt9JQ2RcCPA217e7rNridD9heXYnOrD+RxE4sv3O4GUi6OOsGnNsjNTbba/rlzOtM+hc aZYg== X-Gm-Message-State: APjAAAX5slz7JiUdUbxz0/gt9a1R6LxjcPXyD2IVWF9osKF0ChttWupW TS/LOdV3AzZqJDd/+qOXx+rqw1zWvaTLrxq45z7W38UbTElf7KUM+A9PdPpijrfkJkL660Elt1N PLUbCylDcyTcfBUUmJMaFJEZ2Y01Jbg3r0nM= X-Received: by 2002:a7b:c759:: with SMTP id w25mr6009338wmk.15.1578586061490; Thu, 09 Jan 2020 08:07:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwXR+O6Irjgn/GaJkOXCpnf30KgGD1FiNm0sUHMqw1/wbVxO2aGMcymgxoFGZ08UHSYH/a03w== X-Received: by 2002:a7b:c759:: with SMTP id w25mr6009322wmk.15.1578586061280; Thu, 09 Jan 2020 08:07:41 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id h2sm8591413wrv.66.2020.01.09.08.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:40 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 38/57] objtool: arm64: Decode load/store with memory tag Date: Thu, 9 Jan 2020 16:02:41 +0000 Message-Id: <20200109160300.26150-39-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: drUov8bPNRecLXgXu-NaUQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080746_848950_EA1A0BAF X-CRM114-Status: GOOD ( 10.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load/store instructions provided by the v8.5 memorty tagging architecture extension. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 87 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + 2 files changed, 90 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index becc563345dd..bc4c62401012 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -830,6 +830,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b000011100000000, .decode_func = arm_decode_adv_simd_single_post, }, + { + .mask = 0b111111010000000, + .value = 0b110101010000000, + .decode_func = arm_decode_ld_st_mem_tags, + }, { .mask = 0b001111000000000, .value = 0b000000000000000, @@ -2100,3 +2105,85 @@ int arm_decode_ldapr_stlr_unsc_imm(u32 instr, enum insn_type *type, return 0; } + +int arm_decode_ld_st_mem_tags(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + u32 imm9 = 0; + unsigned char opc = 0, op2 = 0, rn = 0, rt = 0, decode_field = 0; + struct stack_op *op; + + imm9 = (instr >> 12) & ONES(9); + opc = (instr >> 22) & ONES(2); + op2 = (instr >> 10) & ONES(2); + rn = (instr >> 5) & ONES(5); + rt = instr & ONES(6); + + decode_field = (opc << 2) | op2; + + if (decode_field == 0x0 || + (decode_field == 0x8 && imm9 != 0) || + (decode_field == 0xC && imm9 != 0)) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } + + if (!stack_related_reg(rn)) { + *type = INSN_OTHER; + return 0; + } + *type = INSN_STACK; + *immediate = imm9; + + op = calloc(1, sizeof(*op)); + list_add_tail(&op->list, ops_list); + + /* + * Offset should normally be shifted to the + * left of LOG2_TAG_GRANULE + */ + switch (decode_field) { + case 1: + case 5: + case 9: + case 13: + /* post index */ + case 3: + case 7: + case 8: + case 11: + case 15: + /* pre index */ + op->dest.reg = rn; + op->dest.type = OP_DEST_PUSH; + op->dest.offset = SIGN_EXTEND(imm9, 9); + op->src.reg = rt; + op->src.type = OP_SRC_REG; + op->src.offset = 0; + return 0; + case 2: + case 6: + case 10: + case 14: + /* store */ + op->dest.reg = rn; + op->dest.type = OP_DEST_REG_INDIRECT; + op->dest.offset = SIGN_EXTEND(imm9, 9); + op->src.reg = rt; + op->src.type = OP_SRC_REG; + op->src.offset = 0; + return 0; + case 4: + case 12: + /* load */ + op->src.reg = rn; + op->src.type = OP_SRC_REG_INDIRECT; + op->src.offset = SIGN_EXTEND(imm9, 9); + op->dest.reg = rt; + op->dest.type = OP_DEST_REG; + op->dest.offset = 0; + return 0; + } + + return -1; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 1721d9c487d0..e6a62691b487 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -106,6 +106,9 @@ int arm_decode_adv_simd_single(u32 instr, enum insn_type *type, int arm_decode_adv_simd_single_post(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_st_mem_tags(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ldapr_stlr_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E70FE921 for ; Thu, 9 Jan 2020 16:17:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C056220661 for ; Thu, 9 Jan 2020 16:17:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o9zIpUx4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZuYBp5vg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C056220661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=N9heOj4oHI84OnqQdvC9+Vxowqd/65nsy56fOUSxaE0=; b=o9zIpUx4JMhIKh cSdYwL3q+HUFaLIq1pko7TBlYK0pnUn7t3n8qHCJaoE/0Il96/0t03iQD2LgClrwHqEA1r1iTvrqB XtB2lhMCZUVDH9RmZ+ZRiwJwxiaq6e89xYxsaWOzK9pmfxCxM0HyIWI9L3NXwwHVeaWpteU4eLObZ CginzLIzy3Mp5jC+jd+sJt5NX15ylSsVtByILvzFb0TFHD2VVkl8fokr6sV4r2UX716oe6op8Qyi7 fRRkuelw6KmC5JQI2wkbnl+GQ2asF+7GIcKkDJjDwRSOkGXlyBOFCidQGxaS9LoRWqlyMqJlAW1fQ YP9g60mJYXO1fOe1lyOg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaUb-0003Gp-Vk; Thu, 09 Jan 2020 16:17:05 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaLd-0000oX-M2 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:07:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586068; 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=8TcsSF8KRJ3cP4NXTpnMB/PJvDV7qxosAjn0EsJkqoI=; b=ZuYBp5vg4j3X985JuEG402s3b0ysm+aKzbPS3paTdIDquRyuNVHTdsjo+Tbi32pi/PCo7v 1toCV5cH0Ws4FYbNvRegLuzNSId+SXRPcJSLb3esFadMYdhmPQfiZl1KqldKLT9QM49Ae4 aQsjgtQWbsJTDzgIulN25Hkkx5IjRH8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-MX486d2MOwKvD3-7GwLfmw-1; Thu, 09 Jan 2020 11:07:44 -0500 Received: by mail-wm1-f71.google.com with SMTP id z2so620338wmf.5 for ; Thu, 09 Jan 2020 08:07:44 -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=xG6sElk1TWaSPfOVhfzeE5hLeD/94IftIcvZ9UXhm3w=; b=msn/ZEs2D3g8Tv3c1OwTJYtJ51RfyqDdW1hLi/pevoVvwsMTMJf+KU+mm4wLdbsyR8 SVlB5zFKQhToNmO4pDW7otHo/J9svZ/WPPqBDZisGT9vfxFvd4LPngD9huzsJbUaZ9V8 ICK3tZYGMMhG9jvBQWotXK9buklGR2QrSgMN0s6gGk//VAbnm1Phwp3E1DOzMtCXZ9Sz nXrGUmqrN8VUjrYeyEExQ2cYHb3wfav8qrFgvyubRdnUSu95Lm9rmxlIlULfmIVUj7Yi 9vyke1yD749wnY/RvXMuwUrXBTi/INO+m2ZPS9DKClFyFlNniCryvVE1majoWit9bFER zRew== X-Gm-Message-State: APjAAAWbehsCqdd8Oi9UVekgMV6LO+EFTCE4k/joPriyFhMJiw4qKve7 d4xV7dBffuHqjE00LD82YQsusO7CL/WyNp5NtM8Gs1CIukVKZywlMUgk8shYgyZCvxJeYjIpd9y Yy3zxmLDiYHqbIBLMTJb1o4pqds6nD2hXK1c= X-Received: by 2002:a7b:c750:: with SMTP id w16mr6085416wmk.46.1578586063348; Thu, 09 Jan 2020 08:07:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwWrOqLS9+8+0m7ijSmLbqAeygM5PyihSPgaHJWkEuiZnRqKxhbclKLJ2IbV39zii6sYZGEFQ== X-Received: by 2002:a7b:c750:: with SMTP id w16mr6085384wmk.46.1578586063095; Thu, 09 Jan 2020 08:07:43 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id h2sm8591413wrv.66.2020.01.09.08.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:07:42 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 39/57] objtool: arm64: Decode load literal Date: Thu, 9 Jan 2020 16:02:42 +0000 Message-Id: <20200109160300.26150-40-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: MX486d2MOwKvD3-7GwLfmw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080749_815174_E82307E9 X-CRM114-Status: GOOD ( 14.90 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode load literal instruction. Aarch64 load literal is a pseudo-instruction (part of the instruction set) that allows to load literal values may cannot be encoded within a single instruction. The GNU assembler implementation of the pseudo instruction generates constant data within the same section as the pseudo-instruction itself. That data could very well be a valid opcode (e.g. jump, return, stack operation, etc) which confuses objtool. Mark the "instructions" corresponding to load literal offsets as invalid as they should never be reach by the execution flow. Signed-off-by: Julien Thierry --- tools/objtool/arch.h | 3 + tools/objtool/arch/arm64/decode.c | 88 +++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 3 + tools/objtool/arch/x86/decode.c | 5 ++ tools/objtool/check.c | 3 + 5 files changed, 102 insertions(+) diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index 0336efecb9d9..829d6d73aec6 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -68,6 +68,7 @@ struct stack_op { struct list_head list; }; +struct objtool_file; struct instruction; void arch_initial_func_cfi_state(struct cfi_state *state); @@ -78,6 +79,8 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, unsigned long *immediate, struct list_head *ops_list); +int arch_post_process_file(struct objtool_file *file); + bool arch_callee_saved_reg(unsigned char reg); unsigned long arch_jump_destination(struct instruction *insn); diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index bc4c62401012..aed8ba0f812e 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -18,6 +18,47 @@ static bool stack_related_reg(int reg) return reg == CFI_SP || reg == CFI_BP; } +struct insn_loc { + struct section *sec; + unsigned long offset; + struct hlist_node hnode; +}; + +DEFINE_HASHTABLE(text_constants, 16); + +int arch_post_process_file(struct objtool_file *file) +{ + struct hlist_node *tmp; + struct insn_loc *loc; + unsigned int bkt; + int res = 0; + + /* + * Data placed in code sections could turn out to be a valid aarch64 + * opcode. + * If that is the case, change the insn type to invalid as it should + * never be reached by the execution flow. + */ + hash_for_each_safe(text_constants, bkt, tmp, loc, hnode) { + struct instruction *insn; + + insn = find_insn(file, loc->sec, loc->offset); + if (insn) { + insn->type = INSN_INVALID; + } else { + WARN("failed to find constant at %s+0x%lx", + loc->sec->name, loc->offset); + res = -1; + } + hash_del(&loc->hnode); + free(loc); + } + + return res; +} + +static struct insn_loc current_location; + bool arch_callee_saved_reg(unsigned char reg) { switch (reg) { @@ -127,6 +168,8 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, //retrieve instruction (from sec->data->offset) insn = *(u32 *)(sec->data->d_buf + offset); + current_location.sec = sec; + current_location.offset = offset; //dispatch according to encoding classes decode_fun = aarch64_insn_class_decode_table[INSN_CLASS(insn)]; if (decode_fun) @@ -136,6 +179,9 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, if (res) WARN_FUNC("Unsupported instruction", sec, offset); + + memset(¤t_location, 0, sizeof(current_location)); + return res; } @@ -845,6 +891,11 @@ static struct aarch64_insn_decoder ld_st_decoder[] = { .value = 0b000101000000000, .decode_func = arm_decode_ldapr_stlr_unsc_imm, }, + { + .mask = 0b001101000000000, + .value = 0b000100000000000, + .decode_func = arm_decode_ld_regs_literal, + }, { .mask = 0b001101100000000, .value = 0b001000000000000, @@ -1350,6 +1401,43 @@ int arm_decode_ld_st_exclusive(u32 instr, enum insn_type *type, #undef LDLAR_64 #undef LDAR_64 +int arm_decode_ld_regs_literal(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + unsigned char opc = 0, V = 0; + long pc_offset; + struct insn_loc *loc; + + opc = (instr >> 30) & ONES(2); + V = EXTRACT_BIT(instr, 26); + + if (((opc << 1) | V) == 0x7) + return arm_decode_unknown(instr, type, immediate, ops_list); + + pc_offset = instr & GENMASK(23, 5); + + /* Sign extend and multiply by 4 */ + pc_offset = (pc_offset << (64 - 23)); + pc_offset = ((pc_offset >> (64 - 23)) >> 5) << 2; + + loc = malloc(sizeof(*loc)); + loc->sec = current_location.sec; + loc->offset = current_location.offset + pc_offset; + hash_add(text_constants, &loc->hnode, loc->offset); + + /* 64-bit literal */ + if (opc & 1) { + loc = malloc(sizeof(*loc)); + loc->sec = current_location.sec; + loc->offset = current_location.offset + pc_offset + 4; + hash_add(text_constants, &loc->hnode, loc->offset); + } + + *type = INSN_OTHER; + return 0; +} + int arm_decode_ld_st_regs_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list) diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index e6a62691b487..3ec4c69547ac 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -112,6 +112,9 @@ int arm_decode_ld_st_mem_tags(u32 instr, enum insn_type *type, int arm_decode_ldapr_stlr_unsc_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_ld_regs_literal(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_ld_st_noalloc_pair_off(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 650e5d021486..57a5f817a63c 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -497,6 +497,11 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, return 0; } +int arch_post_process_file(struct objtool_file *file) +{ + return 0; +} + void arch_initial_func_cfi_state(struct cfi_state *state) { int i; diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 52a8e64e15ca..e0c6bda261c8 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -279,6 +279,9 @@ static int decode_instructions(struct objtool_file *file) } } + if (arch_post_process_file(file)) + return -1; + return 0; err: From patchwork Thu Jan 9 16:02:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8FC9921 for ; Thu, 9 Jan 2020 16:18:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B85BD206ED for ; Thu, 9 Jan 2020 16:18:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DrMMZqRk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QajPWRSg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B85BD206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Xli3ncsd5B+z1Xx9iWDNwqGz/eMb/QX3yCGSHpQ61tI=; b=DrMMZqRkj5g/NY Je2CXDIeM52oRa6gJLex0aL+kI6nzyVOJhO2cLkI7Q757Euw2eu+/hv738+MWwhtTMzJw/+KkbEHE lbJOvLcREUZMh+2E3WrwdvS5YGZ77PEpCIpQSHMHqyytwljJvOgrZRbaQPkaY672xTT3XTD52GIm3 8lKrGr38RHTCfm8SJX5WhvvbPqR+a7Ii2zaRPArnUbVOlRcmzB4+DovOSV8yZ9U16PkrSf3GGi3s+ ScRltNR7LRkcH9y7fk/QXrp9Ejq4SUQ4AhiW51nGcImmS7syOiaRe08eUWjtwyRIcyvnZXhY1YUQ0 QmAGSEeWz9rDZ2o7reYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaVT-00043D-KI; Thu, 09 Jan 2020 16:17:59 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMB-0001Lk-1t for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:08:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586101; 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=LYNlKLmqsbZC/fAq3Wq7DT2fo1/NaEEPL9lYjtLxQgw=; b=QajPWRSggc3IT4+RY/YyjvuAjndalagEtT1LftR51lhQHXIWMiOOYN61BCstD6D5e2o1cY e6SQLu5ph6RvWcCYtOugqDJZ6OyIxBtEmh/BERpbjja6IUYJeLqcLHSo8avWHqW2C1FRuK 9WGjB+MZqE7HX8RLYlgVOLypzD1Ug88= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-sg9u4Zg_MxafI5dIkpLfuQ-1; Thu, 09 Jan 2020 11:08:17 -0500 Received: by mail-wr1-f71.google.com with SMTP id d8so3037436wrq.12 for ; Thu, 09 Jan 2020 08:08:17 -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=ZBv8vu7vm5b/St4SQhnQrbm+mPlTxzkdMK/VqAAC9ps=; b=LSgNxv485meHfU70kL793IzcAANH9SIX30DLjuupVbOMtS16A1CBPH9aFvW4wMuHXZ XB/KxKzjcFI+vrCFRX6QoDLdJDVVarUcD/B9Pya1ockuPCW7fbTbSyr1f9plQ0w27RlX tMEsNiUnFfIFJvBVM9fSbS9fr2G/O88AFE2qBPUkI6umAzJ63VCLVB9K4820m2vJ6UUO j6tX2iEO9nhSKG9XhyxK+F/bVCVSKOBvB791UmGYVFclCgTHlZFsZIuFTgwIB6OqhsRg YHJn+bl0n3zkX77Mb07XRgZrEWMU1aGmAGnoQdBYDE/TOC/AokeVOd5Y59+dbY52uUE4 VJ7Q== X-Gm-Message-State: APjAAAXQ/6IZMiEzonXrMzYzUxhtl3VuysDHLdC0dGcYHgl26EOwDn40 SVF/mOBZRTAKvCv3ND1DHX5Ha7d7wb2uhCfvqh9Z93jCX6UWIroZRu/00Rcg7BK6VQssub6w4xh F+h2f+98ANZ36g+wRX5iUS3VZAxm5uiBc7rE= X-Received: by 2002:a1c:7d8b:: with SMTP id y133mr5553858wmc.165.1578586096235; Thu, 09 Jan 2020 08:08:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzEpPRHZehtfPC+YY7nOMjooKnEIZisD06WTX2HlS6iQAPTRamE7Xul8iV+xsBwYHmGFnVQRw== X-Received: by 2002:a1c:7d8b:: with SMTP id y133mr5553822wmc.165.1578586095790; Thu, 09 Jan 2020 08:08:15 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m10sm8562605wrx.19.2020.01.09.08.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:15 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 40/57] objtool: arm64: Decode register data processing instructions Date: Thu, 9 Jan 2020 16:02:43 +0000 Message-Id: <20200109160300.26150-41-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: sg9u4Zg_MxafI5dIkpLfuQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080823_305972_2A63CEC0 X-CRM114-Status: GOOD ( 10.17 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode data processing instructions with more than one register as input operand. Due to these multiple register inputs, objtool cannot rely on those instructions to track the CFA state. Luckily, the compiler does not tend to generate these instructions to modify the stack or frame pointer. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 471 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 42 ++ 2 files changed, 513 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index aed8ba0f812e..bb1ba3b0997f 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -128,10 +128,12 @@ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_UNKNOWN] = arm_decode_unknown, [INSN_UNALLOC] = arm_decode_unknown, [INSN_LD_ST_4] = arm_decode_ld_st, + [INSN_DP_REG_5] = arm_decode_dp_reg, [INSN_LD_ST_6] = arm_decode_ld_st, [0b1000 ... INSN_DP_IMM] = arm_decode_dp_imm, [0b1010 ... INSN_SYS_BRANCH] = arm_decode_br_sys, [INSN_LD_ST_C] = arm_decode_ld_st, + [INSN_DP_REG_D] = arm_decode_dp_reg, [INSN_LD_ST_E] = arm_decode_ld_st, }; @@ -2275,3 +2277,472 @@ int arm_decode_ld_st_mem_tags(u32 instr, enum insn_type *type, return -1; } + +static struct aarch64_insn_decoder dp_reg_decoder[] = { + { + .mask = 0b111111000000, + .value = 0b010110000000, + .decode_func = arm_decode_dp_reg_2src, + }, + { + .mask = 0b111111000000, + .value = 0b110110000000, + .decode_func = arm_decode_dp_reg_1src, + }, + { + .mask = 0b011000000000, + .value = 0b000000000000, + .decode_func = arm_decode_dp_reg_logi, + }, + { + .mask = 0b011001000000, + .value = 0b001000000000, + .decode_func = arm_decode_dp_reg_adds, + }, + { + .mask = 0b011001000000, + .value = 0b001001000000, + .decode_func = arm_decode_dp_reg_adde, + }, + { + .mask = 0b011111111111, + .value = 0b010000000000, + .decode_func = arm_decode_dp_reg_addc, + }, + { + .mask = 0b011111011111, + .value = 0b010000000001, + .decode_func = arm_decode_dp_reg_rota, + }, + { + .mask = 0b011111001111, + .value = 0b010000000010, + .decode_func = arm_decode_dp_reg_eval, + }, + { + .mask = 0b011111000010, + .value = 0b010010000000, + .decode_func = arm_decode_dp_reg_cmpr, + }, + { + .mask = 0b011111000010, + .value = 0b010010000010, + .decode_func = arm_decode_dp_reg_cmpi, + }, + { + .mask = 0b011111000000, + .value = 0b010100000000, + .decode_func = arm_decode_dp_reg_csel, + }, + { + .mask = 0b011000000000, + .value = 0b011000000000, + .decode_func = arm_decode_dp_reg_3src, + }, +}; + +int arm_decode_dp_reg(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char op0 = 0, op1 = 0, op2 = 0, op3 = 0; + u32 decode_field = 0; + int i = 0; + + op0 = EXTRACT_BIT(instr, 30); + op1 = EXTRACT_BIT(instr, 28); + op2 = (instr >> 21) & ONES(4); + op3 = (instr >> 10) & ONES(6); + decode_field = (op0 << 5) | (op1 << 4) | op2; + decode_field = (decode_field << 6) | op3; + + for (i = 0; i < ARRAY_SIZE(dp_reg_decoder); i++) { + if ((decode_field & dp_reg_decoder[i].mask) == + dp_reg_decoder[i].value) { + return dp_reg_decoder[i].decode_func(instr, type, + immediate, ops_list); + } + } + return arm_decode_unknown(instr, type, immediate, ops_list); +} + +static struct aarch64_insn_decoder dp_reg_2src_decoder[] = { + { + .mask = 0b00111111, + .value = 0b00000001, + }, + { + .mask = 0b00111000, + .value = 0b00011000, + }, + { + .mask = 0b00100000, + .value = 0b00100000, + }, + { + .mask = 0b01111111, + .value = 0b00000101, + }, + { + .mask = 0b01111100, + .value = 0b00001100, + }, + { + .mask = 0b01111110, + .value = 0b01000010, + }, + { + .mask = 0b01111100, + .value = 0b01000100, + }, + { + .mask = 0b01111000, + .value = 0b01001000, + }, + { + .mask = 0b01110000, + .value = 0b01010000, + }, + { + .mask = 0b10111111, + .value = 0b00000000, + }, + { + .mask = 0b11111111, + .value = 0b00000100, + }, + { + .mask = 0b11111110, + .value = 0b00000110, + }, + { + .mask = 0b11111011, + .value = 0b00010011, + }, + { + .mask = 0b11111001, + .value = 0b10010000, + }, + { + .mask = 0b11111010, + .value = 0b10010000, + }, +}; + +int arm_decode_dp_reg_2src(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, S = 0, opcode = 0; + unsigned char decode_field = 0; + int i = 0; + + sf = EXTRACT_BIT(instr, 31); + S = EXTRACT_BIT(instr, 29); + opcode = (instr >> 10) & ONES(6); + + decode_field = (sf << 7) | (S << 6) | opcode; + + for (i = 0; i < ARRAY_SIZE(dp_reg_2src_decoder); i++) { + if ((decode_field & dp_reg_2src_decoder[i].mask) == + dp_reg_2src_decoder[i].value) { + return arm_decode_unknown(instr, type, immediate, + ops_list); + } + } + + *type = INSN_OTHER; + return 0; +} + +static struct aarch64_insn_decoder dp_reg_1src_decoder[] = { + { + .mask = 0b0000000001000, + .value = 0b0000000001000, + }, + { + .mask = 0b0000000010000, + .value = 0b0000000010000, + }, + { + .mask = 0b0000000100000, + .value = 0b0000000100000, + }, + { + .mask = 0b0000001000000, + .value = 0b0000001000000, + }, + { + .mask = 0b0000010000000, + .value = 0b0000010000000, + }, + { + .mask = 0b0000100000000, + .value = 0b0000100000000, + }, + { + .mask = 0b0001000000000, + .value = 0b0001000000000, + }, + { + .mask = 0b0010000000000, + .value = 0b0010000000000, + }, + { + .mask = 0b0111111111110, + .value = 0b0000000000110, + }, + { + .mask = 0b0100000000000, + .value = 0b0100000000000, + }, +}; + +int arm_decode_dp_reg_1src(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, S = 0, opcode2 = 0, opcode = 0; + u32 decode_field = 0; + int i = 0; + + sf = EXTRACT_BIT(instr, 31); + S = EXTRACT_BIT(instr, 29); + opcode2 = (instr >> 16) & ONES(5); + opcode = (instr >> 10) & ONES(6); + + decode_field = (sf << 6) | (S << 5) | opcode2; + decode_field = (decode_field << 6) | opcode; + + for (i = 0; i < ARRAY_SIZE(dp_reg_1src_decoder); i++) { + if ((decode_field & dp_reg_1src_decoder[i].mask) == + dp_reg_1src_decoder[i].value) { + return arm_decode_unknown(instr, type, immediate, + ops_list); + } + } + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_logi(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, imm6 = 0; + + sf = EXTRACT_BIT(instr, 31); + imm6 = (instr >> 10) & ONES(6); + + if (imm6 >= 0b100000 && !sf) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_adds(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, shift = 0, imm6 = 0; + + sf = EXTRACT_BIT(instr, 31); + shift = (instr >> 22) & ONES(2); + imm6 = (instr >> 10) & ONES(6); + + if ((imm6 >= 0b100000 && !sf) || shift == 0b11) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_adde(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char opt = 0, imm3 = 0; + + opt = (instr >> 22) & ONES(2); + imm3 = (instr >> 10) & ONES(3); + + if (opt != 0 || imm3 >= 0b101) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_addc(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_rota(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, S = 0, op_bit = 0, o2 = 0; + unsigned char decode_field = 0; + + sf = EXTRACT_BIT(instr, 31); + op_bit = EXTRACT_BIT(instr, 30); + S = EXTRACT_BIT(instr, 29); + o2 = EXTRACT_BIT(instr, 4); + + decode_field = (sf << 3) | (op_bit << 2) | (S << 1) | o2; + + if (decode_field != 0b1010) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_eval(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, S = 0, op_bit = 0, o3 = 0, sz = 0; + unsigned char opcode2 = 0, mask = 0; + u32 decode_field = 0; + + sf = EXTRACT_BIT(instr, 31); + op_bit = EXTRACT_BIT(instr, 30); + S = EXTRACT_BIT(instr, 29); + sz = EXTRACT_BIT(instr, 14); + o3 = EXTRACT_BIT(instr, 4); + + opcode2 = (instr >> 15) & ONES(6); + mask = instr & ONES(4); + + decode_field = (sf << 2) | (op_bit << 1) | S; + decode_field = (decode_field << 12) | (opcode2 << 6) | (sz << 5); + decode_field |= (o3 << 4) | mask; + +#define DP_EVAL_SETF_1 0b001000000001101 +#define DP_EVAL_SETF_2 0b001000000101101 + + if (decode_field != DP_EVAL_SETF_1 && + decode_field != DP_EVAL_SETF_2) { + return arm_decode_unknown(instr, type, immediate, ops_list); + } + + *type = INSN_OTHER; + return 0; +#undef DP_EVAL_SETF_1 +#undef DP_EVAL_SETF_2 +} + +int arm_decode_dp_reg_cmpr(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char S = 0, o2 = 0, o3 = 0; + + S = EXTRACT_BIT(instr, 29); + o2 = EXTRACT_BIT(instr, 10); + o3 = EXTRACT_BIT(instr, 4); + + if (!S || o2 || o3) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_csel(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char S = 0, op2 = 0; + + S = EXTRACT_BIT(instr, 29); + op2 = (instr >> 10) & ONES(2); + + if (S || op2 >= 0b10) + return arm_decode_unknown(instr, type, immediate, ops_list); + + *type = INSN_OTHER; + return 0; +} + +int arm_decode_dp_reg_cmpi(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + return arm_decode_dp_reg_cmpr(instr, type, immediate, ops_list); +} + +static struct aarch64_insn_decoder dp_reg_3src_decoder[] = { + { + .mask = 0b0111111, + .value = 0b0000101, + }, + { + .mask = 0b0111110, + .value = 0b0000110, + }, + { + .mask = 0b0111110, + .value = 0b0001000, + }, + { + .mask = 0b0111111, + .value = 0b0001101, + }, + { + .mask = 0b0111110, + .value = 0b0001110, + }, + { + .mask = 0b0110000, + .value = 0b0010000, + }, + { + .mask = 0b0100000, + .value = 0b0100000, + }, + { + .mask = 0b1111111, + .value = 0b0000010, + }, + { + .mask = 0b1111111, + .value = 0b0000011, + }, + { + .mask = 0b1111111, + .value = 0b0000100, + }, + { + .mask = 0b1111111, + .value = 0b0001010, + }, + { + .mask = 0b1111111, + .value = 0b0001011, + }, + { + .mask = 0b1111111, + .value = 0b0001100, + }, +}; + +int arm_decode_dp_reg_3src(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + unsigned char sf = 0, op54 = 0, op31 = 0, o0 = 0; + unsigned char decode_field = 0; + int i = 0; + + sf = EXTRACT_BIT(instr, 31); + op54 = (instr >> 29) & ONES(2); + op31 = (instr >> 21) & ONES(3); + o0 = EXTRACT_BIT(instr, 15); + + decode_field = (sf << 6) | (op54 << 4) | (op31 << 1) | o0; + + for (i = 0; i < ARRAY_SIZE(dp_reg_3src_decoder); i++) { + if ((decode_field & dp_reg_3src_decoder[i].mask) == + dp_reg_3src_decoder[i].value) { + return arm_decode_unknown(instr, type, immediate, + ops_list); + } + } + + *type = INSN_OTHER; + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 3ec4c69547ac..8fb2f2b7564f 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -14,6 +14,8 @@ #define INSN_LD_ST_6 0b0110 //0bx1x0 #define INSN_LD_ST_C 0b1100 //0bx1x0 #define INSN_LD_ST_E 0b1110 //0bx1x0 +#define INSN_DP_REG_5 0b0101 //0bx101 +#define INSN_DP_REG_D 0b1101 //0bx101 #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) @@ -39,6 +41,8 @@ struct aarch64_insn_decoder { /* arm64 instruction classes */ int arm_decode_dp_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_dp_reg(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_br_sys(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_ld_st(u32 instr, enum insn_type *type, @@ -153,4 +157,42 @@ int arm_decode_ld_st_regs_unsigned(u32 instr, enum insn_type *type, int arm_decode_ld_st_exclusive(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); + +/* arm64 data processing -- registers instructions */ +int arm_decode_dp_reg_1src(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_2src(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_3src(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_adde(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_cmpi(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_eval(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_cmpr(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_rota(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_csel(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_addc(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_adds(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); +int arm_decode_dp_reg_logi(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); #endif /* _ARM_INSN_DECODE_H */ From patchwork Thu Jan 9 16:02:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 534AE139A for ; Thu, 9 Jan 2020 16:17:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 160092072A for ; Thu, 9 Jan 2020 16:17:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="df/zhuUX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h1JHEEcM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 160092072A 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=VSd6v2XCL7tjAIUpojFe9tj7oEaJSCkG3u8y79n717U=; b=df/zhuUXAYgHtE 6wC9+Peg/4uJ79If3E40+pquugoSyL17Mv65CunnmiiYSeAiQYrdJizI1t2hTMY4oLmPiFjtHzxjU 5Iz3NO6QW92ODeYKpjMIVasGmtiz91/Hm3jFl3Vif7STrwZPeHTy2pPBQplaY9ecGW3EKe9FTQMM/ tByeYYurDoaAl70IJrXu8pZndvxUBBCqUQ/tfuLF138SWeux866e5Kwd4xF/14sYNvIb5C6hToZRk s5CdqHc1f9QUyQu2dDaFRnkToD4iToayU0WxGCZYBMeHWxp+3JjffUSPqMMdrAjpQzngnAdVfHKvj jgDnNmPsOviyljxAmNGg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaUz-0003aQ-H6; Thu, 09 Jan 2020 16:17:29 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaM9-0001L2-W1 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:08:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586100; 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=rFm9gf9gb1rpbh9IIFaCN3a2qwtakzanEH8ecK3aAqY=; b=h1JHEEcMsF9gx8FbMN2G3hleAqHgfyeg72D4L3ZvCYKBgLpZG+qyxbc/SmnaYFyNOG2O3M GZ7ATgwJ8UTXv/nFwy8ZhEC9pprPFI90c9cP5l46avsC5PHB7qOSRnoHv1GpgkrXxRPEhn CxOyECCLFpbtBxtw1fhjR1Pj3wEHZM0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-Qe_-T9s9Oe-BaMHxBUsqxw-1; Thu, 09 Jan 2020 11:08:18 -0500 Received: by mail-wm1-f69.google.com with SMTP id b9so1097526wmj.6 for ; Thu, 09 Jan 2020 08:08:18 -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=ctt7fi/3NhIYPlxgrIxpO4KG6ezkTHoGLojp3YwAvJc=; b=qI/lQ+vJDkq2SxAsgOVSyciz4q/JJ+d7jaKJTY5h/gXePw8rGilgesr0XxWjKrZTJe 75u3F5Q1JW++T2Yywy2bQau1zOZxN7X4/s9TezxnPysEq4WEiZlzZ7lMu9IpJGBaKFx0 NrPjvez5kSzHBhM0+qB5ySwBd5tYlBRrTzhxnbTQI+Td57s/1I2YHl7T8if2sN1cPQnU x483WEdIzxPPJBU0eJlaTlEbwbaaoXzjMdYbEgf23MLoppDGNehKGlu+uxV+DcyPvgDo PkerLjpcgKXAPXFzRMAACdNTY8EzHdXuq/fK9Ltga/zJwjY96ik6BlavjPACyhjWBoGG 7EZg== X-Gm-Message-State: APjAAAWRXdMNy8lqMYMV2/AbuX274d2dJbFTBfYt5gcdAVXcMLZwreBl s74J6qGJvhqUfzs2lpuTOjs+aqKTEZIqlTRKXDH/mKKrF+1/a/S3Qk0GVa7t9cdLzIGnMAsI+tW Ax3AclKq41v6OTX5hsDSetPqu8YhlYLjMITI= X-Received: by 2002:a05:600c:2488:: with SMTP id 8mr5704793wms.152.1578586097769; Thu, 09 Jan 2020 08:08:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxjzv/MBj0UUOLxwAZL7QjHdlmjkQxcm6p51hFdYJfwpTI9BGX+m6/4LY2WFg1fDeMR4LNnNQ== X-Received: by 2002:a05:600c:2488:: with SMTP id 8mr5704783wms.152.1578586097594; Thu, 09 Jan 2020 08:08:17 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m10sm8562605wrx.19.2020.01.09.08.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:16 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 41/57] objtool: arm64: Decode FP/SIMD data processing instructions Date: Thu, 9 Jan 2020 16:02:44 +0000 Message-Id: <20200109160300.26150-42-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: Qe_-T9s9Oe-BaMHxBUsqxw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080822_226362_66DFDD76 X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org FP/SIMD data processing instructions cannot modify the stack or frame pointer. Simply acknowledge the corresponding opcodes are valid. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 9 +++++++++ tools/objtool/arch/arm64/include/insn_decode.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index bb1ba3b0997f..d35c2b58d309 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -130,11 +130,13 @@ static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_LD_ST_4] = arm_decode_ld_st, [INSN_DP_REG_5] = arm_decode_dp_reg, [INSN_LD_ST_6] = arm_decode_ld_st, + [INSN_DP_SIMD_7] = arm_decode_dp_simd, [0b1000 ... INSN_DP_IMM] = arm_decode_dp_imm, [0b1010 ... INSN_SYS_BRANCH] = arm_decode_br_sys, [INSN_LD_ST_C] = arm_decode_ld_st, [INSN_DP_REG_D] = arm_decode_dp_reg, [INSN_LD_ST_E] = arm_decode_ld_st, + [INSN_DP_SIMD_F] = arm_decode_dp_simd, }; /* @@ -2746,3 +2748,10 @@ int arm_decode_dp_reg_3src(u32 instr, enum insn_type *type, *type = INSN_OTHER; return 0; } + +int arm_decode_dp_simd(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list) +{ + *type = INSN_OTHER; + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 8fb2f2b7564f..2bff4d7da007 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -16,6 +16,8 @@ #define INSN_LD_ST_E 0b1110 //0bx1x0 #define INSN_DP_REG_5 0b0101 //0bx101 #define INSN_DP_REG_D 0b1101 //0bx101 +#define INSN_DP_SIMD_7 0b0111 //0bx111 +#define INSN_DP_SIMD_F 0b1111 //0bx111 #define NR_INSN_CLASS 16 #define INSN_CLASS(opcode) (((opcode) >> 25) & (NR_INSN_CLASS - 1)) @@ -47,6 +49,8 @@ int arm_decode_br_sys(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_ld_st(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); +int arm_decode_dp_simd(u32 instr, enum insn_type *type, + unsigned long *immediate, struct list_head *ops_list); int arm_decode_unknown(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); From patchwork Thu Jan 9 16:02:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14991921 for ; Thu, 9 Jan 2020 16:17:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D929020661 for ; Thu, 9 Jan 2020 16:17:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V0DpIuPo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OpUk9eYj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D929020661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=mdt4QxHcNOEW/OSzdVq4rufUaYb2EyV9aMQQQGj37Q8=; b=V0DpIuPo9zaW5T XmDh7tk7pXlkYohY07urutrArI/2pR6/HbwGpqOF+rHTTawHiwqVvL0/sbd/rYNJaJhRGArhUnXzU 7+aegEZQb073UlpjfSUIpi8jN4mxkGXoKFeCVRjwgKtipLFCtVDa/ONMV6iUqDoMRDSh2Mz0Ekk7j 0MXbQ8NFTjhWGuPVIyiLfMa7oX2zZkruTpvJ5xB2tW/jr9U8tCk0uM2LjfeNzpCXoA5cDTODFPwWv x0wH/CWoNsjARPVH5xl+eZEbCERUibm67qEIqY1z36ThNLLRbkpDNNfEbbQF4I/VsVBqWMrZfiQGn aoCgspzDRWspnv4+o0yQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaV9-0003l1-3v; Thu, 09 Jan 2020 16:17:39 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMB-0001Ma-LJ for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:08:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586102; 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=1QGQugkWC7aDIoxdwItWbSkyE3m0lRZkaG/Q9hC66PQ=; b=OpUk9eYjMCAGgbx7RNqzN0L9vemgK3seiIr99qfa6VAH6OxqVPaTCwA8tqjAOdSfbm0cAe 3kvIp9eshEOQJhiz9qvYZavm2n0UMNSC7ZctxhZWqX3DM78ZjVx3kHwlEUbk02i92CTN8Z hDvYdryldblKS5W2YIVqyr4pKKcj9/c= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-ZKrD1rYYM86AG6VkD5IjAA-1; Thu, 09 Jan 2020 11:08:20 -0500 Received: by mail-wm1-f71.google.com with SMTP id b9so1097549wmj.6 for ; Thu, 09 Jan 2020 08:08:20 -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=TNAXbPtYol4IFhdKQN1YW+us8aGhYHcAVGnDfkl/GLg=; b=kJGbI18cdSZOG/kvOdqhyjamD7hhrosyO6giBAxv2aNzjHNW5CKYrPqoPosT+RMgV7 eKovVIolfb4fc59/0UKXNaMQBeme1KmIy42M6EcxVykn9kqnCFq2exLNyDqX/bwKUNHR OfEbMKPdbGJfPzbaj8/7kmqEir2a1M0chzbShgLp/Q1fgNKe+cAjwMBTGJAPhcTW7pqF JQxnuIkH/zQjOmvd9Bo8ZKs/A/w9WGgMRWQqq4/ca56YD6IVIKdNSLWnd7le2FXoqEuu HQMTqSZpgvwPnC/kGu5I38nc4f7UlH9TI9uRfCRIwODzbV8Y3QqWkOyirboGNoCWF8u2 tAZg== X-Gm-Message-State: APjAAAUO5uvWAJIsPjpxLoVshK3Jd4H8cgiVyVdiAweg8dubLpLwSOLx X489AOAOXFZzTmMKv7OKY7RtQXlwKT12Qwl+rEgifyl1WlpT9GqlmX9ZbWtlaWTbEPzEMOODsCf UFLBeR/FNi8eB8uqQxJTmZQFtz3/iUGSedAA= X-Received: by 2002:a7b:c957:: with SMTP id i23mr5784655wml.49.1578586099469; Thu, 09 Jan 2020 08:08:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwVETqaEKCmXpHz5yplDHZ/sfX5dJd+AzP3YinwYC57N0IL5r0ZPXWJGPR5IniwcSWePRIULw== X-Received: by 2002:a7b:c957:: with SMTP id i23mr5784636wml.49.1578586099286; Thu, 09 Jan 2020 08:08:19 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m10sm8562605wrx.19.2020.01.09.08.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:18 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 42/57] objtool: arm64: Decode SVE instructions Date: Thu, 9 Jan 2020 16:02:45 +0000 Message-Id: <20200109160300.26150-43-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: ZKrD1rYYM86AG6VkD5IjAA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080823_820815_8648B3BE X-CRM114-Status: GOOD ( 11.41 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Decode instructions from the SVE architecture extension. These instructions do not modify the stack or frame pointer. Simply acknowledge the corresponding opcodes are valid. Suggested-by: Raphael Gault Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/decode.c | 109 ++++++++++++++++++ .../objtool/arch/arm64/include/insn_decode.h | 4 + 2 files changed, 113 insertions(+) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index d35c2b58d309..5a5f82b5cb81 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -126,6 +126,7 @@ static int is_arm64(struct elf *elf) static arm_decode_class aarch64_insn_class_decode_table[NR_INSN_CLASS] = { [INSN_RESERVED] = arm_decode_unknown, [INSN_UNKNOWN] = arm_decode_unknown, + [INSN_SVE_ENC] = arm_decode_sve_encoding, [INSN_UNALLOC] = arm_decode_unknown, [INSN_LD_ST_4] = arm_decode_ld_st, [INSN_DP_REG_5] = arm_decode_dp_reg, @@ -2755,3 +2756,111 @@ int arm_decode_dp_simd(u32 instr, enum insn_type *type, *type = INSN_OTHER; return 0; } + +static struct aarch64_insn_decoder sve_enc_decoder[] = { + { + .mask = 0b1111010000111000, + .value = 0b0000010000011000, + }, + { + .mask = 0b1111110000111000, + .value = 0b0001110000000000, + }, + { + .mask = 0b1111010000110000, + .value = 0b0011010000010000, + }, + { + .mask = 0b1111011100111000, + .value = 0b0011010100101000, + }, + { + .mask = 0b1111011000110000, + .value = 0b0011011000100000, + }, + { + .mask = 0b1111010000100000, + .value = 0b0100000000100000, + }, + { + .mask = 0b1111000000000000, + .value = 0b0101000000000000, + }, + { + .mask = 0b1111011111111000, + .value = 0b0110000000101000, + }, + { + .mask = 0b1111011111110000, + .value = 0b0110000000110000, + }, + { + .mask = 0b1111011111100000, + .value = 0b0110000001100000, + }, + { + .mask = 0b1111011110100000, + .value = 0b0110000010100000, + }, + { + .mask = 0b1111011100100000, + .value = 0b0110000100100000, + }, + { + .mask = 0b1111011000100000, + .value = 0b0110001000100000, + }, + { + .mask = 0b1111010000110110, + .value = 0b0110010000000010, + }, + { + .mask = 0b1111010000111111, + .value = 0b0110010000001001, + }, + { + .mask = 0b1111010000111100, + .value = 0b0110010000001100, + }, + { + .mask = 0b1111010000110000, + .value = 0b0110010000010000, + }, + { + .mask = 0b1111010000100000, + .value = 0b0110010000100000, + }, + { + .mask = 0b1111011100111100, + .value = 0b0111000100001000, + }, +}; + +int arm_decode_sve_encoding(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list) +{ + int i = 0; + unsigned char op0 = 0, op1 = 0, op2 = 0, op3 = 0; + u32 decode_field = 0; + + op0 = (instr >> 29) & ONES(3); + op1 = (instr >> 23) & ONES(2); + op2 = (instr >> 17) & ONES(5); + op3 = (instr >> 10) & ONES(6); + + decode_field = (op0 << 2) | op1; + decode_field = (decode_field << 5) | op2; + decode_field = (decode_field << 6) | op3; + + for (i = 0; i < ARRAY_SIZE(sve_enc_decoder); i++) { + if ((decode_field & sve_enc_decoder[i].mask) == + sve_enc_decoder[i].value) + return arm_decode_unknown(instr, type, immediate, + ops_list); + } + + *type = INSN_OTHER; + + return 0; +} diff --git a/tools/objtool/arch/arm64/include/insn_decode.h b/tools/objtool/arch/arm64/include/insn_decode.h index 2bff4d7da007..89cff8791c0b 100644 --- a/tools/objtool/arch/arm64/include/insn_decode.h +++ b/tools/objtool/arch/arm64/include/insn_decode.h @@ -7,6 +7,7 @@ #define INSN_RESERVED 0b0000 #define INSN_UNKNOWN 0b0001 +#define INSN_SVE_ENC 0b0010 #define INSN_UNALLOC 0b0011 #define INSN_DP_IMM 0b1001 //0x100x #define INSN_SYS_BRANCH 0b1011 //0x101x @@ -41,6 +42,9 @@ struct aarch64_insn_decoder { }; /* arm64 instruction classes */ +int arm_decode_sve_encoding(u32 instr, enum insn_type *type, + unsigned long *immediate, + struct list_head *ops_list); int arm_decode_dp_imm(u32 instr, enum insn_type *type, unsigned long *immediate, struct list_head *ops_list); int arm_decode_dp_reg(u32 instr, enum insn_type *type, From patchwork Thu Jan 9 16:02:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DEF3139A for ; Thu, 9 Jan 2020 16:18:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 64912206ED for ; Thu, 9 Jan 2020 16:18:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E9chqJdy"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RARJ8a4K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64912206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=9j6yoMr0gOd+29V2mIREOatAB37dKLz5D9rNvRtebjk=; b=E9chqJdyazNtKT 8Nxzw71014T2nUKWPm64OezzrVnUX5+nRX0A/zFLqqYj7kNhEHRF5ks2e2+xCR9PpGrOGHWBPX2P9 14gDJxedRtxEFz5oOZjDZ0lZsxOFe8+W8X/YC4RKpna4LldCZa87suuqb12kpq2L76G8f1nF/pDOI VkYvoVgJ1dD3o5Y1w/M30t5Z8QQqF83sbbbQhRUzygD89Uqlx2Q+CfEwLJ51tTuj0+LS1588ia6b0 XTWEmM1e3OlTswztxDBFgkENnbjZptxchWicypYKBU6z/nF5M8ZpVjosamadT1M98uUZj0oOQYVqJ 6EHibI4U0NkILWzzxdFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaVq-0004Le-F7; Thu, 09 Jan 2020 16:18:22 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMG-0001QQ-H1 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:08:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586106; 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=rIO2h9KrEYPabWRX3TDhKhoqSrg8+Z2neV2hGtzX3p0=; b=RARJ8a4KEW5xHl9SZK2Fil1zMQgZcN3Ke/qDaVUka6nWDBgWiXCDtmCcEXydtQty2KyA/1 CoePmhUmH3bK0iOmXL9fRcvxPdZZ0aIcuCSDWWQyo4rORgMABIuR+QNO9p4F4Lc47RRAr0 7YveBhvAnHJG87+sWw+MU295nAT+Wzo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-fBmF-eNHNtKjLHU0YRWLeQ-1; Thu, 09 Jan 2020 11:08:22 -0500 Received: by mail-wm1-f69.google.com with SMTP id p5so621998wmc.4 for ; Thu, 09 Jan 2020 08:08:21 -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=XdbyLSo/LKwv0IS4UY8BmEznN2tnAhqPqp9PsERe1ZM=; b=adFA3jBs+p4rrX2O35Jue7LDwb9/Wd3Ho2Fsi8uPSLXll96u1N/0X/iSVrfTnE3RcF EofQQC9PxpPOE5OI3G6X7bKvm7StriAS+dkeDOsiwlj8MI9+l+cLJ72CuGAIvjwiiM4C miMM2hvay/Gx/csKQicJqhEY5H1shkYpkUbr8OGdFiJ4NPk8LUck0/LC3IRy7baFmq+0 y7EMxfT1LAx2ZPNVbIwsahRvqAI056iygok0HsMs5bPc4HGbXj4dkUDvTicDHzvU+yu6 C+0sDmyBLb8+em/OdFN3EJVMxyIwSrJTfc73EzvzJA7IbsLW3Rev0SeDIh5ZWGl56G9E rspQ== X-Gm-Message-State: APjAAAUiInBplMoSnGU2zzj9+aDCi+UDLDos03O2ozL1TzdXRYumvyNv 2MzU2Q/twcrZb8ddTybjdmKoJQgk00TFGCtwedvW0l0VbOTrEGwBg4kpzERQz9B1/Z2A92ZkBSR 2zRLFz044qvQWcwaOgt2D1h1YEBB/EW8tYSI= X-Received: by 2002:a7b:c935:: with SMTP id h21mr5629101wml.173.1578586100890; Thu, 09 Jan 2020 08:08:20 -0800 (PST) X-Google-Smtp-Source: APXvYqybaGwF2SifAH/vF/5c/Zg4lZFldMQtCNPmw+l0nkZ5ezrMFKLX54upiO65e6Aqyi7sdLTdig== X-Received: by 2002:a7b:c935:: with SMTP id h21mr5629084wml.173.1578586100669; Thu, 09 Jan 2020 08:08:20 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m10sm8562605wrx.19.2020.01.09.08.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:20 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 43/57] gcc-plugins: objtool: Add plugin to detect switch table on arm64 Date: Thu, 9 Jan 2020 16:02:46 +0000 Message-Id: <20200109160300.26150-44-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: fBmF-eNHNtKjLHU0YRWLeQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080828_700352_36A8A039 X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Michal Marek , Julien Thierry , linux-kbuild@vger.kernel.org, peterz@infradead.org, catalin.marinas@arm.com, Masahiro Yamada , kernel-hardening@lists.openwall.com, raphael.gault@arm.com, Emese Revfy , jpoimboe@redhat.com, will@kernel.org, Kees Cook Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault This plugins comes into play before the final 2 RTL passes of GCC and detects switch-tables that are to be outputed in the ELF and writes information in an ".discard.switch_table_info" section which will be used by objtool. Signed-off-by: Raphael Gault [J.T.: Change section name to store switch table information, Make plugin Kconfig be selected rather than opt-in by user, Add a relocation in the switch_table_info that points to the jump operation itself] Signed-off-by: Julien Thierry Cc: Masahiro Yamada Cc: Michal Marek Cc: Kees Cook Cc: Emese Revfy Cc: linux-kbuild@vger.kernel.org Cc: kernel-hardening@lists.openwall.com --- arch/arm64/Kconfig | 1 + scripts/Makefile.gcc-plugins | 2 + scripts/gcc-plugins/Kconfig | 4 + .../arm64_switch_table_detection_plugin.c | 94 +++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 scripts/gcc-plugins/arm64_switch_table_detection_plugin.c -- 2.21.0 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1b4476ddb83..a7b2116d5d13 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -90,6 +90,7 @@ config ARM64 select DMA_DIRECT_REMAP select EDAC_SUPPORT select FRAME_POINTER + select GCC_PLUGIN_SWITCH_TABLES if STACK_VALIDATION select GENERIC_ALLOCATOR select GENERIC_ARCH_TOPOLOGY select GENERIC_CLOCKEVENTS diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index 5f7df50cfe7a..a56736df9dc2 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -44,6 +44,8 @@ ifdef CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK endif export DISABLE_ARM_SSP_PER_TASK_PLUGIN +gcc-plugin-$(CONFIG_GCC_PLUGIN_SWITCH_TABLES) += arm64_switch_table_detection_plugin.so + # All the plugin CFLAGS are collected here in case a build target needs to # filter them out of the KBUILD_CFLAGS. GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig index e3569543bdac..f50047939660 100644 --- a/scripts/gcc-plugins/Kconfig +++ b/scripts/gcc-plugins/Kconfig @@ -112,4 +112,8 @@ config GCC_PLUGIN_ARM_SSP_PER_TASK bool depends on GCC_PLUGINS && ARM +config GCC_PLUGIN_SWITCH_TABLES + bool + depends on GCC_PLUGINS && ARM64 + endif diff --git a/scripts/gcc-plugins/arm64_switch_table_detection_plugin.c b/scripts/gcc-plugins/arm64_switch_table_detection_plugin.c new file mode 100644 index 000000000000..9b8b2ec6a3c8 --- /dev/null +++ b/scripts/gcc-plugins/arm64_switch_table_detection_plugin.c @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include "gcc-common.h" + +__visible int plugin_is_GPL_compatible; + +#define GEN_QUAD(rtx) assemble_integer_with_op(".quad ", rtx) + +/* + * Create an array of metadata for each jump table found in the rtl. + * The metadata contains: + * - A pointer to the table of offsets used for the actual branch + * - A pointer to first instruction of the group getting expanded into an + * acutal jump + * - The number of entries in the table of offsets + * - Whether the offsets in the table are signed or not + */ +static unsigned int arm64_switchtbl_rtl_execute(void) +{ + rtx_insn *insn; + rtx_insn *labelp = NULL; + rtx_jump_table_data *tablep = NULL; + section *swt_sec; + section *curr_sec = current_function_section(); + + swt_sec = get_section(".discard.switch_table_info", + SECTION_EXCLUDE | SECTION_COMMON, NULL); + + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { + /* + * Find a tablejump_p INSN (using a dispatch table) + */ + if (!tablejump_p(insn, &labelp, &tablep)) + continue; + + if (labelp && tablep) { + rtx_code_label *label_to_jump; + + /* + * GCC is a bit touchy about adding the label right + * before the jump rtx_insn as it modifies the + * basic_block created for the jump table. + * Make sure we create the label before the whole + * basic_block of the jump table. + */ + label_to_jump = gen_label_rtx(); + SET_LABEL_KIND(label_to_jump, LABEL_NORMAL); + emit_label_before(label_to_jump, insn); + /* Force label to be kept, apparently LABEL_PRESERVE_P is an rvalue :) */ + LABEL_PRESERVE_P(label_to_jump) = 1; + + switch_to_section(swt_sec); + GEN_QUAD(gen_rtx_LABEL_REF(Pmode, labelp)); + GEN_QUAD(gen_rtx_LABEL_REF(Pmode, label_to_jump)); + GEN_QUAD(GEN_INT(GET_NUM_ELEM(tablep->get_labels()))); + GEN_QUAD(GEN_INT(ADDR_DIFF_VEC_FLAGS(tablep).offset_unsigned)); + switch_to_section(curr_sec); + + /* + * Scheduler isn't very happy about leaving labels in + * the middle of jump table basic blocks. + */ + delete_insn(label_to_jump); + } + } + return 0; +} + +#define PASS_NAME arm64_switchtbl_rtl + +#define NO_GATE +#include "gcc-generate-rtl-pass.h" + +__visible int plugin_init(struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) +{ + const char * const plugin_name = plugin_info->base_name; + int tso = 0; + int i; + + if (!plugin_default_version_check(version, &gcc_version)) { + error(G_("incompatible gcc/plugin versions")); + return 1; + } + + PASS_INFO(arm64_switchtbl_rtl, "expand", 1, + PASS_POS_INSERT_AFTER); + + register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, + NULL, &arm64_switchtbl_rtl_pass_info); + + return 0; +} From patchwork Thu Jan 9 16:02:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31984139A for ; Thu, 9 Jan 2020 16:18:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EE63C20661 for ; Thu, 9 Jan 2020 16:18:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UppZoWI1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aX/cRYNy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE63C20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=G8kP8huG1VSr8kOd/mMcoboOesj8rcUJBe/sIRfbLhU=; b=UppZoWI14EF94l WDkuX4ZJHLEdxWp3xsF3zGkLCc2/rqVApiIivxunbaztQKThj/q8UgRe3VQKBsFj0QU+Ues8IixcW /pd+4pRvcb2kG8TIx00smYI6r4Xhehfuy7GQPQLo2i2LNc0NJN56HqDiqfrg4vnqQv1fpXYmRfLTb x+CoYjNLI6HzP4CAmsQnXaJHULZaEyh6q2PYF9Pw1upTKQw9XRPmGSAyiJr3SQCYjowMXO39onROz 5gQy+q71UZ9B4yN5CZYc3lczHT75RaoQkf7F2RZQL/KAhviu+9AD0nMMIahA0nD0m7ycm2iJIQrsO XMLa01P6GzOFATECnbnQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaW7-0004ZR-II; Thu, 09 Jan 2020 16:18:39 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMG-0001Qu-C6 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:08:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586106; 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=GOarOjNmZi3hJWRFzFttRiiIqNBMrq65r/7dnc7x4sE=; b=aX/cRYNycIkx0HEvcuhljdh+EXPHcHRRXIBhyK0owoeoeDfhtWG79gomOmQxraIpKBFHlE HD7R4+fnTAwFFRC7fcilegoHab722M1i0CNYTe/+D0/6ffqzqGmeZyITvjGZXMu+44lDK/ RvnL0+xZ4/xRTRddZInw1X1xWwqzhTk= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-c9sAKqxfOzyW1POlydRXLw-1; Thu, 09 Jan 2020 11:08:23 -0500 Received: by mail-wm1-f70.google.com with SMTP id z2so621105wmf.5 for ; Thu, 09 Jan 2020 08:08:23 -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=BLDFm9M3+IjFaZEcl4UPEjVvM0UAUmFlU++OoIm2TiE=; b=MxSbr3irsIA+DbuRH86nKPH9Yb//1kN0NUHCz9HvZ1DKPDQ2hMN9aAm7XiZSnRQqcf eUbQEnHnKEQqKJsgYEgic0ZtGR6hPLyEVaxxIo5tKtb9maHJs5TlTHgy//rH3M1BR9AA hOmvD3ZstmjifWdfOubh310tbDs+rmokJMgavKNNCLV3uznIEwc+AYOnBGWV6yIZ4uPN 3uE54OKUptsM4IJrsBVGGyFvE/ruRE72P1pzwVkPYcJoatHDOiVXXMnDkyFxyo1lXemx uw4pvuW+F8/LE/OWMd0BziKTwiyEaxyaE8BtXQ8l0gwpzqJMhri2LhImrdF9hlGb/xy+ KL1g== X-Gm-Message-State: APjAAAU3hwzAMRR071hKyRHQ/h0mq21cOPHRF/r9uSiZWTvZlhfu5JzK 8TDSsobK+Q2ZihtpjreWgDjmxT1PwLQFdKBdhB/5KawrLi2YU6HrBBU+bXBIlgHL2SbvVJh/oGC tswFLMX7NMk3RX1JGbfVFHPbOf5E3MvVuoD0= X-Received: by 2002:a05:6000:11c9:: with SMTP id i9mr11472411wrx.164.1578586102404; Thu, 09 Jan 2020 08:08:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzIcTnaZvojXVAuj0JZ6HlaRbgi0z87wgAuWQiTif3WouQy86j3JTCc11glSuk7t/dWJ9Yimg== X-Received: by 2002:a05:6000:11c9:: with SMTP id i9mr11472385wrx.164.1578586102084; Thu, 09 Jan 2020 08:08:22 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id m10sm8562605wrx.19.2020.01.09.08.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:21 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 44/57] objtool: arm64: Implement functions to add switch tables alternatives Date: Thu, 9 Jan 2020 16:02:47 +0000 Message-Id: <20200109160300.26150-45-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: c9sAKqxfOzyW1POlydRXLw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080828_527308_6B7BA93D X-CRM114-Status: GOOD ( 16.78 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch implements the functions required to identify and add as alternatives all the possible destinations of the switch table. This implementation relies on the new plugin introduced previously which records information about the switch-table in a .discard.switch_table_information section. Signed-off-by: Raphael Gault [J.T.: Update arch implementation to new prototypes, Update switch table information section name, Do some clean up, Use the offset sign information, Use the newly added rela to find the corresponding jump instruction] Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/arch_special.c | 251 +++++++++++++++++- .../objtool/arch/arm64/include/arch_special.h | 2 + tools/objtool/check.c | 4 +- tools/objtool/check.h | 2 + 4 files changed, 255 insertions(+), 4 deletions(-) diff --git a/tools/objtool/arch/arm64/arch_special.c b/tools/objtool/arch/arm64/arch_special.c index 5239489c9c57..a15f6697dc74 100644 --- a/tools/objtool/arch/arm64/arch_special.c +++ b/tools/objtool/arch/arm64/arch_special.c @@ -1,15 +1,262 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include + #include "../../special.h" +#include "../../warn.h" +#include "arch_special.h" +#include "bit_operations.h" +#include "insn_decode.h" + +/* + * The arm64_switch_table_detection_plugin generate an array of elements + * described by the following structure. + * Each jump table found in the compilation unit is associated with one of + * entries of the array. + */ +struct switch_table_info { + u64 switch_table_ref; // Relocation target referencing the beginning of the jump table + u64 dyn_jump_ref; // Relocation target referencing the set of instructions setting up the jump to the table + u64 nb_entries; + u64 offset_unsigned; +} __attribute__((__packed__)); + +static bool insn_is_adr_pcrel(struct instruction *insn) +{ + u32 opcode = *(u32 *)(insn->sec->data->d_buf + insn->offset); + + return ((opcode >> 24) & 0x1f) == 0x10; +} + +static s64 next_offset(void *table, u8 entry_size, bool is_signed) +{ + if (!is_signed) { + switch (entry_size) { + case 1: + return *(u8 *)(table); + case 2: + return *(u16 *)(table); + default: + return *(u32 *)(table); + } + } else { + switch (entry_size) { + case 1: + return *(s8 *)(table); + case 2: + return *(s16 *)(table); + default: + return *(s32 *)(table); + } + } +} + +static u32 get_table_entry_size(u32 insn) +{ + unsigned char size = (insn >> 30) & ONES(2); + + switch (size) { + case 0: + return 1; + case 1: + return 2; + default: + return 4; + } +} + +static int add_possible_branch(struct objtool_file *file, + struct instruction *insn, + u32 base, s64 offset) +{ + struct instruction *dest_insn; + struct alternative *alt; + + offset = base + 4 * offset; + + dest_insn = find_insn(file, insn->sec, offset); + if (!dest_insn) + return 0; + + alt = calloc(1, sizeof(*alt)); + if (!alt) { + WARN("allocation failure, can't add jump alternative"); + return -1; + } + + alt->insn = dest_insn; + alt->skip_orig = true; + list_add_tail(&alt->list, &insn->alts); + return 0; +} + +static struct switch_table_info *get_swt_info(struct section *swt_info_sec, + struct instruction *insn) +{ + u64 *table_ref; + + if (!insn->jump_table) { + WARN("no jump table available for %s+0x%lx", + insn->sec->name, insn->offset); + return NULL; + } + table_ref = (void *)(swt_info_sec->data->d_buf + + insn->jump_table->offset); + return container_of(table_ref, struct switch_table_info, + switch_table_ref); +} + +static int add_arm64_jump_table_dests(struct objtool_file *file, + struct instruction *insn) +{ + struct switch_table_info *swt_info; + struct section *objtool_data; + struct section *rodata_sec; + struct section *branch_sec; + struct instruction *pre_jump_insn; + u8 *switch_table; + u32 entry_size; + + objtool_data = find_section_by_name(file->elf, + ".discard.switch_table_info"); + if (!objtool_data) + return 0; + + /* + * 1. Identify entry for the switch table + * 2. Retrieve branch instruction + * 3. Retrieve base offset + * 3. For all entries in switch table: + * 3.1. Compute new offset + * 3.2. Create alternative instruction + * 3.3. Add alt_instr to insn->alts list + */ + swt_info = get_swt_info(objtool_data, insn); + + /* retrieving pre jump instruction (ldr) */ + branch_sec = insn->sec; + pre_jump_insn = find_insn(file, branch_sec, + insn->offset - 3 * sizeof(u32)); + entry_size = get_table_entry_size(*(u32 *)(branch_sec->data->d_buf + + pre_jump_insn->offset)); + + /* retrieving switch table content */ + rodata_sec = find_section_by_name(file->elf, ".rodata"); + switch_table = (u8 *)(rodata_sec->data->d_buf + + insn->jump_table->addend); + + /* + * iterating over the pre-jumps instruction in order to + * retrieve switch base offset. + */ + while (pre_jump_insn && pre_jump_insn->offset <= insn->offset) { + if (insn_is_adr_pcrel(pre_jump_insn)) { + u64 base_offset; + int i; + + base_offset = pre_jump_insn->offset + + pre_jump_insn->immediate; + + /* + * Once we have the switch table entry size + * we add every possible destination using + * alternatives of the original branch + * instruction + */ + for (i = 0; i < swt_info->nb_entries; i++) { + s64 table_offset = next_offset(switch_table, + entry_size, + !swt_info->offset_unsigned); + + if (add_possible_branch(file, insn, + base_offset, + table_offset)) { + return -1; + } + switch_table += entry_size; + } + break; + } + pre_jump_insn = next_insn_same_sec(file, pre_jump_insn); + } + + return 0; +} int arch_add_jump_table_dests(struct objtool_file *file, struct instruction *insn) { - return 0; + return add_arm64_jump_table_dests(file, insn); } +static struct rela *find_swt_info_jump_rela(struct section *swt_info_sec, + u32 index) +{ + u32 rela_offset; + + rela_offset = index * sizeof(struct switch_table_info) + + offsetof(struct switch_table_info, dyn_jump_ref); + return find_rela_by_dest(swt_info_sec, rela_offset); +} + +static struct rela *find_swt_info_table_rela(struct section *swt_info_sec, + u32 index) +{ + u32 rela_offset; + + rela_offset = index * sizeof(struct switch_table_info) + + offsetof(struct switch_table_info, switch_table_ref); + return find_rela_by_dest(swt_info_sec, rela_offset); +} + +/* + * Aarch64 jump tables are just arrays of offsets (of varying size/signess) + * representing the potential destination from a base address loaded by an adr + * instruction. + * + * Aarch64 branches to jump tables are composed of multiple instructions: + * + * ldr x_offset, [x_offsets_table, x_index, ...] + * adr x_dest_base, + * add x_dest, x_target_base, x_offset, ... + * br x_dest + * + * The arm64_switch_table_detection_plugin will make the connection between + * the instruction setting x_offsets_table (dyn_jump_ref) and the actual + * table of offsets (switch_table_ref) + */ struct rela *arch_find_switch_table(struct objtool_file *file, struct instruction *insn) { - return NULL; + struct section *objtool_data; + struct rela *res = NULL; + u32 nb_swt_entries = 0; + u32 i; + + objtool_data = find_section_by_name(file->elf, + ".discard.switch_table_info"); + if (objtool_data) + nb_swt_entries = objtool_data->sh.sh_size / + sizeof(struct switch_table_info); + + for (i = 0; i < nb_swt_entries; i++) { + struct rela *info_rela; + + info_rela = find_swt_info_jump_rela(objtool_data, i); + if (info_rela && info_rela->sym->sec == insn->sec && + info_rela->addend == insn->offset) { + if (res) { + WARN_FUNC("duplicate objtool_data rela", + info_rela->sec, info_rela->offset); + continue; + } + res = find_swt_info_table_rela(objtool_data, i); + if (!res) + WARN_FUNC("missing relocation in objtool data", + info_rela->sec, info_rela->offset); + } + } + + return res; } diff --git a/tools/objtool/arch/arm64/include/arch_special.h b/tools/objtool/arch/arm64/include/arch_special.h index a82a9b3e51df..b96bcee308cf 100644 --- a/tools/objtool/arch/arm64/include/arch_special.h +++ b/tools/objtool/arch/arm64/include/arch_special.h @@ -3,6 +3,8 @@ #ifndef _ARM64_ARCH_SPECIAL_H #define _ARM64_ARCH_SPECIAL_H +#include + #define EX_ENTRY_SIZE 8 #define EX_ORIG_OFFSET 0 #define EX_NEW_OFFSET 4 diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e0c6bda261c8..80ea5bbd36ab 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -33,8 +33,8 @@ struct instruction *find_insn(struct objtool_file *file, return NULL; } -static struct instruction *next_insn_same_sec(struct objtool_file *file, - struct instruction *insn) +struct instruction *next_insn_same_sec(struct objtool_file *file, + struct instruction *insn) { struct instruction *next = list_next_entry(insn, list); diff --git a/tools/objtool/check.h b/tools/objtool/check.h index 91adec42782c..15165d04d9cb 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -66,6 +66,8 @@ int check(const char *objname, bool orc); struct instruction *find_insn(struct objtool_file *file, struct section *sec, unsigned long offset); +struct instruction *next_insn_same_sec(struct objtool_file *file, + struct instruction *insn); #define for_each_insn(file, insn) \ list_for_each_entry(insn, &file->insn_list, list) From patchwork Thu Jan 9 16:02:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E31A921 for ; Thu, 9 Jan 2020 16:18:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3BA68206ED for ; Thu, 9 Jan 2020 16:18:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BVeL2gWd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fmy7i1dF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BA68206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=elT5NlxVaWf+Qu2hzuM3AenZRmORjuCrjFk9B1N7zLI=; b=BVeL2gWdesQ0N5 zXSQTiWMVeckgEVFvlEIJoWCz1wFW0LuisnY1pTHsfqi79bQ2B1/7L7dNU7UZs5bLg4+UbECaOPPh qP0jltzpHLlw3Svq0s+Ls8pzsYkRiBIrpX8OOG93ZLYsq1uR5Dc7l9yESFLyTM98r6xe30Wkw3Jjv GPMjlE1PL4/cplosaEDgtn7mfn8ERn5M0DvMcI0i3Diy8trA+iJiGvVjpe+0/G54zueWhvx9Nl8UN SkzYILYy8n8o+Von1wP5uB3g44Nl8ussKIyFLs5VfX8OKtny/5kcgf2eM0Vl66EHPBraU8cnaEz8r lcuaD5IH9FxqV6DuEeEA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaWK-0004kr-8p; Thu, 09 Jan 2020 16:18:52 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMk-0001tE-7r for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586137; 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=EBN8C/og0fnM2zB/rUvXQIia4F/DYkjcaOKwhnm3gro=; b=Fmy7i1dFbIVvQdA2jMXu1xB4c5ij4m78XOrrRl64fpt9yjxY8EnHuiD4b3BaW7DBIwd8j5 2r6autBNa7wgpp50kKpVAgeHilI65OmSm4Ku3zoHHxFa/5Qm8PtopHpwhfUWss3BK0tXWj 72tF4MoecZPrhLciJF8E3hWrcS+Gje8= 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-46-uDW9lFsXMoCpCdTqDI-u9Q-1; Thu, 09 Jan 2020 11:08:55 -0500 Received: by mail-wr1-f70.google.com with SMTP id c6so3030343wrm.18 for ; Thu, 09 Jan 2020 08:08:55 -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=nKlTXFTfOxenRUeVQ8l+ODGGfg+92uyxs/gH2lHca/E=; b=cu+olnEG4kgKg0GjSPFGYQlGusX4D81JauKv06eI5pcJry4FxeIffUepsNlbGMcUNv cj234GdsmEfaQAXWKiYbtXQ+C0Kf+4bDFZMDf/56vT9NLuDmdNU1UH6t1WZ7J6CapW9c JZzfVgA3B3vgcazmR8xoO1Nio05OSwMESpfWCm0Z/wZ6spit+xlSPmhv28B4VhJpd+ck Im3jNr04pjStMsJUuV9jgvDT1xuoHKRIyG+P+CoyEdUt9O+HsPn0dvDKPGCEnX04j+ZD V6GuRYR9RJFrEnkkGI5YZsbTIWez3sOboHVd4IJGL/2IZEtO/47lwjXqr6CFHg/o1epf K3gw== X-Gm-Message-State: APjAAAU6bszg/YSnceTAG2kOq0JsnHu77itV5096YfEmd6Vbg1F8J0+M cwnU7x6Kif2UqOCLQg/XN33G9DTexZ118zVbApi9CFxKxy/HDRFS+/Ep2QN6/xgHLDoDhZjdwNp MTIOiIQtOKvV1SIqm48QY37pCAyx5S2WG370= X-Received: by 2002:a05:600c:1050:: with SMTP id 16mr6102360wmx.20.1578586134582; Thu, 09 Jan 2020 08:08:54 -0800 (PST) X-Google-Smtp-Source: APXvYqw0602eGGyf/C/0ZAZHC7ZuC4fFVco9svxXb/Fu4KTSXEyS2X/xvzMklpTy/CP9FpmVgXMdeQ== X-Received: by 2002:a05:600c:1050:: with SMTP id 16mr6102340wmx.20.1578586134441; Thu, 09 Jan 2020 08:08:54 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id v8sm8403505wrw.2.2020.01.09.08.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:53 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 45/57] objtool: arm64: Enable stack validation for arm64 Date: Thu, 9 Jan 2020 16:02:48 +0000 Message-Id: <20200109160300.26150-46-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: uDW9lFsXMoCpCdTqDI-u9Q-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080858_370414_AFA1793C X-CRM114-Status: GOOD ( 10.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Add build option to run stack validation at compile time. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a7b2116d5d13..60a17af19aba 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -165,6 +165,7 @@ config ARM64 select HAVE_RCU_TABLE_FREE select HAVE_RSEQ select HAVE_STACKPROTECTOR + select HAVE_STACK_VALIDATION select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES select HAVE_KRETPROBES From patchwork Thu Jan 9 16:02:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 745B0921 for ; Thu, 9 Jan 2020 16:19:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 47CBC20661 for ; Thu, 9 Jan 2020 16:19:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZD/BaH+/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hMvOh/9W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47CBC20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=BoJ05tM2EvjNphMKjdnFN17ZJQeOaHi1SSIxtt8NjHc=; b=ZD/BaH+/ihFlZz JayX/mpqOGzeqg3hc2e6+FBt8KbQ2vxGEzElC4A1iK9gP1kcTdMQgIyMZ9E27WaYfjB0UaJ0JfWfL Zx3FrWuYoz3h20ehzsl4Fl5HFO6LNOOiCFZRVEsndGidqC51R4yhWNKDBt93tMQIUPUJ9Y2yYZnji QpZ0mLV0uLXGftOum+fTq5YBQOaDLnaFtNvc7o0SWnVaGU63bNRfbRCzx1SiGnMI8iAT0niQnX8i+ 1aPkRfkkynfb/fQJfr/St4RvqooVWHsNLyjRhZd5khNuJ7ihJozp/wijHXGm8+ebCAKthBEEiP6JI fiNPnzbVXUcg4QByZxLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaXC-0005ZV-L3; Thu, 09 Jan 2020 16:19:46 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMq-0001wr-5Y for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586140; 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=/nIUOgXVWIb61EZ6bz5wgUle47qxfmMoZ4VlUNkCYRs=; b=hMvOh/9WhVgjGga7FmurQ/aFOks+bTkfW2D7bU4u86HHUlTLzwqyq50MAgx0pEklzSTSUl fK5dTOm8l5ifTxXFMYhz9yJEVdXfG5We1/sXBkvgPxK/wsiJu2khFDBa585NDQRq4L6aIe ewia3zedv9Z5XkvxMro/L5D9EAGQgoo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-dqwE7zpfNZmEvTBGmeUhGQ-1; Thu, 09 Jan 2020 11:08:57 -0500 Received: by mail-wm1-f71.google.com with SMTP id o24so624643wmh.0 for ; Thu, 09 Jan 2020 08:08:56 -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=SOQjJaPeQ6AkeMaBkCNADMS/kyh8erzQiBDqDRYV0Ec=; b=mdotRsL9FBnp/ASIuAaEtph08AsR2TVc6BAwi1i2e91wNKFieXr13RxwwjrvpsKK0F gBDdRy5d0+XHGPiy7OK2F/VJ/4fSUGnQzakRq3ET4Zye07dvtY53RMbOlCx0Suxm0cCT UxtWAk170/WoyfyboJ6Q9/LAoKUJhq5wU+HddJoZwOUx7695NYNTAMZtRovCb04khNwD 1uAQ81f9Iy7QhhpyuFSTWOzY5L9lLMXJyUn2pHI/k+dNLe6vhc7ngu3hLo55UJwwwHr6 M/SozHitoToLKhF65/k6O7iZHe8GNper+Mc5wHNhXWeEqksdIJLpVDExj/OHISLVZzC2 Z9aQ== X-Gm-Message-State: APjAAAWNBW9HqLnUoGAbxXYYEzJJa4+fl2RsLKxaVxfDPQ1+hELzot6u F1kcqoAr0jmb6VCmtClni1kQ5irCiuOzcVYB1fu6XVCF4p9fiO6kV72O2pn6YGKj4bYIYuxUno3 AwweZ6i18NZO1qiQjb1/RlTzJ27Z++vU+wYc= X-Received: by 2002:a1c:8095:: with SMTP id b143mr5978372wmd.7.1578586135882; Thu, 09 Jan 2020 08:08:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxEszMufKupL2p3ncLrB7YUBRc575U8Mr//L6Fw6AnOA6p/ZOQdu3ZNuVMIx6ccyJ0DT1HBiQ== X-Received: by 2002:a1c:8095:: with SMTP id b143mr5978353wmd.7.1578586135722; Thu, 09 Jan 2020 08:08:55 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id v8sm8403505wrw.2.2020.01.09.08.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:55 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 46/57] arm64: alternative: Mark .altinstr_replacement as containing executable instructions Date: Thu, 9 Jan 2020 16:02:49 +0000 Message-Id: <20200109160300.26150-47-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: dqwE7zpfNZmEvTBGmeUhGQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080904_544739_A2C1577D X-CRM114-Status: GOOD ( 12.19 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Until now, the section .altinstr_replacement wasn't marked as containing executable instructions on arm64. This patch changes that so that it is coherent with what is done on x86. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- arch/arm64/include/asm/alternative.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h index b9f8d787eea9..e9e6b81e3eb4 100644 --- a/arch/arm64/include/asm/alternative.h +++ b/arch/arm64/include/asm/alternative.h @@ -71,7 +71,7 @@ static inline void apply_alternatives_module(void *start, size_t length) { } ALTINSTR_ENTRY(feature,cb) \ ".popsection\n" \ " .if " __stringify(cb) " == 0\n" \ - ".pushsection .altinstr_replacement, \"a\"\n" \ + ".pushsection .altinstr_replacement, \"ax\"\n" \ "663:\n\t" \ newinstr "\n" \ "664:\n\t" \ From patchwork Thu Jan 9 16:02:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95A70139A for ; Thu, 9 Jan 2020 16:19:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6D5B520661 for ; Thu, 9 Jan 2020 16:19:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mX9MKLsW"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ezk+4xTf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D5B520661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=g6Op3OL3m2wXWSP56zN5pPS6PX8J20KA6fhWOzdVXdA=; b=mX9MKLsWldBK1p eXab65qPhJb3R49ipFldc62MV+ew1CiZhjQVv3LhRxC0nzSZCLeGQ5cvktgl1ppzmF8a7zLhkzzJC dJJYQ6j80RxceVNBtLpbPugEp/ZdvfUDvaFOdbMjDzs/36uxPcye2/bQTkLNH4tRg+579ciErFQ4I FFN3IxuhypgU0E2Hm35KJin60sjfp+T0YSBOXhQT72qiz3FlYGwhuuFL/+CKB96+SJo1kUvPSxhbs SMWIabPQc6IA5ZuqPfJz2p/rLiUisWleAg451d0ge3kWlKIOCkXkWTZSk4EgYgq/B+tMCv7nG7N4K w9kC1qSBheM/xs/+fdLQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaWi-00057h-Mo; Thu, 09 Jan 2020 16:19:16 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMn-0001wJ-0G for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586140; 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=J44m9E003H18Upos9FG6C8b2vnlMaH/tcVcfPlZlhX0=; b=ezk+4xTf+syIFT0AtXHvkPq0JdYJMf8/t3Wdul+vDUTG5T7/KMGRmYtOq9h+tcpkRZYvcT DM3/zBvXZYR60jmQ0zwbLIWbNyFX3z1TuMCypUhO+K8firgHBLFHJ6PpswDrg9pjAMzISJ uY2um3+J9X8ggE7kjCoIWJFy65bSkSA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-72-RwJ7jwuxNA29nRacGa1Ldw-1; Thu, 09 Jan 2020 11:08:58 -0500 Received: by mail-wr1-f71.google.com with SMTP id o6so3041682wrp.8 for ; Thu, 09 Jan 2020 08:08:58 -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=GX1HWyW2RBViA1jhSt+OmG2SA1mVF9hKLd9ureUedGg=; b=OqGeKybaVUk8jt0UpYWTF42L7M2XUwCCrPV9TH4tvRQyi9NoVnoCGGCdsSHBIv/QwU UeBChnpraYnWdU0sx570g5agYmAqqdtFlPwfOldwNANRYuQWCo7MOSMP8DaIUrYFk8zp 9Xl9wdQFNJvtqi7s5RevjpvnLFeeRnbyrcPe6V0JgBZJSUJ6/w/nXUI32y6IsbZtPBVh 2UwxPCyhD+co7Ymo/OhHKGghZz4AoWR/H1QBLw0KW2pu/OevpcXTLJX9KBG0jJIJjiKL HMlRSWWk4x4KHKPaKDVNH8mB2Nw2A60zV2B+J1q8X29sr3MQd2BoXvaT/2RJHTqvf5hD SH6g== X-Gm-Message-State: APjAAAW6WafdGsfn11KQ8dDeoLkNb2gxs+RNZjhzH+K8CHDj0TYyhP9O S0No/tB4XWyv0J4JejEyumAL/FBGFdejNFhcTBh2MJt2NOwcyYnqewHGQMPCv3wQRMePMM1oug6 MOzvPndu8I3n+QN81RTUNxouojk8Y6P9uMWU= X-Received: by 2002:a7b:c750:: with SMTP id w16mr6091425wmk.46.1578586137409; Thu, 09 Jan 2020 08:08:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwjCp+Y4dd1UCQgpsIRC3EeNqpxSOKmFBNBlJEwGBmeaO0pEch53HDZj8tK+YxsBYtcqb3jbQ== X-Received: by 2002:a7b:c750:: with SMTP id w16mr6091403wmk.46.1578586137235; Thu, 09 Jan 2020 08:08:57 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id v8sm8403505wrw.2.2020.01.09.08.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:56 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 47/57] arm64: assembler: Add macro to annotate asm function having non standard stack-frame. Date: Thu, 9 Jan 2020 16:02:50 +0000 Message-Id: <20200109160300.26150-48-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: RwJ7jwuxNA29nRacGa1Ldw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080901_136474_8553D435 X-CRM114-Status: GOOD ( 10.73 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Some functions don't have standard stack-frames but are intended this way. In order for objtool to ignore those particular cases we add a macro that enables us to annotate the cases we chose to mark as particular. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- include/linux/frame.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/include/linux/frame.h b/include/linux/frame.h index 02d3ca2d9598..1e35e58ab259 100644 --- a/include/linux/frame.h +++ b/include/linux/frame.h @@ -11,14 +11,31 @@ * * For more information, see tools/objtool/Documentation/stack-validation.txt. */ +#ifndef __ASSEMBLY__ #define STACK_FRAME_NON_STANDARD(func) \ static void __used __section(.discard.func_stack_frame_non_standard) \ *__func_stack_frame_non_standard_##func = func +#else + /* + * This macro is the arm64 assembler equivalent of the + * macro STACK_FRAME_NON_STANDARD define at + * ~/include/linux/frame.h + */ + .macro asm_stack_frame_non_standard func + .pushsection ".discard.func_stack_frame_non_standard" + .quad \func + .popsection + .endm +#endif /* __ASSEMBLY__ */ #else /* !CONFIG_STACK_VALIDATION */ +#ifndef __ASSEMBLY__ #define STACK_FRAME_NON_STANDARD(func) - +#else + .macro asm_stack_frame_non_standard func + .endm +#endif /* __ASSEMBLY__ */ #endif /* CONFIG_STACK_VALIDATION */ #endif /* _LINUX_FRAME_H */ From patchwork Thu Jan 9 16:02:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7EB0139A for ; Thu, 9 Jan 2020 16:19:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 963DC20661 for ; Thu, 9 Jan 2020 16:19:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h1C1tx2s"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SfokSEaA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 963DC20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=YvWTrOGFtSo6jJO29FD0TgImemG1itDnVXFPagc2OGA=; b=h1C1tx2sQ4TxSh HumYuoyUN1YfmWzcLGbAs0MwkLAXisy5Ybp9tNz8xT5GUjEEm8C5iyawsz8xot6D5UlnIq8Y40Lma 9cGuavTfmk+YdZKcDiJHqrlHcWz1rVqSW+QzXPuwfRSiIF7qQbP67XeoZ4KaBl+a0ZneXKgkma8js 4jNzQ7jafj957KaII8YSMo1Sv0iCfjUaSNyg8cqjc1pZh/GFoZr4QpwWdEQ/PZjsSk5IwvXA/mxiv KxSDnHN0yKOELufHN7B3tqotzgDX7Kn/GvBLMdeLZMmmQla+/CuhlA5D+4xqxFNfK6lMm55JYtGHZ wMM9fb1tZB68CZBQO6Qg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaWr-0005Hk-QZ; Thu, 09 Jan 2020 16:19:25 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMo-0001xm-Fh for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586140; 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=j3rJbJBi/4wLWjHpSpMH7gUaner+0ML7JaZLfifCTBs=; b=SfokSEaAqLfYeMzXxWsEtZhRdzPoDzwXSEPGA+UTCPCwgcoIuBXUURUbAqkZWYuCfcUPi5 396sVxHczZl1hLsVL9a2mBcU/pwG5KtAh6QiknFlbME2CRPSkNa6QtWJBoCh4/KQtVyAgV kzEIEOsiipGsY0wLCM2qCvtQPmGyfPE= 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-228-Zv26SsnYMfCxmwfFsgftvw-1; Thu, 09 Jan 2020 11:09:00 -0500 Received: by mail-wr1-f70.google.com with SMTP id u12so3048721wrt.15 for ; Thu, 09 Jan 2020 08:08:59 -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=kEfbHgsVU9eDoIkKPm/bUyQidxKwrK2z05bxXpj07hQ=; b=H2SAXeojKZHbzYTt0t545S1id72cBRcYwGkZYQdcHpK7vedjlPz4RVKUto2H5LRBwr X9/0SGoFO4PQG+9LG9NwB5gpRaj9iuI/ty3vkPTRatOtrUvnHzIUZ53bd2z33RfoyQK4 Hzc6d23eey+0ORm/VTvrZYmcOA83kXfEg6wwFdYiVxZaebmU9SicMH79ji6gujD+cJ9g G8prO1rHwo1PBtJYJrmHVUnRLorDDwR3B+/jxXD1Aa8grX82bcYzFsojrzGu/ehNZ/Np ADb6KLt1Jmql83gGwC08pGDcxY88jcd7elxrjZGBvO7evkt0YHhE03HM26DWpPAnroXk t25w== X-Gm-Message-State: APjAAAVw9hubvz59VWV/fR1u2TmGFWcD446oLhYSfFhi6y+7+oadgJlg VA3/gK2XsWaNgildBqLEN7Biizfb2+rXIWs1a46GeRaUGK20oFKwFLiyRjyEFHYII/CVRbqa+q8 mMAQcbjkhUpueXVS9hEYu37en8/Zc9ZTVeWc= X-Received: by 2002:adf:e3d0:: with SMTP id k16mr12018283wrm.241.1578586138794; Thu, 09 Jan 2020 08:08:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzSLia58QbEuzIUwye/7K2S8R5lieQsiVKxVvK2wzbrjNJr4CLjCo4Rn4vyl1YI3pmhsGWMjA== X-Received: by 2002:adf:e3d0:: with SMTP id k16mr12018264wrm.241.1578586138549; Thu, 09 Jan 2020 08:08:58 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id v8sm8403505wrw.2.2020.01.09.08.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:58 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 48/57] arm64: sleep: Prevent stack frame warnings from objtool Date: Thu, 9 Jan 2020 16:02:51 +0000 Message-Id: <20200109160300.26150-49-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: Zv26SsnYMfCxmwfFsgftvw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080902_647183_718CCA1D X-CRM114-Status: UNSURE ( 9.64 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault This code doesn't respect the Arm PCS but it is intended this way. Adapting it to respect the PCS would result in altering the behaviour. In order to suppress objtool's warnings, we setup a stack frame for __cpu_suspend_enter and annotate cpu_resume and _cpu_resume as having non-standard stack frames. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- arch/arm64/kernel/sleep.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S index f5b04dd8a710..55c7c099d32c 100644 --- a/arch/arm64/kernel/sleep.S +++ b/arch/arm64/kernel/sleep.S @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include +#include #include #include #include @@ -90,6 +91,7 @@ ENTRY(__cpu_suspend_enter) str x0, [x1] add x0, x0, #SLEEP_STACK_DATA_SYSTEM_REGS stp x29, lr, [sp, #-16]! + mov x29, sp bl cpu_do_suspend ldp x29, lr, [sp], #16 mov x0, #1 @@ -146,3 +148,6 @@ ENTRY(_cpu_resume) mov x0, #0 ret ENDPROC(_cpu_resume) + + asm_stack_frame_non_standard cpu_resume + asm_stack_frame_non_standard _cpu_resume From patchwork Thu Jan 9 16:02:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C5EF139A for ; Thu, 9 Jan 2020 16:20:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2655D20661 for ; Thu, 9 Jan 2020 16:20:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XlO4cTT7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BFHKoJGn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2655D20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=khgVQ+Itnang6byXD/D1BY8BOIcKgrxcb30E+DClTLw=; b=XlO4cTT76b6FWA WYLjuqVFoGktBQlpWfGNWVoi/uDQnAs2tsapc0lVNGfSqWw2aG+H58nkbS2e/QeBsEkzsBNsJehR3 fFDiRp2jfn6Q73Zy1cNvagTKBnpobmjxPji0E3ooPB4XjVuT3WJ86Orr7LQ+q/lErqksKbvaFEB93 idKy2vrMIcJPbiocilTM8x7LPhnkf8/Dr894JrIrafl7EEP+H5EyDIMylBqqf4tvrw3rcse/+taLz hd8CdOKUeIdVZHx8xqGyl3cJlnL6Iqpb+tjSiZ5PepHJ+CHARAMWj2F6PyQXhBf6s6JZsXYUadAFW WVkCq4J2oNcvrX/aV5Pg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaXa-0006De-T8; Thu, 09 Jan 2020 16:20:10 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaMt-00021D-BW for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586144; 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=mAHGJTw6emz4uceIu6DFrravfZx1rImSewv+paxvKpM=; b=BFHKoJGnOkWEr4Z9Pk87zA3aosYP0UC+PhIRw/hUZY8WEyLYnJOxh7vL7ouY+Axs1nXQoW tZCPaLiYOXgNoi6z/L8aQoG44nLdPsGM89VKs04UI7P1w9fjfLBpyarlAtrEVpsVzB78vT grFdY+nK+ZB2ppmZFPVCa6koRRlKkS4= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-9-bhw7IMOu2_2YXwNP3tzw-1; Thu, 09 Jan 2020 11:09:01 -0500 Received: by mail-wm1-f70.google.com with SMTP id t16so1103033wmt.4 for ; Thu, 09 Jan 2020 08:09:01 -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=4dPDKFSZi3e3u+46jDRIhE74sgAn3tXL+nGRZRHhzxI=; b=Z8ZXG5X69ZGkCEAM+5Pk9DcX+Ip7G+VwaLacX6ERXGRVZaeXYFX9WNZCDfmxvr/K8D BhBQkAMoX8DG7vh0iUsadUTrRQcBqZACf+OmsPB4R2AbBImf3fSUVLLlGdiDHpQl57SH VqqSH9NnJGgxD1H48vcaYMHJQK7/nLXFvyXrdysMb7iQVDXsqjQzGWJ+XNw94bGAW2G0 F9lwSoz5fvMiAFiBvMFucI3JLG1u13EqfsCYPEVdNh4eEYw9Gzno+DrltxGQWahh6shd uwp6IwJgZ1D3/DnGQlHABUHKrovcLS3hH0+uTWbf6DMfLTmy76jUvmDJSAFaG7aaegPx na+w== X-Gm-Message-State: APjAAAXKxrNjxejgp1cBCOy4EQCJNeLDIMAVONrmL9XAWvnoDEz51Sy6 jUDnVtI0apHpOYvlOe9y2p4+e7QOpKKEbkmk9Dv0xsrNAtWI2rGUuqqYKLIZjRrunasWnuEExKJ TZGXOK6bGF/gu7zPPz8sNsPY7qle6f/gyyAo= X-Received: by 2002:adf:a746:: with SMTP id e6mr12285682wrd.329.1578586140098; Thu, 09 Jan 2020 08:09:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxidILoaEYUa5ievTi0I/NuFQayb9Diwg52FSlLGCUYTke4Wmfm1U43xAy4el85wmxpFXckwg== X-Received: by 2002:adf:a746:: with SMTP id e6mr12285661wrd.329.1578586139895; Thu, 09 Jan 2020 08:08:59 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id v8sm8403505wrw.2.2020.01.09.08.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:08:59 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 49/57] arm64: kvm: Annotate non-standard stack frame functions Date: Thu, 9 Jan 2020 16:02:52 +0000 Message-Id: <20200109160300.26150-50-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 9-bhw7IMOu2_2YXwNP3tzw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080907_482879_519E4B05 X-CRM114-Status: GOOD ( 10.76 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Marc Zyngier , Julien Thierry , Suzuki K Poulose , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, James Morse , jpoimboe@redhat.com, will@kernel.org, kvmarm@lists.cs.columbia.edu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Both __guest_entry and __guest_exit functions do not setup a correct stack frame. Because they can be considered as callable functions, even if they are particular cases, we chose to silence the warnings given by objtool by annotating them as non-standard. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry Cc: Marc Zyngier Cc: James Morse Cc: Suzuki K Poulose Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/kvm/hyp/entry.S | 3 +++ 1 file changed, 3 insertions(+) -- 2.21.0 diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S index e5cc8d66bf53..c3443bfd0944 100644 --- a/arch/arm64/kvm/hyp/entry.S +++ b/arch/arm64/kvm/hyp/entry.S @@ -15,6 +15,7 @@ #include #include #include +#include #define CPU_GP_REG_OFFSET(x) (CPU_GP_REGS + x) #define CPU_XREG_OFFSET(x) CPU_GP_REG_OFFSET(CPU_USER_PT_REGS + 8*x) @@ -97,6 +98,7 @@ alternative_else_nop_endif eret sb ENDPROC(__guest_enter) +asm_stack_frame_non_standard __guest_enter ENTRY(__guest_exit) // x0: return code @@ -193,3 +195,4 @@ abort_guest_exit_end: orr x0, x0, x5 1: ret ENDPROC(__guest_exit) +asm_stack_frame_non_standard __guest_exit From patchwork Thu Jan 9 16:02:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19BBF921 for ; Thu, 9 Jan 2020 16:20:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E30D920661 for ; Thu, 9 Jan 2020 16:20:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZzObYQPN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LIkK9Osf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E30D920661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=IIpl/u0diF1kkLiuZx73Lv+8LiV91+PnvYs/2IWzhOg=; b=ZzObYQPNlhM0Qu g74zHGz92iFQSJpuNxNTLnJoRXnz4gJa8WuxlE4gerZktzHOvlgAhnOXT3S97eLssadkmaYqYPmzf QQDlz5BzzXeasBABJFDMHRy/Z2AEU7iGZZS9ouZaNfaBh6smhdo/y6RLq+UdqekewE1PirYlRzrwY +RDqoOFfCwzcYNn02PI15x81c47s2v1kzSWUDZku85P/IoPTQkN0NzWjAWa5bDq1I5BjgmxNFAQ+t PsQ3gyHXA3VDFd9THY1ul+yFDlGyEG4jv5aQgc+RheJIp0bSeVB1QcewlUZz6h/hXQhIAhbbcjTud SqPh//F1wZ1tdjCEANyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaXm-0007Fc-QR; Thu, 09 Jan 2020 16:20:22 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNN-0002YP-L9 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586176; 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=IvAAZHcfP6t4zLwyXztvIUrcq7T/iPtXd+REm1qHjSI=; b=LIkK9OsfPfI4FHZLo4LPY4w5ZKD28CWLE+4mcKpI4V5Tr2y6x3bObSIU+Aa5UJ4kntUDbE 7hb9YyXxU5tGKLSKXgvhs5xsyiS3rvRHP1dnnhspeVRAeRqmHJj5Dy2zV4NOiTGYAibBZK c/X61wq3BDaLrPB8WopzsySPDUFCzLk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-aFtrgCRwPaKRKUrUC3jcAg-1; Thu, 09 Jan 2020 11:09:33 -0500 Received: by mail-wr1-f69.google.com with SMTP id u18so3047070wrn.11 for ; Thu, 09 Jan 2020 08:09:32 -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=+WGb3puDmUzCYPuLm6oXYBSJ99/bjzxumOQhQE5nO+o=; b=jhLvMeWZ+xr7LH12/98UqDem2tE1nWBF420wx07k+hr8Z+2XhHWtPgsoDtcbxBpGyz pWNAjVW1zbnZTuVVwXHwZFcCiOghWlLHAoN1ShjU/fg5mMAV4DQTy7C1o9YCQESRlZZB COAh/uQ9udC/dr2qfxHiDiuINuKaiemdILYtK7uzDOslfC81H6TS5XZ77f+5/N0qkEie y2RZ4iB45dx6qZ65ACaXCvCoH9LiVd7VqA8m27t5fqdkH28MH8DUqJ79E8zHN8keItwX orZ4n4vpY6+3UvTvZMimv4yngOX+KaOBUkHq7Kkr1oloS8rSewhTV0mX7ya2aXubYi0Y 4y0Q== X-Gm-Message-State: APjAAAVQ91enCReCBzSZ5I4EFPoVVhCsqi3VHZm5Pp2UDLwUc7BFWKjF z2Sbf5Szvdcj+xlTAHdWOJwS+4+CzKLYkR5VSnxQT+W2ZlqofPzK6Nsm/VdEt5wxeQS0opfrhck eO4RrjrWQtG0P3rLQVHidVR6694rf2VBnebI= X-Received: by 2002:a5d:6a0f:: with SMTP id m15mr11728058wru.40.1578586172085; Thu, 09 Jan 2020 08:09:32 -0800 (PST) X-Google-Smtp-Source: APXvYqz5V26QjGcxR+qc3PnQJZqKeHaPwzwzDGc3YkRawBmFtmaeyy4yWAZvPxOmJY0ku0p1ZNx85w== X-Received: by 2002:a5d:6a0f:: with SMTP id m15mr11728054wru.40.1578586171944; Thu, 09 Jan 2020 08:09:31 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e8sm8517707wrt.7.2020.01.09.08.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:09:31 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 50/57] arm64: kernel: Add exception on kuser32 to prevent stack analysis Date: Thu, 9 Jan 2020 16:02:53 +0000 Message-Id: <20200109160300.26150-51-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: aFtrgCRwPaKRKUrUC3jcAg-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080937_789675_70E6F49D X-CRM114-Status: GOOD ( 10.66 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault kuser32 being used for compatibility, it contains a32 instructions which are not recognised by objtool when trying to analyse arm64 object files. Thus, we add an exception to skip validation on this particular file. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- arch/arm64/kernel/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index fc6488660f64..f5994679db5f 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -33,6 +33,9 @@ ifneq ($(CONFIG_COMPAT_VDSO), y) obj-$(CONFIG_COMPAT) += sigreturn32.o endif obj-$(CONFIG_KUSER_HELPERS) += kuser32.o + +OBJECT_FILES_NON_STANDARD_kuser32.o := y + obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o From patchwork Thu Jan 9 16:02:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7392921 for ; Thu, 9 Jan 2020 16:21:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C22E5206ED for ; Thu, 9 Jan 2020 16:21:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="s+p0IJs8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AZnf+wMB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C22E5206ED 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=MxTWSFtD9JXBfXA22lR/Ec2FFF/ZvKTOwJ1ipDEb9KI=; b=s+p0IJs8buYQiU F013KV2KOTh3FzK2GCqDDxDPGYibFq5ga3TcO4u/kxWXollv564odaaPDdgf5fKX/XYZi7LzRL3KE WA3ISmKdRAb1PifnYAg08XE/R5G5zIaBGSdX1/dnRTHkWKAN1jUrw4KgnwT0JEYjZbI0RcKewb5+y LN/XyZIFEBMMr7dqe29LdMYt4n8sudxk0SlxBkkRdmq51XRLTnVkJjrXnzPSwdJzTfalTfCIbMG4E Xwu5JjVZyOtixs10NRO6AwxDsUl+Fi2uxRxyDCQ8IOdf8h3v8DBdmwy3u4Y5/RCB+cCX4+DndKjqJ /9l62NwtJ3sCVa8hPRrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaYN-0007m5-O2; Thu, 09 Jan 2020 16:20:59 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNP-0002Zx-Im for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586178; 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=wn1PlW5FinwniCqrxDmb+VE4wicag5GxlG8u/eXxlDw=; b=AZnf+wMBi8oBnLj3J3X/2hjZCEjUEhQT9MN0XtcbNjEV7vcXZoxKHQnetuLtwF6v2BOsDU M9dubHtfVgur8xvUgoKskFo82pYJhuiwCKwrLdgn010e4t+aLcG6kwL/jfzmRD8f0nDj7A Aw0vdc9uj2Ba/AEXlw+CSNKSjWOJy6k= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-X5JnqSg4O1GQfhPsEUKapA-1; Thu, 09 Jan 2020 11:09:35 -0500 Received: by mail-wr1-f71.google.com with SMTP id o6so3042271wrp.8 for ; Thu, 09 Jan 2020 08:09:34 -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=x/rxJnoz2dp9/OgwOSiXn1XXvPb+lm1fPDfoPO+TlzQ=; b=K/Z5CIZ9Gg4AYWxiJ3yZWCWo6QdC1bhJZlsj+68FO3KLmVUdgqhtLPu2jd8+KF3rQK 3XTDrkRk1KN/zEnVoMY/nCYHtzqBtQzsU+2kwf2FPDb/h8jUYcoladiC6tDmDAHAL6EY JoDN1zGYqqA1OgrNXYe0+98FbpCGd6Xh+uMhl2d9Bjc1PmXcGVtzi2aUtBr4CKSqn2GL pZeR7AM5tqr1p7EelZjXpp0+/yo6f8VFxylt5xRsJMgkItD4Z3/xOLDwg4YOtjF+/eLE P1jJGx7S9ikkE2udRnatsksSeBVwx2nUaZECEmUdbFSF4LS0Wn6o6xj6VsQseVOzv+ns R2vQ== X-Gm-Message-State: APjAAAUgGoDWHIN/MGJ7/Am//YZOAa8nxLYy3xb34nyD1YB8W8FnkCxP +2KmwCxXLklamQX708GxCjnHiUMZG4WbfKnckbLtnP1aA+4nd2m+cx2AeZ2JKYmUAaxibgjRJpK KVS2Y+URO0MDf7S1pj10w6afIxaTKpRP7YFg= X-Received: by 2002:a5d:6a88:: with SMTP id s8mr11396382wru.173.1578586173702; Thu, 09 Jan 2020 08:09:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzzBZ0BLVEYI65yhSFFLKAZJl16GgmFQUcOJvP3sjdvkoaxTwI5EQ3O12ZHhk4lBNKmTURtAg== X-Received: by 2002:a5d:6a88:: with SMTP id s8mr11396364wru.173.1578586173488; Thu, 09 Jan 2020 08:09:33 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e8sm8517707wrt.7.2020.01.09.08.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:09:32 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 51/57] arm64: crypto: Add exceptions for crypto object to prevent stack analysis Date: Thu, 9 Jan 2020 16:02:54 +0000 Message-Id: <20200109160300.26150-52-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: X5JnqSg4O1GQfhPsEUKapA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080939_725922_D4FCF51B X-CRM114-Status: GOOD ( 11.12 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Some crypto modules contain `.word` of data in the .text section. Since objtool can't make the distinction between data and incorrect instruction, it gives a warning about the instruction being unknown and stops the analysis of the object file. The exception can be removed if the data are moved to another section or if objtool is tweaked to handle this particular case. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry --- arch/arm64/crypto/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index d0901e610df3..576a19923185 100644 --- a/arch/arm64/crypto/Makefile +++ b/arch/arm64/crypto/Makefile @@ -43,9 +43,11 @@ aes-neon-blk-y := aes-glue-neon.o aes-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM64) += sha256-arm64.o sha256-arm64-y := sha256-glue.o sha256-core.o +OBJECT_FILES_NON_STANDARD_sha256-core.o := y obj-$(CONFIG_CRYPTO_SHA512_ARM64) += sha512-arm64.o sha512-arm64-y := sha512-glue.o sha512-core.o +OBJECT_FILES_NON_STANDARD_sha512-core.o := y obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o chacha-neon-y := chacha-neon-core.o chacha-neon-glue.o @@ -62,6 +64,7 @@ aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o obj-$(CONFIG_CRYPTO_AES_ARM64_BS) += aes-neon-bs.o aes-neon-bs-y := aes-neonbs-core.o aes-neonbs-glue.o +OBJECT_FILES_NON_STANDARD_aes-neonbs-core.o := y CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS From patchwork Thu Jan 9 16:02:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54B01921 for ; Thu, 9 Jan 2020 16:20:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 31A9E20661 for ; Thu, 9 Jan 2020 16:20:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QSNC3JiK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c5Eljg8Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31A9E20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=hhCcVVIfhWsFM52qlAKiwdgap6nWeOwbTLaU1bh+AY8=; b=QSNC3JiKJYKsqz i0w9CELpX6zOLOtXSRCG+Qowk8355waKQgwViELKAvT8dbofz+iSeGFBnRnPy8kAchEhivQbsypID eVJ6wIYd9PhNYW0YEpiyEa8r+5YdFxTuFS8eY08bA1+heXxtdjnuBXLr/JWNAta1+NoQzAbOkcDqD CByu4zACfkBVb0/ZJPWsdineA3r5jf9GuCElQTGO/7fXSH9xDCSOUWN1mDHJsYCXzMNoRowrEoJK5 p2nbm8VqvxTaZ4z4CnTyYkd/Jn7H3gSg3Z1xsiWEXYDRglPri6i8QnfAh6op00FQ5bKkVA3JqmlWV 61kcakIXf9bQrdoYFNmg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaY7-0007XV-FT; Thu, 09 Jan 2020 16:20:43 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNP-0002Zg-7m for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586177; 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=mua/qHbvjxBZzAa9DGgUWjthaiVLr4wGp81bwymTxFo=; b=c5Eljg8ZOZJt2KVzzWYiZiw3aAQddX008DirZRopY94TzxdWlSAdeD+1yhGNpTh8hZaE6W JSy0+27pVuUYTvRUhnrOTD6mKMb+GVGdusg7CbW+euTg1wt8ju8/DYfu7tihrlx+djVE6N Ot+EXxd/x57x+GWpO3+Wkag9fuPNfO4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-80kOVaZRNVazXTyRuax1zw-1; Thu, 09 Jan 2020 11:09:36 -0500 Received: by mail-wm1-f71.google.com with SMTP id y125so890767wmg.1 for ; Thu, 09 Jan 2020 08:09:36 -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=NXlvrJt6z83MLX+WxwdFOCINB+GcX+Yj981D0b2qPGQ=; b=YyviGqgCpCymOHBRFcC6EC/kG4ge2x+I65KXV3UrVCE67WgIk83QJRDdybBOlhYYhi RAzdVGit2Xr8wp+PeuUCbAWPk3iA6DVe5Uy4CsZ4+AxmvhoNGM6LRciiH/WKeV+Jnhhu IWuiCt0R6rOAbiyjjjXuyemCNI6iEsDJUtSubYMKt3bBKelN3NV81sgN8gyf6uPC8wq8 McrFwuwf3EtZvvwO3ZhoqTRAG3/d6p+rUifsMiuZ72rIge2qyBIiQ7I9Wf8mQha4jJE5 OUTdaLD85mNi+N+pnuqxd1akN0Q4vIZRXeL5f9h4k+ikzBtuW78bHyYgoq1G67dt/qUn LmwQ== X-Gm-Message-State: APjAAAXHutwl4J3CG92tC6pCOit4w17t+3wYxF1DbrrKoOAcNc1tw0EU lfsJE0Qc26QuMQf0DwRdboO/VvWLk9sFTyBJI0pdDEN0wsyCxbWY29sTQd224bL0yspdE0B2ZHS 0k3GrFtbFOnbVhEIMtFFN4+yx+pIandJsaDc= X-Received: by 2002:a7b:cbc9:: with SMTP id n9mr5807751wmi.89.1578586175320; Thu, 09 Jan 2020 08:09:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzmBZZfDXBq6RqR3Rkcb9sOH+t9Q3MfPwQWoV78KSevOPVEW0amjALm+VNPMHJy5/8IKwjOOA== X-Received: by 2002:a7b:cbc9:: with SMTP id n9mr5807724wmi.89.1578586175172; Thu, 09 Jan 2020 08:09:35 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e8sm8517707wrt.7.2020.01.09.08.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:09:34 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 52/57] arm64: kernel: Annotate non-standard stack frame functions Date: Thu, 9 Jan 2020 16:02:55 +0000 Message-Id: <20200109160300.26150-53-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 80kOVaZRNVazXTyRuax1zw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080939_366627_0177BE79 X-CRM114-Status: GOOD ( 10.02 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Marc Zyngier , Julien Thierry , Suzuki K Poulose , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, James Morse , jpoimboe@redhat.com, will@kernel.org, kvmarm@lists.cs.columbia.edu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Raphael Gault Annotate assembler functions which are callable but do not setup a correct stack frame. Signed-off-by: Raphael Gault Signed-off-by: Julien Thierry Cc: Marc Zyngier Cc: James Morse Cc: Suzuki K Poulose Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/kernel/hyp-stub.S | 3 +++ arch/arm64/kvm/hyp-init.S | 3 +++ 2 files changed, 6 insertions(+) -- 2.21.0 diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index 73d46070b315..8917d42f38c7 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -6,6 +6,7 @@ * Author: Marc Zyngier */ +#include #include #include #include @@ -42,6 +43,7 @@ ENTRY(__hyp_stub_vectors) ventry el1_fiq_invalid // FIQ 32-bit EL1 ventry el1_error_invalid // Error 32-bit EL1 ENDPROC(__hyp_stub_vectors) +asm_stack_frame_non_standard __hyp_stub_vectors .align 11 @@ -69,6 +71,7 @@ el1_sync: 9: mov x0, xzr eret ENDPROC(el1_sync) +asm_stack_frame_non_standard el1_sync .macro invalid_vector label \label: diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 160be2b4696d..63deea39313d 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -12,6 +12,7 @@ #include #include #include +#include .text .pushsection .hyp.idmap.text, "ax" @@ -118,6 +119,7 @@ CPU_BE( orr x4, x4, #SCTLR_ELx_EE) /* Hello, World! */ eret ENDPROC(__kvm_hyp_init) +asm_stack_frame_non_standard __kvm_hyp_init ENTRY(__kvm_handle_stub_hvc) cmp x0, #HVC_SOFT_RESTART @@ -159,6 +161,7 @@ reset: eret ENDPROC(__kvm_handle_stub_hvc) +asm_stack_frame_non_standard __kvm_handle_stub_hvc .ltorg From patchwork Thu Jan 9 16:02:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43F92139A for ; Thu, 9 Jan 2020 16:21:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1AEDB20661 for ; Thu, 9 Jan 2020 16:21:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NHIkgz1t"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ScP1hP7t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AEDB20661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=zSrlD4wfkFGR+5+na6iY76rPJ3mzWClpH9cGcsoBeto=; b=NHIkgz1tj9AGVZ 4ax3enqe+Chtb5zVlgX1f+Cx6WXB08SFp/sXPeMIepjUfFla9FoPqQZlPD+QdJbepYX2KT1JgCedy LssPomnkqUVZnMpylYxMT3PXuMrpC3E8nZwqgggUntab8kuyapHOmoaoSCrAmBZCdKMHUNYnoMZME 67D0KZiYqghvv+XOLfQmuZs9dwJntackKgqHsx/ujtw5O41bJvw6e9oBsFJXhrCqLLCKfQSdjZsSE NsmMOQcAZeNAZviLnKe2o1W2a7q41rUg0sntxtvmNfGvPip3ZtXBfQVfkfPJbwzk1PyYeSEi4DZ+U oEE4+tSqqzLGhCDeaIWQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaYk-00089q-KE; Thu, 09 Jan 2020 16:21:22 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNS-0002e5-VK for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586181; 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=7axxFTtCe4/hNmI9OgXAAlvq0RYtj2z6BU573XVOuhg=; b=ScP1hP7tnYBCoTdzLy6977XFqZKc7mKqW9cIXiKcuLVWuDnWZUYU18ssKc81Kci8oiLgGY FVP3HbH1a8Mt0Uxr+m+uo1F8gZsmbQ/I64CLJ7bnjUah/lmfqxlwKOrKkxDZsy7ioEuzwD IAyggqh4IJ2XujpIOdiR6p/MndIKvuY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-vM5fI1FqP5CQuAVlgM5l-g-1; Thu, 09 Jan 2020 11:09:37 -0500 Received: by mail-wm1-f71.google.com with SMTP id h130so1097948wme.7 for ; Thu, 09 Jan 2020 08:09:37 -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=ODS9WlTRJORgY55Us9ipxq26EI7DMMwmFDGmBIaDtSs=; b=t9Kij7xddZJWvsASWKRKAvlymcsBQJn6PNQBzfn4NdU6R7FkvE79HloAhA9U2zMn+R T413pwBW6k5BR2AmOI7hkbIb1QgoR9OZxcytVWa8o6W88u8PvgLiKYiolbH4ZWUB6V4X n4HdBS46ovMn1pTpHfHOmQeErTOwt3FBBH90XG8SZuVxjT7uTkh5Cl3BjnsTZUR2lKVQ NFvt10KAYPwgBungRIHYoxnNXtZeSOK06kNtTbjymdnOjwgLsMuzMthLzWHEvVmbIUSv QqhSTA7PpNZqT+NQoCs06KsY0ALPcPOOkFF5Q6Akv8q/a9UPbhMez0WbJTJA/klMnX7/ /9zA== X-Gm-Message-State: APjAAAVD2GAcS5pF2E0H0P5nIEIYakKy3T3hyLkSMA+P818EifYfKJbU RhmxiVf7JCuuotXWvS0RCMFY0kdCUdv0wLoeO05ZyKjplblfm8bCWIiWRXV6bjh6QC1gFPzKjOf 7jT8BCx6H37qpv2DgTiQgDk+1fwBmDIVkuiM= X-Received: by 2002:a1c:a78c:: with SMTP id q134mr5391859wme.98.1578586176750; Thu, 09 Jan 2020 08:09:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwxEWwuCOkJR5Ut8BjsE0zeZF0JVq4HT7AdNp/Reici8OM453wT+4LqvjkdS8rpxKybepscTA== X-Received: by 2002:a1c:a78c:: with SMTP id q134mr5391844wme.98.1578586176598; Thu, 09 Jan 2020 08:09:36 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e8sm8517707wrt.7.2020.01.09.08.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:09:35 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 53/57] arm64: Generate no-ops to pad executable section Date: Thu, 9 Jan 2020 16:02:56 +0000 Message-Id: <20200109160300.26150-54-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: vM5fI1FqP5CQuAVlgM5l-g-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080943_119949_72666D71 X-CRM114-Status: GOOD ( 10.11 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Directive .org fills the gap left to get to the new location with bytes of value 0. Having an executable section contain invalid opcodes confuses objtool, so use .balign to fill the gap with nop instructions instead. Signed-off-by: Julien Thierry --- arch/arm64/kernel/relocate_kernel.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index c1d7db71a726..5e08845f701a 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -118,6 +118,8 @@ ENDPROC(arm64_relocate_new_kernel) .align 3 /* To keep the 64-bit values below naturally aligned. */ .Lcopy_end: +.balign KEXEC_CONTROL_PAGE_SIZE +/* Ensure we didn't go past the limit */ .org KEXEC_CONTROL_PAGE_SIZE /* From patchwork Thu Jan 9 16:02:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A272B921 for ; Thu, 9 Jan 2020 16:21:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1BD7820661 for ; Thu, 9 Jan 2020 16:21:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="J1FhLoUb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HTLpXl9Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BD7820661 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=BnpkrwI7JuBUUMltDq/HU3eGPnaBHesoz512wNvT6tw=; b=J1FhLoUb69TvNp hiVv2ZqTdwg46SFtVq7s9V5xZbxrA3bUj4Xy0aGpUe94i25n/P7R2Hfc4uIdKw2O0ks7qRQpyIfWD hQuh06Etb7J9drfFR3nCYwnPTWKSmu62ujYkopGEASodEPfsyEss+FS0KAbZfndQZehPW+SqHkTY1 YLT/aS83gCRAOjkgGA32nOBvPdmigMQhtCY3s8XOKZDpIEYU76HlC59BJiP3JI3m3IrQwsmqr5Fgc 5bBHMLBHYHppGbGo07bAPkAwzFN4wntc4OP5CEWUSo2JGuOZeUJ7CFNGsBtJurKPUc/ovcSL7Av0T Y9EpP7urPZsjeY3MIW1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaYa-0007xU-U7; Thu, 09 Jan 2020 16:21:12 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNR-0002d8-OW for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:09:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586180; 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=z92LbMne7Yt4VDMBIOJNt2FZqBadMcBmYAHWqfjNEw8=; b=HTLpXl9ZOTLwCIlGDPmEkitrMyTrD6D0jlP6CgTw/Plt5N63LKYtEu+BbbmrmQxu1l+TwO 5ez0AzHG5VG7J7fXJ8M8pw73Jr0uskttLV8iiZ8+hVTE8x8u+yH58JUkuYIFEFpT02MJjt 71HK6jFPox/f8g80IbidDdgLE+M3ZT8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-dEX7-1S6M8-UerYq3OvkKQ-1; Thu, 09 Jan 2020 11:09:39 -0500 Received: by mail-wm1-f70.google.com with SMTP id t16so1103729wmt.4 for ; Thu, 09 Jan 2020 08:09:38 -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=wMGHjJl3e1P107q4BQ6psOhaStZ5a/m6KJ9UhI8WuJA=; b=KhV6ECe2kcIEc2MXdd+xWVM2b2IKEuF/UXBxqf27J8n8m0MR4KDa9M4EsG7NYAcQiF kP5YQK0UnVUvO7mJQ2jLCHHjMZWxXufQNS6NpTRbihCv6iWw8wwpkqnFLafXnqZwbHKq QQ6b0nNyyRrIxxhu09Vc/kqESatel2LUPyZkVtk9daS21C/XZCn6E7gohlmV3Tu0grdC aqgNGP13vjyHmE1tUwHDpkvXG6Whd08dmsTUVZhqyJ1li/8WE62ULOR+lD6ezDaDnLK4 kcp6BbPLjaE7DSaHdu12nun7bg/UQEZBU8ZCgHaGU65Ts2zFvrnCWJgf8UH6XpwweBQT G8gA== X-Gm-Message-State: APjAAAVjRRSQ0RxM9l61R8PCR5ymWRoE1ekBkCZFn0YpvYXsHEtvmTSN rDrUiziKHe2Ken8wtxHEXLzai1M8CRaqdFMqbgL6q4+LnM6AgOweYtgwD1HjvQ9sMavfxqwkWq/ I8oZ1mMoqZCoX/TriV0s/iclrEmmAGgpWmWQ= X-Received: by 2002:a7b:c93a:: with SMTP id h26mr5626263wml.83.1578586178082; Thu, 09 Jan 2020 08:09:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxbW0SbCoj52xkl2G5xsHM6LJP70fkM18f+faXI8eAh4PCwOpImStNR0bRzwb42NSJPmkTJoA== X-Received: by 2002:a7b:c93a:: with SMTP id h26mr5626254wml.83.1578586177927; Thu, 09 Jan 2020 08:09:37 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id e8sm8517707wrt.7.2020.01.09.08.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:09:37 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 54/57] arm64: Move constant to rodata Date: Thu, 9 Jan 2020 16:02:57 +0000 Message-Id: <20200109160300.26150-55-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: dEX7-1S6M8-UerYq3OvkKQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_080941_888309_44691582 X-CRM114-Status: GOOD ( 10.69 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Constant arm64_relocate_new_kernel_size does not need to be in the same section as the new kernel code/data region. Move it to ".rodata" section. Signed-off-by: Julien Thierry --- arch/arm64/kernel/relocate_kernel.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index 5e08845f701a..e7a5fded59e6 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -122,10 +122,13 @@ ENDPROC(arm64_relocate_new_kernel) /* Ensure we didn't go past the limit */ .org KEXEC_CONTROL_PAGE_SIZE +.pushsection ".rodata", "a" /* * arm64_relocate_new_kernel_size - Number of bytes to copy to the * control_code_page. */ .globl arm64_relocate_new_kernel_size +.align 8 arm64_relocate_new_kernel_size: .quad .Lcopy_end - arm64_relocate_new_kernel +.popsection From patchwork Thu Jan 9 16:02:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35DB2921 for ; Thu, 9 Jan 2020 16:22:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 13A782067D for ; Thu, 9 Jan 2020 16:22:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="U9yC7Av0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wc9VQur5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13A782067D 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Rstr0bQmnbiVAKQoXLcR+jNPmgW7ZIpYI79pcjescPs=; b=U9yC7Av0/GPm3D 01U7kU2Wj/6tM2CgvTl27v4RbM0wPXzw22nz0DsBVat6a6zb88isTbTbi8Ms+5gPHh3qNn13y0qQn A840+DXEpnOAiG8+tyi/6tDa9a6rBanmHRLy+MK62tyAoxZMlU0VSxzt41AX/plMXwatIPQyK9/9d ho5wway3VoGVUtF3+SPcSRJ3j087s65H0XcmNfW0LuZ79GuS3ZLBr9DV4YfimNWNIWxqCCeWssL1N pyTGSbWP/QaMlDJ0cQKh2wb0wgaJGBJWD1uYn0mROe91qcDEnyAPCgOMOmSv5rpBBuevxzVZfmgal DN1c2waXhySuJrxy6OWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaZM-0000DE-4W; Thu, 09 Jan 2020 16:22:00 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNy-0004Dm-7G for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:10:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586213; 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=+i3Z5hWXW12eDu4B56KhWBmac7Q2y5XMkxb+3N11Qwo=; b=Wc9VQur51J0ug+Urdh1GgWnoOqal7IHMJWQt2qGLn9cVcBATUp/aWTFnR+gHLnKgv3z64w 8YaBEnC0NWC3rETZM9OivUNFbOP7Bqs7i1fo/0ILK0oIBg1HkfNZOszk6JawNJD3VVqrBH km3A0eCXMCqLbg8aEoV5bPnAfJUEvyI= 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-288-bRcJlu6vMziG5nxC_F4RMw-1; Thu, 09 Jan 2020 11:10:11 -0500 Received: by mail-wr1-f70.google.com with SMTP id b13so3033175wrx.22 for ; Thu, 09 Jan 2020 08:10:11 -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=DAmIKVrG0XTaKJJzMfiZimG349dykVofBy5TCpIMs8E=; b=hInq3S1Yvl4xSA2+lKJiEIBVxTfQliD9xoEDENxme819qkcOXg0uKrFK0VPZuafeLP GfWneaoJNkgpBcUr48w0H3uJ/8PEIsKWlTutfRPtjdjsJxcPT9oPEPw6C79NGvVXCInJ VcXPnRSXQGuWKQkKN5FA1cOngDunQvb4oKJ8ybT8FW/on/MjHgxQNgoVX8Jj/spa1L7V NYBQ+ZWviSslrtSv+xrHj/ouFquDYPoxmtSj5tP/IO4nvxf2aC+DkICu6EKIWSnkeXWt EZayPBm8/wya0B1ELwyRc8VRwKyIsheim5VYGWXmCaE2/450vzTyzv/q5SvHY3tVhALq EYUQ== X-Gm-Message-State: APjAAAUqBQmdlu4YiJXpE8g33imH/XevBIiWi4Nra8ysHcvo08cJDjgB u7jBwGVpXHihapaG9Dne7exMvzMCaF6VYEqFDN6a883cAr2ap3Hf5dv0TjyOk5blCekkSBQD1Vy q2NaXbW1mNb1Ll/xTBVGQdX++80g6Z7QIU0g= X-Received: by 2002:a7b:cb91:: with SMTP id m17mr5844660wmi.146.1578586210076; Thu, 09 Jan 2020 08:10:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyFva8eO8YAHVsY7yqkadvzeSK9FfRmzCmEmBFRtKNIs9P8qgXGmLAvH+I97ylIV2hDbJg/RA== X-Received: by 2002:a7b:cb91:: with SMTP id m17mr5844651wmi.146.1578586209923; Thu, 09 Jan 2020 08:10:09 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id y17sm2820948wma.36.2020.01.09.08.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:10:09 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 55/57] arm64: Mark sigreturn32.o as containing non standard code Date: Thu, 9 Jan 2020 16:02:58 +0000 Message-Id: <20200109160300.26150-56-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: bRcJlu6vMziG5nxC_F4RMw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_081014_360076_6F2BEC1B X-CRM114-Status: GOOD ( 10.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org sigreturn32.o contains aarch32 getting copied to the VDSO for compat user tasks. This code shouldn't get validated by arm64 objtool. Signed-off-by: Julien Thierry --- arch/arm64/kernel/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f5994679db5f..b978026ea368 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o ifneq ($(CONFIG_COMPAT_VDSO), y) obj-$(CONFIG_COMPAT) += sigreturn32.o +OBJECT_FILES_NON_STANDARD_sigreturn32.o := y endif obj-$(CONFIG_KUSER_HELPERS) += kuser32.o From patchwork Thu Jan 9 16:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 164DB139A for ; Thu, 9 Jan 2020 16:21:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D28722067D for ; Thu, 9 Jan 2020 16:21:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ehnmoBey"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PuvD/yRi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D28722067D 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=yZQBA4uBtn++pF2ffV99Br28bkKdkCh5YXTY+YnrfXI=; b=ehnmoBeypzPE9u qQwcqc1yamtyuM03mKhAkXkALmvdnQDCsqhdlnd2Um09G2pFMnk5IliiDdLEbzrX+xVe6cvWXGGR0 oHk3R6BhijRIouY/XA898OHDk4yDZXuUGb4afC/QjSf3o+uOHE2RYDF7013H9Hag2GvQI8RsWYnaW W40rFEQxcfEAxZkAf4ew+AjlYH6+u6FNqJqY7dKb1iriWkMGfSdio/zGwrUmuTvT4ZkAj3o6y5OfW pzpPS9255Qo68FGKfa9vFQH40aRgRgIAh+GkxZkQzlYJOw4xZTC6lyC3Gsdi+DK841pO1SO4YtO8+ Kt0Dw8HIGB0aVSTpq2rw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaZ6-0008Qv-8d; Thu, 09 Jan 2020 16:21:44 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaNz-0004KW-B6 for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:10:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586214; 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=5VgBxd3qS0wKjC/wLgflSpgJ/VaLgo/t0uo8AAjhMac=; b=PuvD/yRiniAoQunmeXmLJiT8bL3RWlbsDZoImXP/6ct0l2HcAy5tCiC0QA2a/SrzXIO5Jl X4S2jbt8DfmBfDem23QZtjFQ0XUSnWGfjQuW5/qDUkSzbgLOLIy9+t/uypO0/L6QfneBGq qVDgGcRRMymg+FvjwLV61uXSid+vhA4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-8fHlPllcPMWKviw31RYjIA-1; Thu, 09 Jan 2020 11:10:12 -0500 Received: by mail-wr1-f72.google.com with SMTP id r2so3051669wrp.7 for ; Thu, 09 Jan 2020 08:10:12 -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=pYrT6TRHMGtnrr0wIPLjvHg1Nvng0fUgO8VFzG9RuSY=; b=o+fagK495gM9Biyd3Jq8O682SRvxvp0tbaRyjAzulEppYTzp43pnSlZhr/AaA2Nb/y QUxYbVxxZ19aZ2k15IiseXCi+Ivtyr9zXFRrxP+dNKXljkcczCNJfW7D3hOj3cHxiiRN 8jDYtEPUiQNGGg0XRM588sBOIi0IyIA4pVIGxf2WbGrqWD439VC766Zn6jSmscrbF9fr Vw7CqR71cg8MC/f8mbNVz2D1WH5gt89r3aO5d+jJO2InISVIDyAFOwPMxqbPuhQxpISg LTaV44Ywgj9OYJpjeFz8wJ5kgPHb6FTuBrnjQILT2olM80pF42ZGLF1uHXQ6Qsfq5vLx AJuQ== X-Gm-Message-State: APjAAAUJZ6FmigAaCdovq/YCbBLPPzUy6FmHEhr9eyldEfyPQscPLjNo PNy2WUD5BAOcdWT0BDelACWkFqGvpuC5wv0IQ+QGEJrzzpNGcheyv4s86JhD/R/49BOcjHgQB4B jJ7ie+gXnGs2vpyRPEFDza4yD34v5xU7udhE= X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr5599512wml.138.1578586211421; Thu, 09 Jan 2020 08:10:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyjp1dWXem4kmadDnAuoaApxhJOhhpVFrfaTf6yB8TLsgHEvhENEDjZczqJHI6GszCgiysJfg== X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr5599496wml.138.1578586211254; Thu, 09 Jan 2020 08:10:11 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id y17sm2820948wma.36.2020.01.09.08.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:10:10 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 56/57] arm64: entry: Avoid empty alternatives entries Date: Thu, 9 Jan 2020 16:02:59 +0000 Message-Id: <20200109160300.26150-57-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 8fHlPllcPMWKviw31RYjIA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_081015_505238_ED7FC4BC X-CRM114-Status: GOOD ( 10.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org kernel_ventry will create alternative entries to potentially replace 0 instructions with 0 instructions for EL1 vectors. While this does not cause an issue, it pointlessly takes up some bytes in the alternatives section. Do not generate such entries. Signed-off-by: Julien Thierry Acked-by: Mark Rutland --- arch/arm64/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 7c6a0a41676f..605bb7cbe499 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -60,16 +60,16 @@ .macro kernel_ventry, el, label, regsize = 64 .align 7 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \el == 0 +alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \regsize == 64 mrs x30, tpidrro_el0 msr tpidrro_el0, xzr .else mov x30, xzr .endif - .endif alternative_else_nop_endif + .endif #endif sub sp, sp, #S_FRAME_SIZE From patchwork Thu Jan 9 16:03:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 11326173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68623921 for ; Thu, 9 Jan 2020 16:22:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 45B2720721 for ; Thu, 9 Jan 2020 16:22:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SmH6fI9C"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eJ6vuxum" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45B2720721 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=BBnZMlYZvoItkSxKHv3d5RnDZJ2nfj2AwJvKhjXRIIk=; b=SmH6fI9C2BQ9H8 sLAB+KAlFCt7zegVaF0rNHIR0p7ig6HpnFMiD8SqR4sXoR8tSsV+g0IVFjKzMI85E8NDXNpRZwXhO N8SJI3L7ntKBuQcYbGCf6JxBosoETsGC8R2dDOpzF24ngvcrbKCNz+pv8RqI4YWwCpcQg2RITWBML dClpe11eSlgxfIzmNlu+prFrC/JEHs64JnwgIubzut8XxJT9fLtyQY65II8yQY4tCZ/AJNDDRMHPv 1T0xcZwFP75j9AcSDbM0AR+Dc0E2OhHbe688KWg80p4koL0cwYRSO/+g0yjyY2t9/Enpj8DGt/THS nQmWuWPy/l/kJEBwcjRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaZf-0000W2-OR; Thu, 09 Jan 2020 16:22:19 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipaO2-0004PL-Ts for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 16:10:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578586217; 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=sbYnzt6Q3TQUglatyKTswckBiC0xrNxpjYH5/smlmTQ=; b=eJ6vuxumQru9kwCeDB4poaj9tNfaGERle0KeyygqX0t5lpro2ucOl/Yi+FOTOEVmZrRIq8 KNhmNT5yxar3i/LnpKodNoFkZj0HAruUIH+dBQpPOybUaBp/KweLRpCXk83km396NXxFGx uFZ8mcSQRkTWDDSewYB6ac6zwu7PRgc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-8yvO9ik2O5WwptoBeeNTBA-1; Thu, 09 Jan 2020 11:10:14 -0500 Received: by mail-wm1-f70.google.com with SMTP id c4so1097816wmb.8 for ; Thu, 09 Jan 2020 08:10:13 -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=ZnSP0pZ70yH/YNEnLlm1kliMX25WmuqwN7ivPVxI2v0=; b=CltvDGN1nUtde+RzNKLr9Dbvr7k9h8tTbfkzhU9ewxMyGJ6H1cIvsiUvw/dBUMBpPD TbgZKJ9HTL1ZvqQpCU5aidFGRsuX4PrMvIw9DHT9nQaPG7o6Oy/kRvLyhZyONOlb/HdY sYGD0J/amPz8Vxf+yub2/cd1yfb5+I+m0rqJRUmwOm7McrK/2+we5eWytSKfvR8fiC+O 84/3w+XI5PoBxpJwvXHRmcgqLZDW/ztSR2Cft3bFQ9Ru+EDHsM3nkfWxguaX85mVM46d fjKN75Zzxc4hjdTULerH5qFYutzLwXKL9ofGl4IhGs0gUDB5v23/umUhKFtLjygBNgWY Pqyg== X-Gm-Message-State: APjAAAVrAXd/9Fkv2lNEo+3KsNJ/yHoQyr+Xf+vzQndRKnQvcybJmSUX 5NTcr9VVW67VgMfMriot0XHdb3aTokqzEvLG+tvJ8f+2L+ba1JKqkZaMu1FEGRDq+YKK8gNSBtJ 83z+2HTh+CdCzMpBAjSRbs6MJkDpxkOXLA+A= X-Received: by 2002:a05:600c:108a:: with SMTP id e10mr5542132wmd.38.1578586212974; Thu, 09 Jan 2020 08:10:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxZtD+rP6Em4mTjnCX/pV4lGl7JJYz5/HOrqpOas0kvGyMcAfBoXa6ico6Rve7JUKRHzsZgbw== X-Received: by 2002:a05:600c:108a:: with SMTP id e10mr5542098wmd.38.1578586212717; Thu, 09 Jan 2020 08:10:12 -0800 (PST) Received: from redfedo.redhat.com (host81-140-166-164.range81-140.btcentralplus.com. [81.140.166.164]) by smtp.gmail.com with ESMTPSA id y17sm2820948wma.36.2020.01.09.08.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:10:12 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v5 57/57] arm64: crypto: Remove redundant branch Date: Thu, 9 Jan 2020 16:03:00 +0000 Message-Id: <20200109160300.26150-58-jthierry@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200109160300.26150-1-jthierry@redhat.com> References: <20200109160300.26150-1-jthierry@redhat.com> MIME-Version: 1.0 X-MC-Unique: 8yvO9ik2O5WwptoBeeNTBA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200109_081019_049259_1A6CC3CF X-CRM114-Status: GOOD ( 11.35 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: Julien Thierry , peterz@infradead.org, catalin.marinas@arm.com, raphael.gault@arm.com, jpoimboe@redhat.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Having a unconditional branch between the macros do_cond_yield_neon and endif_yeild_neon causes the endif_yeild_neon to be unreachable. It so happens that endif_yeild_neon expands to a branch and already allows to provide the label to jump to after the yeild. Get rid of the redundant branch instruction. Signed-off-by: Julien Thierry --- arch/arm64/crypto/sha1-ce-core.S | 3 +-- arch/arm64/crypto/sha2-ce-core.S | 3 +-- arch/arm64/crypto/sha3-ce-core.S | 3 +-- arch/arm64/crypto/sha512-ce-core.S | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/arm64/crypto/sha1-ce-core.S b/arch/arm64/crypto/sha1-ce-core.S index c2ce1f820706..50ca9d11a61f 100644 --- a/arch/arm64/crypto/sha1-ce-core.S +++ b/arch/arm64/crypto/sha1-ce-core.S @@ -132,8 +132,7 @@ CPU_LE( rev32 v11.16b, v11.16b ) st1 {dgav.4s}, [x19] str dgb, [x19, #16] do_cond_yield_neon - b 0b - endif_yield_neon + endif_yield_neon 0b b 1b diff --git a/arch/arm64/crypto/sha2-ce-core.S b/arch/arm64/crypto/sha2-ce-core.S index 6f728a419009..c64716f5de19 100644 --- a/arch/arm64/crypto/sha2-ce-core.S +++ b/arch/arm64/crypto/sha2-ce-core.S @@ -139,8 +139,7 @@ CPU_LE( rev32 v19.16b, v19.16b ) if_will_cond_yield_neon st1 {dgav.4s, dgbv.4s}, [x19] do_cond_yield_neon - b 0b - endif_yield_neon + endif_yield_neon 0b b 1b diff --git a/arch/arm64/crypto/sha3-ce-core.S b/arch/arm64/crypto/sha3-ce-core.S index a7d587fa54f6..2448d8dec0de 100644 --- a/arch/arm64/crypto/sha3-ce-core.S +++ b/arch/arm64/crypto/sha3-ce-core.S @@ -203,8 +203,7 @@ ENTRY(sha3_ce_transform) st1 {v20.1d-v23.1d}, [x8], #32 st1 {v24.1d}, [x8] do_cond_yield_neon - b 0b - endif_yield_neon + endif_yield_neon 0b b 1b diff --git a/arch/arm64/crypto/sha512-ce-core.S b/arch/arm64/crypto/sha512-ce-core.S index ce65e3abe4f2..703724703f8f 100644 --- a/arch/arm64/crypto/sha512-ce-core.S +++ b/arch/arm64/crypto/sha512-ce-core.S @@ -207,8 +207,7 @@ CPU_LE( rev64 v19.16b, v19.16b ) if_will_cond_yield_neon st1 {v8.2d-v11.2d}, [x19] do_cond_yield_neon - b 0b - endif_yield_neon + endif_yield_neon 0b b 1b