From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Hongbo Zhang" <hongbo.zhang@linaro.org>,
"Tanmay Jagdale" <tanmay.jagdale@linaro.org>,
qemu-block@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Radoslaw Biernacki" <radoslaw.biernacki@gmail.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Leif Lindholm" <leif@nuviainc.com>,
"Laszlo Ersek" <lersek@redhat.com>
Subject: [PATCH] hw/block/pflash_cfi01: Limit maximum flash size to 256 MiB
Date: Mon, 25 May 2020 17:58:26 +0200 [thread overview]
Message-ID: <20200525155826.11333-1-philmd@redhat.com> (raw)
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: Maximum 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é <philmd@redhat.com>
---
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 @@
*/
#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
+#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, Error **errp)
}
total_len = pfl->sector_len * pfl->nb_blocs;
+ if (total_len > PFLASH_SIZE_MAX) {
+ char *maxsz = size_to_str(PFLASH_SIZE_MAX);
+ error_setg(errp, "Maximum supported CFI flash size is %s.", maxsz);
+ g_free(maxsz);
+ return;
+ }
/* These are only used to expose the parameters of each device
* in the cfi_table[].
--
2.21.3
next reply other threads:[~2020-05-25 15:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 15:58 Philippe Mathieu-Daudé [this message]
2020-05-25 19:02 ` [PATCH] hw/block/pflash_cfi01: Limit maximum flash size to 256 MiB Laszlo Ersek
2020-05-25 20:59 ` Peter Maydell
2020-06-04 15:16 ` Philippe Mathieu-Daudé
2020-06-04 15:30 ` Peter Maydell
2020-06-04 15:55 ` Philippe Mathieu-Daudé
2020-06-04 16:03 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200525155826.11333-1-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=hongbo.zhang@linaro.org \
--cc=kwolf@redhat.com \
--cc=leif@nuviainc.com \
--cc=lersek@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=radoslaw.biernacki@gmail.com \
--cc=tanmay.jagdale@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).