From: Vijay Kumar <vijaykumar@bravegnu.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Check block driver read error in pflash_cfi0x
Date: Fri, 21 Aug 2009 10:27:38 +0530 [thread overview]
Message-ID: <4A8E2942.8020808@bravegnu.org> (raw)
If a flash file of size smaller than the flash size is specified in
the -pflash option, the block driver returns error. But the
pflash_cfi0x ignores the error. This results in a flash content of all
zeroes. And the simulation aborts while executing code.
This patch adds the checks for errors from bdrv_read and escalates it
to the calling code.
Signed-off-by: Vijay Kumar B. <vijaykumar@bravegnu.org>
Index: qemu/hw/pflash_cfi01.c
===================================================================
--- qemu.orig/hw/pflash_cfi01.c 2009-08-21 09:12:59.000000000 +0530
+++ qemu/hw/pflash_cfi01.c 2009-08-21 10:19:34.000000000 +0530
@@ -507,6 +507,7 @@
{
pflash_t *pfl;
target_phys_addr_t total_len;
+ int ret;
total_len = sector_len * nb_blocs;
@@ -530,7 +531,12 @@
pfl->bs = bs;
if (pfl->bs) {
/* read the initial flash content */
- bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
+ ret = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
+ if (ret < 0) {
+ cpu_unregister_io_memory(pfl->fl_mem);
+ qemu_free(pfl);
+ return NULL;
+ }
}
#if 0 /* XXX: there should be a bit to set up read-only,
* the same way the hardware does (with WP pin).
Index: qemu/hw/pflash_cfi02.c
===================================================================
--- qemu.orig/hw/pflash_cfi02.c 2009-08-21 09:39:04.000000000 +0530
+++ qemu/hw/pflash_cfi02.c 2009-08-21 10:19:42.000000000 +0530
@@ -547,6 +547,7 @@
{
pflash_t *pfl;
int32_t chip_len;
+ int ret;
chip_len = sector_len * nb_blocs;
/* XXX: to be fixed */
@@ -568,7 +569,12 @@
pfl->bs = bs;
if (pfl->bs) {
/* read the initial flash content */
- bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
+ ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
+ if (ret < 0) {
+ cpu_unregister_io_memory(pfl->fl_mem);
+ qemu_free(pfl);
+ return NULL;
+ }
}
#if 0 /* XXX: there should be a bit to set up read-only,
* the same way the hardware does (with WP pin).
next reply other threads:[~2009-08-21 4:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-21 4:57 Vijay Kumar [this message]
2009-08-23 15:54 ` [Qemu-devel] [PATCH] Check block driver read error in pflash_cfi0x andrzej zaborowski
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=4A8E2942.8020808@bravegnu.org \
--to=vijaykumar@bravegnu.org \
--cc=qemu-devel@nongnu.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).