[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240604114522.2630682-1-suhui@nfschina.com>
Date: Tue, 4 Jun 2024 19:45:23 +0800
From: Su Hui <suhui@...china.com>
To: joro@...tes.org,
suravee.suthikulpanit@....com,
will@...nel.org,
robin.murphy@....com
Cc: Su Hui <suhui@...china.com>,
tglx@...utronix.de,
jiang.liu@...ux.intel.com,
iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH] iommu/amd: avoid possible wrong value of 'hwirq' in irq_remapping_alloc()
'devid' is type of int, but 'irq_data->hwirq' is unsigned long.
When 'devid' >= 0xf000, hwirq will have a error value in 64 bit machine.
For example:
(unsigned long)((int)0xf000 << 16) = 0xfffffffff0000000
(unsigned long)((unsigned int)0xf000 << 16) = 0xf0000000
Add a cast to fix this problem.
Fixes: 7c71d306c97b ("irq_remapping/amd: Enhance AMD IR driver to support hierarchical irqdomains")
Signed-off-by: Su Hui <suhui@...china.com>
---
drivers/iommu/amd/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 52d83730a22a..934738dfc8ea 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3506,7 +3506,7 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
}
data->iommu = iommu;
- irq_data->hwirq = (devid << 16) + i;
+ irq_data->hwirq = ((irq_hw_number_t)devid << 16) + i;
irq_data->chip_data = data;
irq_data->chip = &amd_ir_chip;
irq_remapping_prepare_irte(data, cfg, info, devid, index, i);
--
2.30.2
Powered by blists - more mailing lists