Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp576441pxj; Thu, 3 Jun 2021 13:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm3OBxc/UdNQ/VgMIaAt7d2vqu4+jTBADZK5lj++QIqq5RX33XJDBBAktI/acmt7pJGHDO X-Received: by 2002:a05:6402:42c1:: with SMTP id i1mr1305663edc.62.1622753917358; Thu, 03 Jun 2021 13:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622753917; cv=none; d=google.com; s=arc-20160816; b=GIFAEXvhwrPUvhP+8o8fwl1rdzs7fyIIPI67GVg3C2hEC1O1hX/msv28JTc/K3YKKu O65p+X4TsUzobKTunXaOatgWDf2NWjHmPkH4h770PgBtoE0YvgsWWtRhA2pj0BnO6wyL 18SduKvXBUWvT93S9+wnFgIsonphZKoRoR0JC6xbPCBn26KVV9crDWHLwrqD+YveQjog p0ipMl2QzfNkE7mdPnqblQ2jrcguZd/O7mBomorzIPL+EWGCz5ttY/FYMqAfW8fK7kgl 3GvSrEg9mD9KLr3+Ag5AG2uOaJMqLxkOdNYQp+2i6j/ePzCyHkStK97fZhtWPaV6xVNc /ggA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=ajePSH6w747RFvt0ha1FsGJdPjgE8NrO8G+5ql2P4ls=; b=rOeTkRaDbZua0gdPS6/M+wyLf7GYtqS3SDjXv2sLUgfiuQ6nqfhrPNY2y2vKg8As2e HJoHzneWhSPCMw/r9bzkCD8L5icaTd2oa3NRvsed50pNIpkv7uJeUFtOl7zf/3Z31drb jBbPlPBYXz/QOFvy0jWFSu/ZnAnygCSRFGrL7rToPAwRzrJI1K+AynIvd4oTX/3NB7tj tJrTcCAj6G7RUfG4Vn9s6Ob9t20tvmowICKyBxtBS3Md9yYOm42AB/DBwF4lTCOkhc/s ow9NOezo7qAuYbvEA1vr45+JOF8ZwkJ47k8rmuYK2S8ClZt0IlX2n1uOgzYDlRrB/ldA JgNw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si3252922edr.562.2021.06.03.13.58.13; Thu, 03 Jun 2021 13:58:37 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbhFCU5b (ORCPT + 99 others); Thu, 3 Jun 2021 16:57:31 -0400 Received: from mga17.intel.com ([192.55.52.151]:49788 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhFCU5b (ORCPT ); Thu, 3 Jun 2021 16:57:31 -0400 IronPort-SDR: a8UHUQzXeCCct5iRLQjh54zfo0Di1P+RaEo4T/+yggl/05A3ylQnmc1LAeI5Sbfe+LZG77xtqe MbFJNNLr7tmw== X-IronPort-AV: E=McAfee;i="6200,9189,10004"; a="184521561" X-IronPort-AV: E=Sophos;i="5.83,246,1616482800"; d="scan'208";a="184521561" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2021 13:55:32 -0700 IronPort-SDR: MjfM7yT9NG79x395JzZW/keo/oszVCbdecgt/yty7PosWCm9vajnPWokqPWAK11mHE//JujYHK b3hP56vtGhcA== X-IronPort-AV: E=Sophos;i="5.83,246,1616482800"; d="scan'208";a="550306458" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2021 13:55:30 -0700 Date: Thu, 3 Jun 2021 13:58:07 -0700 From: Jacob Pan To: Parav Pandit Cc: "Tian, Kevin" , LKML , Joerg Roedel , Jason Gunthorpe , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Alex Williamson (alex.williamson@redhat.com)" , Jason Wang , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jean-Philippe Brucker , David Gibson , Kirti Wankhede , Robin Murphy , jacob.jun.pan@linux.intel.com Subject: Re: [RFC] /dev/ioasid uAPI proposal Message-ID: <20210603135807.40684468@jacob-builder> In-Reply-To: References: Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Parav, On Tue, 1 Jun 2021 17:30:51 +0000, Parav Pandit wrote: > > From: Tian, Kevin > > Sent: Thursday, May 27, 2021 1:28 PM > > > 5.6. I/O page fault > > +++++++++++++++ > > > > (uAPI is TBD. Here is just about the high-level flow from host IOMMU > > driver to guest IOMMU driver and backwards). > > > > - Host IOMMU driver receives a page request with raw fault_data {rid, > > pasid, addr}; > > > > - Host IOMMU driver identifies the faulting I/O page table according > > to information registered by IOASID fault handler; > > > > - IOASID fault handler is called with raw fault_data (rid, pasid, > > addr), which is saved in ioasid_data->fault_data (used for response); > > > > - IOASID fault handler generates an user fault_data (ioasid, addr), > > links it to the shared ring buffer and triggers eventfd to userspace; > > > > - Upon received event, Qemu needs to find the virtual routing > > information (v_rid + v_pasid) of the device attached to the faulting > > ioasid. If there are multiple, pick a random one. This should be fine > > since the purpose is to fix the I/O page table on the guest; > > > > - Qemu generates a virtual I/O page fault through vIOMMU into guest, > > carrying the virtual fault data (v_rid, v_pasid, addr); > > > Why does it have to be through vIOMMU? I think this flow is for fully emulated IOMMU, the same IOMMU and device drivers run in the host and guest. Page request interrupt is reported by the IOMMU, thus reporting to vIOMMU in the guest. > For a VFIO PCI device, have you considered to reuse the same PRI > interface to inject page fault in the guest? This eliminates any new > v_rid. It will also route the page fault request and response through the > right vfio device. > I am curious how would PCI PRI can be used to inject fault. Are you talking about PCI config PRI extended capability structure? The control is very limited, only enable and reset. Can you explain how would page fault handled in generic PCI cap? Some devices may have device specific way to handle page faults, but I guess this is not the PCI PRI method you are referring to? > > - Guest IOMMU driver fixes up the fault, updates the I/O page table, > > and then sends a page response with virtual completion data (v_rid, > > v_pasid, response_code) to vIOMMU; > > > What about fixing up the fault for mmu page table as well in guest? > Or you meant both when above you said "updates the I/O page table"? > > It is unclear to me that if there is single nested page table maintained > or two (one for cr3 references and other for iommu). Can you please > clarify? > I think it is just one, at least for VT-d, guest cr3 in GPA is stored in the host iommu. Guest iommu driver calls handle_mm_fault to fix the mmu page tables which is shared by the iommu. > > - Qemu finds the pending fault event, converts virtual completion data > > into (ioasid, response_code), and then calls a /dev/ioasid ioctl to > > complete the pending fault; > > > For VFIO PCI device a virtual PRI request response interface is done, it > can be generic interface among multiple vIOMMUs. > same question above, not sure how this works in terms of interrupts and response queuing etc. > > - /dev/ioasid finds out the pending fault data {rid, pasid, addr} > > saved in ioasid_data->fault_data, and then calls iommu api to complete > > it with {rid, pasid, response_code}; > > Thanks, Jacob