From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BC95C4320A for ; Fri, 20 Aug 2021 22:45:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06A646103D for ; Fri, 20 Aug 2021 22:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232835AbhHTWqJ (ORCPT ); Fri, 20 Aug 2021 18:46:09 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:10174 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbhHTWqI (ORCPT ); Fri, 20 Aug 2021 18:46:08 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4GrxYN3sXXzbS; Sat, 21 Aug 2021 00:45:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1629499528; bh=16gKLJUDkQ7g0JmAzH1SE2EE5CY64jDwYOhZeIxA1g8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Syvwzk2S35gJ9J/aw/QJcRoBqhn1mAPzPbMD2mq1AX5V5c6SAiCMepKd280SNNNse 1n07WSjm19aVqG5gSdgWlvndQFAArpNtyWr+RDBSCfmm4dzrv5F5ZkXdRJFhuGfqsJ j7l/atIymYAO8yfHYuUUxdkKSYcrFaI6ZhATveTZwlYCo+YuS/cd2oVFyj9Nj4wFjr qlILDjP0jYwItLUILOP8T9ltfFZM9sGZS46EvQmHX8gywnHnFVGMB5cxv1FTmECSOd 9hHt7IPdGX/HcpQ/Pn5zqiR5rlPJPTUSXvEfPV3qJa/+SP47TXa3UVpXAPF6q8Bt8W 5S3FJ3PCbGfZQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at mail Date: Sat, 21 Aug 2021 00:45:27 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Dmitry Osipenko Cc: Jens Axboe , Thierry Reding , Jonathan Hunter , David Heidelberg , Peter Geis , Ulf Hansson , Adrian Hunter , Christoph Hellwig , Davidlohr Bueso , Rob Herring , Ion Agorria , Svyatoslav Ryhel , linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-efi Subject: Re: [PATCH v6 2/5] partitions/efi: Support non-standard GPT location Message-ID: References: <20210818221920.3893-1-digetx@gmail.com> <20210818221920.3893-3-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210818221920.3893-3-digetx@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Thu, Aug 19, 2021 at 01:19:17AM +0300, Dmitry Osipenko wrote: > Support looking up GPT at a non-standard location specified by a block > device driver. > > Signed-off-by: Dmitry Osipenko > --- > block/partitions/efi.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/block/partitions/efi.c b/block/partitions/efi.c > index aaa3dc487cb5..7ca5c4c374d4 100644 > --- a/block/partitions/efi.c > +++ b/block/partitions/efi.c > @@ -585,6 +585,8 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, > gpt_header *pgpt = NULL, *agpt = NULL; > gpt_entry *pptes = NULL, *aptes = NULL; > legacy_mbr *legacymbr; > + struct gendisk *disk = state->disk; > + const struct block_device_operations *fops = disk->fops; > sector_t total_sectors = get_capacity(state->disk); > u64 lastlba; > > @@ -619,6 +621,16 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, > if (!good_agpt && force_gpt) > good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes); > > + if (!good_agpt && force_gpt && fops->alternative_gpt_sector) { > + sector_t agpt_sector; > + int err; > + > + err = fops->alternative_gpt_sector(disk, &agpt_sector); > + if (!err) > + good_agpt = is_gpt_valid(state, agpt_sector, > + &agpt, &aptes); > + } > + When alternative_gpt_sector is provided I would expect it to override the default, not be a fallback for it. But if someone tries to put a broken (decoy, garbage) GPT at a standard place, current ordering will prevent overriding it. Best Regards Michał Mirosław