Received: by 10.213.65.68 with SMTP id h4csp3863273imn; Tue, 3 Apr 2018 12:00:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4++cnp1z5w5L/r4YuFublhVHnwQMvRslv4Ro+dQVpckUSA+sLRRAuq5VxBmsT6tav29GAg1 X-Received: by 2002:a17:902:6184:: with SMTP id u4-v6mr15728333plj.390.1522782038821; Tue, 03 Apr 2018 12:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522782038; cv=none; d=google.com; s=arc-20160816; b=eBlIM87MoxnT0rEstQvdgNYqTQbCz+9hpKNzXTAdrrekPzNdz6Z8vtbnsdbKvd8l+R NlYwrfLotseM6qfFKf3L1XIh7Xj40G2sDSe8MyV15tkIwRxrw4ZIySUwHfxBQOtXskdD AEVLALkAo2rmPEV0U80FmOViYBEpHikHpLxwE9zdYIXQt4Bw8pkpP8fVPr6qBFqI3X9r Hw+xWJrt+99GmC1n8Ykzam9fG9ywqSQdlYHfCywBAGq0kmmZU+CChWQh9ewYr9jBZiTA 1K5rTEuQzxqDLB9p7i3NCLjaDhM+uOPx3uN1inV36ZtQYeRwNvQR2NxhJImslf4rjQjP fN5w== 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:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=7kVkuUtQDUX1aDVHblgqIjOqsC1RWVD7544SomC6/qs=; b=tw5NDsRcoZe+bMKOqMMiH3scish5RFmeZvG+A/A1cLm2y29AlH8XLsvAXAWkqLo7VN OmC3exaBxcow9VV6grQNGIx3Ux2P+TvjRbbFAoFexzYdNO7+k0z6fDSQL8D6SH+UH6JT RyroDphoz3sQhTUXSC7GkINcWwTzUsDMY03wzd+fMYxY4TUibetUZD8VTa1PSw2oAxCv Qp8+bBvkbG9jFVVMURIRV46jwQ22RzKszPZZqmDFSOgO87dOQsg6jYOrbsoQABjlu50o RxVXF6T4q9Fm2DKEy0pafDE+Bs0XiEnQmUQI3mqvn2j0kSUqfZbXCyykCt+/2S76m8zM hl+A== 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 e12si2427188pgu.155.2018.04.03.12.00.24; Tue, 03 Apr 2018 12:00:38 -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 S1753160AbeDCS6w (ORCPT + 99 others); Tue, 3 Apr 2018 14:58:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:38178 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbeDCS6v (ORCPT ); Tue, 3 Apr 2018 14:58:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1404AAC12; Tue, 3 Apr 2018 18:58:49 +0000 (UTC) Date: Tue, 3 Apr 2018 18:58:48 +0000 From: "Luis R. Rodriguez" To: Lukas Wunner Cc: Hans de Goede , "Luis R. Rodriguez" , Ard Biesheuvel , Greg Kroah-Hartman , Thomas Gleixner , Kalle Valo , Arend Van Spriel , Ingo Molnar , "H . Peter Anvin" , linux-kernel@vger.kernel.org, Peter Jones , 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: <20180403185848.GD30543@wotan.suse.de> References: <20180331121944.8618-1-hdegoede@redhat.com> <20180331121944.8618-2-hdegoede@redhat.com> <20180402232333.GU30543@wotan.suse.de> <17fb3c28-78ff-2e1f-2ada-d33320567761@redhat.com> <20180403180711.GA7957@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403180711.GA7957@wunner.de> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 03, 2018 at 08:07:11PM +0200, Lukas Wunner wrote: > On Tue, Apr 03, 2018 at 10:33:25AM +0200, Hans de Goede wrote: > > I asked Peter Jones for suggestions how to extract this during boot and > > he suggested seeing if there was a copy of the firmware in the > > EFI_BOOT_SERVICES_CODE memory segment, which it turns out there is. > > > > My patch to add support for this contains a table of device-model (dmi > > strings), firmware header (first 64 bits), length and crc32 and then if > > we boot on a device-model which is in the table the code scans the > > EFI_BOOT_SERVICES_CODE for the prefix, if found checks the crc and > > caches the firmware for later use by request-firmware. > > > > So I just do a brute-force search for the firmware, this really is hack, > > nothing standard about it I'm afraid. But it works on 4 different x86 > > tablets I have and makes the touchscreen work OOTB on them, so I believe > > it is a worthwhile hack to have. > > The EFI Firmware Volume contains a kind of filesystem with files > identified by GUIDs. Those files include EFI drivers, ACPI tables, > DMI data and so on. It is actually quite common for vendors to > also include device firmware on the Firmware Volume. Apple is doing > this to ship firmware updates e.g. for the GMUX controller found on > dual GPU MacBook Pros. If they want to update the controller's > firmware, they include it in a BIOS update, and an EFI driver checks > on boot if the firmware update for the controller is necessary and > if so, flashes it. > > The firmware files you're looking for are almost certainly included > on the Firmware Volume as individual files. What Hans implemented seems to have been for a specific x86 hack, best if we confirm if indeed they are present on the Firmware Volume. > Rather than scraping > the EFI memory for firmware, I think it would be cleaner and more > elegant if you just retrieve the files you're interested in from > the Firmware Volume. > > We're doing something similar with Apple EFI properties, see > 58c5475aba67 and c9cc3aaa0281. > > Basically what you need to do to implement this approach is: > > * Determine the GUIDs used by vendors for the files you're interested > in. Either dump the Firmware Volume or take an EFI update as > shipped by the vendor, then feed it to UEFIExtract: > https://github.com/LongSoft/UEFITool > > * Add the EFI Firmware Volume Protocol to include/linux/efi.h: > https://www.intel.com/content/dam/doc/reference-guide/efi-firmware-file-volume-specification.pdf > > * Amend arch/x86/boot/compressed/eboot.c to read the files with the > GUIDs you're interested in into memory and pass the files to the > kernel as setup_data payloads. > > * Once the kernel has booted, make the files you've retrieved > available to device drivers as firmware blobs. Happen to know if devices using Firmware Volumes also sign their firmware and if hw checks the firmware at load time? Luis > The end result is mostly the same as what you're doing here, > and you'll also have a similar array of structs, but instead > of hardcoding 8-byte signatures of firmware files, you'll be > using GUIDs. I envision lots of interesting use cases for > a generic Firmware Volume file retrieval mechanism. What you > need to keep in mind though is that this approach only works > if the kernel is booted via the EFI stub. > > Thanks, > > Lukas > -- Do not panic