From nobody Wed Dec 4 19:17:31 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