[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d0e5e3227e24272ec5f277e6732c5e0a1276d4e1.1588234824.git.ashish.kalra@amd.com>
Date: Thu, 30 Apr 2020 08:43:56 +0000
From: Ashish Kalra <Ashish.Kalra@....com>
To: pbonzini@...hat.com
Cc: tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
joro@...tes.org, bp@...e.de, thomas.lendacky@....com,
x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
srutherford@...gle.com, rientjes@...gle.com,
venu.busireddy@...cle.com, brijesh.singh@....com
Subject: [PATCH v7 10/18] x86/paravirt: Add hypervisor specific hypercall for SEV live migration.
From: Ashish Kalra <ashish.kalra@....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@....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
Powered by blists - more mailing lists