forked from Minki/linux
crypto: ccp: Use the stack and common buffer for status commands
Drop the dedicated status_cmd_buf and instead use a local variable for PLATFORM_STATUS. Now that the low level helper uses an internal buffer for all commands, using the stack for the upper layers is safe even when running with CONFIG_VMAP_STACK=y. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210406224952.4177376-7-seanjc@google.com> Reviewed-by: Brijesh Singh <brijesh.singh@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e4a9af799e
commit
38103671aa
@ -316,15 +316,14 @@ static int sev_platform_shutdown(int *error)
|
||||
|
||||
static int sev_get_platform_state(int *state, int *error)
|
||||
{
|
||||
struct sev_device *sev = psp_master->sev_data;
|
||||
struct sev_user_data_status data;
|
||||
int rc;
|
||||
|
||||
rc = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS,
|
||||
&sev->status_cmd_buf, error);
|
||||
rc = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS, &data, error);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
*state = sev->status_cmd_buf.state;
|
||||
*state = data.state;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -362,15 +361,14 @@ static int sev_ioctl_do_reset(struct sev_issue_cmd *argp, bool writable)
|
||||
|
||||
static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp)
|
||||
{
|
||||
struct sev_device *sev = psp_master->sev_data;
|
||||
struct sev_user_data_status *data = &sev->status_cmd_buf;
|
||||
struct sev_user_data_status data;
|
||||
int ret;
|
||||
|
||||
ret = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS, data, &argp->error);
|
||||
ret = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS, &data, &argp->error);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (copy_to_user((void __user *)argp->data, data, sizeof(*data)))
|
||||
if (copy_to_user((void __user *)argp->data, &data, sizeof(data)))
|
||||
ret = -EFAULT;
|
||||
|
||||
return ret;
|
||||
@ -469,21 +467,20 @@ EXPORT_SYMBOL_GPL(psp_copy_user_blob);
|
||||
static int sev_get_api_version(void)
|
||||
{
|
||||
struct sev_device *sev = psp_master->sev_data;
|
||||
struct sev_user_data_status *status;
|
||||
struct sev_user_data_status status;
|
||||
int error = 0, ret;
|
||||
|
||||
status = &sev->status_cmd_buf;
|
||||
ret = sev_platform_status(status, &error);
|
||||
ret = sev_platform_status(&status, &error);
|
||||
if (ret) {
|
||||
dev_err(sev->dev,
|
||||
"SEV: failed to get status. Error: %#x\n", error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sev->api_major = status->api_major;
|
||||
sev->api_minor = status->api_minor;
|
||||
sev->build = status->build;
|
||||
sev->state = status->state;
|
||||
sev->api_major = status.api_major;
|
||||
sev->api_minor = status.api_minor;
|
||||
sev->build = status.build;
|
||||
sev->state = status.state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ struct sev_device {
|
||||
unsigned int int_rcvd;
|
||||
wait_queue_head_t int_queue;
|
||||
struct sev_misc_dev *misc;
|
||||
struct sev_user_data_status status_cmd_buf;
|
||||
struct sev_data_init init_cmd_buf;
|
||||
|
||||
u8 api_major;
|
||||
|
Loading…
Reference in New Issue
Block a user