Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3588537pxj; Tue, 15 Jun 2021 04:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4Qb1XT1bcmYXyBgT8SIlmqwGW31EiyRJFcRZ7RW3OQG1fGhpAUf4bsywuvckV+e1U5al8 X-Received: by 2002:a17:906:7950:: with SMTP id l16mr1874306ejo.120.1623756283740; Tue, 15 Jun 2021 04:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623756283; cv=none; d=google.com; s=arc-20160816; b=Cw6R8TwAmpFG2+gzF0n2GoL36QGmdk38fQS3mOIYrdwewAQRcBRXqx4zakaxcy1Bin 4s9j1yheLmv6zoGA+O9ZWjSbYmzko9zCRhQ7EVdSzUt3vDqbuMeAW8O5HWNpW0dMbWMf 9wl3y4T8Zbg9ZKdLFUqbtlxGoOurBA+IZ7FwQY2B5eJr8v9vUtI1AnTnvBjA3RAHZwYw Ro6V9P2vMQc/O7c3Ds8YeVcvGrdPsXbAVgLyO44uoDPEA9PhyA1tlhxCFHOVcXjx5BgI cFtuooULceCqF2ExHrAc1keUCnwXWQjv6z3nkQMh9zqi598KYZiflnpQWWcok33c8zY0 cong== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6zIhA2yJuykBLTAxFpo5bYvmvbrLn/gng5f4bN7IW1A=; b=OW1fdFQHGLwZLLZ0ttwPPLCwjBqC0hHh+aCWZE9dTeINtDchmhnkVbt6AiNKPKYQWX 3oYBy7Dm552vaaJ+2mkmM5hWkWkzhaDwM7TDFegGXc7naiPZiN53X7kL6mBfwsczWD+b vg9wyoe6La819e2OBUJuAqyz3YeS82LUYCHwasJ6o9pqKqU7foN3i2d4es6IJBTVFdRV /nwHqwjnq4jAyr0MhYWUNY7+3QVQ8ISZD+HGCR8RRTA6SEC666j1qqC6upBL/V0qrUuz ZFUa7CHmOASWJ4OO7KUA7lAI13GTdYrhiRBAldymV/0WTGAgHuhLnvjl43l1PfB9hRqd K4FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BX06zhZO; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fh1si13555600ejc.91.2021.06.15.04.24.04; Tue, 15 Jun 2021 04:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BX06zhZO; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbhFOLZb (ORCPT + 99 others); Tue, 15 Jun 2021 07:25:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59332 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbhFOLZb (ORCPT ); Tue, 15 Jun 2021 07:25:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623756206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6zIhA2yJuykBLTAxFpo5bYvmvbrLn/gng5f4bN7IW1A=; b=BX06zhZORedZP42ZDuzZIPQ3o42HlTgLfk88W6pyWs1moViIAj32o+3cJjltYtsmaCTOMy v7y6sEDtR2TCNlAd1tS7+B04V3pFoUexuJby1yqDuMXdcAekA0rUHzq1l+zFHVOHzn3S9y a50HxzcBQFv60ipxPfTUEMqqBeS8Cgw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-pXEN-AimNDuyli6m1JxVag-1; Tue, 15 Jun 2021 07:23:25 -0400 X-MC-Unique: pXEN-AimNDuyli6m1JxVag-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C0C9107ACF6; Tue, 15 Jun 2021 11:23:22 +0000 (UTC) Received: from work-vm (ovpn-112-179.ams2.redhat.com [10.36.112.179]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0E301001B2C; Tue, 15 Jun 2021 11:23:10 +0000 (UTC) Date: Tue, 15 Jun 2021 12:23:08 +0100 From: "Dr. David Alan Gilbert" To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , tony.luck@intel.com, npmccallum@redhat.com, Borislav Petkov Subject: Re: [PATCH Part2 RFC v3 14/37] crypto:ccp: Provide APIs to issue SEV-SNP commands Message-ID: References: <20210602141057.27107-1-brijesh.singh@amd.com> <20210602141057.27107-15-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210602141057.27107-15-brijesh.singh@amd.com> User-Agent: Mutt/2.0.7 (2021-05-04) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org * Brijesh Singh (brijesh.singh@amd.com) wrote: > Provide the APIs for the hypervisor to manage an SEV-SNP guest. The > commands for SEV-SNP is defined in the SEV-SNP firmware specification. > > Signed-off-by: Brijesh Singh > --- > drivers/crypto/ccp/sev-dev.c | 24 ++++++++++++ > include/linux/psp-sev.h | 74 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 98 insertions(+) > > diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c > index b225face37b1..def2996111db 100644 > --- a/drivers/crypto/ccp/sev-dev.c > +++ b/drivers/crypto/ccp/sev-dev.c > @@ -1014,6 +1014,30 @@ int sev_guest_df_flush(int *error) > } > EXPORT_SYMBOL_GPL(sev_guest_df_flush); > > +int snp_guest_decommission(struct sev_data_snp_decommission *data, int *error) > +{ > + return sev_do_cmd(SEV_CMD_SNP_DECOMMISSION, data, error); > +} > +EXPORT_SYMBOL_GPL(snp_guest_decommission); > + > +int snp_guest_df_flush(int *error) > +{ > + return sev_do_cmd(SEV_CMD_SNP_DF_FLUSH, NULL, error); > +} > +EXPORT_SYMBOL_GPL(snp_guest_df_flush); > + > +int snp_guest_page_reclaim(struct sev_data_snp_page_reclaim *data, int *error) > +{ > + return sev_do_cmd(SEV_CMD_SNP_PAGE_RECLAIM, data, error); > +} > +EXPORT_SYMBOL_GPL(snp_guest_page_reclaim); > + > +int snp_guest_dbg_decrypt(struct sev_data_snp_dbg *data, int *error) > +{ > + return sev_do_cmd(SEV_CMD_SNP_DBG_DECRYPT, data, error); > +} > +EXPORT_SYMBOL_GPL(snp_guest_dbg_decrypt); > + > static void sev_exit(struct kref *ref) > { > misc_deregister(&misc_dev->misc); > diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h > index 1b53e8782250..63ef766cbd7a 100644 > --- a/include/linux/psp-sev.h > +++ b/include/linux/psp-sev.h > @@ -860,6 +860,65 @@ int sev_guest_df_flush(int *error); > */ > int sev_guest_decommission(struct sev_data_decommission *data, int *error); > > +/** > + * snp_guest_df_flush - perform SNP DF_FLUSH command > + * > + * @sev_ret: sev command return code > + * > + * Returns: > + * 0 if the sev successfully processed the command > + * -%ENODEV if the sev device is not available > + * -%ENOTSUPP if the sev does not support SEV sev not supporting SEV? Is that actually 'sev does not support SNP'? > + * -%ETIMEDOUT if the sev command timed out > + * -%EIO if the sev returned a non-zero return code > + */ > +int snp_guest_df_flush(int *error); > + > +/** > + * snp_guest_decommission - perform SNP_DECOMMISSION command > + * > + * @decommission: sev_data_decommission structure to be processed > + * @sev_ret: sev command return code > + * > + * Returns: > + * 0 if the sev successfully processed the command > + * -%ENODEV if the sev device is not available > + * -%ENOTSUPP if the sev does not support SEV > + * -%ETIMEDOUT if the sev command timed out > + * -%EIO if the sev returned a non-zero return code > + */ > +int snp_guest_decommission(struct sev_data_snp_decommission *data, int *error); > + > +/** > + * snp_guest_page_reclaim - perform SNP_PAGE_RECLAIM command > + * > + * @decommission: sev_snp_page_reclaim structure to be processed > + * @sev_ret: sev command return code > + * > + * Returns: > + * 0 if the sev successfully processed the command > + * -%ENODEV if the sev device is not available > + * -%ENOTSUPP if the sev does not support SEV > + * -%ETIMEDOUT if the sev command timed out > + * -%EIO if the sev returned a non-zero return code > + */ > +int snp_guest_page_reclaim(struct sev_data_snp_page_reclaim *data, int *error); > + > +/** > + * snp_guest_dbg_decrypt - perform SEV SNP_DBG_DECRYPT command > + * > + * @sev_ret: sev command return code > + * > + * Returns: > + * 0 if the sev successfully processed the command > + * -%ENODEV if the sev device is not available > + * -%ENOTSUPP if the sev does not support SEV > + * -%ETIMEDOUT if the sev command timed out > + * -%EIO if the sev returned a non-zero return code > + */ > +int snp_guest_dbg_decrypt(struct sev_data_snp_dbg *data, int *error); > + > + > void *psp_copy_user_blob(u64 uaddr, u32 len); > > #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ > @@ -887,6 +946,21 @@ sev_issue_cmd_external_user(struct file *filep, unsigned int id, void *data, int > > static inline void *psp_copy_user_blob(u64 __user uaddr, u32 len) { return ERR_PTR(-EINVAL); } > > +static inline int > +snp_guest_decommission(struct sev_data_snp_decommission *data, int *error) { return -ENODEV; } > + > +static inline int snp_guest_df_flush(int *error) { return -ENODEV; } > + > +static inline int snp_guest_page_reclaim(struct sev_data_snp_page_reclaim *data, int *error) > +{ > + return -ENODEV; > +} > + > +static inline int snp_guest_dbg_decrypt(struct sev_data_snp_dbg *data, int *error) > +{ > + return -ENODEV; > +} > + > #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ > > #endif /* __PSP_SEV_H__ */ > -- > 2.17.1 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK