mbox series

[v3,00/10] Introduce NVIDIA Tegra Partition Table

Message ID 20200323163431.7678-1-digetx@gmail.com (mailing list archive)
Headers show
Series Introduce NVIDIA Tegra Partition Table | expand

Message

Dmitry Osipenko March 23, 2020, 4:34 p.m. UTC
Some NVIDIA Tegra devices have GPT entry at a wrong location and others may
even not have it at all. So either a custom workaround for GPT parsing or
TegraPT support is needed for those devices if we want to support them in
upstream kernel. The former solution was already rejected [1], let's try
the latter.

[1] https://patchwork.ozlabs.org/patch/1240809/

Big thanks to everyone who helped with figuring out the TegraPT format!

Changelog:

v3: - Fixed "BUG: KASAN: slab-out-of-bounds in tegra_partition". Thanks to
      Peter Geis for noticing the problem.

    - The MMC boot partitions scanning is now opt-in. See this patch:

        mmc: block: Support partition-table scanning on boot partitions

    - The found MMC boot partitions won't be assigned to the MMC boot
      block device ever due to the new GENHD_FL_PART_SCAN_ONCE flag.

      This makes us to ensure that the old behavior of the MMC core is
      preserved for a non-Tegra MMC-block users.

    New patches in v3:

        block: Introduce GENHD_FL_PART_SCAN_ONCE
        mmc: sdhci-tegra: Enable boot partitions scanning on Tegra20 and Tegra30

v2: - Addressed v1 review comments from Stephen Warren by using BIT for
      locating BCT position in IRAM.

    - Added more validations to the TegraPT parser: partition type is
      verified, eMMC instance ID is verified.

    - TegraPT parser now doesn't touch any devices other than eMMC.

    - EKS (encrypted keys) partition is blacklisted now.

    - Implemented eMMC boot partitions scanning. These new patches are
      added in a result:

        mmc: block: Add mmc_bdev_to_part_type() helper
        mmc: block: Add mmc_bdev_to_area_type() helper
        mmc: block: Add MMC_QUIRK_RESCAN_MAIN_BLKDEV
        mmc: block: Enable partition-table scanning for boot partitions
        partitions/tegra: Implement eMMC boot partitions scanning

Dmitry Osipenko (10):
  mmc: core: Add raw_boot_mult field to mmc_ext_csd
  mmc: block: Add mmc_bdev_to_card() helper
  partitions: Introduce NVIDIA Tegra Partition Table
  block: Introduce GENHD_FL_PART_SCAN_ONCE
  mmc: block: Add mmc_bdev_to_part_type() helper
  mmc: block: Add mmc_bdev_to_area_type() helper
  mmc: block: Add MMC_QUIRK_RESCAN_MAIN_BLKDEV
  mmc: block: Support partition-table scanning on boot partitions
  mmc: sdhci-tegra: Enable boot partitions scanning on Tegra20 and
    Tegra30
  partitions/tegra: Implement eMMC boot partitions scanning

 arch/arm/mach-tegra/tegra.c    |  54 +++
 block/genhd.c                  |   2 +-
 block/partition-generic.c      |  13 +-
 block/partitions/Kconfig       |  10 +
 block/partitions/Makefile      |   1 +
 block/partitions/check.c       |   4 +
 block/partitions/tegra.c       | 612 +++++++++++++++++++++++++++++++++
 block/partitions/tegra.h       |   8 +
 drivers/mmc/core/block.c       | 104 ++++++
 drivers/mmc/core/mmc.c         |   2 +
 drivers/mmc/host/sdhci-tegra.c |  10 +-
 include/linux/genhd.h          |  12 +
 include/linux/mmc/blkdev.h     |  15 +
 include/linux/mmc/card.h       |   2 +
 include/linux/mmc/host.h       |   2 +
 include/soc/tegra/bootdata.h   |  46 +++
 include/soc/tegra/common.h     |   9 +
 include/soc/tegra/partition.h  |  91 +++++
 18 files changed, 993 insertions(+), 4 deletions(-)
 create mode 100644 block/partitions/tegra.c
 create mode 100644 block/partitions/tegra.h
 create mode 100644 include/linux/mmc/blkdev.h
 create mode 100644 include/soc/tegra/bootdata.h
 create mode 100644 include/soc/tegra/partition.h

