mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
tpm: drop unused fields in BackendCmd struct
They are never used. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
cffde0ff65
commit
73af65f417
@ -472,10 +472,8 @@ impl BusDevice for Tpm {
|
|||||||
self.regs[CRB_CTRL_START as usize] |= CRB_START_INVOKE;
|
self.regs[CRB_CTRL_START as usize] |= CRB_START_INVOKE;
|
||||||
|
|
||||||
let mut cmd = BackendCmd {
|
let mut cmd = BackendCmd {
|
||||||
locality: locality as u8,
|
|
||||||
buffer: &mut self.data_buff,
|
buffer: &mut self.data_buff,
|
||||||
input_len: cmp::min(self.data_buff_len, TPM_CRB_BUFFER_MAX),
|
input_len: cmp::min(self.data_buff_len, TPM_CRB_BUFFER_MAX),
|
||||||
selftest_done: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = self.emulator.deliver_request(&mut cmd);
|
let _ = self.emulator.deliver_request(&mut cmd);
|
||||||
|
@ -62,12 +62,10 @@ pub enum Error {
|
|||||||
type Result<T> = anyhow::Result<T, Error>;
|
type Result<T> = anyhow::Result<T, Error>;
|
||||||
|
|
||||||
pub struct BackendCmd<'a> {
|
pub struct BackendCmd<'a> {
|
||||||
pub locality: u8,
|
|
||||||
// This buffer is used for both input and output.
|
// This buffer is used for both input and output.
|
||||||
// When used for input, the length of the data is input_len.
|
// When used for input, the length of the data is input_len.
|
||||||
pub buffer: &'a mut [u8],
|
pub buffer: &'a mut [u8],
|
||||||
pub input_len: usize,
|
pub input_len: usize,
|
||||||
pub selftest_done: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Emulator {
|
pub struct Emulator {
|
||||||
@ -285,13 +283,10 @@ impl Emulator {
|
|||||||
|
|
||||||
/// Function to write to data socket and read the response from it
|
/// Function to write to data socket and read the response from it
|
||||||
pub fn deliver_request(&mut self, cmd: &mut BackendCmd) -> Result<()> {
|
pub fn deliver_request(&mut self, cmd: &mut BackendCmd) -> Result<()> {
|
||||||
let isselftest: bool;
|
|
||||||
// SAFETY: type "sockaddr_storage" is valid with an all-zero byte-pattern value
|
// SAFETY: type "sockaddr_storage" is valid with an all-zero byte-pattern value
|
||||||
let mut addr: sockaddr_storage = unsafe { mem::zeroed() };
|
let mut addr: sockaddr_storage = unsafe { mem::zeroed() };
|
||||||
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
|
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
|
||||||
|
let isselftest = is_selftest(&cmd.buffer[0..cmd.input_len]);
|
||||||
cmd.selftest_done = false;
|
|
||||||
isselftest = is_selftest(&cmd.buffer[0..cmd.input_len]);
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"Send cmd: {:02X?} of len {:?} on data_ioc ",
|
"Send cmd: {:02X?} of len {:?} on data_ioc ",
|
||||||
@ -347,16 +342,11 @@ impl Emulator {
|
|||||||
cmd.buffer, output_len, isselftest
|
cmd.buffer, output_len, isselftest
|
||||||
);
|
);
|
||||||
|
|
||||||
if isselftest {
|
if isselftest && output_len < 10 {
|
||||||
if output_len < 10 {
|
return Err(Error::SelfTest(anyhow!(
|
||||||
return Err(Error::SelfTest(anyhow!(
|
"Self test response should have 10 bytes. Only {:?} returned",
|
||||||
"Self test response should have 10 bytes. Only {:?} returned",
|
output_len
|
||||||
output_len
|
)));
|
||||||
)));
|
|
||||||
}
|
|
||||||
let mut errcode: [u8; 4] = [0; 4];
|
|
||||||
errcode.copy_from_slice(&cmd.buffer[6..6 + 4]);
|
|
||||||
cmd.selftest_done = u32::from_ne_bytes(errcode).to_be() == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user