[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate co
From: |
Peter Maydell |
Subject: |
Re: [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate common SEV state |
Date: |
Fri, 7 Jun 2024 15:20:57 +0100 |
On Tue, 4 Jun 2024 at 07:47, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> From: Michael Roth <michael.roth@amd.com>
>
> Currently all SEV/SEV-ES functionality is managed through a single
> 'sev-guest' QOM type. With upcoming support for SEV-SNP, taking this
> same approach won't work well since some of the properties/state
> managed by 'sev-guest' is not applicable to SEV-SNP, which will instead
> rely on a new QOM type with its own set of properties/state.
>
> To prepare for this, this patch moves common state into an abstract
> 'sev-common' parent type to encapsulate properties/state that are
> common to both SEV/SEV-ES and SEV-SNP, leaving only SEV/SEV-ES-specific
> properties/state in the current 'sev-guest' type. This should not
> affect current behavior or command-line options.
>
> As part of this patch, some related changes are also made:
>
> - a static 'sev_guest' variable is currently used to keep track of
> the 'sev-guest' instance. SEV-SNP would similarly introduce an
> 'sev_snp_guest' static variable. But these instances are now
> available via qdev_get_machine()->cgs, so switch to using that
> instead and drop the static variable.
>
> - 'sev_guest' is currently used as the name for the static variable
> holding a pointer to the 'sev-guest' instance. Re-purpose the name
> as a local variable referring the 'sev-guest' instance, and use
> that consistently throughout the code so it can be easily
> distinguished from sev-common/sev-snp-guest instances.
>
> - 'sev' is generally used as the name for local variables holding a
> pointer to the 'sev-guest' instance. In cases where that now points
> to common state, use the name 'sev_common'; in cases where that now
> points to state specific to 'sev-guest' instance, use the name
> 'sev_guest'
>
> In order to enable kernel-hashes for SNP, pull it from
> SevGuestProperties to its parent SevCommonProperties so
> it will be available for both SEV and SNP.
Hi; Coverity points out a problem in this code (CID 1546885):
> @@ -540,12 +491,21 @@ static SevCapability *sev_get_capabilities(Error **errp)
> return NULL;
> }
>
> - fd = open(DEFAULT_SEV_DEVICE, O_RDWR);
> + sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
> + if (!sev_common) {
> + error_setg(errp, "SEV is not configured");
Here we check for a NULL pointer, but we forget to "return",
so execution will continue on...
> + }
> +
> + sev_device = object_property_get_str(OBJECT(sev_common), "sev-device",
> + &error_abort);
...and QEMU will crash here when object_property_get_str()
dereferences the NULL pointer.
Adding a "return NULL;" should fix this.
thanks
-- PMM
- [PULL 09/45] target/i386: fix memory opsize for Mov to/from Seg, (continued)
- [PULL 09/45] target/i386: fix memory opsize for Mov to/from Seg, Paolo Bonzini, 2024/06/04
- [PULL 10/45] target/i386/tcg: Fix RDPID feature check, Paolo Bonzini, 2024/06/04
- [PULL 12/45] update-linux-headers: fix forwarding to asm-generic headers, Paolo Bonzini, 2024/06/04
- [PULL 11/45] target/i386: fix xsave.flat from kvm-unit-tests, Paolo Bonzini, 2024/06/04
- [PULL 13/45] update-linux-headers: move pvpanic.h to correct directory, Paolo Bonzini, 2024/06/04
- [PULL 14/45] linux-headers: Update to current kvm/next, Paolo Bonzini, 2024/06/04
- [PULL 15/45] update-linux-headers: import linux/kvm_para.h header, Paolo Bonzini, 2024/06/04
- [PULL 16/45] machine: allow early use of machine_require_guest_memfd, Paolo Bonzini, 2024/06/04
- [PULL 17/45] i386/sev: Replace error_report with error_setg, Paolo Bonzini, 2024/06/04
- [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate common SEV state, Paolo Bonzini, 2024/06/04
- Re: [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate common SEV state,
Peter Maydell <=
- [PULL 19/45] i386/sev: Move sev_launch_update to separate class method, Paolo Bonzini, 2024/06/04
- [PULL 20/45] i386/sev: Move sev_launch_finish to separate class method, Paolo Bonzini, 2024/06/04
- [PULL 21/45] i386/sev: Introduce 'sev-snp-guest' object, Paolo Bonzini, 2024/06/04
- [PULL 22/45] i386/sev: Add a sev_snp_enabled() helper, Paolo Bonzini, 2024/06/04
- [PULL 23/45] i386/sev: Add sev_kvm_init() override for SEV class, Paolo Bonzini, 2024/06/04
- [PULL 24/45] i386/sev: Add snp_kvm_init() override for SNP class, Paolo Bonzini, 2024/06/04
- [PULL 27/45] i386/sev: Add a class method to determine KVM VM type for SNP guests, Paolo Bonzini, 2024/06/04
- [PULL 32/45] hw/i386/sev: Add function to get SEV metadata from OVMF header, Paolo Bonzini, 2024/06/04
- [PULL 41/45] i386/sev: Reorder struct declarations, Paolo Bonzini, 2024/06/04