Conversation
|
@femiatl Could you please resolve the conflicts such that CI can work on this PR. |
5d880ea to
54e3a52
Compare
VTL0 sends data to the secure kernel during and after initial boot. Use the new attributes parameter to extend load_kdata, allowing it to process data after boot and use the improved format for sending data from VTL0. Small, simple data buffers like certificates can be sent efficiently with the same APIs used for larger aggregated data like module info. The new data format is leveraged to reduce the size of the kernel string table passed from ~10MB (all of rodata) to ~250KB. The validate_module and validate_kexec APIs are extended to use the new attributes.
54e3a52 to
d4626b2
Compare
|
🤖 SemverChecks 🤖 Click for details |
|
It seems that this change is based on new ABI to simplify data transfer. Good idea! As @tgopinath-microsoft noted in #652, this cannot be merged yet. One overall feedback or requested change: This PR needs some detailed comments to explain new ABI and data structures. Also, some functions are with old comments (e.g., these functions no longer get |
| pub pa: u64, | ||
| pub epa: u64, | ||
| data_type: u16, | ||
| pub attr: u16, |
There was a problem hiding this comment.
Is this MemAttr? a bit misleading because we do have HekiDataAttr above.
| // modular_bitfield generates warning. There is an updated crate | ||
| // with fix, but we are locked to current version. |
There was a problem hiding this comment.
We could try to use the updated one.
| } | ||
|
|
||
| /// `HekiDataRange` is a generic container for various types of memory ranges. | ||
| /// It has a context-specific `attributes` |
There was a problem hiding this comment.
Seems this "context-specific attributes" is no longer valid. data_type is now context-specific and attr is just MemAttr.
| const MAX_RANGE_COUNT: usize = | ||
| (Self::SIZE - size_of::<HekiDataHdr>()) / size_of::<HekiDataRange>(); | ||
|
|
||
| pub fn from_bytes(bytes: &[u8]) -> Result<&Self, VsmError> { |
There was a problem hiding this comment.
try_from_bytes would be better.
| Ok(data_page) | ||
| } | ||
|
|
||
| pub fn kdata_type(&self) -> HekiKdataType { |
There was a problem hiding this comment.
Both HekiDataHdr and HekiDataRange have data_type. Do they serve different purposes?
| @@ -254,12 +256,14 @@ pub fn mshv_vsm_end_of_boot() -> i64 { | |||
|
|
|||
| /// VSM function for protecting certain memory ranges (e.g., kernel text, data, heap). | |||
| /// `pa` and `nranges` specify a memory area containing the information about the memory ranges to protect. | |||
There was a problem hiding this comment.
nranges is no longer used.
| /// `pa` and `nranges` specify a memory area containing the information about the memory ranges to protect. | ||
| pub fn mshv_vsm_protect_memory(pa: u64, nranges: u64) -> Result<i64, VsmError> { | ||
| pub fn mshv_vsm_protect_memory(pa: u64, va: u64, attr: u64) -> Result<i64, VsmError> { | ||
| if attr == 0 { |
There was a problem hiding this comment.
Fine for now, but breaking ABI change like this should be gracefully handled in the future.
There was a problem hiding this comment.
Agreed. Let me update the PR with some doc for breaking API as well
| HekiKdataType::try_from(self.hdr.data_type).unwrap_or(HekiKdataType::Unknown) | ||
| } | ||
|
|
||
| pub fn next(&self) -> Option<(u64, u64, usize)> { |
There was a problem hiding this comment.
better to rename this function because next() looks like this is for iterator, but it isn't.
| mem_attr, | ||
| )?; | ||
| } | ||
| let Some(next_data_page_addr) = data_page.next() else { |
There was a problem hiding this comment.
next_data_page_addr is misleading because this is a tuple.
| } | ||
| } | ||
| let attr = HekiDataAttr::from_bytes(attr.to_le_bytes()); | ||
| let data_type = attr.dtype_or_err().unwrap_or(HekiKdataType::Unknown); |
There was a problem hiding this comment.
If this is unknown data, better to return an error here.
|
It seems that unlike the current |
VTL0 sends data to the secure kernel during and after initial boot. Use the new attributes parameter to extend load_kdata, allowing it to process data after boot and use the improved format for sending data from VTL0. Small, simple data buffers like certificates can be sent efficiently with the same APIs used for larger aggregated data like module info.
The new data format is leveraged to reduce the size of the kernel string table passed from ~10MB (all of rodata) to ~250KB.
The validate_module and validate_kexec APIs are extended to use the new attributes.