hypervisor: mshv: Fix panic when rejecting extended guest report

swei2_rw_gpa_arg.data is an array of size 16 and value.to_le_bytes() is
only 8 bytes.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
This commit is contained in:
Tom Dohrmann 2024-08-14 16:02:39 +02:00 committed by Bo Chen
parent ce49a6f4b8
commit ca88d4449e

View File

@ -1012,7 +1012,8 @@ impl cpu::Vcpu for MshvVcpu {
byte_count: std::mem::size_of::<u64>() as u32,
..Default::default()
};
swei2_rw_gpa_arg.data.copy_from_slice(&value.to_le_bytes());
swei2_rw_gpa_arg.data[0..8]
.copy_from_slice(&value.to_le_bytes());
self.fd
.gpa_write(&mut swei2_rw_gpa_arg)
.map_err(|e| cpu::HypervisorCpuError::GpaWrite(e.into()))?;