From patchwork Thu Apr 12 05:02:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 897468 X-Patchwork-Delegate: bmeng.cn@gmail.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="jYL9TxM0"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40M7zB0F0Vz9s1B for ; Thu, 12 Apr 2018 15:01:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A18E6C21CB6; Thu, 12 Apr 2018 04:58:41 +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_DNSWL_NONE, 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 0F1A8C21DDC; Thu, 12 Apr 2018 04:58:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20AFEC21DA2; Thu, 12 Apr 2018 04:57:44 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by lists.denx.de (Postfix) with ESMTPS id B8A0BC21D74 for ; Thu, 12 Apr 2018 04:57:40 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id y66so2610282pfi.7 for ; Wed, 11 Apr 2018 21:57:40 -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=92qUC908lY1YFq1S4pievpk+q6/JKxRa+Xzn7opfH3I=; b=jYL9TxM0VULdEKK+OwcB8umg54scecQRq7nSp5co0qnEuClhrsD0G1PxgrbrfBlwBx dJcM9btiZ4B+p5i30tIdIdGNut+EZ9ZZEmHzh5w88yJkCI4q3yQDiDYoHrNlpTMHjMbS a+lLBZHPX0w03e13H3Xs3SuLeAhYpAE1kptqyp10BsLEsW2lgEtc4vLxT8j/SshZxjpe DvL/7zGkE9GC5jSarXdmGwjYM9feuZihYsJKLXFb0LsPH7KBCgORzOxmGfZQC/n94HCA 8jaOFCtyKsZslIh+PQIsCfhnB9bnuHNG2HsPaDwIfurkJSLDb8e7lWpNkXeAyvGUuYcj myuA== 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=92qUC908lY1YFq1S4pievpk+q6/JKxRa+Xzn7opfH3I=; b=YmbY29dA0QzYDHMtwbt7xGfW2zQS9Lhh7WsvtstDQhrDZjTkE1PEQO3uGcyn8Th+t4 jml+6uLuKPywAZswMPrWtT31n1wOFwPfPE1tewlP1RbMvr89SfZcuFg7aqfCpDnzCgG8 KgMo2lhFsOkBJQGK86eVSlv1UHftdqMRDc7zfNfaQktHom0x+UcRgbq0qgcfKM+NEwj7 XEOQUqFZQWM/mieRCOuEnwjX10YGKp22RBNMTBDgYq9+B5Dm7z5q3wf+tF3eOJAAFO/l mwzynhDZVy98z13wmBZxNE5Srn+FXFOaA+ZeYTm8euiXkycDKUt+gTyigubtgUKUyWOs x1SQ== X-Gm-Message-State: ALQs6tBiH6aSbdAKIYI1b10BMlYN5/Eetc2oSoM62XI0x1nqYqDP/eIj K4Wxd47rF8SzWQ/TM+ybIE4= X-Google-Smtp-Source: AIpwx484Bnv/nH9aGUaW3DHFouvcz835kXtVqX2RxJLwanqt+NimoWR9Lcn0mCGPddNPFz3UZ4J28A== X-Received: by 10.99.42.148 with SMTP id q142mr5504882pgq.425.1523509059451; Wed, 11 Apr 2018 21:57:39 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com. [147.11.156.139]) by smtp.gmail.com with ESMTPSA id s17sm6573715pfk.105.2018.04.11.21.57.38 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Apr 2018 21:57:38 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Wed, 11 Apr 2018 22:02:08 -0700 Message-Id: <1523509343-18123-4-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1523509343-18123-1-git-send-email-bmeng.cn@gmail.com> References: <1523509343-18123-1-git-send-email-bmeng.cn@gmail.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 03/18] bootvx: x86: Explicitly clear the bootloader image size 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" VxWorks bootloader stores its size at a pre-defined offset @ 0x5004. Later when VxWorks kernel boots up and system memory information is retrieved from the E820 table, the bootloader size will be subtracted from the total system memory size to calculate the size of available memory for the OS. Explicitly clear the bootloader image size otherwise if memory at this offset happens to contain some garbage data, the final available memory size for the kernel is insane. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- Changes in v2: None cmd/elf.c | 7 +++++++ include/vxworks.h | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/cmd/elf.c b/cmd/elf.c index c83d4cd..4638d79 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -347,6 +347,13 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) info->entries = install_e820_map(E820MAX, data); info->addr = (info->entries - 1) * sizeof(struct e820entry) + E820_DATA_OFFSET; + + /* + * Explicitly clear the bootloader image size otherwise if memory + * at this offset happens to contain some garbage data, the final + * available memory size for the kernel is insane. + */ + *(u32 *)(base + BOOT_IMAGE_SIZE_OFFSET) = 0; #endif /* diff --git a/include/vxworks.h b/include/vxworks.h index f600dfa..d912076 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -43,6 +43,15 @@ struct e820info { u32 error; /* must be zero */ }; +/* + * VxWorks bootloader stores its size at a pre-defined offset @ 0x5004. + * Later when VxWorks kernel boots up and system memory information is + * retrieved from the E820 table, the bootloader size will be subtracted + * from the total system memory size to calculate the size of available + * memory for the OS. + */ +#define BOOT_IMAGE_SIZE_OFFSET 0x5004 + int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); void boot_prep_vxworks(bootm_headers_t *images); void boot_jump_vxworks(bootm_headers_t *images);