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,URIBL_BLOCKED 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 B3CB9C4360F for ; Wed, 20 Mar 2019 20:19:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 887B72184D for ; Wed, 20 Mar 2019 20:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553113163; bh=K4SS65a/PVhCpymL0qzuqdehs7uhKayOWumk6Ycq74U=; h=Subject:To:Cc:From:Date:List-ID:From; b=awzwQ45pE9sAwCfPd0cmczjzlhvHkuFovuuZxn9yq3OVmy++JSuCOsGjdD026e6CE zRhBWlQG6x4H3IEFf9APHtm9SeCQDwvohEGPNNI2o2UlDjQioGOm67Syw9B71O94OO RWYJUNzfhVL59w5tToR4OnvYnw/E0dV4sIruwqZ4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbfCTUTX (ORCPT ); Wed, 20 Mar 2019 16:19:23 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:38333 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727405AbfCTUTW (ORCPT ); Wed, 20 Mar 2019 16:19:22 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AA83423C9A; Wed, 20 Mar 2019 16:19:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 20 Mar 2019 16:19:21 -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=285N7i j7EYYuqXA/IFSUctUn/nHdGhEO0meCtbL4ND0=; b=r2hpnVdUqKL2yF2okLwULB 06Q5F490ZgWILGp7w8Jx7KSfqzxJBXWC29yh8msrrWnv7Y+tLx0aIbc61u2qF9VS uuZXEFdvxOHdot44/PuM2lcxRxKHrbAY4SCnsTi17RPVEnEmGLr7dT644dzT3gfJ fZXcGhuuvLNF6aChY6i4geVzT5TMN/5mHexv6cEjYGFvvFmelFuncL7F72BQl/BP BSzeDmYgHULzX/Q2AY/rIMU1z6wvUgG3BOc7pxobnZGX+xLO4t21ja0uKl06pEfF Err18N1YtfwH3s8gVmeBW5hqAp2w83qTJR6GgnRr3mr6OFsuSEl0tCochQBIQWvg == 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 02C91E44D7; Wed, 20 Mar 2019 16:19:20 -0400 (EDT) Subject: FAILED: patch "[PATCH] iommu/vt-d: Check identity map for hot-added devices" failed to apply to 4.4-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:13 +0100 Message-ID: <155311315315198@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.4-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; }