qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: John G Johnson <john.g.johnson@oracle.com>
Cc: "Walker, Benjamin" <benjamin.walker@intel.com>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"Jag Raman" <jag.raman@oracle.com>,
	"Swapnil Ingle" <swapnil.ingle@nutanix.com>,
	"Harris, James R" <james.r.harris@intel.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Thanos Makatos" <thanos.makatos@nutanix.com>,
	"Kanth Ghatraju" <Kanth.Ghatraju@oracle.com>,
	"Felipe Franciosi" <felipe@nutanix.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Zhang, Tina" <tina.zhang@intel.com>,
	"Liu, Changpeng" <changpeng.liu@intel.com>,
	"dgilbert@redhat.com" <dgilbert@redhat.com>
Subject: Re: RFC: use VFIO over a UNIX domain socket to implement device offloading
Date: Mon, 15 Jun 2020 11:49:29 +0100	[thread overview]
Message-ID: <20200615104929.GD1491454@stefanha-x1.localdomain> (raw)
In-Reply-To: <E78F4C2E-4382-4C98-9606-F1ABD9753699@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 2984 bytes --]

On Tue, Jun 09, 2020 at 11:25:41PM -0700, John G Johnson wrote:
> > On Jun 2, 2020, at 8:06 AM, Alex Williamson <alex.williamson@redhat.com> wrote:
> > 
> > On Wed, 20 May 2020 17:45:13 -0700
> > John G Johnson <john.g.johnson@oracle.com> wrote:
> > 
> >>> I'm confused by VFIO_USER_ADD_MEMORY_REGION vs VFIO_USER_IOMMU_MAP_DMA.
> >>> The former seems intended to provide the server with access to the
> >>> entire GPA space, while the latter indicates an IOVA to GPA mapping of
> >>> those regions.  Doesn't this break the basic isolation of a vIOMMU?
> >>> This essentially says to me "here's all the guest memory, but please
> >>> only access these regions for which we're providing DMA mappings".
> >>> That invites abuse.
> >>> 
> >> 
> >> 	The purpose behind separating QEMU into multiple processes is
> >> to provide an additional layer protection for the infrastructure against
> >> a malign guest, not for the guest against itself, so preventing a server
> >> that has been compromised by a guest from accessing all of guest memory
> >> adds no additional benefit.  We don’t even have an IOMMU in our current
> >> guest model for this reason.
> > 
> > One of the use cases we see a lot with vfio is nested assignment, ie.
> > we assign a device to a VM where the VM includes a vIOMMU, such that
> > the guest OS can then assign the device to userspace within the guest.
> > This is safe to do AND provides isolation within the guest exactly
> > because the device only has access to memory mapped to the device, not
> > the entire guest address space.  I don't think it's just the hypervisor
> > you're trying to protect, we can't assume there are always trusted
> > drivers managing the device.
> > 
> 
> 	We intend to support an IOMMU.  The question seems to be whether
> it’s implemented in the server or client.  The current proposal has it
> in the server, ala vhost-user, but we are fine with moving it.

It's challenging to implement a fast and secure IOMMU. The simplest
approach is secure but not fast: add protocol messages for
DMA_READ(iova, length) and DMA_WRITE(iova, buffer, length).

An issue with file descriptor passing is that it's hard to revoke access
once the file descriptor has been passed. memfd supports sealing with
fnctl(F_ADD_SEALS) it doesn't revoke mmap(MAP_WRITE) on other processes.

Memory Protection Keys don't seem to be useful here either and their
availability is limited (see pkeys(7)).

One crazy idea is to use KVM as a sandbox for running the device and let
the vIOMMU control the page tables instead of the device (guest). That
way the hardware MMU provides memory translation, but I think this is
impractical because the guest environment is too different from the
Linux userspace environment.

As a starting point adding DMA_READ/DMA_WRITE messages would provide the
functionality and security. Unfortunately it makes DMA expensive and
performance will suffer.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-06-15 10:50 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26  9:47 RFC: use VFIO over a UNIX domain socket to implement device offloading Thanos Makatos
2020-03-27 10:37 ` Thanos Makatos
2020-04-01  9:17 ` Stefan Hajnoczi
2020-04-01 15:49   ` Thanos Makatos
2020-04-01 16:58     ` Marc-André Lureau
2020-04-02 10:19       ` Stefan Hajnoczi
2020-04-02 10:46         ` Daniel P. Berrangé
2020-04-03 12:03           ` Stefan Hajnoczi
2020-04-20 11:05   ` Thanos Makatos
2020-04-22 15:29     ` Stefan Hajnoczi
2020-04-27 10:58       ` Thanos Makatos
2020-04-30 11:23         ` Thanos Makatos
2020-04-30 11:40           ` Daniel P. Berrangé
2020-04-30 15:20             ` Thanos Makatos
2020-05-01 15:01               ` Felipe Franciosi
2020-05-01 15:28                 ` Daniel P. Berrangé
2020-05-04  9:45                   ` Stefan Hajnoczi
2020-05-04 17:49                     ` John G Johnson
2020-05-11 14:37                       ` Stefan Hajnoczi
2020-05-14 16:32     ` John G Johnson
2020-05-14 19:20       ` Alex Williamson
2020-05-21  0:45       ` John G Johnson
2020-06-02 15:06         ` Alex Williamson
2020-06-10  6:25           ` John G Johnson
2020-06-15 10:49             ` Stefan Hajnoczi [this message]
2020-06-18 21:38               ` John G Johnson
2020-06-23 12:27                 ` Stefan Hajnoczi
2020-06-26  3:54                   ` John G Johnson
2020-06-26 13:30                     ` Stefan Hajnoczi
2020-07-02  6:23                       ` John G Johnson
2020-07-15 10:15                         ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200615104929.GD1491454@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=Kanth.Ghatraju@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=benjamin.walker@intel.com \
    --cc=changpeng.liu@intel.com \
    --cc=dgilbert@redhat.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=felipe@nutanix.com \
    --cc=jag.raman@oracle.com \
    --cc=james.r.harris@intel.com \
    --cc=john.g.johnson@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=kwankhede@nvidia.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=swapnil.ingle@nutanix.com \
    --cc=thanos.makatos@nutanix.com \
    --cc=tina.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).