diff options
| author | Logan <Logan@cattn.dev> | 2026-11-23 12:48:20 -0500 |
|---|---|---|
| committer | Logan <Logan@cattn.dev> | 2026-11-23 12:48:20 -0500 |
| commit | af75a43dc9376a3bf5cbd9ab5d7e09936c68cb11 (patch) | |
| tree | a0e1544c3d704d794827753b4bcff64742259fc0 /runtime/test/xmem_test.cpp | |
| parent | 75c2b87a751ca1825caee3fae323cce43c1eb78a (diff) | |
xmem: judge a fault on a committed page by the protection at the faulting address
The handler queried the protection at the start of the 64 KiB page, so
a write to a 4 KiB part the title had made read-only looked allowed and
was resumed, faulting again forever instead of reaching the title's own
handler. It now looks the record up by the page and the protection up
by the faulting address. xmem_test writes to a read-only 4 KiB part of
a read-write page and expects the fault.
Diffstat (limited to 'runtime/test/xmem_test.cpp')
| -rw-r--r-- | runtime/test/xmem_test.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp index 4ea777007..3ec621b0b 100644 --- a/runtime/test/xmem_test.cpp +++ b/runtime/test/xmem_test.cpp | |||
| @@ -530,6 +530,12 @@ void test_physical_pages_commit_on_touch(const PhysicalApi& api) { | |||
| 530 | access_faults(static_cast<volatile uint32_t*>(static_cast<void*>(window)), true), | 530 | access_faults(static_cast<volatile uint32_t*>(static_cast<void*>(window)), true), |
| 531 | "a write to a committed read-only page still faults to the next handler"); | 531 | "a write to a committed read-only page still faults to the next handler"); |
| 532 | VirtualProtect(window, kPage64k, PAGE_READWRITE, &old); | 532 | VirtualProtect(window, kPage64k, PAGE_READWRITE, &old); |
| 533 | check(VirtualProtect(window + 4096, 4096, PAGE_READONLY, &old) != FALSE && | ||
| 534 | access_faults(static_cast<volatile uint32_t*>(static_cast<void*>(window + 4096)), true), | ||
| 535 | "a write to a read-only 4 KiB part of a read-write page still faults to the next handler"); | ||
| 536 | check(!access_faults(static_cast<volatile uint32_t*>(static_cast<void*>(window + 8192)), true), | ||
| 537 | "the rest of that page stays writable"); | ||
| 538 | VirtualProtect(window + 4096, 4096, PAGE_READWRITE, &old); | ||
| 533 | void* const elsewhere = VirtualAlloc(nullptr, kPage64k, MEM_RESERVE, PAGE_READWRITE); | 539 | void* const elsewhere = VirtualAlloc(nullptr, kPage64k, MEM_RESERVE, PAGE_READWRITE); |
| 534 | check(elsewhere != nullptr && access_faults(static_cast<volatile uint32_t*>(elsewhere), false), | 540 | check(elsewhere != nullptr && access_faults(static_cast<volatile uint32_t*>(elsewhere), false), |
| 535 | "a fault outside the mapped pages still reaches the next handler"); | 541 | "a fault outside the mapped pages still reaches the next handler"); |