Re: [PATCH v4 09/15] x86/sev: Provide guest VMPL level to userspace

From: Borislav Petkov
Date: Mon May 27 2024 - 09:51:36 EST


On Wed, Apr 24, 2024 at 10:58:05AM -0500, Tom Lendacky wrote:
> Requesting an attestation report from userspace involves providing the
> VMPL level for the report. Currently any value from 0-3 is valid because
> Linux enforces running at VMPL0.
>
> When an SVSM is present, though, Linux will not be running at VMPL0 and
> only VMPL values starting at the VMPL level Linux is running at to 3 are
> valid. In order to allow userspace to determine the minimum VMPL value
> that can be supplied to an attestation report, create a sysfs entry that
> can be used to retrieve the current VMPL level of Linux.

So what is the use case here: you create the attestation report *on* the
running guest and as part of that, the script which does that should do

cat /sys/.../sev/vmpl

?

But then sev-guest does some VMPL including into some report:

struct snp_report_req {
/* user data that should be included in the report */
__u8 user_data[SNP_REPORT_USER_DATA_SIZE];

/* The vmpl level to be included in the report */
__u32 vmpl;

Why do you need this and can't use sev-guest?

> +static int __init sev_sysfs_init(void)
> +{
> + struct kobject *sev_kobj;
> + int ret;
> +
> + if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
> + return -ENODEV;
> +
> + sev_kobj = kobject_create_and_add("sev", kernel_kobj);

In the main hierarchy?!

This is a x86 CPU thing, so if anything, it should be under
/sys/devices/system/cpu/

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette