The command is used to query the SEV guest status. For more information see [1], section 6.10 [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Spec.pdf Signed-off-by: Brijesh Singh <brijesh.singh@xxxxxxx> --- arch/x86/kvm/svm.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 60cc0f7..63e7d15 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5570,6 +5570,42 @@ err_1: return ret; } +static int sev_guest_status(struct kvm *kvm, + struct kvm_sev_guest_status __user *argp, + int *psp_ret) +{ + int ret; + struct kvm_sev_guest_status params; + struct psp_data_guest_status *status; + + if (!kvm_sev_guest()) + return -ENOTTY; + + if (copy_from_user(¶ms, argp, sizeof(*argp))) + return -EFAULT; + + status = kzalloc(sizeof(*status), GFP_KERNEL); + if (!status) + return -ENOMEM; + + status->hdr.buffer_len = sizeof(*status); + status->handle = kvm_sev_handle(); + ret = psp_guest_status(status, psp_ret); + if (ret) { + printk(KERN_ERR "SEV: GUEST_STATUS ret=%d (%#010x)\n", + ret, *psp_ret); + goto err_1; + } + params.policy = status->policy; + params.state = status->state; + + if (copy_to_user(argp, ¶ms, sizeof(*argp))) + ret = -EFAULT; +err_1: + kfree(status); + return ret; +} + static int amd_sev_issue_cmd(struct kvm *kvm, struct kvm_sev_issue_cmd __user *user_data) { @@ -5595,6 +5631,11 @@ static int amd_sev_issue_cmd(struct kvm *kvm, &arg.ret_code); break; } + case KVM_SEV_GUEST_STATUS: { + r = sev_guest_status(kvm, (void *)arg.opaque, + &arg.ret_code); + break; + } default: break; } -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html