Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat: IoMmu protocol#1728

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
PelleKrab wants to merge8 commits intorust-osdev:main
base:main
Choose a base branch
Loading
fromPelleKrab:Iommu
Draft

Conversation

@PelleKrab
Copy link
Contributor

This PR adds the IoMmu Protocol touefi-rs, enabling easy DMA (Direct Memory Access) for devices. This is a draft to get some initial feedback before writinguefi-rs tests. It is already working in my internal project. The main areas I would like feedback on are:

  • Mapping and DMA Buffer Types: Is this too much abstraction? Should we simplify it by requiring the developer to manually callunmap() andfree_buffer()?
  • Shouldfree_buffer_raw() andunmap_raw() be made public?
  • Repository Organization: Is the general organization within the repo appropriate?

General Implementation:

// Allocate DMA bufferlet sz = some_buffer.len();let page_num =bytes_to_pages(sz);letmut host_buffer = iommu.allocate_buffer(MemoryType::BOOT_SERVICES_DATA,    page_num,EdkiiIommuAttribute::MEMORY_CACHED,)?;// Map buffer for DMAlet(device_addr, mapping, wrt_size) = iommu.map(EdkiiIommuOperation::BUS_MASTER_COMMON_BUFFER,&host_buffer,    size,)?;// Give permissions to the specified deviceiommu.set_attribute(some_device_handle,&mapping,EdkiiIommuAccess::READ)?;// Copy firmware to DMA bufferlet dma_buf = host_buffer.deref_mut();if sz > wrt_size{returnStatus::BUFFER_TOO_SMALL;}dma_buf[..sz].copy_from_slice(&some_buffer[..sz]);// Notify the Device and pass the `device_addr`

ref:
#1723

@nicholasbishop
Copy link
Member

Thanks for working on this :) I haven't had a chance to look at theuefi wrapper in detail yet, but overall it looks reasonable. Could you split the uefi-raw part out to a separate PR? That should be straightforward to review and merge in isolation.

PelleKrab and phip1611 reacted with thumbs up emoji

@nicholasbishop
Copy link
Member

Is this ready for review? Currently it's marked as draft still. (No worries if that's intentional, just want to be sure you're not waiting on review.)

@PelleKrab
Copy link
ContributorAuthor

I still need to write some test for it. I have been busy with some other things, so I'll send those over as soon as I can. Feel free to take a look if you want.

nicholasbishop reacted with thumbs up emoji

@PelleKrab
Copy link
ContributorAuthor

@nicholasbishop I am trying to write some test for this, but I cant seem to get a protocol handle. I went into the uefi shell of the qemu vm, and the IoMmu driver image is present:

dh -p 4e939de9-d948-4b0f-88ed-e6e1ce517c1e -vHandle dump by protocol'4E939DE9-D948-4B0F-88ED-E6E1CE517C1E'Shell> dh -p 03c4e603-ac28-11d3-9a2d-0090273fc14d -vHandle dump by protocol'PXEBaseCode'Shell> dh 28 -v28: 3ECF0C18ImageDevicePath(3ECF2A98)  Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(8657015B-EA43-440D-949A-AF3BE365C0FC)LoadedImage(3ECF20C0)  Name..........: IoMmuDxe

So I am assuming the driver is failing to find hardware. I have tried a few different things, different EDK2 builds and followed the virtio instructionshere, but nothing has worked. Ik it worked on hardware, so if you have any ideas on how to get qemu setup for IoMmu please let me know.

@phip1611
Copy link
Member

So I am assuming the driver is failing to find hardware. I have tried a few different things, different EDK2 builds and followed the virtio instructionshere, but nothing has worked.

Thanks for trying to find a solution! Is there any update here? Have you tried to add an IOMMU to the QEMU VM? Perhaps one is needed so that the protocol will be installed one some handles (-device intel-iommu)?

PelleKrab reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@PelleKrab@nicholasbishop@phip1611

[8]ページ先頭

©2009-2025 Movatter.jp