From patchwork Mon May 4 11:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1282483 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=HFEgHawG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49G1Jq3bQdz9sSk for ; Mon, 4 May 2020 21:46:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25CF981FA7; Mon, 4 May 2020 13:45:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.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=broadcom.com header.i=@broadcom.com header.b="HFEgHawG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9321B81FAA; Mon, 4 May 2020 13:45:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 371FD81F7C for ; Mon, 4 May 2020 13:45:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rayagonda.kokatanur@broadcom.com Received: by mail-pj1-x102e.google.com with SMTP id e6so3571799pjt.4 for ; Mon, 04 May 2020 04:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3p9lZTOZc9SWyUvN9gVcR1UXx4AD7lvh6hewf5M9oL4=; b=HFEgHawGDVDssiNDj0iTg4VpW6fHcZryFCr50H3rkRHOhP6m1wUIb5ROMjRhtRBtFw N1/NDJoRR2IxsH9JSiq4FWdyXZNt8IpX3N+EBTocr1sCy0jOpWfdx3wesZaOQTnuiYcP zU/F8PYoDcD2dtqpGOP39VWNjSQ5G97BTQ1jE= 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=3p9lZTOZc9SWyUvN9gVcR1UXx4AD7lvh6hewf5M9oL4=; b=fwzFlflkvPGmVOrRLbiomlbk3X5uieE5golBTOcgOSm9Z6Xt76VFizrrZdhdgy9WfG 9Dj18SorNvWlWxh7dLD5r5QRRwq8eyRpw50cTJvUKdXJL4mCt+ty7eDGZ1Xpt+zDFmM+ aFCtM0cTfbAQobjTdgtN/Wv5qcvFiuB1YHexkUi7whZqJ0nfmciECBL4Z8uOjUEhnqZk 5ljME2TYQgUllvZY/N5YTxHdMNFkRZD6S4wh0LiPBrUHte1v0VyDHGzOdivQB7rcJuCm AkTeN4N5+/kCxSGqUODW3NbKOx7qexwGd7oiPYb6HbO0md+aQ4Q6eOf5eWcX/VeNaaIo oVxA== X-Gm-Message-State: AGi0PuYMbYTt2cHOku1UOxim5/p1rXo0pUGwlexLuCK6ACH5wULwV9Ix Nw/ROdUEw4BIOZ9/kpG/aULyXhNLCt6hv5jDt7fNrsiMgJOwVDQ07IYaaLHYYQJtjndFBWOUNCZ hLQJednfL3VnzI8FB3SS9qLX9n0NZHMyyOS+a6nYfJHS4HgwrPj4r4Nkwky/QTA13wrJkxbg7YG Ryi+J5zw== X-Google-Smtp-Source: APiQypLNr+7WJPEFY0h8jtL+I7KbSSjs7IADjIyYoDMoHsiJBLVhQ1fYadZGxxui/Du9lsqiBZGEoA== X-Received: by 2002:a17:90a:224b:: with SMTP id c69mr17220138pje.8.1588592716191; Mon, 04 May 2020 04:45:16 -0700 (PDT) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id t20sm6712962pjo.13.2020.05.04.04.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 04:45:15 -0700 (PDT) From: Rayagonda Kokatanur To: u-boot@lists.denx.de, Simon Glass , Marek Vasut , Bharat Kumar Reddy Gooty Cc: Abhishek Shah , Rajesh Ravi , Vladimir Olovyannikov , Rayagonda Kokatanur Subject: [PATCH v2 06/16] board: ns3: add api to save boot parameters passed from BL31 Date: Mon, 4 May 2020 17:14:22 +0530 Message-Id: <20200504114432.10886-7-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200504114432.10886-1-rayagonda.kokatanur@broadcom.com> References: <20200504114432.10886-1-rayagonda.kokatanur@broadcom.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean From: Abhishek Shah Add API to save boot parameters passed from BL31 Use assembly implementation of save_boot_params instead of c function. Because generally ATF does not set up SP_EL2 on exiting. Thus, usage of a C function immediately after exiting with no stack setup done by ATF explicitly, may cause SP_EL2 to be not sane, which in turn causes a crash if this boot was not lucky to get an SP_EL2 in valid range. Replace C implementation with assembly one which does not use stack this early, and let u-boot to set up its stack later. Signed-off-by: Abhishek Shah Signed-off-by: Rajesh Ravi Signed-off-by: Vladimir Olovyannikov Signed-off-by: Rayagonda Kokatanur --- arch/arm/cpu/armv8/bcmns3/lowlevel.S | 9 +++++++ arch/arm/include/asm/arch-bcmns3/bl33_info.h | 26 ++++++++++++++++++++ board/broadcom/bcmns3/ns3.c | 10 ++++++++ 3 files changed, 45 insertions(+) create mode 100644 arch/arm/include/asm/arch-bcmns3/bl33_info.h diff --git a/arch/arm/cpu/armv8/bcmns3/lowlevel.S b/arch/arm/cpu/armv8/bcmns3/lowlevel.S index 202286248e..9d8eb7f117 100644 --- a/arch/arm/cpu/armv8/bcmns3/lowlevel.S +++ b/arch/arm/cpu/armv8/bcmns3/lowlevel.S @@ -88,3 +88,12 @@ ENTRY(__asm_flush_l3_dcache) mov lr, x29 ret ENDPROC(__asm_flush_l3_dcache) + +ENTRY(save_boot_params) +/* + * void set_boot_params(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3) + */ + adr x4, bl33_info + str x0, [x4] + b save_boot_params_ret +ENDPROC(save_boot_params) diff --git a/arch/arm/include/asm/arch-bcmns3/bl33_info.h b/arch/arm/include/asm/arch-bcmns3/bl33_info.h new file mode 100644 index 0000000000..bbc95b0186 --- /dev/null +++ b/arch/arm/include/asm/arch-bcmns3/bl33_info.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Broadcom. + * + */ + +#ifndef BL33_INFO_H +#define BL33_INFO_H +#include + +/* Increase version number each time this file is modified */ +#define BL33_INFO_VERSION 1 + +struct chip_info { + unsigned int chip_id; + unsigned int rev_id; +}; + +struct bl33_info { + unsigned int version; + struct chip_info chip; +}; + +extern struct bl33_info *bl33_info; + +#endif diff --git a/board/broadcom/bcmns3/ns3.c b/board/broadcom/bcmns3/ns3.c index 0b9af6ad9b..f28e34ccc3 100644 --- a/board/broadcom/bcmns3/ns3.c +++ b/board/broadcom/bcmns3/ns3.c @@ -4,6 +4,7 @@ * */ +#include #include #include #include @@ -34,8 +35,17 @@ struct mm_region *mem_map = ns3_mem_map; DECLARE_GLOBAL_DATA_PTR; +/* + * Force the bl33_info to the data-section, as .bss will not be valid + * when save_boot_params is invoked. + */ +struct bl33_info *bl33_info __section(".data"); + int board_init(void) { + if (bl33_info->version != BL33_INFO_VERSION) + printf("*** warning: ATF BL31 and u-boot not in sync! ***\n"); + return 0; }