From patchwork Mon Aug 1 12:12:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 12933726 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E3C2FC00144 for ; Mon, 1 Aug 2022 12:25:24 +0000 (UTC) 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=9Iih0aLJ6mWTc4ucaGIHfS7XwSTEK/mrzgqobm2475g=; b=FCQ0xTVZg4D/u9 KlFNnBLusW4U+N/4IRdkIFYpYOHsrL0KWUX1QIkiPCn/sjrCUc3aXEB2ZthWU1BzLcDqvOPCUXRk0 M0WJ12QX0NcwlW08v8gB3rz5lYWRAxb0alg8B4er1L7u8DbwGcNll13y9XQOOUkJkDmvti70HKglz gA3XqF9OMmG5Smdwzk/QyotH1PmgsiHscqbZ3blDUpkNDj4ew9EbeipujpWImry4WtDN//paofgB4 bqv6wQaWUuPvS0B1qg/f0OkvosX7VDmoSnjtGBcg6XiL9VIoxOl/G86Os8fiyjuQUr38/DSUswNv5 +j1wvzDpW56g3IGTUFPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oIUT1-0067vh-Uu; Mon, 01 Aug 2022 12:24:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oIUHc-005ym1-BK for linux-arm-kernel@lists.infradead.org; Mon, 01 Aug 2022 12:12:30 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5ED16139F; Mon, 1 Aug 2022 05:12:27 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 653A43F73B; Mon, 1 Aug 2022 05:12:25 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, kaleshsingh@google.com, madvenka@linux.microsoft.com, mark.rutland@arm.com, maz@kernel.org, tabba@google.com, will@kernel.org Subject: [PATCH 4/8] arm64: stacktrace: add stackinfo_on_stack() helper Date: Mon, 1 Aug 2022 13:12:05 +0100 Message-Id: <20220801121209.2479449-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220801121209.2479449-1-mark.rutland@arm.com> References: <20220801121209.2479449-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220801_051228_495038_A5635223 X-CRM114-Status: GOOD ( 12.81 ) 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 Factor the core predicate out of on_stack() into a helper which can be used on a pre-populated stack_info. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Fuad Tabba Cc: Kalesh Singh Cc: Madhavan T. Venkataraman Cc: Marc Zyngier Cc: Mark Brown Reviewed-by: Mark Brown Reviewed-by: Kalesh Singh --- arch/arm64/include/asm/stacktrace/common.h | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h index 676002d7d333c..9ed7feb493a36 100644 --- a/arch/arm64/include/asm/stacktrace/common.h +++ b/arch/arm64/include/asm/stacktrace/common.h @@ -66,21 +66,34 @@ struct unwind_state { struct task_struct *task; }; +static inline bool stackinfo_on_stack(const struct stack_info *info, + unsigned long sp, unsigned long size) +{ + if (!info->low) + return false; + + if (sp < info->low || sp + size < sp || sp + size > info->high) + return false; + + return true; +} + static inline bool on_stack(unsigned long sp, unsigned long size, unsigned long low, unsigned long high, enum stack_type type, struct stack_info *info) { - if (!low) - return false; + struct stack_info tmp = { + .low = low, + .high = high, + .type = type, + }; - if (sp < low || sp + size < sp || sp + size > high) + if (!stackinfo_on_stack(&tmp, sp, size)) return false; - if (info) { - info->low = low; - info->high = high; - info->type = type; - } + if (info) + *info = tmp; + return true; }