-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
state:needs-maintainer-feedbackNeeds more information from a maintainer to determine next stepsNeeds more information from a maintainer to determine next stepsstate:needs-triageNeeds to triaged to determine next stepsNeeds to triaged to determine next stepstype:feature-requestA new feature proposalA new feature proposalurgency:mediumImportant with a moderate impactImportant with a moderate impact
Description
Feature Overview
The zerocopy crate provides safe (wrapped unsafe) memory manipulations. This offers the ability to remove a lot of unsafe blocks in Patina and rely on zerocopy to convert to and from bytes, etc.
Solution Overview
Use zerocopy in config_tables module to remove unsafe usage (I'm assuming the ones that pertains to pointer-object casting?)
Alternatives Considered
No response
Urgency
Medium
Are you going to implement the feature request?
I will implement the feature
Do you need maintainer feedback?
Maintainer feedback requested
Anything else?
It'd be nice to get more clarification on exactly the kind of unsafe usage we want prevented. To be specific, for example:
In config_tables/memory_attributes_table.rs:
match core_allocate_pool(efi::BOOT_SERVICES_DATA, size_of::<efi::MemoryAttributesTable>()) {
Ok(empty_ptr) => {
if let Some(empty_mat) = unsafe { (empty_ptr as *mut efi::MemoryAttributesTable).as_mut() } {
...- Now this sort of unsafe usage seems like a good candidate for using
zerocopy. However, regardless, it will still require a cast to a byte slice, which would be an unsafe operation. That could probably also be eliminated if we have aBox-like allocation API -- is that something that's in-scope for this feature or should we let theunsafeneeded to cast into a byte slice remain? - Also, looks like
zerocopyis primarily driven by derive macros and you can't provide custom implementations for those traits. But that means we have a recursive dependency for all children members to also have it implemented. In this case specifically,pub struct MemoryAttributesTable(*mut efi::MemoryAttributesTable);can't implement it untilefi::MemoryAttributesTabledoes, which is an external dependency. Do I duplicate the struct? Is there some other way to implement these traits that I'm missing? Sorry if that's a stupid question.
Metadata
Metadata
Assignees
Labels
state:needs-maintainer-feedbackNeeds more information from a maintainer to determine next stepsNeeds more information from a maintainer to determine next stepsstate:needs-triageNeeds to triaged to determine next stepsNeeds to triaged to determine next stepstype:feature-requestA new feature proposalA new feature proposalurgency:mediumImportant with a moderate impactImportant with a moderate impact
Type
Projects
Status
No status