Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dd99952
chore(devctr): use poetry.group.dev.dependencies
Manciukic Mar 12, 2025
5e6050d
chore(devctr): update poetry lock file
Manciukic Mar 12, 2025
6f390a2
chore(devctr): update rust toolchain to 1.85.0
Manciukic Mar 12, 2025
e4fb5b3
chore(clippy): fix "operator precedence can trip the unwary"
Manciukic Mar 12, 2025
5c57f7c
chore(clippy): mark packed repr ABI explicit as C
Manciukic Mar 12, 2025
729c710
chore(example): fix compilation warning for unused return
Manciukic Mar 12, 2025
9fb2f99
chore(clippy): fix `map_or` can be simplified
Manciukic Mar 12, 2025
b2e84b0
chore(clippy): fix needless call to `as_bytes`
Manciukic Mar 12, 2025
6b9b1a8
chore(clippy): make pointer cast explicit
Manciukic Mar 12, 2025
61e2fa0
chore(devctr): bump to v79
Manciukic Mar 12, 2025
794bc81
chore(clippy): remove unnecessary "ref" in match
Manciukic Mar 12, 2025
7dcebb0
chore(clippy): mark env vars set/remove as unsafe
Manciukic Mar 12, 2025
6a4f1d8
chore(clippy): explicitly mark unsafe calls in unsafe functions
Manciukic Mar 12, 2025
9c2b89c
chore(clippy): mark extern blocks as unsafe
Manciukic Mar 12, 2025
f94d7b3
chore(bindgen): use generated as prefix instead of gen
Manciukic Mar 12, 2025
18bab0a
chore: regenerate auto-generated files in new generated/ prefix
Manciukic Mar 12, 2025
1496726
chore: switch to Rust 2024 edition
Manciukic Mar 12, 2025
4798cdf
chore: run cargo fmt on new edition
Manciukic Mar 12, 2025
0626540
chore(clippy): fix unneeded late initialization
Manciukic Mar 13, 2025
53b7d48
Merge branch 'main' into rust-2024
roypat Mar 13, 2025
a02e2bd
Merge branch 'main' into rust-2024
roypat Mar 13, 2025
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
2 changes: 1 addition & 1 deletion docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ clippy-tracing \
--action fix \
--path ./src \
--exclude benches \
--exclude virtio/gen,bindings.rs,net/gen \
--exclude virtio/generated,bindings.rs,net/generated \
--exclude log-instrument-macros/,log-instrument/,clippy-tracing/ \
--exclude vmm_config/logger.rs,logger/,signal_handler.rs,time.rs
```
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# allowlisted using a toolchain that requires it, causing the A/B-test to
# always fail.
[toolchain]
channel = "1.83.0"
channel = "1.85.0"
targets = ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl"]
profile = "minimal"

2 changes: 1 addition & 1 deletion src/acpi-tables/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "acpi_tables"
version = "0.1.0"
authors = ["The Cloud Hypervisor Authors", "Amazon Firecracker team <firecracker-devel@amazon.com>"]
edition = "2021"
edition = "2024"
license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
86 changes: 47 additions & 39 deletions src/acpi-tables/src/aml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ impl EisaName {

let data = name.as_bytes();

let value: u32 = (u32::from(data[0] - 0x40) << 26
| u32::from(data[1] - 0x40) << 21
| u32::from(data[2] - 0x40) << 16
| name.chars().nth(3).unwrap().to_digit(16).unwrap() << 12
| name.chars().nth(4).unwrap().to_digit(16).unwrap() << 8
| name.chars().nth(5).unwrap().to_digit(16).unwrap() << 4
let value: u32 = ((u32::from(data[0] - 0x40) << 26)
| (u32::from(data[1] - 0x40) << 21)
| (u32::from(data[2] - 0x40) << 16)
| (name.chars().nth(3).unwrap().to_digit(16).unwrap() << 12)
| (name.chars().nth(4).unwrap().to_digit(16).unwrap() << 8)
| (name.chars().nth(5).unwrap().to_digit(16).unwrap() << 4)
| name.chars().nth(6).unwrap().to_digit(16).unwrap())
.swap_bytes();

Expand Down Expand Up @@ -439,7 +439,7 @@ where
r#type: AddressSpaceType::Memory,
min,
max,
type_flags: (cacheable as u8) << 1 | u8::from(read_write),
type_flags: ((cacheable as u8) << 1) | u8::from(read_write),
})
}

Expand Down Expand Up @@ -471,7 +471,7 @@ where
bytes.push(descriptor); // Word Address Space Descriptor
bytes.extend_from_slice(&(TryInto::<u16>::try_into(length).unwrap()).to_le_bytes());
bytes.push(self.r#type as u8); // type
let generic_flags = 1 << 2 /* Min Fixed */ | 1 << 3; // Max Fixed
let generic_flags = (1 << 2) /* Min Fixed */ | (1 << 3); // Max Fixed
bytes.push(generic_flags);
bytes.push(self.type_flags);
}
Expand Down Expand Up @@ -591,9 +591,9 @@ impl Aml for Interrupt {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x89); // Extended IRQ Descriptor
bytes.extend_from_slice(&6u16.to_le_bytes());
let flags = u8::from(self.shared) << 3
| u8::from(self.active_low) << 2
| u8::from(self.edge_triggered) << 1
let flags = (u8::from(self.shared) << 3)
| (u8::from(self.active_low) << 2)
| (u8::from(self.edge_triggered) << 1)
| u8::from(self.consumer);
bytes.push(flags);
bytes.push(1u8); // count
Expand Down Expand Up @@ -682,7 +682,7 @@ impl Aml for Method<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.path.append_aml_bytes(&mut tmp)?;
let flags: u8 = (self.args & 0x7) | u8::from(self.serialized) << 3;
let flags: u8 = (self.args & 0x7) | (u8::from(self.serialized) << 3);
tmp.push(flags);
for child in &self.children {
child.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -766,7 +766,7 @@ impl Aml for Field {
let mut tmp = Vec::new();
self.path.append_aml_bytes(&mut tmp)?;

let flags: u8 = self.access_type as u8 | (self.update_rule as u8) << 5;
let flags: u8 = self.access_type as u8 | ((self.update_rule as u8) << 5);
tmp.push(flags);

for field in self.fields.iter() {
Expand Down Expand Up @@ -1263,15 +1263,17 @@ mod tests {
assert_eq!(
Scope::new(
"_SB_.MBRD".try_into().unwrap(),
vec![&Name::new(
"_CRS".try_into().unwrap(),
&ResourceTemplate::new(vec![&Memory32Fixed::new(
true,
0xE800_0000,
0x1000_0000
)])
)
.unwrap()]
vec![
&Name::new(
"_CRS".try_into().unwrap(),
&ResourceTemplate::new(vec![&Memory32Fixed::new(
true,
0xE800_0000,
0x1000_0000
)])
)
.unwrap()
]
)
.to_aml_bytes()
.unwrap(),
Expand Down Expand Up @@ -1438,13 +1440,15 @@ mod tests {
assert_eq!(
Name::new(
"_CRS".try_into().unwrap(),
&ResourceTemplate::new(vec![&AddressSpace::new_memory(
AddressSpaceCacheable::Cacheable,
true,
0x8_0000_0000u64,
0xf_ffff_ffffu64
)
.unwrap()])
&ResourceTemplate::new(vec![
&AddressSpace::new_memory(
AddressSpaceCacheable::Cacheable,
true,
0x8_0000_0000u64,
0xf_ffff_ffffu64
)
.unwrap()
])
)
.unwrap()
.to_aml_bytes()
Expand Down Expand Up @@ -1491,12 +1495,12 @@ mod tests {
assert_eq!(create_pkg_length(&[0u8; 62], true), vec![63]);
assert_eq!(
create_pkg_length(&[0u8; 64], true),
vec![1 << 6 | (66 & 0xf), 66 >> 4]
vec![(1 << 6) | (66 & 0xf), 66 >> 4]
);
assert_eq!(
create_pkg_length(&[0u8; 4096], true),
vec![
2 << 6 | (4099 & 0xf) as u8,
(2 << 6) | (4099 & 0xf) as u8,
((4099 >> 4) & 0xff).try_into().unwrap(),
((4099 >> 12) & 0xff).try_into().unwrap()
]
Expand Down Expand Up @@ -1553,7 +1557,9 @@ mod tests {
(&"_SB_.PCI0._HID".try_into().unwrap() as &Path)
.to_aml_bytes()
.unwrap(),
[0x2F, 0x03, 0x5F, 0x53, 0x42, 0x5F, 0x50, 0x43, 0x49, 0x30, 0x5F, 0x48, 0x49, 0x44]
[
0x2F, 0x03, 0x5F, 0x53, 0x42, 0x5F, 0x50, 0x43, 0x49, 0x30, 0x5F, 0x48, 0x49, 0x44
]
);
}

Expand Down Expand Up @@ -2007,13 +2013,15 @@ mod tests {
vec![
&Name::new(
"MR64".try_into().unwrap(),
&ResourceTemplate::new(vec![&AddressSpace::new_memory(
AddressSpaceCacheable::Cacheable,
true,
0x0000_0000_0000_0000u64,
0xFFFF_FFFF_FFFF_FFFEu64
)
.unwrap()])
&ResourceTemplate::new(vec![
&AddressSpace::new_memory(
AddressSpaceCacheable::Cacheable,
true,
0x0000_0000_0000_0000u64,
0xFFFF_FFFF_FFFF_FFFEu64
)
.unwrap()
])
)
.unwrap(),
&CreateField::<u64>::new(
Expand Down
2 changes: 1 addition & 1 deletion src/acpi-tables/src/dsdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::mem::size_of;
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory};
use zerocopy::IntoBytes;

use crate::{checksum, AcpiError, Result, Sdt, SdtHeader};
use crate::{AcpiError, Result, Sdt, SdtHeader, checksum};

/// Differentiated System Description Table (DSDT)
///
Expand Down
4 changes: 2 additions & 2 deletions src/acpi-tables/src/fadt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use vm_memory::{Bytes, GuestAddress, GuestMemory};
use zerocopy::little_endian::{U16, U32, U64};
use zerocopy::{Immutable, IntoBytes};

use crate::{checksum, GenericAddressStructure, Result, Sdt, SdtHeader};
use crate::{GenericAddressStructure, Result, Sdt, SdtHeader, checksum};

#[cfg(target_arch = "x86_64")]
pub const IAPC_BOOT_ARG_FLAGS_VGA_NOT_PRESENT: u16 = 2;
Expand Down Expand Up @@ -41,7 +41,7 @@ pub const FADT_F_HW_REDUCED_ACPI: u8 = 20;
/// the pointer to the DSDT table.
/// More information about this table can be found in the ACPI specification:
/// https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#fixed-acpi-description-table-fadt
#[repr(packed)]
#[repr(C, packed)]
#[derive(Debug, Copy, Clone, Default, IntoBytes, Immutable)]
pub struct Fadt {
header: SdtHeader,
Expand Down
4 changes: 2 additions & 2 deletions src/acpi-tables/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum AcpiError {
pub type Result<T> = std::result::Result<T, AcpiError>;

/// ACPI type representing memory addresses
#[repr(packed)]
#[repr(C, packed)]
#[derive(IntoBytes, Immutable, Clone, Copy, Debug, Default)]
pub struct GenericAddressStructure {
pub address_space_id: u8,
Expand Down Expand Up @@ -78,7 +78,7 @@ impl GenericAddressStructure {
}

/// Header included in all System Descriptor Tables
#[repr(packed)]
#[repr(C, packed)]
#[derive(Clone, Debug, Copy, Default, IntoBytes, Immutable)]
pub struct SdtHeader {
pub signature: [u8; 4],
Expand Down
8 changes: 4 additions & 4 deletions src/acpi-tables/src/madt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use vm_memory::{Address, Bytes, GuestAddress, GuestMemory};
use zerocopy::little_endian::U32;
use zerocopy::{Immutable, IntoBytes};

use crate::{checksum, AcpiError, Result, Sdt, SdtHeader};
use crate::{AcpiError, Result, Sdt, SdtHeader, checksum};

const MADT_CPU_ENABLE_FLAG: u32 = 0;

// clippy doesn't understand that we actually "use" the fields of this struct when we serialize
// them as bytes in guest memory, so here we just ignore dead code to avoid having to name
// everything with an underscore prefix
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
#[derive(Copy, Clone, Debug, Default, IntoBytes, Immutable)]
pub struct LocalAPIC {
r#type: u8,
Expand All @@ -43,7 +43,7 @@ impl LocalAPIC {
// them as bytes in guest memory, so here we just ignore dead code to avoid having to name
// everything with an underscore prefix
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
#[derive(Copy, Clone, Debug, Default, IntoBytes, Immutable)]
pub struct IoAPIC {
r#type: u8,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl IoAPIC {
// them as bytes in guest memory, so here we just ignore dead code to avoid having to name
// everything with an underscore prefix
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
#[derive(Debug, IntoBytes, Immutable)]
struct MadtHeader {
sdt: SdtHeader,
Expand Down
4 changes: 2 additions & 2 deletions src/acpi-tables/src/rsdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vm_memory::{Bytes, GuestAddress, GuestMemory};
use zerocopy::little_endian::{U32, U64};
use zerocopy::{Immutable, IntoBytes};

use crate::{checksum, Result, Sdt};
use crate::{Result, Sdt, checksum};

// clippy doesn't understand that we actually "use" the fields of this struct when we serialize
// them as bytes in guest memory, so here we just ignore dead code to avoid having to name
Expand All @@ -21,7 +21,7 @@ use crate::{checksum, Result, Sdt};
/// a pointer to XSDT
/// More information about this structure can be found in the ACPI specification:
/// https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#root-system-description-pointer-rsdp
#[repr(packed)]
#[repr(C, packed)]
#[derive(Clone, Copy, Debug, Default, IntoBytes, Immutable)]
pub struct Rsdp {
signature: [u8; 8],
Expand Down
2 changes: 1 addition & 1 deletion src/acpi-tables/src/xsdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::mem::size_of;
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory};
use zerocopy::IntoBytes;

use crate::{checksum, AcpiError, Result, Sdt, SdtHeader};
use crate::{AcpiError, Result, Sdt, SdtHeader, checksum};

/// Extended System Description Table (XSDT)
///
Expand Down
2 changes: 1 addition & 1 deletion src/clippy-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "clippy-tracing"
version = "0.1.0"
authors = ["Amazon Firecracker team <firecracker-devel@amazon.com>"]
edition = "2021"
edition = "2024"
license = "Apache-2.0"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion src/clippy-tracing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn exec() -> Result<Option<(PathBuf, usize, usize)>, ExecError> {
// The file must not be a `build.rs` file.
let not_build_file = !entry_path.ends_with("build.rs");
// The file must be a `.rs` file.
let is_rs_file = entry_path.extension().map_or(false, |ext| ext == "rs");
let is_rs_file = entry_path.extension().is_some_and(|ext| ext == "rs");

if no_excluded_strings && not_build_file && is_rs_file {
let file = OpenOptions::new()
Expand Down
2 changes: 1 addition & 1 deletion src/clippy-tracing/tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use std::fs::{remove_file, OpenOptions};
use std::fs::{OpenOptions, remove_file};
use std::io::{Read, Write};
use std::process::Command;

Expand Down
2 changes: 1 addition & 1 deletion src/cpu-template-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cpu-template-helper"
version = "1.12.0-dev"
authors = ["Amazon Firecracker team <firecracker-devel@amazon.com>"]
edition = "2021"
edition = "2024"
license = "Apache-2.0"

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions src/cpu-template-helper/src/template/dump/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use vmm::arch::aarch64::regs::{RegSize, PC, SYS_CNTPCT_EL0, SYS_CNTV_CVAL_EL0};
use vmm::arch::aarch64::regs::{PC, RegSize, SYS_CNTPCT_EL0, SYS_CNTV_CVAL_EL0};
use vmm::cpu_config::aarch64::custom_cpu_template::RegisterModifier;
use vmm::cpu_config::templates::{CpuConfiguration, CustomCpuTemplate, RegisterValueFilter};
use vmm::logger::warn;
Expand Down Expand Up @@ -50,7 +50,7 @@ const REG_EXCLUSION_LIST: [u64; 3] = [

#[cfg(test)]
mod tests {
use vmm::arch::aarch64::regs::{reg_size, Aarch64RegisterRef, Aarch64RegisterVec};
use vmm::arch::aarch64::regs::{Aarch64RegisterRef, Aarch64RegisterVec, reg_size};

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions src/cpu-template-helper/src/template/dump/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

use std::collections::BTreeMap;

use vmm::arch::x86_64::gen::msr_index::*;
use vmm::MSR_RANGE;
use vmm::arch::x86_64::generated::msr_index::*;
use vmm::arch::x86_64::msr::MsrRange;
use vmm::cpu_config::templates::{CpuConfiguration, CustomCpuTemplate, RegisterValueFilter};
use vmm::cpu_config::x86_64::cpuid::common::get_vendor_id_from_host;
use vmm::cpu_config::x86_64::cpuid::{Cpuid, VENDOR_ID_AMD};
use vmm::cpu_config::x86_64::custom_cpu_template::{
CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterModifier,
};
use vmm::MSR_RANGE;

use crate::utils::x86_64::{cpuid_leaf_modifier, cpuid_reg_modifier, msr_modifier};

Expand Down
2 changes: 1 addition & 1 deletion src/cpu-template-helper/src/template/strip/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use vmm::cpu_config::aarch64::custom_cpu_template::RegisterModifier;
use vmm::cpu_config::templates::CustomCpuTemplate;

use crate::template::strip::{strip_common, StripError};
use crate::template::strip::{StripError, strip_common};
use crate::utils::aarch64::RegModifierMap;

#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion src/cpu-template-helper/src/template/strip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::utils::tests::{mock_modifier, MockModifierMapKey};
use crate::utils::tests::{MockModifierMapKey, mock_modifier};

#[test]
fn test_strip_common_with_single_input() {
Expand Down
Loading