diff options
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/cputable.c | 36 | ||||
-rw-r--r-- | arch/powerpc/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/lib/feature-fixups.c | 56 |
3 files changed, 57 insertions, 36 deletions
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index ba5b23f54764..817cea1b5ad3 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | #include <asm/oprofile_impl.h> | 19 | #include <asm/oprofile_impl.h> |
20 | #include <asm/code-patching.h> | ||
21 | #include <asm/cputable.h> | 20 | #include <asm/cputable.h> |
22 | #include <asm/prom.h> /* for PTRRELOC on ARCH=ppc */ | 21 | #include <asm/prom.h> /* for PTRRELOC on ARCH=ppc */ |
23 | 22 | ||
@@ -1638,38 +1637,3 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) | |||
1638 | BUG(); | 1637 | BUG(); |
1639 | return NULL; | 1638 | return NULL; |
1640 | } | 1639 | } |
1641 | |||
1642 | void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end) | ||
1643 | { | ||
1644 | struct fixup_entry { | ||
1645 | unsigned long mask; | ||
1646 | unsigned long value; | ||
1647 | long start_off; | ||
1648 | long end_off; | ||
1649 | } *fcur, *fend; | ||
1650 | |||
1651 | fcur = fixup_start; | ||
1652 | fend = fixup_end; | ||
1653 | |||
1654 | for (; fcur < fend; fcur++) { | ||
1655 | unsigned int *pstart, *pend, *p; | ||
1656 | |||
1657 | if ((value & fcur->mask) == fcur->value) | ||
1658 | continue; | ||
1659 | |||
1660 | /* These PTRRELOCs will disappear once the new scheme for | ||
1661 | * modules and vdso is implemented | ||
1662 | */ | ||
1663 | pstart = ((unsigned int *)fcur) + (fcur->start_off / 4); | ||
1664 | pend = ((unsigned int *)fcur) + (fcur->end_off / 4); | ||
1665 | |||
1666 | for (p = pstart; p < pend; p++) { | ||
1667 | *p = PPC_NOP_INSTR; | ||
1668 | asm volatile ("dcbst 0, %0" : : "r" (p)); | ||
1669 | } | ||
1670 | asm volatile ("sync" : : : "memory"); | ||
1671 | for (p = pstart; p < pend; p++) | ||
1672 | asm volatile ("icbi 0,%0" : : "r" (p)); | ||
1673 | asm volatile ("sync; isync" : : : "memory"); | ||
1674 | } | ||
1675 | } | ||
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index e7f7042b9f61..fc52771f0cdb 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile | |||
@@ -26,3 +26,4 @@ endif | |||
26 | obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o | 26 | obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o |
27 | 27 | ||
28 | obj-y += code-patching.o | 28 | obj-y += code-patching.o |
29 | obj-y += feature-fixups.o | ||
diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c new file mode 100644 index 000000000000..f6fd5d2ff10d --- /dev/null +++ b/arch/powerpc/lib/feature-fixups.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org) | ||
3 | * | ||
4 | * Modifications for ppc64: | ||
5 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> | ||
6 | * | ||
7 | * Copyright 2008 Michael Ellerman, IBM Corporation. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <asm/cputable.h> | ||
17 | #include <asm/code-patching.h> | ||
18 | |||
19 | |||
20 | struct fixup_entry { | ||
21 | unsigned long mask; | ||
22 | unsigned long value; | ||
23 | long start_off; | ||
24 | long end_off; | ||
25 | }; | ||
26 | |||
27 | static void patch_feature_section(unsigned long value, struct fixup_entry *fcur) | ||
28 | { | ||
29 | unsigned int *pstart, *pend, *p; | ||
30 | |||
31 | if ((value & fcur->mask) == fcur->value) | ||
32 | return; | ||
33 | |||
34 | pstart = ((unsigned int *)fcur) + (fcur->start_off / 4); | ||
35 | pend = ((unsigned int *)fcur) + (fcur->end_off / 4); | ||
36 | |||
37 | for (p = pstart; p < pend; p++) { | ||
38 | *p = PPC_NOP_INSTR; | ||
39 | asm volatile ("dcbst 0, %0" : : "r" (p)); | ||
40 | } | ||
41 | asm volatile ("sync" : : : "memory"); | ||
42 | for (p = pstart; p < pend; p++) | ||
43 | asm volatile ("icbi 0,%0" : : "r" (p)); | ||
44 | asm volatile ("sync; isync" : : : "memory"); | ||
45 | } | ||
46 | |||
47 | void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end) | ||
48 | { | ||
49 | struct fixup_entry *fcur, *fend; | ||
50 | |||
51 | fcur = fixup_start; | ||
52 | fend = fixup_end; | ||
53 | |||
54 | for (; fcur < fend; fcur++) | ||
55 | patch_feature_section(value, fcur); | ||
56 | } | ||