From ee892120d4f41f44fc63dc5d54c2a6244c351a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Tue, 14 Nov 2023 15:43:10 +0100 Subject: [PATCH 1/2] svsm: add missing Copy derives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing Copy trait derives to multiple types. Copy requires Clone, so derive it as well where needed. To prevent adding new copyable types without the Copy derive, add a lint attribute to lib.rs. Signed-off-by: Carlos López --- src/console.rs | 1 + src/cpu/cpuid.rs | 1 + src/cpu/gdt.rs | 1 + src/cpu/idt.rs | 2 +- src/cpu/percpu.rs | 4 ++-- src/cpu/registers.rs | 2 +- src/cpu/tss.rs | 2 +- src/elf/mod.rs | 14 ++++++++------ src/fw_cfg.rs | 2 +- src/io.rs | 2 +- src/lib.rs | 1 + src/mm/alloc.rs | 2 +- src/mm/vm/mapping/phys_mem.rs | 2 +- src/mm/vm/mapping/reserved.rs | 2 +- src/protocols/mod.rs | 2 +- src/sev/ghcb.rs | 5 +++-- src/sev/msr_protocol.rs | 1 + src/sev/vmsa.rs | 2 +- src/svsm_console.rs | 1 + src/task/tasks.rs | 4 ++-- src/utils/bitmap_allocator.rs | 2 +- 21 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/console.rs b/src/console.rs index 4ecb9e1e6..f661f2eff 100644 --- a/src/console.rs +++ b/src/console.rs @@ -10,6 +10,7 @@ use crate::utils::immut_after_init::ImmutAfterInitCell; use core::fmt; use log; +#[derive(Clone, Copy)] pub struct Console { writer: Option<&'static dyn Terminal>, } diff --git a/src/cpu/cpuid.rs b/src/cpu/cpuid.rs index e59043b71..74b4833a5 100644 --- a/src/cpu/cpuid.rs +++ b/src/cpu/cpuid.rs @@ -51,6 +51,7 @@ pub fn register_cpuid_table(table: &'static SnpCpuidTable) { .expect("Could not initialize CPUID page"); } +#[derive(Clone, Copy)] pub struct CpuidResult { pub eax: u32, pub ebx: u32, diff --git a/src/cpu/gdt.rs b/src/cpu/gdt.rs index aca9ecf29..0657d8f1a 100644 --- a/src/cpu/gdt.rs +++ b/src/cpu/gdt.rs @@ -11,6 +11,7 @@ use core::arch::asm; use core::mem; #[repr(C, packed(2))] +#[derive(Clone, Copy)] pub struct GdtDesc { size: u16, addr: VirtAddr, diff --git a/src/cpu/idt.rs b/src/cpu/idt.rs index e79fa827f..48b0ea345 100644 --- a/src/cpu/idt.rs +++ b/src/cpu/idt.rs @@ -40,7 +40,7 @@ pub const VC_VECTOR: usize = 29; pub const _SX_VECTOR: usize = 30; #[repr(C, packed)] -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct X86ExceptionContext { pub regs: X86GeneralRegs, pub vector: usize, diff --git a/src/cpu/percpu.rs b/src/cpu/percpu.rs index 5b6020f8c..68fc97d8d 100644 --- a/src/cpu/percpu.rs +++ b/src/cpu/percpu.rs @@ -120,7 +120,7 @@ impl IstStacks { } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct GuestVmsaRef { vmsa: Option, caa: Option, @@ -574,7 +574,7 @@ pub fn this_cpu_mut() -> &'static mut PerCpu { unsafe { SVSM_PERCPU_BASE.as_mut_ptr::().as_mut().unwrap() } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct VmsaRegistryEntry { pub paddr: PhysAddr, pub apic_id: u32, diff --git a/src/cpu/registers.rs b/src/cpu/registers.rs index 28bc32e6d..8f2fedb0a 100644 --- a/src/cpu/registers.rs +++ b/src/cpu/registers.rs @@ -25,7 +25,7 @@ pub struct X86GeneralRegs { } #[repr(C, packed)] -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct X86SegmentRegs { pub cs: usize, pub ds: usize, diff --git a/src/cpu/tss.rs b/src/cpu/tss.rs index a7d443d41..3f247c250 100644 --- a/src/cpu/tss.rs +++ b/src/cpu/tss.rs @@ -10,7 +10,7 @@ use crate::address::VirtAddr; pub const _IST_INVALID: usize = 0; pub const IST_DF: usize = 1; -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] #[repr(C, packed)] pub struct X86Tss { reserved1: u32, diff --git a/src/elf/mod.rs b/src/elf/mod.rs index 501825b87..3d0a790fd 100644 --- a/src/elf/mod.rs +++ b/src/elf/mod.rs @@ -35,7 +35,7 @@ use core::mem; /// /// assert_eq!(error_message, "invalid ELF address range"); /// ``` -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum ElfError { FileTooShort, @@ -204,7 +204,7 @@ pub type Elf64char = u8; /// /// In mathematical notation, the range is [vaddr_begin, vaddr_end) /// -#[derive(PartialEq, Eq, Debug, Default)] +#[derive(PartialEq, Eq, Debug, Default, Clone, Copy)] pub struct Elf64AddrRange { pub vaddr_begin: Elf64Addr, pub vaddr_end: Elf64Addr, @@ -330,7 +330,7 @@ impl cmp::PartialOrd for Elf64AddrRange { /// This struct represents a parsed 64-bit ELF file. It contains information /// about the ELF file's header, load segments, dynamic section, and more. -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct Elf64FileRange { pub offset_begin: usize, pub offset_end: usize, @@ -1005,7 +1005,7 @@ impl<'a> Elf64File<'a> { /// Header of the ELF64 file, including fields describing properties such /// as type, machine architecture, entry point, etc. -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct Elf64Hdr { #[allow(unused)] /// An array of 16 bytes representing the ELF identification, including the ELF magic number @@ -1786,6 +1786,7 @@ impl Elf64Dynamic { } /// Information about the allocation of a virtual address range +#[derive(Clone, Copy)] pub struct Elf64ImageLoadVaddrAllocInfo { /// The virtual address (vaddr) range to allocate pub range: Elf64AddrRange, @@ -1997,7 +1998,7 @@ impl<'a> Elf64Symtab<'a> { } /// Represents a relocation entry in an ELF64 file ([`Elf64Rela`]) -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Elf64Rela { /// Offset within the section where the relocation should be applied r_offset: Elf64Addr, @@ -2135,7 +2136,7 @@ impl<'a> Iterator for Elf64ShdrIterator<'a> { } /// Represents a relocation operation -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Elf64RelocOp { /// Destination address where the relocation operation should be applied pub dst: Elf64Addr, @@ -2169,6 +2170,7 @@ pub trait Elf64RelocProcessor { } /// Relocation processor specifically for x86_64 ELF files. +#[derive(Clone, Copy)] pub struct Elf64X86RelocProcessor; impl Elf64X86RelocProcessor { diff --git a/src/fw_cfg.rs b/src/fw_cfg.rs index 44da50963..b5a0e3d17 100644 --- a/src/fw_cfg.rs +++ b/src/fw_cfg.rs @@ -52,7 +52,7 @@ impl From for SvsmError { } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct FwCfgFile { size: u32, selector: u16, diff --git a/src/io.rs b/src/io.rs index 5bca00090..c07f87b9c 100644 --- a/src/io.rs +++ b/src/io.rs @@ -32,7 +32,7 @@ pub trait IOPort: Sync { } } -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct DefaultIOPort {} impl IOPort for DefaultIOPort {} diff --git a/src/lib.rs b/src/lib.rs index 445420c19..11840be6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ // Author: Nicolai Stange #![no_std] +#![deny(missing_copy_implementations)] #![cfg_attr(all(test, test_in_svsm), no_main)] #![cfg_attr(all(test, test_in_svsm), feature(custom_test_frameworks))] #![cfg_attr(all(test, test_in_svsm), test_runner(crate::testing::svsm_test_runner))] diff --git a/src/mm/alloc.rs b/src/mm/alloc.rs index fb7783cf2..8c601e96a 100644 --- a/src/mm/alloc.rs +++ b/src/mm/alloc.rs @@ -228,7 +228,7 @@ impl Page { } } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct MemInfo { total_pages: [usize; MAX_ORDER], free_pages: [usize; MAX_ORDER], diff --git a/src/mm/vm/mapping/phys_mem.rs b/src/mm/vm/mapping/phys_mem.rs index 4106bf0d5..84b64debd 100644 --- a/src/mm/vm/mapping/phys_mem.rs +++ b/src/mm/vm/mapping/phys_mem.rs @@ -10,7 +10,7 @@ use crate::mm::pagetable::PTEntryFlags; use super::{Mapping, VirtualMapping}; /// Map physically contiguous memory -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct VMPhysMem { /// Physical base address to map base: PhysAddr, diff --git a/src/mm/vm/mapping/reserved.rs b/src/mm/vm/mapping/reserved.rs index 1ae9d388f..69cd9745b 100644 --- a/src/mm/vm/mapping/reserved.rs +++ b/src/mm/vm/mapping/reserved.rs @@ -12,7 +12,7 @@ use super::{Mapping, VirtualMapping}; /// Reserve a region of address space so that no other mapping will be /// established there. The map function for this type will always return /// `None`. -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct VMReserved { /// Size in bytes to reserve. Must be aligned to PAGE_SIZE size: usize, diff --git a/src/protocols/mod.rs b/src/protocols/mod.rs index a695a826c..833da34b9 100644 --- a/src/protocols/mod.rs +++ b/src/protocols/mod.rs @@ -9,7 +9,7 @@ pub mod errors; use crate::sev::vmsa::{GuestVMExit, VMSA}; -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct RequestParams { pub guest_exit_code: GuestVMExit, sev_features: u64, diff --git a/src/sev/ghcb.rs b/src/sev/ghcb.rs index 470c7331a..1354798b0 100644 --- a/src/sev/ghcb.rs +++ b/src/sev/ghcb.rs @@ -41,14 +41,14 @@ const OFF_VERSION: u16 = 0xffa; const OFF_USAGE: u16 = 0xffc; #[repr(C, packed)] -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct PageStateChangeHeader { cur_entry: u16, end_entry: u16, reserved: u32, } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum PageStateChangeOp { PscPrivate, PscShared, @@ -126,6 +126,7 @@ impl GHCBExitCode { pub const RUN_VMPL: u64 = 0x80000018; } +#[derive(Clone, Copy)] pub enum GHCBIOSize { Size8, Size16, diff --git a/src/sev/msr_protocol.rs b/src/sev/msr_protocol.rs index 2e899f9cb..8b7501643 100644 --- a/src/sev/msr_protocol.rs +++ b/src/sev/msr_protocol.rs @@ -26,6 +26,7 @@ impl From for SvsmError { } } +#[derive(Clone, Copy)] #[non_exhaustive] pub enum GHCBMsr {} diff --git a/src/sev/vmsa.rs b/src/sev/vmsa.rs index b4fae9d6e..e11a1e262 100644 --- a/src/sev/vmsa.rs +++ b/src/sev/vmsa.rs @@ -53,7 +53,7 @@ pub enum GuestVMExit { } #[repr(C, packed)] -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct VMSASegment { pub selector: u16, pub flags: u16, diff --git a/src/svsm_console.rs b/src/svsm_console.rs index 311130b74..5fe9d3be6 100644 --- a/src/svsm_console.rs +++ b/src/svsm_console.rs @@ -9,6 +9,7 @@ use crate::io::IOPort; use crate::sev::ghcb::GHCBIOSize; use crate::sev::msr_protocol::request_termination_msr; +#[derive(Clone, Copy)] pub struct SVSMIOPort {} impl SVSMIOPort { diff --git a/src/task/tasks.rs b/src/task/tasks.rs index 73f5af79a..a74471b9c 100644 --- a/src/task/tasks.rs +++ b/src/task/tasks.rs @@ -125,7 +125,7 @@ impl TaskRuntime for TscRuntime { /// Tracks task runtime based on the number of times the task has been /// scheduled -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] #[repr(transparent)] pub struct CountRuntime { count: u64, @@ -159,7 +159,7 @@ impl TaskRuntime for CountRuntime { type TaskRuntimeImpl = CountRuntime; #[repr(C)] -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone, Copy)] pub struct TaskContext { pub regs: X86GeneralRegs, pub flags: u64, diff --git a/src/utils/bitmap_allocator.rs b/src/utils/bitmap_allocator.rs index 7927507b9..06e39787b 100644 --- a/src/utils/bitmap_allocator.rs +++ b/src/utils/bitmap_allocator.rs @@ -22,7 +22,7 @@ pub trait BitmapAllocator { pub type BitmapAllocator1024 = BitmapAllocatorTree; -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, Copy)] pub struct BitmapAllocator64 { bits: u64, } From ca618b7b58c49ca7e053012410b5697a70dd7dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Tue, 14 Nov 2023 15:56:06 +0100 Subject: [PATCH 2/2] svsm: add missing Debug derives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing Debug trait derives to multiple types. To prevent adding new types that could derive the type but don't, add a lint attribute to lib.rs. Signed-off-by: Carlos López --- src/acpi/tables.rs | 1 + src/cpu/cpuid.rs | 2 +- src/cpu/gdt.rs | 2 +- src/debug/stacktrace.rs | 1 + src/elf/mod.rs | 10 ++++++++-- src/fw_cfg.rs | 2 +- src/io.rs | 3 ++- src/kernel_launch.rs | 2 +- src/lib.rs | 1 + src/mm/alloc.rs | 3 ++- src/mm/guestmem.rs | 1 + src/mm/pagetable.rs | 1 + src/mm/ptguards.rs | 2 ++ src/serial.rs | 1 + src/sev/ghcb.rs | 3 ++- src/sev/msr_protocol.rs | 2 +- src/sev/secrets_page.rs | 2 +- src/sev/vmsa.rs | 1 + src/svsm_console.rs | 2 +- src/utils/immut_after_init.rs | 2 ++ 20 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/acpi/tables.rs b/src/acpi/tables.rs index ecedad9eb..8c2270227 100644 --- a/src/acpi/tables.rs +++ b/src/acpi/tables.rs @@ -456,6 +456,7 @@ pub struct ACPICPUInfo { /// use svsm::fw_cfg::FwCfg; /// use svsm::io::IOPort; /// +/// #[derive(Debug)] /// struct MyIo; /// /// impl IOPort for MyIo { diff --git a/src/cpu/cpuid.rs b/src/cpu/cpuid.rs index 74b4833a5..d8b2e316b 100644 --- a/src/cpu/cpuid.rs +++ b/src/cpu/cpuid.rs @@ -51,7 +51,7 @@ pub fn register_cpuid_table(table: &'static SnpCpuidTable) { .expect("Could not initialize CPUID page"); } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct CpuidResult { pub eax: u32, pub ebx: u32, diff --git a/src/cpu/gdt.rs b/src/cpu/gdt.rs index 0657d8f1a..0d96c75fd 100644 --- a/src/cpu/gdt.rs +++ b/src/cpu/gdt.rs @@ -11,7 +11,7 @@ use core::arch::asm; use core::mem; #[repr(C, packed(2))] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct GdtDesc { size: u16, addr: VirtAddr, diff --git a/src/debug/stacktrace.rs b/src/debug/stacktrace.rs index 9d11e2728..fe22e8848 100644 --- a/src/debug/stacktrace.rs +++ b/src/debug/stacktrace.rs @@ -53,6 +53,7 @@ pub enum UnwoundStackFrame { type StacksBounds = [StackBounds; 2]; #[cfg(feature = "enable-stacktrace")] +#[derive(Debug)] pub struct StackUnwinder { next_frame: Option, stacks: StacksBounds, diff --git a/src/elf/mod.rs b/src/elf/mod.rs index 3d0a790fd..72b448241 100644 --- a/src/elf/mod.rs +++ b/src/elf/mod.rs @@ -1786,7 +1786,7 @@ impl Elf64Dynamic { } /// Information about the allocation of a virtual address range -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct Elf64ImageLoadVaddrAllocInfo { /// The virtual address (vaddr) range to allocate pub range: Elf64AddrRange, @@ -1796,6 +1796,7 @@ pub struct Elf64ImageLoadVaddrAllocInfo { } /// Represents an ELF64 image load segment +#[derive(Debug)] pub struct Elf64ImageLoadSegment<'a> { /// The virtual address (vaddr) range covering by this segment pub vaddr_range: Elf64AddrRange, @@ -1806,6 +1807,7 @@ pub struct Elf64ImageLoadSegment<'a> { } /// An iterator over ELF64 image load segments within an ELF file +#[derive(Debug)] pub struct Elf64ImageLoadSegmentIterator<'a> { elf_file: &'a Elf64File<'a>, load_base: Elf64Xword, @@ -1938,6 +1940,7 @@ impl Elf64Sym { /// Represents an ELF64 symbol table ([`Elf64Symtab`]) containing /// symbols used within the ELF file. +#[derive(Debug)] struct Elf64Symtab<'a> { /// The underlying buffer containing the symbol table data syms_buf: &'a [u8], @@ -2041,6 +2044,7 @@ impl Elf64Rela { } /// Represents a collection of relocation entries in an ELF64 file ([`Elf64Relas`]) +#[derive(Debug)] struct Elf64Relas<'a> { /// The underlying buffer containing the relocation entries relas_buf: &'a [u8], @@ -2093,6 +2097,7 @@ impl<'a> Elf64Relas<'a> { } /// Represents an iterator over section headers in an ELF64 file +#[derive(Debug)] pub struct Elf64ShdrIterator<'a> { /// The ELF64 file from which section headers are being iterated elf_file: &'a Elf64File<'a>, @@ -2170,7 +2175,7 @@ pub trait Elf64RelocProcessor { } /// Relocation processor specifically for x86_64 ELF files. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct Elf64X86RelocProcessor; impl Elf64X86RelocProcessor { @@ -2265,6 +2270,7 @@ impl Elf64RelocProcessor for Elf64X86RelocProcessor { } /// An iterator that applies relocation operations to ELF64 relocations +#[derive(Debug)] pub struct Elf64AppliedRelaIterator<'a, RP: Elf64RelocProcessor> { /// The ELF64 relocation processor used for applying relocations rela_proc: RP, diff --git a/src/fw_cfg.rs b/src/fw_cfg.rs index b5a0e3d17..bc4e41a78 100644 --- a/src/fw_cfg.rs +++ b/src/fw_cfg.rs @@ -29,7 +29,7 @@ const MAX_FW_CFG_FILES: u32 = 0x1000; //use crate::println; #[non_exhaustive] - +#[derive(Debug)] pub struct FwCfg<'a> { driver: &'a dyn IOPort, } diff --git a/src/io.rs b/src/io.rs index c07f87b9c..3167e7509 100644 --- a/src/io.rs +++ b/src/io.rs @@ -5,8 +5,9 @@ // Author: Joerg Roedel use core::arch::asm; +use core::fmt::Debug; -pub trait IOPort: Sync { +pub trait IOPort: Sync + Debug { fn outb(&self, port: u16, value: u8) { unsafe { asm!("outb %al, %dx", in("al") value, in("dx") port, options(att_syntax)) } } diff --git a/src/kernel_launch.rs b/src/kernel_launch.rs index 6ed0bc498..4879be18f 100644 --- a/src/kernel_launch.rs +++ b/src/kernel_launch.rs @@ -4,7 +4,7 @@ // // Author: Joerg Roedel -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct KernelLaunchInfo { /// Start of the kernel in physical memory. diff --git a/src/lib.rs b/src/lib.rs index 11840be6a..c8625b5cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ #![no_std] #![deny(missing_copy_implementations)] +#![deny(missing_debug_implementations)] #![cfg_attr(all(test, test_in_svsm), no_main)] #![cfg_attr(all(test, test_in_svsm), feature(custom_test_frameworks))] #![cfg_attr(all(test, test_in_svsm), test_runner(crate::testing::svsm_test_runner))] diff --git a/src/mm/alloc.rs b/src/mm/alloc.rs index 8c601e96a..b044b4930 100644 --- a/src/mm/alloc.rs +++ b/src/mm/alloc.rs @@ -1282,8 +1282,9 @@ static TEST_ROOT_MEM_LOCK: SpinLock<()> = SpinLock::new(()); #[cfg(test)] pub const DEFAULT_TEST_MEMORY_SIZE: usize = 16usize * 1024 * 1024; -#[cfg(any(test, fuzzing))] /// A dummy struct to acquire a lock over global memory +#[cfg(any(test, fuzzing))] +#[derive(Debug)] pub struct TestRootMem<'a>(LockGuard<'a, ()>); #[cfg(any(test, fuzzing))] diff --git a/src/mm/guestmem.rs b/src/mm/guestmem.rs index e55931942..4c9e5086d 100644 --- a/src/mm/guestmem.rs +++ b/src/mm/guestmem.rs @@ -171,6 +171,7 @@ unsafe fn do_movsb(src: *const T, dst: *mut T) -> Result<(), SvsmError> { } } +#[derive(Debug)] pub struct GuestPtr where T: Sized + Copy, diff --git a/src/mm/pagetable.rs b/src/mm/pagetable.rs index 47daf5c4d..fc35ba586 100644 --- a/src/mm/pagetable.rs +++ b/src/mm/pagetable.rs @@ -179,6 +179,7 @@ impl IndexMut for PTPage { } } +#[derive(Debug)] pub enum Mapping<'a> { Level3(&'a mut PTEntry), Level2(&'a mut PTEntry), diff --git a/src/mm/ptguards.rs b/src/mm/ptguards.rs index 99f5af078..8c39d5f87 100644 --- a/src/mm/ptguards.rs +++ b/src/mm/ptguards.rs @@ -14,6 +14,7 @@ use crate::mm::virtualrange::{ }; use crate::types::{PAGE_SIZE, PAGE_SIZE_2M}; +#[derive(Debug)] struct RawPTMappingGuard { start: VirtAddr, end: VirtAddr, @@ -25,6 +26,7 @@ impl RawPTMappingGuard { } } +#[derive(Debug)] #[must_use = "if unused the mapping will immediately be unmapped"] pub struct PerCPUPageMappingGuard { mapping: Option, diff --git a/src/serial.rs b/src/serial.rs index 397e29db1..203baabba 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -32,6 +32,7 @@ pub trait Terminal: Sync { } } +#[derive(Debug)] pub struct SerialPort<'a> { pub driver: &'a dyn IOPort, pub port: u16, diff --git a/src/sev/ghcb.rs b/src/sev/ghcb.rs index 1354798b0..bed8b0725 100644 --- a/src/sev/ghcb.rs +++ b/src/sev/ghcb.rs @@ -70,6 +70,7 @@ const PSC_FLAG_HUGE: u64 = 1 << PSC_FLAG_HUGE_SHIFT; const GHCB_BUFFER_SIZE: usize = 0x7f0; #[repr(C, packed)] +#[derive(Debug)] pub struct GHCB { reserved_1: [u8; 0xcb], cpl: u8, @@ -126,7 +127,7 @@ impl GHCBExitCode { pub const RUN_VMPL: u64 = 0x80000018; } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum GHCBIOSize { Size8, Size16, diff --git a/src/sev/msr_protocol.rs b/src/sev/msr_protocol.rs index 8b7501643..2260a5b27 100644 --- a/src/sev/msr_protocol.rs +++ b/src/sev/msr_protocol.rs @@ -26,7 +26,7 @@ impl From for SvsmError { } } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] #[non_exhaustive] pub enum GHCBMsr {} diff --git a/src/sev/secrets_page.rs b/src/sev/secrets_page.rs index d88e97ff9..a09ab7f02 100644 --- a/src/sev/secrets_page.rs +++ b/src/sev/secrets_page.rs @@ -7,7 +7,7 @@ use crate::address::VirtAddr; use crate::sev::vmsa::VMPL_MAX; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] #[repr(C, packed)] pub struct SecretsPage { pub version: u32, diff --git a/src/sev/vmsa.rs b/src/sev/vmsa.rs index e11a1e262..601df5f3e 100644 --- a/src/sev/vmsa.rs +++ b/src/sev/vmsa.rs @@ -62,6 +62,7 @@ pub struct VMSASegment { } #[repr(C, packed)] +#[derive(Debug)] pub struct VMSA { pub es: VMSASegment, pub cs: VMSASegment, diff --git a/src/svsm_console.rs b/src/svsm_console.rs index 5fe9d3be6..28caa0e97 100644 --- a/src/svsm_console.rs +++ b/src/svsm_console.rs @@ -9,7 +9,7 @@ use crate::io::IOPort; use crate::sev::ghcb::GHCBIOSize; use crate::sev::msr_protocol::request_termination_msr; -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct SVSMIOPort {} impl SVSMIOPort { diff --git a/src/utils/immut_after_init.rs b/src/utils/immut_after_init.rs index cf5a8861a..1b96a8785 100644 --- a/src/utils/immut_after_init.rs +++ b/src/utils/immut_after_init.rs @@ -66,6 +66,7 @@ pub enum ImmutAfterInitError { /// } /// ``` /// +#[derive(Debug)] pub struct ImmutAfterInitCell { #[doc(hidden)] data: UnsafeCell>, @@ -221,6 +222,7 @@ unsafe impl Sync for ImmutAfterInitCell {} /// } /// ``` /// +#[derive(Debug)] pub struct ImmutAfterInitRef<'a, T: 'a> { #[doc(hidden)] ptr: ImmutAfterInitCell<*const T>,