diff options
author | Zachary Amsden <zach@vmware.com> | 2005-09-03 18:56:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:06:11 -0400 |
commit | 4bb0d3ec3e5b1e9e2399cdc641b3b6521ac9cdaa (patch) | |
tree | 5e8d7646f5c6a2cec990b6d591f230d496b20664 /arch/i386/mm | |
parent | 2a0694d15d55d0deed928786a6393d5e45e37d76 (diff) |
[PATCH] i386: inline asm cleanup
i386 Inline asm cleanup. Use cr/dr accessor functions.
Also, a potential bugfix. Also, some CR accessors really should be volatile.
Reads from CR0 (numeric state may change in an exception handler), writes to
CR4 (flipping CR4.TSD) and reads from CR2 (page fault) prevent instruction
re-ordering. I did not add memory clobber to CR3 / CR4 / CR0 updates, as it
was not there to begin with, and in no case should kernel memory be clobbered,
except when doing a TLB flush, which already has memory clobber.
I noticed that page invalidation does not have a memory clobber. I can't find
a bug as a result, but there is definitely a potential for a bug here:
#define __flush_tlb_single(addr) \
__asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/mm')
-rw-r--r-- | arch/i386/mm/fault.c | 6 | ||||
-rw-r--r-- | arch/i386/mm/pageattr.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c index 61d9e34af5a6..411b8500ad1b 100644 --- a/arch/i386/mm/fault.c +++ b/arch/i386/mm/fault.c | |||
@@ -233,7 +233,7 @@ fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
233 | int write, si_code; | 233 | int write, si_code; |
234 | 234 | ||
235 | /* get the address */ | 235 | /* get the address */ |
236 | __asm__("movl %%cr2,%0":"=r" (address)); | 236 | address = read_cr2(); |
237 | 237 | ||
238 | if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, | 238 | if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, |
239 | SIGSEGV) == NOTIFY_STOP) | 239 | SIGSEGV) == NOTIFY_STOP) |
@@ -453,7 +453,7 @@ no_context: | |||
453 | printk(" at virtual address %08lx\n",address); | 453 | printk(" at virtual address %08lx\n",address); |
454 | printk(KERN_ALERT " printing eip:\n"); | 454 | printk(KERN_ALERT " printing eip:\n"); |
455 | printk("%08lx\n", regs->eip); | 455 | printk("%08lx\n", regs->eip); |
456 | asm("movl %%cr3,%0":"=r" (page)); | 456 | page = read_cr3(); |
457 | page = ((unsigned long *) __va(page))[address >> 22]; | 457 | page = ((unsigned long *) __va(page))[address >> 22]; |
458 | printk(KERN_ALERT "*pde = %08lx\n", page); | 458 | printk(KERN_ALERT "*pde = %08lx\n", page); |
459 | /* | 459 | /* |
@@ -526,7 +526,7 @@ vmalloc_fault: | |||
526 | pmd_t *pmd, *pmd_k; | 526 | pmd_t *pmd, *pmd_k; |
527 | pte_t *pte_k; | 527 | pte_t *pte_k; |
528 | 528 | ||
529 | asm("movl %%cr3,%0":"=r" (pgd_paddr)); | 529 | pgd_paddr = read_cr3(); |
530 | pgd = index + (pgd_t *)__va(pgd_paddr); | 530 | pgd = index + (pgd_t *)__va(pgd_paddr); |
531 | pgd_k = init_mm.pgd + index; | 531 | pgd_k = init_mm.pgd + index; |
532 | 532 | ||
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c index cb3da6baa704..bce06a79eafa 100644 --- a/arch/i386/mm/pageattr.c +++ b/arch/i386/mm/pageattr.c | |||
@@ -62,7 +62,7 @@ static void flush_kernel_map(void *dummy) | |||
62 | { | 62 | { |
63 | /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */ | 63 | /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */ |
64 | if (boot_cpu_data.x86_model >= 4) | 64 | if (boot_cpu_data.x86_model >= 4) |
65 | asm volatile("wbinvd":::"memory"); | 65 | wbinvd(); |
66 | /* Flush all to work around Errata in early athlons regarding | 66 | /* Flush all to work around Errata in early athlons regarding |
67 | * large page flushing. | 67 | * large page flushing. |
68 | */ | 68 | */ |