Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1196172imm; Tue, 5 Jun 2018 10:30:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIwXf2x1nM1RxdpOcacV0Ged2jzye6IhUNyj3Zt9aONMtSWl7nXjVfslHvHpBR9hBn44CJs X-Received: by 2002:a63:7986:: with SMTP id u128-v6mr5254258pgc.273.1528219833907; Tue, 05 Jun 2018 10:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528219833; cv=none; d=google.com; s=arc-20160816; b=rQuQbzwdDrvv48K/VcGeQrCU3RQs6oscxZCLFHAxHDHBpzEtqgMmRy5QD1AjX6OsoH wk/yB9mnl11egD2J2+UkKmjCSP0e+pAuyLgUQT/ZjHlypsKAghp50EbDGk9ACWdvQWE8 2+FBFnadzb8awCRrIQC9wORA27UZ3NR168421gGhwn4yik/e8sNLYGd+2kiUSJbZkN4+ MKh7KpVn0/f6UpcxaLOi1Kqh2+7s5kkx9cOMghKLHG8DA8iOGGHNOcKu1rWL3HGuLlta RrOO1+9J10NVD6H1cbz8jGyMeam8p2AGSnPo1A4CmesGw3Th5yivYZI75PmX45k5WWfp jAAw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=MkhXcMVkxQsyqp0tfJnfwZmkJE1Ighj8BUeRUIcOwNw=; b=WGop0JruHClKa7DVSuPQqcRv730OJTO76cExPpqALFr8MqGvo6keDn7xQAt7bi8uLp ujZgzkQwIar7nwz/xeL/ngbSEPjDwt9Oija4P4OgrwivnJqZV3g5ykAPS+niq/plMQTN BS6ycbkPGLB9+fTsEQc4lDTGQGlzL2iZ8OVuM31RGA/f0e7TD8tTzYdSc5xdTgHlyj+b OlmcUW+qWWcuKGZB9sfQmjB2MZ1LnNQfeqqgK/qaQvCqBlPfpcUHcHe9p9TGZsI5RH8o 5nm3VKOIsqO5QQ5W991oK5kgZxLjVrJ+UCJA9/eAoOshiCU/qGd2OhobucZiveZzNCo6 tFPA== 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 b37-v6si50012119plb.377.2018.06.05.10.30.19; Tue, 05 Jun 2018 10:30:33 -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 S1752124AbeFER34 (ORCPT + 99 others); Tue, 5 Jun 2018 13:29:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:16179 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeFER3z (ORCPT ); Tue, 5 Jun 2018 13:29:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2018 10:29:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,479,1520924400"; d="scan'208";a="64534862" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga002.jf.intel.com with ESMTP; 05 Jun 2018 10:29:54 -0700 Date: Tue, 5 Jun 2018 10:32:53 -0700 From: Jacob Pan To: Jean-Philippe Brucker Cc: "Tian, Kevin" , Alex Williamson , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , "Wysocki, Rafael J" , "Liu, Yi L" , "Raj, Ashok" , Christoph Hellwig , Lu Baolu , Yi L , Auger Eric , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v4 04/22] iommu/vt-d: add bind_pasid_table function Message-ID: <20180605103253.634ef8fd@jacob-builder> In-Reply-To: <1c1094e8-ecbb-7731-910c-59e4de1e5c70@arm.com> 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> <20180529211746.74f1dd23@w520.home> <20180530125240.34e0e80c@jacob-builder> <1c1094e8-ecbb-7731-910c-59e4de1e5c70@arm.com> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 31 May 2018 10:09:46 +0100 Jean-Philippe Brucker wrote: > On 30/05/18 20:52, Jacob Pan wrote: > >> However I think the model number should be added to > >> pasid_table_config. For one thing it gives us a simple > >> sanity-check, but it also tells which other fields are valid in > >> pasid_table_config. Arm-smmu-v3 needs at least two additional > >> 8-bit fields describing the PASID table format (number of levels > >> and PASID0 behaviour), which are written to device context tables > >> when installing the PASID table pointer. > >> > > We had model number field in v2 of this patchset. My thought was > > that since the config info is meant to be generic, we shouldn't > > include model info. But I also think a simple sanity check can be > > useful, would that be sufficient to address Alex's concern? Of > > course we still need sysfs for more specific IOMMU features. > > > > Would this work? > > enum pasid_table_model { > > PASID_TABLE_FORMAT_HOST, > > PASID_TABLE_FORMAT_ARM_1LVL, > > PASID_TABLE_FORMAT_ARM_2LVL, > > I'd rather use a single PASID_TABLE_FORMAT_ARM, because "2LVL" may be > further split into 2LVL_4k or 2LVL_64k leaf tables... I think it's > best if I add an arch-specific field in pasid_table_config for that, > and for the PASID0 configuration, when adding FORMAT_ARM in a future > patch > sounds good. will only use PASID_TABLE_FORMAT_ARM. > > PASID_TABLE_FORMAT_AMD, > > PASID_TABLE_FORMAT_INTEL, > > }; > > > > /** > > * PASID table data used to bind guest PASID table to the host > > IOMMU. This will > > * enable guest managed first level page tables. > > * @version: for future extensions and identification of the data > > format > > * @bytes: size of this structure > > * @model: PASID table format for different IOMMU models > > * @base_ptr: PASID table pointer > > * @pasid_bits: number of bits supported in the guest PASID > > table, must be less > > * or equal than the host supported PASID size. > > */ > > struct pasid_table_config { > > __u32 version; > > #define PASID_TABLE_CFG_VERSION_1 1 > > __u32 bytes; > > "bytes" could be passed by VFIO as argument to bind_pasid_table, since > it can deduce it from argsz > Are you suggesting we wrap this struct in a vfio struct with argsz? or we directly use this struct? I need to clarify how vfio will use this. - User program: struct pasid_table_config ptc = { .bytes = sizeof(ptc) }; ptc.version = 1; ioctl(device, VFIO_DEVICE_BIND_PASID_TABLE, &ptc); - Kernel: minsz = offsetofend(struct pasid_table_config, pasid_bits); if (ptc.bytes < minsz) return -EINVAL;