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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BCB9C77B7A for ; Wed, 7 Jun 2023 16:55:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8719F85F50; Wed, 7 Jun 2023 18:55:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="tidJQigH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 16C5D8603A; Wed, 7 Jun 2023 18:55:11 +0200 (CEST) Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3D75484720 for ; Wed, 7 Jun 2023 18:55:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-565ee3d14c2so84387877b3.2 for ; Wed, 07 Jun 2023 09:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1686156907; x=1688748907; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0UU8Vl0Ky7T3LYyolBJiORaYsDF7JABD4NaEvJZw5ho=; b=tidJQigHT8uVkeWCz9ws8kIEB5FMzSQxGrk7E0woX41ajFri2LvF/Kfm0ywLuKnqmB THxfhOgCPZ5Y2YZClYHvepd5b7y0tchoTJP7VwzHnt+LJnsB50N3x/pbuByJyBg0kzwC tJTa3uIKiSjKrQRp8rK1EPt4ttzVg6mkm7sLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686156907; x=1688748907; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0UU8Vl0Ky7T3LYyolBJiORaYsDF7JABD4NaEvJZw5ho=; b=CGoRlYotCK2u1NxFYGliGJwZy/JTTVVD4h+h+I9k6WNy+llHNxnHIScwl1PZjwFjDC bfz4NJYDyCrMjLDIRZ8xc7tB6//HJNs96LpK4a430SQ1nrb10PhXOLB6Pzmosm2UNiQq ZKIOORjgCkkKVnnkKm0J+pNLK0HrEFVP+5ELq/tyiQwxJip9kKW35YsyczHZJXZUqmYP slo0pL1yuRyNLQ/Xq9jBRYLRFfRbttjtJxw9QKGPYAzaflKkMjK8vfi19RGenBr4qD+Y /SKnnkI9WEoZxgaGe/zX8cxrRTK4TgV5BmwJ/ppVqXwmn1g8EvrajFEWOu31UbMx1amC YBzQ== X-Gm-Message-State: AC+VfDx33PlYYRx4DzC+64/BnBuw5Rkfc1bxQGFxap0eZj4HWeKE4yAD epIg1xlabMc/ZUbYqR8qsH8XDG+VfqcdoH1DKUCoXw== X-Google-Smtp-Source: ACHHUZ6tIdW/r/o9/CvsJMVMYGV8bXLpeBn0kqa4KEdN95jFlVsc5LSnEzHzpLBHcI5I4aGWtKuiQg== X-Received: by 2002:a81:ab4e:0:b0:568:bc97:13cc with SMTP id d14-20020a81ab4e000000b00568bc9713ccmr6726566ywk.8.1686156906924; Wed, 07 Jun 2023 09:55:06 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-a32f-7d20-53ba-bf5b.res6.spectrum.com. [2603:6081:7b00:6400:a32f:7d20:53ba:bf5b]) by smtp.gmail.com with ESMTPSA id u84-20020a814757000000b00545a08184f8sm4859153ywa.136.2023.06.07.09.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 09:55:06 -0700 (PDT) Date: Wed, 7 Jun 2023 12:55:04 -0400 From: Tom Rini To: Vignesh Raghavendra Cc: u-boot@lists.denx.de Subject: Re: [PATCH] common: spl: Warn about overflow of SRAM stack Message-ID: <20230607165504.GF1871110@bill-the-cat> References: <20230607042841.2906576-1-vigneshr@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NL+Z7Mr2ufla7Vqh" Content-Disposition: inline In-Reply-To: <20230607042841.2906576-1-vigneshr@ti.com> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean --NL+Z7Mr2ufla7Vqh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 07, 2023 at 09:58:41AM +0530, Vignesh Raghavendra wrote: > If early stack usage is exactly same as SIZE_LIMIT_PROVIDE_STACK, then > its most likely to have overflowed beyond this limit and corrupted any > regions beyond stack. Warn about this to the user. >=20 > Signed-off-by: Vignesh Raghavendra > --- >=20 > I found this useful when debugging slient corruption of code/data leading > to random failures post relocation. >=20 > common/spl/spl.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/common/spl/spl.c b/common/spl/spl.c > index 72078a8ebc8e..9a9c8fad7673 100644 > --- a/common/spl/spl.c > +++ b/common/spl/spl.c > @@ -950,6 +950,13 @@ __weak void spl_relocate_stack_check(void) > } > printf("SPL initial stack usage: %lu bytes\n", > CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK) - i); > + > + /* > + * If we used up all of the SIZE_LIMIT_PROVIDE_STACK, then here is high > + * possibility of stack overflow, warn the user accordingly > + */ > + if (!i) > + printf("SPL possible initial stack overflow detected!!\n"); > #endif Since we're already inside of CONFIG_SPL_SYS_REPORT_STACK_F_USAGE being enabled, we should rework the previous print to include something like "%lu bytes free". --=20 Tom --NL+Z7Mr2ufla7Vqh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmSAtl4ACgkQFHw5/5Y0 tyyXGQwAqHucAYGJVW59TVf9aWGcLOzvfjXMhdjLoiJclXkCDS6iJpWLhKCvBAME PDyo1noG4wbdt/82AdRHHOhkHtUQwtcysvST6R/4j/zAzKVK5v6oWD+/Zd7/LlJK b/WYPOeLB6TEe62LlkWDX68t3mq1A5SuZ9cLvuRvGJRPf1EzbLM4iIsNPziSVA8G 5wbrZiHRyYMpAt+9rCIn3q/bb5567sSbpH9KpmqZCShnq0yccU4G+Y43XURIpCTk BwRaPQKhSHjBGaqZka0Tp8a194+4DgUHL4Nx7s6OA0vac+ZoRiXtuYUIgl3zgkOc Cxa3djR3TyyqMN5568D8tcnJfLWGPmQ9fKv69kx9yRHU4GMBV7lmw2kpf43YEuBE aJe9SJkoV6b7JpP9jOVG01R7JXN6KZWpOKpIqJ6STUY7vW1RTTg/3Wi8wOiY1+qE ukLdUIJvI6zR6NEQ2TzcoVutDubEeRn+1iB8mpzH66AZi7yopfo4m48gYt7reo5N b560RzJn =0jKX -----END PGP SIGNATURE----- --NL+Z7Mr2ufla7Vqh--