Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1396460lqa; Mon, 29 Apr 2024 07:27:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpuUmi0cu47zBgjesgEyVvcgEpFTuhtjNxZnDtzvWKtUfgO7/1VUdQ/pyBbXWRUmBw/fP6SafwGLJBxZrWPEhEncL8l+x/Rv9/OYZ2VQ== X-Google-Smtp-Source: AGHT+IEMgfLy8BNdyalq768/XZK+7dii+MCQP+WzAAsHGNuniyZCQgUbbOdwpuAHsCBFGp4U+ED7 X-Received: by 2002:a17:906:3b48:b0:a58:ea69:3f5e with SMTP id h8-20020a1709063b4800b00a58ea693f5emr5460374ejf.38.1714400854439; Mon, 29 Apr 2024 07:27:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714400854; cv=pass; d=google.com; s=arc-20160816; b=Dgx9S4Lt8JET+McCqr6fqXKxAnKUMpTXnLLFGU1167CVmCB9LksrAVVsMs8E+nEUql hgr2hTHIe3HDoZV9XTPqIXWMXCzdyEtMweU9llc5BdNjSXPQ02qHrBo0d6L1w42aKV4g pHyTUEqnZYrT1AejxYMArt67nU4lPN1PEv4O1aRcH5b/DIxAOghU6PmIR3kgCrq8cVRe ZHdm2LXnr3mclRbL+bPqcrPr1w3jn0fRBVbYrz7m9uz1i5mZb5MbhdR3+7jAgFDX3Cme nMHg7SxQr70B/oiTuvCqttXGweTYwDelLEH+CkTQK6MQvXcplsGdu6GekWTHDryigZaF sPNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=S3mlM0E1TrjvYHfesQNSkr38bw44gyQq8z5XmrX3EV0=; fh=0iEP1LsLxQagoo8Da6VxEluHDzUeuhmCxOXYivvqYnE=; b=j+wyX8YkujGHLOdowK+wyzrGQV+Je/V+U6Ax2bgJPezYyAn+prU9brDB37DPclrQB9 2fl086/c/NMFiNbSowCWi/PVF3O6CwRjFi2bhBY1w6hQwLXxdxMdeKDznK0qGWUdAHgk UhhZvEa+PVayTVtFei3AMf7aR27Z/88LrG/hbFeZ2NFi9YIOPt2SnYXrxJq+i3Ho1Cle vaTUtUc1SHvDwBCTHZ2J+ejp9kZP1jTm6av4hdBxTY4MvyD/mpIFY7gMIpDndtqfUuuR SvgLd0f/F54MNCQ+UL43+V6s0l7TeTx1xvldXGWuXpVeqR8LMbV4Ij+CRH7E6nEG92kE yBiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TNvfnSyR; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-3929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ub5-20020a170907c80500b00a58fd7afecbsi1558457ejc.662.2024.04.29.07.27.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:27:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TNvfnSyR; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-3929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F2F331F2175D for ; Mon, 29 Apr 2024 14:27:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45A597BB07; Mon, 29 Apr 2024 14:27:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TNvfnSyR" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C84E478B63 for ; Mon, 29 Apr 2024 14:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714400846; cv=none; b=vD4jyKA0K9wqE8vplnBmLwofe83Eg18K2cKxbyDL/4UhxJBxcrnLFLMr5g3H4zmKzPcDXfaMMX2vtKzQjkdQcDcBDNSCiolf+WawuxsmSFzsGOKdmF0/0bSiu/xdGo1iDeO3iF8fjY6e3A2WlCCjA1+VA7vL5NhtQvjAwksZ6eM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714400846; c=relaxed/simple; bh=dOL5MQJEWlm+ALadfwEWLIsuMmXKHK7rNTd6CxqSNA0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cOdGNNR5ia47c1e5JDXLXckDQORTyGxbCAbum0PFTOtiT4UCHYumLiLYb/YXSaK4E+tzTRg0SMKRou6CCXJcxCOf0LQr5ZExL5xAdF+ymf1q+t7ips7rvgivX8GCX14vsUtdTj1ZlngxXaE5qQ/O07OOKdhwbPDNVz73GL9q3Hg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TNvfnSyR; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-601fef07eaeso5218474a12.1 for ; Mon, 29 Apr 2024 07:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714400844; x=1715005644; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=S3mlM0E1TrjvYHfesQNSkr38bw44gyQq8z5XmrX3EV0=; b=TNvfnSyRLs2kUehKYQg9lgy0+HSgeBrQ3mGDf7ZZH65mLocaUa6qmks0FzpCpzV2Qn BD9e6HPgy7fN6Rvq/0LD6EXaoM+OexYxuE/e59aOI56V3cPh9Ca8QnpVOR3sw6ABQmTD zhRNNRIEGeImEQLC3EKXn8IA+NI8ZMv04IMKNeHcgY4fDFgDqANrxIp6xnrk04TONTN9 bTtORWXUnZv0uKm4bqxVDJHUOsHZEVOBW1jA/qI4nGfb8GxTnxdHg3NbtjHQycg7PlpX 27ZXstLqzB32bkQi8Dbyb9bM5UWaebeMGIIJwt/siu8JpqaKsODF4ih8CqXilsAtdBcW bsmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714400844; x=1715005644; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S3mlM0E1TrjvYHfesQNSkr38bw44gyQq8z5XmrX3EV0=; b=bKvo3xJ+Sf8nY5oV0J1QThTsu/p26dOFqjOWDDyUyFJqpvdpVlGXFQ0NpwtpOrf1zG naaG2EMr+LV4TdZn3pEWYgWfup49OG1OG7snBbfYyfCXu90SYeoXladkk0F2BKMDQ++u qW/mxH4lFeAy9E4JD7Mp9mpJGrpdVHTX1whofEtNdMg9lcfPCE92eL/dGKgyx6/OdUPJ QLAwaL1F3zzv9Q2YUaz1x86sByFJ2cxSVSAbQb0BpzoJEy+Dk9n4yX/qtzCBExKCG4wF icuc+I0c/4AChGxq6nx06fc5KCPyjZ0CLHlXnqGPmIQnXzYz4c9rO1nWFjOtO991PcgV oEXA== X-Forwarded-Encrypted: i=1; AJvYcCXmHkihmlCNPWODgl79e0ugd1o72XE44RmNmqROd8JP43il10AOnR0V+rrUI6wM3F1lXlnM8sJpmlh6T4l28U3Y0vS+GEicg+utT1ld X-Gm-Message-State: AOJu0Yy66PyE808yeMD7hFa8WK68MiBXMXYk0Im5j+kJvEfeZ4bcxa1q iuUHM1j8P1OHJhJURCsgQLaAclIMnQAqJjYP7Y1gHFI8x7DPaX4UI76/E1OZGbfEMNu2wb7ybU4 uog== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:1e5d:0:b0:5f7:651b:fed8 with SMTP id p29-20020a631e5d000000b005f7651bfed8mr29463pgm.12.1714400843944; Mon, 29 Apr 2024 07:27:23 -0700 (PDT) Date: Mon, 29 Apr 2024 07:27:22 -0700 In-Reply-To: <20240427013210.ioz7mv3yuu2r5un6@amd.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240421180122.1650812-1-michael.roth@amd.com> <20240421180122.1650812-22-michael.roth@amd.com> <20240426173515.6pio42iqvjj2aeac@amd.com> <20240426214633.myecxgh6ci3qshmi@amd.com> <20240427013210.ioz7mv3yuu2r5un6@amd.com> Message-ID: Subject: Re: [PATCH v14 21/22] crypto: ccp: Add the SNP_{PAUSE,RESUME}_ATTESTATION commands From: Sean Christopherson To: Michael Roth Cc: kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, vkuznets@redhat.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, bp@alien8.de, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, jarkko@kernel.org, ashish.kalra@amd.com, nikunj.dadhania@amd.com, pankaj.gupta@amd.com, liam.merwick@oracle.com, Larry.Dewey@amd.com Content-Type: text/plain; charset="us-ascii" On Fri, Apr 26, 2024, Michael Roth wrote: > On Fri, Apr 26, 2024 at 05:10:10PM -0700, Sean Christopherson wrote: > > e.g. put the cert in a directory along with a lock. Actually, IIUC, there doesn't > > even need to be a separate lock file. I know very little about userspace programming, > > but common sense and a quick search tells me that file locks are a solved problem. > > > > E.g. it took me ~5 minutes of Googling to come up with this, which AFAICT does > > exactly what you want. > > > > touch ~/vlek.cert > > ( > > flock -e 200 > > echo "Locked the cert, sleeping for 10 seconds" > > sleep 10 > > echo "Igor, it's alive!!!!!!" > > ) 200< vlek.cert > > > > touch ~/vlek.cert > > ( > > flock -s 201 > > echo "Got me a shared lock, no updates for you!" > > ) 201< vlek.cert > > > > Hmm... I did completely miss this option. But I think there are still some > issues here. IIUC you're suggesting (for example): > > "Management": > a) writelock vlek.cert > b) perform SNP_LOAD_VLEK and update vlek.cert contents > c) unlock vlek.cert > > "QEMU": > a) readlock vlek.cert > b) copy cert into guest buffer > c) unlock vlek.cert > > The issue is that after "QEMU" unlocks and return the cert to KVM we'll > have: > > "KVM" > a) return from EXT_GUEST_REQ exit to userspace > b) issue the attestation report to firmware > c) return the attestation report and cert to the guest > > Between a) and b), "Management" can complete another entire update, but > the cert that it passes back to the guest will be stale relative to the > key used to sign the attestation report. I was thinking userspace would hold the lock across SEV_CMD_SNP_GUEST_REQUEST. QEMU: a) readlock vlek.cert b) copy cert into guest buffer c) set kvm_run->immediate_exit d) invoke KVM_RUN e) KVM sends SEV_CMD_SNP_GUEST_REQUEST to PSP f) KVM exits to userspace with -EINTR g) unlock vlek.cert h) invoke KVM_RUN (resume the guest) > If we need to take more time to explore other options it's not > absolutely necessary to have the kernel solve this now. But every userspace > will need to solve it in some way so it seemed like it might be nice to > have a simple reference implementation to start with. Shoving something into the kernel is not a "reference implementation", especially not when it impacts the ABI of multiple subsystems.