Hello Carl-Daniel Hailfinger, ron minnich, David Hendricks,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/flashrom/+/33614
to review the following change.
Change subject: dediprog: Bail out on unsupported, long transfers
......................................................................
dediprog: Bail out on unsupported, long transfers
Change-Id: I7b16701597909c015f98199e73ebb7d923f2b072
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M dediprog.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/14/33614/1
diff --git a/dediprog.c b/dediprog.c
index 8552a3c..8029b64 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -362,7 +362,15 @@
static int prepare_rw_cmd(
struct flashctx *const flash, uint8_t *data_packet, unsigned int count,
- uint8_t dedi_spi_cmd, unsigned int *value, unsigned int *idx, unsigned int start, int is_read) {
+ uint8_t dedi_spi_cmd, unsigned int *value, unsigned int *idx, unsigned int start, int is_read)
+{
+ if (count >= 1 << 16) {
+ msg_perr("%s: Unsupported transfer length of %u blocks! "
+ "Please report a bug at flashrom(a)flashrom.org\n",
+ __func__, count);
+ return 1;
+ }
+
/* First 5 bytes are common in both generations. */
data_packet[0] = count & 0xff;
data_packet[1] = (count >> 8) & 0xff;
--
To view, visit https://review.coreboot.org/c/flashrom/+/33614
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I7b16701597909c015f98199e73ebb7d923f2b072
Gerrit-Change-Number: 33614
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: ron minnich <rminnich(a)chromium.org>
Gerrit-MessageType: newchange
Hello Carl-Daniel Hailfinger, ron minnich, David Hendricks,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/flashrom/+/33613
to review the following change.
Change subject: spi: Move 16MiB partitioning up into spi_chip_read()
......................................................................
spi: Move 16MiB partitioning up into spi_chip_read()
We enforced a 16MiB limit in spi_read_chunked() for multi-die flash
chips that can't be fully read at once. The same limit can be useful
for dediprog programmers. So move it into a more generic place.
Untested.
Change-Id: Iab1fd5b2ea550b4b3ef3e8402e0b6ca218485a51
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M flash.h
M spi.c
M spi25.c
3 files changed, 21 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/13/33613/1
diff --git a/flash.h b/flash.h
index 5bbfa0a..3a7713e 100644
--- a/flash.h
+++ b/flash.h
@@ -37,6 +37,9 @@
#include "libflashrom.h"
#include "layout.h"
+#define KiB (1024)
+#define MiB (1024 * KiB)
+
#define ERROR_PTR ((void*)-1)
/* Error codes */
diff --git a/spi.c b/spi.c
index a4dba19..cdf43c6 100644
--- a/spi.c
+++ b/spi.c
@@ -99,7 +99,15 @@
int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start,
unsigned int len)
{
- return flash->mst->spi.read(flash, buf, start, len);
+ int ret;
+ size_t to_read;
+ for (; len; len -= to_read, buf += to_read, start += to_read) {
+ to_read = min(16*MiB, len);
+ ret = flash->mst->spi.read(flash, buf, start, to_read);
+ if (ret)
+ return ret;
+ }
+ return 0;
}
/*
diff --git a/spi25.c b/spi25.c
index fd87dc9..cca2a04 100644
--- a/spi25.c
+++ b/spi25.c
@@ -657,43 +657,20 @@
/*
* Read a part of the flash chip.
- * FIXME: Use the chunk code from Michael Karcher instead.
- * Each naturally aligned area is read separately in chunks with a maximum size of chunksize.
+ * Data is read in chunks with a maximum size of chunksize.
*/
int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start,
unsigned int len, unsigned int chunksize)
{
- int rc = 0;
- unsigned int i, j, starthere, lenhere, toread;
- /* Limit for multi-die 4-byte-addressing chips. */
- unsigned int area_size = min(flash->chip->total_size * 1024, 16 * 1024 * 1024);
-
- /* Warning: This loop has a very unusual condition and body.
- * The loop needs to go through each area with at least one affected
- * byte. The lowest area number is (start / area_size) since that
- * division rounds down. The highest area number we want is the area
- * where the last byte of the range lives. That last byte has the
- * address (start + len - 1), thus the highest area number is
- * (start + len - 1) / area_size. Since we want to include that last
- * area as well, the loop condition uses <=.
- */
- for (i = start / area_size; i <= (start + len - 1) / area_size; i++) {
- /* Byte position of the first byte in the range in this area. */
- /* starthere is an offset to the base address of the chip. */
- starthere = max(start, i * area_size);
- /* Length of bytes in the range in this area. */
- lenhere = min(start + len, (i + 1) * area_size) - starthere;
- for (j = 0; j < lenhere; j += chunksize) {
- toread = min(chunksize, lenhere - j);
- rc = spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread);
- if (rc)
- break;
- }
- if (rc)
- break;
+ int ret;
+ size_t to_read;
+ for (; len; len -= to_read, buf += to_read, start += to_read) {
+ to_read = min(chunksize, len);
+ ret = spi_nbyte_read(flash, start, buf, to_read);
+ if (ret)
+ return ret;
}
-
- return rc;
+ return 0;
}
/*
--
To view, visit https://review.coreboot.org/c/flashrom/+/33613
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Iab1fd5b2ea550b4b3ef3e8402e0b6ca218485a51
Gerrit-Change-Number: 33613
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: ron minnich <rminnich(a)chromium.org>
Gerrit-MessageType: newchange
Nico Huber has abandoned this change. ( https://review.coreboot.org/c/flashrom/+/30154 )
Change subject: libflashrom.h: Remove line breaks in function signatures
......................................................................
Abandoned
followed an undefined rule
--
To view, visit https://review.coreboot.org/c/flashrom/+/30154
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9d9afb884d92f1edc3a806fa7e2d43808748d0f9
Gerrit-Change-Number: 30154
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: abandon
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/23693 )
Change subject: improve termios settings on some OSes
......................................................................
Patch Set 2:
Any terminal experts around? :)
--
To view, visit https://review.coreboot.org/c/flashrom/+/23693
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5da80f541e02c3b8e676e47a45388bfb115b4762
Gerrit-Change-Number: 23693
Gerrit-PatchSet: 2
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Jonathan A. Kollasch <jakllsch(a)kollasch.net>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Urja Rannikko <urjaman(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Thu, 20 Jun 2019 19:36:15 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment