-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPUID (3/3): CPUID template expansion #3076
CPUID (3/3): CPUID template expansion #3076
Conversation
bd0602d
to
f4c590d
Compare
afb9dba
to
0426291
Compare
41b2bfc
to
c380367
Compare
f55aa01
to
ebb78f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool work done here!
I've done a pass of this PR but I have not gone into the implementation too deeply since it's a draft. I've added some comments related to how the new crates are integrated in Firecracker and I'll take another pass at it once we settle the Firecracker integration side.
I think this PR can be split into at least 3 PRs each with multiple commits to make it more manageable to review:
- One PR that refactors error handling and propagation within Firecracker. This can be even opened agains the
main
branch since its not too coupled to the CPUID crate. - One PR adding the
bit-fields-macros
andbit-fields
crates. - One PR for the new implementation of the
cpuid
crate and changes to Firecracker to make it work.
Each one of these PRs can have multiple commits that can be logically split.
These make sense, but I think the second one might be a bit odd. Given it would be a PR adding libraries that are not being used. It would require some extra description noting it is linked to other PRs. |
3923e07
to
d313d3a
Compare
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR #1030, but was removed in PR #3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR #3076 with ones that are introduced in PR #3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR #1030, but was removed in PR #3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR #3076 with ones that are introduced in PR #3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
Disable IA32_ARCH_CAPABILITIES MSR on AMD by disabling CPUID.07H(ECX=0):EDX[bit 29]. This normalization was added in PR firecracker-microvm#1030, but was removed in PR firecracker-microvm#3076. Signed-off-by: Takahiro Itazuri <[email protected]>
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
#3105 must be merged first
Reason for This PR
Many properties CPUID are not considered when saving and restoring snapshots, this leads to potential instability.
Description of Changes
Reworked the CPUID to support extensive CPU templates, simplifying the existing flow and adding accessor functions and types.
The CPUID templates are under
src/cpuid-templates/
, these have been generated from booting a microVM using Firecracker main with the respective template then reading CPUID from within the microVM.Expanding CPUID to include accessors for most of the Intel specification and some of the AMD specification.
The crate has split into 3 portions, general (
cpuid/
), Intel specific (cpuid/intel
) and AMD specific (cpuid/amd
).Within these:
indexing.rs
contains the leaf index implementationsleaves.rs
contains the leaf definitions,mod.rs
contains the outer structure (Cpuid
,IntelCpuid
andAmdCpuid
respectively).normalize
contains thenormalize
functions which replacefilter_cpuid
and the CPUID transformer logic.registers.rs
contains the register definitions for leaves.At the root
common.rs
retains some of the old functionality that is still used.CpuidTrait::apply_brand_string
,IntelCpuid::default_brand_string()
andAmdCpuid::DEFAULT_BRAND_STRING
replacecpuid/src/brand_string.rs
.Adjustments to testing:
test_coverage
values have been significantly reduced.test_coverage
timeout has been increased to600
as it was consistently timing out on them6gd
instance in CI.test_brand_string
has been simplified.test_api_machine_config
has had a message slightly changed.Linting
This continues the pattern of linting as introduced in #3105.
Code coverage
Code coverage is significantly reduced in large part due to the quantity of generated code for CPUID registers, this can be seen in the report (coverage-report-cpuid-latest.zip) as there ~1000 lines of uncovered generated code under
src/cpuid/intel/registers.rs
.Generated doc tests being excluded from code coverage makes higher coverage difficult here (including doc tests in coverage is a nightly feature).
Future work
There are clear areas where future work would be useful:
RawCpuid
torust-vmm
.(to replaceCpuId
/FamWrapper
) RenovatingCpuId
rust-vmm/kvm#2950x00
0x01
: not EAX and partially EBX.0x05
: not EDX.0x07
0x0A
: not EAX, EBX & EDX.0x0F
: not EBX in sub-leaf 1.0x10
: not sub-leavers 2 & 3, not EAX, EBX & ECX in sub-leaf 1.0x14
: not sub-leaf 1.0x18
, not sub-leaves>0
, not ECX & EDX in sub-leaf 0.0x19
0x1C
: not EAX0x20
: not EBX0x80000000
0x80000001
not EAX.0x80000007
0x80000008
0xD
and0x1B
future work could introduce these.src/cpuid/src/common.rs
andsrc/cpuid/src/bit_helper.rs
can be significantly reduced in size by removing unused functionality.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
git commit -s
).unsafe
code is properly documented.CHANGELOG.md
.