Re: [PATCH V4 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

Juergen Gross
2021-12-05T10:31:54Z

[-- Attachment #1.1.1: Type: text/plain, Size: 1949 bytes --]

On 05.12.21 09:48, Tianyu Lan wrote:
>
>
> On 12/5/2021 4:34 PM, Juergen Gross wrote:
>> On 05.12.21 09:18, Tianyu Lan wrote:
>>> From: Tianyu Lan <Tianyu.Lan@microsoft.com>
>>>
>>> hyperv Isolation VM requires bounce buffer support to copy
>>> data from/to encrypted memory and so enable swiotlb force
>>> mode to use swiotlb bounce buffer for DMA transaction.
>>>
>>> In Isolation VM with AMD SEV, the bounce buffer needs to be
>>> accessed via extra address space which is above shared_gpa_boundary
>>> (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG.
>>> The access physical address will be original physical address +
>>> shared_gpa_boundary. The shared_gpa_boundary in the AMD SEV SNP
>>> spec is called virtual top of memory(vTOM). Memory addresses below
>>> vTOM are automatically treated as private while memory above
>>> vTOM is treated as shared.
>>>
>>> Hyper-V initalizes swiotlb bounce buffer and default swiotlb
>>> needs to be disabled. pci_swiotlb_detect_override() and
>>> pci_swiotlb_detect_4gb() enable the default one. To override
>>> the setting, hyperv_swiotlb_detect() needs to run before
>>> these detect functions which depends on the pci_xen_swiotlb_
>>> init(). Make pci_xen_swiotlb_init() depends on the hyperv_swiotlb
>>> _detect() to keep the order.
>>
>> Why? Does Hyper-V plan to support Xen PV guests? If not, I don't see
>> the need for adding this change.
>>
>
> This is to keep detect function calling order that Hyper-V detect
> callback needs to call before pci_swiotlb_detect_override() and
> pci_swiotlb_detect_4gb(). This is the same for why
> pci_swiotlb_detect_override() needs to depend on the
> pci_xen_swiotlb_detect(). Hyper-V also has such request and so make xen
> detect callback depends on Hyper-V one.

And does this even work without CONFIG_SWIOTLB_XEN, i.e. without
pci_xen_swiotlb_detect() being in the system?

Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]