summaryrefslogtreecommitdiff
path: root/arch/x86/hyperv/hv_vtl.c
diff options
context:
space:
mode:
authorMichael Kelley <mhklinux@outlook.com>2024-01-15 18:20:08 -0800
committerWei Liu <wei.liu@kernel.org>2024-03-01 08:31:42 +0000
commit0f34d11234868dc979730a905717c15067a7d205 (patch)
tree4f2c3abd422447a12102b34d7f24d856640a7cfd /arch/x86/hyperv/hv_vtl.c
parent030ad7af94371f1faeecfc12dda296d8b5a17ef8 (diff)
x86/hyperv: Make encrypted/decrypted changes safe for load_unaligned_zeropad()
In a CoCo VM, when transitioning memory from encrypted to decrypted, or vice versa, the caller of set_memory_encrypted() or set_memory_decrypted() is responsible for ensuring the memory isn't in use and isn't referenced while the transition is in progress. The transition has multiple steps, and the memory is in an inconsistent state until all steps are complete. A reference while the state is inconsistent could result in an exception that can't be cleanly fixed up. However, the kernel load_unaligned_zeropad() mechanism could cause a stray reference that can't be prevented by the caller of set_memory_encrypted() or set_memory_decrypted(), so there's specific code to handle this case. But a CoCo VM running on Hyper-V may be configured to run with a paravisor, with the #VC or #VE exception routed to the paravisor. There's no architectural way to forward the exceptions back to the guest kernel, and in such a case, the load_unaligned_zeropad() specific code doesn't work. To avoid this problem, mark pages as "not present" while a transition is in progress. If load_unaligned_zeropad() causes a stray reference, a normal page fault is generated instead of #VC or #VE, and the page-fault-based fixup handlers for load_unaligned_zeropad() resolve the reference. When the encrypted/decrypted transition is complete, mark the pages as "present" again. Signed-off-by: Michael Kelley <mhklinux@outlook.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Link: https://lore.kernel.org/r/20240116022008.1023398-4-mhklinux@outlook.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <20240116022008.1023398-4-mhklinux@outlook.com>
Diffstat (limited to 'arch/x86/hyperv/hv_vtl.c')
0 files changed, 0 insertions, 0 deletions