Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

td-shim: remove the use of Vec in e820 #700

Merged

Conversation

gaojiaqi7
Copy link
Member

Reducing the use of heap can improve the functional safety. For e820 implementation, use an fixed MAX_E820_ENTRY size array to replace the vector.

Relate issue: #685

@gaojiaqi7 gaojiaqi7 force-pushed the 0511/remove_vectors_in_e820 branch from 5b49c49 to 4a60eb0 Compare May 17, 2024 13:30
}

// Move all entries after the index back one position
for idx in (index + 1..self.num_entries + 1).rev() {
Copy link
Member

@jyao1 jyao1 May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the index > self.num_entries?

what if the index == self.num_entries?

}

// Move all entries after the index forward one position
for idx in index + 1..self.num_entries {
Copy link
Member

@jyao1 jyao1 May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the index > self.num_entries?

what if the index == self.num_entries?

Reducing the use of heap can improve the functional safety. For e820
implementation, use an fixed `MAX_E820_ENTRY` size array to replace the
vector.

Signed-off-by: Jiaqi Gao <[email protected]>
@gaojiaqi7 gaojiaqi7 force-pushed the 0511/remove_vectors_in_e820 branch from 4a60eb0 to 387cc8b Compare May 20, 2024 13:58
}

fn remove_entry(&mut self, index: usize) -> Result<(), E820Error> {
if index >= self.num_entries {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if self.num_entries is 0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.num_entries == 0, the index >= self.num_entries will always be true, then it will return error

@jyao1 jyao1 merged commit 65cc7b0 into confidential-containers:main May 27, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants