From patchwork Sat Nov 24 04:29:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002577 X-Patchwork-Delegate: sjg@chromium.org 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=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Vj3j1jto"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320gZ0kPhz9s8F for ; Sat, 24 Nov 2018 15:34:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C67FDC2246E; Sat, 24 Nov 2018 04:32:54 +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=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 26073C2247B; Sat, 24 Nov 2018 04:30:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 71CC6C22486; Sat, 24 Nov 2018 04:30:11 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by lists.denx.de (Postfix) with ESMTPS id 835B9C22471 for ; Sat, 24 Nov 2018 04:30:10 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id y14-v6so12631061ioa.22 for ; Fri, 23 Nov 2018 20:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ERIedwLAs2XOVOuAEzu1IXVQQTVkK0mveVf2pTPqO4o=; b=Vj3j1jtopUWrLLAZtHA9W9LfxjqSMp23DlcYfO53YccwRz6pX4ZoBR4Jg95U6sNhf3 hp0Bg2BhaS2dyo269igYmC5y4D004fYnHayOxXP3vUTOx66F9gjA3wmQzym/fee5E2Vf Te2QcrjHtKAyVoK9VgakP91R8H1TzQz4E9nRw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ERIedwLAs2XOVOuAEzu1IXVQQTVkK0mveVf2pTPqO4o=; b=Cy23yKrO3s6XMQbYleroyvxz+TOxrIP4e+a9IxHL6Gx1Sw5FX/BEZEOiFNr3KlWGon 90Uxd0rE2QVQSewqo3hXm0J0nf2SWn8aMaotzKlF2eBj8+G5HhowJCX34fOCIr5rDaMr CEJ5Wv6H+zWgjS8el40uw6/xEoNdHOcpxN3cA7eFMS0YRCX+xXayz0y0P2QgkcSn+Vsg c/86qNHzS07zs0fnltytwbNc7uMe8GX4Qt/dJS4oA4YoRXgI7i4zYXC65RwE3lt1/IZh peE/vMpSnRK0mTJVLDXKBQMyTaD3Bl5NHhv1lw8gofTUWEIgGmzLOipBOuf5BxdNVe+a pSbg== X-Gm-Message-State: AA+aEWZD4350MbBe+wNlUIYLNUkwwvCW99Uo9H08fFIh27CfCczebqEv kubB1SvMBqFDYnVCbK0JQyGSeTcQCEim7zjn X-Google-Smtp-Source: AJdET5flEuEeygU9/QN/bsTzk7qvJttnzrdMR/R67cIflQDOtu5M+LvxlKsV2r3Uv/l/6UIkgYiiN7bwnuQe4mf/ X-Received: by 2002:a24:4652:: with SMTP id j79mr12145029itb.36.1543033809553; Fri, 23 Nov 2018 20:30:09 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:29 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-7-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH 06/21] sandbox: Zero the ram buffer on startup 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present the RAM buffer is not inited unless it is read from a file, likely produced by an earlier phase of U-Boot. This causes valgrind warnings whenever the RAM buffer is used. Correct this by initing it if needed. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 7 +++++++ arch/sandbox/include/asm/state.h | 1 + 2 files changed, 8 insertions(+) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index b1566a81435..2f5e6e95182 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -180,6 +180,7 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state, printf("Failed to read RAM buffer '%s': %d\n", arg, err); return err; } + state->ram_buf_read = true; return 0; } @@ -301,6 +302,12 @@ int board_run_command(const char *cmdline) static void setup_ram_buf(struct sandbox_state *state) { + /* Zero the RAM buffer if we didn't read it, to keep valgrind happy */ + if (!state->ram_buf_read) { + memset(state->ram_buf, '\0', state->ram_size); + printf("clear %p %x\n", state->ram_buf, state->ram_size); + } + gd->arch.ram_buf = state->ram_buf; gd->ram_size = state->ram_size; } diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 8fabe70a86d..5a144851025 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -90,6 +90,7 @@ struct sandbox_state { bool show_test_output; /* Don't suppress stdout in tests */ int default_log_level; /* Default log level for sandbox */ bool show_of_platdata; /* Show of-platdata in SPL */ + bool ram_buf_read; /* true if we read the RAM buffer */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]