Skip to content

cpu: Add AppleVirtCPU (KvmCPU equiv for Apple hosts)#3076

Draft
BobbyRBruce wants to merge 1 commit intogem5:developfrom
BobbyRBruce:feature/apple-virt-cpu
Draft

cpu: Add AppleVirtCPU (KvmCPU equiv for Apple hosts)#3076
BobbyRBruce wants to merge 1 commit intogem5:developfrom
BobbyRBruce:feature/apple-virt-cpu

Conversation

@BobbyRBruce
Copy link
Copy Markdown
Member

@BobbyRBruce BobbyRBruce commented Apr 13, 2026

((Just a draft, not ready for review. Still work to be done))

I was testing this on the config script provided in this PR (a simple SE mode hello-world simulation) and while it does load the simulated hardware with a CPU core that utilizes Apple virtualization, it fails due to :

  • Missing SE-grade VA/MMU handling in AppleVirt (address translation/page-fault path not complete).
  • Missing syscall trap bridge depth (SE expects gem5’s syscall emulation flow).

I don't know exactly how close this is to completion but there's certainly some stuff left to do.

Usage Notes

For security purposes, apple requires binaries which require user of the
hypervisor to be signed. Therefore the following is required to sign the
gem5 executable to run correctly on Apple hosts:

cat > hv.entitlements.plist <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "[http://www.apple.com/DTDs/PropertyList-1.0.dtd"\](http://www.apple.com/DTDs/PropertyList-1.0.dtd%22/)>
<plist version="1.0">
<dict>
  <key>com.apple.security.hypervisor</key>
  <true/>
</dict>
</plist>
EOF

codesign -f -s - --entitlements hv.entitlements.plist ./build/ALL/gem5.opt

Example Script

./build/ALL/gem5.opt configs/example/apple_virt_simple.py

Usage Notes
-----------

For security purposes, apple requires binaries which require user of the
hypervisor to be signed. Therefore the following is required to sign the
gem5 executable to run correctly on Apple hosts:

```shell
cat > hv.entitlements.plist <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
<dict>
  <key>com.apple.security.hypervisor</key>
  <true/>
</dict>
</plist>
EOF

codesign -f -s - --entitlements hv.entitlements.plist ./build/ALL/gem5.opt
```

Example Script
--------------

```shell
./build/ALL/gem5.opt configs/example/apple_virt_simple.py
```
@BobbyRBruce BobbyRBruce force-pushed the feature/apple-virt-cpu branch from dfb814d to 8233793 Compare April 13, 2026 19:03
@BobbyRBruce BobbyRBruce changed the title cpu: add Apple Virtualization CPU (KvmCPU equip for Apple hosts) cpu: Add AppleVirtCPU (KvmCPU equiv for Apple hosts) Apr 13, 2026
@BobbyRBruce
Copy link
Copy Markdown
Member Author

Note to self:

For signing the binary, I can have this are part of the scons building process:

sign_identity = ARGUMENTS.get('SIGN_IDENTITY', '-')
entitlements = '#/build_opts/macos/virtualization.entitlements' # Create this
binary = '{path to gem5 bin}' # Whatever way SCons allows us to get this

Command(
    action=f'codesign --force --sign "{sign_identity}" --entitlements "{entitlements}" "{binary}"
)

Though it needs to check we're running on an Apple host with Apple Virtualization enabled.

@powerjg
Copy link
Copy Markdown
Contributor

powerjg commented Apr 14, 2026

I would suggest starting with full system simulation. It's going to be a lot easier to get that working that SE mode. SE mode with KVM has all sorts of complications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cpu General gem5 CPU code (e.g., `BaseCPU`)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants