lib: add a sink for components to register to handle RDMSR/WRMSR #791
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Define a small wrapper around an
ASpace
that allows other Propolis components to register to handle RDMSR/WRMSR instructions directed to specific parts of the MSR "address space." Handlers have the option of fully handling an access, directing the caller to inject #GP, or returning an error indicating the trap couldn't be fully handled. This last option is useful when handling an MSR access requires the handler to call some other, fallible API, like a bhyve ioctl.Create an
MsrSpace
in eachMachine
, give eachVcpu
a reference to it, and haveVcpu::process_vmexit
dispatch MSR operations to its MSR space. MSR handlers are the first exit type that can return a library error, so expandprocess_vmexit
to return aResult<Option<VmEntry>>
, which allows propolis-server/propolis-standalone to distinguish "lib didn't handle the exit" from "lib raised an error" and to handle these cases separately. For MSRs, the propolis-server discipline is to panic on errors, drop unhandled writes, and return 0s for unhandled reads.Define a
VcpuId
newtype that (as you'd expect) represents a vCPU identifier to distinguish vCPU IDs from MSR IDs. The MSR handler callback uses this type, but its use in the rest of Propolis is left for another PR.Tests: ran a propolis-server binary, enabled the USDT probes, booted a guest, and checked that the probes produced the expected results. I've also tested this logic with additional changes that use it to provide an enlightenment interface.
Related to #328 (our most likely paths to a paravirt clock require MSR handling to allow the guest to set up the enlightenment).