From patchwork Tue Jul 26 07:37:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12928977 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 E812DCCA489 for ; Tue, 26 Jul 2022 07:39:20 +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=j0lO4YhpHehymt6pZtEne90WHSrJ7rPiYp3YwaXSO8E=; b=W/tEdxZPDHYgoDn6Zx0rErKFxO /W3+pLu20YOWCFTdqGP2rclcdGQAE4EBirfJwwQmue40R1GO6WY4I8xRszfioiOJGd14Ntq3f1G72 H+BHg63ulgQhzWnDY85h4SRsgXPnBxwfZHNalXIO5w5zKeAq8X3vxKcyqn20op3dD7BIzGhdM792y cN0audi8D4gl+mkO0Vuqq3dY8ALBi1uxpk9J6O9a2P7DfkoauD4TkIM7+LrTuHiPOuFVWp/jeD8EB RMvOKz5sos+sGe8L/nri/1gjaINknoEZY3myNIXuP1bLGKNry2lkLfNFBV0FaGx+9LCY7LgkfdZch Bc9CPxpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGF94-009VpD-SA; Tue, 26 Jul 2022 07:38:23 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGF8j-009Vd3-7z for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2022 07:38:02 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31e619dcbbaso104751897b3.14 for ; Tue, 26 Jul 2022 00:38:00 -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=HJlaI56zFqTbz4E9QM1JRki26p1CmhrJ0ldLZAGD5Gc=; b=Hg/ba+twU69xuQeTauHfGh1xd/IG5mrk63mhJ8YbvAnkIYauk5mYLezBlA1CBAAwo5 iudwXyj1NFecmdhOgDc713Mpd26tUbphRGBTx9y6x3SGfN+p2OKUD22cbjv1uK0Zs2iK 7n537VLpecnFLR32XUyFwgB3FNRhMtF/cc8+8rqGN3vGNoImYNblyhe1sxYMZIG5lzi1 sx9avbYpCLnTFekr6sLBtneCRMNiIRO9FkeJ79AvkazD6dHzX0TGFnDTV7OdwpiJ+6TE YS8w/xFCmTCZs1aYynybx790r1vSYJn2pkRV1zejr+IyokyYFn7uf1IPyeW8bkGwewTz uyvQ== 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=HJlaI56zFqTbz4E9QM1JRki26p1CmhrJ0ldLZAGD5Gc=; b=In/pVLiomZh3A/lG0CDfvIPZ+jVJoWOAbwVOGd6uGFSKXtu9CD7GJId/l6cb+gO2ey 6OltkJeS9rwwFaBY/oKoFzrWodhgodAFjPMc42ZMpbBi8f7pvkoOD+YfqpceNXhD8oP0 46HgBgzS8+5AcmbZnkAHLtU0rcotMGSvsyJ8RgQaZ6q3MyAf+2b98Tv9dkIIJZmWD6n0 EjCQO//31/MSQ4XmP/HWky+oAdrTXjWEAY9+oxOK/8vbsyLEDaargTKsMPTACmo1TYyB yyaVQqspblJjJ9ICVb//5HtfCPXD2U0gpd4Y8Nq5EivKZSoLtzI/116TEm+6BtESRskU tokA== X-Gm-Message-State: AJIora/g648LW6F+jJlV4vK5n826Mk4n8EkiH7VIKilwhVSad0fozn9e p0UVNdGmqsK6JXvyXWWSwjpeNaQAxw3uzKYS2g== X-Google-Smtp-Source: AGRyM1sij8eAETksDM9PJQAcvuFaOFZtWgM4fTTWZ/PJWmBJUpgq02OLuiPRM+zMspwuXb4dIPzCV3Wazxh9bcMfGw== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:4f77:3b64:736a:394e]) (user=kaleshsingh job=sendgmr) by 2002:a25:80d3:0:b0:66f:5da5:204f with SMTP id c19-20020a2580d3000000b0066f5da5204fmr12492060ybm.30.1658821079950; Tue, 26 Jul 2022 00:37:59 -0700 (PDT) Date: Tue, 26 Jul 2022 00:37:35 -0700 In-Reply-To: <20220726073750.3219117-1-kaleshsingh@google.com> Message-Id: <20220726073750.3219117-3-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220726073750.3219117-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH v6 02/17] 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, tabba@google.com, oliver.upton@linux.dev Cc: will@kernel.org, qperret@google.com, kaleshsingh@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, 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-20220726_003801_326224_3364A181 X-CRM114-Status: GOOD ( 13.83 ) 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 Tested-by: Fuad Tabba --- Changes in v6: - Add Fuad's Tested-by tag Changes in v5: - Add Reviewed-by tags from Mark Brown and Fuad - Remove random whitespace change, per Mark Brown arch/arm64/include/asm/stacktrace.h | 6 ++---- arch/arm64/include/asm/stacktrace/common.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 79f455b37c84..43f4b4a6d383 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -65,8 +65,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,8 +74,6 @@ 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; 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) {