Received: by 10.213.65.68 with SMTP id h4csp2275013imn; Thu, 5 Apr 2018 12:01:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+qcuJSoTV20wOwxB17CiVXBo2OHFqMQRqZUDf/Ujm3ie1pLZ11oG8aIASIk/GJnJ8+W/4e X-Received: by 10.99.152.68 with SMTP id l4mr15290261pgo.75.1522954900561; Thu, 05 Apr 2018 12:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522954900; cv=none; d=google.com; s=arc-20160816; b=yuc/I2ALoyjN+XheDxiSBJ2zjPOLk4EqRhOGr03rYDCjjpuLGmZAe79f3zvVeIvtOm W6K2FTWu7zPqzDDA9ogQfvaZgPf6G6FSBVQIKItWblKlKm6Ly5Kdc9XAgIYs1I1K0duQ Fv6FFXmw6msfM5k57eJkKROYsPN0xmSf6N/Mu9pBuNMOTI+AuCw8WLWCQmgbQBHA2VCH y/1DKti+aGqxMMUl1VvcxKUwni78eU5C9Se30EnnwYUgCc/6UG2fWZ+A6K7qXIKpX0Gp oZzboojOpvri9D93Sr0kQoqh7y4QMl5fuZG06ZymYSQarRdW6EEw2FvA0zEFu0sm/CAJ plvA== 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=fR8JYnp5Wtyl3Vaf15EsKrcIJmDvc+N8JHKprLF2Xew=; b=w1BgvgXJbsNhR6/X2VsGpDSHbbfceApQN3XVbVtC8lVdthPeJdsrjJmI8SazaMYrsS mVvZSunpJO3iGb5qkqnxf9WjNb+8pkFr7fmRiX2enFRqH8qQiXqdW7fWjx3YuF5K22rQ Ixx4xdmH3BrjLw1k0ejCynx9YNvUnHXQAVvqHt8OGZ67hE7+75831G7dNkgumTUTxn+0 g7CkDQypuRmuQRhgFw2G3y+r3zEibpwesYzggfyBs7VFScxBdIJia6uBsI77wjsh7z6P PnMsOe3b40I4oQB7JgpZliKnrR7gbn+aDT9U2f/g/yaCQUcDbwlf1+5NczCSuOLu9R6s m7nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GuZiwbmp; 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 b2si5623291pga.730.2018.04.05.12.01.26; Thu, 05 Apr 2018 12:01:40 -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=GuZiwbmp; 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 S1752249AbeDETAF (ORCPT + 99 others); Thu, 5 Apr 2018 15:00:05 -0400 Received: from mail-pl0-f43.google.com ([209.85.160.43]:42489 "EHLO mail-pl0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751655AbeDETAC (ORCPT ); Thu, 5 Apr 2018 15:00:02 -0400 Received: by mail-pl0-f43.google.com with SMTP id g20-v6so20446232plo.9; Thu, 05 Apr 2018 12:00:01 -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=fR8JYnp5Wtyl3Vaf15EsKrcIJmDvc+N8JHKprLF2Xew=; b=GuZiwbmpd5d1uXK03AKqGfNMpdLnQQf119xSr/wCTfHWfHbUQKRw+ilMffSYgZDIy0 CXvX1a7Y7sIvVZ/puQnN0ZZy0X+w0O5FYKEetpD5AoxBgYeh8unppl3H7iBBcRf5K+Zr ZCfNcfAj5GntKUX7qbrjGtf8jMd2bai/OApwrvcQMTUCcxPjMhjElM1Ox/UaoxgFB5Mp RBr3AiVFHHjutpWdJSO6ASlvdr6VOShlI4eXJ7BRCB09m+H5HK8Zu1eEiK5WNytsRt4t co4l9UAjH7D+FG3qtzVmxOQCEauZIiy52gojtT2zAx6coWjcz6ZVyOlaKpfjUs8YNws6 /6zA== 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=fR8JYnp5Wtyl3Vaf15EsKrcIJmDvc+N8JHKprLF2Xew=; b=BgCwypRJ8jGoIci+EU0k4naZhMONn6fckkMaPCoIwMLRiDR+3FzGsQ6fk4ybdXVdnf meqkJXd2itaDaciHi9p0wcfnxFbZT2C5th4Q45owCF0045T8OFeZgOPnoAthLCeuQlwB ZbS5R7BW96Yz1cJ8mArcLr90cObppI6sF2ROjGkrDN/dPkSTAD13IT0FzPMCxN84uPnA +kNKM2571kDvdlhJahvMoNVI1DDWJTnC75oVFl/S22+mcywAe7DL/S9kUL6lUeCZCLMD 4e1M6un7XEmqXtAYL6SUacWbBVeOVMx/ne/yu6v9d2HDUgRLzN6LPfjSOT8rAPLwBWRC YidA== X-Gm-Message-State: AElRT7GfelCyvEUNc/eEnFjRPvqH0N6z6nmRAz3t8UbScAXUXpWaonGL f3KFPp5/ZjR0r8XRq69lgoDyU3il X-Received: by 2002:a17:902:28c3:: with SMTP id f61-v6mr24088714plb.114.1522954801083; Thu, 05 Apr 2018 12:00:01 -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 p3sm13790501pga.45.2018.04.05.11.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 12:00:00 -0700 (PDT) Subject: Re: [PATCH v7 2/5] of: change overlay apply input data from unflattened to FDT To: Jan Kiszka , Rob Herring , pantelis.antoniou@konsulko.com, Pantelis Antoniou Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, geert@linux-m68k.org, laurent.pinchart+renesas@ideasonboard.com, 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: <7bbf615b-3cdd-6bb4-6918-33e48de4225d@gmail.com> Date: Thu, 5 Apr 2018 11:59:59 -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: <09e3db63-cbf9-52a2-ee77-520979f17fea@web.de> 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 Hi Jan, On 04/04/18 15:35, 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? Thank you for the pointer to the driver - that makes it much easier to understand the use case and consider solutions. If you can make the changes directly on the FDT instead of on the expanded devicetree, then you could move to the new API. Looking at the driver, I see one potential issue with that approach. The property "interrupt-map" is added directly to the changeset instead of being an existing property in the overlay. Is it possible to have this property in the overlay when needed? I'll also reply to other comments in this thread. -Frank > > Thanks, > Jan > > [1] > https://github.com/siemens/jailhouse/blob/11ef401a9064644bf7faf28e35c97f27ececd81d/driver/pci.c#L280 > . >