Received: by 10.213.65.68 with SMTP id h4csp472674imn; Sat, 7 Apr 2018 02:54:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+vorVnwwe3OTX94dm14T/+liY5oNyy8h5Gs0ycQXEAStj7oq722+J8LyytW4fXKB/NAT0/ X-Received: by 10.101.96.47 with SMTP id p15mr19875942pgu.430.1523094884930; Sat, 07 Apr 2018 02:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523094884; cv=none; d=google.com; s=arc-20160816; b=v02/s5Y7tKj6uId7VfNPoOkbCDL6uvP2YTx34M1UGGzrIYg3hCadluz9Id/DXYOOX2 /wZfKpJr26wz55fRRzNmVFayVgNeOQvSWYs+uey/geY1juCXq9A/Stb6GuUE2fCl9gqn yK5Olzie38/V9MsyKSmdeue9Yqh1uuCoS/IKppOSS/WzYXSAyWLUB7krS2GbIsupVZR8 fDKDPggMLloCh8Foy6xFj0RgiV9J+MzuwpJCFgo4XhyjgPMXe/Xo/shMd71nu2UNjObn XCa6i/EFhdUUJucl5wMzxBfxHLyRh5D6VOdTD7SfPUrl5vq/x+n8cozWCV/isKN6GtDf oD7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=UnDrxOe4mHuLAT03r09uITWAaSV9xrgYglf+mLPN+eM=; b=TogieiwvVNJDreyuZkjN/+iNnNToHG7e3a4ew1yEROoAd9prBS5gVrcfUBnxWP2rCY kwsZy9xl2+JwgP98tSy4i+l4Na/9mAuNp+rMZdZba8INtbEDZv7wKYvCiG3uNtH3ZtII 7nWHCZdjBahkHo4fuYVws7AQcFSITXyfcTwR14Y54GZZRVVauOfbLkcN8oDgvhoOYQ+s CLteFAdVI/M7TawaM0DoFz7izc+353zTaK4S9x0pFw+qgmGkUE9I2G3K+s2lDr7mscOb mL68/cumaKnv81U0ryMoRglx+uezGiWhtxPV7BlCb/GsRBDd7Fk9Dd5RPTTshhH8exQi wKvA== 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 a17si5866741pff.43.2018.04.07.02.54.08; Sat, 07 Apr 2018 02:54:44 -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 S1751402AbeDGJv1 (ORCPT + 99 others); Sat, 7 Apr 2018 05:51:27 -0400 Received: from bmailout2.hostsharing.net ([83.223.90.240]:52195 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbeDGJvZ (ORCPT ); Sat, 7 Apr 2018 05:51:25 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id 95AA32800A287; Sat, 7 Apr 2018 11:51:22 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 4206610C9F; Sat, 7 Apr 2018 11:51:22 +0200 (CEST) Date: Sat, 7 Apr 2018 11:51:22 +0200 From: Lukas Wunner To: "Luis R. Rodriguez" , Peter Jones , Ard Biesheuvel Cc: Hans de Goede , Greg Kroah-Hartman , Thomas Gleixner , Kalle Valo , Arend Van Spriel , Ingo Molnar , "H . Peter Anvin" , linux-kernel@vger.kernel.org, Dave Olsthoorn , x86@kernel.org, linux-efi@vger.kernel.org, Will Deacon , Andy Lutomirski , Matt Fleming , David Howells , Mimi Zohar , Josh Triplett , Matthew Garrett , One Thousand Gnomes , Linus Torvalds , dmitry.torokhov@gmail.com, mfuzzey@parkeon.com, keescook@chromium.org, nbroeking@me.com, bjorn.andersson@linaro.org, Torsten Duwe Subject: Re: [PATCH 2/2] efi: Add embedded peripheral firmware support Message-ID: <20180407095122.GA21479@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180406141642.23xfaub52gv3zpio@redhat.com> <20180406140832.GF30543@wotan.suse.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 06, 2018 at 02:08:32PM +0000, Luis R. Rodriguez wrote: > How do you get the GUIDs for each driver BTW? They're used as filenames when extracting a Firmware Volume with UEFIExtract. E.g. let's say I'm looking for the EFI driver containing the UCS-2 string "ThunderboltDROM" in the MacBookPro9,1 Firmware Volume: $ UEFIExtract MBP91_00D3_B0C_LOCKED.scap $ grep -rl T.h.u.n.d.e.r.b.o.l.t.D.R.O.M MBP91_00D3_B0C_LOCKED.scap.dump MBP91_00D3_B0C_LOCKED.scap.dump/0 UEFI image/0 7A9354D9-0468-444A-81CE-0BF617D890DF/4 283FA2EE-532C-484D-9383-9F93B36F0B7E/0 7A9354D9-0468-444A-81CE-0BF617D890DF/0 77AD7FDB-DF2A-4302-8898-C72E4CDBD0F4/0 Compressed section/0 FC1BCDB0-7D31-49AA-936A-A4600D9DD083/0 Volume image section/0 7A9354D9-0468-444A-81CE-0BF617D890DF/97 9D1A8B60-6CB0-11DE-8E91-0002A5D5C51B/0 Compressed section/0 FC1BCDB0-7D31-49AA-936A-A4600D9DD083/0 PE32 image section/body.bin That file can then be examined with a hex editor, disassembler, etc. Since Hans knows the 8 byte signature of the file he's looking for, he'd just use: $ grep -rl '\x01\x23\x34\x56\x78\x9a\xbc\xde' ... (The \x syntax works with BSD grep shipping with macOS, but not with GNU grep. pcregrep should work, or grep -P, though the latter has been unreliable for me.) Pretty trivial obviously, the problem is how do you get the Firmware Volume? Apple ships firmware blobs for all supported machines as part of their OS updates, but if the vendor never provides updates (as Hans wrote), your only chance is to dump the ROM. On Macs the ROM is at physical address 0xffe00000. The rEFIt bootloader contains a "fvdump" tool which can be used to dump the Firmware Volume at this address to the ESP: https://github.com/yep/refit/blob/master/refit/dumpfv/dumpfv.c The tool dumps only 2 MByte, but contempary Macs use considerably larger firmware blobs (8 MByte+). A quick Google search turns up these alternative addresses where the ROM may be located: https://github.com/tianocore/edk2/blob/master/OvmfPkg/README "The base address for the 1MB image in QEMU physical memory is 0xfff00000. The base address for the 2MB image is 0xffe00000. The base address for the 4MB image is 0xffc00000." > Otherwise it would be wise to provide a technical reason for why > we'd choose one custom mechanism which would only serve a few tablets > over a mechanism which could serve more devices. An advantage of the approach I'm suggesting is that it also catches firmware even if the EFI driver wasn't loaded. There may even be firmware for devices that aren't present, vendors ship lots of surprising stuff on Firmware Volumes. (I've found a FireWire driver on the 12" MacBook8,1 volume, even though the machine has neither a FireWire port, nor a Thunderbolt port that you could connect a FireWire adapter to. They were probably just too lazy to constrain the firmware contents to what's actually needed on a specific machine.) On Fri, Apr 06, 2018 at 10:16:44AM -0400, Peter Jones wrote: > That said, EFI_FIRMWARE_VOLUME_PROTOCOL is part of the > PI spec, not the UEFI spec. It's not required in order to implement UEFI, > and some implementations don't use it. Even when the implementation > does include PI, there's no guarantee PI protocols are exposed after the > "End of DXE" event (though edk2 will expose this, I think). Thanks for pointing that out, I wasn't aware of it. On Fri, Apr 06, 2018 at 04:28:49PM +0200, Ard Biesheuvel wrote: > > EFI_FIRMWARE_VOLUME_PROTOCOL is not part of the UEFI spec but > > of the PI spec, and so we will be adding dependencies on > > implementation details of the firmware. I am aware we may already have > > done so for the Apple properties support > > ... or maybe not: I thought Lukas alluded to that in this thread, but > I can't actually find any traces of that in the code so I must have > misunderstood. Retrieval of Apple device properties is done using a custom Apple protocol, it doesn't involve the EFI_FIRMWARE_VOLUME_PROTOCOL. What I meant to say is, the EFI stub already stashes PCI ROMs and Apple device properties in setup_data payloads for consumption by the kernel proper, so extending that pattern to retrieval of device firmware (using EFI_FIRMWARE_VOLUME_PROTOCOL) seems kind of natural. Thanks, Lukas