Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3240607imm; Sun, 13 May 2018 07:11:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokwSk7W4ylxRWEqhB0KkH3riYmzdWFMf0L4GmNzkYIkE0UnlLHtYqxuk78V0JWVpKuxTLv X-Received: by 2002:a63:ac1a:: with SMTP id v26-v6mr5573341pge.105.1526220713468; Sun, 13 May 2018 07:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526220713; cv=none; d=google.com; s=arc-20160816; b=AXthMkCsNyBvExbabHk0hi3JFc2vjYYTh75ymr2NnF2gVDAduZRmk1rNRXQvf371wD 0GiPZQ72OAH7wtYEz/q1JuLKgZ2jZmWryoDeSJcmpv5L+uvs0BaPAGZLdMzVsnn5RlqF M2FUKZyS6A4PJhNmVYnnUw132UgSPYqnvr5KPAMa2fKNtT9h989EeigEJwdxA4f4m0A5 gwoaP/OKxbHVSBJ4dAjJ6/F4Zllk/nsGCShr/Gad6tYMeacB28CnVBtXRZpOt80Wz3eQ 6/bEo9a9Ay1pisjXtF+VZbkwYffhQouAdOnuemdcsQutsLZz9Zd3KyGzj0/he3d/Y+M3 MdcA== 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:arc-authentication-results; bh=tx17i+uLysWPPJcKVqgV1vO+uP4Q3yHX3OLXFaShMT4=; b=G9G6DOnbsIVvasx3N4xM/IRjE+FpRqxoczTspQpUFxrVFFGNrHGv3hllpMt1hKWMWm Q3uNaxSyZfHzRvrEVmQg+VJJrfCINdm0i9VZoEgNM0sktBqn3Erg1q0MxIQGCU4gd14S TefEy3W6xGYbgpk/dpN9AGV3ViKkDeulgc4SheVOPBBWLuZzGa+S/1CUklZRxg2JLc4i rM3aPG1zA57pzZGYWOp80cxeD+H1t/0GdRq7Jw2A+xgEhPQCw8n2Xelonv+EJblQ+T+a G/eeG+eBmooV9/vQCDV4rexLX5LIDOhJHpBR75ZYtEHyF2XFPnLfYs4EA1eh8UQU58Zs c6xQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a68-v6si7623355pli.158.2018.05.13.07.11.38; Sun, 13 May 2018 07:11:53 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751690AbeEMOKU (ORCPT + 99 others); Sun, 13 May 2018 10:10:20 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:37709 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbeEMOKR (ORCPT ); Sun, 13 May 2018 10:10:17 -0400 Received: by mail-wm0-f46.google.com with SMTP id l1-v6so10653565wmb.2 for ; Sun, 13 May 2018 07:10:17 -0700 (PDT) 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=tx17i+uLysWPPJcKVqgV1vO+uP4Q3yHX3OLXFaShMT4=; b=KXQxIDjKEDgGY0hxEKBhhNUDgGx/ceHTjSCwOufkDhb/5OQNW686LKRFMcsMB4/HML MGmNK4BTi6cQdoAryq57j99gzeMw8LSeelTgYeUjcmHsuASIjQTC73rD0LyYWjOPVJsl Db2YgWe3osVq/olbwAMOC7+DzkNj4ZRiWFJfwusNW3xkpc2lOvV7o+jc1wT6Gnu8wEC0 et5LNmD7TtRr3IdHIvPpNYkupJzOlGrfOZ0RwfmZv5FFt3ou/Mn1Cd3LIQPZLhxuvyAF ixmh28BKMWV1CZCeqvSlM/IHP+M0GEgXPB5tkDVhwdNHII1LzrPFUZrkFtu9QAsmhYn7 8FfA== X-Gm-Message-State: ALKqPwf/sEsX2Tgpg4daQPmO6z14bilA3P6sw26ER14J97Yh/dpThgua t3LIc6d9RymH+NU9tgxjG52KcsPx23g= X-Received: by 2002:a1c:8350:: with SMTP id f77-v6mr3054833wmd.1.1526220616163; Sun, 13 May 2018 07:10:16 -0700 (PDT) Received: from localhost.localdomain ([109.144.219.116]) by smtp.gmail.com with ESMTPSA id j76-v6sm7966491wmf.33.2018.05.13.07.10.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 May 2018 07:10:15 -0700 (PDT) Subject: Re: [PATCH v5 2/5] efi: Add embedded peripheral firmware support To: "Luis R. Rodriguez" , Ard Biesheuvel , David Howells , Andy Lutomirski , Martijn Coenen , Andy Gross , David Brown , Bjorn Andersson , Matt Fleming Cc: Greg Kroah-Hartman , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Jones , Dave Olsthoorn , Will Deacon , andresx7@gmail.com, Mimi Zohar , Josh Triplett , Dmitry Torokhov , Martin Fuzzey , Kalle Valo , Arend Van Spriel , Linus Torvalds , Nicolas Broeking , Torsten Duwe , Kees Cook , the arch/x86 maintainers , linux-efi@vger.kernel.org, Linux Kernel Mailing List References: <20180429093558.5411-1-hdegoede@redhat.com> <20180429093558.5411-3-hdegoede@redhat.com> <20180503232920.GF27853@wotan.suse.de> <20180508171206.GF27853@wotan.suse.de> From: Hans de Goede Message-ID: Date: Sun, 13 May 2018 15:10:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180508171206.GF27853@wotan.suse.de> Content-Type: text/plain; charset=utf-8; format=flowed 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, On 05/08/2018 06:12 PM, Luis R. Rodriguez wrote: > On Fri, May 04, 2018 at 07:54:28AM +0200, Ard Biesheuvel wrote: >> On 4 May 2018 at 01:29, Luis R. Rodriguez wrote: >>> On Sun, Apr 29, 2018 at 11:35:55AM +0200, Hans de Goede wrote: >> [...] >>>> diff --git a/Documentation/driver-api/firmware/request_firmware.rst b/Documentation/driver-api/firmware/request_firmware.rst >>>> index c8bddbdcfd10..560dfed76e38 100644 >>>> --- a/Documentation/driver-api/firmware/request_firmware.rst >>>> +++ b/Documentation/driver-api/firmware/request_firmware.rst >>>> @@ -73,3 +73,69 @@ If something went wrong firmware_request() returns non-zero and fw_entry >>>> is set to NULL. Once your driver is done with processing the firmware it >>>> can call call firmware_release(fw_entry) to release the firmware image >>>> and any related resource. >>>> + >>>> +EFI embedded firmware support >>>> +============================= >>> >>> This is a new fallback mechanism, please see: >>> >>> Documentation/driver-api/firmware/fallback-mechanisms.rst >>> >>> Refer to the section "Types of fallback mechanisms", augument the list there >>> and then move the section "Firmware sysfs loading facility" to a new file, and >>> then add a new file for your own. >>> >>>> + >>>> +On some devices the system's EFI code / ROM may contain an embedded copy >>>> +of firmware for some of the system's integrated peripheral devices and >>>> +the peripheral's Linux device-driver needs to access this firmware. >>> >>> You in no way indicate this is a just an invented scheme, a custom solution and >>> nothing standard. I realize Ard criticized that the EFI Firmware Volume Protocol >>> is not part of the UEFI spec -- however it is a bit more widely used right? >>> Why can't Linux support it instead? >>> >> >> Most implementations of UEFI are based on PI, > > That seems to be the UEFI Platform Initialization specification: > > http://www.uefi.org/sites/default/files/resources/PI_Spec_1_6.pdf > >> and so it is likely that >> the protocols are available. However, the PI spec does not cover >> firmware blobs, > > Indeed, I cannot find anything about it on the PI Spec, but I *can* easily > find a few documents referring to the Firmware Volume Protocol: > > http://wiki.phoenix.com/wiki/index.php/EFI_FIRMWARE_VOLUME_PROTOCOL > > But this has no references at all... > > I see stupid patents over some of this and authentication mechanisms for it: > > https://patents.google.com/patent/US20170098084 > >> and so it is undefined whether such blobs are self >> contained (i.e., in separate files in the firmware volume), statically >> linked into the driver or maybe even encrypted or otherwise >> encapsulated, and the actual loadable image only lives in memory. > > Got it, thanks this helps! There are two things then: > > 1) The "EFI Firmware Volume Protocol" ("FV" for short in your descriptions > below), and whether to support it or not in the future and recommend it > for future use cases. > > b) Han's EFI scraper to help support 2 drivers, and whether or not to > recommend it for future use cases. > >> Hans's case is the second one, i.e., the firmware is at an arbitrary >> offset in the driver image. Using the FV protocol in this case would >> result in a mix of both approaches: look up the driver file by GUID >> [which could change btw between different versions of the system >> firmware, although this is unlikely] and then still use the prefix/crc >> based approach to sift through the image itself. > > Got it. And to be clear its a reversed engineered solution to what > two vendors decided to do. > >> But my main objection is simply that from the UEFI forum point of >> view, there is a clear distinction between the OS visible interfaces >> in the UEFI spec and the internal interfaces in the PI spec (which for >> instance are not subject to the same rules when it comes to backward >> compatibility), and so I think we should not depend on PI at all. > > Ah I see. > >> This >> is all the more important considering that we are trying to encourage >> the creation of other implementations of UEFI that are not based on PI >> (e.g., uboot for arm64 implements the required UEFI interfaces for >> booting the kernel via GRUB), and adding dependencies on PI protocols >> makes that a moving target. > > Got it! > >> So in my view, we either take a ad-hoc approach which works for the >> few platforms we expect to support, in which case Hans's approach is >> sufficient, > > Modulo it needs some work for ARM as it only works for x86 right now ;) > >> or we architect it properly, in which case we shouldn't >> depend on PI because it does not belong in a properly architected >> OS<->firmware exchange. > > OK, it sounds to me like we have room to then implement our own de-facto > standard for letting vendors stuff firmware into EFI as we in the Linux > community see fit. > > We can start out by supporting existing drivers, but also consider customizing > this in the future for our own needs, so long as we document it and set > expectations well. > > So we need to support what Hans is implementing for two reasons then: > > a) The FV Protocol cannot be used to support the two drivers he's > trying to provide support for -- I believe Hans tried and it didn't work, > Hans, correct me if I'm wrong? > > b) The FV Protocol relies on *internal* interfaces of PI spec, and since: > 1) The PI spec does not define firmware at all > 2) The internal interfaces of PI Spec does not guarantee any backward > compatibility > Any implementation details in FV may be subject to change, and may vary > system to system. Supporting the FV Protocol would be difficult as it > purposely ambiguous. > > If accurate, Hans, can you capture this in your documentation somehow? Yes I've added some extra doc to this extend for the next version of the patchset. Regards, Hans