Skip to content

feat(devices): add remote platform erase support#846

Draft
nmgaston wants to merge 2 commits intomainfrom
remotePlatformErase
Draft

feat(devices): add remote platform erase support#846
nmgaston wants to merge 2 commits intomainfrom
remotePlatformErase

Conversation

@nmgaston
Copy link
Copy Markdown
Contributor

@nmgaston nmgaston commented Mar 18, 2026

NOTE: Requires real AMT 16.0+ hardware with RPE BIOS support for end-to-end testing.

Related PRs

Description

Adds support for Intel Remote Platform Erase (RPE), a CSME 16.0+ feature that allows remote administrators to securely erase platform storage components (SSDs, TPM, BIOS NVM, etc.) on the next system boot.

What's New

API Endpoints

Method Path Description
GET /api/v1/amt/boot/capabilities/:guid Returns AMT_BootCapabilities including the PlatformErase bitmask indicating which erase components the device BIOS supports
POST /api/v1/amt/boot/rpe/:guid Enables or disables the RPE feature in AMT firmware (AMT_BootSettingData PUT)
POST /api/v1/amt/remoteErase/:guid Arms and triggers RPE on the next boot with a bitmask specifying which components to erase

Erase Component Bitmask (AMT_BootCapabilities.PlatformErase)

Per the Intel AMT spec:

Bit Value Component
0 0x01 RPE overall support
2 0x04 Secure Erase All SSDs
3 0x08 Verify Storage Erase (CSME 18.0+)
4 0x10 Generate sanitization report (CSME 18.0+)
6 0x40 TPM Clear
16 0x10000 OEM Custom Action (Raptor Lake CSME 16.1+) — also used as the UI-level CSME-unconfigure sentinel (see Notes)
25 0x2000000 Clear BIOS NVM Variables
26 0x4000000 BIOS Reload of Golden Configuration

RPE Trigger Flow (SendRemoteErase)

  1. GET AMT_BootSettingData — read current state and verify RPEEnabled=true
  2. (CSME path only) CIM_BootConfigSetting.ChangeBootOrder("") — clear any active boot source override before setting CSME reset flags (equivalent to ClearBootOptions in the Intel AMT C# SDK). Skipped for hardware-only targets (TPM, SSDs, BIOS NVM, …) to avoid undefined BIOS boot-order behavior
  3. CIM_BootService.RequestStateChange(32770) — switch firmware to RPE mode (required when boot service is in OCR mode 32769; omitting it causes ActionNotSupported)
  4. If eraseMask contains hardware targets: encode tlvMask (eraseMask with the CSME sentinel bit stripped) as a TLV buffer (ParameterTypeID=1, uint32 LE) and base64-encode it into UefiBootParametersArray
  5. PUT AMT_BootSettingData with PlatformErase=true (if hardware targets present), ConfigurationDataReset=true (if CSME sentinel bit set), UefiBootParametersArray=<TLV> (if hardware targets present)
  6. Verify PlatformErase latched via a follow-up GET — abort if not
  7. CIM_BootService.SetBootConfigRole — activate the boot configuration
  8. RequestPowerStateChange(PowerCycleOffHard) — full S5→S0 power cycle to execute erase on next boot

CIM_BootService.EnabledState Constants (clarified)

Value Meaning
32768 OCR disabled, RPE disabled
32769 OCR enabled, RPE disabled
32770 OCR disabled, RPE enabled
32771 OCR enabled, RPE enabled

SetFeatures correctly computes the required state when OCR and RPE are set together, and setRPE runs before the OCR state change to avoid the OCR state blocking the RPE PUT.

DTO / Feature Surface

AMTFeaturesRequest and Features DTOs (v1 + v2) updated with:

Field Description
rpe Whether RPE is currently active in firmware state
rpeSupported Whether device BIOS supports RPE (Bit 0 of PlatformErase capabilities)
rpeCaps Raw PlatformErase bitmask from AMT_BootCapabilities
rpeSecureErase BIOS supports SSD secure erase
rpeTPMClear BIOS supports TPM clear
rpeClearBIOSNVM BIOS supports clearing BIOS NVM variables
rpeBIOSReload BIOS supports golden config reload

Testing

  • Unit tests added for GetBootCapabilities, SetRPEEnabled, SendRemoteErase use-case functions and HTTP controller handlers
  • SetFeatures tests extended to cover RPE + OCR state combinations
  • Verified on real AMT 16.1 hardware

Notes

  • 0x10000 (rpeCSMEBit) doubles as the raw AMT_BootCapabilities.PlatformErase bit for OEM Custom Action and as the UI-level sentinel for "Unconfigure Intel CSME Firmware". When set in the request mask it sets ConfigurationDataReset=true in the PUT and is stripped from the TLV hardware bitmaskPlatformErase and ConfigurationDataReset are independent flags and are never both set from the same bit
  • UefiBootParametersArray must be non-empty when PlatformErase=true — the firmware returns InvalidRepresentation if the element is present but empty or absent. The TLV device bitmask (ParameterTypeID=1) is mandatory per the Intel RPE spec
  • PowerCycleOffHard (S5→S0) is required for erase execution; MasterBusReset (warm reset) keeps ME power rails energised so the BIOS never gets the opportunity to execute the CSME/platform erase
  • RequestStateChange(32770) must be called before the PUT when the boot service is in OCR mode (32769); omitting it causes ActionNotSupported
  • Devices that don't advertise RPE support (Bit 0 of PlatformErase == 0) return a validation error rather than attempting the operation

@nmgaston nmgaston force-pushed the remotePlatformErase branch 3 times, most recently from ab3a5ce to 2a3c9f3 Compare March 18, 2026 01:13
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 99.13043% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.45%. Comparing base (7705f24) to head (ed07d81).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
internal/usecase/devices/features.go 98.85% 1 Missing ⚠️
pkg/logger/logger.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #846       +/-   ##
===========================================
+ Coverage   40.25%   59.45%   +19.19%     
===========================================
  Files         114      101       -13     
  Lines       10866     8190     -2676     
===========================================
+ Hits         4374     4869      +495     
+ Misses       6091     2921     -3170     
+ Partials      401      400        -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nmgaston nmgaston force-pushed the remotePlatformErase branch 6 times, most recently from 9963ea5 to 3fb92dc Compare March 23, 2026 22:20
Comment thread cmd/amt-stub/main.go Fixed
@nmgaston nmgaston force-pushed the remotePlatformErase branch 2 times, most recently from c155e51 to a51bd01 Compare March 25, 2026 17:29
@nmgaston nmgaston force-pushed the remotePlatformErase branch 3 times, most recently from 89a3df2 to ed07d81 Compare April 10, 2026 04:02
@nmgaston nmgaston linked an issue Apr 16, 2026 that may be closed by this pull request
7 tasks
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.

Add support for Remote Platform Erase in Console

2 participants