From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 874A3606A322 for ; Wed, 2 Dec 2026 12:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=XylfGMOZ Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYjh8-0000Pk-Cm; Wed, 02 Dec 2026 07:44:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYf6d-00033T-8R for qemu-devel@nongnu.org; Wed, 02 Dec 2026 02:50:23 -0500 Received: from mail-westus2azon11012047.outbound.protection.outlook.com ([52.101.48.47] helo=MW6PR02CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYf6a-0003IO-LG for qemu-devel@nongnu.org; Wed, 02 Dec 2026 02:50:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Oyv12nUnXKQ+iDfB+yGOHBEGtocUNRVI6PNfhMWbeJ7CXW6GpJJZs5EjQxSRKKu5xyFzzf6AvWX1fvUzmHsRNzxpJMUvPQdCMQ4GVY1/Sk3ntnjYGLgUN/6F0wZNloKw7dGy7N9D7biUBTueJYg/N7MHfuOFaLmsUvj5pDMhRO8xPGtt0mF6we47HcerFW1LhBwIDDDCWcqZd23AfBeiZGT3sdLbePNB+d5XoEhRX3mPQVN4Oj9hfsCXmC7FcD11mp0mcCxhytconPMRNrPqJ4tCqQyNUYV4fVaRraa8QDyn7xR59ILbNHkpZC1F3mtwvGRF8GeZJfOzbu1wjfuRxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hi3+GjQXgWRUz837Ymh2js8MeEhRKc4gJqiDSO8w35c=; b=FlHmGPL7cEqAf3VI0KIhS18DO3FZ9GiYvYNYBeVn7/SfulzY3ParkMa3TcjyHLhETELp8MES85yobxgdBro1AAKKCTScTvT16c7G/PobVaRtE9sCdG/j3+6Kg82hJiFNFFlIeExZ2hSi6WIgS1fTOzqhYsHwyfuKtdKPuINxbQm05cXaC2LkeYzV5C8yp9+iWGXLPfDqtF86CYppFO+c1lD8lYo4y+6w3faz12NKtQHgA1Y/29R61I3iUDwqWyfxD9Uuk54aVBoRTu3j+ssb/MfJoxnHrX3xKJQihEm0af9nJ0uORFYhNywixe0uaug8KFp+wf54ENiPCj93VM0kGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hi3+GjQXgWRUz837Ymh2js8MeEhRKc4gJqiDSO8w35c=; b=XylfGMOZ7GHXY/uaXeRrA4KFNGv2DRwe5lhiu0Jo6ln47Yw3dg25W47VMI2E6/GCtDrWsDYzkkk/SNBqWNkSs+/zSSuSWWVoz2PD2wY1tx1zjw2sNSa+o5VpNNmTugTpTpg75Kmok2FU5SMqgiC8y9dsQnPCXoiWJsbt47YHz/E= Received: from PH8PR21CA0011.namprd21.prod.outlook.com (2603:10b6:510:2ce::19) by LV1PR12MB028288.namprd12.prod.outlook.com (2603:10b6:408:515::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 07:45:13 +0000 Received: from PH2PEPF00048916.namprd05.prod.outlook.com (2603:10b6:510:2ce:cafe::a2) by PH8PR21CA0011.outlook.office365.com (2603:10b6:510:2ce::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.709.5 via Frontend Transport; Wed, 2 Dec 2026 07:45:13 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by PH2PEPF00048916.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 07:45:12 +0000 Received: from xsjwendlian51.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 01:45:11 -0600 From: Wendy Liang To: CC: Wendy Liang , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Dmitry Osipenko , "Lizhi Hou" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Max Zhen , "Michael S. Tsirkin" , Paolo Bonzini , "Pierrick Bouvier" Subject: [RFC PATCH 0/2] Introduce virtio-accel device for NPU virtualization Date: Tue, 1 Dec 2026 23:44:53 -0800 Message-ID: X-Mailer: git-send-email 2.53.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH2PEPF00048916:EE_|LV1PR12MB028288:EE_ X-MS-Office365-Filtering-Correlation-Id: 51f8413d-380a-46c8-75dc-08df50483298 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|82310400026|36860700016|1800799024|376014|11063799006|18002099003|6133799003|261009221227099003|261009223027099003|3023799007|13003099007|56012099006|10067099003|261021121427099003|261026130827099003|261026140227099003|261021130227099003|261102123227099003|261028144727099003|261021135927099003|261026121527099003|261021123027099003|261022115727099003|261022075727099003|261022113327099003|261022105027099003; X-Microsoft-Antispam-Message-Info: CpEL7NRVvPo2zUZSp9tPOYyBkFVIQFYM9cC1fKI8wR21Nn7WEdPgcHHsjwWfxEcOcnAlf0zF3jk7of5INAHdzRZoS/xhoeEJBZa9qlYS+oBRWkfBKZZswhCesyW+e069Enplb/fSoklVz20ekLWGzX/gPsoKKMGbrGBN87zmnXw4isl1GQ6ygFjvPirOLLZlGLugzj7fZO29c92DVIMPmAS+CuZF7Hoik07XixrysZ6kPZYkcx7v3/keEti97BFDr4X1s3qhFVZW/MoxrVGD1GLLbofhqACyVqC59xmCSCnL4nBzcz9B28oScGTyMLtoVU+JR5cKsNQLmUBCPFyrb+6UNx7la9Noi3/nOdVCV9PvVNp0dIeZBsBMjanmxWzhQm20TMNkZSXH2L/j1yGk61UII0h0bssphwgW+NRk5QSV0yKkvS2pQLQTWpyx43MvS3EzQWOYQHekUIrAG0f35uL3E6EaDx+YveQ5wdqYFU8pf1A0iBSKDu9SJoN9YCMkff/yImvUz14nxoeV9f8L1M/s+ueFBV4AfpwfSua4KPph8UrN+kYP518owH4vSWRmtW+bBZFYgP7dHM/sfnSCpt4zV/uCuFQYB/3NjJhqPBHNGjzl191NbIdPThSsXfXWuqoVmHSkIImBF2aWtgrGuoZUc8ITlt3sdrn44iw6PJk= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(82310400026)(36860700016)(1800799024)(376014)(11063799006)(18002099003)(6133799003)(261009221227099003)(261009223027099003)(3023799007)(13003099007)(56012099006)(10067099003)(261021121427099003)(261026130827099003)(261026140227099003)(261021130227099003)(261102123227099003)(261028144727099003)(261021135927099003)(261026121527099003)(261021123027099003)(261022115727099003)(261022075727099003)(261022113327099003)(261022105027099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wODf9fXMbZ16h3wwyNvwcOBfqtKZ8Z+alUb7PdjMHtdST2JtcxnNhco9FqNVzccc4L5hTT2NoV2f5gf1ITLjTCmh2vhg4v8JsMK3t6CvcnqvCNc2yPp9NR5vQV9GpUM1SkInaDVqRuvG/u319tqiNUcpwcG/xS6sDer6x5+ZypS/cPNvpWFLPh+0WTAjtWmduxayasnsI1Lgu/TFi/RmT/5chubG9m3elzSaS/QWweaQqm4Nq2zS36YBX6tpJSTjjG5QlNCC240YPQmpMs4RmrCzVrPy+BIp+knaWvNvHSsK6/9/RR7JuvMXyK02jm2PgmEi6/s2Tf57fXvbQv75+9iLSpJfOhPFPnkOBO4j8bBBQe17rfpC1EspARjSegpTfNQ3gGk1KY0WoNy43Bo72jzo+InqylfOfJTpW/7i1amC/1fFw4eWaraH8H9+k+zD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 07:45:12.5496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51f8413d-380a-46c8-75dc-08df50483298 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: PH2PEPF00048916.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV1PR12MB028288 Received-SPF: permerror client-ip=52.101.48.47; envelope-from=Wendy.Liang@amd.com; helo=MW6PR02CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 02 Dec 2026 07:44:08 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 This patch series adds a DRM-based accelerator virtio-accel-pci device, which allows a guest to access host NPU resources through the DRM interface. It also adds host-memory blob mapping support for the virtio-accel device. We are trying to support NPU virtualization in QEMU. We have a DRM accelerator driver drivers/accel/amdxdna in upstream Linux kernel for NPU. We checked the existing virtio-gpu and virglrenderer. We also use native context and resource blob ideas because they are similar to our use case. They enable kernel operations (ioctls) across the guest and host. There is no API translation required. We can mirror host DRM ioctls with CCMDs in the guest, and the host replays them. This lets guests use what host driver supports. With the CCMD shim layer in the guest, we can use the same application stack on both guest and host. Guest pages are passed as iovecs to the host, or host buffers are mapped into a PCI BAR which avoids extra copies. We needed to support different types for virtio-gpu devices such as graphics GPU and compute NPUs within the same guest. Virtio implementation allows us to share the same NPU across guests, but we also want to select which drm accel device nodes to use for a guest as we can have multiple accel devices on the host. e.g. from qemu command line, we can specify: `-device virtio-accel-pci,accel-node=accel1` in the guest Linux, the NPU will be presented as `/dev/dri/card<>`, `/dev/dri/renderD<>`. The guest shim layer uses the virtio-gpu kernel driver, no new driver is required. virglrenderer keeps a single static struct global_state with one cookie and one callback table. After the first virgl_renderer_init() call in a qemu process, a second call with a different cookie returns -EBUSY. So there is only one virglrenderer-backed device per QEMU process. QEMU doesn't implement virglrenderer's get_drm_fd callback; even if it did, drm_renderer_create() opens the first render node with a matching driver name for every context, ignoring that fd. There is no way to choose the host device. Also, virtio-accel needs no OpenGL, epoxy or EGL, while virtio-gpu-gl requires opengl. And thus, we created libvxdna (https://github.com/amd/xdna-driver/tree/main/src/vxdna) to support multiple virtio-accel devices in the same guest and multiple DRM accel devices on the host. libvxdna is a userspace library that provides implementation of the vaccel_<> APIs defined in: https://github.com/amd/xdna-driver/blob/main/src/vxdna/include/vaccel.h which is called by the virtio-accel device in QEMU. This library accesses the host NPU device to execute the CCMDs specified by the xdna-driver shim layer (https://github.com/amd/xdna-driver/tree/main/src/shim/virtio) in the guest. Sending this RFC patch series for feedback on this approach. Usage of this patch series: 1. On an AMD NPU enabled host, follow the instructions in https://github.com/amd/xdna-driver/blob/main/README.md to build and install the AMD NPU driver and libvxdna library. 2. Build QEMU with this patch series applied, with the `--enable-drm-accel` option. 3. Build Linux kernel with CONFIG_DRM_VIRTIO_GPU enabled. 4. Create guest linux image with xdna-driver package and xrt package installed. 5. Run qemu with the following command line option to use guest memory: -object memory-backend-memfd,id=mem0,size=16G,share=on \ -machine q35,memory-backend=mem0,accel=kvm \ -device virtio-accel-pci,accel-node=accel0 to use host memory: -machine q35,accel=kvm -m 16G \ -device virtio-accel-pci,accel-node=accel0,hostmem=8G 6. In the guest linux, launch `xrt-smi examine` and `xrt-smi validate` to check NPU status. Wendy Liang (2): hw/display/virtio-accel: add DRM-based accelerator device hw/display/virtio-accel: add host-memory blob mapping MAINTAINERS | 7 + hw/display/meson.build | 15 + hw/display/trace-events | 9 + hw/display/virtio-accel-pci.c | 52 +++ hw/display/virtio-accel.c | 732 +++++++++++++++++++++++++++++++++ hw/display/virtio-gpu-base.c | 3 +- hw/display/virtio-gpu.c | 1 + include/hw/virtio/virtio-gpu.h | 30 ++ meson.build | 7 + meson_options.txt | 2 + scripts/meson-buildoptions.sh | 3 + 11 files changed, 860 insertions(+), 1 deletion(-) create mode 100644 hw/display/virtio-accel-pci.c create mode 100644 hw/display/virtio-accel.c base-commit: fae886567b48c672977acde6b775dd7e2d2121c1 -- 2.53.0