Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158708
b: refs/heads/master
c: 5367b68
h: refs/heads/master
v: v3
  • Loading branch information
Ben Hutchings authored and H. Peter Anvin committed Sep 10, 2009
1 parent 033572f commit e998ab7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b19ae3999891cad21a3995c34d313dda5df014e2
refs/heads/master: 5367b6887e7d8c870a5da7d9b8c6e9c207684e43
16 changes: 13 additions & 3 deletions trunk/arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,23 @@ static inline void cpu_relax(void)
rep_nop();
}

/* Stop speculative execution: */
/* Stop speculative execution and prefetching of modified code. */
static inline void sync_core(void)
{
int tmp;

asm volatile("cpuid" : "=a" (tmp) : "0" (1)
: "ebx", "ecx", "edx", "memory");
#if defined(CONFIG_M386) || defined(CONFIG_M486)
if (boot_cpu_data.x86 < 5)
/* There is no speculative execution.
* jmp is a barrier to prefetching. */
asm volatile("jmp 1f\n1:\n" ::: "memory");
else
#endif
/* cpuid is a barrier to speculative execution.
* Prefetched instructions are automatically
* invalidated when modified. */
asm volatile("cpuid" : "=a" (tmp) : "0" (1)
: "ebx", "ecx", "edx", "memory");
}

static inline void __monitor(const void *eax, unsigned long ecx,
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ void *text_poke_early(void *addr, const void *opcode, size_t len)
unsigned long flags;
local_irq_save(flags);
memcpy(addr, opcode, len);
local_irq_restore(flags);
sync_core();
local_irq_restore(flags);
/* Could also do a CLFLUSH here to speed up CPU recovery; but
that causes hangs on some VIA CPUs. */
return addr;
Expand Down

0 comments on commit e998ab7

Please sign in to comment.