Skip to content

Repair some pain points#546

Merged
ramseymcgrath merged 2 commits intomainfrom
pain-points
Jan 20, 2026
Merged

Repair some pain points#546
ramseymcgrath merged 2 commits intomainfrom
pain-points

Conversation

@ramseymcgrath
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 20, 2026 00:43
@ramseymcgrath ramseymcgrath linked an issue Jan 20, 2026 that may be closed by this pull request
This was linked to issues Jan 20, 2026
@ramseymcgrath ramseymcgrath merged commit bf8ceab into main Jan 20, 2026
16 of 27 checks passed
@ramseymcgrath ramseymcgrath deleted the pain-points branch January 20, 2026 00:44
@github-actions
Copy link

E2E Integration Test Summary

Workflow Run: 815
Commit: f810c42
Branch: 546/merge
Triggered by: pull_request
Timestamp: Tue Jan 20 00:46:18 UTC 2026

Test Results

End-to-End Tests

E2E Tests: FAILED
⏸️ Security Scan: SKIPPED
⏸️ Performance Analysis: SKIPPED

Artifacts

  • Test reports and logs available in workflow artifacts
  • Artifacts retained for 7-30 days depending on type

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses several pain points in the PCILeech firmware generator, focusing on VFIO device management, template rendering security, build system improvements, and script installation.

Changes:

  • Enhanced VFIO diagnostics with improved device binding commands using the new_id approach for more robust driver management
  • Added security-focused template validation requiring device profiling data for timing parameters to prevent fingerprinting
  • Introduced bitwise operation filters for Jinja2 templates and improved error handling with the {% error %} tag
  • Created unified sudo wrapper script (pcileech-sudo) with automatic virtual environment detection
  • Enhanced Vivado build script to properly set SystemVerilog include directories

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_vfio_diagnostics_unit.py Added comprehensive unit tests for new VFIO bind commands using new_id approach and vendor/device ID storage
src/cli/vfio_diagnostics.py Modified bind commands to use new_id approach; added vendor/device ID storage for remediation
src/vivado_handling/pcileech_build_integration.py Added SystemVerilog include directory configuration for header file resolution
src/utils/unified_context.py Added default latency emulation values to timing configuration
src/templating/template_renderer.py Enhanced ErrorTagExtension with caller parameter; added bitwise operation filters (bitor, bitxor, bitand, bitnot)
src/templates/sv/tlp_latency_emulator.sv.j2 Added mandatory device profiling requirements with error tags; enhanced PRNG seed generation using bitwise filters
src/templates/sv/pcileech_tlps128_bar_controller.sv.j2 Added validation requiring timing parameters from device profiling with error tags
src/templates/sv/pcileech_bar_impl_device.sv.j2 Updated interrupt timing seed calculation to use new bitwise filters
src/device_clone/init.py Added module self-import for patching purposes
scripts/vfio_container_manager.py Added DeviceInfo import from vfio_handler
pcileech.py Added namespace mapping for direct script execution without package installation
pcileech-sudo New unified sudo wrapper script with virtual environment detection
install-sudo-wrapper.sh Renamed from pcileech-build-sudo; updated to install new unified wrapper
configs/fallbacks.yaml Added timing configuration and device identifiers to critical variables list
Containerfile Added package installation to enable proper module imports
.gitignore Added temporary files (message.txt, BUILD_LOG_ANALYSIS.md)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +27
# Import the module itself for patching purposes
from pcileechfwgenerator.device_clone import board_config

Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is problematic. Importing the module itself (from pcileechfwgenerator.device_clone import board_config) for "patching purposes" creates a circular dependency and is an anti-pattern. The module is already being imported on line 29 where specific functions are imported from it. If the intent is to allow mocking the module in tests, this should be done in the test files themselves, not in the production code. This import should be removed.

Suggested change
# Import the module itself for patching purposes
from pcileechfwgenerator.device_clone import board_config

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +34
# Timing configuration (MUST come from device profiling)
# Using fallbacks would create fingerprintable patterns
- timing_config.min_latency_cycles
- timing_config.max_latency_cycles
- timing_config.avg_latency_cycles
- timing_config.min_read_latency
- timing_config.max_read_latency
- timing_config.avg_read_latency

Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration has a logical inconsistency. The file declares timing_config values as critical variables (lines 28-33) that MUST NOT have fallbacks, yet unified_context.py provides DEFAULT_TIMING_CONFIG with default values for these same parameters (lines 70-74), and the template in tlp_latency_emulator.sv.j2 uses these values with the default() filter (lines 57, 60).

Either:

  1. Remove these timing values from the critical_variables list if defaults are acceptable
  2. Remove the defaults from DEFAULT_TIMING_CONFIG and update templates to not use the default() filter for these values

The current state sends mixed signals about whether these values require hardware profiling or can use defaults.

Suggested change
# Timing configuration (MUST come from device profiling)
# Using fallbacks would create fingerprintable patterns
- timing_config.min_latency_cycles
- timing_config.max_latency_cycles
- timing_config.avg_latency_cycles
- timing_config.min_read_latency
- timing_config.max_read_latency
- timing_config.avg_read_latency

Copilot uses AI. Check for mistakes.
COPY pyproject.toml setup.py setup.cfg ./

# Install the package itself so `from pcileechfwgenerator.xxx` imports work
RUN pip3 install --no-cache-dir -e . || echo "Warning: Editable install failed, trying regular install" && pip3 install --no-cache-dir .
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The || operator in this RUN command will mask installation failures. If the editable install (pip3 install -e .) fails, the echo statement will succeed (exit code 0), and the subsequent regular install command will never execute because the || operator short-circuits on success. This should use || followed by the actual install command without the echo, or better yet, use ; if [ $? -ne 0 ]; then to properly chain the fallback installation.

Suggested change
RUN pip3 install --no-cache-dir -e . || echo "Warning: Editable install failed, trying regular install" && pip3 install --no-cache-dir .
RUN pip3 install --no-cache-dir -e . || (echo "Warning: Editable install failed, trying regular install" >&2 && pip3 install --no-cache-dir .)

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +68
ln -sf "$INSTALL_DIR/pcileech-sudo" "$INSTALL_DIR/pcileech-build-sudo" 2>/dev/null || \
cp pcileech-sudo "$INSTALL_DIR/pcileech-build-sudo"
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The symlink command on line 67 has an issue. When using ln -sf, the source argument should be relative to the target location or an absolute path. Currently, it's using $INSTALL_DIR/pcileech-sudo as the source, which means the symlink will point to itself (since the target is also in $INSTALL_DIR). The correct source should be just pcileech-sudo (relative to the target directory) or it should be created with ln -sf pcileech-sudo "$INSTALL_DIR/pcileech-build-sudo" after changing to $INSTALL_DIR.

Copilot uses AI. Check for mistakes.
if _spec is None:
# Package not installed, create the namespace mapping manually
# This allows "from pcileechfwgenerator.x import y" to work as "from src.x import y"
import types
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module 'types' is imported with both 'import' and 'import from'.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cant build [BUG] 0.14.8 --fix dont work New bug after update

1 participant