From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id DC51B8045D for ; Fri, 16 Oct 2026 21:36:59 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69GLZk19021519; Sat, 17 Oct 2026 00:35:47 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69GLZk19021519 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="uCCJxsY6" Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69GLZjL8021507 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Sat, 17 Oct 2026 00:35:45 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69GLZjL8021507 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48af4a0bd0fso98842f8f.2 for ; Fri, 16 Oct 2026 14:35:45 -0700 (PDT) X-Gm-Message-State: AFq9FYLi8lPelSC24tVvVZ9f9Pgx1UyJNhIxj6QPt2GPkCtXfFwXfyDT obgaCVRGgU6yNHxCSqHmsRiuJ6UqOXSnoSsBpJ+cYeJjoJmxGaDkct+fY+eI6PhytqCIhMuBejU t73ZGnazpsSkuKgxo/Fc52YyZn9vfRz6bI/GvQBhsC78nldcOXHkcFA== X-Gm-Gg: AYBFou3c+MwTlCMNMPu2drvEVGofG/KTkLrrei/5Y/XtYsLSC1iBL6qpiQ3UKInkakz Du3HBe4cy881a28yjLDY7pgM+tcogXK6YkHbZ/jB4BYRn2T1RDNjKf+p2kP0DYViJ4ciOZMJSmZ iHd8tooHBs7FiJDHvAVBQWicT2O/P+vB5ioYtV8vvhjxkS5UfJrTSStoZbGMng0VQdXnjfdjK7T qBGfYLbCEuI8RCFRGxLl/bRzgckMlEliAa9fcDTa9q2Qcet0LTpl26O8ieQZhCoIzFITQM0zRRo iLGHUw7jT9dPnBLrmG1H9Tjqx+t/JTfEbd/gt+g1i6Z+bWoDq1XP83rYF1lEWbMTcAgGQ7p4qxH HFVCu1X2ys2JfQQ4U X-Received: by 2002:a05:6000:1050:b0:48d:ecba:3cf8 with SMTP id ffacd0b85a97d-48e07fa82f3mr1055689f8f.43.1792186544994; Fri, 16 Oct 2026 14:35:44 -0700 (PDT) X-Received: by 2002:a05:6000:1050:b0:48d:ecba:3cf8 with SMTP id ffacd0b85a97d-48e07fa82f3mr1055659f8f.43.1792186544447; Fri, 16 Oct 2026 14:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792186544; cv=none; d=google.com; s=arc-20260327; b=JEK+ZWM+gB5LziYCpUDuhwkI7LlYUhtNnzL8RKYbAVYm0NX6x9ppfw6FHJnE9vJEVw kq+KXFCetcW0MHRZwsnC9CaeibG6GzANxOWUJODzURCdL9+TiBzpnroxYH+UxNJp9tdk 7BkkNgKFsDOAhRD0DtpboI/db8WMTUi4TSVNsUllP5rCM94zxXgJBVd88Nw7lTMGZrrW aahifXRtDtkdpB25uzeOBialqsVwC8xjy704w64E8+/SJMrZT2ndRvaWLDjHi9usOKhL gN5fJx5JOA1LGYrXq1OeXJ5YF0FiZsPuC+4cz3584ZRM5yk7+wXXqaVUKRt0DeBMwCRv XhTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:dkim-signature; bh=LwCmQQsKUsGNB6tsC8vIC6v8lWj2lMzritP3rnv2BiQ=; fh=ORqO450YHYjnAvQVnHrQRoSXc/Ljts4WdUx12SqEe+w=; b=TjBRRr8S+0QrRuKpFRPn0n1vREYX1GV1JmhF2/m1BHgWYeZc5nx/WDHwsyRF+QFDnU EYh48988xFl01f3Cp3DelzBkWjJt/P//QnoURvYe2uQ1wvFsvaaI+DeV2X/Ki/t63447 MCKatjbMuAt8e5LAuv9f6uSLPPl0NJVa1aWLALewHKEVZeFgY6uxx1AgId86iA1SJsKk kF/KzdKoF3tTDTvmKX1Pck2bOFkdBg5RoTJP48uF58Ig1q6SuUqONq+bIMsUBCYDREv9 iC1LaUH0skvi+dHhyWCHA2r3FF722bPCXUo666nrSJQXlEMCYsBhx78SYqQpNaN+bkpP sdhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=uCCJxsY6; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48dfd4ffb7dsi7039730f8f.227.2026.10.16.14.35.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 14:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=uCCJxsY6; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Message-Id:Date:Subject :From; bh=LwCmQQsKUsGNB6tsC8vIC6v8lWj2lMzritP3rnv2BiQ=; b=uCCJxsY6Iepe70xdcE4 JkGTMQfnr+6sjA+rOb+GJm3qbXo5iw1Qb2o65lZzaPD9OR7/tX4zy0GkVYR7xY2/80u287+BdvqV+ jj3CNIt7sSuWyBpqbfgYtb/mNo1P2lL6kp3k0vUefqqYiILXwP5Zoxqmt5GmlCXccKl7jOK0IvEYC 0Go1gjSLQYQ1yfKMREiU1E0l8K6wVInRXyxJ4BhvrqL0hTUh3u8Xmd1tL7B9p3l5d3tAS0SthW5G/ 4l6w33++Dn8Hx10ZjUH139B1npRZMDZqug9sksU3+ZZSKDP9xAz25wFdI0ZK8nHA5DQtRvOhc2pr8 eJjCDhSQYIy2L2A==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xHpX5-00GeHO-2I; Fri, 16 Oct 2026 23:35:39 +0200 From: Konstantin Khorenko Date: Fri, 16 Oct 2026 23:35:38 +0200 Message-Id: <20261016-b4-prep-khorenko-vstor-103860-4-doexec-vfio-bars-v2-0-2237f8fbb38e@virtuozzo.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAKqY0moC/52PTU7DMBCFr1J5zbS2YzmhK25QqSA2qAvbmWBTy FR2apVWuTt2KjgAyzc/73vvxhLGgIltVzcWMYcUaCxCPqyY82Z8Rwh90UxyqQUXCqyCU8QTHD1 FHI8EOU0UQfCm0xwU9IQXdJCHQGBNTMBbidpyPUjVsGJbvodwWZBvzLsA3Vqww32RzvYD3VSB9 dSahGCjGZ2vI6s2Fb35Q78+v+z2INRjp1poftEUjftEuEOKiw814fdSMYsF+/82WQCH1qJ2qte dEOophzid6XqltaMvdpjn+Qf24PIjVQEAAA== X-Change-ID: 20261014-b4-prep-khorenko-vstor-103860-4-doexec-vfio-bars-072e6b06f243 To: Andrey Drobyshev , Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3246; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=1ugVJ34w4AKw7fKox85WJZTcBIUJfFBUrX9jM2YpApc=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBq0piuTTIGGIL/b7GUVC7U3W35sdpR2R5tLXOjP CWa+gOlvXeJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCatKYrgAKCRBRlgpH+WFc Kv1oEACR27zt9AhSlGk5lyF3bYPOU8jZ+3Dc1ZeBWnlyu7HVyCx21Vj4hpgbZq7BawH1nPio4rS 9xBftzVEWFVGuO4yGmg/Jcnm3PAj8bqv3zPGkiidwVeQiWd2HrIpv57VP7N9adeu2jf6iZ/wUby BaI3QJU5CoAx/YLQxg9nTPFFcSFQRfAxipAcgWQmuUVP6bRzsbDdac5KWG+SZRyUcTIh+9OEZYa nNUgZQBCp30GhoweOmXxb3li72FKsLEvaIF/GkzfdLFcDlT3TI2XIWiIrHNjp62IW1uStQrQgUx 2E7FBwXqhHr6mi9+jjOZaYSyNUPyqK3GtKdrugjx5DxiJ96tp560nYWR5L0WmfvdV0jVK39zw/L 9eZ0n1f27/rKoZJT4+TlqyIHPuBxHZgft0HQu/EvAA2CQnHZxu0kvUbyG4m6ZXQvD8xDKOaFPIk KcJwZkt5lgFEgDvjHKpd1EW3ryjEDj3AJIziKqXWoIn0EVW6mhD2/OxOigurkruNyT0fYk2yiPv zXsUoXzBR7ABUqa8uZTf4Qp0qqTjKSRJuNP/hmJOFySYwOY+58GywToUCAkGUH1Lp+xfVplUaMP JJ+Cqi5HBWStGfBh+oXhOLRjCipF9b9qsZ6QReuHM/gq6CpXn39/PkVzO2VuiG7zWQM8eFgZKSg TSj++qbIZgNBegA== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 0/2] mm: allow MADV_DOEXEC on VFIO BAR mappings X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org VSTOR-103860: keep the VFIO BAR mappings of a QEMU process across a live-update exec, so the device keeps its MMIO mappings without a re-mmap. Applies on top of "mm, exec: fix the MADV_DOEXEC code we carry from Oracle" and needs patch 1 of "mm, binfmt_elf: two fixes also posted to mainline" (the copy_huge_pmd() recheck), because every live-update exec now copies the BAR's huge PMDs. The latter is posted as http://lore.virtuozzo.com/20261014-b4-prep-khorenko-vstor-149847-1-upstream-fixes-v1-0-7fde9ffbebe9@virtuozzo.com Patch 1 (Andrey, reworked) admits shared PFN mappings to MADV_DOEXEC only for VFIO device files, checked with vfio_file_is_valid() through symbol_get() as KVM does; other PFN maps (perf ring buffers, Xen privcmd, /dev/mem) stay refused, as they would underflow pinned_vm or free their memtype twice. The copy takes a file reference, keeps PAT tracking, and write-locks the source VMA. Patch 2 is the selftest: a real VFIO device bound to vfio-pci (the DOEXEC_VFIO_DEVICE variable names it), plus the refused cases. Tested on a KVM guest with the guest's QXL device bound to vfio-pci in no-IOMMU mode, release and debug kernels. Out-of-tree VFIO drivers are admitted by the same check. Andrey tested qemu-update with an NVIDIA vGPU on his first version of patch 1; v2 calls ->open() and ->close() of the vGPU BAR mappings the way that version did. Other out-of-tree drivers were not verified. https://virtuozzo.atlassian.net/browse/VSTOR-150233 --- Changes in v2: - Patch 1: do not refuse a VFIO mapping whose vm_ops has ->close() but no ->open(). The NVIDIA vGPU driver maps the BAR0 pieces of a vGPU that way, so in v1 qemu-update failed on them with EINVAL from madvise(MADV_DOEXEC) (reported by Andrey). The driver now gets ->close() for the original VMA and for the copy with no ->open() in between, a sequence QEMU's MADV_DONTFORK otherwise keeps from it. - Patch 2: the VFIO case now also maps the BAR one page off its size alignment, so that the copy duplicates PTEs; the aligned mapping gets huge PFN entries, which the copy leaves to be faulted in again. Both cases exec a second time without the mark and check that the BAR is gone, so a copy that kept VM_EXEC_KEEP would fail them. - Patch 2: a BAR that cannot be mapped is reported without a stale errno. - Link to v1: http://lore.virtuozzo.com/20261014-b4-prep-khorenko-vstor-103860-4-doexec-vfio-bars-v1-0-7be6c4d68114@virtuozzo.com --- Andrey Drobyshev (1): mm: allow MADV_DOEXEC on shared PFN mappings of device memory Konstantin Khorenko (1): selftests/mm: check MADV_DOEXEC on VFIO BARs and other PFN mappings include/linux/mm.h | 12 ++- mm/madvise.c | 28 +++++-- mm/memory.c | 2 +- mm/mmap.c | 53 ++++++++---- tools/testing/selftests/mm/doexec.c | 157 +++++++++++++++++++++++++++++++++++- 5 files changed, 227 insertions(+), 25 deletions(-) --- base-commit: 5e71073f26ce94dbc9e38e7b65920a46a8c431da change-id: 20261014-b4-prep-khorenko-vstor-103860-4-doexec-vfio-bars-072e6b06f243 Best regards, -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel