From mboxrd@z Thu Jan 1 00:00:00 1970 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 7F08DC00140 for ; Tue, 26 Jul 2022 16:02:25 +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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uRPq5QC6rugqPtv4ZoAG+erkN/USO9Iq71x785meuQc=; b=VwmqQ20c9seUEq NY0U14GpWZNjLCTxWfxZaMDt46X+7sxKETACm93onKsoIzMQqLRUrXnEf99x3IqqOV1DyIsseTt4c v7VVWM9Xct8TONLfZu8ow5FRi3m669Rbstun2u/nh6IgNBWCkkEJek2mSmYbNFeK6royq+wCE1mkf hbyhBFUcdTBvu265uFxW7CmaBueYW+APsNpU6NMpJcrtHrb/ubj7vuh5x31eVHljh3LRYc3aCu2X/ qqabkiMmGKUGU497mDGJ48wsqO7Om3w7YOl/i3+KOh5e2BAKre9J3TLYOBUTPzLmC0QVp1qBBYTbp 4wYYbetNWtRg+g7tETOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGMzn-000pF8-Qn; Tue, 26 Jul 2022 16:01:19 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGMzk-000pD9-Bm for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2022 16:01:17 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6472060D3E; Tue, 26 Jul 2022 16:01:13 +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") 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220726_090116_501392_AD54A42E X-CRM114-Status: GOOD ( 28.06 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel