3931 Commits

Author SHA1 Message Date
Leah Rowe
3efa7754cd util/nvmutil: configurable eintr/eagain
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 16:04:56 +00:00
Leah Rowe
c33e60531a util/nvmutil: configurable retries/pread
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 16:01:19 +00:00
Leah Rowe
144965d9e6 util/nvmutil: support real pwrite/pread
build flag

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 15:52:10 +00:00
Leah Rowe
6d456e403b util/nvmutil: better commented I/O functions
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 15:33:38 +00:00
Leah Rowe
228bed20fe util/nvmutil: make eintr/eagain setup clearer
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 15:07:12 +00:00
Todd Baker
f0ff5fca6a Add Dell OptiPlex 3040 Micro support
Adds libreboot support for the Dell OptiPlex 3040 Micro based on the
OptiPlex 3050 Micro (same Skylake H110 PCH-H platform). Key differences:
DDR3L SODIMMs, Pentium G4400T-class CPUs (Skylake only), Realtek ALC3234
HDA, and Boot Guard neutralization via deguard.

Tested and booted on hardware.

Signed-off-by: Todd Baker <todd_baker@student.uml.edu>
2026-03-14 04:57:22 -04:00
Leah Rowe
bdd23b234b nvmutil: fix rval in close_files
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 07:28:06 +00:00
Leah Rowe
fbc0a62ab0 util/nvmutil: don't check write checksums on partial
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 07:24:37 +00:00
Leah Rowe
90ed69474c util/nvmutil: don't recurse err/close_files
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 07:20:50 +00:00
Leah Rowe
1a8896b82d util/nvmutil: restore pad before reading to it
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 06:40:21 +00:00
Leah Rowe
0d908923a3 util/nvmutil: don't show checksum on bad pwrite
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 06:33:25 +00:00
Leah Rowe
4af9f431da util/nvmutil: always restore saved errno
the last lseek there is only there to reset
state, so its errors are irrelevant.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 06:21:58 +00:00
Leah Rowe
b1725b6a84 util/nvmutil: post-write verification report
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 06:13:25 +00:00
Leah Rowe
ee511881b3 util/nvmutil: optimise fsync / write check
write all at once, then sync all at once,
then verify all at once.

this increases the chancce that all data
gets written first, in the case of power
less, because fsync may take a while on
some systems.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 04:47:28 +00:00
Leah Rowe
05b39d2ff2 util/nvmutil: set EIO on bad memcmp
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 04:06:29 +00:00
Leah Rowe
55564d4064 util/nvmutil: split up rw_gbe_file_part
the post-verification stage deserves a function

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 03:55:12 +00:00
Leah Rowe
eb8a297ba0 util/nvmutil: detect partial gbe rw
we already covered this in prw() which is
what ultimately gets called, but still.

it's logically correct not to check it here.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 03:40:46 +00:00
Leah Rowe
76a00c48b4 util/nvmutil: verify gbe contents after writing
read it back and check. sync to disk first.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 03:26:07 +00:00
Leah Rowe
36f48e055f util/nvmutil: consistent types
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 02:51:53 +00:00
Leah Rowe
c1ff35b781 util/nvmutil: handle zero return in rw_file_exact
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 01:18:57 +00:00
Leah Rowe
ad44c1f9b4 util/nvmutil: rename lseek_eintr
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 01:04:03 +00:00
Leah Rowe
3cb7508ec7 util/nvmutil: fix lseek eintr err check
it should be is equal, not not equal

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 01:03:18 +00:00
Leah Rowe
8d6b28fcf7 util/nvmutil: rename err_eagain() to try_err()
makes more sense in code

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:59:28 +00:00
Leah Rowe
f01657c826 util/nvmutil: make EINTR configurable in prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:55:50 +00:00
Leah Rowe
b89e965ed7 util/nvmutil: tidy up prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:40:00 +00:00
Leah Rowe
69ff774ad3 util/nvmutil: extra overflow check in prw
compliant posix systems should never meet this
check, but i put it here.

