From patchwork Thu Dec 5 19:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13895944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0775E77170 for ; Thu, 5 Dec 2024 19:08:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 081EC6B0085; Thu, 5 Dec 2024 14:08:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0319A6B0089; Thu, 5 Dec 2024 14:08:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC7936B009A; Thu, 5 Dec 2024 14:08:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BAE7B6B0085 for ; Thu, 5 Dec 2024 14:08:07 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 37118141379 for ; Thu, 5 Dec 2024 19:08:07 +0000 (UTC) X-FDA: 82861839858.01.8AB7F2C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 80363A0019 for ; Thu, 5 Dec 2024 19:07:47 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=XnST4onY; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MBgoqD7r; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733425673; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Jw7+No8Q8NJt3qg4bciq81qxw2MOHFfpRoOoPMtFOaQ=; b=upANPCQoyUtx9T5HVE86p/7EbZejx28PVhC+YfKpK4f+r/bHNT+ETcazrm0Mlykn/a4ePw sbQVtwH/MBqdhn8P72W3M24vQdG3k/Cl19GjTkiK7PE3WOjflsz2NIEC4HrBdZ8uZwax5O yGfr3/LioShPFL0trPuW15j+VI092Ec= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1733425673; a=rsa-sha256; cv=pass; b=To6vM0EMzkdxa/v5sZZ47nRpZ7RKL563u2K0JsNCgyUx/QOrTNnLQua1rqfd9oDfzYOZJs k9q+XcEJ+1a/wpHvFxtsCW1b/p/QY4AMOvMpA93CI7A+l/HA458clavkHG18lc65DWjS1H LTj4twcyPM7mx4pLlhiFqCLqOR1kuH8= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=XnST4onY; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MBgoqD7r; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B5J7ScE004597; Thu, 5 Dec 2024 19:07:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=corp-2023-11-20; bh=Jw7+No8Q8NJt3qg4 bciq81qxw2MOHFfpRoOoPMtFOaQ=; b=XnST4onYCTNeekdbGmTzgvd94m4memY7 /DlrhPkup4oe8pIJsdEqGvF+hENtYgjN5q5IBrB5W+Z3aT4mD7VJD93yLLdGK5ul sopHm99ea2FdP7S5iWPCiRXqh92t5ZQnmxaNQ7FaZyEhLbNM8ImmIiZ1ibdWc/6I 9xHV7ifhoPyT1BH0lBp1IizuzC4ZyudTFKop7I9/bMEjF8+hwY4y+qOgk0AFgCY0 5rFwsT9HeJDR+Rlra/gnrMwPEFPN+lm/gEoHJYhIwwLzhy5TWLF/yIuqfdWlM9+2 aX69NJK8sE2XCaKS3wBmmO+0rIlCyCPCxtVC0ZjU1Kgtw38SPuQ9Rg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 437sa04015-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Dec 2024 19:07:58 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4B5HtuPr011691; Thu, 5 Dec 2024 19:07:56 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 437s5bat5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Dec 2024 19:07:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zLA9/byjZ3NppYz7JwR1KYfQJYGMkQdsdIX5prVeRSVukJzPBxlZ7rlXFUzNswmCNtlcswxC9bwRbwZ1F094oGyscoRH/tjlLMHN4bIvth1+a/C7o6aEumdwsCliQKnic92HE/voaPKR86vb+OgrOozYNmWDdzK6RnIjRXnyzdj5Vk4k5lmdtHPgdbOugvhDkQwVHz/Z6x15b1IXsw2P+fRy5zHspJiorDgreWkOuz5IB0W4NDSjezO+Yk+bfk/T44WHhQROGYLrZFuvTqSOuBWbY1qUXAUU7HSCBNWsWkytrGMXOOdOk79yVPYhFNrcf6NI6jTCSpY9XL077ny90w== 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=Jw7+No8Q8NJt3qg4bciq81qxw2MOHFfpRoOoPMtFOaQ=; b=nPJ4wL/bQ8Ta3RXriBSWVaTKqH7RZ0638NtoRBUlfHJMuPUR+rDTP9GEFcxOOHkzNyjhRTNI6qb41AFRuKu5iBGFwP2Ctv2Bhha3kzm0Vi89GgiQIashNNMGtYsvqqtUQfTh6QiICs+VALUhpsD47HWv7FFOrQkhQvmMICdm+iZ6APkCogXTKlv2BA3oZ+ZT7agUGWY82M+IIZ9G8ld+CyP4DiQaWYsEgXO3i153ky4pFLEkKXAyNgA3mvsx1GFBLSGtERuRGtsF9k6xe/8ZAs19lQjUCL8ZzPpGXWhOX0XbnN4kF4ApTDqGQ5IocpMdAzVSfa+z601CQwcJLzuDYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jw7+No8Q8NJt3qg4bciq81qxw2MOHFfpRoOoPMtFOaQ=; b=MBgoqD7rlWlcq8hBraUn5g4oBf90RfDynAeiKGrV26UMsPvYrMZFQR0bFQ49KfsY/ddYCs1KTjTSgCruhPqHEw++IJgDg9ioxJ5wo4iyjM3R4Gln6KEYQa3lWcq6F6MSjlsnPdLsQ7Pp7VrkXZbhN76189MxXG+2Q01MV4YXExU= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by PH8PR10MB6624.namprd10.prod.outlook.com (2603:10b6:510:220::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Thu, 5 Dec 2024 19:07:53 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%7]) with mapi id 15.20.8230.010; Thu, 5 Dec 2024 19:07:53 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: Shuah Khan , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Liam Howlett , Vlastimil Babka , Jann Horn Subject: [PATCH] selftests/mm: add fork CoW guard page test Date: Thu, 5 Dec 2024 19:07:48 +0000 Message-ID: <20241205190748.115656-1-lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.1 X-ClientProxiedBy: LO2P265CA0448.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::28) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|PH8PR10MB6624:EE_ X-MS-Office365-Filtering-Correlation-Id: 75295215-0925-4849-4d8a-08dd15601ec5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: kKoRxdyMd4PYgDvmsJfw/c1oWrKe8Aw3NbUrtLpbpXHVypXaWHg5hUVS4L1/4CSKMkXNMYGGDjhui7ki1E6dSmZxpjVgCtzCUCpFkmbLx9KLkRwb6q1UDNFJX5Kg23VcUCFCqRm0lpNzJmssjZ/phgu4tGazJcqOmf8J+RUtGj9kGZt9L3zM8lHeI7mdU0AcORGMz6TLUXQgj0wa+vA4/Cl3mybi47XwIuTiputH8xUemKWbUrdr7wmzOm+c2QxSO6wKFInBGI8frpXgQW1pvm4QryO1rn2ClRU3Q4TQ3UykalYzTFHzhqsvzKjXesAti+264B+ouui7W6iGj4+fbfwEa0TiPiZPFL9RdfbA+wrsRGqwV5tohrzGFBWSWuevTD4v7V7qgSJMC3aqnvXpDYhPRplxe5yHG0B1TeQ4j0p54XFd/xTBs4Ls1UCXC6Rwyop/k7NC9fZTgwevaZRj2EDtNFPmtaN+rYRTDIucXWbNKPYTaWuwQXsx1Lmi/X18+jeVg002VIQb3IHVtpqzXaE8bmP+w6x6EvaUFGsy2RYnYIzbqqIgRroPIQQQnL6obfEhKvhQ7KWetjShJE4ujrs4mTbrbx3BFHgOsZUIGrjhagiqd4TZDIyh70HaJ5LGS39ekVEoUNwv9WjE7Rvb4zSvMb1JNomp3kro4/7qJMxPQMB9fi5eqFczMP9pWWHT4w1Wzyga+d7TWNjmnwjUqU9mhTaL5sIaylmkCRxeXb3dz3y84bfW2+icLycRTWv3NGWbmLk/3BZ0R5Lmr1S7ctogTyS3b5lgDwru99logRYzoEpAczqHRzii0IFVNtf9bcW599UfPfdVYtpGxHvSxR8jMt2akhs5CTXXO0fHY4uFX/kmimfXzlYllINsg0vcXP51kNFmLTrpHg0rw06/RZOU/je5oxxc9RKJZs/sCzr2V2bW8gkD2atOL6TinbpOPse/ng4W+0SzSAnwbCTVIr3fOPczcT3K1YZLmCgMlcwGAxHYv294lhtPG/lGSlsbCTsV6ltF2OIqfuwQ35is9oW7jj5D1b36/fRpJfARXEifNggoDvqQV/y0opauaadS5wOJiDx3kNNq5xa4djLFH+iCvIw5aBVXw+dJcaJYpCPSFUZ+uLACteBYZY2KwR2ycwNVq8jcDyyvFeLYeHi45Sq3w4kk3FxL1BewX+gZ+GOwUIdvyxMFPAt13s3QY3aM5YuEFg2lSEmnkbasJb3F/DYQKL6XoK9uxoGD4G9H4kdNMcIEZM+CyoLNncTA8TliEqHYa0p8nLlJJfQDPg/anjecQsGHcEXKfbj81y+d20mNX4h72zWtkL2iLmYRWkeKCsBimGGW+ctPMXE+nGmpeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fcp7RugxSgAXzsbOnnUj8qugAJQEMq0ufJcW3imp315yJ8ablVFHa/f8p2kFscy1y0lyf4ZtFmCYCwmqXtC5xYCeYiTxidL4TPS/HpzA0/Usz8nwHw31daGUpo+e5yE2UbUXs/sMnKukk6W4EkA+mXcK6I/OwE80AOOHpH3JXYYc3PDm2xgB1mBtT9dpAmI720auQzSUGa5VaoRI424Y/nfijp0NcqfBIvkxvpYzse1NFwes4SZbWJy7yIOD248xAQzOGuTkSlBGZ8ZZEcKf/zncNz/EQwMefmI/BLrBjTwAfMF/seGgrqpALqM9sg3Zw0qKO6huekp9ZTjFcGNukvTxU8lcYm881GqKa6SH2C5D1goIDuji42bQE47pF/EtjQs1yQPSYEql62AqFNZQ1tmfMseda0NtRpZNXdhe1Nqk2MY6raYEI5bJII/44U/1B4rGsxAu76RWGWPW1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NefjA2H0y6G2gh4yZTytValTHjHX95fwctKZVoCD6jrtnAV10KmB+z8tjJ4ERgUoZ0Q1zs2w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /NZ3EAEquP2Czbl4ZIr8guduZEEEDCA1YpjE0d1O2+IUf4PdSljy8i4eOQqXrRtBW8dNEZha2A5WAORDs7iKzNL9N3iV+U8NNahaBtc/8AB5a1oZCo4sKi6NxsjTPyP8ciM3SCRzyZaLUUcRZoOFJ2H514/wXOdPsetiXir5x6GzwABxt7K28XQVu4YqYTUFhkcEYsZpI53tG1p/pddtSrGPJqjzo7jZEUqlJ/CgSqN820SeGomQDhCGvYElY28mS4ziUZmxRFvLhKwWK/NNAhH1jd1Nvq77OQTIwXvE/KTPB+zDxWIkQrkCjGC7NpTTuM+o8QlTApE1W3QvXgiDYHsi8fwcdUMTPoXgH55ajL/MFgnZyHsDuIcu4ct3ysmMdieCHIdFQ5T+t6rZi8gqAjuqUHCBgaIDxVYl+hszVWou1j4/2Nm2+IPT4lRkMqA8aKqmty8/srfOzzMYEcv/VDloNHLfSDy8Pe9B4C1CSleDASYLOYXTa5yNLzpdQJKrCrVikJ6ZueT/pqViPtuscQsE/6aFZhMITRGhwLo5eZoP/OnrrVvMD7R6oM7IXVj1sVIAEh5IxiMJtjXsAXe0B+thJ1bs8XDzGivCv5mvk98= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75295215-0925-4849-4d8a-08dd15601ec5 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 19:07:53.6183 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VJ1qhSebHeqdvgLJF9zMKyXusZOsivoBvUQDh8nM5lODy58RHjly+XC2RT31GE88B5lAn6OHyM5kZ3omWygn/Jv7qjG8Zy9FLctC4KM+lzA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-05_14,2024-12-05_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412050141 X-Proofpoint-GUID: amCL09qtX8V8AJ7CAZXc1RSqEfUmPS9g X-Proofpoint-ORIG-GUID: amCL09qtX8V8AJ7CAZXc1RSqEfUmPS9g X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 80363A0019 X-Stat-Signature: k5g9z7oi186f6x9rxk36y86xoczgut9q X-Rspam-User: X-HE-Tag: 1733425667-165695 X-HE-Meta: U2FsdGVkX1/XKYivvawajShddLjNuD8fKSQ+yPAAZsCYVJ9b8MiFhCOyUlfciWuM+8N7ycSCXkCLYkUOqkm9kJFPCJ5NscWabcZVh2VQnrIp4e5SczSO1KfLojI6/5SDnDtqJtsb4EEqreeXRUTXPNvwyDDmbNLlVansATsq8EOh4oQd0Wz0FA72oJMaZX+uHvq9wzU6fLT6u6n4Oh+bV2pX4uW2qUrPZuiE7xDJ8lzD+n5w59O2PjJV1wJJWWgd3w5A7bz1FCHWeteOvGFEA4poZwTC7AFs02nlKvHoKVatB8iqk3LBz2oz5rQUeWnMnQwZmcjQPvFSxq/NwyRAjZFWK2C/WSh84tDVr8LSw+bDa2CBh5QDmL6f9/jnwu8mFjZNmTovIOJVeKhur9eJ7CsSuyGf0U1Om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Pi6qtrSIJBdrm5+RWakrz+/MCg31ZwHdOnR748qYwAZp8h8tVmts0g+ec8Wrje0W3YGYdJVBgEZXDuIN4LUx2S X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When we fork anonymous pages, apply a guard page then remove it, the previous CoW mapping is cleared. This might not be obvious to an outside observer without taking some time to think about how the overall process functions, so document that this is the case through a test, which also usefully asserts that the behaviour is as we expect. This is grouped with other, more important, fork tests that ensure that guard pages are correctly propagated on fork. Fix a typo in a nearby comment at the same time. Signed-off-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- tools/testing/selftests/mm/guard-pages.c | 73 +++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) -- 2.47.1 diff --git a/tools/testing/selftests/mm/guard-pages.c b/tools/testing/selftests/mm/guard-pages.c index 7cdf815d0d63..d8f8dee9ebbd 100644 --- a/tools/testing/selftests/mm/guard-pages.c +++ b/tools/testing/selftests/mm/guard-pages.c @@ -990,7 +990,7 @@ TEST_F(guard_pages, fork) MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT_NE(ptr, MAP_FAILED); - /* Establish guard apges in the first 5 pages. */ + /* Establish guard pages in the first 5 pages. */ ASSERT_EQ(madvise(ptr, 5 * page_size, MADV_GUARD_INSTALL), 0); pid = fork(); @@ -1029,6 +1029,77 @@ TEST_F(guard_pages, fork) ASSERT_EQ(munmap(ptr, 10 * page_size), 0); } +/* + * Assert expected behaviour after we fork populated ranges of anonymous memory + * and then guard and unguard the range. + */ +TEST_F(guard_pages, fork_cow) +{ + const unsigned long page_size = self->page_size; + char *ptr; + pid_t pid; + int i; + + /* Map 10 pages. */ + ptr = mmap(NULL, 10 * page_size, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT_NE(ptr, MAP_FAILED); + + /* Populate range. */ + for (i = 0; i < 10 * page_size; i++) { + char chr = 'a' + (i % 26); + + ptr[i] = chr; + } + + pid = fork(); + ASSERT_NE(pid, -1); + if (!pid) { + /* This is the child process now. */ + + /* Ensure the range is as expected. */ + for (i = 0; i < 10 * page_size; i++) { + char expected = 'a' + (i % 26); + char actual = ptr[i]; + + ASSERT_EQ(actual, expected); + } + + /* Establish guard pages across the whole range. */ + ASSERT_EQ(madvise(ptr, 10 * page_size, MADV_GUARD_INSTALL), 0); + /* Remove it. */ + ASSERT_EQ(madvise(ptr, 10 * page_size, MADV_GUARD_REMOVE), 0); + + /* + * By removing the guard pages, the page tables will be + * cleared. Assert that we are looking at the zero page now. + */ + for (i = 0; i < 10 * page_size; i++) { + char actual = ptr[i]; + + ASSERT_EQ(actual, '\0'); + } + + exit(0); + } + + /* Parent process. */ + + /* Parent simply waits on child. */ + waitpid(pid, NULL, 0); + + /* Ensure the range is unchanged in parent anon range. */ + for (i = 0; i < 10 * page_size; i++) { + char expected = 'a' + (i % 26); + char actual = ptr[i]; + + ASSERT_EQ(actual, expected); + } + + /* Cleanup. */ + ASSERT_EQ(munmap(ptr, 10 * page_size), 0); +} + /* * Assert that forking a process with VMAs that do have VM_WIPEONFORK set * behave as expected.