From patchwork Fri Dec 22 21:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879801 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M/jeVl9e; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgVD5bGXz20RD for ; Sat, 23 Dec 2023 08:31:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77F9A87745; Fri, 22 Dec 2023 22:31:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="M/jeVl9e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBF0F8777D; Fri, 22 Dec 2023 22:31:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) (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 32B5C8753D for ; Fri, 22 Dec 2023 22:31:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-67a338dfca7so13675756d6.2 for ; Fri, 22 Dec 2023 13:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280700; x=1703885500; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QiuPnCJkIWirwDrimojMVsTF32M3M2sOimafB8HdgvU=; b=M/jeVl9e3Jnj9rAwC0yDic4kgc7R/dyecQI96jVS4YswWVeVqBQ2wjT9uCOsVTvg/L KULKOpjl9CmNJoPjzbHHkbDHuccZ18MVWdppJdinCOpE3SUNYgCIvP3ryAUbytr7Vi8w dxHS4hQjUU9QbsnqvjdeUC57ZZu7Q6HuYeDlZvEZvVoSE+WkS/G2rDdxwbzB5T6rDHU1 EK2E+JuLG1xX1QKCX10IMmq7XHRyUW0GINccAbbXgPIVlsT7EB0M1DibcTxWydZdJtvz Y3cvtbtJ8wh/3Ym2FiNZ0CeAUiaLBSAPIP9EYo4Go+fPbStOLo0wAkYKYwYVI5/7H4po 5KtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280700; x=1703885500; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QiuPnCJkIWirwDrimojMVsTF32M3M2sOimafB8HdgvU=; b=GPl5gJlji+DkOmYG8NdY6BAFOmFHjqgTE8fFna1JkA05V6yhi5IGTst+1JLQFBqls7 VrjkZqwHyfRDXmLsR1EWezlAb3fvaAbnTsVSbpIQpaOa4MX/ON0h9EuvVQpQtR9ER9Xh tGi+zgze5+K5obFeGBBofVzrcoxXh31sfCQF/1NBtNdtwVOXu1YBezVAkeeOY+IoL96p yaN0qqltgRJqIMgR4Ykxt1bidGnOsR0hj00rk3qpA3cSBxqmbAFH/bRXR7lwiJPm8WiH ufUJpraIVbp31J/cgk8DH2a1APYbVMleKTWrTfojH4gkLdHKzsWL/UUN1/8exHrPHUs6 HyhA== X-Gm-Message-State: AOJu0Yy6U2Jcirv/e8nucN+7IExdzpf4cHh2ZdLNUDvLqh45bJuohZ63 kmYMSSOQiX7NupKqQHc4S/DCRR6sGlTj0qreLDmWmP33cGw= X-Google-Smtp-Source: AGHT+IFKZa0laLB4Q+EfdssPJy6Hnc+Bk2iJmn4bK8iU7616WABtcz0yr2zGWLkWZWGiug8Pf1JhWw== X-Received: by 2002:a05:6214:ac9:b0:67f:2632:9992 with SMTP id g9-20020a0562140ac900b0067f26329992mr3194499qvi.38.1703280699815; Fri, 22 Dec 2023 13:31:39 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:31:39 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Shiji Yang , Marek Vasut , Sean Anderson , Heinrich Schuchardt , Baruch Siach , Michal Simek , Stefan Roese , Qu Wenruo Subject: [PATCH v3 1/9] bloblist: add API to check the register conventions Date: Fri, 22 Dec 2023 13:31:01 -0800 Message-Id: <20231222213110.660402-2-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Add bloblist_check_reg_conv() to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms. Signed-off-by: Raymond Mao --- Changes in v2 - Refactor of bloblist_check_reg_conv(). Changes in v3 - bloblist_check_reg_conv() returns -ENOENT if OF_BOARD is disabled. common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/common/bloblist.c b/common/bloblist.c index 625e480f6b..ba17dd851a 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -542,3 +542,16 @@ int bloblist_maybe_init(void) return 0; } + +int bloblist_check_reg_conv(ulong rfdt, ulong rzero) +{ + if (!IS_ENABLED(CONFIG_OF_BOARD)) + return -ENOENT; + + if (rzero || rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) { + gd->bloblist = NULL; /* Reset the gd bloblist pointer */ + return -EIO; + } + + return 0; +} diff --git a/include/bloblist.h b/include/bloblist.h index 84fc943819..bd32e38a06 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -461,4 +461,16 @@ static inline int bloblist_maybe_init(void) } #endif /* BLOBLIST */ +/** + * bloblist_check_reg_conv() - Check whether the bloblist is compliant to + * the register conventions according to the + * Firmware Handoff spec. + * + * @rfdt: Register that holds the FDT base address. + * @rzero: Register that must be zero. + * Return: 0 if OK, -EIO if the bloblist is not compliant to the register + * conventions, -ENOENT if OF_BOARD is disabled. + */ +int bloblist_check_reg_conv(ulong rfdt, ulong rzero); + #endif /* __BLOBLIST_H */ From patchwork Fri Dec 22 21:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879802 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=mIwZd8K5; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgVP0ZBMz20RD for ; Sat, 23 Dec 2023 08:31:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D89B9877F1; Fri, 22 Dec 2023 22:31:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="mIwZd8K5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E1DB877CA; Fri, 22 Dec 2023 22:31:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) (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 84BE9877BC for ; Fri, 22 Dec 2023 22:31:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-67a338dfca7so13676316d6.2 for ; Fri, 22 Dec 2023 13:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280706; x=1703885506; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z2rx+gtoX65D+sG5rSlOLf55Ss6HbOoowEp2fYIt45c=; b=mIwZd8K55LExVBXJzxDPzlkHkSyaWOr9SmMI1CUmfXx1LTLnsnX59YYw/z7+BQtRQ4 GuYLIx0U3LHRUf6B29WPtt5nGZf72H0KnePKqW8qNp/E6nRB5Jio7xCe5moyz+/q3fKA 5H0LVo2DsUL9OWnxksZm24WggfLYJgF/W1mwyY3EmYMm5rDa5v244ZALs08XFqV4Y/im pzb3XWCSFapvzH7gKWcq75HZddB1N+i3MO30m7v+epgcyHdAJByWVr+npdUFqbCR7klh yncLDSds9NKPUz/F9Le1eq+dGTPWmrBuAad08o3LIxIDdMyaru9Rf7JpwivE1CyMvTI3 LVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280706; x=1703885506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z2rx+gtoX65D+sG5rSlOLf55Ss6HbOoowEp2fYIt45c=; b=jEPKuZ+n1Z8OPkBpXDnQ6ELlP4nzUHWU24zx+gszVoNVUj9naQOmiBWhPB7NddMcDX AbAbxhKptnpVJ5fJJq6UWRWxh0LGtywHkxPZ1JwqKVHkW0fdT7wzHgnJzhH9PblXB8aW 4qCygE7QD3GeczY08vvYtTkspi65/QSidc0Q8IuCA1TGI7HGBwAo6SBjr1dRYXS3J1fU 22wqZ8pbauO8QH7kyhbWMDHE2RGhC/brh9fKuRTLNke8SNGs7RXwV4xn4UBR3Ko+KE+f dyj+NC5GVKb9BFB+bky2en5nqv1Dbta1gbsoW6O9NmHnnm+jvE72/FgPH/NmFIIOSWrg N9/A== X-Gm-Message-State: AOJu0Yx3qwG0dtv+Nj0/pK+sZtKla8RgRxXY3SlIWPRlm3JJzbsO8Wim 0dypufc51AketchDZzUViAvvsuUm4l4QffKaPvmEi9k/hD0= X-Google-Smtp-Source: AGHT+IE/f2TAU0LuqMMW14psdUqdsqsahdMBT6KBa73SAKyO2z9avP0DbiN+rBpxeSU53+A/kJYs7w== X-Received: by 2002:a05:6214:1d24:b0:67f:3c59:a1af with SMTP id f4-20020a0562141d2400b0067f3c59a1afmr2653252qvd.7.1703280705976; Fri, 22 Dec 2023 13:31:45 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:31:45 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Shiji Yang , Kunihiko Hayashi , Marek Vasut , Heinrich Schuchardt , Baruch Siach , Michal Simek , Qu Wenruo , Neil Armstrong , Sean Anderson Subject: [PATCH v3 2/9] bloblist: check bloblist with specified buffer size Date: Fri, 22 Dec 2023 13:31:02 -0800 Message-Id: <20231222213110.660402-3-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Instead of expecting the bloblist total size to be the same as the pre-allocated buffer size, practically we are more interested in whether the pre-allocated buffer size is bigger than the bloblist total size. Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas --- Changes in v2 - New patch file created for v2. common/bloblist.c | 2 +- test/bloblist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index ba17dd851a..db3fbb20cf 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size) return log_msg_ret("Bad magic", -ENOENT); if (hdr->version != BLOBLIST_VERSION) return log_msg_ret("Bad version", -EPROTONOSUPPORT); - if (!hdr->total_size || (size && hdr->total_size != size)) + if (!hdr->total_size || (size && hdr->total_size > size)) return log_msg_ret("Bad total size", -EFBIG); if (hdr->used_size > hdr->total_size) return log_msg_ret("Bad used size", -ENOENT); diff --git a/test/bloblist.c b/test/bloblist.c index 17d9dd03d0..7dab9addf8 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -207,7 +207,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts) hdr->flags++; hdr->total_size--; - ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); hdr->total_size++; hdr->spare++; From patchwork Fri Dec 22 21:31:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879803 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iW8XjkGq; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgVZ3rRPz20RD for ; Sat, 23 Dec 2023 08:32:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4EE65877CD; Fri, 22 Dec 2023 22:31:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iW8XjkGq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBF73877CA; Fri, 22 Dec 2023 22:31:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) (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 D673E877CD for ; Fri, 22 Dec 2023 22:31:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-78120bb5592so105512585a.3 for ; Fri, 22 Dec 2023 13:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280712; x=1703885512; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=90S5eGrJX62iUtWwdZTLVpCYSWiJCMPx+KDc/k+BtAo=; b=iW8XjkGqa81daoxipDpZNW2wVuwxxvgGKXjZtGCOnuJjV3YOUwjgGp0Ivn2Ju1CSda TQby7lXby3DB5OBweZ5lDLgLr/MVwGnjFktU1gET6Dvy9v6X/wS8vbBne40i8VQj7pO7 jxvixzqJsHSb0Vl1kuyb15O8vvl5qLeoPEpPMwtMn/bmeeLyBu6tcmx9x/Q/s66SLN0z kUy6D7vTMB/Yq0Xu5G2Rfso40mSz1wET+ZnmgeJpEp5JIl7r7YnXm+oELPaej4UAbE0N E5h6ZOn1FLIQJINvVwDFs3/Aj3hpToKZdoCe13pWNF8JIULyYM9kL+pl8GoWdEgl1K+4 TE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280712; x=1703885512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=90S5eGrJX62iUtWwdZTLVpCYSWiJCMPx+KDc/k+BtAo=; b=AH8m/b0nlOCWnIz+hG/JIE5fyrv3e+/nzDubM+TDavrs8OnQ1DUJljQhXoRJbYQYYw oRu6boVmnOM4pKhzpImCwS00gsfFh7jPflCtDdF7vygrZUpumahPXrVUNP4/YiOsvlzt jMJwpEuiJ5ldSqGg1pUVSpBiV3gtZoYGr2aLSKA+TBxOpAdzg88ctpccMxzAypnNcdwg /RZ4pGXGiZJ5MpfuIXNtd8pUU5sSzpQ9BOjVqthrEd06nNKkUQnHDDxHefnzbd/9ItR3 EBDXOce5bRlMfnEB9FZMB3BPKDOoe2h/wV/EAawMQSH+l2XcQSTtP4VAXIWm4bIbod3t X+kw== X-Gm-Message-State: AOJu0YwcJiWWUPh6cRtr54Rz+C/OMWA3rX4ycvz1gXY03Wg0jyP1lvZw Ydf/CoOenaoI7a0dRsGUU6fYDLDf0WaEw8M5gPJVQ8198yE= X-Google-Smtp-Source: AGHT+IEQ6I7hP8Y9XNQRBsnG1S2R3od0Zah3dDpOl4dErSxoNAQEBiMnerWRVUMpgcX4+tb5IQS1mw== X-Received: by 2002:a05:6214:500e:b0:67a:a721:ec03 with SMTP id jo14-20020a056214500e00b0067aa721ec03mr2070003qvb.71.1703280712200; Fri, 22 Dec 2023 13:31:52 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:31:51 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Nikhil M Jain , Bin Meng , Devarsh Thakkar , Kunihiko Hayashi , Heinrich Schuchardt , Marek Vasut , Shiji Yang , Baruch Siach , Michal Simek , Sean Anderson , Stefan Roese Subject: [PATCH v3 3/9] bloblist: refactor of bloblist_reloc() Date: Fri, 22 Dec 2023 13:31:03 -0800 Message-Id: <20231222213110.660402-4-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean The current bloblist pointer and size can be retrieved from global data, so we don't need to pass them from the function arguments. This change also help to remove all external access of gd->bloblist outside of bloblist module. Signed-off-by: Raymond Mao Reviewed-by: Simon Glass --- Changes in v2 - New patch file created for v2. Changes in v3 - Check the space size before copying the bloblist. - Add return code of bloblist_reloc(). common/bloblist.c | 10 ++++++++-- common/board_f.c | 8 ++------ include/bloblist.h | 8 ++++---- test/bloblist.c | 6 ++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index db3fbb20cf..5ad1db137a 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -472,13 +472,19 @@ void bloblist_show_list(void) } } -void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) +int bloblist_reloc(void *to, uint to_size) { struct bloblist_hdr *hdr; - memcpy(to, from, from_size); + if (to_size < gd->bloblist->total_size) + return -ENOSPC; + + memcpy(to, gd->bloblist, gd->bloblist->total_size); hdr = to; hdr->total_size = to_size; + gd->bloblist = to; + + return 0; } int bloblist_init(void) diff --git a/common/board_f.c b/common/board_f.c index d4d7d01f8f..00b0430889 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -676,13 +676,9 @@ static int reloc_bloblist(void) return 0; } if (gd->new_bloblist) { - int size = CONFIG_BLOBLIST_SIZE; - debug("Copying bloblist from %p to %p, size %x\n", - gd->bloblist, gd->new_bloblist, size); - bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC, - gd->bloblist, size); - gd->bloblist = gd->new_bloblist; + gd->bloblist, gd->new_bloblist, gd->bloblist->total_size); + bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC); } #endif diff --git a/include/bloblist.h b/include/bloblist.h index bd32e38a06..c1dab11f78 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -418,11 +418,11 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag); * bloblist_reloc() - Relocate the bloblist and optionally resize it * * @to: Pointer to new bloblist location (must not overlap old location) - * @to_size: New size for bloblist (must be larger than from_size) - * @from: Pointer to bloblist to relocate - * @from_size: Size of bloblist to relocate + * @to_size: New size for bloblist + * Return: 0 if OK, -ENOSPC if the new size is small than the bloblist total + * size. */ -void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); +int bloblist_reloc(void *to, uint to_size); /** * bloblist_init() - Init the bloblist system with a single bloblist diff --git a/test/bloblist.c b/test/bloblist.c index 7dab9addf8..1c60bbac36 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -376,13 +376,12 @@ static int bloblist_test_reloc(struct unit_test_state *uts) { const uint large_size = TEST_BLOBLIST_SIZE; const uint small_size = 0x20; - void *old_ptr, *new_ptr; + void *new_ptr; void *blob1, *blob2; ulong new_addr; ulong new_size; ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0)); - old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); /* Add one blob and then one that won't fit */ blob1 = bloblist_add(TEST_TAG, small_size, 0); @@ -394,8 +393,7 @@ static int bloblist_test_reloc(struct unit_test_state *uts) new_addr = TEST_ADDR + TEST_BLOBLIST_SIZE; new_size = TEST_BLOBLIST_SIZE + 0x100; new_ptr = map_sysmem(new_addr, TEST_BLOBLIST_SIZE); - bloblist_reloc(new_ptr, new_size, old_ptr, TEST_BLOBLIST_SIZE); - gd->bloblist = new_ptr; + ut_assertok(bloblist_reloc(new_ptr, new_size)); /* Check the old blob is there and that we can now add the bigger one */ ut_assertnonnull(bloblist_find(TEST_TAG, small_size)); From patchwork Fri Dec 22 21:31:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879804 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=h/1ng1g6; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgVm2jJYz20RD for ; Sat, 23 Dec 2023 08:32:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2A2987579; Fri, 22 Dec 2023 22:32:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="h/1ng1g6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A183286FB5; Fri, 22 Dec 2023 22:32:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) (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 90115877BC for ; Fri, 22 Dec 2023 22:31:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-7810b3c4fa9so241304785a.1 for ; Fri, 22 Dec 2023 13:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280718; x=1703885518; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0B0Hur6ceb0a0gHcAEPiu+wT17rZUpmB+zNLTferZMc=; b=h/1ng1g67JEgl1upIY/Dmn1GXaiPMXrvJx11kp5eDqjeD/MuMQQBmQiLnvEWqc8JmF +/kB9Af2cjU6dTALW6dNrGbTBThVqTS3Aa+kTNvfgQzS+INVFVUmWGbRpX7dnrl6mm2b 5hpqeYhM9/1aHqx/GUDrPDWmZH+D65U807UNryrVP5kAgSWlKbxRC5kJSe2DBhIwSoR3 RxGSkCXvkL+f/DgJkpxaA9yzaEcX+jCCjKs6UcGv2tOtFdseYYYyEtiu/p2f0gnGfQYJ KpPhbFpCrlTDs6x820+1ScCQO0aRqavtlODMILnhUraT970tnqbxC0SPSe5lFRPWIpZO NsVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280718; x=1703885518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0B0Hur6ceb0a0gHcAEPiu+wT17rZUpmB+zNLTferZMc=; b=MAS17fmBy4hb8N+lzcToJGZq3Jdr1j/nmi6h6Wdj9Ynb3gY6nKByFfD2T9C7/A8Wqz P99bWVpd5iieGJGE6eQ7UcmoDIz1eLtVlXtvT5Knonhz+S6Q/n34WqHRn++unmmhk2E/ ZS1LK/fV5hJZYs25UjTRWgH8y3bzsz1vZuhYLWXNQMteDhhWQpsbo8/+EBoXUG7g8i+4 qiJnh3eZP5KTlLL07dlv5R1DzozqIT+QSe8J2mkktkFjC46GSZ9CadOCywlPI1USHQhg BOeoUFo0KNe7XrbmU1+O6TmcRabHZrAuNbNT0EBxvJzGgGdcR7MBJcSG9D1WLP11GgQL chpw== X-Gm-Message-State: AOJu0YxwYfx4bcYlylLghHE2frhnnD8hRWMAm6NTct4sK8OOb6+gj1hs Tjbifcso62HydumtnfbxaWxtT5pxSYqveSOtImfxHagzTow= X-Google-Smtp-Source: AGHT+IH0WR9xpYJQmO5AOMCdSHSbDLx9QcTWhFSkuBySkeTDJfTbDvPh/XLoZFuCripQe+mWV+nF7Q== X-Received: by 2002:a05:6214:1d2a:b0:67f:7e15:fc9e with SMTP id f10-20020a0562141d2a00b0067f7e15fc9emr2923837qvd.63.1703280718104; Fri, 22 Dec 2023 13:31:58 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:31:57 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Nikhil M Jain , Bin Meng , Kunihiko Hayashi , Shiji Yang , Marek Vasut , Heinrich Schuchardt , Baruch Siach , Michal Simek , Neil Armstrong , Qu Wenruo , Sean Anderson Subject: [PATCH v3 4/9] arm: armv7: save boot arguments Date: Fri, 22 Dec 2023 13:31:04 -0800 Message-Id: <20231222213110.660402-5-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage. Signed-off-by: Raymond Mao --- Changes in v2 - New patch file created for v2. Changes in v3 - Swap value of r0 with r2. arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 69e281b086..2ca63ca32c 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) * *************************************************************************/ WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3} +#endif b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) +.section .data +.global saved_args +saved_args: + .rept 4 + .word 0 + .endr +END(saved_args) + #ifdef CONFIG_ARMV7_LPAE WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret From patchwork Fri Dec 22 21:31:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879805 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=x5l5nfaS; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgVz1GzRz20RD for ; Sat, 23 Dec 2023 08:32:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 352508753D; Fri, 22 Dec 2023 22:32:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="x5l5nfaS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0970486FB5; Fri, 22 Dec 2023 22:32:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) (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 F395787805 for ; Fri, 22 Dec 2023 22:32:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-67f8a5ed1a0so9498846d6.2 for ; Fri, 22 Dec 2023 13:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280722; x=1703885522; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=87sG9HPEQ/b8s+kyD+6SBJ8evOSjubcYEd4dkOBwJ+4=; b=x5l5nfaSFlvszRRl9v/nRh2UjJTJ98+pQcVZduomdkpnFHWqvKu3fwdodObyr5K/8S xVanPiXTw3A5gHI2DIDpmpUdL+BavqHuvlTTKXLwqbu8xhRaDo2pnjQbpUPi9sSFff07 ozrhZ/6rLdXon+6ZT+SCwM9S/gNushf/AlIj/wNyyl78L7R484m5QuTuVZaK99GeKzK6 7hb8Hxxba0lZh9ruXbQa04GFjwaHaZOuezJVK3ukSjWSGRGNGL3z//yQlse/oOOFeT7z J1CKlffPh2btCEchItPWPdKkw/Gx9S2SYEaX3PkA1TeMODdFi58nRo1bmW/+wCqYWoUx +Ibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280722; x=1703885522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=87sG9HPEQ/b8s+kyD+6SBJ8evOSjubcYEd4dkOBwJ+4=; b=XqoDyd79815yu8gD/iaoq2cknWZ5/peNRj03jd7goKXm5ly/p7+yUdT9mxOsCAImuY NpOTI3fqvgGGRarI5JIWrWyiq8JQo3ngxhFQaERzV+XHfnjSpoT2XDcmx3mRHTqdHplD LIhB6JFcFhV1pJLJET6GO1QqbZ0kgYxr8jLoOLAHS+dNcmW2ne5m251HeHslUDbwkQJD qVlc5Dp7W7bDotvZKuOpos3M/E7I4GW+VeN6rs5jx8yo2WRYiJy38kK9j5IcYPnnqEle qqE5Ts4uUN9m4IaKOhWIfPyvKPMOpaUWnaV22gc1pCBt7Jtyl6GcGLegthJqd0S6upqx BDUg== X-Gm-Message-State: AOJu0YzNB9oAzoKmx01FNtQiZ3cnQq/DCkM4C7zm0tXqkdSVk3MfX9jE N7fxhJZDMcMhg7qEHzJNkdOPzoL8obVGKkIJuK36x2WnBDM= X-Google-Smtp-Source: AGHT+IGofkQ97qqbcQauHvGXjbxcNmQiP86Y16iyETCi4FjnKqzGIn5e7hEOrNDLgckwvDi0YHxfNA== X-Received: by 2002:a05:6214:f0d:b0:67f:5184:8e5c with SMTP id gw13-20020a0562140f0d00b0067f51848e5cmr2414015qvb.10.1703280722355; Fri, 22 Dec 2023 13:32:02 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:32:01 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Nikhil M Jain , Bin Meng , Marek Vasut , Shiji Yang , Heinrich Schuchardt , Baruch Siach , Michal Simek , Qu Wenruo , Neil Armstrong , Sean Anderson Subject: [PATCH v3 5/9] arm: armv8: save boot arguments Date: Fri, 22 Dec 2023 13:31:05 -0800 Message-Id: <20231222213110.660402-6-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Save boot arguments x[0-3] into an array for handover of bloblist from previous boot stage. Signed-off-by: Raymond Mao Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- Changes in v2 - New patch file created for v2. arch/arm/cpu/armv8/start.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index 6cc1d26e5e..8e704f590e 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -370,5 +370,19 @@ ENTRY(c_runtime_cpu_setup) ENDPROC(c_runtime_cpu_setup) WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + adr x9, saved_args + stp x0, x1, [x9] + /* Increment the address by 16 bytes for the next pair of values */ + stp x2, x3, [x9, #16] +#endif b save_boot_params_ret /* back to my caller */ ENDPROC(save_boot_params) + +.section .data +.global saved_args +saved_args: + .rept 4 + .xword 0 + .endr +END(saved_args) From patchwork Fri Dec 22 21:31:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879806 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LFXmuzkm; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgW84H2Cz20RD for ; Sat, 23 Dec 2023 08:32:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A22298784E; Fri, 22 Dec 2023 22:32:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LFXmuzkm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74F56874D5; Fri, 22 Dec 2023 22:32:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 58B398784E for ; Fri, 22 Dec 2023 22:32:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3bb8977162aso863532b6e.2 for ; Fri, 22 Dec 2023 13:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280726; x=1703885526; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MhINwHp3iYV305XDyq272N0fwqaB+75Ty9O+gTlw/pI=; b=LFXmuzkmR8ByQW0MAiO6AdUeBZVzrQgn8YK9iQ8puXszVJmlXPG8SRpvrZ8otp1Hxn pFOspiRBY+amKer2V2YpIBkJJwr5k/CuScgzVTnNw4/HueTV8CGWXHmYJuvU8Ib2TW5N DCHLXAGjVl29iMHYeCQm7zdqnHRr48Ns5uEqzxLn7QGUew21sjrHdN/6ljr3aVSuS5l4 mjNBf0inul6EE17WBP2t7Nj8AgikdyVhHcIuYZJVJS51AHrhF2KoAc9GZ0+3m8m6lZSR +UMtHnjmys/Pi0Sbios9M9gMaj6QqAcLes/LMm13jMuYU5i60lXqPFF47y3oxLQuOWUP CgMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280726; x=1703885526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MhINwHp3iYV305XDyq272N0fwqaB+75Ty9O+gTlw/pI=; b=NV10wu5yK5TFZZiYK2vr3USob/7CSKaZz6RoW32ceVNRKcqdMLp+aNEZ/SAN6amFNU iiGBrlwmWpcAAjOfg/8bTeQZMCLwT+MxAv7hAzQlvYAbN7csdWPI+bi2i7PmlXA30yGk F9gLvDHaUJ+hO8mwPQ6qyDxrvzKjHISEzEz1pRVPadSmRk/oOnOlJZWeqNsecppWVKZu h5AiPQX0k96W9xmJImr1NILj8OFlD4sIXSFeH/ZsU27wJ0oDV2pwS8gRK16OQOQJLusS Fv7SApT/90ULsF1U+j2qMFpD1MxuiYlYtQNxAKoANHDVYYe4gJS/doC9raOlb+zUqax2 GoMw== X-Gm-Message-State: AOJu0Yzh2/sqeTBxvNlL44wU3hh2wucg2+y2qY6d1j/p7XKJfjxjM7K6 8Gjg+x1OtiE2+k1ty1yAnL6hIDnFq9ta2/s2tEAIFteHpCE= X-Google-Smtp-Source: AGHT+IEU7KJ39NI92CGekwYYWjzZPdnkSGyo9Wz4aLkbPspsnv7H9jMz7k2oi9jxgPGupqgYpMNaAA== X-Received: by 2002:a05:6808:98:b0:3bb:6dfc:c0b0 with SMTP id s24-20020a056808009800b003bb6dfcc0b0mr1805604oic.37.1703280726655; Fri, 22 Dec 2023 13:32:06 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:32:06 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Shiji Yang , Devarsh Thakkar , Heinrich Schuchardt , Baruch Siach , Michal Simek , Qu Wenruo , Sean Anderson Subject: [PATCH v3 6/9] qemu-arm: Get bloblist from boot arguments Date: Fri, 22 Dec 2023 13:31:06 -0800 Message-Id: <20231222213110.660402-7-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Add platform custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9. Add bloblist related options into qemu default config. Signed-off-by: Raymond Mao --- Changes in v2 - Remove low level code for copying boot arguments. - Refactor board_fdt_blob_setup() and remove direct access of gd->bloblist. Changes in v3 - Optimize board_bloblist_from_boot_arg(). board/emulation/qemu-arm/qemu-arm.c | 30 +++++++++++++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 2 files changed, 33 insertions(+) diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 942f1fff57..e225011bf0 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -102,6 +103,15 @@ static struct mm_region qemu_arm64_mem_map[] = { struct mm_region *mem_map = qemu_arm64_mem_map; #endif +/* + * Boot parameters saved from start.S + * saved_args[0]: FDT base address + * saved_args[1]: Bloblist signature + * saved_args[2]: must be 0 + * saved_args[3]: Bloblist base address + */ +extern unsigned long saved_args[]; + int board_init(void) { return 0; @@ -144,6 +154,26 @@ void *board_fdt_blob_setup(int *err) return (void *)CFG_SYS_SDRAM_BASE; } +int board_bloblist_from_boot_arg(unsigned long addr, unsigned long size) +{ + int ret = -ENOENT; + + if (!IS_ENABLED(CONFIG_OF_BOARD) || !IS_ENABLED(CONFIG_BLOBLIST)) + return -ENOENT; + + ret = bloblist_check(saved_args[3], size); + if (ret) + return ret; + + /* Check the register conventions */ + ret = bloblist_check_reg_conv(saved_args[0], saved_args[2]); + if (!ret) + /* Relocate the bloblist to the fixed address */ + ret = bloblist_reloc((void *)addr, CONFIG_BLOBLIST_SIZE); + + return ret; +} + void enable_caches(void) { icache_enable(); diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig index c010c25a92..418f48001c 100644 --- a/configs/qemu_arm64_defconfig +++ b/configs/qemu_arm64_defconfig @@ -69,3 +69,6 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_PCI=y CONFIG_SEMIHOSTING=y CONFIG_TPM=y +CONFIG_BLOBLIST=y +CONFIG_BLOBLIST_ADDR=0x40004000 +CONFIG_BLOBLIST_SIZE=0x4000 From patchwork Fri Dec 22 21:31:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879807 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NBWbJ0gK; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgWL3ZYDz20RD for ; Sat, 23 Dec 2023 08:32:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0BF4487863; Fri, 22 Dec 2023 22:32:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NBWbJ0gK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 979B186FB5; Fri, 22 Dec 2023 22:32:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) (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 D65CD8785E for ; Fri, 22 Dec 2023 22:32:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-67f95d69115so6457926d6.1 for ; Fri, 22 Dec 2023 13:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280730; x=1703885530; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bCG/DVe01GyydbeQCZ1PAmA6FhcgYMKWy7veFsR5W0w=; b=NBWbJ0gKtlhnMpgq8J7w+3T7yHbM/C73gyry/usedW6X9vRPzy1wep/N7t5ZVBOeHS Z9Nks8L9wLlfVlrqVOSgJRT+I2oba/WI0Z++qDC1led17IwBUdB/6K/BwiF7buXZtMpO loWei2trUPLYxSrbLa6DwqF1easLLE3uYlRq8Gmsuma9a57LzR/vQANqDdSmZzJWY/98 fDvqTt44dPKb5vQvcVupcBwcX7zpooC340Ek1+fYvVgFpJ5tOgA6la3YMXmegKHncvuO kfgnH5tLNEK5oyU6A7dlUO5o+QEbp8YDUm6x98RAzJDkz8+6AtXpQOBiZ/5gaAAuM2QN svNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280730; x=1703885530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bCG/DVe01GyydbeQCZ1PAmA6FhcgYMKWy7veFsR5W0w=; b=Q8CXi222y5s702PXsK7vpICZIINqF1QuoAgbdotaG0hASL6O2Em0SGvWTtiVKBtPhb /ksDcZLTpZl315bsYdpFMyMzo8IwNAOhF6YOLnc8usQbMm7eqtiPYNkMlV5s6iPb1/td gF/UysBK5Kwl1lqdhgvv0EMy1LrMXIYMecSs5n9XrJj94+CWYRILxmkfy34E7iRdYOPi EQTDSPGosAoqwdAhJjEdDy8DRxpjmVT2sSbCl3ctyFF3Rads7dcrDTZ5FGkJmOuNzeha jYNFA8wWP9cdPxLxceMad44EEx8cALNcIPy2xL7PsEymN4jPTyisnvaGV0YqgdKtgchz el/g== X-Gm-Message-State: AOJu0Yz/ZZCfrPnXpNKvNzjQx/Z5m98fgkJ73foMLhj5uIM5i0jP8Y5m yZkFw/SQmLZMv1pQGYvXcg6BuDjA2UxPWuxy4a9bp+E2vh8= X-Google-Smtp-Source: AGHT+IH4UFWoEy+QMvcDop1h7Z5dHr1sVFo4d/dgLc+JneRnUxmn4G+VtXKWEttTR3FGqQbEUk0bnA== X-Received: by 2002:a05:6214:2308:b0:67f:4926:60cd with SMTP id gc8-20020a056214230800b0067f492660cdmr2453641qvb.83.1703280730549; Fri, 22 Dec 2023 13:32:10 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:32:10 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Shiji Yang , Marek Vasut , Sean Anderson , Baruch Siach , Heinrich Schuchardt , Michal Simek , Qu Wenruo , Stefan Roese Subject: [PATCH v3 7/9] bloblist: Load the bloblist from the previous loader Date: Fri, 22 Dec 2023 13:31:07 -0800 Message-Id: <20231222213110.660402-8-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean During bloblist initialization, when CONFIG_OF_BOARD is defined, invoke the platform custom function to load the bloblist via boot arguments from the previous loader. If the bloblist exists, copy it into the fixed bloblist memory region. Signed-off-by: Raymond Mao --- common/bloblist.c | 47 ++++++++++++++++++++++++++++------------------ include/bloblist.h | 16 ++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 5ad1db137a..e66afcde64 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -492,31 +492,38 @@ int bloblist_init(void) bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED); int ret = -ENOENT; ulong addr, size; - bool expected; - - /** - * We don't expect to find an existing bloblist in the first phase of - * U-Boot that runs. Also we have no way to receive the address of an - * allocated bloblist from a previous stage, so it must be at a fixed + /* + * If U-Boot is not in the first phase, an existing bloblist must be + * at a fixed address. + */ + bool from_addr = fixed && !u_boot_first_phase(); + /* + * If U-Boot is in the first phase that a board specific routine should + * install the bloblist passed from previous loader to this fixed * address. */ - expected = fixed && !u_boot_first_phase(); + bool from_board = fixed && IS_ENABLED(CONFIG_OF_BOARD) && + u_boot_first_phase(); + if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) - expected = false; + from_addr = false; if (fixed) addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR); size = CONFIG_BLOBLIST_SIZE; - if (expected) { + + if (from_board) + ret = board_bloblist_from_boot_arg(addr, size); + else if (from_addr) ret = bloblist_check(addr, size); - if (ret) { - log_warning("Expected bloblist at %lx not found (err=%d)\n", - addr, ret); - } else { - /* Get the real size, if it is not what we expected */ - size = gd->bloblist->total_size; - } - } + + if (ret) + log_warning("Bloblist at %lx not found (err=%d)\n", + addr, ret); + else + /* Get the real size */ + size = gd->bloblist->total_size; + if (ret) { if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) { void *ptr = memalign(BLOBLIST_ALIGN, size); @@ -525,7 +532,8 @@ int bloblist_init(void) return log_msg_ret("alloc", -ENOMEM); addr = map_to_sysmem(ptr); } else if (!fixed) { - return log_msg_ret("!fixed", ret); + return log_msg_ret("BLOBLIST_FIXED is not enabled", + ret); } log_debug("Creating new bloblist size %lx at %lx\n", size, addr); @@ -538,6 +546,9 @@ int bloblist_init(void) return log_msg_ret("ini", ret); gd->flags |= GD_FLG_BLOBLIST_READY; + bloblist_show_stats(); + bloblist_show_list(); + return 0; } diff --git a/include/bloblist.h b/include/bloblist.h index c1dab11f78..2f4246576e 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -445,6 +445,22 @@ int bloblist_reloc(void *to, uint to_size); */ int bloblist_init(void); +#if (IS_ENABLED(CONFIG_ARCH_QEMU) && IS_ENABLED(CONFIG_ARM)) +/* Board custom function for qemu-arm */ +int board_bloblist_from_boot_arg(unsigned long addr, unsigned long size); +#else +/* + * A board need to implement this custom function if it needs to retrieve + * bloblist from a previous loader + */ +static inline +int board_bloblist_from_boot_arg(unsigned long __always_unused addr, + unsigned long __always_unused size) +{ + return -1; +} +#endif + #if CONFIG_IS_ENABLED(BLOBLIST) /** * bloblist_maybe_init() - Init the bloblist system if not already done From patchwork Fri Dec 22 21:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879808 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Pi8wD/rb; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgWX1XLJz20RD for ; Sat, 23 Dec 2023 08:32:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 741278785E; Fri, 22 Dec 2023 22:32:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Pi8wD/rb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 556E586FB5; Fri, 22 Dec 2023 22:32:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 DB8138785E for ; Fri, 22 Dec 2023 22:32:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3ba2dc0f6b7so1684845b6e.2 for ; Fri, 22 Dec 2023 13:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280735; x=1703885535; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IWhK9E3F7Z6K8heZtrBrHp5U+k+K1SV72L5UTRpSFQ8=; b=Pi8wD/rb/+3GqVoiF3WY8s1ujbX4y4U/Lz7R7s5mXkCmk21Benoxh8j/iu9ii4vFNN xbB/giaIorg6LGLPsNKPrSuorgm7Ommu2q01UqONFmRE36vqxzHRsyNmTHOUVvBtI+zJ gtAkS5fK812p63d7ij7CswrQlt4zXMUD8gpcZgC1gaQRw2GJkyHZhEfkw8yV3o1VMAZG CzgjsgjArl4ph4cEUAhybzACXh9X8Od1o7OjAYFobzEyQ5nlbu06gWXqTkZfSR0chP++ h7/+/dB2CMLhtFtlnMY7DDsZQAQBD2J+VAXHafAn/EakXSEQAeJsbOwRhdwdkuTO2ix3 Kbng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280735; x=1703885535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IWhK9E3F7Z6K8heZtrBrHp5U+k+K1SV72L5UTRpSFQ8=; b=Xw/ut8+Nswv500Utm1iJ/IGaXp8Y7pvnouJ23UOkUXKmF4a11UnrB9HvpOY6TLYa6t Y+mojFwKRDJT0SisUTvxH/l1vTV60An4RzMG5mx9UjAmzkR8mWFbkKAjKjf/wnUK7uE3 JWfeD4rNQu2koU1OAcXHlEso1RB8NhT66XBlStd8qwmcXBHZBgiFdC9YEDEt0iQEjyQ8 EopJw5D/OFbQBbw5i3uR2rDiRISMa3LxE7g0kAZ+WjsABjwt4kBmiXAErNSQA7wO17Ig 8hY6acN15n59pG6nHvBqatZ925PsvFgW8n5Cp26vuhm0Zu3lXmp1n0tnysQOTwXCBXOT uYfw== X-Gm-Message-State: AOJu0YyQnPy8HLzl0Q9bj89DZEd6F+htkCSfzx3weD0M25bpTSiRv8so 1gJIm261WrYklF5Iz2cIP09XWuJ5/70aJUj169r0qCPbNWQ= X-Google-Smtp-Source: AGHT+IEmRRqLRgJTa83vJ/iawIx/LoY9kmHS7hw9aQEqSvawT0XGC9H60+QEs+7wQ12U0EruTw7apw== X-Received: by 2002:a05:6808:3023:b0:3ba:1287:f3dd with SMTP id ay35-20020a056808302300b003ba1287f3ddmr2214975oib.96.1703280735255; Fri, 22 Dec 2023 13:32:15 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:32:14 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Marek Vasut , Sean Anderson , Kunihiko Hayashi , Shiji Yang , Heinrich Schuchardt , Baruch Siach , Michal Simek , Stefan Roese Subject: [PATCH v3 8/9] fdt: update the document and Kconfig description Date: Fri, 22 Dec 2023 13:31:08 -0800 Message-Id: <20231222213110.660402-9-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Update the document and Kconfig to describe the behavior of board specific custom functions when CONFIG_OF_BOARD is defined. Signed-off-by: Raymond Mao --- doc/develop/devicetree/control.rst | 6 +++--- dts/Kconfig | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst index cbb65c9b17..e061f4e812 100644 --- a/doc/develop/devicetree/control.rst +++ b/doc/develop/devicetree/control.rst @@ -104,9 +104,9 @@ in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are using CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device tree binary. -If CONFIG_OF_BOARD is defined, a board-specific routine will provide the -devicetree at runtime, for example if an earlier bootloader stage creates -it and passes it to U-Boot. +If CONFIG_OF_BOARD is defined, board-specific routines will provide the +bloblist and devicetree at runtime, for example if an earlier bootloader stage +creates it and passes it to U-Boot. If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D for the diff --git a/dts/Kconfig b/dts/Kconfig index 00c0aeff89..12d61dc748 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -110,8 +110,11 @@ config OF_BOARD default y if SANDBOX || OF_HAS_PRIOR_STAGE help If this option is enabled, the device tree is provided at runtime by - a custom function called board_fdt_blob_setup(). The board must - implement this function if it wishes to provide special behaviour. + a custom function called board_fdt_blob_setup(). + If this option is enabled, bloblist is provided at runtime by a + custom function called board_bloblist_from_boot_arg(). + The board must implement these functions if it wishes to provide + special behaviour. With this option, the device tree build by U-Boot may be overridden or ignored. See OF_HAS_PRIOR_STAGE. From patchwork Fri Dec 22 21:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1879809 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Dq3BNKuo; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SxgWl6jHgz20RD for ; Sat, 23 Dec 2023 08:33:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D1656874D5; Fri, 22 Dec 2023 22:32:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Dq3BNKuo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDF0A874D5; Fri, 22 Dec 2023 22:32:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) (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 DD82986FB5 for ; Fri, 22 Dec 2023 22:32:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7811dba1d5dso154539985a.3 for ; Fri, 22 Dec 2023 13:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703280739; x=1703885539; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e1V5UI6RajBlcMTf5MAPNP+BoyHTGfN0ZmIyzHUyke0=; b=Dq3BNKuoInoXoboa/2EqS6u6UQHA/Bm92F8qQSw5GlqpPkTJYbECqCBl5uBB3o0bTs KjjrjvNR5PNJXgYyinGVAPekh/CNfIMG3FhdNJblSHxMnVdACo6N2MkqOHQpIltxgmoh spk79yD2jpHbGyQFh6SaOpo/6wRZwJoQWmrOupAUYKcSPVtxxOTLMJfhdti0yLQWSmq4 /Q+70IAhNrpqjUSN/WsWa9hgPQLWQqhndoV+sgqcMDvsfHPnH7TQH3S/o1519kcVEL6B F3dRX790UAMxy6tY5k7pedjfcW7w/tgFJPAp5NwO/SGNklT3savQOqY8vW6VBPAapxK7 S1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703280739; x=1703885539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e1V5UI6RajBlcMTf5MAPNP+BoyHTGfN0ZmIyzHUyke0=; b=H/8Dhrd9dZg7yv76f8XeVDQIyChmBEBUGm5l3IuozPXfmeU5k2dZthONo1foBSXGWL NqKgxgzTjBRbsrcd8ebIc8eO1r3LQWaKLxSkZM/cVq/FPhFtSnF2VQdWmcgzpnTYBcOH yrODwzYBSRLxi0P3x6r1dvvCvgmPP3x+bgFjYCbZuw0YrV44pe+9Ac87kNSHMKAmGb8i ZqSXxSB/zhXItpqz7qi8SHY/ubkCV3AUHjMYOBvT5g/tqVVhLHtOCDYBVhrmxburW3j+ BdJxeAR2z4KIF/efNBVGacYijTuKhXY74123KiVYDMDXQWCJymcdKf0ybgBni1vQrdo5 7ScA== X-Gm-Message-State: AOJu0Yy9kbHTgbz/ZUfYTo4k7hJBBc5WC0c/HxFsV4qArDKNeZBQ0YFX 01S+yNnWcpm7Zg0IBctmZ53mSr9+E7LfreCMBJx27xkIqko= X-Google-Smtp-Source: AGHT+IH6R2g1eIHPWeX6GU6Zw5CykJl01mHJPgK+0VOEkk7iItYvG8lKRorNcRFNwI8b4i6svpImNg== X-Received: by 2002:ad4:4b25:0:b0:67f:9aa6:e9c1 with SMTP id s5-20020ad44b25000000b0067f9aa6e9c1mr1493801qvw.127.1703280739353; Fri, 22 Dec 2023 13:32:19 -0800 (PST) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.115.4.214]) by smtp.gmail.com with ESMTPSA id dm6-20020ad44e26000000b0067f6ec98ae9sm1623096qvb.32.2023.12.22.13.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 13:32:19 -0800 (PST) From: Raymond Mao To: u-boot@lists.denx.de, ilias.apalodimas@linaro.org, sjg@chromium.org, jwerner@chromium.org Cc: Raymond Mao , Tuomas Tynkkynen , Kevin Chen , Bin Meng , Nikhil M Jain , Heinrich Schuchardt , Kunihiko Hayashi , Marek Vasut , Shiji Yang , Baruch Siach , Michal Simek , Stefan Roese , Sean Anderson Subject: [PATCH v3 9/9] qemu-arm: get FDT from bloblist Date: Fri, 22 Dec 2023 13:31:09 -0800 Message-Id: <20231222213110.660402-10-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222213110.660402-1-raymond.mao@linaro.org> References: <20231222213110.660402-1-raymond.mao@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Get devicetree from a bloblist if it exists. If not, fallback to get FDT from the specified memory address. Signed-off-by: Raymond Mao --- Changes in v2 - Refactor of board_fdt_blob_setup(). board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index e225011bf0..d326668caf 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -149,9 +149,17 @@ int dram_init_banksize(void) void *board_fdt_blob_setup(int *err) { + void *fdt = NULL; *err = 0; - /* QEMU loads a generated DTB for us at the start of RAM. */ - return (void *)CFG_SYS_SDRAM_BASE; + + /* Check if a DTB exists in bloblist */ + if (IS_ENABLED(CONFIG_BLOBLIST) && !bloblist_maybe_init()) + fdt = bloblist_find(BLOBLISTT_CONTROL_FDT, 0); + if (!fdt) + /* QEMU loads a generated DTB for us at the start of RAM. */ + return (void *)CFG_SYS_SDRAM_BASE; + + return fdt; } int board_bloblist_from_boot_arg(unsigned long addr, unsigned long size)