From patchwork Mon Apr 1 20:01:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1073176 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IhnLXCu5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Y3Cl2JzBz9sQw for ; Tue, 2 Apr 2019 07:02:27 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C55CEC21DF9; Mon, 1 Apr 2019 20:02:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5C12EC21C27; Mon, 1 Apr 2019 20:01:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 177A8C21CB1; Mon, 1 Apr 2019 20:01:57 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id C3584C21C27 for ; Mon, 1 Apr 2019 20:01:56 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id h18so815518wml.1 for ; Mon, 01 Apr 2019 13:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o1KnhIkv9I8vW16kC2tyon0xkHjt6GBAwXX/SIS7c8o=; b=IhnLXCu5jmTwvMENrmNNvxo83EbHo01u98XaGFr//MaG4X+zCwUJzHHTylG17nc1I3 SQlbeyYPUkmE+yvA7/eBLu6QRsnbBRGpMou4SbK8qPEgUQNBEi/bS48z4glep6nv99Aq p9lawmvB0ruFUTvuwEhYS5Wu5pYT3tZ57x4fIKIIPidpNPY1zzE4yMALzO+6jGzlJwgn /swpXsZRq5L9+jw2EclnbgHy7zxFMjOrgALUGNED57ikB0uKL5FeHrCYTIJxUklJRmkb StpOXgDd0+p5S1ahsF8YAp3lcUqK+h5ORKw4aWmjDGojwODR558PBTOL0wlhO50BJzHQ 4IAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o1KnhIkv9I8vW16kC2tyon0xkHjt6GBAwXX/SIS7c8o=; b=Iv2jA88+ofl2z4tja/yaF5DC69zDo8oHBaXwqAyWjhqbhbfJSiSF4PSrwvyCPCkSzY PwRYkwp4u+bNr1a35Rjnk7KbuH0XISWlzTUirvMrGFGsBI5GtlihWCJVXZ5b6MkrMcLr dRnWa/uaTKGY0094Rg2+Dljt52hnfD3FbCjz8HcXAVVhBs2n3+ZMjx4JMwvhc2RqptHj puJfrGJGXEkq1XYOYJ61kFfBvl5vALHiMwxdiHyVnTXCm5/0trtr6FK9StopYjl92lUb jjtac0UzpsjpkLPNb3HRmsyYXOjCs56XMuQIhrD73Wu1UDh1ZIUJRuEwdffe3YhzBODP eaOg== X-Gm-Message-State: APjAAAWxm5fVWeKxA7x3HT6C42e9lOYYXNHWubKt98U1gl8bmRJoHlsE OsC0ICUUyulL5KidKsBls5c= X-Google-Smtp-Source: APXvYqzQ0Yk2WoHEjrn0FSm+EhoEQ+RvdcuvDtUPCVimf41uzJR1kPHD4G4CL6UiimTi4nBGcFgImQ== X-Received: by 2002:a1c:acc8:: with SMTP id v191mr952004wme.72.1554148916474; Mon, 01 Apr 2019 13:01:56 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:113a:1a5f:8497:9ca8]) by smtp.gmail.com with ESMTPSA id v190sm29322364wme.18.2019.04.01.13.01.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 13:01:55 -0700 (PDT) From: Simon Goldschmidt To: Tom Rini , Simon Glass , u-boot@lists.denx.de Date: Mon, 1 Apr 2019 22:01:49 +0200 Message-Id: <20190401200150.1630-2-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401200150.1630-1-simon.k.r.goldschmidt@gmail.com> References: <20190401200150.1630-1-simon.k.r.goldschmidt@gmail.com> Subject: [U-Boot] [PATCH v4 1/2] dlmalloc: fix malloc range at end of ram X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" If the malloc range passed to mem_malloc_init() is at the end of address range and 'start + size' overflows to 0, following allocations fail as mem_malloc_end is zero (which looks like uninitialized). Fix this by subtracting 1 of 'start + size' overflows to zero. Signed-off-by: Simon Goldschmidt Reviewed-by: Simon Glass --- Changes in v4: None Changes in v3: None common/dlmalloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index edaad299bb..51d3bd671a 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -603,6 +603,10 @@ void mem_malloc_init(ulong start, ulong size) mem_malloc_start = start; mem_malloc_end = start + size; mem_malloc_brk = start; + if (start && size && !mem_malloc_end) { + /* overflow: malloc area is at end of address range */ + mem_malloc_end--; + } debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start, mem_malloc_end); From patchwork Mon Apr 1 20:01:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1073177 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Rxq0HtG/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Y3D50nSkz9sQw for ; Tue, 2 Apr 2019 07:02:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C40CAC21E3B; Mon, 1 Apr 2019 20:02:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E1239C21CB1; Mon, 1 Apr 2019 20:02:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0DAE2C21E2F; Mon, 1 Apr 2019 20:02:00 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 1C7DCC21DA2 for ; Mon, 1 Apr 2019 20:01:58 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y13so13665365wrd.3 for ; Mon, 01 Apr 2019 13:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YjAZIStuno6EWjYgetT0ikyXAyYnwOiL7QmTJEQnTso=; b=Rxq0HtG/SQCxNJeK1BV4TJCAE2kBPIRJATkKb3+e69/Tc+CU56WGQK6bUXTPuxnGLY 8RERXTvC7L/nJd1DRx/cK5GqFvwKPZrHmNGGOCBbtj05+lRlkV6ZvecUeZP2Xag4Vce8 6tKOjhf+ya0B8ouXu1Bk7cE6mtr37o04KNyfSCBgFNCmbICw7I31xb060a+Qm+wSL8rv gvLIqJWyXVtxXTgPRV/jcWFWaeU5T4p6KUnKlkv+80Mo44CGF6qAYu9CJf2FqYWAOOvH ef5BxIf98kFHpbdsuRHEf7tl+VokHmyDFaFg5XQfPxIOTGoY0REgvA6GvuAmTK0WvOTd s4Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YjAZIStuno6EWjYgetT0ikyXAyYnwOiL7QmTJEQnTso=; b=G1upXCQytRjTBswdX77CYfw/HsGlC7mmDC0ct3SbKGRC4UZOVJcaRnoFxJHqXMXdw6 EHvVuBXUFTAPFxok2tpbysuMW7UqisAygBuAcsvRoCMMDU6vIDfDYL7mrOrS4POYYGg4 Fq6svIKXoYTn3akQPLbT7ZzOe5RMica3LlYuJZbkIB6GhhDHJBB/XusVJiOGu/3znAaX s3rFA+BxqENkoKb9dTuPfbMIkBmBu2lhR0LTJiSWlIQvlmqxc4mt3LZomRs8j0DRbNI5 f0sE2Xzyswu119kP0dHiVpNiMWBdApzdnEI6pDJqyfCr8euel6pasLVCTN2/s7vYsLPB JifA== X-Gm-Message-State: APjAAAU5iX2LrS2gpF/LKndzmJDvKwdEkGUSXhQTyWzXeekHH1SZLXHa jLYvD6All5bCb4vDRw4AojCBzAYy X-Google-Smtp-Source: APXvYqykwhpmgZ8gjLl7I8R867J+emhH0SgqT1DzWwA1NdTAp4uRePZhXSKRZHlgDU6M9t+ylMbNtQ== X-Received: by 2002:adf:f88c:: with SMTP id u12mr42106631wrp.235.1554148917812; Mon, 01 Apr 2019 13:01:57 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:113a:1a5f:8497:9ca8]) by smtp.gmail.com with ESMTPSA id v190sm29322364wme.18.2019.04.01.13.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 13:01:56 -0700 (PDT) From: Simon Goldschmidt To: Tom Rini , Simon Glass , u-boot@lists.denx.de Date: Mon, 1 Apr 2019 22:01:50 +0200 Message-Id: <20190401200150.1630-3-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190401200150.1630-1-simon.k.r.goldschmidt@gmail.com> References: <20190401200150.1630-1-simon.k.r.goldschmidt@gmail.com> Subject: [U-Boot] [PATCH v4 2/2] dlmalloc: be compatible to tiny printf X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Convert debug output from '%#lx' to '0x%lx' to be compatible with tiny printf used in SPL. Signed-off-by: Simon Goldschmidt Reviewed-by: Simon Glass --- Changes in v4: - dumped clearing BSS before SPL board_init_f, only real bugfixes remain Changes in v3: - fixed summary ("stack" -> "heap") - enable CONFIG_SPL_CLEAR_BSS_F for socfpga_arria10 using full malloc early in SPL - rebased common/dlmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 51d3bd671a..af6f43dcc9 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -608,7 +608,7 @@ void mem_malloc_init(ulong start, ulong size) mem_malloc_end--; } - debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start, + debug("using memory 0x%lx-0x%lx for malloc()\n", mem_malloc_start, mem_malloc_end); #ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT memset((void *)mem_malloc_start, 0x0, size);