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 X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82566C433DB for ; Thu, 4 Feb 2021 07:09:52 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 536C864DC3 for ; Thu, 4 Feb 2021 07:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 536C864DC3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codefail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DWV6j1dhdzDwq5 for ; Thu, 4 Feb 2021 18:09:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=codefail.de (client-ip=198.54.127.59; helo=mta-06-3.privateemail.com; envelope-from=cmr@codefail.de; receiver=) Received: from MTA-06-3.privateemail.com (mta-06-3.privateemail.com [198.54.127.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DWV4f2phLzDwpk for ; Thu, 4 Feb 2021 18:08:01 +1100 (AEDT) Received: from MTA-06.privateemail.com (localhost [127.0.0.1]) by MTA-06.privateemail.com (Postfix) with ESMTP id 78EE66009C; Thu, 4 Feb 2021 02:07:57 -0500 (EST) Received: from localhost (unknown [10.20.151.215]) by MTA-06.privateemail.com (Postfix) with ESMTPA id 23E4960099; Thu, 4 Feb 2021 07:07:57 +0000 (UTC) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] powerpc64/idle: Fix SP offsets when saving GPRs From: "Christopher M. Riedl" To: "Nicholas Piggin" , , "Michael Ellerman" Date: Thu, 04 Feb 2021 00:59:37 -0600 Message-Id: In-Reply-To: <1612014056.e1qcnzac7c.astroid@bobo.none> X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat Jan 30, 2021 at 7:44 AM CST, Nicholas Piggin wrote: > Excerpts from Michael Ellerman's message of January 30, 2021 9:32 pm: > > "Christopher M. Riedl" writes: > >> The idle entry/exit code saves/restores GPRs in the stack "red zone" > >> (Protected Zone according to PowerPC64 ELF ABI v2). However, the offse= t > >> used for the first GPR is incorrect and overwrites the back chain - th= e > >> Protected Zone actually starts below the current SP. In practice this = is > >> probably not an issue, but it's still incorrect so fix it. > >=20 > > Nice catch. > >=20 > > Corrupting the back chain means you can't backtrace from there, which > > could be confusing for debugging one day. > > Yeah, we seem to have got away without noticing because the CPU will > wake up and return out of here before it tries to unwind the stack, > but if you tried to walk it by hand if the CPU got stuck in idle or > something, then we'd get confused. > > > It does make me wonder why we don't just create a stack frame and use > > the normal macros? It would use a bit more stack space, but we shouldn'= t > > be short of stack space when going idle. > >=20 > > Nick, was there a particular reason for using the red zone? > > I don't recall a particular reason, I think a normal stack frame is > probably a good idea. I'll send a version using STACKFRAMESIZE - I assume that's the "normal" stack frame :) I admit I am a bit confused when I saw the similar but much smaller STACK_FRAME_OVERHEAD which is also used in _some_ cases to save/restore a few registers. > > Thanks, > Nick