Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp747265ybv; Wed, 19 Feb 2020 08:25:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzQz1cybic4ks/ruGR2l9ZlXVzA5yn2rKd+oZrH/9u7qc17Qe0XK4VGBev59cyAMg5EfZxv X-Received: by 2002:a9d:798e:: with SMTP id h14mr19553281otm.257.1582129555012; Wed, 19 Feb 2020 08:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582129555; cv=none; d=google.com; s=arc-20160816; b=Ah5xkiNyharCvSWIFWNv0R9GXExSK5RcyAloyWQiDUyERdeLTpo29BoENAtZZ+h8bZ vYoKcNwiA76WxeniTv2jP5HMfsWyhJL2fAWwOv7oO7pP/d3fNp3/e6cuBZg3JEvFgKCw plH6DiILkUFhJ+W+zrmHPhEsAcCpBgYeNxHXGD78J5imSzueqmIgIkPYF9/erb3kgFKW tTf1drZ/SoNZ1Jw7EN2kovB1Q0KzkXsPUxMXMtZHRHaLVfd/fa/DO6mzA8y8kR8CqK85 eCIoMDScuCtpbIejOHtaWMof2ViElpyjnfzFQKnQBnr1tQjU91PBMZ85fTrMTb8KKK8B v0qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LGUcIpTbEbd2gKzVZah8ywZm+EFWRECsbgMwE4dPkmc=; b=o1RfiOj1zVfs3OaZWhAXfi0boetigIbYLMJBN+odfXwYPsCmcKogb1BtdqBynxg2Xv CI9UuJHCX+SmXjk17tES9fidYw2sxi+4Vp7Ao3vqLYYBY7j85R3m740JUWrT/nx6fAl4 rPxe5jIx/Fbdof1LjbZ+pqkG9kB9ri8qxfru6V81PLXwLOkxGao3gNeLsXh1k6hOZncW 3EOnlGrkeR9MTbt6oHS4D8YNw+QkbaJ1Yd17WsW7GhHC3ib06gg7lqz2tn4mQBXDo2hD Dv/NSeLYqmFVD76IS6viyvEPctVzw2AhNmB1Dq3V3ZcXVJme8KCZAwDdQ0bTfDk0ljSM cglQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=q0KvBn7A; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si95308otc.272.2020.02.19.08.25.41; Wed, 19 Feb 2020 08:25:54 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=q0KvBn7A; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbgBSQZ3 (ORCPT + 99 others); Wed, 19 Feb 2020 11:25:29 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46566 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbgBSQZ3 (ORCPT ); Wed, 19 Feb 2020 11:25:29 -0500 Received: by mail-lj1-f194.google.com with SMTP id x14so958693ljd.13; Wed, 19 Feb 2020 08:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LGUcIpTbEbd2gKzVZah8ywZm+EFWRECsbgMwE4dPkmc=; b=q0KvBn7A14JQWVR1QGa6Q4b8U95+mkJ2Huoy2MrpQLM+x3CC3hwCOoVa/kQCAa2W7e 3kjdB16EuvFpGvPNgwlDpVjhHCwgfyWIiw1IaGYXn1MSNL8IF1a1JjNAYTJc+172PpxZ 5Z7vqbxPTifdCh9BU79UqIkJLfQlOn9qwxbCAR6Y6bIYX48nmkIJrhr87EWUuP0cRAb1 nPTwI8k4maeYJnZeaHiA4yp3J1yLLkAkwPGFGHeMP8H9vTGdP7OdDBpI4g3rkVJ/FpVq d9m3b/L3RLClnokebu6bmvS9R0qn1q+RO2Ih2ptmAuXi2bVjMCusV2prdez3VivLhmuN AoAA== 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:mime-version :content-transfer-encoding; bh=LGUcIpTbEbd2gKzVZah8ywZm+EFWRECsbgMwE4dPkmc=; b=g5WZT/6mRjPY9xhI6zebnx+kYzTg0le6DugGvUo70NNVjyPNa0zMLoxZClzlyxziW2 K1xhLlBStU32Y/543boK6ghgI9CSmWJQrqfWxHSGw+FQfuaOAsDdGchZg/E88mhCgRN0 wnjpZQMQzoaxobpB8ObsBA06n0x9ICK8rg0YRTSLY0FFvirUJKcRBPfq0AAVhLyd+GN9 ldRWpkLun/T41fwlHO5cbl87VoB1dvx9jD/wj8o8oHkefcmX4CdYffwSb69ZZx3Gmy83 kdEGJ8UWvR/OPoQkQl4j1DdBn8HLIysSD7kvL7dNIU1I7TlYW0EWR+K11WIvpKuqrqor LErA== X-Gm-Message-State: APjAAAUaWjwToWqca0sUCObsG/gyBjzrWFYQWHAV0XZYOOp19uxiWDqQ vlO1QklsqYo0cW/lAh9Iv+jVrNUN X-Received: by 2002:a2e:b536:: with SMTP id z22mr15860746ljm.259.1582129526316; Wed, 19 Feb 2020 08:25:26 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id i67sm26819lfd.38.2020.02.19.08.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 08:25:25 -0800 (PST) From: Dmitry Osipenko To: Jens Axboe , Davidlohr Bueso , Colin Cross , Thierry Reding , Jonathan Hunter , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , David Heidelberg , Peter Geis Cc: linux-efi@vger.kernel.org, linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter Date: Wed, 19 Feb 2020 19:23:39 +0300 Message-Id: <20200219162339.16192-1-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The gpt_sector= causes the GPT partition search to look at the specified sector for a valid GPT header if the GPT is not found at the beginning or the end of block device. In particular this is needed for NVIDIA Tegra consumer-grade Android devices in order to make them usable with the upstream kernel because these devices use a proprietary / closed-source partition table format for the EMMC and it's impossible to change the partition's format. Luckily there is a GPT table in addition to the proprietary table, which is placed in uncommon location of the EMMC storage and bootloader passes the location to kernel using "gpt gpt_sector=" cmdline parameters. This patch is based on the original work done by Colin Cross for the downstream Android kernel. Cc: Colin Cross Signed-off-by: Dmitry Osipenko --- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ block/partitions/efi.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 50138e6826a1..ee4781daa379 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1382,6 +1382,11 @@ primary GPT is corrupted, it enables the backup/alternate GPT to be used instead. + gpt_sector [EFI] Forces GPT partition search to look at the + specified sector for a valid GPT header if the GPT is + not found at the beginning or the end of the block + device. + grcan.enable0= [HW] Configuration of physical interface 0. Determines the "Enable 0" bit of the configuration register. Format: 0 | 1 diff --git a/block/partitions/efi.c b/block/partitions/efi.c index db2fef7dfc47..0c8926d76d7a 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -103,6 +103,17 @@ force_gpt_fn(char *str) } __setup("gpt", force_gpt_fn); +/* This allows a kernel command line option 'gpt_sector=' to + * enable GPT header lookup at a non-standard location. + */ +static u64 force_gpt_sector; +static int __init +force_gpt_sector_fn(char *str) +{ + WARN_ON(kstrtoull(str, 10, &force_gpt_sector) < 0); + return 1; +} +__setup("gpt_sector=", force_gpt_sector_fn); /** * efi_crc32() - EFI version of crc32 function @@ -621,6 +632,10 @@ 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 && force_gpt_sector) + good_agpt = is_gpt_valid(state, force_gpt_sector, + &agpt, &aptes); + /* The obviously unsuccessful case */ if (!good_pgpt && !good_agpt) goto fail; -- 2.24.0