lkml.org 
[lkml]   [2017]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Part2 PATCH v5 28/31] KVM: X86: Add memory encryption enabled ops
Date
Extend kvm_x86_ops to add mem_enc_enabled() ops. The ops can be used to
check if memory encryption is enabled for a given VCPU.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
---
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/svm.c | 6 ++++++
2 files changed, 7 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3195a8cc517d..cad9672fbe8c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1076,6 +1076,7 @@ struct kvm_x86_ops {
int (*mem_enc_op)(struct kvm *kvm, void __user *argp);
int (*mem_enc_register_region)(struct kvm *kvm, struct kvm_enc_region *argp);
int (*mem_enc_unregister_region)(struct kvm *kvm, struct kvm_enc_region *argp);
+ bool (*mem_enc_enabled)(struct kvm_vcpu *vcpu);
};

struct kvm_arch_async_pf {
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index daf7aa8ed2c7..5c2f5b15886c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6635,6 +6635,11 @@ static int svm_unregister_enc_region(struct kvm *kvm,
return 0;
}

+static bool mem_enc_enabled(struct kvm_vcpu *vcpu)
+{
+ return to_svm(vcpu)->vmcb->control.nested_ctl & SVM_NESTED_CTL_SEV_ENABLE;
+}
+
static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.cpu_has_kvm_support = has_svm,
.disabled_by_bios = is_disabled,
@@ -6749,6 +6754,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.mem_enc_op = svm_mem_enc_op,
.mem_enc_register_region = svm_register_enc_region,
.mem_enc_unregister_region = svm_unregister_enc_region,
+ .mem_enc_enabled = mem_enc_enabled
};

static int __init svm_init(void)
--
2.9.5
\
 
 \ /
  Last update: 2017-10-04 15:16    [W:0.397 / U:6.660 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site