[PATCH v5 0/3] tpm: Fix default choices for CRB and SPAPR dev models

From: Stefan Berger <stefanb@linux.ibm.com> This series of patches adds an additional check for the SPAPR device model that prevents the choice of a TPM 1.2 backend and chooses a TPM 2 as default. Also CRB now chooses a TPM 2 as default since TPM 1.2 wouldn't work with it, either. Stefan v4->v5: - Added R-b's Stefan Berger (3): qemu: Move setting of TPM default to post parse function qemu: Set SPAPR TPM default to 2.0 and prevent 1.2 choice qemu: Choose TPM 2 for backend as default for CRB interface src/qemu/qemu_domain.c | 12 +++++++++--- src/qemu/qemu_validate.c | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) -- 2.17.1

From: Stefan Berger <stefanb@linux.ibm.com> Move setting the TPM default version out of the validation function into the post parse function. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 7 ++++--- src/qemu/qemu_validate.c | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 42cc78ac1b..f916d840e2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4347,12 +4347,13 @@ qemuDomainDefTPMsPostParse(virDomainDefPtr def) virDomainTPMDefPtr regularTPM = NULL; size_t i; - if (def->ntpms < 2) - return 0; - for (i = 0; i < def->ntpms; i++) { virDomainTPMDefPtr tpm = def->tpms[i]; + /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ + if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) + tpm->version = VIR_DOMAIN_TPM_VERSION_1_2; + if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { if (proxyTPM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index bd7590a00a..d130b52bf2 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3644,10 +3644,6 @@ qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm, { virQEMUCapsFlags flag; - /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ - if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) - tpm->version = VIR_DOMAIN_TPM_VERSION_1_2; - switch (tpm->version) { case VIR_DOMAIN_TPM_VERSION_1_2: /* TPM 1.2 + CRB do not work */ -- 2.17.1

From: Stefan Berger <stefanb@linux.ibm.com> The firmware (SLOF) on QEMU for ppc64 does not support TPM 1.2, so prevent the choice of TPM 1.2 when the SPAPR device model is chosen and use a default of '2.0' (TPM 2) for the backend. This patch addresses BZ 1781913: https://bugzilla.redhat.com/show_bug.cgi?id=1781913 Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 8 ++++++-- src/qemu/qemu_validate.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f916d840e2..b0f5e17613 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4351,8 +4351,12 @@ qemuDomainDefTPMsPostParse(virDomainDefPtr def) virDomainTPMDefPtr tpm = def->tpms[i]; /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ - if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) - tpm->version = VIR_DOMAIN_TPM_VERSION_1_2; + if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) { + if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR) + tpm->version = VIR_DOMAIN_TPM_VERSION_2_0; + else + tpm->version = VIR_DOMAIN_TPM_VERSION_1_2; + } if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { if (proxyTPM) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index d130b52bf2..488f258d00 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3654,6 +3654,12 @@ qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm, virDomainTPMModelTypeToString(tpm->model)); return -1; } + /* TPM 1.2 + SPAPR do not work with any 'type' (backend) */ + if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("TPM 1.2 is not supported with the SPAPR device model")); + return -1; + } break; case VIR_DOMAIN_TPM_VERSION_2_0: case VIR_DOMAIN_TPM_VERSION_DEFAULT: -- 2.17.1

From: Stefan Berger <stefanb@linux.ibm.com> Choose a TPM 2 device for the backend as default for the CRB interface since TPM 1.2 would not work. This patch addresses BZ 1781913: https://bugzilla.redhat.com/show_bug.cgi?id=1781913 Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b0f5e17613..161421b602 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4352,7 +4352,8 @@ qemuDomainDefTPMsPostParse(virDomainDefPtr def) /* TPM 1.2 and 2 are not compatible, so we choose a specific version here */ if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT) { - if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR) + if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR || + tpm->model == VIR_DOMAIN_TPM_MODEL_CRB) tpm->version = VIR_DOMAIN_TPM_VERSION_2_0; else tpm->version = VIR_DOMAIN_TPM_VERSION_1_2; -- 2.17.1

Hi On Fri, Jul 10, 2020 at 12:49 AM Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
From: Stefan Berger <stefanb@linux.ibm.com>
This series of patches adds an additional check for the SPAPR device model that prevents the choice of a TPM 1.2 backend and chooses a TPM 2 as default. Also CRB now chooses a TPM 2 as default since TPM 1.2 wouldn't work with it, either.
Stefan
v4->v5: - Added R-b's
Stefan Berger (3): qemu: Move setting of TPM default to post parse function qemu: Set SPAPR TPM default to 2.0 and prevent 1.2 choice qemu: Choose TPM 2 for backend as default for CRB interface
Series: Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
src/qemu/qemu_domain.c | 12 +++++++++--- src/qemu/qemu_validate.c | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-)
-- 2.17.1
-- Marc-André Lureau

On Tue, Jul 14, 2020 at 23:00:51 +0400, Marc-André Lureau wrote:
Hi
On Fri, Jul 10, 2020 at 12:49 AM Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
From: Stefan Berger <stefanb@linux.ibm.com>
This series of patches adds an additional check for the SPAPR device model that prevents the choice of a TPM 1.2 backend and chooses a TPM 2 as default. Also CRB now chooses a TPM 2 as default since TPM 1.2 wouldn't work with it, either.
Stefan
v4->v5: - Added R-b's
Stefan Berger (3): qemu: Move setting of TPM default to post parse function qemu: Set SPAPR TPM default to 2.0 and prevent 1.2 choice qemu: Choose TPM 2 for backend as default for CRB interface
Series: Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
I've added this tag and pushed the series.
participants (3)
-
Marc-André Lureau
-
Peter Krempa
-
Stefan Berger