From nobody Fri Feb 13 01:43:51 2026 Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 3D88C145350; Tue, 4 Jun 2024 11:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717501570; cv=none; b=V+EZGDqDmr6yNtJsBUkSe9RwMdlZUcKRVHzFzEi8iET2bpqe4C1cz1n+75XUsVT6+qNRmk08AY43x/m4vh0GqzX84OTDO/rHrNaT7DmWBhjaQjNg72nRj0F/qzwOSYtijxYj8O3+ezh/gD9ZRItYKYLIIKPKLfWahiJQqQkoOYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717501570; c=relaxed/simple; bh=p6de8ISvGtQYeLkdgHcT+UhUuBgzjaRIyC6F/0qCGvI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=LYZ5C8UTpTSUYd6pUiewcSEjfK9Ud3RkcQKWDX4+73P9G47RxuW2qSye1cjZHz9Q3x7+xa2YKI0MdYe7vYDBmLoA1cUeRyiZl+kTAolJuDSMlHtNn+JU76KIhCJ6ySNIh1YhCHK3+dlrf6QDZ6ayHJssW2vntIAewakKfU2FpF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id A0ABB606E3AC4; Tue, 4 Jun 2024 19:45:54 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org, robin.murphy@arm.com Cc: Su Hui , tglx@linutronix.de, jiang.liu@linux.intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] iommu/amd: avoid possible wrong value of 'hwirq' in irq_remapping_alloc() Date: Tue, 4 Jun 2024 19:45:23 +0800 Message-Id: <20240604114522.2630682-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'devid' is type of int, but 'irq_data->hwirq' is unsigned long. When 'devid' >=3D 0xf000, hwirq will have a error value in 64 bit machine. For example: (unsigned long)((int)0xf000 << 16) =3D 0xfffffffff0000000 (unsigned long)((unsigned int)0xf000 << 16) =3D 0xf0000000 Add a cast to fix this problem. Fixes: 7c71d306c97b ("irq_remapping/amd: Enhance AMD IR driver to support h= ierarchical irqdomains") Signed-off-by: Su Hui --- 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 *dom= ain, unsigned int virq, } =20 data->iommu =3D iommu; - irq_data->hwirq =3D (devid << 16) + i; + irq_data->hwirq =3D ((irq_hw_number_t)devid << 16) + i; irq_data->chip_data =3D data; irq_data->chip =3D &amd_ir_chip; irq_remapping_prepare_irte(data, cfg, info, devid, index, i); --=20 2.30.2