lkml.org 
[lkml]   [2020]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v7 10/18] x86/paravirt: Add hypervisor specific hypercall for SEV live migration.
Date
From: Ashish Kalra <ashish.kalra@amd.com>

Add a new paravirt callback as part of x86_hyper_runtime
(x86 hypervisor specific runtime callbacks) to do hypervisor
specific page encryption status notifications from the SEV
guest.

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
arch/x86/include/asm/x86_init.h | 10 +++++++++-
arch/x86/kernel/kvm.c | 12 ++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 96d9cd208610..888dca30a17a 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -238,10 +238,18 @@ struct x86_legacy_features {
/**
* struct x86_hyper_runtime - x86 hypervisor specific runtime callbacks
*
- * @pin_vcpu: pin current vcpu to specified physical cpu (run rarely)
+ * @pin_vcpu: pin current vcpu to specified physical
+ * cpu (run rarely)
+ * @sev_migration_hcall: this hypercall is used by the SEV guest
+ * to notify a change in the page encryption
+ * status to the hypervisor.
*/
struct x86_hyper_runtime {
void (*pin_vcpu)(int cpu);
+#if defined(CONFIG_AMD_MEM_ENCRYPT)
+ long (*sev_migration_hcall)(unsigned long physaddr,
+ unsigned long npages, bool enc);
+#endif
};

/**
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 6efe0410fb72..928ddb8a8cfc 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -729,6 +729,15 @@ static void __init kvm_init_platform(void)
x86_platform.apic_post_init = kvm_apic_init;
}

+#if defined(CONFIG_AMD_MEM_ENCRYPT)
+long kvm_sev_migration_hcall(unsigned long physaddr, unsigned long npages,
+ bool enc)
+{
+ return kvm_sev_hypercall3(KVM_HC_PAGE_ENC_STATUS, physaddr, npages,
+ enc);
+}
+#endif
+
const __initconst struct hypervisor_x86 x86_hyper_kvm = {
.name = "KVM",
.detect = kvm_detect,
@@ -736,6 +745,9 @@ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
.init.guest_late_init = kvm_guest_init,
.init.x2apic_available = kvm_para_available,
.init.init_platform = kvm_init_platform,
+#if defined(CONFIG_AMD_MEM_ENCRYPT)
+ .runtime.sev_migration_hcall = kvm_sev_migration_hcall,
+#endif
};

static __init int activate_jump_labels(void)
--
2.17.1
\
 
 \ /
  Last update: 2020-04-30 10:44    [W:0.163 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site