From nobody Thu Apr 25 21:01:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580745602726317.89852942306754; Mon, 3 Feb 2020 08:00:02 -0800 (PST) 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-303-dA1x9xJOMVS3eqMiN6F-xg-1; Mon, 03 Feb 2020 10:59:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C52BADB2A; Mon, 3 Feb 2020 15:59:53 +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 9DBC4388; Mon, 3 Feb 2020 15:59:53 +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 5E46518089D0; Mon, 3 Feb 2020 15:59:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 013FxcLs013455 for ; Mon, 3 Feb 2020 10:59:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id D04CD2166B2C; Mon, 3 Feb 2020 15:59:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC6312166B28 for ; Mon, 3 Feb 2020 15:59:36 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3252F800185 for ; Mon, 3 Feb 2020 15:59:36 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-yMtbosVjNOeoCcEBcCh-UQ-1; Mon, 03 Feb 2020 10:59:31 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 013FjE77091424; Mon, 3 Feb 2020 10:59:29 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxnjpafhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 10:59:28 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 013FjXDg093501; Mon, 3 Feb 2020 10:59:28 -0500 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxnjpafh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 10:59:28 -0500 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 013FuWEN024834; Mon, 3 Feb 2020 15:59:27 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma05wdc.us.ibm.com with ESMTP id 2xw0y6j38g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 15:59:27 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 013FxQFB49349074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2020 15:59:26 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55DFA7805E; Mon, 3 Feb 2020 15:59:26 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF11C7805F; Mon, 3 Feb 2020 15:59:25 +0000 (GMT) Received: from newfield.pok.ibm.com (unknown [9.47.158.66]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2020 15:59:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580745601; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=auJSZwcsx7J33dstsyd/tAjyC7tgjinZhQEhyNZkRmI=; b=XFneJYpqI9nk4Zcr2Nmb5CqN1ejBIGpg8V9mNSJUuWAC8Orf6u2SbSWZSi8Y/vxxAigKb8 JN92nPOMwatzXnYzwmtKlEr2JbRvPhjfcqUbKlcmmscr7giYOVDIatws09py7IjL239uAi LHRJgHRnn5cg+1+4uAQI7z+YNc12cVk= From: Stefan Berger To: libvir-list@redhat.com Subject: [PATCH v2 4/6] qemu: Extend QEMU with tpm-spapr support Date: Mon, 3 Feb 2020 10:59:19 -0500 Message-Id: <20200203155921.127300-5-stefanb@linux.ibm.com> In-Reply-To: <20200203155921.127300-1-stefanb@linux.ibm.com> References: <20200203155921.127300-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-03_05:2020-02-02, 2020-02-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 suspectscore=3 mlxscore=0 adultscore=0 spamscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2002030118 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id 013FjE77091424 X-MC-Unique: yMtbosVjNOeoCcEBcCh-UQ-1 X-MC-Unique: dA1x9xJOMVS3eqMiN6F-xg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 013FxcLs013455 X-loop: libvir-list@redhat.com Cc: aik@ozlabs.ru, marcandre.lureau@redhat.com, Stefan Berger , jtomko@redhat.com, david@gibson.dropbear.id.au 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extend QEMU with tpm-spapr support. Assign a device address to the vTPM device model. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 15 ++++++++++----- src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_domain_address.c | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c8195cfbb9..3df72232ca 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9064,15 +9064,19 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd, =20 =20 static char * -qemuBuildTPMDevStr(const virDomainDef *def) +qemuBuildTPMDevStr(const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - const virDomainTPMDef *tpm =3D def->tpm; + virDomainTPMDef *tpm =3D def->tpm; const char *model =3D virDomainTPMModelTypeToString(tpm->model); =20 virBufferAsprintf(&buf, "%s,tpmdev=3Dtpm-%s,id=3D%s", model, tpm->info.alias, tpm->info.alias); =20 + if (qemuBuildDeviceAddressStr(&buf, def, &tpm->info, qemuCaps) < 0) + return NULL; + return virBufferContentAndReset(&buf); } =20 @@ -9162,7 +9166,8 @@ qemuBuildTPMBackendStr(const virDomainDef *def, =20 static int qemuBuildTPMCommandLine(virCommandPtr cmd, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { char *optstr; g_autofree char *chardev =3D NULL; @@ -9202,7 +9207,7 @@ qemuBuildTPMCommandLine(virCommandPtr cmd, VIR_FREE(fdset); } =20 - if (!(optstr =3D qemuBuildTPMDevStr(def))) + if (!(optstr =3D qemuBuildTPMDevStr(def, qemuCaps))) return -1; =20 virCommandAddArgList(cmd, "-device", optstr, NULL); @@ -9918,7 +9923,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, chardevStdioLogd) < 0) return NULL; =20 - if (qemuBuildTPMCommandLine(cmd, def) < 0) + if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1bf3102f59..1f0f7949fc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7794,6 +7794,8 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm, flag =3D QEMU_CAPS_DEVICE_TPM_CRB; break; case VIR_DOMAIN_TPM_MODEL_SPAPR: + flag =3D QEMU_CAPS_DEVICE_TPM_SPAPR; + break; case VIR_DOMAIN_TPM_MODEL_LAST: default: virReportEnumRangeError(virDomainTPMModel, tpm->model); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 409d850a06..ef17e84d7c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -35,6 +35,7 @@ VIR_LOG_INIT("qemu.qemu_domain_address"); #define VIO_ADDR_SCSI 0x2000ul #define VIO_ADDR_SERIAL 0x30000000ul #define VIO_ADDR_NVRAM 0x3000ul +#define VIO_ADDR_TPM 0x4000ul =20 =20 /** @@ -267,6 +268,15 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) return -1; } =20 + if (def->tpm) { + if (ARCH_IS_PPC64(def->os.arch) && + STRPREFIX(def->os.machine, "pseries")) + def->tpm->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVI= O; + if (qemuDomainAssignSpaprVIOAddress(def, &def->tpm->info, + VIO_ADDR_TPM) < 0) + return -1; + } + /* No other devices are currently supported on spapr-vio */ =20 return 0; --=20 2.17.1