[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 42/49] i386/sev: Add support for SNP CPUID validation
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v3 42/49] i386/sev: Add support for SNP CPUID validation |
Date: |
Wed, 20 Mar 2024 12:18:43 +0000 |
User-agent: |
Mutt/2.2.12 (2023-09-09) |
On Wed, Mar 20, 2024 at 03:39:38AM -0500, Michael Roth wrote:
> SEV-SNP firmware allows a special guest page to be populated with a
> table of guest CPUID values so that they can be validated through
> firmware before being loaded into encrypted guest memory where they can
> be used in place of hypervisor-provided values[1].
>
> As part of SEV-SNP guest initialization, use this interface to validate
> the CPUID entries reported by KVM_GET_CPUID2 prior to initial guest
> start and populate the CPUID page reserved by OVMF with the resulting
> encrypted data.
>
> [1] SEV SNP Firmware ABI Specification, Rev. 0.8, 8.13.2.6
>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
> ---
> target/i386/sev.c | 159 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 158 insertions(+), 1 deletion(-)
>
> +static void
> +sev_snp_cpuid_report_mismatches(SnpCpuidInfo *old,
> + SnpCpuidInfo *new)
> +{
> + size_t i;
> +
> + if (old->count != new->count) {
> + error_report("SEV-SNP: CPUID validation failed due to count
> mismatch, provided: %d, expected: %d",
> + old->count, new->count);
> + }
Missing 'return' here, may result in array out of bounds on 'new->entries'
in the next loop
> +
> + for (i = 0; i < old->count; i++) {
> + SnpCpuidFunc *old_func, *new_func;
> +
> + old_func = &old->entries[i];
> + new_func = &new->entries[i];
> +
> + if (memcmp(old_func, new_func, sizeof(SnpCpuidFunc))) {
> + error_report("SEV-SNP: CPUID validation failed for function
> 0x%x, index: 0x%x.\n"
> + "provided: eax:0x%08x, ebx: 0x%08x, ecx: 0x%08x,
> edx: 0x%08x\n"
> + "expected: eax:0x%08x, ebx: 0x%08x, ecx: 0x%08x,
> edx: 0x%08x",
> + old_func->eax_in, old_func->ecx_in,
> + old_func->eax, old_func->ebx, old_func->ecx,
> old_func->edx,
> + new_func->eax, new_func->ebx, new_func->ecx,
> new_func->edx);
> + }
> + }
> +}
> +
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [PATCH v3 37/49] i386/sev: Add the SNP launch start context, (continued)
[PATCH v3 38/49] i386/sev: Add handling to encrypt/finalize guest launch data, Michael Roth, 2024/03/20
[PATCH v3 39/49] i386/sev: Set CPU state to protected once SNP guest payload is finalized, Michael Roth, 2024/03/20
[PATCH v3 40/49] hw/i386/sev: Add function to get SEV metadata from OVMF header, Michael Roth, 2024/03/20
[PATCH v3 03/49] scripts/update-linux-headers: Add bits.h to file imports, Michael Roth, 2024/03/20
[PATCH v3 41/49] i386/sev: Add support for populating OVMF metadata pages, Michael Roth, 2024/03/20
[PATCH v3 42/49] i386/sev: Add support for SNP CPUID validation, Michael Roth, 2024/03/20
- Re: [PATCH v3 42/49] i386/sev: Add support for SNP CPUID validation,
Daniel P . Berrangé <=
[PATCH v3 43/49] qapi, i386: Move kernel-hashes to SevCommonProperties, Michael Roth, 2024/03/20
[PATCH v3 44/49] i386/sev: Extract build_kernel_loader_hashes, Michael Roth, 2024/03/20
[PATCH v3 45/49] i386/sev: Reorder struct declarations, Michael Roth, 2024/03/20
[PATCH v3 46/49] i386/sev: Allow measured direct kernel boot on SNP, Michael Roth, 2024/03/20
[PATCH v3 47/49] hw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled, Michael Roth, 2024/03/20
[PATCH v3 48/49] hw/i386/sev: Use guest_memfd for legacy ROMs, Michael Roth, 2024/03/20