Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp45152lqb; Tue, 4 Jun 2024 04:46:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWgNIpVYkZDK/y1Imm5IrlwP7FMj5D/ZY8lIjghKZZLYnT74fadytSPB9exwt3RhyZuDU8xqmp4aXTy580tXRuNcTsII7X0IDtTwKziVw== X-Google-Smtp-Source: AGHT+IEZTHhxdvtjPcwjyeeq4RlITWFTQshQoQhqGIrdpnliXqjvG/YQG3Y1eyjSBD+inSotCX+Y X-Received: by 2002:a05:6870:f116:b0:250:6c44:89fb with SMTP id 586e51a60fabf-2508bfb574cmr12983024fac.39.1717501616658; Tue, 04 Jun 2024 04:46:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717501616; cv=pass; d=google.com; s=arc-20160816; b=bvvQDz3UteIo17J0icchrxNeQ8Q0fOnPeOZ/V0+4A+N2qUW0VpD7iFkY07iihOhyme dEp802pGlL6OXT+DYFnpULC0jt3xt3UALJ+ATFW4cwbK86nLVNbIVjfcBXEI9e4EVFQY xqUYeAO+9DPDKVMBHcs6FYiT2hrh8LNXEsD4MwkBUXjAHQWCnMx7XyFwU8+h82x2all4 GOSqHNLxOHCBTImQlE9/Rf7y2dxzNmfpkEAVG2bZneK4845/8UDYhG1kZbuOc0MnCzJA 49yY1WL0zOd3+V/TxPSaM1xyqHVdVxxIRQXfeai1knY67s9G2MJuWT+194ULzwuFN8/f cl0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=eclg86AE2/u0gwM+g9OJoInB2BaG2HDZXaHAInPzQE8=; fh=uGlf/NJfXJMV+ywNuegw6cW+XvW7L7LANK4Ag8yS5/A=; b=UjcMtL8MovmdcgVJhH4+8yTXOdbUP7JOImlL8oYur2uPwG68cGsrbT0SX1aUvhmwVZ T8Q0PFZY2sBfiIkMkmafpg7B0Lm/xmhwb0xeO2RD+e3o0pLbjlKRd2acdlMvTqUN4jtI lkzB4qWsD1nxxEuLa/uT4WXBa36b7wJMcBByhXF5d1Cok42j7hj67V58f7WqRk8rvphk a7HAz6ZlKKxw+r9GFNURiofeGxPcoNIE6DEknZvkAYkpdHPm4G15C8ag8yUTvrRZxvqs Hsptt/DuIc7wkrDjA8Fauuz78ha2NsKGvceTPMb+DnRVb6gkvMeL0FAvaHMEIEFZV87J 9c0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-200533-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200533-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6ce545e953csi3320520a12.73.2024.06.04.04.46.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 04:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200533-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-200533-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200533-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 487FE282E8F for ; Tue, 4 Jun 2024 11:46:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDCE7145A14; Tue, 4 Jun 2024 11:46:10 +0000 (UTC) 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: 8bit '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 --- 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