From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36FC0C07E96 for ; Thu, 8 Jul 2021 18:56:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B0CC661629 for ; Thu, 8 Jul 2021 18:56:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0CC661629 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 767806B0036; Thu, 8 Jul 2021 14:56:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 717966B005D; Thu, 8 Jul 2021 14:56:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569C76B006C; Thu, 8 Jul 2021 14:56:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0036.hostedemail.com [216.40.44.36]) by kanga.kvack.org (Postfix) with ESMTP id 232A46B0036 for ; Thu, 8 Jul 2021 14:56:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 54CD480A9AB6 for ; Thu, 8 Jul 2021 18:56:40 +0000 (UTC) X-FDA: 78340326960.29.6D68F7C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 4FC503000388 for ; Thu, 8 Jul 2021 18:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625770596; 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=1va5nv4AZF0iU5FnZEUJ2+LCm5h8PaUbvUsoxAiHxDY=; b=SnoPYTLQ2uxAUwAg0q7Z1p5+m/rGSe+DRm71vbsaEZIaRLOxwPE/ZUcnI/OdCLFmc7xjzB LSWieuRvIo58pZkq0aFkM23E3ArKEKZ3e9cVXL8JGp5rhd46LctdvoCaM7Bmf9Ptedcj93 3A3KiM/FZ25MEndxO/erXVqT/a2tZbQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-b-5JqyVVPG-OKpR-lNSz1w-1; Thu, 08 Jul 2021 14:56:35 -0400 X-MC-Unique: b-5JqyVVPG-OKpR-lNSz1w-1 Received: by mail-wm1-f70.google.com with SMTP id x6-20020a7bc2060000b0290218ad9a8d4aso1016469wmi.1 for ; Thu, 08 Jul 2021 11:56:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1va5nv4AZF0iU5FnZEUJ2+LCm5h8PaUbvUsoxAiHxDY=; b=U4RdDWqCE91sVZC+khxxY8+mYZT8mFrytbg423qZ+gQc+uO37++pps1xP71OL/mgm1 XPo19w2ayfhEO4kDF93vO7bw2MPB8GoL5UE6I2rSgmG1pSN1rDkZWRozmq9zKXz355dF gTnKBr+H7/C83gihoI2IF+vTHMtcVn2U7Xp4Vb7blyUS+zpkd8SAXgfQVCW5JXoX2sa2 JrPuHGlAQT5Tda1UAinAxC+UMwb4CCXx5eLHVyqrH3bZmu74AorgpqVxcTj8AQ603uZ3 JeIA1KKRicX24svVXrrhRcsSEG43/cmEtIeG/fwip9PL4m2EEC+Nen4rzBMxfr8Mka9V XRSg== X-Gm-Message-State: AOAM5315JbArtzuWfa7eA/8up00228SEbXNpSti2ZVFL0bEsHMtD9G2L 3aDcS4yUWIsnx9DhtRVG8HnbY9og/wE7Z73DIPm0gYuJt5lHv0/ovTfTO3I3kDgI6SYfkFzpSth FRuE37lNBUUY= X-Received: by 2002:a05:6000:1361:: with SMTP id q1mr35672332wrz.179.1625770594433; Thu, 08 Jul 2021 11:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhquME75eUWVHFrrZ+V9pwudJ25ehwm0sVcMEMSNcf4tH+Xhq/bHqTeFabCsx2g8CMjSfcTw== X-Received: by 2002:a05:6000:1361:: with SMTP id q1mr35672310wrz.179.1625770594307; Thu, 08 Jul 2021 11:56:34 -0700 (PDT) Received: from work-vm (cpc109021-salf6-2-0-cust453.10-2.cable.virginm.net. [82.29.237.198]) by smtp.gmail.com with ESMTPSA id o11sm10760305wmc.2.2021.07.08.11.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 11:56:33 -0700 (PDT) Date: Thu, 8 Jul 2021 19:56:31 +0100 From: "Dr. David Alan Gilbert" To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@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 , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part2 RFC v4 14/40] crypto:ccp: Provide APIs to issue SEV-SNP commands Message-ID: References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-15-brijesh.singh@amd.com> MIME-Version: 1.0 In-Reply-To: <20210707183616.5620-15-brijesh.singh@amd.com> User-Agent: Mutt/2.0.7 (2021-05-04) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SnoPYTLQ; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf03.hostedemail.com: domain of dgilbert@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=dgilbert@redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4FC503000388 X-Stat-Signature: whufcmzcj3ich8gdqdi8ensbs86ykir5 X-HE-Tag: 1625770597-186612 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: * 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 84c91bab00bd..ad9a0c8111e0 100644 > --- a/drivers/crypto/ccp/sev-dev.c > +++ b/drivers/crypto/ccp/sev-dev.c > @@ -1017,6 +1017,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 Weird wording. > + * -%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