Skip to content

Commit cb645fe

Browse files
codomaniabp3tk0v
authored andcommitted
crypto: ccp: Add the SNP_SET_CONFIG command
The SEV-SNP firmware provides the SNP_CONFIG command used to set various system-wide configuration values for SNP guests, such as the reported TCB version used when signing guest attestation reports. Add an interface to set this via userspace. [ mdr: Squash in doc patch from Dionna, drop extended request/ certificate handling and simplify this to a simple wrapper around SNP_CONFIG fw cmd. ] Signed-off-by: Brijesh Singh <[email protected]> Co-developed-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Alexey Kardashevskiy <[email protected]> Co-developed-by: Dionna Glaze <[email protected]> Signed-off-by: Dionna Glaze <[email protected]> Signed-off-by: Ashish Kalra <[email protected]> Signed-off-by: Michael Roth <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fad133c commit cb645fe

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Documentation/virt/coco/sev-guest.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,19 @@ SEV-SNP firmware SNP_COMMIT command. This prevents roll-back to a previously
162162
committed firmware version. This will also update the reported TCB to match
163163
that of the currently installed firmware.
164164

165+
2.6 SNP_SET_CONFIG
166+
------------------
167+
:Technology: sev-snp
168+
:Type: hypervisor ioctl cmd
169+
:Parameters (in): struct sev_user_data_snp_config
170+
:Returns (out): 0 on success, -negative on error
171+
172+
SNP_SET_CONFIG is used to set the system-wide configuration such as
173+
reported TCB version in the attestation report. The command is similar
174+
to SNP_CONFIG command defined in the SEV-SNP spec. The current values of
175+
the firmware parameters affected by this command can be queried via
176+
SNP_PLATFORM_STATUS.
177+
165178
3. SEV-SNP CPUID Enforcement
166179
============================
167180

drivers/crypto/ccp/sev-dev.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,23 @@ static int sev_ioctl_do_snp_commit(struct sev_issue_cmd *argp)
20042004
return __sev_do_cmd_locked(SEV_CMD_SNP_COMMIT, &buf, &argp->error);
20052005
}
20062006

2007+
static int sev_ioctl_do_snp_set_config(struct sev_issue_cmd *argp, bool writable)
2008+
{
2009+
struct sev_device *sev = psp_master->sev_data;
2010+
struct sev_user_data_snp_config config;
2011+
2012+
if (!sev->snp_initialized || !argp->data)
2013+
return -EINVAL;
2014+
2015+
if (!writable)
2016+
return -EPERM;
2017+
2018+
if (copy_from_user(&config, (void __user *)argp->data, sizeof(config)))
2019+
return -EFAULT;
2020+
2021+
return __sev_do_cmd_locked(SEV_CMD_SNP_CONFIG, &config, &argp->error);
2022+
}
2023+
20072024
static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
20082025
{
20092026
void __user *argp = (void __user *)arg;
@@ -2061,6 +2078,9 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
20612078
case SNP_COMMIT:
20622079
ret = sev_ioctl_do_snp_commit(&input);
20632080
break;
2081+
case SNP_SET_CONFIG:
2082+
ret = sev_ioctl_do_snp_set_config(&input, writable);
2083+
break;
20642084
default:
20652085
ret = -EINVAL;
20662086
goto out;

include/uapi/linux/psp-sev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum {
3030
SEV_GET_ID2,
3131
SNP_PLATFORM_STATUS,
3232
SNP_COMMIT,
33+
SNP_SET_CONFIG,
3334

3435
SEV_MAX,
3536
};

0 commit comments

Comments
 (0)