From e6bf4f8b3178be2e5b6432f16f969cb6571eda8f Mon Sep 17 00:00:00 2001 From: Zou Cao Date: Fri, 12 Jul 2019 08:44:52 +0800 Subject: [PATCH] alinux: hinic: panic when reading back he IRQ affinity hint It is wrong for using stack variable to store the current code sets an affinity hint, it will cause a panic or returning corrupt data. So this patch moves the mask local variable into hinic_rq struct to avoid this situation. Backtrace: Internal error: Oops: 96000007 [#1] SMP Process irqbalance (pid: 1464, stack limit = 0x000000009bc2bec4) CPU: 35 PID: 1464 Comm: irqbalance Tainted: G W pstate: 00400089 (nzcv daIf +PAN -UAO) pc : __memcpy+0x44/0x180 lr : irq_affinity_hint_proc_show+0x9c/0x100 sp : ffff00002cb7bb60 x29: ffff00002cb7bb60 x28: 0000ffff9f6d9000 x27: ffff803f27cef9c0 x26: ffff00002cb7be30 x25: 0000000000000400 x24: ffff803f290e7000 x23: 0000000000000000 x22: ffff803f27cef980 x21: ffff000009009000 x20: ffff802fb9f01000 x19: ffff00002cb7bba8 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 x8 : 0000000000000000 x7 : 0000000000000000 x6 : ffff00002cb7bba8 x5 : ffff802fb9f01000 x4 : 0000000000000008 x3 : ffff802fb9f01194 x2 : 0000000000000078 x1 : ffff000027d2b8b8 x0 : ffff00002cb7bba8 Call trace: __memcpy+0x44/0x180 seq_read+0x1b4/0x45c proc_reg_read+0x7c/0xb8 __vfs_read+0x58/0x190 vfs_read+0x94/0x154 ksys_read+0x68/0xd8 __arm64_sys_read+0x28/0x34 el0_svc_common+0xe8/0x19c el0_svc_handler+0x78/0x94 el0_svc+0x8/0xc Code: 36100064 b8404423 b80044c3 36180064 (f8408423) ---[ end trace b2cae62a9c2d153f ]--- Signed-off-by: Zou Cao Reviewed-by: Baoyou Xie --- drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h | 1 + drivers/net/ethernet/huawei/hinic/hinic_rx.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h index 6c84f83ec283..8b1580670591 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h @@ -115,6 +115,7 @@ struct hinic_rq { u16 *pi_virt_addr; dma_addr_t pi_dma_addr; + cpumask_t mask; }; struct hinic_qp { diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c index 06b24a92ed7d..8b0d6a6631cc 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -414,7 +414,6 @@ static int rx_request_irq(struct hinic_rxq *rxq) struct hinic_hwdev *hwdev = nic_dev->hwdev; struct hinic_rq *rq = rxq->rq; struct hinic_qp *qp; - struct cpumask mask; int err; rx_add_napi(rxq); @@ -431,8 +430,8 @@ static int rx_request_irq(struct hinic_rxq *rxq) } qp = container_of(rq, struct hinic_qp, rq); - cpumask_set_cpu(qp->q_id % num_online_cpus(), &mask); - return irq_set_affinity_hint(rq->irq, &mask); + cpumask_set_cpu(qp->q_id % num_online_cpus(), &rq->mask); + return irq_set_affinity_hint(rq->irq, &rq->mask); } static void rx_free_irq(struct hinic_rxq *rxq) -- GitLab