Skip to contentSkip to conversation

Can register addresses conversion go through iommu too? probably not..

DISCUSSION [email protected] 3 participants 4 messages Sep 30, 2021 – Oct 1, 2021

lore
Share & tools
lore
#0 lore raw

Hello all,

I know when a device does dma to memory, we use functions like dma_alloc_coherent to allocate a memory region for the dma and we get the kernel virtual address and device virtual address at the same time. The iommu hardware converts the device virtual address to physical address reducing the processing time.

I have a question (to make sure my understanding is correct).

To use registers in the device driver, we use ioremap function to get the kernel virtual address for the device registers. If the OS is running in virtualized environment (a hypervisor under it), this kernel virtual address should go under conversion twice

1. virtual to physical by OS (this physical is not actually physical, an intermediate physical?)

2. intermediate physical to real physical

I thought these two conversions are done by kernel or hypervisor software because iommu is for address translation for the addresses that the device "uses(or generates)", not for the kernel to access the device itself.

Is my understanding correct?

Any help will be appreciated.

Thank you!

Chan Kim

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#1 lore raw
Quoted 6 lines · On Thu, 30 Sep 2021, 08:54 , <[email protected]> wrote:

[If] the OS is running in virtualized environment (a hypervisor under it), this kernel virtual address should go under conversion twice

1. virtual to physical by OS (this physical is not actually physical, an intermediate physical?)

Quoted 8 lines

2. intermediate physical to real physical

I thought these two conversions are done by kernel or hypervisor software because iommu is for address translation for the addresses that the device “uses(or generates)”, not for the kernel to access the device itself.

Is my understanding correct?

Something similar to what you describe happens with old/deprecated technologies. For example, with Full virtualization I/O operations need to go through two software layers.

Virtual Function I/O (VFIO) exposes direct device access to user space in a secure memory (IOMMU) protected environment. With VFIO, a VM Guest can directly access hardware devices on the VM Host Server. This technique improves performance, if compared both to Full virtualization and Paravirtualization. However, with VFIO, devices cannot be shared with multiple VM guests.

Single Root I/O Virtualization (SR-IOV) combines the benefits of performance gains of VFIO and the ability to share a device with several VM Guests (but it requires special hardware that must be capable to appear to two or more VM guests as different devices.

Regards,

Fabio M. De Francesco

P.S.: For further information about Linux virtualization capabilities, please read
https://en.wikipedia.org/wiki/Linux_kernel#Architecture_and_features.

Quoted 6 lines

Any help will be appreciated.

Thank you!

Chan Kim

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#2 lore raw

I see, Thanks a lot! I remember having read about SR-IOV long time ago.

Regards,

Chan Kim

From: FMDF <[email protected]>
Sent: Friday, October 1, 2021 8:41 AM
To: [email protected]
Cc: kernelnewbies <[email protected]>
Subject: Re: Can register addresses conversion go through iommu too? probably not..

On Thu, 30 Sep 2021, 08:54 , <[email protected] <mailto:[email protected]> > wrote:

[If] the OS is running in virtualized environment (a hypervisor under it), this kernel virtual address should go under conversion twice

1. virtual to physical by OS (this physical is not actually physical, an intermediate physical?)

2. intermediate physical to real physical

I thought these two conversions are done by kernel or hypervisor software because iommu is for address translation for the addresses that the device “uses(or generates)”, not for the kernel to access the device itself.

Is my understanding correct?

Something similar to what you describe happens with old/deprecated technologies. For example, with Full virtualization I/O operations need to go through two software layers.

Virtual Function I/O (VFIO) exposes direct device access to user space in a secure memory (IOMMU) protected environment. With VFIO, a VM Guest can directly access hardware devices on the VM Host Server. This technique improves performance, if compared both to Full virtualization and Paravirtualization. However, with VFIO, devices cannot be shared with multiple VM guests.

Single Root I/O Virtualization (SR-IOV) combines the benefits of performance gains of VFIO and the ability to share a device with several VM Guests (but it requires special hardware that must be capable to appear to two or more VM guests as different devices.

Regards,

Fabio M. De Francesco

P.S.: For further information about Linux virtualization capabilities, please read https://en.wikipedia.org/wiki/Linux_kernel#Architecture_and_features.

Any help will be appreciated.

Thank you!

Chan Kim

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#3 lore raw
In reply to [email protected]

Correct

It is done automatically with the help of so called shadow page table

Quoted 32 lines · On Thu, Sep 30, 2021, 13:54 <[email protected]> wrote:

Hello all,

I know when a device does dma to memory, we use functions like dma_alloc_coherent to allocate a memory region for the dma and we get the kernel virtual address and device virtual address at the same time. The iommu hardware converts the device virtual address to physical address reducing the processing time.

I have a question (to make sure my understanding is correct).

To use registers in the device driver, we use ioremap function to get the kernel virtual address for the device registers. If the OS is running in virtualized environment (a hypervisor under it), this kernel virtual address should go under conversion twice

1. virtual to physical by OS (this physical is not actually physical, an intermediate physical?)

2. intermediate physical to real physical

I thought these two conversions are done by kernel or hypervisor software because iommu is for address translation for the addresses that the device “uses(or generates)”, not for the kernel to access the device itself.

Is my understanding correct?

Any help will be appreciated.

Thank you!

Quoted 8 lines

Chan Kim

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies