From: Hao Feng <fenghao@hygon.cn>
To: "'Joerg Roedel '" <joro@8bytes.org>,
"'Paolo Bonzini '" <pbonzini@redhat.com>,
"' Radim Krčmář '" <rkrcmar@redhat.com>,
"'Thomas Gleixner '" <tglx@linutronix.de>,
"'Ingo Molnar '" <mingo@redhat.com>,
"'Borislav Petkov '" <bp@alien8.de>,
"' H. Peter Anvin '" <hpa@zytor.com>
Cc: "'Zhaohui Du '" <duzhaohui@hygon.cn>,
"'Zhiwei Ying '" <yingzhiwei@hygon.cn>,
"'Wen Pu '" <puwen@hygon.cn>, Hao Feng <fenghao@hygon.cn>,
<x86@kernel.org>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 6/6] KVM: SVM: Add support for KVM_SEV_GM_VERIFY_DIGEST command
Date: Mon, 15 Apr 2019 20:04:28 +0800 [thread overview]
Message-ID: <1555329868-17895-7-git-send-email-fenghao@hygon.cn> (raw)
In-Reply-To: <1555329868-17895-1-git-send-email-fenghao@hygon.cn>
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@hygon.cn>
Signed-off-by: Pu Wen <puwen@hygon.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
next prev parent reply other threads:[~2019-04-15 12:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-15 12:04 [PATCH 0/6] Add Hygon SEV support Hao Feng
2019-04-15 12:04 ` [PATCH 1/6] crypto: ccp: Add Hygon Dhyana support Hao Feng
2019-04-15 12:04 ` [PATCH 2/6] crypto: ccp: Define Hygon SEV commands Hao Feng
2019-04-15 12:04 ` [PATCH 3/6] crypto: ccp: Implement SEV_GM_PUBKEY_GEN ioctl command Hao Feng
2019-04-15 12:04 ` [PATCH 4/6] KVM: Define Hygon SEV commands Hao Feng
2019-04-15 12:04 ` [PATCH 5/6] KVM: SVM: Add support for KVM_SEV_GM_GET_DIGEST command Hao Feng
2019-04-15 15:09 ` Borislav Petkov
[not found] ` <896956377bf441c3bfd911716418ce7e@hygon.cn>
2019-04-16 8:15 ` Borislav Petkov
2019-04-16 11:47 ` Hao Feng
2019-04-15 12:04 ` Hao Feng [this message]
2019-04-15 15:32 ` [PATCH 0/6] Add Hygon SEV support Lendacky, Thomas
2019-04-15 15:37 ` Paolo Bonzini
2019-04-15 15:51 ` Pascal Van Leeuwen
2019-04-15 16:04 ` Paolo Bonzini
2019-04-16 6:58 ` Pascal Van Leeuwen
2019-04-16 8:09 ` Paolo Bonzini
2019-04-16 9:08 ` Pascal Van Leeuwen
2019-04-16 10:28 ` Hao Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1555329868-17895-7-git-send-email-fenghao@hygon.cn \
--to=fenghao@hygon.cn \
--cc=bp@alien8.de \
--cc=duzhaohui@hygon.cn \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=puwen@hygon.cn \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yingzhiwei@hygon.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).