aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/xen/enlighten.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2007-08-10 16:31:03 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-11 18:58:13 -0400
commitab144f5ec64c42218a555ec1dbde6b60cf2982d6 (patch)
treee3a4532e1db116e87060c9b18f4cfbf6258fdba3 /arch/i386/xen/enlighten.c
parentd3f3c9346979bfa074c64eac5fc3ed5bba4f40ed (diff)
i386: Make patching more robust, fix paravirt issue
Commit 19d36ccdc34f5ed444f8a6af0cbfdb6790eb1177 "x86: Fix alternatives and kprobes to remap write-protected kernel text" uses code which is being patched for patching. In particular, paravirt_ops does patching in two stages: first it calls paravirt_ops.patch, then it fills any remaining instructions with nop_out(). nop_out calls text_poke() which calls lookup_address() which calls pgd_val() (aka paravirt_ops.pgd_val): that call site is one of the places we patch. If we always do patching as one single call to text_poke(), we only need make sure we're not patching the memcpy in text_poke itself. This means the prototype to paravirt_ops.patch needs to change, to marshal the new code into a buffer rather than patching in place as it does now. It also means all patching goes through text_poke(), which is known to be safe (apply_alternatives is also changed to make a single patch). AK: fix compilation on x86-64 (bad rusty!) AK: fix boot on x86-64 (sigh) AK: merged with other patches Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/i386/xen/enlighten.c')
-rw-r--r--arch/i386/xen/enlighten.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 9a8c1181c001..f0c37511d8da 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -842,7 +842,8 @@ void __init xen_setup_vcpu_info_placement(void)
842 } 842 }
843} 843}
844 844
845static unsigned xen_patch(u8 type, u16 clobbers, void *insns, unsigned len) 845static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
846 unsigned long addr, unsigned len)
846{ 847{
847 char *start, *end, *reloc; 848 char *start, *end, *reloc;
848 unsigned ret; 849 unsigned ret;
@@ -869,7 +870,7 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insns, unsigned len)
869 if (start == NULL || (end-start) > len) 870 if (start == NULL || (end-start) > len)
870 goto default_patch; 871 goto default_patch;
871 872
872 ret = paravirt_patch_insns(insns, len, start, end); 873 ret = paravirt_patch_insns(insnbuf, len, start, end);
873 874
874 /* Note: because reloc is assigned from something that 875 /* Note: because reloc is assigned from something that
875 appears to be an array, gcc assumes it's non-null, 876 appears to be an array, gcc assumes it's non-null,
@@ -877,8 +878,8 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insns, unsigned len)
877 end. */ 878 end. */
878 if (reloc > start && reloc < end) { 879 if (reloc > start && reloc < end) {
879 int reloc_off = reloc - start; 880 int reloc_off = reloc - start;
880 long *relocp = (long *)(insns + reloc_off); 881 long *relocp = (long *)(insnbuf + reloc_off);
881 long delta = start - (char *)insns; 882 long delta = start - (char *)addr;
882 883
883 *relocp += delta; 884 *relocp += delta;
884 } 885 }
@@ -886,7 +887,8 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insns, unsigned len)
886 887
887 default_patch: 888 default_patch:
888 default: 889 default:
889 ret = paravirt_patch_default(type, clobbers, insns, len); 890 ret = paravirt_patch_default(type, clobbers, insnbuf,
891 addr, len);
890 break; 892 break;
891 } 893 }
892 894