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

shared_pool_alloc: zero out allocated DMA buffers #267

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

eric135
Copy link
Contributor

@eric135 eric135 commented Nov 7, 2024

DMA buffers are expected to be zeroed out upon allocation

MSFT#53036590

@eric135 eric135 requested a review from a team as a code owner November 7, 2024 22:58
jstarks
jstarks previously approved these changes Nov 7, 2024
@eric135 eric135 enabled auto-merge (squash) November 7, 2024 23:05
chris-oo
chris-oo previously approved these changes Nov 7, 2024
@jstarks jstarks changed the title Zero out allocated DMA buffers shared_pool_alloc: zero out allocated DMA buffers Nov 8, 2024
@eric135 eric135 dismissed stale reviews from chris-oo and jstarks via 620e2b5 November 8, 2024 18:00
DMA buffers are expected to be zeroed out upon allocation

MSFT#53036590
@eric135
Copy link
Contributor Author

eric135 commented Nov 8, 2024

Rebasing on newest main

@eric135 eric135 merged commit 01c1b4c into microsoft:main Nov 8, 2024
22 checks passed
@@ -36,7 +36,7 @@ use zerocopy::AsBytes;
use zerocopy::FromBytes;

pub trait VfioDmaBuffer: 'static + Send + Sync {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just sanity checking, there's nothing else that implements this trait today?

Choose a reason for hiding this comment

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

Today it is LockedMemorySpawner and SharedPoolAllocator. Tomorrow also EmulatedDmaAllocator for unit tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do they all follow the new contract?

Choose a reason for hiding this comment

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

This change benefits normal boot and all clients are compatible. For Restore functionality there is alternative path to restore buffers without zeroiniting them, at least how it's implemented in #210

After we're going to merge with #260 then I'll test end-to-end if it works too.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's not what I asked though. We've added a new requirement to this method, we need to make sure all types that implement this trait are meeting the new requirement.

Copy link
Contributor

@mattkur mattkur Nov 12, 2024

Choose a reason for hiding this comment

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

All prod types do (LockedMemorySpawner gets it by way of MAP_ANONYMOUS). It seems that the test code does not?

https://github.com/microsoft/openvmm/blob/04454925c9fdad1845b4450743b739e16d8a8b4d/vm/devices/user_driver/src/emulated.rs#L244C1-L250C2

calls:

pub fn alloc(&self, len: usize) -> Option<DmaBuffer> {

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #299

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.

6 participants