Received: by 10.213.65.68 with SMTP id h4csp3820836imn; Tue, 3 Apr 2018 11:09:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx48lsvfGNfcIYgiok++UT7OjvMBEsBCm1/VUDZ7ZikQmEmKxJHRu3BLZJaKvfhLvKCj6yZGu X-Received: by 10.98.60.4 with SMTP id j4mr11317860pfa.229.1522778995588; Tue, 03 Apr 2018 11:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522778995; cv=none; d=google.com; s=arc-20160816; b=UjqoruV0IOzfW/GRBrl12r92UunXPtAb0qrr5mSsH7+mGZ4msdNsNejv+gpvCFMEMy K38gl2+ZKfyWGeq5fb/BsW3Ikxy6pfelTzXGmgvNLdZJhVsM52XCOt6TkY+sKALG/8jD wRRQXWk9x5y9sYtyCgmuoDe068n81iLGFFkw9yZ+H1Crfm/7HG+fvDpNocjlysh576sq b05+gepVu1AiwK0Hor1yt7EGcX6OtHq9mXpUM2REDvsnBK7TEfoQExD89wjVoyac6OcR qx9ShS7o7fBCnHUrg8mqfMjGq4YjxOO92w80nY+rOlF24dmXZVdV71MPjrX0aVyfk5QG Zwyw== 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=yufIbt6y8rXmWRILgN30xftb67GKJLijvhIxQ+jn0Qw=; b=LQoxMMqMfZnj960xA810d9HAXv/6J/B55sAKijzeq8SsyiEuEr2Z8SSPhI3q44gibb mfeyw8sT4NxJqv6sbfPfLvj/uTfAWOHQza7fk0YXTEAljACCd2KcZEavjqNu9wEerAEa pH7ayBLIxlIyuZNR8PdybUUi5pzgGE4dVA+mXJJKgI84dbj3XQAdrI9I/TjAaSth/cj1 HRPiQAM4mqPAviiRqvMMUFi1ZVocYWMKVV6WguXdbzysEf9I4bIfxyaMgEcrkD25iAHe syRxcbOyX05QbaGTHlv2jy7g03IwZq7b6nJ+/PaJQbctcdMVKouxNtZHnU4UQbWJSdxq OJqw== 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 a190si2329234pge.436.2018.04.03.11.09.41; Tue, 03 Apr 2018 11:09:55 -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 S1752814AbeDCSHQ (ORCPT + 99 others); Tue, 3 Apr 2018 14:07:16 -0400 Received: from bmailout2.hostsharing.net ([83.223.90.240]:57681 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbeDCSHO (ORCPT ); Tue, 3 Apr 2018 14:07:14 -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 47C542800B3E0; Tue, 3 Apr 2018 20:07:12 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id E62C727004; Tue, 3 Apr 2018 20:07:11 +0200 (CEST) Date: Tue, 3 Apr 2018 20:07:11 +0200 From: Lukas Wunner To: Hans de Goede Cc: "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 Subject: Re: [PATCH 2/2] efi: Add embedded peripheral firmware support Message-ID: <20180403180711.GA7957@wunner.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17fb3c28-78ff-2e1f-2ada-d33320567761@redhat.com> 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 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. 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. 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