Hi,
I am Newbie at SMMU. I am confused that If hypervisor is enabled, Why do the software in EL1 can modify the TTB of S2 in stream table entry?
The S1ContextPtr in the STE is controlled by the hypervisor. It can point to a CD in hypervisor memory, or it can point to a CD in guest memory, but it is usually not controlled by the OS kernel running in EL1.
In the case where CD reside in guest memory, handling the s1 translation tables is fully delegated to the guest. This is illustrated in slide 13 of this presentation for example: https://events.static.linuxfound.org/sites/events/files/slides/viommu_arm_upload_1.pdf
but it is usually not controlled by the OS kernel running in EL1
>>>Why? In my opinion, the S1 information of the device should be clear to kernel.
Yes, if so, it's safe.
But the hypervisor might need to somehow inform the VM that different streamid corresponds to different CD addresses?
Usually one streamid corresponds to one device. When the hypervisor assigns a device to a VM it will setup the STE.
For stage 1 handling delegation to the guest a viommu is necessary. When the guest programs the CD address in the viommu, the vmm will relay the request to the hypervisor using e.g. a vfio ioctl. See this patch series for an example: https://lkml.org/lkml/2021/2/23/792
Got it, thanks a lot!