Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2586900rdb; Mon, 12 Feb 2024 09:22:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVu5/L9kRzOHh0+yYpbEx1xcjf5Gc9GThVHW/t5qlGpyztQbDFP3FS6/Fg9jgokka5H1QLUn3nRtlyCy7mkreY8/yGSLBhuUVKj3qUGQ== X-Google-Smtp-Source: AGHT+IFmTZe6H28mHH3XkU9sDMe3IBPOsubG+l9YP+spgXVnbQ4iQNa9Nd/tPnMUX0/HYnxFl95f X-Received: by 2002:a05:6402:1512:b0:561:a59f:a3cc with SMTP id f18-20020a056402151200b00561a59fa3ccmr3342985edw.22.1707758543034; Mon, 12 Feb 2024 09:22:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707758543; cv=pass; d=google.com; s=arc-20160816; b=ddzUNp2HH7EXPJfvAsFWAl4yrQHIUIV2wA3/vyP3lMAkJ/PddjwnFrF7l3bN6Wr4GT eaaW5ZCfvt2yahiQpHk6lK4NmUSirZM3nSiFay62jRmZH1t6rzoUxQ2trM9F5UA3wqrH EF5XY3zXqWKc6j6bzrZRkVK8plGtpETBBz0GVXUSs+iVWOTpKWbCbPlwEdL2SG/89o+B vjtLFj6kqQwz/EU7U2lNBZz6rt0vVHnUftnX6nBZdDzeFb4hwN3mPkeQGGOlFzLErS20 ThCTEbUqng0Bz03MV5gW/JqKeLz/RpZj86U0wCzeTnwtYVXNVBJaGMyhtgmGDR1GEY7b xIPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=AOauPAOUW8xmwdezNoz+IWSD863XpUK91dsGE3R14Gg=; fh=dtdvnOvaN+uwUEd16HzwfIO0FtcOP87s7HbneIr+NQo=; b=Ki4DgUWeLTsSDfa0Oyj4Dzg+OG3mC4urFUNIWI6uL9yBEYI70mp+/rkZJVxY/dBUHs gOLbjbo+gSabzn4WCOtLjRBsMo2Af6Wu3BnFbLsELo0wHH6OnquCbq8FLRzl7Yu5O1ES R7ucH4GblaY2ApOYTgHQ25BD3ocdx69MSU4R6ENr1ZmWy7BkKdZFccGKzLDq4gljFH8H hqL152S5FQ07L/L/EjCkgpy+iqPggcOtNPbtFY8t2Lnu0cvv0xqBTNpsQ3e7OkZ/Efsu tnACKc3f1g6zKtLpxHYUKoe0Z0GuY5iL2FM/UjoV710YGJGt2E1rxqKpaV4pXP/3xf5N 4rFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BJwkiqz+; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-62058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCUCYID3eeRDj2Y02Lo8fkcNDmp8K1pWQUQddPBXVjyMObCL3L6p+TNvuES4TYDDRyqfGI4GviSTL6o9Wr3LFeiDXP2h2BVVJhNJNG2/tQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e5-20020a50fb85000000b0055f43795b28si2961656edq.196.2024.02.12.09.22.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:22:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BJwkiqz+; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-62058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EF6E31F281C7 for ; Mon, 12 Feb 2024 17:11:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 425384F8A3; Mon, 12 Feb 2024 17:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BJwkiqz+" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 030B14F5F9 for ; Mon, 12 Feb 2024 17:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757511; cv=none; b=fkw65MF6gyPzqF1e1uUPPj11URPHpDcOQ3uhzGtpQNQKNZ7kq3HvVE3v7HqlrEaiaCu12v4NPhY0sx8Mhak8rJB5zWok4i1mx4UYrm9XHYpCtocXqVWwCBwnxiHCJrEEqmLfBuN2NJAVBJJEhVgVrwA6h6x3ibS0uhhLt51gGZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757511; c=relaxed/simple; bh=/ppasOObi1vl2zoLkHHxsigE/xVlK8tLer+NXGAx/2E=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jKSjZIPU1Lwvm3EWkIB0+/4IPqpf7pJLYm8cbVCxKpxW7+zu3f9WdUraqqMebM/fPIasdCo8qw+2ekYOB41Xml480wl8DIZE/Npdl1MzEfvAAsIr9sTvrOWfPVf5EWg/VUwL0jSt8cRHv5vZ9kI/G31LiB6zOFutPm20+00q21s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BJwkiqz+; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707757508; 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=AOauPAOUW8xmwdezNoz+IWSD863XpUK91dsGE3R14Gg=; b=BJwkiqz+FdLvAn0xYXWPsEFTnhsviBjAS3z7y4R4w3R7cdO6/PNuYYHkMh/lktjzm5Xac8 /SQa7DzRweIK50F50R7LYqHlIpB5tCYrEegr86EUR0GNl6vY+c4coMKUW+Zax1uv96hSQZ uVva3i+5auzqM9sTSHzQTa9neqUK8jo= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-572-O-3ZtJoWNTKcuMHarU0CkA-1; Mon, 12 Feb 2024 12:05:06 -0500 X-MC-Unique: O-3ZtJoWNTKcuMHarU0CkA-1 Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-363ec32bca3so27778445ab.2 for ; Mon, 12 Feb 2024 09:05:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707757506; x=1708362306; 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=AOauPAOUW8xmwdezNoz+IWSD863XpUK91dsGE3R14Gg=; b=RRUvDDFJpvGz75nBzQfEk8UrvpKzy1dw3Fs9KhjTOq3ct5xQ12O3rVmMG9MGJlRevh DQlGbGxiKrjGCS0WfQorw0B2UtA1YKzAPy2YLfDCGrM8JWOaK8kPU8YQtErFzJbLyExW m5I8Co3THeIq+DNKf7MO+6wTtMj/85ZhAKYSmUZt0RdCAqXp/xSJPHpj3Jnf1Fb/6pAc lhIxDvEjRDRCyeXQxMlnz9ptPt9grM86QiigIRoIymPoKh8pS0Uyl2CeiEJkOE5DbIWb V2SspiqZHvroK3KcwWm0gGkFwk/V63fwb/rKPm3IBVGXZQ6vGOFbJ9fCTNWYdhT3kQEP Ot7A== X-Forwarded-Encrypted: i=1; AJvYcCVIJ4ZrnMp78kzkpnLkhxNjrp/a7MnDQ8f2FslMseWHV83FQ66Uh/MSh4036gfRNbJgwuB0V77fyn7UW1O21Wi5Lil26of9F7U5Vyp7 X-Gm-Message-State: AOJu0YwAyKUabTOYy7r8jKR2KR6VJLnl6aaAuXLaR87GPOZZiKnrhY7Z Hluy7DzdbuBGgyaHGT+B48PptC9bvUgbA5ZLJw+rfq+ZpyTlUCf4KALUETrIi1Otlt3UpcM7HCb kTbTmUwkhGEQDEog+m0vxlPNwm0j4pdg5hRgK3Sl0bq6UHtyqZ49r+HJITWo+uQ== X-Received: by 2002:a05:6e02:1c0f:b0:363:bf4f:9242 with SMTP id l15-20020a056e021c0f00b00363bf4f9242mr12359138ilh.0.1707757505977; Mon, 12 Feb 2024 09:05:05 -0800 (PST) X-Received: by 2002:a05:6e02:1c0f:b0:363:bf4f:9242 with SMTP id l15-20020a056e021c0f00b00363bf4f9242mr12359090ilh.0.1707757505683; Mon, 12 Feb 2024 09:05:05 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWTKjfqO4rkuhd2GHVkqqBNv4+4iVoZcGlDpy3HDG1uMMhT2d1jmDXMdgoX5DAWSe6wNqaoupDoOAQYGfaqx0u2YxoUAD4jOURcBV59dRJ0I84dPyAqjUa503odT/ihzOsHVyPnNOPJoHdYRT0Rkp1ITk30Z0jK0uQhOT8ZxCTTsDwHyplbhVXKzzWJ+5KLI0CW6tCa0uQX8eZY5XNRWRGf+QNcHvIm3yhzArCWF1+twWZ8ZnjPN50CfZ2MfWdE75xZdbBSioYKg/nzKmtiQE3HF/9lKHwRBYl6QkNkUBjfurx86zdYaK+ehhpNI3KCup/fqQW91N+qdWpE6M/4gD15NJDcY+cT9NbrcP/cidh0BMgG50wNuXrmnkXpm4oifG69lW1OlbPuCF3FwTEvBEMdMJNhwGJUq73Fb0yEEC3moByn74AQRxFN2+lKgvS7f3ETe1xbUchqRjQJYKyPvAv5d54L1Slq5ySDW0gE8KXZDMWQOLPNjP8lfWTWVQz2cegkBDFZnvSicLwrm7kx6Uyn4iQRg2Q2+2S092z+9EVssL4dTBcBiSfvzP4WR8BM9x2Cnj61ySifZP2b3sit2kXjDiHOKSpVT3XvUxV2NbiqyqaykRhfqoQWedicpEy2bUk4+6LGqp11TmwKitHZJVqrpjqEY5C20DTsYEiFK61AzM8/cBavnY1uHrFpyCAogoztCVgiLv6dR1pGSea50FebaaEoxsF0FdNhpT2In60GDbjrIIPJw9Yq3LE+A7pRuI8M2Pv2xba1cBmYG5BrQ/9vAC0AeyPnL/EjsEcqAD861Ut39qWpRqvM0jpvnlygSo13H7bWAWmrMWzOqUYutqVrxS1vCjbuNPAk4KPe0BHXnX+ou2Ou1LDGvKclXyNuba+zNe/6NIkiQ9tFgwZQWrO6cdbtM29KCOYYYy6I1yQguArOSxd54yZMFBXbHqlvq68ZD7 s5Ogdlm3vmILJeBjg6GR7Gfseo5SInXkPEJuISfamgJq1cKmYEkWiLHdpEXsU2z2bxLv6UizINdscavVhxNtO+f3YWyq67/6mkIHGegdJtwSQkFTQE38Qc6rY4wjyj3IoWWIw3JoTW1arS4PnomVhrCPLrZRuUcqKd4YW697swDORpqc5pjtaQmDUFd3HjddzZ2ykwrVpXhQU0MTWWohfdS3VaXxvAHWG/+cPs5+gvAChdu1Syik831EdMmJCOOtGu+BcmXFq/EhhR6d91D/vA9vXazLvjYergDYBNbDpREevkFO/zUNlr5Hb5RaVHWWDvXX9c Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id bf12-20020a056e02308c00b0036275404ab3sm2025858ilb.85.2024.02.12.09.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:05:04 -0800 (PST) Date: Mon, 12 Feb 2024 10:05:02 -0700 From: Alex Williamson To: Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v7 4/4] vfio: convey kvm that the vfio-pci device is wc safe Message-ID: <20240212100502.2b5009e4.alex.williamson@redhat.com> In-Reply-To: <20240211174705.31992-5-ankita@nvidia.com> References: <20240211174705.31992-1-ankita@nvidia.com> <20240211174705.31992-5-ankita@nvidia.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 11 Feb 2024 23:17:05 +0530 wrote: > From: Ankit Agrawal > > The code to map the MMIO in S2 as NormalNC is enabled when conveyed > that the device is WC safe using a new flag VM_ALLOW_ANY_UNCACHED. > > Make vfio-pci set the VM_ALLOW_ANY_UNCACHED flag. > > This could be extended to other devices in the future once that > is deemed safe. > > Suggested-by: Catalin Marinas > Acked-by: Jason Gunthorpe > Acked-by: Catalin Marinas > Signed-off-by: Ankit Agrawal > --- > drivers/vfio/pci/vfio_pci_core.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c > index 1cbc990d42e0..eba2146202f9 100644 > --- a/drivers/vfio/pci/vfio_pci_core.c > +++ b/drivers/vfio/pci/vfio_pci_core.c > @@ -1862,8 +1862,12 @@ 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. > + * > + * Set an additional flag VM_ALLOW_ANY_UNCACHED to convey kvm that > + * the device is wc safe. > */ That's a pretty superficial comment. Check that this is accurate, but maybe something like: The VM_ALLOW_ANY_UNCACHED flag is implemented for ARM64, allowing stage 2 device mapping attributes to use Normal-NC rather than DEVICE_nGnRE, which allows guest mappings supporting combining attributes (WC). This attribute has potential risks with the GICv2 VCPU interface, but is expected to be safe for vfio-pci use cases. And specifically, I think these other devices that may be problematic as described in the cover letter is a warning against use for vfio-platform, is that correct? Thanks, Alex > - 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;