Added required changes to fit properly android-4.19.79-95 crypto content into msm-4.19 branch. Modifications in abi_gki_aarch64.xml are discarded completely. The order of applying is bottom to top:1f876610feANDROID: dm: Add wrapped key support in dm-default-keyb785dbcb87ANDROID: dm: add support for passing through derive_raw_secret66b3c81270ANDROID: block: Prevent crypto fallback for wrapped keys36500bffb9fscrypt: support passing a keyring key to FS_IOC_ADD_ENCRYPTION_KEYb32863f17fANDROID: dm: add dm-default-key target for metadata encryption94706caf62ANDROID: dm: enable may_passthrough_inline_crypto on some targets44e1174c18ANDROID: dm: add support for passing through inline crypto supporte65d08ae68ANDROID: block: Introduce passthrough keyslot manager8f48f6657dANDROID: ext4, f2fs: enable direct I/O with inline encryptionbbee78199fFROMLIST: scsi: ufs: add program_key() variant op0f1c72a2f5ANDROID: block: export symbols needed for modules to use inline crypto35b62551b9ANDROID: block: fix some inline crypto bugs23b81578bfANDROID: fscrypt: add support for hardware-wrapped keysa076eebee0ANDROID: block: add KSM op to derive software secret from wrapped key3e8c41805fANDROID: block: provide key size as input to inline crypto APIsbb7f6203fbANDROID: ufshcd-crypto: export cap find APIb01c73ea71BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series Change-Id: Ic741913aa478500da94a52eace02bb9192e581b9 Git-repo: https://android.googlesource.com/kernel/common/+/refs/heads/android-4.19 Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org> Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
168 lines
4.1 KiB
C
168 lines
4.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright 2019 Google LLC
|
|
*/
|
|
|
|
#ifndef _UFSHCD_CRYPTO_H
|
|
#define _UFSHCD_CRYPTO_H
|
|
|
|
#ifdef CONFIG_SCSI_UFS_CRYPTO
|
|
#include <linux/keyslot-manager.h>
|
|
#include "ufshcd.h"
|
|
#include "ufshci.h"
|
|
|
|
static inline int ufshcd_num_keyslots(struct ufs_hba *hba)
|
|
{
|
|
return hba->crypto_capabilities.config_count + 1;
|
|
}
|
|
|
|
static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba, unsigned int slot)
|
|
{
|
|
/*
|
|
* The actual number of configurations supported is (CFGC+1), so slot
|
|
* numbers range from 0 to config_count inclusive.
|
|
*/
|
|
return slot < ufshcd_num_keyslots(hba);
|
|
}
|
|
|
|
static inline bool ufshcd_hba_is_crypto_supported(struct ufs_hba *hba)
|
|
{
|
|
return hba->crypto_capabilities.reg_val != 0;
|
|
}
|
|
|
|
static inline bool ufshcd_is_crypto_enabled(struct ufs_hba *hba)
|
|
{
|
|
return hba->caps & UFSHCD_CAP_CRYPTO;
|
|
}
|
|
|
|
/* Functions implementing UFSHCI v2.1 specification behaviour */
|
|
int ufshcd_crypto_cap_find(struct ufs_hba *hba,
|
|
enum blk_crypto_mode_num crypto_mode,
|
|
unsigned int data_unit_size);
|
|
|
|
int ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba,
|
|
struct scsi_cmnd *cmd,
|
|
struct ufshcd_lrb *lrbp);
|
|
|
|
void ufshcd_crypto_enable_spec(struct ufs_hba *hba);
|
|
|
|
void ufshcd_crypto_disable_spec(struct ufs_hba *hba);
|
|
|
|
struct keyslot_mgmt_ll_ops;
|
|
int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
|
|
const struct keyslot_mgmt_ll_ops *ksm_ops);
|
|
|
|
void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba,
|
|
struct request_queue *q);
|
|
|
|
void ufshcd_crypto_destroy_rq_keyslot_manager_spec(struct ufs_hba *hba,
|
|
struct request_queue *q);
|
|
|
|
static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp)
|
|
{
|
|
return lrbp->crypto_enable;
|
|
}
|
|
|
|
/* Crypto Variant Ops Support */
|
|
void ufshcd_crypto_enable(struct ufs_hba *hba);
|
|
|
|
void ufshcd_crypto_disable(struct ufs_hba *hba);
|
|
|
|
int ufshcd_hba_init_crypto(struct ufs_hba *hba);
|
|
|
|
void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q);
|
|
|
|
void ufshcd_crypto_destroy_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q);
|
|
|
|
int ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
|
|
struct scsi_cmnd *cmd,
|
|
struct ufshcd_lrb *lrbp);
|
|
|
|
int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
|
|
struct scsi_cmnd *cmd,
|
|
struct ufshcd_lrb *lrbp);
|
|
|
|
void ufshcd_crypto_debug(struct ufs_hba *hba);
|
|
|
|
int ufshcd_crypto_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op);
|
|
|
|
int ufshcd_crypto_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op);
|
|
|
|
void ufshcd_crypto_set_vops(struct ufs_hba *hba,
|
|
struct ufs_hba_crypto_variant_ops *crypto_vops);
|
|
|
|
#else /* CONFIG_SCSI_UFS_CRYPTO */
|
|
|
|
static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba,
|
|
unsigned int slot)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool ufshcd_hba_is_crypto_supported(struct ufs_hba *hba)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool ufshcd_is_crypto_enabled(struct ufs_hba *hba)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline void ufshcd_crypto_enable(struct ufs_hba *hba) { }
|
|
|
|
static inline void ufshcd_crypto_disable(struct ufs_hba *hba) { }
|
|
|
|
static inline int ufshcd_hba_init_crypto(struct ufs_hba *hba)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q) { }
|
|
|
|
static inline void ufshcd_crypto_destroy_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q) { }
|
|
|
|
static inline int ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
|
|
struct scsi_cmnd *cmd,
|
|
struct ufshcd_lrb *lrbp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
|
|
struct scsi_cmnd *cmd,
|
|
struct ufshcd_lrb *lrbp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void ufshcd_crypto_debug(struct ufs_hba *hba) { }
|
|
|
|
static inline int ufshcd_crypto_suspend(struct ufs_hba *hba,
|
|
enum ufs_pm_op pm_op)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int ufshcd_crypto_resume(struct ufs_hba *hba,
|
|
enum ufs_pm_op pm_op)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void ufshcd_crypto_set_vops(struct ufs_hba *hba,
|
|
struct ufs_hba_crypto_variant_ops *crypto_vops) { }
|
|
|
|
#endif /* CONFIG_SCSI_UFS_CRYPTO */
|
|
|
|
#endif /* _UFSHCD_CRYPTO_H */
|