From 49c19e58aa14fba779bfe331b1ebaba62d31dfa5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 11 Nov 2006 14:25:16 +0000 Subject: [PATCH] Add memory clobbers to several asm statements, to prevent reordering. --- src/threads/init.c | 2 +- src/threads/interrupt.c | 2 +- src/threads/thread.c | 2 +- src/userprog/pagedir.c | 2 +- src/userprog/process.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/threads/init.c b/src/threads/init.c index 2931704..5961deb 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -382,7 +382,7 @@ power_off (void) for (p = s; *p != '\0'; p++) outb (0x8900, *p); - asm ("cli; hlt"); + asm volatile ("cli; hlt" : : : "memory"); printf ("still running...\n"); for (;;); } diff --git a/src/threads/interrupt.c b/src/threads/interrupt.c index 72b3783..3e37213 100644 --- a/src/threads/interrupt.c +++ b/src/threads/interrupt.c @@ -95,7 +95,7 @@ intr_disable (void) /* Disable interrupts by clearing the interrupt flag. See [IA32-v2b] "CLI" and [IA32-v3a] 5.8.1 "Masking Maskable Hardware Interrupts". */ - asm volatile ("cli"); + asm volatile ("cli" : : : "memory"); return old_level; } diff --git a/src/threads/thread.c b/src/threads/thread.c index 938d7f8..1dc34ad 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -389,7 +389,7 @@ idle (void *idle_started_ UNUSED) See [IA32-v2a] "HLT", [IA32-v2b] "STI", and [IA32-v3a] 7.11.1 "HLT Instruction". */ - asm ("sti; hlt"); + asm volatile ("sti; hlt" : : : "memory"); } } diff --git a/src/userprog/pagedir.c b/src/userprog/pagedir.c index 7d99375..30bdfe2 100644 --- a/src/userprog/pagedir.c +++ b/src/userprog/pagedir.c @@ -227,7 +227,7 @@ pagedir_activate (uint32_t *pd) new page tables immediately. See [IA32-v2a] "MOV--Move to/from Control Registers" and [IA32-v3a] 3.7.5 "Base Address of the Page Directory". */ - asm volatile ("movl %0, %%cr3" :: "r" (vtop (pd))); + asm volatile ("movl %0, %%cr3" : : "r" (vtop (pd)) : "memory"); } /* Returns the currently active page directory. */ diff --git a/src/userprog/process.c b/src/userprog/process.c index bece1fe..675dc25 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -72,7 +72,7 @@ execute_thread (void *file_name_) arguments on the stack in the form of a `struct intr_frame', we just point the stack pointer (%esp) to our stack frame and jump to it. */ - asm ("movl %0, %%esp; jmp intr_exit" :: "g" (&if_)); + asm volatile ("movl %0, %%esp; jmp intr_exit" : : "g" (&if_) : "memory"); NOT_REACHED (); } -- 2.30.2