From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1C1C31F992 for ; Tue, 9 Jun 2026 14:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781015915; cv=none; b=qZiqxMS/mxDJgx8XKjDcZEOwl5kTN7IijC/sO1+VMI4GOJVmUqdci/KCB6JVvsW4A2PKvT+ZFPQ7yEVPQvd6wYnHjTE6QIjDTUBVKchs8Ogd15GYCKl4OeA7HmrQ4PaHYZYb/uy6BtR4u7zqo/OcHpUYIM4h6lcH7BDsKXOPGIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781015915; c=relaxed/simple; bh=1+wisLaRZXHWEDGUNtz5zV4JHqSTBLC0Z44dERANkAg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HJht8NUGdhnv9rFcm3+RqLwmWmhyEuD4kHEvNX2oUhHqRb63NWtdrQ7tfKLJrDCfjQMxPoRh1SWu/cSEtb+vI5D4GJbpF4CuOJ7abpm2x/oYwMBqXXRpmz0bRpXpWRm3Gm6/p3OujIFpS5fm4FHCMksA8w8z8pD5iR/VlICD0+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IK+3Yb+s; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IK+3Yb+s" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-36ba9f46338so531980a91.0 for ; Tue, 09 Jun 2026 07:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781015913; x=1781620713; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ptWu2hzkQ1kCjnXDRGNBo5UqedD/Jo7SZZDSrDj9pAA=; b=IK+3Yb+seJg6Kf6duOz1Bp9QIttZqQ/JOG2KBxpaD/H2yRc69/SEMLVew8ZDLtShQp ViE5tNbPsP/1APtZwNoKPvlyh5mbl0RzrNFtWCCcwEF6Dize8q8J4vVd9sJOepqIC+AF yZ/XtsBYpo9UznE8fSCxw314IM4RZgAuECb+UOv1ftpxY/8jre0vDnnY6P5PvTrxIzVZ 8iV0WRE6bFjArAxNislRPBoNdTa0x6pViBiV5+i4fF10oergqwxxgGUaMpr3VdDmDjF2 RvYehCM4RhrycpCVH7xkL+3diI7XzJGQ+t3LBgfZFMFpCCR0Gx94ZGIfqkyxgHrWcEAu jTCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781015913; x=1781620713; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ptWu2hzkQ1kCjnXDRGNBo5UqedD/Jo7SZZDSrDj9pAA=; b=UdsV5V3O461FeJs+bOybtS3SnnUCmhxs9WR4cKdXT0zmNj4yNgg9WeNojGFHrItZge 7kceCsddfXM6pvSRSvqcpQniYyFOv1w1S9TlzQRjjMcmLsNyEUH+f+P9zEE1RuPPrdH3 nS4avfhR/ygmOqXzC6tJgPybTbPhD0t6kg5HNYJ3XtWRk3+9ChVf3G1l30Yy1+GXVFg6 txRHe97Yim3yRVcPoj3gvuFGUpNZAGl9Krlz6mT+GTh4EpTRNv5ZjE1uULx0xIQr6tL0 MjaicxPse45iTmDxuaf4WBI+DIS9Fv+mmrQALzJBeQ8/nmTVGqCawM7mLPNbjaiA6v4K I8Rw== X-Gm-Message-State: AOJu0YxGzpQsAiBSzBp57GG4xIsKEzqnMxa4NXXCd3iF4+5iYjw7GhGW aiKWA1jBwQycuUpT8wLbxZ2EQzJLF5BV3mSV/TobqdQDs1qDBgYVHNY3 X-Gm-Gg: Acq92OGjaGFLsI07uBzUyjsm1PwevPu401v0pjfBkW722QsrMaDrqTLcuPQ8MuRVbjH TG5Qs67clP4HFPy0LhqJIfWMP5faenKzF76E1ec+/lGLA4iLywFFWMdkIV5pqncoKmOmDnFmZlK wuNTdzhmi7z2kL/HoXNna8YhS9Lap+ZMy9Fsbxcl0zFcVz0NZq0SflP8j8YPnyoN+NS6+p+HHIR MI/9iNGlRs2C3/uZ3nyX7bteZTp0Xq/uu10s7+sf2RNBuVBhbiTZJTELzQLyb9GpVHmQWsrSmAf tlIM5Eqm0/COuELxX/uvl89toPpeAyjalhog/AMSZEdl1I2N92p1MYRASryf46zAULoM7Be3cdD QrEDXrC/HKxusOGn3Nn/tLt+9rodfCH/d0liFgsTt0U7b8B9P5zep1sZkGzUSunsIXeBKX72GUX wzvSkL9y5CP/EN+r9T4fQds14M/Rb9YCUsuRud/yiNfA8IHNn9Qmbnw+nk5BCKWJ+ZIDPFoKHaz ky0VZUfn0PIWXBI+197yb2V4JJfo7abQm8= X-Received: by 2002:a17:90b:4d06:b0:36b:9323:c726 with SMTP id 98e67ed59e1d1-370f0963a47mr10191618a91.4.1781015912704; Tue, 09 Jun 2026 07:38:32 -0700 (PDT) Received: from o6.lan ([188.253.112.242]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0b315esm17939677a12.26.2026.06.09.07.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 07:38:31 -0700 (PDT) From: Xueyuan Chen To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, catalin.marinas@arm.com, will@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, hpa@zytor.com, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, yang@os.amperecomputing.com, jannh@google.com, Xueyuan Chen Subject: [RFC PATCH v2 0/3] make persistent huge zero folio read-only Date: Tue, 9 Jun 2026 22:37:58 +0800 Message-ID: <20260609143801.7917-1-xueyuan.chen21@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi all, This series makes the persistent huge zero folio read-only in the direct map where the architecture can support it. The motivation comes from Jann Horn's read-only zero page work[1] and the follow-up discussion[2] with Yang Shi. As Jann pointed out, the kernel has had bugs, including security bugs, where pages taken with read-only semantics were later written to. For the huge zero folio, making the direct map read-only turns such writes into faults instead of silently corrupting shared zero contents. Patch 1 adds a generic arch_make_pages_readonly() hook and uses it after the persistent huge zero folio is allocated. Patches 2 and 3 implement the hook for arm64 and x86. If the hook is not implemented, or the architecture cannot safely update the mapping, the existing writable mapping is left in place. [1] https://lore.kernel.org/linux-mm/20260508-ro-zeropage-v1-1-9808abc20b49@google.com/ [2] https://lore.kernel.org/linux-mm/CAHbLzkrXXe7r3n3jXgDKtwZhRqj=jDx9E6dLOULohnhBguvi9A@mail.gmail.com/ RFC v1 -> RFC v2: - Patch #01: Drop the READONLY_HUGE_ZERO_FOLIO Kconfig option (per Dave, thanks!). - Patch #01: Replace the huge-zero-folio-specific hook with a generic page-range hook (per David, thanks!) - Patch #02 and #03: Update the arm64 and x86 implementations for the new hook. - https://lore.kernel.org/linux-mm/20260527035607.14919-1-xueyuan.chen21@gmail.com/ Xueyuan Chen (3): mm/huge_memory: make persistent huge zero folio read-only arm64/mm: make pages read-only in the linear map x86/mm: make pages read-only in the direct map arch/arm64/mm/pageattr.c | 13 +++++++++++++ arch/x86/mm/init.c | 9 +++++++++ include/linux/mm.h | 2 ++ mm/huge_memory.c | 13 ++++++++++++- 4 files changed, 36 insertions(+), 1 deletion(-) -- 2.47.3