sata_rcar: handle pm_runtime_get_sync failure cases
Subsystems (12)
Sasha Levin
maintainerPATCH 1/24 sata_rcar: handle pm_runtime_get_sync failure cases
From: Navid Emamdoost <[email protected]>
[ Upstream commit eea1238867205b9e48a67c1a63219529a73c46fd ]
Calling pm_runtime_get_sync increments the counter even in case of failure, causing incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.
--- drivers/ata/sata_rcar.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/ata/sata_rcar.c +7 -4
@@ -905,7 +905,7 @@ static int sata_rcar_probe(struct platform_device *pdev)pm_runtime_enable (dev); ret =pm_runtime_get_sync (dev);if (ret <0 ) - goto err_pm_disable; + goto err_pm_put; host =ata_host_alloc (dev,1 );if (!host) {
@@ -935,7 +935,6 @@ static int sata_rcar_probe(struct platform_device *pdev) err_pm_put:pm_runtime_put (dev); -err_pm_disable:pm_runtime_disable (dev);return ret; }
@@ -989,8 +988,10 @@ static int sata_rcar_resume(struct device *dev)int ret; ret =pm_runtime_get_sync (dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put (dev);return ret; + }if (priv->type ==RCAR_GEN3_SATA ) {sata_rcar_init_module (priv);
@@ -1015,8 +1016,10 @@ static int sata_rcar_restore(struct device *dev)int ret; ret =pm_runtime_get_sync (dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put (dev);return ret; + }sata_rcar_setup_port (host);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 2/24 ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function
From: Ye Bin <[email protected]>
[ Upstream commit f650ef61e040bcb175dd8762164b00a5d627f20e ]
BUG: KASAN: use-after-free in ata_scsi_mode_select_xlat+0x10bd/0x10f0 drivers/ata/libata-scsi.c:4045 Read of size 1 at addr ffff88803b8cd003 by task syz-executor.6/12621 CPU: 1 PID: 12621 Comm: syz-executor.6 Not tainted 4.19.95 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xac/0xee lib/dump_stack.c:118 print_address_description+0x60/0x223 mm/kasan/report.c:253 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report mm/kasan/report.c:409 [inline] kasan_report.cold+0xae/0x2d8 mm/kasan/report.c:393 ata_scsi_mode_select_xlat+0x10bd/0x10f0 drivers/ata/libata-scsi.c:4045 ata_scsi_translate+0x2da/0x680 drivers/ata/libata-scsi.c:2035 __ata_scsi_queuecmd drivers/ata/libata-scsi.c:4360 [inline] ata_scsi_queuecmd+0x2e4/0x790 drivers/ata/libata-scsi.c:4409 scsi_dispatch_cmd+0x2ee/0x6c0 drivers/scsi/scsi_lib.c:1867 scsi_queue_rq+0xfd7/0x1990 drivers/scsi/scsi_lib.c:2170 blk_mq_dispatch_rq_list+0x1e1/0x19a0 block/blk-mq.c:1186 blk_mq_do_dispatch_sched+0x147/0x3d0 block/blk-mq-sched.c:108 blk_mq_sched_dispatch_requests+0x427/0x680 block/blk-mq-sched.c:204 __blk_mq_run_hw_queue+0xbc/0x200 block/blk-mq.c:1308 __blk_mq_delay_run_hw_queue+0x3c0/0x460 block/blk-mq.c:1376 blk_mq_run_hw_queue+0x152/0x310 block/blk-mq.c:1413 blk_mq_sched_insert_request+0x337/0x6c0 block/blk-mq-sched.c:397 blk_execute_rq_nowait+0x124/0x320 block/blk-exec.c:64 blk_execute_rq+0xc5/0x112 block/blk-exec.c:101 sg_scsi_ioctl+0x3b0/0x6a0 block/scsi_ioctl.c:507 sg_ioctl+0xd37/0x23f0 drivers/scsi/sg.c:1106 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0xae6/0x1030 fs/ioctl.c:688 ksys_ioctl+0x76/0xa0 fs/ioctl.c:705 __do_sys_ioctl fs/ioctl.c:712 [inline] __se_sys_ioctl fs/ioctl.c:710 [inline] __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710 do_syscall_64+0xa0/0x2e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45c479 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89
f7 48
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f
83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fb0e9602c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fb0e96036d4 RCX: 000000000045c479
RDX: 0000000020000040 RSI: 0000000000000001 RDI: 0000000000000003
RBP: 000000000076bfc0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 000000000000046d R14: 00000000004c6e1a R15: 000000000076bfcc
Allocated by task 12577: set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc mm/kasan/kasan.c:553 [inline] kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:531 __kmalloc+0xf3/0x1e0 mm/slub.c:3749 kmalloc include/linux/slab.h:520 [inline] load_elf_phdrs+0x118/0x1b0 fs/binfmt_elf.c:441 load_elf_binary+0x2de/0x4610 fs/binfmt_elf.c:737 search_binary_handler fs/exec.c:1654 [inline] search_binary_handler+0x15c/0x4e0 fs/exec.c:1632 exec_binprm fs/exec.c:1696 [inline] __do_execve_file.isra.0+0xf52/0x1a90 fs/exec.c:1820 do_execveat_common fs/exec.c:1866 [inline] do_execve fs/exec.c:1883 [inline] __do_sys_execve fs/exec.c:1964 [inline] __se_sys_execve fs/exec.c:1959 [inline] __x64_sys_execve+0x8a/0xb0 fs/exec.c:1959 do_syscall_64+0xa0/0x2e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 12577: set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x129/0x170 mm/kasan/kasan.c:521 slab_free_hook mm/slub.c:1370 [inline] slab_free_freelist_hook mm/slub.c:1397 [inline] slab_free mm/slub.c:2952 [inline] kfree+0x8b/0x1a0 mm/slub.c:3904 load_elf_binary+0x1be7/0x4610 fs/binfmt_elf.c:1118 search_binary_handler fs/exec.c:1654 [inline] search_binary_handler+0x15c/0x4e0 fs/exec.c:1632 exec_binprm fs/exec.c:1696 [inline] __do_execve_file.isra.0+0xf52/0x1a90 fs/exec.c:1820 do_execveat_common fs/exec.c:1866 [inline] do_execve fs/exec.c:1883 [inline] __do_sys_execve fs/exec.c:1964 [inline] __se_sys_execve fs/exec.c:1959 [inline] __x64_sys_execve+0x8a/0xb0 fs/exec.c:1959 do_syscall_64+0xa0/0x2e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff88803b8ccf00 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 259 bytes inside of 512-byte region [ffff88803b8ccf00, ffff88803b8cd100) The buggy address belongs to the page: page:ffffea0000ee3300 count:1 mapcount:0 mapping:ffff88806cc03080 index:0xffff88803b8cc780 compound_mapcount: 0 flags: 0x100000000008100(slab|head) raw: 0100000000008100 ffffea0001104080 0000000200000002 ffff88806cc03080 raw: ffff88803b8cc780 00000000800c000b 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88803b8ccf00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88803b8ccf80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88803b8cd000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^ffff88803b8cd080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fbffff88803b8cd100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
You can refer to "https://www.lkml.org/lkml/2019/1/17/474" reproduce this error.
The exception code is "bd_len = p[3];", "p" value is ffff88803b8cd000
which belongs to the cache kmalloc-512 of size 512. The "page_address(sg_page(scsi_sglist(scmd)))" maybe from sg_scsi_ioctl function "buffer" which allocated by kzalloc, so "buffer" may not page aligned.
This also looks completely buggy on highmem systems and really needs to use akmap_atomic. --Christoph Hellwig
To address above bugs, Paolo Bonzini advise to simpler to just make a char array of size CACHE_MPAGE_LEN+8+8+4-2(or just 64 to make it easy), use sg_copy_to_buffer to copy from the sglist into the buffer, and workthere.
--- drivers/ata/libata-scsi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/ata/libata-scsi.c +6 -3
@@ -3978,12 +3978,13 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) {struct scsi_cmnd *scmd = qc->scsicmd;const u8 *cdb = scmd->cmnd; -const u8 *p;u8 pg, spg;unsigned six_byte, pg_len, hdr_len, bd_len;int len;u16 fp = (u16)-1 ;u8 bp =0xff ; +u8 buffer[64 ]; +const u8 *p = buffer;VPRINTK ("ENTER\n" );
@@ -4017,12 +4018,14 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)if (!scsi_sg_count (scmd) ||scsi_sglist (scmd)->length < len) goto invalid_param_len; - p =page_address (sg_page (scsi_sglist (scmd))); -/* Move past header and block descriptors. */ if (len < hdr_len) goto invalid_param_len; +if (!sg_copy_to_buffer (scsi_sglist (scmd),scsi_sg_count (scmd), + buffer,sizeof (buffer))) + goto invalid_param_len; +if (six_byte) bd_len = p[3 ];else
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 3/24 drm/amd/display: Use kfree() to free rgb_user in calculate_user_regamma_ramp()
In reply to Sasha LevinFrom: Denis Efremov <[email protected]>
[ Upstream commit 43a562774fceba867e8eebba977d7d42f8a2eac7 ]
Use kfree() instead of kvfree() to free rgb_user in calculate_user_regamma_ramp() because the memory is allocated with kcalloc().
--- drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/modules/color/color_gamma.c +1 -1
@@ -1862,7 +1862,7 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,kfree (rgb_regamma); rgb_regamma_alloc_fail: -kvfree (rgb_user); +kfree (rgb_user); rgb_user_alloc_fail:return ret; }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 4/24 riscv/atomic: Fix sign extension for RV64I
In reply to Sasha LevinFrom: Nathan Huckleberry <[email protected]>
[ Upstream commit 6c58f25e6938c073198af8b1e1832f83f8f0df33 ]
The argument passed to cmpxchg is not guaranteed to be sign extended, but lr.w sign extends on RV64I. This makes cmpxchg fail on clang built kernels when __old is negative.
To fix this, we just cast __old to long which sign extends on RV64I. With this fix, clang built RISC-V kernels now boot.
--- arch/riscv/include/asm/cmpxchg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/include/asm/cmpxchg.h +4 -4
@@ -179,7 +179,7 @@" bnez %1, 0b\n" \"1:\n" \ : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ -: " rJ" (__old), " rJ" (__new) \ +: " rJ" ((long)__old), " rJ" (__new) \ : "memory"); \ break; \ case 8: \
@@ -224,7 +224,7 @@RISCV_ACQUIRE_BARRIER \"1:\n" \ : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ -: " rJ" (__old), " rJ" (__new) \ +: " rJ" ((long)__old), " rJ" (__new) \ : "memory"); \ break; \ case 8: \
@@ -270,7 +270,7 @@" bnez %1, 0b\n" \"1:\n" \ : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ -: " rJ" (__old), " rJ" (__new) \ +: " rJ" ((long)__old), " rJ" (__new) \ : "memory"); \ break; \ case 8: \
@@ -316,7 +316,7 @@" fence rw, rw\n" \"1:\n" \ : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ -: " rJ" (__old), " rJ" (__new) \ +: " rJ" ((long)__old), " rJ" (__new) \ : "memory"); \ break; \ case 8: \
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Sasha Levin
maintainerPATCH 5/24 hwrng: ks-sa - Fix runtime PM imbalance on error
In reply to Sasha LevinFrom: Dinghao Liu <[email protected]>
[ Upstream commit 95459261c99f1621d90bc628c2a48e60b7cf9a88 ]
pm_runtime_get_sync() increments the runtime PM usage counter even the call returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/char/hw_random/ks-sa-rng.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/ks-sa-rng.c +1 -0
@@ -208,6 +208,7 @@ static int ks_sa_rng_probe(struct platform_device *pdev) ret =pm_runtime_get_sync (dev);if (ret <0 ) {dev_err (dev,"Failed to enable SA power-domain\n" ); +pm_runtime_put_noidle (dev);pm_runtime_disable (dev);return ret; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 6/24 arm64/sve: Eliminate data races on sve_default_vl
In reply to Sasha LevinFrom: Dave Martin <[email protected]>
[ Upstream commit 1e570f512cbdc5e9e401ba640d9827985c1bea1e ]
sve_default_vl can be modified via the /proc/sys/abi/sve_default_vl sysctl concurrently with use, and modified concurrently by multiple threads.
Adding a lock for this seems overkill, and I don't want to think any more than necessary, so just define wrappers using READ_ONCE()/ WRITE_ONCE().
This will avoid the possibility of torn accesses and repeated loads and stores.
There's no evidence yet that this is going wrong in practice: this is just hygiene. For generic sysctl users, it would be better to build this kind of thing into the sysctl common code somehow.
--- arch/arm64/kernel/fpsimd.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
arch/arm64/kernel/fpsimd.c +18 -7
@@ -12,6 +12,7 @@#include <linux/bug.h> #include <linux/cache.h> #include <linux/compat.h> +#include <linux/compiler.h> #include <linux/cpu.h> #include <linux/cpu_pm.h> #include <linux/kernel.h>
@@ -119,10 +120,20 @@ struct fpsimd_last_state_struct { static DEFINE_PER_CPU(struct fpsimd_last_state_struct, fpsimd_last_state);/* Default VL for tasks that don't set it explicitly: */ -static int sve_default_vl =-1 ; +static int __sve_default_vl =-1 ; + +static int get_sve_default_vl (void ) +{ +return READ_ONCE (__sve_default_vl); +}#ifdef CONFIG_ARM64_SVE +static void set_sve_default_vl (int val) +{ +WRITE_ONCE (__sve_default_vl, val); +} +/* Maximum supported vector length across all CPUs (initially poisoned) */ int __ro_after_init sve_max_vl =SVE_VL_MIN ;int __ro_after_init sve_max_virtualisable_vl =SVE_VL_MIN ;
@@ -345,7 +356,7 @@ static int sve_proc_do_default_vl(struct ctl_table *table, int write, loff_t *ppos) {int ret; -int vl = sve_default_vl; +int vl =get_sve_default_vl ();struct ctl_table tmp_table = { .data = &vl, .maxlen =sizeof (vl),
@@ -362,7 +373,7 @@ static int sve_proc_do_default_vl(struct ctl_table *table, int write,if (!sve_vl_valid (vl))return -EINVAL ; - sve_default_vl =find_supported_vector_length (vl); +set_sve_default_vl (find_supported_vector_length (vl));return 0 ; }
@@ -869,7 +880,7 @@ void __init sve_setup(void)* For the default VL, pick the maximum supported value <= 64. * VL == 64 is guaranteed not to grow the signal frame. */ - sve_default_vl =find_supported_vector_length (64 ); +set_sve_default_vl (find_supported_vector_length (64 ));bitmap_andnot (tmp_map, sve_vq_partial_map, sve_vq_map,SVE_VQ_MAX );
@@ -890,7 +901,7 @@ void __init sve_setup(void)pr_info ("SVE: maximum available vector length %u bytes per vector\n" , sve_max_vl);pr_info ("SVE: default vector length %u bytes per vector\n" , - sve_default_vl); +get_sve_default_vl ());/* KVM decides whether to support mismatched systems. Just warn here: */ if (sve_max_virtualisable_vl < sve_max_vl)
@@ -1030,13 +1041,13 @@ void fpsimd_flush_thread(void)* vector length configured: no kernel task can become a user * task without an exec and hence a call to this function. * By the time the first call to this function is made, all -* early hardware probing is complete, so sve_default_vl +* early hardware probing is complete, so __sve_default_vl * should be valid. * If a bug causes this to go wrong, we make some noise and * try to fudge thread.sve_vl to a safe value here. */ vl = current->thread.sve_vl_onexec ? - current->thread.sve_vl_onexec : sve_default_vl; + current->thread.sve_vl_onexec :get_sve_default_vl ();if (WARN_ON (!sve_vl_valid (vl))) vl =SVE_VL_MIN ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 7/24 ibmvnic: Harden device login requests
In reply to Sasha LevinFrom: Thomas Falcon <[email protected]>
[ Upstream commit dff515a3e71dc8ab3b9dcc2e23a9b5fca88b3c18 ]
The VNIC driver's "login" command sequence is the final step in the driver's initialization process with device firmware, confirming the available device queue resources to be utilized by the driver. Under high system load, firmware may not respond to the request in a timely manner or may abort the request. In such cases, the driver should reattempt the login command sequence. In case of a device error, the number of retries is bounded.
--- drivers/net/ethernet/ibm/ibmvnic.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +17 -4
@@ -779,12 +779,13 @@ static int ibmvnic_login(struct net_device *netdev)struct ibmvnic_adapter *adapter =netdev_priv (netdev);unsigned long timeout =msecs_to_jiffies (30000 );int retry_count =0 ; +int retries =10 ;bool retry;int rc; do { retry = false; - if (retry_count > IBMVNIC_MAX_QUEUES) { + if (retry_count > retries) { netdev_warn(netdev, "Login attempts exceeded\n"); return -1; }
@@ -799,11 +800,23 @@ static int ibmvnic_login(struct net_device *netdev)if (!wait_for_completion_timeout (&adapter->init_done, timeout)) { -netdev_warn (netdev,"Login timed out\n" ); -return -1 ; +netdev_warn (netdev,"Login timed out, retrying...\n" ); + retry = true; + adapter->init_done_rc =0 ; + retry_count++; +continue ; } -if (adapter->init_done_rc ==PARTIALSUCCESS ) { +if (adapter->init_done_rc ==ABORTED ) { +netdev_warn (netdev,"Login aborted, retrying...\n" ); + retry = true; + adapter->init_done_rc =0 ; + retry_count++; +/* FW or device may be busy, so +* wait a bit before retrying login +*/ +msleep (500 ); + }else if (adapter->init_done_rc ==PARTIALSUCCESS ) { retry_count++;release_sub_crqs (adapter,1 );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 8/24 net: alx: fix race condition in alx_remove
In reply to Sasha LevinFrom: Zekun Shen <[email protected]>
[ Upstream commit e89df5c4322c1bf495f62d74745895b5fd2a4393 ]
There is a race condition exist during termination. The path is alx_stop and then alx_remove. An alx_schedule_link_check could be called before alx_stop by interrupt handler and invoke alx_link_check later. Alx_stop frees the napis, and alx_remove cancels any pending works. If any of the work is scheduled before termination and invoked before alx_remove, a null-ptr-deref occurs because both expect alx->napis[i].
This patch fix the race condition by moving cancel_work_sync functions before alx_free_napis inside alx_stop. Because interrupt handler can call alx_schedule_link_check again, alx_free_irq is moved before cancel_work_sync calls too.
--- drivers/net/ethernet/atheros/alx/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/atheros/alx/main.c +5 -4
@@ -1249,8 +1249,12 @@ static int __alx_open(struct alx_priv *alx, bool resume)static void __alx_stop (struct alx_priv *alx) { -alx_halt (alx);alx_free_irq (alx); + +cancel_work_sync (&alx->link_check_wk); +cancel_work_sync (&alx->reset_wk); + +alx_halt (alx);alx_free_rings (alx);alx_free_napis (alx); }
@@ -1858,9 +1862,6 @@ static void alx_remove(struct pci_dev *pdev)struct alx_priv *alx =pci_get_drvdata (pdev);struct alx_hw *hw = &alx->hw; -cancel_work_sync (&alx->link_check_wk); -cancel_work_sync (&alx->reset_wk); -/* restore permanent mac address */ alx_set_macaddr (hw, hw->perm_addr);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 9/24 test_objagg: Fix potential memory leak in error handling
In reply to Sasha LevinFrom: Aditya Pakki <[email protected]>
[ Upstream commit a6379f0ad6375a707e915518ecd5c2270afcd395 ]
In case of failure of check_expect_hints_stats(), the resources allocated by objagg_hints_get should be freed. The patch fixes this issue.
--- lib/test_objagg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_objagg.c +2 -2
@@ -979,10 +979,10 @@ static int test_hints_case(const struct hints_case *hints_case) err_world2_obj_get:for (i--; i >=0 ; i--)world_obj_put (&world2, objagg, hints_case->key_ids[i]); -objagg_hints_put (hints); -objagg_destroy (objagg2); i = hints_case->key_ids_count; +objagg_destroy (objagg2); err_check_expect_hints_stats: +objagg_hints_put (hints); err_hints_get: err_check_expect_stats: err_world_obj_get:
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 10/24 rocker: fix incorrect error handling in dma_rings_init
In reply to Sasha LevinFrom: Aditya Pakki <[email protected]>
[ Upstream commit 58d0c864e1a759a15c9df78f50ea5a5c32b3989e ]
In rocker_dma_rings_init, the goto blocks in case of errors caused by the functions rocker_dma_cmd_ring_waits_alloc() and rocker_dma_ring_create() are incorrect. The patch fixes the order consistent with cleanup in rocker_dma_rings_fini().
--- drivers/net/ethernet/rocker/rocker_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/rocker/rocker_main.c +2 -2
@@ -647,10 +647,10 @@ static int rocker_dma_rings_init(struct rocker *rocker) err_dma_event_ring_bufs_alloc:rocker_dma_ring_destroy (rocker, &rocker->event_ring); err_dma_event_ring_create: +rocker_dma_cmd_ring_waits_free (rocker); +err_dma_cmd_ring_waits_alloc:rocker_dma_ring_bufs_free (rocker, &rocker->cmd_ring,PCI_DMA_BIDIRECTIONAL ); -err_dma_cmd_ring_waits_alloc: -rocker_dma_cmd_ring_waits_free (rocker); err_dma_cmd_ring_bufs_alloc:rocker_dma_ring_destroy (rocker, &rocker->cmd_ring);return err;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 11/24 mvpp2: ethtool rxtx stats fix
In reply to Sasha LevinFrom: Sven Auhagen <[email protected]>
[ Upstream commit cc970925feb9a38c2f0d34305518e00a3084ce85 ]
The ethtool rx and tx queue statistics are reporting wrong values. Fix reading out the correct ones.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -2
@@ -1541,7 +1541,7 @@ static void mvpp2_read_stats(struct mvpp2_port *port)for (q =0 ; q < port->ntxqs; q++)for (i =0 ; i <ARRAY_SIZE (mvpp2_ethtool_txq_regs); i++) *pstats++ +=mvpp2_read_index (port->priv, -MVPP22_CTRS_TX_CTR (port->id, i), +MVPP22_CTRS_TX_CTR (port->id, q), mvpp2_ethtool_txq_regs[i].offset);/* Rxqs are numbered from 0 from the user standpoint, but not from the
@@ -1550,7 +1550,7 @@ static void mvpp2_read_stats(struct mvpp2_port *port)for (q =0 ; q < port->nrxqs; q++)for (i =0 ; i <ARRAY_SIZE (mvpp2_ethtool_rxq_regs); i++) *pstats++ +=mvpp2_read_index (port->priv, - port->first_rxq + i, + port->first_rxq + q, mvpp2_ethtool_rxq_regs[i].offset); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 12/24 pinctrl: qcom: spmi-gpio: fix warning about irq chip reusage
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 5e50311556c9f409a85740e3cb4c4511e7e27da0 ]
Fix the following warnings caused by reusage of the same irq_chip instance for all spmi-gpio gpio_irq_chip instances. Instead embed irq_chip into pmic_gpio_state struct.
gpio gpiochip2: (c440000.qcom,spmi:pmic@2:gpio@c000): detected irqchip that is shared with multiple gpiochips: please fix the driver. gpio gpiochip3: (c440000.qcom,spmi:pmic@4:gpio@c000): detected irqchip that is shared with multiple gpiochips: please fix the driver. gpio gpiochip4: (c440000.qcom,spmi:pmic@a:gpio@c000): detected irqchip that is shared with multiple gpiochips: please fix the driver.
--- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +10 -11
@@ -170,6 +170,7 @@ struct pmic_gpio_state {struct regmap *map;struct pinctrl_dev *ctrl;struct gpio_chip chip; +struct irq_chip irq; };static const struct pinconf_generic_params pmic_gpio_bindings[] = {
@@ -917,16 +918,6 @@ static int pmic_gpio_populate(struct pmic_gpio_state *state,return 0 ; } -static struct irq_chip pmic_gpio_irq_chip = { - .name ="spmi-gpio" , - .irq_ack = irq_chip_ack_parent, - .irq_mask = irq_chip_mask_parent, - .irq_unmask = irq_chip_unmask_parent, - .irq_set_type = irq_chip_set_type_parent, - .irq_set_wake = irq_chip_set_wake_parent, - .flags =IRQCHIP_MASK_ON_SUSPEND , -}; - static int pmic_gpio_domain_translate(struct irq_domain *domain, struct irq_fwspec *fwspec, unsigned long *hwirq,
@@ -1053,8 +1044,16 @@ static int pmic_gpio_probe(struct platform_device *pdev)if (!parent_domain)return -ENXIO ; + state->irq.name ="spmi-gpio" , + state->irq.irq_ack = irq_chip_ack_parent, + state->irq.irq_mask = irq_chip_mask_parent, + state->irq.irq_unmask = irq_chip_unmask_parent, + state->irq.irq_set_type = irq_chip_set_type_parent, + state->irq.irq_set_wake = irq_chip_set_wake_parent, + state->irq.flags =IRQCHIP_MASK_ON_SUSPEND , + girq = &state->chip.irq; - girq->chip = &pmic_gpio_irq_chip; + girq->chip = &state->irq; girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_level_irq; girq->fwnode =of_node_to_fwnode (state->dev->of_node);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 13/24 pinctrl: tegra: Use noirq suspend/resume callbacks
In reply to Sasha LevinFrom: Vidya Sagar <[email protected]>
[ Upstream commit 782b6b69847f34dda330530493ea62b7de3fd06a ]
Use noirq suspend/resume callbacks as other drivers which implement noirq suspend/resume callbacks (Ex:- PCIe) depend on pinctrl driver to configure the signals used by their respective devices in the noirq phase.
--- drivers/pinctrl/tegra/pinctrl-tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +2 -2
@@ -685,8 +685,8 @@ static int tegra_pinctrl_resume(struct device *dev) }const struct dev_pm_ops tegra_pinctrl_pm = { - .suspend = &tegra_pinctrl_suspend, - .resume = &tegra_pinctrl_resume + .suspend_noirq = &tegra_pinctrl_suspend, + .resume_noirq = &tegra_pinctrl_resume };static bool gpio_node_has_range (const char *compatible)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 14/24 s390/ptrace: pass invalid syscall numbers to tracing
In reply to Sasha LevinFrom: Sven Schnelle <[email protected]>
[ Upstream commit 00332c16b1604242a56289ff2b26e283dbad0812 ]
tracing expects to see invalid syscalls, so pass it through. The syscall path in entry.S checks the syscall number before looking up the handler, so it is still safe.
--- arch/s390/kernel/entry.S | 2 +- arch/s390/kernel/ptrace.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
arch/s390/kernel/entry.S +1 -1
@@ -368,9 +368,9 @@ ENTRY(system_call) jnz .Lsysc_nr_ok # svc 0: system call number in %r1 llgfr %r1,%r1 # clear high word in r1 + sth %r1,__PT_INT_CODE+2(%r11) cghi %r1,NR_syscalls jnl .Lsysc_nr_ok - sth %r1,__PT_INT_CODE+2(%r11) slag %r8,%r1,3 .Lsysc_nr_ok: xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
arch/s390/kernel/ptrace.c +2 -4
@@ -844,11 +844,9 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)* call number to gprs[2]. */ if (test_thread_flag (TIF_SYSCALL_TRACE ) && - (tracehook_report_syscall_entry (regs) || - regs->gprs[2 ] >= NR_syscalls)) { +tracehook_report_syscall_entry (regs)) {/* -* Tracing decided this syscall should not happen or the -* debugger stored an invalid system call number. Skip +* Tracing decided this syscall should not happen. Skip * the system call and the system call restart handling. */ clear_pt_regs_flag (regs,PIF_SYSCALL );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 15/24 s390/ptrace: fix setting syscall number
In reply to Sasha LevinFrom: Sven Schnelle <[email protected]>
[ Upstream commit 873e5a763d604c32988c4a78913a8dab3862d2f9 ]
When strace wants to update the syscall number, it sets GPR2 to the desired number and updates the GPR via PTRACE_SETREGSET. It doesn't update regs->int_code which would cause the old syscall executed on syscall restart. As we cannot change the ptrace ABI and don't have a field for the interruption code, check whether the tracee is in a syscall and the last instruction was svc. In that case assume that the tracer wants to update the syscall number and copy the GPR2 value to regs->int_code.
--- arch/s390/kernel/ptrace.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
arch/s390/kernel/ptrace.c +30 -1
@@ -324,6 +324,25 @@ static inline void __poke_user_per(struct task_struct *child, child->thread.per_user.end = data; } +static void fixup_int_code (struct task_struct *child,addr_t data) +{ +struct pt_regs *regs =task_pt_regs (child); +int ilc = regs->int_code >>16 ; +u16 insn; + +if (ilc >6 ) +return ; + +if (ptrace_access_vm (child, regs->psw.addr - (regs->int_code >>16 ), + &insn,sizeof (insn),FOLL_FORCE ) !=sizeof (insn)) +return ; + +/* double check that tracee stopped on svc instruction */ +if ((insn >>8 ) !=0xa ) +return ; + + regs->int_code =0x20000 | (data &0xffff ); +}/* * Write a word to the user area of a process at location addr. This * operation does have an additional problem compared to peek_user.
@@ -335,7 +354,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)struct user *dummy =NULL ;addr_t offset; +if (addr < (addr_t) &dummy->regs.acrs) { +struct pt_regs *regs =task_pt_regs (child);/* * psw and gprs are stored on the stack */
@@ -353,7 +374,11 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)/* Invalid addressing mode bits */ return -EINVAL ; } - *(addr_t *)((addr_t ) &task_pt_regs (child)->psw + addr) = data; + +if (test_pt_regs_flag (regs,PIF_SYSCALL ) && + addr == offsetof(struct user, regs.gprs[2])) +fixup_int_code (child, data); + *(addr_t *)((addr_t ) ®s->psw + addr) = data; }else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) {/*
@@ -719,6 +744,10 @@ static int __poke_user_compat(struct task_struct *child, regs->psw.mask = (regs->psw.mask & ~PSW_MASK_BA ) | (__u64)(tmp &PSW32_ADDR_AMODE ); }else { + +if (test_pt_regs_flag (regs,PIF_SYSCALL ) && + addr == offsetof(struct compat_user, regs.gprs[2])) +fixup_int_code (child, data);/* gpr 0-15 */ *(__u32 *)((addr_t ) ®s->psw + addr*2 +4 ) = tmp; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 16/24 s390/vdso: Use $(LD) instead of $(CC) to link vDSO
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 2b2a25845d534ac6d55086e35c033961fdd83a26 ]
Currently, the VDSO is being linked through $(CC). This does not match how the rest of the kernel links objects, which is through the $(LD) variable.
When clang is built in a default configuration, it first attempts to use the target triple's default linker, which is just ld. However, the user can override this through the CLANG_DEFAULT_LINKER cmake define so that clang uses another linker by default, such as LLVM's own linker, ld.lld. This can be useful to get more optimized links across various different projects.
However, this is problematic for the s390 vDSO because ld.lld does not have any s390 emulatiom support:
https://github.com/llvm/llvm-project/blob/llvmorg-10.0.1-rc1/lld/ELF/Driver.cpp#L132-L150
Thus, if a user is using a toolchain with ld.lld as the default, they will see an error, even if they have specified ld.bfd through the LD make variable:
$ make -j"$(nproc)" -s ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- LLVM=1 \
LD=s390x-linux-gnu-ld \
defconfig arch/s390/kernel/vdso64/
ld.lld: error: unknown emulation: elf64_s390
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)Normally, '-fuse-ld=bfd' could be used to get around this; however, this can be fragile, depending on paths and variable naming. The cleaner solution for the kernel is to take advantage of the fact that $(LD) can be invoked directly, which bypasses the heuristics of $(CC) and respects the user's choice. Similar changes have been done for ARM, ARM64, and MIPS.
--- arch/s390/kernel/vdso64/Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/s390/kernel/vdso64/Makefile +4 -6
@@ -18,8 +18,8 @@ KBUILD_AFLAGS_64 += -m64 -s KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin -KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ - -Wl,--hash-style=both +ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \ + --hash-style=both --build-id -T $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64) $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
@@ -37,8 +37,8 @@ KASAN_SANITIZE := n $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so # link rule for the .so file, .lds has to be first -$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE - $(call if_changed,vdso64ld) +$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) FORCE + $(call if_changed,ld) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -50,8 +50,6 @@ $(obj-vdso64): %.o: %.S FORCE $(call if_changed_dep,vdso64as) # actual build commands -quiet_cmd_vdso64ld = VDSO64L $@ - cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@ quiet_cmd_vdso64as = VDSO64A $@ cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 17/24 s390/vdso: fix vDSO clock_getres()
In reply to Sasha LevinFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit 478237a595120a18e9b52fd2c57a6e8b7a01e411 ]
clock_getres in the vDSO library has to preserve the same behaviour of posix_get_hrtimer_res().
In particular, posix_get_hrtimer_res() does:
sec = 0;
ns = hrtimer_resolution;and hrtimer_resolution depends on the enablement of the high resolution timers that can happen either at compile or at run time.
Fix the s390 vdso implementation of clock_getres keeping a copy of hrtimer_resolution in vdso data and using that directly.
--- arch/s390/include/asm/vdso.h | 1 + arch/s390/kernel/asm-offsets.c | 2 +- arch/s390/kernel/time.c | 1 + arch/s390/kernel/vdso64/clock_getres.S | 10 +++++----- 4 files changed, 8 insertions(+), 6 deletions(-)
arch/s390/include/asm/vdso.h +1 -0
@@ -36,6 +36,7 @@ struct vdso_data {__u32 tk_shift;/* Shift used for xtime_nsec 0x60 */ __u32 ts_dir;/* TOD steering direction 0x64 */ __u64 ts_end;/* TOD steering end 0x68 */ +__u32 hrtimer_res;/* hrtimer resolution 0x70 */ };struct vdso_per_cpu_data {
arch/s390/kernel/asm-offsets.c +1 -1
@@ -76,6 +76,7 @@ int main(void)OFFSET (__VDSO_TK_SHIFT, vdso_data, tk_shift);OFFSET (__VDSO_TS_DIR, vdso_data, ts_dir);OFFSET (__VDSO_TS_END, vdso_data, ts_end); +OFFSET (__VDSO_CLOCK_REALTIME_RES, vdso_data, hrtimer_res);OFFSET (__VDSO_ECTG_BASE, vdso_per_cpu_data, ectg_timer_base);OFFSET (__VDSO_ECTG_USER, vdso_per_cpu_data, ectg_user_time);OFFSET (__VDSO_CPU_NR, vdso_per_cpu_data, cpu_nr);
@@ -87,7 +88,6 @@ int main(void)DEFINE (__CLOCK_REALTIME_COARSE,CLOCK_REALTIME_COARSE );DEFINE (__CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE );DEFINE (__CLOCK_THREAD_CPUTIME_ID,CLOCK_THREAD_CPUTIME_ID ); -DEFINE (__CLOCK_REALTIME_RES,MONOTONIC_RES_NSEC );DEFINE (__CLOCK_COARSE_RES,LOW_RES_NSEC );BLANK ();/* idle data offsets */
arch/s390/kernel/time.c +1 -0
@@ -310,6 +310,7 @@ void update_vsyscall(struct timekeeper *tk) vdso_data->tk_mult = tk->tkr_mono.mult; vdso_data->tk_shift = tk->tkr_mono.shift; + vdso_data->hrtimer_res = hrtimer_resolution;smp_wmb (); ++vdso_data->tb_update_count; }
arch/s390/kernel/vdso64/clock_getres.S +5 -5
@@ -17,12 +17,14 @@ .type __kernel_clock_getres,@function __kernel_clock_getres: CFI_STARTPROC - larl %r1,4f + larl %r1,3f + lg %r0,0(%r1) cghi %r2,__CLOCK_REALTIME_COARSE je 0f cghi %r2,__CLOCK_MONOTONIC_COARSE je 0f - larl %r1,3f + larl %r1,_vdso_data + llgf %r0,__VDSO_CLOCK_REALTIME_RES(%r1) cghi %r2,__CLOCK_REALTIME je 0f cghi %r2,__CLOCK_MONOTONIC
@@ -36,7 +38,6 @@ __kernel_clock_getres: jz 2f 0: ltgr %r3,%r3 jz 1f /* res == NULL */ - lg %r0,0(%r1) xc 0(8,%r3),0(%r3) /* set tp->tv_sec to zero */ stg %r0,8(%r3) /* store tp->tv_usec */ 1: lghi %r2,0
@@ -45,6 +46,5 @@ __kernel_clock_getres: svc 0 br %r14 CFI_ENDPROC -3: .quad __CLOCK_REALTIME_RES -4: .quad __CLOCK_COARSE_RES +3: .quad __CLOCK_COARSE_RES .size __kernel_clock_getres,.-__kernel_clock_getres
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 18/24 arm64: sve: Fix build failure when ARM64_SVE=y and SYSCTL=n
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit e575fb9e76c8e33440fb859572a8b7d430f053d6 ]
When I squashed the 'allnoconfig' compiler warning about the set_sve_default_vl() function being defined but not used in commit 1e570f512cbd ("arm64/sve: Eliminate data races on sve_default_vl"), I accidentally broke the build for configs where ARM64_SVE is enabled, but SYSCTL is not.
Fix this by only compiling the SVE sysctl support if both CONFIG_SVE=y and CONFIG_SYSCTL=y.
--- arch/arm64/kernel/fpsimd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/kernel/fpsimd.c +3 -3
@@ -349,7 +349,7 @@ static unsigned int find_supported_vector_length(unsigned int vl)return sve_vl_from_vq (__bit_to_vq (bit)); } -#ifdef CONFIG_SYSCTL +#if defined(CONFIG_ARM64_SVE ) && defined(CONFIG_SYSCTL ) static int sve_proc_do_default_vl(struct ctl_table *table, int write, void __user *buffer, size_t *lenp,
@@ -395,9 +395,9 @@ static int __init sve_sysctl_init(void) return 0; } -#else /* ! CONFIG_SYSCTL */ +#else /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ static int __init sve_sysctl_init (void ) {return 0 ; } -#endif /* ! CONFIG_SYSCTL */ +#endif /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ #define ZREG (sve_state, vq, n) ((char *)(sve_state) + \ (SVE_SIG_ZREG_OFFSET(vq, n) - SVE_SIG_REGS_OFFSET))
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 19/24 kbuild: improve cc-option to clean up all temporary files
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit f2f02ebd8f3833626642688b2d2c6a7b3c141fa9 ]
When cc-option and friends evaluate compiler flags, the temporary file $$TMP is created as an output object, and automatically cleaned up. The actual file path of $$TMP is .<pid>.tmp, here <pid> is the process ID of $(shell ...) invoked from cc-option. (Please note $$$$ is the escape sequence of $$).
Such garbage files are cleaned up in most cases, but some compiler flags create additional output files.
For example, -gsplit-dwarf creates a .dwo file.
When CONFIG_DEBUG_INFO_SPLIT=y, you will see a bunch of .<pid>.dwo files left in the top of build directories. You may not notice them unless you do 'ls -a', but the garbage files will increase every time you run 'make'.
This commit changes the temporary object path to .tmp_<pid>/tmp, and removes .tmp_<pid> directory when exiting. Separate build artifacts such as *.dwo will be cleaned up all together because their file paths are usually determined based on the base name of the object.
Another example is -ftest-coverage, which outputs the coverage data into <base-name-of-object>.gcno
--- scripts/Kbuild.include | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/Kbuild.include +6 -5
@@ -82,20 +82,21 @@ cc-cross-prefix = $(firstword $(foreach c, $(1), \ $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) # output directory for tests below -TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) +TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ # try-run # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) # Exit code chooses option. "$$TMP" serves as a temporary file and is # automatically cleaned up. try-run = $(shell set -e; \ - TMP="$(TMPOUT).$$$$.tmp"; \ - TMPO="$(TMPOUT).$$$$.o"; \ + TMP=$(TMPOUT)/tmp; \ + TMPO=$(TMPOUT)/tmp.o; \ + mkdir -p $(TMPOUT); \ + trap "rm -rf $(TMPOUT)" EXIT; \ if ($(1)) >/dev/null 2>&1; \ then echo "$(2)"; \ else echo "$(3)"; \ - fi; \ - rm -f "$$TMP" "$$TMPO") + fi) # as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 20/24 recordmcount: support >64k sections
In reply to Sasha LevinFrom: Sami Tolvanen <[email protected]>
[ Upstream commit 4ef57b21d6fb49d2b25c47e4cff467a0c2c8b6b7 ]
When compiling a kernel with Clang and LTO, we need to run recordmcount on vmlinux.o with a large number of sections, which currently fails as the program doesn't understand extended section indexes. This change adds support for processing binaries with >64k sections.
--- scripts/recordmcount.h | 98 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 6 deletions(-)
scripts/recordmcount.h +92 -6
@@ -29,6 +29,11 @@#undef has_rel_mcount#undef tot_relsize#undef get_mcountsym +#undef find_symtab +#undef get_shnum +#undef set_shnum +#undef get_shstrndx +#undef get_symindex#undef get_sym_str_and_relp#undef do_func#undef Elf_Addr
@@ -58,6 +63,11 @@# define __has_rel_mcount __has64_rel_mcount# define has_rel_mcount has64_rel_mcount# define tot_relsize tot64_relsize +# define find_symtab find_symtab64 +# define get_shnum get_shnum64 +# define set_shnum set_shnum64 +# define get_shstrndx get_shstrndx64 +# define get_symindex get_symindex64# define get_sym_str_and_relp get_sym_str_and_relp_64# define do_func do64# define get_mcountsym get_mcountsym_64
@@ -91,6 +101,11 @@# define __has_rel_mcount __has32_rel_mcount# define has_rel_mcount has32_rel_mcount# define tot_relsize tot32_relsize +# define find_symtab find_symtab32 +# define get_shnum get_shnum32 +# define set_shnum set_shnum32 +# define get_shstrndx get_shstrndx32 +# define get_symindex get_symindex32# define get_sym_str_and_relp get_sym_str_and_relp_32# define do_func do32# define get_mcountsym get_mcountsym_32
@@ -173,6 +188,67 @@ static int MIPS_is_fake_mcount(Elf_Rel const *rp)return is_fake; } +static unsigned int get_symindex (Elf_Sym const *sym,Elf32_Word const *symtab, +Elf32_Word const *symtab_shndx) +{ +unsigned long offset; +int index; + +if (sym->st_shndx !=SHN_XINDEX ) +return w2 (sym->st_shndx); + + offset = (unsigned long )sym - (unsigned long )symtab; + index = offset /sizeof (*sym); + +return w (symtab_shndx[index]); +} + +static unsigned int get_shnum (Elf_Ehdr const *ehdr,Elf_Shdr const *shdr0) +{ +if (shdr0 && !ehdr->e_shnum) +return w (shdr0->sh_size); + +return w2 (ehdr->e_shnum); +} + +static void set_shnum (Elf_Ehdr *ehdr,Elf_Shdr *shdr0,unsigned int new_shnum) +{ +if (new_shnum >=SHN_LORESERVE ) { + ehdr->e_shnum =0 ; + shdr0->sh_size =w (new_shnum); + }else + ehdr->e_shnum =w2 (new_shnum); +} + +static int get_shstrndx (Elf_Ehdr const *ehdr,Elf_Shdr const *shdr0) +{ +if (ehdr->e_shstrndx !=SHN_XINDEX ) +return w2 (ehdr->e_shstrndx); + +return w (shdr0->sh_link); +} + +static void find_symtab (Elf_Ehdr *const ehdr,Elf_Shdr const *shdr0, +unsigned const nhdr,Elf32_Word **symtab, +Elf32_Word **symtab_shndx) +{ +Elf_Shdr const *relhdr; +unsigned k; + + *symtab =NULL ; + *symtab_shndx =NULL ; + +for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) { +if (relhdr->sh_type ==SHT_SYMTAB ) + *symtab = (void *)ehdr + relhdr->sh_offset; +else if (relhdr->sh_type ==SHT_SYMTAB_SHNDX ) + *symtab_shndx = (void *)ehdr + relhdr->sh_offset; + +if (*symtab && *symtab_shndx) +break ; + } +} +/* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */ static int append_func(Elf_Ehdr *const ehdr, Elf_Shdr *const shstr,
@@ -188,10 +264,12 @@ static int append_func(Elf_Ehdr *const ehdr,char const *mc_name = (sizeof (Elf_Rela) == rel_entsize) ?".rela__mcount_loc" :".rel__mcount_loc" ; -unsigned const old_shnum =w2 (ehdr->e_shnum);uint_t const old_shoff =_w (ehdr->e_shoff);uint_t const old_shstr_sh_size =_w (shstr->sh_size);uint_t const old_shstr_sh_offset =_w (shstr->sh_offset); +Elf_Shdr *const shdr0 = (Elf_Shdr *)(old_shoff + (void *)ehdr); +unsigned int const old_shnum =get_shnum (ehdr, shdr0); +unsigned int const new_shnum =2 + old_shnum;/* {.rel,}__mcount_loc */ uint_t t =1 +strlen (mc_name) +_w (shstr->sh_size);uint_t new_e_shoff;
@@ -201,6 +279,8 @@ static int append_func(Elf_Ehdr *const ehdr, t += (_align & -t);/* word-byte align */ new_e_shoff = t; +set_shnum (ehdr, shdr0, new_shnum); +/* body for new shstrtab */ if (ulseek (sb.st_size,SEEK_SET ) <0 )return -1 ;
@@ -255,7 +335,6 @@ static int append_func(Elf_Ehdr *const ehdr,return -1 ; ehdr->e_shoff =_w (new_e_shoff); - ehdr->e_shnum =w2 (2 +w2 (ehdr->e_shnum));/* {.rel,}__mcount_loc */ if (ulseek (0 ,SEEK_SET ) <0 )return -1 ;if (uwrite (ehdr,sizeof (*ehdr)) <0 )
@@ -434,6 +513,8 @@ static int find_secsym_ndx(unsigned const txtndx,uint_t *const recvalp, unsigned int *sym_index, Elf_Shdr const *const symhdr, + Elf32_Word const *symtab, + Elf32_Word const *symtab_shndx, Elf_Ehdr const *const ehdr) { Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symhdr->sh_offset)
@@ -445,7 +526,7 @@ static int find_secsym_ndx(unsigned const txtndx,for (symp = sym0, t = nsym; t; --t, ++symp) {unsigned int const st_bind =ELF_ST_BIND (symp->st_info); -if (txtndx ==w2 (symp->st_shndx) +if (txtndx ==get_symindex (symp, symtab, symtab_shndx)/* avoid STB_WEAK */ && (STB_LOCAL == st_bind ||STB_GLOBAL == st_bind)) {/* function symbols on ARM have quirks, avoid them */
@@ -516,21 +597,23 @@ static unsigned tot_relsize(Elf_Shdr const *const shdr0,return totrelsz; } -/* Overall supervision for Elf32 ET_REL file. */ static int do_func (Elf_Ehdr *const ehdr,char const *const fname,unsigned const reltype) {Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w (ehdr->e_shoff) + (void *)ehdr); -unsigned const nhdr =w2 (ehdr->e_shnum); -Elf_Shdr *const shstr = &shdr0[w2 (ehdr->e_shstrndx)]; +unsigned const nhdr =get_shnum (ehdr, shdr0); +Elf_Shdr *const shstr = &shdr0[get_shstrndx (ehdr, shdr0)];char const *const shstrtab = (char const *)(_w (shstr->sh_offset) + (void *)ehdr);Elf_Shdr const *relhdr;unsigned k; +Elf32_Word *symtab; +Elf32_Word *symtab_shndx; +/* Upper bound on space: assume all relevant relocs are for mcount. */ unsigned totrelsz;
@@ -561,6 +644,8 @@ static int do_func(Elf_Ehdr *const ehdr, char const *const fname,return -1 ; } +find_symtab (ehdr, shdr0, nhdr, &symtab, &symtab_shndx); +for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) {char const *const txtname =has_rel_mcount (relhdr, shdr0, shstrtab, fname);
@@ -577,6 +662,7 @@ static int do_func(Elf_Ehdr *const ehdr, char const *const fname, result =find_secsym_ndx (w (relhdr->sh_info), txtname, &recval, &recsym, &shdr0[symsec_sh_link], + symtab, symtab_shndx, ehdr);if (result) goto out;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 21/24 kprobes: Suppress the suspicious RCU warning on kprobes
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 6743ad432ec92e680cd0d9db86cb17b949cf5a43 ]
Anders reported that the lockdep warns that suspicious RCU list usage in register_kprobe() (detected by CONFIG_PROVE_RCU_LIST.) This is because get_kprobe() access kprobe_table[] by hlist_for_each_entry_rcu() without rcu_read_lock.
If we call get_kprobe() from the breakpoint handler context, it is run with preempt disabled, so this is not a problem. But in other cases, instead of rcu_read_lock(), we locks kprobe_mutex so that the kprobe_table[] is not updated. So, current code is safe, but still not good from the view point of RCU.
Joel suggested that we can silent that warning by passing lockdep_is_held() to the last argument of hlist_for_each_entry_rcu().
Add lockdep_is_held(&kprobe_mutex) at the end of the hlist_for_each_entry_rcu() to suppress the warning.
--- kernel/kprobes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/kprobes.c +2 -1
@@ -326,7 +326,8 @@ struct kprobe *get_kprobe(void *addr)struct kprobe *p; head = &kprobe_table[hash_ptr (addr,KPROBE_HASH_BITS )]; -hlist_for_each_entry_rcu (p, head, hlist) { +hlist_for_each_entry_rcu (p, head, hlist, +lockdep_is_held (&kprobe_mutex)) {if (p->addr == addr)return p; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 22/24 blktrace: break out of blktrace setup on concurrent calls
In reply to Sasha LevinFrom: Luis Chamberlain <[email protected]>
[ Upstream commit 1b0b283648163dae2a214ca28ed5a99f62a77319 ]
We use one blktrace per request_queue, that means one per the entire disk. So we cannot run one blktrace on say /dev/vda and then /dev/vda1, or just two calls on /dev/vda.
We check for concurrent setup only at the very end of the blktrace setup though.
If we try to run two concurrent blktraces on the same block device the second one will fail, and the first one seems to go on. However when one tries to kill the first one one will see things like this:
The kernel will show these:
``` debugfs: File 'dropped' in directory 'nvme1n1' already present! debugfs: File 'msg' in directory 'nvme1n1' already present! debugfs: File 'trace0' in directory 'nvme1n1' already present! `` And userspace just sees this error message for the second call: ```
blktrace /dev/nvme1n1
BLKTRACESETUP(2) /dev/nvme1n1 failed: 5/Input/output error ```
The first userspace process #1 will also claim that the files were taken underneath their nose as well. The files are taken away form the first process given that when the second blktrace fails, it will follow up with a BLKTRACESTOP and BLKTRACETEARDOWN. This means that even if go-happy process #1 is waiting for blktrace data, we *have* been asked to take teardown the blktrace.
This can easily be reproduced with break-blktrace [0] run_0005.sh test.
Just break out early if we know we're already going to fail, this will prevent trying to create the files all over again, which we know still exist.
[0] https://github.com/mcgrof/break-blktrace
--- kernel/trace/blktrace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
kernel/trace/blktrace.c +13 -0
@@ -3,6 +3,9 @@* Copyright (C) 2006 Jens Axboe <[email protected]> * */ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/kernel.h> #include <linux/blkdev.h> #include <linux/blktrace_api.h>
@@ -495,6 +498,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,*/ strreplace (buts->name,'/' ,'_' ); +/* +* bdev can be NULL, as with scsi-generic, this is a helpful as +* we can be. +*/ +if (q->blk_trace) { +pr_warn ("Concurrent blktraces are not allowed on %s\n" , + buts->name); +return -EBUSY ; + } + bt =kzalloc (sizeof (*bt),GFP_KERNEL );if (!bt)return -ENOMEM ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 23/24 block: update hctx map when use multiple maps
In reply to Sasha LevinFrom: Weiping Zhang <[email protected]>
[ Upstream commit fe35ec58f0d339221643287bbb7cee15c93a5389 ]
There is an issue when tune the number for read and write queues, if the total queue count was not changed. The hctx->type cannot be updated, since __blk_mq_update_nr_hw_queues will return directly if the total queue count has not been changed.
Reproduce:
dmesg | grep "default/read/poll"
[ 2.607459] nvme nvme0: 48/0/0 default/read/poll queues
cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
48 default
tune the write queues to 24:
echo 24 > /sys/module/nvme/parameters/write_queues echo 1 > /sys/block/nvme0n1/device/reset_controller
dmesg | grep "default/read/poll"
[ 433.547235] nvme nvme0: 24/24/0 default/read/poll queues
cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
48 default
The driver's hardware queue mapping is not same as block layer.
--- block/blk-mq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-mq.c +3 -1
@@ -3279,7 +3279,9 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,if (set->nr_maps ==1 && nr_hw_queues > nr_cpu_ids) nr_hw_queues = nr_cpu_ids; -if (nr_hw_queues <1 || nr_hw_queues == set->nr_hw_queues) +if (nr_hw_queues <1 ) +return ; +if (set->nr_maps ==1 && nr_hw_queues == set->nr_hw_queues)return ;list_for_each_entry (q, &set->tag_list, tag_set_list)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 24/24 RISC-V: Don't allow write+exec only page mapping request in mmap
In reply to Sasha LevinFrom: Yash Shah <[email protected]>
[ Upstream commit e0d17c842c0f824fd4df9f4688709fc6907201e1 ]
As per the table 4.4 of version "20190608-Priv-MSU-Ratified" of the RISC-V instruction set manual[0], the PTE permission bit combination of "write+exec only" is reserved for future use. Hence, don't allow such mapping request in mmap call.
An issue is been reported by David Abdurachmanov, that while running stress-ng with "sysbadaddr" argument, RCU stalls are observed on RISC-V specific kernel.
This issue arises when the stress-sysbadaddr request for pages with "write+exec only" permission bits and then passes the address obtain from this mmap call to various system call. For the riscv kernel, the mmap call should fail for this particular combination of permission bits since it's not valid.
[0]: http://dabbelt.com/~palmer/keep/riscv-isa-manual/riscv-privileged-20190608-1.pdf
[Palmer: Refer to the latest ISA specification at the only link I could find, and update the terminology.]
--- arch/riscv/kernel/sys_riscv.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/riscv/kernel/sys_riscv.c +6 -0
@@ -8,6 +8,7 @@#include <linux/syscalls.h> #include <asm/unistd.h> #include <asm/cacheflush.h> +#include <asm-generic/mman-common.h> static long riscv_sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
@@ -16,6 +17,11 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len, {if (unlikely (offset & (~PAGE_MASK >> page_shift_offset)))return -EINVAL ; + +if ((prot &PROT_WRITE ) && (prot &PROT_EXEC )) +if (unlikely (!(prot &PROT_READ ))) +return -EINVAL ; +return ksys_mmap_pgoff (addr, len, prot, flags, fd, offset >> (PAGE_SHIFT - page_shift_offset)); }
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv