Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp748636ybv; Wed, 19 Feb 2020 08:27:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzC5sYbqh9ZiVmfH6FEnk+joq9a0Qnbj0uxPx2fqX7cB2EAi/Txh5qk79QOtxfY2TFfylnY X-Received: by 2002:a05:6808:a8a:: with SMTP id q10mr4960684oij.66.1582129647621; Wed, 19 Feb 2020 08:27:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582129647; cv=none; d=google.com; s=arc-20160816; b=XDG+kpaDl30vufnbzrs3j8VhoHPzCKj/hMGvg4C6VFi0QJehT04DdJ7n0ouqugfuMa Ofa3PxX6lx89jJZzO5H7CfQMAK0MsYFg7Pc+VbQXxi08f3ztFB6I0wryWEv+CSLnARxA sUJqrCn62VRdOGx8j6y//yLQYGeGQviXey7K58e5ez+AZxc918ur+FbdDKKcTukCpOAh gzAch+4mW5DOGHIVr2SEHDUtLkTJS9V4Mhzd9jQteq6MrJOr5XH0DoAqOaI/wkPhCFq4 GbmlBNPSBQQm1dskXszq25VUfVAqL3dkvPL12sMCKmoToVkuf1nglMtm319Xe2WyCfR4 zo4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=f3RfLpkSg4BBxrjUvuH+ZfTwcMR2+u85t8Ne4yuoFM8=; b=MkCBqrdvbY1l4TfV4V3aY8pbA7fFvrCO28VQ6YvaJyXh0w/7lrDkbVIgBnHBxfpEFq /U7kwByjtvhcGYiiTHzTdmJIdZ7ny8YgEsDv1RNNo0gkp3dLUedw215RMpSubvHQ1Al8 ooibkO0hozDB25z1fyxDPvXygugNUUpzMqNjLV4aeKldg9G7Htw7zjkjyR4dIMT6loKM 9x50YPPKE5ex30qhV4KiMx2aN2x9QXfhXwd6Eb3DukjUG9hMNtpfSprQyLCETNtAkh46 qQIRvkmAI4v3uA6icpoun8UP4vS9qGMZeK+57sUIA8HI+6JncU/ZV+SILuwiQwrR9oat 2t8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fc8JBt6P; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si10043088oib.152.2020.02.19.08.27.15; Wed, 19 Feb 2020 08:27:27 -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=@linaro.org header.s=google header.b=Fc8JBt6P; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbgBSQ1L (ORCPT + 99 others); Wed, 19 Feb 2020 11:27:11 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38195 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbgBSQ1K (ORCPT ); Wed, 19 Feb 2020 11:27:10 -0500 Received: by mail-wm1-f65.google.com with SMTP id a9so1326935wmj.3 for ; Wed, 19 Feb 2020 08:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f3RfLpkSg4BBxrjUvuH+ZfTwcMR2+u85t8Ne4yuoFM8=; b=Fc8JBt6PKQoguEIQYGlBcLTuJrHOI1g5A3hAJnfPRDXX0oNPpUqqxo9Vw/LMVsjgVT RH/u/2vlOwq5OlOuy4h9DPOMRzWbwzo2SILUG38tGFyPpJBOCPiAl5ZgPu33mnkQn/RE RTr1De5zOA/Fy1vZchUb5xFScRQ8T5XzfSj857wzsSp6/ogkPZ7ymNGWMopWXOYvBWMg eTVptxnfZy9vmxiSddnWVsnfCI+iPaSMBWErZJ1ODEje2ZkB6pfASnFmRds6m40QxpNr exO7FjnkT0klGMaxaYKzcGn+85Wpa5fG81pM6HvjkeSpMx7NhT1pcqoxQOqldtQW58y7 NLuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f3RfLpkSg4BBxrjUvuH+ZfTwcMR2+u85t8Ne4yuoFM8=; b=J6wM8lw4CB+hj2xmySBUGuAqFmlfg/kRnC3mShfWKOF0Ga7d1KT/sX8rMxLi7x0LpA cl3U4TuwgUaRcUKjgY3df6TgsTaYXswCpAxng8ZlXzbgxi532025H1Tq5rZs/TM+YCvy xsIJWqszdWeYDj9PN0lVwmSypLxA4Klcwj1P/g//E6vlkChWRTCkUl1DLa0TZMTpa/gd yVgXm5WwjQd4LqBWY9oqPDDz0/n0CLbu/Yy8PxReq03oVQY4OAcv2JIKh4utZ3ZVGoPB +ErCvM8fKjPdpvFE+gpUrwAOWVu2JJQ6cTxajxFd3890Jsh/xsmcdRDFMpd6kguf9UvE n62Q== X-Gm-Message-State: APjAAAWPsLUFhqkbNcnxGrIsPEemd3yAp5gfJcuLQWvYidh+ppTLRJrZ HGpaWX6vprEj5VAqlqLx5IHv8wi1OtREQvONcRWJ+w== X-Received: by 2002:a05:600c:248:: with SMTP id 8mr10927444wmj.1.1582129628720; Wed, 19 Feb 2020 08:27:08 -0800 (PST) MIME-Version: 1.0 References: <20200219162339.16192-1-digetx@gmail.com> In-Reply-To: <20200219162339.16192-1-digetx@gmail.com> From: Ard Biesheuvel Date: Wed, 19 Feb 2020 17:26:57 +0100 Message-ID: Subject: Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter To: Dmitry Osipenko Cc: Jens Axboe , Davidlohr Bueso , Colin Cross , Thierry Reding , Jonathan Hunter , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , linux-efi , linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Linux Doc Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Feb 2020 at 17:25, Dmitry Osipenko wrote: > > 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 Which block device is this parameter applied to? > --- > 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 >