Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp948844pxj; Fri, 21 May 2021 03:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/2FOCCcdAUvglkAeakCQZhKAvefRQu8IvLZR/SBKqYmJYve8TjjG5u/N0wswTOx36yn9L X-Received: by 2002:a17:906:1c04:: with SMTP id k4mr9270494ejg.197.1621591212556; Fri, 21 May 2021 03:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621591212; cv=none; d=google.com; s=arc-20160816; b=mpj3uc8M5G/8FMorvbmjMN23yB1E53YOauebKVHlNuDAKAd49EWv48PzR8P4/u3yzd zXUyEb2I0Ffz6aJez4TLDm6KkxV2pRCw7c0HZ8ET9jf7cq7IQXiTwcsEvvCxJNk+Ulst bpDBKa890ToBHz6VdOtrtF8lRreRTF+fZe2Q++AUoFsNXheAE/WdTglI+sFytnhLQiHx i3lnzBIZMcwNqfEBP2fmN5o3djjcnMFPCA49iqNB9wffnhe8rsN7joA2MP55V4gWtgwh M2StvceahJ2jcjIxENPrE4XJlEObiGMjINOM4oYjxn8b1O/ZBjW51RPjQvL+UUtWcOck tCdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qwq7BgOcZrIZWp8spx72FcsuCFeELBqKrNY2dCZgLTs=; b=zL66dtjXhfLZUByYkePl5VawQvekDF4Vjtfddbd3AnsWSyiNWDYHuvOppsdk6sYICs Yur2LJxBip9B4qKR1ExZ+8zYH/bj9dcBLXWIOPPnRRvdRF13eQwPv+oCTL/TMjKKI68J isXvttcE85zjnjRxUoqskjmx1BqBX6hRrWriTPv933+AsxThAlafuW5+QAEjE+6RafLL SxTYI6NPp98O5Rih81qaHXCxpuJNjgpVGyFKV3NidX4NuGh2v7YH2IOzQB6ea8FP0GcB MadfBHQ67Jtzo4jgt4GqwXoY4e6mI2rrStxRY79XKjnGyBLiocQPxO2olf2ofqKxE103 Ljyg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si2305153ejj.645.2021.05.21.02.59.49; Fri, 21 May 2021 03:00:12 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232552AbhEUGyb (ORCPT + 99 others); Fri, 21 May 2021 02:54:31 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3460 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbhEUGy2 (ORCPT ); Fri, 21 May 2021 02:54:28 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FmcgD5sj3zCswv; Fri, 21 May 2021 14:50:16 +0800 (CST) Received: from dggema765-chm.china.huawei.com (10.1.198.207) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 21 May 2021 14:53:04 +0800 Received: from [10.174.185.210] (10.174.185.210) by dggema765-chm.china.huawei.com (10.1.198.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 21 May 2021 14:53:04 +0800 Subject: Re: [RFC PATCH v1 0/2] iommu/arm-smmu-v3: Add some parameter check in __arm_smmu_tlb_inv_range() To: Robin Murphy , Will Deacon , "Eric Auger" , "moderated list:ARM SMMU DRIVERS" , "open list:IOMMU DRIVERS" , open list CC: References: <20210519094307.3275-1-jiangkunkun@huawei.com> From: Kunkun Jiang Message-ID: <0f4e8394-72e1-e837-d98f-4998b9a71097@huawei.com> Date: Fri, 21 May 2021 14:53:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.185.210] X-ClientProxiedBy: dggeme708-chm.china.huawei.com (10.1.199.104) To dggema765-chm.china.huawei.com (10.1.198.207) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On 2021/5/19 18:01, Robin Murphy wrote: > On 2021-05-19 10:43, Kunkun Jiang wrote: >> Hi all, >> >> This set of patches solves some errors when I tested the SMMU nested >> mode. >> >> Test scenario description: >> guest kernel: 4KB translation granule >> host kernel: 16KB translation granule >> >> errors: >> 1. encountered an endless loop in __arm_smmu_tlb_inv_range because >> num_pages is 0 >> 2. encountered CERROR_ILL because the fields of TLB invalidation >> command are as follow: TG = 2, NUM = 0, SCALE = 0, TTL = 0. The >> combination is exactly the kind of reserved combination pointed >> out in the SMMUv3 spec(page 143-144, version D.a) >> >> In my opinion, it is more appropriate to add parameter check in >> __arm_smmu_tlb_inv_range(), although these problems only appeared >> when I tested the SMMU nested mode. What do you think? > > FWIW I think it would be better to fix the caller to not issue broken > commands in the first place. The kernel shouldn't do so for itself > (and definitely needs fixing if it ever does), so it sounds like the > nesting implementation needs to do a bit more validation of what it's > passing through. Thanks for your reply. I will report these errors to Eric and discuss how to fix them. Thanks, Kunkun Jiang > > Robin. > >> This series include patches as below: >> Patch 1: >> - align the invalid range with leaf page size upwards when smmu >> supports RIL >> >> Patch 2: >> - add a check to standardize granule size when smmu supports RIL >> >> Kunkun Jiang (2): >>    iommu/arm-smmu-v3: Align invalid range with leaf page size upwards >>      when support RIL >>    iommu/arm-smmu-v3: Standardize granule size when support RIL >> >>   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 +++++++++ >>   1 file changed, 9 insertions(+) >> > .