From patchwork Fri Jul 15 06:10:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12918762 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 F044DC43334 for ; Fri, 15 Jul 2022 06:12:10 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9SU1BnMuhA3CiMZfhrXqtVV1dhWIlsYb1JQ/+RLMdGM=; b=BZN2MOZSAN/UbLJbxNLLTLiIGK SFn8/o/oQdSKdQpVNnuAZwZ+Y2yXA18CX+4f6c3QfnJnBMvQqZxdqhb6Icz72eIHi/pVdBXIYun8v ZYNtbZQ1wg0pESJUJyWPGUheFeeMGHntmuD7Y9FgomEN7xA7U/6LZJZvKr/8zvDRmv7CoyE/KxRmO Y847JLZrXfFd92lqAekPg8LfqRcQnlelRBNFPALuS6QT9/VKts2sdN+v4ism0Mu+bn4nBgc5FUwie bPn2Wrrs2Ne++Yd1SONDiWz3bgE1GwnNd8SoMcif0Ca5cOCLBN9jmhoh8sHLD5Vwdxa8J3J0TfWy5 vnk+woiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCEXR-004WCQ-Tq; Fri, 15 Jul 2022 06:10:58 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCEXC-004W7v-Ht for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2022 06:10:43 +0000 Received: by mail-yb1-xb49.google.com with SMTP id m5-20020a2598c5000000b0066faab590c5so3269839ybo.7 for ; Thu, 14 Jul 2022 23:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/Ia+O9M0Pz2+/05x4XoBRaUcJqadaj8Ww7ydsZGTIyc=; b=AsFH83JSc75pqQLjhwbkNC5eEmbVMfMhBpPhg7rjc25BQstmijhQMgTA+PPbxJYlqN QPVHh8kifhnzc58ChmI3fgEyNUKltfrMrL+ztxu2EOY7NCdrkHxnV8NMvG/wC3CD+uXU dAxvUDRaBJDjKtmTWDjl5DPdd+gPLE/+RiY4lPMa2oGT1tRuMwcgcIPgFOqRKpNBMp9d Khxf6sFE2z9CYuQWyepW9GSGfVixtwjnqotLqhBTyVuYzQxt7DIX7fontQfVBdI7aFon MuJbSY7lOoXOx555VBK2EWAbxAa10joar+VP9GpSz11xwuxaKieYJDSmFvWw+Kh7aS+7 lQpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/Ia+O9M0Pz2+/05x4XoBRaUcJqadaj8Ww7ydsZGTIyc=; b=wH9O0CjhoMf3vVwk+DZN3l1ziaZI5js2Ly2UDXsyT9xgcL4WyaiuxlG3vne+yK/xwJ Yl2nk6X/CUMuO/dIyIup0ogsJlqKFKZWWrtrSci6PGBmdOVY55RGyecsNuOP0X/O8KUC zQzBql4sTTGHZu66AeyCOj4x3cE6O3dB5Cwej2HvBY38G8Lc8wbChVIidv/x+lVdpla/ e9LCLci+53pu9rkITBaHn+6l/9BWcpk4dHUrM61YLbhBaatuho+EhI6AX9shPuhQkwKj hz94VUY672yO0LiuEeaWhUiHXtvVPgcQ8F/WPpc4/iICswhDGB+MeF7+ORHqwg9V/xED jZQQ== X-Gm-Message-State: AJIora+BASdI+xlGjKsfqw1EQ7Ao4MZ/HfL0cNt5Rv3OQSP0aS7YJGTM 3L6ra0MSuH5RpOXeZR5AoqpyHj0VGGGvh0wHoQ== X-Google-Smtp-Source: AGRyM1vQf/Bx1CweucDNGXThIQceIJF3jerLq31SSlQ4DRKoZzzVX77BCd9Mi+GQ+qVz+MEqdkAvXKVOyWEjNha+Qg== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:f010:455b:62ce:19e]) (user=kaleshsingh job=sendgmr) by 2002:a0d:f647:0:b0:31d:17cc:3337 with SMTP id g68-20020a0df647000000b0031d17cc3337mr14046493ywf.100.1657865438690; Thu, 14 Jul 2022 23:10:38 -0700 (PDT) Date: Thu, 14 Jul 2022 23:10:11 -0700 In-Reply-To: <20220715061027.1612149-1-kaleshsingh@google.com> Message-Id: <20220715061027.1612149-3-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220715061027.1612149-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 02/18] arm64: stacktrace: Factor out on_accessible_stack_common() From: Kalesh Singh To: maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com Cc: will@kernel.org, qperret@google.com, tabba@google.com, kaleshsingh@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, russell.king@oracle.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, drjones@redhat.com, wangkefeng.wang@huawei.com, elver@google.com, keirf@google.com, yuzenghui@huawei.com, ardb@kernel.org, oupton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, android-mm@google.com, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220714_231042_617416_E3F9C3FE X-CRM114-Status: GOOD ( 14.10 ) 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 Move common on_accessible_stack checks to stacktrace/common.h. This is used in the implementation of the nVHE hypervisor unwinder later in this series. Signed-off-by: Kalesh Singh Reviewed-by: Fuad Tabba Reviewed-by: Mark Brown --- arch/arm64/include/asm/stacktrace.h | 8 ++------ arch/arm64/include/asm/stacktrace/common.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 79f455b37c84..a4f8b84fb459 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -56,7 +56,6 @@ static inline bool on_overflow_stack(unsigned long sp, unsigned long size, struct stack_info *info) { return false; } #endif - /* * We can only safely access per-cpu stacks from current in a non-preemptible * context. @@ -65,8 +64,8 @@ static inline bool on_accessible_stack(const struct task_struct *tsk, unsigned long sp, unsigned long size, struct stack_info *info) { - if (info) - info->type = STACK_TYPE_UNKNOWN; + if (on_accessible_stack_common(tsk, sp, size, info)) + return true; if (on_task_stack(tsk, sp, size, info)) return true; @@ -74,12 +73,9 @@ static inline bool on_accessible_stack(const struct task_struct *tsk, return false; if (on_irq_stack(sp, size, info)) return true; - if (on_overflow_stack(sp, size, info)) - return true; if (on_sdei_stack(sp, size, info)) return true; return false; } - #endif /* __ASM_STACKTRACE_H */ diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h index 64ae4f6b06fe..f58b786460d3 100644 --- a/arch/arm64/include/asm/stacktrace/common.h +++ b/arch/arm64/include/asm/stacktrace/common.h @@ -62,6 +62,9 @@ struct unwind_state { struct task_struct *task; }; +static inline bool on_overflow_stack(unsigned long sp, unsigned long size, + struct stack_info *info); + 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) @@ -80,6 +83,21 @@ static inline bool on_stack(unsigned long sp, unsigned long size, return true; } +static inline bool on_accessible_stack_common(const struct task_struct *tsk, + unsigned long sp, + unsigned long size, + struct stack_info *info) +{ + if (info) + info->type = STACK_TYPE_UNKNOWN; + + /* + * Both the kernel and nvhe hypervisor make use of + * an overflow_stack + */ + return on_overflow_stack(sp, size, info); +} + static inline void unwind_init_common(struct unwind_state *state, struct task_struct *task) {