Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp88046rdb; Fri, 29 Sep 2023 18:11:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzaXmthh0sb1voAsDkt3P+VwG3W1a0BYaB8eOlgtv7jHrIKPsPktj/V1/y/ozC5/4p/O9g X-Received: by 2002:a17:90a:7407:b0:273:f10c:b6d2 with SMTP id a7-20020a17090a740700b00273f10cb6d2mr8854439pjg.18.1696036279923; Fri, 29 Sep 2023 18:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696036279; cv=none; d=google.com; s=arc-20160816; b=vm7XK9B3clyNmBjjMNrjZ5JhsPiy3e7scuYtTHif3UG0yPwT7BG/ECz8PJbt3u8VAI nUCGi/U3gmGj/L6i7uB5/x047mdiGR2woeIekqNUdquNj6ToB7oP7S4KSa6fZVP6YiqK 2ai3kDLNJlYwupBMfW3LrWTmnAJogyPTSG3HG5MnrEkqEd3Mu/MXq6xIT4NT2vJ1M5/E mU9A2LdtLL/zy6BzJDjR5X3Mir+9RSMRU32F0FESC1bqD2P6XiTtm+LYlfCNWn0Lmxls 8re1ydnL8zNI7bxQC5cOBX5lbcuQuo63HblaasqRLxIen9s2kYOUwO8ENIVz87eiey44 zKVQ== 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=eZPhV+/EescYNoXGPgKiBmp8aKwNwiwKoYsNuSuqswY=; fh=CkXwvRq3lxbSON80Qm5rRQpxE3Xg/hOvHLEhsbzTSxI=; b=WIgUu3NgfO81U8jTbrqCU6On1fWr1xI36MtCSuyt8MNU+iI3uH+TXSQpKriqfMsf3q kUFhVdEnhSMb51soR04jwtb58WEaihA7AGjAMFK4e1uLl9yuMHHUQ5M8IPB70sDlRrth N3k6AB41MOVfJ3fgfcK3Gi/gwCeI3kUASBvqCYChxwo232hCs+0p9nK+NdLyJ3fpo/Bg xp5MXlgNmPHKIHHkcGqR0ddFEUxwyIgpWxfPVaE1w0CQmAUh7rYMosdjGyit2bDW58oi vYzen4TkMq8pelxOR+XkIXmAHiSLxOjZKWqhnb26uEujgwfMGOlGrX8GSCMWnXN4XHon ZVnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rbG95gns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d59-20020a17090a6f4100b0027762fed4a0si2527868pjk.11.2023.09.29.18.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 18:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rbG95gns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 0E5F88115477; Fri, 29 Sep 2023 10:30:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233845AbjI2R3N (ORCPT + 99 others); Fri, 29 Sep 2023 13:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbjI2R3E (ORCPT ); Fri, 29 Sep 2023 13:29:04 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A0112689 for ; Fri, 29 Sep 2023 10:26:49 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50302e8fca8so7546e87.0 for ; Fri, 29 Sep 2023 10:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696008407; x=1696613207; 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=eZPhV+/EescYNoXGPgKiBmp8aKwNwiwKoYsNuSuqswY=; b=rbG95gnsWVUIUE7rzWrKlQ4M4yLuF7vQzKHpyg+Y0HvpxUxL4L9zk0dCvE6yKaxko2 VidezBNMeeSjyz1ptJhBL/tM93wGty7tlDsdbodPtvwEo+5U3SskJZrhdQ7krWSO/qj2 zqqgQvRmcN7/HT1acKmFHC6LaxI4bp+0w95Hs5da75dVX/Rkw3be3t1+rUDK9VDyDa37 8FMUz6BT6/MAnAlTMHkaLUu/Y4SGAJ385LXFuJIOQRklV1hx3/hUMPXAOQh6btxdUZxg 2Kt5jATNwQVmYnxjbMY8HduUc1Zezfzjpi55zqNBM69MJpAaW2fu2akh3chu31j/pqQ4 F04A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696008407; x=1696613207; 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=eZPhV+/EescYNoXGPgKiBmp8aKwNwiwKoYsNuSuqswY=; b=olFcLJne3/Bt+95oRLJOdv0BmO8t97ILaDQixWKu15xPrUZfOSrEjGfuepLjp9Jwoi LHkurL2vjRMWYa4JpoJ0rluwmmRaXq4Dlf+PwEFaPIfVoHdhNzC08ygeZlpNuNZ70zGq kC/g1Eos2mR3kRfOc/tdY3lEoRGaAKuk8RT8yoellvnLKZq35c23vEFStiykb8lHMVqh k3BLoxxr8hKdWqkZ2yxdnfqMqQaqgmomI75FG3HOjBYWBvtoEaaOd4L7REQvYA/XVFJ8 bPrFEwEZmXoIGCcoR39V30Roz67H7sypx4R8Wb5mFwqnizuFYn0pnlM/GyneTHvKySKI 0R4Q== X-Gm-Message-State: AOJu0YyTf7bYw9ASFOo0yxynx4AV4WVupib+0xgQYU2M6H2h31RkLxNw Sb/EzIU2hSmpjtzZYYAIsD+/LnU4E2S1itsGqI+lHA== X-Received: by 2002:ac2:4c26:0:b0:501:a2b4:8ff5 with SMTP id u6-20020ac24c26000000b00501a2b48ff5mr3105lfq.7.1696008406607; Fri, 29 Sep 2023 10:26:46 -0700 (PDT) MIME-Version: 1.0 References: <169570181657.596431.6178773442587231200.stgit@dwillia2-xfh.jf.intel.com> <169570185411.596431.3153227201984845022.stgit@dwillia2-xfh.jf.intel.com> <651602dc4c6e3_91c1e2947f@dwillia2-xfh.jf.intel.com.notmuch> In-Reply-To: <651602dc4c6e3_91c1e2947f@dwillia2-xfh.jf.intel.com.notmuch> From: Peter Gonda Date: Fri, 29 Sep 2023 11:26:34 -0600 Message-ID: Subject: Re: [PATCH v4 6/6] virt: tdx-guest: Add Quote generation support using TSM_REPORTS To: Dan Williams Cc: linux-coco@lists.linux.dev, Kuppuswamy Sathyanarayanan , Erdem Aktas , peterz@infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org, dave.hansen@linux.intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 29 Sep 2023 10:30:10 -0700 (PDT) On Thu, Sep 28, 2023 at 4:49=E2=80=AFPM Dan Williams wrote: > > Peter Gonda wrote: > > On Mon, Sep 25, 2023 at 10:17=E2=80=AFPM Dan Williams wrote: > > > > > > From: Kuppuswamy Sathyanarayanan > > > > > > 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 authenticit= y > > > 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 c= an > > > 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 suc= h > > > cases, TDX defines a GetQuote hypercall which can be used by the gues= t > > > 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 Confidenti= al > > > Computing Guest platforms to get the measurement data via ConfigFS. > > > Extend the TSM framework and add support to allow an attestation agen= t > > > 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 usin= g > > > set_memory_decrypted() in tdx_guest_init(). This buffer will be re-us= ed > > > 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 fragmentatio= n > > > 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.3035845348326= 944519.stgit@dwillia2-xfh.jf.intel.com/ [1] > > > Signed-off-by: Kuppuswamy Sathyanarayanan > > > Reviewed-by: Erdem Aktas > > > Signed-off-by: Dan Williams > > > > Hey Dan, > > > > I tried running your test commands on an SNP enabled guest. To build > > the kernel I just checked out linus/master and applied your series. I > > haven't done any debugging yet, so I will update with what I find. > > > > root@Ubuntu2004:~# hexdump -C $report/outblob > > [ 219.871875] ------------[ cut here ]------------ > > [ 219.876642] kernel BUG at include/linux/scatterlist.h:187! > > Ok, it does not like virtual address of one of the buffers, but my > changes "should" not have affected that as get_ext_report() internally > uses snp_dev->certs_data and snp_dev->response for bounce buffering the > actual request / response memory. First test I want to try once I can > get on an SNP system is compare this to the ioctl path just make sure > that succeeds. I tried the IOCTL with our attestation test and it seems to be working fine. I was hoping to debug further next week. I also mailed you offlist to discuss getting access to SNP for testing.