From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07E9933554F for ; Wed, 10 Jun 2026 15:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781104740; cv=none; b=NfHv7N3xcAHPDPZPgYwmPSZEKXNqWJK4F0CtJSur6eY0ncxaJ7DTkY/Hh6R1SR6UKoyR0JWj4NpqHBC99mBR+qYacJeGRAbfRb0JgYeiXzZhKmoSKA5Xul20oNljPb+7aWtsoPf1dg0rLWCIvfOQgKypbmRGsXa1rnZV5LiziuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781104740; c=relaxed/simple; bh=cjehl/AogF+ja+2ZcxwqddIpx4w4iJYwr6NEwkFI7Bg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=a5uIm4txkw45kDsqEHMRxeQbfXnoNHIXTwlBAXMU7F96exjkus4pJhZamHXqlVnQAWw9TH0bHD6bqIYAzzO7kvy923dUXa8SuUPgwSAl3sRlQl+Vf42p/owJy88rz8dcGHEFRj+kA1y1E1eFxJGDJSpn2bKYpAKQvz6BoWgkPqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I6ZNUuzl; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I6ZNUuzl" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf004bf8beso79358105ad.3 for ; Wed, 10 Jun 2026 08:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781104738; x=1781709538; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OH2gPa+CKBfgNfPcHJ5LqpJB+w0Mlwm6m76dwlsEpz0=; b=I6ZNUuzlDuwjSf8mEIj5cZ8KxNyFHIkRPnjqwkP2aJ3iBuNFm/hL4YqFn0m2+omFQU 2csptVNh/2aagLG7hhU5H8U2CTKtLCVEgsak4z4jy7jAIriDPcW/WT8inw4tcqbDofK6 Ib8AQpBzNvJLHNDCbvUHNcXlz8maen4g5lmVtX7AsJ928gv/5r1TRAwusgPxfqapVxKj syXIS56j2vfcDa976Ny97YA8kh5UntSICvPDdGeWRkKA/RAU2o5wUrZDBcUz70gNvKRD VqOS+xSYASnb5YkHEQj/g4gOToyWEUvkwS/bp5JHHJdkTaIWx6Ky4gSSbGSBS+Y4SkHR tjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781104738; x=1781709538; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OH2gPa+CKBfgNfPcHJ5LqpJB+w0Mlwm6m76dwlsEpz0=; b=XxwXT+fdqNXrzGYSJymXiSoWSmfthDnJyobr0ZXSnm/WfZxlBAL9kv0xUgnJEn7VzS ZBjo5/I6Dzb9bU3Tc3v9imZ5qhsitF7tm82v7HguAutAS4WgS9kQ9hFqDXdJp+6r2r2u C/KxY5DhJQQrYOBzB6KX5pV1y7C0uwQWmHdJdKHqJGMz6r5SZlskvHmG6UOe1NVJGRdF IbHvlIG5XIJbaeInw0hGr6MqCq+rtKj7uOmhEq5xIVwsVHOx+ms7PwLX2twNHUdRzIMw F56Tt8esAi6neIftYmSpQlAAzi3hHOHBXiJ40kkw4oq67byt0SRLsOmqg5DyvK+1Tmns ocXw== X-Forwarded-Encrypted: i=1; AFNElJ8EkG608Dh4hlsNj++zmGm4aOPGRQX2EZ7cicUZBI2RMGk7MIZnHbu1uXdWFNcrka6z0dhI9VZ7vauNVR8=@vger.kernel.org X-Gm-Message-State: AOJu0YyEV+XL7eysqXY7w/66N+hN0HQJv/NMIsX0fQOVsvYvUrAFybNo uWBBzwbQCSx5fv7Jgz5bnveZ475BVOmuAbDLnArl4Ehno+t4VcjXa3bVhZovbK8Zzrd8YAlRF0L Zhg== X-Received: from plbmp5.prod.google.com ([2002:a17:902:fd05:b0:2bd:c925:e1dc]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e5ce:b0:2bd:5ab:af95 with SMTP id d9443c01a7336-2c1e77d145fmr286373475ad.0.1781104738079; Wed, 10 Jun 2026 08:18:58 -0700 (PDT) Date: Wed, 10 Jun 2026 15:18:49 +0000 In-Reply-To: <20260610151853.3608948-1-praan@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260610151853.3608948-1-praan@google.com> X-Mailer: git-send-email 2.54.0.1099.g489fc7bff1-goog Message-ID: <20260610151853.3608948-2-praan@google.com> Subject: [RFC PATCH 1/5] vfio: Add UAPI for ZONE_DEVICE-backed P2P registration From: Pranjal Shrivastava To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Bjorn Helgaas , Logan Gunthorpe , Alex Williamson , Jason Gunthorpe , Kevin Tian , Pranjal Shrivastava , Ankit Agrawal , Matt Evans , Vivek Kasireddy , Leon Romanovsky , Shivaji Kant , Samiullah Khawaja Content-Type: text/plain; charset="UTF-8" Introduce VFIO_DEVICE_FEATURE_P2P_REGISTER to the VFIO_DEVICE_FEATURE ioctl. This feature allows a privileged userspace process to register a specific PCI BAR with the kernel's PCI P2P DMA provider framework. Unlike the standard VFIO dmabuf exporter, this feature leverages the pci-p2pdma infrastructure to manufacture ZONE_DEVICE struct pages for the BAR. Standard VFIO mmap() is not supported for BARs registered via this interface. Users are instead expected to use the native p2pmem sysfs interface for memory allocation and management. Signed-off-by: Pranjal Shrivastava --- include/uapi/linux/vfio.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 5de618a3a5ee..adbac3f965eb 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1534,6 +1534,21 @@ struct vfio_device_feature_dma_buf { */ #define VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 12 +/** + * Upon VFIO_DEVICE_FEATURE_SET register a PCI BAR with the kernel + * P2P DMA subsystem (pci-p2pdma). + * + * Once a BAR is registered, it will be added to the device's P2P + * pool and can be allocated via the standard sysfs p2pmem/allocate + * interface. + * + * Note: Standard VFIO mmap() of the BAR will be blocked once it is + * registered for native P2P. + * + * Return: 0 on success, -errno on failure. + */ +#define VFIO_DEVICE_FEATURE_P2P_REGISTER 13 + /* -------- API for Type1 VFIO IOMMU -------- */ /** -- 2.54.0.1099.g489fc7bff1-goog