spec != implementation

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:23:54 +00:00
Leah Rowe
ba2100fbf5 util/nvmutil: extra overflow check in prw
do it at the very end

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:21:10 +00:00
Leah Rowe
3704119436 util/nvmutil: handle EAGAIN in prw()
the cat function can be greatly simplified

handle it conditionally, because not all
functions should use it

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-14 00:21:02 +00:00
Leah Rowe
eadcf89e98 util/nvmutil: split up rw_file_exact
move the gbe-specific parts out of it

what remains is a relatively generic
function; a very conservative implementation,
wrapping around libc functions but with
a few additional safety checks.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 23:34:41 +00:00
Leah Rowe
f8ba774796 util/nvmutil: add negative off check to prw
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 23:22:21 +00:00
Leah Rowe
7fe667789a util/nvmutil: also do libc check on normal io
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 23:18:06 +00:00
Leah Rowe
692632275c util/nvmutil: properly reset lseek on error
don't return. set r instead. this will fall through
and return the same way, but with proper reset.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 23:02:26 +00:00
Leah Rowe
0450c2bef1 util/nvmutil: move libc check to prw()
this still gets done from rw_once, but
it's generic enough that we want it in
our prw() wrapper function.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 22:59:48 +00:00
Leah Rowe
cd74a2a641 util/nvmutil: remove io_args()
most of it can be done in rw_file_once

truly general checks have been moved to prw(),
so that the function is more general purpose.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 22:53:17 +00:00
Leah Rowe
e170ca00e6 util/nvmutil: move EINTR handle to prw()
this way, we now have a universal function
that is reusable elsewhere, with the same
redundancy. the rw_once and rw_exact functions
still get this redundancy, through prw

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 22:45:28 +00:00
Leah Rowe
5ff679e4db util/nvmutil: simplify i/o
we can just fall through to nrw and decide
what function ta call there - either read/write
immediately and return, or fall back to the
portable positional implementation.

this also means we don't have to call io_args
in every function, since everything now runs
through prw()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 22:16:09 +00:00
Leah Rowe
c8e6a6870f util/nvmutil: cast rnum pointer check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 21:03:06 +00:00
Leah Rowe
2a2b37127b util/nvmutil: allow ushort to be 32-bit
no need to limit it here

rename ux to uint. no number specified.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 19:53:35 +00:00
Leah Rowe
19f888d52d util/nvmutil: fix int assert
it can be higher than 32-bit, it's fine

the current check breaks some newer systems

accordingly, u32 becomes ux, x meaning x bits

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 19:46:47 +00:00
Leah Rowe
a9a4cfc614 util/nvmutil: more asserts
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 19:43:44 +00:00
Leah Rowe
5cf2905379 util/nvmutil: nicer typedefs
now that i'm not using stdint, i can use sane
typedef names

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 19:42:00 +00:00
Leah Rowe
dca488ee50 util/nvmutil: remove stdint feature macro
and remove stdint

i don't need it. i typedef these ints myself
and i assert their size

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 19:30:15 +00:00
Leah Rowe
130b25e676 util/nvmutil: safer offset check (use subtraction)
don't allow overflows

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 17:56:35 +00:00
Leah Rowe
dfbdffc6a6 util/nvmutil: check null pointer in io_args
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 17:53:19 +00:00
Leah Rowe
5287a80a7e util/nvmutil: check overflow in io_args
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 17:52:23 +00:00
Leah Rowe
e64b9b3e15 util/nvmutil: fix offset validation
i didn't take into account partial writes, in io_args

this fixes it

unfortunately, this means i have to loosen the offset
check a bit, but it's fine

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 17:46:08 +00:00
Leah Rowe
6b158a8610 util/nvmutil: restrict pointers in io_args
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 17:31:44 +00:00
Leah Rowe
7302714e48 util/nvmutil: check gbe file type before write
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 16:20:30 +00:00
Leah Rowe
d3a0cce466 util/nvmutil: check gbe file size before write
re-check. very unlikely since the program doesn't run
for very long, but we have to check if the file has
changed. this is a basic check of file size.

we could probably check the contents too, but that
would be overkill.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 16:17:05 +00:00
Leah Rowe
d894240574 util/nvmutil: lock gbe file
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-13 15:52:28 +00:00