From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFF16C433F5 for ; Fri, 15 Apr 2022 03:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qBxt8iDwl+4RPh0X3ylc3wlEIb9UA7n3jbVqF7n4b1A=; b=YrvaDBnrNb1tC/ emyX6atdmDeF4rTgPGZOTNouvfr3ByjALqja5mYnxiOoPMCF9ULqbosnyAQlpTrZ8/MyjxSY/1qcW cxvzcno9v09ug5tNtr6IMExwmHiW+qNTMNcX8oC0awpwEUbHLelbin94x7ZSWYmiUkmhrfpbGUVml KwPkrJ6jWdE+4N5fd7uS59e/Ybmo1gi5aDQ0CW+ojq6bxdJ/V7MiH2Hu+uhXfVd/sh9vYsB4ZA3Gz xqS6S14/aIiapgFEO9a6ODUrNKX7J+MS485lTQNZtjnj64dasyXSXsJvh4Bc8gPUicgfqm3+4bwAx QJLPPna4uYwKIaRXphuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfD53-008Ipb-Il; Fri, 15 Apr 2022 03:57:09 +0000 Received: from mail-dm6nam12on20603.outbound.protection.outlook.com ([2a01:111:f400:fe59::603] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfD50-008Inw-3N for linux-arm-kernel@lists.infradead.org; Fri, 15 Apr 2022 03:57:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ir4D+coYxJd19VpwLd1ROzkhqMLc7MZCH9fs2mpJudwKu8J+AqtidzEhaxwBgSX4f80jj/W/3x3JOHgF20uyC+3Fttn+uhnp+hSnD+Kpx3Gw+S6R/TxGHzNR3DOiRJ1xsN5FCTmxeorDbA3vF6LKg5cD55g4EHnuTwb75bjboCf8lw1mAe9Mrv6McQnIQhJMguvTSKMy896Hu815B0AmkJle6kF+bSplO9uCH8EI2CFv364yhcW33yi3azy5QVlUelfGEpeNR7Kes+EceXJymZJTeLNJi0CJve3v/yjaxcc6yjIN9NuueDJWDHZbzcuTzvQui5AYUzRovCXZPP6M4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zb2KoPpbgyGQlfPTPRM+6ao6q5CRoeoA+R5OIzsFrO4=; b=EAJ6grKQ9OA2dINPl/zezdHTsiNaFRT3WoHCibfyDENP2nblWZYjByyI97y9Jz6EpL7KDdVcqsUNyXcAh2hnNfeOHADqE9P6t/Mm8vOn85CBw/m+QbkVDk6rHJi9HXI8RtJKKwmNAA6s2jiZdhMqBCyHauhQY+yT7QzwuxwLhS8uwQoiwnHf66CU699MVQSoFfDRV83QbmMnRxBPDThB/Nok563NinDq3swk1HvK28w6GoZrCctHKkpmG8Svrag2Z2l3d9vJwiE2AJA6p8S1QdP7d+nSt0zIzZQzJciysAqHvbqKIKVE+7FnSCaIbhTWluuksRWBOn7C1P8Jm4W6sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=wanadoo.fr smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zb2KoPpbgyGQlfPTPRM+6ao6q5CRoeoA+R5OIzsFrO4=; b=U8TD5osIyFHDb5Udfbi5zpt/+F7AU8FpFNee2Y6pURGQhLwc8X2TcZYZEIjt1og2/s2zIdD5TRYqSpXCDdpzSMiubnXt6hq7o9OoLkVP22aUD9bmTwuaPJJtbParsu1/Panc4k94qo6tdAtConrYb4hBZvhFDUWn0F2kQ/B6LJ8veYnOu1WA4T00ftIPcxpszFsa+Rh+F8ihz0htpSbtDHQliHmpb4NsrPuW/xbmiY0Orcg1W42+ZUgyfhHdF+CUn8sHfTgCu80cBu3O3kScZOEz92txlf/G+u5vs06/NaCyrcfODU2X3zXZtaeCQNQ4LU8QjT2Ek09E2OCMfIfokg== Received: from BN6PR13CA0019.namprd13.prod.outlook.com (2603:10b6:404:10a::29) by DM5PR12MB1659.namprd12.prod.outlook.com (2603:10b6:4:11::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Fri, 15 Apr 2022 03:57:00 +0000 Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:404:10a:cafe::99) by BN6PR13CA0019.outlook.office365.com (2603:10b6:404:10a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.6 via Frontend Transport; Fri, 15 Apr 2022 03:57:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5164.19 via Frontend Transport; Fri, 15 Apr 2022 03:56:59 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 15 Apr 2022 03:56:59 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 14 Apr 2022 20:56:59 -0700 Received: from Asurada-Nvidia (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22 via Frontend Transport; Thu, 14 Apr 2022 20:56:58 -0700 Date: Thu, 14 Apr 2022 20:56:57 -0700 From: Nicolin Chen To: Robin Murphy CC: , , , , , , , , , , Subject: Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range Message-ID: References: <20220413041745.35174-1-nicolinc@nvidia.com> <37c02fc4-d793-b003-f612-206c987a8a42@arm.com> <13c91dfb-c540-ed8d-daa7-eab7207df221@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <13c91dfb-c540-ed8d-daa7-eab7207df221@arm.com> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7e54d91-7d75-4c56-9330-08da1e93fe40 X-MS-TrafficTypeDiagnostic: DM5PR12MB1659:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9BKyqcuZfiQriq6gTJtPb570vqKJYFVhOcRT/IuENCCW4mfTQb+MHGZ9MTMO8qCuWpQXI1m9NkI3AGjuRg9PRNIhAKznL1nWEouheoQ8nbTHS5zC59ptiNQTEdhtMfd+UKDtJlO0flLTSc9ReA4jfAJiFxb9kOdV/WujTA53TLjIfDWEnbzwBlq5GPQSn8GLAAMKU6ypwjzOYd/AkuS4HRbhvt4aFBXhbqc5Utl7Ne8JzJkNs42So96f9vn4xCZZ26sFB1W+av40o9l+pig4p3+PeP7f1CnpGb2dniPophG6840C04KqT8Vi4KW92wVGLLpUE3wBIjr1UhQKgiPsu7mMvvAnPjRJf7DsY5BeWUhU5TTvKQx4uB+zX8PTyESDWM+UFl2GrSm0+wPoeoY6sJAI0WCfZYxUxYGyl1PXwpHr3MSU7LEA4vBLW2cxxSta5f8FkWYfwTH/0BCJ8wn6ShR04UBvNikaHlf57gi8fRqm6TCnbiS2rrcbeCWhb3103RsWcyT7UucQSDtPSdK/z6gOj4671/0LkHrexo+Y+fBQcRE8qU7MVvhYIKDjhj+oLLhxp0ytJ6/XoA4/mivPgK5rEWSGkZB+nDa9LPtMMKMmldOcUS6zqhvfRoAfJQNvq0XegkDcoSnXZAJMWqFJOMP32HS86wqdg7SE2Rn+wVxyblwt6iczhOiv/d5m1GsDVm6kCzWFyFTSgexeTOnbyQ== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(7416002)(508600001)(53546011)(55016003)(81166007)(82310400005)(5660300002)(9686003)(40460700003)(86362001)(356005)(6916009)(54906003)(2906002)(316002)(36860700001)(186003)(26005)(47076005)(8676002)(33716001)(4326008)(70586007)(70206006)(336012)(426003)(83380400001)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2022 03:56:59.9454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7e54d91-7d75-4c56-9330-08da1e93fe40 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1659 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220414_205706_399792_6FDCF702 X-CRM114-Status: GOOD ( 31.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 14, 2022 at 11:32:38AM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2022-04-13 21:19, Nicolin Chen wrote: > > Hi Robin, > > > > On Wed, Apr 13, 2022 at 02:40:31PM +0100, Robin Murphy wrote: > > > On 2022-04-13 05:17, Nicolin Chen wrote: > > > > To calculate num_pages, the size should be aligned with > > > > "page size", determined by the tg value. Otherwise, its > > > > following "while (iova < end)" might become an infinite > > > > loop if unaligned size is slightly greater than 1 << tg. > > > > > > Hmm, how does a non-page-aligned invalidation request get generated in > > > the first place? > > > > I don't have the testing environment because it was a bug, > > reported by a client who uses SVA feature on top of SMMU. > > > > But judging from the log, the non-page-aligned inv request > > was coming from an likely incorrect end address, e.g. > > { start = 0xff10000, end = 0xff20000 } > > So the size turned out to be 0x10001, unaligned. > > > > I don't have a full call trace on hand right now to see if > > upper callers are doing something wrong when calculate the > > end address, though I've asked the owner to check. > > > > By looking at the call trace within arm_smmu_* functions: > > __arm_smmu_tlb_inv_range > > arm_smmu_tlb_inv_range_asid > > arm_smmu_mm_invalidate_range > > {from mm_notifier_* functions} > > > > There's no address alignment check. Although I do think we > > should fix the source who passes down the non-page-aligned > > parameter, the SMMU driver shouldn't silently dead loop if > > a set of unaligned inputs are given, IMHO. > > Oh, sure, I'm not saying we definitely don't need to fix anything, I'd > just like to get a better understanding of *what* we're fixing. I'd have > (naively) expected the mm layer to give us page-aligned quantities even > in the SVA notifier case, so if we've got a clear off-by-one somewhere > in that path we should fix that before just blindly over-invalidating to > paper over it; I see. Yea, definitely should fix the source too. I've asked the owner to track it down. I sent the change, thinking that we could do it in parallel. > if we still also want to be robust at the SMMU driver end > just in case, something like "if (WARN_ON(num_pages == 0)) num_pages = > 1;" might be more appropriate. However if it turns out that we *can* > actually end up with unsanitised input from some userspace unmap > interface getting this far, then a silent fixup is the best option, but > if so I'd still like to confirm that we're rounding in the same > direction as whoever touched the pagetables (since it can't have been us). I see. I'll give an update once I have the debugging result. Thanks! Nic _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel