[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-6.0 8/9] spapr: Do TPM proxy hotplug sanity checks at pre
From: |
David Gibson |
Subject: |
Re: [PATCH for-6.0 8/9] spapr: Do TPM proxy hotplug sanity checks at pre-plug |
Date: |
Mon, 23 Nov 2020 16:32:44 +1100 |
On Sat, Nov 21, 2020 at 12:42:07AM +0100, Greg Kurz wrote:
> There can be only one TPM proxy at a time. This is currently
> checked at plug time. But this can be detected at pre-plug in
> order to error out earlier.
>
> This allows to get rid of error handling in the plug handler.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Applied to ppc-for-6.0, thanks.
> ---
> hw/ppc/spapr.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index bded059d59c8..5e32d1d396b4 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3957,17 +3957,28 @@ static void spapr_phb_unplug_request(HotplugHandler
> *hotplug_dev,
> }
> }
>
> -static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState
> *dev,
> - Error **errp)
> +static
> +bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> + Error **errp)
> {
> SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
> - SpaprTpmProxy *tpm_proxy = SPAPR_TPM_PROXY(dev);
>
> if (spapr->tpm_proxy != NULL) {
> error_setg(errp, "Only one TPM proxy can be specified for this
> machine");
> - return;
> + return false;
> }
>
> + return true;
> +}
> +
> +static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState
> *dev)
> +{
> + SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
> + SpaprTpmProxy *tpm_proxy = SPAPR_TPM_PROXY(dev);
> +
> + /* Already checked in spapr_tpm_proxy_pre_plug() */
> + g_assert(spapr->tpm_proxy == NULL);
> +
> spapr->tpm_proxy = tpm_proxy;
> }
>
> @@ -3990,7 +4001,7 @@ static void spapr_machine_device_plug(HotplugHandler
> *hotplug_dev,
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE))
> {
> spapr_phb_plug(hotplug_dev, dev);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
> - spapr_tpm_proxy_plug(hotplug_dev, dev, errp);
> + spapr_tpm_proxy_plug(hotplug_dev, dev);
> }
> }
>
> @@ -4053,6 +4064,8 @@ static void
> spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev,
> spapr_core_pre_plug(hotplug_dev, dev, errp);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE))
> {
> spapr_phb_pre_plug(hotplug_dev, dev, errp);
> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
> + spapr_tpm_proxy_pre_plug(hotplug_dev, dev, errp);
> }
> }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
- Re: [PATCH for-6.0 3/9] spapr: Fix pre-2.10 dummy ICP hack, (continued)
- [PATCH for-6.0 6/9] spapr: Make PHB placement functions and spapr_pre_plug_phb() return status, Greg Kurz, 2020/11/20
- [PATCH for-6.0 5/9] spapr: Simplify error path of spapr_core_plug(), Greg Kurz, 2020/11/20
- [PATCH for-6.0 7/9] spapr: Do PHB hoplug sanity check at pre-plug, Greg Kurz, 2020/11/20
- [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), Greg Kurz, 2020/11/20
- [PATCH for-6.0 8/9] spapr: Do TPM proxy hotplug sanity checks at pre-plug, Greg Kurz, 2020/11/20
- Re: [PATCH for-6.0 8/9] spapr: Do TPM proxy hotplug sanity checks at pre-plug,
David Gibson <=
- [PATCH for-6.0 9/9] spapr: spapr_drc_attach() cannot fail, Greg Kurz, 2020/11/20