From 3245b8dde1f70403a28abe1e997b9f4a9fa0a4f3 Mon Sep 17 00:00:00 2001 From: yangwencheng Date: Fri, 17 Nov 2023 08:10:03 +0000 Subject: [PATCH] x86/kvm: Don't hypercall to enc all usable RAM on CSV3 platform Upstream: no The commit 73f1b4fece21 ("x86/kvm: Add kexec support for SEV Live Migration.") traverses the e820 table to force the Host to track the guest RAM as encrypted. Actually, it's somewhat rough for the CSV3 guest, since memory for CSV3 is isolated and invisible to the hypervisor. In order to keep the page encryption states in consistency between the guest and the host, bypass the logic of traversing the e820 table if the guest is using the CSV3 protection. Signed-off-by: yangwencheng Signed-off-by: hanliyang --- arch/x86/kernel/kvm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index b8ab9ee5896c..74e768cdb585 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -44,6 +44,8 @@ #include #include +#include + DEFINE_STATIC_KEY_FALSE(kvm_async_pf_enabled); static int kvmapf = 1; @@ -938,6 +940,9 @@ static void __init kvm_init_platform(void) pv_ops.mmu.notify_page_enc_status_changed = kvm_sev_hc_page_enc_status; +#ifdef CONFIG_HYGON_CSV + if (!csv3_active()) { +#endif /* * Reset the host's shared pages list related to kernel * specific page encryption status settings before we load a @@ -961,6 +966,9 @@ static void __init kvm_init_platform(void) nr_pages, KVM_MAP_GPA_RANGE_ENCRYPTED | KVM_MAP_GPA_RANGE_PAGE_SZ_4K); } +#ifdef CONFIG_HYGON_CSV + } +#endif /* * Ensure that _bss_decrypted section is marked as decrypted in the -- Gitee