Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp802592imn; Tue, 26 Jul 2022 09:40:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1skn8qFAgQvel/2SvENWyZBpYUMUb8AQDK0uXvLDkmfBUkW8b5hoZk7d2Mgy8ONkWJz2OoC X-Received: by 2002:a63:2b15:0:b0:412:4d98:7956 with SMTP id r21-20020a632b15000000b004124d987956mr15351980pgr.325.1658853609992; Tue, 26 Jul 2022 09:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658853609; cv=none; d=google.com; s=arc-20160816; b=GHmX034EHTPIYUTRg/kOEB/0JA7l5t/uONbFGVBQ62jjEQc35Efgikg6ZvyWS0dJ/d oePrLipVbbXPEqUOjIDOfoNvc1D+hpG4raLvnUoOBaGmUFDi48XlBfcHVS6gnC2Qd/wH GoEZzu6BwKbCJ8QR5OcmL2R3tw5xffJRIPoyEwn1roWCKW19O72Hq3Juu0pk4561jqrI PlkLkCpZWuwNHU0/zqzXX2plIoSvVtg0lFCpOyewdk4/U8qH6KjBoKruae3kC8aOuOZf NsQ/2BqV+IJpreBi0n2qlh/XZ4Oyeb1lxy9Y8Cqi6kqVC8ryVuJ+lclr4WTy+4DLzqs0 chkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=m0CV2W7dVE73d4ftCiQVaVjvzGaUUh2uHnu4xDPCb78=; b=GaQ5LjLfqwjok5NFEYAqD1GE3TSE3sUoH4/p99o75dk9c6swroIwxS5FNmLRwuNxR+ uHipPXxWpn1bNMt9hNPkmw4hcw+holHduCu8VTaXQWIiez612QShQx/faMAgc3upxWgv k1XCkTFYhYkShCiCqEzAlX4mBDtKKGn9VLjx/lrnglHz4Y18wn3cmmWOaSIxvK8GKdnc HKU7Bib6X3zl4PFuHDxebP9BS9O4esjOUcM8wszVsuj0pwRS0AsgF7E1hTTkBV1Msvf6 Qw54rTqPk3L6/8wJUwK07nU0w/DInBczAoH9I/JbAYITzGmUilWxZPMVf/WU0jCw5FVJ OMrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t9ReExPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r200-20020a632bd1000000b004114723aa79si17340258pgr.819.2022.07.26.09.39.52; Tue, 26 Jul 2022 09:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t9ReExPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233546AbiGZQBT (ORCPT + 99 others); Tue, 26 Jul 2022 12:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiGZQBQ (ORCPT ); Tue, 26 Jul 2022 12:01:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C20A62EC for ; Tue, 26 Jul 2022 09:01:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 265F0B8188A for ; Tue, 26 Jul 2022 16:01:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBD2BC433D6; Tue, 26 Jul 2022 16:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658851272; bh=DHUG3G6oDdbExivbTRSmCxGZxYcDFTMMnotqPESDqzc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=t9ReExPnzY/gdMw/kXnJlrqdiYV51tB+2NdOr5fIHN6zhEtqWLTU9phWCgOaKw5AQ tRqE2ceotgUs9grXCm6pOLQ8I0zYRJJBFlUmr2OukTnl/JtZ95NQeWyxn4eebjL1cA H97XU93PcxZEn10IkSiYE/vHCSc/dq2muruf9NxYbLUTJuSPC/UrL+rofn7NzG/v3s 7gRiUgO+B+bTgaFY7oEVijyyfdpCXHpoTdaNZIiSV+M8FNVJd1m6yRie2xoq4AtEOG zG7GnXz7WEYcfh9+mnxC2BGd9rgG66cCwt+rj5N4jJiUn6p1yFP9vH7AQTAE03QHtl 9ASVGc/LiMQ3g== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oGMze-00ABgg-I7; Tue, 26 Jul 2022 17:01:10 +0100 Date: Tue, 26 Jul 2022 17:01:09 +0100 Message-ID: <878rofyibe.wl-maz@kernel.org> From: Marc Zyngier To: Kalesh Singh Cc: mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, tabba@google.com, oliver.upton@linux.dev, will@kernel.org, qperret@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 Subject: Re: [PATCH v6 02/17] arm64: stacktrace: Factor out on_accessible_stack_common() In-Reply-To: <20220726073750.3219117-3-kaleshsingh@google.com> References: <20220726073750.3219117-1-kaleshsingh@google.com> <20220726073750.3219117-3-kaleshsingh@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kaleshsingh@google.com, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, tabba@google.com, oliver.upton@linux.dev, will@kernel.org, qperret@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-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Jul 2022 08:37:35 +0100, Kalesh Singh wrote: > > 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); > +} on_accessible_stack has the following comment: /* * We can only safely access per-cpu stacks from current in a non-preemptible * context. */ With this change, I don't think we satisfy this requirement anymore, as we're checking the overflow stack *before* the preemptible check, which is a big change in behaviour. The hypervisor doesn't have this requirement: the unwinding is either done out of context (nVHE, where EL1 unwinds EL2) or in a non-preemptible section (pKVM, where the whole thing is non-preemptible). But the kernel is usually preemptible, so this patch needs fixing. I'll see if I can address it locally (I'm currently moving things around, stay tuned). Thanks, M. -- Without deviation from the norm, progress is not possible.