Received: by 10.213.65.68 with SMTP id h4csp1350584imn; Wed, 4 Apr 2018 17:57:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx48IO9MQAXxdIhzlixWz8+jrKAXLc9s70SMnR7GetPxovBfC9cu7W7tjiBizdX6HYUZztvyS X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr20752221pla.150.1522889839662; Wed, 04 Apr 2018 17:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522889839; cv=none; d=google.com; s=arc-20160816; b=sZB+5XF5tMwJz1hn/yEarOc+cdt59KhI+7BhVhQC+LngzBcVi8pVcCny0k6xTcS5j+ d/bsg9AzARniBFYBREmbdToe2TQ64K3gV6V4eeI/gRRS5hCngwegKmlWaGuC+3TKQs12 ptBLQsCadyT4WqeBRpTKEJp9QL4AoEDHawVE41odUjbWZzNul2Bzo4zzoSLp/Xd7ULj+ 1vTKDVtscOLKIu9C4UsjG/TwL2jdECD7MCRWtkBWyuqbERRlZ5lXZoPrTW1NNMbxva/k orPdZuYEEcP7+9JxkHfy9ivaJE+MB5Qn29rqi5M9+zi5TeTpbDGBB1picTdvjfqdqNqk jMAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=WyeG2DUXZp0rca35j2X6A9KKUG9IcPrL5C7GA5n/kMs=; b=kDIoR15ZhwvCTcGeUGJe2xwmZ8rXcfPylc+OU2lxXf27r9O+XlpwtXlsfsJT5YAluk 6LLiIrtJZZMp06bEIpdUMcftD2iNDcCLfgzjNKcqG7AwH0DA01dvGVdcGNwrQpNKUdhR h5K0RtQ+Uj1H1oeV5TFDE6TH1YfbFi22iXoGvRpZ7eZx1n/PlOjDFVwpHynk0PHUVgjo rMy6F4MyJCNxh1Bd1kSmBO0AA1E7iNjk2i56oyWxvlk/UgPe0zgI5MBMX8YHoZILcBIv p9UFHXoNHYAPQdOtJBOwMV02adznNnOgHja1klqyELnHp9iQY9Z55AQZYDlBfX3vejhH nung== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g190si3668770pgc.741.2018.04.04.17.57.05; Wed, 04 Apr 2018 17:57:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbeDEA4B (ORCPT + 99 others); Wed, 4 Apr 2018 20:56:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:46206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbeDEAz7 (ORCPT ); Wed, 4 Apr 2018 20:55:59 -0400 Received: from mail-qk0-f175.google.com (mail-qk0-f175.google.com [209.85.220.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5768217DF; Thu, 5 Apr 2018 00:55:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5768217DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=robh+dt@kernel.org Received: by mail-qk0-f175.google.com with SMTP id w6so24650931qkb.4; Wed, 04 Apr 2018 17:55:58 -0700 (PDT) X-Gm-Message-State: ALQs6tCx6jB0zHidHV8DOiCWJM7MvaCqjVmj21+DJOki3juic++UwHpP lViYTwlyTsFhjDORr1O3mJ/rycaLqbKRIv7oZQ== X-Received: by 10.55.116.71 with SMTP id p68mr26717632qkc.29.1522889756941; Wed, 04 Apr 2018 17:55:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.213.166 with HTTP; Wed, 4 Apr 2018 17:55:36 -0700 (PDT) In-Reply-To: <09e3db63-cbf9-52a2-ee77-520979f17fea@web.de> References: <1520122673-11003-1-git-send-email-frowand.list@gmail.com> <1520122673-11003-3-git-send-email-frowand.list@gmail.com> <09e3db63-cbf9-52a2-ee77-520979f17fea@web.de> From: Rob Herring Date: Wed, 4 Apr 2018 19:55:36 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 2/5] of: change overlay apply input data from unflattened to FDT To: Jan Kiszka Cc: Frank Rowand , Pantelis Antoniou , Pantelis Antoniou , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Geert Uytterhoeven , Laurent Pinchart , Jailhouse Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 4, 2018 at 5:35 PM, Jan Kiszka wrote: > Hi Frank, > > On 2018-03-04 01:17, frowand.list@gmail.com wrote: >> From: Frank Rowand >> >> Move duplicating and unflattening of an overlay flattened devicetree >> (FDT) into the overlay application code. To accomplish this, >> of_overlay_apply() is replaced by of_overlay_fdt_apply(). >> >> The copy of the FDT (aka "duplicate FDT") now belongs to devicetree >> code, which is thus responsible for freeing the duplicate FDT. The >> caller of of_overlay_fdt_apply() remains responsible for freeing the >> original FDT. >> >> The unflattened devicetree now belongs to devicetree code, which is >> thus responsible for freeing the unflattened devicetree. >> >> These ownership changes prevent early freeing of the duplicated FDT >> or the unflattened devicetree, which could result in use after free >> errors. >> >> of_overlay_fdt_apply() is a private function for the anticipated >> overlay loader. > > We are using of_fdt_unflatten_tree + of_overlay_apply in the > (out-of-tree) Jailhouse loader driver in order to register a virtual > device during hypervisor activation with Linux. The DT overlay is > created from a a template but modified prior to application to account > for runtime-specific parameters. See [1] for the current implementation. > > I'm now wondering how to model that scenario best with the new API. > Given that the loader lost ownership of the unflattened tree but the > modification API exist only for the that DT state, I'm not yet seeing a > clear solution. Should we apply the template in disabled form (status = > "disabled"), modify it, and then activate it while it is already applied? No. I don't think that will work. The of_overlay_apply() function is still there, but static. We can export it again if the need arises. Another option is there is a notifier callback OF_OVERLAY_PRE_APPLY, but I'm not sure we want to make that be the normal interface to make modifications. Rob