From patchwork Thu Sep 8 05:42:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 667255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sV8Nd0Vp0z9s2Q for ; Thu, 8 Sep 2016 15:42:09 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sV8Nc73jyzDsTh for ; Thu, 8 Sep 2016 15:42:08 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sV8NQ1GV8zDrpB for ; Thu, 8 Sep 2016 15:41:57 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u885bl6P093638 for ; Thu, 8 Sep 2016 01:41:55 -0400 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0b-001b2d01.pphosted.com with ESMTP id 25ax05gej4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 08 Sep 2016 01:41:55 -0400 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Sep 2016 15:41:52 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Sep 2016 15:41:49 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: gwshan@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 98BB82BB005A for ; Thu, 8 Sep 2016 15:41:48 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u885fm4Y53739676 for ; Thu, 8 Sep 2016 15:41:48 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u885fmOe021396 for ; Thu, 8 Sep 2016 15:41:48 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u885fm4I021393; Thu, 8 Sep 2016 15:41:48 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 028DDA0270; Thu, 8 Sep 2016 15:41:48 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id EC2EFE3BFA; Thu, 8 Sep 2016 15:41:47 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id D6FA994284F; Thu, 8 Sep 2016 15:42:01 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Thu, 8 Sep 2016 15:42:00 +1000 X-Mailer: git-send-email 2.1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16090805-0008-0000-0000-000000BC39A4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16090805-0009-0000-0000-00000805E536 Message-Id: <1473313320-27581-1-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-08_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1609080081 Subject: [Skiboot] [PATCH] core/pci: Fix criteria in pci_cfg_reg_filter() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair@popple.id.au MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The criteria to match the filter according to PCI config register offset and length is strict one, meaning the accessed region should matches with the filter's tracking region. However, the code isn't correct enough - @len should be replaced with @pcrf->len. The strict matching has to account for the length of current PCI config register access. We have to specify precise region through @start and @len in pci_virt_add_filter() when creating the filter. We lost flexibility. This changes the strict criteria to a relaxed one - the matched filter is returned when the accessed region is overlapped with the filter's region. With this change, the individual filter's handlers should validate the accessed (register) region if necessary. Fixes: 85daa7f00c50 ("core/pci: Support virtual device") Signed-off-by: Gavin Shan Reviewed-by: Alistair Popple Acked-by: Alistair Popple --- core/pci-virt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/pci-virt.c b/core/pci-virt.c index 570c6e8..b531470 100644 --- a/core/pci-virt.c +++ b/core/pci-virt.c @@ -55,9 +55,14 @@ static struct pci_cfg_reg_filter *pci_virt_find_filter( if (!pvd || !len || start >= pvd->cfg_size) return NULL; + /* Return filter if there is overlapped region. We don't + * require strict matching for more flexibility. It also + * means the associated handler should validate the register + * offset and length. + */ list_for_each(&pvd->pcrf, pcrf, link) { - if (start >= pcrf->start && - (start + len) <= (pcrf->start + len)) + if (start < (pcrf->start + pcrf->len) && + (start + len) > pcrf->start) return pcrf; }