Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1769609rdh; Tue, 26 Sep 2023 03:06:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELLKpu+RJulRQTkS2LNeDNpufWv53JOsq+eBRJrpLHD2JaTIVb8ArwLaBs0swF6QkZjIcL X-Received: by 2002:a17:903:2591:b0:1c5:a49e:7aa with SMTP id jb17-20020a170903259100b001c5a49e07aamr8777008plb.27.1695722781610; Tue, 26 Sep 2023 03:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695722781; cv=none; d=google.com; s=arc-20160816; b=qHOutKpCIH6Gch1mX9DVqTnhKqLH3LGBJXtcGnEPRz01gUIIx5DQvq3g96O3/lGChS lTxmpoVJ6N1XJIYPbTcBJDWa4qS7FO1qQFCb/EdDbYu7UR6NPlO4O3VR9tuP8HW18B+9 j/WZX5Gfgo9FrN0wGd4ctugIpSwwkecMuzzEcMU2bQC1G4k3Fd3BC8xpIHtAy3N+rYeF A/Wlk0U5T9zRjtSFCGyn4i6QQ0CGKGSRDa7fo5AglEXqaGc5NHKhg0jYnPKDa20A8A95 K9AFAegJAxSJ1AktEN036p6Kt915c+CDoYpIskikMSmriqgf2D84c1fw0xW1bJIGwYuY scaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BAki6cmup3v3iIQ3+0PU25V5FileBitHeUlCyK3cG3c=; fh=pJrC1RGfowL0UpZGtpVcL393QP1AVX+2WWGphQ2Tggw=; b=E1J+dadvVLIOrgzEkVUtZDxhcE4mNdGAt9rWvP6aTnM96lKBZ6eHT5nEQ/P/5TpOt1 rGXDIpGf+H2fGJcWHK28wSlL79Q4kQdR6w71tsoAPw1txKXumrYnzttQvUtZ1VZzY8Ka c52XNhLZLnBb0+REYqvdBiN3dQ2O9cm9qF3xOF/9iPISTAHcKhwjccjDinXjtJCxueo3 a2ubPRvx9VqzgLDOnrBJU9FYfxFSvoMLIyPmdOawXxcVkjw9voi/aS01ZrNIDLXM2mF0 jA2OnVQ3CcfSvr9sdScZBNUUHfvWWNpVv1UeKPZENOxpWQGS0+AnLtY+8nQYOMNvLAyg 19ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="I8o/be8X"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w14-20020a170902e88e00b001c62d7e4831si1693086plg.588.2023.09.26.03.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 03:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="I8o/be8X"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5D80F818F682; Tue, 26 Sep 2023 01:06:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbjIZIGA (ORCPT + 99 others); Tue, 26 Sep 2023 04:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjIZIGA (ORCPT ); Tue, 26 Sep 2023 04:06:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C5AD7 for ; Tue, 26 Sep 2023 01:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695715553; x=1727251553; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=k0LY01UuWhCyxClR4WMZ+7BFAyL6E1EuK0Byohgt3O4=; b=I8o/be8X5ht5L2yxs8mc+uHDp90+GIDZoli1t2mEy5dnxVsuHMx7TiBq U3QpAJP+m7mQ6CmQu2GWea9cE8sSuU+yPqovoid7Foou9jwhs84GbFdGZ 2CWI5BJcB2ysaNMDTbB0+XOYiM5RWhfNDuYXeQKvq1b+LaT/klFqYXB1p 5L0GAyGEz2zYlys9ZGJRw6Y2HHOfvujgRYN/gRg/5ENfuYSt6zLNmZ+7d oumz8MyaKNs0UVnciD7Gwbi79j7ZX5O0Z0y5SyYSLfrlEEtOkEMNHCmtY ElJ9JkJAFDkWk2lwG/Xi/nGTYv014FX+ajaP92nyc7YyPt2zKhXqlr0W+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360891251" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="360891251" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 01:05:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="778037942" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="778037942" Received: from mtruica-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.39.83]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 01:05:51 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 7C970103D52; Tue, 26 Sep 2023 11:05:48 +0300 (+03) Date: Tue, 26 Sep 2023 11:05:48 +0300 From: kirill.shutemov@linux.intel.com To: Yi Sun Cc: sathyanarayanan.kuppuswamy@linux.intel.com, linux-kernel@vger.kernel.org, heng.su@intel.com, yi.sun@linux.intel.com, Dongcheng Yan Subject: Re: [PATCH v2] x86/tdx: Dump TDX version During the TD Bootup Message-ID: <20230926080548.5blqyozzrhjyiq4m@box.shutemov.name> References: <20230922080322.2071168-1-yi.sun@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230922080322.2071168-1-yi.sun@intel.com> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 01:06:02 -0700 (PDT) On Fri, Sep 22, 2023 at 04:03:22PM +0800, Yi Sun wrote: > It is essential for TD users to be aware of the vendor and version of > the current TDX. Additionally, they can reference the TDX version when > reporting bugs or issues. > > Furthermore, the applications or device drivers running in TD can achieve > enhanced reliability and flexibility by following the TDX Module ABI > specification, because there are significant differences between different > versions of TDX, as mentioned in the "Intel? TDX Module Incompatibilities > between v1.0 and v1.5" reference. Here are a few examples: > > MSR Name Index Reason > ---------------------------------------------- > IA32_UARCH_MISC_CTL 0x1B01 From v1.5 > IA32_ARCH_CAPABILITIES 0x010A Changed in v1.5 > IA32_TSX_CTRL 0x0122 Changed in v1.5 > > CPUID Leaf Sub-leaf Reason > --------------------------------------- > 0x7 2 From v1.5 > 0x22 0 From v1.5 > 0x23 0~3 From v1.5 > 0x80000007 0 From v1.5 > > During TD initialization, the TDX version info can be obtained by calling > TDG.SYS.RD. This will fetch the current version of TDX, including the major > and minor version numbers and vendor ID. > > The TDCALL TDG.SYS.RD originates from TDX version 1.5. If the error > TDCALL_INVALID_OPERAND occurs, it should be treated as TDX version 1.0. > > Co-developed-by: Dongcheng Yan > Signed-off-by: Dongcheng Yan > Signed-off-by: Yi Sun > > diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c > index 1d6b863c42b0..0f51123aa0b9 100644 > --- a/arch/x86/coco/tdx/tdx.c > +++ b/arch/x86/coco/tdx/tdx.c > @@ -37,6 +37,27 @@ > > #define TDREPORT_SUBTYPE_0 0 > > +/* > + * TDX metadata base field id, used by TDCALL TDG.SYS.RD > + * See TDX ABI Spec section 3.3.2.3 Global Metadata Fields > + */ > +#define TDX_SYS_VENDOR_ID_FID 0x0800000200000000ULL > +#define TDX_SYS_MINOR_FID 0x0800000100000003ULL > +#define TDX_SYS_MAJOR_FID 0x0800000100000004ULL > +#define TDX_VENDOR_INTEL 0x8086 > + > +struct tdg_sys_info { > + u32 vendor_id; > + u16 major_version; > + u16 minor_version; > +}; > + > +/* > + * Fetch TDX Module global-scope metadata field via TDG.SYS.RD TDCALL > + * Do NOT change it once initialized. > + */ > +static struct tdg_sys_info td_sys_info; > + Why here? I think we can allocate on stack inside tdx_early_init() and pass down to tdg_get_sysinfo() to fill. The variable is not needed after tdx_early_init() returns. -- Kiryl Shutsemau / Kirill A. Shutemov