From patchwork Mon Sep 27 21:03:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12520813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDC9EC433F5 for ; Mon, 27 Sep 2021 21:12:41 +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 8237860EE7 for ; Mon, 27 Sep 2021 21:12:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8237860EE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LJbEqKxD1a8E3U8SYl7oOi+fYHOQHLImor2Hc30hoD0=; b=rCczu8N1vMJsF/ dkSIfEgEuJ+O+aADlLQvD2Jj4YwUjd93eifUrYsgHQoyhlCDvSbYk6sdxJvm13tzxd5K1BOmseuvw ln2GcSUNqi6UPrEr7a8PkIjU2wDrZJXc5R8TWti1lxRTFccYi8V+Nx59jriLBVTUFkAcWwrFY1mJH RBUYaXu87f+pX2sAjcN/oWyfzg3otrSaXCZf9N+O8phXWf4Y5HtPStrkI7zlnQnSUw4rLOivTG9k5 b971MEBQ4BmisAPk6HEBuML2fcfixv9mujjt7dbRJGrkBajvLDqWQdM2f6fICtuIyU5gzKXEZPdqU 8ETNg5hex0YbBdZhl5Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUxt3-004LOi-JY; Mon, 27 Sep 2021 21:10:10 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUxmX-004ILR-A8 for linux-arm-kernel@lists.infradead.org; Mon, 27 Sep 2021 21:03:26 +0000 Received: by mail-pj1-x102b.google.com with SMTP id v19so13370953pjh.2 for ; Mon, 27 Sep 2021 14:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fx3CrEPWbTBsdv7Fz/Y72SC7soyMpdM/flXeUOHk7Co=; b=XJbgw7UkEF7s3JguBn6NkX9KNS5QjzXleVYxhSlS1VwFFXf6mhaWyiRc/gG6HBpNZv o+VkqjNnAResAHQXEzOl5yHHOu310BZxqB9NVvt7wsVOJXYiYnDGejjKmYQjPywqmHhr uyHFJmUSTmW5H/0zumsOL1jzfsLFqbbShbf12axdg+CkpPnXG6nu32DOhEgSwp69fgFM jtETQKuH44eVidq0FqHevfqvkKUTzq9NuZthbh7yIHJIXbjrGLApV/rF+7jg2Fnx4sa8 oHgpWy92Y1j4fdNSM/pJ4+yNnSMecC/8oDBlOvaB9c1/z40Zf1GfBfjKiVa3i2ehfAmV MXMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fx3CrEPWbTBsdv7Fz/Y72SC7soyMpdM/flXeUOHk7Co=; b=AlCJacqToML6XoR4EaoNFoKOR38O5Gu6z2nVDzfU1eEiNUq+YjUQTpds7+A28B2N5b RHCiBZAnfc23Nx+GQw5M/D+sbhuGB3rz2Rx2/lokauElqfyzb7F34cQqEMk/2e8GQVye V7yaf+aSDLagj56KDHcTrxLWZVSR6a+fqWUR+88wMcIrckqqrJUiWmSAyIvyHQ4wvY/h n5nUokhpMmIMzep13xDYeq9UQR5kN5oTohMOBheIKt8sfuLU8Z6VfrysJ1XA+kfYw8fB BkzDMrwPgmkdbaysZYGWWG1s4xGPlXiu3tNCTyI5+FZeDvbCtUV9GXWhyI/v009/33qf n11w== X-Gm-Message-State: AOAM5330/YcPfnP/YR7yOG7y9UZUL29pWppbGL+U7/CzTz5fDva3LwLx /J7Aci1tBwOQMlG3nQ0uA68= X-Google-Smtp-Source: ABdhPJzyBHlnSeRzNHO0WALa9j+NLwyJEx/T9JF4ia5gx7AS+fUj8jYjvNeh2+23xpREFhtx0Tq5WQ== X-Received: by 2002:a17:90a:2944:: with SMTP id x4mr1236586pjf.131.1632776602501; Mon, 27 Sep 2021 14:03:22 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id e12sm16444086pgv.82.2021.09.27.14.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 14:03:22 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Sasha Levin , Alex Sverdlin , Russell King , Florian Fainelli , Steven Rostedt , Ingo Molnar , Russell King , linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT) Subject: [PATCH stable 4.9 v3 2/4] ARM: 9078/1: Add warn suppress parameter to arm_gen_branch_link() Date: Mon, 27 Sep 2021 14:03:14 -0700 Message-Id: <20210927210316.3217044-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210927210316.3217044-1-f.fainelli@gmail.com> References: <20210927210316.3217044-1-f.fainelli@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210927_140325_381601_7B3468ED X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alex Sverdlin commit 890cb057a46d323fd8c77ebecb6485476614cd21 upstream Will be used in the following patch. No functional change. Signed-off-by: Alexander Sverdlin Signed-off-by: Russell King Signed-off-by: Florian Fainelli --- arch/arm/include/asm/insn.h | 8 ++++---- arch/arm/kernel/ftrace.c | 2 +- arch/arm/kernel/insn.c | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/arm/include/asm/insn.h b/arch/arm/include/asm/insn.h index e96065da4dae..0043bf609f27 100644 --- a/arch/arm/include/asm/insn.h +++ b/arch/arm/include/asm/insn.h @@ -12,18 +12,18 @@ arm_gen_nop(void) } unsigned long -__arm_gen_branch(unsigned long pc, unsigned long addr, bool link); +__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn); static inline unsigned long arm_gen_branch(unsigned long pc, unsigned long addr) { - return __arm_gen_branch(pc, addr, false); + return __arm_gen_branch(pc, addr, false, true); } static inline unsigned long -arm_gen_branch_link(unsigned long pc, unsigned long addr) +arm_gen_branch_link(unsigned long pc, unsigned long addr, bool warn) { - return __arm_gen_branch(pc, addr, true); + return __arm_gen_branch(pc, addr, true, warn); } #endif diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 414e60ed0257..a95bc0a02fd8 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -97,7 +97,7 @@ int ftrace_arch_code_modify_post_process(void) static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) { - return arm_gen_branch_link(pc, addr); + return arm_gen_branch_link(pc, addr, true); } static int ftrace_modify_code(unsigned long pc, unsigned long old, diff --git a/arch/arm/kernel/insn.c b/arch/arm/kernel/insn.c index b760340b7014..eaded01b7edf 100644 --- a/arch/arm/kernel/insn.c +++ b/arch/arm/kernel/insn.c @@ -2,8 +2,9 @@ #include #include -static unsigned long -__arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) +static unsigned long __arm_gen_branch_thumb2(unsigned long pc, + unsigned long addr, bool link, + bool warn) { unsigned long s, j1, j2, i1, i2, imm10, imm11; unsigned long first, second; @@ -11,7 +12,7 @@ __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) offset = (long)addr - (long)(pc + 4); if (offset < -16777216 || offset > 16777214) { - WARN_ON_ONCE(1); + WARN_ON_ONCE(warn); return 0; } @@ -32,8 +33,8 @@ __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) return __opcode_thumb32_compose(first, second); } -static unsigned long -__arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) +static unsigned long __arm_gen_branch_arm(unsigned long pc, unsigned long addr, + bool link, bool warn) { unsigned long opcode = 0xea000000; long offset; @@ -43,7 +44,7 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) offset = (long)addr - (long)(pc + 8); if (unlikely(offset < -33554432 || offset > 33554428)) { - WARN_ON_ONCE(1); + WARN_ON_ONCE(warn); return 0; } @@ -53,10 +54,10 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) } unsigned long -__arm_gen_branch(unsigned long pc, unsigned long addr, bool link) +__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn) { if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) - return __arm_gen_branch_thumb2(pc, addr, link); + return __arm_gen_branch_thumb2(pc, addr, link, warn); else - return __arm_gen_branch_arm(pc, addr, link); + return __arm_gen_branch_arm(pc, addr, link, warn); }