Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp38769pxb; Tue, 7 Sep 2021 17:05:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/qVSOmVf6iS8lkhyBzLF+92ytifHpGwSPNsN8hGhx3Y5B7PGV2R3verg92rsgyd/iIY6K X-Received: by 2002:a92:d48a:: with SMTP id p10mr637671ilg.173.1631059528788; Tue, 07 Sep 2021 17:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631059528; cv=none; d=google.com; s=arc-20160816; b=TC8sUwfxZwbQiBxR/3mfZWauhcTrr/Vk/8DSHiq6cpxccY2y1MQuIVPwThwen6X3nf v79WegEQJ0tjQ91hEm4nKzhMLf/aDsfw0KnmxpY7rJgTjtUg9Bnj2dGJSbuLQLVVWU0Y AW9Pzw8+154tNfACkYtqyTbZMKjORmxi8vt0bkfSJSwrYs98VFZDaf4bmHXiDLtveiIO Bdw4bhml9I0nFOw+RNWtvI5nnxK6DQTWmkjPjO7hhn9fcsQUfRg4Qupe+rL4nidSejWf ptUsjZAArR6VkPhSyPKXhd+dnYJnhRUERFaILDHXZ3dvjN7ynhR4vfVWvJRvmEDRsR8T FzMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=zczYjyEW/5udENZPHTd9kTw28YiXv+mSCpUXCKDrqi0=; b=tkceIPschhuwxzyvN5WOYzxbV81QbLGLETlf5IH2BF+1YDEzBBxbFF6Ryooo1m9bN4 ebYljkV/WqW4HgkonJwQiCaxV5V/p4JgGZg3xLZwx8zlf5eSZQWucIY6B59rw8tI2Tg/ iygQ0xJtGwWTQeXX9EtiPlAmYwgXi0ziFz+//TpAyJneHNNxEa/g4vToknc2ITnhKUFh kCg7pmFXuGuH7VEFVvuiDKihTNpJCk9F/OnUnJffXA/8dkkwfC48sQGU5Snf/3ZliD2x M/8x17un7BaDudh252bvjSdHC5pQ23YBjv/7dH81/klQLenNLbjpq5hN8nBB6t/YZFB5 IWSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si494604ile.34.2021.09.07.17.05.17; Tue, 07 Sep 2021 17:05:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240862AbhIGX6J (ORCPT + 99 others); Tue, 7 Sep 2021 19:58:09 -0400 Received: from mga09.intel.com ([134.134.136.24]:12470 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231519AbhIGX6I (ORCPT ); Tue, 7 Sep 2021 19:58:08 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10100"; a="220369543" X-IronPort-AV: E=Sophos;i="5.85,276,1624345200"; d="scan'208";a="220369543" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 16:57:01 -0700 X-IronPort-AV: E=Sophos;i="5.85,276,1624345200"; d="scan'208";a="538242883" Received: from liao1-mobl.ccr.corp.intel.com (HELO chenyu5-mobl1) ([10.249.169.181]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 16:56:58 -0700 Date: Wed, 8 Sep 2021 07:56:55 +0800 From: Chen Yu To: Ard Biesheuvel Cc: ACPI Devel Maling List , Linux Kernel Mailing List , "Rafael J. Wysocki" , Len Brown , Dan Williams , Andy Shevchenko , Aubrey Li , Ashok Raj , linux-efi Subject: Re: [PATCH 2/5][RFC] efi: Introduce EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and corresponding structures Message-ID: <20210907235655.GA39306@chenyu5-mobl1> References: <14bb2fa2c49934c627aec07077b96720d46b5202.1631025237.git.yu.c.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 07, 2021 at 06:06:28PM +0200, Ard Biesheuvel wrote: > On Tue, 7 Sept 2021 at 17:12, Chen Yu wrote: > > > > Platform Firmware Runtime Update image starts with UEFI headers, and the headers > > are defined in UEFI specification, but some of them have not been defined in the > > kernel yet. > > > > For example, the header layout of a capsule file looks like this: > > > > EFI_CAPSULE_HEADER > > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER > > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER > > EFI_FIRMWARE_IMAGE_AUTHENTICATION > > > > These structures would be used by the Platform Firmware Runtime Update > > driver to parse the format of capsule file to verify if the corresponding > > version number is valid. The EFI_CAPSULE_HEADER has been defined in the > > kernel, however the rest are not, thus introduce corresponding UEFI structures > > accordingly. > > > > The reason why efi_manage_capsule_header_t and efi_manage_capsule_image_header_t > > are packedi might be that: > > According to the uefi spec, > > [Figure 23-6 Firmware Management and Firmware Image Management headers] > > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER is located at the lowest offset within > > the body of the capsule. And this structure is designed to be unaligned to save > > space, because in this way the adjacent drivers and binary payload elements could > > start on byte boundary with no padding. And the > > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER is at the head of each payload, so > > packing this structure also makes room for more data. > > > > Signed-off-by: Chen Yu > > Who is going to use these definitions? I only see this patch, where is > the rest of the series? > Sorry, Ard, and thanks for taking a look at this patch. The user of this definitions is an ACPI device driver, named Platform Firmware Runtime Update driver. This driver is designed to do firmware update via SMI. This driver will do sanity check of the capsule file using these structures before the file is passed to SMI. We put this check in kernel space rather than leaving it to SMI because the latter is very costly. The series patch is at: https://patchwork.kernel.org/project/linux-acpi/list/?series=543211 and the user is mainly PATCH 3/5: https://patchwork.kernel.org/project/linux-acpi/patch/9b2bd7d1e40633ce6f4845fb5c9e30a3faad5e7a.1631025237.git.yu.c.chen@intel.com/ in valid_version(). thanks, Chenyu