Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2395048pxu; Mon, 7 Dec 2020 05:39:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJykqxRtY36FgKEJ4TxrqxlV1t0dHH7gFqcCi5lwGVLwHfuba8/H79Zt0RovQ4MprCQlHOzs X-Received: by 2002:a50:e882:: with SMTP id f2mr19506341edn.76.1607348360575; Mon, 07 Dec 2020 05:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607348360; cv=none; d=google.com; s=arc-20160816; b=iquf2aVH0IgvJlwhad9gBTmC71gRil3SRzv4iD8XNeSc8mmm81iuJDiynPxWP/w62S jNOBVSq4G2TE4Cmzn4wqT0TDGoESW+qpWefaIspqqgILOELKlqWnpoYjfXdvw0JD9cf5 ofapCFOTqv82VcEmlONIxCFpB8tBf114F6Kj7tjUO/y+0HTqZlnaZzO8ait5cI5qg6pB FyBfoG8skJmWQb6yqAa68UFv+3OjzbM8mJuVJ9AEnokS5nJaF0mUZLB8PHrUPYDFOPAB vwwriKmwyl574RE2uC3taUBS8I917mUqCTASUi0AS/5HPmqPPFkKeSHS0MrCB9VT5bp5 B7Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=dvdNhpdUCovFbIit/F4rHa4TymANJGJhkYalCDEFMeM=; b=AoTK2RHQLLTgr2OG4VotI06e2rrC2z9VlT0Ape0FiusyxcmSYj3cWAP3Q0EMgiLNJW l//6g/Gl2RXPBQNkDymk41ky8iRWvdkrlxLO/KBI8K8gcQ7rZieH96MN94ZJWAMuT5w0 wGVsGI71tB7bjSQ2yVBE7FU+f7oKvmuiFYHeMO+qJZfbNKO3y6/zgalGKjeO2IbXOhk4 WnBOKgBwoW47Tvaov7idbAhG8hE/9h++06CBDRtR6+YwyMnjVvFlot3ciDzyhQJJDzuQ TLE4BbnV4eDw5H2MQWs6eo4qyS+hyYtnYRr0AfXL71JZrS9qvBKPQ/htYkwoedfVH0av dRsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm2si8217085edb.472.2020.12.07.05.38.57; Mon, 07 Dec 2020 05:39:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726187AbgLGNh2 (ORCPT + 99 others); Mon, 7 Dec 2020 08:37:28 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9390 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgLGNh2 (ORCPT ); Mon, 7 Dec 2020 08:37:28 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CqPTp1812z79wc; Mon, 7 Dec 2020 21:36:14 +0800 (CST) Received: from [10.174.187.37] (10.174.187.37) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Dec 2020 21:36:35 +0800 Subject: Re: [PATCH] iommu: Up front sanity check in the arm_lpae_map To: Robin Murphy , Will Deacon References: <20201205082957.12544-1-zhukeqian1@huawei.com> <20201207120527.GA4474@willie-the-truck> <2b0ec25b-0fa4-65ca-7c1b-109ce766197f@huawei.com> <9a6f31d7-3471-c045-368b-42ece5a2d34d@arm.com> CC: Suzuki K Poulose , Marc Zyngier , , , Sean Christopherson , Alexios Zavras , , Mark Brown , "James Morse" , Julien Thierry , Catalin Marinas , , Thomas Gleixner , Andrew Morton , From: zhukeqian Message-ID: <2191c045-449e-e7cb-a267-5bd356dab58e@huawei.com> Date: Mon, 7 Dec 2020 21:36:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <9a6f31d7-3471-c045-368b-42ece5a2d34d@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On 2020/12/7 20:46, Robin Murphy wrote: > On 2020-12-07 12:15, zhukeqian wrote: >> Hi, >> >> On 2020/12/7 20:05, Will Deacon wrote: >>> On Mon, Dec 07, 2020 at 12:01:09PM +0000, Robin Murphy wrote: >>>> On 2020-12-05 08:29, Keqian Zhu wrote: >>>>> ... then we have more chance to detect wrong code logic. >>>> >>>> I don't follow that justification - it's still the same check with the same >>>> outcome, so how does moving it have any effect on the chance to detect >>>> errors? >> >>>> >>>> AFAICS the only difference it would make is to make some errors *less* >>>> obvious - if a sufficiently broken caller passes an empty prot value >>>> alongside an invalid size or already-mapped address, this will now quietly >>>> hide the warnings from the more serious condition(s). >>>> >>>> Yes, it will bail out a bit faster in the specific case where the prot value >>>> is the only thing wrong, but since when do we optimise for fundamentally >>>> incorrect API usage? >>> >>> I thought it was the other way round -- doesn't this patch move the "empty >>> prot" check later, so we have a chance to check the size and addresses >>> first? >> >> Yes, this is my original idea. >> For that we treat iommu_prot with no permission as success at early start, defer >> this early return can expose hidden errors. > > ...oh dear, my apologies. I've just had a week off and apparently in that time I lost the ability to read :( > > I was somehow convinced that the existing check happened at the point where we go to install the PTE, and this patch was moving it earlier. Looking at the whole code in context now I see I got it completely backwards. Sorry for being an idiot. > I see :-) I should make a more descriptive commit message. > I guess that only goes to show that a more descriptive commit message would definitely be a good thing :) > I have adapted Will's suggestion and sent v2, please check whether it is OK to you? Cheers, Keqian [...] >> _______________________________________________ >> iommu mailing list >> iommu@lists.linux-foundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/iommu >> > . >