Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1101761ybj; Thu, 7 May 2020 15:01:25 -0700 (PDT) X-Google-Smtp-Source: APiQypLsiQ1xBa+PHzuhO+42+7g+6Yk7BiwoGH46VfdIGjhPyRv2M1CA1tcGDmOM7Byj18tsisz0 X-Received: by 2002:aa7:ca41:: with SMTP id j1mr13362778edt.279.1588888884872; Thu, 07 May 2020 15:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588888884; cv=none; d=google.com; s=arc-20160816; b=GNfIKd7HQNC5rdOKhlwEUH3aZn73I33gZ71TF/Tkmy65ZjxaLEluf/+5FyBFkO8cga cyj4v+EwwrfQmTzwxIn+pmY/IsbF7aHmVmC+rjPUpf4Ou4d9pug521tzOmyKrAHrB/FI xD0yfogOUZpzR/yqqu8Nu8ETMt3CDJcOyjrGKUOBbZWab7EQFerDYBvY3n/oHbyt6vQt 8vD6/Jl6OS+MHNs98WRATVnRtCvqne+IV/DdZ5/DqvljU9THuCgNs+om+NKN6eb87ejX VTmVUY/PeoONksZSE71qYPLAbDs9j5KJvWOVDvzR/BBDdOhzCHWIhk5FGCcQ7tP0VMKi OQpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zoaD/vZ99qPVucnfK3IScYf0rbMkx7qHOiz4Yv3Ogzg=; b=CPpbXTBKyCb5S1Qp5iQ+IEkv96XUJnUyQKnkn7RM+LQODD45ETS5EMYBmjG21EPa9i eiOa3gDshBa+xpAVIbAUPc6JXX0byi8rOt7ZKwyazDct0D2Sge0RV9xD+GQKjN92z1kc nCtKH/m6wSfflqpIABr8qSRc9HQYhGydwFR6QAiO8aNrVVyBdaE+6hyDIeMh/dulNhuP LGOerLPIfmuUSffKjSR6eqh1e5j3tDXfcQlErzrFDTHumlpHGsOVxIJZyNUn1sW+b+u/ X5qMU5m7kN6hZSQz2+0TTsWh4zlX7L/QkKvfjOiKUf0umSPhWbSMEbQn0MHlytbIalGy 1fkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ni1mw1pB; 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 rh26si3588865ejb.81.2020.05.07.15.01.01; Thu, 07 May 2020 15:01:24 -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=Ni1mw1pB; 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 S1727088AbgEGV7P (ORCPT + 99 others); Thu, 7 May 2020 17:59:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48044 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726809AbgEGV7O (ORCPT ); Thu, 7 May 2020 17:59:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588888753; 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: in-reply-to:in-reply-to:references:references; bh=zoaD/vZ99qPVucnfK3IScYf0rbMkx7qHOiz4Yv3Ogzg=; b=Ni1mw1pBzEkIkKE11YYFAQf1jBwyRJNPYsA+w4J2sSLRQC3nZrbnNy6HPOlUrGWZWcT9Of DAkVE/iC6yyEbThvTgO1CjpTB0yYzZaROkOQ421QDj7caYpdP9FviKu9s33G4SDSyrIjIP 0N5lg/rmxsJ998rVxoxz3KNnlKvayrk= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-501-tOHQU31MMQyHiKY5KnOeXg-1; Thu, 07 May 2020 17:59:11 -0400 X-MC-Unique: tOHQU31MMQyHiKY5KnOeXg-1 Received: by mail-qk1-f200.google.com with SMTP id z8so7330998qki.13 for ; Thu, 07 May 2020 14:59:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zoaD/vZ99qPVucnfK3IScYf0rbMkx7qHOiz4Yv3Ogzg=; b=F5i07GRY/hBDuXQLI2Ok0J1V5C4JrGSQy5DsXfvZw9xU1cxioXu4m5F3oA6bOFiOmw 63kqU7ZjSMupmUs2MgpcXqIzOr6A1EzTKGgia5essme5LfGyWU9mTNg0HImiTl7Gq7Iw iwp+RDQamabnB7NcXmosETjqTXOQpFYQMrzKE8avbjJ3sQvVMUXA0PJB/WvGZkiYsjnJ j/Sf4r1CHPvsL9hRwT/IjZBgDH1UBPpnEfEcxDNQmjV+NYp/VvnBh25RCihVM518A2pG ao4DNDfASF3doDoqUuDU9FjoCUA4IODW1Amc261uZqFWvaIpJq8inYppCar1GOKxpSei T1iQ== X-Gm-Message-State: AGi0PuaIBhedA3SvVw8NQhBr9vxCQbmrnphZWkYAms27AluOLreOObQH Zm80C9R+UsCQ7N1icCZ+i2Slno5IKfPfWsEVk9AlmZR/E4vyorXXqr3BnjdVC9o2P3IuuIJy/Xd qdOScsgoQuHs70YZsOJxouXxl X-Received: by 2002:aed:2dc1:: with SMTP id i59mr16853122qtd.182.1588888750767; Thu, 07 May 2020 14:59:10 -0700 (PDT) X-Received: by 2002:aed:2dc1:: with SMTP id i59mr16853106qtd.182.1588888750522; Thu, 07 May 2020 14:59:10 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id y3sm5259605qkc.4.2020.05.07.14.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 14:59:09 -0700 (PDT) Date: Thu, 7 May 2020 17:59:08 -0400 From: Peter Xu To: Alex Williamson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, cohuck@redhat.com, jgg@ziepe.ca Subject: Re: [PATCH v2 0/3] vfio-pci: Block user access to disabled device MMIO Message-ID: <20200507215908.GQ228260@xz-x1> References: <158871401328.15589.17598154478222071285.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <158871401328.15589.17598154478222071285.stgit@gimli.home> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 05, 2020 at 03:54:36PM -0600, Alex Williamson wrote: > v2: > > Locking in 3/ is substantially changed to avoid the retry scenario > within the fault handler, therefore a caller who does not allow retry > will no longer receive a SIGBUS on contention. IOMMU invalidations > are still not included here, I expect that will be a future follow-on > change as we're not fundamentally changing that issue in this series. > The 'add to vma list only on fault' behavior is also still included > here, per the discussion I think it's still a valid approach and has > some advantages, particularly in a VM scenario where we potentially > defer the mapping until the MMIO BAR is actually DMA mapped into the > VM address space (or the guest driver actually accesses the device > if that DMA mapping is eliminated at some point). Further discussion > and review appreciated. Thanks, Hi, Alex, I have a general question on the series. IIUC this series tries to protect illegal vfio userspace writes to device MMIO regions which may cause platform-level issues. That makes perfect sense to me. However what if the write comes from the devices' side? E.g.: - Device A maps MMIO region X - Device B do VFIO_IOMMU_DMA_MAP on Device A's MMIO region X (so X's MMIO PFNs are mapped in device B's IOMMU page table) - Device A clears PCI_COMMAND_MEMORY (reset, etc.) - this should zap all existing vmas that mapping region X, however device B's IOMMU page table is not aware of this? - Device B writes to MMIO region X of device A even if PCI_COMMAND_MEMORY cleared on device A's PCI_COMMAND register Could this happen? Thanks, -- Peter Xu