From nobody Tue May 21 16:53:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635354288412102.70937670242472; Wed, 27 Oct 2021 10:04:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-bO5jWe49NfuMg5_czmSWeg-1; Wed, 27 Oct 2021 13:04:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FDDE101AFA7; Wed, 27 Oct 2021 17:04:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2153217CE1; Wed, 27 Oct 2021 17:04:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C26941800FDD; Wed, 27 Oct 2021 17:04:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19RH0KR5018593 for ; Wed, 27 Oct 2021 13:00:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E056A40D1B9D; Wed, 27 Oct 2021 17:00:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC74C40C1242 for ; Wed, 27 Oct 2021 17:00:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3754811E7A for ; Wed, 27 Oct 2021 17:00:19 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-EfKYKL7GMuG0K1tx6t00fA-1; Wed, 27 Oct 2021 13:00:16 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19RGr0g7021015; Wed, 27 Oct 2021 17:00:15 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3byap9g3ar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Oct 2021 17:00:14 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19RGrSOQ006138; Wed, 27 Oct 2021 17:00:13 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma02dal.us.ibm.com with ESMTP id 3bx4f7r9d7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Oct 2021 17:00:13 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19RH0CoN22479220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 17:00:12 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACD582805E; Wed, 27 Oct 2021 17:00:12 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 943AB2805A; Wed, 27 Oct 2021 17:00:12 +0000 (GMT) Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 27 Oct 2021 17:00:12 +0000 (GMT) X-MC-Unique: bO5jWe49NfuMg5_czmSWeg-1 X-MC-Unique: EfKYKL7GMuG0K1tx6t00fA-1 From: Stefan Berger To: libvir-list@redhat.com Subject: [PATCH] qemu: Extend qemu.conf with PCR banks to activate during 'TPM manufacturing' Date: Wed, 27 Oct 2021 13:00:10 -0400 Message-Id: <20211027170010.1833501-1-stefanb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -pBOm-zmNeaTHgjLkgH2d6qprQnZczf7 X-Proofpoint-ORIG-GUID: -pBOm-zmNeaTHgjLkgH2d6qprQnZczf7 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1, Aquarius:18.0.790, Hydra:6.0.425, FMLib:17.0.607.475 definitions=2021-10-27_05,2021-10-26_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 adultscore=0 phishscore=0 suspectscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270096 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1635354289720100001 Content-Type: text/plain; charset="utf-8" Extend qemu.conf with a configration option swtpm_active_pcr_banks that allows a user to set a comma-separated list of PCR banks to activate during 'TPM manufacturing'. Valid PCR banks are sha1,sha256,sha384 and sha512. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2016599 Signed-off-by: Stefan Berger --- src/qemu/qemu.conf | 8 ++++++++ src/qemu/qemu_conf.c | 6 ++++++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_tpm.c | 8 ++++++++ 4 files changed, 23 insertions(+) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 71fd125699..7aa151ed55 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -915,6 +915,14 @@ #swtpm_user =3D "tss" #swtpm_group =3D "tss" =20 +# The PCR banks to activate during 'TPM manufacturing' before a swtpm inst= ance +# is started the first time. +# +# A comma-separated list without spaces containing sha1,sha256,sha384, or +# sha512. The default is 'sha256'. +# +# swtpm_active_pcr_banks =3D "sha256,sha384" + # For debugging and testing purposes it's sometimes useful to be able to d= isable # libvirt behaviour based on the capabilities of the qemu process. This op= tion # allows to do so. DO _NOT_ use in production and beaware that the behavio= ur diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0451bc70ac..a62525385e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -384,6 +384,8 @@ static void virQEMUDriverConfigDispose(void *obj) g_strfreev(cfg->capabilityfilters); =20 g_free(cfg->deprecationBehavior); + + g_free(cfg->swtpmActivePcrBanks); } =20 =20 @@ -1030,6 +1032,10 @@ virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfi= g *cfg, if (swtpm_group && virGetGroupID(swtpm_group, &cfg->swtpm_group) < 0) return -1; =20 + if (virConfGetValueString(conf, "swtpm_active_pcr_banks", + &cfg->swtpmActivePcrBanks) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 2f64e39a18..37461d9e31 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -219,6 +219,7 @@ struct _virQEMUDriverConfig { =20 uid_t swtpm_user; gid_t swtpm_group; + char *swtpmActivePcrBanks; =20 char **capabilityfilters; =20 diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index e1b08a66c5..69fd1e67e3 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -448,6 +448,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, bool privileged, uid_t swtpm_user, gid_t swtpm_group, + const char *swtpmActivePcrBanks, const char *logfile, const virDomainTPMVersion tpmversion, const unsigned char *secretuuid, @@ -512,6 +513,9 @@ qemuTPMEmulatorRunSetup(const char *storagepath, } =20 if (!incomingMigration) { + if (!swtpmActivePcrBanks) + swtpmActivePcrBanks =3D "sha256"; + virCommandAddArgList(cmd, "--tpm-state", storagepath, "--vmid", vmid, @@ -521,6 +525,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, "--create-platform-cert", "--lock-nvram", "--not-overwrite", + "--pcr-banks", swtpmActivePcrBanks, NULL); } else { virCommandAddArgList(cmd, @@ -568,6 +573,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, bool privileged, uid_t swtpm_user, gid_t swtpm_group, + const char *swtpmActivePcrBanks, const char *swtpmStateDir, const char *shortName, bool incomingMigration) @@ -593,6 +599,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, if (created && qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vm= uuid, privileged, swtpm_user, swtpm_group, + swtpmActivePcrBanks, tpm->data.emulator.logfile, tpm->version, secretuuid, incomingMigration) < 0) goto error; @@ -812,6 +819,7 @@ qemuExtTPMStartEmulator(virQEMUDriver *driver, driver->privileged, cfg->swtpm_user, cfg->swtpm_group, + cfg->swtpmActivePcrBanks, cfg->swtpmStateDir, shortName, incomingMigration))) return -1; --=20 2.31.1