lkml.org 
[lkml]   [2023]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v10 15/50] crypto: ccp: Provide API to issue SEV and SNP commands
    Date
    From: Brijesh Singh <brijesh.singh@amd.com>

    Make sev_do_cmd() a generic API interface for the hypervisor
    to issue commands to manage an SEV and SNP guest. The commands
    for SEV and SNP are defined in the SEV and SEV-SNP firmware
    specifications.

    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
    Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
    ---
    drivers/crypto/ccp/sev-dev.c | 3 ++-
    include/linux/psp-sev.h | 17 +++++++++++++++++
    2 files changed, 19 insertions(+), 1 deletion(-)

    diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
    index fae1fd45eccd..613b25f81498 100644
    --- a/drivers/crypto/ccp/sev-dev.c
    +++ b/drivers/crypto/ccp/sev-dev.c
    @@ -418,7 +418,7 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
    return ret;
    }

    -static int sev_do_cmd(int cmd, void *data, int *psp_ret)
    +int sev_do_cmd(int cmd, void *data, int *psp_ret)
    {
    int rc;

    @@ -428,6 +428,7 @@ static int sev_do_cmd(int cmd, void *data, int *psp_ret)

    return rc;
    }
    +EXPORT_SYMBOL_GPL(sev_do_cmd);

    static int __sev_init_locked(int *error)
    {
    diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
    index a7f92e74564d..61bb5849ebf2 100644
    --- a/include/linux/psp-sev.h
    +++ b/include/linux/psp-sev.h
    @@ -883,6 +883,20 @@ int sev_guest_df_flush(int *error);
    */
    int sev_guest_decommission(struct sev_data_decommission *data, int *error);

    +/**
    + * sev_do_cmd - perform SEV command
    + *
    + * @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
    + */
    +int sev_do_cmd(int cmd, void *data, int *psp_ret);
    +
    void *psp_copy_user_blob(u64 uaddr, u32 len);

    #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
    @@ -898,6 +912,9 @@ sev_guest_deactivate(struct sev_data_deactivate *data, int *error) { return -ENO
    static inline int
    sev_guest_decommission(struct sev_data_decommission *data, int *error) { return -ENODEV; }

    +static inline int
    +sev_do_cmd(int cmd, void *data, int *psp_ret) { return -ENODEV; }
    +
    static inline int
    sev_guest_activate(struct sev_data_activate *data, int *error) { return -ENODEV; }

    --
    2.25.1
    \
     
     \ /
      Last update: 2023-10-16 15:33    [W:4.073 / U:0.468 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site