From patchwork Tue Oct 1 16:38:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 831926 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp388442wrr; Tue, 1 Oct 2024 09:52:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVenN8tV/8wyeA7Fr+1gYrWNfADQnnHyI4ETi4hi6yAtW6dMUr8qcCE/ivzr5LqZGqFs9Qb2g==@linaro.org X-Google-Smtp-Source: AGHT+IHTrgLq2qFPkgcbMHVNToQoybPBKXtEd7t+M185ZlPz0iA2ZN7jlWCttDIsz/XgTEP2Bfc3 X-Received: by 2002:a05:6214:469d:b0:6cb:4b6e:9162 with SMTP id 6a1803df08f44-6cb81a48796mr912106d6.33.1727801544155; Tue, 01 Oct 2024 09:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727801544; cv=none; d=google.com; s=arc-20240605; b=dIn2A+c/MXvaBDOGAPIoVM7FZP3cnj+TONUvGIGIS6p+ZML5dvA9rkFU58pTXV8ZHg DiYXzzmY1K6CraBvbrlcqKn+f260Ds61f9UiXk7lJuqWoAgaE1B69vr2pXIkTgNZ79AX 4RjlVuBIOPSikIhYtfW/ayh/F3KBud2rlU0Gkw2Hp5wbxZK3Xg1aNZnpR3h7gp1Clcrn Fmi2kHCuV3ky5P29266hDkZE/dgmpGoEejGeRqExG9LN90ex2EulxlsMRh0yr1aMezWe PC4PSwdyH4tJoMW0DshzfNfA1Kd/WyKrflZu4hm5d95Ng4q0Yfb1rJtMexvdtpBrIjqB 4v9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vx5tPl8mZ4Syxp4bwv318p0goxHnVxqpE0gfsca6UPE=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=dUSrSbXKwFHVVaAe+o+zN8Qrym+oQ71Ml9vuEUjNzHWoLIVCLS1dciAGL7LbmI1y3I kmvLwxa8lKmZgJS5wZoExpdvZHeotgoUYn8uknh6qerJRpxCU8vPU+7O8Y00yPi6dWIo Z52vk2jrG1F2UtOtvSVAIvPWpNosu9lfvwD3NyCDW/oXi0FMFD1DKLHRhMKtjpfPCDA/ 6w4yAKtcb6uk5eJ5gmKso6npYztN6QePVt9OA7ruXWPWKzHCRZKdQjQrnpDkMPYcgfYo P+OlU8HB6uzCCC3b6QgmIqqHRjVgEJ79PT5Jvl6BITZhPjTu237fG5ROWbC79eImT3qE Pf7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mwuhm+OD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45d77e54bf5si17908221cf.40.2024.10.01.09.52.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Oct 2024 09:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mwuhm+OD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svfuL-0005Jg-5I; Tue, 01 Oct 2024 12:39:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svfuJ-0005Ih-2Y for qemu-devel@nongnu.org; Tue, 01 Oct 2024 12:39:27 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svfuH-00060i-CU for qemu-devel@nongnu.org; Tue, 01 Oct 2024 12:39:26 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42cafda818aso55225095e9.2 for ; Tue, 01 Oct 2024 09:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727800764; x=1728405564; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vx5tPl8mZ4Syxp4bwv318p0goxHnVxqpE0gfsca6UPE=; b=mwuhm+ODcwXmP54+2xl3t6vV6AQOfk0oaffhDRTb7aXgh75L5qsvBQ2RqH+Gv4r1tQ YqqQoffTPJ+w6Jm6cJNvLAOhD7kiEq6pGViXXDuaymfZDYxejsOFPZBKLdglegbP2iZh 1UQyADFEH452rseg6/0hlO32wp9WZRW11qZKtylGL3mcR3M4U134S3GyGM3StUtHh8jc CborEICenQ9PWMuodbnxeSalUs9BjBzuhI81lDEjy3MYq/5dQabyyTQsSwG9MTZa7Wcl LmoKGxfDAwx6ZmxfuJ+vou4ClEW3uRajTM6bRWwZaVtSN0/LAyoGlb5Ur+0pMB7mF1vR gfdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727800764; x=1728405564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vx5tPl8mZ4Syxp4bwv318p0goxHnVxqpE0gfsca6UPE=; b=ONKkL8LbQBYDMiaApv0g+YTebODDZFcLVFdObVzfG2SOfeYZ1kQUxuys39lGj+cEuv cBNoftHomdMGJzQzvuMiKa9iVYnFhiewaS6U4yWl6hf1UGQJTWGOGW8yUGXy1AQFbxIq NcyZVGRCdpUyAnusNfhtVnNrRprjpORAIdxQjcbQmT0rNLrmlMp8ZwddwhtGhw5Vb7VS e6z/5I6DN93+KySX3Bm3bGE9hV4CM6cJS/ROdxIIEE63gf2U7drGzwDbrGBonlZSBhP2 xrEeCt2f/doiZHR0EuiW8aZEToK5OY7S4JmszipC8NbtFfBQjn4G20KAreE4VwAA2AQD 9wNw== X-Gm-Message-State: AOJu0YwUzkKGA/dIe9jqtKzzTRDad40OmQI2D1wAAXiGaJGdGaGZxjQW IoSDMNXKx8MBAHJ2qjvm+W2wbPNGApd3TYnxjsYeYXSHLXrJPLfy9E1jDamG81W3A0CWgt4cP13 1 X-Received: by 2002:adf:a3c1:0:b0:37c:c9ab:e641 with SMTP id ffacd0b85a97d-37cfb823aeemr189070f8f.0.1727800763657; Tue, 01 Oct 2024 09:39:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e6547sm12243771f8f.58.2024.10.01.09.39.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:39:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/54] hw/sd/sdcard: Fix handling of disabled boot partitions Date: Tue, 1 Oct 2024 17:38:31 +0100 Message-Id: <20241001163918.1275441-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241001163918.1275441-1-peter.maydell@linaro.org> References: <20241001163918.1275441-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jan Luebbe 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. This bug is unlikely to affect many users with QEMU's current set of boards, because only aspeed sets boot-partition-size, and it also sets boot-config to 8. So to run into this a user would have to manually mark the boot partition non-booting from within the guest. Cc: qemu-stable@nongnu.org Signed-off-by: Jan Luebbe Message-id: 20240906164834.130257-1-jlu@pengutronix.de Reviewed-by: Peter Maydell [PMM: added note to commit message about effects of bug] Signed-off-by: Peter Maydell --- hw/sd/sd.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2dd7a8217cb..a5d2d929a8a 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) {