From patchwork Tue Nov 8 23:03:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 17264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp25455wru; Tue, 8 Nov 2022 15:08:05 -0800 (PST) X-Google-Smtp-Source: AMsMyM7oGQ/Pc5BaQAxDxlHf/GrGnm+Ina/fbYU/rtpaLCRUhh9nOpoAjQLvvxiBIG/XEMXSN0K+ X-Received: by 2002:a05:6402:50c:b0:461:bc01:1828 with SMTP id m12-20020a056402050c00b00461bc011828mr58568506edv.64.1667948885060; Tue, 08 Nov 2022 15:08:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667948885; cv=none; d=google.com; s=arc-20160816; b=WvRIwEh51xDYHsQDEB9Jg66YXDvDj/1V2eifryCosaE1NjxtrDeGhTRoR9w1bybhjK aj9wSxysTGZ4q8E36iDF9C+eOCxGwuq6txFcqc8rxFeu6n+QDUmVfwtIkktqqSKydIUn LwF4hoZmNB6sW65Ie21ZXTNwfO7uxfjaoMc40rOd9yQrZMgyERSIf9SzAZaRdALpX1pA Qjvdw3RmUnf1olF4DfR/vHbdHmLvAXzWkB0t5wJVVJqPGocO6q0Zbx8l8m2MIPKUc5Sj qYj78i1yM8leeINOES47r6CFMmfQnaV3azWtgwIlNRDwCo2u0ivvf0Ebj5XuP/xlulbK glKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=q+mEapDl3A3nGTAE8boQEVA1WENIGE3CNZVC9sJwYRk=; b=dwr6Yh8zFC8dG1azZ84oZzpAgkRFE7LuFUSMVe8f81adA5tQPbwFl5vP8xZvmXV4xi D6n/LyHFVZceG3FfpZwmU+JUV45ykV1x5YZDdOYxe83gxxbgqK1D6iU6OOom2yjE0hiI VxuD0TJHAgYNjHL1srEeHSatM0LCrGZ070QPENVYwIwShNjA/L5/nZQJ6dhb4YFOBBf+ xNiIgZwN3N7pLbzBDug3aBAuMYjRFwa2dDMN66X4m2rW/h0aJvClwwBZeXLRqD3rggaV ihVbeAMJIUc6aNLWmRr6AvV9Jt2n5K1of7t9xmQUZGW2EUIwXOv8BjkY17qYvNWhM5Io 5Bpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la26-20020a170907781a00b00780488c11bbsi10403377ejc.388.2022.11.08.15.07.40; Tue, 08 Nov 2022 15:08:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiKHXF2 (ORCPT + 99 others); Tue, 8 Nov 2022 18:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiKHXFY (ORCPT ); Tue, 8 Nov 2022 18:05:24 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CD3E63147; Tue, 8 Nov 2022 15:05:23 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from ) id 1osXeZ-0005vA-Rm; Wed, 09 Nov 2022 00:05:12 +0100 Date: Tue, 8 Nov 2022 23:03:48 +0000 From: Daniel Golle To: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Davidlohr Bueso , Matthew Wilcox , "Martin K. Petersen" , Chaitanya Kulkarni , Daniel Golle , Ming Lei , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,PDS_OTHER_BAD_TLD, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748971170188114944?= X-GMAIL-MSGID: =?utf-8?q?1748971170188114944?= Add new GUID allowing to parse uImage.FIT stored in a GPT partition and map filesystem sub-image as sub-partitions. Signed-off-by: Daniel Golle --- block/partitions/efi.c | 9 +++++++++ block/partitions/efi.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 5e9be13a56a8..bf87893eabe4 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state) gpt_entry *ptes = NULL; u32 i; unsigned ssz = queue_logical_block_size(state->disk->queue) / 512; +#ifdef CONFIG_FIT_PARTITION + u32 extra_slot = 65; +#endif if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { kfree(gpt); @@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state) ARRAY_SIZE(ptes[i].partition_name)); utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname); state->parts[i + 1].has_info = true; + /* If this is a U-Boot FIT volume it may have subpartitions */ +#ifdef CONFIG_FIT_PARTITION + if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID)) + (void) parse_fit_partitions(state, start * ssz, size * ssz, + &extra_slot, 127, 1); +#endif } kfree(ptes); kfree(gpt); diff --git a/block/partitions/efi.h b/block/partitions/efi.h index 84b9f36b9e47..06c11f6ae398 100644 --- a/block/partitions/efi.h +++ b/block/partitions/efi.h @@ -51,6 +51,9 @@ #define PARTITION_LINUX_LVM_GUID \ EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \ 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28) +#define PARTITION_LINUX_FIT_GUID \ + EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \ + 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93) typedef struct _gpt_header { __le64 signature;