Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2210984pxk; Sat, 26 Sep 2020 22:32:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkUAxh8K52DixLcOYZPiLpLP8U4kakymNvAwQV7/XUbzMOH8omyZvIUSvwEKE6QPgov0yB X-Received: by 2002:a17:906:a282:: with SMTP id i2mr9956337ejz.39.1601184731537; Sat, 26 Sep 2020 22:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601184731; cv=none; d=google.com; s=arc-20160816; b=rgTEGKgHyJVkMBUAYidismyLRWs/Yik3qNu8vGOm61xhZ57B+rXNWV9IUtxTeIa7aX unXqePfS3QK6C6NlXGCQFPsN0pZve7TcH4QaBE1r9dldf/Zws4WEmXvvTVwuZ1v70vwB YfiO5+FRVRBGuyU3v/2PFkrqAPQ+XcN6qWV/FFKsx14+8tn3AqKPp6c14uxniCqPgW5N 2olTc3RRz6CoAq0KmWuadYn77E9Rp6xoRWRR2d86SbG3gasRfyULz6cc6Z0FPC8/yjzi GD6iEnWav9FtqnQCaCh+QKdu77/ILwLuU4faAUEWvcvmky98R/2nQEDZX8Ef8Z8VRDLX YAKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=4BVYhrzsPE1VX9uc1fj8vcNfbzgyBxP9r3B5DWQ3V9o=; b=QT3kdhyV7wTBlrT9ydviNYm9+tlq5DXo1oyY//a4CfhP6rEjcBKW2WroeSKglSbZQM phLFwcfLWTlHSGMtpqb48r2wreMcwW4w5yfMY0kFythkikK3MoHM1YSXgETK2DFvrEEG LrYE5OYfMTXw6JQUacR/b09XjWLGmlT2OGBVW2cu6NTij23OO1ESuFhGW4Z79Eaqdi2e YjDlBkHbVqJ7EKij3JN9I72+14ebEh6x5cY4LJSnwDxoHjzm3LEeB+7Y6TJ3nSu15PUG FmeM6UBGx+enuYSQWQBY5TqHaDBZD0QlBFJigztNaDdEMt5BYaEQ/3yoIh9H2bmBWf21 V60Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si5506710ejk.73.2020.09.26.22.31.36; Sat, 26 Sep 2020 22:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730224AbgI0FaS (ORCPT + 99 others); Sun, 27 Sep 2020 01:30:18 -0400 Received: from mga07.intel.com ([134.134.136.100]:23634 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbgI0FaS (ORCPT ); Sun, 27 Sep 2020 01:30:18 -0400 IronPort-SDR: HnnCRNj9qAllc+CzZ3KOVlDfFKtYDYEk4b92uzqS+8CgYhWQfgxPHiHaL0nKJfXtjxIKtBWpcQ WSHeZ9Ujh9zw== X-IronPort-AV: E=McAfee;i="6000,8403,9756"; a="225993129" X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="225993129" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2020 22:30:15 -0700 IronPort-SDR: OoVEK/uMjplKf0pD7VtT6xnlAYkCMFVXCHQj4qS6jp5Ev2u3cUAIoZftIz6YeOdsOwF3MPu6i5 zY+tbC0Bg0QQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,308,1596524400"; d="scan'208";a="323909277" Received: from shskylake.sh.intel.com ([10.239.48.137]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2020 22:30:11 -0700 From: Ethan Zhao To: bhelgaas@google.com, oohall@gmail.com, ruscur@russell.cc, lukas@wunner.de, andriy.shevchenko@linux.intel.com, stuart.w.hayes@gmail.com, mr.nuke.me@gmail.com, mika.westerberg@linux.intel.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, pei.p.jia@intel.com, ashok.raj@linux.intel.com, sathyanarayanan.kuppuswamy@intel.com, Ethan Zhao Subject: [PATCH 0/5 V3] Fix DPC hotplug race and enhance error handling Date: Sun, 27 Sep 2020 01:28:36 -0400 Message-Id: <20200927052841.12629-1-haifeng.zhao@intel.com> X-Mailer: git-send-email 2.18.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This simple patch set fixed some serious security issues found when DPC error injection and NVMe SSD hotplug brute force test were doing -- race condition between DPC handler and pciehp, AER interrupt handlers, caused system hang and system with DPC feature couldn't recover to normal working state as expected (NVMe instance lost, mount operation hang, race PCIe access caused uncorrectable errors reported alternatively etc). With this patch set applied, stable 5.9-rc6 on ICS (Ice Lake SP platform, see https://en.wikichip.org/wiki/intel/microarchitectures/ice_lake_(server)) could pass the PCIe Gen4 NVMe SSD brute force hotplug test with any time interval between hot-remove and plug-in operation tens of times without any errors occur and system works normal. With this patch set applied, system with DPC feature could recover from NON-FATAL and FATAL errors injection test and works as expected. System works smoothly when errors happen while hotplug is doing, no uncorrectable errors found. Brute DPC error injection script: for i in {0..100} do setpci -s 64:02.0 0x196.w=000a setpci -s 65:00.0 0x04.w=0544 mount /dev/nvme0n1p1 /root/nvme sleep 1 done Other details see every commits description part. This patch set could be applied to stable 5.9-rc6 directly. Help to review and test. V2: changed according to review by Andy Shevchenko. V3: changed patch 4/5 to simpler coding. Thanks, Ethan Ethan Zhao (5): PCI: define a function to check and wait till port finish DPC handling PCI: pciehp: check and wait port status out of DPC before handling DLLSC and PDC PCI/ERR: get device before call device driver to avoid NULL pointer reference PCI: only return true when dev io state is really changed PCI/ERR: don't mix io state not changed and no driver together drivers/pci/hotplug/pciehp_hpc.c | 4 +++- drivers/pci/pci.h | 34 +++++--------------------------- drivers/pci/pcie/err.c | 18 +++++++++++++++-- include/linux/pci.h | 31 +++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 32 deletions(-) -- 2.18.4