swiotlb: Add swiotlb bounce buffer remap function for HV IVM
authorTianyu Lan <Tianyu.Lan@microsoft.com>
Mon, 13 Dec 2021 07:14:02 +0000 (02:14 -0500)
committerWei Liu <wei.liu@kernel.org>
Mon, 20 Dec 2021 18:01:09 +0000 (18:01 +0000)
commit1a5e91d8375fc8369207cc0b9894a324f2bbf1d9
tree90adc3ada686f1f7e7ea408256ec7bc669d8acc9
parent2585cf9dfaaddf00b069673f27bb3f8530e2039c
swiotlb: Add swiotlb bounce buffer remap function for HV IVM

In Isolation VM with AMD SEV, 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.

Expose swiotlb_unencrypted_base for platforms to set unencrypted
memory base offset and platform calls swiotlb_update_mem_attributes()
to remap swiotlb mem to unencrypted address space. memremap() can
not be called in the early stage and so put remapping code into
swiotlb_update_mem_attributes(). Store remap address and use it to copy
data from/to swiotlb bounce buffer.

Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20211213071407.314309-2-ltykernel@gmail.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
include/linux/swiotlb.h
kernel/dma/swiotlb.c