From patchwork Mon Jun 11 16:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 138258 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4256017lji; Mon, 11 Jun 2018 09:26:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkp1LY3Pa0limgXfMgrMkK+ntWx0x4i0SSCHJAtqZ9u0RcltvXBj1YCJZKyj4da6jprdXu X-Received: by 2002:a0c:cd13:: with SMTP id b19-v6mr15606720qvm.83.1528734398269; Mon, 11 Jun 2018 09:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528734398; cv=none; d=google.com; s=arc-20160816; b=nusqjlwilVTUe7S7OXdAAeYHXySwE8NzahlUita96GyGME3Bo8cLHRSd+T5rK7/Ite iG4CY6Ay970HWtF4EMyWWlFHidAdUxIfgwoJSf8WKZ4Dx6JbbBBh2bdE/+V10BxAZzkW naLWEXlfvsXiaWJC+NjIIxkTesw4Ea9yS+XITzUs/QkHHqREaXy7zF1DuM15kHljE/p2 bFjhPEWWtY/WQ6gC2uiPou4NrUU+6QnxaT6TP3LEa2wMUne6ERlJCqS3gSxJWRiotd+o 5n84Ijq4gPpP8OaXKyjRCOua1rPlyEZ8DQaiUKl8m0LyHYY+eMZkQ1ukCqlBQjAajdli stAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=445GinKz4IC6oqPUbXEXdOxglgxp5ACZ2uv86FjG6gY=; b=rfBw0yw2+h64ObYd7Hd+NMMqEonkT/pAVoO+EENFZXW/xCJoTQIe5cz4gxugzSbEpg TQ8ctktsmmiB8vbpsWjMnlFh2MkHs+rYdK4vklMqhWRy6HsK5kTeTS2/nQM6ZGKLWqdi CdPydtJbOiAIlMJP3nBZzaiMalCmkM9Ju8uFx6IZvaQ2aR50VbD5bMUTCFvXR4pO3esR pTgn80MjZpThsY4Tv46n83wcyR9iy4eAIccTW1p4kfAvB9QBPgTvqBCjP4wWGF8epjm4 9/HaU4vwhuEukRw8OVDTZGOsg5RUENcgbVqtu7+ktCDDWCVpmKEl0eom1zLIuWT7f5qQ Ks3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EYBxUWHN; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n89-v6si4714681qva.105.2018.06.11.09.26.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Jun 2018 09:26:38 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EYBxUWHN; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPeP-0005JF-NT for patch@linaro.org; Mon, 11 Jun 2018 12:26:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPcy-0004ma-Bi for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSPcv-0007n4-Mo for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:08 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:37053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSPcv-0007m1-Dj for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:05 -0400 Received: by mail-wm0-x22c.google.com with SMTP id r125-v6so17678077wmg.2 for ; Mon, 11 Jun 2018 09:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y3QxyfsxrzlbvHTMpL1XPvCWlQo8OMun0kDexsyswN4=; b=EYBxUWHNmkW71wQ3nEsr5Pm8z3629DEmoYOod7TjIoSCnqThQDWfyASIPz0IAOWo50 cC9Ea9uVrPuUqhFvC3pzfx6GNgDd1dIm/Pkvn1RLghDu+sTtcHrt3oI97IIbg742Atdp i9Xo6ARwpFhnEF3Dvzxb4wxaQUViR/MRY0qjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y3QxyfsxrzlbvHTMpL1XPvCWlQo8OMun0kDexsyswN4=; b=U8m8X+NekVCvLwO1QC5ujYeah8sHedesaZNnCnG1S3gNQF/o+EOCfpXjZ3R1ak5d5W 4AUjfXt2rH2IqklekZr5dnI7tfiTkdmrGVgUE1tirlhZitTRWVIY1vnOQ8a28Po79i/3 w8K+oHTaZW0zwJitlk73YYfJgBy6Dl1NzPep2XyDrLcGbdpgyYKwthLzRfDgximXIcm6 GS2KL84ge06TTpLvypMzBju/lvuGTcan3rXnWcaL21/+qF7NXWIZcsKTV0Je67DmBNQ0 sOdz50SPfm5noQNDPibObRHuqs53hcJeAdWSD/p5m1VOhpGdeaWwtiM8Wzz3RuJI/7WK clGg== X-Gm-Message-State: APt69E2/Gg9zBRhgmKIGJhXNA4uni67KEU7cYI0u/kn8IurrGXrmGtTw BKbLRhrO6CNREyY10yUEGQtus8NfhTs= X-Received: by 2002:a1c:e90f:: with SMTP id q15-v6mr9324266wmc.149.1528734304106; Mon, 11 Jun 2018 09:25:04 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id s191-v6sm16460925wmd.27.2018.06.11.09.25.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 09:25:02 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/2] fdt: move prop_entry_size to fdt.h Date: Mon, 11 Jun 2018 17:24:58 +0100 Message-Id: <20180611162459.9178-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180611162459.9178-1-leif.lindholm@linaro.org> References: <20180611162459.9178-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" To be able to resuse the prop_entry_size macro, move it to and rename it grub_fdt_prop_entry_size. Signed-off-by: Leif Lindholm --- grub-core/lib/fdt.c | 25 ++++++++++--------------- include/grub/fdt.h | 5 +++++ 2 files changed, 15 insertions(+), 15 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 2705f2629..0d371c563 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -41,11 +41,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); (2 * sizeof(grub_uint32_t) \ + ALIGN_UP (grub_strlen (name) + 1, sizeof(grub_uint32_t))) -/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff - fields, plus the property value, plus padding if needed. */ -#define prop_entry_size(prop_len) \ - (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) - #define SKIP_NODE_NAME(name, token, end) \ name = (char *) ((token) + 1); \ while (name < (char *) end) \ @@ -86,7 +81,7 @@ static grub_uint32_t *get_next_node (const void *fdt, char *node_name) case FDT_PROP: /* Skip property token and following data (len, nameoff and property value). */ - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_NOP: @@ -150,7 +145,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name) { case FDT_PROP: /* Skip len, nameoff and property value. */ - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_BEGIN_NODE: @@ -249,12 +244,12 @@ static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset, && !grub_strcmp (name, (char *) fdt + grub_fdt_get_off_dt_strings (fdt) + nameoff)) { - if (prop + prop_entry_size(grub_be_to_cpu32(*(prop + 1))) + if (prop + grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop) >= end) return NULL; return prop; } - prop += prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); + prop += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); } else if (grub_be_to_cpu32(*prop) == FDT_NOP) prop++; @@ -319,7 +314,7 @@ advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t value). */ if (token >= end - 1) return 0; - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_NOP: @@ -467,12 +462,12 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, unsigned int needed_space = 0; if (!prop) - needed_space = prop_entry_size(len); + needed_space = grub_fdt_prop_entry_size(len); if (!prop_name_present) needed_space += grub_strlen (name) + 1; if (needed_space > get_free_space (fdt)) return -1; - if (rearrange_blocks (fdt, !prop ? prop_entry_size(len) : 0) < 0) + if (rearrange_blocks (fdt, !prop ? grub_fdt_prop_entry_size(len) : 0) < 0) return -1; } if (!prop_name_present) { @@ -489,10 +484,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, + sizeof(grub_uint32_t)); prop = (void *) (node_name + ALIGN_UP(grub_strlen(node_name) + 1, 4)); - grub_memmove (prop + prop_entry_size(len) / sizeof(*prop), prop, + grub_memmove (prop + grub_fdt_prop_entry_size(len) / sizeof(*prop), prop, struct_end(fdt) - (grub_addr_t) prop); grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt) - + prop_entry_size(len)); + + grub_fdt_prop_entry_size(len)); *prop = grub_cpu_to_be32_compile_time (FDT_PROP); *(prop + 2) = grub_cpu_to_be32 (nameoff); } @@ -500,7 +495,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, /* Insert padding bytes at the end of the value; if they are not needed, they will be overwritten by the following memcpy. */ - *(prop + prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; + *(prop + grub_fdt_prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; grub_memcpy (prop + 3, val, len); return 0; diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 75525fa31..158b1bc4b 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -50,6 +50,11 @@ struct grub_fdt_empty_tree { #define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree) +/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff + fields, plus the property value, plus padding if needed. */ +#define grub_fdt_prop_entry_size(prop_len) \ + (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) + #define grub_fdt_get_header(fdt, field) \ grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field) #define grub_fdt_set_header(fdt, field, value) \ From patchwork Mon Jun 11 16:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 138260 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4257415lji; Mon, 11 Jun 2018 09:28:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ5hi1yM+1suti3E7pIWT5+bB+udOIXfkSWRXrnU0y6JyLjjU4oOcs5Iq4NnR+/HnmTkf4q X-Received: by 2002:a37:1193:: with SMTP id 19-v6mr15611747qkr.379.1528734486137; Mon, 11 Jun 2018 09:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528734486; cv=none; d=google.com; s=arc-20160816; b=0cqMIHtXovBVKbRPSD6/pd+HEcYviqRoXnLO/TH7q8eY3PDpUaebrgIBPhXHJt1Kzc uxVdnuF4I1+8yDrMPBPLCXE54mk3DG/3ySxbzBPGzYHrPISDw7Pm1GNeaCuUBMn8U5ex jGWOUGAxnbKOD9f6rfdfh7kpHt0q7c5zA7tUqDtmZtvU3SoWsTvYzPnCrjs19YjEMaRs Spz0pO6G43I/07abi0ZIceFZTYXbLa+cOc62rQV2Asy7BWYHI8SDOVjOZBwnROrVx+8y pUaR4ioAySKGDvTQljSLjhwrYCsOqYZzwSfgRXLfhDZrPaEorC2d/Gjs77G/ueoCO8Fo ybHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=xDdRpXe4QUX07EWsu0UkNEzVH0yi2Kp2HCNtTsJhs2s=; b=Ar+G9GGt5kooEkcJnXTYF2+fM05N0qHi+QGe2L9A8/M+EBcrq2DicMNPS9J29ny1Ht C5SvT+Va+4M+YG9iiIaz4rceo8s5/GhDzc4YM5uiPtFHdi7zqZUyb3wKEnUw5jhuscrE 5rTzPO61x/+0f4KC7XNcPAwkY/xa7wgdsaEclGiQl5IRLpo7uw3vSTq7J/8wuLLkYtEX tRoL8G35Ascv+qI3GQV3EKOD6mrtDfbDFvIOK65bw4xS5LblBk1PtmgFAhWl7tMb7ysY Uaq21xCfwsuLBo4sD1VHwuP8khOBytSiblFV7gSVjBdeF2vek/QiVYW33JlraRg6v6rr ejwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ajOPLPxo; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 46-v6si4045075qvx.127.2018.06.11.09.28.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Jun 2018 09:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ajOPLPxo; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPfp-0006mk-JA for patch@linaro.org; Mon, 11 Jun 2018 12:28:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPcy-0004mb-C8 for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSPcx-0007py-B3 for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:08 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSPcx-0007oT-4k for grub-devel@gnu.org; Mon, 11 Jun 2018 12:25:07 -0400 Received: by mail-wm0-x241.google.com with SMTP id j15-v6so17770718wme.0 for ; Mon, 11 Jun 2018 09:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/YwM2Z09XUQVu/6R87lc86GC7IeE3aIH8FxE1PaAFzo=; b=ajOPLPxoQU54JEtcko0frmzsbtRJo67glMWnzgzlvSWG2bpvIzSJAXl63l1BMlJxf/ oGmJy2F+bBucyz6zfM1kmBDiurZlLxY8Kg8tLmx9sh3b5Sjn+GYD0VmzdU8GdX7T3EWL t7vQKYhPNGJjHdwEC3idOm2wl+1UeQMz0VZI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/YwM2Z09XUQVu/6R87lc86GC7IeE3aIH8FxE1PaAFzo=; b=gyKalppELF+dtpQqVye7XNskHO2QqVKuIH7wJEapSsDHW1lMvPwXvhl+h5GD68Az2N 2UwRkiYMUmu3O1iwXiNFvkqT9XQydRXwQFELlxfVLXNpm0Ha3j2vL0BJQ+Zi2VfGi0ft 8hmJdPldpz3OxSGRgOExC+CjR+5ENXAL8UWZAzGeNVxFo86g3hNWrpuYRswCNkTF8XGl /vpA4t1rMQM37NuaxwGZ3q9ihyt6+tzwLHJ+MLMzM41g8MA9a3l2n8vSvbARtNq2vFQq TXT+8H2GC3/XpWjQ6l6Ygv36IfIgH9560c9ATVcmvaCtN6/2qqy4VpNI/IJx/AfKB0nZ Ktcg== X-Gm-Message-State: APt69E3Tso66yMo1EFt+7SGQ5As4FPYi3rG83mZ16B/TGRoC61PM1tit NN8mNiESYa0Fu2k8ocGr40EaHwnYB3g= X-Received: by 2002:a1c:454f:: with SMTP id s76-v6mr8357650wma.16.1528734305895; Mon, 11 Jun 2018 09:25:05 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id s191-v6sm16460925wmd.27.2018.06.11.09.25.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 09:25:04 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 2/2] efi/fdt: set address/size cells to 2 for empty tree Date: Mon, 11 Jun 2018 17:24:59 +0100 Message-Id: <20180611162459.9178-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180611162459.9178-1-leif.lindholm@linaro.org> References: <20180611162459.9178-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" When booting an arm* system on UEFI with an empty device tree (currently only when hardware description comes from ACPI), we don't currently set default to 1 cell (32 bits). Set both of these properties, to 2 cells (64 bits), to resolve issues with kexec on some platforms. This change corresponds with linux kernel commit ae8a442dfdc4 ("efi/libstub/arm*: Set default address and size cells values for an empty dtb") and ensures booting through grub does not behave differently from booting the stub loader directly. See also https://patchwork.kernel.org/patch/9561201/ Signed-off-by: Leif Lindholm --- grub-core/loader/efi/fdt.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index c0c6800f7..477ef7485 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -29,6 +29,12 @@ static void *loaded_fdt; static void *fdt; +#define FDT_ADDR_CELLS_STRING "#address-cells" +#define FDT_SIZE_CELLS_STRING "#size-cells" +#define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size (sizeof(grub_uint32_t))) + \ + sizeof (FDT_ADDR_CELLS_STRING) + \ + sizeof (FDT_SIZE_CELLS_STRING)) + void * grub_fdt_load (grub_size_t additional_size) { @@ -46,8 +52,14 @@ grub_fdt_load (grub_size_t additional_size) else raw_fdt = grub_efi_get_firmware_fdt(); - size = - raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; + if (raw_fdt) + { + size = grub_fdt_get_totalsize (raw_fdt); + } + else + { + size = GRUB_FDT_EMPTY_TREE_SZ + FDT_ADDR_SIZE_EXTRA; + } size += additional_size; grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); @@ -63,6 +75,8 @@ grub_fdt_load (grub_size_t additional_size) else { grub_fdt_create_empty_tree (fdt, size); + grub_fdt_set_prop32 (fdt, 0, FDT_ADDR_CELLS_STRING, 2); + grub_fdt_set_prop32 (fdt, 0, FDT_SIZE_CELLS_STRING, 2); } return fdt; }