From patchwork Sat Aug 26 09:06:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 717226 Delivered-To: patch@linaro.org Received: by 2002:a5d:688a:0:b0:317:ecd7:513f with SMTP id h10csp294570wru; Sat, 26 Aug 2023 02:07:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzxchvA88S1A5j8kTOCm02LidIUHBJMQUsoUG4oNdy/WB2asQmWbGDnT8/nT7kQHsOFizh X-Received: by 2002:a5d:5962:0:b0:319:7b96:a1be with SMTP id e34-20020a5d5962000000b003197b96a1bemr13350631wri.71.1693040832970; Sat, 26 Aug 2023 02:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693040832; cv=none; d=google.com; s=arc-20160816; b=W/258QNsL8zn4L3O1KwoxTENgzImjvwA0tYVVzvjVmOhnkg4LR6D1DQ3ALAh7zKBEE ICms+IBgKYr7bjBIAvfl9ygdPLto3VtG/YaxvieUSW6VUxYx2RtYyNzkA+E9Ejzs6oQf 7oS0VCdhqp0paivD2P+xZjXCs+0s7jfDle+YmlL7WfqwWbHGb3ekDemkr3+GufAkLK8r /JGTZAKMVE4lEcLXh20qZ3AWNSHvZPtgeqoTn1ZSOeAOB0pQ9wmoF+uXpSwtVUiUDd9J IQTIfC8Oz1cazu4FIIgXwynvWDrvhNwjDA1dL7gMYrv0HHsjvvzEvFjYxqNhYuYTYonW I0jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Z3RaWYCJ15ExbeJgcomqg04ddmCR4hNpzkwCZ5lmKiY=; fh=wxXZJCQRz/XgBTfKhuJFfNV+eZ/MzU8zncY23uTJ9bU=; b=g/gHkbPHRInG2jzb5McDn0G39zkfig1jQ/nIu1sXtXMusDIh507mcZCxNVbaQj0d1Q +jH71VfF17Q1vZP1qQPGqbzwZDjt/L2x7i+E4xPl7nZC81ezmJF4ruKZ3UB1K+M1e8nY s4dCSw26UIIaeyK/+SzpnGMN5iwGkpPgZZ42AFWeMyGCHwKAQnxg68W7/GBj2iCptsI/ WuUG1VNtI3Lw8ZYpQu73O4prbWLEi9IcEY9aN6EFsFRqJvOvUh7sZHcKljf/HWhUIh0E hr/g88tERU+TCY7sgftI05RxOJguRAT5/0VtO8E7ahAvFAjZ4mZDUlbHCOoYguC50Umt PO3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j18-20020adfea52000000b0031986aa2a8dsi513614wrn.961.2023.08.26.02.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 02:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EEF7D86B3A; Sat, 26 Aug 2023 11:07:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id EA32886B37; Sat, 26 Aug 2023 11:07: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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 1C4D186B19 for ; Sat, 26 Aug 2023 11:07:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 906E11FB; Sat, 26 Aug 2023 02:07:42 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.46.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B2A73F740; Sat, 26 Aug 2023 02:07:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Sughosh Ganu Subject: [RFC PATCH 1/5] dt: Provide a way to remove non-compliant nodes and properties Date: Sat, 26 Aug 2023 14:36:29 +0530 Message-Id: <20230826090633.239342-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230826090633.239342-1-sughosh.ganu@linaro.org> References: <20230826090633.239342-1-sughosh.ganu@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 a function which is registered to spy for a EVT_FT_FIXUP event, and removes the non upstreamed nodes and properties from the devicetree before it gets passed to the OS. This allows removing entire nodes, or specific properties under nodes from the devicetree. The required nodes and properties can be registered for removal through the DT_NON_COMPLIANT_PURGE and DT_NON_COMPLIANT_PURGE_LIST macros. Signed-off-by: Sughosh Ganu --- include/dt-structs.h | 11 +++++++ lib/Makefile | 1 + lib/dt_purge.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 lib/dt_purge.c diff --git a/include/dt-structs.h b/include/dt-structs.h index fa1622cb1d..f535c60471 100644 --- a/include/dt-structs.h +++ b/include/dt-structs.h @@ -57,3 +57,14 @@ struct phandle_2_arg { #endif #endif + +struct dt_non_compliant_purge { + const char *node_path; + const char *prop; +}; + +#define DT_NON_COMPLIANT_PURGE(__name) \ + ll_entry_declare(struct dt_non_compliant_purge, __name, dt_purge) + +#define DT_NON_COMPLIANT_PURGE_LIST(__name) \ + ll_entry_declare_list(struct dt_non_compliant_purge, __name, dt_purge) diff --git a/lib/Makefile b/lib/Makefile index 8d8ccc8bbc..82a906daa0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -37,6 +37,7 @@ endif obj-y += crc8.o obj-y += crc16.o obj-y += crc16-ccitt.o +obj-y += dt_purge.o obj-$(CONFIG_ERRNO_STR) += errno_str.o obj-$(CONFIG_FIT) += fdtdec_common.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o diff --git a/lib/dt_purge.c b/lib/dt_purge.c new file mode 100644 index 0000000000..f893ba9796 --- /dev/null +++ b/lib/dt_purge.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023, Linaro Limited + */ + +#include +#include +#include + +#include + +/** + * dt_non_compliant_purge() - Remove non-upstreamed nodes and properties + * from the DT + * @ctx: Context for event + * @event: Event to process + * + * Iterate through an array of DT nodes and properties, and remove them + * from the device-tree before the DT gets handed over to the kernel. + * These are nodes and properties which do not have upstream bindings + * and need to be purged before being handed over to the kernel. + * + * If both the node and property are specified, delete the property. If + * only the node is specified, delete the entire node, including it's + * subnodes, if any. + * + * Return: 0 if OK, -ve on error + */ +static int dt_non_compliant_purge(void *ctx, struct event *event) +{ + int nodeoff = 0; + int err = 0; + void *fdt; + const struct event_ft_fixup *fixup = &event->data.ft_fixup; + struct dt_non_compliant_purge *purge_entry; + struct dt_non_compliant_purge *purge_start = + ll_entry_start(struct dt_non_compliant_purge, dt_purge); + int nentries = ll_entry_count(struct dt_non_compliant_purge, dt_purge); + + if (fixup->images) + return 0; + + fdt = fixup->tree.fdt; + for (purge_entry = purge_start; purge_entry != purge_start + nentries; + purge_entry++) { + nodeoff = fdt_path_offset(fdt, purge_entry->node_path); + if (nodeoff < 0) { + log_debug("Error (%d) getting node offset for %s\n", + nodeoff, purge_entry->node_path); + continue; + } + + if (purge_entry->prop) { + err = fdt_delprop(fdt, nodeoff, purge_entry->prop); + if (err < 0 && err != -FDT_ERR_NOTFOUND) { + log_debug("Error (%d) deleting %s\n", + err, purge_entry->prop); + goto out; + } + } else { + err = fdt_del_node(fdt, nodeoff); + if (err) { + log_debug("Error (%d) trying to delete node %s\n", + err, purge_entry->node_path); + goto out; + } + } + } + +out: + return err; +} +EVENT_SPY(EVT_FT_FIXUP, dt_non_compliant_purge); From patchwork Sat Aug 26 09:06:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 717227 Delivered-To: patch@linaro.org Received: by 2002:a5d:688a:0:b0:317:ecd7:513f with SMTP id h10csp294632wru; Sat, 26 Aug 2023 02:07:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6R0jLcRsaibxT+lKyxepi2ALgk+AJ/4Z2bY/tieRQqHDt4ufpDP80JojL7hIgoLpeOn5p X-Received: by 2002:a5d:498e:0:b0:317:50b7:2ce3 with SMTP id r14-20020a5d498e000000b0031750b72ce3mr15310137wrq.51.1693040842720; Sat, 26 Aug 2023 02:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693040842; cv=none; d=google.com; s=arc-20160816; b=cx1qsH9IdvJ6nUkQtj6SwzCIvmJSK636Mzc44Ctxohs37B1SVqeVwdkFVcbDkrKtnC X5OagIS+N553aNC6K8Ca/QQWpHBi2kyd8nXzsx24r8OTZHLBPC6xIccoC6qAxcK3vYuZ wRcnuYpoGJvoQv06LtVZioPgo4TZuoxCeyZdS51KNhM9DPANNWgOoyvJEqlwsK3lpWQ3 1YNN8bAde8SjznoH63aoMS6qQPaj/HX5ggGujT0tYTn4xU/oFIBuJws2G3++P9LaTo1Y FrXAcl4GVQmqCMZF7JSWNb5sf7czeFTeoMU+NUaka58l8mysrnUhiBtARigRjWmYb/9P q05w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=blPj5cwzzeBnaGYZJ7VbUZ5MJgpuv+NDggPCip26Sg8=; fh=wxXZJCQRz/XgBTfKhuJFfNV+eZ/MzU8zncY23uTJ9bU=; b=cPLdrdSMClhtp0YhrK/lOdvPdWo6qa1ah4UUZuUCuh5KIvKARBigaWo1ruzMENztn9 uTNwQGm6E60xQFjDvvPvvTgLHQPmc/cDlI6x+uH+VTdO2av0w/ETspV3LMTdnw4Y7Hd/ A1RpBOIBaKvDy6fujf2m5gMsRbfXHM31XNidLSPvpGImrC+HyoxvJ3B5xKLcMGqiSqFo /mcsStba7qLawz7ZDJHPfFaGaSWQnZ6MTvwj82hUtm4o98KdTTMPIqYqF+xtOL/wZ+Pb 8rtxkrFerMgTE8JqpRcNJ0x7WWfNg2didzFZd/ZkooyqHO6eW2v0nJeJRX2shRvzl9Pe +VmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id d14-20020adfef8e000000b003196afc7a39si28665wro.449.2023.08.26.02.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 02:07:22 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C67786B39; Sat, 26 Aug 2023 11:07:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id DD6E086B48; Sat, 26 Aug 2023 11:07:07 +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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 4BFA586B34 for ; Sat, 26 Aug 2023 11:07:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DEC91FB; Sat, 26 Aug 2023 02:07:45 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.46.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C0EB03F740; Sat, 26 Aug 2023 02:07:02 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Sughosh Ganu Subject: [RFC PATCH 2/5] fwu: Add the fwu-mdata node for removal from devicetree Date: Sat, 26 Aug 2023 14:36:30 +0530 Message-Id: <20230826090633.239342-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230826090633.239342-1-sughosh.ganu@linaro.org> References: <20230826090633.239342-1-sughosh.ganu@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 FWU metadata devicetree node points to the device which stores the metadata structure. This node is relevant only in U-Boot, and is not to be passed to the OS. Register for purging this node from the devicetree, before passing it to the OS. Signed-off-by: Sughosh Ganu --- drivers/fwu-mdata/fwu-mdata-uclass.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c b/drivers/fwu-mdata/fwu-mdata-uclass.c index 0a8edaaa41..71411d9c19 100644 --- a/drivers/fwu-mdata/fwu-mdata-uclass.c +++ b/drivers/fwu-mdata/fwu-mdata-uclass.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -53,3 +54,7 @@ UCLASS_DRIVER(fwu_mdata) = { .id = UCLASS_FWU_MDATA, .name = "fwu-mdata", }; + +DT_NON_COMPLIANT_PURGE(fwu_mdata) = { + .node_path = "/fwu-mdata", +}; From patchwork Sat Aug 26 09:06:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 717228 Delivered-To: patch@linaro.org Received: by 2002:a5d:688a:0:b0:317:ecd7:513f with SMTP id h10csp294683wru; Sat, 26 Aug 2023 02:07:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzoOq9akgSFkAUUFIBUJf7GVGPITOEJHLJ5oPI3klDRC0LN7VJedd3aSchM+TdFqTvmV+9 X-Received: by 2002:a5d:560a:0:b0:31a:ed75:75d9 with SMTP id l10-20020a5d560a000000b0031aed7575d9mr14532357wrv.16.1693040851642; Sat, 26 Aug 2023 02:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693040851; cv=none; d=google.com; s=arc-20160816; b=T4lR/4m/2psBupiruvUesUWWbA//qcfuIVNWybukzDQnfKhqcTVEg/N7aBiqoZpdpa Eivry46s+Tzp+QwbiaNJm4GzsSNgxaLSt8IQ4BH2E/Kt55IMqNUKEjQ1L7pve+9i9wu2 YvXkygVFgEWiiQKWwxKo/yadtyF6wy1gDmwbibJnoHWO2hwMDMUnmSpPgisRYh/m3kns Kpy214q3GhLxJivjD58odEVIHW57xsvQggT6i5hRyFQdlVfGnI3mGvOHmzqQmirPKAf+ 6nieK8Z91MvAlxnJgWvMDwf3sQiE4+O883KB49CuW0S/c+7f0lplU/DtYX39r1C8cgGf xKOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=B+rL0+xAJ60yhJdDJLoNZVzfH6NxNbtZrRkx452T5CA=; fh=wxXZJCQRz/XgBTfKhuJFfNV+eZ/MzU8zncY23uTJ9bU=; b=biSKTfAMAEV71Y8eyQ3cI5FemeRZNuYYSLD01w5oiKOggEskNh8p9XIcZ0dYSw5YNb LKR/ayFhQrKr4GH5RpbV6icagQuvs8JXqMKZcHyhAms9/aSYuHIdRunoM9K6XJgVhkQu r7bc27cxIAKj7k4CSReb3st3Hhqsxr6kE3E3691UKZ43utnH3j5z8YyPlntCth9JihNr b0MonSwuuPoltniwQPACy1JuzuFiU5X+sLWpNcMoaV2FXfQHZwpxq5vEzZKrbYB2YMLt cUtscEBWPBomaEbgIw3i25f90a/R8Df844dZ09Hgk0wEsC4lum4ScK95VI2Y9ZUDLWyR npUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id l18-20020adff492000000b003176aed8c4asi1622750wro.187.2023.08.26.02.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 02:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F29086B40; Sat, 26 Aug 2023 11:07:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 9093A86B37; Sat, 26 Aug 2023 11:07:10 +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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id E882286B34 for ; Sat, 26 Aug 2023 11:07:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7BBB11FB; Sat, 26 Aug 2023 02:07:47 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.46.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C7293F740; Sat, 26 Aug 2023 02:07:05 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Sughosh Ganu Subject: [RFC PATCH 3/5] capsule: Add the capsule-key property for removal from devicetree Date: Sat, 26 Aug 2023 14:36:31 +0530 Message-Id: <20230826090633.239342-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230826090633.239342-1-sughosh.ganu@linaro.org> References: <20230826090633.239342-1-sughosh.ganu@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 capsule-key property contains the public key in the form of an EFI Signature List(ESL) structure. This property is relevant only in U-Boot, and is not to be passed to the OS. Register for purging this property from the devicetree, before passing it to the OS. Signed-off-by: Sughosh Ganu --- lib/efi_loader/efi_capsule.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index af8a2ee940..5c6c87458f 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -9,6 +9,7 @@ #define LOG_CATEGORY LOGC_EFI #include +#include #include #include #include @@ -403,6 +404,12 @@ out: return status; } + +DT_NON_COMPLIANT_PURGE(capsule_key) = { + .node_path = "/signature", + .prop = "capsule-key", +}; + #endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ static __maybe_unused bool fwu_empty_capsule(struct efi_capsule_header *capsule) From patchwork Sat Aug 26 09:06:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 717229 Delivered-To: patch@linaro.org Received: by 2002:a5d:688a:0:b0:317:ecd7:513f with SMTP id h10csp294704wru; Sat, 26 Aug 2023 02:07:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrO2QNKshH5cE5HWjjiUsgR9qv6ENIrW4cKv1dPjR4aXmg5fwEVM7dRXKNp95o/7auCTjo X-Received: by 2002:a05:600c:2157:b0:3fe:89be:cd3 with SMTP id v23-20020a05600c215700b003fe89be0cd3mr16966419wml.22.1693040860867; Sat, 26 Aug 2023 02:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693040860; cv=none; d=google.com; s=arc-20160816; b=JixbfoApqso6sCGZiSdcCGdgyd2n47wpfJHH5hq2tyobjY21M6RMSkigSwUM01da/3 V3TeHIt/5BCHdUPVrLuUGy+jVdeNXMgxPkd6cVQAaks+EEAXcZZIyN7ux9io4Yn6rWM6 f+bg7kz2VoqQjlxNMzoY1Ly8HGY1SJBfVIIfzWcxdJOVIsS0fo5l2MDAOICztg2CJqmM 0gbDF2hk5wuy2MLoQQIOvKZ5QQs4NPdjbzwd6KynlH+FRnAkNkGppFUPpCTQj+rmsxEZ lkOO2ucJxK9Vr1gAYVsyUdupKXcCM8XbfYpklS/sIqXK9jiGcgBtUkLbULRcHskM5dOk wpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=u8KaKSX/NOuY4RW1ekqngd1sYU4roSfu4rMg8FOyQWk=; fh=wxXZJCQRz/XgBTfKhuJFfNV+eZ/MzU8zncY23uTJ9bU=; b=y7b94wp3eX1BTThmmlnvHN/QhcNdYWIkqfOWiOmCVeTgmHTyUBuW7tTL176ze+kcj1 3MXSStNRGTcnFIsvHjlAXCuWhrOtZi+3X5njRWAshB33tlcNW2YtUl4mPUuiWJfI1QA1 HKldtEFUga8gJCMOLXyTqL5FiKhJ620VMSB4I5Vd/PijeRqZ4BZEug9K3yr89l7AqyiS UGgq1Q7IE5t4kzy5snA2CVTmUH/goMGreIiElFqBUvJ5+mwFBKEYuxiwXRW0DwfC8KVG X9VgGpukPeHGDzqW/FqwmOD0ibd1a+97SPjl+VRCR9MmM/XR6aAiEKP/ZYoxjjjpZmV2 tKHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id v12-20020a05600c15cc00b003fee7a8aac8si308254wmf.156.2023.08.26.02.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 02:07:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C096286B4B; Sat, 26 Aug 2023 11:07:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D91A786B4B; Sat, 26 Aug 2023 11:07:12 +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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 431BB86B12 for ; Sat, 26 Aug 2023 11:07:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBC841FB; Sat, 26 Aug 2023 02:07:49 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.46.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ABB1B3F844; Sat, 26 Aug 2023 02:07:07 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Sughosh Ganu Subject: [RFC PATCH 4/5] bootefi: Call the EVT_FT_FIXUP event handler Date: Sat, 26 Aug 2023 14:36:32 +0530 Message-Id: <20230826090633.239342-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230826090633.239342-1-sughosh.ganu@linaro.org> References: <20230826090633.239342-1-sughosh.ganu@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 bootefi command passes the devicetree to the kernel through the EFI config table. Call the event handlers for fixing the devicetree before jumping into the kernel. This removes any devicetree nodes and/or properties that are specific only to U-Boot, and are not to be passed to the OS. Signed-off-by: Sughosh Ganu --- cmd/bootefi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index f73d6eb0e2..c359a46ec4 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -237,6 +237,23 @@ static void *get_config_table(const efi_guid_t *guid) return NULL; } +/** + * event_notify_dt_fixup() - call ft_fixup event + * + * @fdt: address of the device tree to be passed to the kernel + * through the configuration table + * Return: None + */ +static void event_notify_dt_fixup(void *fdt) +{ + int ret; + struct event_ft_fixup fixup = {0}; + + fixup.tree.fdt = fdt; + ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup)); + if (ret) + printf("Error: %d: FDT Fixup event failed\n", ret); +} #endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */ /** @@ -318,6 +335,7 @@ efi_status_t efi_install_fdt(void *fdt) efi_carve_out_dt_rsv(fdt); efi_try_purge_kaslr_seed(fdt); + event_notify_dt_fixup(fdt); if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { ret = efi_tcg2_measure_dtb(fdt); From patchwork Sat Aug 26 09:06:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 717230 Delivered-To: patch@linaro.org Received: by 2002:a5d:688a:0:b0:317:ecd7:513f with SMTP id h10csp294766wru; Sat, 26 Aug 2023 02:07:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd9fAa+15mg8fOyyzuFTsKu5XnXKNvSnLeS790CoSQEtmMKqS0hnT11ueJLqYovmGoICbq X-Received: by 2002:a05:6000:1245:b0:319:8979:8fcc with SMTP id j5-20020a056000124500b0031989798fccmr15464535wrx.70.1693040872171; Sat, 26 Aug 2023 02:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693040872; cv=none; d=google.com; s=arc-20160816; b=KA+Q9LaTHfzerS/sqnkvxxERCTLGlwQeGP4pRAetfqtU/VWUGH2irdNoXo1vaLuyfz 9tDDN9kEIozZLu7ASlg+ukqh7rmmxIcyoHRIJLg8pHGi7UPcsUQx/5gembF8WlL/kbxC QgHHN++1Fzfp8oEIBNBZZl3XH8BVvTmoaALgQkk3TUGFtme02TjLzdYmgqUI99MxlR51 zui9P2tOpFyx7gcIuAjpLsn+7OzWdYY3mvxlRjuoVZXLh2L4d9aRg163IecTgUg2t6Dd yZdtT25oopZ7ZPdFZqlE+EAttSTkkTbDU3kvWga5wYqigndCAo7UHBQgT/sEIhQjMYCE lsGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=wfYdew0jrZYyGUHUPqDy815QX/rv6r7KRizp2bYhc28=; fh=wxXZJCQRz/XgBTfKhuJFfNV+eZ/MzU8zncY23uTJ9bU=; b=Ek93E+z3lcJXZIGEDHvXBZF5RL0Sag+Ka89WGAEAYXfDqMCWqJyG4zk9JzTPB09qbc BwOtzLym62JgIKHzeJDKRpv2BVHKf6JG5Dk9Xnxs+/lA+S1OtWz5YDfsnonhxR9GjBkU zd3VqCOxGM6bT1GpCeuJkxN5YS2Dl9IBRECwIcX1s7ip7cuBasE+7EiWaTt12wAaBuKf uldJ/DZGur+keyy2H9RfpvWFjGCokYeSITnztAlq2OoVphSK5Bfju5dyFhNsSsj+NdZ5 P0IDq2muUYtYHOYdKC23eXuiEMco6yMlfUnkY15U8rRGCxckrwACm3A/Ua8Zc1WNtHJQ TXSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z6-20020a5d6546000000b003198b11feedsi13237wrv.646.2023.08.26.02.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 02:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F30586B19; Sat, 26 Aug 2023 11:07:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 463DE86B19; Sat, 26 Aug 2023 11:07:16 +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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id A8D4086B47 for ; Sat, 26 Aug 2023 11:07:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68327D75; Sat, 26 Aug 2023 02:07:52 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.46.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2772D3F740; Sat, 26 Aug 2023 02:07:09 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Sughosh Ganu Subject: [RFC PATCH 5/5] doc: Add a document for non-compliant DT node/property removal Date: Sat, 26 Aug 2023 14:36:33 +0530 Message-Id: <20230826090633.239342-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230826090633.239342-1-sughosh.ganu@linaro.org> References: <20230826090633.239342-1-sughosh.ganu@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 a document explaining the need for removal of non-compliant devicetree nodes and properties. Also describe in brief, the macros that can be used for this removal. Signed-off-by: Sughosh Ganu --- .../devicetree/dt_non_compliant_purge.rst | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 doc/develop/devicetree/dt_non_compliant_purge.rst diff --git a/doc/develop/devicetree/dt_non_compliant_purge.rst b/doc/develop/devicetree/dt_non_compliant_purge.rst new file mode 100644 index 0000000000..c3a8feab5b --- /dev/null +++ b/doc/develop/devicetree/dt_non_compliant_purge.rst @@ -0,0 +1,64 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Removal of non-compliant nodes and properties +============================================= + +The devicetree used in U-Boot might contain nodes and properties which +are specific only to U-Boot, and are not necessarily being used to +describe hardware but to pass information to U-Boot. An example of +such a property would be the public key being passed to U-Boot for +verification. + +This devicetree can then be passed to the OS. Since certain nodes and +properties are not really describing hardware, and more importantly, +these are only relevant to U-Boot, bindings for these cannot be +upstreamed into the devicetree repository. There have been instances +of attempts being made to upstream such bindings, and these deemed not +fit for upstreaming. Not having a binding for these nodes and +properties means that the devicetree fails the schema compliance tests +[1]. This also means that the platform cannot get certifications like +SystemReady [2] which, among other things require a devicetree which +passes the schema compliance tests. + +For such nodes and properties, it has been suggested by the devicetree +maintainers that the right thing to do is to remove them from the +devicetree before it gets passed on to the OS [3]. + +Removing nodes/properties +------------------------- + +In U-Boot, this is been done through adding information on such nodes +and properties in a list. The entire node can be deleted, or a +specific property under a node can be deleted. The list of such nodes +and properties is generated at compile time, and the function to purge +these can be invoked through a EVT_FT_FIXUP event notify call. + +For deleting a node, this can be done by declaring a macro:: + + DT_NON_COMPLIANT_PURGE(fwu_mdata) = { + .node_path = "/fwu-mdata", + }; + +Similarly, for deleting a property under a node, that can be done by +specifying the property name:: + + DT_NON_COMPLIANT_PURGE(capsule_key) = { + .node_path = "/signature", + .prop = "capsule-key", + }; + +In the first example, the entire node with path /fwu-mdata will be +removed. In the second example, the property capsule-key +under /signature node will be removed. + +Similarly, a list of nodes and properties can be specified using the +following macro:: + + DT_NON_COMPLIANT_PURGE_LIST(foo) = { + { .node_path = "/some_node", .prop = "some_bar" }, + { .node_path = "/some_node" }, + }; + +[1] - https://github.com/devicetree-org/dt-schema +[2] - https://www.arm.com/architecture/system-architectures/systemready-certification-program +[3] - https://lore.kernel.org/u-boot/CAL_JsqJN4FeHomL7z3yj0WJ9bpx1oSE7zf26L_GV2oS6cg-5qg@mail.gmail.com/