From nobody Wed Dec 4 18:47:15 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 1716532057323350.6034275253271; Thu, 23 May 2024 23:27:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3EE9B1B89; Fri, 24 May 2024 02:27:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4C1081B59; Fri, 24 May 2024 02:25:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 370661922; Fri, 24 May 2024 02:25:30 -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 8EC8F1924 for ; Fri, 24 May 2024 02:25:28 -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:26 -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:24 -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=1716531929; x=1748067929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m85ncNv/mXobvlYEiQPwtrLdwLzLymDSy69BltPth7g=; b=dpyB31HMH2qmGZBV3W3DRA2CcuDnRRu41OfhzLrLQRGGPebexfzrek1Y IzDfzRf1ITwBFBxtz5Z0N+XPEf1Y+ZC/9deE/c4I7zv+L1wdTbl1/dnVu 28aI/xocqWBaVCEBrD0oRG/lDSz6ztCX8LA2wsR8nvOMV+3HBLp6H7MLL tMMHEWMT6zyANaQ/8N5u3zzQ+oOqoL3dYJOSH0ZLwcQ4TIax/gn1tmqT3 Xundcdh/WqssOqET3NsRnseieCX7u3E+AhnHnKAu5mcKeeUOvAtNs6bRF lLZjegwQW1H0jhibu5H0mrKYf6ArGDdG2HnJ1eBUxYexFZ+GIHe35o0Ix A==; X-CSE-ConnectionGUID: K71Kd3TkTpK8xdu2iWNlwg== X-CSE-MsgGUID: Nfb8dgu7RBa7VO8sByRB6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081235" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081235" X-CSE-ConnectionGUID: 4FmmJzkHRMS94fhkMVs7mg== X-CSE-MsgGUID: U0or5zSPR5+Ech0E/cLDyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34033917" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 01/13] tools: Secure guest check for Intel in virt-host-validate Date: Fri, 24 May 2024 14:21:16 +0800 Message-Id: <20240524062128.523820-2-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: 45IWUIV2MGZ2FIMJOUVMKTCBBORLRVJT X-Message-ID-Hash: 45IWUIV2MGZ2FIMJOUVMKTCBBORLRVJT 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: 1716532059076100001 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 | 22 +++++++++++++++++++++- tools/virt-host-validate-common.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index c8a23e2e99..4f0698b8ce 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -43,7 +43,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag, "svm", "sie", "158", - "sev"); + "sev", + "tdx_host_platform"); =20 static bool quiet; =20 @@ -471,6 +472,7 @@ int virHostValidateSecureGuests(const char *hvname, 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"}; @@ -482,6 +484,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 virHostMsgCheck(hvname, "%s", _("for secure guest support")); if (ARCH_IS_S390(arch)) { @@ -539,6 +543,22 @@ int virHostValidateSecureGuests(const char *hvname, "disabled in firmware."); return VIR_HOST_VALIDATE_FAILURE(level); } + } else if (hasIntelTDX) { + if (virFileReadValueString(&mod_value, "/sys/module/kvm_intel/para= meters/tdx") < 0) { + virHostMsgFail(level, "Intel Trust Domain Extentions not " + "supported by the currently used kernel"= ); + return VIR_HOST_VALIDATE_FAILURE(level); + } + + if (mod_value[0] !=3D 'Y') { + virHostMsgFail(level, + "Intel Trust Domain Extentions appears to be " + "disabled in kernel. Add kvm_intel.tdx=3DY " + "to the kernel cmdline arguments"); + return VIR_HOST_VALIDATE_FAILURE(level); + } + virHostMsgPass(); + return 1; } =20 virHostMsgFail(level, diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-c= ommon.h index 9334fa8588..c64f5669dc 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -39,6 +39,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