Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbdLSPOX (ORCPT ); Tue, 19 Dec 2017 10:14:23 -0500 Received: from mail-sn1nam02on0045.outbound.protection.outlook.com ([104.47.36.45]:58585 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752378AbdLSPOT (ORCPT ); Tue, 19 Dec 2017 10:14:19 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tomasz.Nowicki@cavium.com; From: Tomasz Nowicki To: joro@8bytes.org, robin.murphy@arm.com, will.deacon@arm.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com Cc: Jayachandran.Nair@cavium.com, Ganapatrao.Kulkarni@cavium.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, mw@semihalf.com, stable@vger.kernel.org, Tomasz Nowicki Subject: [PATCH V1 0/1] Fix kernel panic caused by device ID duplication presented to the IOMMU Date: Tue, 19 Dec 2017 16:13:55 +0100 Message-Id: <1513696436-31834-1-git-send-email-tomasz.nowicki@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [12.108.191.226] X-ClientProxiedBy: MWHPR17CA0087.namprd17.prod.outlook.com (2603:10b6:300:c2::25) To SN4PR0701MB3662.namprd07.prod.outlook.com (2603:10b6:803:4d::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2ad1bf38-c8a5-4eb1-7d05-08d546f32b8d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307);SRVR:SN4PR0701MB3662; X-Microsoft-Exchange-Diagnostics: 1;SN4PR0701MB3662;3:u4hEEnWwfCQqT0hvMpqM9Bg0+CuL3jI6ok7MUKqf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bgtHUpflG9jvB4/VuFzJpF0+EmB86VXAT7r7ps0b5k8kEABIK3PFP9WKqA0zzkC3FRTnBYiCb7AaMVN3VlpQ0IaSEB2IazBIoaqwcLTaqdRYUgoI3hhqHfl6viBX+pyFqj7MHwXgxT04KvWVc1bFWRff6ugD8kOeau/yT1AG1FtsUWdqeVddgldnHdx7ipyyvS/vxN5boUizuSgZLgQCh1cLawB2jtdEQIE0WgJ+gCNgH3rH+wOc1zjldJIWoyZnJZIETiSzhw4h0O+rIjNfSVWdqU++ODyQGGrHJ/j+kOH3Ns3d7W8+8EaVDEDM7MdbvveengW7KaW6jGdsfeVDmaNLsUKUrsd3Sw4CPoFhUpJh1Y7yRx8tpWJGA6uaa6/5vutkTFQhA4XVLIwW8qfbwhpL8OE=;4:mgmWGeUTbya7GccToYyrdSYiAxE+1auIeiezl8d1ggQNfd2qbLCINoof5s2DoN3Zdclkurfuy4TE0xk4Oahv28iKV2ktEMbR+dFEwkgU/1n9iZYtQtrQV8myb9S7ydfylSUmlMXvalryVnt/hAL2rYh1yVMEPxdeuxm+s1ILaUmEIpHyEejZ7KE6ArEpuHnKAc4+dfe+UiFnOyEbfzCUMIz3k+n3tjo5wWvr7ClxXF5hb+Rjy6BlaGtI8oHIUiqgaZzzKfabKFgeor955BaWFCZrTU9RQVm0jAGZIEvj2CQ61dLTJ7rRsVQpFRlxPfdU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3231023)(3002001)(93006095)(10201501046)(6041248)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(201708071742011);SRVR:SN4PR0701MB3662;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:SN4PR0701MB3662; X-Forefront-PRVS: 052670E5A4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(376002)(39850400004)(396003)(346002)(199004)(189003)(478600001)(66066001)(16586007)(316002)(6486002)(36756003)(4326008)(2906002)(25786009)(72206003)(6512007)(105586002)(6666003)(16526018)(5660300001)(107886003)(42882006)(68736007)(51416003)(53936002)(106356001)(305945005)(7736002)(97736004)(47776003)(50466002)(81156014)(8676002)(6116002)(3846002)(7416002)(50226002)(52116002)(8936002)(6506007)(386003)(48376002)(81166006)(551934003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN4PR0701MB3662;H:desktop.semihalf.local;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN4PR0701MB3662;23:1fOeqpLbiHsPI511iCNwtOdGnHOFnUeeqHqR+c+?= =?us-ascii?Q?pn7XEhPk0fCiNVvFQjH3hOkPe27q64q0MeKt8oNfrMU1Kcs39AfjNPipJXim?= =?us-ascii?Q?6PCm9+6w+25u8yJ8BslZbzwqlHbQ6qeo5daJC1BA+3mxNNiuelKX3xp3LB4y?= =?us-ascii?Q?bXeN52koL5Wvi/KYA32nkRRZLW9Yt+lvc2r8X96QqLhqHAg+YTzMKjdhskVm?= =?us-ascii?Q?DQcy9LboWscyEaRMWwKL0J323rKebZRwRcNDMWlbpMU2eG+ykzzsMbPW3q4m?= =?us-ascii?Q?F8KIeqBQDL/2CflTNlTIx7Ku+aDEjDqqkjPznOlONWTpqY7irEX4gLZcJGho?= =?us-ascii?Q?8JaXs+oHgVAmIr9qd5wHinWC5/7/FoMqW8qOaxIhdcHCwh5u6RljCnmH2NTM?= =?us-ascii?Q?7dObbt8EdS75phjqQu+GlU2QSVGQG1gIbk7B1MAxFzWphyTUVhltdoYFrABM?= =?us-ascii?Q?HJT5zgQ3FYit/oJbebVEEXMWC03NqmPZCba/wydMoLGW5ZcQ8n9FB0hQLzby?= =?us-ascii?Q?J3MKdRfHaNm1UcSfNOSzjvcn0EtKrzgyFidz+2SlRgI0h4zONQZ2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KZqxO0+/KAHNmiAVkXyzRxE5O5UKKDnwnMKyL2MP2SU01jgHrZU5lvhi8KhviH6tt4Vj9NWGQoWabZL7+m/w7myK0r0z28NFttPefIku87YXIWuh9JSEmquK+oLk1M=;24:ngabs5yrF7d6rpIOHJ0cRyXxrCecN1GG1zy3O+8uv5xIMVHauoH0iRugqRSJivUVthbE8cymZDdESHkzXFI4JYCbzvdRMvFCJy8oVi6uE3w=;7:baAcrLS2SQByx6Nd5ob7MDfyqZEfsa/fexdlJRPlHtgQrYeuO0WrdkvE5dguO7NfLJyRnm8H2OBPrRyd7dOj8iKVMnyrE3yVy2USf8Xz75eY8ZwT6qq0Wn4TLV5I7lnsnK0zfuZ5FIp2/Ey4Xr1GTV6iZArGPHmxQwC1YyDgt7GcSfRyo9zOtN9YnGh+SCZIB0jXh4pnxvRkph/yNAUVKBrOiVfgP/nAFSZ++ZtJ86XYaaLhMd/bh2paMiHu/Cu3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2017 15:14:12.2764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ad1bf38-c8a5-4eb1-7d05-08d546f32b8d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0701MB3662 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1542 Lines: 33 Here is my lspci output of ThunderX2 for which I am observing kernel panic coming from SMMUv3 driver -> arm_smmu_write_strtab_ent() -> BUG_ON(ste_live): # lspci -vt -[0000:00]-+-00.0-[01-1f]--+ [...] + [...] \-00.0-[1e-1f]----00.0-[1f]----00.0 ASPEED Technology, Inc. ASPEED Graphics Family ASP device -> 1f:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family PCI-Express to PCI/PCI-X Bridge -> 1e:00.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge While setting up ASP device SID in IORT dirver: iort_iommu_configure() -> pci_for_each_dma_alias() we need to walk up and iterate over each device which alias transaction from downstream devices. AST device (1f:00.0) gets BDF=0x1f00 and corresponding SID=0x1f00 from IORT. Bridge (1e:00.0) is the first alias. Following PCI Express to PCI/PCI-X Bridge spec: PCIe-to-PCI/X bridges alias transactions from downstream devices using the subordinate bus number. For bridge (1e:00.0), the subordinate is equal to 0x1f. This gives BDF=0x1f00 and SID=1f00 which is the same as downstream device. So it is possible to have two identical SIDs. The question is what we should do about such case. Presented patch prevents from registering the same ID so that SMMUv3 is not complaining later on. Tomasz Nowicki (1): iommu: Make sure device's ID array elements are unique drivers/iommu/iommu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- 2.7.4