From nobody Tue Sep 9 19:03:26 2025 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 1752132222585315.5703104347506; Thu, 10 Jul 2025 00:23:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A1EB01373; Thu, 10 Jul 2025 03:23:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DD004142A; Thu, 10 Jul 2025 03:22:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D3D2113DE; Thu, 10 Jul 2025 03:22:08 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 46C5C13F3 for ; Thu, 10 Jul 2025 03:21:52 -0400 (EDT) Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2025 00:21:52 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2025 00:21:49 -0700 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, 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=1752132112; x=1783668112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9Sz4AlzG+khFbUxbHGTFZrlUFi1xZeJ0huTJ/GcKG5k=; b=IBvyBlLAJi/AqAq4spx+nfpmmbs+DbBSyiHrw0PIsQHHvj5WF3BiURzK 6Qt1KDXJkJNhDYpp5qZUJj04UaN+6IBF1uSIrhKUWRDsiXNNCisbYSpjl H3heutLu1vfJX9Qyd+r+VUzEwSxu4/O22LL69he78tEHhxcSYfRNPyQe8 bTZ1SY4xiwj4n/G43QcU+L4O2hl3hV73eq4QMyW7wCyRi7huCCiFZgdtY PIxDiOebwxm0W+4TRRfQXG8/U9maWoF6T4V3ufDyFtxPKL4c31vMIJB1B YN4oxXYAdzgKeR8fGY/9SfGgw77dhKDNLgWo7iJIzVelc1UFgywKfLO1t w==; X-CSE-ConnectionGUID: uRdP0QBGRSSqAyi0nNQkIw== X-CSE-MsgGUID: zgZmafaqR5mxESe4qPXJtg== X-IronPort-AV: E=McAfee;i="6800,10657,11489"; a="54256968" X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="54256968" X-CSE-ConnectionGUID: sTpDCMmRTm64wH7Z5rxs8w== X-CSE-MsgGUID: HmvDXhHmRe+fFHoKLKi3HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="186997120" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v4 02/23] qemu: Check if INTEL Trust Domain Extention support is enabled Date: Thu, 10 Jul 2025 03:21:04 -0400 Message-ID: <20250710072127.695558-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250710072127.695558-1-zhenzhong.duan@intel.com> References: <20250710072127.695558-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: S7E3Y4WLRR2WHM6HN5EIJ7TUKWDH2HUZ X-Message-ID-Hash: S7E3Y4WLRR2WHM6HN5EIJ7TUKWDH2HUZ 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: 1752132222919116600 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 Reviewed-by: Xiaoyao Li --- 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 b02f8e7a01..732c89fe29 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5322,6 +5322,24 @@ virQEMUCapsKVMSupportsSecureGuestAMD(void) } =20 =20 +/* + * Check whether INTEL Trust Domain Extention (x86) is enabled + */ +static bool +virQEMUCapsKVMSupportsSecureGuestTDX(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. @@ -5335,7 +5353,8 @@ virQEMUCapsKVMSupportsSecureGuest(void) return virQEMUCapsKVMSupportsSecureGuestS390(); =20 if (ARCH_IS_X86(arch)) - return virQEMUCapsKVMSupportsSecureGuestAMD(); + return virQEMUCapsKVMSupportsSecureGuestAMD() || + virQEMUCapsKVMSupportsSecureGuestTDX(); =20 return false; } --=20 2.47.1