5.10.50-rc1 review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 140/593 crypto: hisilicon/sec - fixup 3des minimum key size declaration
In reply to Greg Kroah-HartmanFrom: Kai Ye <[email protected]>
[ Upstream commit 6161f40c630bd7ced5f236cd5fbabec06e47afae ]
Fixup the 3des algorithm minimum key size declaration.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +2 -2
@@ -1515,11 +1515,11 @@ static struct skcipher_alg sec_skciphers[] = { AES_BLOCK_SIZE, AES_BLOCK_SIZE) SEC_SKCIPHER_ALG("ecb(des3_ede)", sec_setkey_3des_ecb, - SEC_DES3_2KEY_SIZE, SEC_DES3_3KEY_SIZE, + SEC_DES3_3KEY_SIZE, SEC_DES3_3KEY_SIZE, DES3_EDE_BLOCK_SIZE, 0) SEC_SKCIPHER_ALG("cbc(des3_ede)", sec_setkey_3des_cbc, - SEC_DES3_2KEY_SIZE, SEC_DES3_3KEY_SIZE, + SEC_DES3_3KEY_SIZE, SEC_DES3_3KEY_SIZE, DES3_EDE_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE) SEC_SKCIPHER_ALG("xts(sm4)", sec_setkey_sm4_xts,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 141/593 Makefile: fix GDB warning with CONFIG_RELR
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
[ Upstream commit 27f2a4db76e8d8a8b601fc1c6a7a17f88bd907ab ]
GDB produces the following warning when debugging kernels built with CONFIG_RELR:
BFD: /android0/linux-next/vmlinux: unknown type [0x13] section `.relr.dyn'
when loading a kernel built with CONFIG_RELR into GDB. It can also prevent debugging symbols using such relocations.
Peter sugguests:
[That flag] means that lld will use dynamic tags and section type numbers in the OS-specific range rather than the generic range. The kernel itself doesn't care about these numbers; it determines the location of the RELR section using symbols defined by a linker script.
--- Makefile | 2 +- scripts/tools-support-relr.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -978,7 +978,7 @@ LDFLAGS_vmlinux += $(call ld-option, -X,) endif ifeq ($(CONFIG_RELR),y) -LDFLAGS_vmlinux += --pack-dyn-relocs=relr +LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags endif # We never want expected sections to be placed heuristically by the
scripts/tools-support-relr.sh +2 -1
@@ -7,7 +7,8 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1 void *p = &p; END -$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file +$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \ + --use-android-relr-tags -o $tmp_file # Despite printing an error message, GNU nm still exits with exit code 0 if it # sees a relr section. So we need to check that nothing is printed to stderr.
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 142/593 media: dvd_usb: memory leak in cinergyt2_fe_attach
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 9ad1efee086e0e913914fa2b2173efb830bad68c ]
When the driver fails to talk with the hardware with dvb_usb_generic_rw, it will return an error to dvb_usb_adapter_frontend_init. However, the driver forgets to free the resource (e.g., struct cinergyt2_fe_state), which leads to a memory leak.
Fix this by freeing struct cinergyt2_fe_state when dvb_usb_generic_rw fails in cinergyt2_frontend_attach.
backtrace:
[<0000000056e17b1a>] kmalloc include/linux/slab.h:552 [inline] [<0000000056e17b1a>] kzalloc include/linux/slab.h:682 [inline] [<0000000056e17b1a>] cinergyt2_fe_attach+0x21/0x80 drivers/media/usb/dvb-usb/cinergyT2-fe.c:271 [<00000000ae0b1711>] cinergyt2_frontend_attach+0x21/0x70 drivers/media/usb/dvb-usb/cinergyT2-core.c:74 [<00000000d0254861>] dvb_usb_adapter_frontend_init+0x11b/0x1b0 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290 [<0000000002e08ac6>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:84 [inline] [<0000000002e08ac6>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:173 [inline] [<0000000002e08ac6>] dvb_usb_device_init.cold+0x4d0/0x6ae drivers/media/usb/dvb-usb/dvb-usb-init.c:287
--- drivers/media/usb/dvb-usb/cinergyT2-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/dvb-usb/cinergyT2-core.c +2 -0
@@ -78,6 +78,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap) ret =dvb_usb_generic_rw (d, st->data,1 , st->data,3 ,0 );if (ret <0 ) { +if (adap->fe_adap[0 ].fe) + adap->fe_adap[0 ].fe->ops.release (adap->fe_adap[0 ].fe);deb_rc ("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n" ); }mutex_unlock (&d->data_mutex);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 143/593 memstick: rtsx_usb_ms: fix UAF
In reply to Greg Kroah-HartmanFrom: Tong Zhang <[email protected]>
[ Upstream commit 42933c8aa14be1caa9eda41f65cde8a3a95d3e39 ]
This patch fixes the following issues:
1. memstick_free_host() will free the host, so the use of ms_dev(host) after it will be a problem. To fix this, move memstick_free_host() after when we are done with ms_dev(host).
2. In rtsx_usb_ms_drv_remove(), pm need to be disabled before we remove and free host otherwise memstick_check will be called and UAF will happen.
[ 11.351173] BUG: KASAN: use-after-free in rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms] [ 11.357077] rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms] [ 11.357376] platform_remove+0x2a/0x50 [ 11.367531] Freed by task 298: [ 11.368537] kfree+0xa4/0x2a0 [ 11.368711] device_release+0x51/0xe0 [ 11.368905] kobject_put+0xa2/0x120 [ 11.369090] rtsx_usb_ms_drv_remove+0x8c/0x140 [rtsx_usb_ms] [ 11.369386] platform_remove+0x2a/0x50
[ 12.038408] BUG: KASAN: use-after-free in __mutex_lock.isra.0+0x3ec/0x7c0 [ 12.045432] mutex_lock+0xc9/0xd0 [ 12.046080] memstick_check+0x6a/0x578 [memstick] [ 12.046509] process_one_work+0x46d/0x750 [ 12.052107] Freed by task 297: [ 12.053115] kfree+0xa4/0x2a0 [ 12.053272] device_release+0x51/0xe0 [ 12.053463] kobject_put+0xa2/0x120 [ 12.053647] rtsx_usb_ms_drv_remove+0xc4/0x140 [rtsx_usb_ms] [ 12.053939] platform_remove+0x2a/0x50
--- drivers/memstick/host/rtsx_usb_ms.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/memstick/host/rtsx_usb_ms.c +4 -6
@@ -799,9 +799,9 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)return 0 ; err_out: -memstick_free_host (msh);pm_runtime_disable (ms_dev (host));pm_runtime_put_noidle (ms_dev (host)); +memstick_free_host (msh);return err; }
@@ -828,9 +828,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev) }mutex_unlock (&host->host_mutex); -memstick_remove_host (msh); -memstick_free_host (msh); -/* Balance possible unbalanced usage count * e.g. unconditional module removal */
@@ -838,10 +835,11 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)pm_runtime_put (ms_dev (host));pm_runtime_disable (ms_dev (host)); -platform_set_drvdata (pdev,NULL ); - +memstick_remove_host (msh);dev_dbg (ms_dev (host),": Realtek USB Memstick controller has been removed\n" ); +memstick_free_host (msh); +platform_set_drvdata (pdev,NULL );return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 144/593 mmc: sdhci-sprd: use sdhci_sprd_writew
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 961470820021e6f9d74db4837bd6831a1a30341b ]
The sdhci_sprd_writew() was defined by never used in sdhci_ops:
drivers/mmc/host/sdhci-sprd.c:134:20: warning: unused function 'sdhci_sprd_writew'
--- drivers/mmc/host/sdhci-sprd.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-sprd.c +1 -0
@@ -393,6 +393,7 @@ static void sdhci_sprd_request_done(struct sdhci_host *host,static struct sdhci_ops sdhci_sprd_ops = { .read_l = sdhci_sprd_readl, .write_l = sdhci_sprd_writel, + .write_w = sdhci_sprd_writew, .write_b = sdhci_sprd_writeb, .set_clock = sdhci_sprd_set_clock, .get_max_clock = sdhci_sprd_get_max_clock,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 145/593 mmc: via-sdmmc: add a check against NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 45c8ddd06c4b729c56a6083ab311bfbd9643f4a6 ]
Before referencing 'host->data', the driver needs to check whether it is null pointer, otherwise it will cause a null pointer reference.
This log reveals it:
[ 29.355199] BUG: kernel NULL pointer dereference, address: 0000000000000014 [ 29.357323] #PF: supervisor write access in kernel mode [ 29.357706] #PF: error_code(0x0002) - not-present page [ 29.358088] PGD 0 P4D 0 [ 29.358280] Oops: 0002 [#1] PREEMPT SMP PTI [ 29.358595] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.12.4- g70e7f0549188-dirty #102 [ 29.359164] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [ 29.359978] RIP: 0010:via_sdc_isr+0x21f/0x410 [ 29.360314] Code: ff ff e8 84 aa d0 fd 66 45 89 7e 28 66 41 f7 c4 00 10 75 56 e8 72 aa d0 fd 66 41 f7 c4 00 c0 74 10 e8 65 aa d0 fd 48 8b 43 18 <c7> 40 14 ac ff ff ff e8 55 aa d0 fd 48 89 df e8 ad fb ff ff e9 77 [ 29.361661] RSP: 0018:ffffc90000118e98 EFLAGS: 00010046 [ 29.362042] RAX: 0000000000000000 RBX: ffff888107d77880 RCX: 0000000000000000 [ 29.362564] RDX: 0000000000000000 RSI: ffffffff835d20bb RDI: 00000000ffffffff [ 29.363085] RBP: ffffc90000118ed8 R08: 0000000000000001 R09: 0000000000000001 [ 29.363604] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000008600 [ 29.364128] R13: ffff888107d779c8 R14: ffffc90009c00200 R15: 0000000000008000 [ 29.364651] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 29.365235] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.365655] CR2: 0000000000000014 CR3: 0000000005a2e000 CR4: 00000000000006e0 [ 29.366170] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 29.366683] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 29.367197] Call Trace: [ 29.367381] <IRQ> [ 29.367537] __handle_irq_event_percpu+0x53/0x3e0 [ 29.367916] handle_irq_event_percpu+0x35/0x90 [ 29.368247] handle_irq_event+0x39/0x60 [ 29.368632] handle_fasteoi_irq+0xc2/0x1d0 [ 29.368950] __common_interrupt+0x7f/0x150 [ 29.369254] common_interrupt+0xb4/0xd0 [ 29.369547] </IRQ> [ 29.369708] asm_common_interrupt+0x1e/0x40 [ 29.370016] RIP: 0010:native_safe_halt+0x17/0x20 [ 29.370360] Code: 07 0f 00 2d db 80 43 00 f4 5d c3 0f 1f 84 00 00 00 00 00 8b 05 c2 37 e5 01 55 48 89 e5 85 c0 7e 07 0f 00 2d bb 80 43 00 fb f4 <5d> c3 cc cc cc cc cc cc cc 55 48 89 e5 e8 67 53 ff ff 8b 0d f9 91 [ 29.371696] RSP: 0018:ffffc9000008fe90 EFLAGS: 00000246 [ 29.372079] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000 [ 29.372595] RDX: 0000000000000000 RSI: ffffffff854f67a4 RDI: ffffffff85403406 [ 29.373122] RBP: ffffc9000008fe90 R08: 0000000000000001 R09: 0000000000000001 [ 29.373646] R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff86009188 [ 29.374160] R13: 0000000000000000 R14: 0000000000000000 R15: ffff888100258000 [ 29.374690] default_idle+0x9/0x10 [ 29.374944] arch_cpu_idle+0xa/0x10 [ 29.375198] default_idle_call+0x6e/0x250 [ 29.375491] do_idle+0x1f0/0x2d0 [ 29.375740] cpu_startup_entry+0x18/0x20 [ 29.376034] start_secondary+0x11f/0x160 [ 29.376328] secondary_startup_64_no_verify+0xb0/0xbb [ 29.376705] Modules linked in: [ 29.376939] Dumping ftrace buffer: [ 29.377187] (ftrace buffer empty) [ 29.377460] CR2: 0000000000000014 [ 29.377712] ---[ end trace 51a473dffb618c47 ]--- [ 29.378056] RIP: 0010:via_sdc_isr+0x21f/0x410 [ 29.378380] Code: ff ff e8 84 aa d0 fd 66 45 89 7e 28 66 41 f7 c4 00 10 75 56 e8 72 aa d0 fd 66 41 f7 c4 00 c0 74 10 e8 65 aa d0 fd 48 8b 43 18 <c7> 40 14 ac ff ff ff e8 55 aa d0 fd 48 89 df e8 ad fb ff ff e9 77 [ 29.379714] RSP: 0018:ffffc90000118e98 EFLAGS: 00010046 [ 29.380098] RAX: 0000000000000000 RBX: ffff888107d77880 RCX: 0000000000000000 [ 29.380614] RDX: 0000000000000000 RSI: ffffffff835d20bb RDI: 00000000ffffffff [ 29.381134] RBP: ffffc90000118ed8 R08: 0000000000000001 R09: 0000000000000001 [ 29.381653] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000008600 [ 29.382176] R13: ffff888107d779c8 R14: ffffc90009c00200 R15: 0000000000008000 [ 29.382697] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 29.383277] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.383697] CR2: 0000000000000014 CR3: 0000000005a2e000 CR4: 00000000000006e0 [ 29.384223] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 29.384736] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 29.385260] Kernel panic - not syncing: Fatal exception in interrupt [ 29.385882] Dumping ftrace buffer: [ 29.386135] (ftrace buffer empty) [ 29.386401] Kernel Offset: disabled [ 29.386656] Rebooting in 1 seconds..
--- drivers/mmc/host/via-sdmmc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/via-sdmmc.c +3 -0
@@ -857,6 +857,9 @@ static void via_sdc_data_isr(struct via_crdr_mmc_host *host, u16 intmask) {BUG_ON (intmask ==0 ); +if (!host->data) +return ; +if (intmask &VIA_CRDR_SDSTS_DT ) host->data->error = -ETIMEDOUT ;else if (intmask & (VIA_CRDR_SDSTS_RC |VIA_CRDR_SDSTS_WC ))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 146/593 spi: meson-spicc: fix a wrong goto jump for avoiding memory leak.
In reply to Greg Kroah-HartmanFrom: zpershuai <[email protected]>
[ Upstream commit 95730d5eb73170a6d225a9998c478be273598634 ]
In meson_spifc_probe function, when enable the device pclk clock is error, it should use clk_disable_unprepare to release the core clock.
--- drivers/spi/spi-meson-spicc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-meson-spicc.c +4 -2
@@ -725,7 +725,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret =clk_prepare_enable (spicc->pclk);if (ret) {dev_err (&pdev->dev,"pclk clock enable failed\n" ); - goto out_master; + goto out_core_clk; }device_reset_optional (&pdev->dev);
@@ -764,9 +764,11 @@ static int meson_spicc_probe(struct platform_device *pdev)return 0 ; out_clk: -clk_disable_unprepare (spicc->core);clk_disable_unprepare (spicc->pclk); +out_core_clk: +clk_disable_unprepare (spicc->core); + out_master:spi_master_put (master);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 147/593 spi: meson-spicc: fix memory leak in meson_spicc_probe
In reply to Greg Kroah-HartmanFrom: zpershuai <[email protected]>
[ Upstream commit b2d501c13470409ee7613855b17e5e5ec4111e1c ]
when meson_spicc_clk_init returns failed, it should goto the out_clk label.
--- drivers/spi/spi-meson-spicc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-meson-spicc.c +1 -1
@@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret =meson_spicc_clk_init (spicc);if (ret) {dev_err (&pdev->dev,"clock registration failed\n" ); - goto out_master; + goto out_clk; } ret =devm_spi_register_master (&pdev->dev, master);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 148/593 crypto: shash - avoid comparing pointers to exported functions under CFI
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 22ca9f4aaf431a9413dcc115dd590123307f274f ]
crypto_shash_alg_has_setkey() is implemented by testing whether the .setkey() member of a struct shash_alg points to the default version, called shash_no_setkey(). As crypto_shash_alg_has_setkey() is a static inline, this requires shash_no_setkey() to be exported to modules.
Unfortunately, when building with CFI, function pointers are routed via CFI stubs which are private to each module (or to the kernel proper) and so this function pointer comparison may fail spuriously.
Let's fix this by turning crypto_shash_alg_has_setkey() into an out of line function.
--- crypto/shash.c | 18 +++++++++++++++--- include/crypto/internal/hash.h | 8 +------- 2 files changed, 16 insertions(+), 10 deletions(-)
crypto/shash.c +15 -3
@@ -20,12 +20,24 @@static const struct crypto_type crypto_shash_type; -int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, -unsigned int keylen) +static int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, +unsigned int keylen) {return -ENOSYS ; } -EXPORT_SYMBOL_GPL (shash_no_setkey); + +/* +* Check whether an shash algorithm has a setkey function. +* +* For CFI compatibility, this must not be an inline function. This is because +* when CFI is enabled, modules won't get the same address for shash_no_setkey +* (if it were exported, which inlining would require) as the core kernel will. +*/ +bool crypto_shash_alg_has_setkey (struct shash_alg *alg) +{ +return alg->setkey != shash_no_setkey; +} +EXPORT_SYMBOL_GPL (crypto_shash_alg_has_setkey);static int shash_setkey_unaligned (struct crypto_shash *tfm,const u8 *key,unsigned int keylen)
include/crypto/internal/hash.h +1 -7
@@ -75,13 +75,7 @@ void crypto_unregister_ahashes(struct ahash_alg *algs, int count);int ahash_register_instance (struct crypto_template *tmpl,struct ahash_instance *inst); -int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, -unsigned int keylen); - -static inline bool crypto_shash_alg_has_setkey (struct shash_alg *alg) -{ -return alg->setkey != shash_no_setkey; -} +bool crypto_shash_alg_has_setkey (struct shash_alg *alg);static inline bool crypto_shash_alg_needs_key (struct shash_alg *alg) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 149/593 media: dvb_net: avoid speculation from net slot
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit abc0226df64dc137b48b911c1fe4319aec5891bb ]
The risk of especulation is actually almost-non-existing here, as there are very few users of TCP/IP using the DVB stack, as, this is mainly used with DVB-S/S2 cards, and only by people that receives TCP/IP from satellite connections, which limits a lot the number of users of such feature(*).
(*) In thesis, DVB-C cards could also benefit from it, but I'm yet to see a hardware that supports it.
Yet, fixing it is trivial.
--- drivers/media/dvb-core/dvb_net.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/media/dvb-core/dvb_net.c +19 -6
@@ -45,6 +45,7 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/netdevice.h> +#include <linux/nospec.h> #include <linux/etherdevice.h> #include <linux/dvb/net.h> #include <linux/uio.h>
@@ -1462,14 +1463,20 @@ static int dvb_net_do_ioctl(struct file *file,struct net_device *netdev;struct dvb_net_priv *priv_data;struct dvb_net_if *dvbnetif = parg; +int if_num = dvbnetif->if_num; -if (dvbnetif->if_num >=DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { +if (if_num >=DVB_NET_DEVICES_MAX ) { ret = -EINVAL ; goto ioctl_error; } + if_num =array_index_nospec (if_num,DVB_NET_DEVICES_MAX ); - netdev = dvbnet->device[dvbnetif->if_num]; +if (!dvbnet->state[if_num]) { + ret = -EINVAL ; + goto ioctl_error; + } + + netdev = dvbnet->device[if_num]; priv_data =netdev_priv (netdev); dvbnetif->pid=priv_data->pid;
@@ -1522,14 +1529,20 @@ static int dvb_net_do_ioctl(struct file *file,struct net_device *netdev;struct dvb_net_priv *priv_data;struct __dvb_net_if_old *dvbnetif = parg; +int if_num = dvbnetif->if_num; + +if (if_num >=DVB_NET_DEVICES_MAX ) { + ret = -EINVAL ; + goto ioctl_error; + } + if_num =array_index_nospec (if_num,DVB_NET_DEVICES_MAX ); -if (dvbnetif->if_num >=DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { +if (!dvbnet->state[if_num]) { ret = -EINVAL ; goto ioctl_error; } - netdev = dvbnet->device[dvbnetif->if_num]; + netdev = dvbnet->device[if_num]; priv_data =netdev_priv (netdev); dvbnetif->pid=priv_data->pid;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 150/593 media: siano: fix device register error path
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 5368b1ee2939961a16e74972b69088433fc52195 ]
As reported by smatch:
drivers/media/common/siano/smsdvb-main.c:1231 smsdvb_hotplug() warn: '&client->entry' not removed from list
If an error occur at the end of the registration logic, it won't drop the device from the list.
--- drivers/media/common/siano/smsdvb-main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/common/siano/smsdvb-main.c +4 -0
@@ -1176,6 +1176,10 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,return 0 ; media_graph_error: +mutex_lock (&g_smsdvb_clientslock); +list_del (&client->entry); +mutex_unlock (&g_smsdvb_clientslock); +smsdvb_debugfs_release (client); client_error:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 151/593 media: imx-csi: Skip first few frames from a BT.656 source
In reply to Greg Kroah-HartmanFrom: Steve Longerbeam <[email protected]>
[ Upstream commit e198be37e52551bb863d07d2edc535d0932a3c4f ]
Some BT.656 sensors (e.g. ADV718x) transmit frames with unstable BT.656 sync codes after initial power on. This confuses the imx CSI,resulting in vertical and/or horizontal sync issues. Skip the first 20 frames to avoid the unstable sync codes.
[fabio: fixed checkpatch warning and increased the frame skipping to 20]
--- drivers/staging/media/imx/imx-media-csi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-csi.c +13 -1
@@ -753,9 +753,10 @@ static int csi_setup(struct csi_priv *priv)static int csi_start (struct csi_priv *priv) { -struct v4l2_fract *output_fi; +struct v4l2_fract *input_fi, *output_fi;int ret; + input_fi = &priv->frame_interval[CSI_SINK_PAD ]; output_fi = &priv->frame_interval[priv->active_output_pad];/* start upstream */
@@ -764,6 +765,17 @@ static int csi_start(struct csi_priv *priv)if (ret)return ret; +/* Skip first few frames from a BT.656 source */ +if (priv->upstream_ep.bus_type ==V4L2_MBUS_BT656 ) { +u32 delay_usec, bad_frames =20 ; + + delay_usec =DIV_ROUND_UP_ULL ((u64 )USEC_PER_SEC * + input_fi->numerator * bad_frames, + input_fi->denominator); + +usleep_range (delay_usec, delay_usec +1000 ); + } +if (priv->dest ==IPU_CSI_DEST_IDMAC ) { ret =csi_idmac_start (priv);if (ret)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 152/593 hwmon: (max31790) Report correct current pwm duty cycles
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 897f6339893b741a5d68ae8e2475df65946041c2 ]
The MAX31790 has two sets of registers for pwm duty cycles, one to request a duty cycle and one to read the actual current duty cycle. Both do not have to be the same.
When reporting the pwm duty cycle to the user, the actual pwm duty cycle from pwm duty cycle registers needs to be reported. When setting it, the pwm target duty cycle needs to be written. Since we don't know the actual pwm duty cycle after a target pwm duty cycle has been written, set the valid flag to false to indicate that actual pwm duty cycle should be read from the chip instead of using cached values.
--- Documentation/hwmon/max31790.rst | 3 ++- drivers/hwmon/max31790.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-)
Documentation/hwmon/max31790.rst +2 -1
@@ -39,5 +39,6 @@ fan[1-12]_input RO fan tachometer speed in RPM fan[1-12]_fault RO fan experienced fault fan[1-6]_target RW desired fan speed in RPM pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode -pwm[1-6] RW fan target duty cycle (0-255) +pwm[1-6] RW read: current pwm duty cycle, + write: target pwm duty cycle (0-255) ================== === =======================================================
drivers/hwmon/max31790.c +3 -3
@@ -104,7 +104,7 @@ static struct max31790_data *max31790_update_device(struct device *dev) data->tach[NR_CHANNEL + i] = rv; }else { rv =i2c_smbus_read_word_swapped (client, -MAX31790_REG_PWMOUT (i)); +MAX31790_REG_PWM_DUTY_CYCLE (i));if (rv <0 ) goto abort; data->pwm[i] = rv;
@@ -299,10 +299,10 @@ static int max31790_write_pwm(struct device *dev, u32 attr, int channel, err = -EINVAL ;break ; } - data->pwm[channel] = val <<8 ; + data->valid = false; err =i2c_smbus_write_word_swapped (client,MAX31790_REG_PWMOUT (channel), - data->pwm[channel]); + val <<8 );break ;case hwmon_pwm_enable: fan_config = data->fan_config[channel];
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 153/593 hwmon: (max31790) Fix pwmX_enable attributes
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 148c847c9e5a54b99850617bf9c143af9a344f92 ]
pwmX_enable supports three possible values:
0: Fan control disabled. Duty cycle is fixed to 0% 1: Fan control enabled, pwm mode. Duty cycle is determined by
values written into Target Duty Cycle registers.
2: Fan control enabled, rpm mode
Duty cycle is adjusted such that fan speed matches the values in Target Count registers
The current code does not do this; instead, it mixes pwm control configuration with fan speed monitoring configuration. Worse, it reports that pwm control would be disabled (pwmX_enable==0) when it is in fact enabled in pwm mode. Part of the problem may be that the chip sets the "TACH input enable" bit on its own whenever the mode bit is set to RPM mode, but that doesn't mean that "TACH input enable" accurately reflects the pwm mode.
Fix it up and only handle pwm control with the pwmX_enable attributes. In the documentation, clarify that disabling pwm control (pwmX_enable=0) sets the pwm duty cycle to 0%. In the code, explain why TACH_INPUT_EN is set together with RPM_MODE.
While at it, only update the configuration register if the configuration has changed, and only update the cached configuration if updating the chip configuration was successful.
--- Documentation/hwmon/max31790.rst | 2 +- drivers/hwmon/max31790.c | 41 ++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 16 deletions(-)
Documentation/hwmon/max31790.rst +1 -1
@@ -38,7 +38,7 @@ Sysfs entries fan[1-12]_input RO fan tachometer speed in RPM fan[1-12]_fault RO fan experienced fault fan[1-6]_target RW desired fan speed in RPM -pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode +pwm[1-6]_enable RW regulator mode, 0=disabled (duty cycle=0%), 1=manual mode, 2=rpm mode pwm[1-6] RW read: current pwm duty cycle, write: target pwm duty cycle (0-255) ================== === =======================================================
drivers/hwmon/max31790.c +26 -15
67 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 154/593 drivers/perf: fix the missed ida_simple_remove() in ddr_perf_probe()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit d96b1b8c9f79b6bb234a31c80972a6f422079376 ]
ddr_perf_probe() misses to call ida_simple_remove() in an error path. Jump to cpuhp_state_err to fix it.
--- drivers/perf/fsl_imx8_ddr_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/perf/fsl_imx8_ddr_perf.c +4 -2
@@ -623,8 +623,10 @@ static int ddr_perf_probe(struct platform_device *pdev) name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DDR_PERF_DEV_NAME "%d" , num); -if (!name) -return -ENOMEM ; +if (!name) { + ret = -ENOMEM ; + goto cpuhp_state_err; + } pmu->devtype_data =of_device_get_match_data (&pdev->dev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 155/593 KVM: PPC: Book3S HV: Fix TLB management on SMT8 POWER9 and POWER10 processors
In reply to Greg Kroah-HartmanFrom: Suraj Jitindar Singh <[email protected]>
[ Upstream commit 77bbbc0cf84834ed130838f7ac1988567f4d0288 ]
The POWER9 vCPU TLB management code assumes all threads in a core share a TLB, and that TLBIEL execued by one thread will invalidate TLBs for all threads. This is not the case for SMT8 capable POWER9 and POWER10 (big core) processors, where the TLB is split between groups of threads. This results in TLB multi-hits, random data corruption, etc.
Fix this by introducing cpu_first_tlb_thread_sibling etc., to determine which siblings share TLBs, and use that in the guest TLB flushing code.
[[email protected]: add changelog and comment]
--- arch/powerpc/include/asm/cputhreads.h | 30 +++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 13 ++++++------ arch/powerpc/kvm/book3s_hv_builtin.c | 2 +- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- 4 files changed, 39 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/cputhreads.h +30 -0
@@ -98,6 +98,36 @@ static inline int cpu_last_thread_sibling(int cpu)return cpu | (threads_per_core -1 ); } +/* +* tlb_thread_siblings are siblings which share a TLB. This is not +* architected, is not something a hypervisor could emulate and a future +* CPU may change behaviour even in compat mode, so this should only be +* used on PowerNV, and only with care. +*/ +static inline int cpu_first_tlb_thread_sibling (int cpu) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return cpu & ~0x6 ;/* Big Core */ +else +return cpu_first_thread_sibling (cpu); +} + +static inline int cpu_last_tlb_thread_sibling (int cpu) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return cpu |0x6 ;/* Big Core */ +else +return cpu_last_thread_sibling (cpu); +} + +static inline int cpu_tlb_thread_sibling_step (void ) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return 2 ;/* Big Core */ +else +return 1 ; +} +static inline u32 get_tensr (void ) {#ifdef CONFIG_BOOKE
arch/powerpc/kvm/book3s_hv.c +7 -6
@@ -2578,7 +2578,7 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)cpumask_t *cpu_in_guest;int i; - cpu =cpu_first_thread_sibling (cpu); + cpu =cpu_first_tlb_thread_sibling (cpu);if (nested) {cpumask_set_cpu (cpu, &nested->need_tlb_flush); cpu_in_guest = &nested->cpu_in_guest;
@@ -2592,9 +2592,10 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)* the other side is the first smp_mb() in kvmppc_run_core(). */ smp_mb (); -for (i =0 ; i < threads_per_core; ++i) -if (cpumask_test_cpu (cpu + i, cpu_in_guest)) -smp_call_function_single (cpu + i, do_nothing,NULL ,1 ); +for (i = cpu; i <=cpu_last_tlb_thread_sibling (cpu); + i +=cpu_tlb_thread_sibling_step ()) +if (cpumask_test_cpu (i, cpu_in_guest)) +smp_call_function_single (i, do_nothing,NULL ,1 ); }static void kvmppc_prepare_radix_vcpu (struct kvm_vcpu *vcpu,int pcpu)
@@ -2625,8 +2626,8 @@ static void kvmppc_prepare_radix_vcpu(struct kvm_vcpu *vcpu, int pcpu)*/ if (prev_cpu != pcpu) {if (prev_cpu >=0 && -cpu_first_thread_sibling (prev_cpu) != -cpu_first_thread_sibling (pcpu)) +cpu_first_tlb_thread_sibling (prev_cpu) != +cpu_first_tlb_thread_sibling (pcpu))radix_flush_cpu (kvm, prev_cpu, vcpu);if (nested) nested->prev_cpu[vcpu->arch.nested_vcpu_id] = pcpu;
arch/powerpc/kvm/book3s_hv_builtin.c +1 -1
@@ -893,7 +893,7 @@ void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,* Thus we make all 4 threads use the same bit. */ if (cpu_has_feature (CPU_FTR_ARCH_300 )) - pcpu =cpu_first_thread_sibling (pcpu); + pcpu =cpu_first_tlb_thread_sibling (pcpu);if (nested) need_tlb_flush = &nested->need_tlb_flush;
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
@@ -67,7 +67,7 @@ static int global_invalidates(struct kvm *kvm)* so use the bit for the first thread to represent the core. */ if (cpu_has_feature (CPU_FTR_ARCH_300 )) - cpu =cpu_first_thread_sibling (cpu); + cpu =cpu_first_tlb_thread_sibling (cpu);cpumask_clear_cpu (cpu, &kvm->arch.need_tlb_flush); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 156/593 btrfs: fix error handling in __btrfs_update_delayed_inode
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit bb385bedded3ccbd794559600de4a09448810f4a ]
If we get an error while looking up the inode item we'll simply bail without cleaning up the delayed node. This results in this style of warning happening on commit:
WARNING: CPU: 0 PID: 76403 at fs/btrfs/delayed-inode.c:1365 btrfs_assert_delayed_root_empty+0x5b/0x90 CPU: 0 PID: 76403 Comm: fsstress Tainted: G W 5.13.0-rc1+ #373 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 RIP: 0010:btrfs_assert_delayed_root_empty+0x5b/0x90 RSP: 0018:ffffb8bb815a7e50 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff95d6d07e1888 RCX: ffff95d6c0fa3000 RDX: 0000000000000002 RSI: 000000000029e91c RDI: ffff95d6c0fc8060 RBP: ffff95d6c0fc8060 R08: 00008d6d701a2c1d R09: 0000000000000000 R10: ffff95d6d1760ea0 R11: 0000000000000001 R12: ffff95d6c15a4d00 R13: ffff95d6c0fa3000 R14: 0000000000000000 R15: ffffb8bb815a7e90 FS: 00007f490e8dbb80(0000) GS:ffff95d73bc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6e75555cb0 CR3: 00000001101ce001 CR4: 0000000000370ef0 Call Trace: btrfs_commit_transaction+0x43c/0xb00 ? finish_wait+0x80/0x80 ? vfs_fsync_range+0x90/0x90 iterate_supers+0x8c/0x100 ksys_sync+0x50/0x90 __do_sys_sync+0xa/0x10 do_syscall_64+0x3d/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae
Because the iref isn't dropped and this leaves an elevated node->count, so any release just re-queues it onto the delayed inodes list. Fix this by going to the out label to handle the proper cleanup of the delayed node.
--- fs/btrfs/delayed-inode.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/btrfs/delayed-inode.c +4 -6
@@ -1032,12 +1032,10 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans, nofs_flag =memalloc_nofs_save (); ret =btrfs_lookup_inode (trans, root, path, &key, mod);memalloc_nofs_restore (nofs_flag); -if (ret >0 ) { -btrfs_release_path (path); -return -ENOENT ; - }else if (ret <0 ) { -return ret; - } +if (ret >0 ) + ret = -ENOENT ; +if (ret <0 ) + goto out; leaf = path->nodes[0 ]; inode_item = btrfs_item_ptr(leaf, path->slots[0],
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 157/593 btrfs: abort transaction if we fail to update the delayed inode
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 04587ad9bef6ce9d510325b4ba9852b6129eebdb ]
If we fail to update the delayed inode we need to abort the transaction, because we could leave an inode with the improper counts or some other such corruption behind.
--- fs/btrfs/delayed-inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/delayed-inode.c +8 -0
@@ -1073,6 +1073,14 @@ err_out:btrfs_delayed_inode_release_metadata (fs_info, node, (ret <0 ));btrfs_release_delayed_inode (node); +/* +* If we fail to update the delayed inode we need to abort the +* transaction, because we could leave the inode with the improper +* counts behind. +*/ +if (ret && ret != -ENOENT ) +btrfs_abort_transaction (trans, ret); +return ret; search:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 158/593 btrfs: sysfs: fix format string for some discard stats
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
[ Upstream commit 8c5ec995616f1202ab92e195fd75d6f60d86f85c ]
The type of discard_bitmap_bytes and discard_extent_bytes is u64 so the format should be %llu, though the actual values would hardly ever overflow to negative values.
--- fs/btrfs/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/sysfs.c +2 -2
@@ -382,7 +382,7 @@ static ssize_t btrfs_discard_bitmap_bytes_show(struct kobject *kobj, {struct btrfs_fs_info *fs_info =discard_to_fs_info (kobj); -return scnprintf (buf,PAGE_SIZE ,"%lld\n" , +return scnprintf (buf,PAGE_SIZE ,"%llu\n" , fs_info->discard_ctl.discard_bitmap_bytes); }BTRFS_ATTR (discard, discard_bitmap_bytes, btrfs_discard_bitmap_bytes_show);
@@ -404,7 +404,7 @@ static ssize_t btrfs_discard_extent_bytes_show(struct kobject *kobj, {struct btrfs_fs_info *fs_info =discard_to_fs_info (kobj); -return scnprintf (buf,PAGE_SIZE ,"%lld\n" , +return scnprintf (buf,PAGE_SIZE ,"%llu\n" , fs_info->discard_ctl.discard_extent_bytes); }BTRFS_ATTR (discard, discard_extent_bytes, btrfs_discard_extent_bytes_show);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 159/593 btrfs: dont clear page extent mapped if were not invalidating the full page
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit bcd77455d590eaa0422a5e84ae852007cfce574a ]
[BUG]
With current btrfs subpage rw support, the following script can lead to fs hang:
$ mkfs.btrfs -f -s 4k $dev $ mount $dev -o nospace_cache $mnt $ fsstress -w -n 100 -p 1 -s 1608140256 -v -d $mnt
The fs will hang at btrfs_start_ordered_extent().
[CAUSE]
In above test case, btrfs_invalidate() will be called with the following parameters:
offset = 0 length = 53248 page dirty = 1 subpage dirty bitmap = 0x2000
Since @offset is 0, btrfs_invalidate() will try to invalidate the full page, and finally call clear_page_extent_mapped() which will detach subpage structure from the page.
And since the page no longer has subpage structure, the subpage dirty bitmap will be cleared, preventing the dirty range from being written back, thus no way to wake up the ordered extent.
[FIX]
Just follow other filesystems, only to invalidate the page if the range covers the full page.
There are cases like truncate_setsize() which can call btrfs_invalidatepage() with offset == 0 and length != 0 for the last page of an inode.
Although the old code will still try to invalidate the full page, we are still safe to just wait for ordered extent to finish.
So it shouldn't cause extra problems.
--- fs/btrfs/inode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +13 -1
@@ -8213,7 +8213,19 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,*/ wait_on_page_writeback (page); -if (offset) { +/* +* For subpage case, we have call sites like +* btrfs_punch_hole_lock_range() which passes range not aligned to +* sectorsize. +* If the range doesn't cover the full page, we don't need to and +* shouldn't clear page extent mapped, as page->private can still +* record subpage dirty bits for other part of the range. +* +* For cases that can invalidate the full even the range doesn't +* cover the full page, like invalidating the last page, we're +* still safe to wait for ordered extent to finish. +*/ +if (!(offset ==0 && length ==PAGE_SIZE )) {btrfs_releasepage (page,GFP_NOFS );return ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 160/593 btrfs: disable build on platforms having page size 256K
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit b05fbcc36be1f8597a1febef4892053a0b2f3f60 ]
With a config having PAGE_SIZE set to 256K, BTRFS build fails with the following message
include/linux/compiler_types.h:326:38: error: call to '__compiletime_assert_791' declared with attribute error:
BUILD_BUG_ON failed: (BTRFS_MAX_COMPRESSED % PAGE_SIZE) != 0
BTRFS_MAX_COMPRESSED being 128K, BTRFS cannot support platforms with 256K pages at the time being.
There are two platforms that can select 256K pages:
- hexagon
- powerpc
Disable BTRFS when 256K page size is selected. Supporting this would require changes to the subpage mode that's currently being developed. Given that 256K is many times larger than page sizes commonly used and for what the algorithms and structures have been tuned, it's out of scope and disabling build is a reasonable option.
--- fs/btrfs/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/Kconfig +2 -0
@@ -18,6 +18,8 @@ config BTRFS_FS select RAID6_PQ select XOR_BLOCKS select SRCU + depends on !PPC_256K_PAGES # powerpc + depends on !PAGE_SIZE_256KB # hexagon help Btrfs is a general purpose copy-on-write filesystem with extents,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 161/593 locking/lockdep: Fix the dep path printing for backwards BFS
In reply to Greg Kroah-HartmanFrom: Boqun Feng <[email protected]>
[ Upstream commit 69c7a5fb2482636f525f016c8333fdb9111ecb9d ]
We use the same code to print backwards lock dependency path as the forwards lock dependency path, and this could result into incorrect printing because for a backwards lock_list ->trace is not the call trace where the lock of ->class is acquired.
Fix this by introducing a separate function on printing the backwards dependency path. Also add a few comments about the printing while we are at it.
--- kernel/locking/lockdep.c | 108 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-)
kernel/locking/lockdep.c +106 -2
@@ -2297,7 +2297,56 @@ static void print_lock_class_header(struct lock_class *class, int depth) }/* -* printk the shortest lock dependencies from @start to @end in reverse order: +* Dependency path printing: +* +* After BFS we get a lock dependency path (linked via ->parent of lock_list), +* printing out each lock in the dependency path will help on understanding how +* the deadlock could happen. Here are some details about dependency path +* printing: +* +* 1) A lock_list can be either forwards or backwards for a lock dependency, +* for a lock dependency A -> B, there are two lock_lists: +* +* a) lock_list in the ->locks_after list of A, whose ->class is B and +* ->links_to is A. In this case, we can say the lock_list is +* "A -> B" (forwards case). +* +* b) lock_list in the ->locks_before list of B, whose ->class is A +* and ->links_to is B. In this case, we can say the lock_list is +* "B <- A" (bacwards case). +* +* The ->trace of both a) and b) point to the call trace where B was +* acquired with A held. +* +* 2) A "helper" lock_list is introduced during BFS, this lock_list doesn't +* represent a certain lock dependency, it only provides an initial entry +* for BFS. For example, BFS may introduce a "helper" lock_list whose +* ->class is A, as a result BFS will search all dependencies starting with +* A, e.g. A -> B or A -> C. +* +* The notation of a forwards helper lock_list is like "-> A", which means +* we should search the forwards dependencies starting with "A", e.g A -> B +* or A -> C. +* +* The notation of a bacwards helper lock_list is like "<- B", which means +* we should search the backwards dependencies ending with "B", e.g. +* B <- A or B <- C. +*/ + +/* +* printk the shortest lock dependencies from @root to @leaf in reverse order. +* +* We have a lock dependency path as follow: +* +* @root @leaf +* | | +* V V +* ->parent ->parent +* | lock_list | <--------- | lock_list | ... | lock_list | <--------- | lock_list | +* | -> L1 | | L1 -> L2 | ... |Ln-2 -> Ln-1| | Ln-1 -> Ln| +* +* , so it's natural that we start from @leaf and print every ->class and +* ->trace until we reach the @root. */ static void __used print_shortest_lock_dependencies(struct lock_list *leaf,
@@ -2325,6 +2374,61 @@ print_shortest_lock_dependencies(struct lock_list *leaf, }while (entry && (depth >=0 )); } +/* +* printk the shortest lock dependencies from @leaf to @root. +* +* We have a lock dependency path (from a backwards search) as follow: +* +* @leaf @root +* | | +* V V +* ->parent ->parent +* | lock_list | ---------> | lock_list | ... | lock_list | ---------> | lock_list | +* | L2 <- L1 | | L3 <- L2 | ... | Ln <- Ln-1 | | <- Ln | +* +* , so when we iterate from @leaf to @root, we actually print the lock +* dependency path L1 -> L2 -> .. -> Ln in the non-reverse order. +* +* Another thing to notice here is that ->class of L2 <- L1 is L1, while the +* ->trace of L2 <- L1 is the call trace of L2, in fact we don't have the call +* trace of L1 in the dependency path, which is alright, because most of the +* time we can figure out where L1 is held from the call trace of L2. +*/ +static void __used +print_shortest_lock_dependencies_backwards (struct lock_list *leaf, +struct lock_list *root) +{ +struct lock_list *entry = leaf; +const struct lock_trace *trace =NULL ; +int depth; + +/*compute depth from generated tree by BFS*/ + depth =get_lock_depth (leaf); + +do { +print_lock_class_header (entry->class, depth); +if (trace) { +printk ("%*s ... acquired at:\n" , depth,"" ); +print_lock_trace (trace,2 ); +printk ("\n" ); + } + +/* +* Record the pointer to the trace for the next lock_list +* entry, see the comments for the function. +*/ + trace = entry->trace; + +if (depth ==0 && (entry != root)) { +printk ("lockdep:%s bad path found in chain graph\n" , __func__); +break ; + } + + entry =get_lock_parent (entry); + depth--; + }while (entry && (depth >=0 )); +} + static void print_irq_lock_scenario(struct lock_list *safe_entry, struct lock_list *unsafe_entry,
@@ -2442,7 +2546,7 @@ print_bad_irq_dependency(struct task_struct *curr, prev_root->trace =save_trace ();if (!prev_root->trace)return ; -print_shortest_lock_dependencies (backwards_entry, prev_root); +print_shortest_lock_dependencies_backwards (backwards_entry, prev_root);pr_warn ("\nthe dependencies between the lock to be acquired" );pr_warn (" and %s-irq-unsafe lock:\n" , irqclass);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 162/593 lockding/lockdep: Avoid to find wrong lock dep path in check_irq_usage()
In reply to Greg Kroah-HartmanFrom: Boqun Feng <[email protected]>
[ Upstream commit 7b1f8c6179769af6ffa055e1169610b51d71edd5 ]
In the step #3 of check_irq_usage(), we seach backwards to find a lock whose usage conflicts the usage of @target_entry1 on safe/unsafe. However, we should only keep the irq-unsafe usage of @target_entry1 into consideration, because it could be a case where a lock is hardirq-unsafe but soft-safe, and in check_irq_usage() we find it because its hardirq-unsafe could result into a hardirq-safe-unsafe deadlock, but currently since we don't filter out the other usage bits, so we may find a lock dependency path softirq-unsafe -> softirq-safe, which in fact doesn't cause a deadlock. And this may cause misleading lockdep splats.
Fix this by only keeping LOCKF_ENABLED_IRQ_ALL bits when we try the backwards search.
--- kernel/locking/lockdep.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/locking/lockdep.c +11 -1
@@ -2764,8 +2764,18 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,* Step 3: we found a bad match! Now retrieve a lock from the backward * list whose usage mask matches the exclusive usage mask from the * lock found on the forward list. +* +* Note, we should only keep the LOCKF_ENABLED_IRQ_ALL bits, considering +* the follow case: +* +* When trying to add A -> B to the graph, we find that there is a +* hardirq-safe L, that L -> ... -> A, and another hardirq-unsafe M, +* that B -> ... -> M. However M is **softirq-safe**, if we use exact +* invert bits of M's usage_mask, we will find another lock N that is +* **softirq-unsafe** and N -> ... -> A, however N -> .. -> M will not +* cause a inversion deadlock. */ - backward_mask =original_mask (target_entry1->class->usage_mask); + backward_mask =original_mask (target_entry1->class->usage_mask &LOCKF_ENABLED_IRQ_ALL ); ret =find_usage_backwards (&this, backward_mask, &target_entry);if (bfs_error (ret)) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 163/593 KVM: s390: get rid of register asm usage
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
[ Upstream commit 4fa3b91bdee1b08348c82660668ca0ca34e271ad ]
Using register asm statements has been proven to be very error prone, especially when using code instrumentation where gcc may add function calls, which clobbers register contents in an unexpected way.
Therefore get rid of register asm statements in kvm code, even though there is currently nothing wrong with them. This way we know for sure that this bug class won't be introduced here.
--- arch/s390/kvm/kvm-s390.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/s390/kvm/kvm-s390.c +9 -9
@@ -327,31 +327,31 @@ static void allow_cpu_feat(unsigned long nr)static inline int plo_test_bit (unsigned char nr) { - register unsigned long r0 asm("0") = (unsigned long) nr | 0x100; +unsigned long function = (unsigned long )nr |0x100 ;int cc; asmvolatile ( +" lgr 0,%[function]\n" /* Parameter registers are ignored for "test bit" */ " plo 0,0,0,0(0)\n" " ipm %0\n" " srl %0,28\n" :"=d" (cc) - :"d" (r0) - :"cc" ); + : [function]"d" (function) + :"cc" ,"0" );return cc ==0 ; } static __always_inline void __insn32_query(unsigned int opcode, u8 *query) { - register unsigned long r0 asm("0") = 0; /* query function */ - register unsigned long r1 asm("1") = (unsigned long) query; - asmvolatile ( -/* Parameter regs are ignored */ +" lghi 0,0\n" +" lgr 1,%[query]\n" +/* Parameter registers are ignored */ " .insn rrf,%[opc] << 16,2,4,6,0\n" : - :"d" (r0),"a" (r1), [opc]"i" (opcode) - :"cc" ,"memory" ); + : [query]"d" ((unsigned long )query), [opc]"i" (opcode) + :"cc" ,"memory" ,"0" ,"1" ); }#define INSN_SORTL 0xb938
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 164/593 regulator: mt6358: Fix vdram2 .vsel_mask
In reply to Greg Kroah-HartmanFrom: Hsin-Hsiung Wang <[email protected]>
[ Upstream commit 50c9462edcbf900f3d5097ca3ad60171346124de ]
The valid vsel value are 0 and 12, so the .vsel_mask should be 0xf.
--- drivers/regulator/mt6358-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mt6358-regulator.c +1 -1
@@ -457,7 +457,7 @@ static struct mt6358_regulator_info mt6358_regulators[] = {MT6358_REG_FIXED ("ldo_vaud28" ,VAUD28 ,MT6358_LDO_VAUD28_CON0 ,0 ,2800000 ),MT6358_LDO ("ldo_vdram2" ,VDRAM2 , vdram2_voltages, vdram2_idx, -MT6358_LDO_VDRAM2_CON0 ,0 ,MT6358_LDO_VDRAM2_ELR0 ,0x10 ,0 ), +MT6358_LDO_VDRAM2_CON0 ,0 ,MT6358_LDO_VDRAM2_ELR0 ,0xf ,0 ),MT6358_LDO ("ldo_vsim1" ,VSIM1 , vsim_voltages, vsim_idx,MT6358_LDO_VSIM1_CON0 ,0 ,MT6358_VSIM1_ANA_CON0 ,0xf00 ,8 ), MT6358_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 165/593 regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit a336dc8f683e5be794186b5643cd34cb28dd2c53 ]
Use DIV_ROUND_UP to prevent truncation by integer division issue. This ensures we return enough delay time.
Also fix returning negative value when new_sel < old_sel.
--- drivers/regulator/da9052-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/da9052-regulator.c +2 -1
@@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,case DA9052_ID_BUCK3 :case DA9052_ID_LDO2 :case DA9052_ID_LDO3 : - ret = (new_sel - old_sel) * info->step_uV /6250 ; + ret =DIV_ROUND_UP (abs (new_sel - old_sel) * info->step_uV, +6250 );break ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 166/593 media: Fix Media Controller API config checks
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit 50e7a31d30e8221632675abed3be306382324ca2 ]
Smatch static checker warns that "mdev" can be null:
sound/usb/media.c:287 snd_media_device_create()
warn: 'mdev' can also be NULL
If CONFIG_MEDIA_CONTROLLER is disabled, this file should not be included in the build.
The below conditions in the sound/usb/Makefile are in place to ensure that media.c isn't included in the build.
sound/usb/Makefile:
snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER &&
(MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)
The following config check in include/media/media-dev-allocator.h is in place to enable the API only when CONFIG_MEDIA_CONTROLLER and CONFIG_USB are enabled.
#if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB)
This check doesn't work as intended when CONFIG_USB=m. When CONFIG_USB=m, CONFIG_USB_MODULE is defined and CONFIG_USB is not. The above config check doesn't catch that CONFIG_USB is defined as a module and disables the API. This results in sound/usb enabling Media Controller specific ALSA driver code, while Media disables the Media Controller API.
Fix the problem requires two changes:
1. Change the check to use IS_ENABLED to detect when CONFIG_USB is enabled as a module or static. Since CONFIG_MEDIA_CONTROLLER is a bool, leave the check unchanged to be consistent with drivers/media/Makefile.
2. Change the drivers/media/mc/Makefile to include mc-dev-allocator.o in mc-objs when CONFIG_USB is enabled.
--- drivers/media/mc/Makefile | 2 +- include/media/media-dev-allocator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/mc/Makefile +1 -1
@@ -3,7 +3,7 @@ mc-objs := mc-device.o mc-devnode.o mc-entity.o \ mc-request.o -ifeq ($(CONFIG_USB),y) +ifneq ($(CONFIG_USB),) mc-objs += mc-dev-allocator.o endif
include/media/media-dev-allocator.h +1 -1
@@ -19,7 +19,7 @@struct usb_device ; -#if defined(CONFIG_MEDIA_CONTROLLER ) && defined(CONFIG_USB ) +#if defined(CONFIG_MEDIA_CONTROLLER ) &&IS_ENABLED (CONFIG_USB )/** * media_device_usb_allocate() - Allocate and return struct &media device *
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 167/593 ACPI: video: use native backlight for GA401/GA502/GA503
In reply to Greg Kroah-HartmanFrom: Luke D Jones <[email protected]>
[ Upstream commit 2dfbacc65d1d2eae587ccb6b93f6280542641858 ]
Force backlight control in these models to use the native interface at /sys/class/backlight/amdgpu_bl0.
--- drivers/acpi/video_detect.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/acpi/video_detect.c +24 -0
@@ -385,6 +385,30 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"), }, }, + { + .callback = video_detect_force_native, + .ident = "ASUSTeK COMPUTER INC. GA401", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "GA401"), + }, + }, + { + .callback = video_detect_force_native, + .ident = "ASUSTeK COMPUTER INC. GA502", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "GA502"), + }, + }, + { + .callback = video_detect_force_native, + .ident = "ASUSTeK COMPUTER INC. GA503", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "GA503"), + }, + }, /* * Desktops which falsely report a backlight and which our heuristics
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 168/593 HID: do not use down_interruptible() when unbinding devices
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit f2145f8dc566c4f3b5a8deb58dcd12bed4e20194 ]
Action of unbinding driver from a device is not cancellable and should not fail, and driver core does not pay attention to the result of "remove" method, therefore using down_interruptible() in hid_device_remove() does not make sense.
--- drivers/hid/hid-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/hid/hid-core.c +3 -7
@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev) {struct hid_device *hdev =to_hid_device (dev);struct hid_driver *hdrv; -int ret =0 ; -if (down_interruptible (&hdev->driver_input_lock)) { - ret = -EINTR ; - goto end; - } +down (&hdev->driver_input_lock); hdev->io_started = false; hdrv = hdev->driver;
@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev)if (!hdev->io_started)up (&hdev->driver_input_lock); -end: -return ret; + +return 0 ; } static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 169/593 EDAC/ti: Add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-HartmanFrom: Bixuan Cui <[email protected]>
[ Upstream commit 0a37f32ba5272b2d4ec8c8d0f6b212b81b578f7e ]
The module misses MODULE_DEVICE_TABLE() for of_device_id tables and thus never autoloads on ID matches.
Add the missing declaration.
--- drivers/edac/ti_edac.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/ti_edac.c +1 -0
@@ -197,6 +197,7 @@ static const struct of_device_id ti_edac_of_match[] = { { .compatible = "ti,emif-dra7xx", .data = (void *)EMIF_TYPE_DRA7 }, {}, }; +MODULE_DEVICE_TABLE (of, ti_edac_of_match);static int _emif_get_id (struct device_node *node) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 170/593 ACPI: processor idle: Fix up C-state latency if not ordered
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit 65ea8f2c6e230bdf71fed0137cf9e9d1b307db32 ]
Generally, the C-state latency is provided by the _CST method or FADT, but some OEM platforms using AMD Picasso, Renoir, Van Gogh, and Cezanne set the C2 latency greater than C3's which causes the C2 state to be skipped.
That will block the core entering PC6, which prevents S0ix working properly on Linux systems.
In other operating systems, the latency values are not validated and this does not cause problems by skipping states.
To avoid this issue on Linux, detect when latencies are not an arithmetic progression and sort them.
--- drivers/acpi/processor_idle.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/acpi/processor_idle.c +40 -0
@@ -16,6 +16,7 @@#include <linux/acpi.h> #include <linux/dmi.h> #include <linux/sched.h> /* need_resched() */ +#include <linux/sort.h> #include <linux/tick.h> #include <linux/cpuidle.h> #include <linux/cpu.h>
@@ -389,10 +390,37 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,return ; } +static int acpi_cst_latency_cmp (const void *a,const void *b) +{ +const struct acpi_processor_cx *x = a, *y = b; + +if (!(x->valid && y->valid)) +return 0 ; +if (x->latency > y->latency) +return 1 ; +if (x->latency < y->latency) +return -1 ; +return 0 ; +} +static void acpi_cst_latency_swap (void *a,void *b,int n) +{ +struct acpi_processor_cx *x = a, *y = b; +u32 tmp; + +if (!(x->valid && y->valid)) +return ; + tmp = x->latency; + x->latency = y->latency; + y->latency = tmp; +} +static int acpi_processor_power_verify (struct acpi_processor *pr) {unsigned int i;unsigned int working =0 ; +unsigned int last_latency =0 ; +unsigned int last_type =0 ; +bool buggy_latency = false; pr->power.timer_broadcast_on_state =INT_MAX ;
@@ -416,12 +444,24 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) }if (!cx->valid)continue ; +if (cx->type >= last_type && cx->latency < last_latency) + buggy_latency = true; + last_latency = cx->latency; + last_type = cx->type;lapic_timer_check_state (i, pr, cx);tsc_check_state (cx->type); working++; } +if (buggy_latency) { +pr_notice ("FW issue: working around C-state latencies out of order\n" ); +sort (&pr->power.states[1 ], max_cstate, +sizeof (struct acpi_processor_cx ), + acpi_cst_latency_cmp, + acpi_cst_latency_swap); + } +lapic_timer_propagate_broadcast (pr);return (working);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 171/593 hv_utils: Fix passing zero to PTR_ERR warning
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit c6a8625fa4c6b0a97860d053271660ccedc3d1b3 ]
Sparse warn this:
drivers/hv/hv_util.c:753 hv_timesync_init() warn:
passing zero to 'PTR_ERR'
Use PTR_ERR_OR_ZERO instead of PTR_ERR to fix this.
--- drivers/hv/hv_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hv/hv_util.c +2 -2
@@ -696,8 +696,8 @@ static int hv_timesync_init(struct hv_util_service *srv)*/ hv_ptp_clock =ptp_clock_register (&ptp_hyperv_info,NULL );if (IS_ERR_OR_NULL (hv_ptp_clock)) { -pr_err ("cannot register PTP clock: %ld\n" , -PTR_ERR (hv_ptp_clock)); +pr_err ("cannot register PTP clock: %d\n" , +PTR_ERR_OR_ZERO (hv_ptp_clock)); hv_ptp_clock =NULL ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 172/593 lib: vsprintf: Fix handling of number field widths in vsscanf
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit 900fdc4573766dd43b847b4f54bd4a1ee2bc7360 ]
The existing code attempted to handle numbers by doing a strto[u]l(), ignoring the field width, and then repeatedly dividing to extract the field out of the full converted value. If the string contains a run of valid digits longer than will fit in a long or long long, this would overflow and no amount of dividing can recover the correct value.
This patch fixes vsscanf() to obey number field widths when parsing the number.
A new _parse_integer_limit() is added that takes a limit for the number of characters to parse. The number field conversion in vsscanf is changed to use this new function.
If a number starts with a radix prefix, the field width must be long enough for at last one digit after the prefix. If not, it will be handled like this:
sscanf("0x4", "%1i", &i): i=0, scanning continues with the 'x' sscanf("0x4", "%2i", &i): i=0, scanning continues with the '4'
This is consistent with the observed behaviour of userland sscanf.
Note that this patch does NOT fix the problem of a single field value overflowing the target type. So for example:
sscanf("123456789abcdef", "%x", &i);Will not produce the correct result because the value obviously overflows INT_MAX. But sscanf will report a successful conversion.
Note that where a very large number is used to mean "unlimited", the value INT_MAX is used for consistency with the behaviour of vsnprintf().
--- lib/kstrtox.c | 13 ++++++-- lib/kstrtox.h | 2 ++ lib/vsprintf.c | 82 +++++++++++++++++++++++++++++--------------------- 3 files changed, 60 insertions(+), 37 deletions(-)
lib/kstrtox.c +10 -3
@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)/* * Convert non-negative integer string representation in explicitly given radix -* to an integer. +* to an integer. A maximum of max_chars characters will be converted. +* * Return number of characters consumed maybe or-ed with overflow bit. * If overflow occurs, result integer (incorrect) is still returned. * * Don't you dare use this function. */ -unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *p, +size_t max_chars) {unsigned long long res;unsigned int rv; res =0 ; rv =0 ; -while (1 ) { +while (max_chars--) {unsigned int c = *s;unsigned int lc = c |0x20 ;/* don't tolower() this line */ unsigned int val;
@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long longreturn rv; } +unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +{ +return _parse_integer_limit (s, base, p,INT_MAX ); +} +static int _kstrtoull (const char *s,unsigned int base,unsigned long long *res) {unsigned long long _res;
lib/kstrtox.h +2 -0
@@ -4,6 +4,8 @@#define KSTRTOX_OVERFLOW (1U << 31)const char *_parse_integer_fixup_radix (const char *s,unsigned int *base); +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *res, +size_t max_chars);unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *res);#endif
lib/vsprintf.c +48 -34
113 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 173/593 Input: goodix - platform/x86: touchscreen_dmi - Move upside down quirks to touchscreen_dmi.c
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 5a6f0dbe621a5c20dc912ac474debf9f11129e03 ]
Move the DMI quirks for upside-down mounted Goodix touchscreens from drivers/input/touchscreen/goodix.c to drivers/platform/x86/touchscreen_dmi.c,
where all the other x86 touchscreen quirks live.
Note the touchscreen_dmi.c code attaches standard touchscreen device-properties to an i2c-client device based on a combination of a DMI match + a device-name match. I've verified that the: Teclast X98 Pro, WinBook TW100 and WinBook TW700 uses an ACPI devicename of "GDIX1001:00" based on acpidumps and/or dmesg output available on the web.
This patch was tested on a Teclast X89 tablet.
--- drivers/input/touchscreen/goodix.c | 52 ------------------------ drivers/platform/x86/touchscreen_dmi.c | 56 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 52 deletions(-)
drivers/input/touchscreen/goodix.c +0 -52
@@ -178,51 +178,6 @@ static const unsigned long goodix_irq_flags[] = { IRQ_TYPE_LEVEL_HIGH, }; -/* -* Those tablets have their coordinates origin at the bottom right -* of the tablet, as if rotated 180 degrees -*/ -static const struct dmi_system_id rotated_screen[] = { -#if defined(CONFIG_DMI) && defined(CONFIG_X86) - { - .ident ="Teclast X89" , - .matches = { -/* tPAD is too generic, also match on bios date */ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BOARD_NAME ,"tPAD" ), -DMI_MATCH (DMI_BIOS_DATE ,"12/19/2014" ), - }, - }, - { - .ident ="Teclast X98 Pro" , - .matches = { -/* -* Only match BIOS date, because the manufacturers -* BIOS does not report the board name at all -* (sometimes)... -*/ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BIOS_DATE ,"10/28/2015" ), - }, - }, - { - .ident ="WinBook TW100" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW100" ) - } - }, - { - .ident ="WinBook TW700" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW700" ) - }, - }, -#endif - {} -}; -static const struct dmi_system_id nine_bytes_report[] = { #if defined(CONFIG_DMI) && defined(CONFIG_X86) {
@@ -1121,13 +1076,6 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) ABS_MT_POSITION_Y, ts->prop.max_y); } -if (dmi_check_system (rotated_screen)) { - ts->prop.invert_x = true; - ts->prop.invert_y = true; -dev_dbg (&ts->client->dev, -"Applying '180 degrees rotated screen' quirk\n" ); - } -if (dmi_check_system (nine_bytes_report)) { ts->contact_size =9 ;
drivers/platform/x86/touchscreen_dmi.c +56 -0
80 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 174/593 platform/x86: touchscreen_dmi: Add an extra entry for the upside down Goodix touchscreen on Teclast X89 tablets
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a22e3803f2a4d947ff0083a9448a169269ea0f62 ]
Teclast X89 tablets come in 2 versions, with Windows pre-installed and with Android pre-installed. These 2 versions have different DMI strings.
Add a match for the DMI strings used by the Android version BIOS.
Note the Android version BIOS has a bug in the DSDT where no IRQ is provided, so for the touchscreen to work a DSDT override fixing this is necessary as well.
--- drivers/platform/x86/touchscreen_dmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +8 -0
@@ -1285,6 +1285,14 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_BOARD_NAME, "X3 Plus"), }, }, + { +/* Teclast X89 (Android version / BIOS) */ + .driver_data = (void *)&gdix1001_00_upside_down_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"WISKY" ), + DMI_MATCH(DMI_BOARD_NAME, "3G062i"), + }, + }, {/* Teclast X89 (Windows version / BIOS) */ .driver_data = (void *)&gdix1001_01_upside_down_data,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 175/593 platform/x86: touchscreen_dmi: Add info for the Goodix GT912 panel of TM800A550L tablets
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit fcd8cf0e3e48f4c66af82c8e799c37cb0cccffe0 ]
The Bay Trail Glavey TM800A550L tablet, which ships with Android installed from the factory, uses a GT912 touchscreen controller which needs to have its firmware uploaded by the OS to work (this is a first for a x86 based device with a Goodix touchscreen controller).
Add a touchscreen_dmi entry for this which specifies the filenames to use for the firmware and config files needed for this.
Note this matches on a GDIX1001 ACPI HID, while the original DSDT uses a HID of GODX0911. For the touchscreen to work on these devices a DSDT override is necessary to fix a missing IRQ and broken GPIO settings in the ACPI-resources for the touchscreen. This override also changes the HID to the standard GDIX1001 id typically used for Goodix touchscreens. The DSDT override is available here:
https://fedorapeople.org/~jwrdegoede/glavey-tm800a550l-dsdt-override/
--- drivers/platform/x86/touchscreen_dmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +21 -0
@@ -316,6 +316,18 @@ static const struct ts_dmi_data gdix1001_01_upside_down_data = { .properties = gdix1001_upside_down_props, }; +static const struct property_entry glavey_tm800a550l_props[] = { +PROPERTY_ENTRY_STRING ("firmware-name" ,"gt912-glavey-tm800a550l.fw" ), +PROPERTY_ENTRY_STRING ("goodix,config-name" ,"gt912-glavey-tm800a550l.cfg" ), +PROPERTY_ENTRY_U32 ("goodix,main-clk" ,54 ), + { } +}; + +static const struct ts_dmi_data glavey_tm800a550l_data = { + .acpi_name ="GDIX1001:00" , + .properties = glavey_tm800a550l_props, +}; +static const struct property_entry gp_electronic_t701_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,960 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,640 ),
@@ -1012,6 +1024,15 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"), }, }, + { /* Glavey TM800A550L */ + .driver_data = (void *)&glavey_tm800a550l_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Above strings are too generic, also match on BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), + }, + }, {/* GP-electronic T701 */ .driver_data = (void *)&gp_electronic_t701_data,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 176/593 ACPI: EC: Make more Asus laptops use ECDT _GPE
In reply to Greg Kroah-HartmanFrom: Chris Chiu <[email protected]>
[ Upstream commit 6306f0431914beaf220634ad36c08234006571d5 ]
More ASUS laptops have the _GPE define in the DSDT table with a different value than the _GPE number in the ECDT.
This is causing media keys not working on ASUS X505BA/BP, X542BA/BP
Add model info to the quirks list.
--- drivers/acpi/ec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/acpi/ec.c +16 -0
@@ -1859,6 +1859,22 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "GL702VMK"),}, NULL}, { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BP"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BP"),}, NULL}, + { ec_honor_ecdt_gpe, "ASUS X550VXK", { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "X550VXK"),}, NULL},
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 177/593 block_dump: remove block_dump feature in mark_inode_dirty()
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit 12e0613715e1cf305fffafaf0e89d810d9a85cc0 ]
block_dump is an old debugging interface, one of it's functions is used to print the information about who write which file on disk. If we enable block_dump through /proc/sys/vm/block_dump and turn on debug log level, we can gather information about write process name, target file name and disk from kernel message. This feature is realized in block_dump___mark_inode_dirty(), it print above information into kernel message directly when marking inode dirty, so it is noisy and can easily trigger log storm. At the same time, get the dentry refcount is also not safe, we found it will lead to deadlock on ext4 file system with data=journal mode.
After tracepoints has been introduced into the kernel, we got a tracepoint in __mark_inode_dirty(), which is a better replacement of block_dump___mark_inode_dirty(). The only downside is that it only trace the inode number and not a file name, but it probably doesn't matter because the original printed file name in block_dump is not accurate in some cases, and we can still find it through the inode number and device id. So this patch delete the dirting inode part of block_dump feature.
--- fs/fs-writeback.c | 25 ------------------------- 1 file changed, 25 deletions(-)
fs/fs-writeback.c +0 -25
@@ -2196,28 +2196,6 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,return ret; } -static noinline void block_dump___mark_inode_dirty(struct inode *inode) -{ -if (inode->i_ino ||strcmp (inode->i_sb->s_id,"bdev" )) { -struct dentry *dentry; -const char *name ="?" ; - - dentry =d_find_alias (inode); -if (dentry) { -spin_lock (&dentry->d_lock); - name = (const char *) dentry->d_name.name; - } -printk (KERN_DEBUG -"%s(%d): dirtied inode %lu (%s) on %s\n" , - current->comm,task_pid_nr (current), inode->i_ino, - name, inode->i_sb->s_id); -if (dentry) { -spin_unlock (&dentry->d_lock); -dput (dentry); - } - } -} -/** * __mark_inode_dirty - internal function *
@@ -2277,9 +2255,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) (dirtytime && (inode->i_state & I_DIRTY_INODE))) return; -if (unlikely (block_dump)) -block_dump___mark_inode_dirty (inode); -spin_lock (&inode->i_lock);if (dirtytime && (inode->i_state &I_DIRTY_INODE )) goto out_unlock_inode;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 178/593 blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2e315dc07df009c3e29d6926871f62a30cfae394 ]
Grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter(), and this way will prevent the request from being re-used when ->fn is running. The approach is same as what we do during handling timeout.
Fix request use-after-free(UAF) related with completion race or queue releasing:
- If one rq is referred before rq->q is frozen, then queue won't be frozen before the request is released during iteration.
- If one rq is referred after rq->q is frozen, refcount_inc_not_zero() will return false, and we won't iterate over this request.
However, still one request UAF not covered: refcount_inc_not_zero() may read one freed request, and it will be handled in next patch.
--- block/blk-mq-tag.c | 44 +++++++++++++++++++++++++++++++++----------- block/blk-mq.c | 14 +++++++++----- block/blk-mq.h | 1 + 3 files changed, 43 insertions(+), 16 deletions(-)
block/blk-mq-tag.c +33 -11
@@ -199,6 +199,16 @@ struct bt_iter_data {bool reserved; }; +static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags, +unsigned int bitnr) +{ +struct request *rq = tags->rqs[bitnr]; + +if (!rq || !refcount_inc_not_zero (&rq->ref)) +return NULL ; +return rq; +} +static bool bt_iter (struct sbitmap *bitmap,unsigned int bitnr,void *data) {struct bt_iter_data *iter_data = data;
@@ -206,18 +216,22 @@ static bool bt_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = hctx->tags;bool reserved = iter_data->reserved;struct request *rq; +bool ret = true;if (!reserved) bitnr += tags->nr_reserved_tags; - rq = tags->rqs[bitnr]; -/* * We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (rq && rq->q == hctx->queue && rq->mq_hctx == hctx) -return iter_data->fn (hctx, rq, iter_data->data, reserved); -return true; + rq =blk_mq_find_and_get_req (tags, bitnr); +if (!rq) +return true; + +if (rq->q == hctx->queue && rq->mq_hctx == hctx) + ret = iter_data->fn (hctx, rq, iter_data->data, reserved); +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -264,6 +278,8 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = iter_data->tags;bool reserved = iter_data->flags &BT_TAG_ITER_RESERVED ;struct request *rq; +bool ret = true; +bool iter_static_rqs = !!(iter_data->flags &BT_TAG_ITER_STATIC_RQS );if (!reserved) bitnr += tags->nr_reserved_tags;
@@ -272,16 +288,19 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)* We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (iter_data->flags &BT_TAG_ITER_STATIC_RQS ) +if (iter_static_rqs) rq = tags->static_rqs[bitnr];else - rq = tags->rqs[bitnr]; + rq =blk_mq_find_and_get_req (tags, bitnr);if (!rq)return true; -if ((iter_data->flags &BT_TAG_ITER_STARTED ) && - !blk_mq_request_started (rq)) -return true; -return iter_data->fn (rq, iter_data->data, reserved); + +if (!(iter_data->flags &BT_TAG_ITER_STARTED ) || +blk_mq_request_started (rq)) + ret = iter_data->fn (rq, iter_data->data, reserved); +if (!iter_static_rqs) +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -348,6 +367,9 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,* indicates whether or not @rq is a reserved request. Return * true to continue iterating tags, false to stop. * @priv: Will be passed as second argument to @fn. +* +* We grab one request reference before calling @fn and release it after +* @fn returns. */ void blk_mq_tagset_busy_iter (struct blk_mq_tag_set *tagset,busy_tag_iter_fn *fn,void *priv)
block/blk-mq.c +9 -5
@@ -927,6 +927,14 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)return false; } +void blk_mq_put_rq_ref (struct request *rq) +{ +if (is_flush_rq (rq, rq->mq_hctx)) + rq->end_io (rq,0 ); +else if (refcount_dec_and_test (&rq->ref)) +__blk_mq_free_request (rq); +} +static bool blk_mq_check_expired (struct blk_mq_hw_ctx *hctx,struct request *rq,void *priv,bool reserved) {
@@ -960,11 +968,7 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,if (blk_mq_req_expired (rq, next))blk_mq_rq_timed_out (rq, reserved); -if (is_flush_rq (rq, hctx)) - rq->end_io (rq,0 ); -else if (refcount_dec_and_test (&rq->ref)) -__blk_mq_free_request (rq); - +blk_mq_put_rq_ref (rq);return true; }
block/blk-mq.h +1 -0
@@ -47,6 +47,7 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,void blk_mq_flush_busy_ctxs (struct blk_mq_hw_ctx *hctx,struct list_head *list);struct request *blk_mq_dequeue_from_ctx (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *start); +void blk_mq_put_rq_ref (struct request *rq);/* * Internal helpers for allocating/freeing the request map
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 179/593 blk-mq: clear stale request in tags->rq[] before freeing one request pool
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit bd63141d585bef14f4caf111f6d0e27fe2300ec6 ]
refcount_inc_not_zero() in bt_tags_iter() still may read one freed request.
Fix the issue by the following approach:
1) hold a per-tags spinlock when reading ->rqs[tag] and calling refcount_inc_not_zero in bt_tags_iter()
2) clearing stale request referred via ->rqs[tag] before freeing request pool, the per-tags spinlock is held for clearing stale ->rq[tag]
So after we cleared stale requests, bt_tags_iter() won't observe freed request any more, also the clearing will wait for pending request reference.
The idea of clearing ->rqs[] is borrowed from John Garry's previous patch and one recent David's patch.
--- block/blk-mq-tag.c | 9 +++++++-- block/blk-mq-tag.h | 6 ++++++ block/blk-mq.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-)
block/blk-mq-tag.c +7 -2
@@ -202,10 +202,14 @@ struct bt_iter_data {static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags,unsigned int bitnr) { -struct request *rq = tags->rqs[bitnr]; +struct request *rq; +unsigned long flags; +spin_lock_irqsave (&tags->lock, flags); + rq = tags->rqs[bitnr];if (!rq || !refcount_inc_not_zero (&rq->ref)) -return NULL ; + rq =NULL ; +spin_unlock_irqrestore (&tags->lock, flags);return rq; }
@@ -538,6 +542,7 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags, tags->nr_tags = total_tags; tags->nr_reserved_tags = reserved_tags; +spin_lock_init (&tags->lock);if (flags &BLK_MQ_F_TAG_HCTX_SHARED )return tags;
block/blk-mq-tag.h +6 -0
@@ -20,6 +20,12 @@ struct blk_mq_tags {struct request **rqs;struct request **static_rqs;struct list_head page_list; + +/* +* used to clear request reference in rqs[] before freeing one +* request pool +*/ +spinlock_t lock; }; extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
block/blk-mq.c +41 -5
64 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 180/593 fs: dlm: cancel work sync othercon
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit c6aa00e3d20c2767ba3f57b64eb862572b9744b3 ]
These rx tx flags arguments are for signaling close_connection() from which worker they are called. Obviously the receive worker cannot cancel itself and vice versa for swork. For the othercon the receive worker should only be used, however to avoid deadlocks we should pass the same flags as the original close_connection() was called.
--- fs/dlm/lowcomms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dlm/lowcomms.c +1 -1
@@ -599,7 +599,7 @@ static void close_connection(struct connection *con, bool and_other, }if (con->othercon && and_other) {/* Will only re-enter once. */ -close_connection (con->othercon, false, true, true); +close_connection (con->othercon, false, tx, rx); } con->rx_leftover =0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 181/593 random32: Fix implicit truncation warning in prandom_seed_state()
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit d327ea15a305024ef0085252fa3657bbb1ce25f5 ]
sparse generates the following warning:
include/linux/prandom.h:114:45: sparse: sparse: cast truncates bits from constant value
This is because the 64-bit seed value is manipulated and then placed in a u32, causing an implicit cast and truncation. A forced cast to u32 doesn't prevent this warning, which is reasonable because a typecast doesn't prove that truncation was expected.
Logical-AND the value with 0xffffffff to make explicit that truncation to 32-bit is intended.
--- include/linux/prandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/prandom.h +1 -1
@@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m)*/ static inline void prandom_seed_state (struct rnd_state *state,u64 seed) { -u32 i = (seed >>32 ) ^ (seed <<10 ) ^ seed; +u32 i = ((seed >>32 ) ^ (seed <<10 ) ^ seed) &0xffffffffUL ; state->s1 =__seed (i,2U ); state->s2 =__seed (i,8U );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 182/593 open: dont silently ignore unknown O-flags in openat2()
In reply to Greg Kroah-HartmanFrom: Christian Brauner <[email protected]>
[ Upstream commit cfe80306a0dd6d363934913e47c3f30d71b721e5 ]
The new openat2() syscall verifies that no unknown O-flag values are set and returns an error to userspace if they are while the older open syscalls like open() and openat() simply ignore unknown flag values:
#define O_FLAG_CURRENTLY_INVALID (1 << 31)
struct open_how how = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID,
.resolve = 0,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how, sizeof(how));
/* succeeds */
fd = openat(-EBADF, "/dev/null", O_RDONLY | O_FLAG_CURRENTLY_INVALID);However, openat2() silently truncates the upper 32 bits meaning:
#define O_FLAG_CURRENTLY_INVALID_LOWER32 (1 << 31)
#define O_FLAG_CURRENTLY_INVALID_UPPER32 (1 << 40)
struct open_how how_lowe32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_LOWER32,
};
struct open_how how_upper32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_UPPER32,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how_lower32, sizeof(how_lower32));
/* succeeds */
fd = openat2(-EBADF, "/dev/null", &how_upper32, sizeof(how_upper32));Fix this by preventing the immediate truncation in build_open_flags().
There's a snafu here though stripping FMODE_* directly from flags would cause the upper 32 bits to be truncated as well due to integer promotion rules since FMODE_* is unsigned int, O_* are signed ints (yuck).
In addition, struct open_flags currently defines flags to be 32 bit which is reasonable. If we simply were to bump it to 64 bit we would need to change a lot of code preemptively which doesn't seem worth it. So simply add a compile-time check verifying that all currently known O_* flags are within the 32 bit range and fail to build if they aren't anymore.
This change shouldn't regress old open syscalls since they silently truncate any unknown values anyway. It is a tiny semantic change for openat2() but it is very unlikely people pass ing > 32 bit unknown flags and the syscall is relatively new too.
--- fs/open.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/open.c +11 -3
@@ -993,12 +993,20 @@ inline struct open_how build_open_how(int flags, umode_t mode)inline int build_open_flags (const struct open_how *how,struct open_flags *op) { -int flags = how->flags; +u64 flags = how->flags; +u64 strip =FMODE_NONOTIFY |O_CLOEXEC ;int lookup_flags =0 ;int acc_mode =ACC_MODE (flags); -/* Must never be set by userspace */ - flags &= ~(FMODE_NONOTIFY |O_CLOEXEC ); +BUILD_BUG_ON_MSG (upper_32_bits (VALID_OPEN_FLAGS ), +"struct open_flags doesn't yet handle flags > 32 bits" ); + +/* +* Strip flags that either shouldn't be set by userspace like +* FMODE_NONOTIFY or that aren't relevant in determining struct +* open_flags like O_CLOEXEC. +*/ + flags &= ~strip;/* * Older syscalls implicitly clear all of the invalid flags or argument
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 183/593 drivers: hv: Fix missing error code in vmbus_connect()
In reply to Greg Kroah-HartmanFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 9de6655cc5a6a1febc514465c87c24a0e96d8dba ]
Eliminate the follow smatch warning:
drivers/hv/connection.c:236 vmbus_connect() warn: missing error code 'ret'.
--- drivers/hv/connection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hv/connection.c +3 -1
@@ -229,8 +229,10 @@ int vmbus_connect(void)*/ for (i =0 ; ; i++) { -if (i ==ARRAY_SIZE (vmbus_versions)) +if (i ==ARRAY_SIZE (vmbus_versions)) { + ret = -EDOM ; goto cleanup; + } version = vmbus_versions[i];if (version > max_version)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 184/593 fs: dlm: fix memory leak when fenced
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit 700ab1c363c7b54c9ea3222379b33fc00ab02f7b ]
I got some kmemleak report when a node was fenced. The user space tool dlm_controld will therefore run some rmdir() in dlm configfs which was triggering some memleaks. This patch stores the sps and cms attributes which stores some handling for subdirectories of the configfs cluster entry and free them if they get released as the parent directory gets freed.
unreferenced object 0xffff88810d9e3e00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 73 70 61 63 65 73 00 00 ........spaces..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000db8b640b>] make_cluster+0x5d/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae
unreferenced object 0xffff88810d9e3a00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 63 6f 6d 6d 73 00 00 00 ........comms...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000a7ef6ad2>] make_cluster+0x82/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae--- fs/dlm/config.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/dlm/config.c +9 -0
@@ -79,6 +79,9 @@ struct dlm_cluster {unsigned int cl_new_rsb_count;unsigned int cl_recover_callbacks;char cl_cluster_name[DLM_LOCKSPACE_LEN ]; + +struct dlm_spaces *sps; +struct dlm_comms *cms; };static struct dlm_cluster *config_item_to_cluster (struct config_item *i)
@@ -379,6 +382,9 @@ static struct config_group *make_cluster(struct config_group *g,if (!cl || !sps || !cms) goto fail; + cl->sps = sps; + cl->cms = cms; +config_group_init_type_name (&cl->group, name, &cluster_type);config_group_init_type_name (&sps->ss_group,"spaces" , &spaces_type);config_group_init_type_name (&cms->cs_group,"comms" , &comms_type);
@@ -428,6 +434,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)static void release_cluster (struct config_item *i) {struct dlm_cluster *cl =config_item_to_cluster (i); + +kfree (cl->sps); +kfree (cl->cms);kfree (cl); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 185/593 ACPICA: Fix memory leak caused by _CID repair function
In reply to Greg Kroah-HartmanFrom: Erik Kaneda <[email protected]>
[ Upstream commit c27bac0314131b11bccd735f7e8415ac6444b667 ]
ACPICA commit 180cb53963aa876c782a6f52cc155d951b26051a
According to the ACPI spec, _CID returns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.
Name (TEST, Package() {
"String object" // this package element has a reference count of 2
})
A memory leak was caused in the _CID repair function because it did not decrement the reference count created by the package. Fix the memory leak by calling acpi_ut_remove_reference on _CID package elements that represent a hardware ID (_HID).
--- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/acpica/nsrepair2.c +7 -0
@@ -375,6 +375,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + +/* +* The original_element holds a reference from the package object +* that represents _HID. Since a new element was created by _HID, +* remove the reference from the _CID package. +*/ +acpi_ut_remove_reference (original_element); } element_ptr++;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 186/593 ACPI: bus: Call kobject_put() in acpi_init() error path
In reply to Greg Kroah-HartmanFrom: Hanjun Guo <[email protected]>
[ Upstream commit 4ac7a817f1992103d4e68e9837304f860b5e7300 ]
Although the system will not be in a good condition or it will not boot if acpi_bus_init() fails, it is still necessary to put the kobject in the error path before returning to avoid leaking memory.
--- drivers/acpi/bus.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/bus.c +1 -0
@@ -1245,6 +1245,7 @@ static int __init acpi_init(void) result =acpi_bus_init ();if (result) { +kobject_put (acpi_kobj);disable_acpi ();return result; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 187/593 ACPI: resources: Add checks for ACPI IRQ override
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
[ Upstream commit 0ec4e55e9f571f08970ed115ec0addc691eda613 ]
The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)
And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}
So the BIOS defines the keyboard IRQ to Level_Low, but the Linux kernel override it to Edge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally.
Quoted 1 line
From the existing comment in
acpi_dev_get_irqresource(), the override
function only needs to be called when IRQ() or IRQNoFlags() is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], if IRQ() is empty or IRQNoFlags() is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] in rsirq.c).
In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an ACPI_RESOURCE_TYPE_IRQ resource as "legacy", in which case the IRQ override is applicable to it.
--- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/acpi/resource.c +8 -1
@@ -430,6 +430,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy (struct acpi_resource_irq *irq) +{ +return irq->triggering ==ACPI_EDGE_SENSITIVE && + irq->polarity ==ACPI_ACTIVE_HIGH && + irq->shareable ==ACPI_EXCLUSIVE ; +} +/** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object.
@@ -468,7 +475,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, }acpi_dev_get_irqresource (res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable,irq_is_legacy (irq));break ;case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : ext_irq = &ares->data.extended_irq;
Signature · 1 line
2.30.2
Re: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override
Quoted 6 lines · Greg Kroah-Hartman
From: Hui Wang <[email protected]>
[ Upstream commit
0ec4e55e9f571f08970ed115ec0addc691eda613]The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
This patch makes my EPIA VIA Esther system stop booting correctly. Reverting it returns things to normal operation. The symptoms are pretty strange. When the kernel hands off to init I get none of the usual output from userspace, but I still get the occasional message from the kernel as modules load. Despite some processes continuing on in the background, I'm never able to ssh into the host, and it never displays a getty on serial console like it should. Sending a break and a command key over serial doesn't work like it should either. I've found I was able to somewhat get a little bit of IO if I plugged in a keyboard or unplugged it, like just jiggling the handle of the usb hot plug routines was enough to get my system to reboot so I only had to resort to hard resets a few times. At any rate, maybe this patch wasn't really ready for stable.
Quoted 70 lines
Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}So the BIOS defines the keyboard IRQ to
Level_Low, but the Linux kernel override it toEdge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally.From the existing comment in
acpi_dev_get_irqresource(), the override function only needs to be called whenIRQ()orIRQNoFlags()is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], ifIRQ()is empty orIRQNoFlags()is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] inrsirq.c).In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an
ACPI_RESOURCE_TYPE_IRQresource as "legacy", in which case the IRQ override is applicable to it.Link https://uefi.org/specs/ACPI/6.4/06_Device_Configuration/Device_Configuration.html#irq-descriptor # [1]Suggested-by Rafael J. Wysocki <[email protected]>Reported-by Manuel Krause <[email protected]>Tested-by Manuel Krause <[email protected]>Signed-off-by Hui Wang <[email protected]>[ rjw: Subject rewrite, changelog edits ]Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/acpi/resource.c +8
-1@@ -430,6 +430,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy (struct acpi_resource_irq *irq) +{ +return irq->triggering ==ACPI_EDGE_SENSITIVE && + irq->polarity ==ACPI_ACTIVE_HIGH && + irq->shareable ==ACPI_EXCLUSIVE ; +} +/** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object. @@ -468,7 +475,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, }acpi_dev_get_irqresource (res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable,irq_is_legacy (irq));break ;case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : ext_irq = &ares->data.extended_irq;Signature · 1 line
2.30.2
Signature · 1 line
Jamie Heilman http://audible.transient.net/~jamie/
Greg Kroah-Hartman
maintainerRe: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override
Quoted 8 lines · Jamie Heilman
Quoted 6 lines · Greg Kroah-Hartman
From: Hui Wang <[email protected]>
[ Upstream commit
0ec4e55e9f571f08970ed115ec0addc691eda613]The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Quoted 13 lines
This patch makes my EPIA VIA Esther system stop booting correctly. Reverting it returns things to normal operation. The symptoms are pretty strange. When the kernel hands off to init I get none of the usual output from userspace, but I still get the occasional message from the kernel as modules load. Despite some processes continuing on in the background, I'm never able to ssh into the host, and it never displays a getty on serial console like it should. Sending a break and a command key over serial doesn't work like it should either. I've found I was able to somewhat get a little bit of IO if I plugged in a keyboard or unplugged it, like just jiggling the handle of the usb hot plug routines was enough to get my system to reboot so I only had to resort to hard resets a few times. At any rate, maybe this patch wasn't really ready for stable.
Do you also have the same problem with 5.14-rc1?
thanks,
greg k-h
Re: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override
Quoted 23 lines · Greg Kroah-Hartman
Quoted 8 lines · Jamie Heilman
Quoted 6 lines · Greg Kroah-Hartman
From: Hui Wang <[email protected]>
[ Upstream commit
0ec4e55e9f571f08970ed115ec0addc691eda613]The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Quoted 13 lines
This patch makes my EPIA VIA Esther system stop booting correctly. Reverting it returns things to normal operation. The symptoms are pretty strange. When the kernel hands off to init I get none of the usual output from userspace, but I still get the occasional message from the kernel as modules load. Despite some processes continuing on in the background, I'm never able to ssh into the host, and it never displays a getty on serial console like it should. Sending a break and a command key over serial doesn't work like it should either. I've found I was able to somewhat get a little bit of IO if I plugged in a keyboard or unplugged it, like just jiggling the handle of the usb hot plug routines was enough to get my system to reboot so I only had to resort to hard resets a few times. At any rate, maybe this patch wasn't really ready for stable.
Quoted 1 line
Do you also have the same problem with 5.14-rc1?
I'm afraid so.
Signature · 1 line
Jamie Heilman http://audible.transient.net/~jamie/
Greg Kroah-Hartman
maintainerRe: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override
Quoted 24 lines · Jamie Heilman
Quoted 23 lines · Greg Kroah-Hartman
Quoted 21 lines · Jamie Heilman
Quoted 6 lines · Greg Kroah-Hartman
From: Hui Wang <[email protected]>
[ Upstream commit
0ec4e55e9f571f08970ed115ec0addc691eda613]The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
This patch makes my EPIA VIA Esther system stop booting correctly. Reverting it returns things to normal operation. The symptoms are pretty strange. When the kernel hands off to init I get none of the usual output from userspace, but I still get the occasional message from the kernel as modules load. Despite some processes continuing on in the background, I'm never able to ssh into the host, and it never displays a getty on serial console like it should. Sending a break and a command key over serial doesn't work like it should either. I've found I was able to somewhat get a little bit of IO if I plugged in a keyboard or unplugged it, like just jiggling the handle of the usb hot plug routines was enough to get my system to reboot so I only had to resort to hard resets a few times. At any rate, maybe this patch wasn't really ready for stable.
Quoted 3 lines
Quoted 1 line
Do you also have the same problem with 5.14-rc1?
I'm afraid so.
That's great! Please work with the developers involved to get this fixed in 5.14-rc1 and we can take the fix into the stable tree as well.
Unless the developers want us to revert this in stable trees now?
thanks,
greg k-h
Re: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override
In reply to Jamie HeilmanQuoted 7 lines · Jamie Heilman
Quoted 6 lines · Greg Kroah-Hartman
From: Hui Wang <[email protected]>
[ Upstream commit
0ec4e55e9f571f08970ed115ec0addc691eda613]The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Quoted 13 lines
This patch makes my EPIA VIA Esther system stop booting correctly. Reverting it returns things to normal operation. The symptoms are pretty strange. When the kernel hands off to init I get none of the usual output from userspace, but I still get the occasional message from the kernel as modules load. Despite some processes continuing on in the background, I'm never able to ssh into the host, and it never displays a getty on serial console like it should. Sending a break and a command key over serial doesn't work like it should either. I've found I was able to somewhat get a little bit of IO if I plugged in a keyboard or unplugged it, like just jiggling the handle of the usb hot plug routines was enough to get my system to reboot so I only had to resort to hard resets a few times. At any rate, maybe this patch wasn't really ready for stable.
Hi Jamie,
Could you please use acpidump to dump the acpi tables and upload them/it to: http://bugs.launchpad.net/bugs/1909814
Thanks.
Quoted 70 lines
Quoted 70 lines
Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}So the BIOS defines the keyboard IRQ to
Level_Low, but the Linux kernel override it toEdge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally.From the existing comment in
acpi_dev_get_irqresource(), the override
function only needs to be called whenIRQ()orIRQNoFlags()is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], ifIRQ()is empty orIRQNoFlags()is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] inrsirq.c).In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an
ACPI_RESOURCE_TYPE_IRQresource as "legacy", in which case the IRQ override is applicable to it.Link https://uefi.org/specs/ACPI/6.4/06_Device_Configuration/Device_Configuration.html#irq-descriptor # [1]Suggested-by Rafael J. Wysocki <[email protected]>Reported-by Manuel Krause <[email protected]>Tested-by Manuel Krause <[email protected]>Signed-off-by Hui Wang <[email protected]>[ rjw: Subject rewrite, changelog edits ]Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/acpi/resource.c +8
-1@@ -430,6 +430,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy (struct acpi_resource_irq *irq) +{ +return irq->triggering ==ACPI_EDGE_SENSITIVE && + irq->polarity ==ACPI_ACTIVE_HIGH && + irq->shareable ==ACPI_EXCLUSIVE ; +} +/** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object. @@ -468,7 +475,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, }acpi_dev_get_irqresource (res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable,irq_is_legacy (irq));break ;case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : ext_irq = &ares->data.extended_irq;Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 188/593 block: fix race between adding/removing rq qos and normal IO
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2cafe29a8d03f02a3d16193bdaae2f3e82a423f9 ]
Yi reported several kernel panics on:
[16687.001777] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... [16687.163549] pc : __rq_qos_track+0x38/0x60
or
[ 997.690455] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 ... [ 997.850347] pc : __rq_qos_done+0x2c/0x50
Turns out it is caused by race between adding rq qos(wbt) and normal IO because rq_qos_add can be run when IO is being submitted, fix this issue by freezing queue before adding/deleting rq qos to queue.
rq_qos_exit() needn't to freeze queue because it is called after queue has been frozen.
iolatency calls rq_qos_add() during allocating queue, so freezing won't add delay because queue usage refcount works at atomic mode at that time.
iocost calls rq_qos_add() when writing cgroup attribute file, that is fine to freeze queue at that time since we usually freeze queue when storing to queue sysfs attribute, meantime iocost only exists on the root cgroup.
wbt_init calls it in blk_register_queue() and queue sysfs attribute store(queue_wb_lat_store() when write it 1st time in case of !BLK_WBT_MQ), the following patch will speedup the queue freezing in wbt_init.
--- block/blk-rq-qos.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
block/blk-rq-qos.h +24 -0
@@ -7,6 +7,7 @@#include <linux/blk_types.h> #include <linux/atomic.h> #include <linux/wait.h> +#include <linux/blk-mq.h> #include "blk-mq-debugfs.h"
@@ -99,8 +100,21 @@ static inline void rq_wait_init(struct rq_wait *rq_wait)static inline void rq_qos_add (struct request_queue *q,struct rq_qos *rqos) { +/* +* No IO can be in-flight when adding rqos, so freeze queue, which +* is fine since we only support rq_qos for blk-mq queue. +* +* Reuse ->queue_lock for protecting against other concurrent +* rq_qos adding/deleting +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock); rqos->next = q->rq_qos; q->rq_qos = rqos; +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);if (rqos->ops->debugfs_attrs)blk_mq_debugfs_register_rqos (rqos);
@@ -110,12 +124,22 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) {struct rq_qos **cur; +/* +* See comment in rq_qos_add() about freezing queue & using +* ->queue_lock. +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock);for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {if (*cur == rqos) { *cur = rqos->next;break ; } } +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);blk_mq_debugfs_unregister_rqos (rqos); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 189/593 platform/x86: asus-nb-wmi: Revert "Drop duplicate DMI quirk structures"
In reply to Greg Kroah-HartmanFrom: Luke D. Jones <[email protected]>
[ Upstream commit 98c0c85b1040db24f0d04d3e1d315c6c7b05cc07 ]
This is a preparation revert for reverting the "add support for ASUS ROG Zephyrus G14 and G15" change. This reverts
commit 67186653c903 ("platform/x86: asus-nb-wmi: Drop duplicate DMI quirk structures")
--- drivers/platform/x86/asus-nb-wmi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +14 -9
@@ -110,7 +110,12 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_vendor_backlight = { +static struct quirk_entry quirk_asus_ga401i = { + .wmi_backlight_power = true, + .wmi_backlight_set_devstate = true, +}; + +static struct quirk_entry quirk_asus_ga502i = { .wmi_backlight_power = true, .wmi_backlight_set_devstate = true, };
@@ -427,7 +432,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -436,7 +441,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -445,7 +450,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -454,7 +459,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -463,7 +468,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -472,7 +477,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -481,7 +486,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -490,7 +495,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 190/593 platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
In reply to Greg Kroah-HartmanFrom: Luke D. Jones <[email protected]>
[ Upstream commit 28117f3a5c3c8375a3304af76357d5bf9cf30f0b ]
The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the acpi_video driver to register since they make acpi_video_get_backlight_type() return acpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk in drivers/acpi/video_detect.c which actually sets the backlight_type to acpi_backlight_native fixinf this properly. This reverts
commit 13bceda68fb9 ("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").
--- drivers/platform/x86/asus-nb-wmi.c | 82 ------------------------------ 1 file changed, 82 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +0 -82
@@ -110,16 +110,6 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_ga401i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; - -static struct quirk_entry quirk_asus_ga502i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; -static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, };
@@ -425,78 +415,6 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_forceals, }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IH", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IVC", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), - }, - .driver_data = &quirk_asus_ga502i, - }, { .callback = dmi_matched, .ident = "Asus Transformer T100TA / T100HA / T100CHI",
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 191/593 platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard()
In reply to Greg Kroah-HartmanFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 28e367127718a9cb85d615a71e152f7acee41bfc ]
The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'error'.
Eliminate the follow smatch warning:
drivers/platform/x86/toshiba_acpi.c:2834 toshiba_acpi_setup_keyboard()
warn: missing error code 'error'.
--- drivers/platform/x86/toshiba_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/toshiba_acpi.c +1 -0
@@ -2831,6 +2831,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)if (!dev->info_supported && !dev->system_event_supported) {pr_warn ("No hotkey query interface found\n" ); + error = -EINVAL ; goto err_remove_filter; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 192/593 nvme-pci: fix var. type for increasing cq_head
In reply to Greg Kroah-HartmanFrom: JK Kim <[email protected]>
[ Upstream commit a0aac973a26d1ac814b9e131e209eb39472a67ce ]
nvmeq->cq_head is compared with nvmeq->q_depth and changed the value and cq_phase for handling the next cq db.
but, nvmeq->q_depth's type is u32 and max. value is 0x10000 when CQP.MSQE is 0xffff and io_queue_depth is 0x10000.
current temp. variable for comparing with nvmeq->q_depth is overflowed when previous nvmeq->cq_head is 0xffff.
in this case, nvmeq->cq_phase is not updated.
so, fix data type for temp. variable to u32.
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1027,7 +1027,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)static inline void nvme_update_cq_head (struct nvme_queue *nvmeq) { -u16 tmp = nvmeq->cq_head +1 ; +u32 tmp = nvmeq->cq_head +1 ;if (tmp == nvmeq->q_depth) { nvmeq->cq_head =0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 193/593 nvmet-fc: do not check for invalid target port in nvmet_fc_handle_fcp_rqst()
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 2a4a910aa4f0acc428dc8d10227c42e14ed21d10 ]
When parsing a request in nvmet_fc_handle_fcp_rqst() we should not check for invalid target ports; if we do the command is aborted from the fcp layer, causing the host to assume a transport error. Rather we should still forward this request to the nvmet layer, which will then correctly fail the command with an appropriate error status.
--- drivers/nvme/target/fc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/nvme/target/fc.c +2 -8
@@ -2499,13 +2499,6 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,u32 xfrlen =be32_to_cpu (cmdiu->data_len);int ret; -/* -* if there is no nvmet mapping to the targetport there -* shouldn't be requests. just terminate them. -*/ -if (!tgtport->pe) - goto transport_error; -/* * Fused commands are currently not supported in the linux * implementation.
@@ -2533,7 +2526,8 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - fod->req.port = tgtport->pe->port; +if (tgtport->pe) + fod->req.port = tgtport->pe->port;/* clear any response payload */ memset (&fod->rspiubuf,0 ,sizeof (fod->rspiubuf));
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 194/593 EDAC/Intel: Do not load EDAC driver when running as a guest
In reply to Greg Kroah-HartmanFrom: Luck, Tony <[email protected]>
[ Upstream commit f0a029fff4a50eb01648810a77ba1873e829fdd4 ]
There's little to no point in loading an EDAC driver running in a guest:
1) The CPU model reported by CPUID may not represent actual h/w
2) The hypervisor likely does not pass in access to memory controller devices
3) Hypervisors generally do not pass corrected error details to guests
Add a check in each of the Intel EDAC drivers for X86_FEATURE_HYPERVISOR and simply return -ENODEV in the init routine.
--- drivers/edac/i10nm_base.c | 3 +++ drivers/edac/pnd2_edac.c | 3 +++ drivers/edac/sb_edac.c | 3 +++ drivers/edac/skx_base.c | 3 +++ 4 files changed, 12 insertions(+)
drivers/edac/i10nm_base.c +3 -0
@@ -263,6 +263,9 @@ static int __init i10nm_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (i10nm_cpuids);if (!id)return -ENODEV ;
drivers/edac/pnd2_edac.c +3 -0
@@ -1554,6 +1554,9 @@ static int __init pnd2_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (pnd2_cpuids);if (!id)return -ENODEV ;
drivers/edac/sb_edac.c +3 -0
@@ -3510,6 +3510,9 @@ static int __init sbridge_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (sbridge_cpuids);if (!id)return -ENODEV ;
drivers/edac/skx_base.c +3 -0
@@ -656,6 +656,9 @@ static int __init skx_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (skx_cpuids);if (!id)return -ENODEV ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 195/593 PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv()
In reply to Greg Kroah-HartmanFrom: Haiyang Zhang <[email protected]>
[ Upstream commit 7d815f4afa87f2032b650ae1bba7534b550a6b8b ]
Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.
--- drivers/pci/controller/pci-hyperv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
@@ -3480,6 +3480,9 @@ static void __exit exit_hv_pci_drv(void)static int __init init_hv_pci_drv (void ) { +if (!hv_is_hyperv_initialized ()) +return -ENODEV ; +/* Set the invalid domain number's bit, so it will not be used */ set_bit (HVPCI_DOM_INVALID , hvpci_dom_map);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 196/593 cifs: improve fallocate emulation
In reply to Greg Kroah-HartmanFrom: Ronnie Sahlberg <[email protected]>
[ Upstream commit 966a3cb7c7db786452a87afdc3b48858fc4d4d6b ]
RHBZ: 1866684
We don't have a real fallocate in the SMB2 protocol so we used to emulate fallocate by simply switching the file to become non-sparse. But as that could potantially consume a lot more data than we intended to fallocate (large sparse file and fallocating a thin slice in the middle) we would only do this IFF the fallocate request was for virtually the entire file.
This patch improves this and starts allowing us to fallocate smaller chunks of a file by overwriting the region with 0, for the parts that are unallocated.
The method used is to first query the server for FSCTL_QUERY_ALLOCATED_RANGES to find what is unallocated in the fallocate range and then to only overwrite-with-zero the unallocated ranges to fill in the holes.
As overwriting-with-zero is different from just allocating blocks, and potentially much more expensive, we limit this to only allow fallocate ranges up to 1Mb in size.
--- fs/cifs/smb2ops.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+)
fs/cifs/smb2ops.c +133 -0
@@ -3459,6 +3459,119 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,return rc; } +static int smb3_simple_fallocate_write_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len, +char *buf) +{ +struct cifs_io_parms io_parms = {0 }; +int nbytes; +struct kvec iov[2 ]; + + io_parms.netfid = cfile->fid.netfid; + io_parms.pid = current->tgid; + io_parms.tcon = tcon; + io_parms.persistent_fid = cfile->fid.persistent_fid; + io_parms.volatile_fid = cfile->fid.volatile_fid; + io_parms.offset = off; + io_parms.length = len; + +/* iov[0] is reserved for smb header */ + iov[1 ].iov_base = buf; + iov[1 ].iov_len = io_parms.length; +return SMB2_write (xid, &io_parms, &nbytes, iov,1 ); +} + +static int smb3_simple_fallocate_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len) +{ +struct file_allocated_range_buffer in_data, *out_data =NULL , *tmp_data; +u32 out_data_len; +char *buf =NULL ; +loff_t l; +int rc; + + in_data.file_offset =cpu_to_le64 (off); + in_data.length =cpu_to_le64 (len); + rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, + cfile->fid.volatile_fid, +FSCTL_QUERY_ALLOCATED_RANGES , true, + (char *)&in_data,sizeof (in_data), +1024 *sizeof (struct file_allocated_range_buffer ), + (char **)&out_data, &out_data_len); +if (rc) + goto out; +/* +* It is already all allocated +*/ +if (out_data_len ==0 ) + goto out; + + buf =kzalloc (1024 *1024 ,GFP_KERNEL ); +if (buf ==NULL ) { + rc = -ENOMEM ; + goto out; + } + + tmp_data = out_data; +while (len) { +/* +* The rest of the region is unmapped so write it all. +*/ +if (out_data_len ==0 ) { + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, len, buf); + goto out; + } + +if (out_data_len <sizeof (struct file_allocated_range_buffer )) { + rc = -EINVAL ; + goto out; + } + +if (off <le64_to_cpu (tmp_data->file_offset)) { +/* +* We are at a hole. Write until the end of the region +* or until the next allocated data, +* whichever comes next. +*/ + l =le64_to_cpu (tmp_data->file_offset) - off; +if (len < l) + l = len; + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, l, buf); +if (rc) + goto out; + off = off + l; + len = len - l; +if (len ==0 ) + goto out; + } +/* +* We are at a section of allocated data, just skip forward +* until the end of the data or the end of the region +* we are supposed to fallocate, whichever comes first. +*/ + l =le64_to_cpu (tmp_data->length); +if (len < l) + l = len; + off += l; + len -= l; + + tmp_data = &tmp_data[1 ]; + out_data_len -=sizeof (struct file_allocated_range_buffer ); + } + + out: +kfree (out_data); +kfree (buf); +return rc; +} + +static long smb3_simple_falloc (struct file *file,struct cifs_tcon *tcon,loff_t off,loff_t len,bool keep_size) {
@@ -3519,6 +3632,26 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, }if ((keep_size == true) || (i_size_read (inode) >= off + len)) { +/* +* At this point, we are trying to fallocate an internal +* regions of a sparse file. Since smb2 does not have a +* fallocate command we have two otions on how to emulate this. +* We can either turn the entire file to become non-sparse +* which we only do if the fallocate is for virtually +* the whole file, or we can overwrite the region with zeroes +* using SMB2_write, which could be prohibitevly expensive +* if len is large. +*/ +/* +* We are only trying to fallocate a small region so +* just write it with zero. +*/ +if (len <=1024 *1024 ) { + rc =smb3_simple_fallocate_range (xid, tcon, cfile, + off, len); + goto out; + } +/* * Check if falloc starts within first few pages of file * and ends within a few pages of the end of file to
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 197/593 ACPI: EC: trust DSDT GPE for certain HP laptop
In reply to Greg Kroah-HartmanFrom: Zhang Rui <[email protected]>
[ Upstream commit 4370cbf350dbaca984dbda9f9ce3fac45d6949d5 ]
On HP Pavilion Gaming Laptop 15-cx0xxx, the ECDT EC and DSDT EC share the same port addresses but different GPEs. And the DSDT GPE is the right one to use.
The current code duplicates DSDT EC with ECDT EC if the port addresses are the same, and uses ECDT GPE as a result, which breaks this machine.
Introduce a new quirk for the HP laptop to trust the DSDT GPE, and avoid duplicating even if the port addresses are the same.
--- drivers/acpi/ec.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +20 -1
@@ -183,6 +183,7 @@ static struct workqueue_struct *ec_query_wq;static int EC_FLAGS_CORRECT_ECDT ;/* Needs ECDT port address correction */ static int EC_FLAGS_IGNORE_DSDT_GPE ;/* Needs ECDT GPE as correction setting */ +static int EC_FLAGS_TRUST_DSDT_GPE ;/* Needs DSDT GPE as correction setting */ static int EC_FLAGS_CLEAR_ON_RESUME ;/* Needs acpi_ec_clear() on boot/resume */ /* --------------------------------------------------------------------------
@@ -1606,7 +1607,8 @@ static int acpi_ec_add(struct acpi_device *device) }if (boot_ec && ec->command_addr == boot_ec->command_addr && - ec->data_addr == boot_ec->data_addr) { + ec->data_addr == boot_ec->data_addr && + !EC_FLAGS_TRUST_DSDT_GPE ) {/* * Trust PNP0C09 namespace location rather than * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1829,6 +1831,18 @@ static int ec_correct_ecdt(const struct dmi_system_id *id)return 0 ; } +/* +* Some ECDTs contain wrong GPE setting, but they share the same port addresses +* with DSDT EC, don't duplicate the DSDT EC with ECDT EC in this case. +* https://bugzilla.kernel.org/show_bug.cgi?id=209989 +*/ +static int ec_honor_dsdt_gpe (const struct dmi_system_id *id) +{ +pr_debug ("Detected system needing DSDT GPE setting.\n" ); +EC_FLAGS_TRUST_DSDT_GPE =1 ; +return 0 ; +} +/* * Some DSDTs contain wrong GPE setting. * Asus FX502VD/VE, GL702VMK, X550VXK, X580VD
@@ -1883,6 +1897,11 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL}, { +/* https://bugzilla.kernel.org/show_bug.cgi?id=209989 */ + ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"),}, NULL}, + { ec_clear_on_resume, "Samsung hardware", { DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, {},
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 198/593 clocksource: Retry clock read if long delays detected
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit db3a34e17433de2390eb80d436970edcebd0ca3e ]
When the clocksource watchdog marks a clock as unstable, this might be due to that clock being unstable or it might be due to delays that happen to occur between the reads of the two clocks. Yes, interrupts are disabled across those two reads, but there are no shortage of things that can delay interrupts-disabled regions of code ranging from SMI handlers to vCPU preemption. It would be good to have some indication as to why the clock was marked unstable.
Therefore, re-read the watchdog clock on either side of the read from the clock under test. If the watchdog clock shows an excessive time delta between its pair of reads, the reads are retried.
The maximum number of retries is specified by a new kernel boot parameter clocksource.max_cswd_read_retries, which defaults to three, that is, up to four reads, one initial and up to three retries. If more than one retry was required, a message is printed on the console (the occasional single retry is expected behavior, especially in guest OSes). If the maximum number of retries is exceeded, the clock under test will be marked unstable. However, the probability of this happening due to various sorts of delays is quite small. In addition, the reason (clock-read delays) for the unstable marking will be apparent.
--- .../admin-guide/kernel-parameters.txt | 6 +++ kernel/time/clocksource.c | 53 ++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -577,6 +577,12 @@ loops can be debugged more effectively on production systems. + clocksource.max_cswd_read_retries= [KNL] + Number of clocksource_watchdog() retries due to + external delays before the clock will be marked + unstable. Defaults to three retries, that is, + four attempts to read the clock under test. + clearcpuid=BITNUM[,BITNUM...] [X86] Disable CPUID feature X for the kernel. See arch/x86/include/asm/cpufeatures.h for the valid bit
kernel/time/clocksource.c +47 -6
75 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 199/593 clocksource: Check per-CPU clock synchronization when marked unstable
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 7560c02bdffb7c52d1457fa551b9e745d4b9e754 ]
Some sorts of per-CPU clock sources have a history of going out of synchronization with each other. However, this problem has purportedy been solved in the past ten years. Except that it is all too possible that the problem has instead simply been made less likely, which might mean that some of the occasional "Marking clocksource 'tsc' as unstable" messages might be due to desynchronization. How would anyone know?
Therefore apply CPU-to-CPU synchronization checking to newly unstable clocksource that are marked with the new CLOCK_SOURCE_VERIFY_PERCPU flag. Lists of desynchronized CPUs are printed, with the caveat that if it is the reporting CPU that is itself desynchronized, it will appear that all the other clocks are wrong. Just like in real life.
--- arch/x86/kernel/tsc.c | 3 +- include/linux/clocksource.h | 2 +- kernel/time/clocksource.c | 60 +++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-)
arch/x86/kernel/tsc.c +2 -1
@@ -1151,7 +1151,8 @@ static struct clocksource clocksource_tsc = { .mask = CLOCKSOURCE_MASK(64), .flags =CLOCK_SOURCE_IS_CONTINUOUS |CLOCK_SOURCE_VALID_FOR_HRES | - CLOCK_SOURCE_MUST_VERIFY, +CLOCK_SOURCE_MUST_VERIFY | + CLOCK_SOURCE_VERIFY_PERCPU, .vdso_clock_mode = VDSO_CLOCKMODE_TSC, .enable = tsc_cs_enable, .resume = tsc_resume,
include/linux/clocksource.h +1 -1
@@ -131,7 +131,7 @@ struct clocksource {#define CLOCK_SOURCE_UNSTABLE 0x40#define CLOCK_SOURCE_SUSPEND_NONSTOP 0x80#define CLOCK_SOURCE_RESELECT 0x100 - +#define CLOCK_SOURCE_VERIFY_PERCPU 0x200/* simplify initialization of mask field */ #define CLOCKSOURCE_MASK (bits) GENMASK_ULL((bits) - 1, 0)
kernel/time/clocksource.c +60 -0
72 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 200/593 tpm_tis_spi: add missing SPI device ID entries
In reply to Greg Kroah-HartmanFrom: Javier Martinez Canillas <[email protected]>
[ Upstream commit c46ed2281bbe4b84e6f3d4bdfb0e4e9ab813fa9d ]
The SPI core always reports a "MODALIAS=spi:<foo>", even if the device was registered via OF. This means that this module won't auto-load if a DT has for example has a node with a compatible "infineon,slb9670" string.
In that case kmod will expect a "MODALIAS=of:N*T*Cinfineon,slb9670" uevent but instead will get a "MODALIAS=spi:slb9670", which is not present in the kernel module aliases:
$ modinfo drivers/char/tpm/tpm_tis_spi.ko | grep alias alias: of:N*T*Cgoogle,cr50C* alias: of:N*T*Cgoogle,cr50 alias: of:N*T*Ctcg,tpm_tis-spiC* alias: of:N*T*Ctcg,tpm_tis-spi alias: of:N*T*Cinfineon,slb9670C* alias: of:N*T*Cinfineon,slb9670 alias: of:N*T*Cst,st33htpm-spiC* alias: of:N*T*Cst,st33htpm-spi alias: spi:cr50 alias: spi:tpm_tis_spi alias: acpi*:SMO0768:*
To workaround this issue, add in the SPI device ID table all the entries that are present in the OF device ID table.
--- drivers/char/tpm/tpm_tis_spi_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/tpm/tpm_tis_spi_main.c +2 -0
@@ -260,6 +260,8 @@ static int tpm_tis_spi_remove(struct spi_device *dev) }static const struct spi_device_id tpm_tis_spi_id[] = { + {"st33htpm-spi" , (unsigned long )tpm_tis_spi_probe }, + {"slb9670" , (unsigned long )tpm_tis_spi_probe }, {"tpm_tis_spi" , (unsigned long )tpm_tis_spi_probe }, {"cr50" , (unsigned long )cr50_spi_probe }, {}
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 201/593 ACPI: tables: Add custom DSDT file as makefile prerequisite
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit d1059c1b1146870c52f3dac12cb7b6cbf39ed27f ]
A custom DSDT file is mostly used during development or debugging, and in that case it is quite likely to want to rebuild the kernel after changing ONLY the content of the DSDT.
This patch adds the custom DSDT as a prerequisite to tables.o to ensure a rebuild if the DSDT file is updated. Make will merge the prerequisites from multiple rules for the same target.
--- drivers/acpi/Makefile | 5 +++++ 1 file changed, 5 insertions(+)
drivers/acpi/Makefile +5 -0
@@ -8,6 +8,11 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # # ACPI Boot-Time Table Parsing # +ifeq ($(CONFIG_ACPI_CUSTOM_DSDT),y) +tables.o: $(src)/../../include/$(subst $\",,$(CONFIG_ACPI_CUSTOM_DSDT_FILE)) ; + +endif + obj-$(CONFIG_ACPI) += tables.o obj-$(CONFIG_X86) += blacklist.o
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 202/593 HID: wacom: Correct base usage for capacitive ExpressKey status bits
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
[ Upstream commit 424d8237945c6c448c8b3f23885d464fb5685c97 ]
The capacitive status of ExpressKeys is reported with usages beginning at 0x940, not 0x950. Bring our driver into alignment with reality.
--- drivers/hid/wacom_wac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/wacom_wac.h +1 -1
@@ -122,7 +122,7 @@#define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0454)#define WACOM_HID_WD_BATTERY_LEVEL (WACOM_HID_UP_WACOMDIGITIZER | 0x043b)#define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910) -#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950) +#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0940)#define WACOM_HID_WD_MODE_CHANGE (WACOM_HID_UP_WACOMDIGITIZER | 0x0980)#define WACOM_HID_WD_MUTE_DEVICE (WACOM_HID_UP_WACOMDIGITIZER | 0x0981)#define WACOM_HID_WD_CONTROLPANEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0982)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 203/593 cifs: fix missing spinlock around update to ses->status
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit 0060a4f28a9ef45ae8163c0805e944a2b1546762 ]
In the other places where we update ses->status we protect the updates via GlobalMid_Lock. So to be consistent add the same locking around it in cifs_put_smb_ses where it was missing.
Addresses-Coverity: 1268904 ("Data race condition")
--- fs/cifs/cifsglob.h | 3 ++- fs/cifs/connect.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-)
fs/cifs/cifsglob.h +2 -1
@@ -979,7 +979,7 @@ struct cifs_ses {struct mutex session_mutex;struct TCP_Server_Info *server;/* pointer to server info */ int ses_count;/* reference counter */ -enum statusEnum status; +enum statusEnum status;/* updates protected by GlobalMid_Lock */ unsigned overrideSecFlg;/* if non-zero override global sec flags */ char *serverOS;/* name of operating system underlying server */ char *serverNOS;/* name of network operating system of server */
@@ -1863,6 +1863,7 @@ require use of the stronger protocol */* list operations on pending_mid_q and oplockQ * updates to XID counters, multiplex id and SMB sequence numbers * list operations on global DnotifyReqList +* updates to ses->status * tcp_ses_lock protects: * list operations on tcp and SMB session lists * tcon->open_file_lock protects the list of open files hanging off the tcon
fs/cifs/connect.c +4 -1
@@ -2829,9 +2829,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses)spin_unlock (&cifs_tcp_ses_lock);return ; } +spin_unlock (&cifs_tcp_ses_lock); + +spin_lock (&GlobalMid_Lock);if (ses->status == CifsGood) ses->status = CifsExiting; -spin_unlock (&cifs_tcp_ses_lock); +spin_unlock (&GlobalMid_Lock);cifs_free_ipc (ses);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 204/593 mailbox: qcom: Use PLATFORM_DEVID_AUTO to register platform device
In reply to Greg Kroah-HartmanFrom: Shawn Guo <[email protected]>
[ Upstream commit 96e39e95c01283ff5695dafe659df88ada802159 ]
In adding APCS clock support for MSM8939, the second clock registration fails due to duplicate device name like below.
[ 0.519657] sysfs: cannot create duplicate filename '/bus/platform/devices/qcom-apcs-msm8916-clk' ... [ 0.661158] qcom_apcs_ipc b111000.mailbox: failed to register APCS clk
This is because MSM8939 has 3 APCS instances for Cluster0 (little cores), Cluster1 (big cores) and CCI (Cache Coherent Interconnect). Although only APCS of Cluster0 and Cluster1 have IPC bits, each of 3 APCS has A53PLL clock control bits. That said, 3 'qcom-apcs-msm8916-clk' devices need to be registered to instantiate all 3 clocks. Use PLATFORM_DEVID_AUTO rather than PLATFORM_DEVID_NONE for platform_device_register_data() call to fix the issue above.
--- drivers/mailbox/qcom-apcs-ipc-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/qcom-apcs-ipc-mailbox.c +1 -1
@@ -128,7 +128,7 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)if (apcs_data->clk_name) { apcs->clk =platform_device_register_data (&pdev->dev, apcs_data->clk_name, -PLATFORM_DEVID_NONE , +PLATFORM_DEVID_AUTO ,NULL ,0 );if (IS_ERR (apcs->clk))dev_err (&pdev->dev,"failed to register APCS clk\n" );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 205/593 block: fix discard request merge
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2705dfb2094777e405e065105e307074af8965c1 ]
ll_new_hw_segment() is reached only in case of single range discard merge, and we don't have max discard segment size limit actually, so it is wrong to run the following check:
if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
it may be always false since req->nr_phys_segments is initialized as one, and bio's segment count is still 1, blk_rq_get_max_segments(reg) is 1 too.
Fix the issue by not doing the check and bypassing the calculation of discard request's nr_phys_segments.
Based on analysis from Wang Shanker.
--- block/blk-merge.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
block/blk-merge.c +6 -2
@@ -552,10 +552,14 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)static inline int ll_new_hw_segment (struct request *req,struct bio *bio,unsigned int nr_phys_segs) { -if (req->nr_phys_segments + nr_phys_segs >blk_rq_get_max_segments (req)) +if (blk_integrity_merge_bio (req->q, req, bio) == false) goto no_merge; -if (blk_integrity_merge_bio (req->q, req, bio) == false) +/* discard request merge won't add new segment */ +if (req_op (req) ==REQ_OP_DISCARD ) +return 1 ; + +if (req->nr_phys_segments + nr_phys_segs >blk_rq_get_max_segments (req)) goto no_merge;/*
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 206/593 kthread_worker: fix return value when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync()
In reply to Greg Kroah-HartmanFrom: Petr Mladek <[email protected]>
[ Upstream commit d71ba1649fa3c464c51ec7163e4b817345bff2c7 ]
kthread_mod_delayed_work() might race with kthread_cancel_delayed_work_sync() or another kthread_mod_delayed_work() call. The function lets the other operation win when it sees work->canceling counter set. And it returns @false.
But it should return @true as it is done by the related workqueue API, see mod_delayed_work_on().
The reason is that the return value might be used for reference counting. It has to distinguish the case when the number of queued works has changed or stayed the same.
The change is safe. kthread_mod_delayed_work() return value is not checked anywhere at the moment.
--- kernel/kthread.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
kernel/kthread.c +12 -7
@@ -1107,14 +1107,14 @@ static bool __kthread_cancel_work(struct kthread_work *work)* modify @dwork's timer so that it expires after @delay. If @delay is zero, * @work is guaranteed to be queued immediately. * -* Return: %true if @dwork was pending and its timer was modified, -* %false otherwise. +* Return: %false if @dwork was idle and queued, %true otherwise. * * A special case is when the work is being canceled in parallel. * It might be caused either by the real kthread_cancel_delayed_work_sync() * or yet another kthread_mod_delayed_work() call. We let the other command -* win and return %false here. The caller is supposed to synchronize these -* operations a reasonable way. +* win and return %true here. The return value can be used for reference +* counting and the number of queued works stays the same. Anyway, the caller +* is supposed to synchronize these operations a reasonable way. * * This function is safe to call from any context including IRQ handler. * See __kthread_cancel_work() and kthread_delayed_work_timer_fn()
@@ -1126,13 +1126,15 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker, {struct kthread_work *work = &dwork->work;unsigned long flags; -int ret = false; +int ret;raw_spin_lock_irqsave (&worker->lock, flags);/* Do not bother with canceling when never queued. */ -if (!work->worker) +if (!work->worker) { + ret = false; goto fast_queue; + }/* Work must not be used with >1 worker, see kthread_queue_work() */ WARN_ON_ONCE (work->worker != worker);
@@ -1150,8 +1152,11 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,* be used for reference counting. */ kthread_cancel_delayed_work_timer (work, &flags); -if (work->canceling) +if (work->canceling) { +/* The number of works in the queue does not change. */ + ret = true; goto out; + } ret =__kthread_cancel_work (work); fast_queue:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 207/593 ia64: mca_drv: fix incorrect array size calculation
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit c5f320ff8a79501bb59338278336ec43acb9d7e2 ]
gcc points out a mistake in the mca driver that goes back to before the git history:
arch/ia64/kernel/mca_drv.c: In function 'init_record_index_pools':arch/ia64/kernel/mca_drv.c:346:54: error: expression does not compute the number of elements in this array; element typ e is 'int', not 'size_t' {aka 'long unsigned int'} [-Werror=sizeof-array-div]
346 | for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
| ^
This is the same as sizeof(size_t), which is two shorter than the actual array. Use the ARRAY_SIZE() macro to get the correct calculation instead.
--- arch/ia64/kernel/mca_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/mca_drv.c +1 -1
@@ -343,7 +343,7 @@ init_record_index_pools(void)/* - 2 - */ sect_min_size = sal_log_sect_min_sizes[0 ]; -for (i =1 ; i <sizeof sal_log_sect_min_sizes/sizeof (size_t ); i++) +for (i =1 ; i <ARRAY_SIZE (sal_log_sect_min_sizes); i++)if (sect_min_size > sal_log_sect_min_sizes[i]) sect_min_size = sal_log_sect_min_sizes[i];
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 208/593 writeback, cgroup: increment isw_nr_in_flight before grabbing an inode
In reply to Greg Kroah-HartmanFrom: Roman Gushchin <[email protected]>
[ Upstream commit 8826ee4fe75051f8cbfa5d4a9aa70565938e724c ]
isw_nr_in_flight is used to determine whether the inode switch queue should be flushed from the umount path. Currently it's increased after grabbing an inode and even scheduling the switch work. It means the umount path can walk past cleanup_offline_cgwb() with active inode references, which can result in a "Busy inodes after unmount." message and use-after-free issues (with inode->i_sb which gets freed).
Fix it by incrementing isw_nr_in_flight before doing anything with the inode and decrementing in the case when switching wasn't scheduled.
The problem hasn't yet been seen in the real life and was discovered by Jan Kara by looking into the code.
--- fs/fs-writeback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/fs-writeback.c +3 -2
@@ -505,6 +505,8 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)if (!isw)return ; +atomic_inc (&isw_nr_in_flight); +/* find and pin the new wb */ rcu_read_lock (); memcg_css =css_from_id (new_wb_id, &memory_cgrp_subsys);
@@ -535,11 +537,10 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)* Let's continue after I_WB_SWITCH is guaranteed to be visible. */ call_rcu (&isw->rcu_head, inode_switch_wbs_rcu_fn); - -atomic_inc (&isw_nr_in_flight);return ; out_free: +atomic_dec (&isw_nr_in_flight);if (isw->new_wb)wb_put (isw->new_wb);kfree (isw);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 209/593 spi: Allow to have all native CSs in use along with GPIOs
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit dbaca8e56ea3f23fa215f48c2d46dd03ede06e02 ]
The commit 7d93aecdb58d ("spi: Add generic support for unused native cs with cs-gpios") excludes the valid case for the controllers that doesn't need to switch native CS in order to perform the transfer, i.e. when
0 native
... ...
<n> - 1 native
<n> GPIO
<n> + 1 GPIO
... ...
where <n> defines maximum of native CSs supported by the controller.
To allow this, bail out from spi_get_gpio_descs() conditionally for the controllers which explicitly marked with SPI_MASTER_GPIO_SS.
--- drivers/spi/spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi.c +3 -2
@@ -2615,8 +2615,9 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr) } ctlr->unused_native_cs =ffz (native_cs_mask); -if (num_cs_gpios && ctlr->max_native_cs && - ctlr->unused_native_cs >= ctlr->max_native_cs) { + +if ((ctlr->flags &SPI_MASTER_GPIO_SS ) && num_cs_gpios && + ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {dev_err (dev,"No unused native chip select available\n" );return -EINVAL ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 210/593 spi: Avoid undefined behaviour when counting unused native CSs
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit f60d7270c8a3d2beb1c23ae0da42497afa3584c2 ]
ffz(), that has been used to count unused native CSs, might cause undefined behaviour when called against ~0U. To fix that, open code it with ffs(~value) - 1.
--- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
@@ -2614,7 +2614,7 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr) native_cs_mask |=BIT (i); } - ctlr->unused_native_cs =ffz (native_cs_mask); + ctlr->unused_native_cs =ffs (~native_cs_mask) -1 ;if ((ctlr->flags &SPI_MASTER_GPIO_SS ) && num_cs_gpios && ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 211/593 media: venus: Rework error fail recover logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 4cba5473c5ce0f1389d316c5dc6f83a0259df5eb ]
The Venus code has a sort of watchdog that attempts to recover from IP errors, implemented as a delayed work job, which calls venus_sys_error_handler().
Right now, it has several issues:
1. It assumes that PM runtime resume never fails
2. It internally runs two while() loops that also assume that PM runtime will never fail to go idle:
while (pm_runtime_active(core->dev_dec) || pm_runtime_active(core->dev_enc)) msleep(10);
...
while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0])) usleep_range(1000, 1500);
3. It uses an OR to merge all return codes and then report to the user
4. If the hardware never recovers, it keeps running on every 10ms, flooding the syslog with 2 messages (so, up to 200 messages per second).
Rework the code, in order to prevent that, by:
1. check the return code from PM runtime resume;
2. don't let the while() loops run forever;
3. store the failed event;
4. use warn ratelimited when it fails to recover.
--- drivers/media/platform/qcom/venus/core.c | 60 +++++++++++++++++++----- 1 file changed, 47 insertions(+), 13 deletions(-)
drivers/media/platform/qcom/venus/core.c +47 -13
@@ -48,52 +48,86 @@ static const struct hfi_core_ops venus_core_ops = { .event_notify = venus_event_notify, }; +#define RPM_WAIT_FOR_IDLE_MAX_ATTEMPTS 10 +static void venus_sys_error_handler (struct work_struct *work) {struct venus_core *core = container_of(work, struct venus_core, work.work); -int ret =0 ; - -pm_runtime_get_sync (core->dev); +int ret, i, max_attempts =RPM_WAIT_FOR_IDLE_MAX_ATTEMPTS ; +const char *err_msg ="" ; +bool failed = false; + + ret =pm_runtime_get_sync (core->dev); +if (ret <0 ) { + err_msg ="resume runtime PM" ; + max_attempts =0 ; + failed = true; + }hfi_core_deinit (core, true); -dev_warn (core->dev,"system error has occurred, starting recovery!\n" ); -mutex_lock (&core->lock); -while (pm_runtime_active (core->dev_dec) ||pm_runtime_active (core->dev_enc)) +for (i =0 ; i < max_attempts; i++) { +if (!pm_runtime_active (core->dev_dec) && !pm_runtime_active (core->dev_enc)) +break ;msleep (10 ); + }venus_shutdown (core);pm_runtime_put_sync (core->dev); -while (core->pmdomains[0 ] &&pm_runtime_active (core->pmdomains[0 ])) +for (i =0 ; i < max_attempts; i++) { +if (!core->pmdomains[0 ] || !pm_runtime_active (core->pmdomains[0 ])) +break ;usleep_range (1000 ,1500 ); + }hfi_reinit (core); -pm_runtime_get_sync (core->dev); + ret =pm_runtime_get_sync (core->dev); +if (ret <0 ) { + err_msg ="resume runtime PM" ; + failed = true; + } + + ret =venus_boot (core); +if (ret && !failed) { + err_msg ="boot Venus" ; + failed = true; + } - ret |=venus_boot (core); - ret |=hfi_core_resume (core, true); + ret =hfi_core_resume (core, true); +if (ret && !failed) { + err_msg ="resume HFI" ; + failed = true; + }enable_irq (core->irq);mutex_unlock (&core->lock); - ret |=hfi_core_init (core); + ret =hfi_core_init (core); +if (ret && !failed) { + err_msg ="init HFI" ; + failed = true; + }pm_runtime_put_sync (core->dev); -if (ret) { +if (failed) {disable_irq_nosync (core->irq); -dev_warn (core->dev,"recovery failed (%d)\n" , ret); +dev_warn_ratelimited (core->dev, +"System error has occurred, recovery failed to %s\n" , + err_msg);schedule_delayed_work (&core->work,msecs_to_jiffies (10 ));return ; } +dev_warn (core->dev,"system error has occurred (recovered)\n" ); +mutex_lock (&core->lock); core->sys_error = false;mutex_unlock (&core->lock);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 212/593 media: s5p_cec: decrement usage count if disabled
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 747bad54a677d8633ec14b39dfbeb859c821d7f2 ]
There's a bug at s5p_cec_adap_enable(): if called to disable the device, it should call pm_runtime_put() instead of pm_runtime_disable(), as the goal here is to decrement the usage_count and not to disable PM runtime.
--- drivers/media/cec/platform/s5p/s5p_cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/cec/platform/s5p/s5p_cec.c +1 -1
@@ -54,7 +54,7 @@ static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable) }else {s5p_cec_mask_tx_interrupts (cec);s5p_cec_mask_rx_interrupts (cec); -pm_runtime_disable (cec->dev); +pm_runtime_put (cec->dev); }return 0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 213/593 media: hantro: do a PM resume earlier
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 892bb6ecead9b834ba7ad1d07513e9eba1baa3a4 ]
The device_run() first enables the clock and then
tries to resume PM runtime, checking for errors.
Well, if for some reason the pm_runtime can not resume, it would be better to detect it beforehand.
So, change the order inside device_run().
--- drivers/staging/media/hantro/hantro_drv.c | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +22 -11
@@ -56,16 +56,12 @@ dma_addr_t hantro_get_ref(struct hantro_ctx *ctx, u64 ts)return hantro_get_dec_buf_addr (ctx, buf); } -static void hantro_job_finish (struct hantro_dev *vpu, -struct hantro_ctx *ctx, -enum vb2_buffer_state result) +static void hantro_job_finish_no_pm (struct hantro_dev *vpu, +struct hantro_ctx *ctx, +enum vb2_buffer_state result) {struct vb2_v4l2_buffer *src, *dst; -pm_runtime_mark_last_busy (vpu->dev); -pm_runtime_put_autosuspend (vpu->dev); -clk_bulk_disable (vpu->variant->num_clocks, vpu->clocks); - src =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); dst =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx);
@@ -81,6 +77,18 @@ static void hantro_job_finish(struct hantro_dev *vpu, result); } +static void hantro_job_finish (struct hantro_dev *vpu, +struct hantro_ctx *ctx, +enum vb2_buffer_state result) +{ +pm_runtime_mark_last_busy (vpu->dev); +pm_runtime_put_autosuspend (vpu->dev); + +clk_bulk_disable (vpu->variant->num_clocks, vpu->clocks); + +hantro_job_finish_no_pm (vpu, ctx, result); +} +void hantro_irq_done (struct hantro_dev *vpu,enum vb2_buffer_state result) {
@@ -152,12 +160,15 @@ static void device_run(void *priv) src =hantro_get_src_buf (ctx); dst =hantro_get_dst_buf (ctx); + ret =pm_runtime_get_sync (ctx->dev->dev); +if (ret <0 ) { +pm_runtime_put_noidle (ctx->dev->dev); + goto err_cancel_job; + } + ret =clk_bulk_enable (ctx->dev->variant->num_clocks, ctx->dev->clocks);if (ret) goto err_cancel_job; - ret =pm_runtime_get_sync (ctx->dev->dev); -if (ret <0 ) - goto err_cancel_job;v4l2_m2m_buf_copy_metadata (src, dst, true);
@@ -165,7 +176,7 @@ static void device_run(void *priv)return ; err_cancel_job: -hantro_job_finish (ctx->dev, ctx,VB2_BUF_STATE_ERROR ); +hantro_job_finish_no_pm (ctx->dev, ctx,VB2_BUF_STATE_ERROR ); }static struct v4l2_m2m_ops vpu_m2m_ops = {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 214/593 crypto: ixp4xx - dma_unmap the correct address
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 9395c58fdddd79cdd3882132cdd04e8ac7ad525f ]
Testing ixp4xx_crypto with CONFIG_DMA_API_DEBUG lead to the following error:
DMA-API: platform ixp4xx_crypto.0: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=24 bytes]
This is due to dma_unmap using the wrong address.
--- drivers/crypto/ixp4xx_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ixp4xx_crypto.c +1 -1
@@ -330,7 +330,7 @@ static void free_buf_chain(struct device *dev, struct buffer_desc *buf, buf1 = buf->next; phys1 = buf->phys_next; -dma_unmap_single (dev, buf->phys_next, buf->buf_len, buf->dir); +dma_unmap_single (dev, buf->phys_addr, buf->buf_len, buf->dir);dma_pool_free (buffer_pool, buf, phys); buf = buf1; phys = phys1;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 215/593 crypto: ixp4xx - update IV after requests
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit e8acf011f2e7e21a7e2fae47cbaa06598e533d40 ]
Crypto selftests fail on ixp4xx since it do not update IV after skcipher requests.
--- drivers/crypto/ixp4xx_crypto.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/crypto/ixp4xx_crypto.c +22 -0
@@ -149,6 +149,8 @@ struct crypt_ctl {struct ablk_ctx {struct buffer_desc *src;struct buffer_desc *dst; +u8 iv[MAX_IVLEN ]; +bool encrypt; };struct aead_ctx {
@@ -381,6 +383,20 @@ static void one_packet(dma_addr_t phys)case CTL_FLAG_PERFORM_ABLK : {struct skcipher_request *req = crypt->data.ablk_req;struct ablk_ctx *req_ctx =skcipher_request_ctx (req); +struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req); +unsigned int ivsize =crypto_skcipher_ivsize (tfm); +unsigned int offset; + +if (ivsize >0 ) { + offset = req->cryptlen - ivsize; +if (req_ctx->encrypt) { +scatterwalk_map_and_copy (req->iv, req->dst, + offset, ivsize,0 ); + }else { +memcpy (req->iv, req_ctx->iv, ivsize); +memzero_explicit (req_ctx->iv, ivsize); + } + }if (req_ctx->dst) {free_buf_chain (dev, req_ctx->dst, crypt->dst_buf);
@@ -876,6 +892,7 @@ static int ablk_perform(struct skcipher_request *req, int encrypt)struct ablk_ctx *req_ctx =skcipher_request_ctx (req);struct buffer_desc src_hook;struct device *dev = &pdev->dev; +unsigned int offset;gfp_t flags = req->base.flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC ;
@@ -885,6 +902,7 @@ static int ablk_perform(struct skcipher_request *req, int encrypt)return -EAGAIN ; dir = encrypt ? &ctx->encrypt : &ctx->decrypt; + req_ctx->encrypt = encrypt; crypt =get_crypt_desc ();if (!crypt)
@@ -900,6 +918,10 @@ static int ablk_perform(struct skcipher_request *req, int encrypt)BUG_ON (ivsize && !req->iv);memcpy (crypt->iv, req->iv, ivsize); +if (ivsize >0 && !encrypt) { + offset = req->cryptlen - ivsize; +scatterwalk_map_and_copy (req_ctx->iv, req->src, offset, ivsize,0 ); + }if (req->src != req->dst) {struct buffer_desc dst_hook; crypt->mode |=NPE_OP_NOT_IN_PLACE ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 216/593 crypto: ux500 - Fix error return code in hash_hw_final()
In reply to Greg Kroah-HartmanFrom: Zhen Lei <[email protected]>
[ Upstream commit b01360384009ab066940b45f34880991ea7ccbfb ]
Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.
--- drivers/crypto/ux500/hash/hash_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/ux500/hash/hash_core.c +1 -0
@@ -1009,6 +1009,7 @@ static int hash_hw_final(struct ahash_request *req) goto out; } }else if (req->nbytes ==0 && ctx->keylen >0 ) { + ret = -EPERM ;dev_err (device_data->dev,"%s: Empty message with keylength > 0, NOT supported\n" , __func__); goto out;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 217/593 sata_highbank: fix deferred probing
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 4a24efa16e7db02306fb5db84518bb0a7ada5a46 ]
The driver overrides the error codes returned by platform_get_irq() to -EINVAL, so if it returns -EPROBE_DEFER, the driver would fail the probe permanently instead of the deferred probing. Switch to propagating the error code upstream, still checking/overriding IRQ0 as libata regards it as "no IRQ" (thus polling) anyway...
--- drivers/ata/sata_highbank.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ata/sata_highbank.c +4 -2
@@ -469,10 +469,12 @@ static int ahci_highbank_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) { +if (irq <0 ) {dev_err (dev,"no irq\n" ); -return -EINVAL ; +return irq; } +if (!irq) +return -EINVAL ; hpriv =devm_kzalloc (dev,sizeof (*hpriv),GFP_KERNEL );if (!hpriv) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 218/593 pata_rb532_cf: fix deferred probing
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 2d3a62fbae8e5badc2342388f65ab2191c209cc0 ]
The driver overrides the error codes returned by platform_get_irq() to -ENOENT, so if it returns -EPROBE_DEFER, the driver would fail the probe permanently instead of the deferred probing. Switch to propagating the error code upstream, still checking/overriding IRQ0 as libata regards it as "no IRQ" (thus polling) anyway...
--- drivers/ata/pata_rb532_cf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ata/pata_rb532_cf.c +4 -2
@@ -115,10 +115,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) { +if (irq <0 ) {dev_err (&pdev->dev,"no IRQ resource found\n" ); -return -ENOENT ; +return irq; } +if (!irq) +return -EINVAL ; gpiod =devm_gpiod_get (&pdev->dev,NULL ,GPIOD_IN );if (IS_ERR (gpiod)) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 219/593 media: I2C: change RST to "RSET" to fix multiple build errors
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 8edcb5049ac29aa3c8acc5ef15dd4036543d747e ]
The use of an enum named 'RST' conflicts with a #define macro named 'RST' in arch/mips/include/asm/mach-rc32434/rb.h.
The MIPS use of RST was there first (AFAICT), so change the media/i2c/ uses of RST to be named 'RSET'.
'git grep -w RSET' does not report any naming conflicts with the new name.
This fixes multiple build errors:
arch/mips/include/asm/mach-rc32434/rb.h:15:14: error: expected identifier before '(' token
15 | #define RST (1 << 15)
| ^
drivers/media/i2c/s5c73m3/s5c73m3.h:356:2: note: in expansion of macro 'RST'
356 | RST,
| ^~~../arch/mips/include/asm/mach-rc32434/rb.h:15:14: error: expected identifier before '(' token
15 | #define RST (1 << 15)
| ^
../drivers/media/i2c/s5k6aa.c:180:2: note: in expansion of macro 'RST'
180 | RST,
| ^~~../arch/mips/include/asm/mach-rc32434/rb.h:15:14: error: expected identifier before '(' token
15 | #define RST (1 << 15)
| ^
../drivers/media/i2c/s5k5baf.c:238:2: note: in expansion of macro 'RST'
238 | RST,
| ^~~and some others that I have trimmed.
--- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 6 +++--- drivers/media/i2c/s5c73m3/s5c73m3.h | 2 +- drivers/media/i2c/s5k4ecgx.c | 10 +++++----- drivers/media/i2c/s5k5baf.c | 6 +++--- drivers/media/i2c/s5k6aa.c | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-)
drivers/media/i2c/s5c73m3/s5c73m3-core.c +3 -3
@@ -1386,7 +1386,7 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)s5c73m3_gpio_deassert (state,STBY );usleep_range (100 ,200 ); -s5c73m3_gpio_deassert (state,RST ); +s5c73m3_gpio_deassert (state,RSET );usleep_range (50 ,100 );return 0 ;
@@ -1401,7 +1401,7 @@ static int __s5c73m3_power_off(struct s5c73m3 *state) {int i, ret; -if (s5c73m3_gpio_assert (state,RST )) +if (s5c73m3_gpio_assert (state,RSET ))usleep_range (10 ,50 );if (s5c73m3_gpio_assert (state,STBY ))
@@ -1606,7 +1606,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state) state->mclk_frequency = pdata->mclk_frequency; state->gpio[STBY ] = pdata->gpio_stby; - state->gpio[RST ] = pdata->gpio_reset; + state->gpio[RSET ] = pdata->gpio_reset;return 0 ; }
drivers/media/i2c/s5c73m3/s5c73m3.h +1 -1
@@ -353,7 +353,7 @@ struct s5c73m3_ctrls {enum s5c73m3_gpio_id {STBY , -RST , +RSET ,GPIO_NUM , };
drivers/media/i2c/s5k4ecgx.c +5 -5
@@ -173,7 +173,7 @@ static const char * const s5k4ecgx_supply_names[] = {enum s5k4ecgx_gpio_id {STBY , -RST , +RSET ,GPIO_NUM , };
@@ -476,7 +476,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)if (s5k4ecgx_gpio_set_value (priv,STBY , priv->gpio[STBY ].level))usleep_range (30 ,50 ); -if (s5k4ecgx_gpio_set_value (priv,RST , priv->gpio[RST ].level)) +if (s5k4ecgx_gpio_set_value (priv,RSET , priv->gpio[RSET ].level))usleep_range (30 ,50 );return 0 ;
@@ -484,7 +484,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)static int __s5k4ecgx_power_off (struct s5k4ecgx *priv) { -if (s5k4ecgx_gpio_set_value (priv,RST , !priv->gpio[RST ].level)) +if (s5k4ecgx_gpio_set_value (priv,RSET , !priv->gpio[RSET ].level))usleep_range (30 ,50 );if (s5k4ecgx_gpio_set_value (priv,STBY , !priv->gpio[STBY ].level))
@@ -872,7 +872,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,int ret; priv->gpio[STBY ].gpio = -EINVAL ; - priv->gpio[RST ].gpio = -EINVAL ; + priv->gpio[RSET ].gpio = -EINVAL ; ret =s5k4ecgx_config_gpio (gpio->gpio, gpio->level,"S5K4ECGX_STBY" );
@@ -891,7 +891,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,s5k4ecgx_free_gpios (priv);return ret; } - priv->gpio[RST ] = *gpio; + priv->gpio[RSET ] = *gpio;if (gpio_is_valid (gpio->gpio))gpio_set_value (gpio->gpio,0 );
drivers/media/i2c/s5k5baf.c +3 -3
@@ -235,7 +235,7 @@ struct s5k5baf_gpio {enum s5k5baf_gpio_id {STBY , -RST , +RSET ,NUM_GPIOS , };
@@ -969,7 +969,7 @@ static int s5k5baf_power_on(struct s5k5baf *state)s5k5baf_gpio_deassert (state,STBY );usleep_range (50 ,100 ); -s5k5baf_gpio_deassert (state,RST ); +s5k5baf_gpio_deassert (state,RSET );return 0 ; err_reg_dis:
@@ -987,7 +987,7 @@ static int s5k5baf_power_off(struct s5k5baf *state) state->apply_cfg =0 ; state->apply_crop =0 ; -s5k5baf_gpio_assert (state,RST ); +s5k5baf_gpio_assert (state,RSET );s5k5baf_gpio_assert (state,STBY );if (!IS_ERR (state->clock))
drivers/media/i2c/s5k6aa.c +5 -5
@@ -177,7 +177,7 @@ static const char * const s5k6aa_supply_names[] = {enum s5k6aa_gpio_id {STBY , -RST , +RSET ,GPIO_NUM , };
@@ -841,7 +841,7 @@ static int __s5k6aa_power_on(struct s5k6aa *s5k6aa) ret = s5k6aa->s_power (1 );usleep_range (4000 ,5000 ); -if (s5k6aa_gpio_deassert (s5k6aa,RST )) +if (s5k6aa_gpio_deassert (s5k6aa,RSET ))msleep (20 );return ret;
@@ -851,7 +851,7 @@ static int __s5k6aa_power_off(struct s5k6aa *s5k6aa) {int ret; -if (s5k6aa_gpio_assert (s5k6aa,RST )) +if (s5k6aa_gpio_assert (s5k6aa,RSET ))usleep_range (100 ,150 );if (s5k6aa->s_power) {
@@ -1510,7 +1510,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,int ret; s5k6aa->gpio[STBY ].gpio = -EINVAL ; - s5k6aa->gpio[RST ].gpio = -EINVAL ; + s5k6aa->gpio[RSET ].gpio = -EINVAL ; gpio = &pdata->gpio_stby;if (gpio_is_valid (gpio->gpio)) {
@@ -1533,7 +1533,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,if (ret <0 )return ret; - s5k6aa->gpio[RST ] = *gpio; + s5k6aa->gpio[RSET ] = *gpio; }return 0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 220/593 sched/uclamp: Fix wrong implementation of cpu.uclamp.min
In reply to Greg Kroah-HartmanFrom: Qais Yousef <[email protected]>
[ Upstream commit 0c18f2ecfcc274a4bcc1d122f79ebd4001c3b445 ]
cpu.uclamp.min is a protection as described in cgroup-v2 Resource Distribution Model
Documentation/admin-guide/cgroup-v2.rst
which means we try our best to preserve the minimum performance point of tasks in this group. See full description of cpu.uclamp.min in the cgroup-v2.rst.
But the current implementation makes it a limit, which is not what was intended.
For example:
tg->cpu.uclamp.min = 20% p0->uclamp[UCLAMP_MIN] = 0 p1->uclamp[UCLAMP_MIN] = 50% Previous Behavior (limit): p0->effective_uclamp = 0 p1->effective_uclamp = 20% New Behavior (Protection): p0->effective_uclamp = 20% p1->effective_uclamp = 50%
Which is inline with how protections should work.
With this change the cgroup and per-task behaviors are the same, as expected.
Additionally, we remove the confusing relationship between cgroup and !user_defined flag.
We don't want for example RT tasks that are boosted by default to max to change their boost value when they attach to a cgroup. If a cgroup wants to limit the max performance point of tasks attached to it, then cpu.uclamp.max must be set accordingly.
Or if they want to set different boost value based on cgroup, then sysctl_sched_util_clamp_min_rt_default must be used to NOT boost to max and set the right cpu.uclamp.min for each group to let the RT tasks obtain the desired boost value when attached to that group.
As it stands the dependency on !user_defined flag adds an extra layer of complexity that is not required now cpu.uclamp.min behaves properly as a protection.
The propagation model of effective cpu.uclamp.min in child cgroups as implemented by cpu_util_update_eff() is still correct. The parent protection sets an upper limit of what the child cgroups will effectively get.
--- kernel/sched/core.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
kernel/sched/core.c +17 -4
@@ -1065,7 +1065,6 @@ uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id) {struct uclamp_se uc_req = p->uclamp_req[clamp_id];#ifdef CONFIG_UCLAMP_TASK_GROUP -struct uclamp_se uc_max;/* * Tasks in autogroups or root task group will be
@@ -1076,9 +1075,23 @@ uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)if (task_group (p) == &root_task_group)return uc_req; - uc_max =task_group (p)->uclamp[clamp_id]; -if (uc_req.value > uc_max.value || !uc_req.user_defined) -return uc_max; +switch (clamp_id) { +case UCLAMP_MIN : { +struct uclamp_se uc_min =task_group (p)->uclamp[clamp_id]; +if (uc_req.value < uc_min.value) +return uc_min; +break ; + } +case UCLAMP_MAX : { +struct uclamp_se uc_max =task_group (p)->uclamp[clamp_id]; +if (uc_req.value > uc_max.value) +return uc_max; +break ; + } +default : +WARN_ON_ONCE (1 ); +break ; + }#endif return uc_req;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 221/593 sched/uclamp: Fix locking around cpu_util_update_eff()
In reply to Greg Kroah-HartmanFrom: Qais Yousef <[email protected]>
[ Upstream commit 93b73858701fd01de26a4a874eb95f9b7156fd4b ]
cpu_cgroup_css_online() calls cpu_util_update_eff() without holding the uclamp_mutex or rcu_read_lock() like other call sites, which is a mistake.
The uclamp_mutex is required to protect against concurrent reads and writes that could update the cgroup hierarchy.
The rcu_read_lock() is required to traverse the cgroup data structures in cpu_util_update_eff().
Surround the caller with the required locks and add some asserts to better document the dependency in cpu_util_update_eff().
--- kernel/sched/core.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/sched/core.c +7 -0
@@ -7620,7 +7620,11 @@ static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)#ifdef CONFIG_UCLAMP_TASK_GROUP /* Propagate the effective uclamp value for the new group */ +mutex_lock (&uclamp_mutex); +rcu_read_lock ();cpu_util_update_eff (css); +rcu_read_unlock (); +mutex_unlock (&uclamp_mutex);#endif return 0 ;
@@ -7710,6 +7714,9 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css)enum uclamp_id clamp_id;unsigned int clamps; +lockdep_assert_held (&uclamp_mutex); +SCHED_WARN_ON (!rcu_read_lock_held ()); +css_for_each_descendant_pre (css, top_css) { uc_parent =css_tg (css)->parent ?css_tg (css)->parent->uclamp :NULL ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 222/593 kbuild: Fix objtool dependency for OBJECT_FILES_NON_STANDARD_<obj> := n
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 8852c552402979508fdc395ae07aa8761aa46045 ]
"OBJECT_FILES_NON_STANDARD_vma.o := n" has a dependency bug. When objtool source is updated, the affected object doesn't get re-analyzed by objtool.
Peter's new variable-sized jump label feature relies on objtool rewriting the object file. Otherwise the system can fail to boot. That effectively upgrades this minor dependency issue to a major bug.
The problem is that variables in prerequisites are expanded early, during the read-in phase. The '$(objtool_dep)' variable indirectly uses '$@', which isn't yet available when the target prerequisites are evaluated.
Use '.SECONDEXPANSION:' which causes '$(objtool_dep)' to be expanded in a later phase, after the target-specific '$@' variable has been defined.
--- scripts/Makefile.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/Makefile.build +3 -2
@@ -275,7 +275,8 @@ define rule_as_o_S endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE +.SECONDEXPANSION: +$(obj)/%.o: $(src)/%.c $(recordmcount_source) $$(objtool_dep) FORCE $(call if_changed_rule,cc_o_c) $(call cmd,force_checksrc)
@@ -356,7 +357,7 @@ cmd_modversions_S = \ fi endif -$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE +$(obj)/%.o: $(src)/%.S $$(objtool_dep) FORCE $(call if_changed_rule,as_o_S) targets += $(filter-out $(subdir-builtin), $(real-obj-y))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 223/593 pata_octeon_cf: avoid WARN_ON() in ata_host_activate()
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit bfc1f378c8953e68ccdbfe0a8c20748427488b80 ]
Iff platform_get_irq() fails (or returns IRQ0) and thus the polling mode has to be used, ata_host_activate() hits the WARN_ON() due to 'irq_handler' parameter being non-NULL if the polling mode is selected. Let's only set the pointer to the driver's IRQ handler if platform_get_irq() returns a valid IRQ # -- this should avoid the unnecessary WARN_ON()...
--- drivers/ata/pata_octeon_cf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_octeon_cf.c +3 -2
@@ -898,10 +898,11 @@ static int octeon_cf_probe(struct platform_device *pdev)return -EINVAL ; } - irq_handler = octeon_cf_interrupt; i =platform_get_irq (dma_dev,0 ); -if (i >0 ) +if (i >0 ) { irq = i; + irq_handler = octeon_cf_interrupt; + } }of_node_put (dma_node); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 224/593 evm: fix writing <securityfs>/evm overflow
In reply to Greg Kroah-HartmanFrom: Mimi Zohar <[email protected]>
[ Upstream commit 49219d9b8785ba712575c40e48ce0f7461254626 ]
EVM_SETUP_COMPLETE is defined as 0x80000000, which is larger than INT_MAX. The "-fno-strict-overflow" compiler option properly prevents signaling EVM that the EVM policy setup is complete. Define and read an unsigned int.
--- security/integrity/evm/evm_secfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
security/integrity/evm/evm_secfs.c +3 -2
@@ -66,12 +66,13 @@ static ssize_t evm_read_key(struct file *filp, char __user *buf,static ssize_t evm_write_key (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -int i, ret; +unsigned int i; +int ret;if (!capable (CAP_SYS_ADMIN ) || (evm_initialized &EVM_SETUP_COMPLETE ))return -EPERM ; - ret =kstrtoint_from_user (buf, count,0 , &i); + ret =kstrtouint_from_user (buf, count,0 , &i);if (ret)return ret;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 225/593 x86/elf: Use _BITUL() macro in UAPI headers
In reply to Greg Kroah-HartmanFrom: Joe Richey <[email protected]>
[ Upstream commit d06aca989c243dd9e5d3e20aa4e5c2ecfdd07050 ]
Replace BIT() in x86's UAPI header with _BITUL(). BIT() is not defined in the UAPI headers and its usage may cause userspace build errors.
--- arch/x86/include/uapi/asm/hwcap2.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/uapi/asm/hwcap2.h +4 -2
@@ -2,10 +2,12 @@#ifndef _ASM_X86_HWCAP2_H#define _ASM_X86_HWCAP2_H +#include <linux/const.h> +/* MONITOR/MWAIT enabled in Ring 3 */ -#define HWCAP2_RING3MWAIT (1 << 0) +#define HWCAP2_RING3MWAIT _BITUL(0)/* Kernel allows FSGSBASE instructions available in Ring 3 */ -#define HWCAP2_FSGSBASE BIT(1) +#define HWCAP2_FSGSBASE _BITUL(1)#endif
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 226/593 crypto: sa2ul - Fix leaks on failure paths with sa_dma_init()
In reply to Greg Kroah-HartmanFrom: Suman Anna <[email protected]>
[ Upstream commit 4c0716ee1d973f6504d13f0e8d4d10350c85ad37 ]
The sa_dma_init() function doesn't release the requested dma channels on all failure paths. Any failure in this function also ends up leaking the dma pool created in sa_init_mem() in the sa_ul_probe() function. Fix all of these issues.
--- drivers/crypto/sa2ul.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/crypto/sa2ul.c +12 -9
@@ -2270,9 +2270,9 @@ static int sa_dma_init(struct sa_crypto_data *dd) dd->dma_rx2 =dma_request_chan (dd->dev,"rx2" );if (IS_ERR (dd->dma_rx2)) { -dma_release_channel (dd->dma_rx1); -return dev_err_probe (dd->dev,PTR_ERR (dd->dma_rx2), -"Unable to request rx2 DMA channel\n" ); + ret =dev_err_probe (dd->dev,PTR_ERR (dd->dma_rx2), +"Unable to request rx2 DMA channel\n" ); + goto err_dma_rx2; } dd->dma_tx =dma_request_chan (dd->dev,"tx" );
@@ -2293,28 +2293,31 @@ static int sa_dma_init(struct sa_crypto_data *dd)if (ret) {dev_err (dd->dev,"can't configure IN dmaengine slave: %d\n" , ret); -return ret; + goto err_dma_config; } ret =dmaengine_slave_config (dd->dma_rx2, &cfg);if (ret) {dev_err (dd->dev,"can't configure IN dmaengine slave: %d\n" , ret); -return ret; + goto err_dma_config; } ret =dmaengine_slave_config (dd->dma_tx, &cfg);if (ret) {dev_err (dd->dev,"can't configure OUT dmaengine slave: %d\n" , ret); -return ret; + goto err_dma_config; }return 0 ; +err_dma_config: +dma_release_channel (dd->dma_tx); err_dma_tx: -dma_release_channel (dd->dma_rx1);dma_release_channel (dd->dma_rx2); +err_dma_rx2: +dma_release_channel (dd->dma_rx1);return ret; }
@@ -2359,7 +2362,7 @@ static int sa_ul_probe(struct platform_device *pdev)sa_init_mem (dev_data); ret =sa_dma_init (dev_data);if (ret) - goto disable_pm_runtime; + goto destroy_dma_pool;spin_lock_init (&dev_data->scid_lock); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -2389,9 +2392,9 @@ release_dma:dma_release_channel (dev_data->dma_rx1);dma_release_channel (dev_data->dma_tx); +destroy_dma_pool:dma_pool_destroy (dev_data->sc_pool); -disable_pm_runtime:pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 227/593 crypto: sa2ul - Fix pm_runtime enable in sa_ul_probe()
In reply to Greg Kroah-HartmanFrom: Suman Anna <[email protected]>
[ Upstream commit 5c8552325e013cbdabc443cd1f1b4d03c4a2e64e ]
The pm_runtime APIs added first in commit 7694b6ca649f ("crypto: sa2ul - Add crypto driver") are not unwound properly and was fixed up partially in commit 13343badae09 ("crypto: sa2ul - Fix PM reference leak in sa_ul_probe()"). This fixed up the pm_runtime usage count but not the state. Fix this properly.
--- drivers/crypto/sa2ul.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/sa2ul.c +1 -0
@@ -2356,6 +2356,7 @@ static int sa_ul_probe(struct platform_device *pdev)if (ret <0 ) {dev_err (&pdev->dev,"%s: failed to get sync: %d\n" , __func__, ret); +pm_runtime_disable (dev);return ret; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 228/593 crypto: ccp - Fix a resource leak in an error handling path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit a6f8e68e238a15bb15f1726b35c695136c64eaba ]
If an error occurs after calling 'sp_get_irqs()', 'sp_free_irqs()' must be called as already done in the error handling path.
--- drivers/crypto/ccp/sp-pci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/ccp/sp-pci.c +4 -2
@@ -222,7 +222,7 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (ret) {dev_err (dev,"dma_set_mask_and_coherent failed (%d)\n" , ret); - goto e_err; + goto free_irqs; } }
@@ -230,10 +230,12 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret =sp_init (sp);if (ret) - goto e_err; + goto free_irqs;return 0 ; +free_irqs: +sp_free_irqs (sp); e_err:dev_notice (dev,"initialization failed\n" );return ret;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 229/593 media: rc: i2c: Fix an error message
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9c87ae1a0dbeb5794957421157fd266d38a869b4 ]
'ret' is known to be 1 here. In fact 'i' is expected instead. Store the return value of 'i2c_master_recv()' in 'ret' so that the error message print the correct error code.
--- drivers/media/i2c/ir-kbd-i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ir-kbd-i2c.c +2 -2
@@ -678,8 +678,8 @@ static int zilog_tx(struct rc_dev *rcdev, unsigned int *txbuf, goto out_unlock; } - i =i2c_master_recv (ir->tx_c, buf,1 ); -if (i !=1 ) { + ret =i2c_master_recv (ir->tx_c, buf,1 ); +if (ret !=1 ) {dev_err (&ir->rc->dev,"i2c_master_recv failed with %d\n" , ret); ret = -EIO ; goto out_unlock;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 230/593 pata_ep93xx: fix deferred probing
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 5c8121262484d99bffb598f39a0df445cecd8efb ]
The driver overrides the error codes returned by platform_get_irq() to -ENXIO, so if it returns -EPROBE_DEFER, the driver would fail the probe permanently instead of the deferred probing. Propagate the error code upstream, as it should have been done from the start...
--- drivers/ata/pata_ep93xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ep93xx.c +1 -1
@@ -928,7 +928,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev)/* INT[3] (IRQ_EP93XX_EXT3) line connected as pull down */ irq =platform_get_irq (pdev,0 );if (irq <0 ) { - err = -ENXIO ; + err = irq; goto err_rel_gpio; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 231/593 locking/lockdep: Reduce LOCKDEP dependency list
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit b8e00abe7d9fe21dd13609e2e3a707e38902b105 ]
Some arches (um, sparc64, riscv, xtensa) cause a Kconfig warning for LOCKDEP.
These arch-es select LOCKDEP_SUPPORT but they are not listed as one of the arch-es that LOCKDEP depends on.
Since (16) arch-es define the Kconfig symbol LOCKDEP_SUPPORT if they intend to have LOCKDEP support, replace the awkward list of arch-es that LOCKDEP depends on with the LOCKDEP_SUPPORT symbol.
But wait. LOCKDEP_SUPPORT is included in LOCK_DEBUGGING_SUPPORT, which is already a dependency here, so LOCKDEP_SUPPORT is redundant and not needed.
That leaves the FRAME_POINTER dependency, but it is part of an expression like this:
depends on (A && B) && (FRAME_POINTER || B')
where B' is a dependency of B so if B is true then B' is true and the value of FRAME_POINTER does not matter. Thus we can also delete the FRAME_POINTER dependency.
Fixes this kconfig warning: (for um, sparc64, riscv, xtensa)
WARNING: unmet direct dependencies detected for LOCKDEP
Depends on [n]: DEBUG_KERNEL [=y] && LOCK_DEBUGGING_SUPPORT [=y] && (FRAME_POINTER [=n] || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86) Selected by [y]:
- PROVE_LOCKING [=y] && DEBUG_KERNEL [=y] && LOCK_DEBUGGING_SUPPORT [=y]
- LOCK_STAT [=y] && DEBUG_KERNEL [=y] && LOCK_DEBUGGING_SUPPORT [=y]
- DEBUG_LOCK_ALLOC [=y] && DEBUG_KERNEL [=y] && LOCK_DEBUGGING_SUPPORT [=y]
--- lib/Kconfig.debug | 1 - 1 file changed, 1 deletion(-)
lib/Kconfig.debug +0 -1
@@ -1302,7 +1302,6 @@ config LOCKDEP bool depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT select STACKTRACE - depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86 select KALLSYMS select KALLSYMS_ALL
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 232/593 media: rkvdec: Fix .buf_prepare
In reply to Greg Kroah-HartmanFrom: Ezequiel Garcia <[email protected]>
[ Upstream commit ba1ed4ae760a81caf39f54232e089d95157a0dba ]
The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length.
If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in rkvdec-h264.c.
[Changed the comment and used V4L2_TYPE_IS_CAPTURE macro]
--- drivers/staging/media/rkvdec/rkvdec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/staging/media/rkvdec/rkvdec.c +9 -1
@@ -471,7 +471,15 @@ static int rkvdec_buf_prepare(struct vb2_buffer *vb)if (vb2_plane_size (vb, i) < sizeimage)return -EINVAL ; } -vb2_set_plane_payload (vb,0 , f->fmt.pix_mp.plane_fmt[0 ].sizeimage); + +/* +* Buffer's bytesused must be written by driver for CAPTURE buffers. +* (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets +* it to buffer length). +*/ +if (V4L2_TYPE_IS_CAPTURE (vq->type)) +vb2_set_plane_payload (vb,0 , f->fmt.pix_mp.plane_fmt[0 ].sizeimage); +return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 233/593 media: exynos4-is: Fix a use after free in isp_video_release
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit 01fe904c9afd26e79c1f73aa0ca2e3d785e5e319 ]
In isp_video_release, file->private_data is freed via _vb2_fop_release()->v4l2_fh_release(). But the freed file->private_data is still used in v4l2_fh_is_singular_file() ->v4l2_fh_is_singular(file->private_data), which is a use after free bug.
My patch uses a variable 'is_singular_file' to avoid the uaf.
v3: https://lore.kernel.org/patchwork/patch/1419058/
--- drivers/media/platform/exynos4-is/fimc-isp-video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/platform/exynos4-is/fimc-isp-video.c +5 -2
@@ -305,17 +305,20 @@ static int isp_video_release(struct file *file)struct fimc_is_video *ivc = &isp->video_capture;struct media_entity *entity = &ivc->ve.vdev.entity;struct media_device *mdev = entity->graph_obj.mdev; +bool is_singular_file;mutex_lock (&isp->video_lock); -if (v4l2_fh_is_singular_file (file) && ivc->streaming) { + is_singular_file =v4l2_fh_is_singular_file (file); + +if (is_singular_file && ivc->streaming) {media_pipeline_stop (entity); ivc->streaming =0 ; }_vb2_fop_release (file,NULL ); -if (v4l2_fh_is_singular_file (file)) { +if (is_singular_file) {fimc_pipeline_call (&ivc->ve, close);mutex_lock (&mdev->graph_mutex);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 234/593 media: au0828: fix a NULL vs IS_ERR() check
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 8f2e452730d2bcd59fe05246f0e19a4c52e0012d ]
The media_device_usb_allocate() function returns error pointers when it's enabled and something goes wrong. It can return NULL as well, but only if CONFIG_MEDIA_CONTROLLER is disabled so that doesn't apply here.
--- drivers/media/usb/au0828/au0828-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-core.c +2 -2
@@ -199,8 +199,8 @@ static int au0828_media_device_init(struct au0828_dev *dev,struct media_device *mdev; mdev =media_device_usb_allocate (udev,KBUILD_MODNAME ,THIS_MODULE ); -if (!mdev) -return -ENOMEM ; +if (IS_ERR (mdev)) +return PTR_ERR (mdev); dev->media_dev = mdev;#endif
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 235/593 media: tc358743: Fix error return code in tc358743_probe_of()
In reply to Greg Kroah-HartmanFrom: Zhen Lei <[email protected]>
[ Upstream commit a6b1e7093f0a099571fc8836ab4a589633f956a8 ]
When the CSI bps per lane is not in the valid range, an appropriate error code -EINVAL should be returned. However, we currently do not explicitly assign this error code to 'ret'. As a result, 0 was incorrectly returned.
--- drivers/media/i2c/tc358743.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/tc358743.c +1 -0
@@ -1974,6 +1974,7 @@ static int tc358743_probe_of(struct tc358743_state *state) bps_pr_lane =2 * endpoint.link_frequencies[0 ];if (bps_pr_lane <62500000U || bps_pr_lane >1000000000U ) {dev_err (dev,"unsupported bps per lane: %u bps\n" , bps_pr_lane); + ret = -EINVAL ; goto disable_clk; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 236/593 media: gspca/gl860: fix zero-length control requests
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 8ed339f23d41e21660a389adf2e7b2966d457ff6 ]
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Control transfers without a data stage are treated as OUT requests by the USB stack and should be using usb_sndctrlpipe(). Failing to do so will now trigger a warning.
Fix the gl860_RTx() helper so that zero-length control reads fail with an error message instead. Note that there are no current callers that would trigger this.
--- drivers/media/usb/gspca/gl860/gl860.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/gspca/gl860/gl860.c +2 -2
@@ -561,8 +561,8 @@ int gl860_RTx(struct gspca_dev *gspca_dev, len, 400 + 200 * (len > 1));memcpy (pdata, gspca_dev->usb_buf, len); }else { - r =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ), - req, pref, val, index,NULL , len,400 ); +gspca_err (gspca_dev,"zero-length read request\n" ); + r = -EINVAL ; } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 237/593 m68k: atari: Fix ATARI_KBD_CORE kconfig unmet dependency warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit c1367ee016e3550745315fb9a2dd1e4ce02cdcf6 ]
Since the code for ATARI_KBD_CORE does not use drivers/input/keyboard/ code, just move ATARI_KBD_CORE to arch/m68k/Kconfig.machine to remove the dependency on INPUT_KEYBOARD.
Removes this kconfig warning:
WARNING: unmet direct dependencies detected for ATARI_KBD_CORE
Depends on [n]: !UML && INPUT [=y] && INPUT_KEYBOARD [=n] Selected by [y]:
- MOUSE_ATARI [=y] && !UML && INPUT [=y] && INPUT_MOUSE [=y] && ATARI [=y]
--- arch/m68k/Kconfig.machine | 3 +++ drivers/input/keyboard/Kconfig | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/m68k/Kconfig.machine +3 -0
@@ -23,6 +23,9 @@ config ATARI this kernel on an Atari, say Y here and browse the material available in <file:Documentation/m68k>; otherwise say N. +config ATARI_KBD_CORE + bool + config MAC bool "Macintosh support" depends on MMU
drivers/input/keyboard/Kconfig +0 -3
@@ -67,9 +67,6 @@ config KEYBOARD_AMIGA To compile this driver as a module, choose M here: the module will be called amikbd. -config ATARI_KBD_CORE - bool - config KEYBOARD_APPLESPI tristate "Apple SPI keyboard and trackpad" depends on ACPI && EFI
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 238/593 media: siano: Fix out-of-bounds warnings in smscore_load_firmware_family2()
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
[ Upstream commit 13dfead49db07225335d4f587a560a2210391a1a ]
Rename struct sms_msg_data4 to sms_msg_data5 and increase the size of its msg_data array from 4 to 5 elements. Notice that at some point the 5th element of msg_data is being accessed in function smscore_load_firmware_family2():
1006 trigger_msg->msg_data[4] = 4; /* Task ID */
Also, there is no need for the object _trigger_msg_ of type struct sms_msg_data *, when _msg_ can be used, directly. Notice that msg_data in struct sms_msg_data is a one-element array, which causes multiple out-of-bounds warnings when accessing beyond its first element in function smscore_load_firmware_family2():
992 struct sms_msg_data *trigger_msg =
993 (struct sms_msg_data *) msg;
994
995 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
996 SMS_INIT_MSG(&msg->x_msg_header,
997 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ, 998 sizeof(struct sms_msg_hdr) + 999 sizeof(u32) * 5); 1000 1001 trigger_msg->msg_data[0] = firmware->start_address; 1002 /* Entry point */ 1003 trigger_msg->msg_data[1] = 6; /* Priority */ 1004 trigger_msg->msg_data[2] = 0x200; /* Stack size */ 1005 trigger_msg->msg_data[3] = 0; /* Parameter */ 1006 trigger_msg->msg_data[4] = 4; /* Task ID */
even when enough dynamic memory is allocated for _msg_:
929 /* PAGE_SIZE buffer shall be enough and dma aligned */
930 msg = kmalloc(PAGE_SIZE, GFP_KERNEL | coredev->gfp_buf_flags);
but as _msg_ is casted to (struct sms_msg_data *):
992 struct sms_msg_data *trigger_msg =
993 (struct sms_msg_data *) msg;
the out-of-bounds warnings are actually valid and should be addressed.
Fix this by declaring object _msg_ of type struct sms_msg_data5 *, which contains a 5-elements array, instead of just 4. And use _msg_ directly, instead of creating object trigger_msg.
This helps with the ongoing efforts to enable -Warray-bounds by fixing the following warnings:
CC [M] drivers/media/common/siano/smscoreapi.odrivers/media/common/siano/smscoreapi.c: In function ‘smscore_load_firmware_family2’:drivers/media/common/siano/smscoreapi.c:1003:24: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1003 | trigger_msg->msg_data[1] = 6; /* Priority */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1004:24: warning: array subscript 2 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1004 | trigger_msg->msg_data[2] = 0x200; /* Stack size */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1005:24: warning: array subscript 3 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1005 | trigger_msg->msg_data[3] = 0; /* Parameter */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~
drivers/media/common/siano/smscoreapi.c:1006:24: warning: array subscript 4 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
1006 | trigger_msg->msg_data[4] = 4; /* Task ID */
| ~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/media/common/siano/smscoreapi.c:12:
drivers/media/common/siano/smscoreapi.h:619:6: note: while referencing ‘msg_data’
619 | u32 msg_data[1];
| ^~~~~~~~--- drivers/media/common/siano/smscoreapi.c | 22 +++++++++------------- drivers/media/common/siano/smscoreapi.h | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-)
drivers/media/common/siano/smscoreapi.c +9 -13
@@ -908,7 +908,7 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, void *buffer, size_t size) {struct sms_firmware *firmware = (struct sms_firmware *) buffer; -struct sms_msg_data4 *msg; +struct sms_msg_data5 *msg;u32 mem_address, calc_checksum =0 ;u32 i, *ptr;u8 *payload = firmware->payload;
@@ -989,24 +989,20 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, goto exit_fw_download;if (coredev->mode ==DEVICE_MODE_NONE ) { -struct sms_msg_data *trigger_msg = - (struct sms_msg_data *) msg; -pr_debug ("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n" );SMS_INIT_MSG (&msg->x_msg_header,MSG_SMS_SWDOWNLOAD_TRIGGER_REQ , -sizeof (struct sms_msg_hdr ) + -sizeof (u32) *5 ); +sizeof (*msg)); - trigger_msg->msg_data[0 ] = firmware->start_address; + msg->msg_data[0 ] = firmware->start_address;/* Entry point */ - trigger_msg->msg_data[1 ] =6 ;/* Priority */ - trigger_msg->msg_data[2 ] =0x200 ;/* Stack size */ - trigger_msg->msg_data[3 ] =0 ;/* Parameter */ - trigger_msg->msg_data[4 ] =4 ;/* Task ID */ + msg->msg_data[1 ] =6 ;/* Priority */ + msg->msg_data[2 ] =0x200 ;/* Stack size */ + msg->msg_data[3 ] =0 ;/* Parameter */ + msg->msg_data[4 ] =4 ;/* Task ID */ - rc =smscore_sendrequest_and_wait (coredev, trigger_msg, - trigger_msg->x_msg_header.msg_length, + rc =smscore_sendrequest_and_wait (coredev, msg, + msg->x_msg_header.msg_length, &coredev->trigger_done); }else { SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_EXEC_REQ,
drivers/media/common/siano/smscoreapi.h +2 -2
@@ -629,9 +629,9 @@ struct sms_msg_data2 {u32 msg_data[2 ]; }; -struct sms_msg_data4 { +struct sms_msg_data5 {struct sms_msg_hdr x_msg_header; -u32 msg_data[4 ]; +u32 msg_data[5 ]; };struct sms_data_download {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 239/593 regulator: fan53880: Fix vsel_mask setting for FAN53880_BUCK
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 2e11737a772b95c6587df73f216eec1762431432 ]
According to the datasheet:
REGISTER DETAILS − 0x02 BUCK, BUCK_OUT is BIT0 ~ BIT7.
So vsel_mask for FAN53880_BUCK should be 0xFF.
--- drivers/regulator/fan53880.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/fan53880.c +1 -1
@@ -79,7 +79,7 @@ static const struct regulator_desc fan53880_regulators[] = { .n_linear_ranges = 2, .n_voltages = 0xf8, .vsel_reg = FAN53880_BUCKVOUT, - .vsel_mask = 0x7f, + .vsel_mask = 0xff, .enable_reg = FAN53880_ENABLE, .enable_mask = 0x10, .enable_time = 480,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 240/593 crypto: nitrox - fix unchecked variable in nitrox_register_interrupts
In reply to Greg Kroah-HartmanFrom: Tong Tiangen <[email protected]>
[ Upstream commit 57c126661f50b884d3812e7db6e00f2e778eccfb ]
Function nitrox_register_interrupts leaves variable 'nr_vecs' unchecked, which would be use as kcalloc parameter later.
--- drivers/crypto/cavium/nitrox/nitrox_isr.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/cavium/nitrox/nitrox_isr.c +4 -0
@@ -306,6 +306,10 @@ int nitrox_register_interrupts(struct nitrox_device *ndev)* Entry 192: NPS_CORE_INT_ACTIVE */ nr_vecs =pci_msix_vec_count (pdev); +if (nr_vecs <0 ) { +dev_err (DEV (ndev),"Error in getting vec count %d\n" , nr_vecs); +return nr_vecs; + }/* Enable MSI-X */ ret =pci_alloc_irq_vectors (pdev, nr_vecs, nr_vecs,PCI_IRQ_MSIX );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 241/593 crypto: omap-sham - Fix PM reference leak in omap sham ops
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit ca323b2c61ec321eb9f2179a405b9c34cdb4f553 ]
pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. We fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced.
--- drivers/crypto/omap-sham.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/omap-sham.c +2 -2
@@ -371,7 +371,7 @@ static int omap_sham_hw_init(struct omap_sham_dev *dd) {int err; - err =pm_runtime_get_sync (dd->dev); + err =pm_runtime_resume_and_get (dd->dev);if (err <0 ) {dev_err (dd->dev,"failed to get sync: %d\n" , err);return err;
@@ -2243,7 +2243,7 @@ static int omap_sham_suspend(struct device *dev)static int omap_sham_resume (struct device *dev) { -int err =pm_runtime_get_sync (dev); +int err =pm_runtime_resume_and_get (dev);if (err <0 ) {dev_err (dev,"failed to get sync: %d\n" , err);return err;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 242/593 crypto: x86/curve25519 - fix cpu feature checking logic in mod_exit
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 1b82435d17774f3eaab35dce239d354548aa9da2 ]
In curve25519_mod_init() the curve25519_alg will be registered only when (X86_FEATURE_BMI2 && X86_FEATURE_ADX). But in curve25519_mod_exit() it still checks (X86_FEATURE_BMI2 || X86_FEATURE_ADX) when do crypto unregister. This will trigger a BUG_ON in crypto_unregister_alg() as alg->cra_refcnt is 0 if the cpu only supports one of X86_FEATURE_BMI2 and X86_FEATURE_ADX.
--- arch/x86/crypto/curve25519-x86_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/crypto/curve25519-x86_64.c +1 -1
@@ -1500,7 +1500,7 @@ static int __init curve25519_mod_init(void) static void __exit curve25519_mod_exit(void) {if (IS_REACHABLE (CONFIG_CRYPTO_KPP ) && - (boot_cpu_has (X86_FEATURE_BMI2 ) ||boot_cpu_has (X86_FEATURE_ADX ))) +static_branch_likely (&curve25519_use_bmi2_adx))crypto_unregister_kpp (&curve25519_alg); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 243/593 crypto: sm2 - remove unnecessary reset operations
In reply to Greg Kroah-HartmanFrom: Tianjia Zhang <[email protected]>
[ Upstream commit 1bc608b4655b8b1491fb100f4cf4f15ae64a8698 ]
This is an algorithm optimization. The reset operation when setting the public key is repeated and redundant, so remove it. At the same time, sm2_ecc_os2ec() is optimized to make the function more simpler and more in line with the Linux code style.
--- crypto/sm2.c | 75 ++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 46 deletions(-)
crypto/sm2.c +29 -46
@@ -119,12 +119,6 @@ static void sm2_ec_ctx_deinit(struct mpi_ec_ctx *ec)memset (ec,0 ,sizeof (*ec)); } -static int sm2_ec_ctx_reset (struct mpi_ec_ctx *ec) -{ -sm2_ec_ctx_deinit (ec); -return sm2_ec_ctx_init (ec); -} -/* RESULT must have been initialized and is set on success to the * point given by VALUE. */
@@ -132,55 +126,48 @@ static int sm2_ecc_os2ec(MPI_POINT result, MPI value) {int rc;size_t n; -const unsigned char *buf; -unsigned char *buf_memory; +unsigned char *buf;MPI x, y; - n = (mpi_get_nbits (value)+7 )/8 ; - buf_memory =kmalloc (n,GFP_KERNEL ); - rc =mpi_print (GCRYMPI_FMT_USG , buf_memory, n, &n, value); -if (rc) { -kfree (buf_memory); -return rc; - } - buf = buf_memory; + n =MPI_NBYTES (value); + buf =kmalloc (n,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; -if (n <1 ) { -kfree (buf_memory); -return -EINVAL ; - } -if (*buf !=4 ) { -kfree (buf_memory); -return -EINVAL ;/* No support for point compression. */ - } -if (((n-1 )%2 )) { -kfree (buf_memory); -return -EINVAL ; - } - n = (n-1 )/2 ; + rc =mpi_print (GCRYMPI_FMT_USG , buf, n, &n, value); +if (rc) + goto err_freebuf; + + rc = -EINVAL ; +if (n <1 || ((n -1 ) %2 )) + goto err_freebuf; +/* No support for point compression */ +if (*buf !=0x4 ) + goto err_freebuf; + + rc = -ENOMEM ; + n = (n -1 ) /2 ; x =mpi_read_raw_data (buf +1 , n); -if (!x) { -kfree (buf_memory); -return -ENOMEM ; - } +if (!x) + goto err_freebuf; y =mpi_read_raw_data (buf +1 + n, n); -kfree (buf_memory); -if (!y) { -mpi_free (x); -return -ENOMEM ; - } +if (!y) + goto err_freex;mpi_normalize (x);mpi_normalize (y); -mpi_set (result->x, x);mpi_set (result->y, y);mpi_set_ui (result->z,1 ); -mpi_free (x); -mpi_free (y); + rc =0 ; -return 0 ; +mpi_free (y); +err_freex: +mpi_free (x); +err_freebuf: +kfree (buf); +return rc; }struct sm2_signature_ctx {
@@ -399,10 +386,6 @@ static int sm2_set_pub_key(struct crypto_akcipher *tfm,MPI a;int rc; - rc =sm2_ec_ctx_reset (ec); -if (rc) -return rc; - ec->Q =mpi_point_new (0 );if (!ec->Q)return -ENOMEM ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 244/593 crypto: sm2 - fix a memory leak in sm2
In reply to Greg Kroah-HartmanFrom: Hongbo Li <[email protected]>
[ Upstream commit 5cd259ca5d466f65ffd21e2e2fa00fb648a8c555 ]
SM2 module alloc ec->Q in sm2_set_pub_key(), when doing alg test in test_akcipher_one(), it will set public key for every test vector, and don't free ec->Q. This will cause a memory leak.
This patch alloc ec->Q in sm2_ec_ctx_init().
--- crypto/sm2.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
crypto/sm2.c +10 -14
@@ -79,10 +79,17 @@ static int sm2_ec_ctx_init(struct mpi_ec_ctx *ec) goto free; rc = -ENOMEM ; + + ec->Q =mpi_point_new (0 ); +if (!ec->Q) + goto free; +/* mpi_ec_setup_elliptic_curve */ ec->G =mpi_point_new (0 ); -if (!ec->G) +if (!ec->G) { +mpi_point_release (ec->Q); goto free; + }mpi_set (ec->G->x, x);mpi_set (ec->G->y, y);
@@ -91,6 +98,7 @@ static int sm2_ec_ctx_init(struct mpi_ec_ctx *ec) rc = -EINVAL ; ec->n =mpi_scanval (ecp->n);if (!ec->n) { +mpi_point_release (ec->Q);mpi_point_release (ec->G); goto free; }
@@ -386,27 +394,15 @@ static int sm2_set_pub_key(struct crypto_akcipher *tfm,MPI a;int rc; - ec->Q =mpi_point_new (0 ); -if (!ec->Q) -return -ENOMEM ; -/* include the uncompressed flag '0x04' */ - rc = -ENOMEM ; a =mpi_read_raw_data (key, keylen);if (!a) - goto error; +return -ENOMEM ;mpi_normalize (a); rc =sm2_ecc_os2ec (ec->Q, a);mpi_free (a); -if (rc) - goto error; - -return 0 ; -error: -mpi_point_release (ec->Q); - ec->Q =NULL ;return rc; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 245/593 mmc: usdhi6rol0: fix error return code in usdhi6_probe()
In reply to Greg Kroah-HartmanFrom: Zhen Lei <[email protected]>
[ Upstream commit 2f9ae69e5267f53e89e296fccee291975a85f0eb ]
Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.
--- drivers/mmc/host/usdhi6rol0.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/usdhi6rol0.c +1 -0
@@ -1801,6 +1801,7 @@ static int usdhi6_probe(struct platform_device *pdev) version =usdhi6_read (host,USDHI6_VERSION );if ((version &0xfff ) !=0xa0d ) { + ret = -EPERM ;dev_err (dev,"Version not recognized %x\n" , version); goto e_clk_off; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 246/593 arm64: consistently use reserved_pg_dir
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit 833be850f1cabd0e3b5337c0fcab20a6e936dd48 ]
Depending on configuration options and specific code paths, we either use the empty_zero_page or the configuration-dependent reserved_ttbr0 as a reserved value for TTBR{0,1}_EL1.
To simplify this code, let's always allocate and use the same reserved_pg_dir, replacing reserved_ttbr0. Note that this is allocated (and hence pre-zeroed), and is also marked as read-only in the kernel Image mapping.
Keeping this separate from the empty_zero_page potentially helps with robustness as the empty_zero_page is used in a number of cases where a failure to map it read-only could allow it to become corrupted.
The (presently unused) swapper_pg_end symbol is also removed, and comments are added wherever we rely on the offsets between the pre-allocated pg_dirs to keep these cases easily identifiable.
--- arch/arm64/include/asm/asm-uaccess.h | 4 ++-- arch/arm64/include/asm/kernel-pgtable.h | 6 ------ arch/arm64/include/asm/mmu_context.h | 6 +++--- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/include/asm/uaccess.h | 4 ++-- arch/arm64/kernel/entry.S | 6 ++++-- arch/arm64/kernel/setup.c | 2 +- arch/arm64/kernel/vmlinux.lds.S | 8 +++----- arch/arm64/mm/proc.S | 2 +- 9 files changed, 17 insertions(+), 22 deletions(-)
arch/arm64/include/asm/asm-uaccess.h +2 -2
@@ -15,10 +15,10 @@ .macro __uaccess_ttbr0_disable, tmp1 mrs \tmp1, ttbr1_el1 // swapper_pg_dir bic \tmp1, \tmp1, #TTBR_ASID_MASK - sub \tmp1, \tmp1, #RESERVED_TTBR0_SIZE // reserved_ttbr0 just before swapper_pg_dir + sub \tmp1, \tmp1, #PAGE_SIZE // reserved_pg_dir just before swapper_pg_dir msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1 isb - add \tmp1, \tmp1, #RESERVED_TTBR0_SIZE + add \tmp1, \tmp1, #PAGE_SIZE msr ttbr1_el1, \tmp1 // set reserved ASID isb .endm
arch/arm64/include/asm/kernel-pgtable.h +0 -6
@@ -89,12 +89,6 @@#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end))#define IDMAP_DIR_SIZE (IDMAP_PGTABLE_LEVELS * PAGE_SIZE) -#ifdef CONFIG_ARM64_SW_TTBR0_PAN -#define RESERVED_TTBR0_SIZE (PAGE_SIZE) -#else -#define RESERVED_TTBR0_SIZE (0) -#endif -/* Initial memory map size */ #if ARM64_SWAPPER_USES_SECTION_MAPS #define SWAPPER_BLOCK_SHIFT SECTION_SHIFT
arch/arm64/include/asm/mmu_context.h +3 -3
@@ -36,11 +36,11 @@ static inline void contextidr_thread_switch(struct task_struct *next) }/* -* Set TTBR0 to empty_zero_page. No translations will be possible via TTBR0. +* Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0. */ static inline void cpu_set_reserved_ttbr0 (void ) { -unsigned long ttbr =phys_to_ttbr (__pa_symbol (empty_zero_page)); +unsigned long ttbr =phys_to_ttbr (__pa_symbol (reserved_pg_dir));write_sysreg (ttbr, ttbr0_el1);isb ();
@@ -192,7 +192,7 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,return ;if (mm == &init_mm) - ttbr =__pa_symbol (empty_zero_page); + ttbr =__pa_symbol (reserved_pg_dir);else ttbr =virt_to_phys (mm->pgd) |ASID (mm) <<48 ;
arch/arm64/include/asm/pgtable.h +1 -0
@@ -530,6 +530,7 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];extern pgd_t idmap_pg_dir[PTRS_PER_PGD ];extern pgd_t idmap_pg_end[];extern pgd_t tramp_pg_dir[PTRS_PER_PGD ]; +extern pgd_t reserved_pg_dir[PTRS_PER_PGD ];extern void set_swapper_pgd (pgd_t *pgdp,pgd_t pgd);
arch/arm64/include/asm/uaccess.h +2 -2
@@ -113,8 +113,8 @@ static inline void __uaccess_ttbr0_disable(void)local_irq_save (flags); ttbr =read_sysreg (ttbr1_el1); ttbr &= ~TTBR_ASID_MASK ; -/* reserved_ttbr0 placed before swapper_pg_dir */ -write_sysreg (ttbr -RESERVED_TTBR0_SIZE , ttbr0_el1); +/* reserved_pg_dir placed before swapper_pg_dir */ +write_sysreg (ttbr -PAGE_SIZE , ttbr0_el1);isb ();/* Set reserved ASID */ write_sysreg (ttbr, ttbr1_el1);
arch/arm64/kernel/entry.S +4 -2
@@ -770,9 +770,10 @@ SYM_CODE_END(ret_to_user) */ .pushsection ".entry.tramp.text", "ax" + // Move from tramp_pg_dir to swapper_pg_dir .macro tramp_map_kernel, tmp mrs \tmp, ttbr1_el1 - add \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE) + add \tmp, \tmp, #(2 * PAGE_SIZE) bic \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
@@ -789,9 +790,10 @@ alternative_else_nop_endif #endif /* CONFIG_QCOM_FALKOR_ERRATUM_1003 */ .endm + // Move from swapper_pg_dir to tramp_pg_dir .macro tramp_unmap_kernel, tmp mrs \tmp, ttbr1_el1 - sub \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE) + sub \tmp, \tmp, #(2 * PAGE_SIZE) orr \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp /*
arch/arm64/kernel/setup.c +1 -1
@@ -366,7 +366,7 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)* faults in case uaccess_enable() is inadvertently called by the init * thread. */ - init_task.thread_info.ttbr0 =__pa_symbol (empty_zero_page); + init_task.thread_info.ttbr0 =__pa_symbol (reserved_pg_dir);#endif if (boot_args[1 ] || boot_args[2 ] || boot_args[3 ]) {
arch/arm64/kernel/vmlinux.lds.S +3 -5
@@ -164,13 +164,11 @@ SECTIONS . += PAGE_SIZE; #endif -#ifdef CONFIG_ARM64_SW_TTBR0_PAN - reserved_ttbr0 = .; - . += RESERVED_TTBR0_SIZE; -#endif + reserved_pg_dir = .; + . += PAGE_SIZE; + swapper_pg_dir = .; . += PAGE_SIZE; - swapper_pg_end = .; . = ALIGN(SEGMENT_ALIGN); __init_begin = .;
arch/arm64/mm/proc.S +1 -1
@@ -168,7 +168,7 @@ SYM_FUNC_END(cpu_do_resume) .pushsection ".idmap.text", "awx" .macro __idmap_cpu_set_reserved_ttbr1, tmp1, tmp2 - adrp \tmp1, empty_zero_page + adrp \tmp1, reserved_pg_dir phys_to_ttbr \tmp2, \tmp1 offset_ttbr1 \tmp2, \tmp1 msr ttbr1_el1, \tmp2
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 247/593 arm64/mm: Fix ttbr0 values stored in struct thread_info for software-pan
In reply to Greg Kroah-HartmanFrom: Anshuman Khandual <[email protected]>
[ Upstream commit 9163f01130304fab1f74683d7d44632da7bda637 ]
When using CONFIG_ARM64_SW_TTBR0_PAN, a task's thread_info::ttbr0 must be the TTBR0_EL1 value used to run userspace. With 52-bit PAs, the PA must be packed into the TTBR using phys_to_ttbr(), but we forget to do this in some of the SW PAN code. Thus, if the value is installed into TTBR0_EL1 (as may happen in the uaccess routines), this could result in UNPREDICTABLE behaviour.
Since hardware with 52-bit PA support almost certainly has HW PAN, which will be used in preference, this shouldn't be a practical issue, but let's fix this for consistency.
--- arch/arm64/include/asm/mmu_context.h | 4 ++-- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/mmu_context.h +2 -2
@@ -192,9 +192,9 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,return ;if (mm == &init_mm) - ttbr =__pa_symbol (reserved_pg_dir); + ttbr =phys_to_ttbr (__pa_symbol (reserved_pg_dir));else - ttbr =virt_to_phys (mm->pgd) |ASID (mm) <<48 ; + ttbr =phys_to_ttbr (virt_to_phys (mm->pgd)) |ASID (mm) <<48 ;WRITE_ONCE (task_thread_info (tsk)->ttbr0, ttbr); }
arch/arm64/kernel/setup.c +1 -1
@@ -366,7 +366,7 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)* faults in case uaccess_enable() is inadvertently called by the init * thread. */ - init_task.thread_info.ttbr0 =__pa_symbol (reserved_pg_dir); + init_task.thread_info.ttbr0 =phys_to_ttbr (__pa_symbol (reserved_pg_dir));#endif if (boot_args[1 ] || boot_args[2 ] || boot_args[3 ]) {
Signature · 9 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 248/593 media: subdev: remove VIDIOC_DQEVENT_TIME32 handling
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 765ba251d2522e2a0daa2f0793fd0f0ce34816ec ]
Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/ VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common code, but for some reason I ended up adding another conversion helper to subdev_do_ioctl() as well. I must have concluded that this does not go through the common conversion, but it has done that since the ioctl handler was first added.
I assume this one is harmless as there should be no way to arrive here from user space if CONFIG_COMPAT_32BIT_TIME is set, but since it is dead code, it should just get removed.
On a 64-bit architecture, as well as a 32-bit architecture without CONFIG_COMPAT_32BIT_TIME, handling this command is a mistake, and the kernel should return an error.
--- drivers/media/v4l2-core/v4l2-subdev.c | 24 ------------------------ 1 file changed, 24 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +0 -24
@@ -428,30 +428,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)return v4l2_event_dequeue (vfh, arg, file->f_flags &O_NONBLOCK ); -case VIDIOC_DQEVENT_TIME32 : { -struct v4l2_event_time32 *ev32 = arg; -struct v4l2_event ev = { }; - -if (!(sd->flags &V4L2_SUBDEV_FL_HAS_EVENTS )) -return -ENOIOCTLCMD ; - - rval =v4l2_event_dequeue (vfh, &ev, file->f_flags &O_NONBLOCK ); - - *ev32 = (struct v4l2_event_time32 ) { - .type = ev.type, - .pending = ev.pending, - .sequence = ev.sequence, - .timestamp.tv_sec = ev.timestamp.tv_sec, - .timestamp.tv_nsec = ev.timestamp.tv_nsec, - .id = ev.id, - }; - -memcpy (&ev32->u, &ev.u,sizeof (ev.u)); -memcpy (&ev32->reserved, &ev.reserved,sizeof (ev.reserved)); - -return rval; - } -case VIDIOC_SUBSCRIBE_EVENT :return v4l2_subdev_call (sd, core, subscribe_event, vfh, arg);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 249/593 media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
In reply to Greg Kroah-HartmanFrom: Dillon Min <[email protected]>
[ Upstream commit 5d11e6aad1811ea293ee2996cec9124f7fccb661 ]
The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open() should be freed from g2d_release() when it's not used.
Fix it
--- drivers/media/platform/s5p-g2d/g2d.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/s5p-g2d/g2d.c +3 -0
@@ -276,6 +276,9 @@ static int g2d_release(struct file *file)struct g2d_dev *dev =video_drvdata (file);struct g2d_ctx *ctx =fh2ctx (file->private_data); +mutex_lock (&dev->mutex); +v4l2_m2m_ctx_release (ctx->fh.m2m_ctx); +mutex_unlock (&dev->mutex);v4l2_ctrl_handler_free (&ctx->ctrl_handler);v4l2_fh_del (&ctx->fh);v4l2_fh_exit (&ctx->fh);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 250/593 hwmon: (lm70) Use device_get_match_data()
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit 6e09d75513d2670b7ab91ab3584fc5bcf2675a75 ]
Use the more modern API to get the match data out of the of match table. This saves some code, lines, and nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n.
--- drivers/hwmon/lm70.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/hwmon/lm70.c +5 -15
@@ -22,9 +22,9 @@#include <linux/hwmon.h> #include <linux/mutex.h> #include <linux/mod_devicetable.h> +#include <linux/property.h> #include <linux/spi/spi.h> #include <linux/slab.h> -#include <linux/of_device.h> #include <linux/acpi.h> #define DRVNAME "lm70"
@@ -173,25 +173,15 @@ MODULE_DEVICE_TABLE(acpi, lm70_acpi_ids);static int lm70_probe (struct spi_device *spi) { -const struct of_device_id *of_match;struct device *hwmon_dev;struct lm70 *p_lm70;int chip; - of_match =of_match_device (lm70_of_ids, &spi->dev); -if (of_match) - chip = (int )(uintptr_t )of_match->data; -else { -#ifdef CONFIG_ACPI -const struct acpi_device_id *acpi_match; +if (dev_fwnode (&spi->dev)) + chip = (int )(uintptr_t )device_get_match_data (&spi->dev); +else + chip =spi_get_device_id (spi)->driver_data; - acpi_match =acpi_match_device (lm70_acpi_ids, &spi->dev); -if (acpi_match) - chip = (int )(uintptr_t )acpi_match->driver_data; - else -#endif - chip =spi_get_device_id (spi)->driver_data; - }/* signaling is SPI_MODE_0 */ if (spi->mode & (SPI_CPOL |SPI_CPHA ))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 251/593 hwmon: (lm70) Revert "hwmon: (lm70) Add support for ACPI"
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit ac61c8aae446b9c0fe18981fe721d4a43e283ad6 ]
This reverts commit b58bd4c6dfe709646ed9efcbba2a70643f9bc873.
None of the ACPI IDs introduced with the reverted patch is a valid ACPI device ID. Any ACPI users of this driver are advised to use PRP0001 and a devicetree-compatible device identification.
--- drivers/hwmon/lm70.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-)
drivers/hwmon/lm70.c +1 -25
@@ -22,10 +22,10 @@#include <linux/hwmon.h> #include <linux/mutex.h> #include <linux/mod_devicetable.h> +#include <linux/of.h> #include <linux/property.h> #include <linux/spi/spi.h> #include <linux/slab.h> -#include <linux/acpi.h> #define DRVNAME "lm70"
@@ -148,29 +148,6 @@ static const struct of_device_id lm70_of_ids[] = {MODULE_DEVICE_TABLE (of, lm70_of_ids);#endif -#ifdef CONFIG_ACPI -static const struct acpi_device_id lm70_acpi_ids[] = { - { - .id ="LM000070" , - .driver_data =LM70_CHIP_LM70 , - }, - { - .id ="TMP00121" , - .driver_data =LM70_CHIP_TMP121 , - }, - { - .id ="LM000071" , - .driver_data =LM70_CHIP_LM71 , - }, - { - .id ="LM000074" , - .driver_data =LM70_CHIP_LM74 , - }, - {}, -}; -MODULE_DEVICE_TABLE (acpi, lm70_acpi_ids); -#endif -static int lm70_probe (struct spi_device *spi) {struct device *hwmon_dev;
@@ -217,7 +194,6 @@ static struct spi_driver lm70_driver = { .driver = { .name = "lm70", .of_match_table = of_match_ptr(lm70_of_ids), - .acpi_match_table = ACPI_PTR(lm70_acpi_ids), }, .id_table = lm70_ids, .probe = lm70_probe,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 252/593 hwmon: (max31722) Remove non-standard ACPI device IDs
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 97387c2f06bcfd79d04a848d35517b32ee6dca7c ]
Valid Maxim Integrated ACPI device IDs would start with MXIM, not with MAX1. On top of that, ACPI device IDs reflecting chip names are almost always invalid.
Remove the invalid ACPI IDs.
--- drivers/hwmon/max31722.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/hwmon/max31722.c +0 -9
@@ -6,7 +6,6 @@* Copyright (c) 2016, Intel Corporation. */ -#include <linux/acpi.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> #include <linux/kernel.h>
@@ -133,20 +132,12 @@ static const struct spi_device_id max31722_spi_id[] = { {"max31723", 0}, {} }; - -static const struct acpi_device_id __maybe_unused max31722_acpi_id[] = { - {"MAX31722" ,0 }, - {"MAX31723" ,0 }, - {} -}; -MODULE_DEVICE_TABLE (spi, max31722_spi_id);static struct spi_driver max31722_driver = { .driver = { .name ="max31722" , .pm = &max31722_pm_ops, - .acpi_match_table =ACPI_PTR (max31722_acpi_id), }, .probe = max31722_probe, .remove = max31722_remove,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 253/593 hwmon: (max31790) Fix fan speed reporting for fan7..12
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit cbbf244f0515af3472084f22b6213121b4a63835 ]
Fans 7..12 do not have their own set of configuration registers. So far the code ignored that and read beyond the end of the configuration register range to get the tachometer period. This resulted in more or less random fan speed values for those fans.
The datasheet is quite vague when it comes to defining the tachometer period for fans 7..12. Experiments confirm that the period is the same for both fans associated with a given set of configuration registers.
--- drivers/hwmon/max31790.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/max31790.c +1 -1
@@ -171,7 +171,7 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,switch (attr) {case hwmon_fan_input: - sr =get_tach_period (data->fan_dynamics[channel]); + sr =get_tach_period (data->fan_dynamics[channel %NR_CHANNEL ]); rpm =RPM_FROM_REG (data->tach[channel], sr); *val = rpm;return 0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 254/593 KVM: nVMX: Sync all PGDs on nested transition with shadow paging
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 07ffaf343e34b555c9e7ea39a9c81c439a706f13 ]
Trigger a full TLB flush on behalf of the guest on nested VM-Enter and VM-Exit when VPID is disabled for L2. kvm_mmu_new_pgd() syncs only the current PGD, which can theoretically leave stale, unsync'd entries in a previous guest PGD, which could be consumed if L2 is allowed to load CR3 with PCID_NOFLUSH=1.
Rename KVM_REQ_HV_TLB_FLUSH to KVM_REQ_TLB_FLUSH_GUEST so that it can be utilized for its obvious purpose of emulating a guest TLB flush.
Note, there is no change the actual TLB flush executed by KVM, even though the fast PGD switch uses KVM_REQ_TLB_FLUSH_CURRENT. When VPID is disabled for L2, vpid02 is guaranteed to be '0', and thus nested_get_vpid02() will return the VPID that is shared by L1 and L2.
Generate the request outside of kvm_mmu_new_pgd(), as getting the common helper to correctly identify which requested is needed is quite painful. E.g. using KVM_REQ_TLB_FLUSH_GUEST when nested EPT is in play is wrong as a TLB flush from the L1 kernel's perspective does not invalidate EPT mappings. And, by using KVM_REQ_TLB_FLUSH_GUEST, nVMX can do future simplification by moving the logic into nested_vmx_transition_tlb_flush().
Message-Id: <[email protected]>
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/hyperv.c | 2 +- arch/x86/kvm/vmx/nested.c | 17 ++++++++++++----- arch/x86/kvm/x86.c | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -84,7 +84,7 @@#define KVM_REQ_APICV_UPDATE \ KVM_ARCH_REQ_FLAGS(25, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)#define KVM_REQ_TLB_FLUSH_CURRENT KVM_ARCH_REQ(26) -#define KVM_REQ_HV_TLB_FLUSH \ +#define KVM_REQ_TLB_FLUSH_GUEST \ KVM_ARCH_REQ_FLAGS(27, KVM_REQUEST_NO_WAKEUP)#define KVM_REQ_APF_READY KVM_ARCH_REQ(28)#define KVM_REQ_MSR_FILTER_CHANGED KVM_ARCH_REQ(29)
arch/x86/kvm/hyperv.c +1 -1
@@ -1564,7 +1564,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,* vcpu->arch.cr3 may not be up-to-date for running vCPUs so we can't * analyze it here, flush TLB regardless of the specified address space. */ -kvm_make_vcpus_request_mask (kvm,KVM_REQ_HV_TLB_FLUSH , +kvm_make_vcpus_request_mask (kvm,KVM_REQ_TLB_FLUSH_GUEST ,NULL , vcpu_mask, &hv_vcpu->tlb_flush); ret_success:
arch/x86/kvm/vmx/nested.c +12 -5
@@ -1142,12 +1142,19 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne/* * Unconditionally skip the TLB flush on fast CR3 switch, all TLB -* flushes are handled by nested_vmx_transition_tlb_flush(). See -* nested_vmx_transition_mmu_sync for details on skipping the MMU sync. +* flushes are handled by nested_vmx_transition_tlb_flush(). */ -if (!nested_ept) -kvm_mmu_new_pgd (vcpu, cr3, true, - !nested_vmx_transition_mmu_sync (vcpu)); +if (!nested_ept) { +kvm_mmu_new_pgd (vcpu, cr3, true, true); + +/* +* A TLB flush on VM-Enter/VM-Exit flushes all linear mappings +* across all PCIDs, i.e. all PGDs need to be synchronized. +* See nested_vmx_transition_mmu_sync() for more details. +*/ +if (nested_vmx_transition_mmu_sync (vcpu)) +kvm_make_request (KVM_REQ_TLB_FLUSH_GUEST , vcpu); + } vcpu->arch.cr3 = cr3;kvm_register_mark_available (vcpu,VCPU_EXREG_CR3 );
arch/x86/kvm/x86.c +1 -1
@@ -8852,7 +8852,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) }if (kvm_check_request (KVM_REQ_TLB_FLUSH_CURRENT , vcpu))kvm_vcpu_flush_tlb_current (vcpu); -if (kvm_check_request (KVM_REQ_HV_TLB_FLUSH , vcpu)) +if (kvm_check_request (KVM_REQ_TLB_FLUSH_GUEST , vcpu))kvm_vcpu_flush_tlb_guest (vcpu);if (kvm_check_request (KVM_REQ_REPORT_TPR_ACCESS , vcpu)) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 255/593 KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 0e75225dfa4c5d5d51291f54a3d2d5895bad38da ]
Use BIT_ULL() instead of an open-coded shift to check whether or not a function is enabled in L1's VMFUNC bitmap. This is a benign bug as KVM supports only bit 0, and will fail VM-Enter if any other bits are set, i.e. bits 63:32 are guaranteed to be zero.
Note, "function" is bounded by hardware as VMFUNC will #UD before taking a VM-Exit if the function is greater than 63.
Before:
if ((vmcs12->vm_function_control & (1 << function)) == 0)
0x000000000001a916 <+118>: mov $0x1,%eax
0x000000000001a91b <+123>: shl %cl,%eax
0x000000000001a91d <+125>: cltq
0x000000000001a91f <+127>: and 0x128(%rbx),%rax
After:
if (!(vmcs12->vm_function_control & BIT_ULL(function & 63)))
0x000000000001a955 <+117>: mov 0x128(%rbx),%rdx
0x000000000001a95c <+124>: bt %rax,%rdx
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +1 -1
@@ -5536,7 +5536,7 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu) } vmcs12 =get_vmcs12 (vcpu); -if ((vmcs12->vm_function_control & (1 << function)) ==0 ) +if (!(vmcs12->vm_function_control &BIT_ULL (function))) goto fail;switch (function) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 256/593 KVM: nVMX: Dont clobber nested MMUs A/D status on EPTP switch
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 272b0a998d084e7667284bdd2d0c675c6a2d11de ]
Drop bogus logic that incorrectly clobbers the accessed/dirty enabling status of the nested MMU on an EPTP switch. When nested EPT is enabled, walk_mmu points at L2's _legacy_ page tables, not L1's EPT for L2.
This is likely a benign bug, as mmu->ept_ad is never consumed (since the MMU is not a nested EPT MMU), and stuffing mmu_role.base.ad_disabled will never propagate into future shadow pages since the nested MMU isn't used to map anything, just to walk L2's page tables.
Note, KVM also does a full MMU reload, i.e. the guest_mmu will be recreated using the new EPTP, and thus any change in A/D enabling will be properly recognized in the relevant MMU.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 7 ------- 1 file changed, 7 deletions(-)
arch/x86/kvm/vmx/nested.c +0 -7
@@ -5484,8 +5484,6 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu, {u32 index =kvm_rcx_read (vcpu);u64 new_eptp; -bool accessed_dirty; -struct kvm_mmu *mmu = vcpu->arch.walk_mmu;if (!nested_cpu_has_eptp_switching (vmcs12) || !nested_cpu_has_ept (vmcs12))
@@ -5494,13 +5492,10 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu,if (index >=VMFUNC_EPTP_ENTRIES )return 1 ; -if (kvm_vcpu_read_guest_page (vcpu, vmcs12->eptp_list_address >>PAGE_SHIFT , &new_eptp, index *8 ,8 ))return 1 ; - accessed_dirty = !!(new_eptp &VMX_EPTP_AD_ENABLE_BIT ); -/* * If the (L2) guest does a vmfunc to the currently * active ept pointer, we don't have to do anything else
@@ -5509,8 +5504,6 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu,if (!nested_vmx_check_eptp (vcpu, new_eptp))return 1 ; - mmu->ept_ad = accessed_dirty; - mmu->mmu_role.base.ad_disabled = !accessed_dirty; vmcs12->ept_pointer = new_eptp;kvm_make_request (KVM_REQ_MMU_RELOAD , vcpu);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 257/593 KVM: x86/mmu: Fix return value in tdp_mmu_map_handle_target_level()
In reply to Greg Kroah-HartmanFrom: Kai Huang <[email protected]>
[ Upstream commit 57a3e96d6d17ae5ac9861ef34af024a627f1c3bb ]
Currently tdp_mmu_map_handle_target_level() returns 0, which is RET_PF_RETRY, when page fault is actually fixed. This makes kvm_tdp_mmu_map() also return RET_PF_RETRY in this case, instead of RET_PF_FIXED. Fix by initializing ret to RET_PF_FIXED.
Note that kvm_mmu_page_fault() resumes guest on both RET_PF_RETRY and RET_PF_FIXED, which means in practice returning the two won't make difference, so this fix alone won't be necessary for stable tree.
Message-Id: <f9e8956223a586cd28c090879a8ff40f5eb6d609.1623717884.git.kai.huang@intel.com>
--- arch/x86/kvm/mmu/tdp_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/tdp_mmu.c +1 -1
@@ -527,7 +527,7 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, int write, kvm_pfn_t pfn, bool prefault) {u64 new_spte; -int ret =0 ; +int ret =RET_PF_FIXED ;int make_spte_ret =0 ;if (unlikely (is_noslot_pfn (pfn))) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 258/593 perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
In reply to Greg Kroah-HartmanFrom: Tuan Phan <[email protected]>
[ Upstream commit 4e16f283edc289820e9b2d6f617ed8e514ee8396 ]
When multiple dtcs share the same IRQ number, the irq_friend which used to refer to dtc object gets calculated incorrect which leads to invalid pointer.
--- drivers/perf/arm-cmn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm-cmn.c +1 -1
@@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn) irq = cmn->dtc[i].irq;for (j = i; j--; ) {if (cmn->dtc[j].irq == irq) { - cmn->dtc[j].irq_friend = j - i; + cmn->dtc[j].irq_friend = i - j; goto next; } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 259/593 KVM: arm64: Dont zero the cycle count register when PMCR_EL0.P is set
In reply to Greg Kroah-HartmanFrom: Alexandru Elisei <[email protected]>
[ Upstream commit 2a71fabf6a1bc9162a84e18d6ab991230ca4d588 ]
According to ARM DDI 0487G.a, page D13-3895, setting the PMCR_EL0.P bit to 1 has the following effect:
"Reset all event counters accessible in the current Exception level, not including PMCCNTR_EL0, to zero."
Similar behaviour is described for AArch32 on page G8-7022. Make it so.
--- arch/arm64/kvm/pmu-emul.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kvm/pmu-emul.c +1 -0
@@ -578,6 +578,7 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)kvm_pmu_set_counter_value (vcpu,ARMV8_PMU_CYCLE_IDX ,0 );if (val &ARMV8_PMU_PMCR_P ) { + mask &= ~BIT (ARMV8_PMU_CYCLE_IDX );for_each_set_bit (i, &mask,32 )kvm_pmu_set_counter_value (vcpu, i,0 ); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 260/593 regulator: hi655x: Fix pass wrong pointer to config.driver_data
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 61eb1b24f9e4f4e0725aa5f8164a932c933f3339 ]
Current code sets config.driver_data to a zero initialized regulator which is obviously wrong. Fix it.
--- drivers/regulator/hi655x-regulator.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/regulator/hi655x-regulator.c +5 -11
@@ -72,7 +72,7 @@ enum hi655x_regulator_id {static int hi655x_is_enabled (struct regulator_dev *rdev) {unsigned int value =0 ; -struct hi655x_regulator *regulator =rdev_get_drvdata (rdev); +const struct hi655x_regulator *regulator =rdev_get_drvdata (rdev);regmap_read (rdev->regmap, regulator->status_reg, &value);return (value & rdev->desc->enable_mask);
@@ -80,7 +80,7 @@ static int hi655x_is_enabled(struct regulator_dev *rdev)static int hi655x_disable (struct regulator_dev *rdev) { -struct hi655x_regulator *regulator =rdev_get_drvdata (rdev); +const struct hi655x_regulator *regulator =rdev_get_drvdata (rdev);return regmap_write (rdev->regmap, regulator->disable_reg, rdev->desc->enable_mask);
@@ -169,7 +169,6 @@ static const struct hi655x_regulator regulators[] = {static int hi655x_regulator_probe (struct platform_device *pdev) {unsigned int i; -struct hi655x_regulator *regulator;struct hi655x_pmic *pmic;struct regulator_config config = { };struct regulator_dev *rdev;
@@ -180,22 +179,17 @@ static int hi655x_regulator_probe(struct platform_device *pdev)return -ENODEV ; } - regulator =devm_kzalloc (&pdev->dev,sizeof (*regulator),GFP_KERNEL ); -if (!regulator) -return -ENOMEM ; - -platform_set_drvdata (pdev, regulator); - config.dev = pdev->dev.parent; config.regmap = pmic->regmap; - config.driver_data = regulator;for (i =0 ; i <ARRAY_SIZE (regulators); i++) { + config.driver_data = (void *) ®ulators[i]; + rdev =devm_regulator_register (&pdev->dev, ®ulators[i].rdesc, &config);if (IS_ERR (rdev)) {dev_err (&pdev->dev,"failed to register regulator %s\n" , - regulator->rdesc.name); + regulators[i].rdesc.name);return PTR_ERR (rdev); } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 261/593 btrfs: clear log tree recovering status if starting transaction fails
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
[ Upstream commit 1aeb6b563aea18cd55c73cf666d1d3245a00f08c ]
When a log recovery is in progress, lots of operations have to take that into account, so we keep this status per tree during the operation. Long time ago error handling revamp patch 79787eaab461 ("btrfs: replace many BUG_ONs with proper error handling") removed clearing of the status in an error branch. Add it back as was intended in e02119d5a7b4 ("Btrfs:
Add a write ahead tree log to optimize synchronous operations").
There are probably no visible effects, log replay is done only during mount and if it fails all structures are cleared so the stale status won't be kept.
--- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/tree-log.c +1 -0
@@ -6348,6 +6348,7 @@ next: error:if (wc.trans)btrfs_end_transaction (wc.trans); +clear_bit (BTRFS_FS_LOG_RECOVERING , &fs_info->flags);btrfs_free_path (path);return ret; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 262/593 x86/sev: Make sure IRQs are disabled while GHCB is active
In reply to Greg Kroah-HartmanFrom: Joerg Roedel <[email protected]>
[ Upstream commit d187f217335dba2b49fc9002aab2004e04acddee ]
The #VC handler only cares about IRQs being disabled while the GHCB is active, as it must not be interrupted by something which could cause another #VC while it holds the GHCB (NMI is the exception for which the backup GHCB exits).
Make sure nothing interrupts the code path while the GHCB is active by making sure that callers of __sev_{get,put}_ghcb() have disabled interrupts upfront.
[ bp: Massage commit message. ]
--- arch/x86/kernel/sev-es.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
arch/x86/kernel/sev-es.c +22 -12
@@ -12,7 +12,6 @@#include <linux/sched/debug.h> /* For show_regs() */ #include <linux/percpu-defs.h> #include <linux/mem_encrypt.h> -#include <linux/lockdep.h> #include <linux/printk.h> #include <linux/mm_types.h> #include <linux/set_memory.h>
@@ -180,11 +179,19 @@ void noinstr __sev_es_ist_exit(void)this_cpu_write (cpu_tss_rw.x86_tss.ist[IST_INDEX_VC ], *(unsigned long *)ist); } -static __always_inline struct ghcb *sev_es_get_ghcb(struct ghcb_state *state) +/* +* Nothing shall interrupt this code path while holding the per-CPU +* GHCB. The backup GHCB is only for NMIs interrupting this path. +* +* Callers must disable local interrupts around it. +*/ +static noinstr struct ghcb *__sev_get_ghcb(struct ghcb_state *state) {struct sev_es_runtime_data *data;struct ghcb *ghcb; +WARN_ON (!irqs_disabled ()); + data =this_cpu_read (runtime_data); ghcb = &data->ghcb_page;
@@ -201,7 +208,9 @@ static __always_inline struct ghcb *sev_es_get_ghcb(struct ghcb_state *state) data->ghcb_active = false; data->backup_ghcb_active = false; +instrumentation_begin ();panic ("Unable to handle #VC exception! GHCB and Backup GHCB are already in use" ); +instrumentation_end (); }/* Mark backup_ghcb active before writing to it */
@@ -452,11 +461,13 @@ static enum es_result vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt/* Include code shared with pre-decompression boot stage */ #include "sev-es-shared.c" -static __always_inline void sev_es_put_ghcb(struct ghcb_state *state) +static noinstr void __sev_put_ghcb(struct ghcb_state *state) {struct sev_es_runtime_data *data;struct ghcb *ghcb; +WARN_ON (!irqs_disabled ()); + data =this_cpu_read (runtime_data); ghcb = &data->ghcb_page;
@@ -480,7 +491,7 @@ void noinstr __sev_es_nmi_complete(void)struct ghcb_state state;struct ghcb *ghcb; - ghcb =sev_es_get_ghcb (&state); + ghcb =__sev_get_ghcb (&state);vc_ghcb_invalidate (ghcb);ghcb_set_sw_exit_code (ghcb,SVM_VMGEXIT_NMI_COMPLETE );
@@ -490,7 +501,7 @@ void noinstr __sev_es_nmi_complete(void)sev_es_wr_ghcb_msr (__pa_nodebug (ghcb));VMGEXIT (); -sev_es_put_ghcb (&state); +__sev_put_ghcb (&state); }static u64 get_jump_table_addr (void )
@@ -502,7 +513,7 @@ static u64 get_jump_table_addr(void)local_irq_save (flags); - ghcb =sev_es_get_ghcb (&state); + ghcb =__sev_get_ghcb (&state);vc_ghcb_invalidate (ghcb);ghcb_set_sw_exit_code (ghcb,SVM_VMGEXIT_AP_JUMP_TABLE );
@@ -516,7 +527,7 @@ static u64 get_jump_table_addr(void) ghcb_sw_exit_info_2_is_valid(ghcb)) ret = ghcb->save.sw_exit_info_2; -sev_es_put_ghcb (&state); +__sev_put_ghcb (&state);local_irq_restore (flags);
@@ -641,7 +652,7 @@ static void sev_es_ap_hlt_loop(void)struct ghcb_state state;struct ghcb *ghcb; - ghcb =sev_es_get_ghcb (&state); + ghcb =__sev_get_ghcb (&state);while (true) {vc_ghcb_invalidate (ghcb);
@@ -658,7 +669,7 @@ static void sev_es_ap_hlt_loop(void)break ; } -sev_es_put_ghcb (&state); +__sev_put_ghcb (&state); }/*
@@ -1317,7 +1328,6 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication) } irq_state =irqentry_nmi_enter (regs); -lockdep_assert_irqs_disabled ();instrumentation_begin ();/*
@@ -1326,7 +1336,7 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)* keep the IRQs disabled to protect us against concurrent TLB flushes. */ - ghcb =sev_es_get_ghcb (&state); + ghcb =__sev_get_ghcb (&state);vc_ghcb_invalidate (ghcb); result =vc_init_em_ctxt (&ctxt, regs, error_code);
@@ -1334,7 +1344,7 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)if (result ==ES_OK ) result =vc_handle_exitcode (&ctxt, ghcb, error_code); -sev_es_put_ghcb (&state); +__sev_put_ghcb (&state);/* Done - now check the result */ switch (result) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 263/593 x86/sev: Split up runtime #VC handler for correct state tracking
In reply to Greg Kroah-HartmanFrom: Joerg Roedel <[email protected]>
[ Upstream commit be1a5408868af341f61f93c191b5e346ee88c82a ]
Split up the #VC handler code into a from-user and a from-kernel part. This allows clean and correct state tracking, as the #VC handler needs to enter NMI-state when raised from kernel mode and plain IRQ state when raised from user-mode.
--- arch/x86/entry/entry_64.S | 4 +- arch/x86/include/asm/idtentry.h | 29 +++---- arch/x86/kernel/sev-es.c | 148 +++++++++++++++++--------------- 3 files changed, 91 insertions(+), 90 deletions(-)
arch/x86/entry/entry_64.S +2 -2
@@ -508,7 +508,7 @@ SYM_CODE_START(\asmsym) movq %rsp, %rdi /* pt_regs pointer */ - call \cfunc + call kernel_\cfunc /* * No need to switch back to the IST stack. The current stack is either
@@ -519,7 +519,7 @@ SYM_CODE_START(\asmsym) /* Switch to the regular task stack */ .Lfrom_usermode_switch_stack_\@: - idtentry_body safe_stack_\cfunc, has_error_code=1 + idtentry_body user_\cfunc, has_error_code=1 _ASM_NOKPROBE(\asmsym) SYM_CODE_END(\asmsym)
arch/x86/include/asm/idtentry.h +10 -19
@@ -315,8 +315,8 @@ static __always_inline void __##func(struct pt_regs *regs)*/ #define DECLARE_IDTENTRY_VC (vector, func) \ DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func); \ - __visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \ - __visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code) + __visible noinstr void kernel_##func(struct pt_regs *regs, unsigned long error_code); \ + __visible noinstr void user_##func(struct pt_regs *regs, unsigned long error_code)/** * DEFINE_IDTENTRY_IST - Emit code for IST entry points
@@ -358,33 +358,24 @@ static __always_inline void __##func(struct pt_regs *regs)DEFINE_IDTENTRY_RAW_ERRORCODE (func)/** -* DEFINE_IDTENTRY_VC_SAFE_STACK - Emit code for VMM communication handler -which runs on a safe stack. +* DEFINE_IDTENTRY_VC_KERNEL - Emit code for VMM communication handler +when raised from kernel mode * @func: Function name of the entry point * * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE */ -#define DEFINE_IDTENTRY_VC_SAFE_STACK (func) \ - DEFINE_IDTENTRY_RAW_ERRORCODE(safe_stack_##func) +#define DEFINE_IDTENTRY_VC_KERNEL (func) \ + DEFINE_IDTENTRY_RAW_ERRORCODE(kernel_##func)/** -* DEFINE_IDTENTRY_VC_IST - Emit code for VMM communication handler -which runs on the VC fall-back stack +* DEFINE_IDTENTRY_VC_USER - Emit code for VMM communication handler +when raised from user mode * @func: Function name of the entry point * * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE */ -#define DEFINE_IDTENTRY_VC_IST (func) \ - DEFINE_IDTENTRY_RAW_ERRORCODE(ist_##func) - -/** -* DEFINE_IDTENTRY_VC - Emit code for VMM communication handler -* @func: Function name of the entry point -* -* Maps to DEFINE_IDTENTRY_RAW_ERRORCODE -*/ -#define DEFINE_IDTENTRY_VC (func) \ - DEFINE_IDTENTRY_RAW_ERRORCODE(func) +#define DEFINE_IDTENTRY_VC_USER (func) \ + DEFINE_IDTENTRY_RAW_ERRORCODE(user_##func)#else /* CONFIG_X86_64 */
arch/x86/kernel/sev-es.c +79 -69
203 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 264/593 sched/rt: Fix RT utilization tracking during policy change
In reply to Greg Kroah-HartmanFrom: Vincent Donnefort <[email protected]>
[ Upstream commit fecfcbc288e9f4923f40fd23ca78a6acdc7fdf6c ]
RT keeps track of the utilization on a per-rq basis with the structure avg_rt. This utilization is updated during task_tick_rt(), put_prev_task_rt() and set_next_task_rt(). However, when the current running task changes its policy, set_next_task_rt() which would usually take care of updating the utilization when the rq starts running RT tasks, will not see a such change, leaving the avg_rt structure outdated. When that very same task will be dequeued later, put_prev_task_rt() will then update the utilization, based on a wrong last_update_time, leading to a huge spike in the RT utilization signal.
The signal would eventually recover from this issue after few ms. Even if no RT tasks are run, avg_rt is also updated in __update_blocked_others(). But as the CPU capacity depends partly on the avg_rt, this issue has nonetheless a significant impact on the scheduler.
Fix this issue by ensuring a load update when a running task changes its policy to RT.
--- kernel/sched/rt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
kernel/sched/rt.c +12 -5
@@ -2291,13 +2291,20 @@ void __init init_sched_rt_class(void)static void switched_to_rt (struct rq *rq,struct task_struct *p) {/* -* If we are already running, then there's nothing -* that needs to be done. But if we are not running -* we may need to preempt the current running task. -* If that current running task is also an RT task +* If we are running, update the avg_rt tracking, as the running time +* will now on be accounted into the latter. +*/ +if (task_current (rq, p)) { +update_rt_rq_load_avg (rq_clock_pelt (rq), rq,0 ); +return ; + } + +/* +* If we are not running we may need to preempt the current +* running task. If that current running task is also an RT task * then see if we can move to another run queue. */ -if (task_on_rq_queued (p) && rq->curr != p) { +if (task_on_rq_queued (p)) {#ifdef CONFIG_SMP if (p->nr_cpus_allowed >1 && rq->rt.overloaded)rt_queue_push_tasks (rq);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 265/593 sched/rt: Fix Deadline utilization tracking during policy change
In reply to Greg Kroah-HartmanFrom: Vincent Donnefort <[email protected]>
[ Upstream commit d7d607096ae6d378b4e92d49946d22739c047d4c ]
DL keeps track of the utilization on a per-rq basis with the structure avg_dl. This utilization is updated during task_tick_dl(), put_prev_task_dl() and set_next_task_dl(). However, when the current running task changes its policy, set_next_task_dl() which would usually take care of updating the utilization when the rq starts running DL tasks, will not see a such change, leaving the avg_dl structure outdated. When that very same task will be dequeued later, put_prev_task_dl() will then update the utilization, based on a wrong last_update_time, leading to a huge spike in the DL utilization signal.
The signal would eventually recover from this issue after few ms. Even if no DL tasks are run, avg_dl is also updated in __update_blocked_others(). But as the CPU capacity depends partly on the avg_dl, this issue has nonetheless a significant impact on the scheduler.
Fix this issue by ensuring a load update when a running task changes its policy to DL.
--- kernel/sched/deadline.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sched/deadline.c +2 -0
@@ -2470,6 +2470,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)check_preempt_curr_dl (rq, p,0 ); elseresched_curr (rq ); + }else { +update_dl_rq_load_avg (rq_clock_pelt (rq), rq,0 ); } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 266/593 sched/uclamp: Fix uclamp_tg_restrict()
In reply to Greg Kroah-HartmanFrom: Qais Yousef <[email protected]>
[ Upstream commit 0213b7083e81f4acd69db32cb72eb4e5f220329a ]
Now cpu.uclamp.min acts as a protection, we need to make sure that the uclamp request of the task is within the allowed range of the cgroup, that is it is clamp()'ed correctly by tg->uclamp[UCLAMP_MIN] and tg->uclamp[UCLAMP_MAX].
As reported by Xuewen [1] we can have some corner cases where there's inversion between uclamp requested by task (p) and the uclamp values of the taskgroup it's attached to (tg). Following table demonstrates 2 corner cases:
| p | tg | effective -----------+-----+------+----------- CASE 1 -----------+-----+------+----------- uclamp_min | 60% | 0% | 60% -----------+-----+------+----------- uclamp_max | 80% | 50% | 50% -----------+-----+------+----------- CASE 2 -----------+-----+------+----------- uclamp_min | 0% | 30% | 30% -----------+-----+------+----------- uclamp_max | 20% | 50% | 20% -----------+-----+------+-----------
With this fix we get:
| p | tg | effective -----------+-----+------+----------- CASE 1 -----------+-----+------+----------- uclamp_min | 60% | 0% | 50% -----------+-----+------+----------- uclamp_max | 80% | 50% | 50% -----------+-----+------+----------- CASE 2 -----------+-----+------+----------- uclamp_min | 0% | 30% | 30% -----------+-----+------+----------- uclamp_max | 20% | 50% | 30% -----------+-----+------+-----------
Additionally uclamp_update_active_tasks() must now unconditionally update both UCLAMP_MIN/MAX because changing the tg's UCLAMP_MAX for instance could have an impact on the effective UCLAMP_MIN of the tasks.
| p | tg | effective -----------+-----+------+----------- old -----------+-----+------+----------- uclamp_min | 60% | 0% | 50% -----------+-----+------+----------- uclamp_max | 80% | 50% | 50% -----------+-----+------+----------- *new* -----------+-----+------+----------- uclamp_min | 60% | 0% | *60%* -----------+-----+------+----------- uclamp_max | 80% |*70%* | *70%* -----------+-----+------+-----------
[1] https://lore.kernel.org/lkml/CAB8ipk_a6VFNjiEnHRHkUMBKbA+qzPQvhtNjJ_YNzQhqV_o8Zw@mail.gmail.com/
--- kernel/sched/core.c | 49 +++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 31 deletions(-)
kernel/sched/core.c +18 -31
@@ -1063,8 +1063,10 @@ static void uclamp_sync_util_min_rt_default(void)static inline struct uclamp_se uclamp_tg_restrict (struct task_struct *p,enum uclamp_id clamp_id) { +/* Copy by value as we could modify it */ struct uclamp_se uc_req = p->uclamp_req[clamp_id];#ifdef CONFIG_UCLAMP_TASK_GROUP +unsigned int tg_min, tg_max, value;/* * Tasks in autogroups or root task group will be
@@ -1075,23 +1077,11 @@ uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)if (task_group (p) == &root_task_group)return uc_req; -switch (clamp_id) { -case UCLAMP_MIN : { -struct uclamp_se uc_min =task_group (p)->uclamp[clamp_id]; -if (uc_req.value < uc_min.value) -return uc_min; -break ; - } -case UCLAMP_MAX : { -struct uclamp_se uc_max =task_group (p)->uclamp[clamp_id]; -if (uc_req.value > uc_max.value) -return uc_max; -break ; - } -default : -WARN_ON_ONCE (1 ); -break ; - } + tg_min =task_group (p)->uclamp[UCLAMP_MIN ].value; + tg_max =task_group (p)->uclamp[UCLAMP_MAX ].value; + value = uc_req.value; + value =clamp (value, tg_min, tg_max); +uclamp_se_set (&uc_req, value, false);#endif return uc_req;
@@ -1290,8 +1280,9 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) }static inline void -uclamp_update_active (struct task_struct *p,enum uclamp_id clamp_id) +uclamp_update_active (struct task_struct *p) { +enum uclamp_id clamp_id;struct rq_flags rf;struct rq *rq;
@@ -1311,9 +1302,11 @@ uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id)* affecting a valid clamp bucket, the next time it's enqueued, * it will already see the updated clamp bucket value. */ -if (p->uclamp[clamp_id].active) { -uclamp_rq_dec_id (rq, p, clamp_id); -uclamp_rq_inc_id (rq, p, clamp_id); +for_each_clamp_id (clamp_id) { +if (p->uclamp[clamp_id].active) { +uclamp_rq_dec_id (rq, p, clamp_id); +uclamp_rq_inc_id (rq, p, clamp_id); + } }task_rq_unlock (rq, p, &rf);
@@ -1321,20 +1314,14 @@ uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id)#ifdef CONFIG_UCLAMP_TASK_GROUP static inline void -uclamp_update_active_tasks (struct cgroup_subsys_state *css, -unsigned int clamps) +uclamp_update_active_tasks (struct cgroup_subsys_state *css) { -enum uclamp_id clamp_id;struct css_task_iter it;struct task_struct *p;css_task_iter_start (css,0 , &it); -while ((p =css_task_iter_next (&it))) { -for_each_clamp_id (clamp_id) { -if ((0x1 << clamp_id) & clamps) -uclamp_update_active (p, clamp_id); - } - } +while ((p =css_task_iter_next (&it))) +uclamp_update_active (p);css_task_iter_end (&it); }
@@ -7749,7 +7736,7 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css) }/* Immediately update descendants RUNNABLE tasks */ -uclamp_update_active_tasks (css, clamps); +uclamp_update_active_tasks (css); } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 267/593 lockdep: Fix wait-type for empty stack
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit f8b298cc39f0619544c607eaef09fd0b2afd10f3 ]
Even the very first lock can violate the wait-context check, consider the various IRQ contexts.
--- kernel/locking/lockdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep.c +1 -1
@@ -4626,7 +4626,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)short curr_inner;int depth; -if (!curr->lockdep_depth || !next_inner || next->trylock) +if (!next_inner || next->trylock)return 0 ;if (!next_outer)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 268/593 lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit c0c2c0dad6a06e0c05e9a52d65f932bd54364c97 ]
When PROVE_RAW_LOCK_NESTING=y many of the selftests FAILED because HARDIRQ context is out-of-bounds for spinlocks. Instead make the default hardware context the threaded hardirq context, which preserves the old locking rules.
The wait-type specific locking selftests will have a non-threaded HARDIRQ variant.
--- lib/locking-selftest.c | 1 + 1 file changed, 1 insertion(+)
lib/locking-selftest.c +1 -0
@@ -186,6 +186,7 @@ static void init_shared_classes(void)#define HARDIRQ_ENTER () \ local_irq_disable(); \ __irq_enter(); \ + lockdep_hardirq_threaded(); \ WARN_ON(!in_irq());#define HARDIRQ_EXIT () \
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 269/593 spi: spi-sun6i: Fix chipselect/clock bug
In reply to Greg Kroah-HartmanFrom: Mirko Vogt <mirko-dev|[email protected]>
[ Upstream commit 0d7993b234c9fad8cb6bec6adfaa74694ba85ecb ]
The current sun6i SPI implementation initializes the transfer too early, resulting in SCK going high before the transfer. When using an additional (gpio) chipselect with sun6i, the chipselect is asserted at a time when clock is high, making the SPI transfer fail.
This is due to SUN6I_GBL_CTL_BUS_ENABLE being written into SUN6I_GBL_CTL_REG at an early stage. Moving that to the transfer function, hence, right before the transfer starts, mitigates that problem.
--- drivers/spi/spi-sun6i.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-sun6i.c +5 -1
@@ -290,6 +290,10 @@ static int sun6i_spi_transfer_one(struct spi_master *master, }sun6i_spi_write (sspi,SUN6I_CLK_CTL_REG , reg); +/* Finally enable the bus - doing so before might raise SCK to HIGH */ + reg =sun6i_spi_read (sspi,SUN6I_GBL_CTL_REG ); + reg |=SUN6I_GBL_CTL_BUS_ENABLE ; +sun6i_spi_write (sspi,SUN6I_GBL_CTL_REG , reg);/* Setup the transfer now... */ if (sspi->tx_buf)
@@ -398,7 +402,7 @@ static int sun6i_spi_runtime_resume(struct device *dev) }sun6i_spi_write (sspi,SUN6I_GBL_CTL_REG , -SUN6I_GBL_CTL_BUS_ENABLE |SUN6I_GBL_CTL_MASTER |SUN6I_GBL_CTL_TP ); +SUN6I_GBL_CTL_MASTER |SUN6I_GBL_CTL_TP );return 0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 270/593 crypto: nx - Fix RCU warning in nx842_OF_upd_status
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
[ Upstream commit 2a96726bd0ccde4f12b9b9a9f61f7b1ac5af7e10 ]
The function nx842_OF_upd_status triggers a sparse RCU warning when it directly dereferences the RCU-protected devdata. This appears to be an accident as there was another variable of the same name that was passed in from the caller.
After it was removed (because the main purpose of using it, to update the status member was itself removed) the global variable unintenionally stood in as its replacement.
This patch restores the devdata parameter.
--- drivers/crypto/nx/nx-842-pseries.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/crypto/nx/nx-842-pseries.c +5 -3
@@ -538,13 +538,15 @@ static int nx842_OF_set_defaults(struct nx842_devdata *devdata)* The status field indicates if the device is enabled when the status * is 'okay'. Otherwise the device driver will be disabled. * -* @prop - struct property point containing the maxsyncop for the update +* @devdata: struct nx842_devdata to use for dev_info +* @prop: struct property point containing the maxsyncop for the update * * Returns: * 0 - Device is available * -ENODEV - Device is not available */ -static int nx842_OF_upd_status (struct property *prop) +static int nx842_OF_upd_status (struct nx842_devdata *devdata, +struct property *prop) {const char *status = (const char *)prop->value;
@@ -758,7 +760,7 @@ static int nx842_OF_upd(struct property *new_prop) goto out;/* Perform property updates */ - ret =nx842_OF_upd_status (status); + ret =nx842_OF_upd_status (new_devdata, status);if (ret) goto error_out;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 271/593 psi: Fix race between psi_trigger_create/destroy
In reply to Greg Kroah-HartmanFrom: Zhaoyang Huang <[email protected]>
[ Upstream commit 8f91efd870ea5d8bc10b0fcc9740db51cd4c0c83 ]
Race detected between psi_trigger_destroy/create as shown below, which cause panic by accessing invalid psi_system->poll_wait->wait_queue_entry and psi_system->poll_timer->entry->next. Under this modification, the race window is removed by initialising poll_wait and poll_timer in group_init which are executed only once at beginning.
psi_trigger_destroy() psi_trigger_create()
mutex_lock(trigger_lock);
rcu_assign_pointer(poll_task, NULL);
mutex_unlock(trigger_lock);
mutex_lock(trigger_lock);
if (!rcu_access_pointer(group->poll_task)) {
timer_setup(poll_timer, poll_timer_fn, 0);
rcu_assign_pointer(poll_task, task);
}
mutex_unlock(trigger_lock); synchronize_rcu();
del_timer_sync(poll_timer); <-- poll_timer has been reinitialized by
psi_trigger_create()So, trigger_lock/RCU correctly protects destruction of group->poll_task but misses this race affecting poll_timer and poll_wait.
--- kernel/sched/psi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/sched/psi.c +6 -6
@@ -179,6 +179,8 @@ struct psi_group psi_system = {static void psi_avgs_work (struct work_struct *work); +static void poll_timer_fn (struct timer_list *t); +static void group_init (struct psi_group *group) {int cpu;
@@ -198,6 +200,8 @@ static void group_init(struct psi_group *group)memset (group->polling_total,0 ,sizeof (group->polling_total)); group->polling_next_update =ULLONG_MAX ; group->polling_until =0 ; +init_waitqueue_head (&group->poll_wait); +timer_setup (&group->poll_timer, poll_timer_fn,0 );rcu_assign_pointer (group->poll_task,NULL ); }
@@ -1126,9 +1130,7 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,return ERR_CAST (task); }atomic_set (&group->poll_wakeup,0 ); -init_waitqueue_head (&group->poll_wait);wake_up_process (task); -timer_setup (&group->poll_timer, poll_timer_fn,0 );rcu_assign_pointer (group->poll_task, task); }
@@ -1180,6 +1182,7 @@ static void psi_trigger_destroy(struct kref *ref) group->poll_task, lockdep_is_held(&group->trigger_lock));rcu_assign_pointer (group->poll_task,NULL ); +del_timer (&group->poll_timer); } }
@@ -1192,17 +1195,14 @@ static void psi_trigger_destroy(struct kref *ref)*/ synchronize_rcu ();/* -* Destroy the kworker after releasing trigger_lock to prevent a +* Stop kthread 'psimon' after releasing trigger_lock to prevent a * deadlock while waiting for psi_poll_work to acquire trigger_lock */ if (task_to_destroy) {/* * After the RCU grace period has expired, the worker * can no longer be found through group->poll_task. -* But it might have been already scheduled before -* that - deschedule it cleanly before destroying it. */ -del_timer_sync (&group->poll_timer);kthread_stop (task_to_destroy); }kfree (t);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 272/593 media: v4l2-async: Clean v4l2_async_notifier_add_fwnode_remote_subdev
In reply to Greg Kroah-HartmanFrom: Ezequiel Garcia <[email protected]>
[ Upstream commit c1cf3d896d124e3e00794f9bfbde49f0fc279e3f ]
Change v4l2_async_notifier_add_fwnode_remote_subdev semantics so it allocates the struct v4l2_async_subdev pointer.
This makes the API consistent: the v4l2-async subdevice addition functions have now a unified usage model. This model is simpler, as it makes v4l2-async responsible for the allocation and release of the subdevice descriptor, and no longer something the driver has to worry about.
On the user side, the change makes the API simpler for the drivers to use and less error-prone.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 17 ++-- drivers/media/platform/omap3isp/isp.c | 79 ++++++++----------- .../platform/sunxi/sun4i-csi/sun4i_csi.c | 9 ++- .../platform/sunxi/sun4i-csi/sun4i_csi.h | 1 - drivers/media/platform/video-mux.c | 14 +--- drivers/media/v4l2-core/v4l2-async.c | 24 +++--- drivers/staging/media/imx/imx-media-csi.c | 14 +--- drivers/staging/media/imx/imx6-mipi-csi2.c | 19 ++--- drivers/staging/media/imx/imx7-media-csi.c | 16 ++-- drivers/staging/media/imx/imx7-mipi-csis.c | 15 ++-- drivers/staging/media/rkisp1/rkisp1-dev.c | 15 ++-- include/media/v4l2-async.h | 15 ++-- 12 files changed, 96 insertions(+), 142 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +7 -10
@@ -1476,7 +1476,8 @@ static int cio2_parse_firmware(struct cio2_device *cio2)struct v4l2_fwnode_endpoint vep = { .bus_type =V4L2_MBUS_CSI2_DPHY }; -struct sensor_async_subdev *s_asd =NULL ; +struct sensor_async_subdev *s_asd; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep; ep = fwnode_graph_get_endpoint_by_id(
@@ -1490,27 +1491,23 @@ static int cio2_parse_firmware(struct cio2_device *cio2)if (ret) goto err_parse; - s_asd =kzalloc (sizeof (*s_asd),GFP_KERNEL ); -if (!s_asd) { - ret = -ENOMEM ; + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &cio2->notifier, ep,sizeof (*s_asd)); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd); goto err_parse; } + s_asd = container_of(asd, struct sensor_async_subdev, asd); s_asd->csi2.port = vep.base.port; s_asd->csi2.lanes = vep.bus.mipi_csi2.num_data_lanes; - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &cio2->notifier, ep, &s_asd->asd); -if (ret) - goto err_parse; -fwnode_handle_put (ep);continue ; err_parse:fwnode_handle_put (ep); -kfree (s_asd);return ret; }
drivers/media/platform/omap3isp/isp.c +33 -46
117 lines not on this page · raw message
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c +6 -3
@@ -118,6 +118,7 @@ static int sun4i_csi_notifier_init(struct sun4i_csi *csi)struct v4l2_fwnode_endpoint vep = { .bus_type =V4L2_MBUS_PARALLEL , }; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep;int ret;
@@ -134,10 +135,12 @@ static int sun4i_csi_notifier_init(struct sun4i_csi *csi) csi->bus = vep.bus.parallel; - ret =v4l2_async_notifier_add_fwnode_remote_subdev (&csi->notifier, - ep, &csi->asd); -if (ret) + asd =v4l2_async_notifier_add_fwnode_remote_subdev (&csi->notifier, + ep,sizeof (*asd)); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd); goto out; + } csi->notifier.ops = &sun4i_csi_notify_ops;
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h +0 -1
@@ -139,7 +139,6 @@ struct sun4i_csi {struct v4l2_mbus_framefmt subdev_fmt;/* V4L2 Async variables */ -struct v4l2_async_subdev asd;struct v4l2_async_notifier notifier;struct v4l2_subdev *src_subdev;int src_pad;
drivers/media/platform/video-mux.c +4 -10
@@ -370,19 +370,13 @@ static int video_mux_async_register(struct video_mux *vmux,if (!ep)continue ; - asd =kzalloc (sizeof (*asd),GFP_KERNEL ); -if (!asd) { -fwnode_handle_put (ep); -return -ENOMEM ; - } - - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &vmux->notifier, ep, asd); + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &vmux->notifier, ep,sizeof (*asd));fwnode_handle_put (ep); -if (ret) { -kfree (asd); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd);/* OK if asd already exists */ if (ret != -EEXIST )return ret;
drivers/media/v4l2-core/v4l2-async.c +12 -12
@@ -673,26 +673,26 @@ v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier, }EXPORT_SYMBOL_GPL (v4l2_async_notifier_add_fwnode_subdev); -int +struct v4l2_async_subdev *v4l2_async_notifier_add_fwnode_remote_subdev (struct v4l2_async_notifier *notif,struct fwnode_handle *endpoint, -struct v4l2_async_subdev *asd) +unsigned int asd_struct_size) { +struct v4l2_async_subdev *asd;struct fwnode_handle *remote; -int ret; remote =fwnode_graph_get_remote_port_parent (endpoint);if (!remote) -return -ENOTCONN ; +return ERR_PTR (-ENOTCONN ); - asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode = remote; - - ret =v4l2_async_notifier_add_subdev (notif, asd); -if (ret) -fwnode_handle_put (remote); - -return ret; + asd =v4l2_async_notifier_add_fwnode_subdev (notif, remote, + asd_struct_size); +/* +* Calling v4l2_async_notifier_add_fwnode_subdev grabs a refcount, +* so drop the one we got in fwnode_graph_get_remote_port_parent. +*/ +fwnode_handle_put (remote); +return asd; }EXPORT_SYMBOL_GPL (v4l2_async_notifier_add_fwnode_remote_subdev);
drivers/staging/media/imx/imx-media-csi.c +4 -10
@@ -1942,19 +1942,13 @@ static int imx_csi_async_register(struct csi_priv *priv) port,0 , FWNODE_GRAPH_ENDPOINT_NEXT);if (ep) { - asd =kzalloc (sizeof (*asd),GFP_KERNEL ); -if (!asd) { -fwnode_handle_put (ep); -return -ENOMEM ; - } - - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &priv->notifier, ep, asd); + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &priv->notifier, ep,sizeof (*asd));fwnode_handle_put (ep); -if (ret) { -kfree (asd); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd);/* OK if asd already exists */ if (ret != -EEXIST )return ret;
drivers/staging/media/imx/imx6-mipi-csi2.c +6 -13
@@ -557,7 +557,7 @@ static int csi2_async_register(struct csi2_dev *csi2)struct v4l2_fwnode_endpoint vep = { .bus_type =V4L2_MBUS_CSI2_DPHY , }; -struct v4l2_async_subdev *asd =NULL ; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep;int ret;
@@ -577,19 +577,13 @@ static int csi2_async_register(struct csi2_dev *csi2)dev_dbg (csi2->dev,"data lanes: %d\n" , csi2->bus.num_data_lanes);dev_dbg (csi2->dev,"flags: 0x%08x\n" , csi2->bus.flags); - asd =kzalloc (sizeof (*asd),GFP_KERNEL ); -if (!asd) { - ret = -ENOMEM ; - goto err_parse; - } - - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &csi2->notifier, ep, asd); -if (ret) - goto err_parse; - + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &csi2->notifier, ep,sizeof (*asd));fwnode_handle_put (ep); +if (IS_ERR (asd)) +return PTR_ERR (asd); + csi2->notifier.ops = &csi2_notify_ops; ret = v4l2_async_subdev_notifier_register(&csi2->sd,
@@ -601,7 +595,6 @@ static int csi2_async_register(struct csi2_dev *csi2) err_parse:fwnode_handle_put (ep); -kfree (asd);return ret; }
drivers/staging/media/imx/imx7-media-csi.c +5 -11
@@ -1191,7 +1191,7 @@ static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = {static int imx7_csi_async_register (struct imx7_csi *csi) { -struct v4l2_async_subdev *asd =NULL ; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep;int ret;
@@ -1200,19 +1200,13 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ep =fwnode_graph_get_endpoint_by_id (dev_fwnode (csi->dev),0 ,0 ,FWNODE_GRAPH_ENDPOINT_NEXT );if (ep) { - asd =kzalloc (sizeof (*asd),GFP_KERNEL ); -if (!asd) { -fwnode_handle_put (ep); -return -ENOMEM ; - } - - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &csi->notifier, ep, asd); + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &csi->notifier, ep,sizeof (*asd));fwnode_handle_put (ep); -if (ret) { -kfree (asd); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd);/* OK if asd already exists */ if (ret != -EEXIST )return ret;
drivers/staging/media/imx/imx7-mipi-csis.c +5 -10
@@ -1006,7 +1006,7 @@ static int mipi_csis_async_register(struct csi_state *state)struct v4l2_fwnode_endpoint vep = { .bus_type =V4L2_MBUS_CSI2_DPHY , }; -struct v4l2_async_subdev *asd =NULL ; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep;int ret;
@@ -1026,17 +1026,13 @@ static int mipi_csis_async_register(struct csi_state *state)dev_dbg (state->dev,"data lanes: %d\n" , state->bus.num_data_lanes);dev_dbg (state->dev,"flags: 0x%08x\n" , state->bus.flags); - asd =kzalloc (sizeof (*asd),GFP_KERNEL ); -if (!asd) { - ret = -ENOMEM ; + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( + &state->notifier, ep,sizeof (*asd)); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd); goto err_parse; } - ret =v4l2_async_notifier_add_fwnode_remote_subdev ( - &state->notifier, ep, asd); -if (ret) - goto err_parse; -fwnode_handle_put (ep); state->notifier.ops = &mipi_csis_notify_ops;
@@ -1050,7 +1046,6 @@ static int mipi_csis_async_register(struct csi_state *state) err_parse:fwnode_handle_put (ep); -kfree (asd);return ret; }
drivers/staging/media/rkisp1/rkisp1-dev.c +6 -9
@@ -252,6 +252,7 @@ static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1) .bus_type = V4L2_MBUS_CSI2_DPHY };struct rkisp1_sensor_async *rk_asd =NULL ; +struct v4l2_async_subdev *asd;struct fwnode_handle *ep; ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(rkisp1->dev),
@@ -263,21 +264,18 @@ static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1)if (ret) goto err_parse; - rk_asd =kzalloc (sizeof (*rk_asd),GFP_KERNEL ); -if (!rk_asd) { - ret = -ENOMEM ; + asd =v4l2_async_notifier_add_fwnode_remote_subdev (ntf, ep, +sizeof (*rk_asd)); +if (IS_ERR (asd)) { + ret =PTR_ERR (asd); goto err_parse; } + rk_asd = container_of(asd, struct rkisp1_sensor_async, asd); rk_asd->mbus_type = vep.bus_type; rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; - ret =v4l2_async_notifier_add_fwnode_remote_subdev (ntf, ep, - &rk_asd->asd); -if (ret) - goto err_parse; -dev_dbg (rkisp1->dev,"registered ep id %d with %d lanes\n" , vep.base.id, rk_asd->lanes);
@@ -288,7 +286,6 @@ static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1)continue ; err_parse:fwnode_handle_put (ep); -kfree (rk_asd);v4l2_async_notifier_cleanup (ntf);return ret; }
include/media/v4l2-async.h +8 -7
@@ -189,9 +189,11 @@ v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,* * @notif: pointer to &struct v4l2_async_notifier * @endpoint: local endpoint pointing to the remote sub-device to be matched -* @asd: Async sub-device struct allocated by the caller. The &struct -* v4l2_async_subdev shall be the first member of the driver's async -* sub-device struct, i.e. both begin at the same memory address. +* @asd_struct_size: size of the driver's async sub-device struct, including +* sizeof(struct v4l2_async_subdev). The &struct +* v4l2_async_subdev shall be the first member of +* the driver's async sub-device struct, i.e. both +* begin at the same memory address. * * Gets the remote endpoint of a given local endpoint, set it up for fwnode * matching and adds the async sub-device to the notifier's @asd_list. The
@@ -199,13 +201,12 @@ v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,* notifier cleanup time. * * This is just like @v4l2_async_notifier_add_fwnode_subdev, but with the -* exception that the fwnode refers to a local endpoint, not the remote one, and -* the function relies on the caller to allocate the async sub-device struct. +* exception that the fwnode refers to a local endpoint, not the remote one. */ -int +struct v4l2_async_subdev *v4l2_async_notifier_add_fwnode_remote_subdev (struct v4l2_async_notifier *notif,struct fwnode_handle *endpoint, -struct v4l2_async_subdev *asd); +unsigned int asd_struct_size);/** * v4l2_async_notifier_add_i2c_subdev - Allocate and add an i2c async
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 273/593 media: video-mux: Skip dangling endpoints
In reply to Greg Kroah-HartmanFrom: Philipp Zabel <[email protected]>
[ Upstream commit 95778c2d0979618e3349b1d2324ec282a5a6adbf ]
i.MX6 device tree include files contain dangling endpoints for the board device tree writers' convenience. These are still included in many existing device trees.
Treat dangling endpoints as non-existent to support them.
--- drivers/media/platform/video-mux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/platform/video-mux.c +9 -1
@@ -362,7 +362,7 @@ static int video_mux_async_register(struct video_mux *vmux,for (i =0 ; i < num_input_pads; i++) {struct v4l2_async_subdev *asd; -struct fwnode_handle *ep; +struct fwnode_handle *ep, *remote_ep; ep = fwnode_graph_get_endpoint_by_id( dev_fwnode(vmux->subdev.dev), i, 0,
@@ -370,6 +370,14 @@ static int video_mux_async_register(struct video_mux *vmux,if (!ep)continue ; +/* Skip dangling endpoints for backwards compatibility */ + remote_ep =fwnode_graph_get_remote_endpoint (ep); +if (!remote_ep) { +fwnode_handle_put (ep); +continue ; + } +fwnode_handle_put (remote_ep); + asd =v4l2_async_notifier_add_fwnode_remote_subdev ( &vmux->notifier, ep,sizeof (*asd));
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 274/593 PM / devfreq: Add missing error code in devfreq_add_device()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 18b380ed61f892ed06838d1f1a5124d966292ed3 ]
Set err code in the error path before jumping to the end of the function.
--- drivers/devfreq/devfreq.c | 1 + 1 file changed, 1 insertion(+)
drivers/devfreq/devfreq.c +1 -0
@@ -789,6 +789,7 @@ struct devfreq *devfreq_add_device(struct device *dev,if (devfreq->profile->timer <0 || devfreq->profile->timer >=DEVFREQ_TIMER_NUM ) {mutex_unlock (&devfreq->lock); + err = -EINVAL ; goto err_dev; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 275/593 ACPI: PM / fan: Put fan device IDs into separate header file
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit b9370dceabb7841c5e65ce4ee4405b9db5231fc4 ]
The ACPI fan device IDs are shared between the fan driver and the device power management code. The former is modular, so it needs to include the table of device IDs for module autoloading and the latter needs that list to avoid attaching the generic ACPI PM domain to fan devices (which doesn't make sense) possibly before the fan driver module is loaded.
Unfortunately, that requires the list of fan device IDs to be updated in two places which is prone to mistakes, so put it into a symbol definition in a separate header file so there is only one copy of it in case it needs to be updated again in the future.
--- drivers/acpi/device_pm.c | 6 ++---- drivers/acpi/fan.c | 7 +++---- drivers/acpi/fan.h | 13 +++++++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 drivers/acpi/fan.h
drivers/acpi/device_pm.c +2 -4
@@ -18,6 +18,7 @@#include <linux/pm_runtime.h> #include <linux/suspend.h> +#include "fan.h" #include "internal.h" #define _COMPONENT ACPI_POWER_COMPONENT
@@ -1298,10 +1299,7 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)* with the generic ACPI PM domain. */ static const struct acpi_device_id special_pm_ids[] = { - {"PNP0C0B" , },/* Generic ACPI fan */ - {"INT3404" , },/* Fan */ - {"INTC1044" , },/* Fan for Tiger Lake generation */ - {"INTC1048" , },/* Fan for Alder Lake generation */ +ACPI_FAN_DEVICE_IDS , {} };struct acpi_device *adev =ACPI_COMPANION (dev);
drivers/acpi/fan.c +3 -4
@@ -16,6 +16,8 @@#include <linux/platform_device.h> #include <linux/sort.h> +#include "fan.h" +MODULE_AUTHOR ("Paul Diefenbaugh" );MODULE_DESCRIPTION ("ACPI Fan Driver" );MODULE_LICENSE ("GPL" );
@@ -24,10 +26,7 @@ static int acpi_fan_probe(struct platform_device *pdev);static int acpi_fan_remove (struct platform_device *pdev);static const struct acpi_device_id fan_device_ids[] = { - {"PNP0C0B" ,0 }, - {"INT3404" ,0 }, - {"INTC1044" ,0 }, - {"INTC1048" ,0 }, +ACPI_FAN_DEVICE_IDS , {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, fan_device_ids);
drivers/acpi/fan.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* +* ACPI fan device IDs are shared between the fan driver and the device power +* management code. +* +* Add new device IDs before the generic ACPI fan one. +*/ +#define ACPI_FAN_DEVICE_IDS \ + {"INT3404", },/* Fan */ \ + {"INTC1044", }, /* Fan for Tiger Lake generation */ \ + {"INTC1048", }, /* Fan for Alder Lake generation */ \ + {"PNP0C0B", } /* Generic ACPI fan */
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 276/593 block: avoid double io accounting for flush request
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 84da7acc3ba53af26f15c4b0ada446127b7a7836 ]
For flush request, rq->end_io() may be called two times, one is from timeout handling(blk_mq_check_expired()), another is from normal completion(__blk_mq_end_request()).
Move blk_account_io_flush() after flush_rq->ref drops to zero, so io accounting can be done just once for flush request.
--- block/blk-flush.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-flush.c +1 -2
@@ -220,8 +220,6 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)unsigned long flags =0 ;struct blk_flush_queue *fq =blk_get_flush_queue (q, flush_rq->mq_ctx); -blk_account_io_flush (flush_rq); -/* release the tag's ownership to the req cloned from */ spin_lock_irqsave (&fq->mq_flush_lock, flags);
@@ -231,6 +229,7 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)return ; } +blk_account_io_flush (flush_rq);/* * Flush request has to be marked as IDLE when it is really ended * because its .end_io() is called from timeout code path too for
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 277/593 nvme-pci: look for StorageD3Enable on companion ACPI device instead
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit e21e0243e7b0f1c2a21d21f4d115f7b37175772a ]
The documentation around the StorageD3Enable property hints that it should be made on the PCI device. This is where newer AMD systems set the property and it's required for S0i3 support.
So rather than look for nodes of the root port only present on Intel systems, switch to the companion ACPI device for all systems. David Box from Intel indicated this should work on Intel as well.
--- drivers/nvme/host/pci.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/nvme/host/pci.c +1 -23
@@ -2836,10 +2836,7 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)#ifdef CONFIG_ACPI static bool nvme_acpi_storage_d3 (struct pci_dev *dev) { -struct acpi_device *adev; -struct pci_dev *root; -acpi_handle handle; -acpi_status status; +struct acpi_device *adev =ACPI_COMPANION (&dev->dev);u8 val;/*
@@ -2847,28 +2844,9 @@ static bool nvme_acpi_storage_d3(struct pci_dev *dev)* must use D3 to support deep platform power savings during * suspend-to-idle. */ - root =pcie_find_root_port (dev); -if (!root) -return false; - adev =ACPI_COMPANION (&root->dev);if (!adev)return false; - -/* -* The property is defined in the PXSX device for South complex ports -* and in the PEGP device for North complex ports. -*/ - status =acpi_get_handle (adev->handle,"PXSX" , &handle); -if (ACPI_FAILURE (status)) { - status =acpi_get_handle (adev->handle,"PEGP" , &handle); -if (ACPI_FAILURE (status)) -return false; - } - -if (acpi_bus_get_device (handle, &adev)) -return false; -if (fwnode_property_read_u8 (acpi_fwnode_handle (adev),"StorageD3Enable" , &val))return false;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 278/593 ACPI: sysfs: Fix a buffer overrun problem with description_show()
In reply to Greg Kroah-HartmanFrom: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 888be6067b97132c3992866bbcf647572253ab3f ]
Currently, a device description can be obtained using ACPI, if the _STR method exists for a particular device, and then exposed to the userspace via a sysfs object as a string value.
If the _STR method is available for a given device then the data (usually a Unicode string) is read and stored in a buffer (of the ACPI_TYPE_BUFFER type) with a pointer to said buffer cached in the struct acpi_device_pnp for later access.
The description_show() function is responsible for exposing the device description to the userspace via a corresponding sysfs object and internally calls the utf16s_to_utf8s() function with a pointer to the buffer that contains the Unicode string so that it can be converted from UTF16 encoding to UTF8 and thus allowing for the value to be safely stored and later displayed.
When invoking the utf16s_to_utf8s() function, the description_show() function also sets a limit of the data that can be saved into a provided buffer as a result of the character conversion to be a total of PAGE_SIZE, and upon completion, the utf16s_to_utf8s() function returns an integer value denoting the number of bytes that have been written into the provided buffer.
Following the execution of the utf16s_to_utf8s() a newline character will be added at the end of the resulting buffer so that when the value is read in the userspace through the sysfs object then it would include newline making it more accessible when working with the sysfs file system in the shell, etc. Normally, this wouldn't be a problem, but if the function utf16s_to_utf8s() happens to return the number of bytes written to be precisely PAGE_SIZE, then we would overrun the buffer and write the newline character outside the allotted space which can have undefined consequences or result in a failure.
To fix this buffer overrun, ensure that there always is enough space left for the newline character to be safely appended.
--- drivers/acpi/device_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/device_sysfs.c +1 -1
@@ -446,7 +446,7 @@ static ssize_t description_show(struct device *dev, (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer, acpi_dev->pnp.str_obj->buffer.length,UTF16_LITTLE_ENDIAN , buf, - PAGE_SIZE); + PAGE_SIZE - 1); buf[result++] ='\n' ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 279/593 mark pstore-blk as broken
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit d07f3b081ee632268786601f55e1334d1f68b997 ]
pstore-blk just pokes directly into the pagecache for the block device without going through the file operations for that by faking up it's own file operations that do not match the block device ones.
As this breaks the control of the block layer of it's page cache, and even now just works by accident only the best thing is to just disable this driver.
--- fs/pstore/Kconfig | 1 + 1 file changed, 1 insertion(+)
fs/pstore/Kconfig +1 -0
@@ -165,6 +165,7 @@ config PSTORE_BLK tristate "Log panic/oops to a block device" depends on PSTORE depends on BLOCK + depends on BROKEN select PSTORE_ZONE default n help
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 280/593 clocksource/drivers/timer-ti-dm: Save and restore timer TIOCP_CFG
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 9517c577f9f722270584cfb1a7b4e1354e408658 ]
As we are using cpu_pm to save and restore context, we must also save and restore the timer sysconfig register TIOCP_CFG. This is needed because we are not calling PM runtime functions at all with cpu_pm.
--- drivers/clocksource/timer-ti-dm.c | 6 ++++++ include/clocksource/timer-ti-dm.h | 1 + 2 files changed, 7 insertions(+)
drivers/clocksource/timer-ti-dm.c +6 -0
@@ -78,6 +78,9 @@ static void omap_dm_timer_write_reg(struct omap_dm_timer *timer, u32 reg,static void omap_timer_restore_context (struct omap_dm_timer *timer) { +__omap_dm_timer_write (timer,OMAP_TIMER_OCP_CFG_OFFSET , + timer->context.ocp_cfg,0 ); +omap_dm_timer_write_reg (timer,OMAP_TIMER_WAKEUP_EN_REG , timer->context.twer); omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG,
@@ -95,6 +98,9 @@ static void omap_timer_restore_context(struct omap_dm_timer *timer)static void omap_timer_save_context (struct omap_dm_timer *timer) { + timer->context.ocp_cfg = +__omap_dm_timer_read (timer,OMAP_TIMER_OCP_CFG_OFFSET ,0 ); + timer->context.tclr =omap_dm_timer_read_reg (timer,OMAP_TIMER_CTRL_REG ); timer->context.twer =
include/clocksource/timer-ti-dm.h +1 -0
@@ -74,6 +74,7 @@#define OMAP_TIMER_ERRATA_I103_I767 0x80000000struct timer_regs { +u32 ocp_cfg;u32 tidr;u32 tier;u32 twer;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 281/593 extcon: extcon-max8997: Fix IRQ freeing at error path
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
[ Upstream commit 610bdc04830a864115e6928fc944f1171dfff6f3 ]
If reading MAX8997_MUIC_REG_STATUS1 fails at probe the driver exits without freeing the requested IRQs.
Free the IRQs prior returning if reading the status fails.
--- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max8997.c +1 -1
@@ -729,7 +729,7 @@ static int max8997_muic_probe(struct platform_device *pdev) 2, info->status);if (ret) {dev_err (info->dev,"failed to read MUIC register\n" ); -return ret; + goto err_irq; } cable_type =max8997_muic_get_cable_type (info,MAX8997_CABLE_GROUP_ADC , &attached);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 282/593 ACPI: APEI: fix synchronous external aborts in user-mode
In reply to Greg Kroah-HartmanFrom: Xiaofei Tan <[email protected]>
[ Upstream commit ccb5ecdc2ddeaff744ee075b54cdff8a689e8fa7 ]
Before commit 8fcc4ae6faf8 ("arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work"), do_sea() would unconditionally signal the affected task from the arch code. Since that change, the GHES driver sends the signals.
This exposes a problem as errors the GHES driver doesn't understand or doesn't handle effectively are silently ignored. It will cause the errors get taken again, and circulate endlessly. User-space task get stuck in this loop.
Existing firmware on Kunpeng9xx systems reports cache errors with the 'ARM Processor Error' CPER records.
Do memory failure handling for ARM Processor Error Section just like for Memory Error Section.
--- drivers/acpi/apei/ghes.c | 81 +++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 17 deletions(-)
drivers/acpi/apei/ghes.c +64 -17
@@ -441,28 +441,35 @@ static void ghes_kick_task_work(struct callback_head *head)gen_pool_free (ghes_estatus_pool, (unsigned long )estatus_node, node_len); } -static bool ghes_handle_memory_failure (struct acpi_hest_generic_data *gdata, -int sev) +static bool ghes_do_memory_failure (u64 physical_addr,int flags) {unsigned long pfn; -int flags =-1 ; -int sec_sev =ghes_severity (gdata->error_severity); -struct cper_sec_mem_err *mem_err =acpi_hest_get_payload (gdata);if (!IS_ENABLED (CONFIG_ACPI_APEI_MEMORY_FAILURE ))return false; -if (!(mem_err->validation_bits &CPER_MEM_VALID_PA )) -return false; - - pfn = mem_err->physical_addr >>PAGE_SHIFT ; + pfn =PHYS_PFN (physical_addr);if (!pfn_valid (pfn)) { pr_warn_ratelimited(FW_WARN GHES_PFX"Invalid address in generic error data: %#llx\n" , - mem_err->physical_addr); + physical_addr);return false; } +memory_failure_queue (pfn, flags); +return true; +} + +static bool ghes_handle_memory_failure (struct acpi_hest_generic_data *gdata, +int sev) +{ +int flags =-1 ; +int sec_sev =ghes_severity (gdata->error_severity); +struct cper_sec_mem_err *mem_err =acpi_hest_get_payload (gdata); + +if (!(mem_err->validation_bits &CPER_MEM_VALID_PA )) +return false; +/* iff following two events can be handled properly by now */ if (sec_sev ==GHES_SEV_CORRECTED && (gdata->flags &CPER_SEC_ERROR_THRESHOLD_EXCEEDED ))
@@ -470,14 +477,56 @@ static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,if (sev ==GHES_SEV_RECOVERABLE && sec_sev ==GHES_SEV_RECOVERABLE ) flags =0 ; -if (flags !=-1 ) { -memory_failure_queue (pfn, flags); -return true; - } +if (flags !=-1 ) +return ghes_do_memory_failure (mem_err->physical_addr, flags);return false; } +static bool ghes_handle_arm_hw_error (struct acpi_hest_generic_data *gdata,int sev) +{ +struct cper_sec_proc_arm *err =acpi_hest_get_payload (gdata); +bool queued = false; +int sec_sev, i; +char *p; + +log_arm_hw_error (err); + + sec_sev =ghes_severity (gdata->error_severity); +if (sev !=GHES_SEV_RECOVERABLE || sec_sev !=GHES_SEV_RECOVERABLE ) +return false; + + p = (char *)(err +1 ); +for (i =0 ; i < err->err_info_num; i++) { +struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p; +bool is_cache = (err_info->type ==CPER_ARM_CACHE_ERROR ); +bool has_pa = (err_info->validation_bits &CPER_ARM_INFO_VALID_PHYSICAL_ADDR ); +const char *error_type ="unknown error" ; + +/* +* The field (err_info->error_info & BIT(26)) is fixed to set to +* 1 in some old firmware of HiSilicon Kunpeng920. We assume that +* firmware won't mix corrected errors in an uncorrected section, +* and don't filter out 'corrected' error here. +*/ +if (is_cache && has_pa) { + queued =ghes_do_memory_failure (err_info->physical_fault_addr,0 ); + p += err_info->length; +continue ; + } + +if (err_info->type <ARRAY_SIZE (cper_proc_error_type_strs)) + error_type = cper_proc_error_type_strs[err_info->type]; + + pr_warn_ratelimited(FW_WARN GHES_PFX +"Unhandled processor error type: %s\n" , + error_type); + p += err_info->length; + } + +return queued; +} +/* * PCIe AER errors need to be sent to the AER driver for reporting and * recovery. The GHES severities map to the following AER severities and
@@ -605,9 +654,7 @@ static bool ghes_do_proc(struct ghes *ghes,ghes_handle_aer (gdata); }else if (guid_equal (sec_type, &CPER_SEC_PROC_ARM )) { -struct cper_sec_proc_arm *err =acpi_hest_get_payload (gdata); - -log_arm_hw_error (err); + queued =ghes_handle_arm_hw_error (gdata, sev); }else {void *err =acpi_hest_get_payload (gdata);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 283/593 blk-wbt: introduce a new disable state to prevent false positive by rwb_enabled()
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
[ Upstream commit 1d0903d61e9645c6330b94247b96dd873dfc11c8 ]
Now that we disable wbt by simply zero out rwb->wb_normal in wbt_disable_default() when switch elevator to bfq, but it's not safe because it will become false positive if we change queue depth. If it become false positive between wbt_wait() and wbt_track() when submit write request, it will lead to drop rqw->inflight to -1 in wbt_done(), which will end up trigger IO hung. Fix this issue by introduce a new state which mean the wbt was disabled.
--- block/blk-wbt.c | 5 +++-- block/blk-wbt.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
block/blk-wbt.c +3 -2
@@ -77,7 +77,8 @@ enum {static inline bool rwb_enabled (struct rq_wb *rwb) { -return rwb && rwb->wb_normal !=0 ; +return rwb && rwb->enable_state !=WBT_STATE_OFF_DEFAULT && + rwb->wb_normal !=0 ; }static void wb_timestamp (struct rq_wb *rwb,unsigned long *var)
@@ -702,7 +703,7 @@ void wbt_disable_default(struct request_queue *q) rwb =RQWB (rqos);if (rwb->enable_state ==WBT_STATE_ON_DEFAULT ) {blk_stat_deactivate (rwb->cb); - rwb->wb_normal =0 ; + rwb->enable_state =WBT_STATE_OFF_DEFAULT ; } }EXPORT_SYMBOL_GPL (wbt_disable_default);
block/blk-wbt.h +1 -0
@@ -34,6 +34,7 @@ enum {enum {WBT_STATE_ON_DEFAULT =1 ,WBT_STATE_ON_MANUAL =2 , +WBT_STATE_OFF_DEFAULT };struct rq_wb {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 284/593 blk-wbt: make sure throttle is enabled properly
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
[ Upstream commit 76a8040817b4b9c69b53f9b326987fa891b4082a ]
After commit a79050434b45 ("blk-rq-qos: refactor out common elements of blk-wbt"), if throttle was disabled by wbt_disable_default(), we could not enable again, fix this by set enable_state back to WBT_STATE_ON_DEFAULT.
--- block/blk-wbt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
block/blk-wbt.c +5 -1
@@ -637,9 +637,13 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)void wbt_enable_default (struct request_queue *q) {struct rq_qos *rqos =wbt_rq_qos (q); +/* Throttling already enabled? */ -if (rqos) +if (rqos) { +if (RQWB (rqos)->enable_state ==WBT_STATE_OFF_DEFAULT ) +RQWB (rqos)->enable_state =WBT_STATE_ON_DEFAULT ;return ; + }/* Queue not registered? Maybe shutting down... */ if (!blk_queue_registered (q))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 285/593 ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros
In reply to Greg Kroah-HartmanFrom: Dwaipayan Ray <[email protected]>
[ Upstream commit 0f39ee8324e75c9d370e84a61323ceb194641a18 ]
Instead of open coding DEVICE_ATTR(), use the DEVICE_ATTR_RW(), DEVICE_ATTR_RO() and DEVICE_ATTR_WO() macros wherever possible.
This required a few functions to be renamed but the functionality itself is unchanged.
--- drivers/acpi/acpi_pad.c | 24 ++++++++------------ drivers/acpi/acpi_tad.c | 14 ++++++------ drivers/acpi/bgrt.c | 20 ++++++++--------- drivers/acpi/device_sysfs.c | 44 ++++++++++++++++++------------------- drivers/acpi/dock.c | 26 +++++++++++----------- drivers/acpi/power.c | 9 ++++---- 6 files changed, 66 insertions(+), 71 deletions(-)
drivers/acpi/acpi_pad.c +9 -15
@@ -261,7 +261,7 @@ static uint32_t acpi_pad_idle_cpus_num(void)return ps_tsk_num; } -static ssize_t acpi_pad_rrtime_store (struct device *dev, +static ssize_t rrtime_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {unsigned long num;
@@ -275,16 +275,14 @@ static ssize_t acpi_pad_rrtime_store(struct device *dev,return count; } -static ssize_t acpi_pad_rrtime_show (struct device *dev, +static ssize_t rrtime_show (struct device *dev,struct device_attribute *attr,char *buf) {return scnprintf (buf,PAGE_SIZE ,"%d\n" , round_robin_time); } -static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR, - acpi_pad_rrtime_show, - acpi_pad_rrtime_store); +static DEVICE_ATTR_RW (rrtime); -static ssize_t acpi_pad_idlepct_store (struct device *dev, +static ssize_t idlepct_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {unsigned long num;
@@ -298,16 +296,14 @@ static ssize_t acpi_pad_idlepct_store(struct device *dev,return count; } -static ssize_t acpi_pad_idlepct_show (struct device *dev, +static ssize_t idlepct_show (struct device *dev,struct device_attribute *attr,char *buf) {return scnprintf (buf,PAGE_SIZE ,"%d\n" , idle_pct); } -static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR, - acpi_pad_idlepct_show, - acpi_pad_idlepct_store); +static DEVICE_ATTR_RW (idlepct); -static ssize_t acpi_pad_idlecpus_store (struct device *dev, +static ssize_t idlecpus_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {unsigned long num;
@@ -319,16 +315,14 @@ static ssize_t acpi_pad_idlecpus_store(struct device *dev,return count; } -static ssize_t acpi_pad_idlecpus_show (struct device *dev, +static ssize_t idlecpus_show (struct device *dev,struct device_attribute *attr,char *buf) {return cpumap_print_to_pagebuf (false, buf,to_cpumask (pad_busy_cpus_bits)); } -static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR, - acpi_pad_idlecpus_show, - acpi_pad_idlecpus_store); +static DEVICE_ATTR_RW (idlecpus);static int acpi_pad_add_sysfs (struct acpi_device *device) {
drivers/acpi/acpi_tad.c +7 -7
@@ -237,7 +237,7 @@ static ssize_t time_show(struct device *dev, struct device_attribute *attr, rt.tz, rt.daylight); } -static DEVICE_ATTR(time, S_IRUSR | S_IWUSR, time_show, time_store); +static DEVICE_ATTR_RW (time);static struct attribute *acpi_tad_time_attrs[] = { &dev_attr_time.attr,
@@ -446,7 +446,7 @@ static ssize_t ac_alarm_show(struct device *dev, struct device_attribute *attr,return acpi_tad_alarm_read (dev, buf,ACPI_TAD_AC_TIMER ); } -static DEVICE_ATTR(ac_alarm, S_IRUSR | S_IWUSR, ac_alarm_show, ac_alarm_store); +static DEVICE_ATTR_RW (ac_alarm);static ssize_t ac_policy_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -462,7 +462,7 @@ static ssize_t ac_policy_show(struct device *dev, struct device_attribute *attr,return acpi_tad_policy_read (dev, buf,ACPI_TAD_AC_TIMER ); } -static DEVICE_ATTR(ac_policy, S_IRUSR | S_IWUSR, ac_policy_show, ac_policy_store); +static DEVICE_ATTR_RW (ac_policy);static ssize_t ac_status_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -478,7 +478,7 @@ static ssize_t ac_status_show(struct device *dev, struct device_attribute *attr,return acpi_tad_status_read (dev, buf,ACPI_TAD_AC_TIMER ); } -static DEVICE_ATTR(ac_status, S_IRUSR | S_IWUSR, ac_status_show, ac_status_store); +static DEVICE_ATTR_RW (ac_status);static struct attribute *acpi_tad_attrs[] = { &dev_attr_caps.attr,
@@ -505,7 +505,7 @@ static ssize_t dc_alarm_show(struct device *dev, struct device_attribute *attr,return acpi_tad_alarm_read (dev, buf,ACPI_TAD_DC_TIMER ); } -static DEVICE_ATTR(dc_alarm, S_IRUSR | S_IWUSR, dc_alarm_show, dc_alarm_store); +static DEVICE_ATTR_RW (dc_alarm);static ssize_t dc_policy_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -521,7 +521,7 @@ static ssize_t dc_policy_show(struct device *dev, struct device_attribute *attr,return acpi_tad_policy_read (dev, buf,ACPI_TAD_DC_TIMER ); } -static DEVICE_ATTR(dc_policy, S_IRUSR | S_IWUSR, dc_policy_show, dc_policy_store); +static DEVICE_ATTR_RW (dc_policy);static ssize_t dc_status_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -537,7 +537,7 @@ static ssize_t dc_status_show(struct device *dev, struct device_attribute *attr,return acpi_tad_status_read (dev, buf,ACPI_TAD_DC_TIMER ); } -static DEVICE_ATTR(dc_status, S_IRUSR | S_IWUSR, dc_status_show, dc_status_store); +static DEVICE_ATTR_RW (dc_status);static struct attribute *acpi_tad_dc_attrs[] = { &dev_attr_dc_alarm.attr,
drivers/acpi/bgrt.c +10 -10
@@ -15,40 +15,40 @@static void *bgrt_image;static struct kobject *bgrt_kobj; -static ssize_t show_version (struct device *dev, +static ssize_t version_show (struct device *dev,struct device_attribute *attr,char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , bgrt_tab.version); } -static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); +static DEVICE_ATTR_RO (version); -static ssize_t show_status (struct device *dev, +static ssize_t status_show (struct device *dev,struct device_attribute *attr,char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , bgrt_tab.status); } -static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); +static DEVICE_ATTR_RO (status); -static ssize_t show_type (struct device *dev, +static ssize_t type_show (struct device *dev,struct device_attribute *attr,char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , bgrt_tab.image_type); } -static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); +static DEVICE_ATTR_RO (type); -static ssize_t show_xoffset (struct device *dev, +static ssize_t xoffset_show (struct device *dev,struct device_attribute *attr,char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , bgrt_tab.image_offset_x); } -static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL); +static DEVICE_ATTR_RO (xoffset); -static ssize_t show_yoffset (struct device *dev, +static ssize_t yoffset_show (struct device *dev,struct device_attribute *attr,char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , bgrt_tab.image_offset_y); } -static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); +static DEVICE_ATTR_RO (yoffset);static ssize_t image_read (struct file *file,struct kobject *kobj,struct bin_attribute *attr,char *buf,loff_t off,size_t count)
drivers/acpi/device_sysfs.c +22 -22
111 lines not on this page · raw message
drivers/acpi/dock.c +13 -13
@@ -484,7 +484,7 @@ int dock_notify(struct acpi_device *adev, u32 event)/* * show_docked - read method for "docked" file in sysfs */ -static ssize_t show_docked (struct device *dev, +static ssize_t docked_show (struct device *dev,struct device_attribute *attr,char *buf) {struct dock_station *dock_station = dev->platform_data;
@@ -493,25 +493,25 @@ static ssize_t show_docked(struct device *dev,acpi_bus_get_device (dock_station->handle, &adev);return snprintf (buf,PAGE_SIZE ,"%u\n" ,acpi_device_enumerated (adev)); } -static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); +static DEVICE_ATTR_RO (docked);/* * show_flags - read method for flags file in sysfs */ -static ssize_t show_flags (struct device *dev, +static ssize_t flags_show (struct device *dev,struct device_attribute *attr,char *buf) {struct dock_station *dock_station = dev->platform_data;return snprintf (buf,PAGE_SIZE ,"%d\n" , dock_station->flags); } -static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); +static DEVICE_ATTR_RO (flags);/* * write_undock - write method for "undock" file in sysfs */ -static ssize_t write_undock (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t undock_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int ret;struct dock_station *dock_station = dev->platform_data;
@@ -525,13 +525,13 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,acpi_scan_lock_release ();return ret ? ret: count; } -static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); +static DEVICE_ATTR_WO (undock);/* * show_dock_uid - read method for "uid" file in sysfs */ -static ssize_t show_dock_uid (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t uid_show (struct device *dev, +struct device_attribute *attr,char *buf) {unsigned long long lbuf;struct dock_station *dock_station = dev->platform_data;
@@ -542,10 +542,10 @@ static ssize_t show_dock_uid(struct device *dev,return snprintf (buf,PAGE_SIZE ,"%llx\n" , lbuf); } -static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); +static DEVICE_ATTR_RO (uid); -static ssize_t show_dock_type (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t type_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct dock_station *dock_station = dev->platform_data;char *type;
@@ -561,7 +561,7 @@ static ssize_t show_dock_type(struct device *dev,return snprintf (buf,PAGE_SIZE ,"%s\n" , type); } -static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL); +static DEVICE_ATTR_RO (type);static struct attribute *dock_attributes[] = { &dev_attr_docked.attr,
drivers/acpi/power.c +5 -4
@@ -886,15 +886,16 @@ static void acpi_release_power_resource(struct device *dev)kfree (resource); } -static ssize_t acpi_power_in_use_show (struct device *dev, -struct device_attribute *attr, -char *buf) { +static ssize_t resource_in_use_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{struct acpi_power_resource *resource; resource =to_power_resource (to_acpi_device (dev));return sprintf (buf,"%u\n" , !!resource->ref_count); } -static DEVICE_ATTR(resource_in_use, 0444, acpi_power_in_use_show, NULL); +static DEVICE_ATTR_RO (resource_in_use);static void acpi_power_sysfs_remove (struct acpi_device *device) {
Signature · 1 line
2.30.2