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 74F2D802A5 for ; Wed, 14 Oct 2026 17:12:44 +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 69EHBRgD001227; Wed, 14 Oct 2026 20:11:28 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69EHBRgD001227 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ikaAK46C" 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 69EHBHgc001177 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 14 Oct 2026 20:11:18 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69EHBHgc001177 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48b01a74792so2919126f8f.0 for ; Wed, 14 Oct 2026 10:11:18 -0700 (PDT) X-Gm-Message-State: AFq9FYJXUSRHf9w+6g2aLmACw1RK+0XUgrYonWwEnH04VoVJYVwvFLpA vHETN3cVoSeG7sDnsq+nLz6SHoVqpZBaZ/nz9FT1Lfe52N1jVOAYrgugnk60+G/OO6FG6a/zHja c/nekCOgt1vSpQ0ZcTx5jUSiIMtvB3DRTUOKP6e6bxrgydq/vHq7nUw== X-Gm-Gg: AYBFou3vhnzNg/fTONqaksPeSlJxdQ0RyypHsZ9FLsQxvlmNBGapLGdBbqcTNmkaVOw ulRvyjFUCDkhoeb/ZsPbwy2c6RgBv854UEeZsLACJYiYzqb3be/Yt6YHUTzU85Q5MLnj427oARe O21USr+uyGqjcXD5TNlOLpPt9a4bqMFBoagO6Y7L/Z/yJEylRP9uwG9x40FSmU/KjWbVlffhg65 5yo2j5kkVbO1JuAZs/GUs+ugjhpnL/7b/7YhOESKbm3oSq+f17dEvDXGWnSHbK8jgPyaWbAvuFe Zh2qLw1cSWxUe1aVHdF9HQwzVymYZQPw8K2mUct1bVvWct/ui57jwM/sbrNXL9fPLKnOfUT10WW uQOyTbthv33A8/Xpc X-Received: by 2002:a05:600c:4747:b0:4a1:88de:9e8b with SMTP id 5b1f17b1804b1-4a18e49d65dmr327337225e9.5.1791997877293; Wed, 14 Oct 2026 10:11:17 -0700 (PDT) X-Received: by 2002:a05:600c:4747:b0:4a1:88de:9e8b with SMTP id 5b1f17b1804b1-4a18e49d65dmr327336445e9.5.1791997876536; Wed, 14 Oct 2026 10:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791997876; cv=none; d=google.com; s=arc-20260327; b=BfGOsgApDQJiNNDvfHqp/O+SZgT59VBZ/j8jpiKOo0YVygX9J5gK62MT8BWXBVSdA5 5Z+l+Wyh8ttb8tLeXBtae4L/JIeEakJBtnxCLrgzrwrDxDbu+ylodLJQxB+VfI/N6IjD 5jmsJUWNk4mSUNl0pJ0oV3jGrVpsRZ6UnmjPHG2ySWzOmqDqBwMEonv2ZXHTAIBC1CPp xPxb2OusfvxNQlyXglfx7kgauYrsVmopVS5i+lfwLwWY8AuSIUv/kWPRH6+hgefJnbkQ 7QiMsSLPS59coZgOhRoW+2x0Z0dM+tyyiSjOk1hcLCR8pSJCkY1b1GQga12EFVEV95iQ 0Xeg== 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=axouB5/KM+a0Af7J+8/17CIt9IkFWyVDr2Mvqz5ibLc=; fh=aQfw1i5a4NQPWqzJLDKkrMTvdRoUn/cswL6yDWdmKfA=; b=EiOL9HpYJlLQYCx9jjl6PSFDs6ySZhQidUlNM8pw8Bdxt4/ud1jS5dHUvULpr/Wg2L JJk2QD1uCfyLzcXWjbfY1Kkf00+epjTToLeT/rcqJ7GFKu2ecThvexkJQreH7Utyq34W RwjxzytZeEJdOX7zd8a4ta0qzJ8DrKqGdxmbevXIJ3inj8JR+CkaOHadig+DRt7d0Nrt pRcII8l6rSsNZAKjPem1zpHGDkCIhzSXUVplhwOa/K2VI7Cv5Yucs31M8mwCCvt2ucLD M5g9wXZFgx2m1WhTUQr4Zk4CKxbHfnSOResuOqygk4CSZB/4uXOZ6/nk3doeo/Vikp39 Xw2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ikaAK46C; 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-48de0ac85fesi16784036f8f.121.2026.10.14.10.11.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2026 10:11:16 -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=ikaAK46C; 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=axouB5/KM+a0Af7J+8/17CIt9IkFWyVDr2Mvqz5ibLc=; b=ikaAK46CkRP9Jea72Mf MsSZf35YzwWYz9cshFrn4jTNySXA/j/hGyzDiM7ilR5tKG5JkOrKDmVgv15xzmlkSfYDKUWZPxHeB JldjPQTynYiDAoLe7NSUuFUAbYponLLchjYhAzdsXQtQ4XiT4dOXIJ6e7PBnHVasYYoJltnBRaRgX nEx4XmfLIog87dyvxGWmoNovRYycJ3JO2a2ADdO/sYDHzHXui4XMYa+3Q37yq2dQo+BRdC9DMzs0d +TLKeDWTPBXJQp/hlaPmGQVJTuUutMQWIJUZQsnEVvHTJhmjTpSeZvzF31OQ5u+cH7WP9/0PtTPsS c4vvFhA9MmfUOiA==; 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 1xH2S6-0081J5-2w; Wed, 14 Oct 2026 19:11:15 +0200 From: Konstantin Khorenko Date: Wed, 14 Oct 2026 19:11:03 +0200 Message-Id: <20261014-b4-prep-khorenko-vstor-149847-2-doexec-pinned-memory-v1-0-36f1120f9b57@virtuozzo.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAKe3z2oC/z2N3Q6CIBiGb6Vx3JfgsKybaKvWSesA8CvJCQzU2 Zz3HuTq8P3Z80wkoNcYyGE1EY+DDtqaGNh6RVQtzBNBVzGTnOZbRhkHycF5dNDU1qNpLAyhsx4 Y35d8BzlUFkdU4LQxWEGLrfVvKJikyGVBVYEkoiPhocev9kZqpaHcMHJfhtDLF6ouSdNVioAgv TCqTpXkWdJnf/31fDmefnoGvQudR9HCwp/nD37dS5XiAAAA X-Change-ID: 20261014-b4-prep-khorenko-vstor-149847-2-doexec-pinned-memory-51b0e4b50c5e To: Vasileios Almpanis , Andrey Drobyshev , Pavel Tikhomirov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3638; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=quAlaRj3nbWKr6NYCBGf+AOJ0+T2WECQnUpd6a/jbgw=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqz7euloAcCKJXnceRJfncuScVXbu/UQoRf65zg RuUiwPmBqeJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCas+3rgAKCRBRlgpH+WFc Kua9D/42rxYpJQCjkxhdfPbA52UXx4eSHphhWjv/YmD6J4xGwm5hXxrx5i/OxzJBejrfLq7od+Z I8gm+7/4RzWh+HNwuOlDKjtvPpsw/8dlp61Pb/MuxaQ/uOwsv4PxL4vcZQiOfNgLCCyC6P7KDpd 4Xj1EAFdyjCvLt2RT9YrDlVoSDPSR9Lla4MB/Lg56cR+7kW4vactwqbSbePVNmjw+U6J0WwN0w6 6KE5bqrk1wRq9ByooNy8GdOBW6044eHeIZhiFcNMxq8dHZ/vr57jVK+LZQmT0Bc1icUrfguz/Sm 4iJTqKEs/RApo4rsnir+l4DGapGtRReVA1nmvJAosT6UbDvFd4gdwLGwHiSqx46aOJTfuNtmImj VCECjXJq8R7RVG9Uk6mGVfA/z0bKOcrRRwoJGpUzQoCSdT5S+DdHNWw2yr5LhPXSVI+bNPwena9 jDMq+qqCxO7lz3SjNBhQgn4mgeJDTOD20GVmGxDFkLkgtjK6usovck+65T9aQ6tOzsAWyfPJVan PiieYkQE27GHHm+x8vEVt7KzMmEtiY2RCCCO6D+QcyFRjh2FA98FIq7DsPRs28wyqqXpE7MUoyx 8yvTW06cYEZp1GiVWEG4+O6Fj8mxGocyfy4ttOjWDWj+ZlKPyA5ho2qY0ktStmiiPNDJrgcyHkQ L75lqyn9sEAVjDg== 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 0/8] mm: keep DMA-pinned MADV_DOEXEC memory working across exec 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-149847: memory preserved across exec with MADV_DOEXEC loses its connection to long-term pins (VFIO DMA, io_uring fixed buffers) after a live-update exec, because the copy into the new mm write protects the pages and the first write in the new image copies them away from the pins. Applies on top of "mm, binfmt_elf: two fixes also posted to mainline". http://lore.virtuozzo.com/20261014-b4-prep-khorenko-vstor-149847-1-upstream-fixes-v1-0-7fde9ffbebe9@virtuozzo.com Patches 1-3 are Oracle's fixes for that path, taken from UEK8 (uek8/u2) as they are: the copy runs under the write lock of the old mm with write_protect_seq held, and preserved PTEs of COW mappings are no longer write protected. Patches 4-6 fix what patch 3 leaves: - 4: the preserved PTE stayed writable in both mms, which page_table_check catches on a debug kernel (kernel BUG at mm/page_table_check.c). Write protect both copies but keep PageAnonExclusive, so the first write in the new image reuses the page. - 5: MMF_HAS_PINNED is carried to the new mm, otherwise a fork in the new image treats pinned pages as unpinned and separates them from their pins. - 6: the preserved ranges of the old mm are zapped right after the copy; while the old mm lived, a page was exclusive in two mms and UFFDIO_MOVE could move its rmap to an anon_vma that is later freed. The zap runs on several threads, as the teardown of these ranges did before. Patch 7 (Andrey) refuses a preserving exec while a CLONE_VM task outside the thread group shares the old mm, and patch 8 is its selftest, which also covers the pinned cases above. A kernel thread on the mm counts too: with vhost in kthread mode, the vz10 default, QEMU has to reset the vhost owner before a preserving exec. Tested with the whole stack on release and debug kernels: the MADV_DOEXEC selftests (including the allocation-failure sweep on the debug kernel), gup_test, a Container start/exec/stop; no BUG, WARNING or KASAN. https://virtuozzo.atlassian.net/browse/VSTOR-150231 --- Andrey Drobyshev (2): exec: protect preserved memory against surviving shared-mm tasks selftests/mm: test memory preservation across exec Anthony Yznaga (3): oracle/mm: fix VM_BUG_ON hit when preserving memory oracle/mm: hold the source mmap write lock when copying PTEs oracle/mm: do not write protect COW mappings when preserving across exec Konstantin Khorenko (3): oracle/mm: write protect preserved PTEs but keep them exclusive oracle/mm: set MMF_HAS_PINNED on the mm receiving preserved pages oracle/mm: zap the preserved ranges of the old mm after copying them fs/exec.c | 111 +++- include/linux/binfmts.h | 4 +- include/linux/mm.h | 1 + include/linux/mm_types.h | 4 + include/linux/rmap.h | 8 +- kernel/fork.c | 37 ++ mm/memory.c | 93 +++- mm/mmap.c | 7 +- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/doexec.c | 814 ++++++++++++++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + 12 files changed, 1050 insertions(+), 35 deletions(-) --- base-commit: 975b3d461d014d75dbc775f44a4758fb41996d09 change-id: 20261014-b4-prep-khorenko-vstor-149847-2-doexec-pinned-memory-51b0e4b50c5e Best regards, -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel