[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1555329868-17895-7-git-send-email-fenghao@hygon.cn>
Date: Mon, 15 Apr 2019 20:04:28 +0800
From: Hao Feng <fenghao@...on.cn>
To: "'Joerg Roedel '" <joro@...tes.org>,
"'Paolo Bonzini '" <pbonzini@...hat.com>,
' Radim Krčmář '
<rkrcmar@...hat.com>, "'Thomas Gleixner '" <tglx@...utronix.de>,
"'Ingo Molnar '" <mingo@...hat.com>,
"'Borislav Petkov '" <bp@...en8.de>,
"' H. Peter Anvin '" <hpa@...or.com>
CC: "'Zhaohui Du '" <duzhaohui@...on.cn>,
"'Zhiwei Ying '" <yingzhiwei@...on.cn>,
"'Wen Pu '" <puwen@...on.cn>, Hao Feng <fenghao@...on.cn>,
<x86@...nel.org>, <kvm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH 6/6] KVM: SVM: Add support for KVM_SEV_GM_VERIFY_DIGEST command
The command is used to send guest owner's key digest to SEV firmware,
firmware will check the key digest to see if the key negotiation is
successful or not.
Signed-off-by: Hao Feng <fenghao@...on.cn>
Signed-off-by: Pu Wen <puwen@...on.cn>
---
arch/x86/kvm/svm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f8e7042..4dbdccf 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -7015,6 +7015,50 @@ static int sev_gm_get_digest(struct kvm *kvm, struct kvm_sev_cmd *argp)
return ret;
}
+static int sev_gm_verify_digest(struct kvm *kvm, struct kvm_sev_cmd *argp)
+{
+ void __user *digest = (void __user *)(uintptr_t)argp->data;
+ struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
+ struct sev_data_gm_verify_digest *data = NULL;
+ struct kvm_sev_gm_verify_digest params;
+ void *digest_blob = NULL;
+ int *error = &argp->error;
+ int ret;
+
+ if (!sev_guest(kvm))
+ return -ENOTTY;
+
+ if (copy_from_user(¶ms, digest, sizeof(params)))
+ return -EFAULT;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ if (params.uaddr) {
+ digest_blob = psp_copy_user_blob(params.uaddr, params.len);
+ if (IS_ERR(digest_blob)) {
+ ret = PTR_ERR(digest_blob);
+ goto e_free;
+ }
+
+ data->address = __psp_pa(digest_blob);
+ data->len = params.len;
+ }
+
+ data->handle = sev->handle;
+ ret = sev_issue_cmd(kvm, SEV_CMD_GM_VERIFY_DIGEST, data, error);
+ if (ret)
+ goto e_free_digest;
+
+e_free_digest:
+ kfree(digest_blob);
+e_free:
+ kfree(data);
+
+ return ret;
+}
+
static int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
{
struct kvm_sev_cmd sev_cmd;
@@ -7059,6 +7103,9 @@ static int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
case KVM_SEV_GM_GET_DIGEST:
r = sev_gm_get_digest(kvm, &sev_cmd);
break;
+ case KVM_SEV_GM_VERIFY_DIGEST:
+ r = sev_gm_verify_digest(kvm, &sev_cmd);
+ break;
default:
r = -EINVAL;
goto out;
--
2.7.4
Powered by blists - more mailing lists