mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: Add api to set sev control register
This register configures the SEV feature control state on a virtual processor. Signed-off-by: Jinank Jain <jinankjain@microsoft.com> Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
@@ -272,6 +272,12 @@ pub enum HypervisorCpuError {
|
|||||||
///
|
///
|
||||||
#[error("Failed to get CPUID entries: {0}")]
|
#[error("Failed to get CPUID entries: {0}")]
|
||||||
GetCpuidVales(#[source] anyhow::Error),
|
GetCpuidVales(#[source] anyhow::Error),
|
||||||
|
///
|
||||||
|
/// Setting SEV control register error
|
||||||
|
///
|
||||||
|
#[cfg(feature = "sev_snp")]
|
||||||
|
#[error("Failed to set sev control register: {0}")]
|
||||||
|
SetSevControlRegister(#[source] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -495,4 +501,8 @@ pub trait Vcpu: Send + Sync {
|
|||||||
) -> Result<[u32; 4]> {
|
) -> Result<[u32; 4]> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "mshv")]
|
||||||
|
fn set_sev_control_register(&self, _reg: u64) -> Result<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1241,6 +1241,18 @@ impl cpu::Vcpu for MshvVcpu {
|
|||||||
]
|
]
|
||||||
.to_vec()
|
.to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Sets the AMD specific vcpu's sev control register.
|
||||||
|
///
|
||||||
|
#[cfg(feature = "sev_snp")]
|
||||||
|
fn set_sev_control_register(&self, vmsa_pfn: u64) -> cpu::Result<()> {
|
||||||
|
let sev_control_reg = snp::get_sev_control_register(vmsa_pfn);
|
||||||
|
|
||||||
|
self.fd
|
||||||
|
.set_sev_control_register(sev_control_reg)
|
||||||
|
.map_err(|e| cpu::HypervisorCpuError::SetSevControlRegister(e.into()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MshvVcpu {
|
impl MshvVcpu {
|
||||||
|
|||||||
Reference in New Issue
Block a user