mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:46:16 +00:00
Drivers: hv: vmbus: Remove second way of mapping ring buffers
With changes to how Hyper-V guest VMs flip memory between private (encrypted) and shared (decrypted), it's no longer necessary to have separate code paths for mapping VMBus ring buffers for for normal VMs and for Confidential VMs. As such, remove the code path that uses vmap_pfn(), and set the protection flags argument to vmap() to account for the difference between normal and Confidential VMs. Signed-off-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Tianyu Lan <Tianyu.Lan@microsoft.com> Link: https://lore.kernel.org/r/1679838727-87310-10-git-send-email-mikelley@microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
This commit is contained in:
parent
a5ddb74588
commit
bb862397f4
@ -186,8 +186,6 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
|
||||
struct page *pages, u32 page_cnt, u32 max_pkt_size)
|
||||
{
|
||||
struct page **pages_wraparound;
|
||||
unsigned long *pfns_wraparound;
|
||||
u64 pfn;
|
||||
int i;
|
||||
|
||||
BUILD_BUG_ON((sizeof(struct hv_ring_buffer) != PAGE_SIZE));
|
||||
@ -196,30 +194,6 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
|
||||
* First page holds struct hv_ring_buffer, do wraparound mapping for
|
||||
* the rest.
|
||||
*/
|
||||
if (hv_isolation_type_snp()) {
|
||||
pfn = page_to_pfn(pages) +
|
||||
PFN_DOWN(ms_hyperv.shared_gpa_boundary);
|
||||
|
||||
pfns_wraparound = kcalloc(page_cnt * 2 - 1,
|
||||
sizeof(unsigned long), GFP_KERNEL);
|
||||
if (!pfns_wraparound)
|
||||
return -ENOMEM;
|
||||
|
||||
pfns_wraparound[0] = pfn;
|
||||
for (i = 0; i < 2 * (page_cnt - 1); i++)
|
||||
pfns_wraparound[i + 1] = pfn + i % (page_cnt - 1) + 1;
|
||||
|
||||
ring_info->ring_buffer = (struct hv_ring_buffer *)
|
||||
vmap_pfn(pfns_wraparound, page_cnt * 2 - 1,
|
||||
pgprot_decrypted(PAGE_KERNEL));
|
||||
kfree(pfns_wraparound);
|
||||
|
||||
if (!ring_info->ring_buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Zero ring buffer after setting memory host visibility. */
|
||||
memset(ring_info->ring_buffer, 0x00, PAGE_SIZE * page_cnt);
|
||||
} else {
|
||||
pages_wraparound = kcalloc(page_cnt * 2 - 1,
|
||||
sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
@ -233,13 +207,17 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
|
||||
|
||||
ring_info->ring_buffer = (struct hv_ring_buffer *)
|
||||
vmap(pages_wraparound, page_cnt * 2 - 1, VM_MAP,
|
||||
PAGE_KERNEL);
|
||||
pgprot_decrypted(PAGE_KERNEL));
|
||||
|
||||
kfree(pages_wraparound);
|
||||
if (!ring_info->ring_buffer)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure the header page is zero'ed since
|
||||
* encryption status may have changed.
|
||||
*/
|
||||
memset(ring_info->ring_buffer, 0, HV_HYP_PAGE_SIZE);
|
||||
|
||||
ring_info->ring_buffer->read_index =
|
||||
ring_info->ring_buffer->write_index = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user