From nobody Sun Sep 28 16:34:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758679779; cv=none; d=zohomail.com; s=zohoarc; b=I1bCLK2EZAEKpgwdyXcTK4gaogRwsFkcqv4kn+6T36iZugdPZPCkebIx/W8D2VhnCAicrrtAVFHfEEnimglJFFgufTyGv/fC3GmECEs8v/Ags0Ota8m5b3MgmHl0GuRNfK/Ws9VXAbl0l+FfM84dexvtYQjivHFJfcV3Z2TqCsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758679779; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JpDWwmGB3FDcx3IksRaylh4MrMqkVjqSJs30QhIpAxg=; b=ZxOW69XqHFSCoKaYiwZ6Xvh6v/WdoyNhit2xV+s/EiZ8rpP+OaPbLFrQ0LSbWQfxUPA/fAXUEfDSmVZgr8K5aA1C/W/cNdNwulb/RBLdRdZPvG06ETAQrXuCdpYzQGRmZHy5VW0EuGiThX0KjRKqYMh4tG4kxYyuvCJpZPkKCP4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17586797798021023.6064905086139; Tue, 23 Sep 2025 19:09:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Evf-00038p-HC; Tue, 23 Sep 2025 22:08:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v1Evd-00037u-5t for qemu-devel@nongnu.org; Tue, 23 Sep 2025 22:08:21 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Evb-0002e2-7k for qemu-devel@nongnu.org; Tue, 23 Sep 2025 22:08:20 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-77d94c6562fso6292998b3a.2 for ; Tue, 23 Sep 2025 19:08:18 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-77d8c3adfd4sm15929130b3a.82.2025.09.23.19.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 19:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758679697; x=1759284497; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JpDWwmGB3FDcx3IksRaylh4MrMqkVjqSJs30QhIpAxg=; b=uQvw/9ESLMKiSMbhCF3/rtAmQn+coYU+sMJa/rziAxt7ZDLQaMWqwWAXKZgoRTPT7L X3ojBzeXTfYFc8TzFKZrZvt4WESe8iRxGHdqi3yVJVLhAXTvOBzwSyCijpPKyngZ1m85 YNoUcnHvRrIRdco+fxJTEUU85O2peBaIOdZp3q83bDMVOFIiOqutPSHTtTqj4NTzMZBC mip8VRCw205N2krmPDqPOVDSfRKZu9i89gyBNVjBZF+Rq1WhfJ1Kx9FrZtvxZApHwqMw JrqXKaUFYpw0V+bSUR3sg1uep5RogON+Gz6FtN37Q0xX5N5UfXPCpwLGVPMV2kfE0Njp zY9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758679697; x=1759284497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpDWwmGB3FDcx3IksRaylh4MrMqkVjqSJs30QhIpAxg=; b=muhqvANPOzorRDbklc/qOfbkwrX2AXUGR4MS0/iQC/GxzIshxe5JTb7uIqSV+q6E8u koOFgGTu32eTaU/9tlXYL9RjmnFO8teSxHyhiwb3OVd58qXvLCiIiTySQsebNDxNTOM4 Pt+ZTB/f8Ob0u5OzTC1Fj0U6TPD6RFzyDGLjrRqaHORCyk0dWGa91++rWJpvTvSd4F/9 BIYEeCD4KHJBwa11wNRzIqkZAFJ+de7CyNB4e2G/3GPJV6vx81X5DBgjTO7kWXeF+hz0 kjYYAdwfIZQSfSOq+QY/+6aPoFV723ttaBqVFmI6/HE4lRDNtff/WcVqdeC2jl5yF89O bD7A== X-Gm-Message-State: AOJu0YwVay1HaDwncFtxUAh4mMUKjrZ/lKOkLRxSz0UZpYL3UySsOG/y /MMYrzYsJD3pRFM2cxZV3rPctK3mXtHrdUoTdaDWfh99mIiGer85QJehOhKwBUSBK0D60YS4Rt4 cbVeF X-Gm-Gg: ASbGncvleVhknUJVevA3ryYbdFVj2bvQHvvjSkjovxmUkdIiw5bN1LaBcRnwEvaReYk gM+uJWBCUsQ3eCfJokQSJyrc8kHuByHd0yAcvH59rZAEtr30Vtu3TfHppognEK0ddQitDQBPTcc tpu8MIPeUSj4CA2XnoMwxHU3yYb8GPCg/S7RSft3uz93ow2/dLJeMk3zxuZLoQqTLBgzJP21/bj Sc9my2mnufL7JhnCrYeNggFtzLprAfMR/ymhYxKr+HMyQ6QOzyR+hkkZK8sAM68k5BBE++MsnZg NuHsEwkgOu+GmVSKeZRcj0qfmH/tfOhQZTK0ix+ser5juzS7BGtLAiPYyfduTVxjfS+CePMJ0t1 wE6tQK0eoBidfCpRXDV7vvEBTzrKp X-Google-Smtp-Source: AGHT+IHTpJEH5+aN3OlfIsrxQV5OWGFwyEgajXBJiTsfggLwyDsOwSuIfiSLedJHCTtZ9O8w+B8nxw== X-Received: by 2002:a05:6a00:889:b0:77f:3f06:1f69 with SMTP id d2e1a72fcca58-77f538e1402mr5382626b3a.12.1758679697274; Tue, 23 Sep 2025 19:08:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: jonwilson030981@googlemail.com, Jon Wilson Subject: [PATCH 2/2] linux-user: Support MADV_DONTDUMP, MADV_DODUMP Date: Tue, 23 Sep 2025 19:08:13 -0700 Message-ID: <20250924020813.3909287-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250924020813.3909287-1-richard.henderson@linaro.org> References: <20250924020813.3909287-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758679781201116600 Content-Type: text/plain; charset="utf-8" From: Jon Wilson Set and clear PAGE_DONTDUMP, and honor that in vma_dump_size. Signed-off-by: Jon Wilson [rth: Use new page_set_flags semantics; also handle DODUMP] Signed-off-by: Richard Henderson --- include/exec/page-protection.h | 6 +++++- linux-user/elfload.c | 4 ++-- linux-user/mmap.c | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/exec/page-protection.h b/include/exec/page-protection.h index 5a18f98a3a..c50ce57d15 100644 --- a/include/exec/page-protection.h +++ b/include/exec/page-protection.h @@ -30,7 +30,11 @@ #define PAGE_PASSTHROUGH 0x40 /* For linux-user, indicates that the page is MAP_ANON. */ #define PAGE_ANON 0x0080 - +/* + * For linux-user, indicates that the page should not be + * included in a core dump. + */ +#define PAGE_DONTDUMP 0x0100 /* Target-specific bits that will be used via page_get_flags(). */ #define PAGE_TARGET_1 0x0200 #define PAGE_TARGET_2 0x0400 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 26c090c95d..b213f1a35b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2120,8 +2120,8 @@ static void bswap_note(struct elf_note *en) */ static size_t vma_dump_size(vaddr start, vaddr end, int flags) { - /* The area must be readable. */ - if (!(flags & PAGE_READ)) { + /* The area must be readable and dumpable. */ + if (!(flags & PAGE_READ) || (flags & PAGE_DONTDUMP)) { return 0; } =20 diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 0b69efe54c..35698c413c 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1254,6 +1254,12 @@ abi_long target_madvise(abi_ulong start, abi_ulong l= en_in, int advice) */ mmap_lock(); switch (advice) { + case MADV_DONTDUMP: + page_set_flags(start, start + len - 1, PAGE_DONTDUMP, 0); + break; + case MADV_DODUMP: + page_set_flags(start, start + len - 1, 0, PAGE_DONTDUMP); + break; case MADV_WIPEONFORK: case MADV_KEEPONFORK: ret =3D -EINVAL; --=20 2.43.0