aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/filst/sc-bad-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/filst/sc-bad-write.c')
-rw-r--r--src/tests/filst/sc-bad-write.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/tests/filst/sc-bad-write.c b/src/tests/filst/sc-bad-write.c
index fbd6260..18e8f4d 100644
--- a/src/tests/filst/sc-bad-write.c
+++ b/src/tests/filst/sc-bad-write.c
@@ -15,7 +15,7 @@
#define PGMASK BITMASK(PGSHIFT, PGBITS) /* Page offset bits (0:12). */
static inline void *pg_round_up (const void *va) {
- return (void *) (((uintptr_t) va + PGSIZE - 1) & ~PGMASK);
+ return (void *) (((uintptr_t) va + PGSIZE - 1) & ~PGMASK);
}
/**
@@ -31,49 +31,49 @@ const char *FAIL = "FAIL\n";
void test_main(void)
{
- // Get the addres of the first unmapped page in the system.
- unsigned page = (unsigned)pg_round_up(&_end_bss);
+ // Get the addres of the first unmapped page in the system.
+ unsigned page = (unsigned)pg_round_up(&_end_bss);
- // Reserve space for 4 parameters.
- unsigned base = page - sizeof(int) * 4;
+ // Reserve space for 4 parameters.
+ unsigned base = page - sizeof(int) * 4;
- // Call write() with space for 4 parameters (should be fine).
- asm volatile (
- "movl %%esp, %%edi;"
- "movl %0, %%esp;" // Set stack pointer to right below page boundary.
- "movl %1, (%%esp);" // Try to call SYS_WRITE
- "movl %2, 4(%%esp);" // Write to STDOUT
- "movl %3, 8(%%esp);" // Load buffer.
- "movl $6, 12(%%esp);" // Write length of string
- "int $0x30;"
- "movl %%edi, %%esp;" // Restore esp.
- :
- : "r" (base),
- "i" (SYS_WRITE),
- "i" (STDOUT_FILENO),
- "r" (WORKS)
- : "%esp", "%eax", "%edi");
+ // Call write() with space for 4 parameters (should be fine).
+ asm volatile (
+ "movl %%esp, %%edi;"
+ "movl %0, %%esp;" // Set stack pointer to right below page boundary.
+ "movl %1, (%%esp);" // Try to call SYS_WRITE
+ "movl %2, 4(%%esp);" // Write to STDOUT
+ "movl %3, 8(%%esp);" // Load buffer.
+ "movl $6, 12(%%esp);" // Write length of string
+ "int $0x30;"
+ "movl %%edi, %%esp;" // Restore esp.
+ :
+ : "r" (base),
+ "i" (SYS_WRITE),
+ "i" (STDOUT_FILENO),
+ "r" (WORKS)
+ : "%esp", "%eax", "%edi");
- // Reserve space for 3 parameters (write requires 4).
- base = page - sizeof(int) * 3;
+ // Reserve space for 3 parameters (write requires 4).
+ base = page - sizeof(int) * 3;
- // Call write() with space for 3 parameters (the kernel should kill us for doing this).
- asm volatile (
- "movl %%esp, %%edi;"
- "movl %0, %%esp;" // Set stack pointer to right below page boundary.
- "movl %1, (%%esp);" // Try to call SYS_WRITE
- "movl %2, 4(%%esp);" // Write to STDOUT
- "movl %3, 8(%%esp);" // Load buffer.
- //"movl $5, 12(%%esp);" // Can not write the last parameter as we would get a pagefault.
- "int $0x30;"
- "movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should).
- :
- : "r" (base),
- "i" (SYS_WRITE),
- "i" (STDOUT_FILENO),
- "r" (FAIL)
- : "%esp", "%eax", "%edi");
+ // Call write() with space for 3 parameters (the kernel should kill us for doing this).
+ asm volatile (
+ "movl %%esp, %%edi;"
+ "movl %0, %%esp;" // Set stack pointer to right below page boundary.
+ "movl %1, (%%esp);" // Try to call SYS_WRITE
+ "movl %2, 4(%%esp);" // Write to STDOUT
+ "movl %3, 8(%%esp);" // Load buffer.
+ //"movl $5, 12(%%esp);" // Can not write the last parameter as we would get a pagefault.
+ "int $0x30;"
+ "movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should).
+ :
+ : "r" (base),
+ "i" (SYS_WRITE),
+ "i" (STDOUT_FILENO),
+ "r" (FAIL)
+ : "%esp", "%eax", "%edi");
- fail("should have died.");
+ fail("should have died.");
}