Browse Source

fix(mmc): remove broken, unsecure, unused eMMC RPMB handling

Replay-protected memory block access is enabled by writing 0x3
to PARTITION_ACCESS (bit[2:0]). Instead the driver is using the
first boot partition, which does not provide any playback protection.
Additionally, it unconditionally activates the first boot partition,
potentially breaking boot for SoCs that consult boot partitions,
require boot ack or downgrading to an old bootloader if the first
partition happens to be the inactive one.

Also, neither enabling or disabling the RPMB observes the
PARTITION_SWITCH_TIME. As there are no in-tree users for these
functions, drop them for now until a properly functional implementation
is added. That one will likely share most code with the existing boot
partition switch, which doesn't suffer from the described issues.

Change-Id: Ia4a3f738f60a0dbcc33782f868cfbb1e1c5b664a
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
pull/1986/head
Ahmad Fatoum 2 years ago
parent
commit
86b015eb1b
  1. 46
      drivers/mmc/mmc.c
  2. 3
      include/drivers/mmc.h

46
drivers/mmc/mmc.c

@ -694,52 +694,6 @@ size_t mmc_erase_blocks(int lba, size_t size)
return size; return size;
} }
static inline void mmc_rpmb_enable(void)
{
mmc_set_ext_csd(CMD_EXTCSD_PARTITION_CONFIG,
PART_CFG_BOOT_PARTITION1_ENABLE |
PART_CFG_BOOT_PARTITION1_ACCESS);
}
static inline void mmc_rpmb_disable(void)
{
mmc_set_ext_csd(CMD_EXTCSD_PARTITION_CONFIG,
PART_CFG_BOOT_PARTITION1_ENABLE);
}
size_t mmc_rpmb_read_blocks(int lba, uintptr_t buf, size_t size)
{
size_t size_read;
mmc_rpmb_enable();
size_read = mmc_read_blocks(lba, buf, size);
mmc_rpmb_disable();
return size_read;
}
size_t mmc_rpmb_write_blocks(int lba, const uintptr_t buf, size_t size)
{
size_t size_written;
mmc_rpmb_enable();
size_written = mmc_write_blocks(lba, buf, size);
mmc_rpmb_disable();
return size_written;
}
size_t mmc_rpmb_erase_blocks(int lba, size_t size)
{
size_t size_erased;
mmc_rpmb_enable();
size_erased = mmc_erase_blocks(lba, size);
mmc_rpmb_disable();
return size_erased;
}
static int mmc_part_switch(unsigned int part_type) static int mmc_part_switch(unsigned int part_type)
{ {
uint8_t part_config = mmc_ext_csd[CMD_EXTCSD_PARTITION_CONFIG]; uint8_t part_config = mmc_ext_csd[CMD_EXTCSD_PARTITION_CONFIG];

3
include/drivers/mmc.h

@ -234,9 +234,6 @@ struct mmc_device_info {
size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size); size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size);
size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size); size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size);
size_t mmc_erase_blocks(int lba, size_t size); size_t mmc_erase_blocks(int lba, size_t size);
size_t mmc_rpmb_read_blocks(int lba, uintptr_t buf, size_t size);
size_t mmc_rpmb_write_blocks(int lba, const uintptr_t buf, size_t size);
size_t mmc_rpmb_erase_blocks(int lba, size_t size);
int mmc_part_switch_current_boot(void); int mmc_part_switch_current_boot(void);
int mmc_part_switch_user(void); int mmc_part_switch_user(void);
size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size); size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size);

Loading…
Cancel
Save