From patchwork Wed Aug 18 00:55:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 499190 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 2BD16C43214 for ; Wed, 18 Aug 2021 00:57:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C4B761056 for ; Wed, 18 Aug 2021 00:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236481AbhHRA5s (ORCPT ); Tue, 17 Aug 2021 20:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234119AbhHRA5r (ORCPT ); Tue, 17 Aug 2021 20:57:47 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 474F2C061764; Tue, 17 Aug 2021 17:57:13 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id x27so906268lfu.5; Tue, 17 Aug 2021 17:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FHpah2Dpj/TPubzzjmkmJuckncZAa3WMYxXsj2gsyts=; b=YSYnszVgE5PGV58mwWn67rQ0Qo3HjRDXp+af5aIntm1uZ8ToaPuKIcgg7+semEvT6o dUSAlnevDzeGlPupiIn5iTD0o/LdvbMteTvM2aALs7CrsxdElukm7Xr3J8RyUTapgeo0 9eXOT38ZR/JjOQ0q+C96ps9+y5sYiDIpD2cg9rnWoeNn/xwGGZYuo7ZKpI+pLsvDvINj M0558BipCq8ETfsCHj4EJqr31sDeOKMhNmRyTWqYBDvbcTjiYIHFPZMmd0DR8+k0I80B 1Er9XwH9kr2FOw3Mo5dmiBcqSz1LZ36b8Tst4F9POz1FBLLnpgBaxAWE3yDr3XzMWLcj Alsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FHpah2Dpj/TPubzzjmkmJuckncZAa3WMYxXsj2gsyts=; b=ErLT+gWbeqUstHwdLPCnj8K7xcPUj/FXKRV/aSSqCLiJgnWCCpW50Uh1PWgIuL6jSh JMKw2tl8mtNnoJ9yvk20mgBpmaAnRLX0OyhYQHc+kUHKALjKk4VwGumVVv4h2P+3JdW+ GGk0eqPecR8fp+GJ6GKXZDDrC8uM7vwu0vikFvIs2p6dVWIpUrxS76BaZnNSrSboLqEm xjVKpoarVpEvhfzTUg37kBVj4+7KEOghqeldfJ6GdGM6Bq9DJBTr/vNl5K90WjSdyMqI yWVsFvWOf/VmK70z0d4zlFwdd+BAZcJK/L/NnKBQMmYbEKgLxsl8MWeBmizqArHEKZrz upkA== X-Gm-Message-State: AOAM533bSTj5kXtXndRGKp201lJdqFk15ni6jIalDRaZkXIKrSusuwiZ fNUcfDWJozhv8oXyhC5uWrQ= X-Google-Smtp-Source: ABdhPJzHR1wMJp3yBjzWxkyYvY33vsGCKBmKN2ow3m7gwngkxK9Xdtf/PN36aCM0S5wPqlQVVECrbQ== X-Received: by 2002:ac2:46ef:: with SMTP id q15mr4460085lfo.407.1629248231719; Tue, 17 Aug 2021 17:57:11 -0700 (PDT) Received: from localhost.localdomain (46-138-85-91.dynamic.spd-mgts.ru. [46.138.85.91]) by smtp.gmail.com with ESMTPSA id h19sm335879lfu.138.2021.08.17.17.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 17:57:11 -0700 (PDT) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Ulf Hansson , Adrian Hunter , Christoph Hellwig , Davidlohr Bueso , Rob Herring , Ion Agorria , Svyatoslav Ryhel Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-efi Subject: [PATCH v5 1/5] block: Add alternative_gpt_sector() operation Date: Wed, 18 Aug 2021 03:55:43 +0300 Message-Id: <20210818005547.14497-2-digetx@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210818005547.14497-1-digetx@gmail.com> References: <20210818005547.14497-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add alternative_gpt_sector() block device operation which specifies alternative location of a GPT entry. This allows us to support Android devices which have GPT entry at a non-standard location and can't be repartitioned easily. Suggested-by: Christoph Hellwig Signed-off-by: Dmitry Osipenko --- include/linux/blkdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 111a3911c4d2..a662a8f5065f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1848,6 +1848,7 @@ struct block_device_operations { int (*report_zones)(struct gendisk *, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data); char *(*devnode)(struct gendisk *disk, umode_t *mode); + int (*alternative_gpt_sector)(struct block_device *, sector_t *); struct module *owner; const struct pr_ops *pr_ops; }; From patchwork Wed Aug 18 00:55:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 499189 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,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 5E6EEC4338F for ; Wed, 18 Aug 2021 00:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F15C61058 for ; Wed, 18 Aug 2021 00:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237281AbhHRA5t (ORCPT ); Tue, 17 Aug 2021 20:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237271AbhHRA5t (ORCPT ); Tue, 17 Aug 2021 20:57:49 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19A96C061764; Tue, 17 Aug 2021 17:57:15 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id y6so1938489lje.2; Tue, 17 Aug 2021 17:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e+PwoAn2TbsYyBgAUnjfJ0mPTEWF4OtaWk/OQ83AcWM=; b=OgIqTjQP/2I6zKJkTHxQkuLSFKrqUuLTgxY0ySO+ixz0jMUFqzcCT9xwsPxRVeLiKj AceLQOQ3vMGT+PU2pteuVzmYf93EIvZeoJRBh/2FjNaktiYpw7WNflnpR/BotzhYSGpB 98jWS9W/kar1qWaeucQN7xYBko4zfdd3Hk1KeqjTXp/DeIkaB5JSXBpn4+h8nlmSlhgr V8+kJaJSczAeEfRjNIy4b5N86aTJtXp+295UQteah/EHX5bNFpRZXehcY1yFbQ+T03iX Zov05ZLQPrRkwhZ8P84I5kQoqhVD5lLT8pS46CvwYKMyvRuVsAtiOumIpO4Ni1mF2Dp/ U4+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e+PwoAn2TbsYyBgAUnjfJ0mPTEWF4OtaWk/OQ83AcWM=; b=dl15Da78pdw/BAfVVj3hKsxjozdl7/ZCvt/42G0pdLStnb7i/2dA1Au1y6C7Q1QVvd ryklFwEQ31ZUzOc+W9ALvHKeFBsDCFbNihEP0TtEJJqsv4kux70/OQVnWFmVtAAeJE0v EwqwydOawrs8KBnE+60aY8y8oSVz5oDDe2bo/kG7gUJS52LohGIsb+sJhM1s+eD5NZO4 8dB8GJYpWppX13NgRSFPBHrVzcxhWz+ut881pTVBlBe9ugcNd3sP+SevBo9Xj6YuN9C7 9hEulNKTVWWNqvNQ/Zhpa1SpjRVH8a+6jz4Ur3kUzxahpjR4iCUg1uRG8pKce0Y3r/qQ D9yg== X-Gm-Message-State: AOAM532j43Xv31ZfTkfuXPTISsN5LT1hMd6DXXJ7vNVJdA1eKl270QvJ F+iy0PI+Lefow3AooD2voao= X-Google-Smtp-Source: ABdhPJyOKk5m9JTY/i1OECIuQzCEr/YJMBQXB5FhWA1QN/Cfa/eQrB2486zb/GmvIuRiJCqXOrKpjw== X-Received: by 2002:a2e:557:: with SMTP id 84mr5516909ljf.507.1629248233491; Tue, 17 Aug 2021 17:57:13 -0700 (PDT) Received: from localhost.localdomain (46-138-85-91.dynamic.spd-mgts.ru. [46.138.85.91]) by smtp.gmail.com with ESMTPSA id h19sm335879lfu.138.2021.08.17.17.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 17:57:13 -0700 (PDT) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Ulf Hansson , Adrian Hunter , Christoph Hellwig , Davidlohr Bueso , Rob Herring , Ion Agorria , Svyatoslav Ryhel Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-efi Subject: [PATCH v5 3/5] mmc: core: Add raw_boot_mult field to mmc_ext_csd Date: Wed, 18 Aug 2021 03:55:45 +0300 Message-Id: <20210818005547.14497-4-digetx@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210818005547.14497-1-digetx@gmail.com> References: <20210818005547.14497-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Bootloader of NVIDIA Tegra devices linearizes the boot0/boot1/main partitions into a single virtual space, and thus, all partition addresses are shifted by the size of boot0 + boot1 partitions. The offset needs to be known in order to find the EFI entry on eMMC storage of Tegra devices. Add raw_boot_mult field to mmc_ext_csd which allows to get size of the boot partitions. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/mmc.c | 2 ++ include/linux/mmc/card.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 838726b68ff3..29e58ffae379 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -418,6 +418,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT]; card->ext_csd.raw_hc_erase_grp_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; + card->ext_csd.raw_boot_mult = + ext_csd[EXT_CSD_BOOT_MULT]; if (card->ext_csd.rev >= 3) { u8 sa_shift = ext_csd[EXT_CSD_S_A_TIMEOUT]; card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG]; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 74e6c0624d27..37f975875102 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -109,6 +109,7 @@ struct mmc_ext_csd { u8 raw_hc_erase_gap_size; /* 221 */ u8 raw_erase_timeout_mult; /* 223 */ u8 raw_hc_erase_grp_size; /* 224 */ + u8 raw_boot_mult; /* 226 */ u8 raw_sec_trim_mult; /* 229 */ u8 raw_sec_erase_mult; /* 230 */ u8 raw_sec_feature_support;/* 231 */ From patchwork Wed Aug 18 00:55:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 499188 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,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 397DFC4338F for ; Wed, 18 Aug 2021 00:57:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21CF661056 for ; Wed, 18 Aug 2021 00:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237277AbhHRA5v (ORCPT ); Tue, 17 Aug 2021 20:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237271AbhHRA5v (ORCPT ); Tue, 17 Aug 2021 20:57:51 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC3AC061764; Tue, 17 Aug 2021 17:57:17 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id p38so1009676lfa.0; Tue, 17 Aug 2021 17:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I01H5a6uHWni87egbbK4J+JI32iz47EYQ+sGtHJn9C8=; b=N6JSsp07CpZCty+GpUO8Ix550NiKbjjfrr3MgQs6vBbp0jeZ2mo4YGpEwCfpOyU2fS XbLBOGzidYQAvvw8vr521Wfpl+G2A0uhBOv5Ao/+qI26ERIW6HSeqZLCqYDifZcjDq7V 9pYnMVA8yeHjOAcvrbyHnCEaB6qUMYtaIpihhyQIVj5zwzxDkX3Ku8fXTkHrxv4yO0gd 4gvZLn8FQk0/6d40xcXz0BDe5lbAZSWFO1PZ8yABdh2ImVq9iJ/txZD2BbBFpnRHtKx7 Di2clJlPnhcSvfIcXGgy8BEivwI85p1b2C8e22q8TlT7KjTgiK9pzkW2eaUG1gSu6aps cQgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I01H5a6uHWni87egbbK4J+JI32iz47EYQ+sGtHJn9C8=; b=ibwHReew4h90c7iobA+39RBGbbzJllBg5SHAflYA3TcYr+jl0OC/AVw4BxNwQtkT9k olC810k00mCjnf/HJMEz/xVY2WIVOeZX+XSlJVE/SkP+Y2JWV6g/GdsxQ9ij42HhfCvF BJWri+JrHZk7quRN69h0q7SQfT7SZV1VBCdRze6OKn/ab051GTtBWhE8U1IoVtlRBqWg H2v+7GURP6sm4HKYTod+dPiFiJJHp+3W5mUG2UMvg1WadJsHAvqWFmN8tMWW94ej5g2k BBMvLMT3pljQPTLfxixUcBfZrOUA+sXKTX0rbEHe7Zj7HA34BwzTWOoP8igkfYIrqhDw 0JDg== X-Gm-Message-State: AOAM533BZxYgAhdi2c9hyLxWYqt/vr2vMGVQtKAg1xMJliV/H28Qmu+Q JZGQKuKhEHs3nBJtqJl70kI= X-Google-Smtp-Source: ABdhPJyM2Pw5uNedmsQZXhYwx6gDYixKDMuB77RrrxaMT/g2PWwc2DQwvCordjK6ChUFqDanxd6hBA== X-Received: by 2002:ac2:428a:: with SMTP id m10mr4503044lfh.636.1629248235291; Tue, 17 Aug 2021 17:57:15 -0700 (PDT) Received: from localhost.localdomain (46-138-85-91.dynamic.spd-mgts.ru. [46.138.85.91]) by smtp.gmail.com with ESMTPSA id h19sm335879lfu.138.2021.08.17.17.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 17:57:14 -0700 (PDT) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Ulf Hansson , Adrian Hunter , Christoph Hellwig , Davidlohr Bueso , Rob Herring , Ion Agorria , Svyatoslav Ryhel Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-efi Subject: [PATCH v5 5/5] partitions/efi: Support non-standard GPT location Date: Wed, 18 Aug 2021 03:55:47 +0300 Message-Id: <20210818005547.14497-6-digetx@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210818005547.14497-1-digetx@gmail.com> References: <20210818005547.14497-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Support looking up GPT at a non-standard location specified by a block device driver. Signed-off-by: Dmitry Osipenko --- block/partitions/efi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index aaa3dc487cb5..b9509f445b3c 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,17 @@ 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) { + struct block_device *bdev = disk->part0; + sector_t agpt_sector; + int err; + + err = fops->alternative_gpt_sector(bdev, &agpt_sector); + if (!err) + good_agpt = is_gpt_valid(state, agpt_sector, + &agpt, &aptes); + } + /* The obviously unsuccessful case */ if (!good_pgpt && !good_agpt) goto fail;