Comments

Dmitry Osipenko March 23, 2020, 4:49 p.m. UTC | #1
23.03.2020 19:34, Dmitry Osipenko пишет:
> Some NVIDIA Tegra devices have GPT entry at a wrong location and others may
> even not have it at all. So either a custom workaround for GPT parsing or
> TegraPT support is needed for those devices if we want to support them in
> upstream kernel. The former solution was already rejected [1], let's try
> the latter.
> 
> [1] https://patchwork.ozlabs.org/patch/1240809/
> 
> Big thanks to everyone who helped with figuring out the TegraPT format!
> 
> Changelog:
> 
> v3: - Fixed "BUG: KASAN: slab-out-of-bounds in tegra_partition". Thanks to
>       Peter Geis for noticing the problem.
> 
>     - The MMC boot partitions scanning is now opt-in. See this patch:
> 
>         mmc: block: Support partition-table scanning on boot partitions
> 
>     - The found MMC boot partitions won't be assigned to the MMC boot
>       block device ever due to the new GENHD_FL_PART_SCAN_ONCE flag.
> 
>       This makes us to ensure that the old behavior of the MMC core is
>       preserved for a non-Tegra MMC-block users.
> 
>     New patches in v3:
> 
>         block: Introduce GENHD_FL_PART_SCAN_ONCE
>         mmc: sdhci-tegra: Enable boot partitions scanning on Tegra20 and Tegra30

I forgot to mention that the TegraPT Kconfig entry now depends on MMC,
which was suggested by Randy Dunlap in the review comment to the v2.
Michał Mirosław March 23, 2020, 6:07 p.m. UTC | #2
On Mon, Mar 23, 2020 at 07:34:21PM +0300, Dmitry Osipenko wrote:
> Some NVIDIA Tegra devices have GPT entry at a wrong location and others may
> even not have it at all. So either a custom workaround for GPT parsing or
> TegraPT support is needed for those devices if we want to support them in
> upstream kernel. The former solution was already rejected [1], let's try
> the latter.
[...]

Hi Dmitry,

This amusing use of whole-device offsets in the TegraPT makes it take
a lot of hacks to support it. Have you considered to first join the MMC
hardware partitions using DM and its linear target and only then processing
the partition table dividing just the merged device?

Best Regards,
Michał Mirosław
Dmitry Osipenko March 23, 2020, 7:44 p.m. UTC | #3
23.03.2020 21:07, Michał Mirosław пишет:
> On Mon, Mar 23, 2020 at 07:34:21PM +0300, Dmitry Osipenko wrote:
>> Some NVIDIA Tegra devices have GPT entry at a wrong location and others may
>> even not have it at all. So either a custom workaround for GPT parsing or
>> TegraPT support is needed for those devices if we want to support them in
>> upstream kernel. The former solution was already rejected [1], let's try
>> the latter.
> [...]
> 
> Hi Dmitry,
> 
> This amusing use of whole-device offsets in the TegraPT makes it take
> a lot of hacks to support it. Have you considered to first join the MMC
> hardware partitions using DM and its linear target and only then processing
> the partition table dividing just the merged device?

Hello Michał,

Thank you very much for the suggestion! I had a thought about that and
it's not apparent to me how to determine when the joining needs to be
done and when not.

The joining shouldn't be done for devices that aren't booting from eMMC
because then the alt GPT entry will be found on a joined block device
and this shouldn't happen.

Actually, maybe we could create a new MMC device-tree property, telling
that the joining needs to be performed. Perhaps this indeed could result
in a less hackery, I'll give it a try and see how it goes.