Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1862589rdb; Thu, 21 Sep 2023 01:28:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFI2dEn+KAU7AQxHjjsqw9r3CZQDCHoXAuQ/BkJdw3opKi/3BCvmxS42Arm2iv4Bi/c/koD X-Received: by 2002:a05:6870:6123:b0:1c4:e139:33e with SMTP id s35-20020a056870612300b001c4e139033emr5057726oae.59.1695284883123; Thu, 21 Sep 2023 01:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695284883; cv=none; d=google.com; s=arc-20160816; b=cRIcifJLX7+SS2u8zWwH19mRml1K3WJ7EgMhVKQ7FXYgXxugo8F76ttrPq92XBzQIE a0uhBwtanGVxM11C/M7kvT5S4Uytazlz/0tZST1tQQshbMy+ZObwhiwLg/KEIIzM50DI 5ihRwho31pOT+9EiQW2HU5dxR9C3dObb4sg2PH+sFjQ/JTnjArq5NXgKgOtlijr0WTWD F1ZGCw/JKflE+4INDlTcB0RioDNk58sfAzHgcdiEg1Q0jnCnImjNL0VeZfIxPvPJCun6 aW+fvrd2ZljVFHGQ2R7JkLyM8oP4catS2ZW9wMR2izCrpugxM0aK1FyFPaX5t2ZZMUtj o45g== 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=cXVITGDPGvQXDKgdBYzXMtxm4MnaABDXn0LhtEv8kjo=; fh=9G+KiOZBZO5GE/uUPbVd5fIUElGaGMaBCliS57hETas=; b=ThdUIkEJddelCUCoaMRvCsUTNiyQscPWTUlHxZmw1bc4z4qzzXCHBgu8lUgRjd94G/ rFG/9LMCysiDofeVWpX4wFlUfbaGdQ2NnvZ2lPbXBSxJtQ8UvvQNABrY2aYFMmXFXjxg yEiuRmJEB1/VRR2M+J+YujanclIoU2yv1iU5qM5EmbBoCpIe22QsQpGWRkaXBlVzPa32 w5kB5wxp2HP09xtpFgGZeaK+5EHuE9YBoAXiHW14s6Mg3KKuRhJBdGIgplElURtuUByA 4nFFvZuNkYBiCKX4XJRaeO7WSEb/oq9wihd4binT8DH8uTO7pL7UCEk+sq32qNq5azYv TjXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tuNgEJSg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h191-20020a6383c8000000b00553ce421356si936669pge.56.2023.09.21.01.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 01:28:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tuNgEJSg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 8F32B8082066; Wed, 20 Sep 2023 14:10:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230186AbjITVKr (ORCPT + 99 others); Wed, 20 Sep 2023 17:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjITVKp (ORCPT ); Wed, 20 Sep 2023 17:10:45 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2AFAB9 for ; Wed, 20 Sep 2023 14:10:38 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-65628b1181cso1301996d6.1 for ; Wed, 20 Sep 2023 14:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695244238; x=1695849038; darn=vger.kernel.org; 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=cXVITGDPGvQXDKgdBYzXMtxm4MnaABDXn0LhtEv8kjo=; b=tuNgEJSg44nwNJy7oYjUWb1KHefDQOJHHZoLTxlzjw2hVIMNUV5WJkWamnnYu7Ct+U Lx9TNV4WeKVnG1nrl4pJp2c3x4xF6DfVy87n7drDdP7Dtehyj+iQwyywgX9JjnE5blur wQVPgQ15VQDHe8rseKMqO1PlHsk8p8tsp1Iv8pNJhtTqBitpjh0IRzA7CMxS8Cpy1vF/ cQQ03llSSDRtxTDTpSpqWHodksAgzyukiUryUWPRqkfzI/Bya0ZhXyxFOhhlTc2Aj3c1 sJNOlPQrPuLrOdpFV+z/Us1vGiS4djw/OVU3hfSzeh7yPwX+u0V3OZipSBlQUhJlTYFu nkMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695244238; x=1695849038; 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=cXVITGDPGvQXDKgdBYzXMtxm4MnaABDXn0LhtEv8kjo=; b=B1/53mZSHsNgurZKjMuy53K8EOVZmy8A15gfKHnTFn113xEv2rLJeaDZxEh0RBn1m8 dn5j8HUYq6ZyVLjv/QYdPjHvBTlUQssLN18CKitpxJsxmIHIFCpychs9NAFSAOJf5+e4 FXeHoOooQoQnAJlt/90D9jyhr4P/yrxt/qu7iqjkCfETBSZhkh9tkMqTW2flELrvbrUe THLe2t6REsrZJCTWAMJDANLMxuWgQETquzmHBF/VrhVZYvSEU/TQzyS6fDCxEjQ9SGSD RBzsNePdTm6h8DLdfvALDSlsbulhp/xEW+qcafAQLwKwr1RO+lgdwbaCXWpRW8wwXrwf MSEg== X-Gm-Message-State: AOJu0YwCSbBgMqpLmRlK96zxQtTYxf/8tVnDRiGS9QHt1EuCv6hn0SDz uUjxOpGihzqTL5ITsZPC+yU3gJXDImzUfTfuU5V2EQ== X-Received: by 2002:a05:6214:398b:b0:657:ace:63eb with SMTP id ny11-20020a056214398b00b006570ace63ebmr3576716qvb.54.1695244237653; Wed, 20 Sep 2023 14:10:37 -0700 (PDT) MIME-Version: 1.0 References: <20230914031349.23516-1-sathyanarayanan.kuppuswamy@linux.intel.com> In-Reply-To: <20230914031349.23516-1-sathyanarayanan.kuppuswamy@linux.intel.com> From: Erdem Aktas Date: Wed, 20 Sep 2023 14:10:26 -0700 Message-ID: Subject: Re: [PATCH v2] virt: tdx-guest: Add Quote generation support using TSM_REPORTS To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Dan Williams , "Kirill A . Shutemov" , "H . Peter Anvin" , Tony Luck , Wander Lairson Costa , Dionna Amalie Glaze , Qinkun Bao , Guorui Yu , linux-coco@lists.linux.dev, x86@kernel.org, linux-kernel@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_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 14:10:44 -0700 (PDT) On Wed, Sep 13, 2023 at 8:14=E2=80=AFPM Kuppuswamy Sathyanarayanan wrote: > > In TDX guest, the attestation process is used to verify the TDX guest > trustworthiness to other entities before provisioning secrets to the > guest. The First step in the attestation process is TDREPORT > generation, which involves getting the guest measurement data in the > format of TDREPORT, which is further used to validate the authenticity > of the TDX guest. TDREPORT by design is integrity-protected and can > only be verified on the local machine. > > To support remote verification of the TDREPORT (in a SGX-based > attestation), the TDREPORT needs to be sent to the SGX Quoting Enclave > (QE) to convert it to a remotely verifiable Quote. SGX QE by design can > only run outside of the TDX guest (i.e. in a host process or in a > normal VM) and guest can use communication channels like vsock or > TCP/IP to send the TDREPORT to the QE. But for security concerns, the > TDX guest may not support these communication channels. To handle such > cases, TDX defines a GetQuote hypercall which can be used by the guest > to request the host VMM to communicate with the SGX QE. 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". > > Trusted Security Module (TSM) [1] exposes a common ABI for Confidential > Computing Guest platforms to get the measurement data via ConfigFS. > Extend the TSM framework and add support to allow an attestation agent > to get the TDX Quote data (included usage example below). > > report=3D/sys/kernel/config/tsm/report/report0 > mkdir $report > dd if=3D/dev/urandom bs=3D64 count=3D1 > $report/inblob > hexdump -C $report/outblob > rmdir $report > > 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 a large enough memory and mark it shared using > set_memory_decrypted() in tdx_guest_init(). This buffer will be re-used > for GetQuote requests in the TDX TSM handler. > > Although this method reserves a fixed chunk of memory for GetQuote > requests, such one time allocation can help avoid memory fragmentation > related allocation failures later in the uptime of the guest. > > Since the Quote generation process is not time-critical or frequently > used, the current version uses a polling model for Quote requests and > it also does not support parallel GetQuote requests. > > Link: https://lore.kernel.org/lkml/169342399185.3934343.30358453483269445= 19.stgit@dwillia2-xfh.jf.intel.com/ [1] > Signed-off-by: Kuppuswamy Sathyanarayanan > --- > > Hi All, > > The original version of this patch series [1] added support for TDX > Guest Quote generation via an IOCTL interface. Since we have multiple > vendors implementing such interface, to avoid ABI proliferation, Dan > proposed using a common ABI for it and submitted the Trusted Secure > module (TSM) report ABI support [2]. This patchset extends the > TSM REPORTS to implement the TDX Quote generation support. Since there > is a change in interface type, I have dropped the previous Acks. > > [1] https://lore.kernel.org/lkml/3c57deb0-a311-2aad-c06b-4938e33491b5@lin= ux.intel.com/ > [2] https://lore.kernel.org/lkml/169342399185.3934343.3035845348326944519= .stgit@dwillia2-xfh.jf.intel.com/ > > Changes since v1: > * Used mutext_lock_interruptible() for quote_lock to allow user > interruption. > * Used msleep_interruptible() instead of ssleep() to allow user > interruption. > * Added check for the set_memory_encrypted() return value. > * Fixed typos in comments and commit log. > Thanks for the changes, the patch looks good to me. Reviewed-by : Erdem Aktas