Received: by 10.213.65.68 with SMTP id h4csp2289871imn; Thu, 5 Apr 2018 12:16:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx48AP/tfWWfSxkxUU54h8zsJzttif5hZmw5TRM4/s2r7bsLLX7IvMG/K1qa0KtvNQjEV5kXH X-Received: by 10.99.65.6 with SMTP id o6mr15526590pga.57.1522955784028; Thu, 05 Apr 2018 12:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522955783; cv=none; d=google.com; s=arc-20160816; b=YVsMIdekaG3sM/yBD7/KCU5epwt37llooSt/gUzhq5C3OUcRrWC+eZ1GCM0ldFNskr wYqjNlM/Cic4fNmw0fbiKO1jASn000NeNAD5hjFWckxFFhj/b9sVcZPgY0knrjqpWkBh khmVUKyzuC8x9C2xhS3SQ+tD1S2u/GwKIQt5kDJxK3fIkRrvYiDD5t1ljXM5B1l3EJcU h/r5K2RHjB5LTn6n/4h/Thaa1LwWcJxywieN8ga3WVqOBeSPXcsSXKKsChCf1qpcqQye zSzeW5M0InKLDbgnHP+mioU8LUW+R8oavyClCX4Wa7RsQ1pMNK//62zaYXt6Z1y2Zksm G43g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=e0uhu4o6R8RVTgLLo2W+sEvVq7d2H8bO5YFYPxJQQs4=; b=m8EGvJzR5CBUVoQb7mMxCmfO5W2r0yqll6/InR9HbnP30uKngs3ertGuqCo95lFJsr b6eGKD680xE2H25siEmXhEn8z2y+aR/0O3usR+V5cHDmPY0Yuad2c9SEFZdsGvvSJkXz OcdYz1TLH7RMVAbp4VEma/ZRWlCxjHTJO7WS0nWyo6v2cUlPlt+4HeD1UYl90yLl1GkJ Z/kwtI0/fOa13RYmIQDkx7wvmLmFMYuetDsaIKTdFkKrRhK8qkEASJ4as1Yai3AdCBtF 40DYlAfFPxDujBYMFyGjp9VTygwn09q4A59jW/eZfOhWrb3cFM+mEieXwACGLkJkHcNt ro2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kk8FrajX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l61-v6si6715188plb.568.2018.04.05.12.16.08; Thu, 05 Apr 2018 12:16:23 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kk8FrajX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbeDETNs (ORCPT + 99 others); Thu, 5 Apr 2018 15:13:48 -0400 Received: from mail-pl0-f53.google.com ([209.85.160.53]:40429 "EHLO mail-pl0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbeDETNq (ORCPT ); Thu, 5 Apr 2018 15:13:46 -0400 Received: by mail-pl0-f53.google.com with SMTP id x4-v6so20513704pln.7; Thu, 05 Apr 2018 12:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=e0uhu4o6R8RVTgLLo2W+sEvVq7d2H8bO5YFYPxJQQs4=; b=kk8FrajXgw8u79QTbTXAFhZWboie6Ll7GKIjX4GTzVP1Y9TuUDPGX4pTxhmcetOzMI lj3MVh5Wc1Hc6TOS1QBJHTG4o9Ene9NRMpWH/1wNel+iqPqJWwJTi7VS0WZ+hU7SblRy 4w7RW0g539hasEoL+8kWDQJaG/t+NeaIj2xHdntDG9YcfztP62gOdrPMxSt3BtJM56g1 VCv3Yvkwuzxf1NGMFN/l6U9m0XWBQeF+PaJijKh4Phn8hxRSsYHrzldekw3z4fXmzcs+ I7GumEKEv/jJ89LUh8JQXr6hOb+5dRcfxddQqozbvtFVpUF5Sds8/QVWrxSGNCRN0uIv YgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=e0uhu4o6R8RVTgLLo2W+sEvVq7d2H8bO5YFYPxJQQs4=; b=JZ34SyaMpt3NLa5N1n2oh6spsI6JXmrHUqy8KGSpi99lF4eZcyAJsJALqB9s2nkU7a el9j7pBkvpHfBzR5eImloyZ+E0dA9S/i7eXGqdyyaxxCEocn0U2UJR9rfcLvXFr9foWh aQB3ZPtJl5UTKF6YeBMHQkryrfnelnAbij4tVWaVEu55dJLwMHS77IO5Qjp+J4fttBCh ZorLzL3+SXofkASCfnEl4wJPO8jOF+QOQECfVn2B9XG6KJSaY0OHGbdtXNCvHnQhdKMw Sm5ZVDyPmKkylU9NZXm22IB5R61MK2W6l0invQBSwyz00hFu9iZzK0JFl4fq7zdPkuOI iZng== X-Gm-Message-State: ALQs6tDU4OHfOMgN8Zkl53nLyZMf/mM1AiyR2UG2QJbtpg0oTjWSg5L/ 1hWwG5V43AZodPduU5iNhpA= X-Received: by 10.167.134.12 with SMTP id p12mr2532165pfn.183.1522955625840; Thu, 05 Apr 2018 12:13:45 -0700 (PDT) Received: from [192.168.1.70] (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id e82sm16299999pfh.115.2018.04.05.12.13.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 12:13:45 -0700 (PDT) Subject: Re: [PATCH v7 2/5] of: change overlay apply input data from unflattened to FDT To: Rob Herring , Jan Kiszka Cc: Pantelis Antoniou , Pantelis Antoniou , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Geert Uytterhoeven , Laurent Pinchart , Jailhouse 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: Frank Rowand Message-ID: Date: Thu, 5 Apr 2018 12:13:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/18 17:55, Rob Herring wrote: > 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. I don't think it will work either. The drivers won't be probed if the nodes are disabled. > The of_overlay_apply() function is still there, but static. We can > export it again if the need arises. I really don't want to export it again. sigh. > 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. This callback is on my list of yet more ways that pointers into the (overlay) FDT are exposed. Which means another solution to the underlying problem (which was an FPGA problem) needs to be created. I'd prefer that use of this mechanism not be expanded in the mean time. Even if that were not the case, using the OF_OVERLAY_PRE_APPLY notifier to modify the tree is problematic because the notifier(s) is called after the overlay FDT is in final form -Frank > > Rob > . >