From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4DEB13AA4C; Tue, 27 Feb 2024 13:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042090; cv=none; b=uXiCYHMYlyHuTRJ9XjzM1YIoSte0Eniz/S7/IBVU9Ob4kdy1be/MuASmmVSmLRgooLnTuq6epJo3EePQJHygw41rEtNtONSJHrXGRFsu8F4yjJS5WmsHm2OHmMcjahjY5SMRnT/wbjGuj70rHKUXq2lm5e1EN+wZKEPcNz6z5FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042090; c=relaxed/simple; bh=TefFGeVuRzhjWXrhdt/feClCmcmPI6Nv9jhDeENy0x0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bTvsFYOulx9W3g18XiRgvGrpxl3G5/5jDDLEIcIckNRs0POnCtCfpXFGngqOpb5s3GZT8j8XlaYoh/7glx+IHle1QGlFhkBl56QQURISxXZNIyyCmBhR6rc51WjZgNl8zK8oPRhIBy3mhqqUz/T4OP4hweqPXlgcxeFbohRAKEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FuRZNI3N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FuRZNI3N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61112C433F1; Tue, 27 Feb 2024 13:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709042090; bh=TefFGeVuRzhjWXrhdt/feClCmcmPI6Nv9jhDeENy0x0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuRZNI3N5o7apcncgd892sV26uQAfO52Ylom3wY4ZpABa0o+9h3xH0VDJyioaCyVl h9GISwUrRWPoFsO/wmFd3tcyrXRDzzqnsZKhLFiSG/RndMs9rXCalta2enly6SruMS OwKlkfSvp13vvWHLANTQuE5NtjM/TW3+8cdiafqo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vidya Sagar , Thomas Gleixner , Shanker Donthineni Subject: [PATCH 6.6 175/299] PCI/MSI: Prevent MSI hardware interrupt number truncation Date: Tue, 27 Feb 2024 14:24:46 +0100 Message-ID: <20240227131631.468137032@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131625.847743063@linuxfoundation.org> References: <20240227131625.847743063@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vidya Sagar commit db744ddd59be798c2627efbfc71f707f5a935a40 upstream. While calculating the hardware interrupt number for a MSI interrupt, the higher bits (i.e. from bit-5 onwards a.k.a domain_nr >= 32) of the PCI domain number gets truncated because of the shifted value casting to return type of pci_domain_nr() which is 'int'. This for example is resulting in same hardware interrupt number for devices 0019:00:00.0 and 0039:00:00.0. To address this cast the PCI domain number to 'irq_hw_number_t' before left shifting it to calculate the hardware interrupt number. Please note that this fixes the issue only on 64-bit systems and doesn't change the behavior for 32-bit systems i.e. the 32-bit systems continue to have the issue. Since the issue surfaces only if there are too many PCIe controllers in the system which usually is the case in modern server systems and they don't tend to run 32-bit kernels. Fixes: 3878eaefb89a ("PCI/MSI: Enhance core to support hierarchy irqdomain") Signed-off-by: Vidya Sagar Signed-off-by: Thomas Gleixner Tested-by: Shanker Donthineni Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240115135649.708536-1-vidyas@nvidia.com Signed-off-by: Greg Kroah-Hartman --- drivers/pci/msi/irqdomain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -61,7 +61,7 @@ static irq_hw_number_t pci_msi_domain_ca return (irq_hw_number_t)desc->msi_index | pci_dev_id(dev) << 11 | - (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; + ((irq_hw_number_t)(pci_domain_nr(dev->bus) & 0xFFFFFFFF)) << 27; } static void pci_msi_domain_set_desc(msi_alloc_info_t *arg,