Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp6366228imm; Sun, 20 May 2018 01:19:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZop/eChSff8E7Cp7NuRg3BESXPopeFSH6ylVkG2X2dxm6/MF6lpH24QpM0jf5DYbGJCsJ+d X-Received: by 2002:a17:902:206:: with SMTP id 6-v6mr8075450plc.294.1526804376510; Sun, 20 May 2018 01:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526804376; cv=none; d=google.com; s=arc-20160816; b=Cf0cbv/CU08UvOP8ra7brZ0ADNbYKUUTmUnuI5UFtk2IyhBE3BRkzNiEKOz3gGWjrD CVPk0BTYZ0CaFvsyMHcTyZrCJe6cxfwIRXPeDJCA7pU8vhk4VLyrxfpGRFXOT58h2M7T Gujwgr5T0ooyVnSwX9K3xZ0aosCT+l9V0aIo5aOebuVYRHqBlMvzYZP+lQchznJq1OnS 6Ye94Px2OPaRxKo3YVLFS7mvKaIlqavOTtBYvx3g8MrP1dqbgATrc447H1+Oqv/2r6wi 2rExc6PpyJAHVgzH/6KnNo4jBjfWF5MGJx/K9cD+COziaSmhFR/Yo7qb/yH/gvWXV49a lFkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=keS7bcOWvgyZUy2XnLxemaEbc5N7snKluHrrmKGnSrA=; b=JGrHkD1E7k2tMaxEOigXicuwJ+VcVEUmJrp0HcUbfanyImDXmzkaQSc0FgkbarhKet XrDfm4MlJRu8qzOfW4MR9qM5iCxDClBG+SILl1Crj5yvDkLbdwRKsGmgsBnMmqKgsnBJ BMLO/YyV6cQ2JV18j8Ak7HmCFWc25mcAkaJn3KrIgdExeSHjb1FJdZLcZtLKYSPuMFQK YgiVwpVdHTyy3LTIeS2ue76j0aA/vgRCRxbb665ia4krawAV11D23+P0qvzMpOaucveQ 8ZbtxD2mWXyu/NhkBXksmoAGb5OFcEnXAGLRGy2xNeUky1ifIKILq4fo2XpZLAEUd6GO wePw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14-v6si8705822pgn.521.2018.05.20.01.19.22; Sun, 20 May 2018 01:19:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751408AbeETIRv convert rfc822-to-8bit (ORCPT + 99 others); Sun, 20 May 2018 04:17:51 -0400 Received: from mga02.intel.com ([134.134.136.20]:51106 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbeETIRs (ORCPT ); Sun, 20 May 2018 04:17:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 May 2018 01:17:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,422,1520924400"; d="scan'208";a="43236986" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 20 May 2018 01:17:47 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 20 May 2018 01:17:46 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.240]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Sun, 20 May 2018 16:17:44 +0800 From: "Liu, Yi L" To: Jacob Pan CC: "Wysocki, Rafael J" , "Tian, Kevin" , "Raj, Ashok" , Jean Delvare , Christoph Hellwig , Lu Baolu , Yi L , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , "David Woodhouse" , Greg Kroah-Hartman , Alex Williamson , Jean-Philippe Brucker Subject: RE: [PATCH v4 10/22] iommu: introduce device fault data Thread-Topic: [PATCH v4 10/22] iommu: introduce device fault data Thread-Index: AQHT1cxs8lFP2WE/GEWKfhv4WmyUHaQ4ZabA Date: Sun, 20 May 2018 08:17:43 +0000 Message-ID: References: <1523915351-54415-1-git-send-email-jacob.jun.pan@linux.intel.com> <1523915351-54415-11-git-send-email-jacob.jun.pan@linux.intel.com> In-Reply-To: <1523915351-54415-11-git-send-email-jacob.jun.pan@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTUyNTMwZTYtZTUzZi00MDcyLWJlMmUtNGVhMGE1ZWJiMTc5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiS0VLcytTZ1RMNFdoTm51TndJeGRrdlVpTlVhQ2lHOEY1U29kc1wvTFloTDdxZEF0anVlQnlObHJmdDdrSnpWNEoifQ== x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, > From: Jacob Pan [mailto:jacob.jun.pan@linux.intel.com] > Sent: Tuesday, April 17, 2018 5:49 AM > include/linux/iommu.h | 102 > +++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 100 insertions(+), 2 deletions(-) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index e963dbd..8968933 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -49,13 +49,17 @@ struct bus_type; > struct device; > struct iommu_domain; > struct notifier_block; > +struct iommu_fault_event; > > /* iommu fault flags */ > -#define IOMMU_FAULT_READ 0x0 > -#define IOMMU_FAULT_WRITE 0x1 > +#define IOMMU_FAULT_READ (1 << 0) > +#define IOMMU_FAULT_WRITE (1 << 1) > +#define IOMMU_FAULT_EXEC (1 << 2) > +#define IOMMU_FAULT_PRIV (1 << 3) > > typedef int (*iommu_fault_handler_t)(struct iommu_domain *, > struct device *, unsigned long, int, void *); > +typedef int (*iommu_dev_fault_handler_t)(struct iommu_fault_event *, void *); > > struct iommu_domain_geometry { > dma_addr_t aperture_start; /* First address that can be mapped */ > @@ -264,6 +268,99 @@ struct iommu_device { > struct device *dev; > }; > > +/* Generic fault types, can be expanded IRQ remapping fault */ > +enum iommu_fault_type { > + IOMMU_FAULT_DMA_UNRECOV = 1, /* unrecoverable fault */ > + IOMMU_FAULT_PAGE_REQ, /* page request fault */ > +}; > + > +enum iommu_fault_reason { > + IOMMU_FAULT_REASON_UNKNOWN = 0, > + > + /* IOMMU internal error, no specific reason to report out */ > + IOMMU_FAULT_REASON_INTERNAL, > + > + /* Could not access the PASID table */ > + IOMMU_FAULT_REASON_PASID_FETCH, > + > + /* > + * PASID is out of range (e.g. exceeds the maximum PASID > + * supported by the IOMMU) or disabled. > + */ > + IOMMU_FAULT_REASON_PASID_INVALID, > + > + /* Could not access the page directory (Invalid PASID entry) */ > + IOMMU_FAULT_REASON_PGD_FETCH, > + > + /* Could not access the page table entry (Bad address) */ > + IOMMU_FAULT_REASON_PTE_FETCH, > + > + /* Protection flag check failed */ > + IOMMU_FAULT_REASON_PERMISSION, > +}; > + > +/** > + * struct iommu_fault_event - Generic per device fault data > + * > + * - PCI and non-PCI devices > + * - Recoverable faults (e.g. page request), information based on PCI ATS > + * and PASID spec. > + * - Un-recoverable faults of device interest > + * - DMA remapping and IRQ remapping faults > + > + * @type contains fault type. > + * @reason fault reasons if relevant outside IOMMU driver, IOMMU driver internal > + * faults are not reported > + * @addr: tells the offending page address > + * @pasid: contains process address space ID, used in shared virtual memory(SVM) > + * @rid: requestor ID > + * @page_req_group_id: page request group index > + * @last_req: last request in a page request group > + * @pasid_valid: indicates if the PRQ has a valid PASID > + * @prot: page access protection flag, e.g. IOMMU_FAULT_READ, > IOMMU_FAULT_WRITE > + * @device_private: if present, uniquely identify device-specific > + * private data for an individual page request. > + * @iommu_private: used by the IOMMU driver for storing fault-specific > + * data. Users should not modify this field before > + * sending the fault response. > + */ > +struct iommu_fault_event { > + enum iommu_fault_type type; > + enum iommu_fault_reason reason; > + u64 addr; > + u32 pasid; > + u32 page_req_group_id; > + u32 last_req : 1; > + u32 pasid_valid : 1; > + u32 prot; I think userspace also needs to know the fault type, reason, pasid, addr, goup_id, prot. So the definition should be included in uapi/Linux/iommu.h. This comment also applies to "struct page_response_msg". Qemu also wants to pass the page response to host. > + u64 device_private; > + u64 iommu_private; These two seems to be in kernel driver specific data. May split the iommu_fault_event definition into two parts. One part for the data required by both driver and userspace. One part for in kernel driver specific data. Thanks, Yi Liu