From nobody Wed Dec 4 08:48:13 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 1716532057323350.6034275253271; Thu, 23 May 2024 23:27:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3EE9B1B89; Fri, 24 May 2024 02:27:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4C1081B59; Fri, 24 May 2024 02:25:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 370661922; Fri, 24 May 2024 02:25:30 -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 8EC8F1924 for ; Fri, 24 May 2024 02:25:28 -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:26 -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:24 -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=1716531929; x=1748067929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m85ncNv/mXobvlYEiQPwtrLdwLzLymDSy69BltPth7g=; b=dpyB31HMH2qmGZBV3W3DRA2CcuDnRRu41OfhzLrLQRGGPebexfzrek1Y IzDfzRf1ITwBFBxtz5Z0N+XPEf1Y+ZC/9deE/c4I7zv+L1wdTbl1/dnVu 28aI/xocqWBaVCEBrD0oRG/lDSz6ztCX8LA2wsR8nvOMV+3HBLp6H7MLL tMMHEWMT6zyANaQ/8N5u3zzQ+oOqoL3dYJOSH0ZLwcQ4TIax/gn1tmqT3 Xundcdh/WqssOqET3NsRnseieCX7u3E+AhnHnKAu5mcKeeUOvAtNs6bRF lLZjegwQW1H0jhibu5H0mrKYf6ArGDdG2HnJ1eBUxYexFZ+GIHe35o0Ix A==; X-CSE-ConnectionGUID: K71Kd3TkTpK8xdu2iWNlwg== X-CSE-MsgGUID: Nfb8dgu7RBa7VO8sByRB6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081235" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081235" X-CSE-ConnectionGUID: 4FmmJzkHRMS94fhkMVs7mg== X-CSE-MsgGUID: U0or5zSPR5+Ech0E/cLDyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033917" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 01/13] tools: Secure guest check for Intel in virt-host-validate Date: Fri, 24 May 2024 14:21:16 +0800 Message-Id: <20240524062128.523820-2-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: 45IWUIV2MGZ2FIMJOUVMKTCBBORLRVJT X-Message-ID-Hash: 45IWUIV2MGZ2FIMJOUVMKTCBBORLRVJT 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: 1716532059076100001 Content-Type: text/plain; charset="utf-8" Add check in virt-host-validate for secure guest support on x86 for Intel Trust Domain Extentions. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virt-host-validate-common.c | 22 +++++++++++++++++++++- tools/virt-host-validate-common.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index c8a23e2e99..4f0698b8ce 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -43,7 +43,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag, "svm", "sie", "158", - "sev"); + "sev", + "tdx_host_platform"); =20 static bool quiet; =20 @@ -471,6 +472,7 @@ int virHostValidateSecureGuests(const char *hvname, g_autoptr(virBitmap) flags =3D NULL; bool hasFac158 =3D false; bool hasAMDSev =3D false; + bool hasIntelTDX =3D false; virArch arch =3D virArchFromHost(); g_autofree char *cmdline =3D NULL; static const char *kIBMValues[] =3D {"y", "Y", "on", "ON", "oN", "On",= "1"}; @@ -482,6 +484,8 @@ int virHostValidateSecureGuests(const char *hvname, hasFac158 =3D true; else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SEV)) hasAMDSev =3D true; + else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= TDX)) + hasIntelTDX =3D true; =20 virHostMsgCheck(hvname, "%s", _("for secure guest support")); if (ARCH_IS_S390(arch)) { @@ -539,6 +543,22 @@ int virHostValidateSecureGuests(const char *hvname, "disabled in firmware."); return VIR_HOST_VALIDATE_FAILURE(level); } + } else if (hasIntelTDX) { + if (virFileReadValueString(&mod_value, "/sys/module/kvm_intel/para= meters/tdx") < 0) { + virHostMsgFail(level, "Intel Trust Domain Extentions not " + "supported by the currently used kernel"= ); + return VIR_HOST_VALIDATE_FAILURE(level); + } + + if (mod_value[0] !=3D 'Y') { + virHostMsgFail(level, + "Intel Trust Domain Extentions appears to be " + "disabled in kernel. Add kvm_intel.tdx=3DY " + "to the kernel cmdline arguments"); + return VIR_HOST_VALIDATE_FAILURE(level); + } + virHostMsgPass(); + return 1; } =20 virHostMsgFail(level, diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-c= ommon.h index 9334fa8588..c64f5669dc 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -39,6 +39,7 @@ typedef enum { VIR_HOST_VALIDATE_CPU_FLAG_SIE, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158, VIR_HOST_VALIDATE_CPU_FLAG_SEV, + VIR_HOST_VALIDATE_CPU_FLAG_TDX, =20 VIR_HOST_VALIDATE_CPU_FLAG_LAST, } virHostValidateCPUFlag; --=20 2.34.1 From nobody Wed Dec 4 08:48:13 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 1716532103756337.71214612841743; Thu, 23 May 2024 23:28:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id ACDD51BA4; Fri, 24 May 2024 02:28:22 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 857CE1BAF; Fri, 24 May 2024 02:25:40 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 445591921; Fri, 24 May 2024 02:25:32 -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 8F8C51921 for ; Fri, 24 May 2024 02:25:31 -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:29 -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:27 -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=1716531932; x=1748067932; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2amirJgucfK1W7p+JmzLNj/31xl7DBFYIHqa/xiaEwQ=; b=TGXAzFL2KZd2m6FWYxX03cZ5NShLymDh8nC8/qXX19ERY1j2mcD/x1dj k9QZj8QCRBWgaoBkqGXA3FJqf5q5NH1hlPiNP0jLvomwLQ8LaU7laEWeG NePvC4GVB06AHiDnBWM2B7EaSNjli1IgiOYxvZsAWl4pY/hkWzq+gvwmL XKoU84iAWVwqciWX3pBfD3QIQ190McAp9aSaJ7Jcli1s0udD4jCeE6QsW SxIepXDgmIGXkBcpo755IHRf7hoDWViCspd+GXuxBtUKIE4jYkioeve7e lOWej4jZpFUnE7Pgj6xdsj4AtrO8DwRMrkOYhn7sI/Hgv9tM3zJfO9TIG w==; X-CSE-ConnectionGUID: fIuWefQnRO2GMyB74ol1yQ== X-CSE-MsgGUID: C0R/t4wfSNC1SJnERZG1Zw== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081240" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081240" X-CSE-ConnectionGUID: X8DELIWoS06Dn6LBho2y4g== X-CSE-MsgGUID: 2fKs9DgBT0GTraWoVdJMiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033921" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 02/13] qemu: Check if INTEL Trust Domain Extention support is enabled Date: Fri, 24 May 2024 14:21:17 +0800 Message-Id: <20240524062128.523820-3-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: R2S7FZ2SZI7IE2WAPVMG4P5SY5MVGWLW X-Message-ID-Hash: R2S7FZ2SZI7IE2WAPVMG4P5SY5MVGWLW 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: 1716532105202100001 Content-Type: text/plain; charset="utf-8" Implement TDX check in order to generate domain feature capability correctly in case the availability of the feature changed. For INTEL TDX the verification is: - checking if "/sys/module/kvm_intel/parameters/tdx" contains the value 'Y': meaning TDX is enabled in the host kernel. Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 21f93c6774..7cccc28e80 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5112,6 +5112,24 @@ virQEMUCapsKVMSupportsSecureGuestAMD(void) } =20 =20 +/* + * Check whether INTEL Trust Domain Extention (x86) is enabled + */ +static bool +virQEMUCapsKVMSupportsSecureGuestINTEL(void) +{ + g_autofree char *modValue =3D NULL; + + if (virFileReadValueString(&modValue, "/sys/module/kvm_intel/parameter= s/tdx") < 0) + return false; + + if (modValue[0] !=3D 'Y') + return false; + + return true; +} + + /* * Check whether the secure guest functionality is enabled. * See the specific architecture function for details on the verifications= made. @@ -5125,7 +5143,8 @@ virQEMUCapsKVMSupportsSecureGuest(void) return virQEMUCapsKVMSupportsSecureGuestS390(); =20 if (ARCH_IS_X86(arch)) - return virQEMUCapsKVMSupportsSecureGuestAMD(); + return virQEMUCapsKVMSupportsSecureGuestAMD() || + virQEMUCapsKVMSupportsSecureGuestINTEL(); =20 return false; } --=20 2.34.1 From nobody Wed Dec 4 08:48:13 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 1716532147367734.0103834233942; Thu, 23 May 2024 23:29:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 58B9B1B48; Fri, 24 May 2024 02:29:06 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 27DFF1B66; Fri, 24 May 2024 02:26:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 607DD1A43; Fri, 24 May 2024 02:25:54 -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 94E311AD5 for ; Fri, 24 May 2024 02:25:34 -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:33 -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:30 -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=1716531935; x=1748067935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z1E8irYsLlkXFnNMIxX3aglYOh8Ep4NQWrLgY2JIlgg=; b=kB5U7u+kJWy+IbRtU6BCQ1Id1zKTcIZzCy9clVA9qSG6gIvqL+d1WZqE AGOfjK+VcWomCIQc0gOu8hereiiwiDxDwRUOxiKTw7sxShOXKoYtGXGUb D8dkfWGGwgWg48YCQmgcV45pxYKalisbMUO7Lyry44B5fQOmBT7nxlVxL atnXg0WYVThxZwq5tQU4rUuIALzCPPqy9iMpnr5BcQ5lBwNMvmiIrDpoV WSXFpusgUopNQchkxSMvV/TrrH5dYGqVysiIq9mvwsw+OxbJfOjAu0bt3 x1RtEQijW4kbn+1j0S7awt+trJdV9eWMmtrY/jcmtvCiTGMOfSM5vyTTP A==; X-CSE-ConnectionGUID: BNgAOlCYR06xPgtnffVXZg== X-CSE-MsgGUID: tEHlR6aWQjyp3b1dYQqBzA== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081243" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081243" X-CSE-ConnectionGUID: gvnOFchnQt+gVluHyyYnhw== X-CSE-MsgGUID: XrUwCMm1RNOmz1O1gmr34A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033928" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 03/13] qemu: Add TDX capability Date: Fri, 24 May 2024 14:21:18 +0800 Message-Id: <20240524062128.523820-4-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: ZACYDVGQBXFRHZ7C3ARIZ3FXPVYKNA4A X-Message-ID-Hash: ZACYDVGQBXFRHZ7C3ARIZ3FXPVYKNA4A 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: 1716532149360100001 Content-Type: text/plain; charset="utf-8" QEMU_CAPS_TDX_GUEST set means TDX supported with this QEMU. Signed-off-by: Chenyi Qiang Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7cccc28e80..33d2b5f392 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -706,6 +706,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "blockjob.backing-mask-protocol", /* QEMU_CAPS_BLOCKJOB_BACK= ING_MASK_PROTOCOL */ "display-reload", /* QEMU_CAPS_DISPLAY_RELOAD */ "usb-mtp", /* QEMU_CAPS_DEVICE_USB_MTP */ + "tdx-guest", /* QEMU_CAPS_TDX_GUEST */ ); =20 =20 @@ -1395,6 +1396,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "cryptodev-backend-lkcf", QEMU_CAPS_OBJECT_CRYPTO_LKCF }, { "pvpanic-pci", QEMU_CAPS_DEVICE_PANIC_PCI }, { "usb-mtp", QEMU_CAPS_DEVICE_USB_MTP }, + { "tdx-guest", QEMU_CAPS_TDX_GUEST}, }; =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 5082967cba..354e8d7958 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -685,6 +685,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL, /* backing-mask-protocol of = block-commit/block-stream */ QEMU_CAPS_DISPLAY_RELOAD, /* 'display-reload' qmp command is supported= */ QEMU_CAPS_DEVICE_USB_MTP, /* -device usb-mtp */ + QEMU_CAPS_TDX_GUEST, /* -object tdx-guest,... */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; --=20 2.34.1 From nobody Wed Dec 4 08:48:13 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 1716532199504862.1775831343263; Thu, 23 May 2024 23:29:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 692011954; Fri, 24 May 2024 02:29:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7B5331B97; Fri, 24 May 2024 02:26:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 051DB1C41; Fri, 24 May 2024 02:26:20 -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 963141BB2 for ; Fri, 24 May 2024 02:25:38 -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:36 -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:34 -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=1716531939; x=1748067939; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+GVi5EAUWbcXrtR71+VocN+i+lLkx4lrTJI4NIFj6sk=; b=Yap1Di0nuIdcM20UpSirnNxsiasoj+nvuwvl/m0rZpSi/IwcvHyJv0mL kkQWNTXXPipC7INt7Oqm5U8m6xGt5vJtnzVz6yXQcphjLL1B9scHHbUsC azq1UJucQWahai72iIg9hMoWsSwwlop9KeVOb8GxqUno9kPtzggELuXM7 RgSn0+94tZt1yVNYupzehgxwhuIGJw3DSPKLOs9xsczgyyuLxdYLR+Wi3 nR7h07n0ueG2114paXJaKutqbn+Mn1kODWMxVOQwSd7PMHmz8vsLxG8nC WtjLYK/lticgHqpr/N/GVGi7Z0Co2LmlKfuGUYCM8ITMeQGIfotoE97iU w==; X-CSE-ConnectionGUID: OYIBTA2bSLCKwMGI8DZQtw== X-CSE-MsgGUID: A/mwIbKBR5uMrRvDRREpMw== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081246" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081246" X-CSE-ConnectionGUID: PH7R5HGjQw21idLD4CH2gw== X-CSE-MsgGUID: VpiDvI2IRRiqnGAAWrz59Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033936" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 04/13] conf: expose TDX feature in domain capabilities Date: Fri, 24 May 2024 14:21:19 +0800 Message-Id: <20240524062128.523820-5-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: IJI2AH6EM6MD5MVRXZ7ASTZKVB5Q2TQL X-Message-ID-Hash: IJI2AH6EM6MD5MVRXZ7ASTZKVB5Q2TQL 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: 1716532201593100001 Content-Type: text/plain; charset="utf-8" Extend qemu TDX capability to domain capabilities. Signed-off-by: Chenyi Qiang Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatdomaincaps.rst | 1 + src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/conf/schemas/domaincaps.rng | 9 +++++++++ src/qemu/qemu_capabilities.c | 13 +++++++++++++ 5 files changed, 25 insertions(+) diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst index 609a767189..36d56a433c 100644 --- a/docs/formatdomaincaps.rst +++ b/docs/formatdomaincaps.rst @@ -651,6 +651,7 @@ capabilities. All features occur as children of the mai= n ``features`` element. + 47 1 diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 68eb3c9797..8bfe19d774 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -42,6 +42,7 @@ VIR_ENUM_IMPL(virDomainCapsFeature, "backup", "async-teardown", "s390-pv", + "tdx", ); =20 static virClass *virDomainCapsClass; diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index fadc30cdd7..690e2a1f03 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -250,6 +250,7 @@ typedef enum { VIR_DOMAIN_CAPS_FEATURE_BACKUP, VIR_DOMAIN_CAPS_FEATURE_ASYNC_TEARDOWN, VIR_DOMAIN_CAPS_FEATURE_S390_PV, + VIR_DOMAIN_CAPS_FEATURE_TDX, =20 VIR_DOMAIN_CAPS_FEATURE_LAST } virDomainCapsFeature; diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.= rng index e7aa4a1066..a5522b1e67 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -308,6 +308,9 @@ + + + @@ -363,6 +366,12 @@ =20 + + + + + + diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 33d2b5f392..53a773b853 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6675,6 +6675,18 @@ virQEMUCapsFillDomainFeatureHypervCaps(virQEMUCaps *= qemuCaps, } =20 =20 +static void +virQEMUCapsFillDomainFeatureTDXCaps(virQEMUCaps *qemuCaps, + virDomainCaps *domCaps) +{ + if (domCaps->arch =3D=3D VIR_ARCH_X86_64 && + domCaps->virttype =3D=3D VIR_DOMAIN_VIRT_KVM && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_TDX_GUEST) && + virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps)) + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_TDX] =3D VIR_TRISTAT= E_BOOL_YES; +} + + int virQEMUCapsFillDomainCaps(virQEMUCaps *qemuCaps, virArch hostarch, @@ -6734,6 +6746,7 @@ virQEMUCapsFillDomainCaps(virQEMUCaps *qemuCaps, virQEMUCapsFillDomainFeatureSGXCaps(qemuCaps, domCaps); virQEMUCapsFillDomainFeatureHypervCaps(qemuCaps, domCaps); virQEMUCapsFillDomainDeviceCryptoCaps(qemuCaps, crypto); + virQEMUCapsFillDomainFeatureTDXCaps(qemuCaps, domCaps); =20 return 0; } --=20 2.34.1 From nobody Wed Dec 4 08:48:13 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 + + + + + + + + + + + + + + + + + + + + + + +