From patchwork Mon Sep 17 03:03:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 146832 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3279794ljw; Sun, 16 Sep 2018 20:18:33 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbw+O+jHSLrEYHPw1ypwjmdwbzg9YkbbkfXpsE0C27DCQq5oOMfwLLxadHDDZWGcmZHBiUm X-Received: by 2002:aa7:860b:: with SMTP id p11-v6mr23689227pfn.247.1537154313382; Sun, 16 Sep 2018 20:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154313; cv=none; d=google.com; s=arc-20160816; b=U7dDNK4zdAQzmR/ThrqUvjkodSsFWB9uLAccVm/vlYkTH3mhnPmAAq8h9B9VoCI3qJ e0I9j/USxYKE2+cRgF9ZKHQQ55HQYAC6kq8yeUoidN/MQp7zxpcKvMj11up8JN+Fa+qo I36s3FEU9Y+Nos4yLvOqOlXE9Ss5iU0eSmnt3FT52t2ewkHyZcUxkCIQ2z0AohkRt1nb jm+84gQUune9Wz/YutUgvoCkMh+YYHfyYWSoTQU/foftSmG0oFcG6au5hBSW0Ai6c+Yc lnl3xzgQxeYmee2zZWbn743mftBUcT33lG6UvJZKOiDK5vmtBG+kBsotgw89B9usCHdo Q/Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=Z0ncOjyrafHCJq+/q7ztZPu7s7yrwhopdsbKhZMQ/mo=; b=woppqvVTg+E8kMe9GXMDOQWgp+0PMpNfTchH9LkHDmkFc/kUHUNw/iyB9aTpVv+H8B SSEZc4cNuOYXJj14cZfmOHlDw4vXJPmyCk0qTyS3yAX1k8/WH6uwjvTbgc0nKN9mj0G1 ktNGprGw+vowf42r8htcq3VaCPZEb0FqwBkfBn3vKmTMQ1opWY56uw2dO6xKCJBh7Jqx 14cD7TrwFLGO4xdyYYdo4NQHG+uCZrbsX02gcKDPYnvRHkshgWwuh33kICd/9BaBgXn+ qEZm819LtIzV5WNAuSLxPCtsxYgooduBW7v/hwGuRix2PAE7PO5FcUdy5K1dLRWUgWYK G8WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b="k/nGr6lL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m29-v6si15345560pgl.304.2018.09.16.20.18.33; Sun, 16 Sep 2018 20:18:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b="k/nGr6lL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730665AbeIQIa7 (ORCPT + 32 others); Mon, 17 Sep 2018 04:30:59 -0400 Received: from mail-eopbgr690134.outbound.protection.outlook.com ([40.107.69.134]:52946 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730105AbeIQIa6 (ORCPT ); Mon, 17 Sep 2018 04:30:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z0ncOjyrafHCJq+/q7ztZPu7s7yrwhopdsbKhZMQ/mo=; b=k/nGr6lLsd2+BRUnvLXZa7idczNcwelnNGn+zqkjWfacTFW80yEeqFqmKI1Sv76I7/xp/AVw2uhG/rPnQPI8svC4hAM714b/d7RKzv/1e80ScsAXx+9B2RDQRppOBmFEzMniToNfzf83yuDxRTtv202lbC2oh79WfM4ZdNB9wNM= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0120.namprd21.prod.outlook.com (10.173.189.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.4; Mon, 17 Sep 2018 03:05:37 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1185.003; Mon, 17 Sep 2018 03:05:37 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Sudeep Holla , Sebastian Reichel , Sebastian Reichel , Sasha Levin Subject: [PATCH AUTOSEL 4.9 07/57] power: vexpress: fix corruption in notifier registration Thread-Topic: [PATCH AUTOSEL 4.9 07/57] power: vexpress: fix corruption in notifier registration Thread-Index: AQHUTjMNWIR4bA6t60CLtpiSJiXfIw== Date: Mon, 17 Sep 2018 03:03:48 +0000 Message-ID: <20180917030340.378-7-alexander.levin@microsoft.com> References: <20180917030340.378-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030340.378-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR21MB0120; 6:QYjzH+oCqPM3XAHYH27WM3L8McLLAE8S+Uf61jjRYsZvtYicaNVENzgpqrHSgFEpW17F87KokftOqxS8qBiEqR6r/zLZhGJpV/chGyOW7AKV+U3ooqzVkgXfVZHIcF75jeknKphHAnxYVd9a/SRP86HCixBtTAimqqNEFa2OKgGpOrI3RiMD2TPuZ3bQykokaeZZTeRWHXMweCp7vNdcuzgHLUyu6glarM4i5NHeNCGFWOHRWlkFmbzhhMg/0J+Zlw/3k8WDevKnF2fFhiEH19yjqRR5gebP5jvAc3KV+BeqE5yuJhEdyrwyETtqlhTox7Zh/aT2xzmSnzfJhUP5rXLOA9WGuGzS/mMfmYsh6Tm9Jz1yWIEjF75TJH4PKb+CsoRCOH+0xJh1uaKUYqiek6MSNQZI0CFtWZJTpPxJFiYnCW1ezWCQdqLlHbY0qeLc/Jbww+Ky3wqsRTSgfcdkfQ==; 5:aSiqcN2Mftx8UwEela2HWYFL4DhVmKg98z4Y80Cl1ilSqkQOM62bGOj17lunqEmd7jqF1a3iUWMLqkKYzRMejrEPSI5Z5E5FCRjonMJoq9N/91zOPlO9NLtRj8ylpBde+3cOkoCxZ6ddEsBFAN6FVz3jcDH1FoP+3NQQ2hzSfQw=; 7:V7JwljVKP35HSJ39G6FYmTar85qTi67UdH2oKfVwXJftPNYchvs/0lb82N/6iySp0HxT+YH63x9lFYF0O3uQz34mKAar+cHJ/8DSiy/5eLYK3lnBHvveqm1smXDatFVGVl/nAvk1AlupCbxKIUWZU40a1tWPej6tvuNCqF24FeA3j50R8KxZPCfUbbMPQufEbUjYOgQPrAKJMRRO988M5lP25YImfAnsCfjOzF3jS+q1BBnYvemhL43PX/d+4Gx4 x-ms-office365-filtering-correlation-id: 70934518-d61a-4cf8-cea4-08d61c4a7179 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020); SRVR:CY4PR21MB0120; x-ms-traffictypediagnostic: CY4PR21MB0120: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(2018427008)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050)(76991041); SRVR:CY4PR21MB0120; BCL:0; PCL:0; RULEID:; SRVR:CY4PR21MB0120; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(396003)(376002)(136003)(39860400002)(366004)(199004)(189003)(54906003)(26005)(110136005)(446003)(2906002)(6346003)(99286004)(316002)(575784001)(86362001)(25786009)(102836004)(10090500001)(2616005)(2900100001)(76176011)(97736004)(36756003)(11346002)(72206003)(478600001)(10290500003)(3846002)(6116002)(1076002)(22452003)(107886003)(5250100002)(2501003)(86612001)(4326008)(217873002)(105586002)(106356001)(6486002)(14444005)(14454004)(256004)(6436002)(8676002)(305945005)(8936002)(6506007)(81156014)(81166006)(7736002)(476003)(486006)(68736007)(186003)(66066001)(6512007)(53936002)(5660300001)(6666003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR21MB0120; H:CY4PR21MB0776.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: tA8HuxYtYGK2e/pIHwWtDZh2GtEkkncGTx5CS5bpSI+4EGN6t0zYb4p4h2Z7Q1EWAhv5wzhmVP8OOgj/ClTFvnqZbf32D33yBNbM1SIHPdrOw16kQQoJcLKYJSpV0a7KXvxJSJWsvd3K2ZOHjmbxZthAfwRGPY8DqDjGFm0g/osUKVYxDzrp1kHfmtUugtGin7D26ywe3083q82kUsV2sKbtqy12JsrejNYthqO96ZSxrms/kff+ambYUXK9F1fJDgZzA0/+EUi6cqQj0y869FnM1tc2XXE3+A945Isf6ax4gtBKL+A2kPgyMoCw+IKTTO5p2ALacS085pOcZCP49lZfuU3/A0xGsYBjzcvgeA0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70934518-d61a-4cf8-cea4-08d61c4a7179 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:03:48.2117 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sudeep Holla [ Upstream commit 09bebb1adb21ecd04adf7ccb3b06f73e3a851e93 ] Vexpress platforms provide two different restart handlers: SYS_REBOOT that restart the entire system, while DB_RESET only restarts the daughter board containing the CPU. DB_RESET is overridden by SYS_REBOOT if it exists. notifier_chain_register used in register_restart_handler by design relies on notifiers to be registered once only, however vexpress restart notifier can get registered twice. When this happen it corrupts list of notifiers, as result some notifiers can be not called on proper event, traverse on list can be cycled forever, and second unregister can access already freed memory. So far, since this was the only restart handler in the system, no issue was observed even if the same notifier was registered twice. However commit 6c5c0d48b686 ("watchdog: sp805: add restart handler") added support for SP805 restart handlers and since the system under test contains two vexpress restart and two SP805 watchdog instances, it was observed that during the boot traversing the restart handler list looped forever as there's a cycle in that list resulting in boot hang. This patch fixes the issues by ensuring that the notifier is installed only once. Cc: Sebastian Reichel Signed-off-by: Sudeep Holla Fixes: 46c99ac66222 ("power/reset: vexpress: Register with kernel restart handler") Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/reset/vexpress-poweroff.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 102f95a09460..e9e749f87517 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -35,6 +35,7 @@ static void vexpress_reset_do(struct device *dev, const char *what) } static struct device *vexpress_power_off_device; +static atomic_t vexpress_restart_nb_refcnt = ATOMIC_INIT(0); static void vexpress_power_off(void) { @@ -99,10 +100,13 @@ static int _vexpress_register_restart_handler(struct device *dev) int err; vexpress_restart_device = dev; - err = register_restart_handler(&vexpress_restart_nb); - if (err) { - dev_err(dev, "cannot register restart handler (err=%d)\n", err); - return err; + if (atomic_inc_return(&vexpress_restart_nb_refcnt) == 1) { + err = register_restart_handler(&vexpress_restart_nb); + if (err) { + dev_err(dev, "cannot register restart handler (err=%d)\n", err); + atomic_dec(&vexpress_restart_nb_refcnt); + return err; + } } device_create_file(dev, &dev_attr_active); From patchwork Mon Sep 17 03:03:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 146831 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3279730ljw; Sun, 16 Sep 2018 20:18:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbGR8cEuAUindecyUU9WBqBV5CmsWsLre5li5Yg1BTDB0TFckb8hW5jEL6ENXln9icRZ+13 X-Received: by 2002:a17:902:82c5:: with SMTP id u5-v6mr22679665plz.83.1537154307079; Sun, 16 Sep 2018 20:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154307; cv=none; d=google.com; s=arc-20160816; b=PedR6B+KKy2FBoEzpGuG4gvCsl8NkCoZLQtA791PQ2BnFigtTrV6ij/QuYUb0UIHh1 qolEUG2F/xnkcx5C6acjbCtC4LLW5/9Lcq12aOOEK+wX8Renn2Me+5SmJjkOpPhEVYne KyODPfIB9njvulIJ32PiKKCIYvhnIidi3MCqf6UnzzC+opJA5QTO4cqR6jkgeYahu+SY +mkjXI5bbWF6mYV9pfgxzbxjeMxHDx41rKu1M9HPpozK2keVtBvKsU2UmErFP6k/UAUC 2pF0xNpy+2FbTQXLdrPCD0R/wyTig2t1v0PwfKSbQUpZeZwPuqJdJjP5NhgKLfI8o2W0 lS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=rxDG7JAXHI9i8o5D9oN0TwheZoOcYiDUb64FcWLSoRE=; b=qyKoh2Xl3nHNAWtXlNIbYpZvP2fr6e9KOWk0VioMXgyJm1dO3NirbnUspWWl7ckuuj bPK/QS9OMKGups6Re1qL44O63FHnra/T5ZFIgFCeZBdtAEcmVgAFazigTsEVS5zdFN/6 ZSp5h69DbzAgFxEshlDc7YcJ7JjnoI4C+Q12fXcstvqY8rfVd1vricRhLhBIfx7xSgEH Wl6CST4JImnoQvA7cLG/hOuhgKTZL1X/zSKXAj8S06yF8Nt6xg1GPPDmyEhBW3K3lzd4 +9fZ8tjH6j0+4dswVgDIAJAOz8lv2BBbujGktQA7D2VfAJRTqkvTDbaexb5dCaNv2V2R jrmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SPUCgAWG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16-v6si14907467pgc.82.2018.09.16.20.18.26; Sun, 16 Sep 2018 20:18:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SPUCgAWG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730680AbeIQIa7 (ORCPT + 32 others); Mon, 17 Sep 2018 04:30:59 -0400 Received: from mail-eopbgr690131.outbound.protection.outlook.com ([40.107.69.131]:27472 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729897AbeIQIa6 (ORCPT ); Mon, 17 Sep 2018 04:30:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rxDG7JAXHI9i8o5D9oN0TwheZoOcYiDUb64FcWLSoRE=; b=SPUCgAWG8989fYAR/6bx+ytI6HDu4kSRZuSKZIfCxNEewj3J0uK+o7FM+jsy4LTZ3JiNtmPi1WM1y+XbwmOShA/egSJbHfD8ruY8uaxWQtxLbySdWRaqkkGd7PwNYWIty2TJS/gXTVvz+HuJbLl2ZVNbgn70DKveGFY+7kACEL0= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0120.namprd21.prod.outlook.com (10.173.189.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.4; Mon, 17 Sep 2018 03:05:37 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1185.003; Mon, 17 Sep 2018 03:05:37 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Zhen Lei , Joerg Roedel , Sasha Levin Subject: [PATCH AUTOSEL 4.9 08/57] iommu/amd: make sure TLB to be flushed before IOVA freed Thread-Topic: [PATCH AUTOSEL 4.9 08/57] iommu/amd: make sure TLB to be flushed before IOVA freed Thread-Index: AQHUTjMOhY6Oyxr/G0y11M2xb5/0Vg== Date: Mon, 17 Sep 2018 03:03:48 +0000 Message-ID: <20180917030340.378-8-alexander.levin@microsoft.com> References: <20180917030340.378-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030340.378-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR21MB0120; 6:d3sK4+0QRck9LMmL4ucLU0qfRsYPiszFiaTNkbsBrzlgkWYZmJ46Uatx9l90C2s/uVIiyvHnvWqqYLzq0TA7JeoDTmw3p8rGUMGPD4oyC88zViC+UUFuZy+loABHUQANnf51dbnCS5I/S1zEz8KKj9BrXUXkw6SoyYl7G4QgWYShvkfmHjBoLjkZKf1C2EO9gw+jQaH0h49xSiXJEqfgxDqc3yBaEATmZZjb1Sdu1c2I3I6f6+MEBqidDfO7xEv/phwCI+iw+ASWMVVNcotf/sMCT8aV7nTgWw6ZcHI11VCDdtYOObeYmOmhNMgFV/IgW8PiiUp2qX9jx1pjbP5yukCONn/4E19IDj3doLMnMAL0XAHpiYLVznzmx6kqfwLAmwE/FHCziyVEil096KEiEXTOsj4xY/bTyFS7V3xXyNR3kyFoQLuZtKRq3ga1wvo6KmJeGY9cxvlCOUKnS4jt3A==; 5:7BPemNI6cxQkWi2a5TIRdBgBYh98TIZAVQOL02RNfpF9jPkQz8V9sb87LDjwhEb51TmgT+7lGEXREntnen9DeqKnD5JZ4mc+FihJj79gIqQXJqsbrMP1WnLpYw818fblfy+5KMqqeysIJU7AwM5uqUR5vFtkuKWP+5hcsxO9Y+Q=; 7:5oUsZne5EFXF88A+ouX/IwD4RouUcOzdkUBcpHMjSocakfre0f9z7TjFHosiFHV+Quj005NPeIHoMS+gIE1njUU4xW6afxwBmrKfVITuye2H1bFpwDLFKuVgBtfwBDMcn8fTOl+PIBHhmpy3DdbDCSHm31QrUZVu8QR/XfYYxyhajrWknlADnbXBPpQUjAMlsuzLY8q4MZ41AfG/GQ34YcYzmgeQINVfPa515eXzKO1EUJWbSqpRuHh6mR0qX/i6 x-ms-office365-filtering-correlation-id: 56a2e0fb-9f93-42b7-49f1-08d61c4a71a8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020); SRVR:CY4PR21MB0120; x-ms-traffictypediagnostic: CY4PR21MB0120: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(269456686620040)(50582790962513)(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(2018427008)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050)(76991041); SRVR:CY4PR21MB0120; BCL:0; PCL:0; RULEID:; SRVR:CY4PR21MB0120; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(396003)(376002)(136003)(39860400002)(366004)(199004)(189003)(54906003)(26005)(110136005)(446003)(2906002)(6346003)(99286004)(316002)(86362001)(25786009)(102836004)(10090500001)(2616005)(2900100001)(76176011)(97736004)(36756003)(11346002)(72206003)(478600001)(10290500003)(3846002)(6116002)(1076002)(22452003)(107886003)(5250100002)(2501003)(86612001)(4326008)(217873002)(105586002)(106356001)(6486002)(14444005)(14454004)(256004)(6436002)(8676002)(305945005)(8936002)(6506007)(81156014)(81166006)(7736002)(476003)(486006)(68736007)(186003)(66066001)(6512007)(53936002)(5660300001)(6666003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR21MB0120; H:CY4PR21MB0776.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: M9svcr6py6glWbEjcmnpbxACcF4nUYjmseKm4CvG2zvvpgI/GjwkLvPw6ECVjl/h7LPp3WRzUtQxpAlVwC2HxhKz3jFqE6ycyUiHuu6Ua/IPhlR5vyO+1hpLd460qoKdQGatAWUxywGYB000B3qAzcI2cUuwrjOWqqwZ/hwaow78y+OtfWTXJGuJDvcd8XwQxgIcMdMXkUZF4/sSKWMGyAIoMsQozdLpTt+97BPFVJaUAZhuN5ZlgX3bD3VxLJcvs+ShbjBPQ95cT054BG0H5XFQNlt0NxicwBYSLQo6mnjj3tsHkpy4ucftY7x8N8DT0DRXrLodWnmSE5WnFOAXM5I5mIXywCssdT1J631eAEw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56a2e0fb-9f93-42b7-49f1-08d61c4a71a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:03:48.7898 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhen Lei [ Upstream commit 3c120143f584360a13614787e23ae2cdcb5e5ccd ] Although the mapping has already been removed in the page table, it maybe still exist in TLB. Suppose the freed IOVAs is reused by others before the flush operation completed, the new user can not correctly access to its meomory. Signed-off-by: Zhen Lei Fixes: b1516a14657a ('iommu/amd: Implement flush queue') Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 0c910a863581..16199b36a11e 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2452,9 +2452,9 @@ static void __unmap_single(struct dma_ops_domain *dma_dom, } if (amd_iommu_unmap_flush) { - dma_ops_free_iova(dma_dom, dma_addr, pages); domain_flush_tlb(&dma_dom->domain); domain_flush_complete(&dma_dom->domain); + dma_ops_free_iova(dma_dom, dma_addr, pages); } else { queue_add(dma_dom, dma_addr, pages); }