Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4035625imm; Tue, 29 May 2018 20:18:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzYVBFdmhX31jg/GP4geVnXxn6UcS3Zsvl1tcXFFfmBTwdK+EdBdSZMwoKJ8a7XU/7HxKJ X-Received: by 2002:a65:61c8:: with SMTP id j8-v6mr813321pgv.370.1527650335470; Tue, 29 May 2018 20:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527650335; cv=none; d=google.com; s=arc-20160816; b=He/BFgedqQGT4JFydwBao7ulCx5bjrKA9RJ1ZmIIYC9dqqZSIviIIZffJTcqkYNSBL Xb88fEhaBUrH8xvOul6U8XxrlcfNI2ej/OIbO5w65AlpeWQbzt7Zf9W5R7DcfKrnoiqL nU2IoC9FzQWvn4de2mKkSvxPb7mAY7ruRZkIlI+1Tw1DPuyw4NNoPaNgeqZLhM0Fl+IW uz7urAKFWmNyBLjhS+1JBg6i/ZJobmKkHtkmKrpgbd5Bjvw0WsYbCHApMJuXaj6yiJq7 Hz8uu21e/qNU7bOfJlsEUi7y/Deyp6FxcIcb+FVo/pSe9CnJUc6zk11u7ZlwGIbpMJrO mLvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=+G6PCxZd1jueWtqHMoehGjIxMsMCi7NTMEno9hrPOLw=; b=eSmWHc5Mo49MyG2yzW3ZzrTXs63PtlZd5w2CMd/o8ncY7a9tIBwJTlcrKd/X/s/TKW hMd/3bc3VKIzpbdkf91xijBSvuOfIATyEFbmuctryy1SSsee6+SnGiO5QzfCd2rcIcu+ iykqBcV2+Q1e2Px90Gg6iRmxyogbRNPqQxONnUT3MSojxFHtfz/FxSKlJiYFtpT6ps04 jaUMuUJD+z6W9mzDqnOd3QxB+0afSBZT4R4lZzneACp+Ryxq1nq+5FXKK3prC0srQC/w idhwTBCpbI7F7RoQoEW2tGgfypt3wYth6agJAYonAQf6FayjAWNqwoTyY4i6o1lIZZzE HHqA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si17527878pgn.334.2018.05.29.20.18.41; Tue, 29 May 2018 20:18:55 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965153AbeE3DR7 (ORCPT + 99 others); Tue, 29 May 2018 23:17:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935743AbeE3DRs (ORCPT ); Tue, 29 May 2018 23:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8E537E43C; Wed, 30 May 2018 03:17:47 +0000 (UTC) Received: from w520.home (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94C0412A71; Wed, 30 May 2018 03:17:46 +0000 (UTC) Date: Tue, 29 May 2018 21:17:46 -0600 From: Alex Williamson To: "Tian, Kevin" Cc: Jacob Pan , Jean-Philippe Brucker , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , "David Woodhouse" , Greg Kroah-Hartman , "Wysocki, Rafael J" , "Liu, Yi L" , "Raj, Ashok" , Jean Delvare , Christoph Hellwig , Lu Baolu , Yi L Subject: Re: [PATCH v4 04/22] iommu/vt-d: add bind_pasid_table function Message-ID: <20180529211746.74f1dd23@w520.home> In-Reply-To: References: <1523915351-54415-1-git-send-email-jacob.jun.pan@linux.intel.com> <1523915351-54415-5-git-send-email-jacob.jun.pan@linux.intel.com> <20180417131047.0a9c310f@w520.home> <20180420164251.5245f822@jacob-builder> <20180529140915.1f174689@w520.home> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 30 May 2018 03:17:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 May 2018 01:41:43 +0000 "Tian, Kevin" wrote: > > From: Alex Williamson [mailto:alex.williamson@redhat.com] > > Sent: Wednesday, May 30, 2018 4:09 AM > > > > On Fri, 20 Apr 2018 16:42:51 -0700 > > Jacob Pan wrote: > > > > > On Fri, 20 Apr 2018 19:25:34 +0100 > > > Jean-Philippe Brucker wrote: > > > > > > > On Tue, Apr 17, 2018 at 08:10:47PM +0100, Alex Williamson wrote: > > > > [...] > > > > > > + /* Assign guest PASID table pointer and size order */ > > > > > > + ctx_lo = (pasidt_binfo->base_ptr & VTD_PAGE_MASK) | > > > > > > + (pasidt_binfo->pasid_bits - MIN_NR_PASID_BITS); > > > > > > > > > > Where does this IOMMU API interface define that base_ptr is 4K > > > > > aligned or the format of the PASID table? Are these all > > > > > standardized or do they vary by host IOMMU? If they're standards, > > > > > maybe we could note that and the spec which defines them when we > > > > > declare base_ptr. If they're IOMMU specific then I don't > > > > > understand how we'll match a user provided PASID table to the > > > > > requirements and format of the host IOMMU. Thanks, > > > > > > > > On SMMUv3 the minimum alignment for base_ptr is 64 bytes, so a > > guest > > > > under a vSMMU might pass a pointer that's not aligned on 4k. > > > > > > > PASID table pointer for VT-d is 4K aligned. > > > > Maybe this information could be part of the data passed to userspace > > > > about IOMMU table formats and features? They're not part of this > > > > series, but I think we wanted to communicate IOMMU-specific features > > > > via sysfs. > > > > > > > Agreed, I believe Yi Liu is working on a sysfs interface such that QEMU > > > can match IOMMU model and features. > > > > Digging this up again since v5 still has this issue. The IOMMU API is > > a kernel internal abstraction of the IOMMU. sysfs is a userspace > > interface. Are we suggesting that the /only/ way to make use of the > > internal IOMMU API here is to have a user provided opaque pasid table > > that we can't even do minimal compatibility sanity testing on and we > > simply hope that hardware covers all the fault conditions without > > taking the host down with it? I guess we have to assume the latter > > since the user has full control of the table, but I have a hard time > > getting past lack of internal ability to use the interface and no > > ability to provide even the slimmest sanity testing. Thanks, > > > > checking size, alignment, ... is OK, which I think is already considered > by vendor IOMMU driver. However sanity testing table format might > be difficult. The initial table provided by guest is likely just all ZEROs. > whatever format violation may be caught only when a PASID entry > is updated... There's sanity testing the actual contents of the table, which I agree would be difficult and would likely require some sort of shadowing at additional overhead, but what about even basic consistency checking? For example, is it possible that due to hardware variations a user might generate a table which works on some systems but not others? What if two table formats are sufficiently similar that the IOMMU driver puts an incompatible table in place but it continuously generates faults, how do we debug that? As an intermediary in this whole process I'd really rather be able to identify that the user claims to be providing a TypeA table but the IOMMU only supports TypeB, so clearly this won't work. I don't see that we have that capability. Thanks, Alex