summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-01-27 03:56:13 +0000
committerLeah Rowe <leah@libreboot.org>2025-01-27 03:56:13 +0000
commit8850acc7da6a37859258c14b72dad267b3714c20 (patch)
tree940f740f709f46a07069149169076cbb17ae276f
parent49506a883283ebb3716de812fd809fba67da602c (diff)
util/nvmutil swap(): Only handle the nvm area
The 128-byte nvm area is all that we need to handle, since that is the only thing we actually work on in nvmutil, based on checksum verification; the latter implies that bytes must be in the correct order. The swap() function previously worked on the entire block, e.g. 4KB on 8KB files, 8KB on 16KB files and 64KB on 128KB files, and it did this twice, so it would have operated on anywhere between 8KB to 128KB of data. It now only operates on 256 bytes at a maximum, or 128 bytes if only handling one block. This is a significant performance optimisation, on big endian host CPUs. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 8e1fef4f..8350504b 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -437,6 +437,6 @@ swap(int partnum) /* swaps bytes in words, not pointers. */
size_t w, x;
uint8_t *n = (uint8_t *) gbe[partnum];
- for (w = nf * ((uint8_t *) &e)[0], x = 1; w < nf; w += 2, x += 2)
+ for (w = nf * ((uint8_t *) &e)[0], x = 1; w < 128; w += 2, x += 2)
n[w] ^= n[x], n[x] ^= n[w], n[w] ^= n[x];
}