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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 159ABC48BF8 for ; Thu, 22 Feb 2024 20:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mUokMhhoOCL4SfYqbdmaChO5ktRk0bDgJgk6m1doYjs=; b=Rq23OnD6F0ZzgV txRzhc4yk+iZV0UrMmIA3wlULLR1FSuln7x6V2fY5yvrqrboASr/5OyPfCn+O4Bp9M5sPxG6dNuDB k3GehecB6UtibUW+CXIDt1oC9J7OXMhPJhqj4NIH+Fdce0SWUsZdXpbaYy+yU4ytp0SGw8XHBzZ1G 3gNxzjQwzg73oM5tSpxq8nxj2seqmHLIvGQKTPxU/dOu8wj0RQru/P+PYDdWk1d9W2bFV60VzI+/F OjguYmMe9If1S4KYbSRndlHmWLmqIe8vj2JlGY9Iaks0IghUnHKB4I4GOyKYRGKbCZCVfpbcyKl/R 6D+55ow3ctjQP54uM4bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdG3s-00000006Ycu-1koF; Thu, 22 Feb 2024 20:52:56 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdG3q-00000006YbR-1m8n for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 20:52:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708635169; 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=UcO6Jui6DKtatymkIK1WWSMn6J5ECJZL7QtFar2I6wY=; b=NcD2H/Pbls79er6dFZpkyVxbGsbH+cO8I4EDHuRalwImZNZ5BWqgx7p+LSQnG6yg5xlIOk J41bOpk7ZTpWWBmZ1eZ1GqaJN8W4pQ6bPQObqwthH0xLUu0UNNw2i7KXdzPhagIn6kR78G e3Mx20twpw22kwyCV0k6BkIfk5iN+Fc= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-qmvCZRd2PAC6Z5K1rmkMKA-1; Thu, 22 Feb 2024 15:52:46 -0500 X-MC-Unique: qmvCZRd2PAC6Z5K1rmkMKA-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c032b61db5so173425b6e.3 for ; Thu, 22 Feb 2024 12:52:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708635165; x=1709239965; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UcO6Jui6DKtatymkIK1WWSMn6J5ECJZL7QtFar2I6wY=; b=jovpRB0dtbYemml/kKlT7me/njqXiSaKdQwyPmc+0dWYZu9Pe5QlKX15RUBVIHe/G0 eh/H/eprHtz0X3CTacoad4D6Xq7zYi3z2uHiW95g5La0CBa0Zv2Mx53oOFEl3RMo9GBL B9QK2ua5bLU82hE/8dvwYeJK/OpB9NcFXwGqP2NJtS6be5g35N8r6DHIDCNl82l1f67l fAM2lOMyIU3uw0bKpmvoXe2r260QZteTiJEA+amfIF6i8xSaA2V6ZA5mS7fFs/D1Yenj Tkn5rNOBb3Q3HlBinQu2XBKB1cyBhIS6i9rMlHLgju0x9TAdPrkczwRrPpySveBVkem8 pkSg== X-Forwarded-Encrypted: i=1; AJvYcCU2rbt1jyh4Icic6EUjt8lNVZl4Eo4h/nEPf7o61nOj8wkYpHOyRpaHh6cqPwTgC+iZr4GFvnWWm/UFYjRHEEyZ0vK8fRrqecF72ke3oMLDmqR+PK0= X-Gm-Message-State: AOJu0YzIAr2uzxPUKdeDrjJRnVjZZtzbBxgb7KZ28kBx5b+5a7FOpbu6 pB/j/Q/NXKA5dkzLpPXq4X6a1+eS3FEbLzKlLCssDWNy9lsBrT/9hWD2xZM1opvIsUgMPh4L77z WGLQN+Pv95acd1DuT1DayJlwHRSdIrakNcGPa2aM7qo4EAgbQzSKKeC4OF73CRLa6gcgWd8Ui X-Received: by 2002:a05:6808:316:b0:3be:b5f6:f355 with SMTP id i22-20020a056808031600b003beb5f6f355mr66178oie.15.1708635165240; Thu, 22 Feb 2024 12:52:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHphM2AEgwOFKuEkCG9cWu5dpOQyfI2E3tisVZLDiLPsoH3PowBIUeuTZNvzTCWg2+WwuAc+Q== X-Received: by 2002:a05:6808:316:b0:3be:b5f6:f355 with SMTP id i22-20020a056808031600b003beb5f6f355mr66138oie.15.1708635164973; Thu, 22 Feb 2024 12:52:44 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id a14-20020a05680802ce00b003c15d61ec3fsm1461018oid.37.2024.02.22.12.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:52:44 -0800 (PST) Date: Thu, 22 Feb 2024 13:52:40 -0700 From: Alex Williamson To: Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v8 4/4] vfio: convey kvm that the vfio-pci device is wc safe Message-ID: <20240222135240.46682bed.alex.williamson@redhat.com> In-Reply-To: <20240220072926.6466-5-ankita@nvidia.com> References: <20240220072926.6466-1-ankita@nvidia.com> <20240220072926.6466-5-ankita@nvidia.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_125254_548212_BEE7B0BF X-CRM114-Status: GOOD ( 23.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 20 Feb 2024 12:59:26 +0530 wrote: > From: Ankit Agrawal > > The VM_ALLOW_ANY_UNCACHED flag is implemented for ARM64, > allowing KVM stage 2 device mapping attributes to use Normal-NC > rather than DEVICE_nGnRE, which allows guest mappings > supporting combining attributes (WC). ARM does not architecturally > guarantee this is safe, and indeed some MMIO regions like the GICv2 > VCPU interface can trigger uncontained faults if Normal-NC is used. > > To safely use VFIO in KVM the platform must guarantee full safety > in the guest where no action taken against a MMIO mapping can > trigger an uncontained failure. We belive that most VFIO PCI > platforms support this for both mapping types, at least in common > flows, based on some expectations of how PCI IP is integrated. So > make vfio-pci set the VM_ALLOW_ANY_UNCACHED flag. > > Suggested-by: Catalin Marinas > Acked-by: Jason Gunthorpe > Acked-by: Catalin Marinas > Reviewed-by: David Hildenbrand > Signed-off-by: Ankit Agrawal > --- > drivers/vfio/pci/vfio_pci_core.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c > index 1cbc990d42e0..c93bea18fc4b 100644 > --- a/drivers/vfio/pci/vfio_pci_core.c > +++ b/drivers/vfio/pci/vfio_pci_core.c > @@ -1862,8 +1862,24 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma > /* > * See remap_pfn_range(), called from vfio_pci_fault() but we can't > * change vm_flags within the fault handler. Set them now. > + * > + * VM_ALLOW_ANY_UNCACHED: The VMA flag is implemented for ARM64, > + * allowing KVM stage 2 device mapping attributes to use Normal-NC > + * rather than DEVICE_nGnRE, which allows guest mappings > + * supporting combining attributes (WC). ARM does not > + * architecturally guarantee this is safe, and indeed some MMIO > + * regions like the GICv2 VCPU interface can trigger uncontained > + * faults if Normal-NC is used. > + * > + * To safely use VFIO in KVM the platform must guarantee full > + * safety in the guest where no action taken against a MMIO > + * mapping can trigger an uncontained failure. We belive that > + * most VFIO PCI platforms support this for both mapping types, > + * at least in common flows, based on some expectations of how > + * PCI IP is integrated. So set VM_ALLOW_ANY_UNCACHED in VMA flags. > */ > - vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); > + vm_flags_set(vma, VM_ALLOW_ANY_UNCACHED | VM_IO | VM_PFNMAP | > + VM_DONTEXPAND | VM_DONTDUMP); > vma->vm_ops = &vfio_pci_mmap_ops; > > return 0; Acked-by: Alex Williamson _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel