Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3893374pxj; Tue, 8 Jun 2021 00:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyphdTPeBWqChB608UuN99uKSLwiP5hktF2WUEcJnzh0sJY/vOewIbiqdz31R0C43m+f2rO X-Received: by 2002:a17:906:fcb5:: with SMTP id qw21mr21684752ejb.57.1623139077661; Tue, 08 Jun 2021 00:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623139077; cv=none; d=google.com; s=arc-20160816; b=Nm/oSHuuSX+itgnP21nGjQ4FFBhbjSfeFVZEEFxZ++oiIzTTRxakT73+BRnYa8iDBQ 26poJNbUPwsv/6jFZXSW0DSNYn9f8z43by0iiS2DpgIid7cBhlDptCiCV3v5Hya16dUR BoXJV59m+kebiV47OSPzbPFzftrOdV+BMca80lk5nwRHhzybnKwKCmhq9KQrarTi2wFa kijtXWIwqW54zHe0E6hUM9SMhrI/DUjM3qy7fYdWqnYNQbq2gagXAocfUJ3s6iUfRfEB l3U8VN39AJ9FIGH523dx8/UTQ4onL3JGwVrRIuEiZ/otMjLP4WWqVCCNqLMK7b0MyxBV opdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=zYa5WyN5uAc4A4H86TawfNojJdggPMlZ/sRJ1BGKDOY=; b=SFOchV/ClgaCyYme3M0qaAYRnA3HFwqrmrGBG6bLcydqevOcRVCJdODkRHtUVcIoi8 TxKWHWqgRVWy6QR3tu2HCJwyTh13tDRNdjjmdqmOt1ThhN38U9Yx0iclRtaX3Hje4NKX E6aXAfUSdIaH3JdAws/wua2O031sT+/DzEi7jUcPp/O4IYB95lrv7csGlCO0Nel93bnI N361xW+FZ/lFXjxPVkw0s2OnH8Mzm+xGwlUUd0Yi/8quiVKUuonAMDUZsc0CKgBluEVB RdYcdPOW3dIu9Go7NTV04yXHc6gAYQ6Vj3ye3DYU9Uj2vu/kHALf2rsINwF7vmM5Wh08 16Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YyVNsaTZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si14271390ejt.569.2021.06.08.00.57.33; Tue, 08 Jun 2021 00:57:57 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YyVNsaTZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbhFHH6K (ORCPT + 99 others); Tue, 8 Jun 2021 03:58:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53154 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhFHH6K (ORCPT ); Tue, 8 Jun 2021 03:58:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623138977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zYa5WyN5uAc4A4H86TawfNojJdggPMlZ/sRJ1BGKDOY=; b=YyVNsaTZxF0bso3/8Rt8E2/kzRfK16wIE3Idq6eAHoJrp1SB8735G0wWispRt+Eyj+0SXu vLD+CLbFDN/EffsQAyutqF1WU5ntshutH39UKhsk5RsrPGYxh8KGaJ2mOx9QgljO8ag3Tt FIx1W+JyGNmgWlosMeJwCpgM0AIkBCE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-wobENg64NDK06sTwou_suQ-1; Tue, 08 Jun 2021 03:56:13 -0400 X-MC-Unique: wobENg64NDK06sTwou_suQ-1 Received: by mail-wm1-f72.google.com with SMTP id h206-20020a1cb7d70000b0290198e478dfeaso422220wmf.3 for ; Tue, 08 Jun 2021 00:56:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zYa5WyN5uAc4A4H86TawfNojJdggPMlZ/sRJ1BGKDOY=; b=lK2gRD6xagDtsOuDcoukQ5iejtFViJuILXhsxnIB09lmJJ6Rr7Q6dlYjT88KvmEHPW hH1ttLapFmpkY54lpVOrcF9bcNERWAGr5ydxIVe6Xn9uEHDBxBbK02qYZP89DQuQhwBz IiTVxFKq7ed6oOKzxcTYBgO2CKE8AnwZ44kNx2ZM11ZzxR3ZNiMTbGtv/AlfZqGHnDIw HBugrzN93EDgNFX35QwBka6lSbofbFUndYJkWzSBqCLutcL6GBhL2QJ5I8tvmpvyB1GY XeIgIdEEnRA+V3XpdZ0I3SdPH0RsbHK3oS0N2E/cEN0xDPVPfyD3ArXdon8XKwPvAMr4 Brrg== X-Gm-Message-State: AOAM532AAqh1Lpyu0pwuB0wjWS1IwujJM2wFmrwVc7Ml8JETs1mYTo+z /Rieq8YVC/DSpiLD662JWbTT2tZa/pZ2wHGZ00esi2SqniSkdL7rE/1+AMaJnjiTJxDPWihq3wc ru8BJ/ZG52eO+JF0V95FJ/I5x X-Received: by 2002:a5d:5752:: with SMTP id q18mr21241445wrw.419.1623138972166; Tue, 08 Jun 2021 00:56:12 -0700 (PDT) X-Received: by 2002:a5d:5752:: with SMTP id q18mr21241386wrw.419.1623138971579; Tue, 08 Jun 2021 00:56:11 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id l31sm1910414wms.16.2021.06.08.00.56.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Jun 2021 00:56:11 -0700 (PDT) Subject: Re: [RFC] /dev/ioasid uAPI proposal To: Jason Gunthorpe Cc: Alex Williamson , "Tian, Kevin" , Jean-Philippe Brucker , "Jiang, Dave" , "Raj, Ashok" , "kvm@vger.kernel.org" , Jonathan Corbet , Robin Murphy , LKML , "iommu@lists.linux-foundation.org" , David Gibson , Kirti Wankhede , David Woodhouse , Jason Wang References: <20210604122830.GK1002214@nvidia.com> <20210604092620.16aaf5db.alex.williamson@redhat.com> <815fd392-0870-f410-cbac-859070df1b83@redhat.com> <20210604155016.GR1002214@nvidia.com> <30e5c597-b31c-56de-c75e-950c91947d8f@redhat.com> <20210604160336.GA414156@nvidia.com> <2c62b5c7-582a-c710-0436-4ac5e8fd8b39@redhat.com> <20210604172207.GT1002214@nvidia.com> <2d1ad075-bec6-bfb9-ce71-ed873795e973@redhat.com> <20210607175926.GJ1002214@nvidia.com> From: Paolo Bonzini Message-ID: Date: Tue, 8 Jun 2021 09:56:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210607175926.GJ1002214@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/06/21 19:59, Jason Gunthorpe wrote: >> The KVM interface is the same kvm-vfio device that exists already. The >> userspace API does not need to change at all: adding one VFIO file >> descriptor with WBINVD enabled to the kvm-vfio device lets the VM use WBINVD >> functionality (see kvm_vfio_update_coherency). > > The problem is we are talking about adding a new /dev/ioasid FD and it > won't fit into the existing KVM VFIO FD interface. There are lots of > options here, one is to add new ioctls that specifically use the new > FD, the other is to somehow use VFIO as a proxy to carry things to the > /dev/ioasid FD code. Exactly. >> Alternatively you can add a KVM_DEV_IOASID_{ADD,DEL} pair of ioctls. But it >> seems useless complication compared to just using what we have now, at least >> while VMs only use IOASIDs via VFIO. > > The simplest is KVM_ENABLE_WBINVD() and be done > with it. The simplest one is KVM_DEV_VFIO_GROUP_ADD/DEL, that already exists and also covers hot-unplug. The second simplest one is KVM_DEV_IOASID_ADD/DEL. It need not be limited to wbinvd support, it's just a generic "let VMs do what userspace can do if it has access to this file descriptor". That it enables guest WBINVD is an implementation detail. >> Either way, there should be no policy attached to the add/delete operations. >> KVM users want to add the VFIO (or IOASID) file descriptors to the device >> independent of WBINVD. If userspace wants/needs to apply its own policy on >> whether to enable WBINVD or not, they can do it on the VFIO/IOASID side: > > Why does KVM need to know abut IOASID's? I don't think it can do > anything with this general information. Indeed, it only uses them as the security proofs---either VFIO or IOASID file descriptors can be used as such. Paolo