Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp728319rwb; Fri, 7 Oct 2022 03:27:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nA1dITbca0JbFF8I7Vuiih5c7xi4u8JTKBHAM315+fOS+02vVntKGZ40qF1vhvVOefgSH X-Received: by 2002:a17:907:d29:b0:78d:2784:54ee with SMTP id gn41-20020a1709070d2900b0078d278454eemr3664938ejc.202.1665138451732; Fri, 07 Oct 2022 03:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665138451; cv=none; d=google.com; s=arc-20160816; b=Iq3Y49bEdoKqDMEeIo8skJB9PEOO+UbNmLzvlcHFbiXj899CKYrpLDulf1gBffiyry 3RWqwlwl/lELFajg7Af6BXRCzzb6GpU6Sli/Uy/g4O89oYSeCLXPueb7WWWB1fYEUC04 UCKdwxvv9omhhAeyrygQEtBOrXxOBG+Jdjv/ayZPBRaBZ8z+oiILNjPbJQ6pLY9SwiR6 WhfmYGi1OUj2TNJ8zh923ISGt5d4Hh2waNsEhgVgUvNI3wAGqeCQeaMVhp7CDaHHgfou pIza8qr+VC12V2ppan4legInxI4FrSNU6bGGb3rEcskFfmFzyHB+76qLSCSbJC0qoLME 2knw== 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=k+I5WhOS16FY7irvxpfSnfTvyCVCLvAaTyU/MnPz2/Y=; b=Xzn2XyBlhj9XCpqfQVHU8JsyWczmdLevFPCo1d67qqCUx4YrzkufWIKP2yrs2lV26c 23jT+SK8JD51CU3itPZceWsvY3CpJBR5rBsz2G78jvnQPR+/DIVquQCkSou0BoFfDqZ3 V0cyB6g/xfo/uNxH4aknZ2O1d5Xue9l8z1Bu1M3S8TwgfKb7QhL3SfQziHQdxnvNgHuM QY5TSWIjBBLMOlF00yOVNf8rNHuyJoE6B+QuOM5NtHPigOACo8a5Nv0lnAkMnAlP4LGc 0mjqI7vQiaMKSpraIay67AfQzA80TuNiMgqaDLrzRo0TpEud3mrTdP8bG4VCQDPOjyUO GrPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="iAs/gUAw"; 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 hq33-20020a1709073f2100b007820f6b65c6si1992988ejc.469.2022.10.07.03.27.05; Fri, 07 Oct 2022 03:27:31 -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="iAs/gUAw"; 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 S229724AbiJGJuu (ORCPT + 99 others); Fri, 7 Oct 2022 05:50:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiJGJu3 (ORCPT ); Fri, 7 Oct 2022 05:50:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB569D525; Fri, 7 Oct 2022 02:50:24 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2979IcK5006691; Fri, 7 Oct 2022 09:50:13 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=k+I5WhOS16FY7irvxpfSnfTvyCVCLvAaTyU/MnPz2/Y=; b=iAs/gUAwVK/BUwf4DfzSV29WP+nfJbsu7d+GIH3703iZ8ORUoZDLmUf3sXkFDUD5hmDe dAv8b+MgvVJpjA1EivolbYwqczeFGdI4xBlAzvNvkGmKZhGs7Ww2vunGREPx3Zln9ft9 DgP4f/fW2hqR5LFGct3I5Vthwxg2tFvzJTn4czZvvVK2wbylOBnKnJ3MAG57PgbMUnC/ R8KJ2YL1isYpbsVz7xRnc7hobs0N0So09PddwZEsZJYs6XpdA76N6DI2RC2h7iUP3m8j bL1IxOAPQJpktZzvx3KzWd2N0rmOel/qB7AXmjbG5ZoxwAMetHEMOwK5pqFHpO9lqVMo yQ== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3k2hc2gsbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Oct 2022 09:50:13 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2979ZqIO012610; Fri, 7 Oct 2022 09:50:11 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3jxd68x6gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Oct 2022 09:50:11 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2979o8WE3473978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Oct 2022 09:50:08 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EDB2A4055; Fri, 7 Oct 2022 09:50:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBA43A4051; Fri, 7 Oct 2022 09:50:07 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 7 Oct 2022 09:50:07 +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 v6 4/6] iommu/s390: Fix incorrect aperture check Date: Fri, 7 Oct 2022 11:50:03 +0200 Message-Id: <20221007095005.2017126-5-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221007095005.2017126-1-schnelle@linux.ibm.com> References: <20221007095005.2017126-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: IUk6XtExZIj4tAYOXSjRIt3c33xd6Cyg X-Proofpoint-ORIG-GUID: IUk6XtExZIj4tAYOXSjRIt3c33xd6Cyg 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_05,2022-10-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 impostorscore=0 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210070058 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 65835a5ca328..a4c6a1a63fef 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -208,7 +208,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