Received: by 10.213.65.68 with SMTP id h4csp975845imn; Wed, 4 Apr 2018 10:20:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48fLDZaSDQ3R6dxMRDD/6CNp0iDvDGNO199k53qPGqeRLMoRx+/2s1/HYs1KvKjd3GO9nTT X-Received: by 10.98.201.194 with SMTP id l63mr14544865pfk.126.1522862448108; Wed, 04 Apr 2018 10:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522862448; cv=none; d=google.com; s=arc-20160816; b=wMigM2kGkS6cerl1s0NEmODUQmQ5KeDEApFR0zif+HErUArXs2ULm7HG9RQ8m+IZ5G 0INrAzXc7o6r1fbLwY0SZ9pz4VS9BTN+kaquwGsH4sbyk3uIUM72sC+W6Z/kbjSfrs/P qNLjX2+JD7SDQ2iwN0ewYOiQUnXF/9rV9CA69d4HPUhFTnDo/nPCaczRQPtFKYWmvpPB HnVEWgq2DsCzaef9YsP1GRM0YazrIi0skj53QAdpoNV0k/vR5tftYd22APMf39s2PHay PWjVksZo+RoLoyYwBQ4l2O86f4v9DoiOYUzO2jSz/y/3m2gLDK5r+5mx/Kp7TRAPpkmF ctHA== 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=H72dnCec+fFeIUtByEiRE0tHT6gqa052i2swcaLBad4=; b=cCJvPyqHo8B1lAHBgZWlUV60ed5BeSWzAIce5ZsHDQfcTD0RL8PZrMiJpUCAkciAKd ZJBvQuCkaBgSp7MQXwKLqUzQwbZzl1uBmzl6m0iGFqPx4bLvFsk/O4z8Z0JpCAPIgY/v 2lpdBbjhqrbgt0ZqPYaRC2QMG90U/OBZcY/FZLUd3EVFJE8N1UAL8xBKqvINXdjv+vN7 5WumOIUA+Z6EtQpLHAGp4Dua/3g5xsSCBGyV+ovZmukQXHXKkswx8vMSnROCGj+Si+H/ znqJR7owU0fUXVrhOwPpHNscOr2vthkByfgdh8x5g3f4GmQltgs4F4lkDjDrkwadjPJ8 i3yQ== 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 q2si3868358pgp.815.2018.04.04.10.20.26; Wed, 04 Apr 2018 10:20:48 -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 S1751312AbeDDRSo (ORCPT + 99 others); Wed, 4 Apr 2018 13:18:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42566 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751178AbeDDRSm (ORCPT ); Wed, 4 Apr 2018 13:18:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 331AB8182D06; Wed, 4 Apr 2018 17:18:41 +0000 (UTC) Received: from redhat.com (dhcp-10-20-1-221.bss.redhat.com [10.20.1.221]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7C8A2024CA2; Wed, 4 Apr 2018 17:18:37 +0000 (UTC) Date: Wed, 4 Apr 2018 13:18:36 -0400 From: Peter Jones To: "Luis R. Rodriguez" Cc: Lukas Wunner , Hans de Goede , Ard Biesheuvel , 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: <20180404171835.xvllgcqirl3b5gd5@redhat.com> 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> <20180403185848.GD30543@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180403185848.GD30543@wotan.suse.de> User-Agent: NeoMutt/20171215 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 04 Apr 2018 17:18:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 04 Apr 2018 17:18:41 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pjones@redhat.com' RCPT:'' 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 06:58:48PM +0000, Luis R. Rodriguez wrote: > 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. To be honest, I'm a bit skeptical about the firmware volume approach. Tools like UEFITool[0] and uefi-firmware-parser[1] have existed for years, still don't seem to reliably parse firmware images I see in the wild, and have a fairly regular need for fixes. These are tools maintained by smart people who are making a real effort, and it still looks pretty hard to do a good job that applies across a lot of platforms. So I'd rather use Hans's existing patches, at least for now, and if someone is interested in hacking on making an efi firmware volume parser for the kernel, switch them to that when such a thing is ready. [0] git@github.com:LongSoft/UEFITool.git [1] git@github.com:theopolis/uefi-firmware-parser.git > > 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? It varies on a per-device basis, of course. Most new Intel machines as of Haswell *should* be verifying their system firmware via Boot Guard, which both checks an RSA signature and measures the firmware into the TPM, but as with everything of this nature, there are certainly vendors that screw it up. (I think AMD has something similar, but I'm really not sure.) -- Peter