Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp215578rwb; Tue, 15 Nov 2022 22:30:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AFLtH3OBp5qTyv3Y8/eE1ZQq/EpDOnt2hqV4SKXDPBTwHZM8R4qwqQBK/dObGkcNLx/o6 X-Received: by 2002:a17:906:ce57:b0:7ad:e161:b026 with SMTP id se23-20020a170906ce5700b007ade161b026mr16945979ejb.760.1668580237645; Tue, 15 Nov 2022 22:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668580237; cv=none; d=google.com; s=arc-20160816; b=hYKApSF7hOdzKf6IekKWceGj3jcJS0kQL05hpdlOd2l9W1Uh2rEbnFsS7OyAhdkGl4 wFpovnaQ19twjU8uq0SQJQd4HLA4u+wnFIr5Hc5Lb8peSozuCSKe8AFkecE8T8pfV9i/ KqffaYqgWk0aj6h3B50hb8PgtOtoOxeON3h5haREVI45yRz64GOaSuaifXsmphVJF6wO YnLbvmaXkgld2VzKMFUKWw6rPLspXx4iHBiG/P3NSrWYf9KZx7ZV76PPVsaPlJ8BTxok YVKPkFjBSM41xzqx9E6e4XZVAb3OGcdnNj/RAQyFKI/LrrpFWW4qeyeLgSrxuQR4oZ5j 9Z9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xBIbGncUDaw9+9fQExXEr9EMk11Qy6KNxmiFSC5q1ww=; b=IYF/VI4GMgjOgFOI4yaJBF9vacAGqBZGWbqLElGuMBx/NZbrLb5J2HecaPOP6rgjvP qP5a4+GrhYrekhn4H/HTm+SQ4dIGygxTaYFsjOJROXx4Pv4u9U3ux+MYkKZKvbntbWun A9rIrqK/j2t14s7TZ0P2wLWso/zQY+2X92IaE5/zAO1pWAqBZWqmVpqsvtsuKzg1SkRp aSiuggRl9Or7PZ0CnSKH5i3f/m73b+uLl07mFeihIWG2KAz4CTSB3fxT8V+8rl9h/0RJ CjiotCBCHEJPC2J7FI9Qtpj+NwhLd+Unc1Ytm5R75MmE5CWTwCmOcgOv6gItFPY3KNdj yR4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eAGBzGmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a17090639d100b0073d710fec77si11561368eje.251.2022.11.15.22.30.16; Tue, 15 Nov 2022 22:30:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eAGBzGmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232711AbiKPG0C (ORCPT + 90 others); Wed, 16 Nov 2022 01:26:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbiKPGZx (ORCPT ); Wed, 16 Nov 2022 01:25:53 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A452C1D0EA; Tue, 15 Nov 2022 22:25:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668579952; x=1700115952; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=fB7JiWADb0P2b2t+ebguTg5N8FbI6r37biHOj8DMLS4=; b=eAGBzGmHzssbMdcUjYIAK92rlUAlDUhb9OfIuq8VVlgMSnHQlWojwbsN /l13RAwojlJyqAzAEzkcDLfwTtLhIXBECS9P1UFf9jdKIs3DxnRUVtTmS QUNLhAfJ3F1hgvH3wImdxQCXG3iVeMoTIwWFGk4UgsxI3jrsSRHnUOiJd Zn6/my6nK547++Q652G8diqR7rwsY8jrj7fM33GdvU+wYkl9Hs5LrGNBM kdugl48pY4st2giPyGbkfnkEg1cVH9RfDxlNFLMdZSnJt0aq7p9HkIx3X 8AyxHZDcLhdYfw/6N17dppYI31daktXzAQ9qtDeKtR2SEn3htTB88draj g==; X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="311170456" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="311170456" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 22:25:52 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="641508622" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="641508622" Received: from gsavithr-mobl.amr.corp.intel.com (HELO [10.209.85.47]) ([10.209.85.47]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 22:25:51 -0800 Message-ID: <556a2475-f0e1-d1cf-1c46-bbe052e5ef40@linux.intel.com> Date: Tue, 15 Nov 2022 22:25:50 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.2.2 Subject: Re: [PATCH v17 1/3] x86/tdx: Add a wrapper to get TDREPORT from the TDX Module Content-Language: en-US To: Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Shuah Khan , Jonathan Corbet Cc: "H . Peter Anvin" , Greg Kroah-Hartman , "Kirill A . Shutemov" , Tony Luck , Kai Huang , Wander Lairson Costa , Isaku Yamahata , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org References: <20221104032355.227814-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20221104032355.227814-2-sathyanarayanan.kuppuswamy@linux.intel.com> <115a87d7-144a-2828-8e4f-9c1f156b73ae@intel.com> <8d5f8a74-f864-3cd9-dac2-7650d83a8b90@linux.intel.com> From: Sathyanarayanan Kuppuswamy In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,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 Hi Dave, On 11/14/22 4:54 PM, Dave Hansen wrote: >> In both the commit log and the comments, I can highlight the "subtype 0" >> information. Will that work for you, or do you prefer that this wrapper >> take the "subtype" option as argument and we pass 0 for the subtype value >> from the TDX guest driver? > I actually think it's a *lot* more clear if the User<->Kernel ABI just > takes the subtype. But, I also heard Greg's concerns about making the > ABI _too_ open-ended. > > So, I really don't care. Just make it clear that, as is, this ABI is > not the "TDREPORT ABI". > Are you fine with the following version? +/* TDX Module call error codes */ +#define TDCALL_RETURN_CODE(a) ((a) >> 32) +#define TDCALL_INVALID_OPERAND 0xc0000100 + +#define TDREPORT_SUBTYPE_0 0 + +/** + * tdx_mcall_get_report0() - Wrapper to get TDREPORT0 (a.k.a. TDREPORT + * subtype 0) using TDG.MR.REPORT TDCALL. + * @reportdata: Address of the input buffer which contains user-defined + * REPORTDATA to be included into TDREPORT. + * @tdreport: Address of the output buffer to store TDREPORT. + * + * Refer to section titled "TDG.MR.REPORT leaf" in the TDX Module + * v1.0 specification for more information on TDG.MR.REPORT TDCALL. + * It is used in the TDX guest driver module to get the TDREPORT0. + * + * Return 0 on success, -EINVAL for invalid operands, or -EIO on + * other TDCALL failures. + */ +int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport) +{ + u64 ret; + + ret = __tdx_module_call(TDX_GET_REPORT, virt_to_phys(tdreport), + virt_to_phys(reportdata), TDREPORT_SUBTYPE_0, + 0, NULL); + if (ret) { + if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND) + return -EINVAL; + return -EIO; + } + + return 0; +} +EXPORT_SYMBOL_GPL(tdx_mcall_get_report0); -- Sathyanarayanan Kuppuswamy Linux Kernel Developer