From nobody Wed Dec 4 19:40:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@intel.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 171653228255123.730055130005212; Thu, 23 May 2024 23:31:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 80CA8172E; Fri, 24 May 2024 02:31:21 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 540C31B62; Fri, 24 May 2024 02:26:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1B3511C28; Fri, 24 May 2024 02:26:23 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 97C981951 for ; Fri, 24 May 2024 02:25:41 -0400 (EDT) Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 23:24:40 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 23:24:37 -0700 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716531942; x=1748067942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r3BOSmlOpWVvta9Vm2UYg8fPMj+NJ6PSUna4O5XsfUI=; b=J6uWg75ounpMuIsGPZgne3xTBymED1M77FDuUNk5AHqMM4nLc7l927f6 RkrmQk1fyPitOeBx6b3VMz9ld6jhn1TwXu9Z+Y6nj5i+nv+0IB+FzPwRw iZkN+xl78YXltWOra01MJFRcoC5V7vkWFdzKRy0YEoOK7KdDLVXUO7RJj K13W4yR6sAa/BBYQteRlaYQpU8tYnHkEm8N4isz1zgxCYvjdgTit1uYiV pVeBmpLBN/rumPMrEaOcaOELvn0Tmle01pQMo84G6UMacRVU9UwEBvYto mlrHrItVrcjMj9CWp/zsG9+9bpD+UQOPhX6VQnpCepxEhj1L1JpxQbs2n w==; X-CSE-ConnectionGUID: IesDKFbETt+k3VtYaXmRLg== X-CSE-MsgGUID: gN9FLospThWVxu43ofrapw== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081250" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081250" X-CSE-ConnectionGUID: aO7t6d5VQVuwnimgtZgycA== X-CSE-MsgGUID: RaqFFYHYQ9CZS+QgoBH5Dg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033954" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 05/13] conf: add tdx as launch security type Date: Fri, 24 May 2024 14:21:20 +0800 Message-Id: <20240524062128.523820-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524062128.523820-1-zhenzhong.duan@intel.com> References: <20240524062128.523820-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WXWXEESYUA77DP7YIBP55T2OPSVKV5QW X-Message-ID-Hash: WXWXEESYUA77DP7YIBP55T2OPSVKV5QW X-MailFrom: zhenzhong.duan@intel.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: phrdina@redhat.com, pkrempa@redhat.com, jjongsma@redhat.com, jsuchane@redhat.com, chenyi.qiang@intel.com, isaku.yamahata@intel.com, xiaoyao.li@intel.com, chao.p.peng@intel.com, Zhenzhong Duan X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1716532284007100001 Content-Type: text/plain; charset="utf-8" When 'tdx' is used, the VM will launched with Intel TDX feature enabled. TDX feature supports running encrypted VM (Trust Domain, TD) under the control of KVM. A TD runs in a CPU model which protects the confidentiality of its memory and its CPU state from other software There is a child element 'policy' and three optional element for tdx type. In 'policy', bit 0 is set to enable TDX debug, bit 28 set to enable sept-ve-disable, other bits are reserved currently. mrConfigId, mrOwner and mrOwnerConfig are base64 encoded SHA384 digest. For example: 0x10000001 xxx xxx xxx Signed-off-by: Zhenzhong Duan --- src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 9 +++++++ src/conf/schemas/domaincommon.rng | 29 +++++++++++++++++++++ src/conf/virconftypes.h | 2 ++ src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_firmware.c | 1 + src/qemu/qemu_namespace.c | 1 + src/qemu/qemu_process.c | 1 + src/qemu/qemu_validate.c | 1 + 9 files changed, 88 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a0912062ff..c557da0c65 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1508,6 +1508,7 @@ VIR_ENUM_IMPL(virDomainLaunchSecurity, "", "sev", "s390-pv", + "tdx", ); =20 typedef enum { @@ -3832,6 +3833,10 @@ virDomainSecDefFree(virDomainSecDef *def) g_free(def->data.sev.dh_cert); g_free(def->data.sev.session); break; + case VIR_DOMAIN_LAUNCH_SECURITY_TDX: + g_free(def->data.tdx.mrconfigid); + g_free(def->data.tdx.mrowner); + g_free(def->data.tdx.mrownerconfig); case VIR_DOMAIN_LAUNCH_SECURITY_PV: case VIR_DOMAIN_LAUNCH_SECURITY_NONE: case VIR_DOMAIN_LAUNCH_SECURITY_LAST: @@ -13649,6 +13654,24 @@ virDomainSEVDefParseXML(virDomainSEVDef *def, } =20 =20 +static int +virDomainTDXDefParseXML(virDomainTDXDef *def, + xmlXPathContextPtr ctxt) +{ + if (virXPathULongLongBase("string(./policy)", ctxt, 16, &def->policy) = < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("failed to get launch security policy for launch = security type TDX")); + return -1; + } + + def->mrconfigid =3D virXPathString("string(./mrConfigId)", ctxt); + def->mrowner =3D virXPathString("string(./mrOwner)", ctxt); + def->mrownerconfig =3D virXPathString("string(./mrOwnerConfig)", ctxt); + + return 0; +} + + static virDomainSecDef * virDomainSecDefParseXML(xmlNodePtr lsecNode, xmlXPathContextPtr ctxt) @@ -13668,6 +13691,10 @@ virDomainSecDefParseXML(xmlNodePtr lsecNode, if (virDomainSEVDefParseXML(&sec->data.sev, ctxt) < 0) return NULL; break; + case VIR_DOMAIN_LAUNCH_SECURITY_TDX: + if (virDomainTDXDefParseXML(&sec->data.tdx, ctxt) < 0) + return NULL; + break; case VIR_DOMAIN_LAUNCH_SECURITY_PV: break; case VIR_DOMAIN_LAUNCH_SECURITY_NONE: @@ -26661,6 +26688,21 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSec= Def *sec) break; } =20 + case VIR_DOMAIN_LAUNCH_SECURITY_TDX: { + virDomainTDXDef *tdx =3D &sec->data.tdx; + + virBufferAsprintf(&childBuf, "0x%llx\n", tdx->pol= icy); + + if (tdx->mrconfigid) + virBufferEscapeString(&childBuf, "%s\= n", tdx->mrconfigid); + if (tdx->mrowner) + virBufferEscapeString(&childBuf, "%s\n", td= x->mrowner); + if (tdx->mrownerconfig) + virBufferEscapeString(&childBuf, "%s\n", tdx->mrownerconfig); + + break; + } + case VIR_DOMAIN_LAUNCH_SECURITY_PV: break; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 356c25405b..7882b7a75d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2856,6 +2856,7 @@ typedef enum { VIR_DOMAIN_LAUNCH_SECURITY_NONE, VIR_DOMAIN_LAUNCH_SECURITY_SEV, VIR_DOMAIN_LAUNCH_SECURITY_PV, + VIR_DOMAIN_LAUNCH_SECURITY_TDX, =20 VIR_DOMAIN_LAUNCH_SECURITY_LAST, } virDomainLaunchSecurity; @@ -2872,10 +2873,18 @@ struct _virDomainSEVDef { virTristateBool kernel_hashes; }; =20 +struct _virDomainTDXDef { + unsigned long long policy; + char *mrconfigid; + char *mrowner; + char *mrownerconfig; +}; + struct _virDomainSecDef { virDomainLaunchSecurity sectype; union { virDomainSEVDef sev; + virDomainTDXDef tdx; } data; }; =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index d84e030255..f6e1782b33 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -520,6 +520,9 @@ s390-pv + + + @@ -565,6 +568,32 @@ =20 + + + tdx + + + + + + + + + + + + + + + + + + + + + + +