From nobody Mon May 6 19:05:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590422371; cv=none; d=zohomail.com; s=zohoarc; b=VqXCF9hIWj58+dauZY7NCdMznpvtCRsg5lj0cLBXArUzdXEqH+uBtMVdF3WfXoCwc5iSjRgF2er7dRk1F4TSd6CKoLZsVyasTz1brARoqPh8/+dMAvaN4ICyFx2m6s3iAzzW+syZuu4rgi5vgBAaqMk2mi7+aO9r07BCjgcM6TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590422371; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=rRrseoAnbJR0ukjPrBzVp2SnpxDePVZX4bWjCZH11to=; b=dIuJ3P24U6ZMgHWZjmkPVx/1r+69y1uRhP9xoqgDzUfv1xY0RJkOLTgSy4xnD8QSlPf5vO1S0WNtQXMpc584rLerOrTSUKahKXIRjeZ0xf9YNgOKwHCcQU8Rhglu0pDBwnTIy7rnhsv+1oiATUuDrIP/0OYD2NBxgVZ+uDn74tA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590422371686795.5171298471988; Mon, 25 May 2020 08:59:31 -0700 (PDT) Received: from localhost ([::1]:51788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdFVh-00044I-Co for importer@patchew.org; Mon, 25 May 2020 11:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdFUp-0003Ht-2E for qemu-devel@nongnu.org; Mon, 25 May 2020 11:58:35 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:27218 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jdFUn-000197-U4 for qemu-devel@nongnu.org; Mon, 25 May 2020 11:58:34 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-3KkScyVZPtK8OyiDGb1AEg-1; Mon, 25 May 2020 11:58:31 -0400 Received: by mail-ed1-f72.google.com with SMTP id f18so7635806eds.6 for ; Mon, 25 May 2020 08:58:30 -0700 (PDT) Received: from x1w.redhat.com (71.red-88-21-204.staticip.rima-tde.net. [88.21.204.71]) by smtp.gmail.com with ESMTPSA id s19sm13923953edx.92.2020.05.25.08.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 08:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590422312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rRrseoAnbJR0ukjPrBzVp2SnpxDePVZX4bWjCZH11to=; b=arEYgp7yWqKzrYTfRJzlU9QJtgJTLhU8IfWJvTgDdLMmk6JW9t5pCcNXaPFmeo24NW6cKx FTZLMV3WLtD3H+7qTyFHTDEkENfWp9TVQ82Yo29XAitX1Chrn/I3VB4RjnDGqGkUKX7Otg 0V/4OPIKaJceSTimJAQMb5Quu357rk0= X-MC-Unique: 3KkScyVZPtK8OyiDGb1AEg-1 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=rRrseoAnbJR0ukjPrBzVp2SnpxDePVZX4bWjCZH11to=; b=JWvx9F+ALW8QX4qhuNjt0eUHPtyqlZ15UTTtJY3AUOXg0BeavteaBqQEaOyOizB3mV zpZmSl9OrIL2KWwPAKmhd3gX+SjWg5F+WH2fxISU5Bw4Wasd5vSU8G7/zqBiQZ5we9nz M7nQB8rMBTCwerL0P1bW7rGHnL1M7uVovlalfyl/FwfoJa/qw8KqeMHxGF+WfiDTZNJ3 4WKeWh5qSxFbrbvPu5tr2a6omuKe2nyts7gHtDeyOCems6S/GLpKzg039xTGujqfIz40 cv1j7ycQWfuoLBVl7GSGWB0yPqzf4VGzZsKkEAiwlxsjXRZd4EHXNWPCXKranNUG5676 KAuQ== X-Gm-Message-State: AOAM531PYZscnTV+P/3MaOUcuJKbE3j5O1oDLxbU8wAASsewnVM/s1fF EykXED66KyjmT66hHUEUjEwv9AV6btylOzpQi4hXwpOMN0ByzyfPW9AXH9hQDvJIR+ossVAdWjH OCri5kRdYbfev0Uk= X-Received: by 2002:a17:906:b4c:: with SMTP id v12mr18559752ejg.25.1590422309772; Mon, 25 May 2020 08:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYrBI41qysSi/fEwZAekUm40KpsZETK7kuVO54dxNUtuOurLaucuM8IFBuDX3KOHqp56l63g== X-Received: by 2002:a17:906:b4c:: with SMTP id v12mr18559691ejg.25.1590422308568; Mon, 25 May 2020 08:58:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH] hw/block/pflash_cfi01: Limit maximum flash size to 256 MiB Date: Mon, 25 May 2020 17:58:26 +0200 Message-Id: <20200525155826.11333-1-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/25 02:40:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Hongbo Zhang , Tanmay Jagdale , qemu-block@nongnu.org, Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Radoslaw Biernacki , Markus Armbruster , Max Reitz , Leif Lindholm , Laszlo Ersek Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As of this commit, the biggest CFI01 NOR flash documented is the Micron PC28F00BP33EF. Its size is 2 GiB (256 MiB). Actually this "2Gb device employs a virtual chip enable feature, which combines two 1Gb die with a common chip enable". Since we do not want to model unrealistic hardware, cap the current model to this maximum. At least we have a datasheet to refer. If a bigger flash is provided, the user get this warning: qemu-system-aarch64: Initialization of device cfi.pflash01 failed: Maximu= m supported CFI flash size is 16 MiB. Note, the sbsa-ref ARM machine introduced in commit 64580903c2b already uses a pair of 256 MiB flash devices. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laszlo Ersek --- hw/block/pflash_cfi01.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 11922c0f96..40f145dde7 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -37,6 +37,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" +#include "qemu/cutils.h" #include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" @@ -68,6 +70,8 @@ do { = \ #define PFLASH_BE 0 #define PFLASH_SECURE 1 =20 +#define PFLASH_SIZE_MAX (256 * MiB) /* Micron PC28F00BP33EF */ + struct PFlashCFI01 { /*< private >*/ SysBusDevice parent_obj; @@ -717,6 +721,12 @@ static void pflash_cfi01_realize(DeviceState *dev, Err= or **errp) } =20 total_len =3D pfl->sector_len * pfl->nb_blocs; + if (total_len > PFLASH_SIZE_MAX) { + char *maxsz =3D size_to_str(PFLASH_SIZE_MAX); + error_setg(errp, "Maximum supported CFI flash size is %s.", maxsz); + g_free(maxsz); + return; + } =20 /* These are only used to expose the parameters of each device * in the cfi_table[]. --=20 2.21.3