5.6.5-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1/254 media: rc: add keymap for Videostrong KII Pro
In reply to Greg Kroah-HartmanFrom: Mohammad Rasim <[email protected]>
[ Upstream commit 30defecb98400575349a7d32f0526e1dc42ea83e ]
This is an NEC remote control device shipped with the Videostrong KII Pro tv box as well as other devices from videostrong.
--- drivers/media/rc/keymaps/Makefile | 1 + .../media/rc/keymaps/rc-videostrong-kii-pro.c | 83 +++++++++++++++++++ include/media/rc-map.h | 1 + 3 files changed, 85 insertions(+) create mode 100644 drivers/media/rc/keymaps/rc-videostrong-kii-pro.c
drivers/media/rc/keymaps/Makefile +1 -0
@@ -119,6 +119,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-videomate-m1f.o \ rc-videomate-s350.o \ rc-videomate-tv-pvr.o \ + rc-videostrong-kii-pro.o \ rc-wetek-hub.o \ rc-wetek-play2.o \ rc-winfast.o \
drivers/media/rc/keymaps/rc-videostrong-kii-pro.c new file +83 -0
83 lines not on this page · raw message
include/media/rc-map.h +1 -0
@@ -274,6 +274,7 @@ struct rc_map *rc_map_get(const char *name);#define RC_MAP_VIDEOMATE_K100 "rc-videomate-k100"#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350"#define RC_MAP_VIDEOMATE_TV_PVR "rc-videomate-tv-pvr" +#define RC_MAP_KII_PRO "rc-videostrong-kii-pro"#define RC_MAP_WETEK_HUB "rc-wetek-hub"#define RC_MAP_WETEK_PLAY2 "rc-wetek-play2"#define RC_MAP_WINFAST "rc-winfast"
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 3/254 EDAC/mc: Report "unknown memory" on too many DIMM labels found
In reply to Greg Kroah-HartmanFrom: Robert Richter <[email protected]>
[ Upstream commit 65bb4d1af92cf007adc0a0c59dadcc393c5cada6 ]
There is a limitation to report only EDAC_MAX_LABELS in e->label of the error descriptor. This is to prevent a potential string overflow.
The current implementation falls back to "any memory" in this case and also stops all further processing to find a unique row and channel of the possible error location.
Reporting "any memory" is wrong as the memory controller reported an error location for one of the layers. Instead, report "unknown memory" and also do not break early in the loop to further check row and channel for uniqueness.
[ bp: Massage commit message. ]
--- drivers/edac/edac_mc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/edac/edac_mc.c +11 -10
@@ -1180,20 +1180,21 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,* channel/memory controller/... may be affected. * Also, don't show errors for empty DIMM slots. */ -if (!e->enable_per_layer_report || !dimm->nr_pages) +if (!dimm->nr_pages)continue ; -if (n_labels >=EDAC_MAX_LABELS ) { - e->enable_per_layer_report = false; -break ; - } n_labels++; -if (p != e->label) { -strcpy (p,OTHER_LABEL ); - p +=strlen (OTHER_LABEL ); +if (n_labels >EDAC_MAX_LABELS ) { + p = e->label; + *p ='\0' ; + }else { +if (p != e->label) { +strcpy (p,OTHER_LABEL ); + p +=strlen (OTHER_LABEL ); + } +strcpy (p, dimm->label); + p +=strlen (p); } -strcpy (p, dimm->label); - p +=strlen (p);/* * get csrow/channel of the DIMM, in order to allow
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 4/254 usb: ucsi: ccg: disable runtime pm during fw flashing
In reply to Greg Kroah-HartmanFrom: Ajay Gupta <[email protected]>
[ Upstream commit 57a5e5f936be583d2c6cef3661c169e3ea4bf922 ]
Ucsi ppm is unregistered during fw flashing so disable runtime pm also and reenable after fw flashing is completed and ppm is re-registered.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +2 -0
@@ -1219,6 +1219,7 @@ static int ccg_restart(struct ucsi_ccg *uc)return status; } +pm_runtime_enable (uc->dev);return 0 ; }
@@ -1234,6 +1235,7 @@ static void ccg_update_firmware(struct work_struct *work)if (flash_mode !=FLASH_NOT_NEEDED ) {ucsi_unregister (uc->ucsi); +pm_runtime_disable (uc->dev);free_irq (uc->irq, uc);ccg_fw_update (uc, flash_mode);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 20/254 null_blk: Suppress an UBSAN complaint triggered when setting memory_backed
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit b9853b4d6fb403ccb1d4d82e2d39fc17fc07519c ]
Although it is not clear to me why UBSAN complains when 'memory_backed' is set, this patch suppresses the UBSAN complaint that is triggered when setting that configfs attribute.
UBSAN: Undefined behaviour in drivers/block/null_blk_main.c:327:1 load of value 16 is not a valid value for type '_Bool' CPU: 2 PID: 8396 Comm: check Not tainted 5.6.0-rc1-dbg+ #14 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: dump_stack+0xa5/0xe6 ubsan_epilogue+0x9/0x26 __ubsan_handle_load_invalid_value+0x6d/0x76 nullb_device_memory_backed_store.cold+0x2c/0x38 [null_blk] configfs_write_file+0x1c4/0x250 [configfs] __vfs_write+0x4c/0x90 vfs_write+0x145/0x2c0 ksys_write+0xd7/0x180 __x64_sys_write+0x47/0x50 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/block/null_blk_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk_main.c +1 -1
@@ -276,7 +276,7 @@ nullb_device_##NAME##_store(struct config_item *item, const char *page, \ { \int (*apply_fn)(struct nullb_device *dev,TYPE new_value) =APPLY ;\struct nullb_device *dev =to_nullb_device (item); \ -TYPE uninitialized_var (new_value ); \ +TYPE new_value =0 ; \int ret; \ \ ret = nullb_device_##TYPE##_attr_store(&new_value, page, count);\
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 21/254 null_blk: fix spurious IO errors after failed past-wp access
In reply to Greg Kroah-HartmanFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit ff77042296d0a54535ddf74412c5ae92cb4ec76a ]
Steps to reproduce:
BLKRESETZONE zone 0 // force EIO pwrite(fd, buf, 4096, 4096); [issue more IO including zone ioctls]
It will start failing randomly including IO to unrelated zones because of ->error "reuse". Trigger can be partition detection as well if test is not run immediately which is even more entertaining.
The fix is of course to clear ->error where necessary.
--- drivers/block/null_blk_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/null_blk_main.c +2 -0
@@ -605,6 +605,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)if (tag !=-1U ) { cmd = &nq->cmds[tag]; cmd->tag = tag; + cmd->error =BLK_STS_OK ; cmd->nq = nq;if (nq->dev->irqmode ==NULL_IRQ_TIMER ) { hrtimer_init(&cmd->timer, CLOCK_MONOTONIC,
@@ -1385,6 +1386,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, cmd->timer.function = null_cmd_timer_expired; } cmd->rq = bd->rq; + cmd->error =BLK_STS_OK ; cmd->nq = nq;blk_mq_start_request (bd->rq);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 19/254 null_blk: Handle null_add_dev() failures properly
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit 9b03b713082a31a5b90e0a893c72aa620e255c26 ]
If null_add_dev() fails then null_del_dev() is called with a NULL argument. Make null_del_dev() handle this scenario correctly. This patch fixes the following KASAN complaint:
null-ptr-deref in null_del_dev+0x28/0x280 [null_blk]
Read of size 8 at addr 0000000000000000 by task find/1062 Call Trace: dump_stack+0xa5/0xe6 __kasan_report.cold+0x65/0x99 kasan_report+0x16/0x20 __asan_load8+0x58/0x90 null_del_dev+0x28/0x280 [null_blk] nullb_group_drop_item+0x7e/0xa0 [null_blk] client_drop_item+0x53/0x80 [configfs] configfs_rmdir+0x395/0x4e0 [configfs] vfs_rmdir+0xb6/0x220 do_rmdir+0x238/0x2c0 __x64_sys_unlinkat+0x75/0x90 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/block/null_blk_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/block/null_blk_main.c +6 -1
@@ -1432,7 +1432,12 @@ static void cleanup_queues(struct nullb *nullb)static void null_del_dev (struct nullb *nullb) { -struct nullb_device *dev = nullb->dev; +struct nullb_device *dev; + +if (!nullb) +return ; + + dev = nullb->dev;ida_simple_remove (&nullb_indexes, nullb->index);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 25/254 ACPI: EC: Do not clear boot_ec_is_ecdt in acpi_ec_add()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 65a691f5f8f0bb63d6a82eec7b0ffd193d8d8a5f ]
The reason for clearing boot_ec_is_ecdt in acpi_ec_add() (if a PNP0C09 device object matching the ECDT boot EC had been found in the namespace) was to cause acpi_ec_ecdt_start() to return early, but since the latter does not look at boot_ec_is_ecdt any more, acpi_ec_add() need not clear it.
Moreover, doing that may be confusing as it may cause "DSDT" to be printed instead of "ECDT" in the EC initialization completion message, so stop doing it.
While at it, split the EC initialization completion message into two messages, one regarding the boot EC and another one printed regardless of whether or not the EC at hand is the boot one.
--- drivers/acpi/ec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/ec.c +4 -2
@@ -1641,7 +1641,6 @@ 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) { - boot_ec_is_ecdt = false;/* * Trust PNP0C09 namespace location rather than * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1661,9 +1660,12 @@ static int acpi_ec_add(struct acpi_device *device)if (ec == boot_ec)acpi_handle_info (boot_ec->handle, -"Boot %s EC used to handle transactions and events\n" , +"Boot %s EC initialization complete\n" , boot_ec_is_ecdt ?"ECDT" :"DSDT" ); +acpi_handle_info (ec->handle, +"EC: Used to handle transactions and events\n" ); + device->driver_data = ec; ret = !!request_region (ec->data_addr,1 ,"EC data" );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 10/254 media: venus: hfi_parser: Ignore HEVC encoding for V1
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit c50cc6dc6c48300af63a6fbc71b647053c15fc80 ]
Some older MSM8916 Venus firmware versions also seem to indicate support for encoding HEVC, even though they really can't. This will lead to errors later because hfi_session_init() fails in this case.
HEVC is already ignored for "dec_codecs", so add the same for "enc_codecs" to make these old firmware versions work correctly.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/venus/hfi_parser.c +1 -0
@@ -181,6 +181,7 @@ static void parse_codecs(struct venus_core *core, void *data)if (IS_V1 (core)) { core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC ; core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK ; + core->enc_codecs &= ~HFI_VIDEO_CODEC_HEVC ; } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 28/254 dma-mapping: Fix dma_pgprot() for unencrypted coherent pages
In reply to Greg Kroah-HartmanFrom: Thomas Hellstrom <[email protected]>
[ Upstream commit 17c4a2ae15a7aaefe84bdb271952678c5c9cd8e1 ]
When dma_mmap_coherent() sets up a mapping to unencrypted coherent memory under SEV encryption and sometimes under SME encryption, it will actually set up an encrypted mapping rather than an unencrypted, causing devices that DMAs from that memory to read encrypted contents. Fix this.
When force_dma_unencrypted() returns true, the linear kernel map of the coherent pages have had the encryption bit explicitly cleared and the page content is unencrypted. Make sure that any additional PTEs we set up to these pages also have the encryption bit cleared by having dma_pgprot() return a protection with the encryption bit cleared in this case.
--- kernel/dma/mapping.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/dma/mapping.c +2 -0
@@ -154,6 +154,8 @@ EXPORT_SYMBOL(dma_get_sgtable_attrs);*/ pgprot_t dma_pgprot (struct device *dev,pgprot_t prot,unsigned long attrs) { +if (force_dma_unencrypted (dev)) + prot =pgprot_decrypted (prot);if (dev_is_dma_coherent (dev) || (IS_ENABLED (CONFIG_DMA_NONCOHERENT_CACHE_SYNC ) && (attrs &DMA_ATTR_NON_CONSISTENT )))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 30/254 debugfs: Check module state before warning in {full/open}_proxy_open()
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 275678e7a9be6a0ea9c1bb493e48abf2f4a01be5 ]
When the module is being removed, the module state is set to MODULE_STATE_GOING. At this point, try_module_get() fails. And when {full/open}_proxy_open() is being called,
it calls try_module_get() to try to hold module reference count. If it fails, it warns about the possibility of debugfs file leak.
If {full/open}_proxy_open() is called while the module is being removed, it fails to hold the module.
So, It warns about debugfs file leak. But it is not the debugfs file leak case. So, this patch just adds module state checking routine in the {full/open}_proxy_open().
Test commands:
#SHELL1
while :
do
modprobe netdevsim
echo 1 > /sys/bus/netdevsim/new_device
modprobe -rv netdevsim
done
#SHELL2
while :
do
cat /sys/kernel/debug/netdevsim/netdevsim1/ports/0/ipsec
done
Splat looks like:
[ 298.766738][T14664] debugfs file owner did not clean up at exit: ipsec [ 298.766766][T14664] WARNING: CPU: 2 PID: 14664 at fs/debugfs/file.c:312 full_proxy_open+0x10f/0x650 [ 298.768595][T14664] Modules linked in: netdevsim(-) openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 n][ 298.771343][T14664] CPU: 2 PID: 14664 Comm: cat Tainted: G W 5.5.0+ #1 [ 298.772373][T14664] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 298.773545][T14664] RIP: 0010:full_proxy_open+0x10f/0x650 [ 298.774247][T14664] Code: 48 c1 ea 03 80 3c 02 00 0f 85 c1 04 00 00 49 8b 3c 24 e8 e4 b5 78 ff 84 c0 75 2d 4c 89 ee 48 [ 298.776782][T14664] RSP: 0018:ffff88805b7df9b8 EFLAGS: 00010282[ 298.777583][T14664] RAX: dffffc0000000008 RBX: ffff8880511725c0 RCX: 0000000000000000 [ 298.778610][T14664] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffff8880540c5c14 [ 298.779637][T14664] RBP: 0000000000000000 R08: fffffbfff15235ad R09: 0000000000000000 [ 298.780664][T14664] R10: 0000000000000001 R11: 0000000000000000 R12: ffffffffc06b5000 [ 298.781702][T14664] R13: ffff88804c234a88 R14: ffff88804c22dd00 R15: ffffffff8a1b5660 [ 298.782722][T14664] FS: 00007fafa13a8540(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000 [ 298.783845][T14664] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 298.784672][T14664] CR2: 00007fafa0e9cd10 CR3: 000000004b286005 CR4: 00000000000606e0 [ 298.785739][T14664] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 298.786769][T14664] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 298.787785][T14664] Call Trace: [ 298.788237][T14664] do_dentry_open+0x63c/0xf50 [ 298.788872][T14664] ? open_proxy_open+0x270/0x270 [ 298.789524][T14664] ? __x64_sys_fchdir+0x180/0x180 [ 298.790169][T14664] ? inode_permission+0x65/0x390 [ 298.790832][T14664] path_openat+0xc45/0x2680 [ 298.791425][T14664] ? save_stack+0x69/0x80 [ 298.791988][T14664] ? save_stack+0x19/0x80 [ 298.792544][T14664] ? path_mountpoint+0x2e0/0x2e0 [ 298.793233][T14664] ? check_chain_key+0x236/0x5d0 [ 298.793910][T14664] ? sched_clock_cpu+0x18/0x170 [ 298.794527][T14664] ? find_held_lock+0x39/0x1d0 [ 298.795153][T14664] do_filp_open+0x16a/0x260
[ ... ]
--- fs/debugfs/file.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/debugfs/file.c +14 -4
@@ -175,8 +175,13 @@ static int open_proxy_open(struct inode *inode, struct file *filp)if (r) goto out; - real_fops =fops_get (real_fops); -if (!real_fops) { +if (!fops_get (real_fops)) { +#ifdef MODULE +if (real_fops->owner && + real_fops->owner->state ==MODULE_STATE_GOING ) + goto out; +#endif +/* Huh? Module did not clean up after itself at exit? */ WARN (1 ,"debugfs file owner did not clean up at exit: %pd" , dentry);
@@ -305,8 +310,13 @@ static int full_proxy_open(struct inode *inode, struct file *filp)if (r) goto out; - real_fops =fops_get (real_fops); -if (!real_fops) { +if (!fops_get (real_fops)) { +#ifdef MODULE +if (real_fops->owner && + real_fops->owner->state ==MODULE_STATE_GOING ) + goto out; +#endif +/* Huh? Module did not cleanup after itself at exit? */ WARN (1 ,"debugfs file owner did not clean up at exit: %pd" , dentry);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 33/254 time/sched_clock: Expire timer in hardirq context
In reply to Greg Kroah-HartmanFrom: Ahmed S. Darwish <[email protected]>
[ Upstream commit 2c8bd58812ee3dbf0d78b566822f7eacd34bdd7b ]
To minimize latency, PREEMPT_RT kernels expires hrtimers in preemptible softirq context by default. This can be overriden by marking the timer's expiry with HRTIMER_MODE_HARD.
sched_clock_timer is missing this annotation: if its callback is preempted and the duration of the preemption exceeds the wrap around time of the underlying clocksource, sched clock will get out of sync.
Mark the sched_clock_timer for expiry in hard interrupt context.
--- kernel/time/sched_clock.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/time/sched_clock.c +5 -4
@@ -208,7 +208,8 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)if (sched_clock_timer.function !=NULL ) {/* update timeout for clock wrap */ -hrtimer_start (&sched_clock_timer, cd.wrap_kt,HRTIMER_MODE_REL ); +hrtimer_start (&sched_clock_timer, cd.wrap_kt, +HRTIMER_MODE_REL_HARD ); } r = rate;
@@ -254,9 +255,9 @@ void __init generic_sched_clock_init(void)* Start the timer to keep sched_clock() properly updated and * sets the initial epoch. */ -hrtimer_init (&sched_clock_timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); +hrtimer_init (&sched_clock_timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_HARD ); sched_clock_timer.function = sched_clock_poll; -hrtimer_start (&sched_clock_timer, cd.wrap_kt,HRTIMER_MODE_REL ); +hrtimer_start (&sched_clock_timer, cd.wrap_kt,HRTIMER_MODE_REL_HARD ); }/*
@@ -293,7 +294,7 @@ void sched_clock_resume(void)struct clock_read_data *rd = &cd.read_data[0 ]; rd->epoch_cyc = cd.actual_read_sched_clock (); -hrtimer_start (&sched_clock_timer, cd.wrap_kt,HRTIMER_MODE_REL ); +hrtimer_start (&sched_clock_timer, cd.wrap_kt,HRTIMER_MODE_REL_HARD ); rd->read_sched_clock = cd.actual_read_sched_clock; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 34/254 irqchip/gic-v4.1: Skip absent CPUs while iterating over redistributors
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 28d160de5194c68ff534443d2a8b6f1d10d57c58 ]
In a system that is only sparsly populated with CPUs, we can end-up with redistributors structures that are not initialized. Let's make sure we don't try and access those when iterating over them (in this case when checking we have a L2 VPE table).
--- drivers/irqchip/irq-gic-v3-its.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +4 -0
@@ -2452,6 +2452,10 @@ static bool allocate_vpe_l2_table(int cpu, u32 id)if (!gic_rdists->has_rvpeid)return true; +/* Skip non-present CPUs */ +if (!base) +return true; + val =gicr_read_vpropbaser (base +SZ_128K +GICR_VPROPBASER ); esz =FIELD_GET (GICR_VPROPBASER_4_1_ENTRY_SIZE , val) +1 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 11/254 firmware: arm_sdei: fix double-lock on hibernate with shared events
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
[ Upstream commit 6ded0b61cf638bf9f8efe60ab8ba23db60ea9763 ]
SDEI has private events that must be registered on each CPU. When CPUs come and go they must re-register and re-enable their private events. Each event has flags to indicate whether this should happen to protect against an event being registered on a CPU coming online, while all the others are unregistering the event.
These flags are protected by the sdei_list_lock spinlock, because the cpuhp callbacks can't take the mutex.
Hibernate needs to unregister all events, but keep the in-memory re-register and re-enable as they are. sdei_unregister_shared() takes the spinlock to walk the list, then calls _sdei_event_unregister() on each shared event. _sdei_event_unregister() tries to take the same spinlock to update re-register and re-enable. This doesn't go so well.
Push the re-register and re-enable updates out to their callers. sdei_unregister_shared() doesn't want these values updated, so doesn't need to do anything.
This also fixes shared events getting lost over hibernate as this path made them look unregistered.
--- drivers/firmware/arm_sdei.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/firmware/arm_sdei.c +15 -17
@@ -491,11 +491,6 @@ static int _sdei_event_unregister(struct sdei_event *event) {lockdep_assert_held (&sdei_events_lock); -spin_lock (&sdei_list_lock); - event->reregister = false; - event->reenable = false; -spin_unlock (&sdei_list_lock); -if (event->type ==SDEI_EVENT_TYPE_SHARED )return sdei_api_event_unregister (event->event_num);
@@ -518,6 +513,11 @@ int sdei_event_unregister(u32 event_num)break ; } +spin_lock (&sdei_list_lock); + event->reregister = false; + event->reenable = false; +spin_unlock (&sdei_list_lock); + err =_sdei_event_unregister (event);if (err)break ;
@@ -585,26 +585,15 @@ static int _sdei_event_register(struct sdei_event *event)lockdep_assert_held (&sdei_events_lock); -spin_lock (&sdei_list_lock); - event->reregister = true; -spin_unlock (&sdei_list_lock); -if (event->type ==SDEI_EVENT_TYPE_SHARED )return sdei_api_event_register (event->event_num, sdei_entry_point, event->registered,SDEI_EVENT_REGISTER_RM_ANY ,0 ); - err =sdei_do_cross_call (_local_event_register, event); -if (err) { -spin_lock (&sdei_list_lock); - event->reregister = false; - event->reenable = false; -spin_unlock (&sdei_list_lock); - +if (err)sdei_do_cross_call (_local_event_unregister, event); - }return err; }
@@ -632,8 +621,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)break ; } +spin_lock (&sdei_list_lock); + event->reregister = true; +spin_unlock (&sdei_list_lock); + err =_sdei_event_register (event);if (err) { +spin_lock (&sdei_list_lock); + event->reregister = false; + event->reenable = false; +spin_unlock (&sdei_list_lock); +sdei_event_destroy (event);pr_warn ("Failed to register event %u: %d\n" , event_num, err);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 39/254 PCI/switchtec: Fix init_completion race condition with poll_wait()
In reply to Greg Kroah-HartmanFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit efbdc769601f4d50018bf7ca50fc9f7c67392ece ]
The call to init_completion() in mrpc_queue_cmd() can theoretically race with the call to poll_wait() in switchtec_dev_poll().
poll() write()
switchtec_dev_poll() switchtec_dev_write()
poll_wait(&s->comp.wait); mrpc_queue_cmd()
init_completion(&s->comp)
init_waitqueue_head(&s->comp.wait)To my knowledge, no one has hit this bug.
Fix this by using reinit_completion() instead of init_completion() in mrpc_queue_cmd().
--- drivers/pci/switch/switchtec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/switch/switchtec.c +1 -1
@@ -175,7 +175,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)kref_get (&stuser->kref); stuser->read_len =sizeof (stuser->data);stuser_set_state (stuser,MRPC_QUEUED ); -init_completion (&stuser->comp); +reinit_completion (&stuser->comp);list_add_tail (&stuser->list, &stdev->mrpc_queue);mrpc_cmd_submit (stdev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 41/254 media: i2c: video-i2c: fix build errors due to imply hwmon
In reply to Greg Kroah-HartmanFrom: Matt Ranostay <[email protected]>
[ Upstream commit 64d4fc9926f09861a35d8f0f7d81f056e6d5af7b ]
Fix build fault when CONFIG_HWMON is a module, and CONFIG_VIDEO_I2C as builtin. This is due to 'imply hwmon' in the respective Kconfig.
Issue build log:
ld: drivers/media/i2c/video-i2c.o: in function `amg88xx_hwmon_init':
video-i2c.c:(.text+0x2e1): undefined reference to `devm_hwmon_device_register_with_info
--- drivers/media/i2c/video-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/video-i2c.c +1 -1
@@ -255,7 +255,7 @@ static int amg88xx_set_power(struct video_i2c_data *data, bool on)return amg88xx_set_power_off (data); } -#if IS_ENABLED (CONFIG_HWMON ) +#if IS_REACHABLE (CONFIG_HWMON )static const u32 amg88xx_temp_config[] = { HWMON_T_INPUT,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 12/254 media: arm64: dts: amlogic: add rc-videostrong-kii-pro keymap
In reply to Greg Kroah-HartmanFrom: Mohammad Rasim <[email protected]>
[ Upstream commit 806d06161af045dba29f3c7747550c93b2ea3ca9 ]
videostrong kii pro comes with a nec rc, add the keymap to the dts
--- arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts +4 -0
@@ -76,3 +76,7 @@ }; }; }; + +&ir { + linux,rc-map-name = "rc-videostrong-kii-pro"; +};
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 48/254 efi/x86: Ignore the memory attributes table on i386
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit dd09fad9d2caad2325a39b766ce9e79cfc690184 ]
Commit:
3a6b6c6fb23667fa ("efi: Make EFI_MEMORY_ATTRIBUTES_TABLE initialization common across all architectures")
moved the call to efi_memattr_init() from ARM specific to the generic EFI init code, in order to be able to apply the restricted permissions described in that table on x86 as well.
We never enabled this feature fully on i386, and so mapping and reserving this table is pointless. However, due to the early call to memblock_reserve(), the memory bookkeeping gets confused to the point where it produces the splat below when we try to map the memory later on:
------------[ cut here ]------------ ioremap on RAM at 0x3f251000 - 0x3fa1afff WARNING: CPU: 0 PID: 0 at arch/x86/mm/ioremap.c:166 __ioremap_caller ... Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.20.0 #48 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 EIP: __ioremap_caller.constprop.0+0x249/0x260 Code: 90 0f b7 05 4e 38 40 de 09 45 e0 e9 09 ff ff ff 90 8d 45 ec c6 05 ... EAX: 00000029 EBX: 00000000 ECX: de59c228 EDX: 00000001 ESI: 3f250fff EDI: 00000000 EBP: de3edf20 ESP: de3edee0 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00200296 CR0: 80050033 CR2: ffd17000 CR3: 1e58c000 CR4: 00040690 Call Trace: ioremap_cache+0xd/0x10 ? old_map_region+0x72/0x9d old_map_region+0x72/0x9d efi_map_region+0x8/0xa efi_enter_virtual_mode+0x260/0x43b start_kernel+0x329/0x3aa i386_start_kernel+0xa7/0xab startup_32_smp+0x164/0x168 ---[ end trace e15ccf6b9f356833 ]---
Let's work around this by disregarding the memory attributes table altogether on i386, which does not result in a loss of functionality or protection, given that we never consumed the contents.
--- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/efi.c +1 -1
@@ -570,7 +570,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, } } -if (efi_enabled (EFI_MEMMAP )) +if (!IS_ENABLED (CONFIG_X86_32 ) &&efi_enabled (EFI_MEMMAP ))efi_memattr_init ();efi_tpm_eventlog_init ();
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 14/254 arm64/mm: Hold memory hotplug lock while walking for kernel page table dump
In reply to Greg Kroah-HartmanFrom: Anshuman Khandual <[email protected]>
[ Upstream commit bf2b59f60ee1fefa768d62ec6e8f4b4d9e04c691 ]
The arm64 page table dump code can race with concurrent modification of the kernel page tables. When a leaf entries are modified concurrently, the dump code may log stale or inconsistent information for a VA range, but this is otherwise not harmful.
When intermediate levels of table are freed, the dump code will continue to use memory which has been freed and potentially reallocated for another purpose. In such cases, the dump code may dereference bogus addresses, leading to a number of potential problems.
Intermediate levels of table may by freed during memory hot-remove, which will be enabled by a subsequent patch. To avoid racing with this, take the memory hotplug lock when walking the kernel page table.
--- arch/arm64/mm/ptdump_debugfs.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/mm/ptdump_debugfs.c +4 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/debugfs.h> +#include <linux/memory_hotplug.h> #include <linux/seq_file.h> #include <asm/ptdump.h>
@@ -7,7 +8,10 @@static int ptdump_show (struct seq_file *m,void *v) {struct ptdump_info *info = m->private; + +get_online_mems ();ptdump_walk (m, info); +put_online_mems ();return 0 ; }DEFINE_SHOW_ATTRIBUTE (ptdump);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 15/254 sched/vtime: Prevent unstable evaluation of WARN(vtime->state)
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
[ Upstream commit f1dfdab694eb3838ac26f4b73695929c07d92a33 ]
As the vtime is sampled under loose seqcount protection by kcpustat, the vtime fields may change as the code flows. Where logic dictates a field has a static value, use a READ_ONCE.
--- kernel/sched/cputime.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-)
kernel/sched/cputime.c +22 -19
@@ -909,8 +909,10 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime) }while (read_seqcount_retry (&vtime->seqcount, seq)); } -static int vtime_state_check (struct vtime *vtime,int cpu) +static int vtime_state_fetch (struct vtime *vtime,int cpu) { +int state =READ_ONCE (vtime->state); +/* * We raced against a context switch, fetch the * kcpustat task again.
@@ -927,10 +929,10 @@ static int vtime_state_check(struct vtime *vtime, int cpu)* * Case 1) is ok but 2) is not. So wait for a safe VTIME state. */ -if (vtime->state ==VTIME_INACTIVE ) +if (state ==VTIME_INACTIVE )return -EAGAIN ; -return 0 ; +return state; }static u64 kcpustat_user_vtime (struct vtime *vtime)
@@ -949,14 +951,15 @@ static int kcpustat_field_vtime(u64 *cpustat, {struct vtime *vtime = &tsk->vtime;unsigned int seq; -int err; do { + int state; + seq = read_seqcount_begin(&vtime->seqcount); - err = vtime_state_check(vtime, cpu); - if (err < 0) - return err; + state = vtime_state_fetch(vtime, cpu); + if (state < 0) + return state; *val = cpustat[usage];
@@ -969,7 +972,7 @@ static int kcpustat_field_vtime(u64 *cpustat,*/ switch (usage) {case CPUTIME_SYSTEM : -if (vtime->state ==VTIME_SYS ) +if (state ==VTIME_SYS ) *val += vtime->stime +vtime_delta (vtime);break ;case CPUTIME_USER :
@@ -981,11 +984,11 @@ static int kcpustat_field_vtime(u64 *cpustat, *val +=kcpustat_user_vtime (vtime);break ;case CPUTIME_GUEST : -if (vtime->state ==VTIME_GUEST &&task_nice (tsk) <=0 ) +if (state ==VTIME_GUEST &&task_nice (tsk) <=0 ) *val += vtime->gtime +vtime_delta (vtime);break ;case CPUTIME_GUEST_NICE : -if (vtime->state ==VTIME_GUEST &&task_nice (tsk) >0 ) +if (state ==VTIME_GUEST &&task_nice (tsk) >0 ) *val += vtime->gtime +vtime_delta (vtime);break ;default :
@@ -1036,23 +1039,23 @@ static int kcpustat_cpu_fetch_vtime(struct kernel_cpustat *dst, {struct vtime *vtime = &tsk->vtime;unsigned int seq; -int err; do { u64 *cpustat; u64 delta; + int state; seq = read_seqcount_begin(&vtime->seqcount); - err = vtime_state_check(vtime, cpu); - if (err < 0) - return err; + state = vtime_state_fetch(vtime, cpu); + if (state < 0) + return state; *dst = *src; cpustat = dst->cpustat; /* Task is sleeping, dead or idle, nothing to add */ - if (vtime->state < VTIME_SYS) + if (state < VTIME_SYS) continue; delta = vtime_delta(vtime);
@@ -1061,15 +1064,15 @@ static int kcpustat_cpu_fetch_vtime(struct kernel_cpustat *dst,* Task runs either in user (including guest) or kernel space, * add pending nohz time to the right place. */ -if (vtime->state ==VTIME_SYS ) { +if (state ==VTIME_SYS ) { cpustat[CPUTIME_SYSTEM ] += vtime->stime + delta; - }else if (vtime->state ==VTIME_USER ) { + }else if (state ==VTIME_USER ) {if (task_nice (tsk) >0 ) cpustat[CPUTIME_NICE ] += vtime->utime + delta;else cpustat[CPUTIME_USER ] += vtime->utime + delta; }else { -WARN_ON_ONCE (vtime->state !=VTIME_GUEST ); +WARN_ON_ONCE (state !=VTIME_GUEST );if (task_nice (tsk) >0 ) { cpustat[CPUTIME_GUEST_NICE ] += vtime->gtime + delta; cpustat[CPUTIME_NICE ] += vtime->gtime + delta;
@@ -1080,7 +1083,7 @@ static int kcpustat_cpu_fetch_vtime(struct kernel_cpustat *dst, } }while (read_seqcount_retry (&vtime->seqcount, seq)); -return err; +return 0 ; }void kcpustat_cpu_fetch (struct kernel_cpustat *dst,int cpu)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 17/254 null_blk: Fix the null_add_dev() error path
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit 2004bfdef945fe55196db6b9cdf321fbc75bb0de ]
If null_add_dev() fails, clear dev->nullb.
This patch fixes the following KASAN complaint:
BUG: KASAN: use-after-free in nullb_device_submit_queues_store+0xcf/0x160 [null_blk] Read of size 8 at addr ffff88803280fc30 by task check/8409 Call Trace: dump_stack+0xa5/0xe6 print_address_description.constprop.0+0x26/0x260 __kasan_report.cold+0x7b/0x99 kasan_report+0x16/0x20 __asan_load8+0x58/0x90 nullb_device_submit_queues_store+0xcf/0x160 [null_blk] configfs_write_file+0x1c4/0x250 [configfs] __vfs_write+0x4c/0x90 vfs_write+0x145/0x2c0 ksys_write+0xd7/0x180 __x64_sys_write+0x47/0x50 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7ff370926317 Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 RSP: 002b:00007fff2dd2da48 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007ff370926317 RDX: 0000000000000002 RSI: 0000559437ef23f0 RDI: 0000000000000001 RBP: 0000559437ef23f0 R08: 000000000000000a R09: 0000000000000001 R10: 0000559436703471 R11: 0000000000000246 R12: 0000000000000002 R13: 00007ff370a006a0 R14: 00007ff370a014a0 R15: 00007ff370a008a0 Allocated by task 8409: save_stack+0x23/0x90 __kasan_kmalloc.constprop.0+0xcf/0xe0 kasan_kmalloc+0xd/0x10 kmem_cache_alloc_node_trace+0x129/0x4c0 null_add_dev+0x24a/0xe90 [null_blk] nullb_device_power_store+0x1b6/0x270 [null_blk] configfs_write_file+0x1c4/0x250 [configfs] __vfs_write+0x4c/0x90 vfs_write+0x145/0x2c0 ksys_write+0xd7/0x180 __x64_sys_write+0x47/0x50 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 8409: save_stack+0x23/0x90 __kasan_slab_free+0x112/0x160 kasan_slab_free+0x12/0x20 kfree+0xdf/0x250 null_add_dev+0xaf3/0xe90 [null_blk] nullb_device_power_store+0x1b6/0x270 [null_blk] configfs_write_file+0x1c4/0x250 [configfs] __vfs_write+0x4c/0x90 vfs_write+0x145/0x2c0 ksys_write+0xd7/0x180 __x64_sys_write+0x47/0x50 do_syscall_64+0x6f/0x2f0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/block/null_blk_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/null_blk_main.c +1 -0
@@ -1788,6 +1788,7 @@ out_cleanup_queues:cleanup_queues (nullb); out_free_nullb:kfree (nullb); + dev->nullb =NULL ; out:return rv; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 62/254 btrfs: qgroup: ensure qgroup_rescan_running is only set when the worker is at least queued
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit d61acbbf54c612ea9bf67eed609494cda0857b3a ]
[BUG]
There are some reports about btrfs wait forever to unmount itself, with the following call trace:
INFO: task umount:4631 blocked for more than 491 seconds.
Tainted: G X 5.3.8-2-default #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
umount D 0 4631 3337 0x00000000
Call Trace:
([<00000000174adf7a>] __schedule+0x342/0x748)
[<00000000174ae3ca>] schedule+0x4a/0xd8
[<00000000174b1f08>] schedule_timeout+0x218/0x420
[<00000000174af10c>] wait_for_common+0x104/0x1d8
[<000003ff804d6994>] btrfs_qgroup_wait_for_completion+0x84/0xb0 [btrfs]
[<000003ff8044a616>] close_ctree+0x4e/0x380 [btrfs]
[<0000000016fa3136>] generic_shutdown_super+0x8e/0x158
[<0000000016fa34d6>] kill_anon_super+0x26/0x40
[<000003ff8041ba88>] btrfs_kill_super+0x28/0xc8 [btrfs]
[<0000000016fa39f8>] deactivate_locked_super+0x68/0x98
[<0000000016fcb198>] cleanup_mnt+0xc0/0x140
[<0000000016d6a846>] task_work_run+0xc6/0x110
[<0000000016d04f76>] do_notify_resume+0xae/0xb8
[<00000000174b30ae>] system_call+0xe2/0x2c8[CAUSE]
The problem happens when we have called qgroup_rescan_init(), but not queued the worker. It can be caused mostly by error handling.
Qgroup ioctl thread | Unmount thread
----------------------------------------+-----------------------------------
| btrfs_qgroup_rescan() | |- qgroup_rescan_init() | | |- qgroup_rescan_running = true; | | | |- trans = btrfs_join_transaction() | | Some error happened | | | |- btrfs_qgroup_rescan() returns error | But qgroup_rescan_running == true; | | close_ctree() | |- btrfs_qgroup_wait_for_completion() | |- running == true; | |- wait_for_completion();
btrfs_qgroup_rescan_worker is never queued, thus no one is going to wake up close_ctree() and we get a deadlock.
All involved qgroup_rescan_init() callers are:
- btrfs_qgroup_rescan()
The example above. It's possible to trigger the deadlock when error happened.
- btrfs_quota_enable()
Not possible. Just after qgroup_rescan_init() we queue the work.
- btrfs_read_qgroup_config()
It's possible to trigger the deadlock. It only init the work, the work queueing happens in btrfs_qgroup_rescan_resume(). Thus if error happened in between, deadlock is possible.
We shouldn't set fs_info->qgroup_rescan_running just in qgroup_rescan_init(), as at that stage we haven't yet queued qgroup rescan worker to run.
[FIX]
Set qgroup_rescan_running before queueing the work, so that we ensure the rescan work is queued when we wait for it.
--- fs/btrfs/qgroup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +9 -2
@@ -1030,6 +1030,7 @@ out_add_root: ret =qgroup_rescan_init (fs_info,0 ,1 );if (!ret) {qgroup_rescan_zero_tracking (fs_info); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); }
@@ -3263,7 +3264,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, sizeof(fs_info->qgroup_rescan_progress)); fs_info->qgroup_rescan_progress.objectid = progress_objectid;init_completion (&fs_info->qgroup_rescan_completion); - fs_info->qgroup_rescan_running = true;spin_unlock (&fs_info->qgroup_lock);mutex_unlock (&fs_info->qgroup_rescan_lock);
@@ -3326,8 +3326,11 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info)qgroup_rescan_zero_tracking (fs_info); +mutex_lock (&fs_info->qgroup_rescan_lock); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); +mutex_unlock (&fs_info->qgroup_rescan_lock);return 0 ; }
@@ -3363,9 +3366,13 @@ int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,void btrfs_qgroup_rescan_resume (struct btrfs_fs_info *fs_info) { -if (fs_info->qgroup_flags &BTRFS_QGROUP_STATUS_FLAG_RESCAN ) +if (fs_info->qgroup_flags &BTRFS_QGROUP_STATUS_FLAG_RESCAN ) { +mutex_lock (&fs_info->qgroup_rescan_lock); + fs_info->qgroup_rescan_running = true;btrfs_queue_work (fs_info->qgroup_rescan_workers, &fs_info->qgroup_rescan_work); +mutex_unlock (&fs_info->qgroup_rescan_lock); + } }/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 63/254 btrfs: remove a BUG_ON() from merge_reloc_roots()
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 7b7b74315b24dc064bc1c683659061c3d48f8668 ]
This was pretty subtle, we default to reloc roots having 0 root refs, so if we crash in the middle of the relocation they can just be deleted. If we successfully complete the relocation operations we'll set our root refs to 1 in prepare_to_merge() and then go on to merge_reloc_roots().
At prepare_to_merge() time if any of the reloc roots have a 0 reference still, we will remove that reloc root from our reloc root rb tree, and then clean it up later.
However this only happens if we successfully start a transaction. If we've aborted previously we will skip this step completely, and only have reloc roots with a reference count of 0, but were never properly removed from the reloc control's rb tree.
This isn't a problem per-se, our references are held by the list the reloc roots are on, and by the original root the reloc root belongs to. If we end up in this situation all the reloc roots will be added to the dirty_reloc_list, and then properly dropped at that point. The reloc control will be free'd and the rb tree is no longer used.
There were two options when fixing this, one was to remove the BUG_ON(), the other was to make prepare_to_merge() handle the case where we couldn't start a trans handle.
IMO this is the cleaner solution. I started with handling the error in prepare_to_merge(), but it turned out super ugly. And in the end this BUG_ON() simply doesn't matter, the cleanup was happening properly, we were just panicing because this BUG_ON() only matters in the success case. So I've opted to just remove it and add a comment where it was.
--- fs/btrfs/relocation.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
fs/btrfs/relocation.c +15 -1
@@ -2561,7 +2561,21 @@ out:free_reloc_roots (&reloc_roots); } -BUG_ON (!RB_EMPTY_ROOT (&rc->reloc_root_tree.rb_root)); +/* +* We used to have +* +* BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root)); +* +* here, but it's wrong. If we fail to start the transaction in +* prepare_to_merge() we will have only 0 ref reloc roots, none of which +* have actually been removed from the reloc_root_tree rb tree. This is +* fine because we're bailing here, and we hold a reference on the root +* for the list that holds it, so these roots will be cleaned up when we +* do the reloc_dirty_list afterwards. Meanwhile the root->reloc_root +* will be cleaned up on unmount. +* +* The remaining nodes will be cleaned up by free_reloc_control. +*/ }static void free_block_list (struct rb_root *blocks)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 67/254 ASoC: dapm: connect virtual mux with default value
In reply to Greg Kroah-HartmanFrom: 이경택 <[email protected]>
commit 3bbbb7728fc853d71dbce4073fef9f281fbfb4dd upstream.
Since a virtual mixer has no backing registers
to decide which path to connect,
it will try to match with initial state.
This is to ensure that the default mixer choice will be correctly powered up during initialization.
Invert flag is used to select initial state of the virtual switch. Since actual hardware can't be disconnected by virtual switch, connected is better choice as initial state in many cases.
--- sound/soc/soc-dapm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +7 -1
@@ -802,7 +802,13 @@ static void dapm_set_mixer_path_status(s val = max - val; p->connect = !!val; }else { - p->connect =0 ; +/* since a virtual mixer has no backing registers to +* decide which path to connect, it will try to match +* with initial state. This is to ensure +* that the default mixer choice will be +* correctly powered up during initialization. +*/ + p->connect = invert; } }
Greg Kroah-Hartman
maintainerPATCH 72/254 ALSA: usb-audio: Add mixer workaround for TRX40 and co
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 2a48218f8e23d47bd3e23cfdfb8aa9066f7dc3e6 upstream.
Some recent boards (supposedly with a new AMD platform) contain the USB audio class 2 device that is often tied with HD-audio. The device exposes an Input Gain Pad control (id=19, control=12) but this node doesn't behave correctly, returning an error for each inquiry of GET_MIN and GET_MAX that should have been mandatory.
As a workaround, simply ignore this node by adding a usbmix_name_map table entry. The currently known devices are:
* 0414:a002 - Gigabyte TRX40 Aorus Pro WiFi
* 0b05:1916 - ASUS ROG Zenith II
* 0b05:1917 - ASUS ROG Strix
* 0db0:0d64 - MSI TRX40 Creator
* 0db0:543d - MSI TRX40
--- sound/usb/mixer_maps.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
sound/usb/mixer_maps.c +28 -0
@@ -359,6 +359,14 @@ static const struct usbmix_name_map cors { 0 } }; +/* Some mobos shipped with a dummy HD-audio show the invalid GET_MIN/GET_MAX +* response for Input Gain Pad (id=19, control=12). Skip it. +*/ +static const struct usbmix_name_map asus_rog_map[] = { + {19 ,NULL ,12 },/* FU, Input Gain Pad */ + {} +}; +/* * Control map entries */
@@ -488,6 +496,26 @@ static const struct usbmix_ctl_map usbmi .id = USB_ID(0x1b1c, 0x0a42), .map = corsair_virtuoso_map, }, + { /* Gigabyte TRX40 Aorus Pro WiFi */ + .id = USB_ID(0x0414, 0xa002), + .map = asus_rog_map, + }, + { /* ASUS ROG Zenith II */ + .id = USB_ID(0x0b05, 0x1916), + .map = asus_rog_map, + }, + { /* ASUS ROG Strix */ + .id = USB_ID(0x0b05, 0x1917), + .map = asus_rog_map, + }, + { /* MSI TRX40 Creator */ + .id = USB_ID(0x0db0, 0x0d64), + .map = asus_rog_map, + }, + { /* MSI TRX40 */ + .id = USB_ID(0x0db0, 0x543d), + .map = asus_rog_map, + }, { 0 } /* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 77/254 ALSA: hda/realtek: Enable mute LED on an HP system
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit f5a88b0accc24c4a9021247d7a3124f90aa4c586 upstream.
The system in question uses ALC285, and it uses GPIO 0x04 to control its mute LED.
The mic mute LED can be controlled by GPIO 0x01, however the system uses DMIC so we should use that to control mic mute LED.
--- sound/pci/hda/patch_realtek.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/pci/hda/patch_realtek.c +12 -0
@@ -4008,6 +4008,12 @@ static void alc269_fixup_hp_gpio_led(stralc_fixup_hp_gpio_led (codec, action,0x08 ,0x10 ); } +static void alc285_fixup_hp_gpio_led (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +alc_fixup_hp_gpio_led (codec, action,0x04 ,0x00 ); +} +static void alc286_fixup_hp_gpio_led (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
@@ -5923,6 +5929,7 @@ enum {ALC294_FIXUP_ASUS_DUAL_SPK ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ,ALC294_FIXUP_ASUS_HPE , + ALC285_FIXUP_HP_GPIO_LED, }; static const struct hda_fixup alc269_fixups[] = {
@@ -7061,6 +7068,10 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC294_FIXUP_ASUS_HEADSET_MIC }, + [ALC285_FIXUP_HP_GPIO_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc285_fixup_hp_gpio_led, + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7208,6 +7219,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x83b9 ,"HP Spectre x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x8497 ,"HP Envy x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x84e7 ,"HP Pavilion 15" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ), +SND_PCI_QUIRK (0x103c ,0x8736 ,"HP" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Greg Kroah-Hartman
maintainerPATCH 78/254 ALSA: hda/realtek - a fake key event is triggered by running shutup
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 476c02e0b4fd9071d158f6a1a1dfea1d36ee0ffd upstream.
On the Lenovo X1C7 machines, after we plug the headset, the rt_resume() and rt_suspend() of the codec driver will be called periodically, the driver can't stay in the rt_suspend state even users doen't use the sound card.
Through debugging, I found when running rt_suspend(), it will call alc225_shutup(), in this function, it will change 3k pull down control by alc_update_coef_idx(codec, 0x4a, 0, 3 << 10), this will trigger a fake key event and that event will resume the codec, when codec suspend agin, it will trigger the fake key event one more time, this process will repeat.
If disable the key event before changing the pull down control, it will not trigger fake key event. It also needs to restore the pull down control and re-enable the key event, otherwise the system can't get key event when codec is in rt_suspend state.
Also move some functions ahead of alc225_shutup(), this can save the function declaration.
--- sound/pci/hda/patch_realtek.c | 170 ++++++++++++++++++++++++++---------------- 1 file changed, 107 insertions(+), 63 deletions(-)
sound/pci/hda/patch_realtek.c +107 -63
@@ -107,6 +107,7 @@ struct alc_spec { unsigned int done_hp_init:1; unsigned int no_shutup_pins:1; unsigned int ultra_low_power:1; + unsigned int has_hs_key:1;/* for PLL fix */ hda_nid_t pll_nid;
@@ -2982,6 +2983,107 @@ static int alc269_parse_auto_config(strureturn alc_parse_auto_config (codec, alc269_ignore, ssids); } +static const struct hda_jack_keymap alc_headset_btn_keymap[] = { + {SND_JACK_BTN_0 ,KEY_PLAYPAUSE }, + {SND_JACK_BTN_1 ,KEY_VOICECOMMAND }, + {SND_JACK_BTN_2 ,KEY_VOLUMEUP }, + {SND_JACK_BTN_3 ,KEY_VOLUMEDOWN }, + {} +}; + +static void alc_headset_btn_callback (struct hda_codec *codec, +struct hda_jack_callback *jack) +{ +int report =0 ; + +if (jack->unsol_res & (7 <<13 )) + report |=SND_JACK_BTN_0 ; + +if (jack->unsol_res & (1 <<16 |3 <<8 )) + report |=SND_JACK_BTN_1 ; + +/* Volume up key */ +if (jack->unsol_res & (7 <<23 )) + report |=SND_JACK_BTN_2 ; + +/* Volume down key */ +if (jack->unsol_res & (7 <<10 )) + report |=SND_JACK_BTN_3 ; + + jack->jack->button_state = report; +} + +static void alc_disable_headset_jack_key (struct hda_codec *codec) +{ +struct alc_spec *spec = codec->spec; + +if (!spec->has_hs_key) +return ; + +switch (codec->core.vendor_id) { +case 0x10ec0215 : +case 0x10ec0225 : +case 0x10ec0285 : +case 0x10ec0295 : +case 0x10ec0289 : +case 0x10ec0299 : +alc_write_coef_idx (codec,0x48 ,0x0 ); +alc_update_coef_idx (codec,0x49 ,0x0045 ,0x0 ); +alc_update_coef_idx (codec,0x44 ,0x0045 <<8 ,0x0 ); +break ; +case 0x10ec0236 : +case 0x10ec0256 : +alc_write_coef_idx (codec,0x48 ,0x0 ); +alc_update_coef_idx (codec,0x49 ,0x0045 ,0x0 ); +break ; + } +} + +static void alc_enable_headset_jack_key (struct hda_codec *codec) +{ +struct alc_spec *spec = codec->spec; + +if (!spec->has_hs_key) +return ; + +switch (codec->core.vendor_id) { +case 0x10ec0215 : +case 0x10ec0225 : +case 0x10ec0285 : +case 0x10ec0295 : +case 0x10ec0289 : +case 0x10ec0299 : +alc_write_coef_idx (codec,0x48 ,0xd011 ); +alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); +alc_update_coef_idx (codec,0x44 ,0x007f <<8 ,0x0045 <<8 ); +break ; +case 0x10ec0236 : +case 0x10ec0256 : +alc_write_coef_idx (codec,0x48 ,0xd011 ); +alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); +break ; + } +} + +static void alc_fixup_headset_jack (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + spec->has_hs_key =1 ; +snd_hda_jack_detect_enable_callback (codec,0x55 , + alc_headset_btn_callback); +snd_hda_jack_add_kctl (codec,0x55 ,"Headset Jack" , false, +SND_JACK_HEADSET , alc_headset_btn_keymap); +break ; +case HDA_FIXUP_ACT_INIT : +alc_enable_headset_jack_key (codec); +break ; + } +} +static void alc269vb_toggle_power_output (struct hda_codec *codec,int power_up) {alc_update_coef_idx (codec,0x04 ,1 <<11 , power_up ? (1 <<11 ) :0 );
@@ -3372,6 +3474,8 @@ static void alc225_shutup(struct hda_codif (!hp_pin) hp_pin =0x21 ; + +alc_disable_headset_jack_key (codec);/* 3k pull low control for Headset jack. */ alc_update_coef_idx (codec,0x4a ,0 ,3 <<10 );
@@ -3411,6 +3515,9 @@ static void alc225_shutup(struct hda_codalc_update_coef_idx (codec,0x4a ,3 <<4 ,2 <<4 );msleep (30 ); } + +alc_update_coef_idx (codec,0x4a ,3 <<10 ,0 ); +alc_enable_headset_jack_key (codec); }static void alc_default_init (struct hda_codec *codec)
@@ -5668,69 +5775,6 @@ static void alc285_fixup_invalidate_dacssnd_hda_override_wcaps (codec,0x03 ,0 ); } -static const struct hda_jack_keymap alc_headset_btn_keymap[] = { - {SND_JACK_BTN_0 ,KEY_PLAYPAUSE }, - {SND_JACK_BTN_1 ,KEY_VOICECOMMAND }, - {SND_JACK_BTN_2 ,KEY_VOLUMEUP }, - {SND_JACK_BTN_3 ,KEY_VOLUMEDOWN }, - {} -}; - -static void alc_headset_btn_callback (struct hda_codec *codec, -struct hda_jack_callback *jack) -{ -int report =0 ; - -if (jack->unsol_res & (7 <<13 )) - report |=SND_JACK_BTN_0 ; - -if (jack->unsol_res & (1 <<16 |3 <<8 )) - report |=SND_JACK_BTN_1 ; - -/* Volume up key */ -if (jack->unsol_res & (7 <<23 )) - report |=SND_JACK_BTN_2 ; - -/* Volume down key */ -if (jack->unsol_res & (7 <<10 )) - report |=SND_JACK_BTN_3 ; - - jack->jack->button_state = report; -} - -static void alc_fixup_headset_jack (struct hda_codec *codec, -const struct hda_fixup *fix,int action) -{ - -switch (action) { -case HDA_FIXUP_ACT_PRE_PROBE : -snd_hda_jack_detect_enable_callback (codec,0x55 , - alc_headset_btn_callback); -snd_hda_jack_add_kctl (codec,0x55 ,"Headset Jack" , false, -SND_JACK_HEADSET , alc_headset_btn_keymap); -break ; -case HDA_FIXUP_ACT_INIT : -switch (codec->core.vendor_id) { -case 0x10ec0215 : -case 0x10ec0225 : -case 0x10ec0285 : -case 0x10ec0295 : -case 0x10ec0289 : -case 0x10ec0299 : -alc_write_coef_idx (codec,0x48 ,0xd011 ); -alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); -alc_update_coef_idx (codec,0x44 ,0x007f <<8 ,0x0045 <<8 ); -break ; -case 0x10ec0236 : -case 0x10ec0256 : -alc_write_coef_idx (codec,0x48 ,0xd011 ); -alc_update_coef_idx (codec,0x49 ,0x007f ,0x0045 ); -break ; - } -break ; - } -} -static void alc295_fixup_chromebook (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
Greg Kroah-Hartman
maintainerPATCH 83/254 ALSA: hda/realtek - Add quirk for MSI GL63
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 1d3aa4a5516d2e4933fe3cca11d3349ef63bc547 upstream.
MSI GL63 laptop requires the similar quirk like other MSI models, ALC1220_FIXUP_CLEVO_P950. The board BIOS doesn't provide a PCI SSID for the device, hence we need to take the codec SSID (1462:1275) instead.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -2447,6 +2447,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x1458 ,0xa0b8 ,"Gigabyte AZ370-Gaming" ,ALC1220_FIXUP_GB_DUAL_CODECS ),SND_PCI_QUIRK (0x1458 ,0xa0cd ,"Gigabyte X570 Aorus Master" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1228 ,"MSI-GP63" ,ALC1220_FIXUP_CLEVO_P950 ), +SND_PCI_QUIRK (0x1462 ,0x1275 ,"MSI-GL63" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1276 ,"MSI-GL73" ,ALC1220_FIXUP_CLEVO_P950 ),SND_PCI_QUIRK (0x1462 ,0x1293 ,"MSI-GP65" ,ALC1220_FIXUP_CLEVO_P950 ), SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Greg Kroah-Hartman
maintainerPATCH 82/254 ALSA: hda/realtek - Add quirk for Lenovo Carbon X1 8th gen
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit ca707b3f00b4f31a6e1eb37e8ae99f15f2bb1fe5 upstream.
The audio setup on the Lenovo Carbon X1 8th gen is the same as that on the Lenovo Carbon X1 7th gen, as such it needs the same ALC285_FIXUP_THINKPAD_HEADSET_JACK quirk.
This fixes volume control of the speaker not working among other things.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -7325,6 +7325,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x17aa ,0x225d ,"Thinkpad T480" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x2292 ,"Thinkpad X1 Yoga 7th" ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ),SND_PCI_QUIRK (0x17aa ,0x2293 ,"Thinkpad X1 Carbon 7th" ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ), +SND_PCI_QUIRK (0x17aa ,0x22be ,"Thinkpad X1 Carbon 8th" ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ),SND_PCI_QUIRK (0x17aa ,0x30bb ,"ThinkCentre AIO" ,ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY ),SND_PCI_QUIRK (0x17aa ,0x30e2 ,"ThinkCentre AIO" ,ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY ), SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
Greg Kroah-Hartman
maintainerPATCH 85/254 media: venus: firmware: Ignore secure call error on first resume
In reply to Greg Kroah-HartmanFrom: Stanimir Varbanov <[email protected]>
commit 2632e7b618a7730969f9782593c29ca53553aa22 upstream.
With the latest cleanup in qcom scm driver the secure monitor call for setting the remote processor state returns EINVAL when it is called for the first time and after another scm call auth_and_reset. The error returned from scm call could be ignored because the state transition is already done in auth_and_reset.
--- drivers/media/platform/qcom/venus/firmware.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/firmware.c +8 -2
@@ -44,8 +44,14 @@ static void venus_reset_cpu(struct venusint venus_set_hw_state (struct venus_core *core,bool resume) { -if (core->use_tz) -return qcom_scm_set_remote_state (resume,0 ); +int ret; + +if (core->use_tz) { + ret =qcom_scm_set_remote_state (resume,0 ); +if (resume && ret == -EINVAL ) + ret =0 ; +return ret; + }if (resume)venus_reset_cpu (core);
Greg Kroah-Hartman
maintainerPATCH 89/254 seccomp: Add missing compat_ioctl for notify
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 3db81afd99494a33f1c3839103f0429c8f30cb9d upstream.
Executing the seccomp_bpf testsuite under a 64-bit kernel with 32-bit userland (both s390 and x86) doesn't work because there's no compat_ioctl handler defined. Add the handler.
--- kernel/seccomp.c | 1 + 1 file changed, 1 insertion(+)
kernel/seccomp.c +1 -0
@@ -1221,6 +1221,7 @@ static const struct file_operations secc .poll = seccomp_notify_poll, .release = seccomp_notify_release, .unlocked_ioctl = seccomp_notify_ioctl, + .compat_ioctl = seccomp_notify_ioctl, };static struct file *init_listener (struct seccomp_filter *filter)
Greg Kroah-Hartman
maintainerPATCH 93/254 ACPI: PM: s2idle: Refine active GPEs check
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit d5406284ff803a578ca503373624312770319054 upstream.
The check for any active GPEs added by commit fdde0ff8590b ("ACPI:
PM: s2idle: Prevent spurious SCIs from waking up the system") turns out to be insufficiently precise to prevent some systems from resuming prematurely due to a spurious EC wakeup, so refine it by first checking if any GPEs other than the EC GPE are active and skipping all of the SCIs coming from the EC that do not produce any genuine wakeup events after processing.
--- drivers/acpi/ec.c | 5 +++++ drivers/acpi/internal.h | 1 + drivers/acpi/sleep.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-)
drivers/acpi/ec.c +5 -0
@@ -2044,6 +2044,11 @@ void acpi_ec_set_gpe_wake_mask(u8 actionacpi_set_gpe_wake_mask (NULL , first_ec->gpe, action); } +bool acpi_ec_other_gpes_active (void ) +{ +return acpi_any_gpe_status_set (first_ec ? first_ec->gpe :U32_MAX ); +} +bool acpi_ec_dispatch_gpe (void ) {u32 ret;
drivers/acpi/internal.h +1 -0
@@ -202,6 +202,7 @@ void acpi_ec_remove_query_handler(struct#ifdef CONFIG_PM_SLEEP void acpi_ec_flush_work (void ); +bool acpi_ec_other_gpes_active (void );bool acpi_ec_dispatch_gpe (void );#endif
drivers/acpi/sleep.c +10 -9
@@ -1017,19 +1017,20 @@ static bool acpi_s2idle_wake(void)return true;/* -* If there are no EC events to process and at least one of the -* other enabled GPEs is active, the wakeup is regarded as a -* genuine one. -* -* Note that the checks below must be carried out in this order -* to avoid returning prematurely due to a change of the EC GPE -* status bit from unset to set between the checks with the -* status bits of all the other GPEs unset. +* If the status bit is set for any enabled GPE other than the +* EC one, the wakeup is regarded as a genuine one. */ -if (acpi_any_gpe_status_set (U32_MAX ) && !acpi_ec_dispatch_gpe ()) +if (acpi_ec_other_gpes_active ())return true;/* +* If the EC GPE status bit has not been set, the wakeup is +* regarded as a spurious one. +*/ +if (!acpi_ec_dispatch_gpe ()) +return false; + +/* * Cancel the wakeup and process all pending events in case * there are any wakeup ones in there. *
Greg Kroah-Hartman
maintainerPATCH 94/254 thermal: int340x_thermal: fix: Update Tiger Lake ACPI device IDs
In reply to Greg Kroah-HartmanFrom: Gayatri Kammela <[email protected]>
commit 26d8bec1e97ba218b7d82afadca1c049eb75f773 upstream.
Tiger Lake's new unique ACPI device IDs for Intel thermal driver are not valid because of missing 'C' in the IDs. Fix the IDs by updating them.
After the update, the new IDs should now look like INT1040 --> INTC1040
INT1043 --> INTC1043
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3403_thermal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1 -1
@@ -369,8 +369,8 @@ static int int3400_thermal_remove(struct }static const struct acpi_device_id int3400_thermal_match[] = { - {"INT1040" ,0 }, {"INT3400" ,0 }, + {"INTC1040" ,0 }, {} };
drivers/thermal/intel/int340x_thermal/int3403_thermal.c +1 -1
@@ -282,8 +282,8 @@ static int int3403_remove(struct platfor }static const struct acpi_device_id int3403_device_ids[] = { - {"INT1043" ,0 }, {"INT3403" ,0 }, + {"INTC1043" ,0 }, {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, int3403_device_ids);
Greg Kroah-Hartman
maintainerPATCH 61/254 block, bfq: fix use-after-free in bfq_idle_slice_timer_body
In reply to Greg Kroah-HartmanFrom: Zhiqiang Liu <[email protected]>
[ Upstream commit 2f95fa5c955d0a9987ffdc3a095e2f4e62c5f2a9 ]
In bfq_idle_slice_timer func, bfqq = bfqd->in_service_queue is not in bfqd-lock critical section. The bfqq, which is not equal to NULL in bfq_idle_slice_timer, may be freed after passing to bfq_idle_slice_timer_body. So we will access the freed memory.
In addition, considering the bfqq may be in race, we should firstly check whether bfqq is in service before doing something on it in bfq_idle_slice_timer_body func. If the bfqq in race is not in service, it means the bfqq has been expired through __bfq_bfqq_expire func, and wait_request flags has been cleared in __bfq_bfqd_reset_in_service func. So we do not need to re-clear the wait_request of bfqq which is not in service.
KASAN log is given as follows:
[13058.354613] ================================================================== [13058.354640] BUG: KASAN: use-after-free in bfq_idle_slice_timer+0xac/0x290 [13058.354644] Read of size 8 at addr ffffa02cf3e63f78 by task fork13/19767 [13058.354646] [13058.354655] CPU: 96 PID: 19767 Comm: fork13 [13058.354661] Call trace: [13058.354667] dump_backtrace+0x0/0x310 [13058.354672] show_stack+0x28/0x38 [13058.354681] dump_stack+0xd8/0x108 [13058.354687] print_address_description+0x68/0x2d0 [13058.354690] kasan_report+0x124/0x2e0 [13058.354697] __asan_load8+0x88/0xb0 [13058.354702] bfq_idle_slice_timer+0xac/0x290 [13058.354707] __hrtimer_run_queues+0x298/0x8b8 [13058.354710] hrtimer_interrupt+0x1b8/0x678 [13058.354716] arch_timer_handler_phys+0x4c/0x78 [13058.354722] handle_percpu_devid_irq+0xf0/0x558 [13058.354731] generic_handle_irq+0x50/0x70 [13058.354735] __handle_domain_irq+0x94/0x110 [13058.354739] gic_handle_irq+0x8c/0x1b0 [13058.354742] el1_irq+0xb8/0x140 [13058.354748] do_wp_page+0x260/0xe28 [13058.354752] __handle_mm_fault+0x8ec/0x9b0 [13058.354756] handle_mm_fault+0x280/0x460 [13058.354762] do_page_fault+0x3ec/0x890 [13058.354765] do_mem_abort+0xc0/0x1b0 [13058.354768] el0_da+0x24/0x28 [13058.354770] [13058.354773] Allocated by task 19731: [13058.354780] kasan_kmalloc+0xe0/0x190 [13058.354784] kasan_slab_alloc+0x14/0x20 [13058.354788] kmem_cache_alloc_node+0x130/0x440 [13058.354793] bfq_get_queue+0x138/0x858 [13058.354797] bfq_get_bfqq_handle_split+0xd4/0x328 [13058.354801] bfq_init_rq+0x1f4/0x1180 [13058.354806] bfq_insert_requests+0x264/0x1c98 [13058.354811] blk_mq_sched_insert_requests+0x1c4/0x488 [13058.354818] blk_mq_flush_plug_list+0x2d4/0x6e0 [13058.354826] blk_flush_plug_list+0x230/0x548 [13058.354830] blk_finish_plug+0x60/0x80 [13058.354838] read_pages+0xec/0x2c0 [13058.354842] __do_page_cache_readahead+0x374/0x438 [13058.354846] ondemand_readahead+0x24c/0x6b0 [13058.354851] page_cache_sync_readahead+0x17c/0x2f8 [13058.354858] generic_file_buffered_read+0x588/0xc58 [13058.354862] generic_file_read_iter+0x1b4/0x278 [13058.354965] ext4_file_read_iter+0xa8/0x1d8 [ext4] [13058.354972] __vfs_read+0x238/0x320 [13058.354976] vfs_read+0xbc/0x1c0 [13058.354980] ksys_read+0xdc/0x1b8 [13058.354984] __arm64_sys_read+0x50/0x60 [13058.354990] el0_svc_common+0xb4/0x1d8 [13058.354994] el0_svc_handler+0x50/0xa8 [13058.354998] el0_svc+0x8/0xc [13058.354999] [13058.355001] Freed by task 19731: [13058.355007] __kasan_slab_free+0x120/0x228 [13058.355010] kasan_slab_free+0x10/0x18 [13058.355014] kmem_cache_free+0x288/0x3f0 [13058.355018] bfq_put_queue+0x134/0x208 [13058.355022] bfq_exit_icq_bfqq+0x164/0x348 [13058.355026] bfq_exit_icq+0x28/0x40 [13058.355030] ioc_exit_icq+0xa0/0x150 [13058.355035] put_io_context_active+0x250/0x438 [13058.355038] exit_io_context+0xd0/0x138 [13058.355045] do_exit+0x734/0xc58 [13058.355050] do_group_exit+0x78/0x220 [13058.355054] __wake_up_parent+0x0/0x50 [13058.355058] el0_svc_common+0xb4/0x1d8 [13058.355062] el0_svc_handler+0x50/0xa8 [13058.355066] el0_svc+0x8/0xc [13058.355067] [13058.355071] The buggy address belongs to the object at ffffa02cf3e63e70#012 which belongs to the cache bfq_queue of size 464 [13058.355075] The buggy address is located 264 bytes inside of#012 464-byte region [ffffa02cf3e63e70, ffffa02cf3e64040) [13058.355077] The buggy address belongs to the page: [13058.355083] page:ffff7e80b3cf9800 count:1 mapcount:0 mapping:ffff802db5c90780 index:0xffffa02cf3e606f0 compound_mapcount: 0 [13058.366175] flags: 0x2ffffe0000008100(slab|head) [13058.370781] raw: 2ffffe0000008100 ffff7e80b53b1408 ffffa02d730c1c90 ffff802db5c90780 [13058.370787] raw: ffffa02cf3e606f0 0000000000370023 00000001ffffffff 0000000000000000 [13058.370789] page dumped because: kasan: bad access detected [13058.370791] [13058.370792] Memory state around the buggy address: [13058.370797] ffffa02cf3e63e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fb fb [13058.370801] ffffa02cf3e63e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [13058.370805] >ffffa02cf3e63f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [13058.370808] ^ [13058.370811] ffffa02cf3e63f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [13058.370815] ffffa02cf3e64000: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc [13058.370817] ================================================================== [13058.370820] Disabling lock debugging due to kernel taint
Here, we directly pass the bfqd to bfq_idle_slice_timer_body func. --V2->V3: rewrite the comment as suggested by Paolo Valente V1->V2: add one comment, and add Fixes and Reported-by tag.
--- block/bfq-iosched.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
block/bfq-iosched.c +12 -4
@@ -6215,20 +6215,28 @@ static struct bfq_queue *bfq_init_rq(struct request *rq)return bfqq; } -static void bfq_idle_slice_timer_body (struct bfq_queue *bfqq) +static void +bfq_idle_slice_timer_body (struct bfq_data *bfqd,struct bfq_queue *bfqq) { -struct bfq_data *bfqd = bfqq->bfqd;enum bfqq_expiration reason;unsigned long flags;spin_lock_irqsave (&bfqd->lock, flags); -bfq_clear_bfqq_wait_request (bfqq); +/* +* Considering that bfqq may be in race, we should firstly check +* whether bfqq is in service before doing something on it. If +* the bfqq in race is not in service, it has already been expired +* through __bfq_bfqq_expire func and its wait_request flags has +* been cleared in __bfq_bfqd_reset_in_service func. +*/ if (bfqq != bfqd->in_service_queue) {spin_unlock_irqrestore (&bfqd->lock, flags);return ; } +bfq_clear_bfqq_wait_request (bfqq); +if (bfq_bfqq_budget_timeout (bfqq))/* * Also here the queue can be safely expired
@@ -6273,7 +6281,7 @@ static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer)* early. */ if (bfqq) -bfq_idle_slice_timer_body (bfqq); +bfq_idle_slice_timer_body (bfqd, bfqq);return HRTIMER_NORESTART ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 52/254 media: mtk-vpu: avoid unaligned access to DTCM buffer.
In reply to Greg Kroah-HartmanFrom: Hsin-Yi Wang <[email protected]>
[ Upstream commit e6599adfad30c340d06574e49a86afa7015c5c60 ]
Previously, vpu->recv_buf and send_buf are forced cast from void __iomem *tcm. vpu->recv_buf->share_buf is passed to vpu_ipi_desc.handler(). It's not able to do unaligned access. Otherwise kernel would crash due to unable to handle kernel paging request.
struct vpu_run {
u32 signaled;
char fw_ver[VPU_FW_VER_LEN];
unsigned int dec_capability;
unsigned int enc_capability;
wait_queue_head_t wq;
};fw_ver starts at 4 byte boundary. If system enables CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, strscpy() will do read_word_at_a_time(), which tries to read 8-byte: *(unsigned long *)addr
vpu_init_ipi_handler() calls strscpy(), which would lead to crash.
vpu_init_ipi_handler() and several other handlers (eg. vpu_dec_ipi_handler) only do read access to this data, so they can be const, and we can use memcpy_fromio() to copy the buf to another non iomem buffer then pass to handler.
--- drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c | 9 ++-- .../media/platform/mtk-vcodec/vdec_vpu_if.c | 6 +-- .../media/platform/mtk-vcodec/venc_vpu_if.c | 12 ++--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 45 ++++++++++--------- drivers/media/platform/mtk-vpu/mtk_vpu.h | 2 +- 5 files changed, 38 insertions(+), 36 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c +5 -4
@@ -15,7 +15,7 @@ static inline struct mtk_mdp_ctx *vpu_to_ctx(struct mtk_mdp_vpu *vpu) return container_of(vpu, struct mtk_mdp_ctx, vpu); } -static void mtk_mdp_vpu_handle_init_ack (struct mdp_ipi_comm_ack *msg) +static void mtk_mdp_vpu_handle_init_ack (const struct mdp_ipi_comm_ack *msg) {struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *) (unsigned long )msg->ap_inst;
@@ -26,10 +26,11 @@ static void mtk_mdp_vpu_handle_init_ack(struct mdp_ipi_comm_ack *msg) vpu->inst_addr = msg->vpu_inst_addr; } -static void mtk_mdp_vpu_ipi_handler (void *data,unsigned int len,void *priv) +static void mtk_mdp_vpu_ipi_handler (const void *data,unsigned int len, +void *priv) { -unsigned int msg_id = *(unsigned int *)data; -struct mdp_ipi_comm_ack *msg = (struct mdp_ipi_comm_ack *)data; +const struct mdp_ipi_comm_ack *msg = data; +unsigned int msg_id = msg->msg_id;struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *) (unsigned long )msg->ap_inst;struct mtk_mdp_ctx *ctx;
drivers/media/platform/mtk-vcodec/vdec_vpu_if.c +3 -3
@@ -9,7 +9,7 @@#include "vdec_ipi_msg.h" #include "vdec_vpu_if.h" -static void handle_init_ack_msg (struct vdec_vpu_ipi_init_ack *msg) +static void handle_init_ack_msg (const struct vdec_vpu_ipi_init_ack *msg) {struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) (unsigned long )msg->ap_inst_addr;
@@ -34,9 +34,9 @@ static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)* This function runs in interrupt context and it means there's an IPI MSG * from VPU. */ -static void vpu_dec_ipi_handler (void *data,unsigned int len,void *priv) +static void vpu_dec_ipi_handler (const void *data,unsigned int len,void *priv) { -struct vdec_vpu_ipi_ack *msg = data; +const struct vdec_vpu_ipi_ack *msg = data;struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) (unsigned long )msg->ap_inst_addr;
drivers/media/platform/mtk-vcodec/venc_vpu_if.c +6 -6
@@ -8,26 +8,26 @@#include "venc_ipi_msg.h" #include "venc_vpu_if.h" -static void handle_enc_init_msg (struct venc_vpu_inst *vpu,void *data) +static void handle_enc_init_msg (struct venc_vpu_inst *vpu,const void *data) { -struct venc_vpu_ipi_msg_init *msg = data; +const struct venc_vpu_ipi_msg_init *msg = data; vpu->inst_addr = msg->vpu_inst_addr; vpu->vsi =vpu_mapping_dm_addr (vpu->dev, msg->vpu_inst_addr); } -static void handle_enc_encode_msg (struct venc_vpu_inst *vpu,void *data) +static void handle_enc_encode_msg (struct venc_vpu_inst *vpu,const void *data) { -struct venc_vpu_ipi_msg_enc *msg = data; +const struct venc_vpu_ipi_msg_enc *msg = data; vpu->state = msg->state; vpu->bs_size = msg->bs_size; vpu->is_key_frm = msg->is_key_frm; } -static void vpu_enc_ipi_handler (void *data,unsigned int len,void *priv) +static void vpu_enc_ipi_handler (const void *data,unsigned int len,void *priv) { -struct venc_vpu_ipi_msg_common *msg = data; +const struct venc_vpu_ipi_msg_common *msg = data;struct venc_vpu_inst *vpu = (struct venc_vpu_inst *)(unsigned long )msg->venc_inst;
drivers/media/platform/mtk-vpu/mtk_vpu.c +23 -22
87 lines not on this page · raw message
drivers/media/platform/mtk-vpu/mtk_vpu.h +1 -1
@@ -15,7 +15,7 @@* VPU interfaces with other blocks by share memory and interrupt. **/ -typedef void (*ipi_handler_t ) (void *data, +typedef void (*ipi_handler_t ) (const void *data,unsigned int len,void *priv);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 112/254 cpu/hotplug: Ignore pm_wakeup_pending() for disable_nonboot_cpus()
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit e98eac6ff1b45e4e73f2e6031b37c256ccb5d36b upstream.
A recent change to freeze_secondary_cpus() which added an early abort if a wakeup is pending missed the fact that the function is also invoked for shutdown, reboot and kexec via disable_nonboot_cpus().
In case of disable_nonboot_cpus() the wakeup event needs to be ignored as the purpose is to terminate the currently running kernel.
Add a 'suspend' argument which is only set when the freeze is in context of a suspend operation. If not set then an eventually pending wakeup event is ignored.
--- include/linux/cpu.h | 12 +++++++++--- kernel/cpu.c | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-)
include/linux/cpu.h +9 -3
@@ -138,12 +138,18 @@ static inline void get_online_cpus(void)static inline void put_online_cpus (void ) {cpus_read_unlock (); }#ifdef CONFIG_PM_SLEEP_SMP -extern int freeze_secondary_cpus (int primary); +int __freeze_secondary_cpus (int primary,bool suspend); +static inline int freeze_secondary_cpus (int primary) +{ +return __freeze_secondary_cpus (primary, true); +} +static inline int disable_nonboot_cpus (void ) { -return freeze_secondary_cpus (0 ); +return __freeze_secondary_cpus (0 , false); } -extern void enable_nonboot_cpus (void ); + +void enable_nonboot_cpus (void );static inline int suspend_disable_secondary_cpus (void ) {
kernel/cpu.c +2 -2
@@ -1212,7 +1212,7 @@ EXPORT_SYMBOL_GPL(cpu_up);#ifdef CONFIG_PM_SLEEP_SMP static cpumask_var_t frozen_cpus; -int freeze_secondary_cpus (int primary) +int __freeze_secondary_cpus (int primary,bool suspend) {int cpu, error =0 ;
@@ -1237,7 +1237,7 @@ int freeze_secondary_cpus(int primary)if (cpu == primary)continue ; -if (pm_wakeup_pending ()) { +if (suspend &&pm_wakeup_pending ()) {pr_info ("Wakeup pending. Abort CPU freeze\n" ); error = -EBUSY ;break ;
Greg Kroah-Hartman
maintainerPATCH 114/254 irqchip/versatile-fpga: Apply clear-mask earlier
In reply to Greg Kroah-HartmanFrom: Sungbo Eo <[email protected]>
commit 6a214a28132f19ace3d835a6d8f6422ec80ad200 upstream.
Clear its own IRQs before the parent IRQ get enabled, so that the remaining IRQs do not accidentally interrupt the parent IRQ controller.
This patch also fixes a reboot bug on OX820 SoC, where the remaining rps-timer IRQ raises a GIC interrupt that is left pending. After that, the rps-timer IRQ is cleared during driver initialization, and there's no IRQ left in rps-irq when local_irq_enable() is called, which evokes an error message "unexpected IRQ trap".
--- drivers/irqchip/irq-versatile-fpga.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/irqchip/irq-versatile-fpga.c +3 -3
@@ -212,6 +212,9 @@ int __init fpga_irq_of_init(struct devicif (of_property_read_u32 (node,"valid-mask" , &valid_mask)) valid_mask =0 ; +writel (clear_mask, base +IRQ_ENABLE_CLEAR ); +writel (clear_mask, base +FIQ_ENABLE_CLEAR ); +/* Some chips are cascaded from a parent IRQ */ parent_irq =irq_of_parse_and_map (node,0 );if (!parent_irq) {
@@ -221,9 +224,6 @@ int __init fpga_irq_of_init(struct devicfpga_irq_init (base, node->name,0 , parent_irq, valid_mask, node); -writel (clear_mask, base +IRQ_ENABLE_CLEAR ); -writel (clear_mask, base +FIQ_ENABLE_CLEAR ); -/* * On Versatile AB/PB, some secondary interrupts have a direct * pass-thru to the primary controller for IRQs 20 and 22-31 which need
Greg Kroah-Hartman
maintainerPATCH 97/254 nvme-fc: Revert "add module to ops template to allow module references"
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 8c5c660529209a0e324c1c1a35ce3f83d67a2aa5 upstream.
The original patch was to resolve the lldd being able to be unloaded while being used to talk to the boot device of the system. However, the end result of the original patch is that any driver unload while a nvme controller is live via the lldd is now being prohibited. Given the module reference, the module teardown routine can't be called, thus there's no way, other than manual actions to terminate the controllers.
--- drivers/nvme/host/fc.c | 14 ++------------ drivers/nvme/target/fcloop.c | 1 - drivers/scsi/lpfc/lpfc_nvme.c | 2 -- drivers/scsi/qla2xxx/qla_nvme.c | 1 - include/linux/nvme-fc-driver.h | 4 ---- 5 files changed, 2 insertions(+), 20 deletions(-)
drivers/nvme/host/fc.c +2 -12
@@ -342,8 +342,7 @@ nvme_fc_register_localport(struct nvme_f !template->ls_req || !template->fcp_io || !template->ls_abort || !template->fcp_abort || !template->max_hw_queues || !template->max_sgl_segments || - !template->max_dif_sgl_segments || !template->dma_boundary || - !template->module) { + !template->max_dif_sgl_segments || !template->dma_boundary) { ret = -EINVAL ; goto out_reghost_failed; }
@@ -2016,7 +2015,6 @@ nvme_fc_ctrl_free(struct kref *ref) {struct nvme_fc_ctrl *ctrl = container_of(ref, struct nvme_fc_ctrl, ref); -struct nvme_fc_lport *lport = ctrl->lport;unsigned long flags;if (ctrl->ctrl.tagset) {
@@ -2043,7 +2041,6 @@ nvme_fc_ctrl_free(struct kref *ref)if (ctrl->ctrl.opts)nvmf_free_options (ctrl->ctrl.opts);kfree (ctrl); -module_put (lport->ops->module); } static void
@@ -3074,15 +3071,10 @@ nvme_fc_init_ctrl(struct device *dev, st goto out_fail; } -if (!try_module_get (lport->ops->module)) { - ret = -EUNATCH ; - goto out_free_ctrl; - } - idx =ida_simple_get (&nvme_fc_ctrl_cnt,0 ,0 ,GFP_KERNEL );if (idx <0 ) { ret = -ENOSPC ; - goto out_mod_put; + goto out_free_ctrl; } ctrl->ctrl.opts = opts;
@@ -3235,8 +3227,6 @@ out_free_queues: out_free_ida:put_device (ctrl->dev);ida_simple_remove (&nvme_fc_ctrl_cnt, ctrl->cnum); -out_mod_put: -module_put (lport->ops->module); out_free_ctrl:kfree (ctrl); out_fail:
drivers/nvme/target/fcloop.c +0 -1
@@ -850,7 +850,6 @@ fcloop_targetport_delete(struct nvmet_fc#define FCLOOP_DMABOUND_4G 0xFFFFFFFFstatic struct nvme_fc_port_template fctemplate = { - .module =THIS_MODULE , .localport_delete = fcloop_localport_delete, .remoteport_delete = fcloop_remoteport_delete, .create_queue = fcloop_create_queue,
drivers/scsi/lpfc/lpfc_nvme.c +0 -2
@@ -1985,8 +1985,6 @@ out_unlock:/* Declare and initialization an instance of the FC NVME template. */ static struct nvme_fc_port_template lpfc_nvme_template = { - .module =THIS_MODULE , -/* initiator-based functions */ .localport_delete = lpfc_nvme_localport_delete, .remoteport_delete = lpfc_nvme_remoteport_delete,
drivers/scsi/qla2xxx/qla_nvme.c +0 -1
@@ -610,7 +610,6 @@ static void qla_nvme_remoteport_delete(s }static struct nvme_fc_port_template qla_nvme_fc_transport = { - .module =THIS_MODULE , .localport_delete = qla_nvme_localport_delete, .remoteport_delete = qla_nvme_remoteport_delete, .create_queue = qla_nvme_alloc_queue,
include/linux/nvme-fc-driver.h +0 -4
@@ -270,8 +270,6 @@ struct nvme_fc_remote_port {* * Host/Initiator Transport Entrypoints/Parameters: * -* @module: The LLDD module using the interface -* * @localport_delete: The LLDD initiates deletion of a localport via * nvme_fc_deregister_localport(). However, the teardown is * asynchronous. This routine is called upon the completion of the
@@ -385,8 +383,6 @@ struct nvme_fc_remote_port {* Value is Mandatory. Allowed to be zero. */ struct nvme_fc_port_template { -struct module *module; -/* initiator-based functions */ void (*localport_delete)(struct nvme_fc_local_port *);void (*remoteport_delete)(struct nvme_fc_remote_port *);
Greg Kroah-Hartman
maintainerPATCH 118/254 pstore: pstore_ftrace_seq_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit 6c871b7314dde9ab64f20de8f5aa3d01be4518e8 upstream.
In Aug 2018 NeilBrown noticed
commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") "Some ->next functions do not increment *pos when they return NULL... Note that such ->next functions are buggy and should be fixed.
A simple demonstration is
dd if=/proc/swaps bs=1000 skip=1
Choose any block size larger than the size of /proc/swaps. This will always show the whole last line of /proc/swaps"
/proc/swaps output was fixed recently, however there are lot of other affected files, and one of them is related to pstore subsystem.
If .next function does not change position index, following .show function will repeat output related to current position index.
There are at least 2 related problems:
- read after lseek beyond end of file, described above by NeilBrown "dd if=<AFFECTED_FILE> bs=1000 skip=1" will generate whole last list
- read after lseek on in middle of last line will output expected rest of last line but then repeat whole last line once again.
If .show() function generates multy-line output (like pstore_ftrace_seq_show() does ?) following bash script cycles endlessly
$ q=;while read -r r;do echo "$((++q)) $r";done < AFFECTED_FILE
Unfortunately I'm not familiar enough to pstore subsystem and was unable to find affected pstore-related file on my test node.
If .next function does not change position index, following .show function will repeat output related to current position index.
--- fs/pstore/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/pstore/inode.c +4 -1
@@ -87,11 +87,11 @@ static void *pstore_ftrace_seq_next(strustruct pstore_private *ps = s->private;struct pstore_ftrace_seq_data *data = v; + (*pos)++; data->off +=REC_SIZE ;if (data->off +REC_SIZE > ps->total_size)return NULL ; - (*pos)++;return data; }
@@ -101,6 +101,9 @@ static int pstore_ftrace_seq_show(structstruct pstore_ftrace_seq_data *data = v;struct pstore_ftrace_record *rec; +if (!data) +return 0 ; + rec = (struct pstore_ftrace_record *)(ps->record->buf + data->off); seq_printf(s, "CPU:%d ts:%llu %08lx %08lx %ps <- %pS\n",
Greg Kroah-Hartman
maintainerPATCH 124/254 signal: Extend exec_id to 64bits
In reply to Greg Kroah-HartmanFrom: Eric W. Biederman <[email protected]>
commit d1e7fd6462ca9fc76650fbe6ca800e35b24267da upstream.
Replace the 32bit exec_id with a 64bit exec_id to make it impossible to wrap the exec_id counter. With care an attacker can cause exec_id wrap and send arbitrary signals to a newly exec'd parent. This bypasses the signal sending checks if the parent changes their credentials during exec.
The severity of this problem can been seen that in my limited testing of a 32bit exec_id it can take as little as 19s to exec 65536 times. Which means that it can take as little as 14 days to wrap a 32bit exec_id. Adam Zabrocki has succeeded wrapping the self_exe_id in 7 days. Even my slower timing is in the uptime of a typical server. Which means self_exec_id is simply a speed bump today, and if exec gets noticably faster self_exec_id won't even be a speed bump.
Extending self_exec_id to 64bits introduces a problem on 32bit architectures where reading self_exec_id is no longer atomic and can take two read instructions. Which means that is is possible to hit a window where the read value of exec_id does not match the written value. So with very lucky timing after this change this still remains expoiltable.
I have updated the update of exec_id on exec to use WRITE_ONCE and the read of exec_id in do_notify_parent to use READ_ONCE to make it clear that there is no locking between these two locations.
--- fs/exec.c | 2 +- include/linux/sched.h | 4 ++-- kernel/signal.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/exec.c +1 -1
@@ -1386,7 +1386,7 @@ void setup_new_exec(struct linux_binprm/* An exec changes our domain. We are no longer part of the thread group */ - current->self_exec_id++; +WRITE_ONCE (current->self_exec_id, current->self_exec_id +1 );flush_signal_handlers (current,0 ); }EXPORT_SYMBOL (setup_new_exec);
include/linux/sched.h +2 -2
@@ -939,8 +939,8 @@ struct task_struct {struct seccomp seccomp;/* Thread group tracking: */ -u32 parent_exec_id; -u32 self_exec_id; +u64 parent_exec_id; +u64 self_exec_id;/* Protection against (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, mempolicy: */ spinlock_t alloc_lock;
kernel/signal.c +1 -1
@@ -1931,7 +1931,7 @@ bool do_notify_parent(struct task_struct* This is only possible if parent == real_parent. * Check if it has changed security domain. */ -if (tsk->parent_exec_id != tsk->parent->self_exec_id) +if (tsk->parent_exec_id !=READ_ONCE (tsk->parent->self_exec_id)) sig =SIGCHLD ; }
Greg Kroah-Hartman
maintainerPATCH 98/254 efi/x86: Add TPM related EFI tables to unencrypted mapping checks
In reply to Greg Kroah-HartmanFrom: Tom Lendacky <[email protected]>
commit f10e80a19b07b58fc2adad7945f8313b01503bae upstream.
When booting with SME active, EFI tables must be mapped unencrypted since they were built by UEFI in unencrypted memory. Update the list of tables to be checked during early_memremap() processing to account for the EFI TPM tables.
This fixes a bug where an EFI TPM log table has been created by UEFI, but it lives in memory that has been marked as usable rather than reserved.
--- arch/x86/platform/efi/efi.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/platform/efi/efi.c +2 -0
@@ -85,6 +85,8 @@ static const unsigned long * const efi_t#ifdef CONFIG_EFI_RCI2_TABLE &rci2_table_phys, #endif + &efi.tpm_log, + &efi.tpm_final_log, };u64 efi_setup;/* efi setup_data physical address */
Greg Kroah-Hartman
maintainerPATCH 127/254 x86/tsc_msr: Make MSR derived TSC frequency more accurate
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit fac01d11722c92a186b27ee26cd429a8066adfb5 upstream.
The "Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 4:
Model-Specific Registers" has the following table for the values from freq_desc_byt:
000B: 083.3 MHz
001B: 100.0 MHz
010B: 133.3 MHz
011B: 116.7 MHz
100B: 080.0 MHz
Notice how for e.g the 83.3 MHz value there are 3 significant digits, which translates to an accuracy of a 1000 ppm, where as a typical crystal oscillator is 20 - 100 ppm, so the accuracy of the frequency format used in the Software Developer’s Manual is not really helpful.
As far as we know Bay Trail SoCs use a 25 MHz crystal and Cherry Trail uses a 19.2 MHz crystal, the crystal is the source clock for a root PLL which outputs 1600 and 100 MHz. It is unclear if the root PLL outputs are used directly by the CPU clock PLL or if there is another PLL in between.
This does not matter though, we can model the chain of PLLs as a single PLL with a quotient equal to the quotients of all PLLs in the chain multiplied.
So we can create a simplified model of the CPU clock setup using a reference clock of 100 MHz plus a quotient which gets us as close to the frequency from the SDM as possible.
For the 83.3 MHz example from above this would give 100 MHz * 5 / 6 = 83 and 1/3 MHz, which matches exactly what has been measured on actual hardware.
Use a simplified PLL model with a reference clock of 100 MHz for all Bay and Cherry Trail models.
This has been tested on the following models:
CPU freq before: CPU freq after: Intel N2840 2165.800 MHz 2166.667 MHz Intel Z3736 1332.800 MHz 1333.333 MHz Intel Z3775 1466.300 MHz 1466.667 MHz Intel Z8350 1440.000 MHz 1440.000 MHz Intel Z8750 1600.000 MHz 1600.000 MHz
This fixes the time drifting by about 1 second per hour (20 - 30 seconds per day) on (some) devices which rely on the tsc_msr.c code to determine the TSC frequency.
--- arch/x86/kernel/tsc_msr.c | 97 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 11 deletions(-)
arch/x86/kernel/tsc_msr.c +86 -11
@@ -18,6 +18,28 @@#define MAX_NUM_FREQS 16/* 4 bits to select the frequency */ /* +* The frequency numbers in the SDM are e.g. 83.3 MHz, which does not contain a +* lot of accuracy which leads to clock drift. As far as we know Bay Trail SoCs +* use a 25 MHz crystal and Cherry Trail uses a 19.2 MHz crystal, the crystal +* is the source clk for a root PLL which outputs 1600 and 100 MHz. It is +* unclear if the root PLL outputs are used directly by the CPU clock PLL or +* if there is another PLL in between. +* This does not matter though, we can model the chain of PLLs as a single PLL +* with a quotient equal to the quotients of all PLLs in the chain multiplied. +* So we can create a simplified model of the CPU clock setup using a reference +* clock of 100 MHz plus a quotient which gets us as close to the frequency +* from the SDM as possible. +* For the 83.3 MHz example from above this would give us 100 MHz * 5 / 6 = +* 83 and 1/3 MHz, which matches exactly what has been measured on actual hw. +*/ +#define TSC_REFERENCE_KHZ 100000 + +struct muldiv { +u32 multiplier; +u32 divider; +}; + +/* * If MSR_PERF_STAT[31] is set, the maximum resolved bus ratio can be * read in MSR_PLATFORM_ID[12:8], otherwise in MSR_PERF_STAT[44:40]. * Unfortunately some Intel Atom SoCs aren't quite compliant to this,
@@ -26,6 +48,11 @@*/ struct freq_desc {bool use_msr_plat; +struct muldiv muldiv[MAX_NUM_FREQS ]; +/* +* Some CPU frequencies in the SDM do not map to known PLL freqs, in +* that case the muldiv array is empty and the freqs array is used. +*/ u32 freqs[MAX_NUM_FREQS ];u32 mask; };
@@ -47,31 +74,66 @@ static const struct freq_desc freq_desc_ .mask = 0x07, }; +/* +* Bay Trail SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 000: 100 * 5 / 6 = 83.3333 MHz +* 001: 100 * 1 / 1 = 100.0000 MHz +* 010: 100 * 4 / 3 = 133.3333 MHz +* 011: 100 * 7 / 6 = 116.6667 MHz +* 100: 100 * 4 / 5 = 80.0000 MHz +*/ static const struct freq_desc freq_desc_byt = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,116700 ,80000 ,0 ,0 ,0 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {7 ,6 }, + {4 ,5 } }, .mask =0x07 , }; +/* +* Cherry Trail SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0000: 100 * 5 / 6 = 83.3333 MHz +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +* 0011: 100 * 7 / 6 = 116.6667 MHz +* 0100: 100 * 4 / 5 = 80.0000 MHz +* 0101: 100 * 14 / 15 = 93.3333 MHz +* 0110: 100 * 9 / 10 = 90.0000 MHz +* 0111: 100 * 8 / 9 = 88.8889 MHz +* 1000: 100 * 7 / 8 = 87.5000 MHz +*/ static const struct freq_desc freq_desc_cht = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,116700 ,80000 ,93300 ,90000 , -88900 ,87500 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {7 ,6 }, + {4 ,5 }, {14 ,15 }, {9 ,10 }, {8 ,9 }, + {7 ,8 } }, .mask =0x0f , }; +/* +* Merriefield SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +*/ static const struct freq_desc freq_desc_tng = { .use_msr_plat = true, - .freqs = {0 ,100000 ,133300 ,0 ,0 ,0 ,0 ,0 }, + .muldiv = { {0 ,0 }, {1 ,1 }, {4 ,3 } }, .mask =0x07 , }; +/* +* Moorefield SDM MSR_FSB_FREQ frequencies simplified PLL model: +* 0000: 100 * 5 / 6 = 83.3333 MHz +* 0001: 100 * 1 / 1 = 100.0000 MHz +* 0010: 100 * 4 / 3 = 133.3333 MHz +* 0011: 100 * 1 / 1 = 100.0000 MHz +*/ static const struct freq_desc freq_desc_ann = { .use_msr_plat = true, - .freqs = {83300 ,100000 ,133300 ,100000 ,0 ,0 ,0 ,0 }, + .muldiv = { {5 ,6 }, {1 ,1 }, {4 ,3 }, {1 ,1 } }, .mask =0x0f , }; +/* 24 MHz crystal? : 24 * 13 / 4 = 78 MHz */ static const struct freq_desc freq_desc_lgm = { .use_msr_plat = true, .freqs = {78000 ,78000 ,78000 ,78000 ,78000 ,78000 ,78000 ,78000 },
@@ -97,9 +159,10 @@ static const struct x86_cpu_id tsc_msr_c*/ unsigned long cpu_khz_from_msr (void ) { -u32 lo, hi, ratio, freq; +u32 lo, hi, ratio, freq, tscref;const struct freq_desc *freq_desc;const struct x86_cpu_id *id; +const struct muldiv *md;unsigned long res;int index;
@@ -119,12 +182,24 @@ unsigned long cpu_khz_from_msr(void)/* Get FSB FREQ ID */ rdmsr (MSR_FSB_FREQ , lo, hi); index = lo & freq_desc->mask; + md = &freq_desc->muldiv[index]; -/* Map CPU reference clock freq ID(0-7) to CPU reference clock freq(KHz) */ - freq = freq_desc->freqs[index]; - -/* TSC frequency = maximum resolved freq * maximum resolved bus ratio */ - res = freq * ratio; +/* +* Note this also catches cases where the index points to an unpopulated +* part of muldiv, in that case the else will set freq and res to 0. +*/ +if (md->divider) { + tscref =TSC_REFERENCE_KHZ * md->multiplier; + freq =DIV_ROUND_CLOSEST (tscref, md->divider); +/* +* Multiplying by ratio before the division has better +* accuracy than just calculating freq * ratio. +*/ + res =DIV_ROUND_CLOSEST (tscref * ratio, md->divider); + }else { + freq = freq_desc->freqs[index]; + res = freq * ratio; + }if (freq ==0 )pr_err ("Error MSR_FSB_FREQ index %d is unknown\n" , index);
Greg Kroah-Hartman
maintainerPATCH 128/254 x86/entry/32: Add missing ASM_CLAC to general_protection entry
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 3d51507f29f2153a658df4a0674ec5b592b62085 upstream.
All exception entry points must have ASM_CLAC right at the beginning. The general_protection entry is missing one.
--- arch/x86/entry/entry_32.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/entry/entry_32.S +1 -0
@@ -1694,6 +1694,7 @@ SYM_CODE_START(int3) SYM_CODE_END(int3) SYM_CODE_START(general_protection) + ASM_CLAC pushl $do_general_protection jmp common_exception SYM_CODE_END(general_protection)
Greg Kroah-Hartman
maintainerPATCH 132/254 KVM: s390: vsie: Fix region 1 ASCE sanity shadow address checks
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit a1d032a49522cb5368e5dfb945a85899b4c74f65 upstream.
In case we have a region 1 the following calculation
(31 + ((gmap->asce & _ASCE_TYPE_MASK) >> 2)*11)
results in 64. As shifts beyond the size are undefined the compiler is free to use instructions like sllg. sllg will only use 6 bits of the shift value (here 64) resulting in no shift at all. That means that ALL addresses will be rejected.
The can result in endless loops, e.g. when prefix cannot get mapped.
--- arch/s390/mm/gmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/s390/mm/gmap.c +5 -1
@@ -787,14 +787,18 @@ static void gmap_call_notifier(struct gmstatic inline unsigned long *gmap_table_walk (struct gmap *gmap,unsigned long gaddr,int level) { +const int asce_type = gmap->asce & _ASCE_TYPE_MASK;unsigned long *table;if ((gmap->asce & _ASCE_TYPE_MASK) +4 < (level *4 ))return NULL ;if (gmap_is_shadow (gmap) && gmap->removed)return NULL ; -if (gaddr & (-1UL << (31 + ((gmap->asce & _ASCE_TYPE_MASK) >>2 )*11 ))) + +if (asce_type != _ASCE_TYPE_REGION1 && + gaddr & (-1UL << (31 + (asce_type >>2 ) *11 )))return NULL ; + table = gmap->table;switch (gmap->asce & _ASCE_TYPE_MASK) {case _ASCE_TYPE_REGION1:
Greg Kroah-Hartman
maintainerPATCH 133/254 KVM: s390: vsie: Fix delivery of addressing exceptions
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit 4d4cee96fb7a3cc53702a9be8299bf525be4ee98 upstream.
Whenever we get an -EFAULT, we failed to read in guest 2 physical address space. Such addressing exceptions are reported via a program intercept to the nested hypervisor.
We faked the intercept, we have to return to guest 2. Instead, right now we would be returning -EFAULT from the intercept handler, eventually crashing the VM.
the correct thing to do is to return 1 as rc == 1 is the internal representation of "we have to go back into g2".
Addressing exceptions can only happen if the g2->g3 page tables reference invalid g2 addresses (say, either a table or the final page is not accessible - so something that basically never happens in sane environments.
Identified by manual code inspection.
--- arch/s390/kvm/vsie.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kvm/vsie.c +1 -0
@@ -1202,6 +1202,7 @@ static int vsie_run(struct kvm_vcpu *vcp scb_s->iprcc =PGM_ADDRESSING ; scb_s->pgmilc =4 ; scb_s->gpsw.addr =__rewind_psw (scb_s->gpsw,4 ); + rc =1 ; }return rc; }
Greg Kroah-Hartman
maintainerPATCH 135/254 KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 31603d4fc2bb4f0815245d496cb970b27b4f636a upstream.
VMCLEAR all in-use VMCSes during a crash, even if kdump's NMI shootdown interrupted a KVM update of the percpu in-use VMCS list.
Because NMIs are not blocked by disabling IRQs, it's possible that crash_vmclear_local_loaded_vmcss() could be called while the percpu list of VMCSes is being modified, e.g. in the middle of list_add() in vmx_vcpu_load_vmcs(). This potential corner case was called out in the original commit[*], but the analysis of its impact was wrong.
Skipping the VMCLEARs is wrong because it all but guarantees that a loaded, and therefore cached, VMCS will live across kexec and corrupt memory in the new kernel. Corruption will occur because the CPU's VMCS cache is non-coherent, i.e. not snooped, and so the writeback of VMCS memory on its eviction will overwrite random memory in the new kernel. The VMCS will live because the NMI shootdown also disables VMX, i.e. the in-progress VMCLEAR will #UD, and existing Intel CPUs do not flush the VMCS cache on VMXOFF.
Furthermore, interrupting list_add() and list_del() is safe due to crash_vmclear_local_loaded_vmcss() using forward iteration. list_add() ensures the new entry is not visible to forward iteration unless the entire add completes, via WRITE_ONCE(prev->next, new). A bad "prev" pointer could be observed if the NMI shootdown interrupted list_del() or list_add(), but list_for_each_entry() does not consume ->prev.
In addition to removing the temporary disabling of VMCLEAR, open code loaded_vmcs_init() in __loaded_vmcs_clear() and reorder VMCLEAR so that the VMCS is deleted from the list only after it's been VMCLEAR'd. Deleting the VMCS before VMCLEAR would allow a race where the NMI shootdown could arrive between list_del() and vmcs_clear() and thus neither flow would execute a successful VMCLEAR. Alternatively, more code could be moved into loaded_vmcs_init(), but that gets rather silly as the only other user, alloc_loaded_vmcs(), doesn't need the smp_wmb() and would need to work around the list_del().
Update the smp_*() comments related to the list manipulation, and opportunistically reword them to improve clarity.
[*] https://patchwork.kernel.org/patch/1675731/#3720461
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/vmx.c | 67 +++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 51 deletions(-)
arch/x86/kvm/vmx/vmx.c +16 -51
@@ -666,43 +666,15 @@ void loaded_vmcs_init(struct loaded_vmcs }#ifdef CONFIG_KEXEC_CORE -/* -* This bitmap is used to indicate whether the vmclear -* operation is enabled on all cpus. All disabled by -* default. -*/ -static cpumask_t crash_vmclear_enabled_bitmap =CPU_MASK_NONE ; - -static inline void crash_enable_local_vmclear (int cpu) -{ -cpumask_set_cpu (cpu, &crash_vmclear_enabled_bitmap); -} - -static inline void crash_disable_local_vmclear (int cpu) -{ -cpumask_clear_cpu (cpu, &crash_vmclear_enabled_bitmap); -} - -static inline int crash_local_vmclear_enabled (int cpu) -{ -return cpumask_test_cpu (cpu, &crash_vmclear_enabled_bitmap); -} -static void crash_vmclear_local_loaded_vmcss (void ) {int cpu =raw_smp_processor_id ();struct loaded_vmcs *v; -if (!crash_local_vmclear_enabled (cpu)) -return ; -list_for_each_entry (v, &per_cpu (loaded_vmcss_on_cpu, cpu), loaded_vmcss_on_cpu_link)vmcs_clear (v->vmcs); } -#else -static inline void crash_enable_local_vmclear (int cpu) { } -static inline void crash_disable_local_vmclear (int cpu) { }#endif /* CONFIG_KEXEC_CORE */ static void __loaded_vmcs_clear (void *arg)
@@ -714,19 +686,24 @@ static void __loaded_vmcs_clear(void *arreturn ;/* vcpu migration can race with cpu offline */ if (per_cpu (current_vmcs, cpu) == loaded_vmcs->vmcs)per_cpu (current_vmcs, cpu) =NULL ; -crash_disable_local_vmclear (cpu); + +vmcs_clear (loaded_vmcs->vmcs); +if (loaded_vmcs->shadow_vmcs && loaded_vmcs->launched) +vmcs_clear (loaded_vmcs->shadow_vmcs); +list_del (&loaded_vmcs->loaded_vmcss_on_cpu_link);/* -* we should ensure updating loaded_vmcs->loaded_vmcss_on_cpu_link -* is before setting loaded_vmcs->vcpu to -1 which is done in -* loaded_vmcs_init. Otherwise, other cpu can see vcpu = -1 fist -* then adds the vmcs into percpu list before it is deleted. +* Ensure all writes to loaded_vmcs, including deleting it from its +* current percpu list, complete before setting loaded_vmcs->vcpu to +* -1, otherwise a different cpu can see vcpu == -1 first and add +* loaded_vmcs to its percpu list before it's deleted from this cpu's +* list. Pairs with the smp_rmb() in vmx_vcpu_load_vmcs(). */ smp_wmb (); -loaded_vmcs_init (loaded_vmcs); -crash_enable_local_vmclear (cpu); + loaded_vmcs->cpu =-1 ; + loaded_vmcs->launched =0 ; }void loaded_vmcs_clear (struct loaded_vmcs *loaded_vmcs)
@@ -1345,18 +1322,17 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpuif (!already_loaded) {loaded_vmcs_clear (vmx->loaded_vmcs);local_irq_disable (); -crash_disable_local_vmclear (cpu);/* -* Read loaded_vmcs->cpu should be before fetching -* loaded_vmcs->loaded_vmcss_on_cpu_link. -* See the comments in __loaded_vmcs_clear(). +* Ensure loaded_vmcs->cpu is read before adding loaded_vmcs to +* this cpu's percpu list, otherwise it may not yet be deleted +* from its previous cpu's percpu list. Pairs with the +* smb_wmb() in __loaded_vmcs_clear(). */ smp_rmb ();list_add (&vmx->loaded_vmcs->loaded_vmcss_on_cpu_link, &per_cpu (loaded_vmcss_on_cpu, cpu)); -crash_enable_local_vmclear (cpu);local_irq_enable (); }
@@ -2292,17 +2268,6 @@ static int hardware_enable(void)INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu));spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); -/* -* Now we can enable the vmclear operation in kdump -* since the loaded_vmcss_on_cpu list on this cpu -* has been initialized. -* -* Though the cpu is not in VMX operation now, there -* is no problem to enable the vmclear operation -* for the loaded_vmcss_on_cpu list is empty! -*/ -crash_enable_local_vmclear (cpu); -kvm_cpu_vmxon (phys_addr);if (enable_ept)ept_sync_global ();
Greg Kroah-Hartman
maintainerPATCH 137/254 KVM: VMX: Add a trampoline to fix VMREAD error handling
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 842f4be95899df22b5843ba1a7c8cf37e831a6e8 upstream.
Add a hand coded assembly trampoline to preserve volatile registers across vmread_error(), and to handle the calling convention differences between 64-bit and 32-bit due to asmlinkage on vmread_error(). Pass @field and @fault on the stack when invoking the trampoline to avoid clobbering volatile registers in the context of the inline assembly.
Calling vmread_error() directly from inline assembly is partially broken on 64-bit, and completely broken on 32-bit. On 64-bit, it will clobber %rdi and %rsi (used to pass @field and @fault) and any volatile regs written by vmread_error(). On 32-bit, asmlinkage means vmread_error() expects the parameters to be passed on the stack, not via regs.
Opportunistically zero out the result in the trampoline to save a few bytes of code for every VMREAD. A happy side effect of the trampoline is that the inline code footprint is reduced by three bytes on 64-bit due to PUSH/POP being more efficent (in terms of opcode bytes) than MOV.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/ops.h | 28 ++++++++++++++++----- arch/x86/kvm/vmx/vmenter.S | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 7 deletions(-)
arch/x86/kvm/vmx/ops.h +21 -7
@@ -12,7 +12,8 @@#define __ex (x) __kvm_handle_fault_on_reboot(x) -asmlinkage void vmread_error(unsigned long field, bool fault); +__attribute__((regparm (0 )))void vmread_error_trampoline (unsigned long field, +bool fault);void vmwrite_error (unsigned long field,unsigned long value);void vmclear_error (struct vmcs *vmcs,u64 phys_addr);void vmptrld_error (struct vmcs *vmcs,u64 phys_addr);
@@ -70,15 +71,28 @@ static __always_inline unsigned long __v asmvolatile ("1: vmread %2, %1\n\t" ".byte 0x3e\n\t" /* branch taken hint */ "ja 3f\n\t" -"mov %2, %%" _ASM_ARG1"\n\t" -"xor %%" _ASM_ARG2", %%" _ASM_ARG2"\n\t" -"2: call vmread_error\n\t" -"xor %k1, %k1\n\t" + +/* +* VMREAD failed. Push '0' for @fault, push the failing +* @field, and bounce through the trampoline to preserve +* volatile registers. +*/ +"push $0\n\t" +"push %2\n\t" +"2:call vmread_error_trampoline\n\t" + +/* +* Unwind the stack. Note, the trampoline zeros out the +* memory for @fault so that the result is '0' on error. +*/ +"pop %2\n\t" +"pop %1\n\t" "3:\n\t" +/* VMREAD faulted. As above, except push '1' for @fault. */ ".pushsection .fixup, \"ax\"\n\t" -"4: mov %2, %%" _ASM_ARG1"\n\t" -"mov $1, %%" _ASM_ARG2"\n\t" +"4: push $1\n\t" +"push %2\n\t" "jmp 2b\n\t" ".popsection\n\t" _ASM_EXTABLE(1b, 4b)
arch/x86/kvm/vmx/vmenter.S +58 -0
61 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 100/254 PCI/ASPM: Clear the correct bits when enabling L1 substates
In reply to Greg Kroah-HartmanFrom: Yicong Yang <[email protected]>
commit 58a3862a10a317a81097ab0c78aecebabb1704f5 upstream.
In pcie_config_aspm_l1ss(), we cleared the wrong bits when enabling ASPM L1 Substates. Instead of the L1.x enable bits (PCI_L1SS_CTL1_L1SS_MASK, 0xf), we cleared the Link Activation Interrupt Enable bit (PCI_L1SS_CAP_L1_PM_SS, 0x10).
Clear the L1.x enable bits before writing the new L1.x configuration.
--- drivers/pci/pcie/aspm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pcie/aspm.c +2 -2
@@ -747,9 +747,9 @@ static void pcie_config_aspm_l1ss(struct/* Enable what we need to enable */ pci_clear_and_set_dword (parent, up_cap_ptr +PCI_L1SS_CTL1 , -PCI_L1SS_CAP_L1_PM_SS , val); +PCI_L1SS_CTL1_L1SS_MASK , val);pci_clear_and_set_dword (child, dw_cap_ptr +PCI_L1SS_CTL1 , -PCI_L1SS_CAP_L1_PM_SS , val); +PCI_L1SS_CTL1_L1SS_MASK , val); }static void pcie_config_aspm_dev (struct pci_dev *pdev,u32 val)
Greg Kroah-Hartman
maintainerPATCH 101/254 PCI: Add boot interrupt quirk mechanism for Xeon chipsets
In reply to Greg Kroah-HartmanFrom: Sean V Kelley <[email protected]>
commit b88bf6c3b6ff77948c153cac4e564642b0b90632 upstream.
The following was observed by Kar Hin Ong with RT patchset:
Backtrace:
irq 19: nobody cared (try booting with the "irqpoll" option)
CPU: 0 PID: 3329 Comm: irq/34-nipalk Tainted:4.14.87-rt49 #1
Hardware name: National Instruments NI PXIe-8880/NI PXIe-8880,
BIOS 2.1.5f1 01/09/2020
Call Trace:
<IRQ>
? dump_stack+0x46/0x5e
? __report_bad_irq+0x2e/0xb0
? note_interrupt+0x242/0x290
? nNIKAL100_memoryRead16+0x8/0x10 [nikal]
? handle_irq_event_percpu+0x55/0x70
? handle_irq_event+0x4f/0x80
? handle_fasteoi_irq+0x81/0x180
? handle_irq+0x1c/0x30
? do_IRQ+0x41/0xd0
? common_interrupt+0x84/0x84
</IRQ>
...
handlers:
[<ffffffffb3297200>] irq_default_primary_handler threaded
[<ffffffffb3669180>] usb_hcd_irq
Disabling IRQ #19The problem being that this device is triggering boot interrupts due to threaded interrupt handling and masking of the IO-APIC. These boot interrupts are then forwarded on to the legacy PCH's PIRQ lines where there is no handler present for the device.
Whenever a PCI device fires interrupt (INTx) to Pin 20 of IOAPIC 2 (GSI 44), the kernel receives two interrupts:
1. Interrupt from Pin 20 of IOAPIC 2 -> Expected
2. Interrupt from Pin 19 of IOAPIC 1 -> UNEXPECTED
Quirks for disabling boot interrupts (preferred) or rerouting the handler exist but do not address these Xeon chipsets' mechanism:
https://lore.kernel.org/lkml/[email protected]/
Add a new mechanism via PCI CFG for those chipsets supporting CIPINTRC register's dis_intx_rout2ich bit.
--- drivers/pci/quirks.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 7 deletions(-)
drivers/pci/quirks.c +73 -7
@@ -1970,26 +1970,92 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_I/* * IO-APIC1 on 6300ESB generates boot interrupts, see Intel order no * 300641-004US, section 5.7.3. +* +* Core IO on Xeon E5 1600/2600/4600, see Intel order no 326509-003. +* Core IO on Xeon E5 v2, see Intel order no 329188-003. +* Core IO on Xeon E7 v2, see Intel order no 329595-002. +* Core IO on Xeon E5 v3, see Intel order no 330784-003. +* Core IO on Xeon E7 v3, see Intel order no 332315-001US. +* Core IO on Xeon E5 v4, see Intel order no 333810-002US. +* Core IO on Xeon E7 v4, see Intel order no 332315-001US. +* Core IO on Xeon D-1500, see Intel order no 332051-001. +* Core IO on Xeon Scalable, see Intel order no 610950. */ -#define INTEL_6300_IOAPIC_ABAR 0x40 +#define INTEL_6300_IOAPIC_ABAR 0x40/* Bus 0, Dev 29, Func 5 */ #define INTEL_6300_DISABLE_BOOT_IRQ (1<<14) +#define INTEL_CIPINTRC_CFG_OFFSET 0x14C/* Bus 0, Dev 5, Func 0 */ +#define INTEL_CIPINTRC_DIS_INTX_ICH (1<<25) +static void quirk_disable_intel_boot_interrupt (struct pci_dev *dev) {u16 pci_config_word; +u32 pci_config_dword;if (noioapicquirk)return ; -pci_read_config_word (dev,INTEL_6300_IOAPIC_ABAR , &pci_config_word); - pci_config_word |=INTEL_6300_DISABLE_BOOT_IRQ ; -pci_write_config_word (dev,INTEL_6300_IOAPIC_ABAR , pci_config_word); - +switch (dev->device) { +case PCI_DEVICE_ID_INTEL_ESB_10 : +pci_read_config_word (dev,INTEL_6300_IOAPIC_ABAR , + &pci_config_word); + pci_config_word |=INTEL_6300_DISABLE_BOOT_IRQ ; +pci_write_config_word (dev,INTEL_6300_IOAPIC_ABAR , + pci_config_word); +break ; +case 0x3c28 :/* Xeon E5 1600/2600/4600 */ +case 0x0e28 :/* Xeon E5/E7 V2 */ +case 0x2f28 :/* Xeon E5/E7 V3,V4 */ +case 0x6f28 :/* Xeon D-1500 */ +case 0x2034 :/* Xeon Scalable Family */ +pci_read_config_dword (dev,INTEL_CIPINTRC_CFG_OFFSET , + &pci_config_dword); + pci_config_dword |=INTEL_CIPINTRC_DIS_INTX_ICH ; +pci_write_config_dword (dev,INTEL_CIPINTRC_CFG_OFFSET , + pci_config_dword); +break ; +default : +return ; + }pci_info (dev,"disabled boot interrupts on device [%04x:%04x]\n" , dev->vendor, dev->device); } -DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_ESB_10 , quirk_disable_intel_boot_interrupt); -DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_ESB_10 , quirk_disable_intel_boot_interrupt); +/* +* Device 29 Func 5 Device IDs of IO-APIC +* containing ABAR—APIC1 Alternate Base Address Register +*/ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_ESB_10 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_ESB_10 , + quirk_disable_intel_boot_interrupt); + +/* +* Device 5 Func 0 Device IDs of Core IO modules/hubs +* containing Coherent Interface Protocol Interrupt Control +* +* Device IDs obtained from volume 2 datasheets of commented +* families above. +*/ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x3c28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0e28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x2f28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x6f28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x2034 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,0x3c28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,0x0e28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,0x2f28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,0x6f28 , + quirk_disable_intel_boot_interrupt); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_INTEL ,0x2034 , + quirk_disable_intel_boot_interrupt);/* Disable boot interrupts on HT-1000 */ #define BC_HT1000_FEATURE_REG 0x64
Greg Kroah-Hartman
maintainerPATCH 102/254 PCI: qcom: Fix the fixup of PCI_VENDOR_ID_QCOM
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
commit 604f3956524a6a53c1e3dd27b4b685b664d181ec upstream.
There exists non-bridge PCIe devices with PCI_VENDOR_ID_QCOM, so limit the fixup to only affect the relevant PCIe bridges.
--- drivers/pci/controller/dwc/pcie-qcom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom.c +7 -1
@@ -1439,7 +1439,13 @@ static void qcom_fixup_class(struct pci_ { dev->class =PCI_CLASS_BRIDGE_PCI <<8 ; } -DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,PCI_ANY_ID , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x0101 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x0104 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x0106 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x0107 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x0302 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x1000 , qcom_fixup_class); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_QCOM ,0x1001 , qcom_fixup_class);static struct platform_driver qcom_pcie_driver = { .probe = qcom_pcie_probe,
Greg Kroah-Hartman
maintainerPATCH 103/254 PCI: endpoint: Fix for concurrent memory allocation in OB address region
In reply to Greg Kroah-HartmanFrom: Kishon Vijay Abraham I <[email protected]>
commit 04e046ca57ebed3943422dee10eec9e73aec081e upstream.
pci-epc-mem uses a bitmap to manage the Endpoint outbound (OB) address region. This address region will be shared by multiple endpoint functions (in the case of multi function endpoint) and it has to be protected from concurrent access to avoid updating an inconsistent state.
Use a mutex to protect bitmap updates to prevent the memory allocation API from returning incorrect addresses.
--- drivers/pci/endpoint/pci-epc-mem.c | 10 ++++++++-- include/linux/pci-epc.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/pci/endpoint/pci-epc-mem.c +8 -2
@@ -79,6 +79,7 @@ int __pci_epc_mem_init(struct pci_epc *e mem->page_size = page_size; mem->pages = pages; mem->size = size; +mutex_init (&mem->lock); epc->mem = mem;
@@ -122,7 +123,7 @@ void __iomem *pci_epc_mem_alloc_addr(str phys_addr_t *phys_addr, size_t size) { int pageno; -void __iomem *virt_addr; +void __iomem *virt_addr =NULL ;struct pci_epc_mem *mem = epc->mem;unsigned int page_shift =ilog2 (mem->page_size);int order;
@@ -130,15 +131,18 @@ void __iomem *pci_epc_mem_alloc_addr(str size =ALIGN (size, mem->page_size); order =pci_epc_mem_get_order (mem, size); +mutex_lock (&mem->lock); pageno =bitmap_find_free_region (mem->bitmap, mem->pages, order);if (pageno <0 ) -return NULL ; + goto ret; *phys_addr = mem->phys_base + ((phys_addr_t )pageno << page_shift); virt_addr =ioremap (*phys_addr, size);if (!virt_addr)bitmap_release_region (mem->bitmap, pageno, order); +ret: +mutex_unlock (&mem->lock);return virt_addr; }EXPORT_SYMBOL_GPL (pci_epc_mem_alloc_addr);
@@ -164,7 +168,9 @@ void pci_epc_mem_free_addr(struct pci_ep pageno = (phys_addr - mem->phys_base) >> page_shift; size =ALIGN (size, mem->page_size); order =pci_epc_mem_get_order (mem, size); +mutex_lock (&mem->lock);bitmap_release_region (mem->bitmap, pageno, order); +mutex_unlock (&mem->lock); }EXPORT_SYMBOL_GPL (pci_epc_mem_free_addr);
include/linux/pci-epc.h +3 -0
@@ -71,6 +71,7 @@ struct pci_epc_ops {* @bitmap: bitmap to manage the PCI address space * @pages: number of bits representing the address region * @page_size: size of each page +* @lock: mutex to protect bitmap */ struct pci_epc_mem {phys_addr_t phys_base;
@@ -78,6 +79,8 @@ struct pci_epc_mem {unsigned long *bitmap;size_t page_size;int pages; +/* mutex to protect against concurrent access for memory allocation*/ +struct mutex lock; };/**
Greg Kroah-Hartman
maintainerPATCH 104/254 erofs: correct the remaining shrink objects
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 9d5a09c6f3b5fb85af20e3a34827b5d27d152b34 upstream.
The remaining count should not include successful
shrink attempts.
--- fs/erofs/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/utils.c +1 -1
@@ -286,7 +286,7 @@ static unsigned long erofs_shrink_scan(sspin_unlock (&erofs_sb_list_lock); sbi->shrinker_run_no = run_no; - freed +=erofs_shrink_workstation (sbi, nr); + freed +=erofs_shrink_workstation (sbi, nr - freed);spin_lock (&erofs_sb_list_lock);/* Get the next list element before we move this one */
Greg Kroah-Hartman
maintainerPATCH 148/254 btrfs: Dont submit any btree write bio if the fs has errors
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit b3ff8f1d380e65dddd772542aa9bff6c86bf715a upstream.
[BUG]
There is a fuzzed image which could cause KASAN report at unmount time.
BUG: KASAN: use-after-free in btrfs_queue_work+0x2c1/0x390 Read of size 8 at addr ffff888067cf6848 by task umount/1922 CPU: 0 PID: 1922 Comm: umount Tainted: G W 5.0.21 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: dump_stack+0x5b/0x8b print_address_description+0x70/0x280 kasan_report+0x13a/0x19b btrfs_queue_work+0x2c1/0x390 btrfs_wq_submit_bio+0x1cd/0x240 btree_submit_bio_hook+0x18c/0x2a0 submit_one_bio+0x1be/0x320 flush_write_bio.isra.41+0x2c/0x70 btree_write_cache_pages+0x3bb/0x7f0 do_writepages+0x5c/0x130 __writeback_single_inode+0xa3/0x9a0 writeback_single_inode+0x23d/0x390 write_inode_now+0x1b5/0x280 iput+0x2ef/0x600 close_ctree+0x341/0x750 generic_shutdown_super+0x126/0x370 kill_anon_super+0x31/0x50 btrfs_kill_super+0x36/0x2b0 deactivate_locked_super+0x80/0xc0 deactivate_super+0x13c/0x150 cleanup_mnt+0x9a/0x130 task_work_run+0x11a/0x1b0 exit_to_usermode_loop+0x107/0x130 do_syscall_64+0x1e5/0x280 entry_SYSCALL_64_after_hwframe+0x44/0xa9
[CAUSE]
The fuzzed image has a completely screwd up extent tree:
leaf 29421568 gen 8 total ptrs 6 free space 3587 owner EXTENT_TREE refs 2 lock (w:0 r:0 bw:0 br:0 sw:0 sr:0) lock_owner 0 current 5938
item 0 key (12587008 168 4096) itemoff 3942 itemsize 53
extent refs 1 gen 9 flags 1
ref#0: extent data backref root 5 objectid 259 offset 0 count 1
item 1 key (12591104 168 8192) itemoff 3889 itemsize 53
extent refs 1 gen 9 flags 1
ref#0: extent data backref root 5 objectid 271 offset 0 count 1
item 2 key (12599296 168 4096) itemoff 3836 itemsize 53
extent refs 1 gen 9 flags 1
ref#0: extent data backref root 5 objectid 259 offset 4096 count 1
item 3 key (29360128 169 0) itemoff 3803 itemsize 33
extent refs 1 gen 9 flags 2
ref#0: tree block backref root 5
item 4 key (29368320 169 1) itemoff 3770 itemsize 33
extent refs 1 gen 9 flags 2
ref#0: tree block backref root 5
item 5 key (29372416 169 0) itemoff 3737 itemsize 33
extent refs 1 gen 9 flags 2
ref#0: tree block backref root 5
Note that leaf 29421568 doesn't have its backref in the extent tree. Thus extent allocator can re-allocate leaf 29421568 for other trees.
In short, the bug is caused by:
- Existing tree block gets allocated to log tree
This got its generation bumped.
- Log tree balance cleaned dirty bit of offending tree block It will not be written back to disk, thus no WRITTEN flag.
- Original owner of the tree block gets COWed
Since the tree block has higher transid, no WRITTEN flag, it's reused, and not traced by transaction::dirty_pages.
- Transaction aborted
Tree blocks get cleaned according to transaction::dirty_pages. But the offending tree block is not recorded at all.
- Filesystem unmount
All pages are assumed to be are clean, destroying all workqueue, then call iput(btree_inode).
But offending tree block is still dirty, which triggers writeback, and causes use-after-free bug.
The detailed sequence looks like this:
- Initial status
eb: 29421568, header=WRITTEN bflags_dirty=0, page_dirty=0, gen=8,
not traced by any dirty extent_iot_tree.
- New tree block is allocated
Since there is no backref for 29421568, it's re-allocated as new tree block.
Keep in mind that tree block 29421568 is still referred by extent tree.
- Tree block 29421568 is filled for log tree
eb: 29421568, header=0 bflags_dirty=1, page_dirty=1, gen=9 << (gen bumped)
traced by btrfs_root::dirty_log_pages
- Some log tree operations
Since the fs is using node size 4096, the log tree can easily go a level higher.
- Log tree needs balance
Tree block 29421568 gets all its content pushed to right, thus now it is empty, and we don't need it. btrfs_clean_tree_block() from __push_leaf_right() get called.
eb: 29421568, header=0 bflags_dirty=0, page_dirty=0, gen=9
traced by btrfs_root::dirty_log_pages
- Log tree write back
btree_write_cache_pages() goes through dirty pages ranges, but since page of tree block 29421568 gets cleaned already, it's not written back to disk. Thus it doesn't have WRITTEN bit set.
But ranges in dirty_log_pages are cleared.
eb: 29421568, header=0 bflags_dirty=0, page_dirty=0, gen=9
not traced by any dirty extent_iot_tree.
- Extent tree update when committing transaction
Since tree block 29421568 has transid equal to running trans, and has no WRITTEN bit, should_cow_block() will use it directly without adding it to btrfs_transaction::dirty_pages.
eb: 29421568, header=0 bflags_dirty=1, page_dirty=1, gen=9
not traced by any dirty extent_iot_tree.
At this stage, we're doomed. We have a dirty eb not tracked by any extent io tree.
- Transaction gets aborted due to corrupted extent tree Btrfs cleans up dirty pages according to transaction::dirty_pages and btrfs_root::dirty_log_pages.
But since tree block 29421568 is not tracked by neither of them, it's still dirty.
eb: 29421568, header=0 bflags_dirty=1, page_dirty=1, gen=9
not traced by any dirty extent_iot_tree.
- Filesystem unmount
Since all cleanup is assumed to be done, all workqueus are destroyed. Then iput(btree_inode) is called, expecting no dirty pages. But tree 29421568 is still dirty, thus triggering writeback. Since all workqueues are already freed, we cause use-after-free.
This shows us that, log tree blocks + bad extent tree can cause wild dirty pages.
[FIX]
To fix the problem, don't submit any btree write bio if the filesytem has any error. This is the last safe net, just in case other cleanup haven't caught catch it.
--- fs/btrfs/extent_io.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
fs/btrfs/extent_io.c +34 -1
@@ -3905,6 +3905,7 @@ int btree_write_cache_pages(struct addre .extent_locked = 0, .sync_io = wbc->sync_mode == WB_SYNC_ALL, }; +struct btrfs_fs_info *fs_info =BTRFS_I (mapping->host)->root->fs_info;int ret =0 ;int done =0 ;int nr_to_write_done =0 ;
@@ -4018,7 +4019,39 @@ retry:end_write_bio (&epd, ret);return ret; } - ret =flush_write_bio (&epd); +/* +* If something went wrong, don't allow any metadata write bio to be +* submitted. +* +* This would prevent use-after-free if we had dirty pages not +* cleaned up, which can still happen by fuzzed images. +* +* - Bad extent tree +* Allowing existing tree block to be allocated for other trees. +* +* - Log tree operations +* Exiting tree blocks get allocated to log tree, bumps its +* generation, then get cleaned in tree re-balance. +* Such tree block will not be written back, since it's clean, +* thus no WRITTEN flag set. +* And after log writes back, this tree block is not traced by +* any dirty extent_io_tree. +* +* - Offending tree block gets re-dirtied from its original owner +* Since it has bumped generation, no WRITTEN flag, it can be +* reused without COWing. This tree block will not be traced +* by btrfs_transaction::dirty_pages. +* +* Now such dirty tree block will not be cleaned by any dirty +* extent io tree. Thus we don't want to submit such wild eb +* if the fs already has error. +*/ +if (!test_bit (BTRFS_FS_STATE_ERROR , &fs_info->fs_state)) { + ret =flush_write_bio (&epd); + }else { + ret = -EUCLEAN ; +end_write_bio (&epd, ret); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 149/254 btrfs: fix btrfs_calc_reclaim_metadata_size calculation
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit fa121a26b2ceabce613e0b4cfc7498cfde73fe8d upstream.
I noticed while running my snapshot torture test that we were getting a lot of metadata chunks allocated with very little actually used. Digging into this we would commit the transaction, still not have enough space, and then force a chunk allocation.
I noticed that we were barely flushing any delalloc at all, despite the fact that we had around 13gib of outstanding delalloc reservations. It turns out this is because of our btrfs_calc_reclaim_metadata_size() calculation. It _only_ takes into account the outstanding ticket sizes, which isn't the whole story. In this particular workload we're slowly filling up the disk, which means our overcommit space will suddenly become a lot less, and our outstanding reservations will be well more than what we can handle. However we are only flushing based on our ticket size, which is much less than we need to actually reclaim.
So fix btrfs_calc_reclaim_metadata_size() to take into account the overage in the case that we've gotten less available space suddenly. This makes it so we attempt to reclaim a lot more delalloc space, which allows us to make our reservations and we no longer are allocating a bunch of needless metadata chunks.
--- fs/btrfs/space-info.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-)
fs/btrfs/space-info.c +34 -9
@@ -159,25 +159,19 @@ static inline u64 calc_global_rsv_need_sreturn (global->size <<1 ); } -int btrfs_can_overcommit (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info,u64 bytes, -enum btrfs_reserve_flush_enum flush) +static u64 calc_available_free_space (struct btrfs_fs_info *fs_info, +struct btrfs_space_info *space_info, +enum btrfs_reserve_flush_enum flush) {u64 profile;u64 avail; -u64 used;int factor; -/* Don't overcommit when in mixed mode. */ -if (space_info->flags &BTRFS_BLOCK_GROUP_DATA ) -return 0 ; -if (space_info->flags &BTRFS_BLOCK_GROUP_SYSTEM ) profile =btrfs_system_alloc_profile (fs_info);else profile =btrfs_metadata_alloc_profile (fs_info); - used =btrfs_space_info_used (space_info, true); avail =atomic64_read (&fs_info->free_chunk_space);/*
@@ -198,6 +192,22 @@ int btrfs_can_overcommit(struct btrfs_fs avail >>=3 ; else avail >>= 1; +return avail; +} + +int btrfs_can_overcommit (struct btrfs_fs_info *fs_info, +struct btrfs_space_info *space_info,u64 bytes, +enum btrfs_reserve_flush_enum flush) +{ +u64 avail; +u64 used; + +/* Don't overcommit when in mixed mode */ +if (space_info->flags &BTRFS_BLOCK_GROUP_DATA ) +return 0 ; + + used =btrfs_space_info_used (space_info, true); + avail =calc_available_free_space (fs_info, space_info, flush);if (used + bytes < space_info->total_bytes + avail)return 1 ;
@@ -629,6 +639,7 @@ btrfs_calc_reclaim_metadata_size(struct {struct reserve_ticket *ticket;u64 used; +u64 avail;u64 expected;u64 to_reclaim =0 ;
@@ -636,6 +647,20 @@ btrfs_calc_reclaim_metadata_size(struct to_reclaim += ticket->bytes;list_for_each_entry (ticket, &space_info->priority_tickets, list) to_reclaim += ticket->bytes; + + avail =calc_available_free_space (fs_info, space_info, +BTRFS_RESERVE_FLUSH_ALL ); + used =btrfs_space_info_used (space_info, true); + +/* +* We may be flushing because suddenly we have less space than we had +* before, and now we're well over-committed based on our current free +* space. If that's the case add in our overage so we make sure to put +* appropriate pressure on the flushing state machine. +*/ +if (space_info->total_bytes + avail < used) + to_reclaim += used - (space_info->total_bytes + avail); +if (to_reclaim)return to_reclaim;
Greg Kroah-Hartman
maintainerPATCH 151/254 btrfs: reloc: clean dirty subvols if we fail to start a transaction
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 6217b0fadd4473a16fabc6aecd7527a9f71af534 upstream.
If we do merge_reloc_roots() we could insert a few roots onto the dirty subvol roots list, where we hold a ref on them. If we fail to start the transaction we need to run clean_dirty_subvols() in order to cleanup the refs.
--- fs/btrfs/relocation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/relocation.c +3 -3
@@ -4221,10 +4221,10 @@ restart: goto out_free; }btrfs_commit_transaction (trans); +out_free: ret =clean_dirty_subvols (rc);if (ret <0 && !err) err = ret; -out_free:btrfs_free_block_rsv (fs_info, rc->block_rsv);btrfs_free_path (path);return err;
@@ -4634,10 +4634,10 @@ int btrfs_recover_relocation(struct btrf trans =btrfs_join_transaction (rc->extent_root);if (IS_ERR (trans)) { err =PTR_ERR (trans); - goto out_free; + goto out_clean; } err =btrfs_commit_transaction (trans); - +out_clean: ret =clean_dirty_subvols (rc);if (ret <0 && !err) err = ret;
Greg Kroah-Hartman
maintainerPATCH 155/254 btrfs: unset reloc control if we fail to recover
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit fb2d83eefef4e1c717205bac71cb1941edf8ae11 upstream.
If we fail to load an fs root, or fail to start a transaction we can bail without unsetting the reloc control, which leads to problems later when we free the reloc control but still have it attached to the file system.
In the normal path we'll end up calling unset_reloc_control() twice, but all it does is set fs_info->reloc_control = NULL, and we can only have one balance at a time so it's not racey.
--- fs/btrfs/relocation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/relocation.c +5 -5
@@ -4593,9 +4593,8 @@ int btrfs_recover_relocation(struct btrf trans =btrfs_join_transaction (rc->extent_root);if (IS_ERR (trans)) { -unset_reloc_control (rc); err =PTR_ERR (trans); - goto out_free; + goto out_unset; } rc->merge_reloc_tree =1 ;
@@ -4615,7 +4614,7 @@ int btrfs_recover_relocation(struct btrfif (IS_ERR (fs_root)) { err =PTR_ERR (fs_root);list_add_tail (&reloc_root->root_list, &reloc_roots); - goto out_free; + goto out_unset; } err =__add_reloc_root (reloc_root);
@@ -4625,7 +4624,7 @@ int btrfs_recover_relocation(struct btrf err =btrfs_commit_transaction (trans);if (err) - goto out_free; + goto out_unset;merge_reloc_roots (rc);
@@ -4641,7 +4640,8 @@ out_clean: ret =clean_dirty_subvols (rc);if (ret <0 && !err) err = ret; -out_free: +out_unset: +unset_reloc_control (rc);kfree (rc); out:if (!list_empty (&reloc_roots))
Greg Kroah-Hartman
maintainerPATCH 158/254 remoteproc: qcom_q6v5_mss: Dont reassign mpss region on shutdown
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
commit 900fc60df22748dbc28e4970838e8f7b8f1013ce upstream.
Trying to reclaim mpss memory while the mba is not running causes the system to crash on devices with security fuses blown, so leave it assigned to the remote on shutdown and recover it on a subsequent boot.
--- drivers/remoteproc/qcom_q6v5_mss.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +24 -11
@@ -1001,11 +1001,6 @@ static void q6v5_mba_reclaim(struct q6v5writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); } - ret =q6v5_xfer_mem_ownership (qproc, &qproc->mpss_perm, - false, qproc->mpss_phys, - qproc->mpss_size); -WARN_ON (ret); -q6v5_reset_assert (qproc); q6v5_clk_disable(qproc->dev, qproc->reset_clks,
@@ -1095,6 +1090,14 @@ static int q6v5_mpss_load(struct q6v5 *q max_addr =ALIGN (phdr->p_paddr + phdr->p_memsz,SZ_4K ); } +/** +* In case of a modem subsystem restart on secure devices, the modem +* memory can be reclaimed only after MBA is loaded. For modem cold +* boot this will be a nop +*/ +q6v5_xfer_mem_ownership (qproc, &qproc->mpss_perm, false, + qproc->mpss_phys, qproc->mpss_size); + mpss_reloc = relocate ? min_addr : qproc->mpss_phys; qproc->mpss_reloc = mpss_reloc;/* Load firmware segments */
@@ -1184,8 +1187,16 @@ static void qcom_q6v5_dump_segment(strucvoid *ptr =rproc_da_to_va (rproc, segment->da, segment->size);/* Unlock mba before copying segments */ -if (!qproc->dump_mba_loaded) +if (!qproc->dump_mba_loaded) { ret =q6v5_mba_load (qproc); +if (!ret) { +/* Reset ownership back to Linux to copy segments */ + ret =q6v5_xfer_mem_ownership (qproc, &qproc->mpss_perm, + false, + qproc->mpss_phys, + qproc->mpss_size); + } + }if (!ptr || ret)memset (dest,0xff , segment->size);
@@ -1196,8 +1207,14 @@ static void qcom_q6v5_dump_segment(struc/* Reclaim mba after copying segments */ if (qproc->dump_segment_mask == qproc->dump_complete_mask) { -if (qproc->dump_mba_loaded) +if (qproc->dump_mba_loaded) { +/* Try to reset ownership back to Q6 */ +q6v5_xfer_mem_ownership (qproc, &qproc->mpss_perm, + true, + qproc->mpss_phys, + qproc->mpss_size);q6v5_mba_reclaim (qproc); + } } }
@@ -1237,10 +1254,6 @@ static int q6v5_start(struct rproc *rproreturn 0 ; reclaim_mpss: - xfermemop_ret =q6v5_xfer_mem_ownership (qproc, &qproc->mpss_perm, - false, qproc->mpss_phys, - qproc->mpss_size); -WARN_ON (xfermemop_ret);q6v5_mba_reclaim (qproc);return ret;
Greg Kroah-Hartman
maintainerPATCH 161/254 time/namespace: Fix time_for_children symlink
In reply to Greg Kroah-HartmanFrom: Michael Kerrisk (man-pages) <[email protected]>
commit b801f1e22c23c259d6a2c955efddd20370de19a6 upstream.
Looking at the contents of the /proc/PID/ns/time_for_children symlink shows an anomaly:
$ ls -l /proc/self/ns/* |awk '{print $9, $10, $11}'
...
/proc/self/ns/pid -> pid:[4026531836]
/proc/self/ns/pid_for_children -> pid:[4026531836]
/proc/self/ns/time -> time:[4026531834]
/proc/self/ns/time_for_children -> time_for_children:[4026531834]
/proc/self/ns/user -> user:[4026531837]
...The reference for 'time_for_children' should be a 'time' namespace, just as the reference for 'pid_for_children' is a 'pid' namespace. In other words, the above time_for_children link should read:
/proc/self/ns/time_for_children -> time:[4026531834]
--- kernel/time/namespace.c | 1 + 1 file changed, 1 insertion(+)
kernel/time/namespace.c +1 -0
@@ -446,6 +446,7 @@ const struct proc_ns_operations timens_oconst struct proc_ns_operations timens_for_children_operations = { .name ="time_for_children" , + .real_ns_name ="time" , .type =CLONE_NEWTIME , .get = timens_for_children_get, .put = timens_put,
Greg Kroah-Hartman
maintainerPATCH 164/254 crypto: mxs-dcp - fix scatterlist linearization for hash
In reply to Greg Kroah-HartmanFrom: Rosioru Dragos <[email protected]>
commit fa03481b6e2e82355c46644147b614f18c7a8161 upstream.
The incorrect traversal of the scatterlist, during the linearization phase lead to computing the hash value of the wrong input buffer. New implementation uses scatterwalk_map_and_copy()
to address this issue.
--- drivers/crypto/mxs-dcp.c | 54 ++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 28 deletions(-)
drivers/crypto/mxs-dcp.c +26 -28
@@ -20,6 +20,7 @@#include <crypto/sha.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> +#include <crypto/scatterwalk.h> #define DCP_MAX_CHANS 4#define DCP_BUF_SZ PAGE_SIZE
@@ -611,49 +612,46 @@ static int dcp_sha_req_to_buf(struct crystruct dcp_async_ctx *actx =crypto_ahash_ctx (tfm);struct dcp_sha_req_ctx *rctx =ahash_request_ctx (req);struct hash_alg_common *halg =crypto_hash_alg_common (tfm); -const int nents =sg_nents (req->src);uint8_t *in_buf = sdcp->coh->sha_in_buf;uint8_t *out_buf = sdcp->coh->sha_out_buf; -uint8_t *src_buf; -struct scatterlist *src; -unsigned int i, len, clen; +unsigned int i, len, clen, oft =0 ;int ret;int fin = rctx->fini;if (fin) rctx->fini =0 ; -for_each_sg (req->src, src, nents, i) { - src_buf =sg_virt (src); - len =sg_dma_len (src); + src = req->src; + len = req->nbytes; -do { -if (actx->fill + len >DCP_BUF_SZ ) - clen =DCP_BUF_SZ - actx->fill; -else - clen = len; +while (len) { +if (actx->fill + len >DCP_BUF_SZ ) + clen =DCP_BUF_SZ - actx->fill; +else + clen = len; -memcpy (in_buf + actx->fill, src_buf, clen); - len -= clen; - src_buf += clen; - actx->fill += clen; +scatterwalk_map_and_copy (in_buf + actx->fill, src, oft, clen, +0 ); -/* -* If we filled the buffer and still have some -* more data, submit the buffer. -*/ -if (len && actx->fill ==DCP_BUF_SZ ) { - ret =mxs_dcp_run_sha (req); -if (ret) -return ret; - actx->fill =0 ; - rctx->init =0 ; - } - }while (len); + len -= clen; + oft += clen; + actx->fill += clen; + +/* +* If we filled the buffer and still have some +* more data, submit the buffer. +*/ +if (len && actx->fill ==DCP_BUF_SZ ) { + ret =mxs_dcp_run_sha (req); +if (ret) +return ret; + actx->fill =0 ; + rctx->init =0 ; + } }if (fin) {
Greg Kroah-Hartman
maintainerPATCH 165/254 io_uring: honor original task RLIMIT_FSIZE
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 4ed734b0d0913e566a9d871e15d24eb240f269f7 upstream.
With the previous fixes for number of files open checking, I added some debug code to see if we had other spots where we're checking rlimit() against the async io-wq workers. The only one I found was file size checking, which we should also honor.
During write and fallocate prep, store the max file size and override that for the current ask if we're in io-wq worker context.
--- fs/io_uring.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/io_uring.c +13 -0
@@ -565,6 +565,7 @@ struct io_kiocb {struct list_head link_list;unsigned int flags;refcount_t refs; +unsigned long fsize;u64 user_data;u32 result;u32 sequence;
@@ -2294,6 +2295,8 @@ static int io_write_prep(struct io_kiocbif (unlikely (!(req->file->f_mode &FMODE_WRITE )))return -EBADF ; + req->fsize =rlimit (RLIMIT_FSIZE ); +/* either don't need iovec imported or already have it */ if (!req->io || req->flags &REQ_F_NEED_CLEANUP )return 0 ;
@@ -2366,10 +2369,17 @@ static int io_write(struct io_kiocb *req } kiocb->ki_flags |=IOCB_WRITE ; +if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur = req->fsize; +if (req->file->f_op->write_iter) ret2 =call_write_iter (req->file, kiocb, &iter);else ret2 =loop_rw_iter (WRITE , req->file, kiocb, &iter); + +if (!force_nonblock) + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur =RLIM_INFINITY ; +/* * Raw bdev writes will -EOPNOTSUPP for IOCB_NOWAIT. Just * retry them without IOCB_NOWAIT.
@@ -2512,8 +2522,10 @@ static void io_fallocate_finish(struct iif (io_req_cancelled (req))return ; + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur = req->fsize; ret =vfs_fallocate (req->file, req->sync.mode, req->sync.off, req->sync.len); + current->signal->rlim[RLIMIT_FSIZE ].rlim_cur =RLIM_INFINITY ;if (ret <0 )req_set_fail_links (req);io_cqring_add_event (req, ret);
@@ -2531,6 +2543,7 @@ static int io_fallocate_prep(struct io_k req->sync.off =READ_ONCE (sqe->off); req->sync.len =READ_ONCE (sqe->addr); req->sync.mode =READ_ONCE (sqe->len); + req->fsize =rlimit (RLIMIT_FSIZE );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 170/254 sched/core: Remove duplicate assignment in sched_tick_remote()
In reply to Greg Kroah-HartmanFrom: Scott Wood <[email protected]>
commit 82e0516ce3a147365a5dd2a9bedd5ba43a18663d upstream.
A redundant "curr = rq->curr" was added; remove it.
--- kernel/sched/core.c | 1 - 1 file changed, 1 deletion(-)
kernel/sched/core.c +0 -1
@@ -3671,7 +3671,6 @@ static void sched_tick_remote(struct worif (cpu_is_offline (cpu)) goto out_unlock; - curr = rq->curr;update_rq_clock (rq);if (!is_idle_task (curr)) {
Greg Kroah-Hartman
maintainerPATCH 173/254 dm writecache: add cond_resched to avoid CPU hangs
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 1edaa447d958bec24c6a79685a5790d98976fd16 upstream.
Initializing a dm-writecache device can take a long time when the persistent memory device is large. Add cond_resched() to a few loops to avoid warnings that the CPU is stuck.
--- drivers/md/dm-writecache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/dm-writecache.c +5 -1
@@ -876,6 +876,7 @@ static int writecache_alloc_entries(strustruct wc_entry *e = &wc->entries[b]; e->index = b; e->write_in_progress = false; +cond_resched (); }return 0 ;
@@ -930,6 +931,7 @@ static void writecache_resume(struct dm_ e->original_sector =le64_to_cpu (wme.original_sector); e->seq_count = le64_to_cpu(wme.seq_count); } +cond_resched (); }#endif for (b =0 ; b < wc->n_blocks; b++) {
@@ -1791,8 +1793,10 @@ static int init_memory(struct dm_writecapmem_assign (sb (wc)->n_blocks,cpu_to_le64 (wc->n_blocks));pmem_assign (sb (wc)->seq_count,cpu_to_le64 (0 )); -for (b =0 ; b < wc->n_blocks; b++) +for (b =0 ; b < wc->n_blocks; b++) {write_original_sector_seq_count (wc, &wc->entries[b],-1 ,-1 ); +cond_resched (); + }writecache_flush_all_metadata (wc);writecache_commit_flushed (wc, false);
Greg Kroah-Hartman
maintainerPATCH 174/254 dm integrity: fix a crash with unusually large tag size
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit b93b6643e9b5a7f260b931e97f56ffa3fa65e26d upstream.
If the user specifies tag size larger than HASH_MAX_DIGESTSIZE, there's a crash in integrity_metadata().
--- drivers/md/dm-integrity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-integrity.c +2 -2
@@ -1519,7 +1519,7 @@ static void integrity_metadata(struct wostruct bio *bio =dm_bio_from_per_bio_data (dio,sizeof (struct dm_integrity_io ));char *checksums;unsigned extra_space =unlikely (digest_size > ic->tag_size) ? digest_size - ic->tag_size :0 ; -char checksums_onstack[HASH_MAX_DIGESTSIZE ]; +char checksums_onstack[max ((size_t )HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];unsigned sectors_to_process = dio->range.n_sectors;sector_t sector = dio->range.logical_sector;
@@ -1748,7 +1748,7 @@ retry_kmap: }while (++s < ic->sectors_per_block);#ifdef INTERNAL_VERIFY if (ic->internal_hash) { -char checksums_onstack[max (HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )]; +char checksums_onstack[max ((size_t )HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];integrity_sector_checksum (ic, logical_sector, mem + bv.bv_offset, checksums_onstack);if (unlikely (memcmp (checksums_onstack,journal_entry_tag (ic, je), ic->tag_size))) {
Greg Kroah-Hartman
maintainerPATCH 178/254 dm clone: Add overflow check for number of regions
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit cd481c12269b4d276f1a52eda0ebd419079bfe3a upstream.
Add overflow check for clone->nr_regions variable, which holds the number of regions of the target.
The overflow can occur with sufficiently large devices, if BITS_PER_LONG == 32. E.g., if the region size is 8 sectors (4K), the overflow would occur for device sizes > 34359738360 sectors (~16TB).
This could result in multiple device sectors wrongly mapping to the same region number, due to the truncation from 64 bits to 32 bits, which would lead to data corruption.
--- drivers/md/dm-clone-target.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/md/dm-clone-target.c +11 -1
@@ -1790,6 +1790,7 @@ error:static int clone_ctr (struct dm_target *ti,unsigned int argc,char **argv) {int r; +sector_t nr_regions;struct clone *clone;struct dm_arg_set as;
@@ -1831,7 +1832,16 @@ static int clone_ctr(struct dm_target *t goto out_with_source_dev; clone->region_shift =__ffs (clone->region_size); - clone->nr_regions =dm_sector_div_up (ti->len, clone->region_size); + nr_regions =dm_sector_div_up (ti->len, clone->region_size); + +/* Check for overflow */ +if (nr_regions != (unsigned long )nr_regions) { + ti->error ="Too many regions. Consider increasing the region size" ; + r = -EOVERFLOW ; + goto out_with_source_dev; + } + + clone->nr_regions = nr_regions; r =validate_nr_regions (clone->nr_regions, &ti->error);if (r)
Greg Kroah-Hartman
maintainerPATCH 180/254 dm clone metadata: Fix return type of dm_clone_nr_of_hydrated_regions()
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit 81d5553d1288c2ec0390f02f84d71ca0f0f9f137 upstream.
dm_clone_nr_of_hydrated_regions() returns the number of regions that have been hydrated so far. In order to do so it employs bitmap_weight().
Until now, the return type of dm_clone_nr_of_hydrated_regions() was unsigned long.
Because bitmap_weight() returns an int, in case BITS_PER_LONG == 64 and the return value of bitmap_weight() is 2^31 (the maximum allowed number of regions for a device), the result is sign extended from 32 bits to 64 bits and an incorrect value is displayed, in the status output of dm-clone, as the number of hydrated regions.
Fix this by having dm_clone_nr_of_hydrated_regions() return an unsigned int.
--- drivers/md/dm-clone-metadata.c | 2 +- drivers/md/dm-clone-metadata.h | 2 +- drivers/md/dm-clone-target.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-clone-metadata.c +1 -1
@@ -656,7 +656,7 @@ bool dm_clone_is_range_hydrated(struct dreturn (bit >= (start + nr_regions)); } -unsigned long dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd) +unsigned int dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd) {return bitmap_weight (cmd->region_map, cmd->nr_regions); }
drivers/md/dm-clone-metadata.h +1 -1
@@ -156,7 +156,7 @@ bool dm_clone_is_range_hydrated(struct d/* * Returns the number of hydrated regions. */ -unsigned long dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd); +unsigned int dm_clone_nr_of_hydrated_regions (struct dm_clone_metadata *cmd);/* * Returns the first unhydrated region with region_nr >= @start
drivers/md/dm-clone-target.c +1 -1
@@ -1473,7 +1473,7 @@ static void clone_status(struct dm_targe goto error; } - DMEMIT("%u %llu/%llu %llu %lu/%lu %u ", + DMEMIT("%u %llu/%llu %llu %u/%lu %u ", DM_CLONE_METADATA_BLOCK_SIZE, (unsigned long long)(nr_metadata_blocks - nr_free_metadata_blocks), (unsigned long long)nr_metadata_blocks,
Greg Kroah-Hartman
maintainerPATCH 181/254 XArray: Fix xas_pause for large multi-index entries
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit c36d451ad386b34f452fc3c8621ff14b9eaa31a6 upstream.
Inspired by the recent Coverity report, I looked for other places where the offset wasn't being converted to an unsigned long before being shifted, and I found one in xas_pause() when the entry being paused is of order >32.
--- lib/test_xarray.c | 37 +++++++++++++++++++++++++++++++++++++ lib/xarray.c | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-)
lib/test_xarray.c +37 -0
@@ -1156,6 +1156,42 @@ static noinline void check_find_entry(stXA_BUG_ON (xa, !xa_empty (xa)); } +static noinline void check_pause(struct xarray *xa) +{ +XA_STATE (xas, xa,0 ); +void *entry; +unsigned int order; +unsigned long index =1 ; +unsigned int count =0 ; + +for (order =0 ; order < order_limit; order++) { +XA_BUG_ON (xa,xa_store_order (xa, index, order, +xa_mk_index (index),GFP_KERNEL )); + index +=1UL << order; + } + +rcu_read_lock (); +xas_for_each (&xas, entry,ULONG_MAX ) { +XA_BUG_ON (xa, entry !=xa_mk_index (1UL << count)); + count++; + } +rcu_read_unlock (); +XA_BUG_ON (xa, count != order_limit); + + count =0 ; +xas_set (&xas,0 ); +rcu_read_lock (); +xas_for_each (&xas, entry,ULONG_MAX ) { +XA_BUG_ON (xa, entry !=xa_mk_index (1UL << count)); + count++; +xas_pause (&xas); + } +rcu_read_unlock (); +XA_BUG_ON (xa, count != order_limit); + +xa_destroy (xa); +} + static noinline void check_move_tiny(struct xarray *xa) {XA_STATE (xas, xa,0 );
@@ -1664,6 +1700,7 @@ static int xarray_checks(void)check_xa_alloc ();check_find (&array);check_find_entry (&array); +check_pause (&array);check_account (&array);check_destroy (&array);check_move (&array);
lib/xarray.c +1 -1
@@ -970,7 +970,7 @@ void xas_pause(struct xa_state *xas) xas->xa_node =XAS_RESTART ;if (node) { -unsigned int offset = xas->xa_offset; +unsigned long offset = xas->xa_offset;while (++offset <XA_CHUNK_SIZE ) {if (!xa_is_sibling (xa_entry (xas->xa, node, offset)))break ;
Greg Kroah-Hartman
maintainerPATCH 179/254 dm clone: Add missing casts to prevent overflows and data corruption
In reply to Greg Kroah-HartmanFrom: Nikos Tsironis <[email protected]>
commit 9fc06ff56845cc5ccafec52f545fc2e08d22f849 upstream.
Add missing casts when converting from regions to sectors.
In case BITS_PER_LONG == 32, the lack of the appropriate casts can lead to overflows and miscalculation of the device sector.
As a result, we could end up discarding and/or copying the wrong parts of the device, thus corrupting the device's data.
--- drivers/md/dm-clone-target.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/dm-clone-target.c +6 -3
@@ -282,7 +282,7 @@ static bool bio_triggers_commit(struct c/* Get the address of the region in sectors */ static inline sector_t region_to_sector (struct clone *clone,unsigned long region_nr) { -return (region_nr << clone->region_shift); +return ((sector_t )region_nr << clone->region_shift); }/* Get the region number of the bio */
@@ -471,7 +471,7 @@ static void complete_discard_bio(structif (test_bit (DM_CLONE_DISCARD_PASSDOWN , &clone->flags) && success) {remap_to_dest (clone, bio);bio_region_range (clone, bio, &rs, &nr_regions); -trim_bio (bio, rs << clone->region_shift, +trim_bio (bio,region_to_sector (clone, rs), nr_regions << clone->region_shift);generic_make_request (bio); }else
@@ -804,11 +804,14 @@ static void hydration_copy(struct dm_clostruct dm_io_region from, to;struct clone *clone = hd->clone; +if (WARN_ON (!nr_regions)) +return ; + region_size = clone->region_size; region_start = hd->region_nr; region_end = region_start + nr_regions -1 ; - total_size = (nr_regions -1 ) << clone->region_shift; + total_size =region_to_sector (clone, nr_regions -1 );if (region_end == clone->nr_regions -1 ) {/*
Greg Kroah-Hartman
maintainerPATCH 147/254 drm/i915/gen12: Disable preemption timeout
In reply to Greg Kroah-HartmanFrom: Tvrtko Ursulin <[email protected]>
commit 07bcfd1291de77ffa9b627b4442783aba1335229 upstream.
Allow super long OpenCL workloads which cannot be preempted within the default timeout to run out of the box.
v2:
* Make it stick out more and apply only to RCS. (Chris)
v3:
* Mention platform override in kconfig. (Joonas)
--- drivers/gpu/drm/i915/Kconfig.profile | 4 ++++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/Kconfig.profile +4 -0
@@ -35,6 +35,10 @@ config DRM_I915_PREEMPT_TIMEOUT May be 0 to disable the timeout. + The compiled in default may get overridden at driver probe time on + certain platforms and certain engines which will be reflected in the + sysfs control. + config DRM_I915_SPIN_REQUEST int "Busywait for request completion (us)" default 5 # microseconds
drivers/gpu/drm/i915/gt/intel_engine_cs.c +9 -4
@@ -274,6 +274,7 @@ static void intel_engine_sanitize_mmio(sstatic int intel_engine_setup (struct intel_gt *gt,enum intel_engine_id id) {const struct engine_info *info = &intel_engines[id]; +struct drm_i915_private *i915 = gt->i915;struct intel_engine_cs *engine;BUILD_BUG_ON (MAX_ENGINE_CLASS >=BIT (GEN11_ENGINE_CLASS_WIDTH ));
@@ -300,11 +301,11 @@ static int intel_engine_setup(struct int engine->id = id; engine->legacy_idx =INVALID_ENGINE ; engine->mask =BIT (id); - engine->i915 = gt->i915; + engine->i915 = i915; engine->gt = gt; engine->uncore = gt->uncore; engine->hw_id = engine->guc_id = info->hw_id; - engine->mmio_base =__engine_mmio_base (gt->i915, info->mmio_bases); + engine->mmio_base =__engine_mmio_base (i915, info->mmio_bases); engine->class = info->class; engine->instance = info->instance;
@@ -319,11 +320,15 @@ static int intel_engine_setup(struct int engine->props.timeslice_duration_ms =CONFIG_DRM_I915_TIMESLICE_DURATION ; +/* Override to uninterruptible for OpenCL workloads. */ +if (INTEL_GEN (i915) ==12 && engine->class ==RENDER_CLASS ) + engine->props.preempt_timeout_ms =0 ; + engine->context_size =intel_engine_context_size (gt, engine->class);if (WARN_ON (engine->context_size >BIT (20 ))) engine->context_size =0 ;if (engine->context_size) -DRIVER_CAPS (gt->i915)->has_logical_contexts = true; +DRIVER_CAPS (i915)->has_logical_contexts = true;/* Nothing to do here, execute in order of dependencies */ engine->schedule =NULL ;
@@ -339,7 +344,7 @@ static int intel_engine_setup(struct int gt->engine_class[info->class][info->instance] = engine; gt->engine[id] = engine; - gt->i915->engine[id] = engine; + i915->engine[id] = engine;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 183/254 crypto: caam/qi2 - fix chacha20 data size error
In reply to Greg Kroah-HartmanFrom: Horia Geantă <[email protected]>
commit 3a5a9e1ef37b030b836d92df8264f840988f4a38 upstream.
HW generates a Data Size error for chacha20 requests that are not a multiple of 64B, since algorithm state (AS) does not have the FINAL bit set.
Since updating req->iv (for chaining) is not required, modify skcipher descriptors to set the FINAL bit for chacha20.
[Note that for skcipher decryption we know that ctx1_iv_off is 0, which allows for an optimization by not checking algorithm type, since append_dec_op1() sets FINAL bit for all algorithms except AES.]
Also drop the descriptor operations that save the IV. However, in order to keep code logic simple, things like S/G tables generation etc. are not touched.
--- drivers/crypto/caam/caamalg_desc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/crypto/caam/caamalg_desc.c +10 -4
@@ -1379,6 +1379,9 @@ void cnstr_shdsc_skcipher_encap(u32 * co const u32 ctx1_iv_off) {u32 *key_jump_cmd; +u32 options = cdata->algtype |OP_ALG_AS_INIT |OP_ALG_ENCRYPT ; +bool is_chacha20 = ((cdata->algtype &OP_ALG_ALGSEL_MASK ) == +OP_ALG_ALGSEL_CHACHA20 );init_sh_desc (desc,HDR_SHARE_SERIAL |HDR_SAVECTX );/* Skip if already shared */
@@ -1417,14 +1420,15 @@ void cnstr_shdsc_skcipher_encap(u32 * co LDST_OFFSET_SHIFT));/* Load operation */ -append_operation (desc, cdata->algtype |OP_ALG_AS_INIT | -OP_ALG_ENCRYPT ); +if (is_chacha20) + options |=OP_ALG_AS_FINALIZE ; +append_operation (desc, options);/* Perform operation */ skcipher_append_src_dst (desc);/* Store IV */ -if (ivsize) +if (!is_chacha20 && ivsize)append_seq_store (desc, ivsize,LDST_SRCDST_BYTE_CONTEXT |LDST_CLASS_1_CCB | (ctx1_iv_off <<LDST_OFFSET_SHIFT ));
@@ -1451,6 +1455,8 @@ void cnstr_shdsc_skcipher_decap(u32 * co const u32 ctx1_iv_off) {u32 *key_jump_cmd; +bool is_chacha20 = ((cdata->algtype &OP_ALG_ALGSEL_MASK ) == +OP_ALG_ALGSEL_CHACHA20 );init_sh_desc (desc,HDR_SHARE_SERIAL |HDR_SAVECTX );/* Skip if already shared */
@@ -1499,7 +1505,7 @@ void cnstr_shdsc_skcipher_decap(u32 * coskcipher_append_src_dst (desc);/* Store IV */ -if (ivsize) +if (!is_chacha20 && ivsize)append_seq_store (desc, ivsize,LDST_SRCDST_BYTE_CONTEXT |LDST_CLASS_1_CCB | (ctx1_iv_off <<LDST_OFFSET_SHIFT ));
Greg Kroah-Hartman
maintainerPATCH 184/254 crypto: caam - update xts sector size for large input length
In reply to Greg Kroah-HartmanFrom: Andrei Botila <[email protected]>
commit 3f142b6a7b573bde6cff926f246da05652c61eb4 upstream.
Since in the software implementation of XTS-AES there is no notion of sector every input length is processed the same way. CAAM implementation has the notion of sector which causes different results between the software implementation and the one in CAAM for input lengths bigger than 512 bytes.
Increase sector size to maximum value on 16 bits.
--- drivers/crypto/caam/caamalg_desc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/caam/caamalg_desc.c +14 -2
@@ -1524,7 +1524,13 @@ EXPORT_SYMBOL(cnstr_shdsc_skcipher_decap*/ void cnstr_shdsc_xts_skcipher_encap (u32 *const desc,struct alginfo *cdata) { -__be64 sector_size =cpu_to_be64 (512 ); +/* +* Set sector size to a big value, practically disabling +* sector size segmentation in xts implementation. We cannot +* take full advantage of this HW feature with existing +* crypto API / dm-crypt SW architecture. +*/ +__be64 sector_size =cpu_to_be64 (BIT (15 ));u32 *key_jump_cmd;init_sh_desc (desc,HDR_SHARE_SERIAL |HDR_SAVECTX );
@@ -1577,7 +1583,13 @@ EXPORT_SYMBOL(cnstr_shdsc_xts_skcipher_e*/ void cnstr_shdsc_xts_skcipher_decap (u32 *const desc,struct alginfo *cdata) { -__be64 sector_size =cpu_to_be64 (512 ); +/* +* Set sector size to a big value, practically disabling +* sector size segmentation in xts implementation. We cannot +* take full advantage of this HW feature with existing +* crypto API / dm-crypt SW architecture. +*/ +__be64 sector_size =cpu_to_be64 (BIT (15 ));u32 *key_jump_cmd;init_sh_desc (desc,HDR_SHARE_SERIAL |HDR_SAVECTX );
Greg Kroah-Hartman
maintainerPATCH 202/254 drm/etnaviv: rework perfmon query infrastructure
In reply to Greg Kroah-HartmanFrom: Christian Gmeiner <[email protected]>
commit ed1dd899baa32d47d9a93d98336472da50564346 upstream.
Report the correct perfmon domains and signals depending on the supported feature flags.
--- drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 59 ++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 7 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +52 -7
@@ -32,6 +32,7 @@ struct etnaviv_pm_domain { };struct etnaviv_pm_domain_meta { +unsigned int feature;const struct etnaviv_pm_domain *domains;u32 nr_domains; };
@@ -410,36 +411,78 @@ static const struct etnaviv_pm_domain dostatic const struct etnaviv_pm_domain_meta doms_meta[] = { { + .feature = chipFeatures_PIPE_3D, .nr_domains =ARRAY_SIZE (doms_3d), .domains = &doms_3d[0 ] }, { + .feature = chipFeatures_PIPE_2D, .nr_domains =ARRAY_SIZE (doms_2d), .domains = &doms_2d[0 ] }, { + .feature = chipFeatures_PIPE_VG, .nr_domains =ARRAY_SIZE (doms_vg), .domains = &doms_vg[0 ] } }; +static unsigned int num_pm_domains (const struct etnaviv_gpu *gpu) +{ +unsigned int num =0 , i; + +for (i =0 ; i <ARRAY_SIZE (doms_meta); i++) { +const struct etnaviv_pm_domain_meta *meta = &doms_meta[i]; + +if (gpu->identity.features & meta->feature) + num += meta->nr_domains; + } + +return num; +} + +static const struct etnaviv_pm_domain *pm_domain (const struct etnaviv_gpu *gpu, +unsigned int index) +{ +const struct etnaviv_pm_domain *domain =NULL ; +unsigned int offset =0 , i; + +for (i =0 ; i <ARRAY_SIZE (doms_meta); i++) { +const struct etnaviv_pm_domain_meta *meta = &doms_meta[i]; + +if (!(gpu->identity.features & meta->feature)) +continue ; + +if (meta->nr_domains < (index - offset)) { + offset += meta->nr_domains; +continue ; + } + + domain = meta->domains + (index - offset); + } + +return domain; +} +int etnaviv_pm_query_dom (struct etnaviv_gpu *gpu,struct drm_etnaviv_pm_domain *domain) { -const struct etnaviv_pm_domain_meta *meta = &doms_meta[domain->pipe]; +const unsigned int nr_domains =num_pm_domains (gpu);const struct etnaviv_pm_domain *dom; -if (domain->iter >= meta->nr_domains) +if (domain->iter >= nr_domains)return -EINVAL ; - dom = meta->domains + domain->iter; + dom =pm_domain (gpu, domain->iter); +if (!dom) +return -EINVAL ; domain->id = domain->iter; domain->nr_signals = dom->nr_signals;strncpy (domain->name, dom->name,sizeof (domain->name)); domain->iter++; -if (domain->iter == meta->nr_domains) +if (domain->iter == nr_domains) domain->iter =0xff ;return 0 ;
@@ -448,14 +491,16 @@ int etnaviv_pm_query_dom(struct etnaviv_int etnaviv_pm_query_sig (struct etnaviv_gpu *gpu,struct drm_etnaviv_pm_signal *signal) { -const struct etnaviv_pm_domain_meta *meta = &doms_meta[signal->pipe]; +const unsigned int nr_domains =num_pm_domains (gpu);const struct etnaviv_pm_domain *dom;const struct etnaviv_pm_signal *sig; -if (signal->domain >= meta->nr_domains) +if (signal->domain >= nr_domains)return -EINVAL ; - dom = meta->domains + signal->domain; + dom =pm_domain (gpu, signal->domain); +if (!dom) +return -EINVAL ;if (signal->iter >= dom->nr_signals)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 207/254 drm/amd/display: Check for null fclk voltage when parsing clock table
In reply to Greg Kroah-HartmanFrom: Michael Strauss <[email protected]>
commit 72f5b5a308c744573fdbc6c78202c52196d2c162 upstream.
[WHY]
In cases where a clock table is malformed such that fclk entries have frequencies but not voltages listed, we don't catch the error and set clocks to 0 instead of using hardcoded values as we should.
[HOW]
Add check for clock tables fclk entry's voltage as well
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +1 -1
@@ -643,7 +643,7 @@ static void rn_clk_mgr_helper_populate_b/* Find lowest DPM, FCLK is filled in reverse order*/ for (i =PP_SMU_NUM_FCLK_DPM_LEVELS -1 ; i >=0 ; i--) { -if (clock_table->FClocks[i].Freq !=0 ) { +if (clock_table->FClocks[i].Freq !=0 && clock_table->FClocks[i].Vol !=0 ) { j = i;break ; }
Greg Kroah-Hartman
maintainerPATCH 209/254 drm/i915/icl+: Dont enable DDI IO power on a TypeC port in TBT mode
In reply to Greg Kroah-HartmanFrom: Imre Deak <[email protected]>
commit 6e8a36c13382b7165d23928caee8d91c1b301142 upstream.
The DDI IO power well must not be enabled for a TypeC port in TBT mode, ensure this during driver loading/system resume.
This gets rid of error messages like
[drm] *ERROR* power well DDI E TC2 IO state mismatch (refcount 1/enabled 0)
and avoids leaking the power ref when disabling the output.
--- drivers/gpu/drm/i915/display/intel_ddi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_ddi.c +5 -1
@@ -2225,7 +2225,11 @@ static void intel_ddi_get_power_domains(return ; dig_port =enc_to_dig_port (encoder); -intel_display_power_get (dev_priv, dig_port->ddi_io_power_domain); + +if (!intel_phy_is_tc (dev_priv, phy) || + dig_port->tc_mode !=TC_PORT_TBT_ALT ) +intel_display_power_get (dev_priv, + dig_port->ddi_io_power_domain);/* * AUX power is only needed for (e)DP mode, and for HDMI mode on TC
Greg Kroah-Hartman
maintainerPATCH 211/254 drm/vboxvideo: Add missing remove_conflicting_pci_framebuffers call, v2
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit a65a97b48694d34248195eb89bf3687403261056 upstream.
The vboxvideo driver is missing a call to remove conflicting framebuffers.
Surprisingly, when using legacy BIOS booting this does not really cause any issues. But when using UEFI to boot the VM then plymouth will draw on both the efifb /dev/fb0 and /dev/drm/card0 (which has registered /dev/fb1 as fbdev emulation).
VirtualBox will actual display the output of both devices (I guess it is showing whatever was drawn last), this causes weird artifacts because of pitch issues in the efifb when the VM window is not sized at 1024x768 (the window will resize to its last size once the vboxvideo driver loads, changing the pitch).
Adding the missing drm_fb_helper_remove_conflicting_pci_framebuffers() call fixes this.
Changes in v2:
-Make the drm_fb_helper_remove_conflicting_pci_framebuffers() call one of
the first things we do in our probe() method
--- drivers/gpu/drm/vboxvideo/vbox_drv.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vboxvideo/vbox_drv.c +4 -0
@@ -41,6 +41,10 @@ static int vbox_pci_probe(struct pci_devif (!vbox_check_supported (VBE_DISPI_ID_HGSMI ))return -ENODEV ; + ret =drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,"vboxvideodrmfb" ); +if (ret) +return ret; + vbox =kzalloc (sizeof (*vbox),GFP_KERNEL );if (!vbox)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 185/254 crypto: ccree - protect against empty or NULL scatterlists
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit ce0fc6db38decf0d2919bfe783de6d6b76e421a9 upstream.
Deal gracefully with a NULL or empty scatterlist which can happen if both cryptlen and assoclen are zero and we're doing in-place AEAD encryption.
This fixes a crash when this causes us to try and map a NULL page, at least with some platforms / DMA mapping configs.
--- drivers/crypto/ccree/cc_buffer_mgr.c | 62 +++++++++++++++-------------------- drivers/crypto/ccree/cc_buffer_mgr.h | 1 2 files changed, 28 insertions(+), 35 deletions(-)
drivers/crypto/ccree/cc_buffer_mgr.c +27 -35
@@ -87,6 +87,8 @@ static unsigned int cc_get_sgl_nents(str {unsigned int nents =0 ; + *lbytes =0 ; +while (nbytes && sg_list) { nents++;/* get the number of bytes in the last entry */
@@ -95,6 +97,7 @@ static unsigned int cc_get_sgl_nents(str nbytes : sg_list->length; sg_list =sg_next (sg_list); } +dev_dbg (dev,"nents %d last bytes %d\n" , nents, *lbytes);return nents; }
@@ -290,37 +293,25 @@ static int cc_map_sg(struct device *dev, unsigned int nbytes, int direction, u32 *nents, u32 max_sg_nents, u32 *lbytes, u32 *mapped_nents) { - if (sg_is_last(sg)) { - /* One entry only case -set to DLLI */ - if (dma_map_sg(dev, sg, 1, direction) != 1) { - dev_err(dev, "dma_map_sg() single buffer failed\n"); -return -ENOMEM ; - } -dev_dbg (dev,"Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n" , - &sg_dma_address (sg),sg_page (sg),sg_virt (sg), - sg->offset, sg->length); - *lbytes = nbytes; - *nents =1 ; - *mapped_nents =1 ; - } else { /*sg_is_last*/ - *nents =cc_get_sgl_nents (dev, sg, nbytes, lbytes); -if (*nents > max_sg_nents) { - *nents =0 ; -dev_err (dev,"Too many fragments. current %d max %d\n" , - *nents, max_sg_nents); -return -ENOMEM ; - } -/* In case of mmu the number of mapped nents might -* be changed from the original sgl nents -*/ - *mapped_nents =dma_map_sg (dev, sg, *nents, direction); -if (*mapped_nents ==0 ) { - *nents =0 ; -dev_err (dev,"dma_map_sg() sg buffer failed\n" ); -return -ENOMEM ; - } + int ret = 0; + + *nents =cc_get_sgl_nents (dev, sg, nbytes, lbytes); +if (*nents > max_sg_nents) { + *nents =0 ; +dev_err (dev,"Too many fragments. current %d max %d\n" , + *nents, max_sg_nents); +return -ENOMEM ; } + ret =dma_map_sg (dev, sg, *nents, direction); +if (dma_mapping_error (dev, ret)) { + *nents =0 ; +dev_err (dev,"dma_map_sg() sg buffer failed %d\n" , ret); +return -ENOMEM ; + } + + *mapped_nents = ret; +return 0 ; }
@@ -555,11 +546,12 @@ void cc_unmap_aead_request(struct devicesg_virt (req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, areq_ctx->assoclen, req->cryptlen); -dma_unmap_sg (dev, req->src,sg_nents (req->src),DMA_BIDIRECTIONAL ); +dma_unmap_sg (dev, req->src, areq_ctx->src.mapped_nents, +DMA_BIDIRECTIONAL );if (req->src != req->dst) {dev_dbg (dev,"Unmapping dst sgl: req->dst=%pK\n" ,sg_virt (req->dst)); -dma_unmap_sg (dev, req->dst,sg_nents (req->dst), +dma_unmap_sg (dev, req->dst, areq_ctx->dst.mapped_nents,DMA_BIDIRECTIONAL ); } if (drvdata->coherent &&
@@ -881,7 +873,7 @@ static int cc_aead_chain_data(struct cc_ &src_last_bytes); sg_index = areq_ctx->src_sgl->length;//check where the data starts -while (sg_index <= size_to_skip) { +while (src_mapped_nents && (sg_index <= size_to_skip)) { src_mapped_nents--; offset -= areq_ctx->src_sgl->length; sgl =sg_next (areq_ctx->src_sgl);
@@ -908,7 +900,7 @@ static int cc_aead_chain_data(struct cc_ size_for_map +=crypto_aead_ivsize (tfm); rc =cc_map_sg (dev, req->dst, size_for_map,DMA_BIDIRECTIONAL , - &areq_ctx->dst.nents, + &areq_ctx->dst.mapped_nents,LLI_MAX_NUM_OF_DATA_ENTRIES , &dst_last_bytes, &dst_mapped_nents);if (rc)
@@ -921,7 +913,7 @@ static int cc_aead_chain_data(struct cc_ offset = size_to_skip;//check where the data starts -while (sg_index <= size_to_skip) { +while (dst_mapped_nents && sg_index <= size_to_skip) { dst_mapped_nents--; offset -= areq_ctx->dst_sgl->length; sgl =sg_next (areq_ctx->dst_sgl);
@@ -1123,7 +1115,7 @@ int cc_map_aead_request(struct cc_drvdatif (is_gcm4543) size_to_map +=crypto_aead_ivsize (tfm); rc =cc_map_sg (dev, req->src, size_to_map,DMA_BIDIRECTIONAL , - &areq_ctx->src.nents, + &areq_ctx->src.mapped_nents, (LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES +LLI_MAX_NUM_OF_DATA_ENTRIES ), &dummy, &mapped_nents);
drivers/crypto/ccree/cc_buffer_mgr.h +1 -0
@@ -25,6 +25,7 @@ enum cc_sg_cpy_direct {struct cc_mlli {cc_sram_addr_t sram_addr; +unsigned int mapped_nents;unsigned int nents;//sg nents unsigned int mlli_nents;//mlli nents might be different than the above };
Greg Kroah-Hartman
maintainerPATCH 216/254 NFS: Fix a few constant_table array definitions
In reply to Greg Kroah-HartmanFrom: Scott Mayhew <[email protected]>
commit 529af90576cfa44aa107e9876e2ebaa053983986 upstream.
nfs_vers_tokens, nfs_xprt_protocol_tokens, and nfs_secflavor_tokens were all missing an empty item at the end of the array, allowing lookup_constant() to potentially walk off the end and trigger and oops.
--- fs/nfs/fs_context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfs/fs_context.c +4 -1
@@ -190,6 +190,7 @@ static const struct constant_table nfs_v { "4.0", Opt_vers_4_0 }, { "4.1", Opt_vers_4_1 }, { "4.2", Opt_vers_4_2 }, + {} }; enum {
@@ -202,13 +203,14 @@ enum {nr__Opt_xprt }; -static const struct constant_table nfs_xprt_protocol_tokens[nr__Opt_xprt] = { +static const struct constant_table nfs_xprt_protocol_tokens[] = { {"rdma" , Opt_xprt_rdma }, {"rdma6" , Opt_xprt_rdma6 }, {"tcp" , Opt_xprt_tcp }, {"tcp6" , Opt_xprt_tcp6 }, {"udp" , Opt_xprt_udp }, {"udp6" , Opt_xprt_udp6 }, + {} };enum {
@@ -239,6 +241,7 @@ static const struct constant_table nfs_s { "spkm3i", Opt_sec_spkmi }, { "spkm3p", Opt_sec_spkmp }, { "sys", Opt_sec_sys }, + {} };/*
Greg Kroah-Hartman
maintainerPATCH 221/254 ocfs2: no need try to truncate file beyond i_size
In reply to Greg Kroah-HartmanFrom: Changwei Ge <[email protected]>
commit 783fda856e1034dee90a873f7654c418212d12d7 upstream.
Linux fallocate(2) with FALLOC_FL_PUNCH_HOLE mode set, its offset can exceed the inode size. Ocfs2 now doesn't allow that offset beyond inode size. This restriction is not necessary and violates fallocate(2) semantics.
If fallocate(2) offset is beyond inode size, just return success and do nothing further.
Otherwise, ocfs2 will crash the kernel.
kernel BUG at fs/ocfs2//alloc.c:7264!
ocfs2_truncate_inline+0x20f/0x360 [ocfs2] ocfs2_remove_inode_range+0x23c/0xcb0 [ocfs2] __ocfs2_change_file_space+0x4a5/0x650 [ocfs2] ocfs2_fallocate+0x83/0xa0 [ocfs2] vfs_fallocate+0x148/0x230 SyS_fallocate+0x48/0x80 do_syscall_64+0x79/0x170
--- fs/ocfs2/alloc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ocfs2/alloc.c +4 -0
@@ -7403,6 +7403,10 @@ int ocfs2_truncate_inline(struct inode *struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;struct ocfs2_inline_data *idata = &di->id2.i_data; +/* No need to punch hole beyond i_size. */ +if (start >=i_size_read (inode)) +return 0 ; +if (end >i_size_read (inode)) end =i_size_read (inode);
Greg Kroah-Hartman
maintainerPATCH 186/254 crypto: ccree - only try to map auth tag if needed
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit 504e84abec7a635b861afd8d7f92ecd13eaa2b09 upstream.
Make sure to only add the size of the auth tag to the source mapping for encryption if it is an in-place operation. Failing to do this previously caused us to try and map auth size len bytes from a NULL mapping and crashing if both the cryptlen and assoclen are zero.
--- drivers/crypto/ccree/cc_buffer_mgr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/ccree/cc_buffer_mgr.c +4 -2
@@ -1109,9 +1109,11 @@ int cc_map_aead_request(struct cc_drvdat } size_to_map = req->cryptlen + areq_ctx->assoclen; -if (areq_ctx->gen_ctx.op_type ==DRV_CRYPTO_DIRECTION_ENCRYPT ) +/* If we do in-place encryption, we also need the auth tag */ +if ((areq_ctx->gen_ctx.op_type ==DRV_CRYPTO_DIRECTION_ENCRYPT ) && + (req->src == req->dst)) { size_to_map += authsize; - + }if (is_gcm4543) size_to_map +=crypto_aead_ivsize (tfm); rc = cc_map_sg(dev, req->src, size_to_map, DMA_BIDIRECTIONAL,
Greg Kroah-Hartman
maintainerPATCH 223/254 s390/diag: fix display of diagnose call statistics
In reply to Greg Kroah-HartmanFrom: Michael Mueller <[email protected]>
commit 6c7c851f1b666a8a455678a0b480b9162de86052 upstream.
Show the full diag statistic table and not just parts of it.
The issue surfaced in a KVM guest with a number of vcpus defined smaller than NR_DIAG_STAT.
--- arch/s390/kernel/diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/diag.c +1 -1
@@ -84,7 +84,7 @@ static int show_diag_stat(struct seq_filstatic void *show_diag_stat_start (struct seq_file *m,loff_t *pos) { -return *pos <= nr_cpu_ids ? (void *)((unsigned long ) *pos +1 ) :NULL ; +return *pos <=NR_DIAG_STAT ? (void *)((unsigned long ) *pos +1 ) :NULL ; }static void *show_diag_stat_next (struct seq_file *m,void *v,loff_t *pos)
Greg Kroah-Hartman
maintainerPATCH 188/254 scsi: zfcp: fix missing erp_lock in port recovery trigger for point-to-point
In reply to Greg Kroah-HartmanFrom: Steffen Maier <[email protected]>
commit 819732be9fea728623e1ed84eba28def7384ad1f upstream.
v2.6.27 commit cc8c282963bd ("[SCSI] zfcp: Automatically attach remote ports") introduced zfcp automatic port scan.
Before that, the user had to use the sysfs attribute "port_add" of an FCP device (adapter) to add and open remote (target) ports, even for the remote peer port in point-to-point topology. That code path did a proper port open recovery trigger taking the erp_lock.
Since above commit, a new helper function zfcp_erp_open_ptp_port() performed an UNlocked port open recovery trigger. This can race with other parallel recovery triggers. In zfcp_erp_action_enqueue() this could corrupt e.g. adapter->erp_total_count or adapter->erp_ready_head.
As already found for fabric topology in v4.17 commit fa89adba1941 ("scsi:
zfcp: fix infinite iteration on ERP ready list"), there was an endless loop during tracing of rport (un)block. A subsequent v4.18 commit 9e156c54ace3 ("scsi: zfcp: assert that the ERP lock is held when tracing a recovery trigger") introduced a lockdep assertion for that case.
As a side effect, that lockdep assertion now uncovered the unlocked code path for PtP. It is from within an adapter ERP action:
zfcp_erp_strategy[1479] intentionally DROPs erp lock around
zfcp_erp_strategy_do_action()
zfcp_erp_strategy_do_action[1441] NO erp lock zfcp_erp_adapter_strategy[876] NO erp lock zfcp_erp_adapter_strategy_open[855] NO erp lock
zfcp_erp_adapter_strategy_open_fsf[806]NO erp lock zfcp_erp_adapter_strat_fsf_xconf[772] erp lock only around
zfcp_erp_action_to_running(), BUT *_not_* around zfcp_erp_enqueue_ptp_port()
zfcp_erp_enqueue_ptp_port[728] BUG: *_not_* taking erp lock _zfcp_erp_port_reopen[432] assumes to be called with erp lock zfcp_erp_action_enqueue[314] assumes to be called with erp lock zfcp_dbf_rec_trig[288] _checks_ to be called with erp lock: lockdep_assert_held(&adapter->erp_lock);
It causes the following lockdep warning:
WARNING: CPU: 2 PID: 775 at drivers/s390/scsi/zfcp_dbf.c:288
zfcp_dbf_rec_trig+0x16a/0x188
no locks held by zfcperp0.0.17c0/775.Fix this by using the proper locked recovery trigger helper function.
--- drivers/s390/scsi/zfcp_erp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/scsi/zfcp_erp.c +1 -1
@@ -725,7 +725,7 @@ static void zfcp_erp_enqueue_ptp_port(st adapter->peer_d_id);if (IS_ERR (port))/* error or port already attached */ return ; -_zfcp_erp_port_reopen (port,0 ,"ereptp1" ); +zfcp_erp_port_reopen (port,0 ,"ereptp1" ); } static enum zfcp_erp_act_result zfcp_erp_adapter_strat_fsf_xconf(
Greg Kroah-Hartman
maintainerPATCH 190/254 scsi: lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 0ab384a49c548baf132ccef249f78d9c6c506380 upstream.
If a call to lpfc_get_cmd_rsp_buf_per_hdwq returns NULL (memory allocation failure), a previously allocated lpfc_io_buf resource is leaked.
Fix by releasing the lpfc_io_buf resource in the failure path.
--- drivers/scsi/lpfc/lpfc_scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_scsi.c +3 -1
@@ -671,8 +671,10 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *ph lpfc_cmd->prot_data_type =0 ;#endif tmp =lpfc_get_cmd_rsp_buf_per_hdwq (phba, lpfc_cmd); -if (!tmp) +if (!tmp) { +lpfc_release_io_buf (phba, lpfc_cmd, lpfc_cmd->hdwq);return NULL ; + } lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd; lpfc_cmd->fcp_rsp = tmp->fcp_rsp;
Greg Kroah-Hartman
maintainerPATCH 225/254 ftrace/kprobe: Show the maxactive number on kprobe_events
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 6a13a0d7b4d1171ef9b80ad69abc37e1daa941b3 upstream.
Show maxactive parameter on kprobe_events. This allows user to save the current configuration and restore it without losing maxactive parameter.
--- kernel/trace/trace_kprobe.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace_kprobe.c +2 -0
@@ -1078,6 +1078,8 @@ static int trace_kprobe_show(struct seq_int i;seq_putc (m,trace_kprobe_is_return (tk) ?'r' :'p' ); +if (trace_kprobe_is_return (tk) && tk->rp.maxactive) +seq_printf (m,"%d" , tk->rp.maxactive);seq_printf (m,":%s/%s" ,trace_probe_group_name (&tk->tp),trace_probe_name (&tk->tp));
Greg Kroah-Hartman
maintainerPATCH 234/254 scsi: sr: get rid of sr global mutex
In reply to Greg Kroah-HartmanFrom: Merlijn Wajer <[email protected]>
commit 51a858817dcdbbdee22cb54b0b2b26eb145ca5b6 upstream.
When replacing the Big Kernel Lock in commit 2a48fc0ab242 ("block:
autoconvert trivial BKL users to private mutex"), the lock was replaced with a sr-wide lock.
This causes very poor performance when using multiple sr devices, as the sr driver was not able to execute more than one command to one drive at any given time, even when there were many CD drives available.
Replace the global mutex with per-sr-device mutex.
Someone tried this patch at the time, but it never made it upstream, due to possible concerns with race conditions, but it's not clear the patch actually caused those:
https://www.spinics.net/lists/linux-scsi/msg63706.html
https://www.spinics.net/lists/linux-scsi/msg63750.html
Also see
http://lists.xiph.org/pipermail/paranoia/2019-December/001647.html
--- drivers/scsi/sr.c | 20 +++++++++++--------- drivers/scsi/sr.h | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-)
drivers/scsi/sr.c +11 -9
@@ -79,7 +79,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM); CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ CDC_MRW|CDC_MRW_W|CDC_RAM) -static DEFINE_MUTEX (sr_mutex);static int sr_probe (struct device *);static int sr_remove (struct device *);static blk_status_t sr_init_command (struct scsi_cmnd *SCpnt);
@@ -536,9 +535,9 @@ static int sr_block_open(struct block_descsi_autopm_get_device (sdev);check_disk_change (bdev); -mutex_lock (&sr_mutex); +mutex_lock (&cd->lock); ret =cdrom_open (&cd->cdi, bdev, mode); -mutex_unlock (&sr_mutex); +mutex_unlock (&cd->lock);scsi_autopm_put_device (sdev);if (ret)
@@ -551,10 +550,10 @@ out:static void sr_block_release (struct gendisk *disk,fmode_t mode) {struct scsi_cd *cd =scsi_cd (disk); -mutex_lock (&sr_mutex); +mutex_lock (&cd->lock);cdrom_release (&cd->cdi, mode);scsi_cd_put (cd); -mutex_unlock (&sr_mutex); +mutex_unlock (&cd->lock); } static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
@@ -565,7 +564,7 @@ static int sr_block_ioctl(struct block_dvoid __user *argp = (void __user *)arg;int ret; -mutex_lock (&sr_mutex); +mutex_lock (&cd->lock); ret =scsi_ioctl_block_when_processing_errors (sdev, cmd, (mode &FMODE_NDELAY ) !=0 );
@@ -595,7 +594,7 @@ put:scsi_autopm_put_device (sdev); out: -mutex_unlock (&sr_mutex); +mutex_unlock (&cd->lock);return ret; }
@@ -608,7 +607,7 @@ static int sr_block_compat_ioctl(structvoid __user *argp =compat_ptr (arg);int ret; -mutex_lock (&sr_mutex); +mutex_lock (&cd->lock); ret =scsi_ioctl_block_when_processing_errors (sdev, cmd, (mode &FMODE_NDELAY ) !=0 );
@@ -638,7 +637,7 @@ put:scsi_autopm_put_device (sdev); out: -mutex_unlock (&sr_mutex); +mutex_unlock (&cd->lock);return ret; }
@@ -745,6 +744,7 @@ static int sr_probe(struct device *dev) disk =alloc_disk (1 );if (!disk) goto fail_free; +mutex_init (&cd->lock);spin_lock (&sr_index_lock); minor =find_first_zero_bit (sr_index_bits,SR_DISKS );
@@ -1055,6 +1055,8 @@ static void sr_kref_release(struct krefput_disk (disk); +mutex_destroy (&cd->lock); +kfree (cd); }
drivers/scsi/sr.h +2 -0
@@ -20,6 +20,7 @@#include <linux/genhd.h> #include <linux/kref.h> +#include <linux/mutex.h> #define MAX_RETRIES 3#define SR_TIMEOUT (30 * HZ)
@@ -51,6 +52,7 @@ typedef struct scsi_cd { bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */struct cdrom_device_info cdi; +struct mutex lock;/* We hold gendisk and scsi_device references on probe and use * the refs on this kref to decide when to release them */ struct kref kref;
Greg Kroah-Hartman
maintainerPATCH 235/254 scsi: sr: Fix sr_block_release()
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 72655c0ebd1d941d80f47bf614b02d563a1e61ae upstream.
This patch fixes the following two complaints:
WARNING: CPU: 3 PID: 1326 at kernel/locking/mutex-debug.c:103 mutex_destroy+0x74/0x80 Modules linked in: scsi_debug sd_mod t10_pi brd scsi_transport_iscsi af_packet crct10dif_pclmul sg aesni_intel glue_helper virtio_balloon button crypto_simd cryptd intel_agp intel_gtt agpgart ip_tables x_tables ipv6 nf_defrag_ipv6 autofs4 ext4 crc16 mbcache jbd2 hid_generic usbhid hid sr_mod cdrom ata_generic pata_acpi virtio_blk virtio_net net_failover failover ata_piix xhci_pci ahci libahci xhci_hcd i2c_piix4 libata virtio_pci usbcore i2c_core virtio_ring scsi_mod usb_common virtio [last unloaded: scsi_debug] CPU: 3 PID: 1326 Comm: systemd-udevd Not tainted 5.6.0-rc1-dbg+ #1 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 RIP: 0010:mutex_destroy+0x74/0x80 Call Trace: sr_kref_release+0xb9/0xd0 [sr_mod] scsi_cd_put+0x79/0x90 [sr_mod] sr_block_release+0x54/0x70 [sr_mod] __blkdev_put+0x2ce/0x3c0 blkdev_put+0x68/0x220 blkdev_close+0x4d/0x60 __fput+0x170/0x3b0 ____fput+0x12/0x20 task_work_run+0xa2/0xf0 exit_to_usermode_loop+0xeb/0xf0 do_syscall_64+0x2be/0x300 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7fa16d40aab7 BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x98/0x420 Read of size 8 at addr ffff8881c6e4f4b0 by task systemd-udevd/1326 CPU: 3 PID: 1326 Comm: systemd-udevd Tainted: G W 5.6.0-rc1-dbg+ #1 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: dump_stack+0xa5/0xe6 print_address_description.constprop.0+0x46/0x60 __kasan_report.cold+0x7b/0x94 kasan_report+0x16/0x20 check_memory_region+0x140/0x1b0 __kasan_check_read+0x15/0x20 __mutex_unlock_slowpath+0x98/0x420 mutex_unlock+0x16/0x20 sr_block_release+0x5c/0x70 [sr_mod] __blkdev_put+0x2ce/0x3c0 hardirqs last enabled at (1875522): [<ffffffff81bb0696>] _raw_spin_unlock_irqrestore+0x56/0x70 blkdev_put+0x68/0x220 blkdev_close+0x4d/0x60 __fput+0x170/0x3b0 ____fput+0x12/0x20 task_work_run+0xa2/0xf0 exit_to_usermode_loop+0xeb/0xf0 do_syscall_64+0x2be/0x300 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7fa16d40aab7 Allocated by task 3201: save_stack+0x23/0x90 __kasan_kmalloc.constprop.0+0xcf/0xe0 kasan_kmalloc+0xd/0x10 kmem_cache_alloc_trace+0x161/0x3c0 sr_probe+0x12f/0xb60 [sr_mod] really_probe+0x183/0x5d0 driver_probe_device+0x13f/0x1a0 __device_attach_driver+0xe6/0x150 bus_for_each_drv+0x101/0x160 __device_attach+0x183/0x230 device_initial_probe+0x17/0x20 bus_probe_device+0x110/0x130 device_add+0xb7b/0xd40 scsi_sysfs_add_sdev+0xe8/0x360 [scsi_mod] scsi_probe_and_add_lun+0xdc4/0x14c0 [scsi_mod] __scsi_scan_target+0x12d/0x850 [scsi_mod] scsi_scan_channel+0xcd/0xe0 [scsi_mod] scsi_scan_host_selected+0x182/0x190 [scsi_mod] store_scan+0x1e9/0x200 [scsi_mod] dev_attr_store+0x42/0x60 sysfs_kf_write+0x8b/0xb0 kernfs_fop_write+0x158/0x250 __vfs_write+0x4c/0x90 vfs_write+0x145/0x2c0 ksys_write+0xd7/0x180 __x64_sys_write+0x47/0x50 do_syscall_64+0x6f/0x300 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 1326: save_stack+0x23/0x90 __kasan_slab_free+0x13a/0x190 kasan_slab_free+0x12/0x20 kfree+0x109/0x410 sr_kref_release+0xc1/0xd0 [sr_mod] scsi_cd_put+0x79/0x90 [sr_mod] sr_block_release+0x54/0x70 [sr_mod] __blkdev_put+0x2ce/0x3c0 blkdev_put+0x68/0x220 blkdev_close+0x4d/0x60 __fput+0x170/0x3b0 ____fput+0x12/0x20 task_work_run+0xa2/0xf0 exit_to_usermode_loop+0xeb/0xf0 do_syscall_64+0x2be/0x300 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/scsi/sr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sr.c +3 -1
@@ -550,10 +550,12 @@ out:static void sr_block_release (struct gendisk *disk,fmode_t mode) {struct scsi_cd *cd =scsi_cd (disk); +mutex_lock (&cd->lock);cdrom_release (&cd->cdi, mode); -scsi_cd_put (cd);mutex_unlock (&cd->lock); + +scsi_cd_put (cd); } static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
Greg Kroah-Hartman
maintainerPATCH 236/254 powerpc: Make setjmp/longjmp signature standard
In reply to Greg Kroah-HartmanFrom: Clement Courbet <[email protected]>
commit c17eb4dca5a353a9dbbb8ad6934fe57af7165e91 upstream.
Declaring setjmp()/longjmp() as taking longs makes the signature non-standard, and makes clang complain. In the past, this has been worked around by adding -ffreestanding to the compile flags.
The implementation looks like it only ever propagates the value (in longjmp) or sets it to 1 (in setjmp), and we only call longjmp with integer parameters.
This allows removing -ffreestanding from the compilation flags.
--- arch/powerpc/include/asm/setjmp.h | 6 ++++-- arch/powerpc/kexec/Makefile | 3 --- arch/powerpc/xmon/Makefile | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/setjmp.h +4 -2
@@ -7,7 +7,9 @@#define JMP_BUF_LEN 23 -extern long setjmp (long *) __attribute__((returns_twice)); -extern void longjmp (long *,long ) __attribute__((noreturn)); +typedef long jmp_buf [JMP_BUF_LEN ]; + +extern int setjmp (jmp_buf env) __attribute__((returns_twice)); +extern void longjmp (jmp_buf env,int val) __attribute__((noreturn));#endif /* _ASM_POWERPC_SETJMP_H */
arch/powerpc/kexec/Makefile +0 -3
@@ -3,9 +3,6 @@ # Makefile for the linux kernel. # -# Avoid clang warnings around longjmp/setjmp declarations -CFLAGS_crash.o += -ffreestanding - obj-y += core.o crash.o core_$(BITS).o obj-$(CONFIG_PPC32) += relocate_32.o
arch/powerpc/xmon/Makefile +0 -3
@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for xmon -# Avoid clang warnings around longjmp/setjmp declarations -subdir-ccflags-y := -ffreestanding - GCOV_PROFILE := n KCOV_INSTRUMENT := n UBSAN_SANITIZE := n
Greg Kroah-Hartman
maintainerPATCH 242/254 powerpc/xive: Fix xmon support on the PowerNV platform
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
commit 97ef275077932c65b1b8ec5022abd737a9fbf3e0 upstream.
The PowerNV platform has multiple IRQ chips and the xmon command dumping the state of the XIVE interrupt should only operate on the XIVE IRQ chip.
--- arch/powerpc/sysdev/xive/common.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/sysdev/xive/common.c +4 -0
@@ -258,11 +258,15 @@ notrace void xmon_xive_do_dump(int cpu)int xmon_xive_get_irq_config (u32 hw_irq,struct irq_data *d) { +struct irq_chip *chip =irq_data_get_irq_chip (d);int rc;u32 target;u8 prio;u32 lirq; +if (!is_xive_irq (chip)) +return -EINVAL ; + rc = xive_ops->get_irq_config (hw_irq, &target, &prio, &lirq);if (rc) {xmon_printf ("IRQ 0x%08x : no config rc=%d\n" , hw_irq, rc);
Greg Kroah-Hartman
maintainerPATCH 243/254 powerpc/kprobes: Ignore traps that happened in real mode
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 21f8b2fa3ca5b01f7a2b51b89ce97a3705a15aa0 upstream.
When a program check exception happens while MMU translation is disabled, following Oops happens in kprobe_handler() in the following code:
} else if (*addr != BREAKPOINT_INSTRUCTION) {BUG: Unable to handle kernel data access on read at 0x0000e268 Faulting instruction address: 0xc000ec34 Oops: Kernel access of bad area, sig: 11 [#1] BE PAGE_SIZE=16K PREEMPT CMPC885 Modules linked in: CPU: 0 PID: 429 Comm: cat Not tainted 5.6.0-rc1-s3k-dev-00824-g84195dc6c58a #3267 NIP: c000ec34 LR: c000ecd8 CTR: c019cab8 REGS: ca4d3b58 TRAP: 0300 Not tainted (5.6.0-rc1-s3k-dev-00824-g84195dc6c58a) MSR: 00001032 <ME,IR,DR,RI> CR: 2a4d3c52 XER: 00000000 DAR: 0000e268 DSISR: c0000000 GPR00: c000b09c ca4d3c10 c66d0620 00000000 ca4d3c60 00000000 00009032 00000000 GPR08: 00020000 00000000 c087de44 c000afe0 c66d0ad0 100d3dd6 fffffff3 00000000 GPR16: 00000000 00000041 00000000 ca4d3d70 00000000 00000000 0000416d 00000000 GPR24: 00000004 c53b6128 00000000 0000e268 00000000 c07c0000 c07bb6fc ca4d3c60 NIP [c000ec34] kprobe_handler+0x128/0x290 LR [c000ecd8] kprobe_handler+0x1cc/0x290 Call Trace: [ca4d3c30] [c000b09c] program_check_exception+0xbc/0x6fc [ca4d3c50] [c000e43c] ret_from_except_full+0x0/0x4 --- interrupt: 700 at 0xe268 Instruction dump: 913e0008 81220000 38600001 3929ffff 91220000 80010024 bb410008 7c0803a6 38210020 4e800020 38600000 4e800020 <813b0000> 6d2a7fe0 2f8a0008 419e0154 ---[ end trace 5b9152d4cdadd06d ]---
kprobe is not prepared to handle events in real mode and functions running in real mode should have been blacklisted, so kprobe_handler() can safely bail out telling 'this trap is not mine' for any trap that happened while in real-mode.
If the trap happened with MSR_IR or MSR_DR cleared, return 0 immediately.
--- arch/powerpc/kernel/kprobes.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/kprobes.c +3 -0
@@ -264,6 +264,9 @@ int kprobe_handler(struct pt_regs *regs)if (user_mode (regs))return 0 ; +if (!(regs->msr &MSR_IR ) || !(regs->msr &MSR_DR )) +return 0 ; +/* * We don't want to be preempted for the entire * duration of kprobe processing
Greg Kroah-Hartman
maintainerPATCH 226/254 clk: ingenic/jz4770: Exit with error if CGU init failed
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit c067b46d731a764fc46ecc466c2967088c97089e upstream.
Exit jz4770_cgu_init() if the 'cgu' pointer we get is NULL, since the pointer is passed as argument to functions later on.
--- drivers/clk/ingenic/jz4770-cgu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/ingenic/jz4770-cgu.c +3 -1
@@ -432,8 +432,10 @@ static void __init jz4770_cgu_init(struc cgu =ingenic_cgu_new (jz4770_cgu_clocks,ARRAY_SIZE (jz4770_cgu_clocks), np); -if (!cgu) +if (!cgu) {pr_err ("%s: failed to initialise CGU\n" , __func__); +return ; + } retval =ingenic_cgu_register_clocks (cgu);if (retval)
Greg Kroah-Hartman
maintainerPATCH 248/254 drm/amdgpu: fix gfx hang during suspend with video playback (v2)
In reply to Greg Kroah-HartmanFrom: Prike Liang <[email protected]>
[ Upstream commit 487eca11a321ef33bcf4ca5adb3c0c4954db1b58 ]
The system will be hang up during S3 suspend because of SMU is pending for GC not respose the register CP_HQD_ACTIVE access request.This issue root cause of accessing the GC register under enter GFX CGGPG and can be fixed by disable GFX CGPG before perform suspend.
v2: Use disable the GFX CGPG instead of RLC safe mode guard.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -2
@@ -2285,8 +2285,6 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev) {int i, r; -amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE ); -amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE );for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)
@@ -3309,6 +3307,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) } } +amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE ); +amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE ); +amdgpu_amdkfd_suspend (adev);amdgpu_ras_suspend (adev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 252/254 perf/core: Fix event cgroup tracking
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 33238c50451596be86db1505ab65fee5172844d0 ]
Song reports that installing cgroup events is broken since:
db0503e4f675 ("perf/core: Optimize perf_install_in_event()")
The problem being that cgroup events try to track cpuctx->cgrp even for disabled events, which is pointless and actively harmful since the above commit. Rework the code to have explicit enable/disable hooks for cgroup events, such that we can limit cgroup tracking to active events.
More specifically, since the above commit disabled events are no longer added to their context from the 'right' CPU, and we can't access things like the current cgroup for a remote CPU.
--- kernel/events/core.c | 70 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 27 deletions(-)
kernel/events/core.c +43 -27
@@ -935,16 +935,10 @@ perf_cgroup_set_shadow_time(struct perf_event *event, u64 now) event->shadow_ctx_time = now - t->timestamp; } -/* -* Update cpuctx->cgrp so that it is set when first cgroup event is added and -* cleared when last cgroup event is removed. -*/ static inline void -list_update_cgroup_event (struct perf_event *event, -struct perf_event_context *ctx,bool add) +perf_cgroup_event_enable (struct perf_event *event,struct perf_event_context *ctx) {struct perf_cpu_context *cpuctx; -struct list_head *cpuctx_entry;if (!is_cgroup_event (event))return ;
@@ -961,28 +955,41 @@ list_update_cgroup_event(struct perf_event *event,* because if the first would mismatch, the second would not try again * and we would leave cpuctx->cgrp unset. */ -if (add && !cpuctx->cgrp) { +if (ctx->is_active && !cpuctx->cgrp) {struct perf_cgroup *cgrp =perf_cgroup_from_task (current, ctx);if (cgroup_is_descendant (cgrp->css.cgroup, event->cgrp->css.cgroup)) cpuctx->cgrp = cgrp; } -if (add && ctx->nr_cgroups++) +if (ctx->nr_cgroups++)return ; -else if (!add && --ctx->nr_cgroups) + +list_add (&cpuctx->cgrp_cpuctx_entry, +per_cpu_ptr (&cgrp_cpuctx_list, event->cpu)); +} + +static inline void +perf_cgroup_event_disable (struct perf_event *event,struct perf_event_context *ctx) +{ +struct perf_cpu_context *cpuctx; + +if (!is_cgroup_event (event))return ; -/* no cgroup running */ -if (!add) +/* +* Because cgroup events are always per-cpu events, +* @ctx == &cpuctx->ctx. +*/ + cpuctx = container_of(ctx, struct perf_cpu_context, ctx); + +if (--ctx->nr_cgroups) +return ; + +if (ctx->is_active && cpuctx->cgrp) cpuctx->cgrp =NULL ; - cpuctx_entry = &cpuctx->cgrp_cpuctx_entry; -if (add) -list_add (cpuctx_entry, -per_cpu_ptr (&cgrp_cpuctx_list, event->cpu)); -else - list_del(cpuctx_entry); +list_del (&cpuctx->cgrp_cpuctx_entry); }#else /* !CONFIG_CGROUP_PERF */
@@ -1048,11 +1055,14 @@ static inline u64 perf_cgroup_event_time(struct perf_event *event) }static inline void -list_update_cgroup_event (struct perf_event *event, -struct perf_event_context *ctx,bool add) +perf_cgroup_event_enable (struct perf_event *event,struct perf_event_context *ctx) { } +static inline void +perf_cgroup_event_disable (struct perf_event *event,struct perf_event_context *ctx) +{ +}#endif /*
@@ -1682,13 +1692,14 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx)add_event_to_groups (event, ctx); } -list_update_cgroup_event (event, ctx, true); -list_add_rcu (&event->event_entry, &ctx->event_list); ctx->nr_events++;if (event->attr.inherit_stat) ctx->nr_stat++; +if (event->state >PERF_EVENT_STATE_OFF ) +perf_cgroup_event_enable (event, ctx); + ctx->generation++; }
@@ -1864,8 +1875,6 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) event->attach_state &= ~PERF_ATTACH_CONTEXT ; -list_update_cgroup_event (event, ctx, false); - ctx->nr_events--;if (event->attr.inherit_stat) ctx->nr_stat--;
@@ -1882,8 +1891,10 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)* of error state is by explicit re-enabling * of the event */ -if (event->state >PERF_EVENT_STATE_OFF ) +if (event->state >PERF_EVENT_STATE_OFF ) { +perf_cgroup_event_disable (event, ctx);perf_event_set_state (event,PERF_EVENT_STATE_OFF ); + } ctx->generation++; }
@@ -2114,6 +2125,7 @@ event_sched_out(struct perf_event *event,if (READ_ONCE (event->pending_disable) >=0 ) {WRITE_ONCE (event->pending_disable,-1 ); +perf_cgroup_event_disable (event, ctx); state =PERF_EVENT_STATE_OFF ; }perf_event_set_state (event, state);
@@ -2250,6 +2262,7 @@ static void __perf_event_disable(struct perf_event *event,event_sched_out (event, cpuctx, ctx);perf_event_set_state (event,PERF_EVENT_STATE_OFF ); +perf_cgroup_event_disable (event, ctx); }/*
@@ -2633,7 +2646,7 @@ static int __perf_install_in_context(void *info) }#ifdef CONFIG_CGROUP_PERF -if (is_cgroup_event (event)) { +if (event->state >PERF_EVENT_STATE_OFF &&is_cgroup_event (event)) {/* * If the current cgroup doesn't match the event's * cgroup, we should not try to schedule it.
@@ -2793,6 +2806,7 @@ static void __perf_event_enable(struct perf_event *event,ctx_sched_out (ctx, cpuctx,EVENT_TIME );perf_event_set_state (event,PERF_EVENT_STATE_INACTIVE ); +perf_cgroup_event_enable (event, ctx);if (!ctx->is_active)return ;
@@ -3447,8 +3461,10 @@ static int merge_sched_in(struct perf_event *event, void *data) }if (event->state ==PERF_EVENT_STATE_INACTIVE ) { -if (event->attr.pinned) +if (event->attr.pinned) { +perf_cgroup_event_disable (event, ctx);perf_event_set_state (event,PERF_EVENT_STATE_ERROR ); + } sid->can_add_hw =0 ; sid->ctx->rotate_necessary =1 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 250/254 drm/i915/gt: Fill all the unused space in the GGTT
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
[ Upstream commit 0b72a251bf92ca2378530fa1f9b35a71830ab51c ]
When we allocate space in the GGTT we may have to allocate a larger region than will be populated by the object to accommodate fencing. Make sure that this space beyond the end of the buffer points safely into scratch space, in case the HW tries to access it anyway (e.g. fenced access to the last tile row).
v2: Preemptively / conservatively guard gen6 ggtt as well.
--- drivers/gpu/drm/i915/gt/intel_ggtt.c | 37 ++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +27 -10
@@ -199,10 +199,11 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm, enum i915_cache_level level, u32 flags) { -struct i915_ggtt *ggtt =i915_vm_to_ggtt (vm); -struct sgt_iter sgt_iter; -gen8_pte_t __iomem *gtt_entries;const gen8_pte_t pte_encode =gen8_ggtt_pte_encode (0 , level,0 ); +struct i915_ggtt *ggtt =i915_vm_to_ggtt (vm); +gen8_pte_t __iomem *gte; +gen8_pte_t __iomem *end; +struct sgt_iter iter;dma_addr_t addr;/*
@@ -210,10 +211,17 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,* not to allow the user to override access to a read only page. */ - gtt_entries = (gen8_pte_t __iomem *)ggtt->gsm; - gtt_entries += vma->node.start /I915_GTT_PAGE_SIZE ; -for_each_sgt_daddr (addr, sgt_iter, vma->pages) -gen8_set_pte (gtt_entries++, pte_encode | addr); + gte = (gen8_pte_t __iomem *)ggtt->gsm; + gte += vma->node.start /I915_GTT_PAGE_SIZE ; + end = gte + vma->node.size /I915_GTT_PAGE_SIZE ; + +for_each_sgt_daddr (addr, iter, vma->pages) +gen8_set_pte (gte++, pte_encode | addr); +GEM_BUG_ON (gte > end); + +/* Fill the allocated but "unused" space beyond the end of the buffer */ +while (gte < end) +gen8_set_pte (gte++, vm->scratch[0 ].encode);/* * We want to flush the TLBs only after we're certain all the PTE
@@ -249,13 +257,22 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm, u32 flags) {struct i915_ggtt *ggtt =i915_vm_to_ggtt (vm); -gen6_pte_t __iomem *entries = (gen6_pte_t __iomem *)ggtt->gsm; -unsigned int i = vma->node.start /I915_GTT_PAGE_SIZE ; +gen6_pte_t __iomem *gte; +gen6_pte_t __iomem *end;struct sgt_iter iter;dma_addr_t addr; + gte = (gen6_pte_t __iomem *)ggtt->gsm; + gte += vma->node.start /I915_GTT_PAGE_SIZE ; + end = gte + vma->node.size /I915_GTT_PAGE_SIZE ; +for_each_sgt_daddr (addr, iter, vma->pages) -iowrite32 (vm->pte_encode (addr, level, flags), &entries[i++]); +iowrite32 (vm->pte_encode (addr, level, flags), gte++); +GEM_BUG_ON (gte > end); + +/* Fill the allocated but "unused" space beyond the end of the buffer */ +while (gte < end) +iowrite32 (vm->scratch[0 ].encode, gte++);/* * We want to flush the TLBs only after we're certain all the PTE
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 251/254 perf/core: Unify {pinned,flexible}_sched_in()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit ab6f824cfdf7363b5e529621cbc72ae6519c78d1 ]
Less is more; unify the two very nearly identical function.
--- kernel/events/core.c | 58 ++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 37 deletions(-)
kernel/events/core.c +21 -37
@@ -1986,6 +1986,12 @@ static int perf_get_aux_event(struct perf_event *event,return 1 ; } +static inline struct list_head *get_event_list (struct perf_event *event) +{ +struct perf_event_context *ctx = event->ctx; +return event->attr.pinned ? &ctx->pinned_active : &ctx->flexible_active; +} +static void perf_group_detach (struct perf_event *event) {struct perf_event *sibling, *tmp;
@@ -2028,12 +2034,8 @@ static void perf_group_detach(struct perf_event *event)if (!RB_EMPTY_NODE (&event->group_node)) {add_event_to_groups (sibling, event->ctx); -if (sibling->state ==PERF_EVENT_STATE_ACTIVE ) { -struct list_head *list = sibling->attr.pinned ? - &ctx->pinned_active : &ctx->flexible_active; - -list_add_tail (&sibling->active_list, list); - } +if (sibling->state ==PERF_EVENT_STATE_ACTIVE ) +list_add_tail (&sibling->active_list,get_event_list (sibling)); }WARN_ON_ONCE (sibling->ctx != event->ctx);
@@ -2350,6 +2352,8 @@ event_sched_in(struct perf_event *event, {int ret =0 ; +WARN_ON_ONCE (event->ctx != ctx); +lockdep_assert_held (&ctx->lock);if (event->state <=PERF_EVENT_STATE_OFF )
@@ -3425,10 +3429,12 @@ struct sched_in_data {int can_add_hw; }; -static int pinned_sched_in (struct perf_event *event,void *data) +static int merge_sched_in (struct perf_event *event,void *data) {struct sched_in_data *sid = data; +WARN_ON_ONCE (event->ctx != sid->ctx); +if (event->state <=PERF_EVENT_STATE_OFF )return 0 ;
@@ -3437,37 +3443,15 @@ static int pinned_sched_in(struct perf_event *event, void *data)if (group_can_go_on (event, sid->cpuctx, sid->can_add_hw)) {if (!group_sched_in (event, sid->cpuctx, sid->ctx)) -list_add_tail (&event->active_list, &sid->ctx->pinned_active); +list_add_tail (&event->active_list,get_event_list (event)); } -/* -* If this pinned group hasn't been scheduled, -* put it in error state. -*/ -if (event->state ==PERF_EVENT_STATE_INACTIVE ) -perf_event_set_state (event,PERF_EVENT_STATE_ERROR ); - -return 0 ; -} - -static int flexible_sched_in (struct perf_event *event,void *data) -{ -struct sched_in_data *sid = data; - -if (event->state <=PERF_EVENT_STATE_OFF ) -return 0 ; - -if (!event_filter_match (event)) -return 0 ; +if (event->state ==PERF_EVENT_STATE_INACTIVE ) { +if (event->attr.pinned) +perf_event_set_state (event,PERF_EVENT_STATE_ERROR ); -if (group_can_go_on (event, sid->cpuctx, sid->can_add_hw)) { -int ret =group_sched_in (event, sid->cpuctx, sid->ctx); -if (ret) { - sid->can_add_hw =0 ; - sid->ctx->rotate_necessary =1 ; -return 0 ; - } -list_add_tail (&event->active_list, &sid->ctx->flexible_active); + sid->can_add_hw =0 ; + sid->ctx->rotate_necessary =1 ; }return 0 ;
@@ -3485,7 +3469,7 @@ ctx_pinned_sched_in(struct perf_event_context *ctx,visit_groups_merge (&ctx->pinned_groups,smp_processor_id (), - pinned_sched_in, &sid); + merge_sched_in, &sid); } static void
@@ -3500,7 +3484,7 @@ ctx_flexible_sched_in(struct perf_event_context *ctx,visit_groups_merge (&ctx->flexible_groups,smp_processor_id (), - flexible_sched_in, &sid); + merge_sched_in, &sid); } static void
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 254/254 powerpc/kasan: Fix kasan_remap_early_shadow_ro()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit af92bad615be75c6c0d1b1c5b48178360250a187 ]
At the moment kasan_remap_early_shadow_ro() does nothing, because k_end is 0 and k_cur < 0 is always true.
Change the test to k_cur != k_end, as done inkasan_init_shadow_page_tables()
--- arch/powerpc/mm/kasan/kasan_init_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/kasan/kasan_init_32.c +1 -1
@@ -101,7 +101,7 @@ static void __init kasan_remap_early_shadow_ro(void)kasan_populate_pte (kasan_early_shadow_pte, prot); -for (k_cur = k_start &PAGE_MASK ; k_cur < k_end; k_cur +=PAGE_SIZE ) { +for (k_cur = k_start &PAGE_MASK ; k_cur != k_end; k_cur +=PAGE_SIZE ) {pmd_t *pmd =pmd_offset (pud_offset (pgd_offset_k (k_cur), k_cur), k_cur);pte_t *ptep =pte_offset_kernel (pmd, k_cur);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 228/254 kmod: make request_module() return an error when autoloading is disabled
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit d7d27cfc5cf0766a26a8f56868c5ad5434735126 upstream.
Patch series "module autoloading fixes and cleanups", v5.
This series fixes a bug where request_module() was reporting success to kernel code when module autoloading had been completely disabled via 'echo > /proc/sys/kernel/modprobe'.
It also addresses the issues raised on the original thread
(https://lkml.kernel.org/lkml/[email protected]/T/#u)
bydocumenting the modprobe sysctl, adding a self-test for the empty path case, and downgrading a user-reachable WARN_ONCE().
This patch (of 4):
It's long been possible to disable kernel module autoloading completely (while still allowing manual module insertion) by setting /proc/sys/kernel/modprobe to the empty string.
This can be preferable to setting it to a nonexistent file since it avoids the overhead of an attempted execve(), avoids potential deadlocks, and avoids the call to security_kernel_module_request() and thus on SELinux-based systems eliminates the need to write SELinux rules to dontaudit module_request.
However, when module autoloading is disabled in this way, request_module() returns 0. This is broken because callers expect 0 to mean that the module was successfully loaded.
Apparently this was never noticed because this method of disabling module autoloading isn't used much, and also most callers don't use the return value of request_module() since it's always necessary to check whether the module registered its functionality or not anyway.
But improperly returning 0 can indeed confuse a few callers, for example get_fs_type() in fs/filesystems.c where it causes a WARNING to be hit:
if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
fs = __get_fs_type(name, len);
WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
}This is easily reproduced with:
echo > /proc/sys/kernel/modprobe
mount -t NONEXISTENT none /
It causes:
request_module fs-NONEXISTENT succeeded, but still no fs? WARNING: CPU: 1 PID: 1106 at fs/filesystems.c:275 get_fs_type+0xd6/0xf0 [...]
This should actually use pr_warn_once() rather than WARN_ONCE(), since it's also user-reachable if userspace immediately unloads the module. Regardless, request_module() should correctly return an error when it fails. So let's make it return -ENOENT, which matches the error when the modprobe binary doesn't exist.
I've also sent patches to document and test this case.
--- kernel/kmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kmod.c +2 -2
@@ -120,7 +120,7 @@ out:* invoke it. * * If module auto-loading support is disabled then this function -* becomes a no-operation. +* simply returns -ENOENT. */ int __request_module (bool wait,const char *fmt, ...) {
@@ -137,7 +137,7 @@ int __request_module(bool wait, const chWARN_ON_ONCE (wait &¤t_is_async ());if (!modprobe_path[0 ]) -return 0 ; +return -ENOENT ;va_start (args, fmt); ret =vsnprintf (module_name,MODULE_NAME_LEN , fmt, args);
Greg Kroah-Hartman
maintainerPATCH 229/254 cpufreq: powernv: Fix use-after-free
In reply to Greg Kroah-HartmanFrom: Oliver O'Halloran <[email protected]>
commit d0a72efac89d1c35ac55197895201b7b94c5e6ef upstream.
The cpufreq driver has a use-after-free that we can hit if:
a) There's an OCC message pending when the notifier is registered, and
b) The cpufreq driver fails to register with the core.
When a) occurs the notifier schedules a workqueue item to handle the message. The backing work_struct is located on chips[].throttle and when b) happens we clean up by freeing the array. Once we get to the (now free) queued item and the kernel crashes.
--- drivers/cpufreq/powernv-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/powernv-cpufreq.c +6 -0
@@ -1080,6 +1080,12 @@ free_and_return:static inline void clean_chip_info (void ) { +int i; + +/* flush any pending work items */ +if (chips) +for (i =0 ; i < nr_chips; i++) +cancel_work_sync (&chips[i].throttle);kfree (chips); }
Greg Kroah-Hartman
maintainerPATCH 231/254 libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 8305f72f952cff21ce8109dc1ea4b321c8efc5af upstream.
During system resume from suspend, this can be observed on ASM1062 PMP controller:
ata10.01: SATA link down (SStatus 0 SControl 330)
ata10.02: hard resetting link
ata10.02: SATA link down (SStatus 0 SControl 330)
ata10.00: configured for UDMA/133
Kernel panic - not syncing: stack-protector: Kernel in: sata_pmp_eh_recover+0xa2b/0xa40 CPU: 2 PID: 230 Comm: scsi_eh_9 Tainted: P OE #49-Ubuntu Hardware name: System manufacturer System Product 1001 12/10/2017 Call Trace: dump_stack+0x63/0x8b panic+0xe4/0x244 ? sata_pmp_eh_recover+0xa2b/0xa40 __stack_chk_fail+0x19/0x20 sata_pmp_eh_recover+0xa2b/0xa40 ? ahci_do_softreset+0x260/0x260 [libahci] ? ahci_do_hardreset+0x140/0x140 [libahci] ? ata_phys_link_offline+0x60/0x60 ? ahci_stop_engine+0xc0/0xc0 [libahci] sata_pmp_error_handler+0x22/0x30 ahci_error_handler+0x45/0x80 [libahci] ata_scsi_port_error_handler+0x29b/0x770 ? ata_scsi_cmd_error_handler+0x101/0x140 ata_scsi_error+0x95/0xd0 ? scsi_try_target_reset+0x90/0x90 scsi_error_handler+0xd0/0x5b0 kthread+0x121/0x140 ? scsi_eh_get_sense+0x200/0x200 ? kthread_create_worker_on_cpu+0x70/0x70 ret_from_fork+0x22/0x40
Kernel Offset: 0xcc00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
Since sata_pmp_eh_recover_pmp() doens't set rc when ATA_DFLAG_DETACH is set, sata_pmp_eh_recover() continues to run. During retry it triggers the stack protector.
Set correct rc in sata_pmp_eh_recover_pmp() to let sata_pmp_eh_recover() jump to pmp_fail directly.
--- drivers/ata/libata-pmp.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/libata-pmp.c +1 -0
@@ -763,6 +763,7 @@ static int sata_pmp_eh_recover_pmp(strucif (dev->flags &ATA_DFLAG_DETACH ) { detach =1 ; + rc = -ENODEV ; goto fail; }
Greg Kroah-Hartman
maintainerPATCH 224/254 Input: i8042 - add Acer Aspire 5738z to nomux list
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit ebc68cedec4aead47d8d11623d013cca9bf8e825 upstream.
The Acer Aspire 5738z has a button to disable (and re-enable) the touchpad next to the touchpad.
When this button is pressed a LED underneath indicates that the touchpad is disabled (and an event is send to userspace and GNOME shows its touchpad enabled / disable OSD thingie).
So far so good, but after re-enabling the touchpad it no longer works.
The laptop does not have an external ps2 port, so mux mode is not needed and disabling mux mode fixes the touchpad no longer working after toggling it off and back on again, so lets add this laptop model to the nomux list.
--- drivers/input/serio/i8042-x86ia64io.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +11 -0
@@ -530,6 +530,17 @@ static const struct dmi_system_id __init DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"), }, }, + { + /* + * Acer Aspire 5738z + * Touchpad stops working in mux mode when dis- + re-enabled + * with the touchpad enable/disable toggle hotkey + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"), + }, + }, { } };
Greg Kroah-Hartman
maintainerPATCH 233/254 xen/blkfront: fix memory allocation flags in blkfront_setup_indirect()
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit 3a169c0be75b59dd85d159493634870cdec6d3c4 upstream.
Commit 1d5c76e664333 ("xen-blkfront: switch kcalloc to kvcalloc for large array allocation") didn't fix the issue it was meant to, as the flags for allocating the memory are GFP_NOIO, which will lead the memory allocation falling back to kmalloc().
So instead of GFP_NOIO use GFP_KERNEL and do all the memory allocation in blkfront_setup_indirect() in a memalloc_noio_{save,restore} section.
--- drivers/block/xen-blkfront.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/block/xen-blkfront.c +12 -5
@@ -47,6 +47,7 @@#include <linux/bitmap.h> #include <linux/list.h> #include <linux/workqueue.h> +#include <linux/sched/mm.h> #include <xen/xen.h> #include <xen/xenbus.h>
@@ -2189,10 +2190,12 @@ static void blkfront_setup_discard(strucstatic int blkfront_setup_indirect (struct blkfront_ring_info *rinfo) { -unsigned int psegs, grants; +unsigned int psegs, grants, memflags;int err, i;struct blkfront_info *info = rinfo->dev_info; + memflags =memalloc_noio_save (); +if (info->max_indirect_segments ==0 ) {if (!HAS_EXTRA_REQ ) grants =BLKIF_MAX_SEGMENTS_PER_REQUEST ;
@@ -2224,7 +2227,7 @@ static int blkfront_setup_indirect(strucBUG_ON (!list_empty (&rinfo->indirect_pages));for (i =0 ; i < num; i++) { -struct page *indirect_page =alloc_page (GFP_NOIO ); +struct page *indirect_page =alloc_page (GFP_KERNEL );if (!indirect_page) goto out_of_memory;list_add (&indirect_page->lru, &rinfo->indirect_pages);
@@ -2235,15 +2238,15 @@ static int blkfront_setup_indirect(struc rinfo->shadow[i].grants_used =kvcalloc (grants,sizeof (rinfo->shadow[i].grants_used[0 ]), -GFP_NOIO ); +GFP_KERNEL ); rinfo->shadow[i].sg =kvcalloc (psegs,sizeof (rinfo->shadow[i].sg[0 ]), -GFP_NOIO ); +GFP_KERNEL );if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants =kvcalloc (INDIRECT_GREFS (grants),sizeof (rinfo->shadow[i].indirect_grants[0 ]), -GFP_NOIO ); +GFP_KERNEL ); if ((rinfo->shadow[i].grants_used == NULL) || (rinfo->shadow[i].sg == NULL) || (info->max_indirect_segments &&
@@ -2252,6 +2255,7 @@ static int blkfront_setup_indirect(strucsg_init_table (rinfo->shadow[i].sg, psegs); } +memalloc_noio_restore (memflags);return 0 ;
@@ -2271,6 +2275,9 @@ out_of_memory:__free_page (indirect_page); } } + +memalloc_noio_restore (memflags); +return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 26/254 clocksource/drivers/timer-microchip-pit64b: Fix rate for gck
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 0585244523f0f4de7e4480375e871617a79cab98 ]
Generic clock rate needs to be set in case it was selected as timer clock source in mchp_pit64b_init_mode(). Otherwise it will be enabled with wrong rate.
--- drivers/clocksource/timer-microchip-pit64b.c | 1 + 1 file changed, 1 insertion(+)
drivers/clocksource/timer-microchip-pit64b.c +1 -0
@@ -264,6 +264,7 @@ static int __init mchp_pit64b_init_mode(struct mchp_pit64b_timer *timer,if (!best_diff) { timer->mode |=MCHP_PIT64B_MR_SGCLK ; +clk_set_rate (timer->gclk, gclk_round); goto done; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 27/254 x86: Dont let pgprot_modify() change the page encryption bit
In reply to Greg Kroah-HartmanFrom: Thomas Hellstrom <[email protected]>
[ Upstream commit 6db73f17c5f155dbcfd5e48e621c706270b84df0 ]
When SEV or SME is enabled and active, vm_get_page_prot() typically returns with the encryption bit set. This means that users of pgprot_modify(, vm_get_page_prot()) (mprotect_fixup(), do_mmap()) end up with a value of vma->vm_pg_prot that is not consistent with the intended protection of the PTEs.
This is also important for fault handlers that rely on the VMA vm_page_prot to set the page protection. Fix this by not allowing pgprot_modify() to change the encryption bit, similar to how it's done for PAT bits.
--- arch/x86/include/asm/pgtable.h | 7 +++++-- arch/x86/include/asm/pgtable_types.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/include/asm/pgtable.h +5 -2
@@ -627,12 +627,15 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)return __pmd (val); } -/* mprotect needs to preserve PAT bits when updating vm_page_prot */ +/* +* mprotect needs to preserve PAT and encryption bits when updating +* vm_page_prot +*/ #define pgprot_modify pgprot_modifystatic inline pgprot_t pgprot_modify (pgprot_t oldprot,pgprot_t newprot) {pgprotval_t preservebits =pgprot_val (oldprot) & _PAGE_CHG_MASK; -pgprotval_t addbits =pgprot_val (newprot); +pgprotval_t addbits =pgprot_val (newprot) & ~_PAGE_CHG_MASK;return __pgprot (preservebits | addbits); }
arch/x86/include/asm/pgtable_types.h +1 -1
@@ -118,7 +118,7 @@*/ #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \ _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \ - _PAGE_SOFT_DIRTY | _PAGE_DEVMAP) + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP | _PAGE_ENC)#define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE)/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 74/254 ALSA: hda: Fix potential access overflow in beep helper
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 0ad3f0b384d58f3bd1f4fb87d0af5b8f6866f41a upstream.
The beep control helper function blindly stores the values in two stereo channels no matter whether the actual control is mono or stereo. This is practically harmless, but it annoys the recently introduced sanity check, resulting in an error when the checker is enabled.
This patch corrects the behavior to store only on the defined array member.
--- sound/pci/hda/hda_beep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_beep.c +5 -1
@@ -290,8 +290,12 @@ int snd_hda_mixer_amp_switch_get_beep(st {struct hda_codec *codec =snd_kcontrol_chip (kcontrol);struct hda_beep *beep = codec->beep; +int chs =get_amp_channels (kcontrol); +if (beep && (!beep->enabled || !ctl_has_mute (kcontrol))) { - ucontrol->value.integer.value[0 ] = +if (chs &1 ) + ucontrol->value.integer.value[0 ] = beep->enabled; +if (chs &2 ) ucontrol->value.integer.value[1 ] = beep->enabled;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 76/254 ALSA: pcm: oss: Fix regression by buffer overflow fix
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit ae769d3556644888c964635179ef192995f40793 upstream.
The recent fix for the OOB access in PCM OSS plugins (commitf2ecf903ef06: "ALSA: pcm: oss: Avoid plugin buffer overflow") caused a regression on OSS applications. The patch introduced the size check in client and slave size calculations to limit to each plugin's buffer size, but I overlooked that some code paths call those without allocating the buffer but just for estimation.
This patch fixes the bug by skipping the size check for those code paths while keeping checking in the actual transfer calls.
--- sound/core/oss/pcm_plugin.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
sound/core/oss/pcm_plugin.c +24 -8
@@ -196,7 +196,9 @@ int snd_pcm_plugin_free(struct snd_pcm_preturn 0 ; } -snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *plug,snd_pcm_uframes_t drv_frames) +static snd_pcm_sframes_t plug_client_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t drv_frames, +bool check_size) {struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;int stream;
@@ -209,7 +211,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_siif (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { plugin =snd_pcm_plug_last (plug);while (plugin && drv_frames >0 ) { -if (drv_frames > plugin->buf_frames) +if (check_size && drv_frames > plugin->buf_frames) drv_frames = plugin->buf_frames; plugin_prev = plugin->prev;if (plugin->src_frames)
@@ -222,7 +224,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_si plugin_next = plugin->next;if (plugin->dst_frames) drv_frames = plugin->dst_frames (plugin, drv_frames); -if (drv_frames > plugin->buf_frames) +if (check_size && drv_frames > plugin->buf_frames) drv_frames = plugin->buf_frames; plugin = plugin_next; }
@@ -231,7 +233,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_sireturn drv_frames; } -snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *plug,snd_pcm_uframes_t clt_frames) +static snd_pcm_sframes_t plug_slave_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t clt_frames, +bool check_size) {struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;snd_pcm_sframes_t frames;
@@ -252,14 +256,14 @@ snd_pcm_sframes_t snd_pcm_plug_slave_sizif (frames <0 )return frames; } -if (frames > plugin->buf_frames) +if (check_size && frames > plugin->buf_frames) frames = plugin->buf_frames; plugin = plugin_next; } }else if (stream ==SNDRV_PCM_STREAM_CAPTURE ) { plugin =snd_pcm_plug_last (plug);while (plugin) { -if (frames > plugin->buf_frames) +if (check_size && frames > plugin->buf_frames) frames = plugin->buf_frames; plugin_prev = plugin->prev;if (plugin->src_frames) {
@@ -274,6 +278,18 @@ snd_pcm_sframes_t snd_pcm_plug_slave_sizreturn frames; } +snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t drv_frames) +{ +return plug_client_size (plug, drv_frames, false); +} + +snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *plug, +snd_pcm_uframes_t clt_frames) +{ +return plug_slave_size (plug, clt_frames, false); +} +static int snd_pcm_plug_formats (const struct snd_mask *mask,snd_pcm_format_t format) {
@@ -630,7 +646,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_tra src_channels = dst_channels; plugin = next; } -return snd_pcm_plug_client_size (plug, frames); +return plug_client_size (plug, frames, true); }snd_pcm_sframes_t snd_pcm_plug_read_transfer (struct snd_pcm_substream *plug,struct snd_pcm_plugin_channel *dst_channels_final,snd_pcm_uframes_t size)
@@ -640,7 +656,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transnd_pcm_sframes_t frames = size;int err; - frames =snd_pcm_plug_slave_size (plug, frames); + frames =plug_slave_size (plug, frames, true);if (frames <0 )return frames;
Greg Kroah-Hartman
maintainerPATCH 75/254 ALSA: ice1724: Fix invalid access for enumerated ctl items
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit c47914c00be346bc5b48c48de7b0da5c2d1a296c upstream.
The access to Analog Capture Source control value implemented in prodigy_hifi.c is wrong, as caught by the recently introduced sanity check; it should be accessing value.enumerated.item[] instead of value.integer.value[]. This patch corrects the wrong access pattern.
--- sound/pci/ice1712/prodigy_hifi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/ice1712/prodigy_hifi.c +2 -2
@@ -536,7 +536,7 @@ static int wm_adc_mux_enum_get(struct snstruct snd_ice1712 *ice =snd_kcontrol_chip (kcontrol);mutex_lock (&ice->gpio_mutex); - ucontrol->value.integer.value[0 ] =wm_get (ice,WM_ADC_MUX ) &0x1f ; + ucontrol->value.enumerated.item[0 ] =wm_get (ice,WM_ADC_MUX ) &0x1f ;mutex_unlock (&ice->gpio_mutex);return 0 ; }
@@ -550,7 +550,7 @@ static int wm_adc_mux_enum_put(struct snmutex_lock (&ice->gpio_mutex); oval =wm_get (ice,WM_ADC_MUX ); - nval = (oval &0xe0 ) | ucontrol->value.integer.value[0 ]; + nval = (oval &0xe0 ) | ucontrol->value.enumerated.item[0 ];if (nval != oval) {wm_put (ice,WM_ADC_MUX , nval); change =1 ;
Greg Kroah-Hartman
maintainerPATCH 86/254 media: hantro: Read be32 words starting at every fourth byte
In reply to Greg Kroah-HartmanFrom: Andrzej Pietrasiewicz <[email protected]>
commit e34bca49e4953e5c2afc0425303199a5fd515f82 upstream.
Since (luma/chroma)_qtable is an array of unsigned char, indexing it returns consecutive byte locations, but we are supposed to read the arrays in four-byte words. Consequently, we should be pointing get_unaligned_be32() at consecutive word locations instead.
--- drivers/staging/media/hantro/hantro_h1_jpeg_enc.c | 9 +++++++-- drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/staging/media/hantro/hantro_h1_jpeg_enc.c +7 -2
@@ -67,12 +67,17 @@ hantro_h1_jpeg_enc_set_qtable(struct han unsigned char *chroma_qtable) {u32 reg, i; +__be32 *luma_qtable_p; +__be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable;for (i =0 ; i <H1_JPEG_QUANT_TABLE_COUNT ; i++) { - reg =get_unaligned_be32 (&luma_qtable[i]); + reg =get_unaligned_be32 (&luma_qtable_p[i]);vepu_write_relaxed (vpu, reg,H1_REG_JPEG_LUMA_QUAT (i)); - reg =get_unaligned_be32 (&chroma_qtable[i]); + reg =get_unaligned_be32 (&chroma_qtable_p[i]);vepu_write_relaxed (vpu, reg,H1_REG_JPEG_CHROMA_QUAT (i)); } }
drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c +7 -2
@@ -98,12 +98,17 @@ rk3399_vpu_jpeg_enc_set_qtable(struct ha unsigned char *chroma_qtable) {u32 reg, i; +__be32 *luma_qtable_p; +__be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable;for (i =0 ; i <VEPU_JPEG_QUANT_TABLE_COUNT ; i++) { - reg =get_unaligned_be32 (&luma_qtable[i]); + reg =get_unaligned_be32 (&luma_qtable_p[i]);vepu_write_relaxed (vpu, reg,VEPU_REG_JPEG_LUMA_QUAT (i)); - reg =get_unaligned_be32 (&chroma_qtable[i]); + reg =get_unaligned_be32 (&chroma_qtable_p[i]);vepu_write_relaxed (vpu, reg,VEPU_REG_JPEG_CHROMA_QUAT (i)); } }
Greg Kroah-Hartman
maintainerPATCH 56/254 md: check arrays is suspended in mddev_detach before call quiesce operations
In reply to Greg Kroah-HartmanFrom: Guoqing Jiang <[email protected]>
[ Upstream commit 6b40bec3b13278d21fa6c1ae7a0bdf2e550eed5f ]
Don't call quiesce(1) and quiesce(0) if array is already suspended, otherwise in level_store, the array is writable after mddev_detach in below part though the intention is to make array writable after resume.
mddev_suspend(mddev); mddev_detach(mddev); ... mddev_resume(mddev);
And it also causes calltrace as follows in [1].
[48005.653834] WARNING: CPU: 1 PID: 45380 at kernel/kthread.c:510 kthread_park+0x77/0x90 [...] [48005.653976] CPU: 1 PID: 45380 Comm: mdadm Tainted: G OE 5.4.10-arch1-1 #1 [48005.653979] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./J4105-ITX, BIOS P1.40 08/06/2018 [48005.653984] RIP: 0010:kthread_park+0x77/0x90 [48005.654015] Call Trace: [48005.654039] r5l_quiesce+0x3c/0x70 [raid456] [48005.654052] raid5_quiesce+0x228/0x2e0 [raid456] [48005.654073] mddev_detach+0x30/0x70 [md_mod] [48005.654090] level_store+0x202/0x670 [md_mod] [48005.654099] ? security_capable+0x40/0x60 [48005.654114] md_attr_store+0x7b/0xc0 [md_mod] [48005.654123] kernfs_fop_write+0xce/0x1b0 [48005.654132] vfs_write+0xb6/0x1a0 [48005.654138] ksys_write+0x67/0xe0 [48005.654146] do_syscall_64+0x4e/0x140 [48005.654155] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [48005.654161] RIP: 0033:0x7fa0c8737497
[1]: https://bugzilla.kernel.org/show_bug.cgi?id=206161
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -6184,7 +6184,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);static void mddev_detach (struct mddev *mddev) {md_bitmap_wait_behind_writes (mddev); -if (mddev->pers && mddev->pers->quiesce) { +if (mddev->pers && mddev->pers->quiesce && !mddev->suspended) { mddev->pers->quiesce (mddev,1 ); mddev->pers->quiesce (mddev,0 ); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 92/254 ACPICA: Allow acpi_any_gpe_status_set() to skip one GPE
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 0ce792d660bda990c675eaf14ce09594a9b85cbf upstream.
The check carried out by acpi_any_gpe_status_set() is not precise enough for the suspend-to-idle implementation in Linux and in some cases it is necessary make it skip one GPE (specifically, the EC GPE) from the check to prevent a race condition leading to a premature system resume from occurring.
For this reason, redefine acpi_any_gpe_status_set() to take the number of a GPE to skip as an argument.
--- drivers/acpi/acpica/achware.h | 2 - drivers/acpi/acpica/evxfgpe.c | 17 ++++++++++----- drivers/acpi/acpica/hwgpe.c | 47 +++++++++++++++++++++++++++++++++--------- drivers/acpi/sleep.c | 2 - include/acpi/acpixf.h | 2 - 5 files changed, 53 insertions(+), 17 deletions(-)
drivers/acpi/acpica/achware.h +1 -1
@@ -101,7 +101,7 @@ acpi_status acpi_hw_enable_all_runtime_gacpi_status acpi_hw_enable_all_wakeup_gpes (void ); -u8 acpi_hw_check_all_gpes (void ); +u8 acpi_hw_check_all_gpes (acpi_handle gpe_skip_device,u32 gpe_skip_number); acpi_status acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
drivers/acpi/acpica/evxfgpe.c +12 -5
@@ -799,17 +799,19 @@ ACPI_EXPORT_SYMBOL(acpi_enable_all_wakeu* * FUNCTION: acpi_any_gpe_status_set * -* PARAMETERS: None +* PARAMETERS: gpe_skip_number - Number of the GPE to skip * * RETURN: Whether or not the status bit is set for any GPE * -* DESCRIPTION: Check the status bits of all enabled GPEs and return TRUE if any -* of them is set or FALSE otherwise. +* DESCRIPTION: Check the status bits of all enabled GPEs, except for the one +* represented by the "skip" argument, and return TRUE if any of +* them is set or FALSE otherwise. * ******************************************************************************/ -u32 acpi_any_gpe_status_set (void ) +u32 acpi_any_gpe_status_set (u32 gpe_skip_number) {acpi_status status; +acpi_handle gpe_device;u8 ret;ACPI_FUNCTION_TRACE (acpi_any_gpe_status_set);
@@ -819,7 +821,12 @@ u32 acpi_any_gpe_status_set(void)return (FALSE); } - ret =acpi_hw_check_all_gpes (); + status =acpi_get_gpe_device (gpe_skip_number, &gpe_device); +if (ACPI_FAILURE (status)) { + gpe_device =NULL ; + } + + ret =acpi_hw_check_all_gpes (gpe_device, gpe_skip_number); (void )acpi_ut_release_mutex (ACPI_MTX_EVENTS );return (ret);
drivers/acpi/acpica/hwgpe.c +38 -9
93 lines not on this page · raw message
drivers/acpi/sleep.c +1 -1
@@ -1026,7 +1026,7 @@ static bool acpi_s2idle_wake(void)* status bit from unset to set between the checks with the * status bits of all the other GPEs unset. */ -if (acpi_any_gpe_status_set () && !acpi_ec_dispatch_gpe ()) +if (acpi_any_gpe_status_set (U32_MAX ) && !acpi_ec_dispatch_gpe ())return true;/*
include/acpi/acpixf.h +1 -1
@@ -752,7 +752,7 @@ ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void)) -ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void)) +ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(u32 gpe_skip_number)) ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_fixed_event_status_set(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
Greg Kroah-Hartman
maintainerPATCH 109/254 KEYS: reaching the keys quotas correctly
In reply to Greg Kroah-HartmanFrom: Yang Xu <[email protected]>
commit 2e356101e72ab1361821b3af024d64877d9a798d upstream.
Currently, when we add a new user key, the calltrace as below:
add_key()
key_create_or_update()
key_alloc()
__key_instantiate_and_link
generic_key_instantiate
key_payload_reserve
......Since commit a08bf91ce28e ("KEYS: allow reaching the keys quotas exactly"), we can reach max bytes/keys in key_alloc, but we forget to remove this limit when we reserver space for payload in key_payload_reserve. So we can only reach max keys but not max bytes when having delta between plen and type->def_datalen. Remove this limit when instantiating the key, so we can keep consistent with key_alloc.
Also, fix the similar problem in keyctl_chown_key().
--- security/keys/key.c | 2 +- security/keys/keyctl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
security/keys/key.c +1 -1
@@ -382,7 +382,7 @@ int key_payload_reserve(struct key *key,spin_lock (&key->user->lock);if (delta >0 && - (key->user->qnbytes + delta >= maxbytes || + (key->user->qnbytes + delta > maxbytes || key->user->qnbytes + delta < key->user->qnbytes)) { ret = -EDQUOT ; }
security/keys/keyctl.c +2 -2
@@ -937,8 +937,8 @@ long keyctl_chown_key(key_serial_t id, u key_quota_root_maxbytes : key_quota_maxbytes;spin_lock (&newowner->lock); -if (newowner->qnkeys +1 >= maxkeys || - newowner->qnbytes + key->quotalen >= maxbytes || +if (newowner->qnkeys +1 > maxkeys || + newowner->qnbytes + key->quotalen > maxbytes || newowner->qnbytes + key->quotalen < newowner->qnbytes) goto quota_overrun;
Greg Kroah-Hartman
maintainerPATCH 111/254 rcu: Make rcu_barrier() account for offline no-CBs CPUs
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit 127e29815b4b2206c0a97ac1d83f92ffc0e25c34 upstream.
Currently, rcu_barrier() ignores offline CPUs, However, it is possible for an offline no-CBs CPU to have callbacks queued, and rcu_barrier() must wait for those callbacks. This commit therefore makes rcu_barrier() directly invoke the rcu_barrier_func() with interrupts disabled for such CPUs. This requires passing the CPU number into this function so that it can entrain the rcu_barrier() callback onto the correct CPU's callback list, given that the code must instead execute on the current CPU.
While in the area, this commit fixes a bug where the first CPU's callback might have been invoked before rcu_segcblist_entrain() returned, which would also result in an early wakeup.
--- include/trace/events/rcu.h | 1 + kernel/rcu/tree.c | 36 ++++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-)
include/trace/events/rcu.h +1 -0
@@ -712,6 +712,7 @@ TRACE_EVENT_RCU(rcu_torture_read,* "Begin": rcu_barrier() started. * "EarlyExit": rcu_barrier() piggybacked, thus early exit. * "Inc1": rcu_barrier() piggyback check counter incremented. +* "OfflineNoCBQ": rcu_barrier() found offline no-CBs CPU with callbacks. * "OnlineQ": rcu_barrier() found online CPU with callbacks. * "OnlineNQ": rcu_barrier() found online CPU, no callbacks. * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
kernel/rcu/tree.c +24 -12
@@ -3090,9 +3090,10 @@ static void rcu_barrier_callback(struct/* * Called with preemption disabled, and from cross-cpu IRQ context. */ -static void rcu_barrier_func (void *unused) +static void rcu_barrier_func (void *cpu_in) { -struct rcu_data *rdp =raw_cpu_ptr (&rcu_data); +uintptr_t cpu = (uintptr_t )cpu_in; +struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu);rcu_barrier_trace (TPS ("IRQ" ),-1 , rcu_state.barrier_sequence); rdp->barrier_head.func = rcu_barrier_callback;
@@ -3119,7 +3120,7 @@ static void rcu_barrier_func(void *unuse*/ void rcu_barrier (void ) { -int cpu; +uintptr_t cpu;struct rcu_data *rdp;unsigned long s =rcu_seq_snap (&rcu_state.barrier_sequence);
@@ -3142,13 +3143,14 @@ void rcu_barrier(void)rcu_barrier_trace (TPS ("Inc1" ),-1 , rcu_state.barrier_sequence);/* -* Initialize the count to one rather than to zero in order to -* avoid a too-soon return to zero in case of a short grace period -* (or preemption of this task). Exclude CPU-hotplug operations -* to ensure that no offline CPU has callbacks queued. +* Initialize the count to two rather than to zero in order +* to avoid a too-soon return to zero in case of an immediate +* invocation of the just-enqueued callback (or preemption of +* this task). Exclude CPU-hotplug operations to ensure that no +* offline non-offloaded CPU has callbacks queued. */ init_completion (&rcu_state.barrier_completion); -atomic_set (&rcu_state.barrier_cpu_count,1 ); +atomic_set (&rcu_state.barrier_cpu_count,2 );get_online_cpus ();/*
@@ -3158,13 +3160,23 @@ void rcu_barrier(void)*/ for_each_possible_cpu (cpu) { rdp =per_cpu_ptr (&rcu_data, cpu); -if (!cpu_online (cpu) && +if (cpu_is_offline (cpu) && !rcu_segcblist_is_offloaded (&rdp->cblist))continue ; -if (rcu_segcblist_n_cbs (&rdp->cblist)) { +if (rcu_segcblist_n_cbs (&rdp->cblist) &&cpu_online (cpu)) {rcu_barrier_trace (TPS ("OnlineQ" ), cpu, rcu_state.barrier_sequence); -smp_call_function_single (cpu, rcu_barrier_func,NULL ,1 ); +smp_call_function_single (cpu, rcu_barrier_func, (void *)cpu,1 ); + }else if (rcu_segcblist_n_cbs (&rdp->cblist) && +cpu_is_offline (cpu)) { +rcu_barrier_trace (TPS ("OfflineNoCBQ" ), cpu, + rcu_state.barrier_sequence); +local_irq_disable (); +rcu_barrier_func ((void *)cpu); +local_irq_enable (); + }else if (cpu_is_offline (cpu)) { +rcu_barrier_trace (TPS ("OfflineNoCBNoQ" ), cpu, + rcu_state.barrier_sequence); }else {rcu_barrier_trace (TPS ("OnlineNQ" ), cpu, rcu_state.barrier_sequence);
@@ -3176,7 +3188,7 @@ void rcu_barrier(void)* Now that we have an rcu_barrier_callback() callback on each * CPU, and thus each counted, remove the initial count. */ -if (atomic_dec_and_test (&rcu_state.barrier_cpu_count)) +if (atomic_sub_and_test (2 , &rcu_state.barrier_cpu_count))complete (&rcu_state.barrier_completion);/* Wait for all rcu_barrier_callback() callbacks to be invoked. */
Greg Kroah-Hartman
maintainerPATCH 113/254 genirq/debugfs: Add missing sanity checks to interrupt injection
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit a740a423c36932695b01a3e920f697bc55b05fec upstream.
Interrupts cannot be injected when the interrupt is not activated and when a replay is already in progress.
--- kernel/irq/debugfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/irq/debugfs.c +9 -2
@@ -206,8 +206,15 @@ static ssize_t irq_debug_write(struct fichip_bus_lock (desc);raw_spin_lock_irqsave (&desc->lock, flags); -if (irq_settings_is_level (desc) || desc->istate &IRQS_NMI ) { -/* Can't do level nor NMIs, sorry */ +/* +* Don't allow injection when the interrupt is: +* - Level or NMI type +* - not activated +* - replaying already +*/ +if (irq_settings_is_level (desc) || + !irqd_is_activated (&desc->irq_data) || + (desc->istate & (IRQS_NMI |IRQS_REPLAY ))) { err = -EINVAL ; }else { desc->istate |=IRQS_PENDING ;
Greg Kroah-Hartman
maintainerPATCH 123/254 ath9k: Handle txpower changes even when TPC is disabled
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
commit 968ae2caad0782db5dbbabb560d3cdefd2945d38 upstream.
When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to reconfigure HW's maximum txpower.
This fixes 0dBm txpower setting when user attaches to an interface for the first time with the following scenario:
ieee80211_do_open()
ath9k_add_interface()
ath9k_set_txpower() /* Set TX power with not yet initialized
sc->hw->conf.power_level */
ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
raise IEEE80211_CONF_CHANGE_POWER */
ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */This issue can be reproduced with the following:
$ modprobe -r ath9k
$ modprobe ath9k
$ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
$ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
$ killall wpa_supplicant
$ iw dev /* TX power goes back to calibrated value and subsequent
calls will be fine */--- drivers/net/wireless/ath/ath9k/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/main.c +3 -0
@@ -1457,6 +1457,9 @@ static int ath9k_config(struct ieee80211ath_chanctx_set_channel (sc, ctx, &hw->conf.chandef); } +if (changed &IEEE80211_CONF_CHANGE_POWER ) +ath9k_set_txpower (sc,NULL ); +mutex_unlock (&sc->mutex);ath9k_ps_restore (sc);
Greg Kroah-Hartman
maintainerPATCH 45/254 gfs2: Dont demote a glock until its revokes are written
In reply to Greg Kroah-HartmanFrom: Bob Peterson <[email protected]>
[ Upstream commit df5db5f9ee112e76b5202fbc331f990a0fc316d6 ]
Before this patch, run_queue would demote glocks based on whether there are any more holders. But if the glock has pending revokes that haven't been written to the media, giving up the glock might end in file system corruption if the revokes never get written due to io errors, node crashes and fences, etc. In that case, another node will replay the metadata blocks associated with the glock, but because the revoke was never written, it could replay that block even though the glock had since been granted to another node who might have made changes.
This patch changes the logic in run_queue so that it never demotes a glock until its count of pending revokes reaches zero.
--- fs/gfs2/glock.c | 3 +++ 1 file changed, 3 insertions(+)
fs/gfs2/glock.c +3 -0
@@ -645,6 +645,9 @@ __acquires(&gl->gl_lockref.lock) goto out_unlock;if (nonblock) goto out_sched; +smp_mb (); +if (atomic_read (&gl->gl_revokes) !=0 ) + goto out_sched;set_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags);GLOCK_BUG_ON (gl, gl->gl_demote_state ==LM_ST_EXCLUSIVE ); gl->gl_target = gl->gl_demote_state;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 131/254 KVM: nVMX: Properly handle userspace interrupt window request
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit a1c77abb8d93381e25a8d2df3a917388244ba776 upstream.
Return true for vmx_interrupt_allowed() if the vCPU is in L2 and L1 has external interrupt exiting enabled. IRQs are never blocked in hardware if the CPU is in the guest (L2 from L1's perspective) when IRQs trigger VM-Exit.
The new check percolates up to kvm_vcpu_ready_for_interrupt_injection() and thus vcpu_run(), and so KVM will exit to userspace if userspace has requested an interrupt window (to inject an IRQ into L1).
Remove the @external_intr param from vmx_check_nested_events(), which is actually an indicator that userspace wants an interrupt window, e.g. it's named @req_int_win further up the stack. Injecting a VM-Exit into L1 to try and bounce out to L0 userspace is all kinds of broken and is no longer necessary.
Remove the hack in nested_vmx_vmexit() that attempted to workaround the breakage in vmx_check_nested_events() by only filling interrupt info if there's an actual interrupt pending. The hack actually made things worse because it caused KVM to _never_ fill interrupt info when the LAPIC resides in userspace (kvm_cpu_has_interrupt() queries interrupt.injected, which is always cleared by prepare_vmcs12() before reaching the hack in nested_vmx_vmexit()).
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx/nested.c | 18 ++++-------------- arch/x86/kvm/vmx/vmx.c | 9 +++++++-- arch/x86/kvm/x86.c | 10 +++++----- 4 files changed, 17 insertions(+), 22 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -1180,7 +1180,7 @@ struct kvm_x86_ops {bool (*pt_supported)(void );bool (*pku_supported)(void ); -int (*check_nested_events)(struct kvm_vcpu *vcpu,bool external_intr); +int (*check_nested_events)(struct kvm_vcpu *vcpu);void (*request_immediate_exit)(struct kvm_vcpu *vcpu);void (*sched_in)(struct kvm_vcpu *kvm,int cpu);
arch/x86/kvm/vmx/nested.c +4 -14
@@ -3604,7 +3604,7 @@ static void nested_vmx_update_pending_db vcpu->arch.exception.payload); } -static int vmx_check_nested_events (struct kvm_vcpu *vcpu,bool external_intr) +static int vmx_check_nested_events (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu);unsigned long exit_qual;
@@ -3680,8 +3680,7 @@ static int vmx_check_nested_events(strucreturn 0 ; } -if ((kvm_cpu_has_interrupt (vcpu) || external_intr) && -nested_exit_on_intr (vcpu)) { +if (kvm_cpu_has_interrupt (vcpu) &&nested_exit_on_intr (vcpu)) {if (block_nested_events)return -EBUSY ;nested_vmx_vmexit (vcpu,EXIT_REASON_EXTERNAL_INTERRUPT ,0 ,0 );
@@ -4329,17 +4328,8 @@ void nested_vmx_vmexit(struct kvm_vcpu * vcpu->arch.mp_state =KVM_MP_STATE_RUNNABLE ;if (likely (!vmx->fail)) { -/* -* TODO: SDM says that with acknowledge interrupt on -* exit, bit 31 of the VM-exit interrupt information -* (valid interrupt) is always set to 1 on -* EXIT_REASON_EXTERNAL_INTERRUPT, so we shouldn't -* need kvm_cpu_has_interrupt(). See the commit -* message for details. -*/ -if (nested_exit_intr_ack_set (vcpu) && - exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT && -kvm_cpu_has_interrupt (vcpu)) { +if (exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT && +nested_exit_intr_ack_set (vcpu)) {int irq =kvm_cpu_get_interrupt (vcpu);WARN_ON (irq <0 ); vmcs12->vm_exit_intr_info = irq |
arch/x86/kvm/vmx/vmx.c +7 -2
@@ -4507,8 +4507,13 @@ static int vmx_nmi_allowed(struct kvm_vcstatic int vmx_interrupt_allowed (struct kvm_vcpu *vcpu) { -return (!to_vmx (vcpu)->nested.nested_run_pending && -vmcs_readl (GUEST_RFLAGS ) &X86_EFLAGS_IF ) && +if (to_vmx (vcpu)->nested.nested_run_pending) +return false; + +if (is_guest_mode (vcpu) &&nested_exit_on_intr (vcpu)) +return true; + +return (vmcs_readl (GUEST_RFLAGS ) &X86_EFLAGS_IF ) && !(vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); }
arch/x86/kvm/x86.c +5 -5
@@ -7635,7 +7635,7 @@ static void update_cr8_intercept(struct kvm_x86_ops->update_cr8_intercept (vcpu, tpr, max_irr); } -static int inject_pending_event (struct kvm_vcpu *vcpu,bool req_int_win) +static int inject_pending_event (struct kvm_vcpu *vcpu) {int r;
@@ -7671,7 +7671,7 @@ static int inject_pending_event(struct k* from L2 to L1. */ if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) { - r = kvm_x86_ops->check_nested_events (vcpu, req_int_win); + r = kvm_x86_ops->check_nested_events (vcpu);if (r !=0 )return r; }
@@ -7733,7 +7733,7 @@ static int inject_pending_event(struct k* KVM_REQ_EVENT only on certain events and not unconditionally? */ if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) { - r = kvm_x86_ops->check_nested_events (vcpu, req_int_win); + r = kvm_x86_ops->check_nested_events (vcpu);if (r !=0 )return r; }
@@ -8266,7 +8266,7 @@ static int vcpu_enter_guest(struct kvm_v goto out; } -if (inject_pending_event (vcpu, req_int_win) !=0 ) +if (inject_pending_event (vcpu) !=0 ) req_immediate_exit = true;else {/* Enable SMI/NMI/IRQ window open exits if needed.
@@ -8496,7 +8496,7 @@ static inline int vcpu_block(struct kvmstatic inline bool kvm_vcpu_running (struct kvm_vcpu *vcpu) {if (is_guest_mode (vcpu) && kvm_x86_ops->check_nested_events) - kvm_x86_ops->check_nested_events (vcpu, false); + kvm_x86_ops->check_nested_events (vcpu);return (vcpu->arch.mp_state ==KVM_MP_STATE_RUNNABLE && !vcpu->arch.apf.halted);
Greg Kroah-Hartman
maintainerPATCH 95/254 thermal: devfreq_cooling: inline all stubs for CONFIG_DEVFREQ_THERMAL=n
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
commit 3f5b9959041e0db6dacbea80bb833bff5900999f upstream.
When CONFIG_DEVFREQ_THERMAL is disabled all functions except of_devfreq_cooling_register_power() were already inlined. Also inline the last function to avoid compile errors when multiple drivers call of_devfreq_cooling_register_power() when CONFIG_DEVFREQ_THERMAL is not set. Compilation failed with the following message:
multiple definition of `of_devfreq_cooling_register_power'
(which then lists all usages of of_devfreq_cooling_register_power())
Thomas Zimmermann reported this problem [0] on a kernel config with CONFIG_DRM_LIMA={m,y}, CONFIG_DRM_PANFROST={m,y} and CONFIG_DEVFREQ_THERMAL=n after both, the lima and panfrost drivers gained devfreq cooling support.
[0] https://www.spinics.net/lists/dri-devel/msg252825.html
--- include/linux/devfreq_cooling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/devfreq_cooling.h +1 -1
@@ -75,7 +75,7 @@ void devfreq_cooling_unregister(struct t#else /* !CONFIG_DEVFREQ_THERMAL */ -struct thermal_cooling_device * +static inline struct thermal_cooling_device *of_devfreq_cooling_register_power (struct device_node *np,struct devfreq *df,struct devfreq_cooling_power *dfc_power) {
Greg Kroah-Hartman
maintainerPATCH 139/254 smb3: fix performance regression with setting mtime
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
commit cf5371ae460eb8e484e4884747af270c86c3c469 upstream.
There are cases when we don't want to send the SMB2 flush operation (e.g. when user specifies mount parm "nostrictsync") and it can be a very expensive operation on the server. In most cases in order to set mtime, we simply need to flush (write) the dirtry pages from the client and send the writes to the server not also send a flush protocol operation to the server.
--- fs/cifs/inode.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
fs/cifs/inode.c +12 -11
@@ -2516,25 +2516,26 @@ cifs_setattr_nounix(struct dentry *diren/* * Attempt to flush data before changing attributes. We need to do -* this for ATTR_SIZE and ATTR_MTIME for sure, and if we change the -* ownership or mode then we may also need to do this. Here, we take -* the safe way out and just do the flush on all setattr requests. If -* the flush returns error, store it to report later and continue. +* this for ATTR_SIZE and ATTR_MTIME. If the flush of the data +* returns error, store it to report later and continue. * * BB: This should be smarter. Why bother flushing pages that * will be truncated anyway? Also, should we error out here if -* the flush returns error? +* the flush returns error? Do we need to check for ATTR_MTIME_SET flag? */ - rc =filemap_write_and_wait (inode->i_mapping); -if (is_interrupt_error (rc)) { - rc = -ERESTARTSYS ; - goto cifs_setattr_exit; +if (attrs->ia_valid & (ATTR_MTIME |ATTR_SIZE |ATTR_CTIME )) { + rc =filemap_write_and_wait (inode->i_mapping); +if (is_interrupt_error (rc)) { + rc = -ERESTARTSYS ; + goto cifs_setattr_exit; + } +mapping_set_error (inode->i_mapping, rc); } -mapping_set_error (inode->i_mapping, rc); rc =0 ; -if (attrs->ia_valid &ATTR_MTIME ) { +if ((attrs->ia_valid &ATTR_MTIME ) && + !(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) { rc =cifs_get_writable_file (cifsInode,FIND_WR_ANY , &wfile);if (!rc) { tcon =tlink_tcon (wfile->tlink);
Greg Kroah-Hartman
maintainerPATCH 171/254 arm64: dts: allwinner: h5: Fix PMU compatible
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
commit 4ae7a3c3d7d31260f690d8d658f0365f3eca67a2 upstream.
The commit c35a516a4618 ("arm64: dts: allwinner: H5: Add PMU node") introduced support for the PMU found on the Allwinner H5. However, the binding only allows for a single compatible, while the patch was adding two.
Make sure we follow the binding.
--- arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +1 -2
@@ -38,8 +38,7 @@ }; pmu { - compatible = "arm,cortex-a53-pmu", - "arm,armv8-pmuv3"; + compatible = "arm,cortex-a53-pmu"; interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
Greg Kroah-Hartman
maintainerPATCH 138/254 KVM: VMX: fix crash cleanup when KVM wasnt used
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit dbef2808af6c594922fe32833b30f55f35e9da6d upstream.
If KVM wasn't used at all before we crash the cleanup procedure fails with
BUG: unable to handle page fault for address: ffffffffffffffc8 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 23215067 P4D 23215067 PUD 23217067 PMD 0 Oops: 0000 [#8] SMP PTI CPU: 0 PID: 3542 Comm: bash Kdump: loaded Tainted: G D 5.6.0-rc2+ #823 RIP: 0010:crash_vmclear_local_loaded_vmcss.cold+0x19/0x51 [kvm_intel]
The root cause is that loaded_vmcss_on_cpu list is not yet initialized, we initialize it in hardware_enable() but this only happens when we start a VM.
Previously, we used to have a bitmap with enabled CPUs and that was preventing [masking] the issue.
Initialized loaded_vmcss_on_cpu list earlier, right before we assign crash_vmclear_loaded_vmcss pointer. blocked_vcpu_on_cpu list and blocked_vcpu_on_cpu_lock are moved altogether for consistency.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/vmx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx/vmx.c +7 -5
@@ -2264,10 +2264,6 @@ static int hardware_enable(void) !hv_get_vp_assist_page(cpu))return -EFAULT ; -INIT_LIST_HEAD (&per_cpu (loaded_vmcss_on_cpu, cpu)); -INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu)); -spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); -kvm_cpu_vmxon (phys_addr);if (enable_ept)ept_sync_global ();
@@ -8025,7 +8021,7 @@ module_exit(vmx_exit);static int __init vmx_init (void ) { -int r; +int r, cpu;#if IS_ENABLED (CONFIG_HYPERV )/*
@@ -8079,6 +8075,12 @@ static int __init vmx_init(void)return r; } +for_each_possible_cpu (cpu) { +INIT_LIST_HEAD (&per_cpu (loaded_vmcss_on_cpu, cpu)); +INIT_LIST_HEAD (&per_cpu (blocked_vcpu_on_cpu, cpu)); +spin_lock_init (&per_cpu (blocked_vcpu_on_cpu_lock, cpu)); + } +#ifdef CONFIG_KEXEC_CORE rcu_assign_pointer (crash_vmclear_loaded_vmcss, crash_vmclear_local_loaded_vmcss);
Greg Kroah-Hartman
maintainerPATCH 197/254 selftests/powerpc: Add tlbie_test in .gitignore
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 47bf235f324c696395c30541fe4fcf99fcd24188 upstream.
The commit identified below added tlbie_test but forgot to add it in .gitignore.
--- tools/testing/selftests/powerpc/mm/.gitignore | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/powerpc/mm/.gitignore +1 -0
@@ -6,3 +6,4 @@ segv_errors wild_bctr large_vm_fork_separation bad_accesses +tlbie_test
Greg Kroah-Hartman
maintainerPATCH 206/254 drm/amdgpu: unify fw_write_wait for new gfx9 asics
In reply to Greg Kroah-HartmanFrom: Aaron Liu <[email protected]>
commit 2960758cce2310774de60bbbd8d6841d436c54d9 upstream.
Make the fw_write_wait default case true since presumably all new gfx9 asics will have updated firmware. That is using unique WAIT_REG_MEM packet with opration=1.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -1158,6 +1158,8 @@ static void gfx_v9_0_check_fw_write_wait adev->gfx.mec_fw_write_wait = true;break ;default : + adev->gfx.me_fw_write_wait = true; + adev->gfx.mec_fw_write_wait = true;break ; } }
Greg Kroah-Hartman
maintainerPATCH 191/254 scsi: lpfc: Fix broken Credit Recovery after driver load
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 835214f5d5f516a38069bc077c879c7da00d6108 upstream.
When driver is set to enable bb credit recovery, the switch displayed the setting as inactive. If the link bounces, it switches to Active.
During link up processing, the driver currently does a MBX_READ_SPARAM followed by a MBX_CONFIG_LINK. These mbox commands are queued to be executed, one at a time and the completion is processed by the worker thread. Since the MBX_READ_SPARAM is done BEFORE the MBX_CONFIG_LINK, the BB_SC_N bit is never set the the returned values. BB Credit recovery status only gets set after the driver requests the feature in CONFIG_LINK, which is done after the link up. Thus the ordering of READ_SPARAM needs to follow the CONFIG_LINK.
Fix by reordering so that READ_SPARAM is done after CONFIG_LINK. Added a HBA_DEFER_FLOGI flag so that any FLOGI handling waits until after the READ_SPARAM is done so that the proper BB credit value is set in the FLOGI payload.
--- drivers/scsi/lpfc/lpfc.h | 1 drivers/scsi/lpfc/lpfc_hbadisc.c | 59 +++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 20 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -0
@@ -749,6 +749,7 @@ struct lpfc_hba {* capability */ #define HBA_FLOGI_ISSUED 0x100000/* FLOGI was issued */ +#define HBA_DEFER_FLOGI 0x800000/* Defer FLOGI till read_sparm cmpl */ uint32_t fcp_ring_in_use;/* When polling test if intr-hndlr active*/ struct lpfc_dmabuf slim2p;
drivers/scsi/lpfc/lpfc_hbadisc.c +39 -20
90 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 246/254 Revert "drm/dp_mst: Remove VCPI while disabling topology mgr"
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
[ Upstream commit a86675968e2300fb567994459da3dbc4cd1b322a ]
This reverts commit 64e62bdf04ab8529f45ed0a85122c703035dec3a.
This commit ends up causing some lockdep splats due to trying to grab the payload lock while holding the mgr's lock:
[ 54.010099]
[ 54.011765] ======================================================
[ 54.018670] WARNING: possible circular locking dependency detected
[ 54.025577] 5.5.0-rc6-02274-g77381c23ee63 #47 Not tainted
[ 54.031610] ------------------------------------------------------
[ 54.038516] kworker/1:6/1040 is trying to acquire lock:
[ 54.044354] ffff888272af3228 (&mgr->payload_lock){+.+.}, at:
drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.054957]
[ 54.054957] but task is already holding lock:
[ 54.061473] ffff888272af3060 (&mgr->lock){+.+.}, at:
drm_dp_mst_topology_mgr_set_mst+0x3c/0x2e4
[ 54.071193]
[ 54.071193] which lock already depends on the new lock.
[ 54.071193]
[ 54.080334]
[ 54.080334] the existing dependency chain (in reverse order) is:
[ 54.088697]
[ 54.088697] -> #1 (&mgr->lock){+.+.}:
[ 54.094440] __mutex_lock+0xc3/0x498
[ 54.099015] drm_dp_mst_topology_get_port_validated+0x25/0x80
[ 54.106018] drm_dp_update_payload_part1+0xa2/0x2e2
[ 54.112051] intel_mst_pre_enable_dp+0x144/0x18f
[ 54.117791] intel_encoders_pre_enable+0x63/0x70
[ 54.123532] hsw_crtc_enable+0xa1/0x722
[ 54.128396] intel_update_crtc+0x50/0x194
[ 54.133455] skl_commit_modeset_enables+0x40c/0x540
[ 54.139485] intel_atomic_commit_tail+0x5f7/0x130d
[ 54.145418] intel_atomic_commit+0x2c8/0x2d8
[ 54.150770] drm_atomic_helper_set_config+0x5a/0x70
[ 54.156801] drm_mode_setcrtc+0x2ab/0x833
[ 54.161862] drm_ioctl+0x2e5/0x424
[ 54.166242] vfs_ioctl+0x21/0x2f
[ 54.170426] do_vfs_ioctl+0x5fb/0x61e
[ 54.175096] ksys_ioctl+0x55/0x75
[ 54.179377] __x64_sys_ioctl+0x1a/0x1e
[ 54.184146] do_syscall_64+0x5c/0x6d
[ 54.188721] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 54.194946]
[ 54.194946] -> #0 (&mgr->payload_lock){+.+.}:
[ 54.201463]
[ 54.201463] other info that might help us debug this:
[ 54.201463]
[ 54.210410] Possible unsafe locking scenario:
[ 54.210410]
[ 54.217025] CPU0 CPU1
[ 54.222082] ---- ----
[ 54.227138] lock(&mgr->lock);
[ 54.230643] lock(&mgr->payload_lock);
[ 54.237742] lock(&mgr->lock);
[ 54.244062] lock(&mgr->payload_lock);
[ 54.248346]
[ 54.248346] *** DEADLOCK ***
[ 54.248346]
[ 54.254959] 7 locks held by kworker/1:6/1040:
[ 54.259822] #0: ffff888275c4f528 ((wq_completion)events){+.+.},
at: worker_thread+0x455/0x6e2
[ 54.269451] #1: ffffc9000119beb0
((work_completion)(&(&dev_priv->hotplug.hotplug_work)->work)){+.+.},
at: worker_thread+0x455/0x6e2
[ 54.282768] #2: ffff888272a403f0 (&dev->mode_config.mutex){+.+.},
at: i915_hotplug_work_func+0x4b/0x2be
[ 54.293368] #3: ffffffff824fc6c0 (drm_connector_list_iter){.+.+},
at: i915_hotplug_work_func+0x17e/0x2be
[ 54.304061] #4: ffffc9000119bc58 (crtc_ww_class_acquire){+.+.},
at: drm_helper_probe_detect_ctx+0x40/0xfd
[ 54.314855] #5: ffff888272a40470 (crtc_ww_class_mutex){+.+.}, at:
drm_modeset_lock+0x74/0xe2
[ 54.324385] #6: ffff888272af3060 (&mgr->lock){+.+.}, at:
drm_dp_mst_topology_mgr_set_mst+0x3c/0x2e4
[ 54.334597]
[ 54.334597] stack backtrace:
[ 54.339464] CPU: 1 PID: 1040 Comm: kworker/1:6 Not tainted
5.5.0-rc6-02274-g77381c23ee63 #47
[ 54.348893] Hardware name: Google Fizz/Fizz, BIOS
Google_Fizz.10139.39.0 01/04/2018
[ 54.357451] Workqueue: events i915_hotplug_work_func
[ 54.362995] Call Trace:
[ 54.365724] dump_stack+0x71/0x9c
[ 54.369427] check_noncircular+0x91/0xbc
[ 54.373809] ? __lock_acquire+0xc9e/0xf66
[ 54.378286] ? __lock_acquire+0xc9e/0xf66
[ 54.382763] ? lock_acquire+0x175/0x1ac
[ 54.387048] ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.393177] ? __mutex_lock+0xc3/0x498
[ 54.397362] ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.403492] ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.409620] ? drm_dp_dpcd_access+0xd9/0x101
[ 54.414390] ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.420517] ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
[ 54.426645] ? intel_digital_port_connected+0x34d/0x35c
[ 54.432482] ? intel_dp_detect+0x227/0x44e
[ 54.437056] ? ww_mutex_lock+0x49/0x9a
[ 54.441242] ? drm_helper_probe_detect_ctx+0x75/0xfd
[ 54.446789] ? intel_encoder_hotplug+0x4b/0x97
[ 54.451752] ? intel_ddi_hotplug+0x61/0x2e0
[ 54.456423] ? mark_held_locks+0x53/0x68
[ 54.460803] ? _raw_spin_unlock_irqrestore+0x3a/0x51
[ 54.466347] ? lockdep_hardirqs_on+0x187/0x1a4
[ 54.471310] ? drm_connector_list_iter_next+0x89/0x9a
[ 54.476953] ? i915_hotplug_work_func+0x206/0x2be
[ 54.482208] ? worker_thread+0x4d5/0x6e2
[ 54.486587] ? worker_thread+0x455/0x6e2
[ 54.490966] ? queue_work_on+0x64/0x64
[ 54.495151] ? kthread+0x1e9/0x1f1
[ 54.498946] ? queue_work_on+0x64/0x64
[ 54.503130] ? kthread_unpark+0x5e/0x5e
[ 54.507413] ? ret_from_fork+0x3a/0x50The proper fix for this is probably cleanup the VCPI allocations when we're enabling the topology, or on the first payload allocation. For now though, let's just revert.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +0 -13
@@ -3504,7 +3504,6 @@ static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count)int drm_dp_mst_topology_mgr_set_mst (struct drm_dp_mst_topology_mgr *mgr,bool mst_state) {int ret =0 ; -int i =0 ;struct drm_dp_mst_branch *mstb =NULL ;mutex_lock (&mgr->lock);
@@ -3565,22 +3564,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms/* this can fail if the device is gone */ drm_dp_dpcd_writeb (mgr->aux,DP_MSTM_CTRL ,0 ); ret =0 ; -mutex_lock (&mgr->payload_lock);memset (mgr->payloads,0 , mgr->max_payloads *sizeof (struct drm_dp_payload )); mgr->payload_mask =0 ;set_bit (0 , &mgr->payload_mask); -for (i =0 ; i < mgr->max_payloads; i++) { -struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i]; - -if (vcpi) { - vcpi->vcpi =0 ; - vcpi->num_slots =0 ; - } - mgr->proposed_vcpis[i] =NULL ; - } mgr->vcpi_mask =0 ; -mutex_unlock (&mgr->payload_lock); - mgr->payload_id_table_cleared = false; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 227/254 clk: ingenic/TCU: Fix round_rate returning error
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit edcc42945dee85e9dec3737f3dbf59d917ae5418 upstream.
When requesting a rate superior to the parent's rate, it would return -EINVAL instead of simply returning the parent's rate like it should.
--- drivers/clk/ingenic/tcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/ingenic/tcu.c +1 -1
@@ -189,7 +189,7 @@ static long ingenic_tcu_round_rate(strucu8 prescale;if (req_rate > rate) -return -EINVAL ; +return rate; prescale =ingenic_tcu_get_prescale (rate, req_rate);
Greg Kroah-Hartman
maintainerPATCH 130/254 KVM: PPC: Book3S HV: Skip kvmppc_uvmem_free if Ultravisor is not supported
In reply to Greg Kroah-HartmanFrom: Fabiano Rosas <[email protected]>
commit 9bee484b280a059c1faa10ae174af4f4af02c805 upstream.
kvmppc_uvmem_init checks for Ultravisor support and returns early if it is not present. Calling kvmppc_uvmem_free at module exit will cause an Oops:
$ modprobe -r kvm-hv
Oops: Kernel access of bad area, sig: 11 [#1] <snip> NIP: c000000000789e90 LR: c000000000789e8c CTR: c000000000401030 REGS: c000003fa7bab9a0 TRAP: 0300 Not tainted (5.6.0-rc6-00033-g6c90b86a745a-dirty) MSR: 9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 24002282 XER: 00000000 CFAR: c000000000dae880 DAR: 0000000000000008 DSISR: 40000000 IRQMASK: 1 GPR00: c000000000789e8c c000003fa7babc30 c0000000016fe500 0000000000000000 GPR04: 0000000000000000 0000000000000006 0000000000000000 c000003faf205c00 GPR08: 0000000000000000 0000000000000001 000000008000002d c00800000ddde140 GPR12: c000000000401030 c000003ffffd9080 0000000000000001 0000000000000000 GPR16: 0000000000000000 0000000000000000 000000013aad0074 000000013aaac978 GPR20: 000000013aad0070 0000000000000000 00007fffd1b37158 0000000000000000 GPR24: 000000014fef0d58 0000000000000000 000000014fef0cf0 0000000000000001 GPR28: 0000000000000000 0000000000000000 c0000000018b2a60 0000000000000000 NIP [c000000000789e90] percpu_ref_kill_and_confirm+0x40/0x170 LR [c000000000789e8c] percpu_ref_kill_and_confirm+0x3c/0x170 Call Trace: [c000003fa7babc30] [c000003faf2064d4] 0xc000003faf2064d4 (unreliable) [c000003fa7babcb0] [c000000000400e8c] dev_pagemap_kill+0x6c/0x80 [c000003fa7babcd0] [c000000000401064] memunmap_pages+0x34/0x2f0 [c000003fa7babd50] [c00800000dddd548] kvmppc_uvmem_free+0x30/0x80 [kvm_hv] [c000003fa7babd80] [c00800000ddcef18] kvmppc_book3s_exit_hv+0x20/0x78 [kvm_hv] [c000003fa7babda0] [c0000000002084d0] sys_delete_module+0x1d0/0x2c0 [c000003fa7babe20] [c00000000000b9d0] system_call+0x5c/0x68 Instruction dump: 3fc2001b fb81ffe0 fba1ffe8 fbe1fff8 7c7f1b78 7c9c2378 3bde4560 7fc3f378 f8010010 f821ff81 486249a1 60000000 <e93f0008> 7c7d1b78 712a0002 40820084 ---[ end trace 5774ef4dc2c98279 ]---
So this patch checks if kvmppc_uvmem_init actually allocated anything before running kvmppc_uvmem_free.
--- arch/powerpc/kvm/book3s_hv_uvmem.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kvm/book3s_hv_uvmem.c +3 -0
@@ -806,6 +806,9 @@ out:void kvmppc_uvmem_free (void ) { +if (!kvmppc_uvmem_bitmap) +return ; +memunmap_pages (&kvmppc_uvmem_pgmap);release_mem_region (kvmppc_uvmem_pgmap.res.start,resource_size (&kvmppc_uvmem_pgmap.res));
Greg Kroah-Hartman
maintainerPATCH 232/254 ipmi: fix hung processes in __get_guid()
In reply to Greg Kroah-HartmanFrom: Wen Yang <[email protected]>
commit 32830a0534700f86366f371b150b17f0f0d140d7 upstream.
The wait_event() function is used to detect command completion. When send_guid_cmd() returns an error, smi_send() has not been called to send data. Therefore, wait_event() should not be used on the error path, otherwise it will cause the following warning:
[ 1361.588808] systemd-udevd D 0 1501 1436 0x00000004 [ 1361.588813] ffff883f4b1298c0 0000000000000000 ffff883f4b188000 ffff887f7e3d9f40 [ 1361.677952] ffff887f64bd4280 ffffc90037297a68 ffffffff8173ca3b ffffc90000000010 [ 1361.767077] 00ffc90037297ad0 ffff887f7e3d9f40 0000000000000286 ffff883f4b188000 [ 1361.856199] Call Trace: [ 1361.885578] [<ffffffff8173ca3b>] ? __schedule+0x23b/0x780 [ 1361.951406] [<ffffffff8173cfb6>] schedule+0x36/0x80 [ 1362.010979] [<ffffffffa071f178>] get_guid+0x118/0x150 [ipmi_msghandler] [ 1362.091281] [<ffffffff810d5350>] ? prepare_to_wait_event+0x100/0x100 [ 1362.168533] [<ffffffffa071f755>] ipmi_register_smi+0x405/0x940 [ipmi_msghandler] [ 1362.258337] [<ffffffffa0230ae9>] try_smi_init+0x529/0x950 [ipmi_si] [ 1362.334521] [<ffffffffa022f350>] ? std_irq_setup+0xd0/0xd0 [ipmi_si] [ 1362.411701] [<ffffffffa0232bd2>] init_ipmi_si+0x492/0x9e0 [ipmi_si] [ 1362.487917] [<ffffffffa0232740>] ? ipmi_pci_probe+0x280/0x280 [ipmi_si] [ 1362.568219] [<ffffffff810021a0>] do_one_initcall+0x50/0x180 [ 1362.636109] [<ffffffff812231b2>] ? kmem_cache_alloc_trace+0x142/0x190 [ 1362.714330] [<ffffffff811b2ae1>] do_init_module+0x5f/0x200 [ 1362.781208] [<ffffffff81123ca8>] load_module+0x1898/0x1de0 [ 1362.848069] [<ffffffff811202e0>] ? __symbol_put+0x60/0x60 [ 1362.913886] [<ffffffff8130696b>] ? security_kernel_post_read_file+0x6b/0x80 [ 1362.998514] [<ffffffff81124465>] SYSC_finit_module+0xe5/0x120 [ 1363.068463] [<ffffffff81124465>] ? SYSC_finit_module+0xe5/0x120 [ 1363.140513] [<ffffffff811244be>] SyS_finit_module+0xe/0x10 [ 1363.207364] [<ffffffff81003c04>] do_syscall_64+0x74/0x180
Message-Id: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +2 -2
@@ -3188,8 +3188,8 @@ static void __get_guid(struct ipmi_smi *if (rv)/* Send failed, no GUID available. */ bmc->dyn_guid_set =0 ; - -wait_event (intf->waitq, bmc->dyn_guid_set !=2 ); +else +wait_event (intf->waitq, bmc->dyn_guid_set !=2 );/* dyn_guid_set makes the guid data available. */ smp_rmb ();
Greg Kroah-Hartman
maintainerPATCH 253/254 perf/core: Remove struct sched_in_data
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 2c2366c7548ecee65adfd264517ddf50f9e2d029 ]
We can deduce the ctx and cpuctx from the event, no need to pass them along. Remove the structure and pass in can_add_hw directly.
--- kernel/events/core.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
kernel/events/core.c +11 -25
@@ -3437,17 +3437,11 @@ static int visit_groups_merge(struct perf_event_groups *groups, int cpu,return 0 ; } -struct sched_in_data { -struct perf_event_context *ctx; -struct perf_cpu_context *cpuctx; -int can_add_hw; -}; -static int merge_sched_in (struct perf_event *event,void *data) { -struct sched_in_data *sid = data; - -WARN_ON_ONCE (event->ctx != sid->ctx); +struct perf_event_context *ctx = event->ctx; +struct perf_cpu_context *cpuctx =__get_cpu_context (ctx); +int *can_add_hw = data;if (event->state <=PERF_EVENT_STATE_OFF )return 0 ;
@@ -3455,8 +3449,8 @@ static int merge_sched_in(struct perf_event *event, void *data)if (!event_filter_match (event))return 0 ; -if (group_can_go_on (event, sid->cpuctx, sid->can_add_hw)) { -if (!group_sched_in (event, sid->cpuctx, sid->ctx)) +if (group_can_go_on (event, cpuctx, *can_add_hw)) { +if (!group_sched_in (event, cpuctx, ctx))list_add_tail (&event->active_list,get_event_list (event)); }
@@ -3466,8 +3460,8 @@ static int merge_sched_in(struct perf_event *event, void *data)perf_event_set_state (event,PERF_EVENT_STATE_ERROR ); } - sid->can_add_hw =0 ; - sid->ctx->rotate_necessary =1 ; + *can_add_hw =0 ; + ctx->rotate_necessary =1 ; }return 0 ;
@@ -3477,30 +3471,22 @@ static void ctx_pinned_sched_in(struct perf_event_context *ctx, struct perf_cpu_context *cpuctx) { - struct sched_in_data sid = { - .ctx = ctx, - .cpuctx = cpuctx, - .can_add_hw =1 , - }; + int can_add_hw = 1;visit_groups_merge (&ctx->pinned_groups,smp_processor_id (), - merge_sched_in, &sid); + merge_sched_in, &can_add_hw); }static void ctx_flexible_sched_in (struct perf_event_context *ctx,struct perf_cpu_context *cpuctx) { -struct sched_in_data sid = { - .ctx = ctx, - .cpuctx = cpuctx, - .can_add_hw =1 , - }; +int can_add_hw =1 ;visit_groups_merge (&ctx->flexible_groups,smp_processor_id (), - merge_sched_in, &sid); + merge_sched_in, &can_add_hw); } static void
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 230/254 hfsplus: fix crash and filesystem corruption when deleting files
In reply to Greg Kroah-HartmanFrom: Simon Gander <[email protected]>
commit 25efb2ffdf991177e740b2f63e92b4ec7d310a92 upstream.
When removing files containing extended attributes, the hfsplus driver may remove the wrong entries from the attributes b-tree, causing major filesystem damage and in some cases even kernel crashes.
To remove a file, all its extended attributes have to be removed as well. The driver does this by looking up all keys in the attributes b-tree with the cnid of the file. Each of these entries then gets deleted using the key used for searching, which doesn't contain the attribute's name when it should. Since the key doesn't contain the name, the deletion routine will not find the correct entry and instead remove the one in front of it. If parent nodes have to be modified, these become corrupt as well. This causes invalid links and unsorted entries that not even macOS's fsck_hfs is able to fix.
To fix this, modify the search key before an entry is deleted from the attributes b-tree by copying the found entry's key into the search key, therefore ensuring that the correct entry gets removed from the tree.
--- fs/hfsplus/attributes.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/hfsplus/attributes.c +4 -0
@@ -292,6 +292,10 @@ static int __hfsplus_delete_attr(structreturn -ENOENT ; } +/* Avoid btree corruption */ +hfs_bnode_read (fd->bnode, fd->search_key, + fd->keyoffset, fd->keylength); + err =hfs_brec_remove (fd);if (err)return err;
Greg Kroah-Hartman
maintainerPATCH 247/254 drm/dp_mst: Fix clearing payload state on topology disable
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
[ Upstream commit 8732fe46b20c951493bfc4dba0ad08efdf41de81 ]
The issues caused by:
commit 64e62bdf04ab ("drm/dp_mst: Remove VCPI while disabling topology mgr")
Prompted me to take a closer look at how we clear the payload state in general when disabling the topology, and it turns out there's actually two subtle issues here.
The first is that we're not grabbing &mgr.payload_lock when clearing the payloads in drm_dp_mst_topology_mgr_set_mst(). Seeing as the canonical lock order is &mgr.payload_lock -> &mgr.lock (because we always want &mgr.lock to be the inner-most lock so topology validation always works), this makes perfect sense. It also means that -technically- there could be racing between someone calling drm_dp_mst_topology_mgr_set_mst() to disable the topology, along with a modeset occurring that's modifying the payload state at the same time.
The second is the more obvious issue that Wayne Lin discovered, that we're not clearing proposed_payloads when disabling the topology.
I actually can't see any obvious places where the racing caused by the first issue would break something, and it could be that some of our higher-level locks already prevent this by happenstance, but better safe then sorry. So, let's make it so that drm_dp_mst_topology_mgr_set_mst() first grabs &mgr.payload_lock followed by &mgr.lock so that we never race when modifying the payload state. Then, we also clear proposed_payloads to fix the original issue of enabling a new topology with a dirty payload state. This doesn't clear any of the drm_dp_vcpi structures, but those are getting destroyed along with the ports anyway.
Changes since v1:
* Use sizeof(mgr->payloads[0])/sizeof(mgr->proposed_vcpis[0]) instead - vsyrjala
--- drivers/gpu/drm/drm_dp_mst_topology.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -1
@@ -3506,6 +3506,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool msint ret =0 ;struct drm_dp_mst_branch *mstb =NULL ; +mutex_lock (&mgr->payload_lock);mutex_lock (&mgr->lock);if (mst_state == mgr->mst_state) goto out_unlock;
@@ -3564,7 +3565,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms/* this can fail if the device is gone */ drm_dp_dpcd_writeb (mgr->aux,DP_MSTM_CTRL ,0 ); ret =0 ; -memset (mgr->payloads,0 , mgr->max_payloads *sizeof (struct drm_dp_payload )); +memset (mgr->payloads,0 , + mgr->max_payloads *sizeof (mgr->payloads[0 ])); +memset (mgr->proposed_vcpis,0 , + mgr->max_payloads *sizeof (mgr->proposed_vcpis[0 ])); mgr->payload_mask =0 ;set_bit (0 , &mgr->payload_mask); mgr->vcpi_mask =0 ;
@@ -3573,6 +3577,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms out_unlock:mutex_unlock (&mgr->lock); +mutex_unlock (&mgr->payload_lock);if (mstb)drm_dp_mst_topology_put_mstb (mstb);return ret;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 249/254 drm/i915/ggtt: do not set bits 1-11 in gen12 ptes
In reply to Greg Kroah-HartmanFrom: Daniele Ceraolo Spurio <[email protected]>
[ Upstream commit 69edc390a54268d41e45089cb972bf71510f5f07 ]
On TGL, bits 2-4 in the GGTT PTE are not ignored anymore and are instead used for some extra VT-d capabilities. We don't (yet?) have support for those capabilities, but, given that we shared the pte_encode function betweed GGTT and PPGTT, we still set those bits to the PPGTT PPAT values. The DMA engine gets very confused when those bits are set while the iommu is enabled, leading to errors. E.g. when loading the GuC we get:
[ 9.796218] DMAR: DRHD: handling fault status reg 2 [ 9.796235] DMAR: [DMA Write] Request device [00:02.0] PASID ffffffff fault addr 0 [fault reason 02] Present bit in context entry is clear [ 9.899215] [drm:intel_guc_fw_upload [i915]] *ERROR* GuC firmware signature verification failed
To fix this, just have dedicated gen8_pte_encode function per type of gtt. Also, explicitly set vm->pte_encode for gen8_ppgtt, even if we don't use it, to make sure we don't accidentally assign it to the GGTT one, like we do for gen6_ppgtt, in case we need it in the future.
--- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_ggtt.c | 13 ++++++++++--- drivers/gpu/drm/i915/gt/intel_gtt.c | 24 ------------------------ drivers/gpu/drm/i915/gt/intel_gtt.h | 4 ---- 4 files changed, 36 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +26 -0
@@ -25,6 +25,30 @@ static u64 gen8_pde_encode(const dma_addr_t addr,return pde; } +static u64 gen8_pte_encode (dma_addr_t addr, +enum i915_cache_level level, +u32 flags) +{ +gen8_pte_t pte = addr | _PAGE_PRESENT | _PAGE_RW; + +if (unlikely (flags &PTE_READ_ONLY )) + pte &= ~_PAGE_RW; + +switch (level) { +case I915_CACHE_NONE : + pte |=PPAT_UNCACHED ; +break ; +case I915_CACHE_WT : + pte |=PPAT_DISPLAY_ELLC ; +break ; +default : + pte |=PPAT_CACHED ; +break ; + } + +return pte; +} +static void gen8_ppgtt_notify_vgt (struct i915_ppgtt *ppgtt,bool create) {struct drm_i915_private *i915 = ppgtt->vm.i915;
@@ -706,6 +730,8 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt) ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc; ppgtt->vm.clear_range = gen8_ppgtt_clear; + ppgtt->vm.pte_encode = gen8_pte_encode; +if (intel_vgpu_active (gt->i915))gen8_ppgtt_notify_vgt (ppgtt, true);
drivers/gpu/drm/i915/gt/intel_ggtt.c +10 -3
@@ -167,6 +167,13 @@ static void gmch_ggtt_invalidate(struct i915_ggtt *ggtt)intel_gtt_chipset_flush (); } +static u64 gen8_ggtt_pte_encode (dma_addr_t addr, +enum i915_cache_level level, +u32 flags) +{ +return addr | _PAGE_PRESENT; +} +static void gen8_set_pte (void __iomem *addr,gen8_pte_t pte) {writeq (pte, addr);
@@ -182,7 +189,7 @@ static void gen8_ggtt_insert_page(struct i915_address_space *vm,gen8_pte_t __iomem *pte = (gen8_pte_t __iomem *)ggtt->gsm + offset /I915_GTT_PAGE_SIZE ; -gen8_set_pte (pte,gen8_pte_encode (addr, level,0 )); +gen8_set_pte (pte,gen8_ggtt_pte_encode (addr, level,0 )); ggtt->invalidate (ggtt); }
@@ -195,7 +202,7 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,struct i915_ggtt *ggtt =i915_vm_to_ggtt (vm);struct sgt_iter sgt_iter;gen8_pte_t __iomem *gtt_entries; -const gen8_pte_t pte_encode =gen8_pte_encode (0 , level,0 ); +const gen8_pte_t pte_encode =gen8_ggtt_pte_encode (0 , level,0 );dma_addr_t addr;/*
@@ -890,7 +897,7 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt) ggtt->vm.vma_ops.set_pages = ggtt_set_pages; ggtt->vm.vma_ops.clear_pages = clear_pages; - ggtt->vm.pte_encode = gen8_pte_encode; + ggtt->vm.pte_encode = gen8_ggtt_pte_encode;setup_private_pat (ggtt->vm.gt->uncore);
drivers/gpu/drm/i915/gt/intel_gtt.c +0 -24
@@ -454,30 +454,6 @@ void gtt_write_workarounds(struct intel_gt *gt) } } -u64 gen8_pte_encode (dma_addr_t addr, -enum i915_cache_level level, -u32 flags) -{ -gen8_pte_t pte = addr | _PAGE_PRESENT | _PAGE_RW; - -if (unlikely (flags &PTE_READ_ONLY )) - pte &= ~_PAGE_RW; - -switch (level) { -case I915_CACHE_NONE : - pte |=PPAT_UNCACHED ; -break ; -case I915_CACHE_WT : - pte |=PPAT_DISPLAY_ELLC ; -break ; -default : - pte |=PPAT_CACHED ; -break ; - } - -return pte; -} -static void tgl_setup_private_ppat (struct intel_uncore *uncore) {/* TGL doesn't support LLC or AGE settings */
drivers/gpu/drm/i915/gt/intel_gtt.h +0 -4
@@ -515,10 +515,6 @@ struct i915_ppgtt *i915_ppgtt_create(struct intel_gt *gt);void i915_gem_suspend_gtt_mappings (struct drm_i915_private *i915);void i915_gem_restore_gtt_mappings (struct drm_i915_private *i915); -u64 gen8_pte_encode (dma_addr_t addr, -enum i915_cache_level level, -u32 flags); -int setup_page_dma (struct i915_address_space *vm,struct i915_page_dma *p);void cleanup_page_dma (struct i915_address_space *vm,struct i915_page_dma *p);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 245/254 arm64: Always force a branch protection mode when the compiler has one
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
commit b8fdef311a0bd9223f10754f94fdcf1a594a3457 upstream.
Compilers with branch protection support can be configured to enable it by default, it is likely that distributions will do this as part of deploying branch protection system wide. As well as the slight overhead from having some extra NOPs for unused branch protection features this can cause more serious problems when the kernel is providing pointer authentication to userspace but not built for pointer authentication itself. In that case our switching of keys for userspace can affect the kernel unexpectedly, causing pointer authentication instructions in the kernel to corrupt addresses.
To ensure that we get consistent and reliable behaviour always explicitly initialise the branch protection mode, ensuring that the kernel is built the same way regardless of the compiler defaults.
[This is a reworked version of b8fdef311a0bd9223f1075 ("arm64: Always force a branch protection mode when the compiler has one") for backport. Kernels prior to 74afda4016a7 ("arm64: compile the kernel with ptrauth return address signing") don't have any Makefile machinery for forcing on pointer auth but still have issues if the compiler defaults it on so need this reworked version. -- broonie]
--- arch/arm64/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/Makefile +4 -0
@@ -65,6 +65,10 @@ stack_protector_prepare: prepare0 include/generated/asm-offsets.h)) endif +# Ensure that if the compiler supports branch protection we default it +# off. +KBUILD_CFLAGS += $(call cc-option,-mbranch-protection=none) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__
Greg Kroah-Hartman
maintainerPATCH 244/254 powerpc/64: Prevent stack protection in early boot
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 7053f80d96967d8e72e9f2a724bbfc3906ce2b07 upstream.
The previous commit reduced the amount of code that is run before we setup a paca. However there are still a few remaining functions that run with no paca, or worse, with an arbitrary value in r13 that will be used as a paca pointer.
In particular the stack protector canary is stored in the paca, so if stack protector is activated for any of these functions we will read the stack canary from wherever r13 points. If r13 happens to point outside of memory we will get a machine check / checkstop.
For example if we modify initialise_paca() to trigger stack protection, and then boot in the mambo simulator with r13 poisoned in skiboot before calling the kernel:
DEBUG: 19952232: (19952232): INSTRUCTION: PC=0xC0000000191FC1E8: [0x3C4C006D]: addis r2,r12,0x6D [fetch]
DEBUG: 19952236: (19952236): INSTRUCTION: PC=0xC00000001807EAD8: [0x7D8802A6]: mflr r12 [fetch]
FATAL ERROR: 19952276: (19952276): Check Stop for 0:0: Machine Check with ME bit of MSR off
DEBUG: 19952276: (19952276): INSTRUCTION: PC=0xC0000000191FCA7C: [0xE90D0CF8]: ld r8,0xCF8(r13) [Instruction Failed]
INFO: 19952276: (19952277): ** Execution stopped: Mambo Error, Machine Check Stop, ** systemsim % bt
pc: 0xC0000000191FCA7C initialise_paca+0x54 lr: 0xC0000000191FC22C early_setup+0x44 stack:0x00000000198CBED0 0x0 +0x0 stack:0x00000000198CBF00 0xC0000000191FC22C early_setup+0x44 stack:0x00000000198CBF90 0x1801C968 +0x1801C968
So annotate the relevant functions to ensure stack protection is never enabled for them.
--- arch/powerpc/kernel/paca.c | 4 ++-- arch/powerpc/kernel/setup.h | 6 ++++++ arch/powerpc/kernel/setup_64.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/kernel/paca.c +2 -2
@@ -176,7 +176,7 @@ static struct slb_shadow * __init new_slstruct paca_struct **paca_ptrs__read_mostly ;EXPORT_SYMBOL (paca_ptrs); -void __init initialise_paca (struct paca_struct *new_paca,int cpu) +void __init __nostackprotector initialise_paca(struct paca_struct *new_paca, int cpu) {#ifdef CONFIG_PPC_PSERIES new_paca->lppaca_ptr =NULL ;
@@ -205,7 +205,7 @@ void __init initialise_paca(struct paca_ }/* Put the paca pointer into r13 and SPRG_PACA */ -void setup_paca (struct paca_struct *new_paca) +void __nostackprotector setup_paca(struct paca_struct *new_paca) {/* Setup r13 */ local_paca = new_paca;
arch/powerpc/kernel/setup.h +6 -0
@@ -8,6 +8,12 @@#ifndef __ARCH_POWERPC_KERNEL_SETUP_H#define __ARCH_POWERPC_KERNEL_SETUP_H +#ifdef CONFIG_CC_IS_CLANG +#define __nostackprotector +#else +#define __nostackprotector __attribute__((__optimize__("no-stack-protector"))) +#endif +void initialize_cache_info (void );void irqstack_early_init (void );
arch/powerpc/kernel/setup_64.c +1 -1
@@ -279,7 +279,7 @@ void __init record_spr_defaults(void)* device-tree is not accessible via normal means at this point. */ -void __init early_setup (unsigned long dt_ptr) +void __init __nostackprotector early_setup(unsigned long dt_ptr) {static __initdata struct paca_struct boot_paca;
Greg Kroah-Hartman
maintainerPATCH 240/254 powerpc/xive: Use XIVE_BAD_IRQ instead of zero to catch non configured IPIs
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
commit b1a504a6500df50e83b701b7946b34fce27ad8a3 upstream.
When a CPU is brought up, an IPI number is allocated and recorded under the XIVE CPU structure. Invalid IPI numbers are tracked with interrupt number 0x0.
On the PowerNV platform, the interrupt number space starts at 0x10 and this works fine. However, on the sPAPR platform, it is possible to allocate the interrupt number 0x0 and this raises an issue when CPU 0 is unplugged. The XIVE spapr driver tracks allocated interrupt numbers in a bitmask and it is not correctly updated when interrupt number 0x0 is freed. It stays allocated and it is then impossible to reallocate.
Fix by using the XIVE_BAD_IRQ value instead of zero on both platforms.
--- arch/powerpc/sysdev/xive/common.c | 12 +++--------- arch/powerpc/sysdev/xive/native.c | 4 ++-- arch/powerpc/sysdev/xive/spapr.c | 4 ++-- arch/powerpc/sysdev/xive/xive-internal.h | 7 +++++++ 4 files changed, 14 insertions(+), 13 deletions(-)
arch/powerpc/sysdev/xive/common.c +3 -9
@@ -68,13 +68,6 @@ static u32 xive_ipi_irq;/* Xive state for each CPU */ static DEFINE_PER_CPU(struct xive_cpu *, xive_cpu); -/* -* A "disabled" interrupt should never fire, to catch problems -* we set its logical number to this -*/ -#define XIVE_BAD_IRQ 0x7fffffff -#define XIVE_MAX_IRQ (XIVE_BAD_IRQ - 1) -/* An invalid CPU target */ #define XIVE_INVALID_TARGET (-1)
@@ -1150,7 +1143,7 @@ static int xive_setup_cpu_ipi(unsigned i xc =per_cpu (xive_cpu, cpu);/* Check if we are already setup */ -if (xc->hw_ipi !=0 ) +if (xc->hw_ipi !=XIVE_BAD_IRQ )return 0 ;/* Grab an IPI from the backend, this will populate xc->hw_ipi */
@@ -1187,7 +1180,7 @@ static void xive_cleanup_cpu_ipi(unsigne/* Disable the IPI and free the IRQ data */ /* Already cleaned up ? */ -if (xc->hw_ipi ==0 ) +if (xc->hw_ipi ==XIVE_BAD_IRQ )return ;/* Mask the IPI */
@@ -1343,6 +1336,7 @@ static int xive_prepare_cpu(unsigned intif (np) xc->chip_id =of_get_ibm_chip_id (np);of_node_put (np); + xc->hw_ipi =XIVE_BAD_IRQ ;per_cpu (xive_cpu, cpu) = xc; }
arch/powerpc/sysdev/xive/native.c +2 -2
@@ -312,7 +312,7 @@ static void xive_native_put_ipi(unsigneds64 rc;/* Free the IPI */ -if (!xc->hw_ipi) +if (xc->hw_ipi ==XIVE_BAD_IRQ )return ;for (;;) { rc =opal_xive_free_irq (xc->hw_ipi);
@@ -320,7 +320,7 @@ static void xive_native_put_ipi(unsignedmsleep (OPAL_BUSY_DELAY_MS );continue ; } - xc->hw_ipi =0 ; + xc->hw_ipi =XIVE_BAD_IRQ ;break ; } }
arch/powerpc/sysdev/xive/spapr.c +2 -2
@@ -560,11 +560,11 @@ static int xive_spapr_get_ipi(unsigned istatic void xive_spapr_put_ipi (unsigned int cpu,struct xive_cpu *xc) { -if (!xc->hw_ipi) +if (xc->hw_ipi ==XIVE_BAD_IRQ )return ;xive_irq_bitmap_free (xc->hw_ipi); - xc->hw_ipi =0 ; + xc->hw_ipi =XIVE_BAD_IRQ ; }#endif /* CONFIG_SMP */
arch/powerpc/sysdev/xive/xive-internal.h +7 -0
@@ -5,6 +5,13 @@ #ifndef __XIVE_INTERNAL_H #define __XIVE_INTERNAL_H +/* + * A "disabled" interrupt should never fire, to catch problems + * we set its logical number to this + */ +#define XIVE_BAD_IRQ 0x7fffffff +#define XIVE_MAX_IRQ (XIVE_BAD_IRQ - 1) + /* Each CPU carry one of these with various per-CPU state */ struct xive_cpu { #ifdef CONFIG_SMP
Greg Kroah-Hartman
maintainerPATCH 239/254 powerpc/hash64/devmap: Use H_PAGE_THP_HUGE when setting up huge devmap PTE entries
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
commit 36b78402d97a3b9aeab136feb9b00d8647ec2c20 upstream.
H_PAGE_THP_HUGE is used to differentiate between a THP hugepage and hugetlb hugepage entries. The difference is WRT how we handle hash fault on these address. THP address enables MPSS in segments. We want to manage devmap hugepage entries similar to THP pt entries. Hence use H_PAGE_THP_HUGE for devmap huge PTE entries.
With current code while handling hash PTE fault, we do set is_thp = true when finding devmap PTE huge PTE entries.
Current code also does the below sequence we setting up huge devmap entries.
entry = pmd_mkhuge(pfn_t_pmd(pfn, prot)); if (pfn_t_devmap(pfn)) entry = pmd_mkdevmap(entry);
In that case we would find both H_PAGE_THP_HUGE and PAGE_DEVMAP set for huge devmap PTE entries. This results in false positive error like below.
kernel BUG at /home/kvaneesh/src/linux/mm/memory.c:4321!
Oops: Exception in kernel mode, sig: 5 [#1]
LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
Modules linked in:
CPU: 56 PID: 67996 Comm: t_mmap_dio Not tainted 5.6.0-rc4-59640-g371c804dedbc #128
....
NIP [c00000000044c9e4] __follow_pte_pmd+0x264/0x900
LR [c0000000005d45f8] dax_writeback_one+0x1a8/0x740
Call Trace:
str_spec.74809+0x22ffb4/0x2d116c (unreliable)
dax_writeback_one+0x1a8/0x740
dax_writeback_mapping_range+0x26c/0x700
ext4_dax_writepages+0x150/0x5a0
do_writepages+0x68/0x180
__filemap_fdatawrite_range+0x138/0x180
file_write_and_wait_range+0xa4/0x110
ext4_sync_file+0x370/0x6e0
vfs_fsync_range+0x70/0xf0
sys_msync+0x220/0x2e0
system_call+0x5c/0x68This is because our pmd_trans_huge check doesn't exclude _PAGE_DEVMAP.
To make this all consistent, update pmd_mkdevmap to set H_PAGE_THP_HUGE and pmd_trans_huge check now excludes _PAGE_DEVMAP correctly.
--- arch/powerpc/include/asm/book3s/64/hash-4k.h | 6 ++++++ arch/powerpc/include/asm/book3s/64/hash-64k.h | 8 +++++++- arch/powerpc/include/asm/book3s/64/pgtable.h | 4 +++- arch/powerpc/include/asm/book3s/64/radix.h | 5 +++++ 4 files changed, 21 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +6 -0
@@ -156,6 +156,12 @@ extern pmd_t hash__pmdp_huge_get_and_cleextern int hash__has_transparent_hugepage (void );#endif +static inline pmd_t hash__pmd_mkdevmap (pmd_t pmd) +{ +BUG (); +return pmd; +} +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
arch/powerpc/include/asm/book3s/64/hash-64k.h +7 -1
@@ -246,7 +246,7 @@ static inline void mark_hpte_slot_valid(*/ static inline int hash__pmd_trans_huge (pmd_t pmd) { -return !!((pmd_val (pmd) & (_PAGE_PTE |H_PAGE_THP_HUGE )) == +return !!((pmd_val (pmd) & (_PAGE_PTE |H_PAGE_THP_HUGE | _PAGE_DEVMAP)) == (_PAGE_PTE |H_PAGE_THP_HUGE )); }
@@ -272,6 +272,12 @@ extern pmd_t hash__pmdp_huge_get_and_cle unsigned long addr, pmd_t *pmdp);extern int hash__has_transparent_hugepage (void );#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + +static inline pmd_t hash__pmd_mkdevmap (pmd_t pmd) +{ +return __pmd (pmd_val (pmd) | (_PAGE_PTE |H_PAGE_THP_HUGE | _PAGE_DEVMAP)); +} +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_64K_H */
arch/powerpc/include/asm/book3s/64/pgtable.h +3 -1
@@ -1303,7 +1303,9 @@ extern void serialize_against_pte_lookupstatic inline pmd_t pmd_mkdevmap (pmd_t pmd) { -return __pmd (pmd_val (pmd) | (_PAGE_PTE | _PAGE_DEVMAP)); +if (radix_enabled ()) +return radix__pmd_mkdevmap (pmd); +return hash__pmd_mkdevmap (pmd); }static inline int pmd_devmap (pmd_t pmd)
arch/powerpc/include/asm/book3s/64/radix.h +5 -0
@@ -263,6 +263,11 @@ static inline int radix__has_transparent }#endif +static inline pmd_t radix__pmd_mkdevmap (pmd_t pmd) +{ +return __pmd (pmd_val (pmd) | (_PAGE_PTE | _PAGE_DEVMAP)); +} +extern int __meminit radix__vmemmap_create_mapping (unsigned long start,unsigned long page_size,unsigned long phys);
Greg Kroah-Hartman
maintainerPATCH 241/254 powerpc/64: Setup a paca before parsing device tree etc.
In reply to Greg Kroah-HartmanFrom: Daniel Axtens <[email protected]>
commit d4a8e98621543d5798421eed177978bf2b3cdd11 upstream.
Currently we set up the paca after parsing the device tree for CPU features. Prior to that, r13 contains random data, which means there is random data in r13 while we're running the generic dt parsing code.
This random data varies depending on whether we boot through a vmlinux or a zImage: for the vmlinux case it's usually around zero, but for zImages we see random values like 912a72603d420015.
This is poor practice, and can also lead to difficult-to-debug crashes. For example, when kcov is enabled, the kcov instrumentation attempts to read preempt_count out of the current task, which goes via the paca. This then crashes in the zImage case.
Similarly stack protector can cause crashes if r13 is bogus, by reading from the stack canary in the paca.
To resolve this:
- move the paca setup to before the CPU feature parsing.
- because we no longer have access to CPU feature flags in paca setup, change the HV feature test in the paca setup path to consider the actual value of the MSR rather than the CPU feature.
Translations get switched on once we leave early_setup, so I think we'd already catch any other cases where the paca or task aren't set up.
Boot tested on a P9 guest and host.
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 1 - arch/powerpc/kernel/paca.c | 10 +++++++--- arch/powerpc/kernel/setup_64.c | 30 ++++++++++++++++++++++++------ 3 files changed, 31 insertions(+), 10 deletions(-)
arch/powerpc/kernel/dt_cpu_ftrs.c +0 -1
@@ -139,7 +139,6 @@ static void __init cpufeatures_setup_cpu/* Initialize the base environment -- clear FSCR/HFSCR. */ hv_mode = !!(mfmsr () &MSR_HV );if (hv_mode) { -/* CPU_FTR_HVMODE is used early in PACA setup */ cur_cpu_spec->cpu_features |=CPU_FTR_HVMODE ;mtspr (SPRN_HFSCR ,0 ); }
arch/powerpc/kernel/paca.c +7 -3
@@ -214,11 +214,15 @@ void setup_paca(struct paca_struct *new_/* On Book3E, initialize the TLB miss exception frames */ mtspr (SPRN_SPRG_TLB_EXFRAME , local_paca->extlb);#else -/* In HV mode, we setup both HPACA and PACA to avoid problems +/* +* In HV mode, we setup both HPACA and PACA to avoid problems * if we do a GET_PACA() before the feature fixups have been -* applied +* applied. +* +* Normally you should test against CPU_FTR_HVMODE, but CPU features +* are not yet set up when we first reach here. */ -if (early_cpu_has_feature (CPU_FTR_HVMODE )) +if (mfmsr () &MSR_HV )mtspr (SPRN_SPRG_HPACA , local_paca);#endif mtspr (SPRN_SPRG_PACA , local_paca);
arch/powerpc/kernel/setup_64.c +24 -6
@@ -285,18 +285,36 @@ void __init early_setup(unsigned long dt/* -------- printk is _NOT_ safe to use here ! ------- */ -/* Try new device tree based feature discovery ... */ -if (!dt_cpu_ftrs_init (__va (dt_ptr))) -/* Otherwise use the old style CPU table */ -identify_cpu (0 ,mfspr (SPRN_PVR )); - -/* Assume we're on cpu 0 for now. Don't write to the paca yet! */ +/* +* Assume we're on cpu 0 for now. +* +* We need to load a PACA very early for a few reasons. +* +* The stack protector canary is stored in the paca, so as soon as we +* call any stack protected code we need r13 pointing somewhere valid. +* +* If we are using kcov it will call in_task() in its instrumentation, +* which relies on the current task from the PACA. +* +* dt_cpu_ftrs_init() calls into generic OF/fdt code, as well as +* printk(), which can trigger both stack protector and kcov. +* +* percpu variables and spin locks also use the paca. +* +* So set up a temporary paca. It will be replaced below once we know +* what CPU we are on. +*/ initialise_paca (&boot_paca,0 );setup_paca (&boot_paca);fixup_boot_paca ();/* -------- printk is now safe to use ------- */ +/* Try new device tree based feature discovery ... */ +if (!dt_cpu_ftrs_init (__va (dt_ptr))) +/* Otherwise use the old style CPU table */ +identify_cpu (0 ,mfspr (SPRN_PVR )); +/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();
Greg Kroah-Hartman
maintainerPATCH 238/254 powerpc/fsl_booke: Avoid creating duplicate tlb1 entry
In reply to Greg Kroah-HartmanFrom: Laurentiu Tudor <[email protected]>
commit aa4113340ae6c2811e046f08c2bc21011d20a072 upstream.
In the current implementation, the call to loadcam_multi() is wrapped between switch_to_as1() and restore_to_as0() calls so, when it tries to create its own temporary AS=1 TLB1 entry, it ends up duplicating the existing one created by switch_to_as1(). Add a check to skip creating the temporary entry if already running in AS=1.
--- arch/powerpc/mm/nohash/tlb_low.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/mm/nohash/tlb_low.S +11 -1
@@ -397,7 +397,7 @@ _GLOBAL(set_context) * extern void loadcam_entry(unsigned int index) * * Load TLBCAM[index] entry in to the L2 CAM MMU - * Must preserve r7, r8, r9, and r10 + * Must preserve r7, r8, r9, r10 and r11 */ _GLOBAL(loadcam_entry) mflr r5
@@ -433,6 +433,10 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PH */ _GLOBAL(loadcam_multi) mflr r8 + /* Don't switch to AS=1 if already there */ + mfmsr r11 + andi. r11,r11,MSR_IS + bne 10f /* * Set up temporary TLB entry that is the same as what we're
@@ -458,6 +462,7 @@ _GLOBAL(loadcam_multi) mtmsr r6 isync +10: mr r9,r3 add r10,r3,r4 2: bl loadcam_entry
@@ -466,6 +471,10 @@ _GLOBAL(loadcam_multi) mr r3,r9 blt 2b + /* Don't return to AS=0 if we were in AS=1 at function start */ + andi. r11,r11,MSR_IS + bne 3f + /* Return to AS=0 and clear the temporary entry */ mfmsr r6 rlwinm. r6,r6,0,~(MSR_IS|MSR_DS)
@@ -481,6 +490,7 @@ _GLOBAL(loadcam_multi) tlbwe isync +3: mtlr r8 blr #endif
Greg Kroah-Hartman
maintainerPATCH 237/254 powerpc/64/tm: Dont let userspace set regs->trap via sigreturn
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit c7def7fbdeaa25feaa19caf4a27c5d10bd8789e4 upstream.
In restore_tm_sigcontexts() we take the trap value directly from the user sigcontext with no checking:
err |= __get_user(regs->trap, &sc->gp_regs[PT_TRAP]);
This means we can be in the kernel with an arbitrary regs->trap value.
Although that's not immediately problematic, there is a risk we could trigger one of the uses of CHECK_FULL_REGS():
#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
It can also cause us to unnecessarily save non-volatile GPRs again in save_nvgprs(), which shouldn't be problematic but is still wrong.
It's also possible it could trick the syscall restart machinery, which relies on regs->trap not being == 0xc00 (see 9a81c16b5275 ("powerpc:
fix double syscall restarts")), though I haven't been able to make that happen.
Finally it doesn't match the behaviour of the non-TM case, in restore_sigcontext() which zeroes regs->trap.
So change restore_tm_sigcontexts() to zero regs->trap.
This was discovered while testing Nick's upcoming rewrite of the syscall entry path. In that series the call to save_nvgprs() prior to signal handling (do_notify_resume()) is removed, which leaves the low-bit of regs->trap uncleared which can then trigger the FULL_REGS() WARNs in setup_tm_sigcontexts().
--- arch/powerpc/kernel/signal_64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/signal_64.c +3 -1
@@ -473,8 +473,10 @@ static long restore_tm_sigcontexts(struc err |=__get_user (tsk->thread.ckpt_regs.ccr, &sc->gp_regs[PT_CCR ]); +/* Don't allow userspace to set the trap value */ + regs->trap =0 ; +/* These regs are not checkpointed; they can go in 'regs'. */ - err |=__get_user (regs->trap, &sc->gp_regs[PT_TRAP ]); err |=__get_user (regs->dar, &sc->gp_regs[PT_DAR ]); err |=__get_user (regs->dsisr, &sc->gp_regs[PT_DSISR ]); err |=__get_user (regs->result, &sc->gp_regs[PT_RESULT ]);
Greg Kroah-Hartman
maintainerPATCH 182/254 xarray: Fix early termination of xas_for_each_marked
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 7e934cf5ace1dceeb804f7493fa28bb697ed3c52 upstream.
xas_for_each_marked() is using entry == NULL as a termination condition of the iteration. When xas_for_each_marked() is used protected only by RCU, this can however race with xas_store(xas, NULL) in the following way:
TASK1 TASK2page_cache_delete() find_get_pages_range_tag()
xas_for_each_marked()
xas_find_marked()
off = xas_find_chunk()
xas_store(&xas, NULL)
xas_init_marks(&xas);
...
rcu_assign_pointer(*slot, NULL);
entry = xa_entry(off);And thus xas_for_each_marked() terminates prematurely possibly leading to missed entries in the iteration (translating to missing writeback of some pages or a similar problem).
If we find a NULL entry that has been marked, skip it (unless we're trying to allocate an entry).
--- include/linux/xarray.h | 6 + lib/xarray.c | 2 tools/testing/radix-tree/Makefile | 4 - tools/testing/radix-tree/iteration_check_2.c | 87 +++++++++++++++++++++++++++ tools/testing/radix-tree/main.c | 1 tools/testing/radix-tree/test.h | 1 6 files changed, 98 insertions(+), 3 deletions(-)
include/linux/xarray.h +5 -1
@@ -1648,6 +1648,7 @@ static inline void *xas_next_marked(stru xa_mark_t mark) {struct xa_node *node = xas->xa_node; +void *entry;unsigned int offset;if (unlikely (xas_not_node (node) || node->shift))
@@ -1659,7 +1660,10 @@ static inline void *xas_next_marked(strureturn NULL ;if (offset ==XA_CHUNK_SIZE )return xas_find_marked (xas, max, mark); -return xa_entry (xas->xa, node, offset); + entry =xa_entry (xas->xa, node, offset); +if (!entry) +return xas_find_marked (xas, max, mark); +return entry; }/*
lib/xarray.c +2 -0
@@ -1208,6 +1208,8 @@ void *xas_find_marked(struct xa_state *x } entry =xa_entry (xas->xa, xas->xa_node, xas->xa_offset); +if (!entry && !(xa_track_free (xas->xa) && mark ==XA_FREE_MARK )) +continue ;if (!xa_is_node (entry))return entry; xas->xa_node =xa_to_node (entry);
tools/testing/radix-tree/Makefile +2 -2
@@ -7,8 +7,8 @@ LDLIBS+= -lpthread -lurcu TARGETS = main idr-test multiorder xarray CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o bitmap.o OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \ - regression4.o \ - tag_check.o multiorder.o idr-test.o iteration_check.o benchmark.o + regression4.o tag_check.o multiorder.o idr-test.o iteration_check.o \ + iteration_check_2.o benchmark.o ifndef SHIFT SHIFT=3
tools/testing/radix-tree/iteration_check_2.c new file +87 -0
87 lines not on this page · raw message
tools/testing/radix-tree/main.c +1 -0
@@ -311,6 +311,7 @@ int main(int argc, char **argv)regression4_test ();iteration_test (0 ,10 +90 * long_run);iteration_test (7 ,10 +90 * long_run); +iteration_test2 (10 +90 * long_run);single_thread_tests (long_run);/* Free any remaining preallocated nodes */
tools/testing/radix-tree/test.h +1 -0
@@ -34,6 +34,7 @@ void xarray_tests(void);void tag_check (void );void multiorder_checks (void );void iteration_test (unsigned order,unsigned duration); +void iteration_test2 (unsigned duration);void benchmark (void );void idr_checks (void );void ida_tests (void );
Greg Kroah-Hartman
maintainerPATCH 189/254 scsi: ufs: fix Auto-Hibern8 error detection
In reply to Greg Kroah-HartmanFrom: Stanley Chu <[email protected]>
commit 5a244e0ea67b293abb1d26c825db2ddde5f2862f upstream.
Auto-Hibern8 may be disabled by some vendors or sysfs in runtime even if Auto-Hibern8 capability is supported by host. If Auto-Hibern8 capability is supported by host but not actually enabled, Auto-Hibern8 error shall not happen.
To fix this, provide a way to detect if Auto-Hibern8 is actually enabled first, and bypass Auto-Hibern8 disabling case in ufshcd_is_auto_hibern8_error().
--- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshcd.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +2 -1
@@ -5486,7 +5486,8 @@ static irqreturn_t ufshcd_update_uic_errstatic bool ufshcd_is_auto_hibern8_error (struct ufs_hba *hba,u32 intr_mask) { -if (!ufshcd_is_auto_hibern8_supported (hba)) +if (!ufshcd_is_auto_hibern8_supported (hba) || + !ufshcd_is_auto_hibern8_enabled (hba))return false;if (!(intr_mask &UFSHCD_UIC_HIBERN8_MASK ))
drivers/scsi/ufs/ufshcd.h +6 -0
@@ -55,6 +55,7 @@#include <linux/clk.h> #include <linux/completion.h> #include <linux/regulator/consumer.h> +#include <linux/bitfield.h> #include "unipro.h" #include <asm/irq.h>
@@ -773,6 +774,11 @@ static inline bool ufshcd_is_auto_hibernreturn (hba->capabilities &MASK_AUTO_HIBERN8_SUPPORT ); } +static inline bool ufshcd_is_auto_hibern8_enabled (struct ufs_hba *hba) +{ +return FIELD_GET (UFSHCI_AHIBERN8_TIMER_MASK , hba->ahit) ? true : false; +} +#define ufshcd_writel (hba, val, reg) \ writel((val), (hba)->mmio_base + (reg))#define ufshcd_readl (hba, reg) \
Greg Kroah-Hartman
maintainerPATCH 187/254 crypto: ccree - dec auth tag size from cryptlen map
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit 8962c6d2c2b8ca51b0f188109015b15fc5f4da44 upstream.
Remove the auth tag size from cryptlen before mapping the destination in out-of-place AEAD decryption thus resolving a crash with extended testmgr tests.
--- drivers/crypto/ccree/cc_buffer_mgr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/crypto/ccree/cc_buffer_mgr.c +6 -2
@@ -894,8 +894,12 @@ static int cc_aead_chain_data(struct cc_if (req->src != req->dst) { size_for_map = areq_ctx->assoclen + req->cryptlen; - size_for_map += (direct ==DRV_CRYPTO_DIRECTION_ENCRYPT ) ? - authsize :0 ; + +if (direct ==DRV_CRYPTO_DIRECTION_ENCRYPT ) + size_for_map += authsize; +else + size_for_map -= authsize; +if (is_gcm4543) size_for_map +=crypto_aead_ivsize (tfm);
Greg Kroah-Hartman
maintainerPATCH 220/254 fs/filesystems.c: downgrade user-reachable WARN_ONCE() to pr_warn_once()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 26c5d78c976ca298e59a56f6101a97b618ba3539 upstream.
After request_module(), nothing is stopping the module from being unloaded until someone takes a reference to it via try_get_module().
The WARN_ONCE() in get_fs_type() is thus user-reachable, via userspace running 'rmmod' concurrently.
Since WARN_ONCE() is for kernel bugs only, not for user-reachable situations, downgrade this warning to pr_warn_once().
Keep it printed once only, since the intent of this warning is to detect a bug in modprobe at boot time. Printing the warning more than once wouldn't really provide any useful extra information.
--- fs/filesystems.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/filesystems.c +3 -1
@@ -272,7 +272,9 @@ struct file_system_type *get_fs_type(con fs =__get_fs_type (name, len);if (!fs && (request_module ("fs-%.*s" , len, name) ==0 )) { fs =__get_fs_type (name, len); -WARN_ONCE (!fs,"request_module fs-%.*s succeeded, but still no fs?\n" , len, name); +if (!fs) +pr_warn_once ("request_module fs-%.*s succeeded, but still no fs?\n" , + len, name); }if (dot && fs && !(fs->fs_flags &FS_HAS_SUBTYPE )) {
Greg Kroah-Hartman
maintainerPATCH 222/254 perf tools: Support Python 3.8+ in Makefile
In reply to Greg Kroah-HartmanFrom: Sam Lunt <[email protected]>
commit b9c9ce4e598e012ca7c1813fae2f4d02395807de upstream.
Python 3.8 changed the output of 'python-config --ldflags' to no longer include the '-lpythonX.Y' flag (this apparently fixed an issue loading modules with a statically linked Python executable). The libpython feature check in linux/build/feature fails if the Python library is not included in FEATURE_CHECK_LDFLAGS-libpython variable.
This adds a check in the Makefile to determine if PYTHON_CONFIG accepts the '--embed' flag and passes that flag alongside '--ldflags' if so.
tools/perf is the only place the libpython feature check is used.
--- tools/perf/Makefile.config | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tools/perf/Makefile.config +10 -1
@@ -228,8 +228,17 @@ strip-libs = $(filter-out -l%,$(1)) PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) +# Python 3.8 changed the output of `python-config --ldflags` to not include the +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for +# libpython fails if that flag is not included in LDFLAGS +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0) + PYTHON_CONFIG_LDFLAGS := --ldflags --embed +else + PYTHON_CONFIG_LDFLAGS := --ldflags +endif + ifdef PYTHON_CONFIG - PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) + PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
Greg Kroah-Hartman
maintainerPATCH 219/254 ASoC: cs4270: pull reset GPIO low then high
In reply to Greg Kroah-HartmanFrom: Mike Willard <[email protected]>
commit ccfc531695f3a4aada042f6bdb33ac6be24e1aec upstream.
Pull the RST line low then high when initializing the driver, in order to force a reset of the chip.
Previously, the line was not pulled low, which could result in the chip registers not resetting to their default values on boot.
--- sound/soc/codecs/cs4270.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-)
sound/soc/codecs/cs4270.c +35 -5
@@ -137,6 +137,9 @@ struct cs4270_private {/* power domain regulators */ struct regulator_bulk_data supplies[ARRAY_SIZE (supply_names)]; + +/* reset gpio */ +struct gpio_desc *reset_gpio; };static const struct snd_soc_dapm_widget cs4270_dapm_widgets[] = {
@@ -649,6 +652,22 @@ static const struct regmap_config cs4270 };/** +* cs4270_i2c_remove - deinitialize the I2C interface of the CS4270 +* @i2c_client: the I2C client object +* +* This function puts the chip into low power mode when the i2c device +* is removed. +*/ +static int cs4270_i2c_remove (struct i2c_client *i2c_client) +{ +struct cs4270_private *cs4270 =i2c_get_clientdata (i2c_client); + +gpiod_set_value_cansleep (cs4270->reset_gpio,0 ); + +return 0 ; +} + +/** * cs4270_i2c_probe - initialize the I2C interface of the CS4270 * @i2c_client: the I2C client object * @id: the I2C device ID (ignored)
@@ -660,7 +679,6 @@ static int cs4270_i2c_probe(struct i2c_c const struct i2c_device_id *id) {struct cs4270_private *cs4270; -struct gpio_desc *reset_gpiod;unsigned int val;int ret, i;
@@ -679,10 +697,21 @@ static int cs4270_i2c_probe(struct i2c_cif (ret <0 )return ret; - reset_gpiod =devm_gpiod_get_optional (&i2c_client->dev,"reset" , -GPIOD_OUT_HIGH ); -if (PTR_ERR (reset_gpiod) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +/* reset the device */ + cs4270->reset_gpio =devm_gpiod_get_optional (&i2c_client->dev,"reset" , +GPIOD_OUT_LOW ); +if (IS_ERR (cs4270->reset_gpio)) { +dev_dbg (&i2c_client->dev,"Error getting CS4270 reset GPIO\n" ); +return PTR_ERR (cs4270->reset_gpio); + } + +if (cs4270->reset_gpio) { +dev_dbg (&i2c_client->dev,"Found reset GPIO\n" ); +gpiod_set_value_cansleep (cs4270->reset_gpio,1 ); + } + +/* Sleep 500ns before i2c communications */ +ndelay (500 ); cs4270->regmap =devm_regmap_init_i2c (i2c_client, &cs4270_regmap);if (IS_ERR (cs4270->regmap))
@@ -735,6 +764,7 @@ static struct i2c_driver cs4270_i2c_driv }, .id_table = cs4270_id, .probe = cs4270_i2c_probe, + .remove = cs4270_i2c_remove, };module_i2c_driver (cs4270_i2c_driver);
Greg Kroah-Hartman
maintainerPATCH 218/254 drm/i915/gt: Treat idling as a RPS downclock event
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit 98479ada421a8fd2123b98efd398a6f1379307ab upstream.
If we park/unpark faster than we can respond to RPS events, we never will process a downclock event after expiring a waitboost, and thus we will forever restart the GPU at max clocks even if the workload switches and doesn't justify full power.
--- drivers/gpu/drm/i915/gt/intel_rps.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/gt/intel_rps.c +13 -0
@@ -763,6 +763,19 @@ void intel_rps_park(struct intel_rps *rpintel_uncore_forcewake_get (rps_to_uncore (rps),FORCEWAKE_MEDIA );rps_set (rps, rps->idle_freq, false);intel_uncore_forcewake_put (rps_to_uncore (rps),FORCEWAKE_MEDIA ); + +/* +* Since we will try and restart from the previously requested +* frequency on unparking, treat this idle point as a downclock +* interrupt and reduce the frequency for resume. If we park/unpark +* more frequently than the rps worker can run, we will not respond +* to any EI and never see a change in frequency. +* +* (Note we accommodate Cherryview's limitation of only using an +* even bin by applying it to all.) +*/ + rps->cur_freq = +max_t (int,round_down (rps->cur_freq -1 ,2 ), rps->min_freq); }void intel_rps_boost (struct i915_request *rq)
Greg Kroah-Hartman
maintainerPATCH 215/254 NFS: finish_automount() requires us to hold 2 refs to the mount record
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 75da98586af75eb80664714a67a9895bf0a5517e upstream.
We must not return from nfs_d_automount() without holding 2 references to the mount record. Doing so, will trigger the BUG() in finish_automount(). Also ensure that we don't try to reschedule the automount timer with a negative or zero timeout value.
--- fs/nfs/namespace.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/nfs/namespace.c +7 -5
@@ -145,6 +145,7 @@ struct vfsmount *nfs_d_automount(structstruct vfsmount *mnt =ERR_PTR (-ENOMEM );struct nfs_server *server =NFS_SERVER (d_inode (path->dentry));struct nfs_client *client = server->nfs_client; +int timeout =READ_ONCE (nfs_mountpoint_expiry_timeout);int ret;if (IS_ROOT (path->dentry))
@@ -190,12 +191,12 @@ struct vfsmount *nfs_d_automount(structif (IS_ERR (mnt)) goto out_fc; -if (nfs_mountpoint_expiry_timeout <0 ) +mntget (mnt);/* prevent immediate expiration */ +if (timeout <=0 ) goto out_fc; -mntget (mnt);/* prevent immediate expiration */ mnt_set_expiry (mnt, &nfs_automount_list); -schedule_delayed_work (&nfs_automount_task, nfs_mountpoint_expiry_timeout); +schedule_delayed_work (&nfs_automount_task, timeout); out_fc:put_fs_context (fc);
@@ -233,10 +234,11 @@ const struct inode_operations nfs_referrstatic void nfs_expire_automounts (struct work_struct *work) {struct list_head *list = &nfs_automount_list; +int timeout =READ_ONCE (nfs_mountpoint_expiry_timeout);mark_mounts_for_expiry (list); -if (!list_empty (list)) -schedule_delayed_work (&nfs_automount_task, nfs_mountpoint_expiry_timeout); +if (!list_empty (list) && timeout >0 ) +schedule_delayed_work (&nfs_automount_task, timeout); }void nfs_release_automount_timer (void )
Greg Kroah-Hartman
maintainerPATCH 217/254 ext4: fix a data race at inode->i_blocks
In reply to Greg Kroah-HartmanFrom: Qian Cai <[email protected]>
commit 28936b62e71e41600bab319f262ea9f9b1027629 upstream.
inode->i_blocks could be accessed concurrently as noticed by KCSAN,
BUG: KCSAN: data-race in ext4_do_update_inode [ext4] / inode_add_bytes
write to 0xffff9a00d4b982d0 of 8 bytes by task 22100 on cpu 118:
inode_add_bytes+0x65/0xf0 __inode_add_bytes at fs/stat.c:689 (inlined by) inode_add_bytes at fs/stat.c:702 ext4_mb_new_blocks+0x418/0xca0 [ext4] ext4_ext_map_blocks+0x1a6b/0x27b0 [ext4] ext4_map_blocks+0x1a9/0x950 [ext4] _ext4_get_block+0xfc/0x270 [ext4] ext4_get_block_unwritten+0x33/0x50 [ext4] __block_write_begin_int+0x22e/0xae0 __block_write_begin+0x39/0x50 ext4_write_begin+0x388/0xb50 [ext4] ext4_da_write_begin+0x35f/0x8f0 [ext4] generic_perform_write+0x15d/0x290 ext4_buffered_write_iter+0x11f/0x210 [ext4] ext4_file_write_iter+0xce/0x9e0 [ext4] new_sync_write+0x29c/0x3b0 __vfs_write+0x92/0xa0 vfs_write+0x103/0x260 ksys_write+0x9d/0x130 __x64_sys_write+0x4c/0x60 do_syscall_64+0x91/0xb05 entry_SYSCALL_64_after_hwframe+0x49/0xbe
read to 0xffff9a00d4b982d0 of 8 bytes by task 8 on cpu 65:
ext4_do_update_inode+0x4a0/0xf60 [ext4] ext4_inode_blocks_set at fs/ext4/inode.c:4815 ext4_mark_iloc_dirty+0xaf/0x160 [ext4] ext4_mark_inode_dirty+0x129/0x3e0 [ext4] ext4_convert_unwritten_extents+0x253/0x2d0 [ext4] ext4_convert_unwritten_io_end_vec+0xc5/0x150 [ext4] ext4_end_io_rsv_work+0x22c/0x350 [ext4] process_one_work+0x54f/0xb90 worker_thread+0x80/0x5f0 kthread+0x1cd/0x1f0 ret_from_fork+0x27/0x50
4 locks held by kworker/u256:0/8:
#0: ffff9a025abc4328 ((wq_completion)ext4-rsv-conversion){+.+.}, at: process_one_work+0x443/0xb90 #1: ffffab5a862dbe20 ((work_completion)(&ei->i_rsv_conversion_work)){+.+.}, at: process_one_work+0x443/0xb90 #2: ffff9a025a9d0f58 (jbd2_handle){++++}, at: start_this_handle+0x1c1/0x9d0 [jbd2]
#3: ffff9a00d4b985d8 (&(&ei->i_raw_lock)->rlock){+.+.}, at: ext4_do_update_inode+0xaa/0xf60 [ext4]
irq event stamp: 3009267 hardirqs last enabled at (3009267): [<ffffffff980da9b7>] __find_get_block+0x107/0x790 hardirqs last disabled at (3009266): [<ffffffff980da8f9>] __find_get_block+0x49/0x790 softirqs last enabled at (3009230): [<ffffffff98a0034c>] __do_softirq+0x34c/0x57c softirqs last disabled at (3009223): [<ffffffff97cc67a2>] irq_exit+0xa2/0xc0
Reported by Kernel Concurrency Sanitizer on:
CPU: 65 PID: 8 Comm: kworker/u256:0 Tainted: G L 5.6.0-rc2-next-20200221+ #7 Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019 Workqueue: ext4-rsv-conversion ext4_end_io_rsv_work [ext4]
The plain read is outside of inode->i_lock critical section which results in a data race. Fix it by adding READ_ONCE() there.
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -4812,7 +4812,7 @@ static int ext4_inode_blocks_set(handle_ struct ext4_inode_info *ei) {struct inode *inode = &(ei->vfs_inode); -u64 i_blocks = inode->i_blocks; +u64 i_blocks =READ_ONCE (inode->i_blocks);struct super_block *sb = inode->i_sb;if (i_blocks <= ~0U ) {
Greg Kroah-Hartman
maintainerPATCH 214/254 NFS: Fix a page leak in nfs_destroy_unlinked_subrequests()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit add42de31721fa29ed77a7ce388674d69f9d31a4 upstream.
When we detach a subrequest from the list, we must also release the reference it holds to the parent.
--- fs/nfs/write.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/write.c +1 -0
@@ -444,6 +444,7 @@ nfs_destroy_unlinked_subrequests(struct } subreq->wb_head = subreq; +nfs_release_request (old_head);if (test_and_clear_bit (PG_INODE_REF , &subreq->wb_flags)) {nfs_release_request (subreq);
Greg Kroah-Hartman
maintainerPATCH 213/254 NFS: Fix use-after-free issues in nfs_pageio_add_request()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit dc9dc2febb17f72e9878eb540ad3996f7984239a upstream.
We need to ensure that we create the mirror requests before calling nfs_pageio_add_request_mirror() on the request we are adding. Otherwise, we can end up with a use-after-free if the call to nfs_pageio_add_request_mirror() triggers I/O.
--- fs/nfs/pagelist.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
fs/nfs/pagelist.c +24 -24
@@ -1177,38 +1177,38 @@ int nfs_pageio_add_request(struct nfs_paif (desc->pg_error <0 ) goto out_failed; -for (midx =0 ; midx < desc->pg_mirror_count; midx++) { -if (midx) { -nfs_page_group_lock (req); - -/* find the last request */ -for (lastreq = req->wb_head; - lastreq->wb_this_page != req->wb_head; - lastreq = lastreq->wb_this_page) - ; - - dupreq =nfs_create_subreq (req, lastreq, - pgbase, offset, bytes); - -nfs_page_group_unlock (req); -if (IS_ERR (dupreq)) { - desc->pg_error =PTR_ERR (dupreq); - goto out_failed; - } - }else - dupreq = req; +/* Create the mirror instances first, and fire them off */ +for (midx =1 ; midx < desc->pg_mirror_count; midx++) { +nfs_page_group_lock (req); + +/* find the last request */ +for (lastreq = req->wb_head; + lastreq->wb_this_page != req->wb_head; + lastreq = lastreq->wb_this_page) + ; + + dupreq =nfs_create_subreq (req, lastreq, + pgbase, offset, bytes); + +nfs_page_group_unlock (req); +if (IS_ERR (dupreq)) { + desc->pg_error =PTR_ERR (dupreq); + goto out_failed; + } -if (nfs_pgio_has_mirroring (desc)) - desc->pg_mirror_idx = midx; + desc->pg_mirror_idx = midx;if (!nfs_pageio_add_request_mirror (desc, dupreq)) goto out_cleanup_subreq; } + desc->pg_mirror_idx =0 ; +if (!nfs_pageio_add_request_mirror (desc, req)) + goto out_failed; +return 1 ; out_cleanup_subreq: -if (req != dupreq) -nfs_pageio_cleanup_request (desc, dupreq); +nfs_pageio_cleanup_request (desc, dupreq); out_failed:nfs_pageio_error_cleanup (desc);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 212/254 nfsd: fsnotify on rmdir under nfsd/clients/
In reply to Greg Kroah-HartmanFrom: J. Bruce Fields <[email protected]>
commit 69afd267982e733a555fede4e85fe30329ed0588 upstream.
Userspace should be able to monitor nfsd/clients/ to see when clients come and go, but we're failing to send fsnotify events.
--- fs/nfsd/nfsctl.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/nfsctl.c +1 -0
@@ -1333,6 +1333,7 @@ void nfsd_client_rmdir(struct dentry *dedget (dentry); ret =simple_rmdir (dir, dentry);WARN_ON_ONCE (ret); +fsnotify_rmdir (dir, dentry);d_delete (dentry);inode_unlock (dir); }
Greg Kroah-Hartman
maintainerPATCH 210/254 powerpc/pseries: Avoid NULL pointer dereference when drmem is unavailable
In reply to Greg Kroah-HartmanFrom: Libor Pechacek <[email protected]>
commit a83836dbc53e96f13fec248ecc201d18e1e3111d upstream.
In guests without hotplugagble memory drmem structure is only zero initialized. Trying to manipulate DLPAR parameters results in a crash.
$ echo "memory add count 1" > /sys/kernel/dlpar
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
...
NIP: c0000000000ff294 LR: c0000000000ff248 CTR: 0000000000000000
REGS: c0000000fb9d3880 TRAP: 0300 Tainted: G E (5.5.0-rc6-2-default)
MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE> CR: 28242428 XER: 20000000
CFAR: c0000000009a6c10 DAR: 0000000000000010 DSISR: 40000000 IRQMASK: 0
...
NIP dlpar_memory+0x6e4/0xd00
LR dlpar_memory+0x698/0xd00
Call Trace:
dlpar_memory+0x698/0xd00 (unreliable)
handle_dlpar_errorlog+0xc0/0x190
dlpar_store+0x198/0x4a0
kobj_attr_store+0x30/0x50
sysfs_kf_write+0x64/0x90
kernfs_fop_write+0x1b0/0x290
__vfs_write+0x3c/0x70
vfs_write+0xd0/0x260
ksys_write+0xdc/0x130
system_call+0x5c/0x68Taking closer look at the code, I can see that for_each_drmem_lmb is a macro expanding into for (lmb = &drmem_info->lmbs[0]; lmb <= &drmem_info->lmbs[drmem_info->n_lmbs - 1]; lmb++). When drmem_info->lmbs is NULL, the loop would iterate through the whole address range if it weren't stopped by the NULL pointer dereference on the next line.
This patch aligns for_each_drmem_lmb and for_each_drmem_lmb_in_range macro behavior with the common C semantics, where the end marker does not belong to the scanned range, and alters get_lmb_range() semantics. As a side effect, the wraparound observed in the crash is prevented.
--- arch/powerpc/include/asm/drmem.h | 4 ++-- arch/powerpc/platforms/pseries/hotplug-memory.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/drmem.h +2 -2
@@ -27,12 +27,12 @@ struct drmem_lmb_info {extern struct drmem_lmb_info *drmem_info;#define for_each_drmem_lmb_in_range (lmb, start, end) \ - for ((lmb) = (start); (lmb) <= (end); (lmb)++) + for ((lmb) = (start); (lmb) < (end); (lmb)++)#define for_each_drmem_lmb (lmb) \ for_each_drmem_lmb_in_range((lmb), \ &drmem_info->lmbs[0], \ - &drmem_info->lmbs[drmem_info->n_lmbs - 1]) + &drmem_info->lmbs[drmem_info->n_lmbs])/* * The of_drconf_cell_v1 struct defines the layout of the LMB data
arch/powerpc/platforms/pseries/hotplug-memory.c +4 -4
@@ -223,7 +223,7 @@ static int get_lmb_range(u32 drc_index, struct drmem_lmb **end_lmb) {struct drmem_lmb *lmb, *start, *end; -struct drmem_lmb *last_lmb; +struct drmem_lmb *limit; start =NULL ;for_each_drmem_lmb (lmb) {
@@ -236,10 +236,10 @@ static int get_lmb_range(u32 drc_index,if (!start)return -EINVAL ; - end = &start[n_lmbs -1 ]; + end = &start[n_lmbs]; - last_lmb = &drmem_info->lmbs[drmem_info->n_lmbs -1 ]; -if (end > last_lmb) + limit = &drmem_info->lmbs[drmem_info->n_lmbs]; +if (end > limit)return -EINVAL ; *start_lmb = start;
Greg Kroah-Hartman
maintainerPATCH 208/254 drm/prime: fix extracting of the DMA addresses from a scatterlist
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
commit c0f83d164fb8f3a2b7bc379a6c1e27d1123a9eab upstream.
Scatterlist elements contains both pages and DMA addresses, but one should not assume 1:1 relation between them. The sg->length is the size of the physical memory chunk described by the sg->page, while sg_dma_len(sg) is the size of the DMA (IO virtual) chunk described by the sg_dma_address(sg).
The proper way of extracting both: pages and DMA addresses of the whole buffer described by a scatterlist it to iterate independently over the sg->pages/sg->length and sg_dma_address(sg)/sg_dma_len(sg) entries.
--- drivers/gpu/drm/drm_prime.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_prime.c +25 -12
@@ -962,27 +962,40 @@ int drm_prime_sg_to_page_addr_arrays(strunsigned count;struct scatterlist *sg;struct page *page; -u32 len, index; +u32 page_len, page_index;dma_addr_t addr; +u32 dma_len, dma_index; - index =0 ; +/* +* Scatterlist elements contains both pages and DMA addresses, but +* one shoud not assume 1:1 relation between them. The sg->length is +* the size of the physical memory chunk described by the sg->page, +* while sg_dma_len(sg) is the size of the DMA (IO virtual) chunk +* described by the sg_dma_address(sg). +*/ + page_index =0 ; + dma_index =0 ;for_each_sg (sgt->sgl, sg, sgt->nents, count) { - len =sg_dma_len (sg); + page_len = sg->length; page =sg_page (sg); + dma_len =sg_dma_len (sg); addr =sg_dma_address (sg); -while (len >0 ) { -if (WARN_ON (index >= max_entries)) +while (pages && page_len >0 ) { +if (WARN_ON (page_index >= max_entries))return -1 ; -if (pages) - pages[index] = page; -if (addrs) - addrs[index] = addr; - + pages[page_index] = page; page++; + page_len -=PAGE_SIZE ; + page_index++; + } +while (addrs && dma_len >0 ) { +if (WARN_ON (dma_index >= max_entries)) +return -1 ; + addrs[dma_index] = addr; addr +=PAGE_SIZE ; - len -=PAGE_SIZE ; - index++; + dma_len -=PAGE_SIZE ; + dma_index++; } }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 204/254 drm/amdgpu/powerplay: using the FCLK DPM table to set the MCLK
In reply to Greg Kroah-HartmanFrom: Yuxian Dai <[email protected]>
commit 022ac4c9c55be35a2d1f71019a931324c51b0dab upstream.
1.Using the FCLK DPM table to set the MCLK for DPM states consist of three entities:
FCLK
UCLK
MEMCLK
All these three clk change together, MEMCLK from FCLK, so use the fclk frequency.
2.we should show the current working clock freqency from clock table metric
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/renoir_ppt.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +6 -0
@@ -240,6 +240,7 @@ static int renoir_print_clk_levels(strucuint32_t cur_value =0 , value =0 , count =0 , min =0 , max =0 ;DpmClocks_t *clk_table = smu->smu_table.clocks_table;SmuMetrics_t metrics; +bool cur_value_match_level = false;if (!clk_table || clk_type >=SMU_CLK_COUNT )return -EINVAL ;
@@ -298,8 +299,13 @@ static int renoir_print_clk_levels(strucGET_DPM_CUR_FREQ (clk_table, clk_type, i, value); size +=sprintf (buf + size,"%d: %uMhz %s\n" , i, value, cur_value == value ?"*" :"" ); +if (cur_value == value) + cur_value_match_level = true; } +if (!cur_value_match_level) + size +=sprintf (buf + size," %uMhz *\n" , cur_value); +return size; }
drivers/gpu/drm/amd/powerplay/renoir_ppt.h +1 -1
@@ -37,7 +37,7 @@ extern void renoir_set_ppt_funcs(struct freq = table->SocClocks[dpm_level].Freq; \break ; \case SMU_MCLK : \ - freq = table->MemClocks[dpm_level].Freq; \ + freq = table->FClocks[dpm_level].Freq; \break ; \case SMU_DCEFCLK : \ freq = table->DcfClocks[dpm_level].Freq; \
Greg Kroah-Hartman
maintainerPATCH 205/254 drm/amd/powerplay: implement the is_dpm_running()
In reply to Greg Kroah-HartmanFrom: Prike Liang <[email protected]>
commit 4ee2bb22ddb53a2eafc675690d0d67452029ca37 upstream.
As the pmfw hasn't exported the interface of SMU feature mask to APU SKU so just force on all the features to driver inquired interface at early initial stage.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +12 -0
@@ -887,6 +887,17 @@ static int renoir_read_sensor(struct smureturn ret; } +static bool renoir_is_dpm_running (struct smu_context *smu) +{ +/* +* Util now, the pmfw hasn't exported the interface of SMU +* feature mask to APU SKU so just force on all the feature +* at early initial stage. +*/ +return true; + +} +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_clk_index = renoir_get_smu_clk_index,
@@ -928,6 +939,7 @@ static const struct pptable_funcs renoir .mode2_reset = smu_v12_0_mode2_reset, .set_soft_freq_limited_range = smu_v12_0_set_soft_freq_limited_range, .set_driver_table_location = smu_v12_0_set_driver_table_location, + .is_dpm_running = renoir_is_dpm_running, };void renoir_set_ppt_funcs (struct smu_context *smu)
Greg Kroah-Hartman
maintainerPATCH 203/254 drm: Remove PageReserved manipulation from drm_pci_alloc
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit ea36ec8623f56791c6ff6738d0509b7920f85220 upstream.
drm_pci_alloc/drm_pci_free are very thin wrappers around the core dma facilities, and we have no special reason within the drm layer to behave differently. In particular, since
commit de09d31dd38a50fdce106c15abd68432eebbd014
Author: Kirill A. Shutemov <[email protected]> Date: Fri Jan 15 16:51:42 2016 -0800
page-flags: define PG_reserved behavior on compound pages
As far as I can see there's no users of PG_reserved on compound pages. Let's use PF_NO_COMPOUND here.
it has been illegal to combine GFP_COMP with SetPageReserved, so lets stop doing both and leave the dma layer to its own devices.
--- drivers/gpu/drm/drm_pci.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_pci.c +2 -21
@@ -51,8 +51,6 @@drm_dma_handle_t *drm_pci_alloc (struct drm_device * dev,size_t size,size_t align) {drm_dma_handle_t *dmah; -unsigned long addr; -size_t sz;/* pci_alloc_consistent only guarantees alignment to the smallest * PAGE_SIZE order which is greater than or equal to the requested size.
@@ -68,20 +66,13 @@ drm_dma_handle_t *drm_pci_alloc(struct d dmah->size = size; dmah->vaddr =dma_alloc_coherent (&dev->pdev->dev, size, &dmah->busaddr, -GFP_KERNEL | __GFP_COMP); +GFP_KERNEL );if (dmah->vaddr ==NULL ) {kfree (dmah);return NULL ; } -/* XXX - Is virt_to_page() legal for consistent mem? */ -/* Reserve */ -for (addr = (unsigned long )dmah->vaddr, sz = size; - sz >0 ; addr +=PAGE_SIZE , sz -=PAGE_SIZE ) { -SetPageReserved (virt_to_page ((void *)addr)); - } -return dmah; }
@@ -94,19 +85,9 @@ EXPORT_SYMBOL(drm_pci_alloc);*/ void __drm_legacy_pci_free (struct drm_device * dev,drm_dma_handle_t * dmah) { -unsigned long addr; -size_t sz; - -if (dmah->vaddr) { -/* XXX - Is virt_to_page() legal for consistent mem? */ -/* Unreserve */ -for (addr = (unsigned long )dmah->vaddr, sz = dmah->size; - sz >0 ; addr +=PAGE_SIZE , sz -=PAGE_SIZE ) { -ClearPageReserved (virt_to_page ((void *)addr)); - } +if (dmah->vaddr)dma_free_coherent (&dev->pdev->dev, dmah->size, dmah->vaddr, dmah->busaddr); - } }/**
Greg Kroah-Hartman
maintainerPATCH 199/254 vfio: platform: Switch to platform_get_irq_optional()
In reply to Greg Kroah-HartmanFrom: Eric Auger <[email protected]>
commit 723fe298ad85ad1278bd2312469ad14738953cc6 upstream.
Since commit 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()"), platform_get_irq() calls dev_err() on an error. As we enumerate all interrupts until platform_get_irq() fails, we now systematically get a message such as:
"vfio-platform fff51000.ethernet: IRQ index 3 not found" which is a false positive.
Let's use platform_get_irq_optional() instead.
--- drivers/vfio/platform/vfio_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/platform/vfio_platform.c +1 -1
@@ -44,7 +44,7 @@ static int get_platform_irq(struct vfio_ {struct platform_device *pdev = (struct platform_device *) vdev->opaque; -return platform_get_irq (pdev, i); +return platform_get_irq_optional (pdev, i); }static int vfio_platform_probe (struct platform_device *pdev)
Greg Kroah-Hartman
maintainerPATCH 201/254 drm/bridge: analogix-anx78xx: Fix drm_dp_link helper removal
In reply to Greg Kroah-HartmanFrom: Torsten Duwe <[email protected]>
commit 3e138a63d6674a4567a018a31e467567c40b14d5 upstream.
drm_dp_link_rate_to_bw_code and ...bw_code_to_link_rate simply divide by and multiply with 27000, respectively. Avoid an overflow in the u8 dpcd[0] and the multiply+divide alltogether.
--- drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +2 -3
@@ -722,10 +722,9 @@ static int anx78xx_dp_link_training(struif (err)return err; - dpcd[0 ] =drm_dp_max_link_rate (anx78xx->dpcd); - dpcd[0 ] =drm_dp_link_rate_to_bw_code (dpcd[0 ]); err =regmap_write (anx78xx->map[I2C_IDX_TX_P0 ], -SP_DP_MAIN_LINK_BW_SET_REG , dpcd[0 ]); +SP_DP_MAIN_LINK_BW_SET_REG , + anx78xx->dpcd[DP_MAX_LINK_RATE ]);if (err)return err;