diff --git a/Documentation/devicetree/bindings/power/supply/overheat_mitigation.txt b/Documentation/devicetree/bindings/power/supply/overheat_mitigation.txt deleted file mode 100644 index af66a5a09880..000000000000 --- a/Documentation/devicetree/bindings/power/supply/overheat_mitigation.txt +++ /dev/null @@ -1,19 +0,0 @@ -google,overheat_mitigation -~~~~~~~~~~~~~~ - -Required properties: - - compatible : "google,overheat_mitigation" - - google,begin-mitigation-temp: USB port temperature threshold in decidegrees - Celsius at which to begin overheat mitigation - - google,end-mitigation-temp: USB port temperature threshold in decidegrees - Celsius at which to end overheat mitigation - - google,port-overheat-work-interval: period in milliseconds at which the - driver should monitor the overheat status - - google,polling-freq: the frequency at which the USB connected status should - be polled (ex. if this is set to 3, check USB status every 3rd work - interval) - -Optional properties: - - google,accessory-monitoring-period: the length of time in seconds that the - driver should monitor USB port temperature after a USB accessory is plugged - in diff --git a/arch/arm64/boot/dts/qcom/pm8150.dtsi b/arch/arm64/boot/dts/qcom/pm8150.dtsi index e6e5f4bacd44..d6b8eb94dd94 100644 --- a/arch/arm64/boot/dts/qcom/pm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150.dtsi @@ -47,9 +47,8 @@ <0x0 0x8 0x5 IRQ_TYPE_NONE>; interrupt-names = "kpdpwr", "resin", "resin-bark", "kpdpwr-resin-bark"; - qcom,pon-dbc-delay = <62>; - qcom,pon-sw-dbc-delay = <15500>; - qcom,pon-sw-debounce; + qcom,pon-dbc-delay = <62500>; + qcom,kpdpwr-sw-debounce; qcom,system-reset; qcom,store-hard-reset-reason; diff --git a/arch/arm64/configs/cuttlefish_defconfig b/arch/arm64/configs/cuttlefish_defconfig index 0efc89923262..d20d61ce5c89 100644 --- a/arch/arm64/configs/cuttlefish_defconfig +++ b/arch/arm64/configs/cuttlefish_defconfig @@ -483,6 +483,7 @@ CONFIG_SECURITY_SELINUX=y CONFIG_INIT_STACK_ALL_ZERO=y CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y CONFIG_CRYPTO_ADIANTUM=y +CONFIG_CRYPTO_BLAKE2B=y CONFIG_CRYPTO_LZ4=y CONFIG_CRYPTO_ANSI_CPRNG=y # CONFIG_CRYPTO_DEV_VIRTIO is not set diff --git a/arch/arm64/configs/raphael_defconfig b/arch/arm64/configs/raphael_defconfig index 80cf48d36b06..f15cfe75ed94 100644 --- a/arch/arm64/configs/raphael_defconfig +++ b/arch/arm64/configs/raphael_defconfig @@ -480,7 +480,6 @@ CONFIG_PINCTRL_QCOM_SPMI_PMIC=y CONFIG_PINCTRL_SM8150=y CONFIG_GPIO_SYSFS=y CONFIG_POWER_RESET_QCOM=y -CONFIG_USB_OVERHEAT_MITIGATION=y CONFIG_QCOM_DLOAD_MODE=y CONFIG_QPNP_FG_GEN4=y CONFIG_QPNP_SMB5=y @@ -500,7 +499,6 @@ CONFIG_QTI_AOP_REG_COOLING_DEVICE=y CONFIG_QTI_QMI_COOLING_DEVICE=y CONFIG_QTI_QMI_SENSOR=y CONFIG_REGULATOR_COOLING_DEVICE=y -CONFIG_THERMAL_EMULATION=y CONFIG_QTI_BCL_PMIC5=y CONFIG_QTI_BCL_SOC_DRIVER=y CONFIG_QTI_ADC_TM=y @@ -885,6 +883,7 @@ CONFIG_STATIC_USERMODEHELPER=y CONFIG_STATIC_USERMODEHELPER_PATH="" CONFIG_SECURITY_SELINUX=y CONFIG_CRYPTO_GCM=y +CONFIG_CRYPTO_BLAKE2B=y CONFIG_CRYPTO_CHACHA20POLY1305=y CONFIG_CRYPTO_XCBC=y CONFIG_CRYPTO_TWOFISH=y diff --git a/arch/x86/configs/x86_64_cuttlefish_defconfig b/arch/x86/configs/x86_64_cuttlefish_defconfig index d56cc2d5bd5e..6349f2fb92d0 100644 --- a/arch/x86/configs/x86_64_cuttlefish_defconfig +++ b/arch/x86/configs/x86_64_cuttlefish_defconfig @@ -518,6 +518,7 @@ CONFIG_INIT_STACK_ALL_ZERO=y CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y # CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set CONFIG_CRYPTO_ADIANTUM=y +CONFIG_CRYPTO_BLAKE2B=y CONFIG_CRYPTO_AES_NI_INTEL=y CONFIG_CRYPTO_LZ4=y # CONFIG_CRYPTO_DEV_VIRTIO is not set diff --git a/crypto/Kconfig b/crypto/Kconfig index ebe475134edc..4ccd56a0b89c 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -533,30 +533,23 @@ config CRYPTO_CRC32_PCLMUL which will enable any routine to use the CRC-32-IEEE 802.3 checksum and gain better performance as compared with the table implementation. -config CRYPTO_BLAKE2S - tristate "BLAKE2s digest algorithm" - select CRYPTO_LIB_BLAKE2S_GENERIC +config CRYPTO_BLAKE2B + tristate "BLAKE2b digest algorithm" select CRYPTO_HASH help - Implementation of cryptographic hash function BLAKE2s - optimized for 8-32bit platforms and can produce digests of any size - between 1 to 32. The keyed hash is also implemented. + Implementation of cryptographic hash function BLAKE2b (or just BLAKE2), + optimized for 64bit platforms and can produce digests of any size + between 1 to 64. The keyed hash is also implemented. This module provides the following algorithms: - - blake2s-128 - - blake2s-160 - - blake2s-224 - - blake2s-256 + - blake2b-160 + - blake2b-256 + - blake2b-384 + - blake2b-512 See https://blake2.net for further information. -config CRYPTO_BLAKE2S_X86 - tristate "BLAKE2s digest algorithm (x86 accelerated version)" - depends on X86 && 64BIT - select CRYPTO_LIB_BLAKE2S_GENERIC - select CRYPTO_ARCH_HAVE_LIB_BLAKE2S - config CRYPTO_CRCT10DIF tristate "CRCT10DIF algorithm" select CRYPTO_HASH diff --git a/crypto/Makefile b/crypto/Makefile index 1f2bd75ae200..9f9d02855dce 100644 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -76,7 +76,7 @@ obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o obj-$(CONFIG_CRYPTO_WP512) += wp512.o CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149 obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o -obj-$(CONFIG_CRYPTO_BLAKE2S) += blake2s_generic.o +obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o obj-$(CONFIG_CRYPTO_ECB) += ecb.o obj-$(CONFIG_CRYPTO_CBC) += cbc.o diff --git a/crypto/blake2b_generic.c b/crypto/blake2b_generic.c new file mode 100644 index 000000000000..2f15a9725054 --- /dev/null +++ b/crypto/blake2b_generic.c @@ -0,0 +1,322 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR Apache-2.0) +/* + * BLAKE2b reference source code package - reference C implementations + * + * Copyright 2012, Samuel Neves . You may use this under the + * terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at + * your option. The terms of these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - OpenSSL license : https://www.openssl.org/source/license.html + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * More information about the BLAKE2 hash function can be found at + * https://blake2.net. + * + * Note: the original sources have been modified for inclusion in linux kernel + * in terms of coding style, using generic helpers and simplifications of error + * handling. + */ + +#include +#include +#include +#include +#include +#include + +#define BLAKE2B_160_DIGEST_SIZE (160 / 8) +#define BLAKE2B_256_DIGEST_SIZE (256 / 8) +#define BLAKE2B_384_DIGEST_SIZE (384 / 8) +#define BLAKE2B_512_DIGEST_SIZE (512 / 8) + +enum blake2b_constant { + BLAKE2B_BLOCKBYTES = 128, + BLAKE2B_KEYBYTES = 64, +}; + +struct blake2b_state { + u64 h[8]; + u64 t[2]; + u64 f[2]; + u8 buf[BLAKE2B_BLOCKBYTES]; + size_t buflen; +}; + +static const u64 blake2b_IV[8] = { + 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL +}; + +static const u8 blake2b_sigma[12][16] = { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, + { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, + { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, + { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, + { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, + { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, + { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, + { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, + { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, + { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, + { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } +}; + +static void blake2b_increment_counter(struct blake2b_state *S, const u64 inc) +{ + S->t[0] += inc; + S->t[1] += (S->t[0] < inc); +} + +#define G(r,i,a,b,c,d) \ + do { \ + a = a + b + m[blake2b_sigma[r][2*i+0]]; \ + d = ror64(d ^ a, 32); \ + c = c + d; \ + b = ror64(b ^ c, 24); \ + a = a + b + m[blake2b_sigma[r][2*i+1]]; \ + d = ror64(d ^ a, 16); \ + c = c + d; \ + b = ror64(b ^ c, 63); \ + } while (0) + +#define ROUND(r) \ + do { \ + G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \ + G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \ + G(r,2,v[ 2],v[ 6],v[10],v[14]); \ + G(r,3,v[ 3],v[ 7],v[11],v[15]); \ + G(r,4,v[ 0],v[ 5],v[10],v[15]); \ + G(r,5,v[ 1],v[ 6],v[11],v[12]); \ + G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \ + G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \ + } while (0) + +static void blake2b_compress(struct blake2b_state *S, + const u8 block[BLAKE2B_BLOCKBYTES]) +{ + u64 m[16]; + u64 v[16]; + size_t i; + + for (i = 0; i < 16; ++i) + m[i] = get_unaligned_le64(block + i * sizeof(m[i])); + + for (i = 0; i < 8; ++i) + v[i] = S->h[i]; + + v[ 8] = blake2b_IV[0]; + v[ 9] = blake2b_IV[1]; + v[10] = blake2b_IV[2]; + v[11] = blake2b_IV[3]; + v[12] = blake2b_IV[4] ^ S->t[0]; + v[13] = blake2b_IV[5] ^ S->t[1]; + v[14] = blake2b_IV[6] ^ S->f[0]; + v[15] = blake2b_IV[7] ^ S->f[1]; + + ROUND(0); + ROUND(1); + ROUND(2); + ROUND(3); + ROUND(4); + ROUND(5); + ROUND(6); + ROUND(7); + ROUND(8); + ROUND(9); + ROUND(10); + ROUND(11); +#ifdef CONFIG_CC_IS_CLANG +#pragma nounroll /* https://bugs.llvm.org/show_bug.cgi?id=45803 */ +#endif + for (i = 0; i < 8; ++i) + S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; +} + +#undef G +#undef ROUND + +struct blake2b_tfm_ctx { + u8 key[BLAKE2B_KEYBYTES]; + unsigned int keylen; +}; + +static int blake2b_setkey(struct crypto_shash *tfm, const u8 *key, + unsigned int keylen) +{ + struct blake2b_tfm_ctx *tctx = crypto_shash_ctx(tfm); + + if (keylen == 0 || keylen > BLAKE2B_KEYBYTES) { + crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + + memcpy(tctx->key, key, keylen); + tctx->keylen = keylen; + + return 0; +} + +static int blake2b_init(struct shash_desc *desc) +{ + struct blake2b_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); + struct blake2b_state *state = shash_desc_ctx(desc); + const int digestsize = crypto_shash_digestsize(desc->tfm); + + memset(state, 0, sizeof(*state)); + memcpy(state->h, blake2b_IV, sizeof(state->h)); + + /* Parameter block is all zeros except index 0, no xor for 1..7 */ + state->h[0] ^= 0x01010000 | tctx->keylen << 8 | digestsize; + + if (tctx->keylen) { + /* + * Prefill the buffer with the key, next call to _update or + * _final will process it + */ + memcpy(state->buf, tctx->key, tctx->keylen); + state->buflen = BLAKE2B_BLOCKBYTES; + } + return 0; +} + +static int blake2b_update(struct shash_desc *desc, const u8 *in, + unsigned int inlen) +{ + struct blake2b_state *state = shash_desc_ctx(desc); + const size_t left = state->buflen; + const size_t fill = BLAKE2B_BLOCKBYTES - left; + + if (!inlen) + return 0; + + if (inlen > fill) { + state->buflen = 0; + /* Fill buffer */ + memcpy(state->buf + left, in, fill); + blake2b_increment_counter(state, BLAKE2B_BLOCKBYTES); + /* Compress */ + blake2b_compress(state, state->buf); + in += fill; + inlen -= fill; + while (inlen > BLAKE2B_BLOCKBYTES) { + blake2b_increment_counter(state, BLAKE2B_BLOCKBYTES); + blake2b_compress(state, in); + in += BLAKE2B_BLOCKBYTES; + inlen -= BLAKE2B_BLOCKBYTES; + } + } + memcpy(state->buf + state->buflen, in, inlen); + state->buflen += inlen; + + return 0; +} + +static int blake2b_final(struct shash_desc *desc, u8 *out) +{ + struct blake2b_state *state = shash_desc_ctx(desc); + const int digestsize = crypto_shash_digestsize(desc->tfm); + size_t i; + + blake2b_increment_counter(state, state->buflen); + /* Set last block */ + state->f[0] = (u64)-1; + /* Padding */ + memset(state->buf + state->buflen, 0, BLAKE2B_BLOCKBYTES - state->buflen); + blake2b_compress(state, state->buf); + + /* Avoid temporary buffer and switch the internal output to LE order */ + for (i = 0; i < ARRAY_SIZE(state->h); i++) + __cpu_to_le64s(&state->h[i]); + + memcpy(out, state->h, digestsize); + return 0; +} + +static struct shash_alg blake2b_algs[] = { + { + .base.cra_name = "blake2b-160", + .base.cra_driver_name = "blake2b-160-generic", + .base.cra_priority = 100, + .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, + .base.cra_blocksize = BLAKE2B_BLOCKBYTES, + .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), + .base.cra_module = THIS_MODULE, + .digestsize = BLAKE2B_160_DIGEST_SIZE, + .setkey = blake2b_setkey, + .init = blake2b_init, + .update = blake2b_update, + .final = blake2b_final, + .descsize = sizeof(struct blake2b_state), + }, { + .base.cra_name = "blake2b-256", + .base.cra_driver_name = "blake2b-256-generic", + .base.cra_priority = 100, + .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, + .base.cra_blocksize = BLAKE2B_BLOCKBYTES, + .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), + .base.cra_module = THIS_MODULE, + .digestsize = BLAKE2B_256_DIGEST_SIZE, + .setkey = blake2b_setkey, + .init = blake2b_init, + .update = blake2b_update, + .final = blake2b_final, + .descsize = sizeof(struct blake2b_state), + }, { + .base.cra_name = "blake2b-384", + .base.cra_driver_name = "blake2b-384-generic", + .base.cra_priority = 100, + .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, + .base.cra_blocksize = BLAKE2B_BLOCKBYTES, + .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), + .base.cra_module = THIS_MODULE, + .digestsize = BLAKE2B_384_DIGEST_SIZE, + .setkey = blake2b_setkey, + .init = blake2b_init, + .update = blake2b_update, + .final = blake2b_final, + .descsize = sizeof(struct blake2b_state), + }, { + .base.cra_name = "blake2b-512", + .base.cra_driver_name = "blake2b-512-generic", + .base.cra_priority = 100, + .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, + .base.cra_blocksize = BLAKE2B_BLOCKBYTES, + .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), + .base.cra_module = THIS_MODULE, + .digestsize = BLAKE2B_512_DIGEST_SIZE, + .setkey = blake2b_setkey, + .init = blake2b_init, + .update = blake2b_update, + .final = blake2b_final, + .descsize = sizeof(struct blake2b_state), + } +}; + +static int __init blake2b_mod_init(void) +{ + return crypto_register_shashes(blake2b_algs, ARRAY_SIZE(blake2b_algs)); +} + +static void __exit blake2b_mod_fini(void) +{ + crypto_unregister_shashes(blake2b_algs, ARRAY_SIZE(blake2b_algs)); +} + +subsys_initcall(blake2b_mod_init); +module_exit(blake2b_mod_fini); + +MODULE_AUTHOR("David Sterba "); +MODULE_DESCRIPTION("BLAKE2b generic implementation"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_CRYPTO("blake2b-160"); +MODULE_ALIAS_CRYPTO("blake2b-160-generic"); +MODULE_ALIAS_CRYPTO("blake2b-256"); +MODULE_ALIAS_CRYPTO("blake2b-256-generic"); +MODULE_ALIAS_CRYPTO("blake2b-384"); +MODULE_ALIAS_CRYPTO("blake2b-384-generic"); +MODULE_ALIAS_CRYPTO("blake2b-512"); +MODULE_ALIAS_CRYPTO("blake2b-512-generic"); diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6101b24daf95..870ac523bec8 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1807,8 +1807,9 @@ static int alg_test_comp(const struct alg_test_desc *desc, const char *driver, return err; } -static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, - u32 type, u32 mask) +static int __alg_test_hash(const struct hash_testvec *template, + unsigned int tcount, const char *driver, + u32 type, u32 mask) { struct crypto_ahash *tfm; int err; @@ -1820,16 +1821,51 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, return PTR_ERR(tfm); } - err = test_hash(tfm, desc->suite.hash.vecs, - desc->suite.hash.count, true); + err = test_hash(tfm, template, tcount, true); if (!err) - err = test_hash(tfm, desc->suite.hash.vecs, - desc->suite.hash.count, false); - + err = test_hash(tfm, template, tcount, false); crypto_free_ahash(tfm); return err; } +static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, + u32 type, u32 mask) +{ + const struct hash_testvec *template = desc->suite.hash.vecs; + unsigned int tcount = desc->suite.hash.count; + unsigned int nr_unkeyed, nr_keyed; + int err; + + /* + * For OPTIONAL_KEY algorithms, we have to do all the unkeyed tests + * first, before setting a key on the tfm. To make this easier, we + * require that the unkeyed test vectors (if any) are listed first. + */ + + for (nr_unkeyed = 0; nr_unkeyed < tcount; nr_unkeyed++) { + if (template[nr_unkeyed].ksize) + break; + } + for (nr_keyed = 0; nr_unkeyed + nr_keyed < tcount; nr_keyed++) { + if (!template[nr_unkeyed + nr_keyed].ksize) { + pr_err("alg: hash: test vectors for %s out of order, " + "unkeyed ones must come first\n", desc->alg); + return -EINVAL; + } + } + + err = 0; + if (nr_unkeyed) { + err = __alg_test_hash(template, nr_unkeyed, driver, type, mask); + template += nr_unkeyed; + } + + if (!err && nr_keyed) + err = __alg_test_hash(template, nr_keyed, driver, type, mask); + + return err; +} + static int alg_test_crc32c(const struct alg_test_desc *desc, const char *driver, u32 type, u32 mask) { @@ -2541,28 +2577,32 @@ static const struct alg_test_desc alg_test_descs[] = { .test = alg_test_null, .fips_allowed = 1, }, { - .alg = "blake2s-128", + .alg = "blake2b-160", .test = alg_test_hash, + .fips_allowed = 0, .suite = { - .hash = __VECS(blakes2s_128_tv_template) + .hash = __VECS(blake2b_160_tv_template) } }, { - .alg = "blake2s-160", + .alg = "blake2b-256", .test = alg_test_hash, + .fips_allowed = 0, .suite = { - .hash = __VECS(blakes2s_160_tv_template) + .hash = __VECS(blake2b_256_tv_template) } }, { - .alg = "blake2s-224", + .alg = "blake2b-384", .test = alg_test_hash, + .fips_allowed = 0, .suite = { - .hash = __VECS(blakes2s_224_tv_template) + .hash = __VECS(blake2b_384_tv_template) } }, { - .alg = "blake2s-256", + .alg = "blake2b-512", .test = alg_test_hash, + .fips_allowed = 0, .suite = { - .hash = __VECS(blakes2s_256_tv_template) + .hash = __VECS(blake2b_512_tv_template) } }, { .alg = "cbc(aes)", diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 19e3830bad28..d6f2a3d6245d 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -39481,8 +39481,8 @@ static const struct comp_testvec zstd_decomp_tv_template[] = { "functions.", }, }; - -static const char blake2_ordered_sequence[] = + +static const char blake2b_ordered_sequence[] = "\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" "\x10\x11\x12\x13\x14\x15\x16\x17" @@ -39516,221 +39516,277 @@ static const char blake2_ordered_sequence[] = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"; -static const struct hash_testvec blakes2s_128_tv_template[] = {{ - .digest = (u8[]){ 0x64, 0x55, 0x0d, 0x6f, 0xfe, 0x2c, 0x0a, 0x01, - 0xa1, 0x4a, 0xba, 0x1e, 0xad, 0xe0, 0x20, 0x0c, }, +static const struct hash_testvec blake2b_160_tv_template[] = {{ + .digest = (u8[]){ 0x33, 0x45, 0x52, 0x4a, 0xbf, 0x6b, 0xbe, 0x18, + 0x09, 0x44, 0x92, 0x24, 0xb5, 0x97, 0x2c, 0x41, + 0x79, 0x0b, 0x6c, 0xf2, }, }, { - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 64, - .digest = (u8[]){ 0xdc, 0x66, 0xca, 0x8f, 0x03, 0x86, 0x58, 0x01, - 0xb0, 0xff, 0xe0, 0x6e, 0xd8, 0xa1, 0xa9, 0x0e, }, + .digest = (u8[]){ 0x11, 0xcc, 0x66, 0x61, 0xe9, 0x22, 0xb0, 0xe4, + 0x07, 0xe0, 0xa5, 0x72, 0x49, 0xc3, 0x8d, 0x4f, + 0xf7, 0x6d, 0x8e, 0xc8, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 1, - .digest = (u8[]){ 0x88, 0x1e, 0x42, 0xe7, 0xbb, 0x35, 0x80, 0x82, - 0x63, 0x7c, 0x0a, 0x0f, 0xd7, 0xec, 0x6c, 0x2f, }, + .digest = (u8[]){ 0x31, 0xe3, 0xd9, 0xd5, 0x4e, 0x72, 0xd8, 0x0b, + 0x2b, 0x3b, 0xd7, 0x6b, 0x82, 0x7a, 0x1d, 0xfb, + 0x56, 0x2f, 0x79, 0x4c, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 7, - .digest = (u8[]){ 0xcf, 0x9e, 0x07, 0x2a, 0xd5, 0x22, 0xf2, 0xcd, - 0xa2, 0xd8, 0x25, 0x21, 0x80, 0x86, 0x73, 0x1c, }, + .digest = (u8[]){ 0x28, 0x20, 0xd1, 0xbe, 0x7f, 0xcc, 0xc1, 0x62, + 0xd9, 0x0d, 0x9a, 0x4b, 0x47, 0xd1, 0x5e, 0x04, + 0x74, 0x2a, 0x53, 0x17, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 15, - .digest = (u8[]){ 0xf6, 0x33, 0x5a, 0x2c, 0x22, 0xa0, 0x64, 0xb2, - 0xb6, 0x3f, 0xeb, 0xbc, 0xd1, 0xc3, 0xe5, 0xb2, }, + .digest = (u8[]){ 0x45, 0xe9, 0x95, 0xb6, 0xc4, 0xe8, 0x22, 0xea, + 0xfe, 0xd2, 0x37, 0xdb, 0x46, 0xbf, 0xf1, 0x25, + 0xd5, 0x03, 0x1d, 0x81, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 247, - .digest = (u8[]){ 0x72, 0x66, 0x49, 0x60, 0xf9, 0x4a, 0xea, 0xbe, - 0x1f, 0xf4, 0x60, 0xce, 0xb7, 0x81, 0xcb, 0x09, }, + .digest = (u8[]){ 0x7e, 0xb9, 0xf2, 0x9b, 0x2f, 0xc2, 0x01, 0xd4, + 0xb0, 0x4f, 0x08, 0x2b, 0x8e, 0xbd, 0x06, 0xef, + 0x1c, 0xc4, 0x25, 0x95, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 256, - .digest = (u8[]){ 0xd5, 0xa4, 0x0e, 0xc3, 0x16, 0xc7, 0x51, 0xa6, - 0x3c, 0xd0, 0xd9, 0x11, 0x57, 0xfa, 0x1e, 0xbb, }, + .digest = (u8[]){ 0x6e, 0x35, 0x01, 0x70, 0xbf, 0xb6, 0xc4, 0xba, + 0x33, 0x1b, 0xa6, 0xd3, 0xc2, 0x5d, 0xb4, 0x03, + 0x95, 0xaf, 0x29, 0x16, }, }}; -static const struct hash_testvec blakes2s_160_tv_template[] = {{ - .plaintext = blake2_ordered_sequence, +static const struct hash_testvec blake2b_256_tv_template[] = {{ + .plaintext = blake2b_ordered_sequence, .psize = 7, - .digest = (u8[]){ 0xb4, 0xf2, 0x03, 0x49, 0x37, 0xed, 0xb1, 0x3e, - 0x5b, 0x2a, 0xca, 0x64, 0x82, 0x74, 0xf6, 0x62, - 0xe3, 0xf2, 0x84, 0xff, }, + .digest = (u8[]){ 0x9d, 0xf1, 0x4b, 0x72, 0x48, 0x76, 0x4a, 0x86, + 0x91, 0x97, 0xc3, 0x5e, 0x39, 0x2d, 0x2a, 0x6d, + 0x6f, 0xdc, 0x5b, 0x79, 0xd5, 0x97, 0x29, 0x79, + 0x20, 0xfd, 0x3f, 0x14, 0x91, 0xb4, 0x42, 0xd2, }, }, { - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 256, - .digest = (u8[]){ 0xaa, 0x56, 0x9b, 0xdc, 0x98, 0x17, 0x75, 0xf2, - 0xb3, 0x68, 0x83, 0xb7, 0x9b, 0x8d, 0x48, 0xb1, - 0x9b, 0x2d, 0x35, 0x05, }, + .digest = (u8[]){ 0x39, 0xa7, 0xeb, 0x9f, 0xed, 0xc1, 0x9a, 0xab, + 0xc8, 0x34, 0x25, 0xc6, 0x75, 0x5d, 0xd9, 0x0e, + 0x6f, 0x9d, 0x0c, 0x80, 0x49, 0x64, 0xa1, 0xf4, + 0xaa, 0xee, 0xa3, 0xb9, 0xfb, 0x59, 0x98, 0x35, }, }, { .ksize = 1, .key = "B", - .digest = (u8[]){ 0x50, 0x16, 0xe7, 0x0c, 0x01, 0xd0, 0xd3, 0xc3, - 0xf4, 0x3e, 0xb1, 0x6e, 0x97, 0xa9, 0x4e, 0xd1, - 0x79, 0x65, 0x32, 0x93, }, + .digest = (u8[]){ 0xc3, 0x08, 0xb1, 0xbf, 0xe4, 0xf9, 0xbc, 0xb4, + 0x75, 0xaf, 0x3f, 0x59, 0x6e, 0xae, 0xde, 0x6a, + 0xa3, 0x8e, 0xb5, 0x94, 0xad, 0x30, 0xf0, 0x17, + 0x1c, 0xfb, 0xd8, 0x3e, 0x8a, 0xbe, 0xed, 0x9c, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 1, - .digest = (u8[]){ 0x1c, 0x2b, 0xcd, 0x9a, 0x68, 0xca, 0x8c, 0x71, - 0x90, 0x29, 0x6c, 0x54, 0xfa, 0x56, 0x4a, 0xef, - 0xa2, 0x3a, 0x56, 0x9c, }, + .digest = (u8[]){ 0x34, 0x75, 0x8b, 0x64, 0x71, 0x35, 0x62, 0x82, + 0x97, 0xfb, 0x09, 0xc7, 0x93, 0x0c, 0xd0, 0x4e, + 0x95, 0x28, 0xe5, 0x66, 0x91, 0x12, 0xf5, 0xb1, + 0x31, 0x84, 0x93, 0xe1, 0x4d, 0xe7, 0x7e, 0x55, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 15, - .digest = (u8[]){ 0x36, 0xc3, 0x5f, 0x9a, 0xdc, 0x7e, 0xbf, 0x19, - 0x68, 0xaa, 0xca, 0xd8, 0x81, 0xbf, 0x09, 0x34, - 0x83, 0x39, 0x0f, 0x30, }, + .digest = (u8[]){ 0xce, 0x74, 0xa9, 0x2e, 0xe9, 0x40, 0x3d, 0xa2, + 0x11, 0x4a, 0x99, 0x25, 0x7a, 0x34, 0x5d, 0x35, + 0xdf, 0x6a, 0x48, 0x79, 0x2a, 0x93, 0x93, 0xff, + 0x1f, 0x3c, 0x39, 0xd0, 0x71, 0x1f, 0x20, 0x7b, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 64, - .digest = (u8[]){ 0x86, 0x80, 0x78, 0xa4, 0x14, 0xec, 0x03, 0xe5, - 0xb6, 0x9a, 0x52, 0x0e, 0x42, 0xee, 0x39, 0x9d, - 0xac, 0xa6, 0x81, 0x63, }, + .digest = (u8[]){ 0x2e, 0x84, 0xdb, 0xa2, 0x5f, 0x0e, 0xe9, 0x52, + 0x79, 0x50, 0x69, 0x9f, 0xf1, 0xfd, 0xfc, 0x9d, + 0x89, 0x83, 0xa9, 0xb6, 0xa4, 0xd5, 0xfa, 0xb5, + 0xbe, 0x35, 0x1a, 0x17, 0x8a, 0x2c, 0x7f, 0x7d, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 247, - .digest = (u8[]){ 0x2d, 0xd8, 0xd2, 0x53, 0x66, 0xfa, 0xa9, 0x01, - 0x1c, 0x9c, 0xaf, 0xa3, 0xe2, 0x9d, 0x9b, 0x10, - 0x0a, 0xf6, 0x73, 0xe8, }, + .digest = (u8[]){ 0x2e, 0x26, 0xf0, 0x09, 0x02, 0x65, 0x90, 0x09, + 0xcc, 0xf5, 0x4c, 0x44, 0x74, 0x0e, 0xa0, 0xa8, + 0x25, 0x4a, 0xda, 0x61, 0x56, 0x95, 0x7d, 0x3f, + 0x6d, 0xc0, 0x43, 0x17, 0x95, 0x89, 0xcd, 0x9d, }, }}; -static const struct hash_testvec blakes2s_224_tv_template[] = {{ - .plaintext = blake2_ordered_sequence, +static const struct hash_testvec blake2b_384_tv_template[] = {{ + .plaintext = blake2b_ordered_sequence, .psize = 1, - .digest = (u8[]){ 0x61, 0xb9, 0x4e, 0xc9, 0x46, 0x22, 0xa3, 0x91, - 0xd2, 0xae, 0x42, 0xe6, 0x45, 0x6c, 0x90, 0x12, - 0xd5, 0x80, 0x07, 0x97, 0xb8, 0x86, 0x5a, 0xfc, - 0x48, 0x21, 0x97, 0xbb, }, + .digest = (u8[]){ 0xcc, 0x01, 0x08, 0x85, 0x36, 0xf7, 0x84, 0xf0, + 0xbb, 0x76, 0x9e, 0x41, 0xc4, 0x95, 0x7b, 0x6d, + 0x0c, 0xde, 0x1f, 0xcc, 0x8c, 0xf1, 0xd9, 0x1f, + 0xc4, 0x77, 0xd4, 0xdd, 0x6e, 0x3f, 0xbf, 0xcd, + 0x43, 0xd1, 0x69, 0x8d, 0x14, 0x6f, 0x34, 0x8b, + 0x2c, 0x36, 0xa3, 0x39, 0x68, 0x2b, 0xec, 0x3f, }, }, { - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 247, - .digest = (u8[]){ 0x9e, 0xda, 0xc7, 0x20, 0x2c, 0xd8, 0x48, 0x2e, - 0x31, 0x94, 0xab, 0x46, 0x6d, 0x94, 0xd8, 0xb4, - 0x69, 0xcd, 0xae, 0x19, 0x6d, 0x9e, 0x41, 0xcc, - 0x2b, 0xa4, 0xd5, 0xf6, }, + .digest = (u8[]){ 0xc8, 0xf8, 0xf0, 0xa2, 0x69, 0xfa, 0xcc, 0x4d, + 0x32, 0x5f, 0x13, 0x88, 0xca, 0x71, 0x99, 0x8f, + 0xf7, 0x30, 0x41, 0x5d, 0x6e, 0x34, 0xb7, 0x6e, + 0x3e, 0xd0, 0x46, 0xb6, 0xca, 0x30, 0x66, 0xb2, + 0x6f, 0x0c, 0x35, 0x54, 0x17, 0xcd, 0x26, 0x1b, + 0xef, 0x48, 0x98, 0xe0, 0x56, 0x7c, 0x05, 0xd2, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .digest = (u8[]){ 0x32, 0xc0, 0xac, 0xf4, 0x3b, 0xd3, 0x07, 0x9f, - 0xbe, 0xfb, 0xfa, 0x4d, 0x6b, 0x4e, 0x56, 0xb3, - 0xaa, 0xd3, 0x27, 0xf6, 0x14, 0xbf, 0xb9, 0x32, - 0xa7, 0x19, 0xfc, 0xb8, }, + .ksize = 32, + .key = blake2b_ordered_sequence, + .digest = (u8[]){ 0x15, 0x09, 0x7a, 0x90, 0x13, 0x23, 0xab, 0x0c, + 0x0b, 0x43, 0x21, 0x9a, 0xb5, 0xc6, 0x0c, 0x2e, + 0x7c, 0x57, 0xfc, 0xcc, 0x4b, 0x0f, 0xf0, 0x57, + 0xb7, 0x9c, 0xe7, 0x0f, 0xe1, 0x57, 0xac, 0x37, + 0x77, 0xd4, 0xf4, 0x2f, 0x03, 0x3b, 0x64, 0x09, + 0x84, 0xa0, 0xb3, 0x24, 0xb7, 0xae, 0x47, 0x5e, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 7, - .digest = (u8[]){ 0x73, 0xad, 0x5e, 0x6d, 0xb9, 0x02, 0x8e, 0x76, - 0xf2, 0x66, 0x42, 0x4b, 0x4c, 0xfa, 0x1f, 0xe6, - 0x2e, 0x56, 0x40, 0xe5, 0xa2, 0xb0, 0x3c, 0xe8, - 0x7b, 0x45, 0xfe, 0x05, }, + .digest = (u8[]){ 0x0b, 0x82, 0x88, 0xca, 0x05, 0x2f, 0x1b, 0x15, + 0xdc, 0xbb, 0x22, 0x27, 0x11, 0x6b, 0xf4, 0xd1, + 0xe9, 0x8f, 0x1b, 0x0b, 0x58, 0x3f, 0x5e, 0x86, + 0x80, 0x82, 0x6f, 0x8e, 0x54, 0xc1, 0x9f, 0x12, + 0xcf, 0xe9, 0x56, 0xc1, 0xfc, 0x1a, 0x08, 0xb9, + 0x4a, 0x57, 0x0a, 0x76, 0x3c, 0x15, 0x33, 0x18, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 15, - .digest = (u8[]){ 0x16, 0x60, 0xfb, 0x92, 0x54, 0xb3, 0x6e, 0x36, - 0x81, 0xf4, 0x16, 0x41, 0xc3, 0x3d, 0xd3, 0x43, - 0x84, 0xed, 0x10, 0x6f, 0x65, 0x80, 0x7a, 0x3e, - 0x25, 0xab, 0xc5, 0x02, }, + .digest = (u8[]){ 0x4a, 0x81, 0x55, 0xb9, 0x79, 0x42, 0x8c, 0xc6, + 0x4f, 0xfe, 0xca, 0x82, 0x3b, 0xb2, 0xf7, 0xbc, + 0x5e, 0xfc, 0xab, 0x09, 0x1c, 0xd6, 0x3b, 0xe1, + 0x50, 0x82, 0x3b, 0xde, 0xc7, 0x06, 0xee, 0x3b, + 0x29, 0xce, 0xe5, 0x68, 0xe0, 0xff, 0xfa, 0xe1, + 0x7a, 0xf1, 0xc0, 0xfe, 0x57, 0xf4, 0x60, 0x49, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 64, - .digest = (u8[]){ 0xca, 0xaa, 0x39, 0x67, 0x9c, 0xf7, 0x6b, 0xc7, - 0xb6, 0x82, 0xca, 0x0e, 0x65, 0x36, 0x5b, 0x7c, - 0x24, 0x00, 0xfa, 0x5f, 0xda, 0x06, 0x91, 0x93, - 0x6a, 0x31, 0x83, 0xb5, }, + .digest = (u8[]){ 0x34, 0xbd, 0xe1, 0x99, 0x43, 0x9f, 0x82, 0x72, + 0xe7, 0xed, 0x94, 0x9e, 0xe1, 0x84, 0xee, 0x82, + 0xfd, 0x26, 0x23, 0xc4, 0x17, 0x8d, 0xf5, 0x04, + 0xeb, 0xb7, 0xbc, 0xb8, 0xf3, 0x68, 0xb7, 0xad, + 0x94, 0x8e, 0x05, 0x3f, 0x8a, 0x5d, 0x8d, 0x81, + 0x3e, 0x88, 0xa7, 0x8c, 0xa2, 0xd5, 0xdc, 0x76, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 256, - .digest = (u8[]){ 0x90, 0x02, 0x26, 0xb5, 0x06, 0x9c, 0x36, 0x86, - 0x94, 0x91, 0x90, 0x1e, 0x7d, 0x2a, 0x71, 0xb2, - 0x48, 0xb5, 0xe8, 0x16, 0xfd, 0x64, 0x33, 0x45, - 0xb3, 0xd7, 0xec, 0xcc, }, + .digest = (u8[]){ 0x22, 0x14, 0xf4, 0xb0, 0x4c, 0xa8, 0xb5, 0x7d, + 0xa7, 0x5c, 0x04, 0xeb, 0xd8, 0x8d, 0x04, 0x71, + 0xc7, 0x3c, 0xc7, 0x6e, 0x8b, 0x20, 0x36, 0x40, + 0x9d, 0xd0, 0x60, 0xc6, 0xe3, 0x0b, 0x6e, 0x50, + 0xf5, 0xaf, 0xf5, 0xc6, 0x3b, 0xe3, 0x84, 0x6a, + 0x93, 0x1b, 0x12, 0xd6, 0x18, 0x27, 0xba, 0x36, }, }}; -static const struct hash_testvec blakes2s_256_tv_template[] = {{ - .plaintext = blake2_ordered_sequence, +static const struct hash_testvec blake2b_512_tv_template[] = {{ + .plaintext = blake2b_ordered_sequence, .psize = 15, - .digest = (u8[]){ 0xd9, 0x7c, 0x82, 0x8d, 0x81, 0x82, 0xa7, 0x21, - 0x80, 0xa0, 0x6a, 0x78, 0x26, 0x83, 0x30, 0x67, - 0x3f, 0x7c, 0x4e, 0x06, 0x35, 0x94, 0x7c, 0x04, - 0xc0, 0x23, 0x23, 0xfd, 0x45, 0xc0, 0xa5, 0x2d, }, + .digest = (u8[]){ 0x44, 0x4b, 0x24, 0x0f, 0xe3, 0xed, 0x86, 0xd0, + 0xe2, 0xef, 0x4c, 0xe7, 0xd8, 0x51, 0xed, 0xde, + 0x22, 0x15, 0x55, 0x82, 0xaa, 0x09, 0x14, 0x79, + 0x7b, 0x72, 0x6c, 0xd0, 0x58, 0xb6, 0xf4, 0x59, + 0x32, 0xe0, 0xe1, 0x29, 0x51, 0x68, 0x76, 0x52, + 0x7b, 0x1d, 0xd8, 0x8f, 0xc6, 0x6d, 0x71, 0x19, + 0xf4, 0xab, 0x3b, 0xed, 0x93, 0xa6, 0x1a, 0x0e, + 0x2d, 0x2d, 0x2a, 0xea, 0xc3, 0x36, 0xd9, 0x58, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .digest = (u8[]){ 0x48, 0xa8, 0x99, 0x7d, 0xa4, 0x07, 0x87, 0x6b, - 0x3d, 0x79, 0xc0, 0xd9, 0x23, 0x25, 0xad, 0x3b, - 0x89, 0xcb, 0xb7, 0x54, 0xd8, 0x6a, 0xb7, 0x1a, - 0xee, 0x04, 0x7a, 0xd3, 0x45, 0xfd, 0x2c, 0x49, }, + .ksize = 64, + .key = blake2b_ordered_sequence, + .digest = (u8[]){ 0x10, 0xeb, 0xb6, 0x77, 0x00, 0xb1, 0x86, 0x8e, + 0xfb, 0x44, 0x17, 0x98, 0x7a, 0xcf, 0x46, 0x90, + 0xae, 0x9d, 0x97, 0x2f, 0xb7, 0xa5, 0x90, 0xc2, + 0xf0, 0x28, 0x71, 0x79, 0x9a, 0xaa, 0x47, 0x86, + 0xb5, 0xe9, 0x96, 0xe8, 0xf0, 0xf4, 0xeb, 0x98, + 0x1f, 0xc2, 0x14, 0xb0, 0x05, 0xf4, 0x2d, 0x2f, + 0xf4, 0x23, 0x34, 0x99, 0x39, 0x16, 0x53, 0xdf, + 0x7a, 0xef, 0xcb, 0xc1, 0x3f, 0xc5, 0x15, 0x68, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 1, - .digest = (u8[]){ 0x22, 0x27, 0xae, 0xaa, 0x6e, 0x81, 0x56, 0x03, - 0xa7, 0xe3, 0xa1, 0x18, 0xa5, 0x9a, 0x2c, 0x18, - 0xf4, 0x63, 0xbc, 0x16, 0x70, 0xf1, 0xe7, 0x4b, - 0x00, 0x6d, 0x66, 0x16, 0xae, 0x9e, 0x74, 0x4e, }, + .digest = (u8[]){ 0xd2, 0x11, 0x31, 0x29, 0x3f, 0xea, 0xca, 0x72, + 0x21, 0xe4, 0x06, 0x65, 0x05, 0x2a, 0xd1, 0x02, + 0xc0, 0x8d, 0x7b, 0xf1, 0x09, 0x3c, 0xef, 0x88, + 0xe1, 0x68, 0x0c, 0xf1, 0x3b, 0xa4, 0xe3, 0x03, + 0xed, 0xa0, 0xe3, 0x60, 0x58, 0xa0, 0xdb, 0x52, + 0x8a, 0x66, 0x43, 0x09, 0x60, 0x1a, 0xbb, 0x67, + 0xc5, 0x84, 0x31, 0x40, 0xfa, 0xde, 0xc1, 0xd0, + 0xff, 0x3f, 0x4a, 0x69, 0xd9, 0x92, 0x26, 0x86, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 7, - .digest = (u8[]){ 0x58, 0x5d, 0xa8, 0x60, 0x1c, 0xa4, 0xd8, 0x03, - 0x86, 0x86, 0x84, 0x64, 0xd7, 0xa0, 0x8e, 0x15, - 0x2f, 0x05, 0xa2, 0x1b, 0xbc, 0xef, 0x7a, 0x34, - 0xb3, 0xc5, 0xbc, 0x4b, 0xf0, 0x32, 0xeb, 0x12, }, + .digest = (u8[]){ 0xa3, 0x3e, 0x50, 0xbc, 0xfb, 0xd9, 0xf0, 0x82, + 0xa6, 0xd1, 0xdf, 0xaf, 0x82, 0xd0, 0xcf, 0x84, + 0x9a, 0x25, 0x3c, 0xae, 0x6d, 0xb5, 0xaf, 0x01, + 0xd7, 0xaf, 0xed, 0x50, 0xdc, 0xe2, 0xba, 0xcc, + 0x8c, 0x38, 0xf5, 0x16, 0x89, 0x38, 0x86, 0xce, + 0x68, 0x10, 0x63, 0x64, 0xa5, 0x79, 0x53, 0xb5, + 0x2e, 0x8e, 0xbc, 0x0a, 0xce, 0x95, 0xc0, 0x1e, + 0x69, 0x59, 0x1d, 0x3b, 0xd8, 0x19, 0x90, 0xd7, }, }, { - .ksize = 32, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 64, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 64, - .digest = (u8[]){ 0x89, 0x75, 0xb0, 0x57, 0x7f, 0xd3, 0x55, 0x66, - 0xd7, 0x50, 0xb3, 0x62, 0xb0, 0x89, 0x7a, 0x26, - 0xc3, 0x99, 0x13, 0x6d, 0xf0, 0x7b, 0xab, 0xab, - 0xbd, 0xe6, 0x20, 0x3f, 0xf2, 0x95, 0x4e, 0xd4, }, + .digest = (u8[]){ 0x65, 0x67, 0x6d, 0x80, 0x06, 0x17, 0x97, 0x2f, + 0xbd, 0x87, 0xe4, 0xb9, 0x51, 0x4e, 0x1c, 0x67, + 0x40, 0x2b, 0x7a, 0x33, 0x10, 0x96, 0xd3, 0xbf, + 0xac, 0x22, 0xf1, 0xab, 0xb9, 0x53, 0x74, 0xab, + 0xc9, 0x42, 0xf1, 0x6e, 0x9a, 0xb0, 0xea, 0xd3, + 0x3b, 0x87, 0xc9, 0x19, 0x68, 0xa6, 0xe5, 0x09, + 0xe1, 0x19, 0xff, 0x07, 0x78, 0x7b, 0x3e, 0xf4, + 0x83, 0xe1, 0xdc, 0xdc, 0xcf, 0x6e, 0x30, 0x22, }, }, { .ksize = 1, .key = "B", - .plaintext = blake2_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 247, - .digest = (u8[]){ 0x2e, 0x74, 0x1c, 0x1d, 0x03, 0xf4, 0x9d, 0x84, - 0x6f, 0xfc, 0x86, 0x32, 0x92, 0x49, 0x7e, 0x66, - 0xd7, 0xc3, 0x10, 0x88, 0xfe, 0x28, 0xb3, 0xe0, - 0xbf, 0x50, 0x75, 0xad, 0x8e, 0xa4, 0xe6, 0xb2, }, + .digest = (u8[]){ 0xc2, 0x96, 0x2c, 0x6b, 0x84, 0xff, 0xee, 0xea, + 0x9b, 0xb8, 0x55, 0x2d, 0x6b, 0xa5, 0xd5, 0xe5, + 0xbd, 0xb1, 0x54, 0xb6, 0x1e, 0xfb, 0x63, 0x16, + 0x6e, 0x22, 0x04, 0xf0, 0x82, 0x7a, 0xc6, 0x99, + 0xf7, 0x4c, 0xff, 0x93, 0x71, 0x57, 0x64, 0xd0, + 0x08, 0x60, 0x39, 0x98, 0xb8, 0xd2, 0x2b, 0x4e, + 0x81, 0x8d, 0xe4, 0x8f, 0xb2, 0x1e, 0x8f, 0x99, + 0x98, 0xf1, 0x02, 0x9b, 0x4c, 0x7c, 0x97, 0x1a, }, }, { - .ksize = 16, - .key = blake2_ordered_sequence, - .plaintext = blake2_ordered_sequence, + .ksize = 32, + .key = blake2b_ordered_sequence, + .plaintext = blake2b_ordered_sequence, .psize = 256, - .digest = (u8[]){ 0xb9, 0xd2, 0x81, 0x0e, 0x3a, 0xb1, 0x62, 0x9b, - 0xad, 0x44, 0x05, 0xf4, 0x92, 0x2e, 0x99, 0xc1, - 0x4a, 0x47, 0xbb, 0x5b, 0x6f, 0xb2, 0x96, 0xed, - 0xd5, 0x06, 0xb5, 0x3a, 0x7c, 0x7a, 0x65, 0x1d, }, + .digest = (u8[]){ 0x0f, 0x32, 0x05, 0x09, 0xad, 0x9f, 0x25, 0xf7, + 0xf2, 0x00, 0x71, 0xc9, 0x9f, 0x08, 0x58, 0xd1, + 0x67, 0xc3, 0xa6, 0x2c, 0x0d, 0xe5, 0x7c, 0x15, + 0x35, 0x18, 0x5a, 0x68, 0xc1, 0xca, 0x1c, 0x6e, + 0x0f, 0xc4, 0xf6, 0x0c, 0x43, 0xe1, 0xb4, 0x3d, + 0x28, 0xe4, 0xc7, 0xa1, 0xcf, 0x6b, 0x17, 0x4e, + 0xf1, 0x5b, 0xb5, 0x53, 0xd4, 0xa7, 0xd0, 0x5b, + 0xae, 0x15, 0x81, 0x15, 0xd0, 0x88, 0xa0, 0x3c, }, }}; #endif /* _CRYPTO_TESTMGR_H */ diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 885efb5452c5..4187af3ff90f 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,4 +83,3 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o obj-$(CONFIG_ARCH_QCOM) += qcom/ -obj-y += google/ diff --git a/drivers/power/supply/google/Kconfig b/drivers/power/supply/google/Kconfig deleted file mode 100644 index 0198ad39d298..000000000000 --- a/drivers/power/supply/google/Kconfig +++ /dev/null @@ -1,4 +0,0 @@ -config USB_OVERHEAT_MITIGATION - tristate "Google USB Overheat Mitigation" - help - Say Y here to enable Google USB overheat mitigation diff --git a/drivers/power/supply/google/Makefile b/drivers/power/supply/google/Makefile deleted file mode 100644 index 2c3f790660d8..000000000000 --- a/drivers/power/supply/google/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_USB_OVERHEAT_MITIGATION) += overheat_mitigation.o diff --git a/drivers/power/supply/google/overheat_mitigation.c b/drivers/power/supply/google/overheat_mitigation.c deleted file mode 100644 index ed2511b105a1..000000000000 --- a/drivers/power/supply/google/overheat_mitigation.c +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Copyright 2018 Google, Inc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USB_OVERHEAT_MITIGATION_VOTER "USB_OVERHEAT_MITIGATION_VOTER" - -enum { - USB_NO_LIMIT = 0, - USB_OVERHEAT_THROTTLE = 1, - USB_MAX_THROTTLE_STATE = USB_OVERHEAT_THROTTLE, -}; - -static bool mitigation_enabled = true; -module_param_named( - enable, mitigation_enabled, bool, 0600 -); - -struct overheat_event_stats { - int plug_temp; - int max_temp; - int trip_time; - int hysteresis_time; - int cleared_time; -}; - -struct overheat_info { - struct device *dev; - struct power_supply *usb_psy; - struct votable *usb_icl_votable; - struct votable *disable_power_role_switch; - struct notifier_block psy_nb; - struct delayed_work port_overheat_work; - struct wakeup_source overheat_ws; - struct overheat_event_stats stats; - struct thermal_cooling_device *cooling_dev; - - bool usb_connected; - bool accessory_connected; - bool usb_replug; - bool overheat_mitigation; - bool overheat_work_running; - - int temp; - int plug_temp; - int max_temp; - time_t plug_time; - time_t trip_time; - time_t hysteresis_time; - - int begin_temp; - int clear_temp; - int overheat_work_delay_ms; - int polling_freq; - int check_status; - unsigned long throttle_state; -}; - -#define PSY_GET_PROP(psy, psp) psy_get_prop(psy, psp, #psp) -static inline int psy_get_prop(struct power_supply *psy, - enum power_supply_property psp, - char *prop_name) -{ - union power_supply_propval val; - int ret = 0; - - if (!psy) - return -EINVAL; - pr_debug("get %s for '%s'...\n", prop_name, psy->desc->name); - ret = power_supply_get_property(psy, psp, &val); - if (ret < 0) { - pr_err("failed to get %s from '%s', ret=%d\n", prop_name, - psy->desc->name, ret); - return ret; - } - pr_debug("get %s for '%s' => %d\n", prop_name, psy->desc->name, - val.intval); - return val.intval; -} - -#define OVH_ATTR(_name) \ -static ssize_t _name##_show(struct device *dev, \ - struct device_attribute *attr, \ - char *buf) \ -{ \ - struct overheat_info *ovh_info = dev_get_drvdata(dev); \ - \ - return scnprintf(buf, PAGE_SIZE, "%d\n", ovh_info->stats._name);\ -} \ -static DEVICE_ATTR_RO(_name); - -OVH_ATTR(max_temp); -OVH_ATTR(plug_temp); -OVH_ATTR(trip_time); -OVH_ATTR(hysteresis_time); -OVH_ATTR(cleared_time); - -static struct attribute *ovh_attr[] = { - &dev_attr_max_temp.attr, - &dev_attr_plug_temp.attr, - &dev_attr_hysteresis_time.attr, - &dev_attr_trip_time.attr, - &dev_attr_cleared_time.attr, - NULL, -}; - -static const struct attribute_group ovh_attr_group = { - .attrs = ovh_attr, -}; - -static inline time_t get_seconds_since_boot(void) -{ - return div_u64(ktime_to_ns(ktime_get_boottime()), NSEC_PER_SEC); -} - -static inline int get_dts_vars(struct overheat_info *ovh_info) -{ - struct device *dev = ovh_info->dev; - struct device_node *node = dev->of_node; - int ret; - - ret = of_property_read_u32(node, "google,begin-mitigation-temp", - &ovh_info->begin_temp); - if (ret < 0) { - dev_err(ovh_info->dev, - "cannot read begin-mitigation-temp, ret=%d\n", ret); - return ret; - } - - ret = of_property_read_u32(node, "google,end-mitigation-temp", - &ovh_info->clear_temp); - if (ret < 0) { - dev_err(ovh_info->dev, - "cannot read end-mitigation-temp, ret=%d\n", ret); - return ret; - } - - ret = of_property_read_u32(node, "google,port-overheat-work-interval", - &ovh_info->overheat_work_delay_ms); - if (ret < 0) { - dev_err(ovh_info->dev, - "cannot read port-overheat-work-interval, ret=%d\n", - ret); - return ret; - } - - ret = of_property_read_u32(node, "google,polling-freq", - &ovh_info->polling_freq); - if (ret < 0) { - dev_err(ovh_info->dev, - "cannot read polling-freq, ret=%d\n", ret); - return ret; - } - - return 0; -} - -static int suspend_usb(struct overheat_info *ovh_info) -{ - int ret; - - ovh_info->usb_replug = false; - - /* disable USB */ - ret = vote(ovh_info->disable_power_role_switch, - USB_OVERHEAT_MITIGATION_VOTER, true, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't vote for disable_power_role_switch ret=%d\n", - ret); - return ret; - } - - /* suspend charging */ - ret = vote(ovh_info->usb_icl_votable, - USB_OVERHEAT_MITIGATION_VOTER, true, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't vote for USB ICL ret=%d\n", ret); - return ret; - } - - ovh_info->trip_time = get_seconds_since_boot(); - ovh_info->overheat_mitigation = true; - return ret; -} - -static int resume_usb(struct overheat_info *ovh_info) -{ - int ret; - - /* Fill out stats so userspace can read them. */ - ovh_info->stats.max_temp = ovh_info->max_temp; - ovh_info->stats.plug_temp = ovh_info->plug_temp; - ovh_info->stats.trip_time = - (int) (ovh_info->trip_time - ovh_info->plug_time); - ovh_info->stats.hysteresis_time = - (int) (ovh_info->hysteresis_time - ovh_info->trip_time); - ovh_info->stats.cleared_time = - (int) (get_seconds_since_boot() - ovh_info->hysteresis_time); - - /* enable charging */ - ret = vote(ovh_info->usb_icl_votable, - USB_OVERHEAT_MITIGATION_VOTER, false, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't un-vote for USB ICL ret=%d\n", ret); - return ret; - } - - /* enable USB */ - ret = vote(ovh_info->disable_power_role_switch, - USB_OVERHEAT_MITIGATION_VOTER, false, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't un-vote for disable_power_role_switch ret=%d\n", - ret); - return ret; - } - - /* Notify userspace to read the stats. */ - kobject_uevent(&ovh_info->dev->kobj, KOBJ_CHANGE); - - ovh_info->max_temp = INT_MIN; - ovh_info->plug_temp = INT_MIN; - ovh_info->plug_time = 0; - ovh_info->trip_time = 0; - ovh_info->hysteresis_time = 0; - ovh_info->overheat_mitigation = false; - ovh_info->usb_replug = false; - return ret; -} - -/* - * Update usb_connected, accessory_connected, usb_replug, and plug_temp - * status in overheat_info struct. - */ -static int update_usb_status(struct overheat_info *ovh_info) -{ - int ret; - bool prev_state = ovh_info->usb_connected || - ovh_info->accessory_connected; - bool curr_state; - int *check_status = &ovh_info->check_status; - - /* Port is too hot to safely check the connected status. */ - if (ovh_info->overheat_mitigation && - ovh_info->temp > ovh_info->clear_temp) - return -EBUSY; - - if (ovh_info->overheat_mitigation) { - if (!ovh_info->hysteresis_time) - ovh_info->hysteresis_time = get_seconds_since_boot(); - // Only check USB status every polling_freq instances - *check_status = (*check_status + 1) % ovh_info->polling_freq; - if (*check_status > 0) - return 0; - ret = vote(ovh_info->disable_power_role_switch, - USB_OVERHEAT_MITIGATION_VOTER, false, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't un-vote for disable_power_role_switch ret=%d\n", - ret); - return ret; - } - msleep(200); - } - - dev_dbg(ovh_info->dev, "Updating USB connected status\n"); - - /* - * Update USB present status to determine if USB has been disconnected. - * If we use USB online status to determine replug, we will need to - * extend the delay between re-enabling CC detection and checking the - * USB online status. - */ - ret = PSY_GET_PROP(ovh_info->usb_psy, POWER_SUPPLY_PROP_PRESENT); - if (ret < 0) - return ret; - ovh_info->usb_connected = ret; - - ret = PSY_GET_PROP(ovh_info->usb_psy, POWER_SUPPLY_PROP_TYPEC_MODE); - if (ret < 0) - return ret; - ovh_info->accessory_connected = (ret == POWER_SUPPLY_TYPEC_SINK) || - (ret == POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE); - - curr_state = ovh_info->usb_connected || ovh_info->accessory_connected; - if (curr_state && !prev_state) { - ovh_info->plug_time = get_seconds_since_boot(); - ovh_info->plug_temp = ovh_info->temp; - } - - if (ovh_info->overheat_mitigation) { - ret = vote(ovh_info->disable_power_role_switch, - USB_OVERHEAT_MITIGATION_VOTER, true, 0); - if (ret < 0) { - dev_err(ovh_info->dev, - "Couldn't vote for disable_power_role_switch ret=%d\n", - ret); - return ret; - } - } - - if (curr_state != prev_state) - dev_info(ovh_info->dev, - "USB is %sconnected", - curr_state ? "" : "dis"); - - // USB should be disconnected for two cycles before replug is acked - if (ovh_info->overheat_mitigation && !curr_state && !prev_state) - ovh_info->usb_replug = true; - - return 0; -} - -static inline int get_usb_port_temp(struct overheat_info *ovh_info) -{ - int temp; - - temp = PSY_GET_PROP(ovh_info->usb_psy, POWER_SUPPLY_PROP_TEMP); - - if (temp == -EINVAL || temp == -ENODATA) - return temp; - - dev_info(ovh_info->dev, "Update USB port temp:%d\n", temp); - if (temp > ovh_info->max_temp) - ovh_info->max_temp = temp; - - ovh_info->temp = temp; - return 0; -} - -static int psy_changed(struct notifier_block *nb, unsigned long action, - void *data) -{ - struct power_supply *psy = data; - struct overheat_info *ovh_info = - container_of(nb, struct overheat_info, psy_nb); - - if ((action != PSY_EVENT_PROP_CHANGED) || (psy == NULL) || - (psy->desc == NULL) || (psy->desc->name == NULL)) - return NOTIFY_OK; - - if (action == PSY_EVENT_PROP_CHANGED && - !strcmp(psy->desc->name, "usb")) { - dev_dbg(ovh_info->dev, "name=usb evt=%lu\n", action); - if (!ovh_info->overheat_work_running) - schedule_delayed_work(&ovh_info->port_overheat_work, 0); - } - return NOTIFY_OK; -} - -static void port_overheat_work(struct work_struct *work) -{ - struct overheat_info *ovh_info = - container_of(work, struct overheat_info, - port_overheat_work.work); - int ret = 0; - - // Take a wake lock to ensure we poll the temp regularly - if (!ovh_info->overheat_work_running) - __pm_stay_awake(&ovh_info->overheat_ws); - ovh_info->overheat_work_running = true; - - if (get_usb_port_temp(ovh_info) < 0) - goto rerun; - - ret = update_usb_status(ovh_info); - if (ret < 0) - goto rerun; - - if (ovh_info->overheat_mitigation && (!mitigation_enabled || - (ovh_info->temp < ovh_info->clear_temp && ovh_info->usb_replug))) { - dev_err(ovh_info->dev, "Port overheat mitigated\n"); - resume_usb(ovh_info); - } else if (!ovh_info->overheat_mitigation && - mitigation_enabled && ovh_info->temp > ovh_info->begin_temp) { - dev_err(ovh_info->dev, "Port overheat triggered\n"); - suspend_usb(ovh_info); - goto rerun; - } - - if (ovh_info->overheat_mitigation || ovh_info->throttle_state) - goto rerun; - // Do not run again, USB port isn't overheated - ovh_info->overheat_work_running = false; - __pm_relax(&ovh_info->overheat_ws); - return; - -rerun: - schedule_delayed_work( - &ovh_info->port_overheat_work, - msecs_to_jiffies(ovh_info->overheat_work_delay_ms)); -} - -static int usb_get_cur_state(struct thermal_cooling_device *cooling_dev, - unsigned long *state) -{ - struct overheat_info *ovh_info = cooling_dev->devdata; - - if (!ovh_info) - return -EINVAL; - - *state = ovh_info->throttle_state; - - return 0; -} - -static int usb_get_max_state(struct thermal_cooling_device *cooling_dev, - unsigned long *state) -{ - *state = USB_MAX_THROTTLE_STATE; - - return 0; -} - -static int usb_set_cur_state(struct thermal_cooling_device *cooling_dev, - unsigned long state) -{ - struct overheat_info *ovh_info = cooling_dev->devdata; - unsigned long current_state; - - if (!ovh_info) - return -EINVAL; - - if (state > USB_MAX_THROTTLE_STATE) - return -EINVAL; - - current_state = ovh_info->throttle_state; - ovh_info->throttle_state = state; - - if (current_state != state) { - dev_info(ovh_info->dev, "usb overheat throttle state=%lu\n", - state); - mod_delayed_work(system_wq, &ovh_info->port_overheat_work, 0); - } - return 0; -} - -static const struct thermal_cooling_device_ops usb_cooling_ops = { - .get_max_state = usb_get_max_state, - .get_cur_state = usb_get_cur_state, - .set_cur_state = usb_set_cur_state, -}; - -static int ovh_probe(struct platform_device *pdev) -{ - int ret = 0; - struct overheat_info *ovh_info; - struct power_supply *usb_psy; - struct votable *usb_icl_votable; - struct votable *disable_power_role_switch; - - usb_psy = power_supply_get_by_name("usb"); - if (!usb_psy) - return -EPROBE_DEFER; - - usb_icl_votable = find_votable("USB_ICL"); - if (usb_icl_votable == NULL) { - pr_err("Couldn't find USB_ICL votable\n"); - return -EPROBE_DEFER; - } - - disable_power_role_switch = find_votable("DISABLE_POWER_ROLE_SWITCH"); - if (disable_power_role_switch == NULL) { - pr_err("Couldn't find DISABLE_POWER_ROLE_SWITCH votable\n"); - return -EPROBE_DEFER; - } - - ovh_info = devm_kzalloc(&pdev->dev, sizeof(*ovh_info), GFP_KERNEL); - if (!ovh_info) - return -ENOMEM; - - ovh_info->dev = &pdev->dev; - ovh_info->usb_icl_votable = usb_icl_votable; - ovh_info->disable_power_role_switch = disable_power_role_switch; - ovh_info->usb_psy = usb_psy; - ovh_info->max_temp = INT_MIN; - ovh_info->plug_temp = INT_MIN; - - ret = get_dts_vars(ovh_info); - if (ret < 0) - return -ENODEV; - - // initialize votables - vote(ovh_info->usb_icl_votable, - USB_OVERHEAT_MITIGATION_VOTER, false, 0); - vote(ovh_info->disable_power_role_switch, - USB_OVERHEAT_MITIGATION_VOTER, false, 0); - - wakeup_source_init(&ovh_info->overheat_ws, "overheat_mitigation"); - INIT_DELAYED_WORK(&ovh_info->port_overheat_work, port_overheat_work); - - // register power supply change notifier to update usb metric data - ovh_info->psy_nb.notifier_call = psy_changed; - ret = power_supply_reg_notifier(&ovh_info->psy_nb); - if (ret < 0) { - dev_err(ovh_info->dev, - "Cannot register power supply notifer, ret=%d\n", ret); - return ret; - } - - /* Register cooling device */ - ovh_info->cooling_dev = thermal_of_cooling_device_register( - dev_of_node(ovh_info->dev), "usb-port", - ovh_info, &usb_cooling_ops); - - if (IS_ERR(ovh_info->cooling_dev)) { - ret = PTR_ERR(ovh_info->cooling_dev); - dev_err(ovh_info->dev, "%s: failed to register cooling device: %d\n", - __func__, ret); - return ret; - } - - platform_set_drvdata(pdev, ovh_info); - ret = sysfs_create_group(&ovh_info->dev->kobj, &ovh_attr_group); - if (ret < 0) { - dev_err(ovh_info->dev, - "Cannot create sysfs group, ret=%d\n", ret); - } - - return 0; -} - -static int ovh_remove(struct platform_device *pdev) -{ - struct overheat_info *ovh_info = platform_get_drvdata(pdev); - if (ovh_info) { - power_supply_unreg_notifier(&ovh_info->psy_nb); - sysfs_remove_group(&ovh_info->dev->kobj, &ovh_attr_group); - wakeup_source_trash(&ovh_info->overheat_ws); - } - return 0; -} - -static const struct of_device_id match_table[] = { - { - .compatible = "google,overheat_mitigation", - }, - {}, -}; - -static struct platform_driver ovh_driver = { - .driver = { - .name = "google,overheat_mitigation", - .owner = THIS_MODULE, - .of_match_table = match_table, - }, - .probe = ovh_probe, - .remove = ovh_remove, -}; - -module_platform_driver(ovh_driver); -MODULE_DESCRIPTION("USB port overheat mitigation driver"); -MODULE_AUTHOR("Maggie White "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/supply/qcom/qpnp-smb5.c b/drivers/power/supply/qcom/qpnp-smb5.c index f0f7549a3f50..770672f5221e 100644 --- a/drivers/power/supply/qcom/qpnp-smb5.c +++ b/drivers/power/supply/qcom/qpnp-smb5.c @@ -467,9 +467,6 @@ static int smb5_parse_dt(struct smb5 *chip) chg->qc_class_ab = of_property_read_bool(node, "qcom,distinguish-qc-class-ab"); - chg->ext_fg = of_property_read_bool(node, - "qcom,support-ext-fg"); - rc = of_property_read_u32(node, "qcom,wd-bark-time-secs", &chip->dt.wd_bark_time); if (rc < 0 || chip->dt.wd_bark_time < MIN_WD_BARK_TIME) @@ -2095,7 +2092,6 @@ static enum power_supply_property smb5_batt_props[] = { POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_FORCE_RECHARGE, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, - POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, POWER_SUPPLY_PROP_FCC_STEPPER_ENABLE, POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL, @@ -2247,13 +2243,6 @@ static int smb5_batt_get_prop(struct power_supply *psy, rc = smblib_get_prop_from_bms(chg, POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, val); break; - case POWER_SUPPLY_PROP_CAPACITY_LEVEL: - if (chg->ext_fg) - rc = smblib_get_prop_from_bms(chg, - POWER_SUPPLY_PROP_CAPACITY_LEVEL, val); - else - rc = smblib_get_prop_batt_capacity_level(chg, val); - break; case POWER_SUPPLY_PROP_FCC_STEPPER_ENABLE: val->intval = chg->fcc_stepper_enable; break; diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index e21a719c593d..e20440a99813 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -52,7 +52,6 @@ && (!chg->typec_legacy || chg->typec_legacy_use_rp_icl)) static bool off_charge_flag; -static bool first_boot_flag; bool smblib_rsbux_low(struct smb_charger *chg, int r_thr); static int smblib_get_prop_typec_mode(struct smb_charger *chg); @@ -2224,28 +2223,6 @@ int smblib_get_prop_batt_capacity(struct smb_charger *chg, return rc; } -int smblib_get_prop_batt_capacity_level(struct smb_charger *chg, - union power_supply_propval *val) -{ - int rc,cap; - union power_supply_propval capacity; - - rc = smblib_get_prop_from_bms(chg, POWER_SUPPLY_PROP_CAPACITY, &capacity); - - cap=capacity.intval; - if (cap <= 0) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; - if (cap > 0 && cap <= 20) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; - if (cap > 20 && cap <= 90) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; - if (cap > 90 && cap <= 99) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_HIGH; - if (cap == 100) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; - return rc; -} - static bool smblib_is_jeita_warm_charging(struct smb_charger *chg) { union power_supply_propval pval = {0, }; @@ -2633,23 +2610,6 @@ int smblib_get_prop_batt_iterm(struct smb_charger *chg, return rc; } -static int smblib_set_wdog_bark_timer(struct smb_charger *chg, - int wdog_timer) -{ - u8 val = 0; - int rc; - - val = (ilog2(wdog_timer / 16) << BARK_WDOG_TIMEOUT_SHIFT) - & BARK_WDOG_TIMEOUT_MASK; - rc = smblib_masked_write(chg, SNARL_BARK_BITE_WD_CFG_REG, - BARK_WDOG_TIMEOUT_MASK, val); - if (rc < 0) { - pr_err("Couldn't configue WD config rc=%d\n", rc); - return rc; - } - return rc; -} - int smblib_get_prop_batt_charge_done(struct smb_charger *chg, union power_supply_propval *val) { @@ -2667,8 +2627,6 @@ int smblib_get_prop_batt_charge_done(struct smb_charger *chg, val->intval = (stat == TERMINATE_CHARGE); if (val->intval == 1) { - /* when charge done, set bark timer to 128s to decrease wakeups */ - smblib_set_wdog_bark_timer(chg, BARK_TIMER_LONG); vote(chg->awake_votable, CHG_AWAKE_VOTER, false, 0); vote(chg->awake_votable, DC_AWAKE_VOTER, false, 0); } @@ -6254,14 +6212,6 @@ static void smblib_cc_un_compliant_charge_work(struct work_struct *work) } } -static void smb_check_init_boot(struct work_struct *work) -{ - struct smb_charger *chg = container_of(work, struct smb_charger, - check_init_boot.work); - first_boot_flag = true; - if (chg->usb_psy) - power_supply_changed(chg->usb_psy); -} static void smblib_micro_usb_plugin(struct smb_charger *chg, bool vbus_rising) { @@ -6390,8 +6340,6 @@ void smblib_usb_plugin_locked(struct smb_charger *chg) /* Schedule work to enable parallel charger */ vote(chg->awake_votable, PL_DELAY_VOTER, true, 0); - if (!first_boot_flag) - schedule_delayed_work(&chg->check_init_boot, msecs_to_jiffies(18000)); queue_delayed_work(system_power_efficient_wq, &chg->pl_enable_work, msecs_to_jiffies(PL_DELAY_MS)); queue_delayed_work(system_power_efficient_wq, &chg->charger_type_recheck, @@ -7242,7 +7190,6 @@ static void typec_src_removal(struct smb_charger *chg) cancel_delayed_work_sync(&chg->pl_enable_work); cancel_delayed_work_sync(&chg->raise_qc3_vbus_work); - cancel_delayed_work_sync(&chg->check_init_boot); /* reset input current limit voters */ vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, @@ -7347,9 +7294,6 @@ static void typec_src_removal(struct smb_charger *chg) if (chg->use_extcon) smblib_notify_device_mode(chg, false); - /* when src removal, set bark timer back to default 16s */ - smblib_set_wdog_bark_timer(chg, BARK_TIMER_NORMAL); - chg->typec_legacy = false; pr_err("%s:", __func__); if (chg->pd_verifed) @@ -7845,8 +7789,6 @@ irqreturn_t dc_plugin_irq_handler(int irq, void *data) schedule_work(&chg->dcin_aicl_work); } else { - /* when dc plug out, set bark timer back to default 16s */ - smblib_set_wdog_bark_timer(chg, BARK_TIMER_NORMAL); vote(chg->awake_votable, DC_AWAKE_VOTER, false, 0); vote(chg->dc_icl_votable, DCIN_ADAPTER_VOTER, true, 100000); chg->flag_dc_present = 0; @@ -9328,7 +9270,6 @@ int smblib_init(struct smb_charger *chg) setup_timer(&chg->apsd_timer, apsd_timer_cb, (unsigned long)chg); - INIT_DELAYED_WORK(&chg->check_init_boot, smb_check_init_boot); if (chg->wa_flags & CHG_TERMINATION_WA) { INIT_WORK(&chg->chg_termination_work, smblib_chg_termination_work); @@ -9486,7 +9427,6 @@ int smblib_deinit(struct smb_charger *chg) cancel_delayed_work_sync(&chg->usbov_dbc_work); cancel_delayed_work_sync(&chg->role_reversal_check); cancel_delayed_work_sync(&chg->pr_swap_detach_work); - cancel_delayed_work_sync(&chg->check_init_boot); power_supply_unreg_notifier(&chg->nb); smblib_destroy_votables(chg); qcom_step_chg_deinit(); diff --git a/drivers/power/supply/qcom/smb5-lib.h b/drivers/power/supply/qcom/smb5-lib.h index 9ef81e943cd9..0cdb9476e637 100644 --- a/drivers/power/supply/qcom/smb5-lib.h +++ b/drivers/power/supply/qcom/smb5-lib.h @@ -145,10 +145,6 @@ enum print_reason { #define TYPE_RECHECK_TIME_5S 5000 #define TYPE_RECHECK_COUNT 3 -/* wdog bark timer */ -#define BARK_TIMER_LONG 128 -#define BARK_TIMER_NORMAL 16 - enum hvdcp3_type { HVDCP3_NONE = 0, HVDCP3_CLASSA_18W, @@ -565,8 +561,6 @@ struct smb_charger { struct delayed_work pr_lock_clear_work; struct delayed_work micro_usb_switch_work; - struct delayed_work check_init_boot; - struct alarm lpd_recheck_timer; struct alarm moisture_protection_alarm; struct alarm chg_termination_alarm; @@ -769,7 +763,6 @@ struct smb_charger { int micro_usb_pre_state; bool dcin_uusb_over_gpio_en; bool aicl_disable; - bool ext_fg; }; enum quick_charge_type { @@ -852,8 +845,6 @@ int smblib_get_prop_batt_present(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_batt_capacity(struct smb_charger *chg, union power_supply_propval *val); -int smblib_get_prop_batt_capacity_level(struct smb_charger *chg, - union power_supply_propval *val); int smblib_get_prop_batt_status(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_batt_charge_type(struct smb_charger *chg, diff --git a/drivers/soc/qcom/scm.c b/drivers/soc/qcom/scm.c index baf95004b386..b067c9baf4e2 100644 --- a/drivers/soc/qcom/scm.c +++ b/drivers/soc/qcom/scm.c @@ -392,7 +392,6 @@ static int ___scm_call_armv8_64(u64 x0, u64 x1, u64 x2, u64 x3, u64 x4, u64 x5, register u64 r5 asm("x5") = x5; register u64 r6 asm("x6") = 0; - atomic_inc(&scm_call_count); do { asm volatile( __asmeq("%0", R0_STR) @@ -421,8 +420,6 @@ static int ___scm_call_armv8_64(u64 x0, u64 x1, u64 x2, u64 x3, u64 x4, u64 x5, "x14", "x15", "x16", "x17"); } while (r0 == SCM_INTERRUPTED); - atomic_dec(&scm_call_count); - if (ret1) *ret1 = r1; if (ret2) @@ -456,7 +453,6 @@ static int ___scm_call_armv8_32(u32 w0, u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, register u32 r5 asm("w5") = w5; register u32 r6 asm("w6") = 0; - atomic_inc(&scm_call_count); do { asm volatile( __asmeq("%0", R0_STR) @@ -486,8 +482,6 @@ static int ___scm_call_armv8_32(u32 w0, u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, } while (r0 == SCM_INTERRUPTED); - atomic_dec(&scm_call_count); - if (ret1) *ret1 = r1; if (ret2) @@ -523,7 +517,6 @@ static int __scm_call_armv8_32(u32 w0, u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, register u32 r5 asm("r5") = w5; register u32 r6 asm("r6") = 0; - atomic_inc(&scm_call_count); do { asm volatile( __asmeq("%0", R0_STR) @@ -551,8 +544,6 @@ static int __scm_call_armv8_32(u32 w0, u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, } while (r0 == SCM_INTERRUPTED); - atomic_dec(&scm_call_count); - if (ret1) *ret1 = r1; if (ret2) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index ae7ef765d1e1..81771251d9c5 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2012,8 +2012,6 @@ static void functionfs_unbind(struct ffs_data *ffs) ENTER(); if (!WARN_ON(!ffs->gadget)) { - /* dequeue before freeing ep0req */ - usb_ep_dequeue(ffs->gadget->ep0, ffs->ep0req); mutex_lock(&ffs->mutex); usb_ep_free_request(ffs->gadget->ep0, ffs->ep0req); ffs->ep0req = NULL; diff --git a/fs/verity/enable.c b/fs/verity/enable.c index 835c3399fee5..fbebb8b7d134 100644 --- a/fs/verity/enable.c +++ b/fs/verity/enable.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -391,25 +390,27 @@ int fsverity_ioctl_enable(struct file *filp, const void __user *uarg) goto out_drop_write; err = enable_verity(filp, &arg); - if (err) - goto out_allow_write_access; /* - * Some pages of the file may have been evicted from pagecache after - * being used in the Merkle tree construction, then read into pagecache - * again by another process reading from the file concurrently. Since - * these pages didn't undergo verification against the file digest which - * fs-verity now claims to be enforcing, we have to wipe the pagecache - * to ensure that all future reads are verified. + * We no longer drop the inode's pagecache after enabling verity. This + * used to be done to try to avoid a race condition where pages could be + * evicted after being used in the Merkle tree construction, then + * re-instantiated by a concurrent read. Such pages are unverified, and + * the backing storage could have filled them with different content, so + * they shouldn't be used to fulfill reads once verity is enabled. + * + * But, dropping the pagecache has a big performance impact, and it + * doesn't fully solve the race condition anyway. So for those reasons, + * and also because this race condition isn't very important relatively + * speaking (especially for small-ish files, where the chance of a page + * being used, evicted, *and* re-instantiated all while enabling verity + * is quite small), we no longer drop the inode's pagecache. */ - filemap_write_and_wait(inode->i_mapping); - invalidate_inode_pages2(inode->i_mapping); /* * allow_write_access() is needed to pair with deny_write_access(). * Regardless, the filesystem won't allow writing to verity files. */ -out_allow_write_access: allow_write_access(filp); out_drop_write: mnt_drop_write_file(filp); diff --git a/fs/verity/verify.c b/fs/verity/verify.c index b89e6e1e04e0..97681d323c6c 100644 --- a/fs/verity/verify.c +++ b/fs/verity/verify.c @@ -279,15 +279,15 @@ EXPORT_SYMBOL_GPL(fsverity_enqueue_verify_work); int __init fsverity_init_workqueue(void) { /* - * Use an unbound workqueue to allow bios to be verified in parallel - * even when they happen to complete on the same CPU. This sacrifices - * locality, but it's worthwhile since hashing is CPU-intensive. + * Use a high-priority workqueue to prioritize verification work, which + * blocks reads from completing, over regular application tasks. * - * Also use a high-priority workqueue to prioritize verification work, - * which blocks reads from completing, over regular application tasks. + * For performance reasons, don't use an unbound workqueue. Using an + * unbound workqueue for crypto operations causes excessive scheduler + * latency on ARM64. */ fsverity_read_workqueue = alloc_workqueue("fsverity_read_queue", - WQ_UNBOUND | WQ_HIGHPRI, + WQ_HIGHPRI, num_online_cpus()); if (!fsverity_read_workqueue) return -ENOMEM; diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index e5d333d8f148..171f45089a23 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2135,9 +2135,9 @@ static void uclamp_set(struct kernfs_open_file *of, {"top-app", "10", "max", 1, 1}, // 10-100% {"foreground", "10", "80", 1, 0}, // 10-80% {"background", "0", "50", 0, 0}, // 0-50% - {"system-background", "0", "60", 0, 0}, // 0-60% + {"system-background", "0", "50", 0, 0}, // 0-60% {"restricted", "0", "20", 0, 0}, // 0-20% - {"display", "50", "100", 1, 1}, + {"display", "20", "100", 1, 1}, {"camera-daemon", "20", "max", 1, 1}, // 20-100% }; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index fcb5024fbad1..9103549c10d0 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12115,11 +12115,19 @@ void set_cpu_sd_state_idle(void) */ void nohz_balance_enter_idle(int cpu) { - /* - * If this cpu is going down, then nothing needs to be done. - */ - if (!cpu_active(cpu)) + if (!cpu_active(cpu)) { + /* + * A CPU can be paused while it is idle with it's tick + * stopped. nohz_balance_exit_idle() should be called + * from the local CPU, so it can't be called during + * pause. This results in paused CPU participating in + * the nohz idle balance, which should be avoided. + * When the paused CPU exits idle and enters again, + * exempt the paused CPU from nohz_balance_exit_idle. + */ + nohz_balance_exit_idle(cpu); return; + } /* Spare idle load balancing on CPUs that don't want to be disturbed: */ if (!is_housekeeping_cpu(cpu)) diff --git a/kernel/sched/features.h b/kernel/sched/features.h index 41e3498b238e..6f60ed8086ca 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -45,7 +45,7 @@ SCHED_FEAT(WAKEUP_PREEMPTION, true) SCHED_FEAT(HRTICK, false) SCHED_FEAT(DOUBLE_TICK, false) -SCHED_FEAT(LB_BIAS, false) +SCHED_FEAT(LB_BIAS, true) /* * Decrement CPU capacity based on time not spent running tasks diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 7787ed5fc43e..506e8505d83d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -152,6 +153,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer, raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags); } cpu_relax(); + ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS); } } @@ -1071,6 +1073,7 @@ int hrtimer_cancel(struct hrtimer *timer) if (ret >= 0) return ret; cpu_relax(); + ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS); } } EXPORT_SYMBOL_GPL(hrtimer_cancel); diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index f8e1845aa464..a2bc0fd50290 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h @@ -164,3 +164,4 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases); extern u64 get_next_timer_interrupt(unsigned long basej, u64 basem); void timer_clear_idle(void); +#define TIMER_LOCK_TIGHT_LOOP_DELAY_NS 350 diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 52d964ab0e03..d3e973ccf6e1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -945,6 +945,7 @@ static struct timer_base *lock_timer_base(struct timer_list *timer, raw_spin_unlock_irqrestore(&base->lock, *flags); } cpu_relax(); + ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS); } } @@ -1267,6 +1268,7 @@ int del_timer_sync(struct timer_list *timer) if (ret >= 0) return ret; cpu_relax(); + ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS); } } EXPORT_SYMBOL(del_timer_sync); diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index fa334f46d701..d0882908a158 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -257,9 +257,7 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) case TC_ACT_STOLEN: case TC_ACT_TRAP: *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; - /* fall through */ - case TC_ACT_SHOT: - return NULL; + case TC_ACT_RECLASSIFY: return cbq_reclassify(skb, cl); } diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 38aeea667e6f..4a76ceeca6fd 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -315,8 +315,11 @@ static void dev_watchdog(unsigned long arg) } } - if (some_queue_timedout) + if (some_queue_timedout) { + WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit queue %u timed out\n", + dev->name, netdev_drivername(dev), i); dev->netdev_ops->ndo_tx_timeout(dev); + } if (!mod_timer(&dev->watchdog_timer, round_jiffies(jiffies + dev->watchdog_timeo)))