Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp386040imm; Thu, 31 May 2018 02:11:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKIBgakK1wr1W5S6S8xOmftWYCaekzHS0ZiHT4a5TfbCGs+cxJ9LPnNX+Qgio2orEwKfrgt X-Received: by 2002:a62:48cd:: with SMTP id q74-v6mr5940589pfi.153.1527757865996; Thu, 31 May 2018 02:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527757865; cv=none; d=google.com; s=arc-20160816; b=CbIGhQ2RMqdCN7l7e/u+x2Y4Ykugq+qJ2LGrig84b7Up88xD8EG3IPmHDY4HtcI/UK WYPy+uX2sA2+fVB83UrdNUGAE6IR+RuoF7sPbCpizZMOJusytCNdpiY9YAaSO1Cd90is okjNKwpkzOZAVhExGq9xPCsu4v1XTbrnW3nHN04hzBctYXAnX2+0+x6DWxQVY2WWM7NK +CZVnTuSAaNFc9kaoTEiw5v1oku1DHB+cto/7pWMZryL1svc3dxPqY6xAspCTid3xMjX ck0SaLkx6pCBZatKOTuGd9i44Oknf6cbht4vyazSzXcK1KUsLnJ0bqRNvqW/LjLHVq2F RbqQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=7qJcCh0+Vfni2/mDsP5t7ey/nPYDZvbRVLqS1um3Zmk=; b=VjJ1sGGVuNC7jdvZl3HNtO2qOSG2JYOwfp7dsyWRLX1j/mOSVB6AU/nK4ZMn/AguWT SK1oIsCnpYYFiBtiu7wJG+9ALhxJ+kTl7Njdjpo4lv/FK/bf/HTPcq7i9Ph5ay9iSqd5 WsL+AjwL55c/Mk9ai6efY/xqh8csMr/Xs3j0zhOqPhxnO6XkAI6MD1Hx+W7C1L3XFr/y DlyH4ZVtqORCKDDSc5Cn1PzjhQIcNGvDtvJkErB5Mcks1R833Ozu2wic84xkT5pT5pLF HLevgr18l2lDuZWvn0pMHVoZCYr4ZCastxXFdPHeg1VbiNducu61+u5YiUL99m853B5t Pr4w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si37751475pfc.186.2018.05.31.02.10.51; Thu, 31 May 2018 02:11:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754217AbeEaJKB (ORCPT + 99 others); Thu, 31 May 2018 05:10:01 -0400 Received: from foss.arm.com ([217.140.101.70]:38326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754026AbeEaJJ5 (ORCPT ); Thu, 31 May 2018 05:09:57 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3A85C15AB; Thu, 31 May 2018 02:09:57 -0700 (PDT) Received: from [10.1.210.39] (ostrya.cambridge.arm.com [10.1.210.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D0E343F5A1; Thu, 31 May 2018 02:09:54 -0700 (PDT) Subject: Re: [PATCH v4 04/22] iommu/vt-d: add bind_pasid_table function To: Jacob Pan 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 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> From: Jean-Philippe Brucker Message-ID: <1c1094e8-ecbb-7731-910c-59e4de1e5c70@arm.com> Date: Thu, 31 May 2018 10:09:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180530125240.34e0e80c@jacob-builder> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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 Thanks, Jean > enum pasid_table_model model; > __u64 base_ptr; > __u8 pasid_bits; > }; > > > >> Compatibility: new optional features are easy to add to a given model, >> just add a new sysfs file. If in the future, the host describes a new >> feature that is mandatory, or implements a different PASID table >> format, how does it ensure that user understands it? Perhaps use a >> new model number for this, e.g. "arm-smmu-v3-a=3", with similar >> features. I think it would be the same if the host stops supporting a >> feature for a given model, because they are ABI. But we can also >> define default values from the start, for example "if ssid_bits file >> isn't present, default value is 0 - PASID not supported" >> >> Thanks, >> Jean > > [Jacob Pan] >