mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tpm: save almost 8KB stack space
The largest possible PTM response is only 16 bytes. Size the output buffer correctly. In the socket read function, rely on the caller to provide a sufficiently large buffer. That eliminates another large stack variable. In total this saves almost 8KB stack space. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -216,7 +216,16 @@ impl Emulator {
|
||||
))
|
||||
})?;
|
||||
|
||||
let mut output = [0_u8; TPM_CRB_BUFFER_MAX];
|
||||
// The largest response is 16 bytes so far.
|
||||
if msg_len_out > 16 {
|
||||
return Err(Error::RunControlCmd(anyhow!(
|
||||
"Response size is too large for Cmd {:02X?}, max 16 wanted {}",
|
||||
cmd,
|
||||
msg_len_out
|
||||
)));
|
||||
}
|
||||
|
||||
let mut output = [0u8; 16];
|
||||
|
||||
// Every Control Cmd gets atleast a result code in response. Read it
|
||||
let read_size = self.control_socket.read(&mut output).map_err(|e| {
|
||||
|
||||
Reference in New Issue
Block a user