From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A04AC47082 for ; Tue, 8 Jun 2021 07:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05656600D1 for ; Tue, 8 Jun 2021 07:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbhFHH6K (ORCPT ); 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-Google-Smtp-Source: ABdhPJxv6B3Fm9uWkkuLZ42Sp23/j0I/On5RIFlSJAMEPX1XlarvGPgTQWrWA1V8+3s21lkavNZEgg== 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