Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4314164ioa; Wed, 27 Apr 2022 00:28:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwDj9yLavPEVhujpINfyTYFKutUY48LSetf6Mx2hEzf0K/I0fbEKbj6q3kUt4vADulLe49 X-Received: by 2002:a17:903:32d2:b0:15d:478c:8b46 with SMTP id i18-20020a17090332d200b0015d478c8b46mr4279832plr.127.1651044495798; Wed, 27 Apr 2022 00:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651044495; cv=none; d=google.com; s=arc-20160816; b=E/KuWnemxT6vSA09bmZEZlKaNa+VHVZzoahm93jAS2dUiJXGOQlxlIbcEQIJm9F+qW BYR+cM3G4CBkdMcQSUdRvz0St4BySZ23vfU0zIdb5ohcmHeynm4FFutZWs8QKn40r07E udvlDyRUoKFGwObgAFUkn6DWfyK92ArsNP8lALMFLiqyk3weFd/thyCK+EjheO+0QG4P SE2b2h5ztK/sUKJwtAjVCUw9kuCIWmZ9SeHUGuaESlpKZFuHYzREOo6rKNBEVlttGRVN CWoHhBGl1ofijJAUfEEBMb/Sj3ak9gVODnt9jLMUr2PA1y8d6i6SEeGGEzGfto1tq5qM 0mpw== 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=fY7NJdCFk/OTddCGqJnLG8sqEz0kb4drK+thajta1gY=; b=W9aRTi0yyH2RLa+wd6XbU1TARhAYW+pArjoOtcMBOxoYASyIulax78eaeZ2f9GmBzp oVUJ3R0TpvSKP5nD2ajskw0eCpJ9xLrSOmZWlwDZGhNFdag/bq+26VZ13mziS1NtLABy yY+8I6HyT0+wFRza9M6n4cFo0+NqwI91KE4+FAcRz9femvSdWP2OK7Uf2TXtvxM2aUHt JrUyFTwK8JatIcHmKeZx9t7pobAMp65A9AG2tgSadq81cH5a3PmCERtR5sgkHz4D1orQ LtjHQARuGMcORqb7WGTwuaPWsh8ferurjSxnFVJ4NXLymThEsv8/YGS/N/N04cOJCDxI w7xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=md2DCqKo; 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 d8-20020a654248000000b003816043eec9si663542pgq.190.2022.04.27.00.28.02; Wed, 27 Apr 2022 00:28:15 -0700 (PDT) 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=md2DCqKo; 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 S1357620AbiD0EIn (ORCPT + 99 others); Wed, 27 Apr 2022 00:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbiD0EIl (ORCPT ); Wed, 27 Apr 2022 00:08:41 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1271CB31 for ; Tue, 26 Apr 2022 21:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651032326; x=1682568326; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=FZHtsAFaRuQD3iQqtoOKS8GLIsWSCXJtA8Y7MOpLAxw=; b=md2DCqKoqRMEZ0l/QVU+17064wdV5eqmCDIwF5n2lqMhNlmkTLZZbpfE jHccZeG85YUCITfoyC3OxeRdrgv0+LRpERhG3/gdnAwQwi485YAFf0DG0 DcnFEvvc5QKmZQho2GyE8SUNB9+87iG64Cg+x26kzDRKpe42BIi3M0G6M b6m4JZqzPziGmQkjVRJipGHN3npVUIZn2NE6mdCK/fABDsox2ido8/8nF rcwk6oGhhQkiModVznwXgHrYUN8QHC8WFTcpQox8MPdVtqxXE5Sly2RXx RzCpS7eZLuXZul3RuplBJN+lEsDIlB0n9euy5L288HCSuCkGhGD+mD5eX g==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="328748426" X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="328748426" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 21:05:25 -0700 X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="730594987" Received: from jsaetton-mobl1.amr.corp.intel.com (HELO [10.209.41.167]) ([10.209.41.167]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 21:05:24 -0700 Message-ID: <405a4f3c-3d49-f3c2-441b-8d8b9d5eec23@linux.intel.com> Date: Tue, 26 Apr 2022 21:05:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.7.0 Subject: Re: [PATCH v4 1/3] x86/tdx: Add TDX Guest attestation interface driver Content-Language: en-US To: Kai Huang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H . Peter Anvin" , "Kirill A . Shutemov" , Tony Luck , Andi Kleen , linux-kernel@vger.kernel.org References: <20220422233418.1203092-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20220422233418.1203092-2-sathyanarayanan.kuppuswamy@linux.intel.com> <0457ce8e78ddd1d6c7832176368e095adae1bc18.camel@intel.com> From: Sathyanarayanan Kuppuswamy In-Reply-To: <0457ce8e78ddd1d6c7832176368e095adae1bc18.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 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 Kai, On 4/24/22 10:44 PM, Kai Huang wrote: >> In TDX guest, attestation is used to verify the trustworthiness of a TD >> to other entities before making any secure communication. > Before provisioning secrets to the TD. > >> One usage example is, when a TD guest uses encrypted drive and the >> decryption keys required to access the drive are stored in a secure >> 3rd party keyserver, TD guest can use the quote generated via the >> attestation process to prove its trustworthiness with keyserver and >> get access to the storage keys. > "The key server can use attestation to verify TD's trustworthiness and release > the decryption keys to the TD". > > It is the key server who starts the attestation request, but not the TD. > >> General steps involved in attestation process are, >> >>   1. TD guest generates the TDREPORT that contains version information >>      about the Intel TDX module, measurement of the TD, along with a >>      TD-specified nonce. >>   2. TD guest shares the TDREPORT with TD host via GetQuote hypercall >>      which is used by the host to generate a quote via quoting >>      enclave (QE). >>   3. Quote generation completion notification is sent to TD OS via >>      callback interrupt vector configured by TD using >>      SetupEventNotifyInterrupt hypercall. >>   4. After receiving the generated TDQUOTE, a remote verifier can be >>      used to verify the quote and confirm the trustworthiness of the >>      TD. > Let's separate TDREPORT generation and Quote generation, and get rid of details > of how to get Quote part for now. Detail of GetQuote belongs to the patch which > implements it. Here I think we should focus on explaining why we need such a > basic driver to allow userspace to get the TDREPORT. > > Below is for your reference: > > " > The attestation process consists of two steps: TDREPORT generation and Quote > generation. TDREPORT (TDREPORT_STRUCT) is a fixed-size data structure generated > by the TDX module to contain the TD-specific informatin (such as TD > measurements), platform information such as the security version of the platform > and the TDX module and the MAC to protect the integrity of the TDREPORT. TD > kernel uses TDCALL[TDG.MR.REPORT] to get the TDREPORT from the TDX module. A > user-provided 64-Byte REPORTDATA is used as input and included in the TDREPORT. > Typically it can be some nonce provided by attestation service so the TDREPORT > can be verified uniquely. > > TDREPORT can only be verified locally as the MAC key is bound to the platform. > TDX attestation leverages Intel SGX Quote Enclave (QE) to verify the TDREPORT > locally and convert it to a remote verifiable Quote to support remote > attestation of the TDREPORT. After getting the TDREPORT, the second step of > attestation process is to send the TDREPORT to QE to generate the Quote. > > How is the QE, or Quote Generation Service (QGS) in general, implemented and > deployed is implementation specific. As a result, how to send the TDREPORT to > QE/QGS also depends on QE/QGS implementation and the deployment. TDX doesn't > support SGX inside a TD, so the QE/QGS can be deployed in the host, or inside a > dedicated legacy VM. > > A typical implementation is TD userspace attestation software gets the TDREPORT > from TD kernel, sends it to QE/QGS, and QE/QGS returns the Quote. The data and > data format that TD userspace attestation software sends to the QE/QGS is also > implementation specific, but not necessarily just the raw TDREPORT. TD > attestation software can use any available communication channel to talk to > QE/QGS, such as using vsock and tcp/ip. > > To support the case that those communication channels are not directly available > to the TD, TDX also defines TDVMCALLs to allow TD to use TDVMCALL to ask VMM to > help with sending the TDREPORT and receiving the Quote. This support is > documented in the GHCI spec "5.4 TD attestation". > > Implement a basic attestation driver to allow TD userspace to get the TDREPORT > so the attestation software can send it to the QE to generate a Quote for remote > verification. > " > > >> >> More details on above mentioned steps can be found in TDX Guest-Host >> Communication Interface (GHCI) for Intel TDX 1.0, section titled >> "TD attestation". >> >> To allow the attestation agent (user application) to implement this >> feature, add an IOCTL interface to get TDREPORT and TDQUOTE from the >> user space. Since attestation agent can also use methods like vosck or >> TCP/IP to get the TDQUOTE, adding an IOCTL interface for it is an >> optional feature. So to simplify the driver, first add support for >> TDX_CMD_GET_TDREPORT IOCTL. Support for TDQUOTE IOCTL will be added by >> follow-on patches. >> >> TDREPORT can be generated by sending a TDCALL with leaf ID as 0x04. >> More details about the TDREPORT TDCALL can be found in Intel Trust >> Domain Extensions (Intel TDX) Module specification, section titled >> "TDG.MR.REPORT Leaf". Add a wrapper function (tdx_mcall_tdreport()) >> to get the TDREPORT from the TDX Module. This API will be used by the >> interface driver to request for TDREPORT. >> >> Also note that explicit access permissions are not enforced in this >> driver because the quote and measurements are not a secret. However >> the access permissions of the device node can be used to set any >> desired access policy. The udev default is usually root access >> only. How about the following summary? It includes important notes mentioned by you and some more driver info. x86/tdx: Add TDX Guest attestation interface driver In TDX guest, attestation is used to verify the trustworthiness of a TD to other entities before provisioning secrets to the TD. One usage example is, when a TD guest uses encrypted drive and if the decryption keys required to access the drive are stored in a secure 3rd party key server, the key server can use attestation to verify TD's trustworthiness and release the decryption keys to the TD. The attestation process consists of two steps: TDREPORT generation and Quote generation. TDREPORT (TDREPORT_STRUCT) is a fixed-size data structure generated by the TDX module which contains TD-specific information (such as TD measurements), platform security version, and the MAC to protect the integrity of the TDREPORT. The TD kernel uses TDCALL[TDG.MR.REPORT] to get the TDREPORT from the TDX module. A user-provided 64-Byte REPORTDATA is used as input and included in the TDREPORT. Typically it can be some nonce provided by attestation service so the TDREPORT can be verified uniquely. More details about TDREPORT can be found in Intel TDX Module specification, section titled "TDG.MR.REPORT Leaf". After getting the TDREPORT, the second step of the attestation process is to send the TDREPORT to Quoting Enclave (QE) or Quote Generation Service (QGS) to generate the Quote. However, the method of sending the TDREPORT to QE/QGS, communication channel used and data format used is specific to the implementation of QE/QGS. A typical implementation is, TD userspace attestation software gets the TDREPORT from TD kernel, sends it to QE/QGS, and QE/QGS returns the Quote. TD attestation software can use any available communication channel to talk to QE/QGS, such as using vsock and tcp/ip. To support the case that those communication channels are not directly available to the TD, TDX also defines TDVMCALL (TDG.VP.VMCALL) to allow TD to ask VMM to help with sending the TDREPORT and receiving the Quote. This support is documented in the GHCI spec section titled "5.4 TD attestation". Implement a basic attestation driver to allow TD userspace to get the TDREPORT, which is sent to QE by the attestation software to generate a Quote for remote verification. Add a wrapper function (tdx_mcall_tdreport()) to get the TDREPORT from the TDX Module. This API will be used by the interface driver to request for TDREPORT. Also note that explicit access permissions are not enforced in this driver because the quote and measurements are not a secret. However the access permissions of the device node can be used to set any desired access policy. The udev default is usually root access only. -- Sathyanarayanan Kuppuswamy Linux Kernel Developer