Skip to content
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

vmm: Remove PC from vCPU config dump #4118

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
if no limit is set). This avoids the kernel reallocating the fdtable during
Firecracker operations, resulting in a 30ms to 70ms reduction of snapshot
restore times for medium to large microVMs with many devices attached.
- Changed the dump feature of `cpu-template-helper` tool not to enumerate program
counter (PC) on ARM because it is determined by the given kernel image and
it is useless in the custom CPU template context.

### Fixed

Expand Down
1 change: 1 addition & 0 deletions docs/cpu_templates/cpu-template-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,5 @@ validation check.

| Register name | ID |
|----------------------|--------------------|
| Program Counter | 0x6030000000100040 |
| KVM_REG_ARM_TIMER_CNT| 0x603000000013df1a |
15 changes: 13 additions & 2 deletions src/vmm/src/vstate/vcpu/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.

use kvm_bindings::*;
use kvm_ioctls::*;
use logger::{error, IncMetric, METRICS};
use utils::vm_memory::{Address, GuestAddress, GuestMemoryMmap};
use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
use versionize_derive::Versionize;

use crate::arch::aarch64::regs::{
Aarch64RegisterOld, Aarch64RegisterRef, Aarch64RegisterVec, KVM_REG_ARM_TIMER_CNT,
arm64_core_reg_id, offset__of, Aarch64RegisterOld, Aarch64RegisterRef, Aarch64RegisterVec,
KVM_REG_ARM_TIMER_CNT,
};
use crate::arch::aarch64::vcpu::{
get_all_registers, get_all_registers_ids, get_mpidr, get_mpstate, get_registers, set_mpstate,
Expand Down Expand Up @@ -208,11 +210,20 @@ impl KvmVcpu {
pub fn dump_cpu_config(&self) -> Result<CpuConfiguration, KvmVcpuError> {
let mut reg_list = get_all_registers_ids(&self.fd).map_err(KvmVcpuError::DumpCpuConfig)?;

let kvm_reg_pc = {
let kreg_off = offset__of!(kvm_regs, regs);
let pc_off = offset__of!(user_pt_regs, pc) + kreg_off;
arm64_core_reg_id!(KVM_REG_SIZE_U64, pc_off)
};

// KVM_REG_ARM_TIMER_CNT should be removed, because it depends on the elapsed time and
// the dumped CPU config is used to create custom CPU templates to modify CPU features
// exposed to guests or ot detect CPU configuration changes caused by firecracker/KVM/
// BIOS.
reg_list.retain(|&reg_id| reg_id != KVM_REG_ARM_TIMER_CNT);
// The value of program counter (PC) is determined by the given kernel image. It should not
// be overwritten by a custom CPU template and does not need to be tracked in a fingerprint
// file.
reg_list.retain(|&reg_id| reg_id != KVM_REG_ARM_TIMER_CNT && reg_id != kvm_reg_pc);

let mut regs = Aarch64RegisterVec::default();
get_registers(&self.fd, &reg_list, &mut regs).map_err(KvmVcpuError::DumpCpuConfig)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
"addr": "0x603000000010003e",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100040",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000"
},
{
"addr": "0x6030000000100042",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000101"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
"addr": "0x603000000010003e",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100040",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000"
},
{
"addr": "0x6030000000100042",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000101"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
"addr": "0x603000000010003e",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100040",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000"
},
{
"addr": "0x6030000000100042",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000101"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
"addr": "0x6030000000100000",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001111111000000000000000000000"
},
{
"addr": "0x6030000000100002",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100004",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
"addr": "0x603000000010003e",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100040",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000"
},
{
"addr": "0x6030000000100042",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000101"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
"addr": "0x603000000010003e",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
{
"addr": "0x6030000000100040",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000"
},
{
"addr": "0x6030000000100042",
"bitmap": "0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000101"
Expand Down
5 changes: 1 addition & 4 deletions tools/devtool
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,7 @@ cmd_test() {

# If we got to here, we've got all we need to continue.
say "Kernel version: $(uname -r)"
if [ "$(uname --machine)" = "x86_64" ]; then
say "Microcode version: $(sudo cat /sys/devices/system/cpu/cpu0/microcode/version)"
fi
say "$(lscpu)"
say "$(sed '/^processor.*: 0$/,/^processor.*: 1$/!d; /^processor.*: 1$/d' /proc/cpuinfo)"
say "Starting test run ..."

# Testing (running Firecracker via the jailer) needs root access,
Expand Down