Re: [PATCH] selftests/mm: Handle implicit read permissions in madv_populate
From: cxg
Date: Mon Nov 16 2026 - 02:01:56 EST
Thanks for the suggestion.
Agreed. Since this behavior is specific to RISC-V, a simple architecture-specific check is sufficient.
I've simplified the patch to use |#ifdef __riscv|in |test_prot_write()|, removing the |/proc/self/maps|parsing and the additional PROT_NONE test.
The updated test passes all 16 tests on RISC-V with Linux 7.2.0.
Since the original patch is already in Andrew's mm tree, would you prefer a v2 or an incremental fix?
Thanks,
Xionggui
On 11/14/26 03:02, David Hildenbrand (Arm) wrote:
On 11/12/26 04:18, Xionggui Chen wrote:
From: Xionggui Chen <chenxionggui@xxxxxxxxxxxxxxxxxxx>I would have said, if RISCV is the odd one, special case it and call it a day?
The madv_populate selftest assumes that a mapping created with
PROT_WRITE cannot be read, and expects MADV_POPULATE_READ to fail
with EINVAL.
However, some architectures, including RISC-V, may implicitly grant
read permission to PROT_WRITE mappings. On such architectures,
MADV_POPULATE_READ succeeds, causing the test to fail incorrectly.
Check the actual VMA permissions through /proc/self/maps and adjust
the expected result accordingly.
Add a PROT_NONE test to verify that MADV_POPULATE_READ still fails
with EINVAL for mappings without read permission.
On RISC-V with Linux 7.2.0, the original test fails 1 out of 16
tests, while the updated test passes all 17 tests.
That would keep the changes to test_prot_write() to a minimum.