Skip to content

Commit e45e761

Browse files
kelleymhbp3tk0v
authored andcommitted
init: Call mem_encrypt_init() after Hyper-V hypercall init is done
Full Hyper-V initialization, including support for hypercalls, is done as an apic_post_init callback via late_time_init(). mem_encrypt_init() needs to make hypercalls when it marks swiotlb memory as decrypted. But mem_encrypt_init() is currently called a few lines before late_time_init(), so the hypercalls don't work. Fix this by moving mem_encrypt_init() after late_time_init() and related clock initializations. The intervening initializations don't do any I/O that requires the swiotlb, so moving mem_encrypt_init() slightly later has no impact. Signed-off-by: Michael Kelley <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c7b5254 commit e45e761

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

init/main.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,6 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
10881088
*/
10891089
locking_selftest();
10901090

1091-
/*
1092-
* This needs to be called before any devices perform DMA
1093-
* operations that might use the SWIOTLB bounce buffers. It will
1094-
* mark the bounce buffers as decrypted so that their usage will
1095-
* not cause "plain-text" data to be decrypted when accessed.
1096-
*/
1097-
mem_encrypt_init();
1098-
10991091
#ifdef CONFIG_BLK_DEV_INITRD
11001092
if (initrd_start && !initrd_below_start_ok &&
11011093
page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
@@ -1112,6 +1104,17 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
11121104
late_time_init();
11131105
sched_clock_init();
11141106
calibrate_delay();
1107+
1108+
/*
1109+
* This needs to be called before any devices perform DMA
1110+
* operations that might use the SWIOTLB bounce buffers. It will
1111+
* mark the bounce buffers as decrypted so that their usage will
1112+
* not cause "plain-text" data to be decrypted when accessed. It
1113+
* must be called after late_time_init() so that Hyper-V x86/x64
1114+
* hypercalls work when the SWIOTLB bounce buffers are decrypted.
1115+
*/
1116+
mem_encrypt_init();
1117+
11151118
pid_idr_init();
11161119
anon_vma_init();
11171120
#ifdef CONFIG_X86

0 commit comments

Comments
 (0)