Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1047455rwb; Thu, 6 Oct 2022 07:52:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DGP0rwWtquoaaVy6I5pTSuNv+i31YsQZo+MAxVzOudSeXR16+wc4EN634k6/aXSnqre42 X-Received: by 2002:a17:906:eeca:b0:730:6880:c398 with SMTP id wu10-20020a170906eeca00b007306880c398mr192100ejb.706.1665067966466; Thu, 06 Oct 2022 07:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665067966; cv=none; d=google.com; s=arc-20160816; b=Po6BtPMLH4O5kiroslGYmd7uZIKxono84/RwbWIwxzizMCawX1Uq7c5BNFTIEiRhqA Ot49m3/3ImQGbuLdgXKWWYLIKxAHNpE/56EStKoo0qVAn+zsuXmoFNViW+up4p3KP6jn Y0V8UPTwFf64DQkbw76iyTP6gCeiP+gYSt5hPQaIHXlfjLN1wsp+aXS1ydnk85eHen8K 0q8oSn1fCdPZCD5MdO/pqPjBbd70gk2Y4YxXIfqq64HvgcJ8SUr70FbLhISIOAFjjk6D m5lEL9fuDNCdnHXldWyiOCW5fOQrcq2eb65XmsBG0OOmFk81OWMQcmPjqFWk+AavyNgD QPzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RG8/UdkqUqnbHz/nuNFqudmbPfwKpeVn1BnIwSdDneE=; b=JHNJcBnbWbklJ5icOJuXVdfaErQRoUlLjPQy7j4gPACD0/0dcCDFNaMyoq+mBwh5cb lHeF6GNqSdpLr8BWmvqfiS3+rVjnEQBEd58J67yAqjTqu6r0vHqkYylluWLer6MgwZtl vlsZSoyl/2ZnSMTAjCwRcwjDAY+ZiW+XhiN4uJOYjIAiMvBMeT9eC4KWUNjhb4e3/7qH XaJVBLo+W+cSYQuqohuAJIRpj5mLasIqcNxe4+FKwSHbuRXB/3rrZOCXFZJUykT9MIlQ 4TDX42wpEjQupYUi2cOlxvROOv2BIV52Tt9jBHrSzwVeuZpILEXou/ttZ7NQ+uGLR81f ISmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="SgeVGR/8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a05640226c900b00456fa16e075si17855551edd.457.2022.10.06.07.52.11; Thu, 06 Oct 2022 07:52:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="SgeVGR/8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbiJFOra (ORCPT + 99 others); Thu, 6 Oct 2022 10:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiJFOrW (ORCPT ); Thu, 6 Oct 2022 10:47:22 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A003847A; Thu, 6 Oct 2022 07:47:21 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 296EAVM0031517; Thu, 6 Oct 2022 14:47:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=RG8/UdkqUqnbHz/nuNFqudmbPfwKpeVn1BnIwSdDneE=; b=SgeVGR/8MYdtncWuD2bBtuoJzuc85ngcSXwt7qs+vD8Dib8R/4umtg/avouxDZDshp2l kBiOWNI1yQWM74NcKh+b+KnjrE64RhwaqYe9PlEJxq6FhPb3IXZKcFqfqqmMIyjrLWpm em42QVq0fz0fgoWfs9l26mwWl/cXdBrUuqF5WKcKz4zugVlBEHCtc3ngLzIUlhtRw2MD L8ldkOFC/0d+r8Lm9vpeGwV1Xi5zn6aKSIUsUY32k858GRF77eEEbcAw6SeHCowuPyVV 4Fy0khv/BVu7NYMJrcm+30lD/g/B3F/4qdwdCcZi2DNkB3GNji7hi37ZjXdUuxiQcgvA rA== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k1y14meu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Oct 2022 14:47:08 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 296EaSBi010179; Thu, 6 Oct 2022 14:47:06 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3jxd6978dm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Oct 2022 14:47:06 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 296ElXOJ49807852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Oct 2022 14:47:33 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 975F0A4040; Thu, 6 Oct 2022 14:47:03 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20830A4057; Thu, 6 Oct 2022 14:47:03 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 6 Oct 2022 14:47:03 +0000 (GMT) From: Niklas Schnelle To: Matthew Rosato , Pierre Morel , iommu@lists.linux.dev Cc: linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/6] iommu/s390: Fix incorrect aperture check Date: Thu, 6 Oct 2022 16:46:58 +0200 Message-Id: <20221006144700.3380098-5-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006144700.3380098-1-schnelle@linux.ibm.com> References: <20221006144700.3380098-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mNJ3eIiFjVYBp3GKHbGh4ahtnyrklcab X-Proofpoint-GUID: mNJ3eIiFjVYBp3GKHbGh4ahtnyrklcab X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-06_02,2022-10-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 bulkscore=0 impostorscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210060085 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The domain->geometry.aperture_end specifies the last valid address treat it as such when checking if a DMA address is valid. Reviewed-by: Pierre Morel Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle --- drivers/iommu/s390-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 1f6c9bee9a80..a89fd0256f99 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -206,7 +206,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain, int rc = 0; if (dma_addr < s390_domain->domain.geometry.aperture_start || - dma_addr + size > s390_domain->domain.geometry.aperture_end) + (dma_addr + size - 1) > s390_domain->domain.geometry.aperture_end) return -EINVAL; nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; -- 2.34.1