Page MenuHomeFreeBSD

arm64: Add boot_el-based hypervisor detection
AbandonedPublic

Authored by wac_gmail.com on Thu, Jan 8, 9:12 AM.
Tags
None
Referenced Files
F141934711: D54595.diff
Tue, Jan 13, 7:05 AM
F141930287: D54595.id169304.diff
Tue, Jan 13, 12:39 AM
F141928084: D54595.diff
Mon, Jan 12, 9:58 PM
F141891686: D54595.diff
Mon, Jan 12, 2:18 AM
Unknown Object (File)
Sat, Jan 10, 4:39 AM
Unknown Object (File)
Fri, Jan 9, 8:11 PM
Unknown Object (File)
Thu, Jan 8, 3:51 PM
Unknown Object (File)
Thu, Jan 8, 11:28 AM
Subscribers

Details

Reviewers
andrew
manu
Summary

The only hypervisor detection in arm64 right now is the identify_hypervisor_smbios call. There is a more systemic way to detect this for ARM64.

This patch checks if we booted into EL1, then we check if EL2 is implemented. If EL2 is implemented and we didn't boot into it, we set vm_guest to the generic VM value. We don't know what the hypervisor is, but we are reasonably assured there is one which is why we didn't boot into the higher exception level.

Tested on arm64 c4a VMs on GCE (where this can enable a PCI_QUIRK_ENABLE_MSI_VM to get MSI correctly enabled without /boot/loader.conf changes).

Test Plan

Boot various sized arm64 c4a VMs with this patch and observe kern.vm_guest set.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

wac_gmail.com edited the summary of this revision. (Show Details)

Can this be more specific to GCE? There are systems where the kernel may enter in EL1, but not be under a hypervisor, e.g. the. Windows Dev Kit 2023. Setting vm_guest = VM_GUEST_VM also changes things like hz to 100.

Well drat. Thanks for the example of hardware that does that. The AArch64 exception model doc I read suggested that wasn't the accepted practice and I was hoping to find something more general than a giant stack of magic strings in identify_hypervisor_smbios. I'll abandon this approach and come back with the patch to smbios_subr.c after I've had a chance to test it.