Don't use direct mapping to patch kernel text From: Jan Beulich It took me quite a while to figure out that this was the reason the Xen kernel (with this merged into it) doesn't boot anymore (because it sets up the direct mapping portion representing the kernel image as read-only), and the alternative code needs less 'black magic': if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END) instr -= VSYSCALL_START - (unsigned long)&__vsyscall_0; [AK: not strictly needed as a mainline bugfix, but let's do the Xen people a favour] Signed-off-by: Andi Kleen Index: linux/arch/x86_64/kernel/setup.c =================================================================== --- linux.orig/arch/x86_64/kernel/setup.c +++ linux/arch/x86_64/kernel/setup.c @@ -498,7 +498,7 @@ void apply_alternatives(void *start, voi instr = a->instr; /* vsyscall code is not mapped yet. resolve it manually. */ if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END) - instr = __va(instr - (u8*)VSYSCALL_START + (u8*)__pa_symbol(&__vsyscall_0)); + instr -= VSYSCALL_START - (unsigned long)&__vsyscall_0; __inline_memcpy(instr, a->replacement, a->replacementlen); diff = a->instrlen - a->replacementlen;