From nobody Mon Dec 15 21:24:45 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 1750845226955969.1822801235297; Wed, 25 Jun 2025 02:53:46 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C2A3D14EE; Wed, 25 Jun 2025 05:53:45 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 36B42147D; Wed, 25 Jun 2025 05:50:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C3B9145F; Wed, 25 Jun 2025 05:50:49 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 F00AF145C for ; Wed, 25 Jun 2025 05:50:34 -0400 (EDT) Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2025 02:49:33 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2025 02:49: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=-3.1 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=1750845036; x=1782381036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkKAgo+o74IAdLFDQurwzSdSmysvN1hZvquJoj74hpM=; b=Ab7dZq7gr/Eendq+gwXTL9mbmyBIIhtyxWMGXbHoaoWudziciNgeLXJy 6h1rBPDRlJzi7+jQUUuDsOLf7rN52bYqzSuLejTRQkU4/Fk/cSINUQtHO gGAL2j0u6PCQH8RMIgfGwzMUvzMOQeTEGm9DBNnRXhNtAhiXtOX8tGHG7 oGH0m21k46mF1jLARS6JjzVS13qH8M+vgjKYBZ1uvvsWFKNz6OoHiNayc 2aDkwHOuqCP7bHqazNK6ADG5WoC4lvxjoyUqnIkysjsblRu8o1m9J9k0d Y6n0QUWNR/eHNixplzz8ewYVcJWRIGUMiIPKlZX4EHGdIMnm0mjiA0NKS g==; X-CSE-ConnectionGUID: jnCKAKqpTfiEZRcJvpe4XA== X-CSE-MsgGUID: CTv1c8/uQ369WFTRJFeOZg== X-IronPort-AV: E=McAfee;i="6800,10657,11474"; a="70680295" X-IronPort-AV: E=Sophos;i="6.16,264,1744095600"; d="scan'208";a="70680295" X-CSE-ConnectionGUID: BGvhAkMQTC6Xe0RfHtMJLw== X-CSE-MsgGUID: k7Jewd50S9iu1BSSCKRCSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,264,1744095600"; d="scan'208";a="151786567" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v2 01/21] tools: Secure guest check for Intel in virt-host-validate Date: Wed, 25 Jun 2025 17:45:13 +0800 Message-Id: <20250625094533.234897-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250625094533.234897-1-zhenzhong.duan@intel.com> References: <20250625094533.234897-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: C2UBA2XO5KPFYBDFA5BRM4EJ5T3MV3R6 X-Message-ID-Hash: C2UBA2XO5KPFYBDFA5BRM4EJ5T3MV3R6 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: 1750845228351116600 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 | 31 ++++++++++++++++++++++++++++++- tools/virt-host-validate-common.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 63cc3dbe7b..59f6ac3319 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -44,7 +44,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag, "svm", "sie", "158", - "sev"); + "sev", + "tdx_host_platform"); =20 =20 int virHostValidateDeviceExists(const char *hvname, @@ -434,12 +435,36 @@ virHostValidateAMDSev(const char *hvname, } =20 =20 +static int virHostValidateIntelTDX(virValidateLevel level) +{ + g_autofree char *mod_value =3D NULL; + + if (virFileReadValueString(&mod_value, "/sys/module/kvm_intel/paramete= rs/tdx") < 0) { + virValidateFail(level, "Intel Trust Domain Extentions not " + "supported by the currently used kernel"); + return VIR_VALIDATE_FAILURE(level); + } + + if (mod_value[0] !=3D 'Y') { + virValidateFail(level, + "Intel Trust Domain Extentions appears to be " + "disabled in kernel. Add kvm_intel.tdx=3DY " + "to the kernel cmdline arguments"); + return VIR_VALIDATE_FAILURE(level); + } + + virValidatePass(); + return 1; +} + + int virHostValidateSecureGuests(const char *hvname, virValidateLevel level) { 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"}; @@ -450,6 +475,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 virValidateCheck(hvname, "%s", _("Checking for secure guest support")); if (ARCH_IS_S390(arch)) { @@ -485,6 +512,8 @@ int virHostValidateSecureGuests(const char *hvname, } } else if (hasAMDSev) { return virHostValidateAMDSev(hvname, level); + } else if (hasIntelTDX) { + return virHostValidateIntelTDX(level); } =20 virValidateFail(level, diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-c= ommon.h index 7fb3545fe3..c81d203933 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -32,6 +32,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