mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
cb77cb5abe
blk_keyslot_manager is misnamed because it doesn't necessarily manage keyslots. It actually does several different things: - Contains the crypto capabilities of the device. - Provides functions to control the inline encryption hardware. Originally these were just for programming/evicting keyslots; however, new functionality (hardware-wrapped keys) will require new functions here which are unrelated to keyslots. Moreover, device-mapper devices already (ab)use "keyslot_evict" to pass key eviction requests to their underlying devices even though device-mapper devices don't have any keyslots themselves (so it really should be "evict_key", not "keyslot_evict"). - Sometimes (but not always!) it manages keyslots. Originally it always did, but device-mapper devices don't have keyslots themselves, so they use a "passthrough keyslot manager" which doesn't actually manage keyslots. This hack works, but the terminology is unnatural. Also, some hardware doesn't have keyslots and thus also uses a "passthrough keyslot manager" (support for such hardware is yet to be upstreamed, but it will happen eventually). Let's stop having keyslot managers which don't actually manage keyslots. Instead, rename blk_keyslot_manager to blk_crypto_profile. This is a fairly big change, since for consistency it also has to update keyslot manager-related function names, variable names, and comments -- not just the actual struct name. However it's still a fairly straightforward change, as it doesn't change any actual functionality. Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC Reviewed-by: Mike Snitzer <snitzer@redhat.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20211018180453.40441-4-ebiggers@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* MMC crypto engine (inline encryption) support
|
|
*
|
|
* Copyright 2020 Google LLC
|
|
*/
|
|
|
|
#include <linux/blk-crypto.h>
|
|
#include <linux/mmc/host.h>
|
|
|
|
#include "core.h"
|
|
#include "crypto.h"
|
|
#include "queue.h"
|
|
|
|
void mmc_crypto_set_initial_state(struct mmc_host *host)
|
|
{
|
|
/* Reset might clear all keys, so reprogram all the keys. */
|
|
if (host->caps2 & MMC_CAP2_CRYPTO)
|
|
blk_crypto_reprogram_all_keys(&host->crypto_profile);
|
|
}
|
|
|
|
void mmc_crypto_setup_queue(struct request_queue *q, struct mmc_host *host)
|
|
{
|
|
if (host->caps2 & MMC_CAP2_CRYPTO)
|
|
blk_crypto_register(&host->crypto_profile, q);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
|
|
|
|
void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
|
|
{
|
|
struct request *req = mmc_queue_req_to_req(mqrq);
|
|
struct mmc_request *mrq = &mqrq->brq.mrq;
|
|
struct blk_crypto_keyslot *keyslot;
|
|
|
|
if (!req->crypt_ctx)
|
|
return;
|
|
|
|
mrq->crypto_ctx = req->crypt_ctx;
|
|
|
|
keyslot = req->crypt_keyslot;
|
|
if (keyslot)
|
|
mrq->crypto_key_slot = blk_crypto_keyslot_index(keyslot);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);
|