From nobody Sat Nov 8 05:39:28 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550159920010178.3833391899143; Thu, 14 Feb 2019 07:58:40 -0800 (PST) Received: from localhost ([127.0.0.1]:50722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guJPA-0005fO-Oj for importer@patchew.org; Thu, 14 Feb 2019 10:58:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guJOK-0005MA-V0 for qemu-devel@nongnu.org; Thu, 14 Feb 2019 10:57:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1guJOJ-0001Vk-5C for qemu-devel@nongnu.org; Thu, 14 Feb 2019 10:57:36 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:37283) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1guJOF-0001Lt-QK for qemu-devel@nongnu.org; Thu, 14 Feb 2019 10:57:33 -0500 Received: by mail-wm1-x332.google.com with SMTP id x10so6544368wmg.2 for ; Thu, 14 Feb 2019 07:57:31 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t5sm3285397wmg.43.2019.02.14.07.57.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 07:57:28 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 26D821FF80; Thu, 14 Feb 2019 15:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5HzScgweH/LT3COUBSjLSx495c3HIR+EP5WTK2Cdz/g=; b=tis5n5zh/AboKjxFdUk/eYfeMLe02n3Mn6Em8u5Mk0s+Tujs/CzsAbsQOp6oK3p90f oKn5q5Muho+Lm4O0KuHfyvUKuDlEEr+LjDWdLBtNlJ4TbfdF/58Y6wiju/ItrLPdfDmk Vday3OW+US2y40NW4KuF1H/XO8DkNmaCmaoSEVcYfCe7/vHe78X+WAtgY7esQrYTNsH4 bRaQorTn9lSZVJ4oZLhzEUcoLPvEp7Wx84WUsX7U9rmIH+d27PTPS7DvHQQs99geSrhp FoPr+XImVt5PQquHC4LoI5NBazoboMiChzYq2W5FtPnq6gI7rHMGPgW3O2Vf01nLmv1I 72aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5HzScgweH/LT3COUBSjLSx495c3HIR+EP5WTK2Cdz/g=; b=nYd+tzUEbR18Mtnl8kGOYL1rkKtwN4E+ZUxNMca8sCLfjjE7kgs9wSoDvoMsPsAm+a 0YabPw8Qrun3tmuI2h6omXCJBnrF9NelyUTyv+TXXAsSWP3R1ni/ZmK5I8j2UbETi+3C lj4Nz6wU9C+WbnuhOzBAxMYhu3KGU0z3/emY9dMmEdjrxKG4bqWa/p38YnPI7bkElB2Y qYp/fUJP094f03ICa5wVxuyn4x8pneaIRk347QivAnOyjqDEl0e7IsJJ2R8dye9FlpCv z/mIpwmmi4rEPseWO+CNj7tS3+M8OQIIRHeFz7ey0jDU6vAU9h2EquMNbhFZZ3qObgTh BEjg== X-Gm-Message-State: AHQUAube0jQSIr6gX4tSP3GC1bYqeQw/1/bz+LFkLoaCRAa3P8mpS20I o0VJ1WotBtnYP4fOJu7wH8aUuQ== X-Google-Smtp-Source: AHgI3IbnV4bUMn4A5P8z+f6vwLr69k3MehNtg3jRxVam7XzDupyWDWk4lTWtEMssGLXolgIbILxpSg== X-Received: by 2002:a1c:a5c8:: with SMTP id o191mr3170037wme.137.1550159849213; Thu, 14 Feb 2019 07:57:29 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 14 Feb 2019 15:57:14 +0000 Message-Id: <20190214155714.8779-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PATCH] hw/block: report when pflash backing file isn't aligned X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkg-qemu-devel@lists.alioth.debian.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , ard.biesheuvel@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It looks like there was going to be code to check we had some sort of alignment so lets replace it with an actual check. This is a bit more useful than the enigmatic "failed to read the initial flash content" when we attempt to read the number of bytes the device should have. This is a potential confusing stumbling block when you move from using -bios to using -drive if=3Dpflash,file=3Dblob,format=3Draw,readonly for loading your firmware code. Signed-off-by: Alex Benn=C3=A9e --- hw/block/pflash_cfi01.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index bffb4c40e7..f3251b236c 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -722,12 +722,19 @@ static void pflash_cfi01_realize(DeviceState *dev, Er= ror **errp) } device_len =3D sector_len_per_device * blocks_per_device; =20 - /* XXX: to be fixed */ -#if 0 - if (total_len !=3D (8 * 1024 * 1024) && total_len !=3D (16 * 1024 * 10= 24) && - total_len !=3D (32 * 1024 * 1024) && total_len !=3D (64 * 1024 * 1= 024)) - return NULL; -#endif + /* + * Validate the backing store is the right size for pflash + * devices. It has to be padded to a multiple of the flash block + * size. + */ + if (pfl->blk) { + uint64_t backing_len =3D blk_getlength(pfl->blk); + if (device_len !=3D backing_len) { + error_setg(errp, "backing file wrong size " + "(%" PRId64 " !=3D %" PRId64")", backing_len, devic= e_len); + return; + } + } =20 memory_region_init_rom_device( &pfl->mem, OBJECT(dev), --=20 2.20.1