* [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives
@ 2011-10-20 12:53 juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 1/2] hw/nand: " juha.riihimaki
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: juha.riihimaki @ 2011-10-20 12:53 UTC (permalink / raw)
To: qemu-devel
From: Juha Riihimäki <juha.riihimaki@nokia.com>
Make NAND and OneNAND device models reject read-only drives.
Test for example by running
$ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device nand,drive=foo,chip_id=0x59 -kernel /dev/null
or
$ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device onenand,drive=foo -kernel /dev/null
Changes v1->v2:
+ fix bug introduced in pagesize calculation for NAND devices without a drive image
+ revise commit message in hw/nand patch
Juha Riihimäki (2):
hw/nand: reject read-only drives
hw/onenand: reject read-only drives
hw/nand.c | 20 +++++++++++++-------
hw/onenand.c | 5 +++++
2 files changed, 18 insertions(+), 7 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] hw/nand: reject read-only drives
2011-10-20 12:53 [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives juha.riihimaki
@ 2011-10-20 12:53 ` juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 2/2] hw/onenand: " juha.riihimaki
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: juha.riihimaki @ 2011-10-20 12:53 UTC (permalink / raw)
To: qemu-devel
From: Juha Riihimäki <juha.riihimaki@nokia.com>
also gracefully fail on nand_device_init() for unsupported block
size instead of aborting.
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
hw/nand.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/nand.c b/hw/nand.c
index c27783e..fad00d1 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -19,6 +19,7 @@
# include "flash.h"
# include "blockdev.h"
# include "sysbus.h"
+#include "qemu-error.h"
# define NAND_CMD_READ0 0x00
# define NAND_CMD_READ1 0x01
@@ -384,18 +385,23 @@ static int nand_device_init(SysBusDevice *dev)
nand_init_2048(s);
break;
default:
- hw_error("%s: Unsupported NAND block size.\n", __func__);
+ error_report("Unsupported NAND block size");
+ return -1;
}
pagesize = 1 << s->oob_shift;
s->mem_oob = 1;
- if (s->bdrv && bdrv_getlength(s->bdrv) >=
+ if (s->bdrv) {
+ if (bdrv_is_read_only(s->bdrv)) {
+ error_report("Can't use a read-only drive");
+ return -1;
+ }
+ if (bdrv_getlength(s->bdrv) >=
(s->pages << s->page_shift) + (s->pages << s->oob_shift)) {
- pagesize = 0;
- s->mem_oob = 0;
- }
-
- if (!s->bdrv) {
+ pagesize = 0;
+ s->mem_oob = 0;
+ }
+ } else {
pagesize += 1 << s->page_shift;
}
if (pagesize) {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] hw/onenand: reject read-only drives
2011-10-20 12:53 [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 1/2] hw/nand: " juha.riihimaki
@ 2011-10-20 12:53 ` juha.riihimaki
2011-11-08 9:17 ` [Qemu-devel] [PATCH v2 0/2] nand/onenand: " Markus Armbruster
2011-11-14 3:02 ` andrzej zaborowski
3 siblings, 0 replies; 5+ messages in thread
From: juha.riihimaki @ 2011-10-20 12:53 UTC (permalink / raw)
To: qemu-devel
From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
hw/onenand.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/hw/onenand.c b/hw/onenand.c
index 6f68f70..7898da9 100644
--- a/hw/onenand.c
+++ b/hw/onenand.c
@@ -26,6 +26,7 @@
#include "memory.h"
#include "exec-memory.h"
#include "sysbus.h"
+#include "qemu-error.h"
/* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */
#define PAGE_SHIFT 11
@@ -772,6 +773,10 @@ static int onenand_initfn(SysBusDevice *dev)
s->image = memset(g_malloc(size + (size >> 5)),
0xff, size + (size >> 5));
} else {
+ if (bdrv_is_read_only(s->bdrv)) {
+ error_report("Can't use a read-only drive");
+ return -1;
+ }
s->bdrv_cur = s->bdrv;
}
s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives
2011-10-20 12:53 [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 1/2] hw/nand: " juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 2/2] hw/onenand: " juha.riihimaki
@ 2011-11-08 9:17 ` Markus Armbruster
2011-11-14 3:02 ` andrzej zaborowski
3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 9:17 UTC (permalink / raw)
To: juha.riihimaki; +Cc: andrew.zaborowski, peter.maydell, qemu-devel
[Adding a few cc's, hope it helps]
juha.riihimaki@nokia.com writes:
> From: Juha Riihimäki <juha.riihimaki@nokia.com>
>
> Make NAND and OneNAND device models reject read-only drives.
> Test for example by running
>
> $ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device nand,drive=foo,chip_id=0x59 -kernel /dev/null
>
> or
>
> $ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device onenand,drive=foo -kernel /dev/null
>
> Changes v1->v2:
> + fix bug introduced in pagesize calculation for NAND devices without a drive image
> + revise commit message in hw/nand patch
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives
2011-10-20 12:53 [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives juha.riihimaki
` (2 preceding siblings ...)
2011-11-08 9:17 ` [Qemu-devel] [PATCH v2 0/2] nand/onenand: " Markus Armbruster
@ 2011-11-14 3:02 ` andrzej zaborowski
3 siblings, 0 replies; 5+ messages in thread
From: andrzej zaborowski @ 2011-11-14 3:02 UTC (permalink / raw)
To: juha.riihimaki; +Cc: qemu-devel, Markus Armbruster
On 20 October 2011 14:53, <juha.riihimaki@nokia.com> wrote:
> From: Juha Riihimäki <juha.riihimaki@nokia.com>
>
> Make NAND and OneNAND device models reject read-only drives.
> Test for example by running
>
> $ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device nand,drive=foo,chip_id=0x59 -kernel /dev/null
>
> or
>
> $ qemu-system-arm -drive if=none,file=/dev/zero,readonly,id=foo -device onenand,drive=foo -kernel /dev/null
>
> Changes v1->v2:
> + fix bug introduced in pagesize calculation for NAND devices without a drive image
> + revise commit message in hw/nand patch
Thanks, applied.
Cheers
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-14 3:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20 12:53 [Qemu-devel] [PATCH v2 0/2] nand/onenand: reject read-only drives juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 1/2] hw/nand: " juha.riihimaki
2011-10-20 12:53 ` [Qemu-devel] [PATCH v2 2/2] hw/onenand: " juha.riihimaki
2011-11-08 9:17 ` [Qemu-devel] [PATCH v2 0/2] nand/onenand: " Markus Armbruster
2011-11-14 3:02 ` andrzej zaborowski
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).