Skip to content
/ tdx-demo Public

Valdi AI demo using Confidential Compute, NVIDIA and TDX

License

Notifications You must be signed in to change notification settings

storj/tdx-demo

Repository files navigation

TDX Confidential Computing Demo

A Python application demonstrating Intel TDX (Trust Domain Extensions) confidential computing capabilities on H200 bare metal nodes.

Features

  • TDX Guest VM Provisioning - Automated Trust Domain creation with encrypted memory
  • Remote Attestation - Generate and verify TD quotes
  • Confidential Workload Execution - Secure data processing in isolated memory
  • GPU Confidential Computing - H200 GPU workloads with TDX protection
  • Secure Cleanup - Proper memory wiping and resource teardown

Quick Start

# Clone and setup
git clone <repository-url>
cd tdx-demo
chmod +x setup.sh quickstart.sh

# One-command start
./quickstart.sh

Installation

Prerequisites

  • Ubuntu 24.04 (Noble) with Intel TDX kernel
  • H200 bare metal node with TDX support
  • Minimum 8GB RAM, 50GB disk space
  • Root/sudo access

Automated Setup

sudo ./setup.sh

This installs all dependencies and configures the environment.

Verify Installation

# Check TDX support
cat /sys/module/kvm_intel/parameters/tdx  # Should show 'Y'

# Test the demo
source venv/bin/activate
sudo -E venv/bin/python src/main.py

Usage

Basic Demo

# Run complete demo
sudo -E venv/bin/python src/main.py

# Or use make
make run

Attestation Only

sudo -E venv/bin/python src/main.py --attestation-only

Verbose Mode

sudo -E venv/bin/python src/main.py --verbose

Custom Workload

sudo -E venv/bin/python src/main.py --workload my_script.py

GPU Workloads

# Enable GPU in config.yaml first
nano config.yaml  # Set gpu.enabled: true

# Run GPU workload
sudo -E venv/bin/python src/main.py

# Or specify GPU workload type explicitly
# Edit config.yaml: workload.type: "gpu_compute"

GPU Workload Types:

  • vector_add - GPU vector addition
  • matrix_multiply - GPU matrix operations
  • ml_inference - ML model inference on GPU
  • benchmark - GPU performance tests

Configuration

Edit config.yaml to customize:

VM Settings

vm:
  name: "tdx-demo-vm"
  memory: 4096          # Memory in MB
  vcpus: 2              # Number of vCPUs
  disk_size: 20         # Disk size in GB

Workload Settings

workload:
  type: "data_processing"   # Options: data_processing, ml_inference, gpu_compute
  encryption: true
  params:
    data_size: 1048576      # Bytes to process
    iterations: 10          # Number of iterations

GPU Settings (Optional)

gpu:
  enabled: true             # Enable GPU workloads
  passthrough: false        # GPU passthrough to VM (advanced)
  device_id: "0"           # GPU device ID
  workload_types:
    - "vector_add"         # CUDA vector operations
    - "matrix_multiply"    # Matrix computations
    - "ml_inference"       # ML model inference

Note: GPU workloads require NVIDIA drivers and optionally PyCUDA for real GPU operations. Without PyCUDA, workloads are simulated but demonstrate the framework.

Logging

logging:
  level: "INFO"             # DEBUG, INFO, WARNING, ERROR
  file: "logs/tdx-demo.log"
  console: true

Project Structure

tdx-demo/
├── src/
│   ├── main.py              # Main orchestrator
│   ├── vm_manager.py        # TDX VM lifecycle
│   ├── attestation.py       # Attestation service
│   ├── workload.py          # Workload executor
│   └── utils/               # Configuration and logging
├── guest/
│   └── guest_agent.py       # Agent for TD guest
├── tests/                   # Unit tests
├── config.yaml              # Configuration
├── requirements.txt         # Python dependencies
└── README.md               # This file

Platform Status

Working Features ✅

  • TDX VM creation with encrypted memory backing (memfd)
  • KVM TDX detection and enablement
  • Attestation workflow (quote generation and verification)
  • Confidential workload execution patterns
  • Secure resource cleanup

Known Limitations ⚠️

Guest OS Boot: Currently disabled due to TDVF firmware metadata compatibility between QEMU 8.2.2 and OVMF 2024.02-3+tdx1.0. The demo successfully demonstrates all confidential computing patterns and attestation without the OS boot.

Tested Environment:

  • Ubuntu 24.04 with Intel TDX kernel
  • QEMU 8.2.2, Libvirt 10.0.0
  • OVMF 2024.02-3+tdx1.0 (kobuk-team PPA)
  • H200 bare metal with TDX support

Troubleshooting

TDX Not Detected

# Check kernel support
dmesg | grep -i tdx

# Verify KVM module
cat /sys/module/kvm_intel/parameters/tdx

Solution: Ensure BIOS has Intel TDX enabled and you're running a TDX-enabled kernel.

Libvirt Connection Error

# Check libvirt status
sudo systemctl status libvirtd

# Restart if needed
sudo systemctl restart libvirtd

# Verify group membership
groups $USER  # Should include 'libvirt'

Solution: Log out and back in after adding user to libvirt group.

Python Dependencies Error

# Install build dependencies
sudo apt install -y libvirt-dev pkg-config python3-dev build-essential

# Retry installation
pip install -r requirements.txt

VM Creation Fails

# Check disk space
df -h /var/lib/libvirt/images/

# Check libvirt logs
sudo journalctl -u libvirtd -n 50

# Clean up old VMs
sudo virsh list --all
sudo virsh destroy <vm-name>
sudo virsh undefine <vm-name>

GPU Not Detected

# Check GPU
nvidia-smi

# Check NVIDIA drivers
nvidia-smi --query-gpu=driver_version --format=csv,noheader

# Install drivers if needed
sudo apt install nvidia-driver-535  # Or latest version

Solution: Ensure NVIDIA drivers are installed and GPU is visible to the system.

Output

Logs

# View logs
tail -f logs/tdx-demo.log

# Check attestation quotes
ls -lh quotes/

VM Management

# List VMs
sudo virsh list --all

# View VM console
sudo virsh console tdx-demo-vm

# Check VM info
sudo virsh dominfo tdx-demo-vm

Example Output

╭─────────────────────────────────────────────╮
│ TDX Confidential Computing Demo             │
│ Demonstrating Intel Trust Domain Extensions │
╰─────────────────────────────────────────────╯

Step 1: Provisioning TDX Guest VM
✅ Trust Domain created
✅ VM Status: running
   Memory: 4096 MB (encrypted)
   vCPUs: 2

Step 2: Remote Attestation
✅ TD quote generated
✅ Attestation verified
✅ Trust established: Running on genuine Intel TDX hardware
   Quote hash: 83a846c91221c5d5...

Step 3: Executing Confidential Workload
✅ Workload completed
✅ Processed: 10485760 bytes
   Duration: 1.00s
   Memory encryption: Active (MKTME)

✅ Demo completed successfully!

Security Notes

  • ⚠️ This is a demonstration application
  • 🔒 TD memory is encrypted and isolated from host
  • ✅ Attestation verifies authentic TDX hardware
  • 🗑️ Secrets are zeroized on cleanup
  • 📝 Sensitive data is redacted from logs

Resources

About

Valdi AI demo using Confidential Compute, NVIDIA and TDX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published