From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D675C4360F for ; Wed, 20 Mar 2019 20:19:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D52F921873 for ; Wed, 20 Mar 2019 20:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553113156; bh=RU4zAV8PB0MJfTPEpJL0Z9XnHjxVEaLzvzn0uifcNPM=; h=Subject:To:Cc:From:Date:List-ID:From; b=CG+ml0OBFI0UASOWmXEjbNrVglOSBVpxgzQRyK2fFOkJfuIFfv9jtHFPHpXpKHBKr sPHCzdnB4PYwt+Xn2NTbzJWlaNQNSEOXdFJtCSFxjHwC8GMCot2mZTBa3iRdcSAfwA 3Un6SsUxVpxrhNr9wCZhLJcil0WhCPz0keqcNKJ8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbfCTUTQ (ORCPT ); Wed, 20 Mar 2019 16:19:16 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:54053 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbfCTUTQ (ORCPT ); Wed, 20 Mar 2019 16:19:16 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2F278222C9; Wed, 20 Mar 2019 16:19:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 20 Mar 2019 16:19:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=x+CEWA BobN3wPzCLuJkhRf10CriNr7C5FecX9neZc6c=; b=eQIRHPeWUFlm6Q7V75Uhi3 7DOcvWXXXOD0rmveh3Z/OGwpveC+LEVqNt+zRPsVV1ECenGYBqW+n4bo9k6ZzW2t KlAxDop/v8V6/G3eDWCFOQZgRVnSNzyhe/snOudJq1Eqo0mdLo70cstsx9GodaRi Wsb9K3+oY/9hwADP7cjJRyXlJdyzKsqDioasVegq4Bkkdbi/xv/a0rVP9vHNoLHL DGM9dFSfMLzQwyF1aFI5mQgKRsINt9eeLbwOlSQzvq9JlH7ZOayl9rMKA0iTkil1 2mioqBonDqMWTAavyWq3AfC9vdyNE7txVe+j8mehHpq8iIu/PvZN0tSjHW3evenQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrieeigddufeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrhhomh epghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 7CDCEE4360; Wed, 20 Mar 2019 16:19:14 -0400 (EDT) Subject: FAILED: patch "[PATCH] iommu/vt-d: Check identity map for hot-added devices" failed to apply to 4.14-stable tree To: baolu.lu@linux.intel.com, ashok.raj@intel.com, fenghua.yu@intel.com, jacob.jun.pan@linux.intel.com, jisben@google.com, jroedel@suse.de, xmdong@google.com Cc: From: Date: Wed, 20 Mar 2019 21:19:11 +0100 Message-ID: <1553113151207211@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.14-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 117266fd59ddf46e98e36df09326d861738c6180 Mon Sep 17 00:00:00 2001 From: Lu Baolu Date: Mon, 25 Feb 2019 10:46:36 +0800 Subject: [PATCH] iommu/vt-d: Check identity map for hot-added devices The Intel IOMMU driver will put devices into a static identity mapped domain during boot if the kernel parameter "iommu=pt" is used. That means the IOMMU hardware will translate a DMA address into the same memory address. Unfortunately, hot-added devices are not subject to this. That results in some devices not working properly after hot added. A quick way to reproduce this issue is to boot a system with iommu=pt and, remove then readd the pci device with echo 1 > /sys/bus/pci/devices/[pci_source_id]/remove echo 1 > /sys/bus/pci/rescan You will find the identity mapped domain was replaced with a normal domain. Cc: Ashok Raj Cc: Jacob Pan Cc: Fenghua Yu Cc: stable@vger.kernel.org Reported-by: Jis Ben Signed-off-by: Lu Baolu Tested-by: James Dong Fixes: 99dcadede42f ('intel-iommu: Support PCIe hot-plug') Signed-off-by: Joerg Roedel diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 00f46021d690..c30b73d41bf2 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -4567,16 +4567,19 @@ static int device_notifier(struct notifier_block *nb, if (iommu_dummy(dev)) return 0; - if (action != BUS_NOTIFY_REMOVED_DEVICE) - return 0; - - domain = find_domain(dev); - if (!domain) - return 0; + if (action == BUS_NOTIFY_REMOVED_DEVICE) { + domain = find_domain(dev); + if (!domain) + return 0; - dmar_remove_one_dev_info(dev); - if (!domain_type_is_vm_or_si(domain) && list_empty(&domain->devices)) - domain_exit(domain); + dmar_remove_one_dev_info(dev); + if (!domain_type_is_vm_or_si(domain) && + list_empty(&domain->devices)) + domain_exit(domain); + } else if (action == BUS_NOTIFY_ADD_DEVICE) { + if (iommu_should_identity_map(dev, 1)) + domain_add_dev_info(si_domain, dev); + } return 0; }