From: Sasha Levin Date: Tue, 23 Apr 2019 15:45:11 +0000 (-0400) Subject: patches for 4.14 X-Git-Tag: v3.18.139~45^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b00eda4132a5829fc21e92a8680718e8b26c7d5e;p=thirdparty%2Fkernel%2Fstable-queue.git patches for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/crypto-crypto4xx-properly-set-iv-after-de-and-encryp.patch b/queue-4.14/crypto-crypto4xx-properly-set-iv-after-de-and-encryp.patch new file mode 100644 index 00000000000..04c89861bbb --- /dev/null +++ b/queue-4.14/crypto-crypto4xx-properly-set-iv-after-de-and-encryp.patch @@ -0,0 +1,81 @@ +From 786bc43e7e900fd900d452211e615a5ad800bc32 Mon Sep 17 00:00:00 2001 +From: Christian Lamparter +Date: Thu, 19 Apr 2018 18:41:55 +0200 +Subject: crypto: crypto4xx - properly set IV after de- and encrypt + +[ Upstream commit fc340115ffb8235c1bbd200c28855e6373d0dd1a ] + +This patch fixes cts(cbc(aes)) test when cbc-aes-ppc4xx is used. +alg: skcipher: Test 1 failed (invalid result) on encryption for cts(cbc-aes-ppc4xx) +00000000: 4b 10 75 fc 2f 14 1b 6a 27 35 37 33 d1 b7 70 05 +00000010: 97 +alg: skcipher: Failed to load transform for cts(cbc(aes)): -2 + +The CTS cipher mode expect the IV (req->iv) of skcipher_request +to contain the last ciphertext block after the {en,de}crypt +operation is complete. + +Fix this issue for the AMCC Crypto4xx hardware engine. +The tcrypt test case for cts(cbc(aes)) is now correctly passed. + +name : cts(cbc(aes)) +driver : cts(cbc-aes-ppc4xx) +module : cts +priority : 300 +refcnt : 1 +selftest : passed +internal : no +type : skcipher +async : yes +blocksize : 16 +min keysize : 16 +max keysize : 32 +ivsize : 16 +chunksize : 16 +walksize : 16 + +Signed-off-by: Christian Lamparter +Signed-off-by: Herbert Xu +Signed-off-by: Sasha Levin +--- + drivers/crypto/amcc/crypto4xx_alg.c | 3 ++- + drivers/crypto/amcc/crypto4xx_core.c | 9 +++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/drivers/crypto/amcc/crypto4xx_alg.c b/drivers/crypto/amcc/crypto4xx_alg.c +index 4afca3968773..e3b8bebfdd30 100644 +--- a/drivers/crypto/amcc/crypto4xx_alg.c ++++ b/drivers/crypto/amcc/crypto4xx_alg.c +@@ -138,7 +138,8 @@ static int crypto4xx_setkey_aes(struct crypto_ablkcipher *cipher, + sa = (struct dynamic_sa_ctl *) ctx->sa_in; + ctx->hash_final = 0; + +- set_dynamic_sa_command_0(sa, SA_NOT_SAVE_HASH, SA_NOT_SAVE_IV, ++ set_dynamic_sa_command_0(sa, SA_NOT_SAVE_HASH, (cm == CRYPTO_MODE_CBC ? ++ SA_SAVE_IV : SA_NOT_SAVE_IV), + SA_LOAD_HASH_FROM_SA, SA_LOAD_IV_FROM_STATE, + SA_NO_HEADER_PROC, SA_HASH_ALG_NULL, + SA_CIPHER_ALG_AES, SA_PAD_TYPE_ZERO, +diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c +index 3f9eee7e555f..8d4d8db244e9 100644 +--- a/drivers/crypto/amcc/crypto4xx_core.c ++++ b/drivers/crypto/amcc/crypto4xx_core.c +@@ -645,6 +645,15 @@ static u32 crypto4xx_ablkcipher_done(struct crypto4xx_device *dev, + addr = dma_map_page(dev->core_dev->device, sg_page(dst), + dst->offset, dst->length, DMA_FROM_DEVICE); + } ++ ++ if (pd_uinfo->sa_va->sa_command_0.bf.save_iv == SA_SAVE_IV) { ++ struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req); ++ ++ crypto4xx_memcpy_from_le32((u32 *)req->iv, ++ pd_uinfo->sr_va->save_iv, ++ crypto_skcipher_ivsize(skcipher)); ++ } ++ + crypto4xx_ret_sg_desc(dev, pd_uinfo); + if (ablk_req->base.complete != NULL) + ablk_req->base.complete(&ablk_req->base, 0); +-- +2.19.1 + diff --git a/queue-4.14/mmc-sdhci-fix-data-command-crc-error-handling.patch b/queue-4.14/mmc-sdhci-fix-data-command-crc-error-handling.patch new file mode 100644 index 00000000000..47aa80b5d37 --- /dev/null +++ b/queue-4.14/mmc-sdhci-fix-data-command-crc-error-handling.patch @@ -0,0 +1,115 @@ +From 43bdc07ad34335022ca0ea4af38ce369d421627d Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Thu, 15 Nov 2018 15:53:41 +0200 +Subject: mmc: sdhci: Fix data command CRC error handling + +[ Upstream commit 4bf780996669280171c9cd58196512849b93434e ] + +Existing data command CRC error handling is non-standard and does not work +with some Intel host controllers. Specifically, the assumption that the host +controller will continue operating normally after the error interrupt, +is not valid. Change the driver to handle the error in the same manner +as a data CRC error, taking care to ensure that the data line reset is +done for single or multi-block transfers, and it is done before +unmapping DMA. + +Signed-off-by: Adrian Hunter +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/sdhci.c | 40 +++++++++++++++------------------------- + 1 file changed, 15 insertions(+), 25 deletions(-) + +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c +index 0edcc2763f3c..2d59b0389567 100644 +--- a/drivers/mmc/host/sdhci.c ++++ b/drivers/mmc/host/sdhci.c +@@ -1002,8 +1002,7 @@ static bool sdhci_needs_reset(struct sdhci_host *host, struct mmc_request *mrq) + return (!(host->flags & SDHCI_DEVICE_DEAD) && + ((mrq->cmd && mrq->cmd->error) || + (mrq->sbc && mrq->sbc->error) || +- (mrq->data && ((mrq->data->error && !mrq->data->stop) || +- (mrq->data->stop && mrq->data->stop->error))) || ++ (mrq->data && mrq->data->stop && mrq->data->stop->error) || + (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))); + } + +@@ -1055,6 +1054,16 @@ static void sdhci_finish_data(struct sdhci_host *host) + host->data = NULL; + host->data_cmd = NULL; + ++ /* ++ * The controller needs a reset of internal state machines upon error ++ * conditions. ++ */ ++ if (data->error) { ++ if (!host->cmd || host->cmd == data_cmd) ++ sdhci_do_reset(host, SDHCI_RESET_CMD); ++ sdhci_do_reset(host, SDHCI_RESET_DATA); ++ } ++ + if ((host->flags & (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) == + (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) + sdhci_adma_table_post(host, data); +@@ -1079,17 +1088,6 @@ static void sdhci_finish_data(struct sdhci_host *host) + if (data->stop && + (data->error || + !data->mrq->sbc)) { +- +- /* +- * The controller needs a reset of internal state machines +- * upon error conditions. +- */ +- if (data->error) { +- if (!host->cmd || host->cmd == data_cmd) +- sdhci_do_reset(host, SDHCI_RESET_CMD); +- sdhci_do_reset(host, SDHCI_RESET_DATA); +- } +- + /* + * 'cap_cmd_during_tfr' request must not use the command line + * after mmc_command_done() has been called. It is upper layer's +@@ -2560,7 +2558,7 @@ static void sdhci_timeout_data_timer(unsigned long data) + * * + \*****************************************************************************/ + +-static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) ++static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p) + { + if (!host->cmd) { + /* +@@ -2583,20 +2581,12 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) + else + host->cmd->error = -EILSEQ; + +- /* +- * If this command initiates a data phase and a response +- * CRC error is signalled, the card can start transferring +- * data - the card may have received the command without +- * error. We must not terminate the mmc_request early. +- * +- * If the card did not receive the command or returned an +- * error which prevented it sending data, the data phase +- * will time out. +- */ ++ /* Treat data command CRC error the same as data CRC error */ + if (host->cmd->data && + (intmask & (SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)) == + SDHCI_INT_CRC) { + host->cmd = NULL; ++ *intmask_p |= SDHCI_INT_DATA_CRC; + return; + } + +@@ -2824,7 +2814,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) + } + + if (intmask & SDHCI_INT_CMD_MASK) +- sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK); ++ sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK, &intmask); + + if (intmask & SDHCI_INT_DATA_MASK) + sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); +-- +2.19.1 + diff --git a/queue-4.14/mmc-sdhci-handle-auto-command-errors.patch b/queue-4.14/mmc-sdhci-handle-auto-command-errors.patch new file mode 100644 index 00000000000..983d5b66f48 --- /dev/null +++ b/queue-4.14/mmc-sdhci-handle-auto-command-errors.patch @@ -0,0 +1,109 @@ +From a05960a14d30352492206fcb4f636ead03642b7e Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Thu, 15 Nov 2018 15:53:43 +0200 +Subject: mmc: sdhci: Handle auto-command errors + +[ Upstream commit af849c86109d79222e549826068bbf4e7f9a2472 ] + +If the host controller supports auto-commands then enable the auto-command +error interrupt and handle it. In the case of auto-CMD23, the error is +treated the same as manual CMD23 error. In the case of auto-CMD12, +commands-during-transfer are not permitted, so the error handling is +treated the same as a data error. + +Signed-off-by: Adrian Hunter +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/sdhci.c | 35 +++++++++++++++++++++++++++++++++++ + drivers/mmc/host/sdhci.h | 7 ++++++- + 2 files changed, 41 insertions(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c +index 8abbe40a9a05..9540fda7fc6b 100644 +--- a/drivers/mmc/host/sdhci.c ++++ b/drivers/mmc/host/sdhci.c +@@ -790,6 +790,11 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) + else + host->ier = (host->ier & ~dma_irqs) | pio_irqs; + ++ if (host->flags & (SDHCI_AUTO_CMD23 | SDHCI_AUTO_CMD12)) ++ host->ier |= SDHCI_INT_AUTO_CMD_ERR; ++ else ++ host->ier &= ~SDHCI_INT_AUTO_CMD_ERR; ++ + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); + } +@@ -2560,6 +2565,21 @@ static void sdhci_timeout_data_timer(unsigned long data) + + static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p) + { ++ /* Handle auto-CMD12 error */ ++ if (intmask & SDHCI_INT_AUTO_CMD_ERR && host->data_cmd) { ++ struct mmc_request *mrq = host->data_cmd->mrq; ++ u16 auto_cmd_status = sdhci_readw(host, SDHCI_AUTO_CMD_STATUS); ++ int data_err_bit = (auto_cmd_status & SDHCI_AUTO_CMD_TIMEOUT) ? ++ SDHCI_INT_DATA_TIMEOUT : ++ SDHCI_INT_DATA_CRC; ++ ++ /* Treat auto-CMD12 error the same as data error */ ++ if (!mrq->sbc && (host->flags & SDHCI_AUTO_CMD12)) { ++ *intmask_p |= data_err_bit; ++ return; ++ } ++ } ++ + if (!host->cmd) { + /* + * SDHCI recovers from errors by resetting the cmd and data +@@ -2594,6 +2614,21 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p) + return; + } + ++ /* Handle auto-CMD23 error */ ++ if (intmask & SDHCI_INT_AUTO_CMD_ERR) { ++ struct mmc_request *mrq = host->cmd->mrq; ++ u16 auto_cmd_status = sdhci_readw(host, SDHCI_AUTO_CMD_STATUS); ++ int err = (auto_cmd_status & SDHCI_AUTO_CMD_TIMEOUT) ? ++ -ETIMEDOUT : ++ -EILSEQ; ++ ++ if (mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { ++ mrq->sbc->error = err; ++ sdhci_finish_mrq(host, mrq); ++ return; ++ } ++ } ++ + if (intmask & SDHCI_INT_RESPONSE) + sdhci_finish_command(host); + } +diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h +index 860b2c729e68..c0d5458c36d4 100644 +--- a/drivers/mmc/host/sdhci.h ++++ b/drivers/mmc/host/sdhci.h +@@ -151,7 +151,8 @@ + #define SDHCI_INT_ERROR_MASK 0xFFFF8000 + + #define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \ +- SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX) ++ SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX | \ ++ SDHCI_INT_AUTO_CMD_ERR) + #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ + SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ + SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ +@@ -167,6 +168,10 @@ + #define SDHCI_CQE_INT_MASK (SDHCI_CQE_INT_ERR_MASK | SDHCI_INT_CQE) + + #define SDHCI_AUTO_CMD_STATUS 0x3C ++#define SDHCI_AUTO_CMD_TIMEOUT 0x00000002 ++#define SDHCI_AUTO_CMD_CRC 0x00000004 ++#define SDHCI_AUTO_CMD_END_BIT 0x00000008 ++#define SDHCI_AUTO_CMD_INDEX 0x00000010 + + #define SDHCI_HOST_CONTROL2 0x3E + #define SDHCI_CTRL_UHS_MASK 0x0007 +-- +2.19.1 + diff --git a/queue-4.14/mmc-sdhci-rename-sdhci_acmd12_err-and-sdhci_int_acmd.patch b/queue-4.14/mmc-sdhci-rename-sdhci_acmd12_err-and-sdhci_int_acmd.patch new file mode 100644 index 00000000000..62270097b1e --- /dev/null +++ b/queue-4.14/mmc-sdhci-rename-sdhci_acmd12_err-and-sdhci_int_acmd.patch @@ -0,0 +1,112 @@ +From d6f6b786879076fbb87c08379828c2e507748943 Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Thu, 15 Nov 2018 15:53:42 +0200 +Subject: mmc: sdhci: Rename SDHCI_ACMD12_ERR and SDHCI_INT_ACMD12ERR + +[ Upstream commit 869f8a69bb3a4aec4eb914a330d4ba53a9eed495 ] + +The SDHCI_ACMD12_ERR register is used for auto-CMD23 and auto-CMD12 +errors, as is the SDHCI_INT_ACMD12ERR interrupt bit. Rename them to +SDHCI_AUTO_CMD_STATUS and SDHCI_INT_AUTO_CMD_ERR respectively. + +Signed-off-by: Adrian Hunter +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/sdhci-esdhc-imx.c | 12 ++++++------ + drivers/mmc/host/sdhci.c | 4 ++-- + drivers/mmc/host/sdhci.h | 4 ++-- + 3 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c +index ff5c4ad37a3a..8c0b80a54e4d 100644 +--- a/drivers/mmc/host/sdhci-esdhc-imx.c ++++ b/drivers/mmc/host/sdhci-esdhc-imx.c +@@ -425,7 +425,7 @@ static u16 esdhc_readw_le(struct sdhci_host *host, int reg) + val = readl(host->ioaddr + ESDHC_MIX_CTRL); + else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) + /* the std tuning bits is in ACMD12_ERR for imx6sl */ +- val = readl(host->ioaddr + SDHCI_ACMD12_ERR); ++ val = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); + } + + if (val & ESDHC_MIX_CTRL_EXE_TUNE) +@@ -490,7 +490,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) + } + writel(new_val , host->ioaddr + ESDHC_MIX_CTRL); + } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { +- u32 v = readl(host->ioaddr + SDHCI_ACMD12_ERR); ++ u32 v = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); + u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL); + if (val & SDHCI_CTRL_TUNED_CLK) { + v |= ESDHC_MIX_CTRL_SMPCLK_SEL; +@@ -508,7 +508,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) + v &= ~ESDHC_MIX_CTRL_EXE_TUNE; + } + +- writel(v, host->ioaddr + SDHCI_ACMD12_ERR); ++ writel(v, host->ioaddr + SDHCI_AUTO_CMD_STATUS); + writel(m, host->ioaddr + ESDHC_MIX_CTRL); + } + return; +@@ -937,9 +937,9 @@ static void esdhc_reset_tuning(struct sdhci_host *host) + writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); + writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { +- ctrl = readl(host->ioaddr + SDHCI_ACMD12_ERR); ++ ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); + ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; +- writel(ctrl, host->ioaddr + SDHCI_ACMD12_ERR); ++ writel(ctrl, host->ioaddr + SDHCI_AUTO_CMD_STATUS); + } + } + } +@@ -1303,7 +1303,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) + + /* clear tuning bits in case ROM has set it already */ + writel(0x0, host->ioaddr + ESDHC_MIX_CTRL); +- writel(0x0, host->ioaddr + SDHCI_ACMD12_ERR); ++ writel(0x0, host->ioaddr + SDHCI_AUTO_CMD_STATUS); + writel(0x0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + } + +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c +index 2d59b0389567..8abbe40a9a05 100644 +--- a/drivers/mmc/host/sdhci.c ++++ b/drivers/mmc/host/sdhci.c +@@ -82,8 +82,8 @@ void sdhci_dumpregs(struct sdhci_host *host) + SDHCI_DUMP("Int enab: 0x%08x | Sig enab: 0x%08x\n", + sdhci_readl(host, SDHCI_INT_ENABLE), + sdhci_readl(host, SDHCI_SIGNAL_ENABLE)); +- SDHCI_DUMP("AC12 err: 0x%08x | Slot int: 0x%08x\n", +- sdhci_readw(host, SDHCI_ACMD12_ERR), ++ SDHCI_DUMP("ACmd stat: 0x%08x | Slot int: 0x%08x\n", ++ sdhci_readw(host, SDHCI_AUTO_CMD_STATUS), + sdhci_readw(host, SDHCI_SLOT_INT_STATUS)); + SDHCI_DUMP("Caps: 0x%08x | Caps_1: 0x%08x\n", + sdhci_readl(host, SDHCI_CAPABILITIES), +diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h +index 1d7d61e25dbf..860b2c729e68 100644 +--- a/drivers/mmc/host/sdhci.h ++++ b/drivers/mmc/host/sdhci.h +@@ -144,7 +144,7 @@ + #define SDHCI_INT_DATA_CRC 0x00200000 + #define SDHCI_INT_DATA_END_BIT 0x00400000 + #define SDHCI_INT_BUS_POWER 0x00800000 +-#define SDHCI_INT_ACMD12ERR 0x01000000 ++#define SDHCI_INT_AUTO_CMD_ERR 0x01000000 + #define SDHCI_INT_ADMA_ERROR 0x02000000 + + #define SDHCI_INT_NORMAL_MASK 0x00007FFF +@@ -166,7 +166,7 @@ + + #define SDHCI_CQE_INT_MASK (SDHCI_CQE_INT_ERR_MASK | SDHCI_INT_CQE) + +-#define SDHCI_ACMD12_ERR 0x3C ++#define SDHCI_AUTO_CMD_STATUS 0x3C + + #define SDHCI_HOST_CONTROL2 0x3E + #define SDHCI_CTRL_UHS_MASK 0x0007 +-- +2.19.1 + diff --git a/queue-4.14/modpost-file2alias-check-prototype-of-handler.patch b/queue-4.14/modpost-file2alias-check-prototype-of-handler.patch new file mode 100644 index 00000000000..77e0611077f --- /dev/null +++ b/queue-4.14/modpost-file2alias-check-prototype-of-handler.patch @@ -0,0 +1,57 @@ +From c9b46675422df9acae7d105b7a772bd8af4af54b Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Thu, 22 Nov 2018 13:28:42 +0900 +Subject: modpost: file2alias: check prototype of handler + +commit f880eea68fe593342fa6e09be9bb661f3c297aec upstream. + +Use specific prototype instead of an opaque pointer so that the +compiler can catch function prototype mismatch. + +Signed-off-by: Masahiro Yamada +Reviewed-by: Mathieu Malaterre +Signed-off-by: Nathan Chancellor +Signed-off-by: Sasha Levin +--- + scripts/mod/file2alias.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c +index 6e3ae94cf123..55b4c0dc2b93 100644 +--- a/scripts/mod/file2alias.c ++++ b/scripts/mod/file2alias.c +@@ -47,7 +47,7 @@ typedef struct { + struct devtable { + const char *device_id; /* name of table, __mod___*_device_table. */ + unsigned long id_size; +- void *function; ++ int (*do_entry)(const char *filename, void *symval, char *alias); + }; + + /* Define a variable f that holds the value of field f of struct devid +@@ -1228,12 +1228,11 @@ static bool sym_is(const char *name, unsigned namelen, const char *symbol) + static void do_table(void *symval, unsigned long size, + unsigned long id_size, + const char *device_id, +- void *function, ++ int (*do_entry)(const char *filename, void *symval, char *alias), + struct module *mod) + { + unsigned int i; + char alias[500]; +- int (*do_entry)(const char *, void *entry, char *alias) = function; + + device_id_check(mod->name, device_id, size, id_size, symval); + /* Leave last one: it's the terminator. */ +@@ -1346,7 +1345,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, + + if (sym_is(name, namelen, p->device_id)) { + do_table(symval, sym->st_size, p->id_size, +- p->device_id, p->function, mod); ++ p->device_id, p->do_entry, mod); + break; + } + } +-- +2.19.1 + diff --git a/queue-4.14/modpost-file2alias-go-back-to-simple-devtable-lookup.patch b/queue-4.14/modpost-file2alias-go-back-to-simple-devtable-lookup.patch new file mode 100644 index 00000000000..851ce229f68 --- /dev/null +++ b/queue-4.14/modpost-file2alias-go-back-to-simple-devtable-lookup.patch @@ -0,0 +1,443 @@ +From a403969605bedb40718b98ec33a0be2e01ae2b05 Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Thu, 22 Nov 2018 13:28:41 +0900 +Subject: modpost: file2alias: go back to simple devtable lookup + +commit ec91e78d378cc5d4b43805a1227d8e04e5dfa17d upstream. + +Commit e49ce14150c6 ("modpost: use linker section to generate table.") +was not so cool as we had expected first; it ended up with ugly section +hacks when commit dd2a3acaecd7 ("mod/file2alias: make modpost compile +on darwin again") came in. + +Given a certain degree of unknowledge about the link stage of host +programs, I really want to see simple, stupid table lookup so that +this works in the same way regardless of the underlying executable +format. + +Signed-off-by: Masahiro Yamada +Acked-by: Mathieu Malaterre +[nc: Omit rpmsg, sdw, tbsvc, and typec as they do not exist here] +Signed-off-by: Nathan Chancellor +Signed-off-by: Sasha Levin +--- + scripts/mod/file2alias.c | 136 +++++++++++++-------------------------- + 1 file changed, 45 insertions(+), 91 deletions(-) + +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c +index 29d6699d5a06..6e3ae94cf123 100644 +--- a/scripts/mod/file2alias.c ++++ b/scripts/mod/file2alias.c +@@ -50,46 +50,6 @@ struct devtable { + void *function; + }; + +-#define ___cat(a,b) a ## b +-#define __cat(a,b) ___cat(a,b) +- +-/* we need some special handling for this host tool running eventually on +- * Darwin. The Mach-O section handling is a bit different than ELF section +- * handling. The differnces in detail are: +- * a) we have segments which have sections +- * b) we need a API call to get the respective section symbols */ +-#if defined(__MACH__) +-#include +- +-#define INIT_SECTION(name) do { \ +- unsigned long name ## _len; \ +- char *__cat(pstart_,name) = getsectdata("__TEXT", \ +- #name, &__cat(name,_len)); \ +- char *__cat(pstop_,name) = __cat(pstart_,name) + \ +- __cat(name, _len); \ +- __cat(__start_,name) = (void *)__cat(pstart_,name); \ +- __cat(__stop_,name) = (void *)__cat(pstop_,name); \ +- } while (0) +-#define SECTION(name) __attribute__((section("__TEXT, " #name))) +- +-struct devtable **__start___devtable, **__stop___devtable; +-#else +-#define INIT_SECTION(name) /* no-op for ELF */ +-#define SECTION(name) __attribute__((section(#name))) +- +-/* We construct a table of pointers in an ELF section (pointers generally +- * go unpadded by gcc). ld creates boundary syms for us. */ +-extern struct devtable *__start___devtable[], *__stop___devtable[]; +-#endif /* __MACH__ */ +- +-#if !defined(__used) +-# if __GNUC__ == 3 && __GNUC_MINOR__ < 3 +-# define __used __attribute__((__unused__)) +-# else +-# define __used __attribute__((__used__)) +-# endif +-#endif +- + /* Define a variable f that holds the value of field f of struct devid + * based at address m. + */ +@@ -102,16 +62,6 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; + #define DEF_FIELD_ADDR(m, devid, f) \ + typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) + +-/* Add a table entry. We test function type matches while we're here. */ +-#define ADD_TO_DEVTABLE(device_id, type, function) \ +- static struct devtable __cat(devtable,__LINE__) = { \ +- device_id + 0*sizeof((function)((const char *)NULL, \ +- (void *)NULL, \ +- (char *)NULL)), \ +- SIZE_##type, (function) }; \ +- static struct devtable *SECTION(__devtable) __used \ +- __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) +- + #define ADD(str, sep, cond, field) \ + do { \ + strcat(str, sep); \ +@@ -431,7 +381,6 @@ static int do_hid_entry(const char *filename, + + return 1; + } +-ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); + + /* Looks like: ieee1394:venNmoNspNverN */ + static int do_ieee1394_entry(const char *filename, +@@ -456,7 +405,6 @@ static int do_ieee1394_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); + + /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ + static int do_pci_entry(const char *filename, +@@ -500,7 +448,6 @@ static int do_pci_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); + + /* looks like: "ccw:tNmNdtNdmN" */ + static int do_ccw_entry(const char *filename, +@@ -524,7 +471,6 @@ static int do_ccw_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); + + /* looks like: "ap:tN" */ + static int do_ap_entry(const char *filename, +@@ -535,7 +481,6 @@ static int do_ap_entry(const char *filename, + sprintf(alias, "ap:t%02X*", dev_type); + return 1; + } +-ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); + + /* looks like: "css:tN" */ + static int do_css_entry(const char *filename, +@@ -546,7 +491,6 @@ static int do_css_entry(const char *filename, + sprintf(alias, "css:t%01X", type); + return 1; + } +-ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); + + /* Looks like: "serio:tyNprNidNexN" */ + static int do_serio_entry(const char *filename, +@@ -566,7 +510,6 @@ static int do_serio_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); + + /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or + * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if) +@@ -604,7 +547,6 @@ static int do_acpi_entry(const char *filename, + } + return 1; + } +-ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); + + /* looks like: "pnp:dD" */ + static void do_pnp_device_entry(void *symval, unsigned long size, +@@ -725,7 +667,6 @@ static int do_pcmcia_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); + + static int do_vio_entry(const char *filename, void *symval, + char *alias) +@@ -745,7 +686,6 @@ static int do_vio_entry(const char *filename, void *symval, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); + + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +@@ -818,7 +758,6 @@ static int do_input_entry(const char *filename, void *symval, + do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); + return 1; + } +-ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); + + static int do_eisa_entry(const char *filename, void *symval, + char *alias) +@@ -830,7 +769,6 @@ static int do_eisa_entry(const char *filename, void *symval, + strcat(alias, "*"); + return 1; + } +-ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); + + /* Looks like: parisc:tNhvNrevNsvN */ + static int do_parisc_entry(const char *filename, void *symval, +@@ -850,7 +788,6 @@ static int do_parisc_entry(const char *filename, void *symval, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); + + /* Looks like: sdio:cNvNdN. */ + static int do_sdio_entry(const char *filename, +@@ -867,7 +804,6 @@ static int do_sdio_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); + + /* Looks like: ssb:vNidNrevN. */ + static int do_ssb_entry(const char *filename, +@@ -884,7 +820,6 @@ static int do_ssb_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); + + /* Looks like: bcma:mNidNrevNclN. */ + static int do_bcma_entry(const char *filename, +@@ -903,7 +838,6 @@ static int do_bcma_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); + + /* Looks like: virtio:dNvN */ + static int do_virtio_entry(const char *filename, void *symval, +@@ -919,7 +853,6 @@ static int do_virtio_entry(const char *filename, void *symval, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); + + /* + * Looks like: vmbus:guid +@@ -942,7 +875,6 @@ static int do_vmbus_entry(const char *filename, void *symval, + + return 1; + } +-ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); + + /* Looks like: i2c:S */ + static int do_i2c_entry(const char *filename, void *symval, +@@ -953,7 +885,6 @@ static int do_i2c_entry(const char *filename, void *symval, + + return 1; + } +-ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); + + /* Looks like: spi:S */ + static int do_spi_entry(const char *filename, void *symval, +@@ -964,7 +895,6 @@ static int do_spi_entry(const char *filename, void *symval, + + return 1; + } +-ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); + + static const struct dmifield { + const char *prefix; +@@ -1019,7 +949,6 @@ static int do_dmi_entry(const char *filename, void *symval, + strcat(alias, ":"); + return 1; + } +-ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); + + static int do_platform_entry(const char *filename, + void *symval, char *alias) +@@ -1028,7 +957,6 @@ static int do_platform_entry(const char *filename, + sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); + return 1; + } +-ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); + + static int do_mdio_entry(const char *filename, + void *symval, char *alias) +@@ -1053,7 +981,6 @@ static int do_mdio_entry(const char *filename, + + return 1; + } +-ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); + + /* Looks like: zorro:iN. */ + static int do_zorro_entry(const char *filename, void *symval, +@@ -1064,7 +991,6 @@ static int do_zorro_entry(const char *filename, void *symval, + ADD(alias, "i", id != ZORRO_WILDCARD, id); + return 1; + } +-ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); + + /* looks like: "pnp:dD" */ + static int do_isapnp_entry(const char *filename, +@@ -1080,7 +1006,6 @@ static int do_isapnp_entry(const char *filename, + (function >> 12) & 0x0f, (function >> 8) & 0x0f); + return 1; + } +-ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); + + /* Looks like: "ipack:fNvNdN". */ + static int do_ipack_entry(const char *filename, +@@ -1096,7 +1021,6 @@ static int do_ipack_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); + + /* + * Append a match expression for a single masked hex digit. +@@ -1167,7 +1091,6 @@ static int do_amba_entry(const char *filename, + + return 1; + } +-ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); + + /* + * looks like: "mipscdmm:tN" +@@ -1183,7 +1106,6 @@ static int do_mips_cdmm_entry(const char *filename, + sprintf(alias, "mipscdmm:t%02X*", type); + return 1; + } +-ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_mips_cdmm_entry); + + /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* + * All fields are numbers. It would be nicer to use strings for vendor +@@ -1208,7 +1130,6 @@ static int do_x86cpu_entry(const char *filename, void *symval, + sprintf(alias + strlen(alias), "%04X*", feature); + return 1; + } +-ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); + + /* LOOKS like cpu:type:*:feature:*FEAT* */ + static int do_cpu_entry(const char *filename, void *symval, char *alias) +@@ -1218,7 +1139,6 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias) + sprintf(alias, "cpu:type:*:feature:*%04X*", feature); + return 1; + } +-ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); + + /* Looks like: mei:S:uuid:N:* */ + static int do_mei_entry(const char *filename, void *symval, +@@ -1237,7 +1157,6 @@ static int do_mei_entry(const char *filename, void *symval, + + return 1; + } +-ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); + + /* Looks like: rapidio:vNdNavNadN */ + static int do_rio_entry(const char *filename, +@@ -1257,7 +1176,6 @@ static int do_rio_entry(const char *filename, + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); + + /* Looks like: ulpi:vNpN */ + static int do_ulpi_entry(const char *filename, void *symval, +@@ -1270,7 +1188,6 @@ static int do_ulpi_entry(const char *filename, void *symval, + + return 1; + } +-ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); + + /* Looks like: hdaudio:vNrNaN */ + static int do_hda_entry(const char *filename, void *symval, char *alias) +@@ -1287,7 +1204,6 @@ static int do_hda_entry(const char *filename, void *symval, char *alias) + add_wildcard(alias); + return 1; + } +-ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry); + + /* Looks like: fsl-mc:vNdN */ + static int do_fsl_mc_entry(const char *filename, void *symval, +@@ -1299,7 +1215,6 @@ static int do_fsl_mc_entry(const char *filename, void *symval, + sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *obj_type); + return 1; + } +-ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry); + + /* Does namelen bytes of name exactly match the symbol? */ + static bool sym_is(const char *name, unsigned namelen, const char *symbol) +@@ -1332,6 +1247,44 @@ static void do_table(void *symval, unsigned long size, + } + } + ++static const struct devtable devtable[] = { ++ {"hid", SIZE_hid_device_id, do_hid_entry}, ++ {"ieee1394", SIZE_ieee1394_device_id, do_ieee1394_entry}, ++ {"pci", SIZE_pci_device_id, do_pci_entry}, ++ {"ccw", SIZE_ccw_device_id, do_ccw_entry}, ++ {"ap", SIZE_ap_device_id, do_ap_entry}, ++ {"css", SIZE_css_device_id, do_css_entry}, ++ {"serio", SIZE_serio_device_id, do_serio_entry}, ++ {"acpi", SIZE_acpi_device_id, do_acpi_entry}, ++ {"pcmcia", SIZE_pcmcia_device_id, do_pcmcia_entry}, ++ {"vio", SIZE_vio_device_id, do_vio_entry}, ++ {"input", SIZE_input_device_id, do_input_entry}, ++ {"eisa", SIZE_eisa_device_id, do_eisa_entry}, ++ {"parisc", SIZE_parisc_device_id, do_parisc_entry}, ++ {"sdio", SIZE_sdio_device_id, do_sdio_entry}, ++ {"ssb", SIZE_ssb_device_id, do_ssb_entry}, ++ {"bcma", SIZE_bcma_device_id, do_bcma_entry}, ++ {"virtio", SIZE_virtio_device_id, do_virtio_entry}, ++ {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, ++ {"i2c", SIZE_i2c_device_id, do_i2c_entry}, ++ {"spi", SIZE_spi_device_id, do_spi_entry}, ++ {"dmi", SIZE_dmi_system_id, do_dmi_entry}, ++ {"platform", SIZE_platform_device_id, do_platform_entry}, ++ {"mdio", SIZE_mdio_device_id, do_mdio_entry}, ++ {"zorro", SIZE_zorro_device_id, do_zorro_entry}, ++ {"isapnp", SIZE_isapnp_device_id, do_isapnp_entry}, ++ {"ipack", SIZE_ipack_device_id, do_ipack_entry}, ++ {"amba", SIZE_amba_id, do_amba_entry}, ++ {"mipscdmm", SIZE_mips_cdmm_device_id, do_mips_cdmm_entry}, ++ {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry}, ++ {"cpu", SIZE_cpu_feature, do_cpu_entry}, ++ {"mei", SIZE_mei_cl_device_id, do_mei_entry}, ++ {"rapidio", SIZE_rio_device_id, do_rio_entry}, ++ {"ulpi", SIZE_ulpi_device_id, do_ulpi_entry}, ++ {"hdaudio", SIZE_hda_device_id, do_hda_entry}, ++ {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry}, ++}; ++ + /* Create MODULE_ALIAS() statements. + * At this time, we cannot write the actual output C source yet, + * so we write into the mod->dev_table_buf buffer. */ +@@ -1386,13 +1339,14 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, + else if (sym_is(name, namelen, "pnp_card")) + do_pnp_card_entries(symval, sym->st_size, mod); + else { +- struct devtable **p; +- INIT_SECTION(__devtable); ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(devtable); i++) { ++ const struct devtable *p = &devtable[i]; + +- for (p = __start___devtable; p < __stop___devtable; p++) { +- if (sym_is(name, namelen, (*p)->device_id)) { +- do_table(symval, sym->st_size, (*p)->id_size, +- (*p)->device_id, (*p)->function, mod); ++ if (sym_is(name, namelen, p->device_id)) { ++ do_table(symval, sym->st_size, p->id_size, ++ p->device_id, p->function, mod); + break; + } + } +-- +2.19.1 + diff --git a/queue-4.14/series b/queue-4.14/series index da21cd8d8ed..90e93a47e86 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -10,3 +10,10 @@ ipv4-recompile-ip-options-in-ipv4_link_failure.patch ipv4-ensure-rcu_read_lock-in-ipv4_link_failure.patch net-thunderx-raise-xdp-mtu-to-1508.patch net-thunderx-don-t-allow-jumbo-frames-with-xdp.patch +crypto-crypto4xx-properly-set-iv-after-de-and-encryp.patch +mmc-sdhci-fix-data-command-crc-error-handling.patch +mmc-sdhci-rename-sdhci_acmd12_err-and-sdhci_int_acmd.patch +mmc-sdhci-handle-auto-command-errors.patch +modpost-file2alias-go-back-to-simple-devtable-lookup.patch +modpost-file2alias-check-prototype-of-handler.patch +tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch diff --git a/queue-4.14/tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch b/queue-4.14/tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch new file mode 100644 index 00000000000..67cd55fb3eb --- /dev/null +++ b/queue-4.14/tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch @@ -0,0 +1,38 @@ +From ad4a0c8606f2643c88d60a060f8a1dae2685b5a5 Mon Sep 17 00:00:00 2001 +From: Jarkko Sakkinen +Date: Fri, 8 Feb 2019 18:30:59 +0200 +Subject: tpm/tpm_i2c_atmel: Return -E2BIG when the transfer is incomplete + +[ Upstream commit 442601e87a4769a8daba4976ec3afa5222ca211d ] + +Return -E2BIG when the transfer is incomplete. The upper layer does +not retry, so not doing that is incorrect behaviour. + +Cc: stable@vger.kernel.org +Fixes: a2871c62e186 ("tpm: Add support for Atmel I2C TPMs") +Signed-off-by: Jarkko Sakkinen +Reviewed-by: Stefan Berger +Reviewed-by: Jerry Snitselaar +Signed-off-by: Sasha Levin +--- + drivers/char/tpm/tpm_i2c_atmel.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c +index 32a8e27c5382..cc4e642d3180 100644 +--- a/drivers/char/tpm/tpm_i2c_atmel.c ++++ b/drivers/char/tpm/tpm_i2c_atmel.c +@@ -69,6 +69,10 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len) + if (status < 0) + return status; + ++ /* The upper layer does not support incomplete sends. */ ++ if (status != len) ++ return -E2BIG; ++ + return 0; + } + +-- +2.19.1 +