From patchwork Tue Sep 10 13:51:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 19902 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EE06125A72 for ; Tue, 10 Sep 2013 13:51:51 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id u18sf9008653qcx.10 for ; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=1ydYkeC1U3w2gIscbHnDgBOl3Kv/17tMvP5YHbWIf+k=; b=k1ABhRvvrJ8Op3cM6D1CxIsRvlS0AuXy/UOGXNJjkpVxnoxwIA8aufZoEu1qHZF8i9 oouGCccVcVW1IgpHUXkcUbPwUmufHqD3ulDq2Uj/QnpFyGa5Wn/9LfGVUsO1FZP/vPHO V9atpj5+1u0M1ZnRcJU1pNm6VNb4tAbbyjJI940JRNzZWKCnpLP00eOAgYU5Mj56mv6J fWgir28z6/qfUmg4mCbVSltE//MRG83Q8vewBTT2HiqJ8JDpDJeJY8eBW+i+YUb522Yt 16X4lbk+T5em2IZQ06h177drCxI+FjByv5MlHcCTHYJ69tFnm+F+qbvFISc5BSlPM/cP 471w== X-Received: by 10.236.24.195 with SMTP id x43mr8414104yhx.3.1378821111413; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.100 with SMTP id j4ls1790648qew.29.gmail; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) X-Received: by 10.52.170.232 with SMTP id ap8mr171797vdc.40.1378821111196; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id dp7si4449564ved.149.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 06:51:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.50; Received: by mail-vb0-f50.google.com with SMTP id x14so5214934vbb.9 for ; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) X-Gm-Message-State: ALoCoQmq/d/dyA1WPQgwp8Gd5XelihId2U/6Ka298FET3JC+STN3+oHmh2sjbnDZEnxKWlNvhZlX X-Received: by 10.52.230.102 with SMTP id sx6mr19242919vdc.15.1378821111081; Tue, 10 Sep 2013 06:51:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp2271vcz; Tue, 10 Sep 2013 06:51:50 -0700 (PDT) X-Received: by 10.180.11.239 with SMTP id t15mr13226900wib.4.1378821109677; Tue, 10 Sep 2013 06:51:49 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id et7si7023236wjd.90.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 10 Sep 2013 06:51:49 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VJOM6-0001yS-I9; Tue, 10 Sep 2013 14:51:46 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Peter Crosthwaite , Alexander Graf Subject: [PATCH] device_tree.c: Terminate the empty reservemap in create_device_tree() Date: Tue, 10 Sep 2013 14:51:46 +0100 Message-Id: <1378821106-7563-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Device trees created with create_device_tree() may not have any entries in their reservemap, because the FDT API requires that the reservemap is completed before any FDT nodes are added, and create_device_tree() itself creates a node. However we were not calling fdt_finish_reservemap(), which meant that there was no terminator in the reservemap list and whatever happened to be at the start of the FDT data section would end up being interpreted as reservemap entries. Avoid this by calling fdt_finish_reservemap() to add the terminator. Signed-off-by: Peter Maydell Acked-by: Alexander Graf --- On ARM this manifested as a DTB with /memreserve/ 0x0000000100000000 0x0000000200000009; and my mach-virt test kernel wasn't booting as a result. device_tree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/device_tree.c b/device_tree.c index ffec99a..391da8c 100644 --- a/device_tree.c +++ b/device_tree.c @@ -41,6 +41,10 @@ void *create_device_tree(int *sizep) if (ret < 0) { goto fail; } + ret = fdt_finish_reservemap(fdt); + if (ret < 0) { + goto fail; + } ret = fdt_begin_node(fdt, ""); if (ret < 0) { goto fail;