OP-TEE Storage Migration and Versioning - Analysis
Overview
This document analyzes OP-TEE’s storage migration and versioning mechanisms, covering format versioning, backward compatibility, schema evolution, and migration strategies between different storage backends and versions.Storage Format Versioning
RPMB File System Versioning
- Location:
/home/dzb/optee/optee_os/core/tee/tee_rpmb_fs.c - Current Version: FS_VERSION = 2
- Magic Number: 0x52504D42 (“RPMB” in ASCII)
Hash Tree Compatibility
The hash tree implementation supports format evolution through configuration:HUK Subkey Compatibility Layer
Hardware Unique Key derivation includes compatibility mode for legacy systems:Migration Between Storage Backends
REE File System Migration
The REE file system supports migration from non-integrity-protected to integrity-protected mode:RPMB to REE Migration Strategy
While not directly implemented, the architecture supports migration through:- Export Phase: Read all objects from source storage
- Key Preservation: Maintain FEK encryption for seamless transition
- Import Phase: Write objects to destination storage format
- Validation: Verify integrity of migrated data
Backward Compatibility Mechanisms
Configuration-Based Compatibility
Multiple compile-time flags control compatibility behavior:Directory File Format Evolution
Directory entries use reserved space for future expansion:Object ID Compatibility
Support for zero-length object IDs with special encoding:Schema Evolution Strategies
Counter-Based Evolution
Monotonic counters provide migration checkpoints:Versioned Storage Operations
Each storage backend can implement version-specific behavior:Test Infrastructure for Migration
Dedicated test framework for storage format validation:Version Detection and Negotiation
Magic Number Validation
Storage formats use magic numbers for identification:Feature Detection
Runtime detection of storage capabilities:Migration Safety Mechanisms
Atomic Migration Operations
Migration operations use the same atomic commit mechanisms:- Preparation: Verify source and destination integrity
- Copy: Transfer data while maintaining encryption
- Verification: Validate copied data
- Commit: Atomically switch to new format
- Cleanup: Remove old format data