From patchwork Thu Jun 8 11:51:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 772961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wk3g91T26z9s7B for ; Thu, 8 Jun 2017 21:51:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ROZdJkOV"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wk3g90VtGzDqLF for ; Thu, 8 Jun 2017 21:51:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ROZdJkOV"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wk3fv4x7LzDqLk for ; Thu, 8 Jun 2017 21:51:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ROZdJkOV"; dkim-atps=neutral Received: by mail-pg0-x241.google.com with SMTP id a70so4354045pge.0 for ; Thu, 08 Jun 2017 04:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=sKlriuP2xZceaRfzn3Lm7P3Pzt3G5eRKIIciSXxRgcw=; b=ROZdJkOVS65h7KnTpOskSLG0uuQubIYShdgCrmoN0NK7XyDIbiggvpBFKcEQA4ocdp TwgkdtoLaqqVYPFuCTqph/bDlVKZhhwaXzrVoc9H9pj9T5Cl8MtRdtrdsKhnEiyzzuVd J3zXnMLDD+F6eGz0Ph/Ch7I2fSmj1ysmad6fAufXqmCv7SmMlM4HKg97uvbCkWGYACd6 DG4N1bvGHA+oi/1uneagtJnDKGfDT5vMfy4ev4vKcvodXal7ZyDN36qinS8QyLhZXBXV 8YG5B416tj50TFnzv1vLB9Ox36c8jHz9A/rj7qQCBHe9MIau1qkEDk6LeVp8qoKGvDyj dADg== 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; bh=sKlriuP2xZceaRfzn3Lm7P3Pzt3G5eRKIIciSXxRgcw=; b=i0nnt1aOX05E8dKbC9zopoH6YCiuWHvKuJJAWRnbGATMQy0uGk7H3AkWsBaOk4QoRg 6kU/2BuCtpN1hfJL0U3MPhTpf/BoATvhVYyQUxkvYxVNQJiVAyN+A2vu4YcCh8vnZ8kq g18SdJgldpldKH+9o0fHrAa/H8bAjqi93i5dFemec47zFUf/hUx/s68O9iuIgr96FlJz EmNwATuYKgc4IXILh9SJCR8RlWLG1dQfC6u63+PQzg9cxpVXtLCnwNvMEqiW74gka1dV yiUxGH+fYxBHMeRefe8bBreYwAywEvNX4nj9ZMgNEXgqaRVgMk33QR6n5/RV8oSYXS+j aasQ== X-Gm-Message-State: AODbwcBYJe9qX7Ij5BT4inQwvXprjS1VhlR3Suy66mlm8W7DxlO0TQGD wTYjDWmllRJL9lGH X-Received: by 10.84.177.164 with SMTP id x33mr24235031plb.43.1496922693914; Thu, 08 Jun 2017 04:51:33 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id q6sm10514163pfi.129.2017.06.08.04.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 04:51:33 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 8 Jun 2017 21:51:22 +1000 Message-Id: <20170608115122.6978-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [Skiboot] [PATCH] core/fdt: Always add a reserve map X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently we skip adding the reserved ranges block to the generated FDT blob if we are excluding the root node. This can result in a DTB that dtc will barf on because the reserved memory ranges overlap with the start of the dt_struct block. As an example: $ fdtdump broken.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x7f3 (2035) // off_dt_struct: 0x30 <----\ // off_dt_strings: 0x7b8 | this is bad! // off_mem_rsvmap: 0x30 <----/ // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 /memreserve/ 0x100000000 0x300000004; /memreserve/ 0x3300000001 0x169626d2c; /memreserve/ 0x706369652d736c6f 0x7473000000000003; *continues* With this patch: $ fdtdump working.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x803 (2051) // off_dt_struct: 0x40 // off_dt_strings: 0x7c8 // off_mem_rsvmap: 0x30 // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 // 0040: tag: 0x00000001 (FDT_BEGIN_NODE) / { // 0048: tag: 0x00000003 (FDT_PROP) // 07fb: string: phandle // 0054: value phandle = <0x00000001>; *continues* Signed-off-by: Oliver O'Halloran --- core/fdt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/fdt.c b/core/fdt.c index eabbd5411a47..0131c5e21f84 100644 --- a/core/fdt.c +++ b/core/fdt.c @@ -172,6 +172,9 @@ static int __create_dtb(void *fdt, size_t len, fdt_create(fdt, len); if (root == dt_root && !exclusive) create_dtb_reservemap(fdt, root); + else + fdt_finish_reservemap(fdt); + flatten_dt_node(fdt, root, exclusive); save_err(fdt_finish(fdt));