From patchwork Thu Apr 25 19:22:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1091054 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="bH5n0tUv"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44qnC54kt0z9s3q for ; Fri, 26 Apr 2019 05:22:55 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 07C62C21E49; Thu, 25 Apr 2019 19:22:51 +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, 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 8D60AC21C2C; Thu, 25 Apr 2019 19:22:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 40B5AC21C2C; Thu, 25 Apr 2019 19:22:47 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id E8B9FC21BE5 for ; Thu, 25 Apr 2019 19:22:46 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id f7so964667wrs.2 for ; Thu, 25 Apr 2019 12:22:46 -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; bh=B5mG8isOkGBr+G58nH0v6NEJu2AgMLIkQl3k3Qnoexc=; b=bH5n0tUvEEDwN2wPUXHcl1CTEDNPkwXLrTWII71QcXs1s6AZaOMsj/aNeMXtt6bpWe 0SYSDVHvibJPUHMPDl4l0WuUQab8zcykR7uRd0yTV+OLrpbX03zvxAdODnrpms0B+r9B 6NKkGfp9sbVKs0q0VVoDZ5tQud4xreQjUhUvant2Z5SjjcXY7TNzD3GKWAACwPBmUIRx Diu8x1kbKv3N8Lzwm2ix53vZ4jSFT4+6aewx+Nj4tXAIf1eOp76MvaUqfaBX/O8z9A2S /FDxF6CI6AnWSxCJyIbyuKVpmISJKHbb/iqmqoT0gpdwYdaTrieApmFVnnQpDgro1kg8 aNkA== 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; bh=B5mG8isOkGBr+G58nH0v6NEJu2AgMLIkQl3k3Qnoexc=; b=Gbz2dIw6pDg2eGrZOBu6xXpmMowFEY7rL8fK1/vrJZBJG5K4osaagLUlgIOnq0a2yt lDZTiulBW3rYWFYaq8bLGHN8YQnmVBDfBJGO2ITADVs2Q5tHb9KkwOvcHxjjpbA1k2dt FshxNJXVsIKe3UFBq3MCPPl0LYjwmdydyk+onJ9wmr03T468CxLUL4tvbjvF7uhPVrb7 +eCaLM5hlRb+3ipHQt/aFr+xqkN5J4LGiF8kkt1xOG0+QmIyL3PNpe8rt1WvDmEWFc4w Nv7rp4NJ1FcNTXpIZl8fjI4R19xCLPV78eurLp+S40Tz1f3D698WW+H31ZsUc9xRbNBy 4osg== X-Gm-Message-State: APjAAAWSo99pUW8U2yLJUYlFc0f7Z3bGKtxlEj3mT7Y1Y7BfzeYvaGdx qjmFW4FnUhytB2/RY9cgat4= X-Google-Smtp-Source: APXvYqwRwv9sQC2CvCDhuP3g/TK280cN9hRwLFPn8k0zchWIvZehF+mkej0uOnfrwDrtW5yPtdV3pg== X-Received: by 2002:adf:e407:: with SMTP id g7mr26479415wrm.47.1556220166595; Thu, 25 Apr 2019 12:22:46 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:1caf:b95c:3a06:5af0]) by smtp.gmail.com with ESMTPSA id 17sm18644406wrk.91.2019.04.25.12.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 12:22:45 -0700 (PDT) From: Simon Goldschmidt To: Tom Rini Date: Thu, 25 Apr 2019 21:22:39 +0200 Message-Id: <20190425192240.5925-1-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 Cc: Stefan Roese , u-boot@lists.denx.de, Mans Rullgard Subject: [U-Boot] [PATCH v5 1/2] spl: fix linker size check off-by-one errors 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" This fixes SPL linker script size checks for 3 lds files where the size checks were implemented as "x < YYY_MAX_SIZE". Fix the size checks to be "x <= YYY_MAX_SIZE" instead. Signed-off-by: Simon Goldschmidt --- Changes in v5: - added patch to fix linker size checks off-by-one error arch/arm/cpu/u-boot-spl.lds | 6 +++--- arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 4 ++-- arch/microblaze/cpu/u-boot-spl.lds | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds index a2aa93a735..97899a567f 100644 --- a/arch/arm/cpu/u-boot-spl.lds +++ b/arch/arm/cpu/u-boot-spl.lds @@ -79,16 +79,16 @@ SECTIONS } #if defined(IMAGE_MAX_SIZE) -ASSERT(__image_copy_end - __image_copy_start < (IMAGE_MAX_SIZE), \ +ASSERT(__image_copy_end - __image_copy_start <= (IMAGE_MAX_SIZE), \ "SPL image too big"); #endif #if defined(CONFIG_SPL_BSS_MAX_SIZE) -ASSERT(__bss_end - __bss_start < (CONFIG_SPL_BSS_MAX_SIZE), \ +ASSERT(__bss_end - __bss_start <= (CONFIG_SPL_BSS_MAX_SIZE), \ "SPL image BSS too big"); #endif #if defined(CONFIG_SPL_MAX_FOOTPRINT) -ASSERT(__bss_end - _start < (CONFIG_SPL_MAX_FOOTPRINT), \ +ASSERT(__bss_end - _start <= (CONFIG_SPL_MAX_FOOTPRINT), \ "SPL image plus BSS too big"); #endif diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds index 3955bea23a..74f6355229 100644 --- a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds +++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds @@ -52,11 +52,11 @@ SECTIONS } #if defined(IMAGE_MAX_SIZE) -ASSERT(__image_copy_end - __start < (IMAGE_MAX_SIZE), \ +ASSERT(__image_copy_end - __start <= (IMAGE_MAX_SIZE), \ "SPL image too big"); #endif #if defined(CONFIG_SPL_BSS_MAX_SIZE) -ASSERT(__bss_end - __bss_start < (CONFIG_SPL_BSS_MAX_SIZE), \ +ASSERT(__bss_end - __bss_start <= (CONFIG_SPL_BSS_MAX_SIZE), \ "SPL image BSS too big"); #endif diff --git a/arch/microblaze/cpu/u-boot-spl.lds b/arch/microblaze/cpu/u-boot-spl.lds index 99c62b51a1..3387eb7189 100644 --- a/arch/microblaze/cpu/u-boot-spl.lds +++ b/arch/microblaze/cpu/u-boot-spl.lds @@ -57,6 +57,6 @@ SECTIONS } #if defined(CONFIG_SPL_MAX_FOOTPRINT) -ASSERT(__end - _start < (CONFIG_SPL_MAX_FOOTPRINT), \ +ASSERT(__end - _start <= (CONFIG_SPL_MAX_FOOTPRINT), \ "SPL image plus BSS too big"); #endif From patchwork Thu Apr 25 19:22:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1091055 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="HtHouAOO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44qnCY64GBz9s3q for ; Fri, 26 Apr 2019 05:23:21 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8FEDAC21DB6; Thu, 25 Apr 2019 19:23:08 +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 DF7FAC21E3B; Thu, 25 Apr 2019 19:22:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5393AC21C2C; Thu, 25 Apr 2019 19:22:48 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id 050F3C21BE5 for ; Thu, 25 Apr 2019 19:22:48 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id r6so947506wrm.4 for ; Thu, 25 Apr 2019 12:22:48 -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=GP7Ij4LDCNwv9ryOqHPMC9Q7heZuztklGEAhBlp4+Bs=; b=HtHouAOOmLM6aGwnj7mCBCdRmgwnTNeB2iHkuqN2aoa2C326cXPfoNYEZusnqFsLWd qVMpBEwyGY5358zs6ilnuse/EuQ9GGDBPuzobZqTztsjnAW1L8LZFGpYEuoNGi2SZLje 2rRXRxN+Le6VBgQbuCuUBcooYozLIotLar4TI0E0tJj/PLzE1DYenzC2hrhJO1reYE8J XRG+ptzyGKz2Pc4RESb9wCaoGq9KVRu2DXsZgQv9zMlyewMHfLI8pq7+q5GL4VWiZV1N NndXt6gYjVnAYaMEVsOj+nDSDTm8A8Yf/B8rrbGS9XOzhvg/OeXC/y0r1qmKUJ9cIA/o 2BEw== 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=GP7Ij4LDCNwv9ryOqHPMC9Q7heZuztklGEAhBlp4+Bs=; b=AlfvdJUq7EnCejpcHpAAhHOtDNyE3TaMIyhMdKS5Xjgrcx7P1w0RHUVRPfpsp3n7Bi JuNa00tvo1xm9BqG8DMF2ymQfBdMZoqLnZDNZbDsvjn5MZe/mbvUIvw1bpGUGC4ZAqaV hQGUiy3Gz/a3Vs0vrPzxw/bqbfKI5qWQm70IaJa8xM2ax9nTXpNFVKpd8VqVXzRldzCw OTbOJGBnjBngdN70+gfFZskrrm0WQWt+4MUAK5MOLWY/s7jOCCLC2+FcKTWWpvLRU6oR ZWZhRGkTOPlDdZzvhiNLRI+KjLrTcozKn00okmzx5B0c5RmH1YODuqSEP6qmuu6/koZS VYmA== X-Gm-Message-State: APjAAAUALm0TSSRIss0TbWkk2KoVulVDKTIh8hPlpqV/agmqByVx6BeI wQKtL8Y9MBFjPRnODWyGSW8= X-Google-Smtp-Source: APXvYqzk0aEC6VL6rDYphzlL6jigt8LVjdPKbSOiq/wLiVO+4jwPuoFS202PRPb4TxNOwC1rrnZv2Q== X-Received: by 2002:a5d:6b46:: with SMTP id x6mr26109920wrw.313.1556220167719; Thu, 25 Apr 2019 12:22:47 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:1caf:b95c:3a06:5af0]) by smtp.gmail.com with ESMTPSA id 17sm18644406wrk.91.2019.04.25.12.22.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 12:22:47 -0700 (PDT) From: Simon Goldschmidt To: Tom Rini Date: Thu, 25 Apr 2019 21:22:40 +0200 Message-Id: <20190425192240.5925-2-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425192240.5925-1-simon.k.r.goldschmidt@gmail.com> References: <20190425192240.5925-1-simon.k.r.goldschmidt@gmail.com> Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 2/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 --- Changes in v5: - this patch was 1/2 in v4 but is now 2/2 as the 2nd patch of v4 has already been accepted - rearrange the code to make it only 8 bytes plus in code size for arm (which fixes smartweb SPL overflowing) common/dlmalloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 6f12a18d54..38859ecbd4 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -601,8 +601,12 @@ void *sbrk(ptrdiff_t increment) void mem_malloc_init(ulong start, ulong size) { mem_malloc_start = start; - mem_malloc_end = start + size; mem_malloc_brk = start; + mem_malloc_end = start + size; + if (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);