From nobody Sun Dec 14 12:13:22 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 1751264560849800.4748876668847; Sun, 29 Jun 2025 23:22:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D3E2B12E4; Mon, 30 Jun 2025 02:22:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 14F3E1469; Mon, 30 Jun 2025 02:21:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 67ED21238; Mon, 30 Jun 2025 02:21:32 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 B206C12E2 for ; Mon, 30 Jun 2025 02:21:31 -0400 (EDT) Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2025 23:21:31 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2025 23:21:29 -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=1751264492; x=1782800492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkKAgo+o74IAdLFDQurwzSdSmysvN1hZvquJoj74hpM=; b=TWOeQ+QW4HLytFVtvObotFcUm9elU7b6jS4+UjrwSYEoODFSlaDglhkX KZdpqV6PgfT2DZgbEpAEqaE/x82+QkKO7ztbjBqvZve7Vsy0V1X1nTlmr I6nanXk8TtxySV47jmzYCYFL91izt8k6c6KxKU8BIsN/SnnYgjkzne8RC lwGpnypAzdwbNVvX/JSBxrbrUtJi4i/ZWNipwjoa9Y9s8Z9ekSac7O/qM gVbMxO3SuX7/IBr5KEm/936F/pH0nzXIQq4LNhsgFMNsVa2DGo2JLLJyb 17gymoibqfIdqrMzXTSG5tyNlKp4pV9Ymk16XXm8RMql96NEMTonqg703 g==; X-CSE-ConnectionGUID: QaUKQlj8QFSD0C1jnrEnxQ== X-CSE-MsgGUID: 5hp3hv4QR76oZ6UUycQgRQ== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="70912498" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="70912498" X-CSE-ConnectionGUID: nvbzNMKsR4Cg6q2vWzsbzQ== X-CSE-MsgGUID: s5KQ3OF7S22W+wsZz0cjbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153549218" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v3 01/21] tools: Secure guest check for Intel in virt-host-validate Date: Mon, 30 Jun 2025 14:17:12 +0800 Message-Id: <20250630061732.303374-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250630061732.303374-1-zhenzhong.duan@intel.com> References: <20250630061732.303374-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PDHNYZJEHZLXWMGOIWHMWSBZMDQDBJNV X-Message-ID-Hash: PDHNYZJEHZLXWMGOIWHMWSBZMDQDBJNV 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: 1751264561738116600 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 Reviewed-by: Xiaoyao Li --- 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