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 175213217826241.28870737989405; Thu, 10 Jul 2025 00:22:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 62880140F; Thu, 10 Jul 2025 03:22:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BB8C313F5; Thu, 10 Jul 2025 03:21:53 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 16F67108A; Thu, 10 Jul 2025 03:21:49 -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 5EC41108A for ; Thu, 10 Jul 2025 03:21:48 -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:48 -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:45 -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=1752132109; x=1783668109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h2hz2fUav0Evba39KF+qlBoDlJ6POI7lUJutbzNQB34=; b=QlZjg+vtf8YULuFtcIcTGFBl97Ci9U3ZKTRYhp5wwXD2UOw3sBvIw4o0 il6S3p5ykYZ16WWCtXbfQef2kf8K6fyZ9cge+V1F2E9ALD8pW3UMvbnd/ blnxqUkpp8E/rh850i1r12dfXJKBTzvQjch3nyMCPjpokewdIDfJbOcOY 2FXUOd7Z/SLDI5vv5C/1IOo4QTYrEd0zmVrIFfFem1gJ0//fhfk68rNA/ 7DW93INSQcSuIduOg5fQHljltiHp0bladqjq59qeYYxfFTM7wXEsFS3Yy 6B8gjbIS9GBZHyrUya2MDYQUVOsjyFrnPiVK/Ap1FBUvMV1GB9E1vDAxl A==; X-CSE-ConnectionGUID: 1hYiOPlBSu+MQOACV70mgA== X-CSE-MsgGUID: Z0zf+WT/QYCLCJUJKhRxjQ== X-IronPort-AV: E=McAfee;i="6800,10657,11489"; a="54256961" X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="54256961" X-CSE-ConnectionGUID: 4GGUdwZGSTSR5M1x7lQRUg== X-CSE-MsgGUID: kwef6bsSSwSLu2bKbN0W1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="186997115" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v4 01/23] tools: Secure guest check for Intel in virt-host-validate Date: Thu, 10 Jul 2025 03:21:03 -0400 Message-ID: <20250710072127.695558-2-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: K7C3GJ6CR6RJGZCTYBGMAY6UQPDRLYJJ X-Message-ID-Hash: K7C3GJ6CR6RJGZCTYBGMAY6UQPDRLYJJ 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: 1752132180587116600 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.47.1