From patchwork Fri Jul 10 08:52:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1326568 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=VTbgIqUR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4B36K65rMlz9sRR for ; Fri, 10 Jul 2020 18:53:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D293482182; Fri, 10 Jul 2020 10:53:16 +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="VTbgIqUR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FDF182186; Fri, 10 Jul 2020 10:53:05 +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-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 BB9C98217D for ; Fri, 10 Jul 2020 10:52:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=rayagonda.kokatanur@broadcom.com Received: by mail-pf1-x42c.google.com with SMTP id s26so2260553pfm.4 for ; Fri, 10 Jul 2020 01:52:58 -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=Ej+Kd8merAay+oH/GWrIfCK1CSavPzmFjPpv8HGyZSE=; b=VTbgIqUR6YUsvWGwznYcWo2KcLXghMyPwQ1niF9emUn35T9b4dMT9lUy3ThuyOgbG7 Y4rcF4pH4AdiH0ud0oZzcWNI+JMw5dksGUPBtFR3Yec9E7NzwrLHCFy2Di/ewHGzWmXM YBsz7EFn5d5ZTf1VkS0cCjuRnyNHds6Y8WVLg= 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=Ej+Kd8merAay+oH/GWrIfCK1CSavPzmFjPpv8HGyZSE=; b=LhiuD9YTVewQEJg1a6C91/hVerbTrfwYf/EQu+moE+CD174UkXemnZQDAUMERNGG3t gyFDCgmgrutylDmmA+bxjRC2e8bt7G87Hq9yfus7aaura4EjcXWQt2NCaB8/JdqNWkkr rB9jb9UHo+9uMYaIuLRpeWRgzyQ1euOo4xRZso48lno6WGeMVTR9NoygvsxhYQ2czqky MvXxohhMmPRQ/q2O2q0ZKAMEpAG8BJrF1rfTkarbW8UgECIAii2j2Dmcan6gVmr7AB3b 2uxAVK29rfResQnz13Nb3+efECJkUetICVK3ndcv1vt83hGBAqHovpZsTOj4I7vMIaps 9MDg== X-Gm-Message-State: AOAM531UIsrl1IG9vaIeqfdtHxaZQdAiJXn5DxYupie2DYgm7oFTglAG PxFmd3uHUDoUIzFQn8lS9G2rJfTZaMmPfVIE0LAnzY/rRuBdWaBkjFY3Iv1TZncyPH3la2qVE54 QWFsEgu1g6ojbH/nhOX1M3PzJr7f5RglJGYe4JMleVbi+huoBYMsU3RIfqrqfzzhL1C1jtLfmvk Vq9ZI= X-Google-Smtp-Source: ABdhPJzxuEPpOlZLFxX37QR51GdBR39qwZdtndCivvwtF7wCc3TuQL2JzHCjCdIFa/hFDDVasWVJew== X-Received: by 2002:a63:6442:: with SMTP id y63mr55430226pgb.18.1594371176501; Fri, 10 Jul 2020 01:52:56 -0700 (PDT) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k26sm5145914pgi.16.2020.07.10.01.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 01:52:55 -0700 (PDT) From: Rayagonda Kokatanur To: u-boot@lists.denx.de, Simon Glass , Marek Vasut , Bharat Gooty , Peter Tyser , Thomas Fitzsimmons Cc: Abhishek Shah , Rajesh Ravi , Vladimir Olovyannikov , Rayagonda Kokatanur Subject: [PATCH v4 05/15] board: ns3: add api to save boot parameters passed from BL31 Date: Fri, 10 Jul 2020 14:22:10 +0530 Message-Id: <20200710085220.32730-6-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200710085220.32730-1-rayagonda.kokatanur@broadcom.com> References: <20200710085220.32730-1-rayagonda.kokatanur@broadcom.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 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 Reviewed-by: Simon Glass --- 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 6709c9a188..bf1a17ab03 100644 --- a/arch/arm/cpu/armv8/bcmns3/lowlevel.S +++ b/arch/arm/cpu/armv8/bcmns3/lowlevel.S @@ -87,3 +87,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 e38156723c..5e644bd466 100644 --- a/board/broadcom/bcmns3/ns3.c +++ b/board/broadcom/bcmns3/ns3.c @@ -8,6 +8,7 @@ #include #include #include +#include static struct mm_region ns3_mem_map[] = { { @@ -33,8 +34,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; }