Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932852AbbBDIKd (ORCPT ); Wed, 4 Feb 2015 03:10:33 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:55988 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbbBDIK3 (ORCPT ); Wed, 4 Feb 2015 03:10:29 -0500 From: "Ian Munsie" To: mpe Cc: benh , mikey , linux-kernel , linuxppc-dev , "Aneesh Kumar K.V" , Ryan Grimm , Vaibhav Jain , Philippe Bergheaud , Ian Munsie Subject: [PATCH 2/2] cxl: Fail AFU initialisation if an invalid configuration record is found Date: Wed, 4 Feb 2015 19:09:02 +1100 Message-Id: <1423037342-26753-2-git-send-email-imunsie@au.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423037342-26753-1-git-send-email-imunsie@au.ibm.com> References: <1423037342-26753-1-git-send-email-imunsie@au.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15020408-0033-0000-0000-0000010414DA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1701 Lines: 49 From: Ian Munsie If an AFU claims to have a configuration record but doesn't actually contain a vendor and device ID, fail the AFU initialisation. Right now this is just a way of politely letting AFU developers know that they need to fix their config space, but later on we may expose the AFUs as actual PCI devices in their own right and don't want to inadvertendly expose an AFU with a bad config space. Signed-off-by: Ian Munsie --- drivers/misc/cxl/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index 128481e..f7c01a9 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -599,6 +599,8 @@ static int cxl_read_afu_descriptor(struct cxl_afu *afu) static int cxl_afu_descriptor_looks_ok(struct cxl_afu *afu) { + int i; + if (afu->psa && afu->adapter->ps_size < (afu->pp_offset + afu->pp_size*afu->max_procs_virtualised)) { dev_err(&afu->dev, "per-process PSA can't fit inside the PSA!\n"); @@ -608,6 +610,13 @@ static int cxl_afu_descriptor_looks_ok(struct cxl_afu *afu) if (afu->pp_psa && (afu->pp_size < PAGE_SIZE)) dev_warn(&afu->dev, "AFU uses < PAGE_SIZE per-process PSA!"); + for (i = 0; i < afu->crs_num; i++) { + if ((cxl_afu_cr_read32(afu, i, 0) == 0)) { + dev_err(&afu->dev, "ABORTING: AFU configuration record %i is invalid\n", i); + return -EINVAL; + } + } + return 0; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/