mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
hypervisor: kvm: add two safety comments
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
d272113d0c
commit
6c89c541da
@ -2066,6 +2066,7 @@ impl cpu::Vcpu for KvmVcpu {
|
|||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
fn get_tdx_exit_details(&mut self) -> cpu::Result<TdxExitDetails> {
|
fn get_tdx_exit_details(&mut self) -> cpu::Result<TdxExitDetails> {
|
||||||
let kvm_run = self.fd.get_kvm_run();
|
let kvm_run = self.fd.get_kvm_run();
|
||||||
|
// SAFETY: accessing a union field in a valid structure
|
||||||
let tdx_vmcall = unsafe { &mut kvm_run.__bindgen_anon_1.tdx.u.vmcall };
|
let tdx_vmcall = unsafe { &mut kvm_run.__bindgen_anon_1.tdx.u.vmcall };
|
||||||
|
|
||||||
tdx_vmcall.status_code = TDG_VP_VMCALL_INVALID_OPERAND;
|
tdx_vmcall.status_code = TDG_VP_VMCALL_INVALID_OPERAND;
|
||||||
@ -2089,6 +2090,7 @@ impl cpu::Vcpu for KvmVcpu {
|
|||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
fn set_tdx_status(&mut self, status: TdxExitStatus) {
|
fn set_tdx_status(&mut self, status: TdxExitStatus) {
|
||||||
let kvm_run = self.fd.get_kvm_run();
|
let kvm_run = self.fd.get_kvm_run();
|
||||||
|
// SAFETY: accessing a union field in a valid structure
|
||||||
let tdx_vmcall = unsafe { &mut kvm_run.__bindgen_anon_1.tdx.u.vmcall };
|
let tdx_vmcall = unsafe { &mut kvm_run.__bindgen_anon_1.tdx.u.vmcall };
|
||||||
|
|
||||||
tdx_vmcall.status_code = match status {
|
tdx_vmcall.status_code = match status {
|
||||||
|
Loading…
Reference in New Issue
Block a user