From: Eric Biggers Date: Thu, 6 Dec 2018 04:53:00 +0000 (-0800) Subject: FROMGIT: dm crypt: log the encryption algorithm implementation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=505d1d4021d07216ad55406ff599cb1d6038cc78;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git FROMGIT: dm crypt: log the encryption algorithm implementation Log the encryption algorithm's driver name when a dm-crypt target is created. This will help people determine whether the expected implementation is being used. In some cases we've seen people do benchmarks and reject using encryption for performance reasons, when in fact they used a much slower implementation than was possible on the hardware. It can make an enormous difference; e.g., AES-XTS on ARM can be over 10x faster with the crypto extensions than without. It can also be useful to know if an implementation using an external crypto accelerator is being used instead of a software implementation. Example message: [ 29.307629] device-mapper: crypt: xts(aes) using implementation "xts-aes-ce" We've already found the similar message in fs/crypto/keyinfo.c to be very useful. Signed-off-by: Eric Biggers Signed-off-by: Mike Snitzer (cherry picked from commit 32bbca787931a371256ac51219a6e9c9dbc86960 https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next) Test: Verified that the message is logged when dm-crypt is used. Change-Id: I20857a5350266431924e177dea50418aeb95009d Signed-off-by: Eric Biggers --- diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index c60d29d09687..47b59682d9f6 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1893,6 +1893,13 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode) } } + /* + * dm-crypt performance can vary greatly depending on which crypto + * algorithm implementation is used. Help people debug performance + * problems by logging the ->cra_driver_name. + */ + DMINFO("%s using implementation \"%s\"", ciphermode, + crypto_skcipher_alg(any_tfm(cc))->base.cra_driver_name); return 0; } @@ -1911,6 +1918,8 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode) return err; } + DMINFO("%s using implementation \"%s\"", ciphermode, + crypto_aead_alg(any_tfm_aead(cc))->base.cra_driver_name); return 0; }