Repository navigation
fix(svdconv): guard bit masks and bound dimension expansion - #2659
Conversation
Test Results 4 files - 41 40 suites - 121 40s ⏱️ - 18m 45s Results for commit 43c3f60. ± Comparison against base commit 8f4936a. This pull request removes 1453 and adds 69 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Propagate SFD file creation failures and validate actual expression operands before opening output. Discard the entire condition when an operand cannot be generated. Add regressions for invalid field and register operands, failed output creation, and stale SFD preservation. Release and UBSan pass 210 active unit tests and 48 integration tests.
Retain checked wide intermediate arithmetic while restoring 32-bit header interfaces and field expressions. Remove the added 64-bit default-mask extension and document the Cortex-M scope. Cover 32-bit output boundaries, rejected wider ranges and full-width write-mask sign extension. Release and UBSan each pass 211 active unit tests and 48 integration tests.
Reject references through absent register or field containers before accessing the first child. Invalid inherited fields can leave these containers empty and trigger an end-iterator assertion on MSVC. Add regression coverage for both register and peripheral lookup paths.
Check raw model offsets and signed widths against the 32-bit header range before converting them. Insert fields without replacing existing map entries, and cover negative widths, large aliasing offsets, and overlapping field groups.
…ix/svdconv-input-bounds
…s check' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Keep field positions and masks wide across grouping, padding, generator interfaces and formatting, while preserving the 32-bit output range. Accept signed widths in the mask helper without narrowing and guard unsigned padding calculations. Remove redundant enum validation and successful 64-bit input assumptions from tests. Restore the already-correct reset-value mask calculation and retain all required expansion and output-failure checks.
|
The Copilot review from 20 October applies to commit
Both threads are resolved and have regression-test details in the linked replies. The old overview still says "2 open issues", so it has been collapsed as outdated; its original text remains available. This is a status clarification, not a new Copilot assessment. A new Copilot review is currently unavailable because GitHub reports "Monthly limit reached". |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2659 +/- ##
==========================================
+ Coverage 86.30% 87.45% +1.15%
==========================================
Files 207 207
Lines 33322 33533 +211
==========================================
+ Hits 28757 29325 +568
+ Misses 4565 4208 -357
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
SVDConv could overflow or sign-extend field masks, wrap dimension indices and addresses, and create excessive
model copies for nested dimensions. This change validates supported 32-bit register and field ranges before
generation, uses overflow-safe arithmetic, and bounds model expansion before output.
Related to #2647 and the security and code-quality tracking issue.
Changes
SvdUtils::GetBitRange32()beforenarrowing. Preserve existing 32-bit generator interfaces and formatting, raw getter contracts and unset sentinels.
Existing internal 64-bit preparation remains; this PR does not add 64-bit input/output support.
calculating reserved padding. Bound automatically generated enum lists with
MAX_BITWIDTH_FOR_COMBObefore shifting.Preserve the existing
dimIncrementunit interpretation.and inherited content. M249 aborts before any generator runs; M250 reports invalid or overflowing dimension ranges.
This bounds expansion work, not XML size or total process memory.
invalid, handle missing inherited child containers, and propagate output-opening failures so SFR compilation
cannot consume a stale SFD.
models, and failed/stale SFD generation. Document the checked range boundary and its possible model-level cleanup
in
tools/svdconv/docs/todo.md.Validation
For
35b0cac3:One existing unit test remains disabled. Header regressions cover overwide fields, overlaps and valid padding.
rejection before generation, and successful conversion of the next input. Test dimensions derive from the limit.
50a6cba7processed 404 installed SVD paths, producing 404 nonempty headersand 403 nonempty SFD files, with no crashes or timeouts. Generated pack headers were not compiled, and SFD files
were not loaded into a debugger.
ARM/V2M_MPS3_SSE_300_BSP/1.5.0/SVD/SSE300.svdpreviously generated an incorrect SFD: its 64-bitCNTCVregisters used
unsigned intdeclarations and zero masks (& 0x0). The new check reports M226 and prevents thatincorrect SFD. The header already omitted these registers, replacing their address ranges with reserved space;
header generation still completes.
Checklist