diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 5e9be13a56a8..3155a4f6767a 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -98,6 +98,15 @@ static int force_gpt; static int __init force_gpt_fn(char *str) { + /* + * This check allows to properly parse cmdline variants like + * "gpt gpt_sector=" and "gpt_sector= gpt" since + * "gpt" overlaps with the "gpt_sector=", see tegra_gpt_sector_fn(). + * The argument is absent for a boolean cmdline option. + */ + if (strlen(str)) + return 0; + force_gpt = 1; return 1; } diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d6c819dd68ed..4d884c834152 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2169,6 +2169,19 @@ int mmc_detect_card_removed(struct mmc_host *host) } EXPORT_SYMBOL(mmc_detect_card_removed); +/* + * This allows a kernel command line option 'gpt_sector=' to + * enable GPT header lookup at a non-standard location. This option + * is provided to kernel by NVIDIA's proprietary bootloader. + */ +static sector_t cmdline_gpt_sector; +static int __init cmdline_gpt_sector_fn(char *str) +{ + WARN_ON(kstrtoull(str, 10, &cmdline_gpt_sector) < 0); + return 1; +} +__setup("gpt_sector=", cmdline_gpt_sector_fn); + int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector) { unsigned int boot_sectors_num; @@ -2183,6 +2196,11 @@ int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector) mmc_card_is_removable(card->host)) return -ENOENT; + if (cmdline_gpt_sector) { + *gpt_sector = cmdline_gpt_sector; + return 0; + } + /* * eMMC storage has two special boot partitions in addition to the * main one. NVIDIA's bootloader linearizes eMMC boot0->boot1->main