aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest
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 /drivers/lguest
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 'drivers/lguest')
-rw-r--r--drivers/lguest/lguest.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/lguest/lguest.c b/drivers/lguest/lguest.c
index 524beea7fb19..6e135ac0834f 100644
--- a/drivers/lguest/lguest.c
+++ b/drivers/lguest/lguest.c
@@ -936,23 +936,24 @@ static const struct lguest_insns
936/* Now our patch routine is fairly simple (based on the native one in 936/* Now our patch routine is fairly simple (based on the native one in
937 * paravirt.c). If we have a replacement, we copy it in and return how much of 937 * paravirt.c). If we have a replacement, we copy it in and return how much of
938 * the available space we used. */ 938 * the available space we used. */
939static unsigned lguest_patch(u8 type, u16 clobber, void *insns, unsigned len) 939static unsigned lguest_patch(u8 type, u16 clobber, void *ibuf,
940 unsigned long addr, unsigned len)
940{ 941{
941 unsigned int insn_len; 942 unsigned int insn_len;
942 943
943 /* Don't do anything special if we don't have a replacement */ 944 /* Don't do anything special if we don't have a replacement */
944 if (type >= ARRAY_SIZE(lguest_insns) || !lguest_insns[type].start) 945 if (type >= ARRAY_SIZE(lguest_insns) || !lguest_insns[type].start)
945 return paravirt_patch_default(type, clobber, insns, len); 946 return paravirt_patch_default(type, clobber, ibuf, addr, len);
946 947
947 insn_len = lguest_insns[type].end - lguest_insns[type].start; 948 insn_len = lguest_insns[type].end - lguest_insns[type].start;
948 949
949 /* Similarly if we can't fit replacement (shouldn't happen, but let's 950 /* Similarly if we can't fit replacement (shouldn't happen, but let's
950 * be thorough). */ 951 * be thorough). */
951 if (len < insn_len) 952 if (len < insn_len)
952 return paravirt_patch_default(type, clobber, insns, len); 953 return paravirt_patch_default(type, clobber, ibuf, addr, len);
953 954
954 /* Copy in our instructions. */ 955 /* Copy in our instructions. */
955 memcpy(insns, lguest_insns[type].start, insn_len); 956 memcpy(ibuf, lguest_insns[type].start, insn_len);
956 return insn_len; 957 return insn_len;
957} 958}
958 959