intel_th: Fixes for v5.5
Subsystems (3)
Alexander Shishkin
maintainerHi Greg,
These are the fixes I have so far. Both fixes are for commits in v5.2, so stable is CC'd: one is incorrect irq freeing and one is a NULL dereference from unintended use. Also included 2 new PCI IDs. Signed tag below, individual patches follow. Please consider applying or pullyng. Thanks!
The following changes since commit e42617b825f8073569da76dc4510bfa019b1c35a:
Linux 5.5-rc1 (2019-12-08 14:57:55 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git tags/intel_th-fixes-for-greg-20191216
for you to fetch changes up to 43420a735c271925c74fea8e75c4d6b89fc83bbf:
intel_th: msu: Fix window switching without windows (2019-12-16 19:50:26 +0200)
----------------------------------------------------------------intel_th: Fixes for v5.5
These are:
* 2 new PCI IDs
* 2 bugfixes for bugs added in v5.2
----------------------------------------------------------------
Alexander Shishkin (4):
intel_th: pci: Add Comet Lake PCH-V support
intel_th: pci: Add Elkhart Lake SOC support
intel_th: Fix freeing IRQs
intel_th: msu: Fix window switching without windows
drivers/hwtracing/intel_th/core.c | 7 ++++--- drivers/hwtracing/intel_th/intel_th.h | 2 ++ drivers/hwtracing/intel_th/msu.c | 14 +++++++++----- drivers/hwtracing/intel_th/pci.c | 10 ++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-)
Signature · 1 line
2.24.0
Alexander Shishkin
maintainer[GIT PULL 1/4] intel_th: pci: Add Comet Lake PCH-V support
This adds Intel(R) Trace Hub PCI ID for Comet Lake PCH-V.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -204,6 +204,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x06a6), .driver_data = (kernel_ulong_t)&intel_th_2x, }, + { +/* Comet Lake PCH-V */ +PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0xa3a6 ), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, {/* Ice Lake NNPI */ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
Signature · 1 line
2.24.0
Alexander Shishkin
maintainer[GIT PULL 2/4] intel_th: pci: Add Elkhart Lake SOC support
In reply to Alexander ShishkinThis adds support for Intel Trace Hub in Elkhart Lake.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -234,6 +234,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4da6), .driver_data = (kernel_ulong_t)&intel_th_2x, }, + { +/* Elkhart Lake */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4b26), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, { 0 }, };
Signature · 1 line
2.24.0
Alexander Shishkin
maintainer[GIT PULL 3/4] intel_th: Fix freeing IRQs
In reply to Alexander ShishkinCommit aac8da65174a ("intel_th: msu: Start handling IRQs") implicitly relies on the use of devm_request_irq() to subsequently free the irqs on device removal, but in case of the pci_free_irq_vectors() API, the handlers need to be freed before it is called. Therefore, at the moment the driver's remove path trips a BUG_ON(irq_has_action()):
Quoted 18 lines
kernel BUG at
drivers/pci/msi.c:375!
invalid opcode: 0000 1 SMPCPU: 2 PID: 818 Comm: rmmod Not tainted 5.5.0-rc1+ #1 RIP: 0010:free_msi_irqs+0x67/0x1c0 pci_disable_msi+0x116/0x150 pci_free_irq_vectors+0x1b/0x20 intel_th_pci_remove+0x22/0x30 [intel_th_pci] pci_device_remove+0x3e/0xb0 device_release_driver_internal+0xf0/0x1c0 driver_detach+0x4c/0x8f bus_remove_driver+0x5c/0xd0 driver_unregister+0x31/0x50 pci_unregister_driver+0x40/0x90 intel_th_pci_driver_exit+0x10/0xad6 [intel_th_pci] __x64_sys_delete_module+0x147/0x290 ? exit_to_usermode_loop+0xd7/0x120 do_syscall_64+0x57/0x1b0 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Fix this by explicitly freeing irqs before freeing the vectors. We keep using the devm_* variants because they are still useful in early error paths.
--- drivers/hwtracing/intel_th/core.c | 7 ++++--- drivers/hwtracing/intel_th/intel_th.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/hwtracing/intel_th/core.c +4 -3
@@ -834,9 +834,6 @@ static irqreturn_t intel_th_irq(int irq, void *data) ret |= d->irq (th->thdev[i]); } -if (ret ==IRQ_NONE ) -pr_warn_ratelimited ("nobody cared for irq\n" ); -return ret; }
@@ -887,6 +884,7 @@ intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,if (th->irq ==-1 ) th->irq = devres[r].start; + th->num_irqs++;break ;default : dev_warn(dev, "Unknown resource type %lx\n",
@@ -940,6 +938,9 @@ void intel_th_free(struct intel_th *th) th->num_thdevs =0 ; +for (i =0 ; i < th->num_irqs; i++) +devm_free_irq (th->dev, th->irq + i, th); +pm_runtime_get_sync (th->dev);pm_runtime_forbid (th->dev);
drivers/hwtracing/intel_th/intel_th.h +2 -0
@@ -261,6 +261,7 @@ enum th_mmio_idx {* @num_thdevs: number of devices in the @thdev array * @num_resources: number of resources in the @resource array * @irq: irq number +* @num_irqs: number of IRQs is use * @id: this Intel TH controller's device ID in the system * @major: device node major for output devices */
@@ -277,6 +278,7 @@ struct intel_th {unsigned int num_thdevs;unsigned int num_resources;int irq; +int num_irqs;int id;int major;
Signature · 1 line
2.24.0
Alexander Shishkin
maintainer[GIT PULL 4/4] intel_th: msu: Fix window switching without windows
In reply to Alexander ShishkinCommit 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger window switch") adds a NULL pointer dereference in the case when there are no windows allocated:
Quoted 10 lines
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 1 SMP CPU: 5 PID: 1110 Comm: bash Not tainted 5.5.0-rc1+ #1 RIP: 0010:msc_win_switch+0xa/0x80 [intel_th_msu] Call Trace: ? win_switch_store+0x9b/0xc0 [intel_th_msu] dev_attr_store+0x17/0x30
Quoted 8 lines
sysfs_kf_write+0x3e/0x50 kernfs_fop_write+0xda/0x1b0 __vfs_write+0x1b/0x40 vfs_write+0xb9/0x1a0 ksys_write+0x67/0xe0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x57/0x1d0 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Fix that by disallowing window switching with multiwindow buffers without windows.
--- drivers/hwtracing/intel_th/msu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/hwtracing/intel_th/msu.c +9 -5
@@ -1676,10 +1676,13 @@ static int intel_th_msc_init(struct msc *msc)return 0 ; } -static void msc_win_switch (struct msc *msc) +static int msc_win_switch (struct msc *msc) {struct msc_window *first; +if (list_empty (&msc->win_list)) +return -EINVAL ; + first = list_first_entry(&msc->win_list, struct msc_window, entry);if (msc_is_last_win (msc->cur_win))
@@ -1691,6 +1694,8 @@ static void msc_win_switch(struct msc *msc) msc->base_addr =msc_win_base_dma (msc->cur_win);intel_th_trace_switch (msc->thdev); + +return 0 ; }/**
@@ -2025,16 +2030,15 @@ win_switch_store(struct device *dev, struct device_attribute *attr,if (val !=1 )return -EINVAL ; + ret = -EINVAL ;mutex_lock (&msc->buf_mutex);/* * Window switch can only happen in the "multi" mode. * If a external buffer is engaged, they have the full * control over window switching. */ -if (msc->mode !=MSC_MODE_MULTI || msc->mbuf) - ret = -ENOTSUPP ; -else -msc_win_switch (msc); +if (msc->mode ==MSC_MODE_MULTI && !msc->mbuf) + ret =msc_win_switch (msc);mutex_unlock (&msc->buf_mutex);return ret ? ret : size;
Signature · 1 line
2.24.0
Greg Kroah-Hartman
maintainerRe: [GIT PULL 4/4] intel_th: msu: Fix window switching without windows
Quoted 3 lines · Alexander Shishkin
Commit
6cac7866c2741("intel_th: msu: Add a sysfs attribute to trigger window switch") adds a NULL pointer dereference in the case when there are no windows allocated:
Commit ids should only be specified in 12 digits, not 13 :)
Quoted 20 lines
Quoted 11 lines
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 1 SMP CPU: 5 PID: 1110 Comm: bash Not tainted 5.5.0-rc1+ #1 RIP: 0010:msc_win_switch+0xa/0x80 [intel_th_msu] Call Trace: ? win_switch_store+0x9b/0xc0 [intel_th_msu] dev_attr_store+0x17/0x30Quoted 8 lines
sysfs_kf_write+0x3e/0x50 kernfs_fop_write+0xda/0x1b0 __vfs_write+0x1b/0x40 vfs_write+0xb9/0x1a0 ksys_write+0x67/0xe0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x57/0x1d0 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Quoted 5 lines
Fix that by disallowing window switching with multiwindow buffers without windows.
Signed-off-by Alexander Shishkin <[email protected]>Fixes 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger window switch")
Same here.
I can go edit it by hand...
Re: [GIT PULL 4/4] intel_th: msu: Fix window switching without windows
Hi Greg,
Quoted 7 lines · On Tue, 17 Dec 2019 13:06:29 +0100 Greg Kroah-Hartman…
Quoted 3 lines · Alexander Shishkin
Commit
6cac7866c2741("intel_th: msu: Add a sysfs attribute to trigger window switch") adds a NULL pointer dereference in the case when there are no windows allocated:Commit ids should only be specified in 12 digits, not 13 :)
It is possible that 13 digits may be necessary to be unambiguous within a git repo. In fact, as we continue with a single git repo (Linus'), at some point 13 digits will become normal.
Signature · 2 lines
Cheers, Stephen Rothwell
Alexander Shishkin
maintainerQuoted 6 lines · Alexander Shishkin
Hi Greg,
These are the fixes I have so far. Both fixes are for commits in v5.2, so stable is CC'd: one is incorrect irq freeing and one is a NULL dereference from unintended use. Also included 2 new PCI IDs. Signed tag below, individual patches follow. Please consider applying or pullyng. Thanks!
The tag is wrong, apologies. Should be:
The following changes since commit e42617b825f8073569da76dc4510bfa019b1c35a:
Linux 5.5-rc1 (2019-12-08 14:57:55 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git tags/intel_th-fixes-for-greg-20191216
for you to fetch changes up to 6958619f52e9bc47d7aee0475e9d2c1ae2fcda75:
intel_th: msu: Fix window switching without windows (2019-12-17 13:36:01 +0200)
----------------------------------------------------------------intel_th: Fixes for v5.5
These are:
* 2 new PCI IDs
* 2 bugfixes for bugs added in v5.2
----------------------------------------------------------------
Alexander Shishkin (4):
intel_th: pci: Add Comet Lake PCH-V support
intel_th: pci: Add Elkhart Lake SOC support
intel_th: Fix freeing IRQs
intel_th: msu: Fix window switching without windows
drivers/hwtracing/intel_th/core.c | 7 ++++--- drivers/hwtracing/intel_th/intel_th.h | 2 ++ drivers/hwtracing/intel_th/msu.c | 14 +++++++++----- drivers/hwtracing/intel_th/pci.c | 10 ++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-)