Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp43753rwr; Tue, 2 May 2023 15:37:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XqA/Bux3sV0yUEGji5uN76UZgqugzCq15++EQS+V1SQd6TOpf8wb0qjMyRKDAmDv3ZJIk X-Received: by 2002:a05:6a20:9382:b0:f4:d4a8:9c55 with SMTP id x2-20020a056a20938200b000f4d4a89c55mr23926806pzh.40.1683067032130; Tue, 02 May 2023 15:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683067032; cv=none; d=google.com; s=arc-20160816; b=JaBspmP7aVh+qUqJ4gAoiBb5Io2XvAXfOovNQ+dnySxJJzeOe8ZA7tHfjM1Cwu3gU/ k2QZeLOclOza1oY60nEheZ5EaqR/GksDWrM85cQ6FYoK2vnNAiXx6N4LW4pz3/9BdXDW Y8hO0D7k92ThfRBdMJlTBXJd2H3oRLfzUg34prmOB7j7+3/K3fmbgjX8NKs7yPgUG05F hfEiQmiHWAYlwkshYmewvGaZyk1H1IUJVKt5sQZCBDJxdz/DiEdv86FY7GPnaFYNIQNs Jj2uh2v/ZEg8Mio4XHGm5Ujk7evSTiuxcTWNb0s/RaislvNkNbTIwNykOO6ZPjBGyjRI qmwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=lwFGIxh3mR4IxnfjO7Fh/+VSIOsZ1HZ3AsHMkzhJzVc=; b=vzKKS2XM7mRewz6yhxR3MEgvi+vyhCVICdUEAVXga6+oGSNMKUbhj/W+tfNB2UZaBa ZdF3mQdlV3UIMCVQVOUHHdtJTCy8bHB3jJes2JHrIJJpbz0SGQQ05ogqZMGkO4ov9wfO JG/eJvCTkZ3RP4vdV0ABlRBWfIvfqNU2YYsr9vPHdokUYxTDvBmj2UVXwL1snG8TkqGK Y9UR6sAfg5NuaSaYTfVhR6TGcBSb+B532fMO+0WOUSRttl/2Ur4xvJWLucuyHSVNk5OG gYoXSb5q3OBCgJxAMWKC4HJVIN0Qggba5ddT8Lu7S3Ua1luEekWJ0fVPQ2TexKby3ehI xMoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=LV4Xm+Pf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce19-20020a17090aff1300b002474fac337dsi89766pjb.30.2023.05.02.15.36.58; Tue, 02 May 2023 15:37:12 -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=@google.com header.s=20221208 header.b=LV4Xm+Pf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjEBW2L (ORCPT + 99 others); Tue, 2 May 2023 18:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjEBW2J (ORCPT ); Tue, 2 May 2023 18:28:09 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437BA10E4 for ; Tue, 2 May 2023 15:28:08 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-b9246a5f3feso7172956276.1 for ; Tue, 02 May 2023 15:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683066487; x=1685658487; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lwFGIxh3mR4IxnfjO7Fh/+VSIOsZ1HZ3AsHMkzhJzVc=; b=LV4Xm+Pf/B+mhX6Eux2/d4iyrBd+wh5nhjdM+6mLRXMO0SKOeWUfAlVseraSM1dEGE zp84L/n/KBh/e0R29D/3dwDFGaI3EmTrw4gip9y8rvwrtj6zd510NLG9bCl8vpjqlLk6 o2KkipHhztX/aduTGfL4R2o2kOeTZ9dixM84r1Sqyq6Qo6RT5YMk02pcMg+hrqkPPtkf btppu9GSiN7ZpCPLog7vQNKAz5X0GBqCYIc6rYgC6Xgwc7lFXuKzu5gZRkmivJTBYDGs RXlaV1cyEDnI8lJFyjWOkhHyQhdqvPPGPVyeXM4agzscC27+w9gcBgbcS8H8+y6pNjoT HrDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683066487; x=1685658487; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lwFGIxh3mR4IxnfjO7Fh/+VSIOsZ1HZ3AsHMkzhJzVc=; b=Q2yDdYlNxeaffZ8KfpgnjJOnUQwA6QfOFswiHKr9LwEplFGRvFVGU0gajHLBwzbN5M qOL+offoNGAxp/GPJw+h67yuUkvs3hqyvaPdatTgUezFNodWGifdS2CQheIGvWq3Y36g YEV/dZDFWpaNHT9mlVVKWw+nqu45sVajKsXQWhj6MBN6ZTT/9aZ4aYiXwFJr6Dj0I8Ca RpmOXwadH15nIxuDTJBVPjLTacq4roNUwePmdham1f0jaHlQ+uzDKtUbbqX+PVjcJyK5 6++F169Nibr0Fy0/sT2+uK7czknATz1vGYhhoxRiz5NjMv6KAFhqTElHD6MVvJW/AJmn 8+YA== X-Gm-Message-State: AC+VfDyLMiQpGGX49fqcRm7mOfv2HA+1faIG4wmClSln/hYp+AhlEUO2 U07YvM1rcOX56wAT7j58gwjbP9R80gIRCu5ZxNf3uA== X-Received: by 2002:a25:ad91:0:b0:b96:9160:8da4 with SMTP id z17-20020a25ad91000000b00b9691608da4mr17677838ybi.17.1683066487198; Tue, 02 May 2023 15:28:07 -0700 (PDT) MIME-Version: 1.0 References: <20230413034108.1902712-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20230413034108.1902712-3-sathyanarayanan.kuppuswamy@linux.intel.com> In-Reply-To: <20230413034108.1902712-3-sathyanarayanan.kuppuswamy@linux.intel.com> From: Chong Cai Date: Tue, 2 May 2023 15:27:53 -0700 Message-ID: Subject: Re: [PATCH v2 2/3] virt: tdx-guest: Add Quote generation support To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Shuah Khan , Jonathan Corbet , "H . Peter Anvin" , "Kirill A . Shutemov" , Tony Luck , Wander Lairson Costa , Erdem Aktas , Dionna Amalie Glaze , Qinkun Bao , Guorui Yu , Du Fan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Wed, Apr 12, 2023 at 8:42=E2=80=AFPM Kuppuswamy Sathyanarayanan wrote: > > In TDX guest, the second stage in attestation process is to send the > TDREPORT to QE/QGS to generate the TD Quote. For platforms that does > not support communication channels like vsock or TCP/IP, implement > support to get TD Quote using hypercall. GetQuote hypercall can be used > by the TD guest to request VMM facilitate the Quote generation via > QE/QGS. More details about GetQuote hypercall can be found in TDX > Guest-Host Communication Interface (GHCI) for Intel TDX 1.0, section > titled "TDG.VP.VMCALL". > > Add support for TDX_CMD_GET_QUOTE IOCTL to allow attestation agent > submit GetQuote requests from the user space using GetQuote hypercall. > > Since GetQuote is an asynchronous request hypercall, VMM will use > callback interrupt vector configured by SetupEventNotifyInterrupt > hypercall to notify the guest about Quote generation completion or > failure. So register an IRQ handler for it. > > GetQuote TDVMCALL requires TD guest pass a 4K aligned shared buffer > with TDREPORT data as input, which is further used by the VMM to copy > the TD Quote result after successful Quote generation. To create the > shared buffer, allocate the required memory using alloc_pages() and > mark it shared using set_memory_decrypted() in tdx_guest_init(). This > buffer will be re-used for GetQuote requests in TDX_CMD_GET_QUOTE > IOCTL handler. > > Although this method will reserve a fixed chunk of memory for > GetQuote requests during the init time, it is preferable to the > alternative choice of allocating/freeing the shared buffer in the > TDX_CMD_GET_QUOTE IOCTL handler, which will damage the direct map. Thanks Sathyanarayanan for the work. The patch looks good. Reserving a fixe= d chunk of memory for GetQuote makes sense to me. And just want to re-emphasize that the TDVMCALL approach is important for many use cases that cannot depend on virtio/vsock.