Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp946668pxj; Fri, 21 May 2021 02:56:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjjcppv0xdSvbwQ81EDsqjuCYxb4EQei/TRSJBuHD5kk06/skBrFelqSf1uIg+ArsXwOSs X-Received: by 2002:a05:6402:2714:: with SMTP id y20mr10112945edd.348.1621590990802; Fri, 21 May 2021 02:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621590990; cv=none; d=google.com; s=arc-20160816; b=ZXbEzSn/hN4g4pvNP+2iiETNUH4+fFO/Vd82eByLteLHxR2Vmc7EGB0/hPnajsQ3R4 EL35soWanANte5Mba7+uzN64wxZz4Wp1sJiH0LcDpEfWMRG54eTgV6OmaPRRHzeo2945 nvCsEl27j/beduE1DeyM19hD8zDoV6DIV9RU6TVJPBlBIg0lOy8pbGQo0ho66HZA3fQ/ RoVjpAL9k+I90tfr7PInv8lQORGBK9kaUdNg7afQH6rYA/lwDHoaGE6lualLigoYzzN2 fryM5kwNKsTunZ02CvS6HZop9CRJsqqb32726mVR1zPVyVMEun7ftcnki+H5yRTN0ahN rU7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=N2kiU4glsP8t5TXU8Wfim3qWiuTSc6ivf2Gh1w4ggco=; b=A2Ja8ve20RZDvbFDCE03gFy+FYmCKFqxEb7eTGCMhzaPmip1h1UyKfnFn3U1P7jz4A NlExhtrb+jbkH0tm0Mgtrc+0ojsuSeRIqbIj4y7uGbFqFNR1rxyQ/a465SlR8Eq06f4o wJ3WjH0U+Wf/kxwG/bYTdrR63F/n2R6xigIvBV1Ix4egtieQ7nnX3UM5C5yiZS3kQa9i DWYx3toA6RPZk3ZYmxc9SFgHfA/wxfPiCaNVO4qiSv6vMLaaHMNpJHeU7yN9xYtMWR77 rNmwB9BEeOiTkEEHN9n8M/kqXfRIL7AEj4tVSI71YkupadA4pryu0cj4C0UIvg0iRv1D ynHg== 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 g18si4643957edb.157.2021.05.21.02.56.07; Fri, 21 May 2021 02:56:30 -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 S232864AbhEUGma (ORCPT + 99 others); Fri, 21 May 2021 02:42:30 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3458 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbhEUGi4 (ORCPT ); Fri, 21 May 2021 02:38:56 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FmcKG17ZbzCvPY; Fri, 21 May 2021 14:34:42 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 21 May 2021 14:37:30 +0800 Received: from [10.174.187.155] (10.174.187.155) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 21 May 2021 14:37:29 +0800 Subject: Re: [RFC PATCH v3 1/8] iommu: Evolve the device fault reporting framework To: Alex Williamson , Lu Baolu , Kevin Tian CC: Cornelia Huck , Will Deacon , "Robin Murphy" , Joerg Roedel , "Jean-Philippe Brucker" , Eric Auger , , , , , , , Christoph Hellwig , Jonathan Cameron , "Barry Song" , , References: <20210409034420.1799-1-lushenming@huawei.com> <20210409034420.1799-2-lushenming@huawei.com> <20210518125843.68552b67.alex.williamson@redhat.com> From: Shenming Lu Message-ID: Date: Fri, 21 May 2021 14:37:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20210518125843.68552b67.alex.williamson@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.155] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/19 2:58, Alex Williamson wrote: > On Fri, 9 Apr 2021 11:44:13 +0800 > Shenming Lu wrote: > >> This patch follows the discussion here: >> >> https://lore.kernel.org/linux-acpi/YAaxjmJW+ZMvrhac@myrica/ >> >> Besides SVA/vSVA, such as VFIO may also enable (2nd level) IOPF to remove >> pinning restriction. In order to better support more scenarios of using >> device faults, we extend iommu_register_fault_handler() with flags and >> introduce FAULT_REPORT_ to describe the device fault reporting capability >> under a specific configuration. >> >> Note that we don't further distinguish recoverable and unrecoverable faults >> by flags in the fault reporting cap, having PAGE_FAULT_REPORT_ + >> UNRECOV_FAULT_REPORT_ seems not a clean way. >> >> In addition, still take VFIO as an example, in nested mode, the 1st level >> and 2nd level fault reporting may be configured separately and currently >> each device can only register one iommu dev fault handler, so we add a >> handler update interface for this. > > > IIUC, you're introducing flags for the fault handler callout, which > essentially allows the IOMMU layer to filter which types of faults the > handler can receive. You then need an update function to modify those > flags. Why can't the handler itself perform this filtering? For > instance in your vfio example, the handler registered by the type1 > backend could itself return fault until the fault transfer path to the > device driver is established. Thanks, As discussed in [1]: In nested IOPF, we have to figure out whether a fault comes from L1 or L2. A SMMU stall event comes with this information, but a PRI page request doesn't. The IOMMU driver can walk the page tables to find out the level information. If the walk terminates at L1, further inject to the guest. Otherwise fix the fault at L2 in VFIO. It's not efficient compared to hardware-provided info. And in pinned case, if VFIO can tell the IOMMU driver that no L2 fault is expected, there is no need to walk the page tables in the IOMMU driver? [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210108145217.2254447-4-jean-philippe@linaro.org/ Thanks, Shenming > > Alex > > . >