From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: [RFC PATCH v1 28/28] KVM: SVM: add command to query SEV API version Date: Mon, 22 Aug 2016 19:29:46 -0400 Message-ID: <147190858654.9523.6224226679168122395.stgit__3879.28374480016$1471908633$gmane$org@brijesh-build-machine> References: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Received: from mail-cys01nam02on0064.outbound.protection.outlook.com ([104.47.37.64]:36177 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932578AbcHVXaB (ORCPT ); Mon, 22 Aug 2016 19:30:01 -0400 In-Reply-To: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> Sender: linux-crypto-owner@vger.kernel.org List-ID: Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 4af195d..88b8f89 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5779,6 +5779,25 @@ err_1: return ret; } +static int sev_api_version(int *psp_ret) +{ + int ret; + struct psp_data_status *status; + + status = kzalloc(sizeof(*status), GFP_KERNEL); + if (!status) + return -ENOMEM; + + ret = psp_platform_status(status, psp_ret); + if (ret) + goto err; + + ret = (status->api_major << 8) | status->api_minor; +err: + kfree(status); + return ret; +} + static int amd_sev_issue_cmd(struct kvm *kvm, struct kvm_sev_issue_cmd __user *user_data) { @@ -5819,6 +5838,10 @@ static int amd_sev_issue_cmd(struct kvm *kvm, &arg.ret_code); break; } + case KVM_SEV_API_VERSION: { + r = sev_api_version(&arg.ret_code); + break; + } default: break; }