From: Tom Lendacky <thomas.lendacky@amd.com>
To: Dionna Glaze <dionnaglaze@google.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Ashish Kalra <ashish.kalra@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-coco@lists.linux.dev, Michael Roth <michael.roth@amd.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Russ Weight <russ.weight@linux.dev>,
Danilo Krummrich <dakr@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Tianfei zhang <tianfei.zhang@intel.com>,
Alexey Kardashevskiy <aik@amd.com>,
kvm@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v5 08/10] KVM: SVM: move sev_issue_cmd_external_user to new API
Date: Tue, 12 Nov 2024 09:52:07 -0600 [thread overview]
Message-ID: <d49430ec-8701-72c1-36ab-4d9e612ac443@amd.com> (raw)
In-Reply-To: <20241107232457.4059785-9-dionnaglaze@google.com>
On 11/7/24 17:24, Dionna Glaze wrote:
> ccp now prefers all calls from external drivers to dominate all calls
> into the driver on behalf of a user with a successful
> sev_check_external_user call.
Would it be simpler to have the new APIs take an fd for an argument,
instead of doing this rework?
Thanks,
Tom
>
> CC: Sean Christopherson <seanjc@google.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Borislav Petkov <bp@alien8.de>
> CC: Dave Hansen <dave.hansen@linux.intel.com>
> CC: Ashish Kalra <ashish.kalra@amd.com>
> CC: Tom Lendacky <thomas.lendacky@amd.com>
> CC: John Allen <john.allen@amd.com>
> CC: Herbert Xu <herbert@gondor.apana.org.au>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Michael Roth <michael.roth@amd.com>
> CC: Luis Chamberlain <mcgrof@kernel.org>
> CC: Russ Weight <russ.weight@linux.dev>
> CC: Danilo Krummrich <dakr@redhat.com>
> CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> CC: "Rafael J. Wysocki" <rafael@kernel.org>
> CC: Tianfei zhang <tianfei.zhang@intel.com>
> CC: Alexey Kardashevskiy <aik@amd.com>
>
> Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
> ---
> arch/x86/kvm/svm/sev.c | 18 +++++++++++++++---
> drivers/crypto/ccp/sev-dev.c | 12 ------------
> include/linux/psp-sev.h | 27 ---------------------------
> 3 files changed, 15 insertions(+), 42 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index d0e0152aefb32..cea41b8cdabe4 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -528,21 +528,33 @@ static int sev_bind_asid(struct kvm *kvm, unsigned int handle, int *error)
> return ret;
> }
>
> -static int __sev_issue_cmd(int fd, int id, void *data, int *error)
> +static int sev_check_external_user(int fd)
> {
> struct fd f;
> - int ret;
> + int ret = 0;
>
> f = fdget(fd);
> if (!fd_file(f))
> return -EBADF;
>
> - ret = sev_issue_cmd_external_user(fd_file(f), id, data, error);
> + if (!file_is_sev(fd_file(f)))
> + ret = -EBADF;
>
> fdput(f);
> return ret;
> }
>
> +static int __sev_issue_cmd(int fd, int id, void *data, int *error)
> +{
> + int ret;
> +
> + ret = sev_check_external_user(fd);
> + if (ret)
> + return ret;
> +
> + return sev_do_cmd(id, data, error);
> +}
> +
> static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error)
> {
> struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index f92e6a222da8a..67f6425b7ed07 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -2493,18 +2493,6 @@ bool file_is_sev(struct file *p)
> }
> EXPORT_SYMBOL_GPL(file_is_sev);
>
> -int sev_issue_cmd_external_user(struct file *filep, unsigned int cmd,
> - void *data, int *error)
> -{
> - int rc = file_is_sev(filep) ? 0 : -EBADF;
> -
> - if (rc)
> - return rc;
> -
> - return sev_do_cmd(cmd, data, error);
> -}
> -EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user);
> -
> void sev_pci_init(void)
> {
> struct sev_device *sev = psp_master->sev_data;
> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
> index ed85c0cfcfcbe..b4164d3600702 100644
> --- a/include/linux/psp-sev.h
> +++ b/include/linux/psp-sev.h
> @@ -860,30 +860,6 @@ int sev_platform_init(struct sev_platform_init_args *args);
> */
> int sev_platform_status(struct sev_user_data_status *status, int *error);
>
> -/**
> - * sev_issue_cmd_external_user - issue SEV command by other driver with a file
> - * handle.
> - *
> - * This function can be used by other drivers to issue a SEV command on
> - * behalf of userspace. The caller must pass a valid SEV file descriptor
> - * so that we know that it has access to SEV device.
> - *
> - * @filep - SEV device file pointer
> - * @cmd - command to issue
> - * @data - command buffer
> - * @error: 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
> - * -%EBADF if the file pointer is bad or does not grant access
> - */
> -int sev_issue_cmd_external_user(struct file *filep, unsigned int id,
> - void *data, int *error);
> -
> /**
> * file_is_sev - returns whether a file pointer is for the SEV device
> *
> @@ -1043,9 +1019,6 @@ sev_guest_activate(struct sev_data_activate *data, int *error) { return -ENODEV;
>
> static inline int sev_guest_df_flush(int *error) { return -ENODEV; }
>
> -static inline int
> -sev_issue_cmd_external_user(struct file *filep, unsigned int id, void *data, int *error) { return -ENODEV; }
> -
> static inline bool file_is_sev(struct file *filep) { return false; }
>
> static inline void *psp_copy_user_blob(u64 __user uaddr, u32 len) { return ERR_PTR(-EINVAL); }
next prev parent reply other threads:[~2024-11-12 15:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241107232457.4059785-1-dionnaglaze@google.com>
2024-11-07 23:24 ` [PATCH v5 04/10] crypto: ccp: Fix uapi definitions of PSP errors Dionna Glaze
2024-11-08 16:14 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-07 23:24 ` [PATCH v5 05/10] crypto: ccp: Add GCTX API to track ASID assignment Dionna Glaze
2024-11-08 17:24 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-11 17:13 ` Tom Lendacky
2024-11-11 21:16 ` Kalra, Ashish
2024-11-11 21:35 ` Dionna Amalie Glaze
2024-11-11 21:48 ` Kalra, Ashish
2024-11-07 23:24 ` [PATCH v5 06/10] crypto: ccp: Add DOWNLOAD_FIRMWARE_EX support Dionna Glaze
2024-11-08 15:42 ` Dionna Amalie Glaze
2024-11-08 17:44 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-11 22:10 ` Kalra, Ashish
2024-11-11 22:37 ` Dionna Amalie Glaze
2024-11-07 23:24 ` [PATCH v5 07/10] crypto: ccp: Add preferred access checking method Dionna Glaze
2024-11-11 22:46 ` Tom Lendacky
2024-11-12 19:47 ` Dionna Amalie Glaze
2024-11-12 21:08 ` Tom Lendacky
2024-11-07 23:24 ` [PATCH v5 08/10] KVM: SVM: move sev_issue_cmd_external_user to new API Dionna Glaze
2024-11-12 15:52 ` Tom Lendacky [this message]
2024-11-12 19:30 ` Dionna Amalie Glaze
2024-11-12 22:06 ` Tom Lendacky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d49430ec-8701-72c1-36ab-4d9e612ac443@amd.com \
--to=thomas.lendacky@amd.com \
--cc=aik@amd.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dakr@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dionnaglaze@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rafael@kernel.org \
--cc=russ.weight@linux.dev \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=tianfei.zhang@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox