qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/sd/sdcard: Fix handling of disabled boot partitions
@ 2024-09-06 16:48 Jan Luebbe
  2024-09-30 14:18 ` Peter Maydell
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Luebbe @ 2024-09-06 16:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jan Luebbe, Philippe Mathieu-Daudé, Bin Meng, qemu-block

The enable bits in the EXT_CSD_PART_CONFIG ext_csd register do *not*
specify whether the boot partitions exist, but whether they are enabled
for booting. Existence of the boot partitions is specified by a
EXT_CSD_BOOT_MULT != 0.

Currently, in the case of boot-partition-size=1M and boot-config=0,
Linux detects boot partitions of 1M. But as sd_bootpart_offset always
returns 0, all reads/writes are mapped to the same offset in the backing
file.

Fix this bug by calculating the offset independent of which partition is
enabled for booting.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 hw/sd/sd.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index a140a32ccd46..26d6eebe898d 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -774,19 +774,12 @@ static uint32_t sd_blk_len(SDState *sd)
  */
 static uint32_t sd_bootpart_offset(SDState *sd)
 {
-    bool partitions_enabled;
     unsigned partition_access;
 
     if (!sd->boot_part_size || !sd_is_emmc(sd)) {
         return 0;
     }
 
-    partitions_enabled = sd->ext_csd[EXT_CSD_PART_CONFIG]
-                                   & EXT_CSD_PART_CONFIG_EN_MASK;
-    if (!partitions_enabled) {
-        return 0;
-    }
-
     partition_access = sd->ext_csd[EXT_CSD_PART_CONFIG]
                                  & EXT_CSD_PART_CONFIG_ACC_MASK;
     switch (partition_access) {
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-03 21:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 16:48 [PATCH] hw/sd/sdcard: Fix handling of disabled boot partitions Jan Luebbe
2024-09-30 14:18 ` Peter Maydell
2024-09-30 20:01   ` Jan Lübbe
2024-10-01 13:01     ` Peter Maydell
2024-10-03 21:31       ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).