Received: by 10.213.65.68 with SMTP id h4csp2292276imn; Thu, 5 Apr 2018 12:19:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx48fCY/kPzpAGeL/79oqzdRchovtN2wCH+s4BM5wnmfgMccvW7SJkAIjqs9qFrN5hWIXDFDB X-Received: by 2002:a17:902:a589:: with SMTP id az9-v6mr23935478plb.283.1522955952097; Thu, 05 Apr 2018 12:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522955952; cv=none; d=google.com; s=arc-20160816; b=0PT4uGOzi1ZPjUBTZZOIkhSPkl7/0UYWaFhRRmE6rBnLhAUTr0sBOJbA/aPfX58knT P/72E8K4TgCCybSOSapdtl2Po9kmZ9qKsbDTvMUZ3BH9Ttf30XkbPr4KJ5pNTMFgnLwm YgHaq3rvxE6uXJc+tSH6k02wweU5XOyzfoeOMeO3jrjxedcGDPmokP9wKT8shlepupR2 r8rb38rxtH/oc4vHfKz15gHGgr3cr8IaRRCyWZ9i0B6K9oTaWcXbxCHJdd8Cu7T/DJgO Uj8PjLXZno7CAME0tmXP3KJNUuEKuVFdjXKDNuMeXcBQWbM5Xr9YwVQ6tyH42/TaI//k SJow== 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=Jyx6Mp+K3h+Yxit0y9as/4Urayg2QLh4oBQwjL6H+34=; b=vIRVCxWhbcfpChsV/tgz0eyOcUVcO4dGnQ2SU5696F9ygIQkmv3DIPRZvbsqw833IU /hqYGsAx5x/4uUSsVs/YGqwfFxgV9v097gfX4doMjkNeT0XbMjlpczJVo+b4LJaI4dur Gpwf1UZEQjOS1eY/GFtb0pAqvYYpVf2eID1kfxMwabUjAtwnnhF+lmbl+HTBvUVJ/Vch gJnJlZkzHf2U22mgNopgzysaM1XSfPdkXxxRhomP/TPp3dcId7bEp8wCi4JZ6mLzmf69 BNr2Jfbfc7hC8khc+yyh3r0u4C6K5A7YBpYNlKjhcCS5ewZdEBjsKVL7N9uF6HC9W/SA g5tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EjcQ8cj1; 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 3-v6si8769164plv.323.2018.04.05.12.18.56; Thu, 05 Apr 2018 12:19:12 -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=EjcQ8cj1; 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 S1752132AbeDETQ5 (ORCPT + 99 others); Thu, 5 Apr 2018 15:16:57 -0400 Received: from mail-pl0-f51.google.com ([209.85.160.51]:43467 "EHLO mail-pl0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752023AbeDETQy (ORCPT ); Thu, 5 Apr 2018 15:16:54 -0400 Received: by mail-pl0-f51.google.com with SMTP id a39-v6so1216728pla.10; Thu, 05 Apr 2018 12:16:54 -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=Jyx6Mp+K3h+Yxit0y9as/4Urayg2QLh4oBQwjL6H+34=; b=EjcQ8cj1fL5gH0F/t/VrNrYODm5qsZULMprDGkbXzGZad/36mLNpvcaf1YugeV5kqx +MNIyoIW+tkVTedApzVuXGDMplIwx2U0QvSCdSPgDbQhhNIMPx2brguAf8+Dnrq7SXwK 3o4M9VK87vIgZBlBF2DGc9OLSy0Guxicdk2DP8KfBQQeJdSdA9H8ua7Y/fsxg4FsC0LC P2C3cB+EyK4k7AsGW7ahFjjiAOsPkyWoPsDeHw0rcymsivNdqL3/QBKkig0Q6zG2Xee1 9wv3Az+vBPjaABjpIUswP3aKOeAV7qqOL/qwfBpffDtfpcJkdo+HKGacGUk6L/u79GZ8 uDIw== 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=Jyx6Mp+K3h+Yxit0y9as/4Urayg2QLh4oBQwjL6H+34=; b=T3HVdo+BiSVcVOosu4nzfbPib06V8zUkkuwMQ+yVdEfy5Dg0F9f9n416Bl/K+l0sIz FwCLhr3KrCad5GKYhQKlDtZbk8FtH669VrRRIk8UlF7NJftKYrSwllYeU4L2FfIHDFuh NlikVttq/3ZPw8CBxcEfRyQzpD8jRBHc8jlX7LC8tiKPlu/jpu8i6g1WH+enNdH0lYPp b3FHbhmf5fiUbhemK67UUL1eDSZDZXvA+klXSwvUpWGh0LqXgVMyjnBReOxH4tfz3Was NvOwbRZ6MJV6I+pIMN2nbfq3oBgJqikgfwj7LiLa/lHoNocJEClvv0y9pacC1kVn6HZp Ldzw== X-Gm-Message-State: AElRT7GdQ+yQpic5apPrwZya1aYHWzV7hHBHqEZNh7QLSf8tf72j17UW 1H5X0AB13QArjckx1gO0aK8= X-Received: by 2002:a17:902:6e8c:: with SMTP id v12-v6mr23793251plk.24.1522955814093; Thu, 05 Apr 2018 12:16:54 -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 o30sm8021784pgn.8.2018.04.05.12.16.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 12:16:53 -0700 (PDT) Subject: Re: [PATCH v7 2/5] of: change overlay apply input data from unflattened to FDT To: Jan Kiszka , Rob Herring Cc: Pantelis Antoniou , Pantelis Antoniou , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Geert Uytterhoeven , Laurent Pinchart , Jailhouse , Frank Rowand 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> <935d6135-c5db-e5f8-b850-8ef26ce0c0a0@web.de> From: Frank Rowand Message-ID: <69c06530-94df-b67b-4e56-6519275afb45@gmail.com> Date: Thu, 5 Apr 2018 12:16:52 -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: <935d6135-c5db-e5f8-b850-8ef26ce0c0a0@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 On 04/05/18 00:22, Jan Kiszka wrote: > On 2018-04-05 02: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. >> >> The of_overlay_apply() function is still there, but static. We can >> export it again if the need arises. > > That would be the simplest solution from our perspective, but I'm not > sure if that is in the original spirit of this change. For short term out of tree usage, exporting of_overlay_apply() is ok. Yes, for in-tree, exporting it again defeats the attempted process to solve the overlay issues to make them acceptable in main line. >> >> 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. > > And would calling modification functions from that callback be legal at all? It might work in some specific cases, but the result is undefined. > > Jan >