implement user mode catchable exceptions, refactor system status codes to use NTLSTATUS_ prefix, update build scripts to use shared literal macros for linker arguments, update named queue lifetime cleanup to include KeNamedQueueUnpublishHandle.
This commit is contained in:
1 parent
1f5477cf66
commit
b7fcfce6f7
140 files changed
+7649
-3943
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// Page-cache write/truncate invalidation regression test.
|
||||
// Verifies cached clean pages are not reused after file write or truncate.
|
||||
// Page-cache write/truncate coherency regression test.
|
||||
// Verifies cached pages stay coherent after file write and cached tails are dropped after truncate.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -79,14 +79,14 @@ static uint32_t create_temp(uint32_t* fileOut, const char** pathOut) {
|
||||
SYS_FILE_FLAG_NONE,
|
||||
&h);
|
||||
uint32_t s = SysOpenFile(&req);
|
||||
if (s == STATUS_SUCCESS) {
|
||||
if (s == NTLSTATUS_SUCCESS) {
|
||||
*fileOut = h;
|
||||
if (pathOut) *pathOut = paths[i];
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_NOT_FOUND;
|
||||
return NTLSTATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
static void fill_patterns(void) {
|
||||
@@ -100,7 +100,7 @@ static void checked_write(uint32_t file, const void* buffer, size_t size, const
|
||||
size_t done = 0;
|
||||
SYS_FILE_IO_REQUEST req = SysMakeFileIoRequest(file, buffer, size, &done);
|
||||
uint32_t s = SysWriteFile(&req);
|
||||
if (s != STATUS_SUCCESS) fail_status(what, s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status(what, s);
|
||||
if (done != size) fail("short write");
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ static void checked_read(uint32_t file, void* buffer, size_t size, size_t* gotOu
|
||||
memset(buffer, 0xCC, size);
|
||||
SYS_FILE_IO_REQUEST req = SysMakeFileIoRequest(file, buffer, size, &got);
|
||||
uint32_t s = SysReadFile(&req);
|
||||
if (s != STATUS_SUCCESS) fail_status(what, s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status(what, s);
|
||||
if (gotOut) *gotOut = got;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ int main(void) {
|
||||
uint32_t file = 0;
|
||||
const char* path = 0;
|
||||
uint32_t s = create_temp(&file, &path);
|
||||
if (s != STATUS_SUCCESS) fail_status("create temp", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("create temp", s);
|
||||
|
||||
print("pcache_invalidate: using ");
|
||||
print(path ? path : "<unknown>");
|
||||
@@ -129,7 +129,7 @@ int main(void) {
|
||||
checked_write(file, gOriginal, sizeof(gOriginal), "write original");
|
||||
|
||||
s = SysSeekFile(file, 0);
|
||||
if (s != STATUS_SUCCESS) fail_status("seek fill", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("seek fill", s);
|
||||
|
||||
SYS_FILE_CACHE_STATS before;
|
||||
SYS_FILE_CACHE_STATS afterFill;
|
||||
@@ -137,23 +137,24 @@ int main(void) {
|
||||
SYS_FILE_CACHE_STATS afterWrite;
|
||||
SYS_FILE_CACHE_STATS afterRewriteRead;
|
||||
SYS_FILE_CACHE_STATS afterTruncate;
|
||||
if (query_cache(&before) != STATUS_SUCCESS) fail("initial stats query failed");
|
||||
if (query_cache(&before) != NTLSTATUS_SUCCESS) fail("initial stats query failed");
|
||||
|
||||
size_t got = 0;
|
||||
checked_read(file, gReadback, sizeof(gReadback), &got, "first read");
|
||||
if (got != sizeof(gOriginal)) fail("first read size mismatch");
|
||||
if (memcmp(gReadback, gOriginal, sizeof(gOriginal)) != 0) fail("first read data mismatch");
|
||||
|
||||
if (query_cache(&afterFill) != STATUS_SUCCESS) fail("fill stats query failed");
|
||||
if (afterFill.Loads <= before.Loads) fail("initial read did not populate cache");
|
||||
if (query_cache(&afterFill) != NTLSTATUS_SUCCESS) fail("fill stats query failed");
|
||||
if (afterFill.Loads <= before.Loads && afterFill.Hits <= before.Hits)
|
||||
fail("initial read did not touch cache");
|
||||
|
||||
s = SysSeekFile(file, 0);
|
||||
if (s != STATUS_SUCCESS) fail_status("seek second", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("seek second", s);
|
||||
checked_read(file, gReadback, sizeof(gReadback), &got, "second read");
|
||||
if (got != sizeof(gOriginal)) fail("second read size mismatch");
|
||||
if (memcmp(gReadback, gOriginal, sizeof(gOriginal)) != 0) fail("second read data mismatch");
|
||||
|
||||
if (query_cache(&afterSecond) != STATUS_SUCCESS) fail("second stats query failed");
|
||||
if (query_cache(&afterSecond) != NTLSTATUS_SUCCESS) fail("second stats query failed");
|
||||
// Do not require this second read to hit: the cache is intentionally
|
||||
// bounded and pcache_pressure.exe may have left it at the soft limit, so
|
||||
// the newly-populated temp pages are eligible for immediate pressure
|
||||
@@ -161,20 +162,20 @@ int main(void) {
|
||||
// is covered by pcache_mmap_read_reuse.exe.
|
||||
|
||||
s = SysSeekFile(file, 0);
|
||||
if (s != STATUS_SUCCESS) fail_status("seek rewrite", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("seek rewrite", s);
|
||||
checked_write(file, gReplacement, sizeof(gReplacement), "rewrite first page");
|
||||
|
||||
if (query_cache(&afterWrite) != STATUS_SUCCESS) fail("post-write stats query failed");
|
||||
if (afterWrite.Invalidations <= afterSecond.Invalidations) fail("write did not invalidate cached page");
|
||||
if (query_cache(&afterWrite) != NTLSTATUS_SUCCESS) fail("post-write stats query failed");
|
||||
if (afterWrite.DirtyMarks <= afterSecond.DirtyMarks) fail("rewrite did not dirty cached page");
|
||||
|
||||
uint32_t mapping = 0;
|
||||
s = SysCreateFileMapping(file, SYS_VM_READ, SYS_MAP_FLAG_NONE, sizeof(gReplacement), &mapping);
|
||||
if (s != STATUS_SUCCESS) fail_status("create mapping after rewrite", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("create mapping after rewrite", s);
|
||||
|
||||
void* mappedBase = 0;
|
||||
s = SysMapFile(mapping, 0, sizeof(gReplacement), SYS_MAP_ACCESS_READ, SYS_MAP_FLAG_NONE, &mappedBase);
|
||||
SysCloseHandle(mapping);
|
||||
if (s != STATUS_SUCCESS) fail_status("map after rewrite", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("map after rewrite", s);
|
||||
if (!mappedBase) fail("map after rewrite returned null");
|
||||
|
||||
volatile uint8_t* mappedView = (volatile uint8_t*)mappedBase;
|
||||
@@ -185,30 +186,30 @@ int main(void) {
|
||||
fail("stale mmap data after write invalidation");
|
||||
}
|
||||
s = SysFreeVm(mappedBase);
|
||||
if (s != STATUS_SUCCESS) fail_status("unmap after rewrite", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("unmap after rewrite", s);
|
||||
|
||||
s = SysSeekFile(file, 0);
|
||||
if (s != STATUS_SUCCESS) fail_status("seek verify rewrite", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("seek verify rewrite", s);
|
||||
checked_read(file, gReadback, sizeof(gReadback), &got, "read after rewrite");
|
||||
if (got != sizeof(gOriginal)) fail("rewrite read size mismatch");
|
||||
if (memcmp(gReadback, gReplacement, sizeof(gReplacement)) != 0) fail("stale data after write invalidation");
|
||||
if (memcmp(gReadback + sizeof(gReplacement), gOriginal + sizeof(gReplacement),
|
||||
sizeof(gOriginal) - sizeof(gReplacement)) != 0) fail("unwritten page changed after rewrite");
|
||||
|
||||
if (query_cache(&afterRewriteRead) != STATUS_SUCCESS) fail("rewrite-read stats query failed");
|
||||
if (query_cache(&afterRewriteRead) != NTLSTATUS_SUCCESS) fail("rewrite-read stats query failed");
|
||||
|
||||
s = SysTruncateFile(file, TRUNC_SIZE);
|
||||
if (s != STATUS_SUCCESS) fail_status("truncate", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("truncate", s);
|
||||
uint64_t truncatedSize = 0;
|
||||
s = SysGetFileSize(file, &truncatedSize);
|
||||
if (s != STATUS_SUCCESS) fail_status("get truncated size", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("get truncated size", s);
|
||||
if (truncatedSize != TRUNC_SIZE) fail("truncate size mismatch");
|
||||
|
||||
if (query_cache(&afterTruncate) != STATUS_SUCCESS) fail("truncate stats query failed");
|
||||
if (query_cache(&afterTruncate) != NTLSTATUS_SUCCESS) fail("truncate stats query failed");
|
||||
if (afterTruncate.Invalidations <= afterRewriteRead.Invalidations) fail("truncate did not invalidate cached tail");
|
||||
|
||||
s = SysSeekFile(file, 0);
|
||||
if (s != STATUS_SUCCESS) fail_status("seek truncated", s);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("seek truncated", s);
|
||||
checked_read(file, gReadback, sizeof(gReadback), &got, "read truncated");
|
||||
if (got != TRUNC_SIZE) fail("truncated read length mismatch");
|
||||
if (memcmp(gReadback, gReplacement, TRUNC_SIZE) != 0) fail("truncated data mismatch");
|
||||
|
||||
Reference in new issue
Block a user