Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp300079pxv; Thu, 8 Jul 2021 02:53:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCPCMw4ej2xteBUe/2OyEW93crBADJ2Mk23wuEW/JvY+A50GsbT6tQhAKQwqDytsgnu3aW X-Received: by 2002:a05:6602:160c:: with SMTP id x12mr24184908iow.16.1625738013209; Thu, 08 Jul 2021 02:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625738013; cv=none; d=google.com; s=arc-20160816; b=se+96UuUbOYTXbYPK8cr2Lsjpx+Ywlym0ju2rzpu8KvbjrISYk18mEfOHYFkldTTlj rKV+FpLawVO53cn391wlqwbMhEaqky5e+cw6ubkW8by5eJPA3Lk3T179Cnm/pKG9Javi FvpQFm1xYHMRV5s8dvLeWKGMDo0t+Bz0k3yANo0NXqAJSBsvQFT1WmXLohTfkvzt0xX0 STLP3ROCE/HV+Bsfd6FEM4l61+NjKuJ/IxOSav6STTwXdJ3LZHU3LBCjWf672nr5X5tj IUvPhixxodJ+h/Xv1lY3G7oz4AhrHBnfEjZS4B936Fjob0UqolsTRd3RDgy/c2SQfdCI 8AHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=bLZeQgJQWNieyMxpHonoPK10uPFmRbYZfTpkLWo61FE=; b=tll/7yxMIADup7qSei+xtPy3E8+sBNNZcj1ARm2l4b9AmUVdv08FwIeDkNHTbao8Mu w954ysMCYOZma1QVYviw9YJoEj7ebWEByeTXxmiK5vqO2Xy4Ysa6OweNHbB/Y91zI/tl i95OgiVlbPPPs7+vBbFzA/typ8UOAuOuazQ0YSohCzzPu6jXjnc9nvgDU5EcSCK6aaos rEw3R0aMMi2lBc+/OdeAEkfjfyKgZx+PnEGiBcGG1YfemNfL1VkRCcyeE0d7Jzc2KtAG toG2ax6SRw/UQQU26Qw8qh3avXVdk9PlwIsCaArMlih+BqX9B6PNWNb0pclTFR0J/Uk4 Y8JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si1881091jap.126.2021.07.08.02.53.21; Thu, 08 Jul 2021 02:53:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbhGHJzD (ORCPT + 99 others); Thu, 8 Jul 2021 05:55:03 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:10432 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231360AbhGHJzC (ORCPT ); Thu, 8 Jul 2021 05:55:02 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GLBMP60LjzZpW0; Thu, 8 Jul 2021 17:49:05 +0800 (CST) Received: from dggpeml500016.china.huawei.com (7.185.36.70) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 8 Jul 2021 17:52:18 +0800 Received: from [10.174.148.223] (10.174.148.223) by dggpeml500016.china.huawei.com (7.185.36.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 8 Jul 2021 17:52:17 +0800 Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC To: Anthony Yznaga , , , , CC: , , , , , , , , , , , , , , , , , , , , , "Gonglei (Arei)" References: <1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com> From: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" Message-ID: Date: Thu, 8 Jul 2021 17:52:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.148.223] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anthony and Steven, ?? 2020/7/28 1:11, Anthony Yznaga ะด??: > This patchset adds support for preserving an anonymous memory range across > exec(3) using a new madvise MADV_DOEXEC argument. The primary benefit for > sharing memory in this manner, as opposed to re-attaching to a named shared > memory segment, is to ensure it is mapped at the same virtual address in > the new process as it was in the old one. An intended use for this is to > preserve guest memory for guests using vfio while qemu exec's an updated > version of itself. By ensuring the memory is preserved at a fixed address, > vfio mappings and their associated kernel data structures can remain valid. > In addition, for the qemu use case, qemu instances that back guest RAM with > anonymous memory can be updated. > We have a requirement like yours, but ours seems more complex. We want to isolate some memory regions from the VM's memory space and the start a child process who will using these memory regions. I've wrote a draft to support this feature, but I just find that my draft is pretty like yours. It seems that you've already abandoned this patchset, why ? > Patches 1 and 2 ensure that loading of ELF load segments does not silently > clobber existing VMAS, and remove assumptions that the stack is the only > VMA in the mm when the stack is set up. Patch 1 re-introduces the use of > MAP_FIXED_NOREPLACE to load ELF binaries that addresses the previous issues > and could be considered on its own. > > Patches 3, 4, and 5 introduce the feature and an opt-in method for its use > using an ELF note. > > Anthony Yznaga (5): > elf: reintroduce using MAP_FIXED_NOREPLACE for elf executable mappings > mm: do not assume only the stack vma exists in setup_arg_pages() > mm: introduce VM_EXEC_KEEP > exec, elf: require opt-in for accepting preserved mem > mm: introduce MADV_DOEXEC > > arch/x86/Kconfig | 1 + > fs/binfmt_elf.c | 196 +++++++++++++++++++++++++-------- > fs/exec.c | 33 +++++- > include/linux/binfmts.h | 7 +- > include/linux/mm.h | 5 + > include/uapi/asm-generic/mman-common.h | 3 + > kernel/fork.c | 2 +- > mm/madvise.c | 25 +++++ > mm/mmap.c | 47 ++++++++ > 9 files changed, 266 insertions(+), 53 deletions(-) > -- Sincerely yours, Longpeng(Mike)